Skip to content

Commit 4cb4dcd

Browse files
committed
clean: Apply configuration from d2h
1 parent e0b03f7 commit 4cb4dcd

File tree

12 files changed

+337
-126
lines changed

12 files changed

+337
-126
lines changed

.circleci/config.yml

Lines changed: 168 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,194 @@
1-
version: 2
1+
version: 2.1
22

3-
reference:
4-
build-common: &common-build
5-
working_directory: ~/diff2html-cli
6-
steps: &common-steps
3+
jobs:
4+
checkout-and-version:
5+
docker:
6+
- image: codacy/git-version
7+
working_directory: ~/workdir
8+
steps:
79
- checkout
10+
- run:
11+
name: Get next version
12+
command: |
13+
# Hack: Set a unique fake name for the release branch to avoid releasing master as the new 3.x major release for now
14+
export NEXT_VERSION="$(/bin/git-version --folder=$PWD --release-branch=FAKE-RELEASE-BRANCH-NAME)"
15+
echo "Next version is ${NEXT_VERSION}"
16+
echo "${NEXT_VERSION}" > .version
17+
- run:
18+
name: Get next npm tag name
19+
command: |
20+
if [ "${GITHUB_REF#refs/heads/}" = "master" ]; then
21+
export PUBLISH_TAG="latest"
22+
elif [ "${GITHUB_REF#refs/heads/}" = "next" ]; then
23+
export PUBLISH_TAG="next"
24+
else
25+
export PUBLISH_TAG="pr"
26+
fi
27+
echo "Next tag is ${PUBLISH_TAG}"
28+
echo "${PUBLISH_TAG}" > .tag
29+
- persist_to_workspace:
30+
root: ~/workdir
31+
paths:
32+
- '*'
33+
34+
build-common: &common-build
35+
docker:
36+
- image: node
37+
working_directory: ~/workdir
38+
steps:
39+
- attach_workspace:
40+
at: ~/workdir
841
- restore_cache:
9-
key: dependency-cache-{{ checksum "yarn.lock" }}
10-
- run: yarn
42+
key: yarn-cache-{{ checksum "yarn.lock" }}
43+
- run:
44+
name: Log environment setup
45+
command: |
46+
node -v
47+
yarn -v
48+
- run:
49+
name: Install dependencies
50+
command: yarn
1151
- save_cache:
12-
key: dependency-cache-{{ checksum "yarn.lock" }}
52+
key: yarn-cache-{{ checksum "yarn.lock" }}
1353
paths:
14-
- ./node_modules
15-
- run: yarn run build
16-
- run: yarn run coverage
54+
- /usr/local/share/.cache/yarn
55+
- run: yarn run validate
56+
- store_artifacts:
57+
path: coverage
58+
- store_test_results:
59+
path: coverage
1760

1861
build-latest: &latest-build
19-
working_directory: ~/diff2html-cli
62+
docker:
63+
- image: node
64+
working_directory: ~/workdir
2065
steps:
21-
- checkout
66+
- attach_workspace:
67+
at: ~/workdir
2268
- restore_cache:
23-
key: dependency-cache-{{ checksum "yarn.lock" }}
24-
- run: yarn
69+
key: yarn-cache-{{ checksum "yarn.lock" }}
70+
- run:
71+
name: Log environment setup
72+
command: |
73+
node -v
74+
yarn -v
75+
- run:
76+
name: Install dependencies
77+
command: yarn
2578
- save_cache:
26-
key: dependency-cache-{{ checksum "yarn.lock" }}
79+
key: yarn-cache-{{ checksum "yarn.lock" }}
2780
paths:
28-
- ./node_modules
29-
- run: yarn run test
30-
- run: yarn run lint
31-
- run: yarn run coverage
32-
- run: yarn run codacy
81+
- /usr/local/share/.cache/yarn
82+
- run: yarn run validate
83+
- store_artifacts:
84+
path: coverage
85+
- store_test_results:
86+
path: coverage
87+
- run: yarn run coverage:push
88+
- persist_to_workspace:
89+
root: ~/workdir
90+
paths:
91+
- '*'
3392

34-
jobs:
35-
build-node_8:
93+
build-node-10:
3694
<<: *common-build
3795
docker:
38-
- image: node:8
96+
- image: node:10
3997

40-
build-node_10:
98+
build-node-11:
4199
<<: *common-build
42100
docker:
43-
- image: node:10
101+
- image: node:11
44102

45-
build-node_11:
103+
build-node-12:
46104
<<: *common-build
47105
docker:
48-
- image: node:11
106+
- image: node:12
49107

