Grid環境構築用のChefリポジトリです。
リビジョン | 20e66a1b2ac0add589ceaad090d6be012e74adf2 (tree) |
---|---|
日時 | 2019-03-03 18:25:49 |
作者 | whitestar <whitestar@user...> |
コミッター | whitestar |
add yarn-installer recipe to the nodejs_utils cookbook.
@@ -1,5 +1,9 @@ | ||
1 | 1 | # nodejs_utils CHANGELOG |
2 | 2 | |
3 | +0.2.0 | |
4 | +----- | |
5 | +- add yarn-installer recipe. | |
6 | + | |
3 | 7 | 0.1.0 |
4 | 8 | ----- |
5 | 9 | - Initial release. |
@@ -0,0 +1,22 @@ | ||
1 | +GEM | |
2 | + remote: https://rubygems.org/ | |
3 | + specs: | |
4 | + chef-api (0.8.0) | |
5 | + logify (~> 0.1) | |
6 | + mime-types | |
7 | + logify (0.2.0) | |
8 | + mime-types (3.2.2) | |
9 | + mime-types-data (~> 3.2015) | |
10 | + mime-types-data (3.2018.0812) | |
11 | + stove (6.0.0) | |
12 | + chef-api (~> 0.5) | |
13 | + logify (~> 0.2) | |
14 | + | |
15 | +PLATFORMS | |
16 | + ruby | |
17 | + | |
18 | +DEPENDENCIES | |
19 | + stove | |
20 | + | |
21 | +BUNDLED WITH | |
22 | + 1.16.0 |
@@ -1,7 +1,7 @@ | ||
1 | 1 | nodejs_utils Cookbook |
2 | 2 | ===================== |
3 | 3 | |
4 | -This cookbook installs `n`, `nvm` (Node.js Version Managers) setup scripts. | |
4 | +This cookbook installs `n`, `nvm` (Node.js Version Managers) and `yarn` setup scripts. | |
5 | 5 | |
6 | 6 | ## Contents |
7 | 7 |
@@ -15,6 +15,7 @@ This cookbook installs `n`, `nvm` (Node.js Version Managers) setup scripts. | ||
15 | 15 | - [nodejs_utils::default](#nodejs_utilsdefault) |
16 | 16 | - [nodejs_utils::n-installer](#nodejs_utilsn-installer) |
17 | 17 | - [nodejs_utils::nvm-installer](#nodejs_utilsnvm-installer) |
18 | + - [nodejs_utils::yarn-installer](#nodejs_utilsyarn-installer) | |
18 | 19 | - [License and Authors](#license-and-authors) |
19 | 20 | |
20 | 21 | ## Requirements |
@@ -34,7 +35,8 @@ This cookbook installs `n`, `nvm` (Node.js Version Managers) setup scripts. | ||
34 | 35 | |
35 | 36 | |Key|Type|Description, example|Default| |
36 | 37 | |:--|:--|:--|:--| |
37 | -|`['nodejs_utils']['nvm']['version']`|String|latest: 'master'|`'v0.33.6'`| | |
38 | +|`['nodejs_utils']['nvm']['version']`|String|latest: 'master'|`'v0.33.11'`| | |
39 | +|`['nodejs_utils']['yarn']['version']`|String||`'latest'`| | |
38 | 40 | |
39 | 41 | ## Usage |
40 | 42 |
@@ -52,12 +54,16 @@ This recipe installs the `n` setup script. | ||
52 | 54 | |
53 | 55 | This recipe installs the `nvm` setup script. |
54 | 56 | |
57 | +#### nodejs_utils::nvm-installer | |
58 | + | |
59 | +This recipe installs the `yarn` setup script. | |
60 | + | |
55 | 61 | ## License and Authors |
56 | 62 | |
57 | 63 | - Author:: whitestar at osdn.jp |
58 | 64 | |
59 | 65 | ```text |
60 | -Copyright 2017, whitestar | |
66 | +Copyright 2017-2019, whitestar | |
61 | 67 | |
62 | 68 | Licensed under the Apache License, Version 2.0 (the "License"); |
63 | 69 | you may not use this file except in compliance with the License. |
@@ -3,12 +3,58 @@ require 'rubocop/rake_task' | ||
3 | 3 | require 'foodcritic' |
4 | 4 | require 'stove/rake_task' |
5 | 5 | |
6 | +tpl_cookbook = '00cookbook' | |
7 | +cookbook_name = File.basename(Dir.pwd) | |
8 | + | |
9 | +desc 'Initialize project' | |
10 | +task :init do | |
11 | + next if cookbook_name == tpl_cookbook | |
12 | + | |
13 | + [ | |
14 | + '.foodcritic', | |
15 | + '.rubocop.yml', | |
16 | + 'Berksfile', | |
17 | + 'chefignore', | |
18 | + 'concourse.yml', | |
19 | + 'fly-vars.yml', | |
20 | + 'fly-vars.local.yml', | |
21 | + 'Gemfile', | |
22 | + 'Gemfile.lock', | |
23 | + 'version', | |
24 | + ].each {|conf| | |
25 | + sh "cp ../#{tpl_cookbook}/#{conf} ./" unless File.exist?(conf) | |
26 | + } | |
27 | + | |
28 | + ruby [ | |
29 | + %(-pne '$_.gsub!(/^cookbook-name: .*$/, "cookbook-name: #{cookbook_name}")'), | |
30 | + '-i fly-vars.local.yml', | |
31 | + ].join(' ') | |
32 | +end | |
33 | + | |
34 | +desc 'Update project' | |
35 | +task :update do | |
36 | + next if cookbook_name == tpl_cookbook | |
37 | + | |
38 | + [ | |
39 | + 'Rakefile', | |
40 | + 'chefignore', | |
41 | + 'concourse.yml', | |
42 | + 'fly-vars.yml', | |
43 | + 'Gemfile', | |
44 | + 'Gemfile.lock', | |
45 | + ].each {|conf| | |
46 | + sh "cp ../#{tpl_cookbook}/#{conf} ./" | |
47 | + } | |
48 | +end | |
49 | + | |
50 | +desc 'fly set-pipeline' | |
6 | 51 | task :'set-pipeline' do |
7 | 52 | sh [ |
8 | - "fly -t $CC_TARGET sp -p #{File.basename(Dir.pwd)}-cookbook -c concourse.yml", | |
9 | - '-l fly-vars.yml -l ~/sec/credentials-prod.yml', | |
53 | + "fly -t $CC_TARGET sp -p #{cookbook_name}-cookbook -c concourse.yml", | |
54 | + '-l fly-vars.yml -l fly-vars.local.yml -l ~/sec/credentials-prod.yml', | |
10 | 55 | ].join(' ') |
11 | 56 | end |
57 | +desc 'rake set-pipeline alias' | |
12 | 58 | task sp: 'set-pipeline' |
13 | 59 | |
14 | 60 | namespace :style do |
@@ -2,7 +2,7 @@ | ||
2 | 2 | # Cookbook Name:: nodejs_utils |
3 | 3 | # Attributes:: default |
4 | 4 | # |
5 | -# Copyright 2017, whitestar | |
5 | +# Copyright 2017-2019, whitestar | |
6 | 6 | # |
7 | 7 | # Licensed under the Apache License, Version 2.0 (the "License"); |
8 | 8 | # you may not use this file except in compliance with the License. |
@@ -17,4 +17,5 @@ | ||
17 | 17 | # limitations under the License. |
18 | 18 | # |
19 | 19 | |
20 | -default['nodejs_utils']['nvm']['version'] = 'v0.33.6' # latest: 'master' | |
20 | +default['nodejs_utils']['nvm']['version'] = 'v0.33.11' # latest: 'master' | |
21 | +default['nodejs_utils']['yarn']['version'] = 'latest' |
@@ -0,0 +1,20 @@ | ||
1 | +# Put files/directories that should be ignored in this file. | |
2 | +# Lines that start with '# ' are comments. | |
3 | + | |
4 | +Berksfile.lock | |
5 | + | |
6 | +# concourse | |
7 | +concourse.yml | |
8 | +fly-vars.yml | |
9 | +fly-vars.local.yml | |
10 | + | |
11 | +# emacs | |
12 | +*~ | |
13 | + | |
14 | +.rubocop_todo.yml | |
15 | + | |
16 | +# vim | |
17 | +*.sw[a-z] | |
18 | + | |
19 | +# subversion | |
20 | +*/.svn/* |
@@ -1,5 +1,4 @@ | ||
1 | 1 | --- |
2 | -# $ fly -t $CC_TARGET sp -p nodejs_utils-cookbook -c concourse.yml -l fly-vars.yml -l ~/sec/credentials-prod.yml | |
3 | 2 | resources: |
4 | 3 | - name: src-git |
5 | 4 | type: git |
@@ -1,3 +1,2 @@ | ||
1 | 1 | --- |
2 | -cookbook-name: nodejs_utils | |
3 | 2 | chefdk-version: 1.6.11 |
@@ -0,0 +1,53 @@ | ||
1 | +# | |
2 | +# Cookbook Name:: nodejs_utils | |
3 | +# Recipe:: yarn-installer | |
4 | +# | |
5 | +# Copyright 2019, whitestar | |
6 | +# | |
7 | +# Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | +# you may not use this file except in compliance with the License. | |
9 | +# You may obtain a copy of the License at | |
10 | +# | |
11 | +# http://www.apache.org/licenses/LICENSE-2.0 | |
12 | +# | |
13 | +# Unless required by applicable law or agreed to in writing, software | |
14 | +# distributed under the License is distributed on an "AS IS" BASIS, | |
15 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | +# See the License for the specific language governing permissions and | |
17 | +# limitations under the License. | |
18 | +# | |
19 | + | |
20 | +doc_url = 'https://yarnpkg.com/en/docs/' | |
21 | + | |
22 | +[ | |
23 | + 'curl', | |
24 | +].each {|pkg| | |
25 | + resources(package: pkg) rescue package pkg do | |
26 | + action :install | |
27 | + end | |
28 | +} | |
29 | + | |
30 | +[ | |
31 | + 'yarn_install', | |
32 | +].each {|script| | |
33 | + template "/usr/local/bin/#{script}" do | |
34 | + source "usr/local/bin/#{script}" | |
35 | + owner 'root' | |
36 | + group 'root' | |
37 | + mode '0755' | |
38 | + action :create | |
39 | + end | |
40 | +} | |
41 | + | |
42 | +log 'yarn-installer post install message' do | |
43 | + message <<-"EOM" | |
44 | +Note: You must execute the following command manually. | |
45 | + See #{doc_url} | |
46 | + * install yarn: | |
47 | + $ yarn_install | |
48 | + ... | |
49 | + $ source ~/.bashrc | |
50 | + $ yarn -v | |
51 | + 1.13.0 | |
52 | +EOM | |
53 | +end |
@@ -0,0 +1,13 @@ | ||
1 | +#!/bin/sh | |
2 | + | |
3 | +PATH=.:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin | |
4 | + | |
5 | +<% | |
6 | +yarn_ver = node['nodejs_utils']['yarn']['version'] | |
7 | + | |
8 | +if yarn_ver == 'latest' | |
9 | +-%> | |
10 | +curl -o- -L https://yarnpkg.com/install.sh | bash | |
11 | +<% else -%> | |
12 | +curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version <%= yarn_ver %> | |
13 | +<% end -%> |
@@ -1 +1 @@ | ||
1 | -0.1.0 | |
1 | +0.2.0 |
@@ -0,0 +1,16 @@ | ||
1 | +name 'nodejs-utils' | |
2 | +description 'Node.js Setup Utilities' | |
3 | + | |
4 | +run_list( | |
5 | + 'recipe[nodejs_utils::n-installer]', | |
6 | + 'recipe[nodejs_utils::nvm-installer]', | |
7 | + 'recipe[nodejs_utils::yarn-installer]', | |
8 | +) | |
9 | + | |
10 | +#env_run_lists | |
11 | + | |
12 | +default_attributes( | |
13 | +) | |
14 | + | |
15 | +override_attributes( | |
16 | +) |