cli-kit 3.3.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +10 -0
  3. data/.github/workflows/cla.yml +22 -0
  4. data/.github/workflows/ruby.yml +64 -0
  5. data/.gitignore +2 -0
  6. data/.rubocop.sorbet.yml +47 -0
  7. data/.rubocop.yml +22 -13
  8. data/Gemfile +13 -3
  9. data/Gemfile.lock +110 -28
  10. data/README.md +46 -3
  11. data/Rakefile +28 -1
  12. data/bin/console +3 -3
  13. data/bin/onchange +30 -0
  14. data/bin/tapioca +29 -0
  15. data/bin/test_gen +4 -1
  16. data/bin/testunit +3 -2
  17. data/cli-kit.gemspec +7 -6
  18. data/dev.yml +35 -3
  19. data/examples/minimal/example.rb +5 -3
  20. data/examples/single-file/example.rb +25 -35
  21. data/gen/lib/gen/commands/help.rb +8 -10
  22. data/gen/lib/gen/commands/new.rb +23 -9
  23. data/gen/lib/gen/commands.rb +21 -9
  24. data/gen/lib/gen/entry_point.rb +12 -3
  25. data/gen/lib/gen/generator.rb +39 -18
  26. data/gen/lib/gen/help.rb +63 -0
  27. data/gen/lib/gen.rb +18 -23
  28. data/gen/template/bin/update-deps +2 -2
  29. data/gen/template/lib/__app__/commands.rb +1 -4
  30. data/gen/template/lib/__app__.rb +8 -17
  31. data/gen/template/test/example_test.rb +1 -1
  32. data/lib/cli/kit/args/definition.rb +344 -0
  33. data/lib/cli/kit/args/evaluation.rb +245 -0
  34. data/lib/cli/kit/args/parser/node.rb +132 -0
  35. data/lib/cli/kit/args/parser.rb +129 -0
  36. data/lib/cli/kit/args/tokenizer.rb +133 -0
  37. data/lib/cli/kit/args.rb +16 -0
  38. data/lib/cli/kit/base_command.rb +17 -32
  39. data/lib/cli/kit/command_help.rb +271 -0
  40. data/lib/cli/kit/command_registry.rb +69 -17
  41. data/lib/cli/kit/config.rb +30 -25
  42. data/lib/cli/kit/core_ext.rb +30 -0
  43. data/lib/cli/kit/error_handler.rb +134 -67
  44. data/lib/cli/kit/executor.rb +39 -20
  45. data/lib/cli/kit/ini.rb +32 -39
  46. data/lib/cli/kit/levenshtein.rb +12 -4
  47. data/lib/cli/kit/logger.rb +23 -3
  48. data/lib/cli/kit/opts.rb +301 -0
  49. data/lib/cli/kit/resolver.rb +10 -2
  50. data/lib/cli/kit/sorbet_runtime_stub.rb +156 -0
  51. data/lib/cli/kit/support/test_helper.rb +31 -22
  52. data/lib/cli/kit/support.rb +2 -0
  53. data/lib/cli/kit/system.rb +217 -48
  54. data/lib/cli/kit/util.rb +52 -107
  55. data/lib/cli/kit/version.rb +3 -1
  56. data/lib/cli/kit.rb +104 -8
  57. metadata +35 -22
  58. data/.github/probots.yml +0 -2
  59. data/.travis.yml +0 -14
  60. data/lib/cli/kit/autocall.rb +0 -21
  61. data/lib/cli/kit/ruby_backports/enumerable.rb +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1c78454dde57819601c7ef40040c02943b72ea2f3831718a2a4362731c2cf9a
4
- data.tar.gz: 6e4e1adcdd54eb38d419b2d2d936ec03a05190cf72baaabd1002e1407dfdcf49
3
+ metadata.gz: e576da52278c6b0596840691bffbb12546b54bf2238145455a45333d6101f773
4
+ data.tar.gz: 24243f1a2d66ad3b12fb2728b73b608038950d958ffc31dc0ab7951c3714533a
5
5
  SHA512:
