# nodejs_utils CHANGELOG
+0.2.0
+-----
+- add yarn-installer recipe.
+
0.1.0
-----
- Initial release.
--- /dev/null
+GEM
+ remote: https://rubygems.org/
+ specs:
+ chef-api (0.8.0)
+ logify (~> 0.1)
+ mime-types
+ logify (0.2.0)
+ mime-types (3.2.2)
+ mime-types-data (~> 3.2015)
+ mime-types-data (3.2018.0812)
+ stove (6.0.0)
+ chef-api (~> 0.5)
+ logify (~> 0.2)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ stove
+
+BUNDLED WITH
+ 1.16.0
nodejs_utils Cookbook
=====================
-This cookbook installs `n`, `nvm` (Node.js Version Managers) setup scripts.
+This cookbook installs `n`, `nvm` (Node.js Version Managers) and `yarn` setup scripts.
## Contents
- [nodejs_utils::default](#nodejs_utilsdefault)
- [nodejs_utils::n-installer](#nodejs_utilsn-installer)
- [nodejs_utils::nvm-installer](#nodejs_utilsnvm-installer)
+ - [nodejs_utils::yarn-installer](#nodejs_utilsyarn-installer)
- [License and Authors](#license-and-authors)
## Requirements
|Key|Type|Description, example|Default|
|:--|:--|:--|:--|
-|`['nodejs_utils']['nvm']['version']`|String|latest: 'master'|`'v0.33.6'`|
+|`['nodejs_utils']['nvm']['version']`|String|latest: 'master'|`'v0.33.11'`|
+|`['nodejs_utils']['yarn']['version']`|String||`'latest'`|
## Usage
This recipe installs the `nvm` setup script.
+#### nodejs_utils::nvm-installer
+
+This recipe installs the `yarn` setup script.
+
## License and Authors
- Author:: whitestar at osdn.jp
```text
-Copyright 2017, whitestar
+Copyright 2017-2019, whitestar
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
require 'foodcritic'
require 'stove/rake_task'
+tpl_cookbook = '00cookbook'
+cookbook_name = File.basename(Dir.pwd)
+
+desc 'Initialize project'
+task :init do
+ next if cookbook_name == tpl_cookbook
+
+ [
+ '.foodcritic',
+ '.rubocop.yml',
+ 'Berksfile',
+ 'chefignore',
+ 'concourse.yml',
+ 'fly-vars.yml',
+ 'fly-vars.local.yml',
+ 'Gemfile',
+ 'Gemfile.lock',
+ 'version',
+ ].each {|conf|
+ sh "cp ../#{tpl_cookbook}/#{conf} ./" unless File.exist?(conf)
+ }
+
+ ruby [
+ %(-pne '$_.gsub!(/^cookbook-name: .*$/, "cookbook-name: #{cookbook_name}")'),
+ '-i fly-vars.local.yml',
+ ].join(' ')
+end
+
+desc 'Update project'
+task :update do
+ next if cookbook_name == tpl_cookbook
+
+ [
+ 'Rakefile',
+ 'chefignore',
+ 'concourse.yml',
+ 'fly-vars.yml',
+ 'Gemfile',
+ 'Gemfile.lock',
+ ].each {|conf|
+ sh "cp ../#{tpl_cookbook}/#{conf} ./"
+ }
+end
+
+desc 'fly set-pipeline'
task :'set-pipeline' do
sh [
- "fly -t $CC_TARGET sp -p #{File.basename(Dir.pwd)}-cookbook -c concourse.yml",
- '-l fly-vars.yml -l ~/sec/credentials-prod.yml',
+ "fly -t $CC_TARGET sp -p #{cookbook_name}-cookbook -c concourse.yml",
+ '-l fly-vars.yml -l fly-vars.local.yml -l ~/sec/credentials-prod.yml',
].join(' ')
end
+desc 'rake set-pipeline alias'
task sp: 'set-pipeline'
namespace :style do
# Cookbook Name:: nodejs_utils
# Attributes:: default
#
-# Copyright 2017, whitestar
+# Copyright 2017-2019, whitestar
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# limitations under the License.
#
-default['nodejs_utils']['nvm']['version'] = 'v0.33.6' # latest: 'master'
+default['nodejs_utils']['nvm']['version'] = 'v0.33.11' # latest: 'master'
+default['nodejs_utils']['yarn']['version'] = 'latest'
--- /dev/null
+# Put files/directories that should be ignored in this file.
+# Lines that start with '# ' are comments.
+
+Berksfile.lock
+
+# concourse
+concourse.yml
+fly-vars.yml
+fly-vars.local.yml
+
+# emacs
+*~
+
+.rubocop_todo.yml
+
+# vim
+*.sw[a-z]
+
+# subversion
+*/.svn/*
---
-# $ fly -t $CC_TARGET sp -p nodejs_utils-cookbook -c concourse.yml -l fly-vars.yml -l ~/sec/credentials-prod.yml
resources:
- name: src-git
type: git
---
-cookbook-name: nodejs_utils
chefdk-version: 1.6.11
--- /dev/null
+#
+# Cookbook Name:: nodejs_utils
+# Recipe:: yarn-installer
+#
+# Copyright 2019, whitestar
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+doc_url = 'https://yarnpkg.com/en/docs/'
+
+[
+ 'curl',
+].each {|pkg|
+ resources(package: pkg) rescue package pkg do
+ action :install
+ end
+}
+
+[
+ 'yarn_install',
+].each {|script|
+ template "/usr/local/bin/#{script}" do
+ source "usr/local/bin/#{script}"
+ owner 'root'
+ group 'root'
+ mode '0755'
+ action :create
+ end
+}
+
+log 'yarn-installer post install message' do
+ message <<-"EOM"
+Note: You must execute the following command manually.
+ See #{doc_url}
+ * install yarn:
+ $ yarn_install
+ ...
+ $ source ~/.bashrc
+ $ yarn -v
+ 1.13.0
+EOM
+end
--- /dev/null
+#!/bin/sh
+
+PATH=.:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
+
+<%
+yarn_ver = node['nodejs_utils']['yarn']['version']
+
+if yarn_ver == 'latest'
+-%>
+curl -o- -L https://yarnpkg.com/install.sh | bash
+<% else -%>
+curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version <%= yarn_ver %>
+<% end -%>
--- /dev/null
+name 'nodejs-utils'
+description 'Node.js Setup Utilities'
+
+run_list(
+ 'recipe[nodejs_utils::n-installer]',
+ 'recipe[nodejs_utils::nvm-installer]',
+ 'recipe[nodejs_utils::yarn-installer]',
+)
+
+#env_run_lists
+
+default_attributes(
+)
+
+override_attributes(
+)