jade_systems_toolbox 0.1.0 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1564046e94dbda9d89321692a3c7f7e41c56377bc1693495d45fcdb97fbbddc2
4
- data.tar.gz: c78fdc0c03d57f69c1f86f105eb31f5b0be4bbc310740d457f548a757d380354
3
+ metadata.gz: 8bb1d901493c286300b53d74441705dc7402263497e998f5490ca14beac572a5
4
+ data.tar.gz: bc12fcce57604c61fe617eac640c3ab38e6204da916e73124162df78c519e803
5
5
  SHA512:
6
- metadata.gz: 056fc421ea13e0d2f66c3a6bfbe0e904a139ec23c6886ef0978087bd71513268e79f58a906d929f87fd9b59fc2845544a1a47073341fabc55931d92d769de837
7
- data.tar.gz: af541bff905aba2abd9dd41b0eb9af5aee155fbc8d939d3f962f9d83dc01a19c8ddeddc189c41cba230785c4bc1a30470eb928e2a7268132f86c8c9bebf09e27
6
+ metadata.gz: 58b7e44b6210955e1b50fc2601cc018a2434c92c105436bf923ab818577448c8f11cc90ed81128bfa6290c86f455b6aeb4e444682d4966ebc04c7cab1f382c37
7
+ data.tar.gz: 91636de5259a810060040aa51d3cc0fc1bb914358c679e2dc12dad59e639dafcbf3869a0a1f6886228e302154596195503315c92f9ed567cd6394ca708c1d2b1
data/.rubocop.yml CHANGED
@@ -1,13 +1,33 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.6
2
+ TargetRubyVersion: 3.2
3
3
 
4
- Style/StringLiterals:
4
+ # Omakase Ruby styling for Rails
5
+ inherit_gem:
6
+ rubocop-rails-omakase: rubocop.yml
7
+
8
+ # Your own specialized rules go here
9
+
10
+ Layout/HeredocIndentation:
5
11
  Enabled: true
6
- EnforcedStyle: double_quotes
7
12
 
8
- Style/StringLiteralsInInterpolation:
13
+ Layout/IndentationConsistency:
9
14
  Enabled: true
10
- EnforcedStyle: double_quotes
15
+ EnforcedStyle: normal
11
16
 