6
- metadata.gz: f57fe58683a342a39957fd19cedc79641583456100e7e63b71e4e395b0fc705938ccaa1574bc36d975dda6f6b5c7fcbf28406972432abcf3ac890bb1334e2715
7
- data.tar.gz: 5f1f0bf80809f7ff4ae97ab4cd0871ceaef6b4c4967b06fdcae5ccb1c869524c351c1a2acf7cab83cd2416ce37766033b5c63d6ff2480fd660067d74dcc51f8f
6
+ metadata.gz: 8e7f4f5c4cc6620a2d98eca89e85ad57e6a9a0bd94ec704503ac0c9ba84f631984beb7c71c60e8b24ddbd2c4cf88b30cc298d3b05009f565450348a5b82c8d7f
7
+ data.tar.gz: ac1c63ad107ca13fda07413a17054a17bb69ec6ae793f2a0abb97a5c2616c15fe7aaeaf7c3328b7ce035136dd72007df51fe7f5aab15e0c90199ede7ddd8d1e0
@@ -0,0 +1,10 @@
1
+ version: 2
2
+
3
+ updates:
4
+ - package-ecosystem: bundler
5
+ directory: "/"
6
+ schedule:
7
+ interval: weekly
8
+ time: "07:00"
9
+ timezone: America/Toronto
10
+ open-pull-requests-limit: 99
@@ -0,0 +1,22 @@
1
+ name: Contributor License Agreement (CLA)
2
+
3
+ on:
4
+ pull_request_target:
5
+ types: [opened, synchronize]
6
+ issue_comment:
7
+ types: [created]
8
+
9
+ jobs:
10
+ cla:
11
+ runs-on: ubuntu-latest
12
+ if: |
13
+ (github.event.issue.pull_request
14
+ && !github.event.issue.pull_request.merged_at
15
+ && contains(github.event.comment.body, 'signed')
16
+ )
17
+ || (github.event.pull_request && !github.event.pull_request.merged)
18
+ steps:
19
+ - uses: Shopify/shopify-cla-action@v1
20
+ with:
21
+ github-token: ${{ secrets.GITHUB_TOKEN }}
22
+ cla-token: ${{ secrets.CLA_TOKEN }}
@@ -0,0 +1,64 @@
1
+ name: Ruby
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+
7
+ style:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/checkout@v2
11
+ - name: Set up Ruby
12
+ uses: ruby/setup-ruby@v1
13
+ with:
14
+ ruby-version: '2.7'
15
+ bundler-cache: true
16
+ - name: Check style
17
+ run: bundle exec rake style
18
+
19
+ typecheck:
20
+ runs-on: ubuntu-latest
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - name: Set up Ruby
24
+ uses: ruby/setup-ruby@v1
25
+ with:
26
+ ruby-version: '2.7'
27
+ bundler-cache: true
28
+ - name: Typecheck
29
+ run: bundle exec srb tc
30
+
31
+ test:
32
+ strategy:
33
+ matrix:
34
+ os: [macos-latest, ubuntu-latest]
35
+ ruby-version: ['2.7', '3.0']
36
+
37
+ runs-on: ${{ matrix.os }}
38
+ steps:
39
+ - uses: actions/checkout@v2
40
+ - name: Set up Ruby
41
+ uses: ruby/setup-ruby@v1
42
+ with:
43
+ ruby-version: ${{ matrix.ruby-version }}
44
+ bundler-cache: true
45
+ - name: Run tests
46
+ run: bundle exec rake test
47
+
48
+ test-windows:
49
+ strategy:
50
+ matrix:
51
+ ruby-version: ['2.7', '3.0']
52
+
53
+ runs-on: windows-latest
54
+ env:
55
+ BUNDLE_WITHOUT: typecheck
56
+ steps:
57
+ - uses: actions/checkout@v2
58
+ - name: Set up Ruby
59
+ uses: ruby/setup-ruby@v1
60
+ with:
61
+ ruby-version: ${{ matrix.ruby-version }}
62
+ bundler-cache: true
63
+ - name: Run tests
64
+ run: bundle exec rake test
data/.gitignore CHANGED
@@ -4,6 +4,8 @@ build
4
4
  .DS_Store
5
5
  .bundle
6
6
 
7
+ /coverage
8
+
7
9
  .starscope.db
8
10
  cscope.out
9
11
  tags
