Skip to content

Commit b18cb93

Browse files
authored
Merge pull request #89 from rtfpessoa/apply-configs-from-d2h
Apply configs from d2h
2 parents e0b03f7 + 8461d0e commit b18cb93

24 files changed

+689
-507
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 "[email protected]"
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.

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,22 @@
11
---
2-
name: Bug report
3-
about: Create a report to help us improve
4-
title: ''
5-
labels: ''
6-
assignees: ''
72

8-
---
3+
name: Bug report about: Create a report to help us improve title: '' labels: '' assignees: '' ---**Describe the bug** A
4+
clear and concise description of what the bug is.
95

10-
**Describe the bug**
11-
A clear and concise description of what the bug is.
6+
**To Reproduce** Steps to reproduce the behavior:
127

13-
**To Reproduce**
14-
Steps to reproduce the behavior:
158
1. Go to '...'
169
2. Click on '....'
1710
3. Scroll down to '....'
1811
4. See error
1912

20-
**Expected behavior**
21-
A clear and concise description of what you expected to happen.
13+
**Expected behavior** A clear and concise description of what you expected to happen.
2214

23-
**Screenshots**
24-
If applicable, add screenshots to help explain your problem.
15+
**Screenshots** If applicable, add screenshots to help explain your problem.
2516

2617
**Desktop (please complete the following information):**
27-
- OS: [e.g. Windows, Linux, Mac]
28-
- Version [e.g. 22]
2918

30-
**Additional context**
31-
Add any other context about the problem here.
19+
- OS: [e.g. Windows, Linux, Mac]
20+
- Version [e.g. 22]
21+
22+
**Additional context** Add any other context about the problem here.
Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
---
2-
name: Feature request
3-
about: Suggest an idea for this project
4-
title: ''
5-
labels: ''
6-
assignees: ''
72

8-
---
9-
10-
**Is your feature request related to a problem? Please describe.**
11-
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
3+
name: Feature request about: Suggest an idea for this project title: '' labels: '' assignees: '' ---**Is your feature
4+
request related to a problem? Please describe.** A clear and concise description of what the problem is. Ex. I'm always
5+
frustrated when [...]
126

13-
**Describe the solution you'd like**
14-
A clear and concise description of what you want to happen.
7+
**Describe the solution you'd like** A clear and concise description of what you want to happen.
158

16-
**Describe alternatives you've considered**
17-
A clear and concise description of any alternative solutions or features you've considered.
9+
**Describe alternatives you've considered** A clear and concise description of any alternative solutions or features
10+
you've considered.
1811

19-
**Additional context**
20-
Add any other context or screenshots about the feature request here.
12+
**Additional context** Add any other context or screenshots about the feature request here.

0 commit comments

Comments
 (0)