setup_script_generator 0.2.1 → 0.2.6
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 -48
- data/lib/setup_script_generator/templates/non-customizable-section.sh.erb +24 -30
- data/lib/setup_script_generator/templates/provisions/node.sh +18 -16
- data/lib/setup_script_generator/templates/provisions/ruby.sh +39 -19
- data/lib/setup_script_generator/version.rb +1 -1
- data/setup_script_generator.gemspec +0 -4
- metadata +10 -38
- 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: bf213e5c70d16dcdb1e39d45bbcc412d506c9bc9fe1c17df9873b1a647294412
|
|
4
|
+
data.tar.gz: d5893fdb48d55b91da2a5104da6f251257e7cc130e7cf34d5450e8b165564eda
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 858393d01c48d5977538984fab3bc1b3f5082992a7c73c45d3d32d7bf5a9813c9139ae06364e61deae27bead4ce6cade875e367041f660e6cfb89333ecef65c6
|
|
7
|
+
data.tar.gz: 55aaa0d7db1e05ab253d5c82d7091e020951350a35715b42bf9419510d76ee981479411094505538318c69ebc080d810befa7a53a18b02bd02e428a66a7fc2eb
|
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
|
@@ -2,9 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
set -euo pipefail
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
### PROJECT SETUP ##############################################################
|
|
6
|
+
|
|
7
|
+
# Feel free to add whatever functions or variables you want to add in this
|
|
8
|
+
# section. You may also delete this section altogether if your project doesn't
|
|
9
|
+
# need a custom setup.
|
|
10
|
+
|
|
11
|
+
provision-project() {
|
|
12
|
+
# This function gets called automatically below.
|
|
13
|
+
# Feel free to remove these comments.
|
|
14
|
+
# If your project needs custom setup, then place that here.
|
|
15
|
+
true
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
### DON'T MODIFY ANYTHING BELOW THIS LINE! #####################################
|
|
19
|
+
|
|
20
|
+
# This setup script was generated with setup_script_generator 0.2.3,
|
|
21
|
+
# available on RubyGems.
|
|
22
|
+
#
|
|
23
|
+
# To regenerate this section, install the gem and run:
|
|
24
|
+
#
|
|
25
|
+
# generate-setup -p ruby
|
|
26
|
+
#
|
|
6
27
|
|
|
7
|
-
|
|
28
|
+
# --- SETUP --------------------------------------------------------------------
|
|
29
|
+
|
|
30
|
+
something_already_printed=0
|
|
8
31
|
|
|
9
32
|
determine-platform() {
|
|
10
33
|
local uname=$(uname)
|
|
@@ -111,7 +134,7 @@ install() {
|
|
|
111
134
|
sudo apt-get install -y "$package"
|
|
112
135
|
fi
|
|
113
136
|
elif has-executable yum; then
|
|
114
|
-
package="${
|
|
137
|
+
package="${rpm_package:-$default_package}"
|
|
115
138
|
|
|
116
139
|
if [[ -n $package ]]; then
|
|
117
140
|
sudo yum install -y "$package"
|
|
@@ -125,28 +148,24 @@ install() {
|
|
|
125
148
|
check-for-package-manager() {
|
|
126
149
|
local platform=$(determine-platform)
|
|
127
150
|
|
|
128
|
-
if [[ $platform == "linux" ]]; then
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
print-wrapped "\
|
|
132
|
-
The setup script assumes you're using Debian or a Debian-derived flavor of
|
|
133
|
-
Linux (i.e. something with Apt). If this is not the case, then we would
|
|
134
|
-
gladly take a PR fixing this!"
|
|
135
|
-
exit 1
|
|
136
|
-
fi
|
|
137
|
-
else
|
|
138
|
-
if ! has-executable brew; then
|
|
139
|
-
error "You don't seem to have Homebrew installed."
|
|
140
|
-
print-wrapped "\
|
|
141
|
-
Follow the instructions here to do this:
|
|
142
|
-
|
|
143
|
-
http://brew.sh
|
|
144
|
-
|
|
145
|
-
Then re-run this script."
|
|
146
|
-
exit 1
|
|
147
|
-
fi
|
|
151
|
+
if [[ $platform == "linux" ]] && ! has-executable apt-get && ! has-executable yum; then
|
|
152
|
+
# TODO: Check if build-essential is installed on Debian?
|
|
153
|
+
# TODO: Check if 'Development Tools' group is installed on RedHat?
|
|
148
154
|
|
|
155
|
+
error "You don't seem to have a package manager installed."
|
|
156
|
+
print-wrapped "\
|
|
157
|
+
This setup script assumes you're using a flavor of Linux derived from Debian or
|
|
158
|
+
RedHat (i.e. something with Apt or Yum). If this is not the case, then we would
|
|
159
|
+
gladly take a PR fixing this!"
|
|
160
|
+
exit 1
|
|
161
|
+
elif [[ $platform == "mac" ]] && ! has-executable brew; then
|
|
149
162
|
# TODO: Check that OS X Command Line Tools are installed?
|
|
163
|
+
|
|
164
|
+
error "You don't seem to have Homebrew installed."
|
|
165
|
+
print-wrapped "\
|
|
166
|
+
Visit <https://brew.sh> and follow the instructions there, then re-run this
|
|
167
|
+
script."
|
|
168
|
+
exit 1
|
|
150
169
|
fi
|
|
151
170
|
}
|
|
152
171
|
|
|
@@ -154,29 +173,55 @@ install-development-libraries() {
|
|
|
154
173
|
install rpm=zlib-devel
|
|
155
174
|
}
|
|
156
175
|
|
|
176
|
+
setup() {
|
|
177
|
+
cd "$(dirname "$(dirname "$0")")"
|
|
178
|
+
check-for-package-manager
|
|
179
|
+
install-development-libraries
|
|
180
|
+
run-provisions
|
|
181
|
+
if type provision-project &>/dev/null; then
|
|
182
|
+
provision-project
|
|
183
|
+
fi
|
|
184
|
+
success "Setup complete!"
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
# --- RUBY ---------------------------------------------------------------------
|
|
188
|
+
|
|
157
189
|
provision-ruby() {
|
|
158
|
-
|
|
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
|
|
159
195
|
REQUIRED_RUBY_VERSION=$(cat .ruby-version)
|
|
160
196
|
else
|
|
161
197
|
error "You don't seem to have a Ruby version set in your project."
|
|
162
198
|
print-wrapped "\
|
|
163
|
-
You'll need to create a .ruby-version file in your
|
|
164
|
-
this script.
|
|
165
|
-
"
|
|
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."
|
|
166
201
|
exit 1
|
|
167
202
|
fi
|
|
168
203
|
|
|
169
|
-
|
|
204
|
+
ensure-ruby-development-libraries-installed
|
|
170
205
|
ensure-ruby-installed
|
|
171
|
-
|
|
206
|
+
ensure-project-ruby-dependencies-installed
|
|
172
207
|
}
|
|
173
208
|
|
|
174
|
-
|
|
175
|
-
|
|
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
|
|
176
216
|
}
|
|
177
217
|
|
|
178
218
|
ensure-ruby-installed() {
|
|
179
|
-
if has-executable
|
|
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
|
|
180
225
|
if ! (rbenv versions | grep $REQUIRED_RUBY_VERSION'\>' &>/dev/null); then
|
|
181
226
|
banner "Installing Ruby $REQUIRED_RUBY_VERSION with rbenv"
|
|
182
227
|
rbenv install --skip-existing "$REQUIRED_RUBY_VERSION"
|
|
@@ -185,10 +230,10 @@ ensure-ruby-installed() {
|
|
|
185
230
|
PREFIX='' source /usr/local/share/chruby/chruby.sh
|
|
186
231
|
if ! (chruby '' | grep $REQUIRED_RUBY_VERSION'\>' &>/dev/null); then
|
|
187
232
|
if has-executable install-ruby; then
|
|
188
|
-
|
|
233
|
+
banner "Installing Ruby $REQUIRED_RUBY_VERSION with install-ruby"
|
|
189
234
|
install-ruby "$REQUIRED_RUBY_VERSION"
|
|
190
235
|
else
|
|
191
|
-
error "Please install Ruby $REQUIRED_RUBY_VERSION"
|
|
236
|
+
error "Please use chruby to install Ruby $REQUIRED_RUBY_VERSION!"
|
|
192
237
|
fi
|
|
193
238
|
fi
|
|
194
239
|
elif has-executable rvm; then
|
|
@@ -200,33 +245,39 @@ ensure-ruby-installed() {
|
|
|
200
245
|
else
|
|
201
246
|
error "You don't seem to have a Ruby manager installed."
|
|
202
247
|
print-wrapped "\
|
|
203
|
-
We recommend using
|
|
204
|
-
|
|
205
|
-
https://github.com/rbenv/rbenv#installation
|
|
248
|
+
We recommend using asdf. You can find instructions to install it here:
|
|
206
249
|
|
|
207
|
-
|
|
208
|
-
automatically loaded.
|
|
250
|
+
https://asdf-vm.com
|
|
209
251
|
|
|
210
|
-
When you're done,
|
|
252
|
+
When you're done, close and re-open this terminal tab and re-run this script."
|
|
211
253
|
exit 1
|
|
212
254
|
fi
|
|
213
255
|
}
|
|
214
256
|
|
|
215
|
-
|
|
257
|
+
has-bundler() {
|
|
258
|
+
has-executable bundle && bundle -v &>/dev/null
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
ensure-project-ruby-dependencies-installed() {
|
|
216
262
|
banner 'Installing Ruby dependencies'
|
|
217
|
-
|
|
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
|
+
|
|
218
270
|
bundle check || bundle install
|
|
219
271
|
}
|
|
220
272
|
|
|
221
273
|
run-provisions() {
|
|
222
274
|
provision-ruby
|
|
223
|
-
}
|
|
224
275
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
run-provisions
|
|
229
|
-
success "Done!"
|
|
276
|
+
if type provision-project &>/dev/null; then
|
|
277
|
+
provision-project
|
|
278
|
+
fi
|
|
230
279
|
}
|
|
231
280
|
|
|
281
|
+
# --- FIN ----------------------------------------------------------------------
|
|
282
|
+
|
|
232
283
|
setup
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
# To regenerate this section, install the gem and run:
|
|
7
7
|
#
|
|
8
8
|
<% if provisions.any? -%>
|
|
9
|
-
# generate-setup <%= provisions.map { |p| "-p #{p.name}" }.join(" ")
|
|
10
|
-
<% else
|
|
9
|
+
# generate-setup <%= provisions.map { |p| "-p #{p.name}" }.join(" ") %>
|
|
10
|
+
<% else -%>
|
|
11
11
|
# generate-setup
|
|
12
|
-
<% end
|
|
12
|
+
<% end -%>
|
|
13
13
|
#
|
|
14
14
|
|
|
15
15
|
# --- SETUP --------------------------------------------------------------------
|
|
@@ -121,7 +121,7 @@ install() {
|
|
|
121
121
|
sudo apt-get install -y "$package"
|
|
122
122
|
fi
|
|
123
123
|
elif has-executable yum; then
|
|
124
|
-
package="${
|
|
124
|
+
package="${rpm_package:-$default_package}"
|
|
125
125
|
|
|
126
126
|
if [[ -n $package ]]; then
|
|
127
127
|
sudo yum install -y "$package"
|
|
@@ -135,28 +135,24 @@ install() {
|
|
|
135
135
|
check-for-package-manager() {
|
|
136
136
|
local platform=$(determine-platform)
|
|
137
137
|
|
|
138
|
-
if [[ $platform == "linux" ]]; then
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
print-wrapped "\
|
|
142
|
-
The setup script assumes you're using Debian or a Debian-derived flavor of
|
|
143
|
-
Linux (i.e. something with Apt). If this is not the case, then we would
|
|
144
|
-
gladly take a PR fixing this!"
|
|
145
|
-
exit 1
|
|
146
|
-
fi
|
|
147
|
-
else
|
|
148
|
-
if ! has-executable brew; then
|
|
149
|
-
error "You don't seem to have Homebrew installed."
|
|
150
|
-
print-wrapped "\
|
|
151
|
-
Follow the instructions here to do this:
|
|
152
|
-
|
|
153
|
-
http://brew.sh
|
|
154
|
-
|
|
155
|
-
Then re-run this script."
|
|
156
|
-
exit 1
|
|
157
|
-
fi
|
|
138
|
+
if [[ $platform == "linux" ]] && ! has-executable apt-get && ! has-executable yum; then
|
|
139
|
+
# TODO: Check if build-essential is installed on Debian?
|
|
140
|
+
# TODO: Check if 'Development Tools' group is installed on RedHat?
|
|
158
141
|
|
|
142
|
+
error "You don't seem to have a package manager installed."
|
|
143
|
+
print-wrapped "\
|
|
144
|
+
This setup script assumes you're using a flavor of Linux derived from Debian or
|
|
145
|
+
RedHat (i.e. something with Apt or Yum). If this is not the case, then we would
|
|
146
|
+
gladly take a PR fixing this!"
|
|
147
|
+
exit 1
|
|
148
|
+
elif [[ $platform == "mac" ]] && ! has-executable brew; then
|
|
159
149
|
# TODO: Check that OS X Command Line Tools are installed?
|
|
150
|
+
|
|
151
|
+
error "You don't seem to have Homebrew installed."
|
|
152
|
+
print-wrapped "\
|
|
153
|
+
Visit <https://brew.sh> and follow the instructions there, then re-run this
|
|
154
|
+
script."
|
|
155
|
+
exit 1
|
|
160
156
|
fi
|
|
161
157
|
}
|
|
162
158
|
|
|
@@ -172,8 +168,10 @@ setup() {
|
|
|
172
168
|
<% if provisions.any? -%>
|
|
173
169
|
run-provisions
|
|
174
170
|
<% end -%>
|
|
175
|
-
provision-project
|
|
176
|
-
|
|
171
|
+
if type provision-project &>/dev/null; then
|
|
172
|
+
provision-project
|
|
173
|
+
fi
|
|
174
|
+
success "Setup complete!"
|
|
177
175
|
}
|
|
178
176
|
|
|
179
177
|
<% provisions.each do |provision| -%>
|
|
@@ -187,10 +185,6 @@ run-provisions() {
|
|
|
187
185
|
<% provisions.each do |provision| -%>
|
|
188
186
|
provision-<%= provision.name %>
|
|
189
187
|
<% end -%>
|
|
190
|
-
|
|
191
|
-
if type provision-project &>/dev/null; then
|
|
192
|
-
provision-project
|
|
193
|
-
fi
|
|
194
188
|
}
|
|
195
189
|
<% end -%>
|
|
196
190
|
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
provision-node() {
|
|
2
|
-
if [[ -f .
|
|
2
|
+
if [[ -f .tool-versions ]]; then
|
|
3
|
+
REQUIRED_NODE_VERSION=$(cat .tool-versions | grep '^nodejs ' | sed -Ee 's/^nodejs (.+)$/\1/')
|
|
4
|
+
elif [[ -f .node-version ]]; then
|
|
3
5
|
REQUIRED_NODE_VERSION=$(cat .node-version)
|
|
4
6
|
elif [[ -f .nvmrc ]]; then
|
|
5
7
|
REQUIRED_NODE_VERSION=$(cat .nvmrc)
|
|
6
8
|
else
|
|
7
9
|
error "You don't seem to have a Node version set in your project."
|
|
8
10
|
print-wrapped "\
|
|
9
|
-
You'll need to create a .
|
|
10
|
-
can run this script.
|
|
11
|
-
"
|
|
11
|
+
You'll need to create either a .tool-versions file or .nvmrc file in your
|
|
12
|
+
project before you can run this script."
|
|
12
13
|
exit 1
|
|
13
14
|
fi
|
|
14
15
|
|
|
15
16
|
ensure-node-installed
|
|
16
|
-
|
|
17
|
+
ensure-project-node-dependencies-installed
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
ensure-node-installed() {
|
|
20
|
-
if has-executable
|
|
21
|
+
if has-executable asdf; then
|
|
22
|
+
if ! (asdf current nodejs | grep $REQUIRED_NODE_VERSION'\>' &>/dev/null); then
|
|
23
|
+
banner "Installing Node $REQUIRED_NODE_VERSION with asdf"
|
|
24
|
+
asdf install nodejs $REQUIRED_NODE_VERSION
|
|
25
|
+
fi
|
|
26
|
+
elif has-executable nodenv; then
|
|
21
27
|
if ! (nodenv versions | grep $REQUIRED_NODE_VERSION'\>' &>/dev/null); then
|
|
22
28
|
banner "Installing Node $REQUIRED_NODE_VERSION with nodenv"
|
|
23
29
|
nodenv install --skip-existing "$REQUIRED_NODE_VERSION"
|
|
@@ -31,19 +37,16 @@ ensure-node-installed() {
|
|
|
31
37
|
else
|
|
32
38
|
error "You don't seem to have a Node manager installed."
|
|
33
39
|
print-wrapped "\
|
|
34
|
-
We recommend using
|
|
35
|
-
|
|
36
|
-
https://github.com/nodenv/nodenv#installation
|
|
40
|
+
We recommend using asdf. You can find instructions to install it here:
|
|
37
41
|
|
|
38
|
-
|
|
39
|
-
automatically loaded.
|
|
42
|
+
https://asdf-vm.com
|
|
40
43
|
|
|
41
|
-
When you're done,
|
|
44
|
+
When you're done, close and re-open this terminal tab and re-run this script."
|
|
42
45
|
exit 1
|
|
43
46
|
fi
|
|
44
47
|
}
|
|
45
48
|
|
|
46
|
-
|
|
49
|
+
ensure-project-node-dependencies-installed() {
|
|
47
50
|
banner 'Installing Node dependencies'
|
|
48
51
|
|
|
49
52
|
if [[ -f package-lock.json ]]; then
|
|
@@ -53,9 +56,8 @@ install-node-dependencies() {
|
|
|
53
56
|
else
|
|
54
57
|
error "Sorry, I'm not sure how to install your dependencies."
|
|
55
58
|
print-wrapped "\
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
+
Are you missing a package.json? Have you run 'npm install' or 'yarn install'
|
|
60
|
+
yet?"
|
|
59
61
|
exit 1
|
|
60
62
|
fi
|
|
61
63
|
}
|
|
@@ -1,26 +1,39 @@
|
|
|
1
1
|
provision-ruby() {
|
|
2
|
-
|
|
2
|
+
USE_BUNDLER_1=0
|
|
3
|
+
|
|
4
|
+
if [[ -f .tool-versions ]]; then
|
|
5
|
+
REQUIRED_RUBY_VERSION=$(cat .tool-versions | grep '^ruby ' | sed -Ee 's/^ruby (.+)$/\1/')
|
|
6
|
+
elif [[ -f .ruby-version ]]; then
|
|
3
7
|
REQUIRED_RUBY_VERSION=$(cat .ruby-version)
|
|
4
8
|
else
|
|
5
9
|
error "You don't seem to have a Ruby version set in your project."
|
|
6
10
|
print-wrapped "\
|
|
7
|
-
You'll need to create a .ruby-version file in your
|
|
8
|
-
this script.
|
|
9
|
-
"
|
|
11
|
+
You'll need to create either a .tool-versions file or .ruby-version file in your
|
|
12
|
+
project before you can run this script."
|
|
10
13
|
exit 1
|
|
11
14
|
fi
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
ensure-ruby-development-libraries-installed
|
|
14
17
|
ensure-ruby-installed
|
|
15
|
-
|
|
18
|
+
ensure-project-ruby-dependencies-installed
|
|
16
19
|
}
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
ensure-ruby-development-libraries-installed() {
|
|
22
|
+
local platform=$(determine-platform)
|
|
23
|
+
|
|
24
|
+
if [[ $platform == "linux" ]]; then
|
|
25
|
+
banner "Installing Ruby development libraries"
|
|
26
|
+
install apt=ruby-dev rpm=ruby-devel
|
|
27
|
+
fi
|
|
20
28
|
}
|
|
21
29
|
|
|
22
30
|
ensure-ruby-installed() {
|
|
23
|
-
if has-executable
|
|
31
|
+
if has-executable asdf; then
|
|
32
|
+
if ! (asdf current ruby | grep $REQUIRED_RUBY_VERSION'\>' &>/dev/null); then
|
|
33
|
+
banner "Installing Ruby $REQUIRED_RUBY_VERSION with asdf"
|
|
34
|
+
asdf install ruby $REQUIRED_RUBY_VERSION
|
|
35
|
+
fi
|
|
36
|
+
elif has-executable rbenv; then
|
|
24
37
|
if ! (rbenv versions | grep $REQUIRED_RUBY_VERSION'\>' &>/dev/null); then
|
|
25
38
|
banner "Installing Ruby $REQUIRED_RUBY_VERSION with rbenv"
|
|
26
39
|
rbenv install --skip-existing "$REQUIRED_RUBY_VERSION"
|
|
@@ -29,10 +42,10 @@ ensure-ruby-installed() {
|
|
|
29
42
|
PREFIX='' source /usr/local/share/chruby/chruby.sh
|
|
30
43
|
if ! (chruby '' | grep $REQUIRED_RUBY_VERSION'\>' &>/dev/null); then
|
|
31
44
|
if has-executable install-ruby; then
|
|
32
|
-
|
|
45
|
+
banner "Installing Ruby $REQUIRED_RUBY_VERSION with install-ruby"
|
|
33
46
|
install-ruby "$REQUIRED_RUBY_VERSION"
|
|
34
47
|
else
|
|
35
|
-
error "Please install Ruby $REQUIRED_RUBY_VERSION"
|
|
48
|
+
error "Please use chruby to install Ruby $REQUIRED_RUBY_VERSION!"
|
|
36
49
|
fi
|
|
37
50
|
fi
|
|
38
51
|
elif has-executable rvm; then
|
|
@@ -44,20 +57,27 @@ ensure-ruby-installed() {
|
|
|
44
57
|
else
|
|
45
58
|
error "You don't seem to have a Ruby manager installed."
|
|
46
59
|
print-wrapped "\
|
|
47
|
-
We recommend using
|
|
48
|
-
|
|
49
|
-
https://github.com/rbenv/rbenv#installation
|
|
60
|
+
We recommend using asdf. You can find instructions to install it here:
|
|
50
61
|
|
|
51
|
-
|
|
52
|
-
automatically loaded.
|
|
62
|
+
https://asdf-vm.com
|
|
53
63
|
|
|
54
|
-
When you're done,
|
|
64
|
+
When you're done, close and re-open this terminal tab and re-run this script."
|
|
55
65
|
exit 1
|
|
56
66
|
fi
|
|
57
67
|
}
|
|
58
68
|
|
|
59
|
-
|
|
69
|
+
has-bundler() {
|
|
70
|
+
has-executable bundle && bundle -v &>/dev/null
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
ensure-project-ruby-dependencies-installed() {
|
|
60
74
|
banner 'Installing Ruby dependencies'
|
|
61
|
-
|
|
75
|
+
|
|
76
|
+
if [[ $USE_BUNDLER_1 -eq 1 ]] && (! has-bundler || ! [[ $(bundle -v) =~ ^Bundler version 1\. ]]); then
|
|
77
|
+
gem install bundler -v '~> 1.0'
|
|
78
|
+
elif ! has-bundler; then
|
|
79
|
+
gem install bundler
|
|
80
|
+
fi
|
|
81
|
+
|
|
62
82
|
bundle check || bundle install
|
|
63
83
|
}
|
|
@@ -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,44 +1,16 @@
|
|
|
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.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Elliot Winkler
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
12
|
-
dependencies:
|
|
13
|
-
|
|
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'
|
|
41
|
-
description:
|
|
11
|
+
date: 2020-07-26 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description:
|
|
42
14
|
email:
|
|
43
15
|
- elliot.winkler@gmail.com
|
|
44
16
|
executables:
|
|
@@ -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
|
|
@@ -76,7 +48,7 @@ metadata:
|
|
|
76
48
|
homepage_uri: https://github.com/mcmire/setup_script_generator
|
|
77
49
|
source_code_uri: https://github.com/mcmire/setup_script_generator
|
|
78
50
|
changelog_uri: https://github.com/mcmire/setup_script_generator/tree/master/CHANGELOG.md
|
|
79
|
-
post_install_message:
|
|
51
|
+
post_install_message:
|
|
80
52
|
rdoc_options: []
|
|
81
53
|
require_paths:
|
|
82
54
|
- lib
|
|
@@ -91,8 +63,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
91
63
|
- !ruby/object:Gem::Version
|
|
92
64
|
version: '0'
|
|
93
65
|
requirements: []
|
|
94
|
-
rubygems_version: 3.
|
|
95
|
-
signing_key:
|
|
66
|
+
rubygems_version: 3.1.2
|
|
67
|
+
signing_key:
|
|
96
68
|
specification_version: 4
|
|
97
69
|
summary: Generate setup scripts for your projects.
|
|
98
70
|
test_files: []
|
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.1)
|
|
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
|