@@ -0,0 +1,47 @@
1
+ Sorbet:
2
+ Enabled: true
3
+
4
+ Sorbet/ValidSigil:
5
+ Enabled: true
6
+ Exclude:
7
+ - lib/cli/kit/sorbet_runtime_stub.rb
8
+
9
+ Sorbet/FalseSigil:
10
+ Enabled: false
11
+
12
+ Sorbet/TrueSigil:
13
+ Enabled: true
14
+ Include:
15
+ - "**/*.rb"
16
+ - "**/*.rbi"
17
+ - "**/*.rake"
18
+ - "**/*.ru"
19
+ Exclude:
20
+ - lib/cli/kit/sorbet_runtime_stub.rb
21
+ - "test/**/*"
22
+ - "lib/cli/kit/support/test_helper.rb"
23
+
24
+ Sorbet/EnforceSigilOrder:
25
+ Enabled: true
26
+
27
+ Sorbet/EnforceSignatures:
28
+ Enabled: true
29
+ Exclude:
30
+ - lib/cli/kit/sorbet_runtime_stub.rb
31
+ - "test/**/*"
32
+ - bin/testunit
33
+ - "lib/cli/kit/support/test_helper.rb"
34
+
35
+ Sorbet/SignatureBuildOrder:
36
+ Enabled: true
37
+
38
+ Sorbet/KeywordArgumentOrdering:
39
+ Enabled: true
40
+
41
+ Sorbet/ConstantsFromStrings:
42
+ Enabled: true
43
+ Exclude:
44
+ - "examples/**/*"
45
+
46
+ Sorbet/ForbidIncludeConstLiteral:
47
+ Enabled: false
data/.rubocop.yml CHANGED
@@ -1,9 +1,18 @@
1
+ inherit_gem:
2
+ rubocop-shopify: rubocop-cli.yml
3
+
1
4
  inherit_from:
2
- - http://shopify.github.io/ruby-style-guide/rubocop.yml
5
+ - .rubocop.sorbet.yml
6
+
7
+ require:
8
+ - rubocop-sorbet
3
9
 
4
10
  AllCops:
5
- Exclude: [ 'gen/template/**/*' ]
6
- TargetRubyVersion: 2.3
11
+ Exclude:
12
+ - gen/template/**/*
13
+ - vendor/**/*
14
+ TargetRubyVersion: 2.7
15
+ NewCops: disable
7
16
 
8
17
  Style/ClassAndModuleChildren:
9
18
  Exclude:
@@ -12,15 +21,8 @@ Style/ClassAndModuleChildren:
12
21
  Style/FrozenStringLiteralComment:
13
22
  Enabled: false
14
23
 
15
- Shopify/RubocopComments:
16
- Enabled: false
17
-
18
- # This doesn't understand that <<~ doesn't exist in 2.0
19
- Layout/IndentHeredoc:
20
- Enabled: false
21
-
22
24
  # This doesn't take into account retrying from an exception
23
- Lint/HandleExceptions:
25
+ Lint/SuppressedException:
24
26
  Enabled: false
25
27
 
26
28
  # allow String.new to create mutable strings
@@ -39,6 +41,13 @@ Style/RegexpLiteral:
39
41
  Style/MultilineBlockChain:
40
42
  Enabled: false
41
43
 
42
- # allow using names to be more expressive
43
- Performance/RedundantBlockCall:
44
+ Style/StringLiterals:
45
+ EnforcedStyle: single_quotes
46
+
47
+ # We heavily manage output on purpose
48
+ Style/GlobalStdStream:
49
+ Enabled: false
50
+
51
+ # Sometimes (often) explicit is good
52
+ Style/EmptyElse:
44
53
  Enabled: false
data/Gemfile CHANGED
@@ -1,16 +1,26 @@
1
1
  # NOTE: These are development-only dependencies
2
- source "https://rubygems.org"
2
+ source 'https://rubygems.org'
3
3
 
4
4
  gemspec
5
5
 
6
6
  group :development, :test do
