shopify-cli 1.13.1 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f924d0de5639f7af794a6b35305b0bdcd78e2fad0f8a4c589006d249f48bbac
4
- data.tar.gz: 701e91a9b522933b26f3a26baeab8f900a9cb3aa181e3b847b8a231c9edd5f04
3
+ metadata.gz: d8f8161eea7a180b04614de6e548d11126711cdeabb05f7eb85c1d35cc6c1769
4
+ data.tar.gz: e07cb22654f647771d78d1aad39514534fcc2817a01a16f24e03b896828ca583
5
5
  SHA512:
6
- metadata.gz: 96191b61830023526627944dcf5c4ac6a6b883aa060f81be3095cf5275763ef1552268cdcf46bc9d9b65cf9960ce879aa12b07cd799f2068f65329143a3149cc
7
- data.tar.gz: 7e4d1e6c0c6b60609b661261cb0846acf5e42d58da4d525a8706df538c0ef3b7d55e9b26d45f8db8a6977aa5802d041bb639b0d4618718366333f2768f2dc1b8
6
+ metadata.gz: 24bb19308430c1fab1336af24b68182e63223bb24e62eb98c551a7bf34a23f8dc615c0ebe4b74381458085101316f47ec467d37192b28d86d528ef3020d6b220
7
+ data.tar.gz: f7afb287929f611361137c909846f5f64e8fc58dbfaffa460c37b3b64deae46f33d79d7201bb23f2819de3da2b4b9666ce1fc9d08f6993a91872a0dffaf1ce83
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  Unreleased
2
2
  ------
3
3
 
