jade_systems_toolbox 0.1.0 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +27 -7
- data/.vscode/extensions.json +16 -0
- data/.vscode/settings.json +70 -0
- data/README.md +191 -13
- data/Rakefile +0 -1
- data/exe/tool +1 -0
- data/lib/jade_systems_toolbox/cli.rb +40 -55
- data/lib/jade_systems_toolbox/error_reporter.rb +2 -0
- data/lib/jade_systems_toolbox/version.rb +1 -1
- data/lib/jade_systems_toolbox.rb +0 -2
- data/templates/extensions.json +16 -0
- data/templates/settings.json +70 -0
- metadata +7 -50
- data/jade_systems_toolbox.gemspec +0 -39
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 77d28ae152583dfee09836b6c268f052e18a3e065db172036839fe63ae1da1f0
|
|
4
|
+
data.tar.gz: '08307e9fb8f296a5e71e2d990e7a2edd387e1f9a0cea8d53d1d015da2feefd92'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4ab241764b4b1514a4d770a605b2db8053b03986be8e5164a1813832e1241bf97698582046122565642b6d0b9cdb6023c2ca0912923d95224ffff54680733beb
|
|
7
|
+
data.tar.gz: cf374537e612eb3011dd2f7dae3d57b318a7d3be9439609f61dff5bc7d87e937d8cbedf2b91a454118dbfd8428f0d6c66ec84f68633bfc3688e5f96f61ef0d45
|
data/.rubocop.yml
CHANGED
|
@@ -1,13 +1,33 @@
|
|
|
1
1
|
AllCops:
|
|
2
|
-
TargetRubyVersion: 2
|
|
2
|
+
TargetRubyVersion: 3.2
|
|
3
3
|
|
|
4
|
-
|
|
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
|
-
|
|
13
|
+
Layout/IndentationConsistency:
|
|
9
14
|
Enabled: true
|
|
10
|
-
EnforcedStyle:
|
|
15
|
+
EnforcedStyle: normal
|
|
11
16
|
|
|
12
|
-
Layout/
|
|
13
|
-
|
|
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,212 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Jade Systems' Toolbox
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This gem installs a program to help do container-based development. It provides functions to:
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
16
|
+
## Installation
|
|
12
17
|
|
|
13
|
-
|
|
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
|
-
|
|
20
|
+
```bash
|
|
21
|
+
gem install --user-install jade_systems_toolbox
|
|
22
|
+
```
|
|
16
23
|
|
|
17
|
-
|
|
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
|
-
|
|
28
|
+
### Summary
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
Commands:
|
|
32
|
+
tool down # docker compose down
|
|
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 initialize_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 terminal # Run a shell in the container
|
|
43
|
+
tool up # docker compose up -d
|
|
44
|
+
tool version # Show the version number of the tool.
|
|
45
|
+
|
|
46
|
+
Options:
|
|
47
|
+
-v, [--verbose], [--no-verbose], [--skip-verbose]
|
|
48
|
+
# Default: false
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Tutorial
|
|
52
|
+
|
|
53
|
+
The broad steps to start a brand new project are:
|
|
54
|
+
|
|
55
|
+
1. Create a directory for the project, and change directory into the new directory.
|
|
56
|
+
1. Decide which container(s) you want to use.
|
|
57
|
+
1. Initialize the container(s).
|
|
58
|
+
1. Bring up the container(s).
|
|
59
|
+
1. Open a terminal session and create the application (e.g. `rails new` if you're doing a Rails project.)
|
|
60
|
+
1. Run the editor and otherwise do what you need to do to create your project.
|
|
61
|
+
1. When the web server is ready to run (if you're developing a web app), run the server.
|
|
62
|
+
1. Open a browser window to the web server.
|
|
63
|
+
1. When you're done, bring down the containers.
|
|
64
|
+
|
|
65
|
+
To start:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
mkdir project && cd project
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
#### Choose Containers
|
|
72
|
+
|
|
73
|
+
`tool` can install `compose.yml` for Rails development with SQLite, or Postgres, or MySQL, or MariaDB. You can also choose the Ruby version
|
|
74
|
+
[Coming soon: Install a compose file from any URL, and/or choose any image as the base.]
|
|
75
|
+
|
|
76
|
+
The default intialization command is:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
tool init
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The initialization installs
|
|
83
|
+
|
|
84
|
+
* A `compose.yml` file for Rails development with a SQLite database, using Ruby 3.4, and the `bookworm` version of Debian.
|
|
85
|
+
* On Linux, a `compose.override.yml` file.
|
|
86
|
+
* A `.devcontainer.json` file, so VScode can edit without the context of the container.
|
|
87
|
+
* `.vscode/settings.json` and `vscode/extensions.json` so developers have a consistent experience in VScode (mostly linting and autoformatting).
|
|
88
|
+
|
|
89
|
+
You can change some of the defaults. To choose another database:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
tool init --database postgres
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The choices are `mariadb`, `mysql`, `postgres`, and `sqlite`.
|
|
96
|
+
|
|
97
|
+
To choose a different ruby version and Debian version:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
tool init --ruby-version 3.2 --distro-version bullseye
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
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.
|
|
104
|
+
|
|
105
|
+
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.
|
|
106
|
+
|
|
107
|
+
#### Start the Containers
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
tool up
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
This takes a while to run, the first time you run it when the image isn't already downloaded to your computer.
|
|
114
|
+
|
|
115
|
+
### Open a Terminal Session
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
tool terminal
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
This connects to the `web` service defined in the `compose.yml` file. If you want to connect to another service:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
tool terminal --service mysql
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### Start VScode
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
tool edit
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
#### Run the Server
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
tool server
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
This runs `bin/dev`. To run something else, e.g. a bare Puma so you can debug it:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
tool server "bin/rails s -b 0.0.0.0"
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
If you have other services running servers, or the server is in a sub-directory of your project:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
tool server --work-dir test/app --service monitor
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
To terminate the server, type Control-C.
|
|
152
|
+
|
|
153
|
+
#### Open a Browser Window
|
|
154
|
+
|
|
155
|
+
To connect to the server running on service `web` on port 3000:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
tool open
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
If the server is listening on a different port:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
tool open --container-port 5990
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
As usual, if the server is running in a different service:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
tool open --service monitor
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
If you want to connect to a path other than `/`:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
tool open --path letter_opener
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
#### Bring Down the Containers
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
tool down
|
|
183
|
+
```
|
|
22
184
|
|
|
23
185
|
## Development
|
|
24
186
|
|
|
25
187
|
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
188
|
|
|
27
|
-
To
|
|
189
|
+
To test locally without installing, run the executable like this:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
ruby -I lib exe/tool [COMMAND]
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
To run in another directory, use the path name from the directory you're in, to the directory where you checked out the gem's code, for example:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
ruby -I ../jade_systems_toolbox/lib ../jade_systems_toolbox/exe/tool [COMMAND]
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
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.2.gem`. (Change the version number to match the current version number.)
|
|
202
|
+
|
|
203
|
+
## Release
|
|
204
|
+
|
|
205
|
+
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
206
|
|
|
29
207
|
## Contributing
|
|
30
208
|
|
|
31
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
|
209
|
+
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
210
|
|
|
33
211
|
## License
|
|
34
212
|
|
|
@@ -36,4 +214,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
|
36
214
|
|
|
37
215
|
## Code of Conduct
|
|
38
216
|
|
|
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/
|
|
217
|
+
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
data/exe/tool
CHANGED
|
@@ -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
|
|
@@ -14,34 +16,39 @@ module JadeSystemsToolbox
|
|
|
14
16
|
|
|
15
17
|
desc "down", "docker compose down"
|
|
16
18
|
def down
|
|
17
|
-
|
|
19
|
+
system("docker compose down")
|
|
18
20
|
end
|
|
19
21
|
|
|
20
|
-
desc "edit", "devcontainer
|
|
22
|
+
desc "edit", "devcontainer open"
|
|
21
23
|
def edit
|
|
22
24
|
`devcontainer open`
|
|
23
25
|
end
|
|
24
26
|
|
|
27
|
+
desc "init", "Initialize compose files and devcontainer.json"
|
|
25
28
|
option :compose_file, default: "compose.yml"
|
|
26
29
|
option :database, default: "sqlite", aliases: "-d"
|
|
27
30
|
option :ruby_version, default: "3.4", aliases: "-r"
|
|
28
31
|
option :distro_version, default: "bookworm", aliases: "-t" # For Toy Story.
|
|
29
|
-
desc "init", "Initialize compose files and devcontainer.json"
|
|
30
32
|
def init
|
|
31
33
|
invoke :initialize_docker
|
|
32
34
|
invoke :initialize_vscode, [], {}
|
|
33
35
|
end
|
|
34
36
|
|
|
37
|
+
desc "initialize_docker", "Initialize compose files"
|
|
35
38
|
option :compose_file, default: "compose.yml"
|
|
36
39
|
option :database, default: "sqlite", aliases: "-d"
|
|
37
40
|
option :ruby_version, default: "3.4", aliases: "-r"
|
|
38
41
|
option :distro_version, default: "bookworm", aliases: "-t" # For Toy Story.
|
|
39
|
-
desc "initialize_docker", "Initialize compose files"
|
|
40
42
|
def initialize_docker
|
|
41
|
-
get_and_save_file(
|
|
43
|
+
get_and_save_file(
|
|
44
|
+
"https://github.com/lcreid/docker/raw/refs/heads/main/rails-app-sqlite/compose.yml",
|
|
45
|
+
) do |file_contents|
|
|
42
46
|
file_contents.gsub!(
|
|
43
47
|
/jade:rails-app-[0-9]+\.[0-9]+-\w+-\w+$/,
|
|
44
|
-
"jade:rails-app-#{options[:ruby_version] ||
|
|
48
|
+
"jade:rails-app-#{options[:ruby_version] || "3.4"}" \
|
|
49
|
+
"-#{options[:database] || "sqlite"}" \
|
|
50
|
+
"-#{options[:distro_version] || bookworm}",
|
|
51
|
+
)
|
|
45
52
|
end
|
|
46
53
|
|
|
47
54
|
case Gem::Platform.local.os
|
|
@@ -52,18 +59,24 @@ module JadeSystemsToolbox
|
|
|
52
59
|
end
|
|
53
60
|
end
|
|
54
61
|
|
|
55
|
-
desc "
|
|
62
|
+
desc "initilize_vscode", "Initialize devcontainer.json for vscode"
|
|
56
63
|
def initialize_vscode
|
|
57
64
|
get_and_save_file("https://github.com/lcreid/docker/raw/refs/heads/main/.devcontainer.json") do |file_contents|
|
|
58
65
|
file_contents.gsub!(/, "compose.override.yml"/, "") unless Gem::Platform.local.os == "linux"
|
|
59
66
|
end
|
|
67
|
+
|
|
68
|
+
Dir.mkdir(".vscode") unless Dir.exist?(".vscode")
|
|
69
|
+
[
|
|
70
|
+
"https://github.com/lcreid/jade_systems_toolbox/raw/refs/heads/main/templates/extensions.json",
|
|
71
|
+
"https://github.com/lcreid/jade_systems_toolbox/raw/refs/heads/main/templates/settings.json",
|
|
72
|
+
].each { get_and_save_file(_1, target_directory: File.join(".", ".vscode")) }
|
|
60
73
|
end
|
|
61
74
|
|
|
75
|
+
desc "open", "Open a page on the services's first port"
|
|
62
76
|
option :service, default: "web"
|
|
63
77
|
option :path, default: "/"
|
|
64
78
|
option :container_port, default: 3000, type: :numeric
|
|
65
79
|
option :protocol, default: "http"
|
|
66
|
-
desc "open", "Open a page on the SERVICE's PORT"
|
|
67
80
|
def open
|
|
68
81
|
service = options[:service]
|
|
69
82
|
path = options[:path]
|
|
@@ -72,6 +85,7 @@ module JadeSystemsToolbox
|
|
|
72
85
|
|
|
73
86
|
container_ports = compose_yaml.dig("services", "service", "ports")
|
|
74
87
|
container_port = container_ports&.[](0) || container_port
|
|
88
|
+
path = "/#{path}" if path[0] != "/"
|
|
75
89
|
`open "#{protocol}://localhost:#{host_port_from_container_port(service:, container_port:)}#{path}"`
|
|
76
90
|
end
|
|
77
91
|
|
|
@@ -83,9 +97,10 @@ module JadeSystemsToolbox
|
|
|
83
97
|
end
|
|
84
98
|
|
|
85
99
|
desc "ports", "Get the host ports for the container ports defined in `compose.yml`"
|
|
100
|
+
option :compose_file, default: "compose.yml"
|
|
86
101
|
def ports
|
|
87
102
|
services = compose_yaml["services"]
|
|
88
|
-
service_ports = services.
|
|
103
|
+
service_ports = services.transform_values { |attributes| attributes&.[]("ports") }
|
|
89
104
|
|
|
90
105
|
service_ports.each do |service, ports|
|
|
91
106
|
ports&.each do |container_port|
|
|
@@ -100,34 +115,39 @@ module JadeSystemsToolbox
|
|
|
100
115
|
def server(command = "bin/dev")
|
|
101
116
|
service = options[:service]
|
|
102
117
|
workdir = "-w #{options[:work_dir]} " unless options[:work_dir].nil?
|
|
103
|
-
|
|
104
|
-
run_via_pty("docker compose exec #{workdir}#{service} #{command}")
|
|
118
|
+
system("docker compose exec #{workdir}#{service} #{command}")
|
|
105
119
|
end
|
|
106
120
|
|
|
107
121
|
desc "terminal", "Run a shell in the container"
|
|
108
122
|
option :service, default: "web"
|
|
109
123
|
def terminal
|
|
110
124
|
service = options[:service]
|
|
111
|
-
|
|
125
|
+
system("docker compose exec -it #{service} '/bin/bash'")
|
|
112
126
|
end
|
|
113
127
|
|
|
114
128
|
desc "up", "docker compose up -d"
|
|
115
129
|
def up
|
|
116
|
-
|
|
130
|
+
system("docker compose up -d")
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
desc "version", "Show the version number of the tool."
|
|
134
|
+
def version
|
|
135
|
+
puts JadeSystemsToolbox::VERSION
|
|
117
136
|
end
|
|
118
137
|
|
|
119
138
|
private
|
|
120
139
|
|
|
121
|
-
def compose_yaml = @compose_yaml ||= YAML.load_file(options[:compose_file])
|
|
140
|
+
def compose_yaml = @compose_yaml ||= YAML.load_file(options[:compose_file] || "compose.yml")
|
|
122
141
|
|
|
123
|
-
def get_and_save_file(url)
|
|
124
|
-
|
|
125
|
-
file_contents = get_file_from_internet(url: )
|
|
142
|
+
def get_and_save_file(url, target_directory: nil)
|
|
143
|
+
file_contents = get_file_from_internet(url:)
|
|
126
144
|
yield file_contents if block_given?
|
|
145
|
+
file_name = Pathname.new(url).basename.to_s
|
|
146
|
+
file_name = Pathname.new(target_directory) + file_name unless target_directory.nil?
|
|
127
147
|
File.write(file_name, file_contents)
|
|
128
148
|
end
|
|
129
149
|
|
|
130
|
-
def get_file_from_internet(redirects: 10
|
|
150
|
+
def get_file_from_internet(url:, redirects: 10)
|
|
131
151
|
raise Errorl.new("Too many redirects", options[:verbose]) if redirects.zero?
|
|
132
152
|
|
|
133
153
|
uri = URI.parse(url)
|
|
@@ -139,13 +159,13 @@ module JadeSystemsToolbox
|
|
|
139
159
|
when Net::HTTPSuccess
|
|
140
160
|
response.body
|
|
141
161
|
when Net::HTTPRedirection
|
|
142
|
-
get_file_from_internet(redirects: redirects - 1, url: response[
|
|
162
|
+
get_file_from_internet(redirects: redirects - 1, url: response["location"])
|
|
143
163
|
else
|
|
144
164
|
response.error!
|
|
145
165
|
end
|
|
146
166
|
end
|
|
147
167
|
|
|
148
|
-
def host_port_from_container_port(service: "web"
|
|
168
|
+
def host_port_from_container_port(container_port:, service: "web")
|
|
149
169
|
ports = container_port.to_s.match(/([0-9]+:){0,1}([0-9]+$)/)
|
|
150
170
|
if !ports[1].nil?
|
|
151
171
|
ports[2].to_s
|
|
@@ -154,40 +174,5 @@ module JadeSystemsToolbox
|
|
|
154
174
|
output.match(/[0-9]+$/)
|
|
155
175
|
end
|
|
156
176
|
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
177
|
end
|
|
193
178
|
end
|
data/lib/jade_systems_toolbox.rb
CHANGED
|
@@ -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.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Larry Reid
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
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.
|
|
113
|
-
signing_key:
|
|
70
|
+
rubygems_version: 3.6.7
|
|
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
|