12
- Layout/LineLength:
13
- Max: 120
17
+ Layout/IndentationWidth:
18
+ Enabled: true
19
+
20
+ Style/TrailingCommaInArguments:
21
+ Enabled: true
22
+ EnforcedStyleForMultiline: consistent_comma
23
+
24
+ Style/TrailingCommaInArrayLiteral:
25
+ EnforcedStyleForMultiline: consistent_comma
26
+
27
+ Style/TrailingCommaInHashLiteral:
28
+ EnforcedStyleForMultiline: consistent_comma
29
+
30
+ Style/FrozenStringLiteralComment:
31
+ Enabled: true
32
+ EnforcedStyle: always # or 'always' or 'never' depending on your preference
33
+ SafeAutoCorrect: true # Set to true for safe autocorrection, false if you need to review changes
@@ -0,0 +1,16 @@
1
+ {
2
+ // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3
+ // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4
+ // List of extensions which should be recommended for users of this workspace.
5
+ "recommendations": [
6
+ "adpyke.vscode-sql-formatter",
7
+ "eamodio.gitlens",
8
+ "esbenp.prettier-vscode",
9
+ "mechatroner.rainbow-csv",
10
+ "ms-vsliveshare.vsliveshare",
11
+ "redhat.vscode-yaml",
12
+ "shopify.ruby-extensions-pack",
13
+ ],
14
+ // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
15
+ "unwantedRecommendations": []
16
+ }
@@ -0,0 +1,70 @@
1
+ {
2
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
3
+ "[ruby]": {
4
+ "editor.defaultFormatter": "Shopify.ruby-lsp",
5
+ "editor.formatOnPaste": true,
6
+ "editor.formatOnSave": true,
7
+ "editor.formatOnType": true,
8
+ "editor.tabSize": 2
9
+ },
10
+ "rubyLsp.formatter": "rubocop",
11
+ "rubyLsp.linters": [
12
+ "rubocop"
13
+ ],
14
+ "rubyLsp.enabledFeatures": {
15
+ "codeActions": true,
16
+ "diagnostics": true,
17
+ "documentHighlights": true,
18
+ "documentLink": true,
19
+ "documentSymbols": true,
20
+ "foldingRanges": true,
21
+ "formatting": true,
22
+ "hover": true,
23
+ "inlayHint": true,
24
+ "onTypeFormatting": true,
25
+ "selectionRanges": true,
26
+ "semanticHighlighting": true,
27
+ "completion": true
28
+ },
29
+ "[scss]": {
30
+ "editor.formatOnPaste": true,
31
+ "editor.formatOnSave": true,
32
+ "editor.formatOnType": true,
33
+ "editor.tabSize": 2
34
+ },
35
+ "launch": {
36
+ "configurations": [],
37
+ "compounds": []
38
+ },
39
+ "[erb]": {
40
+ "editor.tabSize": 2
41
+ },
42
+ "[html]": {
43
+ "editor.formatOnPaste": true,
44
+ "editor.formatOnSave": true,
45
+ "editor.formatOnType": true,
46
+ "editor.tabSize": 2
47
+ },
48
+ "[js]": {
49
+ "editor.formatOnPaste": true,
50
+ "editor.formatOnSave": true,
51
+ "editor.formatOnType": true,
52
+ "editor.tabSize": 2
53
+ },
54
+ "[json]": {
55
+ "editor.formatOnPaste": true,
56
+ "editor.formatOnSave": true,
57
+ "editor.formatOnType": true,
58
+ "editor.tabSize": 2
59
+ },
60
+ "[css]": {
61
+ "editor.formatOnPaste": true,
62
+ "editor.formatOnSave": true,
63
+ "editor.formatOnType": true,
64
+ "editor.tabSize": 2
65
+ },
66
+ "files.trimTrailingWhitespace": true,
67
+ "[sql]": {
68
+ "editor.defaultFormatter": "adpyke.vscode-sql-formatter"
69
+ }
70
+ }
data/README.md CHANGED
@@ -1,34 +1,228 @@
1
- # JadeSystemsToolbox
1
+ # Jade Systems' Toolbox
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ This gem installs a program to help do container-based development. It provides functions to:
4
4
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/jade_systems_toolbox`. To experiment with that code, run `bin/console` for an interactive prompt.
5
+ * Prepare a directory for development in containers, including some files to configure VScode.
6
+ * Bring up the container(s).
7
+ * Open VScode on the code in the container.
8
+ * Open a browser window on the application-under-development's web server.
9
+ * Open a terminal session on the application container.
10
+ * Show mapping of container ports to the ports on your host (laptop, development machine).
6
11
 
7
- ## Installation
12
+ [At the moment, this gem has been tested on Ubuntu. In theory, it will do the job for Windows, Macos, and Linux. Feel free to raise issues if it doesn't.]
8
13
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
14
+ One of many things this gem _doesn't_ do is impose a Ruby code style on you. The recommended extensions installed by the `init` command include formatting and linting using RuboCop, but you'll get the default RuboCop rules, or the rules from whatever other RuboCop gem you might use (e.g. https://github.com/rails/rubocop-rails-omakase, or https://github.com/standardrb/standard).
10
15
 
11
- Install the gem and add to the application's Gemfile by executing:
16
+ ## Installation
12
17
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
18
+ Don't install this gem in your application. It's meant to be a tool available everywhere on your device. Install the gem by executing:
14
19
 
15
- If bundler is not being used to manage dependencies, install the gem by executing:
20
+ ```bash
21
+ gem install --user-install jade_systems_toolbox
22
+ ```
16
23
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
24
+ (If you know what the implications are of _not_ putting `--user-install`, you can install the gem without it.)
18
25
 
19
26
  ## Usage
20
27
 
21
- TODO: Write usage instructions here
28
+ ### Summary
29
+
30
+ ```terminal
31
+ Commands:
32
+ tool down # docker compose down. Deletes the container. You probably want stop.
33
+ tool edit # devcontainer open
34
+ tool help [COMMAND] # Describe available commands or one specific command
35
+ tool init # Initialize compose files and devcontainer.json
36
+ tool initialize_docker # Initialize compose files
37
+ tool initilize_vscode # Initialize devcontainer.json for vscode
38
+ tool open # Open a page on the services's first port
39
+ tool port [CONTAINER_PORT] # Get the host port for the CONTAINER_PORT's container port CONTAINER_PORT
40
+ tool ports # Get the host ports for the container ports defined in `compose.yml`
41
+ tool server [COMMAND] # Run the server in the container
42
+ tool stop # Stop the service(s) but preserve the container(s)
43
+ tool terminal # Run a shell in the container
44
+ tool up # docker compose up -d
45
+ tool version # Show the version number of the tool.
46
+
47
+ Options:
48
+ -v, [--verbose], [--no-verbose], [--skip-verbose]
49
+ # Default: false
50
+ ```
51
+
52
+ ### Tutorial
53
+
54
+ The broad steps to start a brand new project are:
55
+
56
+ 1. Create a directory for the project, and change directory into the new directory.
57
+ 1. Decide which container(s) you want to use.
58
+ 1. Initialize the container(s).
59
+ 1. Bring up the container(s).
60
+ 1. Open a terminal session and create the application (e.g. `rails new` if you're doing a Rails project.)
61
+ 1. Run the editor and otherwise do what you need to do to create your project.
62
+ 1. When the web server is ready to run (if you're developing a web app), run the server.
63
+ 1. Open a browser window to the web server.
64
+ 1. When you're done, stop the containers.
65
+ 1. If you need to delete the containers, down tools.
66
+
67
+ To start:
68
+
69
+ ```bash
70
+ mkdir project && cd project
71
+ ```
72
+
73
+ #### Choose Containers
74
+
75
+ `tool` can install `compose.yml` for Rails development with SQLite, or Postgres, or MySQL, or MariaDB. You can also choose the Ruby version
76
+ [Coming soon: Install a compose file from any URL, and/or choose any image as the base.]
77
+
78
+ The default intialization command is:
79
+
80
+ ```bash
81
+ tool init
82
+ ```
83
+
84
+ The initialization installs
85
+
86
+ * A `compose.yml` file for Rails development with a SQLite database, using Ruby 3.4, and the `bookworm` version of Debian.
87
+ * On Linux, a `compose.override.yml` file.
88
+ * A `.devcontainer.json` file, so VScode can edit without the context of the container.
89
+ * `.vscode/settings.json` and `vscode/extensions.json` so developers have a consistent experience in VScode (mostly linting and autoformatting).
90
+
91
+ You can change some of the defaults. To choose another database:
92
+
93
+ ```bash
94
+ tool init --database postgres
95
+ ```
96
+
97
+ The choices are `mariadb`, `mysql`, `postgres`, and `sqlite`.
98
+
99
+ To choose a different ruby version and Debian version:
100
+
101
+ ```bash
102
+ tool init --ruby-version 3.2 --distro-version bullseye
103
+ ```
104
+
105
+ You can choose a currently supported Ruby version, and a Debian version that supports that Ruby version, from the containers built by https://github.com/lcreid/docker.
106
+
107
+ You're free to modify the `compose.yml` (and `compose.override.yml` on Linux). If you run `tool init` again, it will over-write your changes.
108
+
109
+ #### Start the Containers
110
+
111
+ ```bash
112
+ tool up
113
+ ```
114
+
115
+ This takes a while to run, the first time you run it when the image isn't already downloaded to your computer.
116
+
117
+ ### Open a Terminal Session
118
+
119
+ ```bash
120
+ tool terminal
121
+ ```
122
+
123
+ This connects to the `web` service defined in the `compose.yml` file. If you want to connect to another service:
124
+
125
+ ```bash
126
+ tool terminal --service mysql
127
+ ```
128
+
129
+ #### Start VScode
130
+
131
+ ```bash
132
+ tool edit
133
+ ```
134
+
135
+ #### Run the Server
136
+
137
+ ```bash
138
+ tool server
139
+ ```
140
+
141
+ This runs `bin/dev`. To run something else, e.g. a bare Puma so you can debug it:
142
+
143
+ ```bash
144
+ tool server "bin/rails s -b 0.0.0.0"
145
+ ```
146
+
147
+ If you have other services running servers, or the server is in a sub-directory of your project:
148
+
149
+ ```bash
150
+ tool server --work-dir test/app --service monitor
151
+ ```
152
+
153
+ To terminate the server, type Control-C.
154
+
155
+ #### Open a Browser Window
156
+
157
+ To connect to the server running on service `web` on port 3000:
158
+
159
+ ```bash
160
+ tool open
161
+ ```
162
+
163
+ If the server is listening on a different port:
164
+
165
+ ```bash
166
+ tool open --container-port 5990
167
+ ```
168
+
169
+ As usual, if the server is running in a different service:
170
+
171
+ ```bash
172
+ tool open --service monitor
173
+ ```
174
+
175
+ If you want to connect to a path other than `/`:
176
+
177
+ ```bash
178
+ tool open --path letter_opener
179
+ ```
180
+
181
+ #### Stop the Containers
182
+
183
+ ```bash
184
+ tool stop
185
+ ```
186
+
187
+ #### Bring Down the Containers
188
+
189
+ This destroys the containers, which will likely destroy all your gems.
190
+
191
+ ```bash
192
+ tool down
193
+ ```
194
+
195
+ Skip the confirmation mesage with:
196
+
197
+ ```bash
198
+ tool down --force
199
+ ```
22
200
 
23
201
  ## Development
24
202
 
25
203
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
204
 
27
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
205
+ To test locally without installing, run the executable like this:
206
+
207
+ ```bash
208
+ ruby -I lib exe/tool [COMMAND]
209
+ ```
210
+
211
+ To run in another directory, use the path from the directory you're in, to the directory where you checked out the gem's code. For example:
212
+
213
+ ```bash
214
+ ruby -I ../jade_systems_toolbox/lib ../jade_systems_toolbox/exe/tool [COMMAND]
215
+ ```
216
+
217
+ To install this gem onto your local machine, build it: `gem build jade_systems_toolbox.gemspec`, and install it: `gem install -l jade_systems_toolbox-0.1.4.gem`. (Change the version number to match the current version number.)
218
+
219
+ ## Release
220
+
221
+ To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
222
 
29
223
  ## Contributing
30
224
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jade_systems_toolbox. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/jade_systems_toolbox/blob/main/CODE_OF_CONDUCT.md).
225
+ Bug reports and pull requests are welcome on GitHub at https://github.com/lcreid/jade_systems_toolbox. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/lcreid/jade_systems_toolbox/blob/main/CODE_OF_CONDUCT.md).
32
226
 
33
227
  ## License
34
228
 
@@ -36,4 +230,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
36
230
 
37
231
  ## Code of Conduct
38
232
 
39
- Everyone interacting in the JadeSystemsToolbox project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/jade_systems_toolbox/blob/main/CODE_OF_CONDUCT.md).
233
+ Everyone interacting in the JadeSystemsToolbox project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/lcreid/jade_systems_toolbox/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -5,7 +5,6 @@ require "rake/testtask"
5
5
 
6
6
  Rake::TestTask.new(:test) do |t|
7
7
  t.libs << "test"
8
- t.libs << "lib"
9
8
  t.test_files = FileList["test/**/test_*.rb"]
10
9
  end
11
10
 
data/exe/tool CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  # To debug without installing, run as `ruby -I lib exe/tool...`
4
5
  require "jade_systems_toolbox"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module JadeSystemsToolbox
2
4
  class Cli < Thor
3
5
  # This and other improvements from Matt: https://mattbrictson.com/blog/fixing-thor-cli-behavior
@@ -12,36 +14,45 @@ module JadeSystemsToolbox
12
14
 
13
15
  class_option :verbose, type: :boolean, default: false, aliases: "-v"
14
16
 
15
- desc "down", "docker compose down"
17
+ desc "down", "docker compose down. Deletes the container. You probably want stop."
18
+ option :force, default: "n", aliases: "-f"
16
19
  def down
17
- `docker compose down`
20
+ force = ask("tool down destroys the containers. Are you sure?").downcase unless options[:force] == "y"
21
+ exit(1) if force[0] != "y"
22
+
23
+ system("docker compose down")
18
24
  end
19
25
 
20
- desc "edit", "devcontainer edit"
26
+ desc "edit", "devcontainer open"
21
27
  def edit
22
28
  `devcontainer open`
23
29
  end
24
30
 
31
+ desc "init", "Initialize compose files and devcontainer.json"
25
32
  option :compose_file, default: "compose.yml"
26
33
  option :database, default: "sqlite", aliases: "-d"
27
34
  option :ruby_version, default: "3.4", aliases: "-r"
28
35
  option :distro_version, default: "bookworm", aliases: "-t" # For Toy Story.
29
- desc "init", "Initialize compose files and devcontainer.json"
30
36
  def init
31
37
  invoke :initialize_docker
32
38
  invoke :initialize_vscode, [], {}
33
39
  end
34
40
 
41
+ desc "initialize_docker", "Initialize compose files"
35
42
  option :compose_file, default: "compose.yml"
36
43
  option :database, default: "sqlite", aliases: "-d"
37
44
  option :ruby_version, default: "3.4", aliases: "-r"
38
45
  option :distro_version, default: "bookworm", aliases: "-t" # For Toy Story.
39
- desc "initialize_docker", "Initialize compose files"
40
46
  def initialize_docker
41
- get_and_save_file("https://github.com/lcreid/docker/raw/refs/heads/main/rails-app-sqlite/compose.yml") do |file_contents|
47
+ get_and_save_file(
48
+ "https://github.com/lcreid/docker/raw/refs/heads/main/rails-app-sqlite/compose.yml",
49
+ ) do |file_contents|
42
50
  file_contents.gsub!(
43
51
  /jade:rails-app-[0-9]+\.[0-9]+-\w+-\w+$/,
44
- "jade:rails-app-#{options[:ruby_version] || '3.4'}-#{options[:database] || "sqlite"}-#{options[:distro_version] || bookworm}")
52
+ "jade:rails-app-#{options[:ruby_version] || "3.4"}" \
53
+ "-#{options[:database] || "sqlite"}" \
54
+ "-#{options[:distro_version] || "bookworm"}",
55
+ )
45
56
  end
46
57
 
47
58
  case Gem::Platform.local.os
@@ -52,18 +63,24 @@ module JadeSystemsToolbox
52
63
  end
53
64
  end
54
65
 
55
- desc "initilaize_vscode", "Initialize devcontainer.json for vscode"
66
+ desc "initilize_vscode", "Initialize devcontainer.json for vscode"
56
67
  def initialize_vscode
57
68
  get_and_save_file("https://github.com/lcreid/docker/raw/refs/heads/main/.devcontainer.json") do |file_contents|
58
69
  file_contents.gsub!(/, "compose.override.yml"/, "") unless Gem::Platform.local.os == "linux"
59
70
  end
71
+
72
+ Dir.mkdir(".vscode") unless Dir.exist?(".vscode")
73
+ [
74
+ "https://github.com/lcreid/jade_systems_toolbox/raw/refs/heads/main/templates/extensions.json",
75
+ "https://github.com/lcreid/jade_systems_toolbox/raw/refs/heads/main/templates/settings.json",
76
+ ].each { get_and_save_file(_1, target_directory: File.join(".", ".vscode")) }
60
77
  end
61
78
 
79
+ desc "open", "Open a page on the services's first port"
62
80
  option :service, default: "web"
63
81
  option :path, default: "/"
64
82
  option :container_port, default: 3000, type: :numeric
65
83
  option :protocol, default: "http"
66
- desc "open", "Open a page on the SERVICE's PORT"
67
84
  def open
68
85
  service = options[:service]
69
86
  path = options[:path]
@@ -72,6 +89,7 @@ module JadeSystemsToolbox
72
89
 
73
90
  container_ports = compose_yaml.dig("services", "service", "ports")
74
91
  container_port = container_ports&.[](0) || container_port
92
+ path = "/#{path}" if path[0] != "/"
75
93
  `open "#{protocol}://localhost:#{host_port_from_container_port(service:, container_port:)}#{path}"`
76
94
  end
77
95
 
@@ -83,9 +101,10 @@ module JadeSystemsToolbox
83
101
  end
84
102
 
85
103
  desc "ports", "Get the host ports for the container ports defined in `compose.yml`"
104
+ option :compose_file, default: "compose.yml"
86
105
  def ports
87
106
  services = compose_yaml["services"]
88
- service_ports = services.map { |service, attributes| [service, attributes&.[]("ports")] }.to_h
107
+ service_ports = services.transform_values { |attributes| attributes&.[]("ports") }
89
108
 
90
109
  service_ports.each do |service, ports|
91
110
  ports&.each do |container_port|
@@ -100,34 +119,44 @@ module JadeSystemsToolbox
100
119
  def server(command = "bin/dev")
101
120
  service = options[:service]
102
121
  workdir = "-w #{options[:work_dir]} " unless options[:work_dir].nil?
103
- puts("docker compose exec #{workdir}#{service} #{command}")
104
- run_via_pty("docker compose exec #{workdir}#{service} #{command}")
122
+ system("docker compose exec #{workdir}#{service} #{command}")
123
+ end
124
+
125
+ desc "stop", "Stop the service(s) but preserve the container(s)"
126
+ def stop
127
+ system("docker compose stop")
105
128
  end
106
129
 
107
130
  desc "terminal", "Run a shell in the container"
108
131
  option :service, default: "web"
109
132
  def terminal
110
133
  service = options[:service]
111
- run_via_pty("docker compose exec -it #{service} '/bin/bash'")
134
+ system("docker compose exec -it #{service} '/bin/bash'")
112
135
  end
113
136
 
114
137
  desc "up", "docker compose up -d"
115
138
  def up
116
- `docker compose up -d`
139
+ system("docker compose up -d")
140
+ end
141
+
142
+ desc "version", "Show the version number of the tool."
143
+ def version
144
+ puts JadeSystemsToolbox::VERSION
117
145
  end
118
146
 
119
147
  private
120
148
 
121
- def compose_yaml = @compose_yaml ||= YAML.load_file(options[:compose_file])
149
+ def compose_yaml = @compose_yaml ||= YAML.load_file(options[:compose_file] || "compose.yml")
122
150
 
123
- def get_and_save_file(url)
124
- file_name = Pathname.new(url).basename.to_s
125
- file_contents = get_file_from_internet(url: )
151
+ def get_and_save_file(url, target_directory: nil)
152
+ file_contents = get_file_from_internet(url:)
126
153
  yield file_contents if block_given?
154
+ file_name = Pathname.new(url).basename.to_s
155
+ file_name = Pathname.new(target_directory) + file_name unless target_directory.nil?
127
156
  File.write(file_name, file_contents)
128
157
  end
129
158
 
130
- def get_file_from_internet(redirects: 10, url:)
159
+ def get_file_from_internet(url:, redirects: 10)
131
160
  raise Errorl.new("Too many redirects", options[:verbose]) if redirects.zero?
132
161
 
133
162
  uri = URI.parse(url)
@@ -139,13 +168,13 @@ module JadeSystemsToolbox
139
168
  when Net::HTTPSuccess
140
169
  response.body
141
170
  when Net::HTTPRedirection
142
- get_file_from_internet(redirects: redirects - 1, url: response['location'])
171
+ get_file_from_internet(redirects: redirects - 1, url: response["location"])
143
172
  else
144
173
  response.error!
145
174
  end
146
175
  end
147
176
 
148
- def host_port_from_container_port(service: "web", container_port:)
177
+ def host_port_from_container_port(container_port:, service: "web")
149
178
  ports = container_port.to_s.match(/([0-9]+:){0,1}([0-9]+$)/)
150
179
  if !ports[1].nil?
151
180
  ports[2].to_s
@@ -154,40 +183,5 @@ module JadeSystemsToolbox
154
183
  output.match(/[0-9]+$/)
155
184
  end
156
185
  end
157
-
158
- # A variation with popen was here:
159
- # https://nickcharlton.net/posts/ruby-subprocesses-with-stdout-stderr-streams.html
160
- # This implementation inspired by the docs:
161
- # https://docs.ruby-lang.org/en/3.4/PTY.html#method-c-spawn
162
- def run_via_pty(command)
163
- child_stdout_stderr, child_stdin, pid = PTY.spawn(command)
164
- puts "PID: #{pid}" if options[:verbose]
165
- io_threads = [
166
- me = Thread.new do
167
- $stdout.raw do |stdout|
168
- until (c = child_stdout_stderr.getc).nil? do
169
- stdout.putc c
170
- end
171
- end
172
- rescue Errno::EIO => exception
173
- puts exception.message if options[:verbose]
174
- me.terminate
175
- end,
176
- me = Thread.new do
177
- until (c = $stdin.getc).nil? do
178
- child_stdin.putc c
179
- end
180
- rescue Errno::EIO => exception
181
- puts exception.message if options[:verbose]
182
- me.terminate
183
- end,
184
- ]
185
- io_threads.each { _1.join }
186
- ensure
187
- io_threads.each { _1.terminate if _1.alive? }
188
- child_stdout_stderr.close
189
- child_stdin.close
190
- Process.wait(pid)
191
- end
192
186
  end
193
187
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module JadeSystemsToolbox
2
4
  class ErrorReporter < Thor
3
5
  class << self
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JadeSystemsToolbox
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.4"
5
5
  end
@@ -2,9 +2,7 @@
2
2
 
3
3
  require "debug"
4
4
  require "net/http"
5
- require "open3"
6
5
  require "pathname"
7
- require "pty"
8
6
  require "thor"
9
7
  require "yaml"
10
8
 
@@ -0,0 +1,16 @@
1
+ {
2
+ // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3
+ // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4
+ // List of extensions which should be recommended for users of this workspace.
5
+ "recommendations": [
6
+ "adpyke.vscode-sql-formatter",
7
+ "eamodio.gitlens",
8
+ "esbenp.prettier-vscode",
9
+ "mechatroner.rainbow-csv",
10
+ "ms-vsliveshare.vsliveshare",
11
+ "redhat.vscode-yaml",
12
+ "shopify.ruby-extensions-pack",
13
+ ],
14
+ // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
15
+ "unwantedRecommendations": []
16
+ }
@@ -0,0 +1,70 @@
1
+ {
2
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
3
+ "[ruby]": {
4
+ "editor.defaultFormatter": "Shopify.ruby-lsp",
5
+ "editor.formatOnPaste": true,
6
+ "editor.formatOnSave": true,
7
+ "editor.formatOnType": true,
8
+ "editor.tabSize": 2
9
+ },
10
+ "rubyLsp.formatter": "rubocop",
11
+ "rubyLsp.linters": [
12
+ "rubocop"
13
+ ],
14
+ "rubyLsp.enabledFeatures": {
15
+ "codeActions": true,
16
+ "diagnostics": true,
17
+ "documentHighlights": true,
18
+ "documentLink": true,
19
+ "documentSymbols": true,
20
+ "foldingRanges": true,
21
+ "formatting": true,
22
+ "hover": true,
23
+ "inlayHint": true,
24
+ "onTypeFormatting": true,
25
+ "selectionRanges": true,
26
+ "semanticHighlighting": true,
27
+ "completion": true
28
+ },
29
+ "[scss]": {
30
+ "editor.formatOnPaste": true,
31
+ "editor.formatOnSave": true,
32
+ "editor.formatOnType": true,
33
+ "editor.tabSize": 2
34
+ },
35
+ "launch": {
36
+ "configurations": [],
37
+ "compounds": []
38
+ },
39
+ "[erb]": {
40
+ "editor.tabSize": 2
41
+ },
42
+ "[html]": {
43
+ "editor.formatOnPaste": true,
44
+ "editor.formatOnSave": true,
45
+ "editor.formatOnType": true,
46
+ "editor.tabSize": 2
47
+ },
48
+ "[js]": {
49
+ "editor.formatOnPaste": true,
50
+ "editor.formatOnSave": true,
51
+ "editor.formatOnType": true,
52
+ "editor.tabSize": 2
53
+ },
54
+ "[json]": {
55
+ "editor.formatOnPaste": true,
56
+ "editor.formatOnSave": true,
57
+ "editor.formatOnType": true,
58
+ "editor.tabSize": 2
59
+ },
60
+ "[css]": {
61
+ "editor.formatOnPaste": true,
62
+ "editor.formatOnSave": true,
63
+ "editor.formatOnType": true,
64
+ "editor.tabSize": 2
65
+ },
66
+ "files.trimTrailingWhitespace": true,
67
+ "[sql]": {
68
+ "editor.defaultFormatter": "adpyke.vscode-sql-formatter"
69
+ }
70
+ }
metadata CHANGED
@@ -1,43 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jade_systems_toolbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Larry Reid
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2025-07-06 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: open3
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.1'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '0.1'
27
- - !ruby/object:Gem::Dependency
28
- name: pathname
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '0.2'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '0.2'
41
12
  - !ruby/object:Gem::Dependency
42
13
  name: thor
43
14
  requirement: !ruby/object:Gem::Requirement
@@ -52,21 +23,6 @@ dependencies:
52
23
  - - "~>"
53
24
  - !ruby/object:Gem::Version
54
25
  version: '1.3'
55
- - !ruby/object:Gem::Dependency
56
- name: yaml
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '0.2'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '0.2'
69
- description:
70
26
  email:
71
27
  - lcreid@jadesystems.ca
72
28
  executables:
@@ -75,18 +31,21 @@ extensions: []
75
31
  extra_rdoc_files: []
76
32
  files:
77
33
  - ".rubocop.yml"
34
+ - ".vscode/extensions.json"
35
+ - ".vscode/settings.json"
78
36
  - CHANGELOG.md
79
37
  - CODE_OF_CONDUCT.md
80
38
  - LICENSE.txt
81
39
  - README.md
82
40
  - Rakefile
83
41
  - exe/tool
84
- - jade_systems_toolbox.gemspec
85
42
  - lib/jade_systems_toolbox.rb
86
43
  - lib/jade_systems_toolbox/cli.rb
87
44
  - lib/jade_systems_toolbox/error_reporter.rb
88
45
  - lib/jade_systems_toolbox/version.rb
89
46
  - sig/jade_systems_toolbox.rbs
47
+ - templates/extensions.json
48
+ - templates/settings.json
90
49
  homepage: https://github.com/lcreid/jade_systems_toolbox
91
50
  licenses:
92
51
  - MIT
@@ -94,7 +53,6 @@ metadata:
94
53
  homepage_uri: https://github.com/lcreid/jade_systems_toolbox
95
54
  source_code_uri: https://github.com/lcreid/jade_systems_toolbox
96
55
  changelog_uri: https://github.com/lcreid/jade_systems_toolbox/CHANGELOG.nd
97
- post_install_message:
98
56
  rdoc_options: []
99
57
  require_paths:
100
58
  - lib
@@ -109,8 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
67
  - !ruby/object:Gem::Version
110
68
  version: '0'
111
69
  requirements: []
112
- rubygems_version: 3.4.20
113
- signing_key:
70
+ rubygems_version: 4.0.6
114
71
  specification_version: 4
115
72
  summary: A collection of command line commands to support development.
116
73
  test_files: []
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/jade_systems_toolbox/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "jade_systems_toolbox"
7
- spec.version = JadeSystemsToolbox::VERSION
8
- spec.authors = ["Larry Reid"]
9
- spec.email = ["lcreid@jadesystems.ca"]
10
-
11
- spec.summary = "A collection of command line commands to support development."
12
- spec.homepage = "https://github.com/lcreid/jade_systems_toolbox"
13
- spec.license = "MIT"
14
- spec.required_ruby_version = ">= 3.2"
15
-
16
- spec.metadata["homepage_uri"] = spec.homepage
17
- spec.metadata["source_code_uri"] = spec.homepage
18
- spec.metadata["changelog_uri"] = File.join(spec.homepage, "CHANGELOG.nd")
19
-
20
- # Specify which files should be added to the gem when it is released.
21
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
- spec.files = Dir.chdir(__dir__) do
23
- `git ls-files -z`.split("\x0").reject do |f|
24
- (File.expand_path(f) == __FILE__) ||
25
- f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
26
- end
27
- end
28
- spec.bindir = "exe"
29
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
- spec.require_paths = ["lib"]
31
-
32
- spec.add_dependency "open3", "~> 0.1"
33
- spec.add_dependency "pathname", "~> 0.2"
34
- spec.add_dependency "thor", "~> 1.3"
35
- spec.add_dependency "yaml", "~> 0.2"
36
-
37
- # For more information and examples about making a new gem, check out our
38
- # guide at: https://bundler.io/guides/creating_gem.html
39
- end