shopify-cli 1.0.4 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/CONTRIBUTING.md +1 -1
- data/.travis.yml +3 -2
- data/CHANGELOG.md +21 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +13 -13
- data/bin/load_shopify.rb +3 -1
- data/bin/shopify +2 -0
- data/docs/Gemfile.lock +23 -13
- data/docs/getting-started/index.md +3 -2
- data/docs/getting-started/install/index.md +55 -9
- data/docs/getting-started/uninstall/index.md +1 -1
- data/docs/getting-started/upgrade/index.md +8 -4
- data/ext/shopify-cli/extconf.rb +40 -20
- data/lib/project_types/extension/cli.rb +1 -0
- data/lib/project_types/extension/features/argo_config.rb +60 -0
- data/lib/project_types/extension/messages/messages.rb +3 -0
- data/lib/project_types/extension/models/type.rb +1 -0
- data/lib/project_types/extension/models/types/checkout_post_purchase.rb +5 -2
- data/lib/project_types/extension/tasks/create_extension.rb +1 -1
- data/lib/project_types/extension/tasks/get_app.rb +1 -1
- data/lib/project_types/extension/tasks/update_draft.rb +1 -1
- data/lib/project_types/node/commands/create.rb +4 -4
- data/lib/project_types/node/commands/deploy/heroku.rb +6 -1
- data/lib/project_types/node/commands/generate/billing.rb +7 -5
- data/lib/project_types/node/commands/generate/page.rb +9 -5
- data/lib/project_types/node/commands/generate/webhook.rb +5 -1
- data/lib/project_types/node/commands/serve.rb +5 -5
- data/lib/project_types/node/messages/messages.rb +5 -1
- data/lib/project_types/rails/commands/create.rb +56 -5
- data/lib/project_types/rails/commands/generate.rb +1 -0
- data/lib/project_types/rails/commands/generate/webhook.rb +3 -2
- data/lib/project_types/rails/commands/serve.rb +11 -7
- data/lib/project_types/rails/gem.rb +61 -6
- data/lib/project_types/rails/messages/messages.rb +32 -12
- data/lib/project_types/script/commands/create.rb +1 -5
- data/lib/project_types/script/commands/disable.rb +1 -2
- data/lib/project_types/script/commands/enable.rb +5 -5
- data/lib/project_types/script/commands/push.rb +1 -6
- data/lib/project_types/script/config/extension_points.yml +4 -4
- data/lib/project_types/script/errors.rb +8 -0
- data/lib/project_types/script/forms/create.rb +1 -1
- data/lib/project_types/script/layers/domain/errors.rb +2 -0
- data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +36 -1
- data/lib/project_types/script/layers/infrastructure/errors.rb +8 -0
- data/lib/project_types/script/layers/infrastructure/script_service.rb +6 -2
- data/lib/project_types/script/messages/messages.rb +22 -48
- data/lib/project_types/script/ui/error_handler.rb +12 -0
- data/lib/rubygems_plugin.rb +18 -10
- data/lib/shopify-cli/admin_api/populate_resource_command.rb +1 -1
- data/lib/shopify-cli/command.rb +12 -6
- data/lib/shopify-cli/commands/connect.rb +7 -75
- data/lib/shopify-cli/commands/create.rb +1 -1
- data/lib/shopify-cli/commands/system.rb +21 -12
- data/lib/shopify-cli/context.rb +68 -0
- data/lib/shopify-cli/core/entry_point.rb +4 -1
- data/lib/shopify-cli/core/executor.rb +3 -5
- data/lib/shopify-cli/core/monorail.rb +1 -1
- data/lib/shopify-cli/db.rb +1 -1
- data/lib/shopify-cli/git.rb +1 -1
- data/lib/shopify-cli/heroku.rb +21 -5
- data/lib/shopify-cli/js_deps.rb +2 -2
- data/lib/shopify-cli/js_system.rb +2 -2
- data/lib/shopify-cli/messages/messages.rb +35 -25
- data/lib/shopify-cli/process_supervision.rb +60 -21
- data/lib/shopify-cli/project.rb +17 -9
- data/lib/shopify-cli/project_type.rb +3 -2
- data/lib/shopify-cli/sub_command.rb +1 -0
- data/lib/shopify-cli/task.rb +2 -2
- data/lib/shopify-cli/tasks.rb +11 -4
- data/lib/shopify-cli/tasks/ensure_env.rb +74 -17
- data/lib/shopify-cli/tunnel.rb +22 -7
- data/lib/shopify-cli/version.rb +1 -1
- data/lib/shopify_cli.rb +35 -9
- data/shopify-cli.gemspec +4 -1
- data/vendor/deps/cli-kit/REVISION +1 -1
- data/vendor/deps/cli-kit/lib/cli/kit.rb +1 -1
- data/vendor/deps/cli-kit/lib/cli/kit/autocall.rb +2 -2
- data/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb +12 -6
- data/vendor/deps/cli-kit/lib/cli/kit/executor.rb +9 -11
- data/vendor/deps/cli-kit/lib/cli/kit/logger.rb +8 -2
- data/vendor/deps/cli-kit/lib/cli/kit/support/test_helper.rb +7 -7
- data/vendor/deps/cli-kit/lib/cli/kit/system.rb +48 -17
- data/vendor/deps/cli-ui/REVISION +1 -1
- data/vendor/deps/cli-ui/lib/cli/ui.rb +5 -4
- data/vendor/deps/cli-ui/lib/cli/ui/ansi.rb +9 -3
- data/vendor/deps/cli-ui/lib/cli/ui/color.rb +1 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +3 -2
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +1 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/box.rb +13 -5
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/bracket.rb +29 -2
- data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +21 -10
- data/vendor/deps/cli-ui/lib/cli/ui/os.rb +63 -0
- data/vendor/deps/cli-ui/lib/cli/ui/prompt.rb +11 -2
- data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +1 -0
- data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +3 -3
- data/vendor/deps/cli-ui/lib/cli/ui/spinner/spin_group.rb +6 -8
- data/vendor/deps/cli-ui/lib/cli/ui/widgets.rb +2 -0
- data/vendor/gen/lib/gen.rb +39 -0
- data/vendor/gen/lib/gen/commands.rb +18 -0
- data/vendor/gen/lib/gen/commands/help.rb +20 -0
- data/vendor/gen/lib/gen/commands/new.rb +21 -0
- data/vendor/gen/lib/gen/entry_point.rb +10 -0
- data/vendor/gen/lib/gen/generator.rb +165 -0
- data/vendor/gen/template/.gitignore +2 -0
- data/vendor/gen/template/Gemfile +10 -0
- data/vendor/gen/template/README.md +1 -0
- data/vendor/gen/template/bin/testunit +23 -0
- data/vendor/gen/template/bin/update-deps +97 -0
- data/vendor/gen/template/dev-gems.yml +3 -0
- data/vendor/gen/template/dev-vendor.yml +4 -0
- data/vendor/gen/template/exe/__app__-gems +17 -0
- data/vendor/gen/template/exe/__app__-vendor +18 -0
- data/vendor/gen/template/lib/__app__.rb +33 -0
- data/vendor/gen/template/lib/__app__/commands.rb +18 -0
- data/vendor/gen/template/lib/__app__/commands/example.rb +19 -0
- data/vendor/gen/template/lib/__app__/commands/help.rb +21 -0
- data/vendor/gen/template/lib/__app__/entry_point.rb +10 -0
- data/vendor/gen/template/test/example_test.rb +17 -0
- data/vendor/gen/template/test/test_helper.rb +22 -0
- metadata +26 -4
- data/Vagrantfile +0 -17
- data/lib/project_types/script/forms/script_form.rb +0 -69
|
@@ -9,9 +9,12 @@ module Rails
|
|
|
9
9
|
},
|
|
10
10
|
|
|
11
11
|
gem: {
|
|
12
|
+
checking_installation_path: "Checking path %s for gem %s",
|
|
13
|
+
installed: "Installed %s gem",
|
|
12
14
|
installed_debug: "%s installed: %s",
|
|
13
15
|
installing: "Installing %s gem...",
|
|
14
|
-
|
|
16
|
+
setting_gem_home: "GEM_HOME being set to %s",
|
|
17
|
+
setting_gem_path: "GEM_PATH being set to %s",
|
|
15
18
|
},
|
|
16
19
|
|
|
17
20
|
create: {
|
|
@@ -33,6 +36,15 @@ module Rails
|
|
|
33
36
|
See {{underline:https://github.com/Shopify/shopify-app-cli/blob/master/docs/installing-ruby.md}}
|
|
34
37
|
for our recommended method of installing ruby.
|
|
35
38
|
MSG
|
|
39
|
+
dir_exists: "Project directory %s already exists. Please use a different name.",
|
|
40
|
+
install_failure: "Error installing %s gem",
|
|
41
|
+
node_required: "node is required to create a rails project. Download at https://nodejs.org/en/download.",
|
|
42
|
+
node_version_failure: "Failed to get the current node version. Please make sure it is installed as " \
|
|
43
|
+
"per the instructions at https://nodejs.org/en.",
|
|
44
|
+
yarn_required: "yarn is required to create a rails project. Download at " \
|
|
45
|
+
"https://classic.yarnpkg.com/en/docs/install.",
|
|
46
|
+
yarn_version_failure: "Failed to get the current yarn version. Please make sure it is installed as per " \
|
|
47
|
+
"the instructions at https://classic.yarnpkg.com/en/docs/install.",
|
|
36
48
|
},
|
|
37
49
|
|
|
38
50
|
info: {
|
|
@@ -40,13 +52,18 @@ module Rails
|
|
|
40
52
|
serve: "{{*}} Change directories to your new project folder {{green:%s}} and run {{command:%s serve}} " \
|
|
41
53
|
"to start a local server",
|
|
42
54
|
install: "{{*}} Then, visit {{underline:%s/test}} to install {{green:%s}} on your Dev Store",
|
|
55
|
+
open_new_shell: "{{*}} {{yellow:After installing %s, please open a new Command Prompt or PowerShell " \
|
|
56
|
+
"window to continue.}}",
|
|
43
57
|
},
|
|
44
|
-
installing_bundler: "Installing bundler
|
|
58
|
+
installing_bundler: "Installing bundler...",
|
|
45
59
|
generating_app: "Generating new rails app project in %s...",
|
|
46
|
-
adding_shopify_gem: "{{v}} Adding shopify_app gem
|
|
60
|
+
adding_shopify_gem: "{{v}} Adding shopify_app gem...",
|
|
61
|
+
node_version: "node %s",
|
|
62
|
+
yarn_version: "yarn %s",
|
|
47
63
|
running_bundle_install: "Running bundle install...",
|
|
48
64
|
running_generator: "Running shopify_app generator...",
|
|
49
|
-
running_migrations: "Running migrations
|
|
65
|
+
running_migrations: "Running migrations...",
|
|
66
|
+
running_webpacker_install: "Running webpacker:install...",
|
|
50
67
|
},
|
|
51
68
|
|
|
52
69
|
deploy: {
|
|
@@ -65,14 +82,14 @@ module Rails
|
|
|
65
82
|
Deploy the current Rails project to Heroku
|
|
66
83
|
Usage: {{command:%s deploy heroku}}
|
|
67
84
|
HELP
|
|
68
|
-
downloading: "Downloading Heroku CLI
|
|
85
|
+
downloading: "Downloading Heroku CLI...",
|
|
69
86
|
downloaded: "Downloaded Heroku CLI",
|
|
70
|
-
installing: "Installing Heroku CLI
|
|
87
|
+
installing: "Installing Heroku CLI...",
|
|
71
88
|
installed: "Installed Heroku CLI",
|
|
72
89
|
authenticated_with_account: "{{v}} Authenticated with Heroku as `%s`",
|
|
73
|
-
authenticating: "Authenticating with Heroku
|
|
90
|
+
authenticating: "Authenticating with Heroku...",
|
|
74
91
|
authenticated: "{{v}} Authenticated with Heroku",
|
|
75
|
-
deploying: "Deploying to Heroku
|
|
92
|
+
deploying: "Deploying to Heroku...",
|
|
76
93
|
deployed: "{{v}} Deployed to Heroku",
|
|
77
94
|
db_check: {
|
|
78
95
|
validating: "Validating application...",
|
|
@@ -86,7 +103,7 @@ module Rails
|
|
|
86
103
|
SQLITE
|
|
87
104
|
},
|
|
88
105
|
git: {
|
|
89
|
-
checking: "Checking git repo
|
|
106
|
+
checking: "Checking git repo...",
|
|
90
107
|
initialized: "Git repo initialized",
|
|
91
108
|
what_branch: "What branch would you like to deploy?",
|
|
92
109
|
branch_selected: "{{v}} Git branch `%s` selected for deploy",
|
|
@@ -95,10 +112,10 @@ module Rails
|
|
|
95
112
|
no_apps_found: "No existing Heroku app found. What would you like to do?",
|
|
96
113
|
name: "What is your Heroku app’s name?",
|
|
97
114
|
select: "Specify an existing Heroku app",
|
|
98
|
-
selecting: "Selecting Heroku app `%s
|
|
115
|
+
selecting: "Selecting Heroku app `%s`...",
|
|
99
116
|
selected: "{{v}} Heroku app `%s` selected",
|
|
100
117
|
create: "Create a new Heroku app",
|
|
101
|
-
creating: "Creating new Heroku app
|
|
118
|
+
creating: "Creating new Heroku app...",
|
|
102
119
|
created: "{{v}} New Heroku app created",
|
|
103
120
|
},
|
|
104
121
|
},
|
|
@@ -203,7 +220,10 @@ module Rails
|
|
|
203
220
|
host_must_be_https: "{{red:HOST must be a HTTPS url.}}",
|
|
204
221
|
},
|
|
205
222
|
|
|
206
|
-
open_info:
|
|
223
|
+
open_info: <<~MESSAGE,
|
|
224
|
+
{{*}} To install and start using your app, open this URL in your browser:
|
|
225
|
+
{{green:%s}}
|
|
226
|
+
MESSAGE
|
|
207
227
|
running_server: "Running server...",
|
|
208
228
|
},
|
|
209
229
|
|
|
@@ -34,12 +34,8 @@ module Script
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def self.help
|
|
37
|
-
ShopifyCli::Context.message('script.create.help', ShopifyCli::TOOL_NAME)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def self.extended_help
|
|
41
37
|
allowed_values = Script::Layers::Application::ExtensionPoints.types.map { |type| "{{cyan:#{type}}}" }
|
|
42
|
-
ShopifyCli::Context.message('script.create.
|
|
38
|
+
ShopifyCli::Context.message('script.create.help', ShopifyCli::TOOL_NAME, allowed_values.join(', '))
|
|
43
39
|
end
|
|
44
40
|
end
|
|
45
41
|
end
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
module Script
|
|
4
4
|
module Commands
|
|
5
5
|
class Disable < ShopifyCli::Command
|
|
6
|
-
prerequisite_task :ensure_env
|
|
7
|
-
|
|
8
6
|
def call(_args, _name)
|
|
7
|
+
ShopifyCli::Tasks::EnsureEnv.call(@ctx, required: [:api_key, :secret, :shop])
|
|
9
8
|
project = ScriptProject.current
|
|
10
9
|
Layers::Application::DisableScript.call(
|
|
11
10
|
ctx: @ctx,
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
module Script
|
|
4
4
|
module Commands
|
|
5
5
|
class Enable < ShopifyCli::Command
|
|
6
|
-
prerequisite_task :ensure_env
|
|
7
6
|
options do |parser, flags|
|
|
8
7
|
parser.on('--config_props=KEYVALUEPAIRS', Array) do |t|
|
|
9
8
|
flags[:config_props] = Hash[t.map { |s| s.split(':') }]
|
|
@@ -12,6 +11,7 @@ module Script
|
|
|
12
11
|
end
|
|
13
12
|
|
|
14
13
|
def call(_args, _name)
|
|
14
|
+
ShopifyCli::Tasks::EnsureEnv.call(@ctx, required: [:api_key, :secret, :shop])
|
|
15
15
|
project = ScriptProject.current
|
|
16
16
|
api_key = project.env[:api_key]
|
|
17
17
|
shop_domain = project.env[:shop]
|
|
@@ -32,6 +32,8 @@ module Script
|
|
|
32
32
|
title: project.script_name
|
|
33
33
|
))
|
|
34
34
|
@ctx.puts(@ctx.message('script.enable.info'))
|
|
35
|
+
rescue Errors::InvalidConfigYAMLError => e
|
|
36
|
+
UI::ErrorHandler.pretty_print_and_raise(e)
|
|
35
37
|
rescue StandardError => e
|
|
36
38
|
UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.message('script.enable.error.operation_failed'))
|
|
37
39
|
end
|
|
@@ -40,10 +42,6 @@ module Script
|
|
|
40
42
|
ShopifyCli::Context.message('script.enable.help', ShopifyCli::TOOL_NAME)
|
|
41
43
|
end
|
|
42
44
|
|
|
43
|
-
def self.extended_help
|
|
44
|
-
ShopifyCli::Context.message('script.enable.extended_help', ShopifyCli::TOOL_NAME)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
45
|
private
|
|
48
46
|
|
|
49
47
|
def acquire_configuration(config_file: nil, config_props: nil)
|
|
@@ -59,6 +57,8 @@ module Script
|
|
|
59
57
|
})
|
|
60
58
|
end
|
|
61
59
|
configuration
|
|
60
|
+
rescue Errno::ENOENT, Psych::SyntaxError
|
|
61
|
+
raise Errors::InvalidConfigYAMLError, options.flags[:config_file]
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
# No slice pre Ruby 2.5 so roll our own
|
|
@@ -3,13 +3,12 @@
|
|
|
3
3
|
module Script
|
|
4
4
|
module Commands
|
|
5
5
|
class Push < ShopifyCli::Command
|
|
6
|
-
prerequisite_task :ensure_env
|
|
7
|
-
|
|
8
6
|
options do |parser, flags|
|
|
9
7
|
parser.on('--force') { |t| flags[:force] = t }
|
|
10
8
|
end
|
|
11
9
|
|
|
12
10
|
def call(_args, _name)
|
|
11
|
+
ShopifyCli::Tasks::EnsureEnv.call(@ctx, required: [:api_key, :secret, :shop])
|
|
13
12
|
project = ScriptProject.current
|
|
14
13
|
api_key = project.env[:api_key]
|
|
15
14
|
return @ctx.puts(self.class.help) unless api_key &&
|
|
@@ -31,10 +30,6 @@ module Script
|
|
|
31
30
|
def self.help
|
|
32
31
|
ShopifyCli::Context.message('script.push.help', ShopifyCli::TOOL_NAME)
|
|
33
32
|
end
|
|
34
|
-
|
|
35
|
-
def self.extended_help
|
|
36
|
-
ShopifyCli::Context.message('script.push.extended_help', ShopifyCli::TOOL_NAME)
|
|
37
|
-
end
|
|
38
33
|
end
|
|
39
34
|
end
|
|
40
35
|
end
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
discount:
|
|
2
2
|
assemblyscript:
|
|
3
3
|
package: "@shopify/extension-point-as-discount"
|
|
4
|
-
version: "^0.2.
|
|
4
|
+
version: "^0.2.10"
|
|
5
5
|
sdk-version: "^6.0.0"
|
|
6
6
|
toolchain-version: "^1.1.0"
|
|
7
7
|
unit_limit_per_order:
|
|
8
8
|
assemblyscript:
|
|
9
9
|
package: "@shopify/extension-point-as-unit-limit-per-order"
|
|
10
|
-
version: "^0.1.
|
|
10
|
+
version: "^0.1.12"
|
|
11
11
|
sdk-version: "^6.0.0"
|
|
12
12
|
toolchain-version: "^1.1.0"
|
|
13
13
|
payment_filter:
|
|
14
14
|
assemblyscript:
|
|
15
15
|
package: "@shopify/extension-point-as-payment-filter"
|
|
16
|
-
version: "^0.2.
|
|
16
|
+
version: "^0.2.8"
|
|
17
17
|
sdk-version: "^6.0.0"
|
|
18
18
|
toolchain-version: "^1.1.0"
|
|
19
19
|
shipping_filter:
|
|
20
20
|
assemblyscript:
|
|
21
21
|
package: "@shopify/extension-point-as-shipping-filter"
|
|
22
|
-
version: "^0.2.
|
|
22
|
+
version: "^0.2.10"
|
|
23
23
|
sdk-version: "^6.0.0"
|
|
24
24
|
toolchain-version: "^1.1.0"
|
|
@@ -9,9 +9,17 @@ module Script
|
|
|
9
9
|
class NoExistingStoresError < ScriptProjectError
|
|
10
10
|
attr_reader :organization_id
|
|
11
11
|
def initialize(organization_id)
|
|
12
|
+
super()
|
|
12
13
|
@organization_id = organization_id
|
|
13
14
|
end
|
|
14
15
|
end
|
|
15
16
|
class ScriptProjectAlreadyExistsError < ScriptProjectError; end
|
|
17
|
+
class InvalidConfigYAMLError < ScriptProjectError
|
|
18
|
+
attr_reader :config_file
|
|
19
|
+
def initialize(config_file)
|
|
20
|
+
super()
|
|
21
|
+
@config_file = config_file
|
|
22
|
+
end
|
|
23
|
+
end
|
|
16
24
|
end
|
|
17
25
|
end
|
|
@@ -8,12 +8,14 @@ module Script
|
|
|
8
8
|
class InvalidExtensionPointError < ScriptProjectError
|
|
9
9
|
attr_reader :type
|
|
10
10
|
def initialize(type)
|
|
11
|
+
super()
|
|
11
12
|
@type = type
|
|
12
13
|
end
|
|
13
14
|
end
|
|
14
15
|
class ScriptNotFoundError < ScriptProjectError
|
|
15
16
|
attr_reader :script_name, :extension_point_type
|
|
16
17
|
def initialize(extension_point_type, script_name)
|
|
18
|
+
super()
|
|
17
19
|
@script_name = script_name
|
|
18
20
|
@extension_point_type = extension_point_type
|
|
19
21
|
end
|
|
@@ -34,7 +34,9 @@ module Script
|
|
|
34
34
|
|
|
35
35
|
def dependencies_installed?
|
|
36
36
|
# Assuming if node_modules folder exist at root of script folder, all deps are installed
|
|
37
|
-
ctx.dir_exist?("node_modules")
|
|
37
|
+
return false unless ctx.dir_exist?("node_modules")
|
|
38
|
+
check_if_ep_dependencies_up_to_date!
|
|
39
|
+
true
|
|
38
40
|
end
|
|
39
41
|
|
|
40
42
|
private
|
|
@@ -58,6 +60,39 @@ module Script
|
|
|
58
60
|
def bytecode
|
|
59
61
|
File.read(format(BYTECODE_FILE, name: script_name))
|
|
60
62
|
end
|
|
63
|
+
|
|
64
|
+
def check_if_ep_dependencies_up_to_date!
|
|
65
|
+
return true if ENV['SHOPIFY_CLI_SCRIPTS_IGNORE_OUTDATED']
|
|
66
|
+
|
|
67
|
+
# ignore exit code since it will not be 0 unless every package is up to date which they probably won't be
|
|
68
|
+
out, _ = ctx.capture2e("npm", "outdated", "--json", "--depth", "0")
|
|
69
|
+
parsed_outdated_check = JSON.parse(out)
|
|
70
|
+
outdated_ep_packages = parsed_outdated_check
|
|
71
|
+
.select { |package_name, _| package_name.start_with?('@shopify/extension-point-as-') }
|
|
72
|
+
.select { |_, version_info| !package_is_up_to_date?(version_info) }
|
|
73
|
+
.keys
|
|
74
|
+
raise Errors::PackagesOutdatedError.new(outdated_ep_packages),
|
|
75
|
+
"NPM packages out of date: #{outdated_ep_packages.join(', ')}" unless outdated_ep_packages.empty?
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def package_is_up_to_date?(version_info)
|
|
79
|
+
require 'semantic/semantic'
|
|
80
|
+
current_version = version_info['current']
|
|
81
|
+
latest_version = version_info['latest']
|
|
82
|
+
|
|
83
|
+
# making an assumption that the script developer knows what they're doing if they're not referencing a
|
|
84
|
+
# semver version
|
|
85
|
+
begin
|
|
86
|
+
current_version = ::Semantic::Version.new(current_version)
|
|
87
|
+
latest_version = ::Semantic::Version.new(latest_version)
|
|
88
|
+
rescue ArgumentError
|
|
89
|
+
return true
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
return false if current_version.major < latest_version.major
|
|
93
|
+
return false if latest_version.major == 0 && current_version.minor < latest_version.minor
|
|
94
|
+
true
|
|
95
|
+
end
|
|
61
96
|
end
|
|
62
97
|
end
|
|
63
98
|
end
|
|
@@ -21,6 +21,7 @@ module Script
|
|
|
21
21
|
class ScriptRepushError < ScriptProjectError
|
|
22
22
|
attr_reader :api_key
|
|
23
23
|
def initialize(api_key)
|
|
24
|
+
super()
|
|
24
25
|
@api_key = api_key
|
|
25
26
|
end
|
|
26
27
|
end
|
|
@@ -33,6 +34,13 @@ module Script
|
|
|
33
34
|
class ShopScriptConflictError < ScriptProjectError; end
|
|
34
35
|
class ShopScriptUndefinedError < ScriptProjectError; end
|
|
35
36
|
class TaskRunnerNotFoundError < ScriptProjectError; end
|
|
37
|
+
class PackagesOutdatedError < ScriptProjectError
|
|
38
|
+
attr_reader :outdated_packages
|
|
39
|
+
def initialize(outdated_packages)
|
|
40
|
+
super("EP packages are outdated and need to be updated: #{outdated_packages.join(', ')}")
|
|
41
|
+
@outdated_packages = outdated_packages
|
|
42
|
+
end
|
|
43
|
+
end
|
|
36
44
|
end
|
|
37
45
|
end
|
|
38
46
|
end
|
|
@@ -49,7 +49,7 @@ module Script
|
|
|
49
49
|
resp_hash = script_service_request(
|
|
50
50
|
query_name: query_name,
|
|
51
51
|
api_key: api_key,
|
|
52
|
-
shop_domain: shop_domain,
|
|
52
|
+
shop_domain: format_shop_domain(shop_domain),
|
|
53
53
|
variables: variables,
|
|
54
54
|
)
|
|
55
55
|
user_errors = resp_hash["data"]["shopScriptUpdateOrCreate"]["userErrors"]
|
|
@@ -76,7 +76,7 @@ module Script
|
|
|
76
76
|
resp_hash = script_service_request(
|
|
77
77
|
query_name: query_name,
|
|
78
78
|
api_key: api_key,
|
|
79
|
-
shop_domain: shop_domain,
|
|
79
|
+
shop_domain: format_shop_domain(shop_domain),
|
|
80
80
|
variables: variables,
|
|
81
81
|
)
|
|
82
82
|
user_errors = resp_hash["data"]["shopScriptDelete"]["userErrors"]
|
|
@@ -91,6 +91,10 @@ module Script
|
|
|
91
91
|
|
|
92
92
|
private
|
|
93
93
|
|
|
94
|
+
def format_shop_domain(shop_domain)
|
|
95
|
+
shop_domain.delete_suffix("/")
|
|
96
|
+
end
|
|
97
|
+
|
|
94
98
|
class ScriptServiceAPI < ShopifyCli::API
|
|
95
99
|
property(:api_key, accepts: String)
|
|
96
100
|
property(:shop_id, accepts: Integer)
|
|
@@ -29,7 +29,7 @@ module Script
|
|
|
29
29
|
no_existing_orgs_cause: "You don't have any partner organizations.",
|
|
30
30
|
no_existing_orgs_help: "Please visit https://partners.shopify.com/ to create a partners account.",
|
|
31
31
|
|
|
32
|
-
no_existing_stores_cause: "You don't have any
|
|
32
|
+
no_existing_stores_cause: "You don't have any stores.",
|
|
33
33
|
no_existing_stores_help: "Visit https://partners.shopify.com/%{organization_id}/stores/ to create one.",
|
|
34
34
|
|
|
35
35
|
project_exists_cause: "Directory with the same name as the script already exists.",
|
|
@@ -38,9 +38,12 @@ module Script
|
|
|
38
38
|
invalid_extension_cause: "Invalid extension point %s",
|
|
39
39
|
invalid_extension_help: "Allowed values: %s.",
|
|
40
40
|
|
|
41
|
+
invalid_config: "Can't change the configuration values because %1$s is missing or "\
|
|
42
|
+
"it is not formatted properly.",
|
|
43
|
+
|
|
41
44
|
script_not_found_cause: "Couldn't find script %s for extension point %s",
|
|
42
45
|
|
|
43
|
-
app_not_installed_cause: "App not installed on
|
|
46
|
+
app_not_installed_cause: "App not installed on store.",
|
|
44
47
|
|
|
45
48
|
app_script_not_pushed_help: "Push the script and then try this command again.",
|
|
46
49
|
|
|
@@ -67,18 +70,19 @@ module Script
|
|
|
67
70
|
"on this extension point.",
|
|
68
71
|
shop_script_conflict_help: "Disable that script or uninstall that app and try again.",
|
|
69
72
|
|
|
70
|
-
shop_script_undefined_cause: "Script is already turned off in
|
|
73
|
+
shop_script_undefined_cause: "Script is already turned off in store.",
|
|
74
|
+
|
|
75
|
+
packages_outdated_cause: "The following npm packages are out of date: %s.",
|
|
76
|
+
packages_outdated_help: "Run `npm update` to update them.",
|
|
71
77
|
},
|
|
72
78
|
|
|
73
79
|
create: {
|
|
74
80
|
help: <<~HELP,
|
|
75
81
|
{{command:%1$s create script}}: Creates a script project.
|
|
76
82
|
Usage: {{command:%1$s create script}}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
\s\s{{command:--name=NAME}} Script project name. Use any string.
|
|
81
|
-
\s\s{{command:--extension_point=TYPE}} Extension point name. Allowed values: %2$s.
|
|
83
|
+
Options:
|
|
84
|
+
{{command:--name=NAME}} Script project name. Use any string.
|
|
85
|
+
{{command:--extension_point=TYPE}} Extension point name. Allowed values: %2$s.
|
|
82
86
|
HELP
|
|
83
87
|
|
|
84
88
|
error: {
|
|
@@ -94,14 +98,12 @@ module Script
|
|
|
94
98
|
help: <<~HELP,
|
|
95
99
|
Build the script and put it into production. If you've already pushed a script with the same extension point, use --force to replace the current script with the newest one.
|
|
96
100
|
Usage: {{command:%s push}}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
\s\sOptions:
|
|
100
|
-
\s\s{{command:[--force]}} Forces the script to be overwritten if an instance of it already exists.
|
|
101
|
+
Options:
|
|
102
|
+
{{command:[--force]}} Forces the script to be overwritten if an instance of it already exists.
|
|
101
103
|
HELP
|
|
102
104
|
|
|
103
105
|
error: {
|
|
104
|
-
operation_failed: "
|
|
106
|
+
operation_failed: "Couldn't push script to app.",
|
|
105
107
|
},
|
|
106
108
|
|
|
107
109
|
script_pushed: "{{v}} Script pushed to app (API key: %{api_key}).",
|
|
@@ -109,27 +111,24 @@ module Script
|
|
|
109
111
|
|
|
110
112
|
disable: {
|
|
111
113
|
help: <<~HELP,
|
|
112
|
-
Turn off script in
|
|
114
|
+
Turn off script in store.
|
|
113
115
|
Usage: {{command:%s disable}}
|
|
114
116
|
HELP
|
|
115
117
|
|
|
116
118
|
error: {
|
|
117
119
|
operation_failed: "Can't disable script.",
|
|
118
|
-
not_pushed_to_app: "Can't disable the script because it hasn't been pushed to the app.",
|
|
119
120
|
},
|
|
120
121
|
|
|
121
|
-
script_disabled: "{{v}} Script disabled. Script is turned off in
|
|
122
|
+
script_disabled: "{{v}} Script disabled. Script is turned off in store.",
|
|
122
123
|
},
|
|
123
124
|
|
|
124
125
|
enable: {
|
|
125
126
|
help: <<~HELP,
|
|
126
|
-
Turn on script in
|
|
127
|
+
Turn on script in store.
|
|
127
128
|
Usage: {{command:%s enable}}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
\s\s{{command:--config_props='name1:value1, name2:value2'}} Optional. Define the configuration of your script by passing individual name and value pairs. If used with --config_file, then matching values in --config_props will override those set in the file.
|
|
132
|
-
\s\s{{command:--config_file=<path/to/YAMLFilename>}} Optional. Define the configuration of your script using a YAML formatted file. --config_props values override properties in this file.
|
|
129
|
+
Options:
|
|
130
|
+
{{command:--config_props='name1:value1, name2:value2'}} Optional. Define the configuration of your script by passing individual name and value pairs. If used with --config_file, then matching values in --config_props will override those set in the file.
|
|
131
|
+
{{command:--config_file=<path/to/YAMLFilename>}} Optional. Define the configuration of your script using a YAML formatted file. --config_props values override properties in this file.
|
|
133
132
|
HELP
|
|
134
133
|
|
|
135
134
|
info: "{{*}} A script always remains enabled until you disable it - even after pushing "\
|
|
@@ -138,11 +137,10 @@ module Script
|
|
|
138
137
|
|
|
139
138
|
error: {
|
|
140
139
|
operation_failed: "Can't enable script.",
|
|
141
|
-
not_pushed_to_app: "Can't enable the script because it hasn't been pushed to the app.",
|
|
142
140
|
},
|
|
143
141
|
|
|
144
142
|
script_enabled: "{{v}} Script enabled. %{type} script %{title} in app (API key: %{api_key}) "\
|
|
145
|
-
"is turned on in
|
|
143
|
+
"is turned on in store {{green:%{shop_domain}}}",
|
|
146
144
|
},
|
|
147
145
|
|
|
148
146
|
project_deps: {
|
|
@@ -152,35 +150,11 @@ module Script
|
|
|
152
150
|
installed: "Missing dependencies installed",
|
|
153
151
|
},
|
|
154
152
|
|
|
155
|
-
test: {
|
|
156
|
-
help: <<~HELP,
|
|
157
|
-
Runs unit tests on your script.
|
|
158
|
-
Usage: {{command:%s test}}
|
|
159
|
-
HELP
|
|
160
|
-
|
|
161
|
-
error: {
|
|
162
|
-
operation_failed: "Tests didn't run or they ran with failures.",
|
|
163
|
-
},
|
|
164
|
-
|
|
165
|
-
running: "Running tests",
|
|
166
|
-
success: "{{v}} Tests finished.",
|
|
167
|
-
},
|
|
168
|
-
|
|
169
153
|
forms: {
|
|
170
154
|
create: {
|
|
171
155
|
select_extension_point: "Which extension point do you want to use?",
|
|
172
156
|
script_name: "Script Name",
|
|
173
157
|
},
|
|
174
|
-
script_form: {
|
|
175
|
-
ask_app_api_key_default: "Which app do you want this script to belong to?",
|
|
176
|
-
ask_shop_domain_default: "Select a development store",
|
|
177
|
-
fetching_organizations: "Fetching partner organizations",
|
|
178
|
-
fetched_organizations: "Fetched partner organizations",
|
|
179
|
-
select_organization: "Select partner organization.",
|
|
180
|
-
using_app: "Using app {{green:%{title} (%{api_key})}}.",
|
|
181
|
-
using_development_store: "Using development store {{green:%{domain}}}",
|
|
182
|
-
using_organization: "Partner organization {{green:%s}}.",
|
|
183
|
-
},
|
|
184
158
|
},
|
|
185
159
|
|
|
186
160
|
application: {
|