Skip to content

Commit a95e6d6

Browse files
authored
Merge pull request #54 from ngs/circleci2
Setup CircleCI 2.0
2 parents 89beaf6 + de12108 commit a95e6d6

File tree

8 files changed

+920
-683
lines changed

8 files changed

+920
-683
lines changed

.circleci/check-tag.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
set -eu
4+
5+
PKG=draft-js-markdown-shortcuts-plugin
6+
V=$(npm show $PKG version)
7+
[ $V = $CIRCLE_TAG ] || (
8+
echo "${PKG} ${V} does not match with CIRCLE_TAG ${CIRCLE_TAG}"; exit 1
9+
)

.circleci/config.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
version: 2
2+
3+
references:
4+
base: &base
5+
docker:
6+
- image: circleci/node:8.11.3
7+
8+
environment:
9+
MOCHA_FILE: mocha-test-results/test-results.xml
10+
11+
restore_cache: &restore_yarn_cache
12+
restore_cache:
13+
keys:
14+
- v1-yarn-cache-{{ checksum "yarn.lock" }}
15+
16+
save_cache: &save_yarn_cache
17+
save_cache:
18+
paths:
19+
- ~/.cache/yarn
20+
key: v1-yarn-cache-{{ checksum "yarn.lock" }}
21+
22+
restore_cache: &restore_npm_cache
23+
restore_cache:
24+
keys:
25+
- v1-dependencies-{{ checksum "yarn.lock" }}
26+
27+
save_cache: &save_npm_cache
28+
save_cache:
29+
paths:
30+
- node_modules
31+
key: v1-dependencies-{{ checksum "yarn.lock" }}
32+
33+
jobs:
34+
lint:
35+
<<: *base
36+
steps:
37+
- checkout
38+
- <<: *restore_yarn_cache
39+
- <<: *restore_npm_cache
40+
- run: yarn
41+
- <<: *save_yarn_cache
42+
- <<: *save_npm_cache
43+
- run:
44+
name: Run eslint
45+
command: npm run eslint -- --max-warnings 0
46+
47+
tests:
48+
<<: *base
49+
steps:
50+
- checkout
51+
- <<: *restore_npm_cache
52+
- run: npm test
53+
- run:
54+
name: Send coverage to Coveralls
55+
command: cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
56+
- store_test_results:
57+
path: mocha-test-results
58+
- store_artifacts:
59+
path: lib
60+
destination: lib
61+
- store_artifacts:
62+
path: coverage
63+
destination: coverage
64+
65+
publish:
66+
<<: *base
67+
steps:
68+
- checkout
69+
- <<: *restore_npm_cache
70+
# - run: .circleci/check-tag.sh
71+
# - run: .circleci/export-api-key.sh
72+
- run: npm publish
73+
74+
75+
deploy_demo:
76+
<<: *base
77+
steps:
78+
- checkout
79+
- <<: *restore_npm_cache
80+
- run: .circleci/setup-git-user.sh
81+
- run: npm run build:demo
82+
- run: npm run deploy:demo
83+
- store_artifacts:
84+
path: demo/public
85+
destination: demo
86+
87+
workflows:
88+
version: 2
89+
pkg:
90+
jobs:
91+
- lint:
92+
filters:
93+
branches:
94+
ignore: gh-pages
95+
96+
- tests:
97+
requires:
98+
- lint
99+
100+
- publish:
101+
requires:
102+
- tests
103+
filters:
104+
branches:
105+
ignore: /.*/
106+
tags:
107+
only: /^v[0-9]+\.[0-9]+\.[0-9]+$/
108+
109+
- deploy_demo:
110+
requires:
111+
- tests
112+
filters:
113+
branches:
114+
only: [master, /deploy-.+/]

.circleci/export-api-key.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
3+
set -eu
4+
5+
echo "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}" >> ~/.npmrc
6+
chmod 600 ~/.npmrc

.circleci/setup-git-user.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
git config --global user.email "[email protected]"
4+
git config --global user.name "Circle CI"

.node-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.9.4
1+
8.11.1

circle.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

