Skip to content

Commit cfefc49

Browse files
committed
Initial commit
0 parents  commit cfefc49

18 files changed

+7592
-0
lines changed

.circleci/config.yml

+162
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
---
2+
version: 2.1
3+
4+
executors:
5+
node:
6+
parameters:
7+
tag:
8+
type: string
9+
default: latest
10+
working_directory: ~/build
11+
docker:
12+
- image: node:<< parameters.tag >>
13+
14+
commands:
15+
setup:
16+
description: Setup environment
17+
parameters:
18+
is_alpine:
19+
type: boolean
20+
default: false
21+
steps:
22+
- when:
23+
condition: << parameters.is_alpine >>
24+
steps:
25+
- run:
26+
name: Install Alpine Linux build dependencies
27+
command: apk add --no-cache ca-certificates git openssh-client
28+
- checkout
29+
- when:
30+
condition: << parameters.is_alpine >>
31+
steps:
32+
- run:
33+
name: Save Alpine Linux version
34+
command: |
35+
echo "alpine: $(cat /etc/alpine-release)" >> .versions
36+
- run:
37+
name: Save Node.js and Yarn versions
38+
command: |
39+
echo "node: ${NODE_VERSION}" >> .versions
40+
echo "yarn: ${YARN_VERSION}" >> .versions
41+
cat .versions
42+
install:
43+
description: Install dependencies
44+
parameters:
45+
save_cache:
46+
type: boolean
47+
default: true
48+
steps:
49+
- restore_cache:
50+
key: yarn-cache-{{ arch }}-{{ checksum ".versions" }}-
51+
- restore_cache:
52+
key: node-modules-{{ arch }}-{{ checksum ".versions" }}-{{ checksum "yarn.lock" }}
53+
- run:
54+
name: Set yarn cache
55+
command: yarn config set cache-folder $HOME/.yarn-cache
56+
- run:
57+
name: Add npm authentication token
58+
command: echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > .npmrc
59+
- run:
60+
name: Install dependencies
61+
command: yarn install --frozen-lockfile --non-interactive
62+
- when:
63+
condition: << parameters.save_cache >>
64+
steps:
65+
- save_cache:
66+
key: yarn-cache-{{ arch }}-{{ checksum ".versions" }}-{{ epoch }}
67+
paths: ~/.yarn-cache
68+
- save_cache:
69+
key: node-modules-{{ arch }}-{{ checksum ".versions" }}-{{ checksum "yarn.lock" }}
70+
paths: node_modules
71+
jobs:
72+
test:
73+
description: Test Node.js package
74+
parameters:
75+
tag:
76+
type: string
77+
default: latest
78+
is_alpine:
79+
type: boolean
80+
default: false
81+
upload_coverage:
82+
type: boolean
83+
default: false
84+
executor:
85+
name: node
86+
tag: << parameters.tag >>
87+
steps:
88+
- setup:
89+
is_alpine: << parameters.is_alpine >>
90+
- install
91+
- run:
92+
name: Test package
93+
command: yarn test
94+
- run:
95+
name: Build package
96+
command: yarn run build
97+
- when:
98+
condition: << parameters.upload_coverage >>
99+
steps:
100+
- run:
101+
name: Upload coverage to Codecov
102+
command: |
103+
if [[ -n "${CODECOV_TOKEN}" ]]; then
104+
yarn global add codecov
105+
codecov
106+
fi
107+
publish:
108+
description: Publish Node.js package
109+
executor:
110+
name: node
111+
tag: carbon
112+
steps:
113+
- setup
114+
- install
115+
- run:
116+
name: Build package
117+
command: yarn run build
118+
- deploy:
119+
name: Publish package
120+
command: npm publish --access public
121+
122+
references:
123+
version_tags: &version_tags
124+
tags:
125+
only: /^v.*/
126+
127+
workflows:
128+
default:
129+
jobs:
130+
- test:
131+
name: test-latest
132+
- test:
133+
name: test-latest-alpine
134+
tag: alpine
135+
is_alpine: true
136+
- test:
137+
name: test-dubnium
138+
tag: dubnium
139+
- test:
140+
name: test-dubnium-alpine
141+
tag: dubnium-alpine
142+
is_alpine: true
143+
- test:
144+
name: test-carbon
145+
tag: carbon
146+
upload_coverage: true
147+
- test:
148+
name: test-carbon-alpine
149+
tag: carbon-alpine
150+
is_alpine: true
151+
- publish:
152+
filters:
153+
branches:
154+
ignore: /.*/
155+
<<: *version_tags
156+
requires:
157+
- test-latest
158+
- test-latest-alpine
159+
- test-dubnium
160+
- test-dubnium-alpine
161+
- test-carbon
162+
- test-carbon-alpine

