Skip to content

Commit 36fc158

Browse files
authored
Major Repository/Project Cleanup (#11)
* Switch from NPM to Yarn * Add new linting rules, with ESLint * Re-enable and fix unit test for `ChangeEvent` types * Improve build process for debugging vs release
1 parent 92f5292 commit 36fc158

24 files changed

+7388
-14096
lines changed

.circleci/config.yml

Lines changed: 91 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,79 @@
1-
version: 2
1+
version: 2.1
22

33
defaults: &defaults
44
working_directory: ~/repo
55
docker:
66
- image: circleci/node:lts-buster
77

88
jobs:
9-
build_and_test:
9+
verify_code:
1010
<<: *defaults
1111

12-
environment:
13-
KEYS_DIR: '/tmp/keys'
14-
DX_CLI_URL: 'https://developer.salesforce.com/media/salesforce-cli/sfdx-linux-amd64.tar.xz'
12+
parameters:
13+
build_mode:
14+
type: string
15+
description: |-
16+
The build mode to use when bundling the final package
17+
enum:
18+
- debug
19+
- release
20+
default: debug
1521

1622
steps:
1723
- checkout
1824

1925
- restore_cache:
2026
keys:
21-
- v1-dependencies-{{ checksum "package-lock.json" }}
27+
- v1-dependencies-{{ checksum "yarn.lock" }}
2228
- v1-dependencies-
2329

2430
- run:
2531
name: Node Dependencies
2632
command: |
27-
npm install
33+
yarn install
2834
2935
- save_cache:
3036
paths:
3137
- node_modules
32-
key: v1-dependencies-{{ checksum "package-lock.json" }}
38+
key: v1-dependencies-{{ checksum "yarn.lock" }}
39+
40+
- run:
41+
name: Build Package
42+
command: |
43+
yarn build:<< parameters.build_mode >>
3344
3445
- persist_to_workspace:
3546
root: ~/repo
36-
paths: .
47+
paths:
48+
- dist
3749

3850
- run:
39-
name: Build Package
51+
name: Lint Code
4052
command: |
41-
npm run build
53+
yarn lint
4254
4355
- run:
4456
name: Unit Tests
4557
command: |
46-
npm test
58+
yarn test
59+
60+
integration_tests:
61+
<<: *defaults
62+
63+
environment:
64+
KEYS_DIR: '/tmp/keys'
65+
DX_CLI_URL: 'https://developer.salesforce.com/media/salesforce-cli/sfdx-linux-amd64.tar.xz'
66+
67+
steps:
68+
- checkout
69+
70+
- attach_workspace:
71+
at: ~/repo
72+
73+
- restore_cache:
74+
keys:
75+
- v1-dependencies-{{ checksum "yarn.lock" }}
76+
- v1-dependencies-
4777

4878
- run:
4979
name: Salesforce CLI
@@ -99,19 +129,16 @@ jobs:
99129
./deploy_and_test_apex.sh
100130
101131
- store_test_results:
102-
working_directory: test/integ
103132
path: test/integ/test_reports
104133

105-
publish:
134+
bump_version:
106135
<<: *defaults
107136

108137
steps:
109138
- checkout
110139

111-
- restore_cache:
112-
keys:
113-
- v1-dependencies-{{ checksum "package-lock.json" }}
114-
- v1-dependencies-
140+
- attach_workspace:
141+
at: ~/repo
115142

116143
- add_ssh_keys:
117144
fingerprints:
@@ -120,14 +147,21 @@ jobs:
120147
- run:
121148
name: Update Package Version
122149
command: |
123-
npm version --no-git-tag-version version $CIRCLE_TAG -m "[skip ci] Update package version: %s"
150+
yarn version \
151+
--message "[skip ci] Update package version: %s" \
152+
--patch
124153
git push origin master
125154
155+
publish:
156+
<<: *defaults
157+
158+
steps:
126159
- run:
127160
name: Publish NPM Package
128161
command: |
129162
echo "//registry.npmjs.org/:_authToken=$npm_TOKEN" > ~/repo/.npmrc
130-
npm publish
163+
yarn publish
164+
131165
132166
non_master: &non_master
133167
filters:
@@ -139,15 +173,44 @@ master_only: &master_only
139173
branches:
140174
only: master
141175

176+
tagged_only: &tagged_only
177+
filters:
178+
tags:
179+
only: /^v\d+\.\d+\.\d+$/
180+
branches:
181+
ignore: /.*/
182+
142183
workflows:
143-
version: 2
144-
ci-cd:
184+
185+
development:
145186
jobs:
146-
- build_and_test:
187+
- verify_code:
188+
name: verify_code_dev
147189
<<: *non_master
190+
- integration_tests:
191+
name: integration_tests_dev
192+
requires:
193+
- verify_code_dev
194+
195+
production:
196+
jobs:
197+
- verify_code:
198+
name: verify_code_production
199+
<<: *master_only
200+
- integration_tests:
201+
name: integration_tests_production
202+
requires:
203+
- verify_code_production
204+
- bump_version:
205+
requires:
206+
- integration_tests_production
207+
208+
release:
209+
jobs:
210+
- verify_code:
211+
name: verify_code_release
212+
build_mode: release
213+
<<: *tagged_only
148214
- publish:
149-
filters:
150-
branches:
151-
ignore: /.*/
152-
tags:
153-
only: /^\d+\.\d+\.\d+$/
215+
requires:
216+
- verify_code_release

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.github
2+
dist
3+
node_modules
4+
package-lock.json

.eslintrc

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
{
2+
"env": {
3+
"commonjs": true,
4+
"es2021": true,
5+
"node": true,
6+
"mocha": true
7+
},
8+
"extends": [
9+
"eslint:recommended",
10+
"plugin:jsonc/recommended-with-jsonc"
11+
],
12+
"overrides": [
13+
{
14+
"files": [
15+
".eslintrc",
16+
"*.json"
17+
],
18+
"parser": "jsonc-eslint-parser"
19+
}
20+
],
21+
"parserOptions": {
22+
"ecmaVersion": 12,
23+
"sourceType": "module"
24+
},
25+
"plugins": [
26+
"jsonc",
27+
"putout"
28+
],
29+
"root": true,
30+
"rules": {
31+
"arrow-parens": "error",
32+
"arrow-spacing": "error",
33+
"array-bracket-newline": [
34+
"error",
35+
{
36+
"minItems": 1
37+
}
38+
],
39+
"array-element-newline": [
40+
"error",
41+
"always"
42+
],
43+
"camelcase": [
44+
"error",
45+
{
46+
"properties": "never"
47+
}
48+
],
49+
"comma-dangle": [
50+
"error",
51+
"always-multiline"
52+
],
53+
"comma-spacing": "error",
54+
"eol-last": "error",
55+
"function-call-argument-newline": [
56+
"error",
57+
"consistent"
58+
],
59+
"function-paren-newline": [
60+
"error",
61+
"consistent"
62+
],
63+
"indent": [
64+
"error",
65+
2
66+
],
67+
"key-spacing": "error",
68+
"keyword-spacing": "error",
69+
"max-len": [
70+
"error",
71+
{
72+
"code": 100,
73+
"tabWidth": 2,
74+
"ignoreTrailingComments": true,
75+
"ignoreUrls": true,
76+
"ignoreStrings": true,
77+
"ignoreTemplateLiterals": true,
78+
"ignoreRegExpLiterals": true
79+
}
80+
],
81+
"multiline-ternary": [
82+
"error",
83+
"always"
84+
],
85+
"newline-per-chained-call": "error",
86+
"no-constant-condition": [
87+
"error",
88+
{
89+
"checkLoops": false
90+
}
91+
],
92+
"no-multiple-empty-lines": [
93+
"error",
94+
{
95+
"max": 1,
96+
"maxBOF": 0,
97+
"maxEOF": 1
98+
}
99+
],
100+
"no-trailing-spaces": "error",
101+
"no-unused-vars": "error",
102+
"object-curly-newline": [
103+
"error",
104+
{
105+
"ExportDeclaration": "always",
106+
"ImportDeclaration": {
107+
"minProperties": 2,
108+
"multiline": true
109+
},
110+
"ObjectExpression": {
111+
"minProperties": 1,
112+
"multiline": true
113+
},
114+
"ObjectPattern": {
115+
"minProperties": 2,
116+
"multiline": true
117+
}
118+
}
119+
],
120+
"object-curly-spacing": [
121+
"error",
122+
"always"
123+
],
124+
"object-property-newline": [
125+
"error",
126+
{
127+
"allowAllPropertiesOnSameLine": false
128+
}
129+
],
130+
"putout/for-of-multiple-properties-destructuring": "error",
131+
"putout/multiple-properties-destructuring": [
132+
"error",
133+
{
134+
"minProperties": 2
135+
}
136+
],
137+
"quote-props": [
138+
"error",
139+
"consistent"
140+
],
141+
"quotes": "error",
142+
"semi": "error",
143+
"space-before-blocks": [
144+
"error",
145+
"always"
146+
],
147+
"space-infix-ops": "error"
148+
}
149+
}

.mocharc.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
2-
"require": ["esm", "handlebars-loader"],
2+
"enable-source-maps": true,
3+
"require": [
4+
"esm",
5+
"handlebars-loader"
6+
],
37
"spec": "test/unit/**/*.test.js",
48
"timeout": 10000
59
}

.nycrc.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{
22
"all": true,
3-
"include": ["src/**/*.js"],
4-
"require": ["esm"],
3+
"include": [
4+
"src/**/*.js"
5+
],
6+
"require": [
7+
"esm"
8+
],
59
"reporter": "text",
610
"check-coverage": true,
711
"lines": 100,

.prettierrc

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

0 commit comments

Comments
 (0)