7
- gem 'rubocop', '~> 0.56.0'
7
+ gem 'cli-ui', git: 'https://github.com/Shopify/cli-ui', ref: '0eefd57248f42ec163639884e77a071d82bfbda8'
8
+ gem 'rubocop'
9
+ gem 'rubocop-rake'
10
+ gem 'rubocop-shopify'
11
+ gem 'rubocop-sorbet'
8
12
  gem 'byebug'
9
13
  gem 'method_source'
14
+ gem 'simplecov'
15
+ end
16
+
17
+ group :typecheck do
18
+ gem 'sorbet-static-and-runtime'
19
+ gem 'tapioca', require: false
10
20
  end
11
21
 
12
22
  group :test do
13
- gem 'mocha', '~> 1.5.0', require: false
23
+ gem 'mocha', '~> 2.0.1', require: false
14
24
  gem 'minitest', '>= 5.0.0', require: false
15
25
  gem 'minitest-reporters', require: false
16
26
  end
data/Gemfile.lock CHANGED
@@ -1,56 +1,138 @@
1
+ GIT
2
+ remote: https://github.com/Shopify/cli-ui
3
+ revision: 0eefd57248f42ec163639884e77a071d82bfbda8
4
+ ref: 0eefd57248f42ec163639884e77a071d82bfbda8
5
+ specs:
6
+ cli-ui (1.5.1)
7
+
1
8
  PATH
2
9
  remote: .
3
10
  specs:
4
- cli-kit (3.3.0)
11
+ cli-kit (4.0.0)
5
12
  cli-ui (>= 1.1.4)
6
13
 
7
14
  GEM
8
15
  remote: https://rubygems.org/
9
16
  specs:
10
17
  ansi (1.5.0)
11
- ast (2.4.0)
12
- builder (3.2.3)
13
- byebug (9.0.6)
14
- cli-ui (1.2.3)
15
- metaclass (0.0.4)
16
- method_source (0.8.2)
17
- minitest (5.10.2)
18
- minitest-reporters (1.1.14)
18
+ ast (2.4.2)
19
+ builder (3.2.4)
20
+ byebug (11.1.3)
21
+ diff-lcs (1.5.0)
22
+ docile (1.4.0)
23
+ json (2.6.2)
24
+ method_source (1.0.0)
25
+ minitest (5.16.3)
26
+ minitest-reporters (1.5.0)
19
27
  ansi
20
28
  builder
21
29
  minitest (>= 5.0)
22
30
  ruby-progressbar
23
- mocha (1.5.0)
24
- metaclass (~> 0.0.1)
25
- parallel (1.12.1)
26
- parser (2.5.1.0)
27
- ast (~> 2.4.0)
28
- powerpack (0.1.1)
29
- rainbow (3.0.0)
30
- rake (10.5.0)
31
- rubocop (0.56.0)
31
+ mocha (2.0.2)
32
+ ruby2_keywords (>= 0.0.5)
33
+ netrc (0.11.0)
34
+ parallel (1.22.1)
35
+ parser (3.1.2.1)
36
+ ast (~> 2.4.1)
37
+ rainbow (3.1.1)
38
+ rake (13.0.6)
39
+ rbi (0.0.16)
40
+ ast
41
+ parser (>= 2.6.4.0)
42
+ sorbet-runtime (>= 0.5.9204)
43
+ unparser
44
+ regexp_parser (2.6.0)
45
+ rexml (3.2.5)
46
+ rubocop (1.39.0)
47
+ json (~> 2.3)
32
48
  parallel (~> 1.10)
33
- parser (>= 2.5)
34
- powerpack (~> 0.1)
49
+ parser (>= 3.1.2.1)
35
50
  rainbow (>= 2.2.2, < 4.0)
51
+ regexp_parser (>= 1.8, < 3.0)
52
+ rexml (>= 3.2.5, < 4.0)
53
+ rubocop-ast (>= 1.23.0, < 2.0)
36
54
  ruby-progressbar (~> 1.7)