package.json

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,42 @@
66
"scripts": {
77
"eslint": "node_modules/.bin/eslint .",
88
"build": "npm run clean && npm run build:js",
9-
"build:demo": "NODE_ENV=production webpack --config demo/webpack.config.prod.js && rm -rf demo/public/css && cp -R demo/publicTemplate/* demo/public/",
10-
"build:js": "BABEL_DISABLE_CACHE=1 BABEL_ENV=production NODE_ENV=production node_modules/.bin/babel --out-dir='lib' --ignore='**/__test__/*' src",
11-
"clean": "node_modules/.bin/rimraf lib; node_modules/.bin/rimraf demo/public",
12-
"deploy:demo": "COMMIT=$(git rev-parse --short HEAD) && BRANCH=gh-pages && GIT_URL=$(git remote get-url origin) && DIR=.deploy; rm -rf $DIR; (git clone $GIT_URL -b $BRANCH $DIR || (git init $DIR && cd $DIR && git remote add origin $GIT_URL && git checkout -b $BRANCH)) && rm -rf ${DIR}/* && cp -R ${DIR}/../demo/public/* $DIR && cd $DIR && git add -A && git commit -m \"Built artifacts of ${COMMIT} [ci skip]\" && git push origin $BRANCH",
9+
"build:demo":
10+
"NODE_ENV=production webpack --config demo/webpack.config.prod.js && rm -rf demo/public/css && cp -R demo/publicTemplate/* demo/public/",
11+
"build:js":
12+
"BABEL_DISABLE_CACHE=1 BABEL_ENV=production NODE_ENV=production node_modules/.bin/babel --out-dir='lib' --ignore='**/__test__/*' src",
13+
"clean":
14+
"node_modules/.bin/rimraf lib; node_modules/.bin/rimraf demo/public",
15+
"deploy:demo":
16+
"COMMIT=$(git rev-parse --short HEAD) && BRANCH=gh-pages && GIT_URL=$(git config --get remote.origin.url) && DIR=.deploy; rm -rf $DIR; (git clone $GIT_URL -b $BRANCH $DIR || (git init $DIR && cd $DIR && git remote add origin $GIT_URL && git checkout -b $BRANCH)) && rm -rf ${DIR}/* && cp -R ${DIR}/../demo/public/* $DIR && cd $DIR && git add -A && git commit -m \"Built artifacts of ${COMMIT}\" && git push origin $BRANCH",
1317
"prepublish": "npm run build",
1418
"start": "npm run start:dev",
1519
"start:dev": "node_modules/.bin/babel-node ./demo/server.js",
1620
"test": "npm run test:coverage",
17-
"test:coverage": "node_modules/.bin/nyc --require babel-core/register npm run test:mocha",
21+
"test:coverage":
22+
"node_modules/.bin/nyc --require babel-core/register npm run test:mocha",
1823
"test:mocha": "mocha --opts .mocha.opts $(find src -name '*-test.js')",
1924
"test:watch": "npm test | npm run watch",
2025
"watch": "npm-watch",
2126
"postinstall": "opencollective postinstall"
2227
},
2328
"watch": {
2429
"test": {
25-
"patterns": [
26-
"src/**/*.js"
27-
]
30+
"patterns": ["src/**/*.js"]
2831
}
2932
},
3033
"repository": {
3134
"type": "git",
3235
"url": "git+https://github.com/ngs/draft-js-markdown-shortcuts-plugin.git"
3336
},
34-
"keywords": [
35-
"draftjs",
36-
"editor",
37-
"plugin",
38-
"markdown"
39-
],
37+
"keywords": ["draftjs", "editor", "plugin", "markdown"],
4038
"author": "Atsushi Nagase",
4139
"license": "MIT",
4240
"bugs": {
4341
"url": "https://github.com/ngs/draft-js-markdown-shortcuts-plugin/issues"
4442
},
45-
"homepage": "https://github.com/ngs/draft-js-markdown-shortcuts-plugin#readme",
43+
"homepage":
44+
"https://github.com/ngs/draft-js-markdown-shortcuts-plugin#readme",
4645
"devDependencies": {
4746
"autoprefixer": "^6.5.3",
4847
"babel-cli": "^6.18.0",
@@ -102,13 +101,12 @@
102101
"webpack-hot-middleware": "^2.13.2"
103102
},
104103
"peerDependencies": {
105-
"draft-js-plugins-editor": "^2.0.0 || ~2.0.0-rc.1 || 2.0.0-rc2 || 2.0.0-rc1 || 2.0.0-beta12",
104+
"draft-js-plugins-editor":
105+
"^2.0.0 || ~2.0.0-rc.1 || 2.0.0-rc2 || 2.0.0-rc1 || 2.0.0-beta12",
106106
"react": "^16.0.0 || ^15.0.0",
107107
"react-dom": "^16.0.0 || ^15.0.0"
108108
},
109-
"contributors": [
110-
"Atsushi Nagase <[email protected]>"
111-
],
109+
"contributors": ["Atsushi Nagase <[email protected]>"],
112110
"dependencies": {
113111
"decorate-component-with-props": "^1.1.0",
114112
"draft-js": "~0.10.5",
@@ -120,4 +118,4 @@
120118
"type": "opencollective",
121119
"url": "https://opencollective.com/draft-js-markdown-shortcuts-plugin"
122120
}
123-
}
121+
}

0 commit comments

Comments
 (0)