.circleci/envvars.sh

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
set -u
5+
6+
help () {
7+
echo
8+
echo '# This will set all required environment variables on the CircleCI project.'
9+
echo
10+
echo '# Supply values to set when prompted.'
11+
echo '# Values left blank will not be updated.'
12+
echo
13+
echo 'Values may also be provided via' \
14+
'the corresponding environment variable (prefixed with CI_).'
15+
echo 'Optionally, set NONINTERACTIVE=true to skip all prompts.'
16+
echo
17+
echo 'For example, assuming CIRCLE_TOKEN is set in your environment,' \
18+
'update NPM_TOKEN with'
19+
echo
20+
echo ' $ NONINTERACTIVE=true CI_NPM_TOKEN=token .circleci/envvars.sh'
21+
}
22+
23+
help_circleci () {
24+
echo
25+
echo '> Get a personal CircleCI API Token at' \
26+
'https://circleci.com/account/api'
27+
}
28+
29+
help_npm_token () {
30+
echo
31+
echo '> Use an npm token with publish permission.'
32+
}
33+
34+
help_codecov () {
35+
echo
36+
echo '> Get the Repository Upload Token at' \
37+
"https://codecov.io/gh/${circle_repo}/settings"
38+
}
39+
40+
command -v jq >/dev/null 2>&1 || \
41+
(echo 'jq required: https://stedolan.github.io/jq/' && exit 2)
42+
43+
envvar () {
44+
name=$1
45+
value=${2:-}
46+
if [[ -n $value ]]; then
47+
if [[ -z $circle_token ]]; then
48+
echo
49+
echo 'Error: missing CircleCI token.'
50+
exit 2
51+
fi
52+
53+
curl -X POST \
54+
--header 'Content-Type: application/json' \
55+
-u "${circle_token}:" \
56+
-d '{"name": "'$name'", "value": "'$value'"}' \
57+
"https://circleci.com/api/v1.1/project/github/${circle_repo}/envvar"
58+
fi
59+
}
60+
61+
main () {
62+
noninteractive=$1
63+
circle_repo=$(jq -r .repository package.json)
64+
65+
circle_token=${CIRCLE_TOKEN:-}
66+
[[ -n "${circle_token}" || $noninteractive == 'true' ]] || help_circleci
67+
if [[ -z $circle_token && $noninteractive != 'true' ]]; then
68+
read -p '> CircleCI API token (CIRCLE_TOKEN): ' circle_token
69+
fi
70+
71+
npm_token=${CI_NPM_TOKEN:-}
72+
[[ -n "${npm_token}" || $noninteractive == 'true' ]] || help_npm_token
73+
if [[ -z $npm_token && $noninteractive != 'true' ]]; then
74+
read -p '> NPM token (NPM_TOKEN): ' npm_token
75+
fi
76+
77+
codecov_token=${CI_CODECOV_TOKEN:-}
78+
[[ -n "${codecov_token}" || $noninteractive == 'true' ]] || help_codecov
79+
if [[ -z $codecov_token && $noninteractive != 'true' ]]; then
80+
read -p '> Codecov token (CODECOV_TOKEN): ' codecov_token
81+
fi
82+
83+
envvar 'NPM_TOKEN' "${npm_token}"
84+
envvar 'CODECOV_TOKEN' "${codecov_token}"
85+
}
86+
87+
noninteractive=${NONINTERACTIVE:-false}
88+
if [[ $noninteractive != 'true' ]]; then
89+
help
90+
fi
91+
main $noninteractive

.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
indent_style = space
9+
indent_size = 2

.gitignore

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Parts of this file were adapted from
2+
# GitHub’s collection of .gitignore file templates
3+
# which are Copyright (c) 2018 GitHub, Inc.
4+
# and released under the MIT License.
5+
# For more details, visit the project page:
6+
# https://github.com/github/gitignore
7+
8+
# Build directories
9+
dist
10+
package
11+
12+
# Local config
13+
examples/local.json
14+
15+
# Tern
16+
.tern-project
17+
.tern-port
18+
19+
# npm config
20+
.npmrc
21+
22+
# Temporary development files
23+
tmp
24+
25+
# npm lockfile (only yarn.lock supported)
26+
package-lock.json
27+
28+
# Logs
29+
logs
30+
*.log
31+
npm-debug.log*
32+
yarn-debug.log*
33+
yarn-error.log*
34+
35+
# Runtime data
36+
pids
37+
*.pid
38+
*.seed
39+
*.pid.lock
40+
41+
# Directory for instrumented libs generated by jscoverage/JSCover
42+
lib-cov
43+
44+
# Coverage directory used by tools like istanbul
45+
coverage
46+
47+
# nyc test coverage
48+
.nyc_output
49+
50+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
51+
.grunt
52+
53+
# Bower dependency directory (https://bower.io/)
54+
bower_components
55+
56+
# node-waf configuration
57+
.lock-wscript
58+
59+
# Compiled binary addons (https://nodejs.org/api/addons.html)
60+
build/Release
61+
62+
# Dependency directories
63+
node_modules/
64+
jspm_packages/
65+
66+
# TypeScript v1 declaration files
67+
typings/
68+
69+
# Optional npm cache directory
70+
.npm
71+
72+
# Optional eslint cache
73+
.eslintcache
74+
75+
# Optional REPL history
76+
.node_repl_history
77+
78+
# Output of 'npm pack'
79+
*.tgz
80+
81+
# Yarn Integrity file
82+
.yarn-integrity
83+
84+
# dotenv environment variables file
85+
.env
86+
87+
# parcel-bundler cache (https://parceljs.org/)
88+
.cache
89+
90+
# next.js build output
91+
.next
92+
93+
# nuxt.js build output
94+
.nuxt
95+
96+
# vuepress build output
97+
.vuepress/dist
98+
99+
# Serverless directories
100+
.serverless/
101+
102+
# FuseBox cache
103+
.fusebox/
104+
105+
#DynamoDB Local files
106+
.dynamodb/

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lts/dubnium

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/)
6+
and this project adheres to [Semantic Versioning](https://semver.org/).
7+
8+
## [Unreleased]
9+
10+
[Unreleased]: https://github.com/makenew/jsmodule/compare/v0.0.0...HEAD

0 commit comments

Comments
 (0)