37
- unicode-display_width (~> 1.0, >= 1.0.1)
38
- ruby-progressbar (1.8.1)
39
- unicode-display_width (1.3.2)
55
+ unicode-display_width (>= 1.4.0, < 3.0)
56
+ rubocop-ast (1.23.0)
57
+ parser (>= 3.1.1.0)
58
+ rubocop-rake (0.6.0)
59
+ rubocop (~> 1.0)
60
+ rubocop-shopify (2.10.1)
61
+ rubocop (~> 1.35)
62
+ rubocop-sorbet (0.6.11)
63
+ rubocop (>= 0.90.0)
64
+ ruby-progressbar (1.11.0)
65
+ ruby2_keywords (0.0.5)
66
+ simplecov (0.21.2)
67
+ docile (~> 1.1)
68
+ simplecov-html (~> 0.11)
69
+ simplecov_json_formatter (~> 0.1)
70
+ simplecov-html (0.12.3)
71
+ simplecov_json_formatter (0.1.4)
72
+ sorbet (0.5.10554)
73
+ sorbet-static (= 0.5.10554)
74
+ sorbet-runtime (0.5.10554)
75
+ sorbet-static (0.5.10554-universal-darwin-14)
76
+ sorbet-static (0.5.10554-universal-darwin-15)
77
+ sorbet-static (0.5.10554-universal-darwin-16)
78
+ sorbet-static (0.5.10554-universal-darwin-17)
79
+ sorbet-static (0.5.10554-universal-darwin-18)
80
+ sorbet-static (0.5.10554-universal-darwin-19)
81
+ sorbet-static (0.5.10554-universal-darwin-20)
82
+ sorbet-static (0.5.10554-universal-darwin-21)
83
+ sorbet-static (0.5.10554-universal-darwin-22)
84
+ sorbet-static (0.5.10554-x86_64-linux)
85
+ sorbet-static-and-runtime (0.5.10554)
86
+ sorbet (= 0.5.10554)
87
+ sorbet-runtime (= 0.5.10554)
88
+ spoom (1.1.12)
89
+ sorbet (>= 0.5.9204)
90
+ sorbet-runtime (>= 0.5.9204)
91
+ thor (>= 0.19.2)
92
+ tapioca (0.10.3)
93
+ bundler (>= 1.17.3)
94
+ netrc (>= 0.11.0)
95
+ parallel (>= 1.21.0)
96
+ rbi (~> 0.0.0, >= 0.0.16)
97
+ sorbet-static-and-runtime (>= 0.5.9892)
98
+ spoom (~> 1.1.0, >= 1.1.11)
99
+ thor (>= 1.2.0)
100
+ yard-sorbet
101
+ thor (1.2.1)
102
+ unicode-display_width (2.3.0)
103
+ unparser (0.6.5)
104
+ diff-lcs (~> 1.3)
105
+ parser (>= 3.1.0)
106
+ webrick (1.7.0)
107
+ yard (0.9.28)
108
+ webrick (~> 1.7.0)
109
+ yard-sorbet (0.7.0)
110
+ sorbet-runtime (>= 0.5)
111
+ yard (>= 0.9)
40
112
 
41
113
  PLATFORMS
114
+ arm64-darwin-21
42
115
  ruby
116
+ universal-darwin
117
+ x86_64-linux
43
118
 
44
119
  DEPENDENCIES
45
- bundler (~> 1.15)
120
+ bundler (~> 2.1)
46
121
  byebug
47
122
  cli-kit!
123
+ cli-ui!
48
124
  method_source
49
125
  minitest (>= 5.0.0)
50
126
  minitest-reporters
51
- mocha (~> 1.5.0)
52
- rake (~> 10.0)
53
- rubocop (~> 0.56.0)
127
+ mocha (~> 2.0.1)
128
+ rake (~> 13.0)
129
+ rubocop
130
+ rubocop-rake
131
+ rubocop-shopify
132
+ rubocop-sorbet
133
+ simplecov
134
+ sorbet-static-and-runtime
135
+ tapioca
54
136
 
55
137
  BUNDLED WITH
56
- 1.17.3
138
+ 2.2.24
data/README.md CHANGED
@@ -26,9 +26,52 @@ select how the project consumes `cli-kit` and `cli-ui`. The available options a
26
26
 
27
27
  You're now ready to write your very first `cli-kit` application!
28
28
 