4
+ Version 1.14.0
5
+ --------------
6
+ * [1275](https://github.com/Shopify/shopify-app-cli/pull/1275): Use script.json to specify script metadata
7
+ * [1279](https://github.com/Shopify/shopify-app-cli/pull/1279): Fix bug where a script push still fails after the user answers the force push prompt
8
+ * [1288](https://github.com/Shopify/shopify-app-cli/pull/1288): Fix bug where Scripts SDK was included for projects that don't require it
9
+
4
10
  Version 1.13.1
5
11
  --------------
6
12
  * [1274](https://github.com/Shopify/shopify-app-cli/pull/1274): Only print api_key during error if it exists
@@ -39,10 +39,10 @@ module Script
39
39
 
40
40
  module Domain
41
41
  autoload :Errors, Project.project_filepath("layers/domain/errors")
42
- autoload :ConfigUi, Project.project_filepath("layers/domain/config_ui")
43
42
  autoload :PushPackage, Project.project_filepath("layers/domain/push_package")
44
43
  autoload :Metadata, Project.project_filepath("layers/domain/metadata")
45
44
  autoload :ExtensionPoint, Project.project_filepath("layers/domain/extension_point")
45
+ autoload :ScriptJson, Project.project_filepath("layers/domain/script_json")
46
46
  autoload :ScriptProject, Project.project_filepath("layers/domain/script_project")
47
47
  end
48
48
 
@@ -8,12 +8,13 @@ module Script
8
8
  end
9
9
 
10
10
  def call(_args, _name)
11
- Tasks::EnsureEnv.call(@ctx)
11
+ fresh_env = Tasks::EnsureEnv.call(@ctx)
12
+ force = options.flags.key?(:force) || !!fresh_env
12
13
 
13
14
  api_key = Layers::Infrastructure::ScriptProjectRepository.new(ctx: @ctx).get.api_key
14
15
  return @ctx.puts(self.class.help) unless api_key
15
16
 
16
- Layers::Application::PushScript.call(ctx: @ctx, force: options.flags.key?(:force))
17
+ Layers::Application::PushScript.call(ctx: @ctx, force: force)
17
18
  @ctx.puts(@ctx.message("script.push.script_pushed", api_key: api_key))
18
19
  rescue StandardError => e
19
20
  msg = if api_key
@@ -1,19 +1,22 @@
1
1
  mutation AppScriptUpdateOrCreate(
2
2
  $extensionPointName: ExtensionPointName!,
3
3
  $title: String,
4
- $configUi: String,
4
+ $description: String,
5
5
  $sourceCode: String,
6
6
  $language: String,
7
7
  $force: Boolean,
8
8
  $schemaMajorVersion: String,
9
9
  $schemaMinorVersion: String,
10
10
  $useMsgpack: Boolean,
11
- $uuid: String
11
+ $uuid: String,
12
+ $configurationUi: Boolean,
13
+ $scriptJsonVersion: String,
14
+ $configurationDefinition: String,
12
15
  ) {
13
16
  appScriptUpdateOrCreate(
14
17
  extensionPointName: $extensionPointName
15
18
  title: $title
16
- configUi: $configUi
19
+ description: $description
17
20
  sourceCode: $sourceCode
18
21
  language: $language
19
22
  force: $force
@@ -21,6 +24,9 @@ mutation AppScriptUpdateOrCreate(
21
24
  schemaMinorVersion: $schemaMinorVersion
22
25
  useMsgpack: $useMsgpack,
23
26
  uuid: $uuid
27
+ configurationUi: $configurationUi
28
+ scriptJsonVersion: $scriptJsonVersion
29
+ configurationDefinition: $configurationDefinition
24
30
  ) {
25
31
  userErrors {
26
32
  field
@@ -12,16 +12,17 @@ module Script
12
12
 
13
13
  in_new_directory_context(ctx, script_name) do
14
14
  extension_point = ExtensionPoints.get(type: extension_point_type)
15
- project = Infrastructure::ScriptProjectRepository.new(ctx: ctx).create(
15
+ script_project_repo = Infrastructure::ScriptProjectRepository.new(ctx: ctx)
16
+ project = script_project_repo.create(
16
17
  script_name: script_name,
17
18
  extension_point_type: extension_point_type,
18
- language: language,
19
- no_config_ui: no_config_ui
19
+ language: language
20
20
  )
21
21
  project_creator = Infrastructure::Languages::ProjectCreator
22
22
  .for(ctx, language, extension_point, script_name, project.id)
23
23
  install_dependencies(ctx, language, script_name, project_creator)
24
24
  bootstrap(ctx, project_creator)
25
+ script_project_repo.update_or_create_script_json(title: script_name, configuration_ui: !no_config_ui)
25
26
  project
26
27
  end
27
28
  end
@@ -14,21 +14,16 @@ module Script
14
14
  end
15
15
  end
16
16
 
17
- class InvalidConfigUiDefinitionError < ScriptProjectError
18
- attr_reader :filename
19
- def initialize(filename)
17
+ class MissingScriptJsonFieldError < ScriptProjectError
18
+ attr_reader :field
19
+ def initialize(field)
20
20
  super()
21
- @filename = filename
21
+ @field = field
22
22
  end
23
23
  end
24
24
 
25
- class MissingSpecifiedConfigUiDefinitionError < ScriptProjectError
26
- attr_reader :filename
27
- def initialize(filename)
28
- super()
29
- @filename = filename
30
- end
31
- end
25
+ class InvalidScriptJsonDefinitionError < ScriptProjectError; end
26
+ class NoScriptJsonFile < ScriptProjectError; end
32
27
 
33
28
  class ScriptNotFoundError < ScriptProjectError
34
29
  attr_reader :script_name, :extension_point_type
@@ -7,8 +7,7 @@ module Script
7
7
  attr_reader :id,
8
8
  :uuid,
9
9
  :extension_point_type,
10
- :script_name,
11
- :config_ui,
10
+ :script_json,
12
11
  :script_content,
13
12
  :compiled_type,
14
13
  :metadata
@@ -17,33 +16,30 @@ module Script
17
16
  id:,
18
17
  uuid:,
19
18
  extension_point_type:,
20
- script_name:,
21
19
  script_content:,
22
20
  compiled_type:,
23
21
  metadata:,
24
- config_ui:
22
+ script_json:
25
23
  )
26
24
  @id = id
27
25
  @uuid = uuid
28
26
  @extension_point_type = extension_point_type
29
- @script_name = script_name
30
27
  @script_content = script_content
31
28
  @compiled_type = compiled_type
32
29
  @metadata = metadata
33
- @config_ui = config_ui
30
+ @script_json = script_json
34
31
  end
35
32
 
36
33
  def push(script_service, api_key, force)
37
34
  script_service.push(
38
35
  uuid: @uuid,
39
36
  extension_point_type: @extension_point_type,
40
- script_name: @script_name,
41
37
  script_content: @script_content,
42
38
  compiled_type: @compiled_type,
43
39
  api_key: api_key,
44
40
  force: force,
45
41
  metadata: @metadata,
46
- config_ui: @config_ui,
42
+ script_json: @script_json,
47
43
  )
48
44
  end
49
45
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Script
4
+ module Layers
5
+ module Domain
6
+ class ScriptJson
7
+ attr_reader :content, :version, :title, :description, :configuration_ui, :configuration
8
+
9
+ REQUIRED_FIELDS = %w(version title)
10
+
11
+ def initialize(content:)
12
+ validate_content!(content)
13
+
14
+ @content = content
15
+ @version = @content["version"].to_s
16
+ @title = @content["title"]
17
+ @description = @content["description"]
18
+ @configuration_ui = @content["configurationUi"]
19
+ @configuration = @content["configuration"]
20
+ end
21
+
22
+ private
23
+
24
+ def validate_content!(content)
25
+ REQUIRED_FIELDS.each do |field|
26
+ raise Errors::MissingScriptJsonFieldError, field if content[field].nil?
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -15,7 +15,7 @@ module Script
15
15
  property! :script_name, accepts: String
16
16
  property! :language, accepts: String
17
17
 
18
- property :config_ui, accepts: ConfigUi
18
+ property :script_json, accepts: ScriptJson
19
19
 
20
20
  def initialize(*)
21
21
  super
@@ -6,40 +6,36 @@ module Script
6
6
  module Errors
7
7
  class AppNotInstalledError < ScriptProjectError; end
8
8
  class BuildError < ScriptProjectError; end
9
- class ConfigUiSyntaxError < ScriptProjectError; end
9
+ class ScriptJsonSyntaxError < ScriptProjectError; end
10
10
 
11
- class ConfigUiMissingKeysError < ScriptProjectError
12
- attr_reader :filename, :missing_keys
13
- def initialize(filename, missing_keys)
11
+ class ScriptJsonMissingKeysError < ScriptProjectError
12
+ attr_reader :missing_keys
13
+ def initialize(missing_keys)
14
14
  super()
15
- @filename = filename
16
15
  @missing_keys = missing_keys
17
16
  end
18
17
  end
19
18
 
20
- class ConfigUiInvalidInputModeError < ScriptProjectError
21
- attr_reader :filename, :valid_input_modes
22
- def initialize(filename, valid_input_modes)
19
+ class ScriptJsonInvalidValueError < ScriptProjectError
20
+ attr_reader :valid_input_modes
21
+ def initialize(valid_input_modes)
23
22
  super()
24
- @filename = filename
25
23
  @valid_input_modes = valid_input_modes
26
24
  end
27
25
  end
28
26
 
29
- class ConfigUiFieldsMissingKeysError < ScriptProjectError
30
- attr_reader :filename, :missing_keys
31
- def initialize(filename, missing_keys)
27
+ class ScriptJsonFieldsMissingKeysError < ScriptProjectError
28
+ attr_reader :missing_keys
29
+ def initialize(missing_keys)
32
30
  super()
33
- @filename = filename
34
31
  @missing_keys = missing_keys
35
32
  end
36
33
  end
37
34
 
38
- class ConfigUiFieldsInvalidTypeError < ScriptProjectError
39
- attr_reader :filename, :valid_types
40
- def initialize(filename, valid_types)
35
+ class ScriptJsonFieldsInvalidValueError < ScriptProjectError
36
+ attr_reader :valid_types
37
+ def initialize(valid_types)
41
38
  super()
42
- @filename = filename
43
39
  @valid_types = valid_types
44
40
  end
45
41
  end
@@ -45,27 +45,20 @@ module Script
45
45
  end
46
46
 
47
47
  def write_package_json
48
- package_json = <<~HERE
49
- {
50
- "name": "#{script_name}",
51
- "version": "1.0.0",
52
- "devDependencies": {
53
- "@shopify/scripts-sdk-as": "#{extension_point.sdks.assemblyscript.sdk_version}",
54
- "@shopify/scripts-toolchain-as": "#{extension_point.sdks.assemblyscript.toolchain_version}",
55
- "#{extension_point.sdks.assemblyscript.package}": "#{extension_point_version}",
56
- "@as-pect/cli": "^6.0.0",
57
- "assemblyscript": "^0.18.13"
58
- },
59
- "scripts": {
60
- "test": "asp --summary --verbose",
61
- "build": "#{build_command}"
62
- },
63
- "engines": {
64
- "node": ">=#{MIN_NODE_VERSION}"
65
- }
66
- }
67
- HERE
68
- ctx.write("package.json", package_json)
48
+ package_json = {
49
+ name: script_name,
50
+ version: "1.0.0",
51
+ devDependencies: dev_dependencies,
52
+ scripts: {
53
+ test: "asp --summary --verbose",
54
+ build: build_command,
55
+ },
56
+ engines: {
57
+ node: ">=#{MIN_NODE_VERSION}",
58
+ },
59
+ }
60
+
61
+ ctx.write("package.json", JSON.pretty_generate(package_json))
69
62
  end
70
63
 
71
64
  def bootstap_command
@@ -90,6 +83,21 @@ module Script
90
83
  "#{BUILD} --domain #{domain} --ep #{type} #{ASC_ARGS}"
91
84
  end
92
85
  end
86
+
87
+ def dev_dependencies
88
+ dependencies = {
89
+ "@as-pect/cli": "^6.0.0",
90
+ "assemblyscript": "^0.18.13",
91
+ "@shopify/scripts-toolchain-as": extension_point.sdks.assemblyscript.toolchain_version,
92
+ "#{extension_point.sdks.assemblyscript.package}": extension_point_version,
93
+ }
94
+
95
+ if extension_point.sdks.assemblyscript.sdk_version
96
+ dependencies["@shopify/scripts-sdk-as"] = extension_point.sdks.assemblyscript.sdk_version
97
+ end
98
+
99
+ dependencies
100
+ end
93
101
  end
94
102
  end
95
103
  end
@@ -15,11 +15,10 @@ module Script
15
15
  id: build_file_path,
16
16
  uuid: script_project.uuid,
17
17
  extension_point_type: script_project.extension_point_type,
18
- script_name: script_project.script_name,
19
18
  script_content: script_content,
20
19
  compiled_type: compiled_type,
21
20
  metadata: metadata,
22
- config_ui: script_project.config_ui,
21
+ script_json: script_project.script_json,
23
22
  )
24
23
  end
25
24
 
@@ -32,11 +31,10 @@ module Script
32
31
  id: build_file_path,
33
32
  uuid: script_project.uuid,
34
33
  extension_point_type: script_project.extension_point_type,
35
- script_name: script_project.script_name,
36
34
  script_content: script_content,
37
35
  compiled_type: compiled_type,
38
36
  metadata: metadata,
39
- config_ui: script_project.config_ui,
37
+ script_json: script_project.script_json,
40
38
  )
41
39
  end
42
40
 
@@ -7,24 +7,19 @@ module Script
7
7
  include SmartProperties
8
8
  property! :ctx, accepts: ShopifyCli::Context
9
9
 
10
- DEFAULT_CONFIG_UI_FILENAME = "config-ui.yml"
10
+ SCRIPT_JSON_FILENAME = "script.json"
11
11
  MUTABLE_ENV_VALUES = %i(uuid)
12
12
 
13
- def create(script_name:, extension_point_type:, language:, no_config_ui:)
13
+ def create(script_name:, extension_point_type:, language:)
14
14
  validate_metadata!(extension_point_type, language)
15
15
 
16
- config_ui_file = nil
17
- optional_identifiers = {}
18
- optional_identifiers.merge!(config_ui_file: DEFAULT_CONFIG_UI_FILENAME) unless no_config_ui
19
-
20
16
  ShopifyCli::Project.write(
21
17
  ctx,
22
18
  project_type: :script,
23
19
  organization_id: nil,
24
20
  extension_point_type: extension_point_type,
25
21
  script_name: script_name,
26
- language: language,
27
- **optional_identifiers
22
+ language: language
28
23
  )
29
24
 
30
25
  Domain::ScriptProject.new(
@@ -32,23 +27,20 @@ module Script
32
27
  env: project.env,
33
28
  script_name: script_name,
34
29
  extension_point_type: extension_point_type,
35
- language: language,
36
- config_ui: config_ui_file
30
+ language: language
37
31
  )
38
32
  end
39
33
 
40
34
  def get
41
35
  validate_metadata!(extension_point_type, language)
42
36
 
43
- config_ui = ConfigUiRepository.new(ctx: ctx).get(config_ui_file)
44
-
45
37
  Domain::ScriptProject.new(
46
38
  id: project.directory,
47
39
  env: project.env,
48
40
  script_name: script_name,
49
41
  extension_point_type: extension_point_type,
50
42
  language: language,
51
- config_ui: config_ui
43
+ script_json: ScriptJsonRepository.new(ctx: ctx).get
52
44
  )
53
45
  end
54
46
 
@@ -66,7 +58,7 @@ module Script
66
58
  script_name: script_name,
67
59
  extension_point_type: extension_point_type,
68
60
  language: language,
69
- config_ui: ConfigUiRepository.new(ctx: ctx).get(config_ui_file),
61
+ script_json: ScriptJsonRepository.new(ctx: ctx).get,
70
62
  )
71
63
  end
72
64
 
@@ -85,7 +77,22 @@ module Script
85
77
  script_name: script_name,
86
78
  extension_point_type: extension_point_type,
87
79
  language: language,
88
- config_ui: ConfigUiRepository.new(ctx: ctx).get(config_ui_file),
80
+ script_json: ScriptJsonRepository.new(ctx: ctx).get,
81
+ )
82
+ end
83
+
84
+ def update_or_create_script_json(title:, configuration_ui: false)
85
+ script_json = ScriptJsonRepository
86
+ .new(ctx: ctx)
87
+ .update_or_create(title: title, configuration_ui: configuration_ui)
88
+
89
+ Domain::ScriptProject.new(
90
+ id: ctx.root,
91
+ env: project.env,
92
+ script_name: script_name,
93
+ extension_point_type: extension_point_type,
94
+ language: language,
95
+ script_json: script_json,
89
96
  )
90
97
  end
91
98
 
@@ -103,10 +110,6 @@ module Script
103
110
  project_config_value!("script_name")
104
111
  end
105
112
 
106
- def config_ui_file
107
- project_config_value("config_ui_file")
108
- end
109
-
110
113
  def language
111
114
  project_config_value("language")&.downcase || default_language
112
115
  end
@@ -137,32 +140,40 @@ module Script
137
140
  end
138
141
  end
139
142
 
140
- class ConfigUiRepository
143
+ class ScriptJsonRepository
141
144
  include SmartProperties
142
145
  property! :ctx, accepts: ShopifyCli::Context
143
146
 
144
- def get(filename)
145
- return nil unless filename
147
+ def get
148
+ current_script_json || raise(Domain::Errors::NoScriptJsonFile)
149
+ end
146
150
 
147
- path = File.join(ctx.root, filename)
148
- raise Domain::Errors::MissingSpecifiedConfigUiDefinitionError, filename unless File.exist?(path)
151
+ def update_or_create(title:, configuration_ui:)
152
+ json = current_script_json&.content || {}
153
+ json["version"] ||= "1"
154
+ json["title"] = title
155
+ json["configurationUi"] = !!configuration_ui
149
156
 
150
- content = File.read(path)
151
- raise Domain::Errors::InvalidConfigUiDefinitionError, filename unless valid_config_ui?(content)
157
+ ctx.write(SCRIPT_JSON_FILENAME, JSON.pretty_generate(json))
152
158
 
153
- Domain::ConfigUi.new(
154
- filename: filename,
155
- content: content,
156
- )
159
+ Domain::ScriptJson.new(content: json)
157
160
  end
158
161
 
159
162
  private
160
163
 
161
- def valid_config_ui?(raw_yaml)
162
- require "yaml" # takes 20ms, so deferred as late as possible.
163
- YAML.safe_load(raw_yaml)
164
+ def current_script_json
165
+ return nil unless ctx.file_exist?(SCRIPT_JSON_FILENAME)
166
+
167
+ content = ctx.read(SCRIPT_JSON_FILENAME)
168
+ raise Domain::Errors::InvalidScriptJsonDefinitionError unless valid_script_json?(content)
169
+
170
+ Domain::ScriptJson.new(content: JSON.parse(content))
171
+ end
172
+
173
+ def valid_script_json?(content)
174
+ JSON.parse(content)
164
175
  true
165
- rescue Psych::SyntaxError
176
+ rescue JSON::ParserError
166
177
  false
167
178
  end
168
179
  end
@@ -13,26 +13,28 @@ module Script
13
13
  def push(
14
14
  uuid:,
15
15
  extension_point_type:,
16
- script_name:,
17
16
  script_content:,
18
17
  compiled_type:,
19
18
  api_key: nil,
20
19
  force: false,
21
20
  metadata:,
22
- config_ui:
21
+ script_json:
23
22
  )
24
23
  query_name = "app_script_update_or_create"
25
24
  variables = {
26
25
  uuid: uuid,
27
26
  extensionPointName: extension_point_type.upcase,
28
- title: script_name,
29
- configUi: config_ui&.content,
27
+ title: script_json.title,
28
+ description: script_json.description,
30
29
  sourceCode: Base64.encode64(script_content),
31
30
  language: compiled_type,
32
31
  force: force,
33
32
  schemaMajorVersion: metadata.schema_major_version.to_s, # API expects string value
34
33
  schemaMinorVersion: metadata.schema_minor_version.to_s, # API expects string value
35
34
  useMsgpack: metadata.use_msgpack,
35
+ scriptJsonVersion: script_json.version,
36
+ configurationUi: script_json.configuration_ui,
37
+ configurationDefinition: script_json.configuration&.to_json,
36
38
  }
37
39
  resp_hash = script_service_request(query_name: query_name, api_key: api_key, variables: variables)
38
40
  user_errors = resp_hash["data"]["appScriptUpdateOrCreate"]["userErrors"]
@@ -41,16 +43,20 @@ module Script
41
43
 
42
44
  if user_errors.any? { |e| e["tag"] == "already_exists_error" }
43
45
  raise Errors::ScriptRepushError, uuid
44
- elsif (e = user_errors.any? { |err| err["tag"] == "config_ui_syntax_error" })
45
- raise Errors::ConfigUiSyntaxError, config_ui&.filename
46
- elsif (e = user_errors.find { |err| err["tag"] == "config_ui_missing_keys_error" })
47
- raise Errors::ConfigUiMissingKeysError.new(config_ui&.filename, e["message"])
48
- elsif (e = user_errors.find { |err| err["tag"] == "config_ui_invalid_input_mode_error" })
49
- raise Errors::ConfigUiInvalidInputModeError.new(config_ui&.filename, e["message"])
50
- elsif (e = user_errors.find { |err| err["tag"] == "config_ui_fields_missing_keys_error" })
51
- raise Errors::ConfigUiFieldsMissingKeysError.new(config_ui&.filename, e["message"])
52
- elsif (e = user_errors.find { |err| err["tag"] == "config_ui_fields_invalid_type_error" })
53
- raise Errors::ConfigUiFieldsInvalidTypeError.new(config_ui&.filename, e["message"])
46
+ elsif (e = user_errors.any? { |err| err["tag"] == "configuration_syntax_error" })
47
+ raise Errors::ScriptJsonSyntaxError
48
+ elsif (e = user_errors.find { |err| err["tag"] == "configuration_definition_missing_keys_error" })
49
+ raise Errors::ScriptJsonMissingKeysError, e["message"]
50
+ elsif (e = user_errors.find { |err| err["tag"] == "configuration_definition_invalid_value_error" })
51
+ raise Errors::ScriptJsonInvalidValueError, e["message"]
52
+ elsif (e = user_errors.find do |err|
53
+ err["tag"] == "configuration_definition_schema_field_missing_keys_error"
54
+ end)
55
+ raise Errors::ScriptJsonFieldsMissingKeysError, e["message"]
56
+ elsif (e = user_errors.find do |err|
57
+ err["tag"] == "configuration_definition_schema_field_invalid_value_error"
58
+ end)
59
+ raise Errors::ScriptJsonFieldsInvalidValueError, e["message"]
54
60
  elsif user_errors.find { |err| %w(not_use_msgpack_error schema_version_argument_error).include?(err["tag"]) }
55
61
  raise Domain::Errors::MetadataValidationError
56
62
  else
@@ -51,30 +51,33 @@ module Script
51
51
  invalid_config: "Can't change the configuration values because %1$s is missing or "\
52
52
  "it is not formatted properly.",
53
53
 
54
- invalid_config_ui_definition_cause: "The UI configuration file %s contains invalid YAML.",
55
- invalid_config_ui_definition_help: "Fix the errors and try again.",
54
+ missing_script_json_field_cause: "The script.json file is missing the required %s field.",
55
+ missing_script_json_field_help: "Add the field and try again.",
56
56
 
57
- missing_config_ui_definition_cause: "You are missing the UI configuration file %s.",
58
- missing_config_ui_definition_help: "Create this file and try again.",
57
+ invalid_script_json_definition_cause: "The script.json file contains invalid JSON.",
58
+ invalid_script_json_definition_help: "Fix the errors and try again.",
59
59
 
60
- config_ui_syntax_error_cause: "The UI configuration file %{filename} is not formatted properly.",
61
- config_ui_syntax_error_help: "Fix the errors and try again.",
60
+ no_script_json_file_cause: "You are missing the required script.json file.",
61
+ no_script_json_file_help: "Create this file and try again.",
62
62
 
63
- config_ui_missing_keys_error_cause: "The UI configuration file %{filename} is missing required keys: "\
63
+ configuration_syntax_error_cause: "The script.json configuration schema is not formatted properly.",
64
+ configuration_syntax_error_help: "Fix the errors and try again.",
65
+
66
+ configuration_missing_keys_error_cause: "The script.json configuration schema is missing required keys: "\
64
67
  "%{missing_keys}.",
65
- config_ui_missing_keys_error_help: "Add the keys and try again.",
68
+ configuration_missing_keys_error_help: "Add the keys and try again.",
66
69
 
67
- config_ui_invalid_input_mode_error_cause: "The UI configuration file %{filename} only accept "\
68
- "one of the following input mode(s): %{valid_input_modes}.",
69
- config_ui_invalid_input_mode_error_help: "Change the input modes and try again.",
70
+ configuration_invalid_value_error_cause: "The script.json configuration only accepts "\
71
+ "one of the following types(s): %{valid_input_modes}.",
72
+ configuration_invalid_value_error_help: "Change the type and try again.",
70
73
 
71
- config_ui_fields_missing_keys_error_cause: "A field entry in the UI configuration file %{filename} is "\
72
- "missing required keys: %{missing_keys}.",
73
- config_ui_fields_missing_keys_error_help: "Add the keys and try again.",
74
+ configuration_schema_field_missing_keys_error_cause: "A field entry in the script.json configuration "\
75
+ "schema is missing required keys: %{missing_keys}.",
76
+ configuration_definition_schema_field_missing_keys_error_help: "Add the keys and try again.",
74
77
 
75
- config_ui_fields_invalid_type_error_cause: "The UI configuration file %{filename} fields only accept "\
76
- "one of the following type(s): %{valid_types}.",
77
- config_ui_fields_invalid_type_error_help: "Change the types and try again.",
78
+ configuration_schema_field_invalid_value_error_cause: "The script.json configuration schema fields only "\
79
+ "accept one of the following type(s): %{valid_types}.",
80
+ configuration_schema_field_invalid_value_error_help: "Change the types and try again.",
78
81
 
79
82
  script_not_found_cause: "Couldn't find script %s for extension point %s",
80
83
 
@@ -11,7 +11,7 @@ module Script
11
11
  script_project_repo = Layers::Infrastructure::ScriptProjectRepository.new(ctx: ctx)
12
12
  script_project = script_project_repo.get
13
13
 
14
- return if script_project.api_key && script_project.api_secret && script_project.uuid_defined?
14
+ return false if script_project.api_key && script_project.api_secret && script_project.uuid_defined?
15
15
 
16
16
  org = ask_org
17
17
  app = ask_app(org["apps"])
@@ -22,6 +22,8 @@ module Script
22
22
  secret: app["apiSecretKeys"].first["secret"],
23
23
  uuid: uuid
24
24
  )
25
+
26
+ true
25
27
  end
26
28
 
27
29
  private
@@ -120,17 +120,20 @@ module Script
120
120
  cause_of_error: ShopifyCli::Context.message("script.error.metadata_not_found_cause"),
121
121
  help_suggestion: ShopifyCli::Context.message("script.error.metadata_not_found_help"),
122
122
  }
123
- when Layers::Domain::Errors::InvalidConfigUiDefinitionError
123
+ when Layers::Domain::Errors::MissingScriptJsonFieldError
124
124
  {
125
- cause_of_error: ShopifyCli::Context
126
- .message("script.error.invalid_config_ui_definition_cause", e.filename),
127
- help_suggestion: ShopifyCli::Context.message("script.error.invalid_config_ui_definition_help"),
125
+ cause_of_error: ShopifyCli::Context.message("script.error.missing_script_json_field_cause", e.field),
126
+ help_suggestion: ShopifyCli::Context.message("script.error.missing_script_json_field_help"),
128
127
  }
129
- when Layers::Domain::Errors::MissingSpecifiedConfigUiDefinitionError
128
+ when Layers::Domain::Errors::InvalidScriptJsonDefinitionError
130
129
  {
131
- cause_of_error: ShopifyCli::Context
132
- .message("script.error.missing_config_ui_definition_cause", e.filename),
133
- help_suggestion: ShopifyCli::Context.message("script.error.missing_config_ui_definition_help"),
130
+ cause_of_error: ShopifyCli::Context.message("script.error.invalid_script_json_definition_cause"),
131
+ help_suggestion: ShopifyCli::Context.message("script.error.invalid_script_json_definition_help"),
132
+ }
133
+ when Layers::Domain::Errors::NoScriptJsonFile
134
+ {
135
+ cause_of_error: ShopifyCli::Context.message("script.error.no_script_json_file_cause"),
136
+ help_suggestion: ShopifyCli::Context.message("script.error.no_script_json_file_help"),
134
137
  }
135
138
  when Layers::Infrastructure::Errors::AppNotInstalledError
136
139
  {
@@ -141,49 +144,46 @@ module Script
141
144
  cause_of_error: ShopifyCli::Context.message("script.error.build_error_cause"),
142
145
  help_suggestion: ShopifyCli::Context.message("script.error.build_error_help"),
143
146
  }
144
- when Layers::Infrastructure::Errors::ConfigUiSyntaxError
147
+ when Layers::Infrastructure::Errors::ScriptJsonSyntaxError
145
148
  {
146
- cause_of_error: ShopifyCli::Context.message(
147
- "script.error.config_ui_syntax_error_cause",
148
- filename: e.message
149
- ),
150
- help_suggestion: ShopifyCli::Context.message("script.error.config_ui_syntax_error_help"),
149
+ cause_of_error: ShopifyCli::Context.message("script.error.configuration_syntax_error_cause"),
150
+ help_suggestion: ShopifyCli::Context.message("script.error.configuration_syntax_error_help"),
151
151
  }
152
- when Layers::Infrastructure::Errors::ConfigUiMissingKeysError
152
+ when Layers::Infrastructure::Errors::ScriptJsonMissingKeysError
153
153
  {
154
154
  cause_of_error: ShopifyCli::Context.message(
155
- "script.error.config_ui_missing_keys_error_cause",
156
- filename: e.filename,
155
+ "script.error.configuration_missing_keys_error_cause",
157
156
  missing_keys: e.missing_keys
158
157
  ),
159
- help_suggestion: ShopifyCli::Context.message("script.error.config_ui_missing_keys_error_help"),
158
+ help_suggestion: ShopifyCli::Context.message("script.error.configuration_missing_keys_error_help"),
160
159
  }
161
- when Layers::Infrastructure::Errors::ConfigUiInvalidInputModeError
160
+ when Layers::Infrastructure::Errors::ScriptJsonInvalidValueError
162
161
  {
163
162
  cause_of_error: ShopifyCli::Context.message(
164
- "script.error.config_ui_invalid_input_mode_error_cause",
165
- filename: e.filename,
163
+ "script.error.configuration_invalid_value_error_cause",
166
164
  valid_input_modes: e.valid_input_modes
167
165
  ),
168
- help_suggestion: ShopifyCli::Context.message("script.error.config_ui_invalid_input_mode_error_help"),
166
+ help_suggestion: ShopifyCli::Context.message("script.error.configuration_invalid_value_error_help"),
169
167
  }
170
- when Layers::Infrastructure::Errors::ConfigUiFieldsMissingKeysError
168
+ when Layers::Infrastructure::Errors::ScriptJsonFieldsMissingKeysError
171
169
  {
172
170
  cause_of_error: ShopifyCli::Context.message(
173
- "script.error.config_ui_fields_missing_keys_error_cause",
174
- filename: e.filename,
171
+ "script.error.configuration_schema_field_missing_keys_error_cause",
175
172
  missing_keys: e.missing_keys
176
173
  ),
177
- help_suggestion: ShopifyCli::Context.message("script.error.config_ui_fields_missing_keys_error_help"),
174
+ help_suggestion: ShopifyCli::Context.message(
175
+ "script.error.configuration_definition_schema_field_missing_keys_error_help"
176
+ ),
178
177
  }
179
- when Layers::Infrastructure::Errors::ConfigUiFieldsInvalidTypeError
178
+ when Layers::Infrastructure::Errors::ScriptJsonFieldsInvalidValueError
180
179
  {
181
180
  cause_of_error: ShopifyCli::Context.message(
182
- "script.error.config_ui_fields_invalid_type_error_cause",
183
- filename: e.filename,
181
+ "script.error.configuration_schema_field_invalid_value_error_cause",
184
182
  valid_types: e.valid_types
185
183
  ),
186
- help_suggestion: ShopifyCli::Context.message("script.error.config_ui_fields_invalid_type_error_help"),
184
+ help_suggestion: ShopifyCli::Context.message(
185
+ "script.error.configuration_schema_field_invalid_value_error_help"
186
+ ),
187
187
  }
188
188
  when Layers::Infrastructure::Errors::DependencyInstallError
189
189
  {
@@ -144,6 +144,19 @@ module ShopifyCli
144
144
  File.write(ctx_path(fname), content)
145
145
  end
146
146
 
147
+ # will read a file relative to the context root unless the file path is absolute.
148
+ #
149
+ # #### Parameters
150
+ # * `fname` - filename of the file that you are reading, relative to root unless it is absolute.
151
+ #
152
+ # #### Example
153
+ #
154
+ # @ctx.read('file.txt')
155
+ #
156
+ def read(fname)
157
+ File.read(ctx_path(fname))
158
+ end
159
+
147
160
  # will read a binary file relative to the context root unless the file path is absolute.
148
161
  #
149
162
  # #### Parameters
@@ -1,3 +1,3 @@
1
1
  module ShopifyCli
2
- VERSION = "1.13.1"
2
+ VERSION = "1.14.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.1
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-14 00:00:00.000000000 Z
11
+ date: 2021-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -227,11 +227,11 @@ files:
227
227
  - lib/project_types/script/layers/application/extension_points.rb
228
228
  - lib/project_types/script/layers/application/project_dependencies.rb
229
229
  - lib/project_types/script/layers/application/push_script.rb
230
- - lib/project_types/script/layers/domain/config_ui.rb
231
230
  - lib/project_types/script/layers/domain/errors.rb
232
231
  - lib/project_types/script/layers/domain/extension_point.rb
233
232
  - lib/project_types/script/layers/domain/metadata.rb
234
233
  - lib/project_types/script/layers/domain/push_package.rb
234
+ - lib/project_types/script/layers/domain/script_json.rb
235
235
  - lib/project_types/script/layers/domain/script_project.rb
236
236
  - lib/project_types/script/layers/infrastructure/command_runner.rb
237
237
  - lib/project_types/script/layers/infrastructure/errors.rb
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Script
4
- module Layers
5
- module Domain
6
- class ConfigUi
7
- attr_reader :filename, :content
8
-
9
- def initialize(filename:, content:)
10
- @filename = filename
11
- @content = content
12
- end
13
- end
14
- end
15
- end
16
- end