shopify-cli 1.13.0 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +1 -1
- data/.github/CONTRIBUTING.md +7 -7
- data/.github/DESIGN.md +3 -3
- data/.github/workflows/build.yml +1 -1
- data/.gitignore +3 -0
- data/.rubocop.yml +3 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +57 -24
- data/Gemfile +4 -0
- data/Gemfile.lock +32 -0
- data/LICENSE +4 -1
- data/README.md +94 -26
- data/RELEASING.md +31 -7
- data/Rakefile +2 -2
- data/SECURITY.md +1 -1
- data/THEMEKIT_MIGRATION.md +18 -0
- data/bin/load_shopify.rb +1 -1
- data/bin/shopify +3 -3
- data/dev.yml +1 -1
- data/docs/app/node/index.md +1 -1
- data/docs/app/rails/index.md +1 -1
- data/docs/core/index.md +1 -1
- data/docs/getting-started/index.md +1 -1
- data/docs/getting-started/install/index.md +1 -1
- data/docs/getting-started/migrate/index.md +1 -1
- data/docs/getting-started/uninstall/index.md +1 -1
- data/docs/getting-started/upgrade/index.md +1 -1
- data/docs/help/start-app/index.md +1 -1
- data/docs/index.md +1 -1
- data/ext/shopify-cli/extconf.rb +17 -5
- data/install.sh +1 -1
- data/lib/docgen/index_template.md.erb +2 -2
- data/lib/graphql/all_orgs_with_extensions.graphql +37 -0
- data/lib/graphql/api_versions.graphql +1 -1
- data/lib/graphql/find_organization.graphql +2 -1
- data/lib/project_types/extension/cli.rb +18 -15
- data/lib/project_types/extension/commands/build.rb +4 -5
- data/lib/project_types/extension/commands/connect.rb +35 -0
- data/lib/project_types/extension/commands/create.rb +12 -16
- data/lib/project_types/extension/commands/extension_command.rb +2 -2
- data/lib/project_types/extension/commands/info.rb +86 -0
- data/lib/project_types/extension/commands/push.rb +8 -7
- data/lib/project_types/extension/commands/register.rb +4 -5
- data/lib/project_types/extension/commands/serve.rb +5 -8
- data/lib/project_types/extension/commands/tunnel.rb +3 -1
- data/lib/project_types/extension/errors.rb +9 -0
- data/lib/project_types/extension/extension_project.rb +17 -1
- data/lib/project_types/extension/extension_project_keys.rb +1 -0
- data/lib/project_types/extension/features/argo.rb +6 -6
- data/lib/project_types/extension/features/argo_runtime.rb +22 -56
- data/lib/project_types/extension/features/argo_serve.rb +25 -18
- data/lib/project_types/extension/forms/connect.rb +42 -0
- data/lib/project_types/extension/forms/questions/ask_name.rb +14 -6
- data/lib/project_types/extension/forms/questions/ask_registration.rb +51 -0
- data/lib/project_types/extension/messages/messages.rb +80 -16
- data/lib/project_types/extension/models/specification.rb +1 -0
- data/lib/project_types/extension/models/specification_handlers/{checkout_argo_extension.rb → checkout_ui_extension.rb} +3 -1
- data/lib/project_types/extension/models/specification_handlers/default.rb +13 -3
- data/lib/project_types/extension/models/specification_handlers/theme_app_extension.rb +89 -0
- data/lib/project_types/extension/models/specifications.rb +1 -0
- data/lib/project_types/extension/tasks/configure_features.rb +6 -7
- data/lib/project_types/extension/tasks/configure_options.rb +20 -0
- data/lib/project_types/extension/tasks/get_extensions.rb +32 -0
- data/lib/project_types/node/cli.rb +9 -21
- data/lib/project_types/node/commands/connect.rb +8 -2
- data/lib/project_types/node/commands/create.rb +9 -5
- data/lib/project_types/node/commands/deploy.rb +15 -5
- data/lib/project_types/node/commands/deploy/heroku.rb +29 -29
- data/lib/project_types/node/commands/generate.rb +4 -2
- data/lib/project_types/node/commands/open.rb +4 -2
- data/lib/project_types/node/commands/serve.rb +3 -2
- data/lib/project_types/node/commands/tunnel.rb +4 -2
- data/lib/project_types/node/messages/messages.rb +47 -90
- data/lib/project_types/rails/cli.rb +9 -21
- data/lib/project_types/rails/commands/connect.rb +8 -2
- data/lib/project_types/rails/commands/create.rb +10 -6
- data/lib/project_types/rails/commands/deploy.rb +15 -5
- data/lib/project_types/rails/commands/deploy/heroku.rb +84 -82
- data/lib/project_types/rails/commands/generate.rb +15 -5
- data/lib/project_types/rails/commands/generate/webhook.rb +28 -26
- data/lib/project_types/rails/commands/open.rb +4 -2
- data/lib/project_types/rails/commands/serve.rb +3 -2
- data/lib/project_types/rails/commands/tunnel.rb +4 -2
- data/lib/project_types/rails/messages/messages.rb +72 -119
- data/lib/project_types/script/cli.rb +6 -8
- data/lib/project_types/script/commands/create.rb +3 -1
- data/lib/project_types/script/commands/push.rb +12 -5
- data/lib/project_types/script/graphql/app_script_update_or_create.graphql +9 -3
- data/lib/project_types/script/layers/application/create_script.rb +4 -3
- data/lib/project_types/script/layers/domain/errors.rb +6 -11
- data/lib/project_types/script/layers/domain/push_package.rb +4 -8
- data/lib/project_types/script/layers/domain/script_json.rb +32 -0
- data/lib/project_types/script/layers/domain/script_project.rb +1 -1
- data/lib/project_types/script/layers/infrastructure/errors.rb +13 -17
- data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb +29 -21
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +2 -4
- data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +45 -34
- data/lib/project_types/script/layers/infrastructure/script_service.rb +37 -16
- data/lib/project_types/script/messages/messages.rb +66 -55
- data/lib/project_types/script/tasks/ensure_env.rb +22 -1
- data/lib/project_types/script/ui/error_handler.rb +32 -32
- data/lib/project_types/theme/cli.rb +16 -27
- data/lib/project_types/theme/commands/check.rb +33 -0
- data/lib/project_types/theme/commands/delete.rb +64 -0
- data/lib/project_types/theme/commands/init.rb +42 -0
- data/lib/project_types/theme/commands/language_server.rb +16 -0
- data/lib/project_types/theme/commands/package.rb +55 -0
- data/lib/project_types/theme/commands/publish.rb +43 -0
- data/lib/project_types/theme/commands/pull.rb +51 -0
- data/lib/project_types/theme/commands/push.rb +58 -32
- data/lib/project_types/theme/commands/serve.rb +8 -16
- data/lib/project_types/theme/forms/confirm_store.rb +15 -0
- data/lib/project_types/theme/forms/select.rb +59 -0
- data/lib/project_types/theme/messages/messages.rb +118 -103
- data/lib/project_types/theme/ui/sync_progress_bar.rb +20 -0
- data/lib/shopify-cli/admin_api.rb +57 -38
- data/lib/shopify-cli/admin_api/populate_resource_command.rb +6 -14
- data/lib/shopify-cli/admin_api/schema.rb +1 -10
- data/lib/shopify-cli/api.rb +29 -14
- data/lib/shopify-cli/command.rb +15 -3
- data/lib/shopify-cli/commands.rb +7 -2
- data/lib/shopify-cli/commands/help.rb +2 -29
- data/lib/shopify-cli/commands/login.rb +95 -0
- data/lib/shopify-cli/commands/logout.rb +24 -8
- data/lib/shopify-cli/commands/populate.rb +23 -0
- data/lib/{project_types/node → shopify-cli}/commands/populate/customer.rb +2 -8
- data/lib/{project_types/node → shopify-cli}/commands/populate/draft_order.rb +2 -2
- data/lib/{project_types/node → shopify-cli}/commands/populate/product.rb +2 -8
- data/lib/shopify-cli/commands/store.rb +15 -0
- data/lib/shopify-cli/commands/switch.rb +39 -0
- data/lib/shopify-cli/commands/system.rb +12 -0
- data/lib/shopify-cli/commands/whoami.rb +28 -0
- data/lib/shopify-cli/connect.rb +32 -0
- data/lib/shopify-cli/context.rb +65 -4
- data/lib/shopify-cli/core/entry_point.rb +3 -22
- data/lib/shopify-cli/core/monorail.rb +6 -2
- data/lib/shopify-cli/db.rb +4 -4
- data/lib/shopify-cli/http_request.rb +16 -0
- data/lib/shopify-cli/identity_auth.rb +282 -0
- data/lib/shopify-cli/{oauth → identity_auth}/servlet.rb +11 -12
- data/lib/shopify-cli/messages/messages.rb +140 -46
- data/lib/shopify-cli/packager.rb +5 -5
- data/lib/shopify-cli/partners_api.rb +21 -44
- data/lib/shopify-cli/partners_api/organizations.rb +8 -0
- data/lib/shopify-cli/project_commands.rb +16 -0
- data/lib/shopify-cli/project_type.rb +0 -31
- data/lib/shopify-cli/shopifolk.rb +8 -11
- data/lib/shopify-cli/sub_command.rb +1 -0
- data/lib/shopify-cli/tasks.rb +3 -0
- data/lib/shopify-cli/tasks/confirm_store.rb +18 -0
- data/lib/shopify-cli/tasks/create_api_client.rb +2 -2
- data/lib/shopify-cli/tasks/ensure_authenticated.rb +13 -0
- data/lib/shopify-cli/tasks/ensure_loopback_url.rb +1 -1
- data/lib/shopify-cli/tasks/ensure_project_type.rb +12 -0
- data/lib/shopify-cli/tasks/select_org_and_shop.rb +0 -3
- data/lib/shopify-cli/theme/dev_server.rb +98 -0
- data/lib/shopify-cli/theme/dev_server/certificate_manager.rb +79 -0
- data/lib/shopify-cli/theme/dev_server/header_hash.rb +94 -0
- data/lib/shopify-cli/theme/dev_server/hot-reload.js +93 -0
- data/lib/shopify-cli/theme/dev_server/hot_reload.rb +76 -0
- data/lib/shopify-cli/theme/dev_server/local_assets.rb +87 -0
- data/lib/shopify-cli/theme/dev_server/proxy.rb +205 -0
- data/lib/shopify-cli/theme/dev_server/sse.rb +75 -0
- data/lib/shopify-cli/theme/dev_server/watcher.rb +59 -0
- data/lib/shopify-cli/theme/dev_server/web_server.rb +140 -0
- data/lib/shopify-cli/theme/development_theme.rb +69 -0
- data/lib/shopify-cli/theme/file.rb +112 -0
- data/lib/shopify-cli/theme/ignore_filter.rb +109 -0
- data/lib/shopify-cli/theme/mime_type.rb +34 -0
- data/lib/shopify-cli/theme/syncer.rb +332 -0
- data/lib/shopify-cli/theme/theme.rb +204 -0
- data/lib/shopify-cli/tunnel.rb +1 -1
- data/lib/shopify-cli/version.rb +1 -1
- data/lib/shopify_cli.rb +18 -11
- data/shopify-cli.gemspec +12 -5
- data/shopify.fish +1 -1
- data/shopify.sh +1 -1
- metadata +91 -35
- data/.github/workflows/release.yml +0 -59
- data/lib/project_types/extension/features/argo_serve_options.rb +0 -41
- data/lib/project_types/node/commands/populate.rb +0 -23
- data/lib/project_types/rails/commands/populate.rb +0 -23
- data/lib/project_types/rails/commands/populate/customer.rb +0 -31
- data/lib/project_types/rails/commands/populate/draft_order.rb +0 -28
- data/lib/project_types/rails/commands/populate/product.rb +0 -30
- data/lib/project_types/script/layers/domain/config_ui.rb +0 -16
- data/lib/project_types/theme/commands/connect.rb +0 -54
- data/lib/project_types/theme/commands/create.rb +0 -48
- data/lib/project_types/theme/commands/deploy.rb +0 -38
- data/lib/project_types/theme/commands/generate.rb +0 -20
- data/lib/project_types/theme/commands/generate/env.rb +0 -79
- data/lib/project_types/theme/forms/connect.rb +0 -34
- data/lib/project_types/theme/forms/create.rb +0 -22
- data/lib/project_types/theme/tasks/ensure_themekit_installed.rb +0 -78
- data/lib/project_types/theme/themekit.rb +0 -113
- data/lib/shopify-cli/commands/connect.rb +0 -64
- data/lib/shopify-cli/commands/create.rb +0 -50
- data/lib/shopify-cli/oauth.rb +0 -198
@@ -3,143 +3,158 @@ module Theme
|
|
3
3
|
module Messages
|
4
4
|
MESSAGES = {
|
5
5
|
theme: {
|
6
|
-
|
7
|
-
|
6
|
+
help: <<~HELP,
|
7
|
+
Suite of commands for developing Shopify themes. See {{command:%1$s theme <command> --help}} for usage of each command.
|
8
|
+
Usage: {{command:%1$s theme [ %2$s ]}}
|
9
|
+
HELP
|
10
|
+
|
11
|
+
init: {
|
8
12
|
help: <<~HELP,
|
9
|
-
{{command:%s
|
10
|
-
|
13
|
+
{{command:%s theme init}}: Clones a Git repository to use as a starting point for building a new theme.
|
14
|
+
|
15
|
+
Usage: {{command:%s theme init [ NAME ]}}
|
16
|
+
|
11
17
|
Options:
|
12
|
-
{{command
|
13
|
-
{{command:--password=PASSWORD}} Private app password. App must have Read and Write Theme access.
|
14
|
-
{{command:--themeid=THEMEID}} Theme ID. Must be an existing theme on your store.
|
18
|
+
{{command:-u, --clone-url=URL}} The Git URL to clone from. Defaults to Shopify's example theme, Dawn: https://github.com/Shopify/dawn.git
|
15
19
|
HELP
|
16
|
-
|
17
|
-
connect: "Downloading theme files...",
|
18
|
-
failed: "Couldn't download theme files from store",
|
19
|
-
connected: "{{green:%s}} files were downloaded from {{underline:%s}} to {{green:%s}}",
|
20
|
+
ask_name: "Theme name",
|
20
21
|
},
|
21
|
-
|
22
|
-
|
23
|
-
duplicate_theme: "Duplicate theme",
|
24
|
-
failed: "Couldn't create the theme",
|
25
|
-
help: <<~HELP,
|
26
|
-
{{command:%s create theme}}: Creates a theme.
|
27
|
-
Usage: {{command:%s create theme}}
|
28
|
-
Options:
|
29
|
-
{{command:--store=MYSHOPIFYDOMAIN}} Store URL. Must be an existing store with private apps enabled.
|
30
|
-
{{command:--password=PASSWORD}} Private app password. App must have Read and Write Theme access.
|
31
|
-
{{command:--name=NAME}} Theme name. Any string.
|
32
|
-
HELP
|
33
|
-
info: {
|
34
|
-
created: "{{green:%s}} was created for {{underline:%s}} in {{green:%s}}",
|
35
|
-
},
|
36
|
-
},
|
37
|
-
deploy: {
|
38
|
-
abort: "Theme wasn't deployed",
|
39
|
-
confirmation: "This will change your live theme. Do you wish to proceed?",
|
22
|
+
publish: {
|
23
|
+
confirmation: "This will change your live theme. Do you want to continue?",
|
40
24
|
deploying: "Deploying theme",
|
41
25
|
error: "Theme couldn't be deployed",
|
42
26
|
help: <<~HELP,
|
43
|
-
{{command:%s
|
44
|
-
Usage: {{command:%s
|
27
|
+
{{command:%s theme publish}}: Set a remote theme as the live theme.
|
28
|
+
Usage: {{command:%s theme publish [ THEME_ID ]}}
|
29
|
+
|
30
|
+
Options:
|
31
|
+
{{command:-f, --force}} Skip confirmation.
|
32
|
+
|
33
|
+
Run without arguments to select theme from a list.
|
45
34
|
HELP
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
push_fail: "Theme files couldn't be updated",
|
35
|
+
done: "Your theme is now live at %s",
|
36
|
+
not_found: "Theme #%s does not exist",
|
37
|
+
select: "Select theme to push to",
|
38
|
+
confirm: "Are you sure you want to make %s the new live theme on %s?",
|
51
39
|
},
|
52
40
|
forms: {
|
53
41
|
ask_password: "Password:",
|
54
42
|
ask_store: "Store domain:",
|
55
|
-
create: {
|
56
|
-
ask_title: "Title:",
|
57
|
-
private_app: <<~APP,
|
58
|
-
To create a new theme, Shopify App CLI needs to connect with a private app installed on your store. Visit {{underline:%s/admin/apps/private}} to create a new API key and password, or retrieve an existing password.
|
59
|
-
If you create a new private app, ensure that it has Read and Write Theme access.
|
60
|
-
APP
|
61
|
-
},
|
62
|
-
connect: {
|
63
|
-
private_app: <<~APP,
|
64
|
-
To fetch your existing themes, Shopify App CLI needs to connect with your store. Visit {{underline:%s/admin/apps/private}} to create a new API key and password, or retrieve an existing password.
|
65
|
-
If you create a new private app, ensure that it has Read and Write Theme access.
|
66
|
-
APP
|
67
|
-
},
|
68
43
|
errors: "%s can't be blank",
|
69
44
|
},
|
70
|
-
generate: {
|
71
|
-
env: {
|
72
|
-
ask_password: "Password",
|
73
|
-
ask_password_default: "Password (defaults to {{green:%s}})",
|
74
|
-
ask_store: "Store",
|
75
|
-
ask_store_default: "Store (defaults to {{green:%s}})",
|
76
|
-
ask_theme: "Select theme",
|
77
|
-
help: <<~HELP,
|
78
|
-
Create or update configuration file in the current directory.
|
79
|
-
Usage: {{command:%s generate env}}
|
80
|
-
Options:
|
81
|
-
{{command:--store=MYSHOPIFYDOMAIN}} Store URL. Must be an existing store with private apps enabled.
|
82
|
-
{{command:--password=PASSWORD}} Private app password. App must have Read and Write Theme access.
|
83
|
-
{{command:--themeid=THEMEID}} Theme ID. Must be an existing theme on your store.
|
84
|
-
HELP
|
85
|
-
no_themes: "Please create a new theme using %s create theme",
|
86
|
-
},
|
87
|
-
help: <<~HELP,
|
88
|
-
Generate code in your Theme. Currently supports generating new envs.
|
89
|
-
Usage: {{command:%s generate [ env ]}}
|
90
|
-
HELP
|
91
|
-
},
|
92
45
|
push: {
|
93
46
|
remove_abort: "Theme files weren't deleted",
|
94
|
-
remove_confirm:
|
47
|
+
remove_confirm:
|
48
|
+
"This will delete the local and remote copies of the theme files, which " \
|
49
|
+
"can't be undone. Do you want to continue?",
|
95
50
|
error: {
|
96
51
|
push_error: "Theme files couldn't be pushed to Shopify",
|
97
52
|
remove_error: "Theme files couldn't be removed from Shopify",
|
98
53
|
},
|
99
54
|
help: <<~HELP,
|
100
|
-
{{command:%s push}}: Uploads your local theme files to
|
101
|
-
|
55
|
+
{{command:%s theme push}}: Uploads your local theme files to the connected store, overwriting the remote version if specified.
|
56
|
+
|
57
|
+
Usage: {{command:%s theme push [ ROOT ]}}
|
58
|
+
|
102
59
|
Options:
|
103
|
-
{{command
|
104
|
-
{{command
|
105
|
-
{{command
|
60
|
+
{{command:-i, --themeid=THEMEID}} Theme ID. Must be an existing theme on your store.
|
61
|
+
{{command:-d, --development}} Push to your remote development theme, and create it if needed.
|
62
|
+
{{command:-u, --unpublished}} Create a new unpublished theme and push to it.
|
63
|
+
{{command:-n, --nodelete}} Runs the push command without deleting remote files from Shopify.
|
64
|
+
{{command:-j, --json}} Output JSON instead of a UI.
|
65
|
+
{{command:-a, --allow-live}} Allow push to a live theme.
|
66
|
+
{{command:-p, --publish}} Publish as the live theme after uploading.
|
67
|
+
|
68
|
+
Run without options to select theme from a list.
|
106
69
|
HELP
|
107
70
|
info: {
|
108
|
-
|
109
|
-
remove: "Theme files were deleted from {{green:%s}} and Shopify",
|
71
|
+
pushing: "Pushing theme files to %s (#%s) on %s",
|
110
72
|
},
|
111
73
|
push: "Pushing theme files to Shopify",
|
112
|
-
|
74
|
+
select: "Select theme to push to",
|
75
|
+
live: "Are you sure you want to push to your live theme?",
|
76
|
+
theme_not_found: "Theme #%s doesn't exist",
|
77
|
+
done: <<~DONE,
|
78
|
+
{{green:Your theme was pushed successfully}}
|
79
|
+
|
80
|
+
{{info:View your theme:}}
|
81
|
+
{{underline:%s}}
|
82
|
+
|
83
|
+
{{info:Customize this theme in the Online Store Editor:}}
|
84
|
+
{{underline:%s}}
|
85
|
+
DONE
|
86
|
+
name: "Theme name",
|
113
87
|
},
|
114
88
|
serve: {
|
115
89
|
help: <<~HELP,
|
116
|
-
|
117
|
-
Usage: {{command:%s serve}}
|
90
|
+
Uploads the current theme as a development theme to the connected store, then prints theme editor and preview URLs to your terminal. While running, changes will push to the store in real time.
|
91
|
+
Usage: {{command:%s theme serve}}
|
118
92
|
HELP
|
119
|
-
serve: "Viewing theme
|
93
|
+
serve: "Viewing theme…",
|
120
94
|
open_fail: "Couldn't open the theme",
|
121
95
|
},
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
96
|
+
check: {
|
97
|
+
help: <<~HELP,
|
98
|
+
Check your theme for errors, suggestions, and best practices.
|
99
|
+
Usage: {{command:%s check}}
|
100
|
+
HELP
|
101
|
+
},
|
102
|
+
delete: {
|
103
|
+
help: <<~HELP,
|
104
|
+
{{command:%s theme delete}}: Delete remote themes from the connected store. This command can't be undone.
|
105
|
+
|
106
|
+
Usage: {{command:%s theme delete [ THEME_ID [ ... ] ]}}
|
107
|
+
|
108
|
+
Options:
|
109
|
+
{{command:-d, --development}} Delete your development theme.
|
110
|
+
{{command:-a, --show-all}} Include others development themes in theme list.
|
111
|
+
{{command:-f, --force}} Skip confirmation.
|
112
|
+
|
113
|
+
Run without options to select the theme to delete from a list.
|
114
|
+
HELP
|
115
|
+
select: "Select theme to delete",
|
116
|
+
done: "%s theme(s) deleted",
|
117
|
+
not_found: "{{x}} Theme #%s does not exist",
|
118
|
+
live: "{{x}} Theme #%s is your live theme. You can't delete it.",
|
119
|
+
confirm: "Are you sure you want to delete %s on %s?",
|
137
120
|
},
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
121
|
+
package: {
|
122
|
+
help: <<~HELP,
|
123
|
+
{{command:%s theme package}}: Package your theme into a .zip file, ready to upload to the Online Store.
|
124
|
+
|
125
|
+
Usage: {{command:%s theme package [ ROOT ]}}
|
126
|
+
HELP
|
127
|
+
error: {
|
128
|
+
prereq_command_required: "%1$s is required for packaging a theme. Please install %1$s "\
|
129
|
+
"using the appropriate package manager for your system.",
|
130
|
+
missing_config: "Provide a config/settings_schema.json to package your theme",
|
131
|
+
missing_theme_name: "Provide a theme_info.theme_name configuration in config/settings_schema.json",
|
142
132
|
},
|
133
|
+
done: "Theme packaged in %s",
|
134
|
+
},
|
135
|
+
language_server: {
|
136
|
+
help: <<~HELP,
|
137
|
+
{{command:%1$s theme language-server}}: Start a Language Server Protocol server.
|
138
|
+
|
139
|
+
Usage: {{command:%1$s theme language-server}}
|
140
|
+
HELP
|
141
|
+
},
|
142
|
+
pull: {
|
143
|
+
help: <<~HELP,
|
144
|
+
{{command:%s theme pull}}: Downloads your remote theme files locally.
|
145
|
+
|
146
|
+
Usage: {{command:%s theme pull [ ROOT ]}}
|
147
|
+
|
148
|
+
Options:
|
149
|
+
{{command:-i, --themeid=THEMEID}} The Theme ID. Must be an existing theme on your store.
|
150
|
+
{{command:-n, --nodelete}} Runs the pull command without deleting local files.
|
151
|
+
|
152
|
+
Run without options to select theme from a list.
|
153
|
+
HELP
|
154
|
+
select: "Select a theme to pull from",
|
155
|
+
pulling: "Pulling theme files from %s (#%s) on %s",
|
156
|
+
done: "Theme pulled successfully",
|
157
|
+
not_found: "{{x}} Theme #%s doesn't exist",
|
143
158
|
},
|
144
159
|
},
|
145
160
|
}.freeze
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Theme
|
2
|
+
module UI
|
3
|
+
class SyncProgressBar
|
4
|
+
def initialize(syncer)
|
5
|
+
@syncer = syncer
|
6
|
+
end
|
7
|
+
|
8
|
+
def progress(method, **args)
|
9
|
+
@syncer.delay_errors!
|
10
|
+
CLI::UI::Progress.progress do |bar|
|
11
|
+
@syncer.public_send(method, **args) do |left, total|
|
12
|
+
bar.tick(set_percent: 1 - left.to_f / total)
|
13
|
+
end
|
14
|
+
bar.tick(set_percent: 1)
|
15
|
+
end
|
16
|
+
@syncer.report_errors!
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -38,9 +38,15 @@ module ShopifyCli
|
|
38
38
|
# ShopifyCli::AdminAPI.query(@ctx, 'all_organizations')
|
39
39
|
#
|
40
40
|
def query(ctx, query_name, shop:, api_version: nil, **variables)
|
41
|
-
|
41
|
+
CLI::Kit::Util.begin do
|
42
42
|
api_client(ctx, api_version, shop).query(query_name, variables: variables)
|
43
|
+
end.retry_after(API::APIRequestUnauthorizedError, retries: 1) do
|
44
|
+
ShopifyCli::IdentityAuth.new(ctx: ctx).reauthenticate
|
43
45
|
end
|
46
|
+
rescue API::APIRequestUnauthorizedError
|
47
|
+
ctx.abort(ctx.message("core.api.error.failed_auth"))
|
48
|
+
rescue API::APIRequestForbiddenError
|
49
|
+
ctx.abort(ctx.message("core.api.error.forbidden", ShopifyCli::TOOL_NAME))
|
44
50
|
end
|
45
51
|
|
46
52
|
##
|
@@ -75,52 +81,47 @@ module ShopifyCli
|
|
75
81
|
# path: 'data.json',
|
76
82
|
# token: 'password')
|
77
83
|
#
|
78
|
-
def rest_request(ctx, shop:, path:, body: nil, method: "GET", api_version: nil, token: nil)
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
+
def rest_request(ctx, shop:, path:, query: nil, body: nil, method: "GET", api_version: nil, token: nil)
|
85
|
+
CLI::Kit::Util.begin do
|
86
|
+
ShopifyCli::DB.set(shopify_exchange_token: token) unless token.nil?
|
87
|
+
url = URI::HTTPS.build(
|
88
|
+
host: shop,
|
89
|
+
path: "/admin/api/#{fetch_api_version(ctx, api_version, shop)}/#{path}",
|
90
|
+
query: query,
|
91
|
+
)
|
92
|
+
resp = api_client(ctx, api_version, shop, path: path).request(url: url.to_s, body: body, method: method)
|
93
|
+
ShopifyCli::DB.set(shopify_exchange_token: nil) unless token.nil?
|
94
|
+
resp
|
95
|
+
end.retry_after(API::APIRequestUnauthorizedError) do
|
96
|
+
ShopifyCli::IdentityAuth.new(ctx: ctx).reauthenticate
|
97
|
+
end
|
84
98
|
end
|
85
99
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
.retry_after(API::APIRequestUnauthorizedError, retries: 1) do
|
92
|
-
authenticate(ctx, shop)
|
93
|
-
end
|
94
|
-
rescue API::APIRequestUnauthorizedError
|
95
|
-
ctx.abort(ctx.message("core.api.error.failed_auth"))
|
100
|
+
def get_shop_or_abort(ctx)
|
101
|
+
ctx.abort(
|
102
|
+
ctx.message("core.populate.error.no_shop", ShopifyCli::TOOL_NAME)
|
103
|
+
) unless ShopifyCli::DB.exists?(:shop)
|
104
|
+
ShopifyCli::DB.get(:shop)
|
96
105
|
end
|
97
106
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
service: "admin",
|
103
|
-
client_id: env.api_key,
|
104
|
-
secret: env.secret,
|
105
|
-
scopes: env.scopes,
|
106
|
-
token_path: "/access_token",
|
107
|
-
options: { "grant_options[]" => "per user" },
|
108
|
-
).authenticate("https://#{shop}/admin/oauth")
|
107
|
+
private
|
108
|
+
|
109
|
+
def authenticate(ctx, _shop)
|
110
|
+
ShopifyCli::IdentityAuth.new(ctx: ctx).authenticate
|
109
111
|
end
|
110
112
|
|
111
113
|
def api_client(ctx, api_version, shop, path: "graphql.json")
|
112
114
|
new(
|
113
115
|
ctx: ctx,
|
114
|
-
|
115
|
-
token: admin_access_token(ctx, shop),
|
116
|
+
token: access_token(ctx, shop),
|
116
117
|
url: "https://#{shop}/admin/api/#{fetch_api_version(ctx, api_version, shop)}/#{path}",
|
117
118
|
)
|
118
119
|
end
|
119
120
|
|
120
|
-
def
|
121
|
-
ShopifyCli::DB.get(:
|
121
|
+
def access_token(ctx, shop)
|
122
|
+
ShopifyCli::DB.get(:shopify_exchange_token) do
|
122
123
|
authenticate(ctx, shop)
|
123
|
-
ShopifyCli::DB.get(:
|
124
|
+
ShopifyCli::DB.get(:shopify_exchange_token)
|
124
125
|
end
|
125
126
|
end
|
126
127
|
|
@@ -128,14 +129,32 @@ module ShopifyCli
|
|
128
129
|
return api_version unless api_version.nil?
|
129
130
|
client = new(
|
130
131
|
ctx: ctx,
|
131
|
-
|
132
|
-
token: admin_access_token(ctx, shop),
|
132
|
+
token: access_token(ctx, shop),
|
133
133
|
url: "https://#{shop}/admin/api/unstable/graphql.json",
|
134
134
|
)
|
135
|
-
|
136
|
-
|
137
|
-
|
135
|
+
CLI::Kit::Util.begin do
|
136
|
+
versions = client.query("api_versions")["data"]["publicApiVersions"]
|
137
|
+
# return the most recent supported version
|
138
|
+
versions
|
139
|
+
.select { |version| version["supported"] }
|
140
|
+
.map { |version| version["handle"] }
|
141
|
+
.sort
|
142
|
+
.reverse[0]
|
143
|
+
end.retry_after(API::APIRequestUnauthorizedError, retries: 1) do
|
144
|
+
ShopifyCli::IdentityAuth.new(ctx: ctx).reauthenticate
|
145
|
+
end
|
146
|
+
rescue API::APIRequestUnauthorizedError
|
147
|
+
ctx.abort(ctx.message("core.api.error.failed_auth"))
|
148
|
+
rescue API::APIRequestForbiddenError
|
149
|
+
ctx.abort(ctx.message("core.api.error.forbidden", ShopifyCli::TOOL_NAME))
|
138
150
|
end
|
139
151
|
end
|
152
|
+
|
153
|
+
def auth_headers(token)
|
154
|
+
{
|
155
|
+
Authorization: "Bearer #{token}",
|
156
|
+
"X-Shopify-Access-Token" => token, # TODO: Remove when we no longer need private apps
|
157
|
+
}
|
158
|
+
end
|
140
159
|
end
|
141
160
|
end
|
@@ -25,12 +25,11 @@ module ShopifyCli
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def call(args, _)
|
28
|
-
return unless Project.current
|
29
|
-
Tasks::EnsureEnv.call(@ctx)
|
30
28
|
@args = args
|
31
29
|
@input = Hash.new
|
32
30
|
@count = DEFAULT_COUNT
|
33
31
|
@help = false
|
32
|
+
@skip_shop_confirmation = false
|
34
33
|
input_options
|
35
34
|
resource_options.parse(@args)
|
36
35
|
|
@@ -41,8 +40,8 @@ module ShopifyCli
|
|
41
40
|
return @ctx.puts(output)
|
42
41
|
end
|
43
42
|
|
44
|
-
|
45
|
-
|
43
|
+
ShopifyCli::Tasks::ConfirmStore.call(@ctx) unless @skip_shop_confirmation
|
44
|
+
@shop = AdminAPI.get_shop_or_abort(@ctx)
|
46
45
|
if @silent
|
47
46
|
spin_group = CLI::UI::SpinGroup.new
|
48
47
|
spin_group.add(@ctx.message("core.populate.populating", @count, camel_case_resource_type)) do |spinner|
|
@@ -89,7 +88,7 @@ module ShopifyCli
|
|
89
88
|
|
90
89
|
opts.on("--silent") { |v| @silent = v }
|
91
90
|
|
92
|
-
opts.on("--shop
|
91
|
+
opts.on("--skip-shop-confirmation") { |v| @skip_shop_confirmation = v }
|
93
92
|
end
|
94
93
|
end
|
95
94
|
|
@@ -130,7 +129,7 @@ module ShopifyCli
|
|
130
129
|
"core.populate.completion_message",
|
131
130
|
@count,
|
132
131
|
"#{camel_case_resource_type}#{plural}",
|
133
|
-
|
132
|
+
@shop,
|
134
133
|
camel_case_resource_type,
|
135
134
|
admin_url,
|
136
135
|
snake_case_resource_type
|
@@ -138,7 +137,7 @@ module ShopifyCli
|
|
138
137
|
end
|
139
138
|
|
140
139
|
def admin_url
|
141
|
-
"https://#{
|
140
|
+
"https://#{@shop}/admin/"
|
142
141
|
end
|
143
142
|
|
144
143
|
def price
|
@@ -147,13 +146,6 @@ module ShopifyCli
|
|
147
146
|
|
148
147
|
private
|
149
148
|
|
150
|
-
def get_shop(ctx)
|
151
|
-
res = ShopifyCli::Tasks::SelectOrgAndShop.call(ctx)
|
152
|
-
domain = res[:shop_domain]
|
153
|
-
Project.current.env.update(ctx, :shop, domain)
|
154
|
-
domain
|
155
|
-
end
|
156
|
-
|
157
149
|
def camel_case_resource_type
|
158
150
|
@camel_case_resource_type ||= self.class.to_s.split("::").last
|
159
151
|
end
|