29
+ ## Upgrading to version 5
30
+
31
+ Version 5 includes breaking changes and significant new features. Notably:
32
+
33
+ * `autocall` is completely removed;
34
+ * A help system and command-line option parsing system is added.
35
+
36
+ Migrating away from `autocall` is as simple as replacing `autocall(:X) { y }` with `X = y`.
37
+
38
+ Using the new help system is not yet well-documented, but some hints can be found in the
39
+ `gen/ilb/gen/commands` directory of this repo. Existing commands in existing apps should continue to
40
+ work.
41
+
42
+ To use the new help system, commands should all define `invoke` instead of `call`. `invoke` takes
43
+ `name` as before, but the first argument is now an instance of `Opts`, defined in the command class,
44
+ which must be a subclass of `CLI::Kit::Opts`. For example:
45
+
46
+ ```ruby
47
+ class MyCommand < CLI::Kit::BaseCommand
48
+ class Opts < CLI::Kit::Opts
49
+ def force
50
+ flag(short: '-f', long: '--force', description: 'Force the operation')
51
+ end
52
+ end
53
+ def invoke(op, _name)
54
+ if op.force
55
+ puts 'Forcing the operation'
56
+ else
57
+ puts 'Not forcing the operation'
58
+ end
59
+ end
60
+ end
61
+ ```
62
+
63
+ This particular structure was chosen to allow the code to by fully typed using sorbet, as `invoke`
64
+ can be tagged with `sig { params(op: Opts, _name: String).void }`, and the `#force` method visibly
65
+ exists.
66
+
67
+ `-h/--help` is installed as a default flag, and running this command with `--help` is handled before
68
+ reaching `#invoke`, to print a help message (for which several other class methods on `BaseCommand`
69
+ provide text: `command_name`, `desc`, `long_desc`, `usage`, `example`, and `help_sections`). See
70
+ `gen/lib/gen/commands/new.rb` for an example.
71
+
29
72
  ## How do `cli-kit` Applications Work?
30
73
 
31
- The executable for your `cli-kit` app is stored in the "exe" directory. To execute the app, simply
74
+ The executable for your `cli-kit` app is stored in the "exe" directory. To execute the app, simply
32
75
  run:
33
76
  ```bash
34
77
  ./exe/myproject
@@ -38,7 +81,7 @@ run:
38
81
  * `/exe/` - Location of the executables for your application.
39
82
  * `/lib/` - Location of the resources for your app (modules, classes, helpers, etc).
40
83
  * `myproject.rb` - This file is the starting point for where to look for all other files. It
41
- configures autoload and autocall for the app.
84
+ configures autoload for the app.
42
85
  * `myproject/` - Stores the various commands/entry points.
43
86
  * `entry_point.rb` - This is the file that is first called from the executable. It handles
44
87
  loading and commands.
@@ -113,4 +156,4 @@ powerful command-line user interface elements. For more details on how to use `c
113
156
 
114
157
  ## Examples
115
158
 
