setup_script_generator 0.2.3 → 0.2.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 +4 -4
- data/.editorconfig +2 -0
- data/.gitignore +1 -0
- data/.tool-versions +1 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +1 -1
- data/README.md +66 -51
- data/bin/setup +99 -3
- data/lib/setup_script_generator/templates/provisions/ruby.sh +2 -0
- data/lib/setup_script_generator/version.rb +1 -1
- data/setup_script_generator.gemspec +0 -4
- metadata +5 -33
- data/.ruby-version +0 -1
- data/Gemfile.lock +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7abbab871c8809934382abcaded81af412afe8a30837dbbb9337d48e8eb0fb02
|
4
|
+
data.tar.gz: 9b220d798bac841e9436822710fc55f131b284b660cbbad30cd03f3ffb5ca71b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b04ff789fdf36f3914d30a3bb1dd37881d637b4566d850a3c5aa681cbdd4570f6f9b11146f4d12b6bf415a026ea93bde4d6ff16e57108c71f3ac25da3ef57385
|
7
|
+
data.tar.gz: 314df7615aa78a2cb4e9881c876e0b1669658bc92f2d9ad5d20c5fbf99ae1fd459688f4daf2a1b8e203c4ce3402d0c5c132c1e39155815abbc34fd1abd14a67e
|
data/.editorconfig
ADDED
data/.gitignore
CHANGED
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.7.1
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,81 +1,96 @@
|
|
1
1
|
# Setup Script Generator
|
2
2
|
|
3
|
-
Every project needs a [setup script][setup-script]
|
4
|
-
|
5
|
-
|
3
|
+
Every project needs a [setup script][setup-script]
|
4
|
+
to quickly ready new developers for contributing to the project.
|
5
|
+
However, a good setup script is time-consuming to write:
|
6
6
|
|
7
7
|
[setup-script]: https://thoughtbot.com/blog/shell-script-suggestions-for-speedy-setups
|
8
8
|
|
9
|
-
The
|
9
|
+
* The script must make sure that the proper version of your project's language is installed,
|
10
|
+
taking into account the usage of version managers.
|
11
|
+
* The script must be idempotent,
|
12
|
+
installing new requirements while skipping over existing ones.
|
13
|
+
* The script must provide friendly messages (successful or otherwise).
|
14
|
+
* The script must be quick to run.
|
15
|
+
* The script must be usable on multiple platforms.
|
16
|
+
* The script must be easy to read and maintain.
|
10
17
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
* The script must make sure that the proper version of your project's
|
16
|
-
implementation language is installed, and if said language has version
|
17
|
-
managers (such as for Ruby or Node), the script must take them into account
|
18
|
-
as well.
|
19
|
-
* The script must provide friendly errors if any checks fail.
|
20
|
-
(Bonus points for colors and/or emoji.)
|
21
|
-
* The script must be idempotent, so that if changes to the development are
|
22
|
-
made, the script can be run again, and any requirements that are already
|
23
|
-
satisfied will be skipped, while new requirements will be installed.
|
24
|
-
* The script must be easy to read and maintain in the future.
|
18
|
+
Given these constraints,
|
19
|
+
this project generates a setup script that you can place in your own project.
|
20
|
+
This script is implemented in Bash
|
21
|
+
so that it is is performant, portable, and maintainable.
|
25
22
|
|
26
|
-
|
27
|
-
project, so that you can keep all of your teammates on the same page and offer
|
28
|
-
them a nice experience going forward.
|
29
|
-
|
30
|
-
## Installation
|
31
|
-
|
32
|
-
Currently, the generator is available through a Ruby gem. You can install this
|
33
|
-
gem by first installing Ruby, then running:
|
23
|
+
## Usage
|
34
24
|
|
35
|
-
|
25
|
+
Currently, the generator is available through a Ruby gem.
|
26
|
+
You can install this gem by first installing Ruby, then by running:
|
36
27
|
|
37
|
-
|
28
|
+
```
|
29
|
+
gem install setup_script_generator
|
30
|
+
```
|
38
31
|
|
39
|
-
After installing the gem, navigate to your project.
|
40
|
-
|
32
|
+
After installing the gem, navigate to your project.
|
33
|
+
You now have the `generate-setup` command
|
34
|
+
which will allow you to generate a setup script where you like.
|
35
|
+
A common location is `bin/setup`, so you could say:
|
41
36
|
|
42
37
|
generate-setup bin/setup
|
43
38
|
|
44
|
-
Now
|
45
|
-
|
46
|
-
|
47
|
-
|
39
|
+
Now open up this file in your editor.
|
40
|
+
By default, this script is fairly empty,
|
41
|
+
although it does offer a section at the top
|
42
|
+
to which you can add custom code:
|
48
43
|
|
49
|
-
|
44
|
+
``` bash
|
45
|
+
provision-project() {
|
46
|
+
# ...
|
47
|
+
}
|
48
|
+
```
|
50
49
|
|
51
|
-
|
50
|
+
While it is perfectly fine to update this function,
|
51
|
+
you will probably find it more useful to run `generate-setup` with a set of *provisions*.
|
52
|
+
These extend your script with checks and installation steps
|
53
|
+
for languages, frameworks, or services on which your project relies.
|
54
|
+
For instance, if your project requires Ruby,
|
55
|
+
then you'd want to run:
|
52
56
|
|
53
|
-
|
57
|
+
```
|
58
|
+
generate-setup bin/setup --provision ruby
|
59
|
+
```
|
54
60
|
|
55
|
-
|
61
|
+
(Don't worry, if you've already run `generate-setup`,
|
62
|
+
you can re-run it at any point in the future
|
63
|
+
to add or remove provisions.)
|
56
64
|
|
57
|
-
|
65
|
+
You can also use more than one provision if that's what you need:
|
58
66
|
|
59
|
-
|
60
|
-
|
67
|
+
```
|
68
|
+
generate-setup bin/setup --provision ruby --provision node
|
69
|
+
```
|
61
70
|
|
62
|
-
|
71
|
+
And you can get a list of available provisions by running:
|
72
|
+
|
73
|
+
```
|
74
|
+
generate-setup --list-provisions
|
75
|
+
```
|
63
76
|
|
64
77
|
Finally, to see the full list of options, run:
|
65
78
|
|
66
|
-
|
79
|
+
```
|
80
|
+
generate-setup --help
|
81
|
+
```
|
67
82
|
|
68
83
|
## Development
|
69
84
|
|
70
|
-
Naturally, this
|
71
|
-
|
72
|
-
|
73
|
-
bin/setup
|
85
|
+
Naturally, this project comes with its own setup script.
|
86
|
+
Simply run this command to get started:
|
74
87
|
|
75
|
-
|
88
|
+
```
|
89
|
+
bin/setup
|
90
|
+
```
|
76
91
|
|
77
92
|
## Author/License
|
78
93
|
|
79
|
-
|
80
|
-
|
81
|
-
|
94
|
+
Setup Script Generator is copyright © 2019-2020 Elliot Winkler
|
95
|
+
(<elliot.winkler@gmail.com>)
|
96
|
+
and is released under the [MIT license](LICENSE.txt).
|
data/bin/setup
CHANGED
@@ -17,12 +17,12 @@ provision-project() {
|
|
17
17
|
|
18
18
|
### DON'T MODIFY ANYTHING BELOW THIS LINE! #####################################
|
19
19
|
|
20
|
-
# This setup script was generated with setup_script_generator 0.2.
|
20
|
+
# This setup script was generated with setup_script_generator 0.2.3,
|
21
21
|
# available on RubyGems.
|
22
22
|
#
|
23
23
|
# To regenerate this section, install the gem and run:
|
24
24
|
#
|
25
|
-
# generate-setup
|
25
|
+
# generate-setup -p ruby
|
26
26
|
#
|
27
27
|
|
28
28
|
# --- SETUP --------------------------------------------------------------------
|
@@ -177,10 +177,106 @@ setup() {
|
|
177
177
|
cd "$(dirname "$(dirname "$0")")"
|
178
178
|
check-for-package-manager
|
179
179
|
install-development-libraries
|
180
|
-
|
180
|
+
run-provisions
|
181
|
+
if type provision-project &>/dev/null; then
|
182
|
+
provision-project
|
183
|
+
fi
|
181
184
|
success "Setup complete!"
|
182
185
|
}
|
183
186
|
|
187
|
+
# --- RUBY ---------------------------------------------------------------------
|
188
|
+
|
189
|
+
provision-ruby() {
|
190
|
+
USE_BUNDLER_1=0
|
191
|
+
|
192
|
+
if [[ -f .tool-versions ]]; then
|
193
|
+
REQUIRED_RUBY_VERSION=$(cat .tool-versions | grep '^ruby ' | sed -Ee 's/^ruby (.+)$/\1/')
|
194
|
+
elif [[ -f .ruby-version ]]; then
|
195
|
+
REQUIRED_RUBY_VERSION=$(cat .ruby-version)
|
196
|
+
else
|
197
|
+
error "You don't seem to have a Ruby version set in your project."
|
198
|
+
print-wrapped "\
|
199
|
+
You'll need to create either a .tool-versions file or .ruby-version file in your
|
200
|
+
project before you can run this script."
|
201
|
+
exit 1
|
202
|
+
fi
|
203
|
+
|
204
|
+
ensure-ruby-development-libraries-installed
|
205
|
+
ensure-ruby-installed
|
206
|
+
ensure-project-ruby-dependencies-installed
|
207
|
+
}
|
208
|
+
|
209
|
+
ensure-ruby-development-libraries-installed() {
|
210
|
+
local platform=$(determine-platform)
|
211
|
+
|
212
|
+
if [[ $platform == "linux" ]]; then
|
213
|
+
banner "Installing Ruby development libraries"
|
214
|
+
install apt=ruby-dev rpm=ruby-devel
|
215
|
+
fi
|
216
|
+
}
|
217
|
+
|
218
|
+
ensure-ruby-installed() {
|
219
|
+
if has-executable asdf; then
|
220
|
+
if ! (asdf current ruby | grep $REQUIRED_RUBY_VERSION'\>' &>/dev/null); then
|
221
|
+
banner "Installing Ruby $REQUIRED_RUBY_VERSION with asdf"
|
222
|
+
asdf install ruby $REQUIRED_RUBY_VERSION
|
223
|
+
fi
|
224
|
+
elif has-executable rbenv; then
|
225
|
+
if ! (rbenv versions | grep $REQUIRED_RUBY_VERSION'\>' &>/dev/null); then
|
226
|
+
banner "Installing Ruby $REQUIRED_RUBY_VERSION with rbenv"
|
227
|
+
rbenv install --skip-existing "$REQUIRED_RUBY_VERSION"
|
228
|
+
fi
|
229
|
+
elif has-executable chruby-exec; then
|
230
|
+
PREFIX='' source /usr/local/share/chruby/chruby.sh
|
231
|
+
if ! (chruby '' | grep $REQUIRED_RUBY_VERSION'\>' &>/dev/null); then
|
232
|
+
if has-executable install-ruby; then
|
233
|
+
banner "Installing Ruby $REQUIRED_RUBY_VERSION with install-ruby"
|
234
|
+
install-ruby "$REQUIRED_RUBY_VERSION"
|
235
|
+
else
|
236
|
+
error "Please use chruby to install Ruby $REQUIRED_RUBY_VERSION!"
|
237
|
+
fi
|
238
|
+
fi
|
239
|
+
elif has-executable rvm; then
|
240
|
+
if ! (rvm list | grep $required_ruby_version'\>' &>/dev/null); then
|
241
|
+
banner "Installing Ruby $required_ruby_version with rvm"
|
242
|
+
rvm install $required_ruby_version
|
243
|
+
rvm use $required_ruby_version
|
244
|
+
fi
|
245
|
+
else
|
246
|
+
error "You don't seem to have a Ruby manager installed."
|
247
|
+
print-wrapped "\
|
248
|
+
We recommend using asdf. You can find instructions to install it here:
|
249
|
+
|
250
|
+
https://asdf-vm.com
|
251
|
+
|
252
|
+
When you're done, close and re-open this terminal tab and re-run this script."
|
253
|
+
exit 1
|
254
|
+
fi
|
255
|
+
}
|
256
|
+
|
257
|
+
has-bundler() {
|
258
|
+
has-executable bundle && bundle -v &>/dev/null
|
259
|
+
}
|
260
|
+
|
261
|
+
ensure-project-ruby-dependencies-installed() {
|
262
|
+
banner 'Installing Ruby dependencies'
|
263
|
+
|
264
|
+
if [[ $USE_BUNDLER_1 -eq 1 ]] && (! has-bundler || [[ $(bundle -v) =~ '^1\.' ]]); then
|
265
|
+
gem install bundler -v '~> 1.0'
|
266
|
+
elif ! has-bundler; then
|
267
|
+
gem install bundler
|
268
|
+
fi
|
269
|
+
|
270
|
+
bundle check || bundle install
|
271
|
+
}
|
272
|
+
|
273
|
+
run-provisions() {
|
274
|
+
provision-ruby
|
275
|
+
|
276
|
+
if type provision-project &>/dev/null; then
|
277
|
+
provision-project
|
278
|
+
fi
|
279
|
+
}
|
184
280
|
|
185
281
|
# --- FIN ----------------------------------------------------------------------
|
186
282
|
|
@@ -30,8 +30,4 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.bindir = "exe"
|
31
31
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
32
|
spec.require_paths = ["lib"]
|
33
|
-
|
34
|
-
spec.add_development_dependency "bundler", "~> 1.17"
|
35
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
36
|
-
# spec.add_development_dependency "rspec", "~> 3.0"
|
37
33
|
end
|
metadata
CHANGED
@@ -1,43 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: setup_script_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elliot Winkler
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.17'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.17'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '10.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '10.0'
|
11
|
+
date: 2020-06-20 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
41
13
|
description:
|
42
14
|
email:
|
43
15
|
- elliot.winkler@gmail.com
|
@@ -46,10 +18,10 @@ executables:
|
|
46
18
|
extensions: []
|
47
19
|
extra_rdoc_files: []
|
48
20
|
files:
|
21
|
+
- ".editorconfig"
|
49
22
|
- ".gitignore"
|
50
|
-
- ".
|
23
|
+
- ".tool-versions"
|
51
24
|
- Gemfile
|
52
|
-
- Gemfile.lock
|
53
25
|
- LICENSE.txt
|
54
26
|
- README.md
|
55
27
|
- Rakefile
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.6.3
|
data/Gemfile.lock
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
setup_script_generator (0.2.3)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
rake (10.5.0)
|
10
|
-
|
11
|
-
PLATFORMS
|
12
|
-
ruby
|
13
|
-
|
14
|
-
DEPENDENCIES
|
15
|
-
bundler (~> 1.17)
|
16
|
-
rake (~> 10.0)
|
17
|
-
setup_script_generator!
|
18
|
-
|
19
|
-
BUNDLED WITH
|
20
|
-
1.17.3
|