Skip to content

Commit c06f9bf

Browse files
authored
Use generated package of onix (#35)
* use theme downloader * introduce dryrun option * introduce dryrun mode * take snapshot of update 20201208, 20201217, 20201220 * fix invalid nest * take snapshot of create 20201208, 20201217, 20201220 * do not use fixtures as snapshots * attempt to replace onix-message parser * may worth to bump deps * make buildable again * fix some type contradiction * deref string * make bit safe * bump snapshots
1 parent d6b7ca0 commit c06f9bf

39 files changed

+1286
-680
lines changed

.github/workflows/download_theme.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: theme download
2+
on:
3+
schedule:
4+
- cron: "0 1 * * 1" # Every Monday morning
5+
pull_request:
6+
types:
7+
- opened
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: actions/setup-python@v2
15+
- name: Set up Theme-kit
16+
run: curl -s https://shopify.github.io/themekit/scripts/install.py | sudo python
17+
- name: Download liquid
18+
run: theme download
19+
env:
20+
THEME_APP_SECRET: ${{ secrets.THEME_APP_SECRET }}
21+
THEME_ID: ${{ secrets.THEME_ID }}
22+
- name: Create Pull Request
23+
uses: peter-evans/[email protected]
24+
with:
25+
title: Update theme
26+
base: main

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ download/contents: $(MD_FILES)
2727
import: $(GO_FILES)
2828
$(BZL) run //onix/cmd -- --input $(PWD)/onix/$(ONIX_FILE)
2929

30+
import/dry: $(GO_FILES)
31+
$(BZL) run //onix/cmd -- --dryRun --input $(PWD)/onix/$(ONIX_FILE)
32+
cp -r $(BZL_BIN)/onix/cmd/cmd_/cmd.runfiles/k9books/onix/*.json $(CURDIR)/onix/snapshots/
33+
3034
watch:
3135
$(TK) watch --dir theme
3236

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@ $ make deploy/contents
1616

1717
```sh
1818
$ make ONIX_FILE=20201208.onix import
19+
20+
# dry-run writes snapshot json to onix/snapshots
21+
$ make ONIX_FILE=20201208.onix import/dry
1922
```

WORKSPACE

+7
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,13 @@ go_repository(
14621462
version = "v1.0.6",
14631463
)
14641464

1465+
go_repository(
1466+
name = "com_github_kogai_onix_codegen",
1467+
importpath = "github.com/kogai/onix-codegen",
1468+
sum = "h1:GgbXJYRfb65u8DHwKjq8c0uJQe2uYkHFjydese+2XOY=",
1469+
version = "v0.0.0-20210115161516-0134b80e0f71",
1470+
)
1471+
14651472
go_rules_dependencies()
14661473

14671474
go_register_toolchains()

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ require (
1212
github.com/bold-commerce/go-shopify v2.3.0+incompatible
1313
github.com/gomarkdown/markdown v0.0.0-20201113031856-722100d81a8e
1414
github.com/google/go-querystring v1.0.0 // indirect
15+
github.com/kogai/onix-codegen v0.0.0-20210115161516-0134b80e0f71
1516
github.com/shopspring/decimal v1.2.0 // indirect
1617
github.com/spf13/cobra v1.1.1
1718
github.com/tdewolff/minify/v2 v2.9.10

go.sum

+6
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV
145145
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
146146
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
147147
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
148+
github.com/kogai/onix-codegen v0.0.0-20210114135750-18c2feec0315 h1:kZ3952hgt25gTSS3Y9d6F7ppCvaj87DKyZ9KemCZyc4=
149+
github.com/kogai/onix-codegen v0.0.0-20210114135750-18c2feec0315/go.mod h1:O6sFzL6G9/WlHKtUaORq8Z/DQuATGdo5GCo+QcQSye4=
150+
github.com/kogai/onix-codegen v0.0.0-20210115150916-b4661a1eb629 h1:BQJKUZi76Jyb9s4T8XLFvJKMreU3HQHT+R4QuAzMR7Q=
151+
github.com/kogai/onix-codegen v0.0.0-20210115150916-b4661a1eb629/go.mod h1:O6sFzL6G9/WlHKtUaORq8Z/DQuATGdo5GCo+QcQSye4=
152+
github.com/kogai/onix-codegen v0.0.0-20210115161516-0134b80e0f71 h1:GgbXJYRfb65u8DHwKjq8c0uJQe2uYkHFjydese+2XOY=
153+
github.com/kogai/onix-codegen v0.0.0-20210115161516-0134b80e0f71/go.mod h1:O6sFzL6G9/WlHKtUaORq8Z/DQuATGdo5GCo+QcQSye4=
148154
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
149155
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
150156
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=

gqlgenc/client/model.go

+12-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

onix/BUILD.bazel

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
1+
load("@io_bazel_rules_go//go:def.bzl", "go_library")
22

33
go_library(
44
name = "go_default_library",
@@ -14,16 +14,6 @@ go_library(
1414
deps = [
1515
"//gqlgenc/client:go_default_library",
1616
"@com_github_bold_commerce_go_shopify//:go_default_library",
17-
],
18-
)
19-
20-
go_test(
21-
name = "go_default_test",
22-
srcs = ["onix_test.go"],
23-
data = glob(["fixtures/*"]),
24-
embed = [":go_default_library"],
25-
deps = [
26-
"//gqlgenc/client:go_default_library",
27-
"@in_gopkg_go_playground_assert_v1//:go_default_library",
17+
"@com_github_kogai_onix_codegen//go:go",
2818
],
2919
)

onix/cmd/main.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@ var rootCmd = &cobra.Command{
1313
Short: "onix-kit imports ONIX for Books 2.1 file to Shopify",
1414
Run: func(cmd *cobra.Command, args []string) {
1515
input := cmd.Flag("input").Value.String()
16+
dryRun := cmd.Flag("dryRun").Value.String()
1617
if input == "" {
1718
log.Fatalln("[input] should be passed.")
1819
}
19-
if err := onix.Run(input); err != nil {
20+
if err := onix.Run(input, dryRun == "true"); err != nil {
2021
log.Fatalln(err)
2122
}
2223
},
2324
}
2425

2526
func main() {
2627
rootCmd.PersistentFlags().StringP("input", "i", "", "input ONIX for Books 2.1 file")
28+
rootCmd.PersistentFlags().BoolP("dryRun", "d", false, "dry run")
2729

2830
if err := rootCmd.Execute(); err != nil {
2931
log.Fatal(err)

0 commit comments

Comments
 (0)