116
- - [A Simple To-Do App](https://github.com/Shopify/cli-kit-example)
159
+ - [A Simple To-Do App](https://github.com/Shopify/cli-kit-example)
data/Rakefile CHANGED
@@ -1 +1,28 @@
1
- require "bundler/gem_tasks"
1
+ $LOAD_PATH.unshift(File.expand_path('../lib', __FILE__))
2
+ require 'rake/testtask'
3
+ require 'rubocop/rake_task'
4
+ require 'bundler/gem_tasks'
5
+ require 'sorbet-runtime' unless ENV['BUNDLE_WITHOUT'] == 'typecheck'
6
+
7
+ TEST_ROOT = File.expand_path('../test', __FILE__)
8
+
9
+ Rake::TestTask.new do |t|
10
+ t.libs += ['test']
11
+ t.test_files = FileList[File.join(TEST_ROOT, '**', '*_test.rb')]
12
+ t.verbose = false
13
+ t.warning = false
14
+ end
15
+
16
+ RuboCop::RakeTask.new(:style) do |t|
17
+ t.options = ['--display-cop-names']
18
+ end
19
+
20
+ task :test_gen_bundler do
21
+ sh 'DEPS=bundler bin/test_gen'
22
+ end
23
+
24
+ task :test_gen_vendor do
25
+ sh 'DEPS=vendor bin/test_gen'
26
+ end
27
+
28
+ task(default: [:test, :style, :test_gen_bundler, :test_gen_vendor])
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "cli/kit"
3
+ require 'bundler/setup'
4
+ require 'cli/kit'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require "cli/kit"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start(__FILE__)
data/bin/onchange ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ # typed: ignore
3
+ # frozen_string_literal: true
4
+
5
+ require('open3')
6
+
7
+ extra_fswatch_args, cmd_args = if (rest_index = ARGV.index('--'))
8
+ [ARGV[0...rest_index], ARGV[rest_index + 1..-1]]
9
+ else
10
+ [[], ARGV]
11
+ end
12
+
13
+ if cmd_args.size == 1 && cmd_args =~ /[&;|]/
14
+ cmd_args = ['bash', '-c', cmd_args[0]]
15
+ end
16
+
17
+ system(*cmd_args)
18
+
19
+ fswatch_args = [
20
+ '-e', 'coverage',
21
+ '-e', '/\.git',
22
+ '--one-per-batch',
23
+ *extra_fswatch_args,
24
+ '.',
25
+ ]
26
+
27
+ Open3.popen3('fswatch', *fswatch_args) do |stdin, stdout, _stderr, _wait_thr|
28
+ stdin.close
29
+ stdout.each { |_| system(*cmd_args) }
30
+ end
data/bin/tapioca ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'tapioca' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require 'pathname'
12
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path('../bundle', __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require 'rubygems'
27
+ require 'bundler/setup'
28
+
29
+ load Gem.bin_path('tapioca', 'tapioca')
data/bin/test_gen CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env bash
2
+ set -euo pipefail
2
3
 
3
4
  # Make sure we're in the cli kit directory
4
5
  CURR_DIR=$(dirname "$0")
@@ -19,7 +20,9 @@ mv myapp ../
19
20
  cd ../myapp
20
21
 
21
22
  # Test
22
- bundle install
23
+ if [[ $DEPS == 'bundler' ]]; then
24
+ bundle install
25
+ fi
23
26
  bin/testunit
24
27
 
25
28
  if [[ $DEPS == 'vendor' ]]; then
data/bin/testunit CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'bundler/setup'
5
+ require 'sorbet-runtime' unless ENV['BUNDLE_WITHOUT'] == 'typecheck'
5
6
 
6
7
  root = File.expand_path('../..', __FILE__)
7
8
  CLI_TEST_ROOT = root + '/test'
@@ -9,12 +10,12 @@ CLI_TEST_ROOT = root + '/test'
9
10
  $LOAD_PATH.unshift(CLI_TEST_ROOT)
10
11
 
11
12
  def test_files
12
- Dir.glob(CLI_TEST_ROOT + "/**/*_test.rb")
13
+ Dir.glob(CLI_TEST_ROOT + '/**/*_test.rb')
13
14
  end
14
15
 
15
16
  if ARGV.empty?
16
17
  test_files.each { |f| require(f) }
17
- exit 0
18
+ exit(0)
18
19
  end
19
20
 
20
21
  # A list of files is presumed to be specified
data/cli-kit.gemspec CHANGED
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'cli/kit/version'
@@ -14,16 +15,16 @@ Gem::Specification.new do |spec|
14
15
  spec.homepage = 'https://github.com/shopify/cli-kit'
15
16
  spec.license = 'MIT'
16
17
 
17
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
- f.match(%r{^(test|spec|features)/})
18
+ spec.files = %x(git ls-files -z).split("\x0").reject do |f|
19
+ f.match(%r{^(sorbet|test|spec|features)/})
19
20
  end
20
21
  spec.bindir = 'exe'
21
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
23
  spec.require_paths = ['lib']
23
24
 
24
- spec.add_runtime_dependency 'cli-ui', '>= 1.1.4'
25
+ spec.add_runtime_dependency('cli-ui', '~> 2.0')
25
26
 
26
- spec.add_development_dependency 'bundler', '~> 1.15'
27
- spec.add_development_dependency 'rake', '~> 10.0'
28
- spec.add_development_dependency 'minitest', '~> 5.0'
27
+ spec.add_development_dependency('bundler', '~> 2.1')
28
+ spec.add_development_dependency('minitest', '~> 5.0')
29
+ spec.add_development_dependency('rake', '~> 13.0')
29
30
  end