shopify-cli 0.9.1 → 0.9.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 +3 -0
- data/CHANGELOG.md +5 -0
- data/RELEASING.md +4 -4
- data/lib/project_types/script/cli.rb +2 -3
- data/lib/project_types/script/commands/push.rb +1 -0
- data/lib/project_types/script/layers/application/build_script.rb +7 -10
- data/lib/project_types/script/layers/application/create_script.rb +16 -7
- data/lib/project_types/script/layers/application/project_dependencies.rb +3 -4
- data/lib/project_types/script/layers/application/push_script.rb +13 -11
- data/lib/project_types/script/layers/infrastructure/assemblyscript_dependency_manager.rb +0 -22
- data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +64 -0
- data/lib/project_types/script/layers/infrastructure/errors.rb +1 -1
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +5 -2
- data/lib/project_types/script/layers/infrastructure/script_repository.rb +9 -6
- data/lib/project_types/script/layers/infrastructure/task_runner.rb +18 -0
- data/lib/project_types/script/layers/infrastructure/test_suite_repository.rb +6 -3
- data/lib/project_types/script/script_project.rb +22 -9
- data/lib/shopify-cli/api.rb +2 -0
- data/lib/shopify-cli/context.rb +51 -0
- data/lib/shopify-cli/git.rb +14 -10
- data/lib/shopify-cli/messages/messages.rb +8 -2
- data/lib/shopify-cli/version.rb +1 -1
- metadata +4 -4
- data/lib/project_types/script/layers/infrastructure/assemblyscript_wasm_builder.rb +0 -39
- data/lib/project_types/script/layers/infrastructure/script_builder.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2b12fdb1aec476c1b05eee2e33817d3636f76927d4cdc5700347344b687e28d
|
4
|
+
data.tar.gz: 83411b72925dbe120a4c89fa1d715f3fe61a7596ed4d356f03b537ea6bb31481
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3557bcc2a93f0775a294b0c2d1c784949e84602155de21d3d3db89237ae7e50bbf3ba591bdc329ca6074ae27178444c6c939cd42ac361dcb5a9d50a9de4e8567
|
7
|
+
data.tar.gz: 78ebf53316d6bebf24bb04832a5b052512d46df48f9f71cc3f388305c6210cd0ec32b2f1ba9151cd80d8199a26142c8684775f93198d7d9b61bf1291d1d39732
|
data/.github/CODEOWNERS
CHANGED
data/CHANGELOG.md
CHANGED
data/RELEASING.md
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
|
14
14
|
5. Commit the changes with a commit message like "Packaging for release X.Y.Z"
|
15
15
|
```
|
16
|
-
$ git commit -am "Packaging for release
|
16
|
+
$ git commit -am "Packaging for release vX.Y.Z"
|
17
17
|
```
|
18
18
|
|
19
19
|
6. Push out the changes
|
@@ -21,7 +21,7 @@
|
|
21
21
|
$ git push -u origin release_X_Y_Z
|
22
22
|
```
|
23
23
|
|
24
|
-
7. Open a PR for the branch, get necessary approvals from code owners and merge into main branch
|
24
|
+
7. Open a PR for the branch, get necessary approvals from code owners and merge into main branch. Note that the PR title will be the release note in Shipit, so make sure it mentions the release
|
25
25
|
|
26
26
|
8. Deploy using Shipit
|
27
27
|
|
@@ -34,8 +34,8 @@
|
|
34
34
|
10. Clone the `Shopify/homebrew-shopify` repository (if not already cloned), and then
|
35
35
|
* create a branch named `release_X_Y_Z_of_shopify-cli`
|
36
36
|
* update the brew formula in `shopify-cli.rb` with the generated formula in `packaging/builds/X.Y.Z/` in the `Shopify/shopify-app-cli` repo (from step 9)
|
37
|
-
* commit the change and create a PR
|
38
|
-
* when PR is approved, merge into main branch
|
37
|
+
* commit the change and create a PR on the [Shopify Homebrew repository](https://github.com/Shopify/homebrew-shopify)
|
38
|
+
* when PR is approved, merge into main branch
|
39
39
|
|
40
40
|
11. Go to [releases](https://github.com/Shopify/shopify-app-cli/releases) page of `Shopify/shopify-app-cli` repo and create a new release:
|
41
41
|
* use the tag created in step 8 by Shipit (should be "vX.Y.Z")
|
@@ -51,15 +51,14 @@ module Script
|
|
51
51
|
autoload :Errors, Project.project_filepath('layers/infrastructure/errors')
|
52
52
|
autoload :AssemblyScriptDependencyManager,
|
53
53
|
Project.project_filepath('layers/infrastructure/assemblyscript_dependency_manager')
|
54
|
+
autoload :AssemblyScriptTaskRunner, Project.project_filepath('layers/infrastructure/assemblyscript_task_runner')
|
54
55
|
autoload :AssemblyScriptTsConfig, Project.project_filepath('layers/infrastructure/assemblyscript_tsconfig')
|
55
|
-
autoload :AssemblyScriptWasmBuilder,
|
56
|
-
Project.project_filepath('layers/infrastructure/assemblyscript_wasm_builder')
|
57
56
|
autoload :DependencyManager, Project.project_filepath('layers/infrastructure/dependency_manager')
|
58
57
|
autoload :PushPackageRepository, Project.project_filepath('layers/infrastructure/push_package_repository')
|
59
58
|
autoload :ExtensionPointRepository, Project.project_filepath('layers/infrastructure/extension_point_repository')
|
60
|
-
autoload :ScriptBuilder, Project.project_filepath('layers/infrastructure/script_builder')
|
61
59
|
autoload :ScriptRepository, Project.project_filepath('layers/infrastructure/script_repository')
|
62
60
|
autoload :ScriptService, Project.project_filepath('layers/infrastructure/script_service')
|
61
|
+
autoload :TaskRunner, Project.project_filepath('layers/infrastructure/task_runner')
|
63
62
|
autoload :TestSuiteRepository, Project.project_filepath('layers/infrastructure/test_suite_repository')
|
64
63
|
end
|
65
64
|
end
|
@@ -5,11 +5,11 @@ module Script
|
|
5
5
|
module Application
|
6
6
|
class BuildScript
|
7
7
|
class << self
|
8
|
-
def call(ctx:, script:)
|
8
|
+
def call(ctx:, task_runner:, script:)
|
9
9
|
return if CLI::UI::Frame.open(ctx.message('script.application.building')) do
|
10
10
|
begin
|
11
11
|
UI::StrictSpinner.spin(ctx.message('script.application.building_script')) do |spinner|
|
12
|
-
build(script)
|
12
|
+
build(ctx, task_runner, script)
|
13
13
|
spinner.update_title(ctx.message('script.application.built'))
|
14
14
|
end
|
15
15
|
true
|
@@ -25,16 +25,13 @@ module Script
|
|
25
25
|
|
26
26
|
private
|
27
27
|
|
28
|
-
def build(script)
|
29
|
-
script_repo = Infrastructure::ScriptRepository.new
|
30
|
-
script_builder = Infrastructure::ScriptBuilder.for(script)
|
31
|
-
compiled_type = script_builder.compiled_type
|
28
|
+
def build(ctx, task_runner, script)
|
29
|
+
script_repo = Infrastructure::ScriptRepository.new(ctx: ctx)
|
32
30
|
script_content = script_repo.with_temp_build_context do
|
33
|
-
|
31
|
+
task_runner.build
|
34
32
|
end
|
35
|
-
|
36
|
-
|
37
|
-
.create_push_package(script, script_content, compiled_type)
|
33
|
+
Infrastructure::PushPackageRepository.new(ctx: ctx)
|
34
|
+
.create_push_package(script, script_content, task_runner.compiled_type)
|
38
35
|
end
|
39
36
|
end
|
40
37
|
end
|
@@ -9,15 +9,15 @@ module Script
|
|
9
9
|
class << self
|
10
10
|
def call(ctx:, language:, script_name:, extension_point_type:)
|
11
11
|
extension_point = ExtensionPoints.get(type: extension_point_type)
|
12
|
-
create_project(ctx,
|
12
|
+
project = create_project(ctx, script_name, extension_point)
|
13
|
+
install_dependencies(ctx, language, script_name, extension_point, project)
|
13
14
|
create_definition(ctx, language, extension_point, script_name)
|
14
15
|
end
|
15
16
|
|
16
17
|
private
|
17
18
|
|
18
|
-
def create_project(ctx,
|
19
|
-
ScriptProject.create(script_name)
|
20
|
-
ctx.root = File.join(ctx.root, script_name)
|
19
|
+
def create_project(ctx, script_name, extension_point)
|
20
|
+
ScriptProject.create(ctx, script_name)
|
21
21
|
ScriptProject.write(
|
22
22
|
ctx,
|
23
23
|
project_type: :script,
|
@@ -25,17 +25,26 @@ module Script
|
|
25
25
|
extension_point_type: extension_point.type,
|
26
26
|
script_name: script_name
|
27
27
|
)
|
28
|
+
ScriptProject.current
|
29
|
+
end
|
30
|
+
|
31
|
+
def install_dependencies(ctx, language, script_name, extension_point, project)
|
32
|
+
task_runner = Infrastructure::TaskRunner.for(ctx, language, script_name, project.source_file)
|
28
33
|
ProjectDependencies
|
29
34
|
.bootstrap(ctx: ctx, language: language, extension_point: extension_point, script_name: script_name)
|
30
35
|
ProjectDependencies
|
31
|
-
.install(ctx: ctx,
|
36
|
+
.install(ctx: ctx, task_runner: task_runner)
|
32
37
|
end
|
33
38
|
|
34
39
|
def create_definition(ctx, language, extension_point, script_name)
|
35
40
|
script = nil
|
36
41
|
UI::StrictSpinner.spin(ctx.message('script.create.creating')) do |spinner|
|
37
|
-
script = Infrastructure::ScriptRepository.new.create_script(
|
38
|
-
|
42
|
+
script = Infrastructure::ScriptRepository.new(ctx: ctx).create_script(
|
43
|
+
language,
|
44
|
+
extension_point,
|
45
|
+
script_name
|
46
|
+
)
|
47
|
+
Infrastructure::TestSuiteRepository.new(ctx: ctx).create_test_suite(script)
|
39
48
|
spinner.update_title(ctx.message('script.create.created'))
|
40
49
|
end
|
41
50
|
script
|
@@ -7,15 +7,14 @@ module Script
|
|
7
7
|
dep_manager.bootstrap
|
8
8
|
end
|
9
9
|
|
10
|
-
def self.install(ctx:,
|
11
|
-
dep_manager = Infrastructure::DependencyManager.for(ctx, language, extension_point, script_name)
|
10
|
+
def self.install(ctx:, task_runner:)
|
12
11
|
CLI::UI::Frame.open(ctx.message('script.project_deps.checking_with_npm')) do
|
13
12
|
begin
|
14
|
-
if
|
13
|
+
if task_runner.dependencies_installed?
|
15
14
|
ctx.puts(ctx.message('script.project_deps.none_required'))
|
16
15
|
else
|
17
16
|
UI::StrictSpinner.spin(ctx.message('script.project_deps.installing')) do |spinner|
|
18
|
-
|
17
|
+
task_runner.install_dependencies
|
19
18
|
spinner.update_title(ctx.message('script.project_deps.installed'))
|
20
19
|
end
|
21
20
|
end
|
@@ -5,21 +5,23 @@ module Script
|
|
5
5
|
module Application
|
6
6
|
class PushScript
|
7
7
|
class << self
|
8
|
-
def call(ctx:, language:, extension_point_type:, script_name:, api_key:, force:)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
def call(ctx:, language:, extension_point_type:, script_name:, source_file:, api_key:, force:)
|
9
|
+
script = Infrastructure::ScriptRepository.new(ctx: ctx).get_script(
|
10
|
+
language,
|
11
|
+
extension_point_type,
|
12
|
+
script_name
|
13
|
+
)
|
14
|
+
task_runner = Infrastructure::TaskRunner.for(ctx, language, script_name, source_file)
|
15
|
+
ProjectDependencies.install(ctx: ctx, task_runner: task_runner)
|
16
|
+
BuildScript.call(ctx: ctx, task_runner: task_runner, script: script)
|
17
|
+
push_script(ctx, task_runner, script, api_key, force)
|
15
18
|
end
|
16
19
|
|
17
20
|
private
|
18
21
|
|
19
|
-
def push_script(ctx, script, api_key, force)
|
20
|
-
|
21
|
-
|
22
|
-
.get_push_package(script, compiled_type)
|
22
|
+
def push_script(ctx, task_runner, script, api_key, force)
|
23
|
+
Infrastructure::PushPackageRepository.new(ctx: ctx)
|
24
|
+
.get_push_package(script, task_runner.compiled_type)
|
23
25
|
.push(Infrastructure::ScriptService.new(ctx: ctx), api_key, force)
|
24
26
|
ctx.puts(ctx.message('script.application.pushed'))
|
25
27
|
end
|
@@ -16,30 +16,8 @@ module Script
|
|
16
16
|
write_package_json
|
17
17
|
end
|
18
18
|
|
19
|
-
def installed?
|
20
|
-
# Assuming if node_modules folder exist at root of script folder, all deps are installed
|
21
|
-
Dir.exist?("node_modules")
|
22
|
-
end
|
23
|
-
|
24
|
-
def install
|
25
|
-
check_node_version!
|
26
|
-
|
27
|
-
output, status = @ctx.capture2e("npm", "install", "--no-audit", "--no-optional", "--loglevel error")
|
28
|
-
raise Errors::DependencyInstallError, output unless status.success?
|
29
|
-
end
|
30
|
-
|
31
19
|
private
|
32
20
|
|
33
|
-
def check_node_version!
|
34
|
-
output, status = @ctx.capture2e("node", "--version")
|
35
|
-
raise Errors::DependencyInstallError, output unless status.success?
|
36
|
-
|
37
|
-
version = Semantic::Version.new(output[1..-1])
|
38
|
-
unless version >= Semantic::Version.new("12.16.0")
|
39
|
-
raise Errors::DependencyInstallError, "Node version must be >= v12.16.0 Current version: #{output}."
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
21
|
def write_npmrc
|
44
22
|
@ctx.system(
|
45
23
|
'npm', '--userconfig', './.npmrc', 'config', 'set', '@shopify:registry', 'https://registry.npmjs.com'
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Layers
|
5
|
+
module Infrastructure
|
6
|
+
class AssemblyScriptTaskRunner
|
7
|
+
BYTECODE_FILE = "%{name}.wasm"
|
8
|
+
SCRIPT_SDK_BUILD = "npx --no-install shopify-scripts-build --src=../%{source} --binary=#{BYTECODE_FILE} "\
|
9
|
+
"-- --lib=../node_modules --validate --optimize"
|
10
|
+
|
11
|
+
attr_reader :ctx, :script_name, :script_source_file
|
12
|
+
|
13
|
+
def initialize(ctx, script_name, script_source_file)
|
14
|
+
@ctx = ctx
|
15
|
+
@script_name = script_name
|
16
|
+
@script_source_file = script_source_file
|
17
|
+
end
|
18
|
+
|
19
|
+
def build
|
20
|
+
compile
|
21
|
+
bytecode
|
22
|
+
end
|
23
|
+
|
24
|
+
def compiled_type
|
25
|
+
"wasm"
|
26
|
+
end
|
27
|
+
|
28
|
+
def install_dependencies
|
29
|
+
check_node_version!
|
30
|
+
|
31
|
+
output, status = ctx.capture2e("npm", "install", "--no-audit", "--no-optional", "--loglevel error")
|
32
|
+
raise Errors::DependencyInstallError, output unless status.success?
|
33
|
+
end
|
34
|
+
|
35
|
+
def dependencies_installed?
|
36
|
+
# Assuming if node_modules folder exist at root of script folder, all deps are installed
|
37
|
+
ctx.exist?("node_modules")
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def check_node_version!
|
43
|
+
output, status = @ctx.capture2e("node", "--version")
|
44
|
+
raise Errors::DependencyInstallError, output unless status.success?
|
45
|
+
|
46
|
+
require 'semantic/semantic'
|
47
|
+
version = ::Semantic::Version.new(output[1..-1])
|
48
|
+
unless version >= ::Semantic::Version.new("12.16.0")
|
49
|
+
raise Errors::DependencyInstallError, "Node version must be >= v12.16.0. Current version: #{output.strip}."
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def compile
|
54
|
+
out, status = ctx.capture2e(format(SCRIPT_SDK_BUILD, source: script_source_file, name: script_name))
|
55
|
+
raise Domain::Errors::ServiceFailureError, out unless status.success?
|
56
|
+
end
|
57
|
+
|
58
|
+
def bytecode
|
59
|
+
File.read(format(BYTECODE_FILE, name: script_name))
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -6,7 +6,6 @@ module Script
|
|
6
6
|
module Errors
|
7
7
|
class AppNotInstalledError < ScriptProjectError; end
|
8
8
|
class AppScriptUndefinedError < ScriptProjectError; end
|
9
|
-
class BuilderNotFoundError < ScriptProjectError; end
|
10
9
|
class BuildError < ScriptProjectError; end
|
11
10
|
class DependencyError < ScriptProjectError; end
|
12
11
|
class DependencyInstallError < ScriptProjectError; end
|
@@ -32,6 +31,7 @@ module Script
|
|
32
31
|
class ShopAuthenticationError < ScriptProjectError; end
|
33
32
|
class ShopScriptConflictError < ScriptProjectError; end
|
34
33
|
class ShopScriptUndefinedError < ScriptProjectError; end
|
34
|
+
class TaskRunnerNotFoundError < ScriptProjectError; end
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -4,6 +4,9 @@ module Script
|
|
4
4
|
module Layers
|
5
5
|
module Infrastructure
|
6
6
|
class PushPackageRepository
|
7
|
+
include SmartProperties
|
8
|
+
property! :ctx, accepts: ShopifyCli::Context
|
9
|
+
|
7
10
|
def create_push_package(script, script_content, compiled_type)
|
8
11
|
build_file_path = file_path(script.name, compiled_type)
|
9
12
|
write_to_path(build_file_path, script_content)
|
@@ -34,8 +37,8 @@ module Script
|
|
34
37
|
private
|
35
38
|
|
36
39
|
def write_to_path(path, content)
|
37
|
-
|
38
|
-
|
40
|
+
ctx.mkdir_p(File.dirname(path))
|
41
|
+
ctx.write(path, content)
|
39
42
|
end
|
40
43
|
|
41
44
|
def file_path(script_name, compiled_type)
|
@@ -4,10 +4,13 @@ module Script
|
|
4
4
|
module Layers
|
5
5
|
module Infrastructure
|
6
6
|
class ScriptRepository
|
7
|
+
include SmartProperties
|
8
|
+
property! :ctx, accepts: ShopifyCli::Context
|
9
|
+
|
7
10
|
BOOTSTRAP_SRC = "npx --no-install shopify-scripts-bootstrap src %{src_base}"
|
8
11
|
|
9
12
|
def create_script(language, extension_point, script_name)
|
10
|
-
|
13
|
+
ctx.mkdir_p(src_base)
|
11
14
|
out, status = CLI::Kit::System.capture2e(format(BOOTSTRAP_SRC, src_base: src_base))
|
12
15
|
raise Domain::Errors::ServiceFailureError, out unless status.success?
|
13
16
|
|
@@ -33,13 +36,13 @@ module Script
|
|
33
36
|
def with_temp_build_context
|
34
37
|
prev_dir = Dir.pwd
|
35
38
|
temp_dir = "#{project_base}/temp"
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
+
ctx.mkdir_p(temp_dir)
|
40
|
+
ctx.chdir(temp_dir)
|
41
|
+
ctx.cp_r("#{src_base}/.", ".")
|
39
42
|
yield
|
40
43
|
ensure
|
41
|
-
|
42
|
-
|
44
|
+
ctx.chdir(prev_dir)
|
45
|
+
ctx.rm_rf(temp_dir)
|
43
46
|
end
|
44
47
|
|
45
48
|
def relative_path_to_src
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Layers
|
5
|
+
module Infrastructure
|
6
|
+
class TaskRunner
|
7
|
+
TASK_RUNNERS = {
|
8
|
+
"ts" => Infrastructure::AssemblyScriptTaskRunner,
|
9
|
+
}
|
10
|
+
|
11
|
+
def self.for(ctx, language, script_name, script_source_file)
|
12
|
+
raise Errors::TaskRunnerNotFoundError unless TASK_RUNNERS[language]
|
13
|
+
TASK_RUNNERS[language].new(ctx, script_name, script_source_file)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -6,6 +6,9 @@ module Script
|
|
6
6
|
module Layers
|
7
7
|
module Infrastructure
|
8
8
|
class TestSuiteRepository
|
9
|
+
include SmartProperties
|
10
|
+
property! :ctx, accepts: ShopifyCli::Context
|
11
|
+
|
9
12
|
ASPECT_DTS_FILENAME = "as-pect.d.ts"
|
10
13
|
ASPECT_DTS_FILE_CONTENTS = "/// <reference types=\"@as-pect/assembly/types/as-pect\" />"
|
11
14
|
BOOTSTRAP_TEST = "npx --no-install shopify-scripts-bootstrap test %{test_base}"
|
@@ -14,8 +17,8 @@ module Script
|
|
14
17
|
# Remove this once we have a test suite for js
|
15
18
|
return unless script.language == "ts"
|
16
19
|
|
17
|
-
|
18
|
-
|
20
|
+
ctx.mkdir_p(test_base)
|
21
|
+
ctx.cp(aspect_config_template(script.language), "#{test_base}/as-pect.config.js")
|
19
22
|
out, status = CLI::Kit::System.capture2e(format(BOOTSTRAP_TEST, test_base: test_base))
|
20
23
|
raise Domain::Errors::ServiceFailureError, out unless status.success?
|
21
24
|
|
@@ -46,7 +49,7 @@ module Script
|
|
46
49
|
end
|
47
50
|
|
48
51
|
def relative_path_to_source_dir
|
49
|
-
src_path_from_root = ScriptRepository.new.relative_path_to_src
|
52
|
+
src_path_from_root = ScriptRepository.new(ctx: ctx).relative_path_to_src
|
50
53
|
Pathname.new(src_path_from_root).relative_path_from(test_dir)
|
51
54
|
end
|
52
55
|
|
@@ -3,14 +3,28 @@
|
|
3
3
|
module Script
|
4
4
|
class ScriptProject < ShopifyCli::Project
|
5
5
|
SUPPORTED_LANGUAGES = %w(ts)
|
6
|
+
SOURCE_DIR = "src"
|
6
7
|
|
7
8
|
attr_reader :extension_point_type, :script_name, :language
|
8
9
|
|
9
|
-
def initialize(
|
10
|
-
super
|
10
|
+
def initialize(*args)
|
11
|
+
super
|
11
12
|
@extension_point_type = lookup_config('extension_point_type')
|
12
13
|
@script_name = lookup_config('script_name')
|
13
14
|
@language = 'ts'
|
15
|
+
ShopifyCli::Core::Monorail.metadata = {
|
16
|
+
"script_name" => @script_name,
|
17
|
+
"extension_point_type" => @extension_point_type,
|
18
|
+
"language" => @language,
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def source_file
|
23
|
+
"#{SOURCE_DIR}/#{file_name}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def file_name
|
27
|
+
"script.#{language}"
|
14
28
|
end
|
15
29
|
|
16
30
|
private
|
@@ -21,16 +35,15 @@ module Script
|
|
21
35
|
end
|
22
36
|
|
23
37
|
class << self
|
24
|
-
def create(dir)
|
25
|
-
raise Errors::ScriptProjectAlreadyExistsError, dir if
|
26
|
-
|
27
|
-
|
28
|
-
Dir.chdir(dir)
|
38
|
+
def create(ctx, dir)
|
39
|
+
raise Errors::ScriptProjectAlreadyExistsError, dir if ctx.exist?(dir)
|
40
|
+
ctx.mkdir_p(dir)
|
41
|
+
ctx.chdir(dir)
|
29
42
|
end
|
30
43
|
|
31
44
|
def cleanup(ctx:, script_name:, root_dir:)
|
32
|
-
|
33
|
-
ctx.rm_r("#{root_dir}/#{script_name}") if
|
45
|
+
ctx.chdir(root_dir)
|
46
|
+
ctx.rm_r("#{root_dir}/#{script_name}") if ctx.exist?("#{root_dir}/#{script_name}")
|
34
47
|
end
|
35
48
|
end
|
36
49
|
end
|
data/lib/shopify-cli/api.rb
CHANGED
data/lib/shopify-cli/context.rb
CHANGED
@@ -131,6 +131,47 @@ module ShopifyCli
|
|
131
131
|
File.write(ctx_path(fname), content)
|
132
132
|
end
|
133
133
|
|
134
|
+
# will change directories and update the root, the filepath is relative to the command root unless absolute
|
135
|
+
#
|
136
|
+
# #### Parameters
|
137
|
+
# * `path` - the file path to a directory, relative to the context root to remove from the FS
|
138
|
+
#
|
139
|
+
def chdir(path)
|
140
|
+
Dir.chdir(ctx_path(path))
|
141
|
+
self.root = ctx_path(path)
|
142
|
+
end
|
143
|
+
|
144
|
+
# checks if a directory exists, the filepath is relative to the command root unless absolute
|
145
|
+
#
|
146
|
+
# #### Parameters
|
147
|
+
# * `path` - the file path to a directory, relative to the context root to remove from the FS
|
148
|
+
#
|
149
|
+
def exist?(path)
|
150
|
+
Dir.exist?(ctx_path(path))
|
151
|
+
end
|
152
|
+
|
153
|
+
# will recursively copy a directory from the FS, the filepath is relative to the command
|
154
|
+
# root unless absolute
|
155
|
+
#
|
156
|
+
# #### Parameters
|
157
|
+
# * `from` - the path of the original file
|
158
|
+
# * `to` - the destination path
|
159
|
+
#
|
160
|
+
def cp_r(from, to)
|
161
|
+
FileUtils.cp_r(ctx_path(from), ctx_path(to))
|
162
|
+
end
|
163
|
+
|
164
|
+
# will copy a directory from the FS, the filepath is relative to the command
|
165
|
+
# root unless absolute
|
166
|
+
#
|
167
|
+
# #### Parameters
|
168
|
+
# * `from` - the path of the original file
|
169
|
+
# * `to` - the destination path
|
170
|
+
#
|
171
|
+
def cp(from, to)
|
172
|
+
FileUtils.cp(ctx_path(from), ctx_path(to))
|
173
|
+
end
|
174
|
+
|
134
175
|
# will rename a file from one place to another, relative to the command root
|
135
176
|
# unless the path is absolute.
|
136
177
|
#
|
@@ -162,6 +203,16 @@ module ShopifyCli
|
|
162
203
|
FileUtils.rm_r(ctx_path(fname))
|
163
204
|
end
|
164
205
|
|
206
|
+
# will force remove a directory from the FS, the filepath is relative to the command
|
207
|
+
# root unless absolute
|
208
|
+
#
|
209
|
+
# #### Parameters
|
210
|
+
# * `fname` - the file path to a directory, relative to the context root to remove from the FS
|
211
|
+
#
|
212
|
+
def rm_rf(fname)
|
213
|
+
FileUtils.rm_rf(ctx_path(fname))
|
214
|
+
end
|
215
|
+
|
165
216
|
# will create a directory, recursively if it does not exist. So if you create
|
166
217
|
# a directory `foo/bar/dun`, this will also create the directories `foo` and
|
167
218
|
# `foo/bar` if they do not exist. The path will be made relative to the command
|
data/lib/shopify-cli/git.rb
CHANGED
@@ -46,10 +46,10 @@ module ShopifyCli
|
|
46
46
|
if Dir.exist?(dest)
|
47
47
|
ctx.abort(ctx.message('core.git.error.directory_exists'))
|
48
48
|
else
|
49
|
-
|
49
|
+
success_message = ctx.message('core.git.cloned', dest)
|
50
|
+
CLI::UI::Frame.open(ctx.message('core.git.cloning', repository, dest), success_text: success_message) do
|
50
51
|
clone_progress('clone', '--single-branch', repository, dest, ctx: ctx)
|
51
52
|
end
|
52
|
-
ctx.done(ctx.message('core.git.cloned', dest))
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -121,19 +121,23 @@ module ShopifyCli
|
|
121
121
|
def clone_progress(*git_command, ctx:)
|
122
122
|
CLI::UI::Progress.progress do |bar|
|
123
123
|
msg = []
|
124
|
-
|
125
|
-
|
126
|
-
|
124
|
+
require 'open3'
|
125
|
+
|
126
|
+
success = Open3.popen3('git', *git_command, '--progress') do |_stdin, _stdout, stderr, thread|
|
127
|
+
while (line = stderr.gets)
|
128
|
+
next unless line.strip.start_with?('Receiving objects:')
|
129
|
+
percent = (line.match(/Receiving objects:\s+(\d+)/)[1].to_f / 100).round(2)
|
127
130
|
bar.tick(set_percent: percent)
|
128
131
|
next
|
129
132
|
end
|
130
|
-
|
133
|
+
|
134
|
+
msg << stderr
|
135
|
+
thread.value
|
131
136
|
end.success?
|
132
|
-
|
133
|
-
|
134
|
-
end
|
137
|
+
|
138
|
+
ctx.abort(msg.join("\n")) unless success
|
135
139
|
bar.tick(set_percent: 1.0)
|
136
|
-
|
140
|
+
success
|
137
141
|
end
|
138
142
|
end
|
139
143
|
end
|
@@ -60,8 +60,8 @@ module ShopifyCli
|
|
60
60
|
no_commits_made: "No git commits have been made. Please make at least one commit.",
|
61
61
|
},
|
62
62
|
|
63
|
-
cloning: "Cloning into %s...",
|
64
|
-
cloned: "Cloned into %s",
|
63
|
+
cloning: "Cloning %s into %s...",
|
64
|
+
cloned: "{{v}} Cloned into %s",
|
65
65
|
},
|
66
66
|
|
67
67
|
help: {
|
@@ -154,6 +154,12 @@ module ShopifyCli
|
|
154
154
|
},
|
155
155
|
},
|
156
156
|
|
157
|
+
api: {
|
158
|
+
error: {
|
159
|
+
internal_server_error: '{{red:{{x}} An unexpected error occurred on Shopify.}}',
|
160
|
+
},
|
161
|
+
},
|
162
|
+
|
157
163
|
populate: {
|
158
164
|
options: {
|
159
165
|
header: "{{bold:{{cyan:%s}} options:}}",
|
data/lib/shopify-cli/version.rb
CHANGED
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: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -229,15 +229,15 @@ files:
|
|
229
229
|
- lib/project_types/script/layers/domain/push_package.rb
|
230
230
|
- lib/project_types/script/layers/domain/script.rb
|
231
231
|
- lib/project_types/script/layers/infrastructure/assemblyscript_dependency_manager.rb
|
232
|
+
- lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb
|
232
233
|
- lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb
|
233
|
-
- lib/project_types/script/layers/infrastructure/assemblyscript_wasm_builder.rb
|
234
234
|
- lib/project_types/script/layers/infrastructure/dependency_manager.rb
|
235
235
|
- lib/project_types/script/layers/infrastructure/errors.rb
|
236
236
|
- lib/project_types/script/layers/infrastructure/extension_point_repository.rb
|
237
237
|
- lib/project_types/script/layers/infrastructure/push_package_repository.rb
|
238
|
-
- lib/project_types/script/layers/infrastructure/script_builder.rb
|
239
238
|
- lib/project_types/script/layers/infrastructure/script_repository.rb
|
240
239
|
- lib/project_types/script/layers/infrastructure/script_service.rb
|
240
|
+
- lib/project_types/script/layers/infrastructure/task_runner.rb
|
241
241
|
- lib/project_types/script/layers/infrastructure/test_suite_repository.rb
|
242
242
|
- lib/project_types/script/messages/messages.rb
|
243
243
|
- lib/project_types/script/script_project.rb
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Script
|
4
|
-
module Layers
|
5
|
-
module Infrastructure
|
6
|
-
class AssemblyScriptWasmBuilder
|
7
|
-
BYTECODE_FILE = "%{name}.wasm"
|
8
|
-
SCRIPT_SDK_BUILD = "npx --no-install shopify-scripts-build --src=../%{source} --binary=#{BYTECODE_FILE} "\
|
9
|
-
"-- --lib=../node_modules --validate --optimize"
|
10
|
-
|
11
|
-
attr_reader :script
|
12
|
-
|
13
|
-
def initialize(script)
|
14
|
-
@script = script
|
15
|
-
end
|
16
|
-
|
17
|
-
def build
|
18
|
-
compile
|
19
|
-
bytecode
|
20
|
-
end
|
21
|
-
|
22
|
-
def compiled_type
|
23
|
-
"wasm"
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def compile
|
29
|
-
out, status = CLI::Kit::System.capture2e(format(SCRIPT_SDK_BUILD, source: script.id, name: script.name))
|
30
|
-
raise Domain::Errors::ServiceFailureError, out unless status.success?
|
31
|
-
end
|
32
|
-
|
33
|
-
def bytecode
|
34
|
-
File.read(format(BYTECODE_FILE, name: script.name))
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Script
|
4
|
-
module Layers
|
5
|
-
module Infrastructure
|
6
|
-
class NoopBuilder
|
7
|
-
def initialize(script)
|
8
|
-
@script = script
|
9
|
-
end
|
10
|
-
|
11
|
-
def build
|
12
|
-
File.read(@script.filename)
|
13
|
-
end
|
14
|
-
|
15
|
-
def compiled_type
|
16
|
-
@script.language
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class ScriptBuilder
|
21
|
-
COMPILERS = {
|
22
|
-
"ts" => Infrastructure::AssemblyScriptWasmBuilder,
|
23
|
-
"js" => Infrastructure::NoopBuilder,
|
24
|
-
"json" => Infrastructure::NoopBuilder,
|
25
|
-
}
|
26
|
-
|
27
|
-
def self.for(script)
|
28
|
-
raise Errors::BuilderNotFoundError unless COMPILERS[script.language]
|
29
|
-
COMPILERS[script.language].new(script)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|