50-
build-node_12:
108+
build-node-13:
51109
<<: *latest-build
52110
docker:
53-
- image: node:12
111+
- image: node:13
112+
113+
publish_library:
114+
docker:
115+
- image: node:13
116+
working_directory: ~/workdir
117+
steps:
118+
- attach_workspace:
119+
at: ~/workdir
120+
- run:
121+
name: Configure Yarn version
122+
command: |
123+
yarn config set version-tag-prefix ""
124+
yarn config set version-git-message "Release version %s"
125+
- run:
126+
name: Configure Git
127+
command: |
128+
git config user.email "circleci@users.noreply.github.com"
129+
git config user.name "CircleCI"
130+
- run:
131+
name: Version package
132+
command: |
133+
# Update version in packages to publish
134+
yarn version --non-interactive --new-version $(cat .version)
135+
- run:
136+
name: Setup npm credentials
137+
command: |
138+
rm -f .npmrc
139+
touch .npmrc
140+
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" >> .npmrc
141+
echo "registry=https://registry.npmjs.org/" >> .npmrc
142+
echo "access=public" >> .npmrc
143+
echo "save-exact=true" >> .npmrc
144+
- run:
145+
name: Publish npm package
146+
command: |
147+
# Publish package versions to npmjs.org
148+
yarn publish --tag $(cat .tag) --non-interactive --new-version $(cat .version)
149+
- run:
150+
name: Setup gpr credentials
151+
command: |
152+
rm -f .npmrc
153+
touch .npmrc
154+
echo "//npm.pkg.github.com/:_authToken=${GPR_AUTH_TOKEN}" >> .npmrc
155+
echo "@rtfpessoa:registry=https://npm.pkg.github.com/" >> .npmrc
156+
echo "access=public" >> .npmrc
157+
echo "save-exact=true" >> .npmrc
158+
- run:
159+
name: Publish gpr package
160+
command: |
161+
# HACK: Override npm package name to be able to publish in GitHub
162+
sed -i 's/^ "name":.*/ "name": "@rtfpessoa\/diff2html-cli",/g' package.json
163+
echo "Going to publish version $(cat .version) to GitHub"
164+
yarn publish --tag $(cat .tag) --non-interactive --new-version $(cat .version)
165+
# HACK: Restore npm package name
166+
sed -i 's/^ "name":.*/ "name": "diff2html-cli",/g' package.json
54167
55168
workflows:
56-
version: 2
57-
build:
169+
validate-and-publish:
58170
jobs:
59-
- build-node_8
60-
- build-node_10
61-
- build-node_11
62-
- build-node_12
171+
- checkout-and-version
172+
- build-node-10:
173+
requires:
174+
- checkout-and-version
175+
- build-node-11:
176+
requires:
177+
- checkout-and-version
178+
- build-node-12:
179+
requires:
180+
- checkout-and-version
181+
- build-node-13:
182+
requires:
183+
- checkout-and-version
184+
- publish_approval:
185+
type: approval
186+
requires:
187+
- build-node-10
188+
- build-node-11
189+
- build-node-12
190+
- build-node-13
191+
- publish_library:
192+
requires:
193+
- publish_approval
194+

.eslintrc.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
parserOptions: {
4+
ecmaVersion: 2018,
5+
sourceType: 'module',
6+
},
7+
env: {
8+
browser: true,
9+
es6: true,
10+
node: true,
11+
},
12+
globals: {
13+
Atomics: 'readonly',
14+
SharedArrayBuffer: 'readonly',
15+
document: 'readonly',
16+
navigator: 'readonly',
17+
window: 'readonly',
18+
},
19+
extends: [
20+
'eslint:recommended',
21+
'plugin:@typescript-eslint/eslint-recommended',
22+
'plugin:@typescript-eslint/recommended',
23+
'plugin:json/recommended',
24+
'plugin:promise/recommended',
25+
'plugin:import/errors',
26+
'plugin:import/warnings',
27+
'plugin:import/typescript',
28+
'plugin:node/recommended',
29+
'plugin:sonarjs/recommended',
30+
'plugin:jest/recommended',
31+
'plugin:jest/style',
32+
'prettier',
33+
'prettier/@typescript-eslint',
34+
'prettier/babel',
35+
],
36+
plugins: ['@typescript-eslint', 'json', 'promise', 'import', 'node', 'sonarjs', 'jest', 'optimize-regex'],
37+
rules: {
38+
// Enable
39+
'optimize-regex/optimize-regex': 'error',
40+
// Hack: For some reason we need pass again the extensions
41+
'node/no-missing-import': [
42+
'error',
43+
{
44+
tryExtensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
45+
},
46+
],
47+
// Disable
48+
// https://github.com/benmosher/eslint-plugin-import/issues/1446
49+
'import/named': 'off',
50+
// We don't need this since we are using transpilation
51+
'node/no-unsupported-features/es-syntax': 'off',
52+
'no-process-exit': 'off',
53+
// Too verbose
54+
'sonarjs/no-duplicate-string': 'off',
55+
// Too verbose
56+
'sonarjs/cognitive-complexity': 'off',
57+
},
58+
};

.eslintrc.json

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

.gitignore

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Eclipse
2+
.classpath
3+
.project
4+
.settings/
5+
16
# Intellij
27
.idea/
38
*.iml
@@ -6,13 +11,22 @@
611
# Mac
712
.DS_Store
813

14+
# Maven
15+
log/
16+
target/
17+
918
# Node
10-
/node_modules/
11-
/npm-debug.log
12-
/yarn-error.log
19+
node_modules/
20+
npm-debug.log
21+
yarn-error.log
1322

1423
# Coverage
15-
/coverage/
24+
coverage/
25+
26+
# Bower
27+
bower_components/
28+
29+
# Terraform
30+
/terraform/.terraform
1631

17-
# Build
18-
/build/
32+
/lib/

.prettierrc.json

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
{
2-
"tabWidth": 2,
2+
"arrowParens": "avoid",
3+
"bracketSpacing": true,
4+
"htmlWhitespaceSensitivity": "css",
5+
"insertPragma": false,
6+
"jsxBracketSameLine": false,
7+
"jsxSingleQuote": false,
38
"printWidth": 120,
4-
"useTabs": false,
9+
"proseWrap": "always",
10+
"quoteProps": "as-needed",
11+
"requirePragma": false,
512
"semi": true,
6-
"trailingComma": "none",
7-
"bracketSpacing": true,
8-
"arrowParens": "always"
13+
"singleQuote": true,
14+
"tabWidth": 2,
15+
"trailingComma": "all",
16+
"useTabs": false
917
}

0 commit comments

Comments
 (0)