node-publisher 3.0.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +2 -4
- package/.nvmrc +1 -1
- package/CHANGELOG.md +46 -18
- package/package.json +11 -12
- package/src/client/yarn.js +23 -1
- package/src/client/yarn.spec.js +90 -16
- package/src/setup/release-branch/index.js +3 -5
- package/src/utils/index.js +12 -12
package/.eslintrc.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"env": {
|
|
3
3
|
"browser": false,
|
|
4
4
|
"es6": true,
|
|
5
|
-
"jest
|
|
5
|
+
"jest": true,
|
|
6
6
|
"node": true
|
|
7
7
|
},
|
|
8
8
|
"extends": ["standard", "prettier", "prettier/standard"],
|
|
@@ -11,9 +11,7 @@
|
|
|
11
11
|
"SharedArrayBuffer": "readonly"
|
|
12
12
|
},
|
|
13
13
|
"parser": "babel-eslint",
|
|
14
|
-
"plugins": [
|
|
15
|
-
"jest"
|
|
16
|
-
],
|
|
14
|
+
"plugins": ["jest"],
|
|
17
15
|
"rules": {
|
|
18
16
|
"react/no-unused-prop-types": "off",
|
|
19
17
|
"react/prop-types": "off",
|
package/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
v22.16.0
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
### v3.1.0 (2024-01-24)
|
|
2
|
+
|
|
3
|
+
#### Pull requests
|
|
4
|
+
|
|
5
|
+
- [#55](https://github.com/zendesk/node-publisher/pull/55) Upgrade offline-github-changelog to fix duplicate authors ([Sune Simonsen](mailto:sune@we-knowhow.dk))
|
|
6
|
+
- [#54](https://github.com/zendesk/node-publisher/pull/54) Make local installs work with yarn v4 ([Sune Simonsen](mailto:sune@we-knowhow.dk))
|
|
7
|
+
|
|
8
|
+
#### Commits to master
|
|
9
|
+
|
|
10
|
+
- [v3.1.0](https://github.com/zendesk/node-publisher/commit/5a1605e05a331211d8533533aba481aa724263ab) ([Sune Simonsen](mailto:sune@we-knowhow.dk))
|
|
11
|
+
- [Update changelog](https://github.com/zendesk/node-publisher/commit/f06d6612e0a3fc350ba06b9925c42852e92c32c8) ([Sune Simonsen](mailto:sune@we-knowhow.dk))
|
|
12
|
+
|
|
13
|
+
### v3.0.0 (2022-12-06)
|
|
14
|
+
|
|
15
|
+
#### Pull requests
|
|
16
|
+
|
|
17
|
+
- [#47](https://github.com/zendesk/node-publisher/pull/47) Upgrade offline-github-changelog \(Major\) ([Sune Simonsen](mailto:sune@we-knowhow.dk))
|
|
18
|
+
- [#46](https://github.com/zendesk/node-publisher/pull/46) Upgrade offline-github-changelog ([Sune Simonsen](mailto:sune@we-knowhow.dk))
|
|
19
|
+
|
|
20
|
+
#### Commits to master
|
|
21
|
+
|
|
22
|
+
- [v3.0.0](https://github.com/zendesk/node-publisher/commit/0f45304577e5fed207837410288891468bb75cd5) ([Sune Simonsen](mailto:sune@we-knowhow.dk))
|
|
23
|
+
- [Fixed incorrect version in package.json](https://github.com/zendesk/node-publisher/commit/58470f3f6eb3d33794dc9644404c14b78cd08310) ([Sune Simonsen](mailto:sune@we-knowhow.dk))
|
|
24
|
+
- [Update changelog](https://github.com/zendesk/node-publisher/commit/44c13daf67e3ddda081c86090817654358500f62) ([Sune Simonsen](mailto:sune@we-knowhow.dk))
|
|
25
|
+
- [v1.6.0](https://github.com/zendesk/node-publisher/commit/881d9273d016e37fb742ecb20e5b946f7cf6efd2) ([Sune Simonsen](mailto:sune@we-knowhow.dk))
|
|
26
|
+
- [Update changelog](https://github.com/zendesk/node-publisher/commit/bc7bbe4d1c8fcd25942ecf46e300c10eed1bce12) ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
27
|
+
- [+1 more](https://github.com/zendesk/node-publisher/compare/v2.0.0...v3.0.0)
|
|
28
|
+
|
|
1
29
|
### v2.0.0 (2021-09-17)
|
|
2
30
|
|
|
3
31
|
- [v2.0.0](https://github.com/zendesk/node-publisher/commit/0527a926c6af2f080ed13d8b7b9ddd0cb516dd36) ([Sune Simonsen](mailto:sune@we-knowhow.dk))
|
|
@@ -17,7 +45,7 @@
|
|
|
17
45
|
|
|
18
46
|
#### Pull requests
|
|
19
47
|
|
|
20
|
-
- [#45](https://github.com/zendesk/node-publisher/pull/45) Upgrade offline-github-changelog to the latest version \(Major\) ([Sune Simonsen](mailto:sune@we-knowhow.dk)
|
|
48
|
+
- [#45](https://github.com/zendesk/node-publisher/pull/45) Upgrade offline-github-changelog to the latest version \(Major\) ([Sune Simonsen](mailto:sune@we-knowhow.dk))
|
|
21
49
|
|
|
22
50
|
#### Commits to master
|
|
23
51
|
|
|
@@ -29,7 +57,7 @@
|
|
|
29
57
|
#### Pull requests
|
|
30
58
|
|
|
31
59
|
- [#44](https://github.com/zendesk/node-publisher/pull/44) Upgrade offline-github-changelog to the latest version ([Sune Simonsen](mailto:sune@we-knowhow.dk))
|
|
32
|
-
- [#42](https://github.com/zendesk/node-publisher/pull/42) Add GitHub Actions workflows to migrate away from Travis-CI ([Attila Večerek](mailto:avecerek@zendesk.com), [
|
|
60
|
+
- [#42](https://github.com/zendesk/node-publisher/pull/42) Add GitHub Actions workflows to migrate away from Travis-CI ([Attila Večerek](mailto:avecerek@zendesk.com), [John Shen](mailto:john@everops.com))
|
|
33
61
|
- [#43](https://github.com/zendesk/node-publisher/pull/43) Use node version from .nvmrc in GHA workflow ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
34
62
|
|
|
35
63
|
#### Commits to master
|
|
@@ -42,7 +70,7 @@
|
|
|
42
70
|
#### Pull requests
|
|
43
71
|
|
|
44
72
|
- [#41](https://github.com/zendesk/node-publisher/pull/41) Fix reading the contents of .nvmrc ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
45
|
-
- [#40](https://github.com/zendesk/node-publisher/pull/40) Remove dependency on NVM ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
73
|
+
- [#40](https://github.com/zendesk/node-publisher/pull/40) Remove dependency on NVM ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
46
74
|
|
|
47
75
|
#### Commits to master
|
|
48
76
|
|
|
@@ -55,11 +83,11 @@
|
|
|
55
83
|
|
|
56
84
|
- [#37](https://github.com/zendesk/node-publisher/pull/37) Update jest ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
57
85
|
- [#36](https://github.com/zendesk/node-publisher/pull/36) Update lint-staged ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
58
|
-
- [#33](https://github.com/zendesk/node-publisher/pull/33) Update dependencies ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
86
|
+
- [#33](https://github.com/zendesk/node-publisher/pull/33) Update dependencies ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
59
87
|
- [#35](https://github.com/zendesk/node-publisher/pull/35) Fix the generated config for custom release branches ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
60
88
|
- [#34](https://github.com/zendesk/node-publisher/pull/34) Order branches during the release branch selection setup process ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
61
|
-
- [#32](https://github.com/zendesk/node-publisher/pull/32) Implement a setup script, take 2 ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
62
|
-
- [#31](https://github.com/zendesk/node-publisher/pull/31) Address security alerts ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
89
|
+
- [#32](https://github.com/zendesk/node-publisher/pull/32) Implement a setup script, take 2 ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
90
|
+
- [#31](https://github.com/zendesk/node-publisher/pull/31) Address security alerts ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
63
91
|
|
|
64
92
|
#### Commits to master
|
|
65
93
|
|
|
@@ -71,7 +99,7 @@
|
|
|
71
99
|
#### Pull requests
|
|
72
100
|
|
|
73
101
|
- [#30](https://github.com/zendesk/node-publisher/pull/30) Fix the build step not committing the changes ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
74
|
-
- [#28](https://github.com/zendesk/node-publisher/pull/28) Add --branch release param ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
102
|
+
- [#28](https://github.com/zendesk/node-publisher/pull/28) Add --branch release param ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
75
103
|
|
|
76
104
|
#### Commits to master
|
|
77
105
|
|
|
@@ -82,7 +110,7 @@
|
|
|
82
110
|
|
|
83
111
|
#### Pull requests
|
|
84
112
|
|
|
85
|
-
- [#26](https://github.com/zendesk/node-publisher/pull/26) Support multiple release configurations ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
113
|
+
- [#26](https://github.com/zendesk/node-publisher/pull/26) Support multiple release configurations ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
86
114
|
|
|
87
115
|
#### Commits to master
|
|
88
116
|
|
|
@@ -93,7 +121,7 @@
|
|
|
93
121
|
|
|
94
122
|
#### Pull requests
|
|
95
123
|
|
|
96
|
-
- [#27](https://github.com/zendesk/node-publisher/pull/27) Remove version constraints and add prerelease option ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
124
|
+
- [#27](https://github.com/zendesk/node-publisher/pull/27) Remove version constraints and add prerelease option ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
97
125
|
|
|
98
126
|
#### Commits to master
|
|
99
127
|
|
|
@@ -104,7 +132,7 @@
|
|
|
104
132
|
|
|
105
133
|
#### Pull requests
|
|
106
134
|
|
|
107
|
-
- [#24](https://github.com/zendesk/node-publisher/pull/24) Add details to package.json + minor adjustments ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
135
|
+
- [#24](https://github.com/zendesk/node-publisher/pull/24) Add details to package.json + minor adjustments ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
108
136
|
- [#23](https://github.com/zendesk/node-publisher/pull/23) Fix small typo in readme ([Marc Høegh](mailto:Anifacted@users.noreply.github.com))
|
|
109
137
|
|
|
110
138
|
#### Commits to master
|
|
@@ -118,8 +146,8 @@
|
|
|
118
146
|
|
|
119
147
|
- [#22](https://github.com/zendesk/node-publisher/pull/22) Add publish config to be able to release with yarn again ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
120
148
|
- [#21](https://github.com/zendesk/node-publisher/pull/21) Rename package and adds licenses field to package.json ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
121
|
-
- [#20](https://github.com/zendesk/node-publisher/pull/20) Remove private repo configuration ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
122
|
-
- [#18](https://github.com/zendesk/node-publisher/pull/18) Update README ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
149
|
+
- [#20](https://github.com/zendesk/node-publisher/pull/20) Remove private repo configuration ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
150
|
+
- [#18](https://github.com/zendesk/node-publisher/pull/18) Update README ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
123
151
|
|
|
124
152
|
#### Commits to master
|
|
125
153
|
|
|
@@ -164,7 +192,7 @@
|
|
|
164
192
|
|
|
165
193
|
#### Pull requests
|
|
166
194
|
|
|
167
|
-
- [#14](https://github.com/zendesk/node-publisher/pull/14) Add test runner whitelist ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
195
|
+
- [#14](https://github.com/zendesk/node-publisher/pull/14) Add test runner whitelist ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
168
196
|
|
|
169
197
|
#### Commits to master
|
|
170
198
|
|
|
@@ -213,7 +241,7 @@
|
|
|
213
241
|
|
|
214
242
|
#### Pull requests
|
|
215
243
|
|
|
216
|
-
- [#6](https://github.com/zendesk/node-publisher/pull/6) Call local package bins directly instead of relying on
|
|
244
|
+
- [#6](https://github.com/zendesk/node-publisher/pull/6) Call local package bins directly instead of relying on \`yarn\` or \`npx\` ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
217
245
|
|
|
218
246
|
#### Commits to master
|
|
219
247
|
|
|
@@ -224,7 +252,7 @@
|
|
|
224
252
|
|
|
225
253
|
#### Pull requests
|
|
226
254
|
|
|
227
|
-
- [#5](https://github.com/zendesk/node-publisher/pull/5) Run binaries of local packages either using
|
|
255
|
+
- [#5](https://github.com/zendesk/node-publisher/pull/5) Run binaries of local packages either using \`yarn\` or \`npx\` ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
228
256
|
|
|
229
257
|
#### Commits to master
|
|
230
258
|
|
|
@@ -235,7 +263,7 @@
|
|
|
235
263
|
|
|
236
264
|
#### Pull requests
|
|
237
265
|
|
|
238
|
-
- [#4](https://github.com/zendesk/node-publisher/pull/4) Extend
|
|
266
|
+
- [#4](https://github.com/zendesk/node-publisher/pull/4) Extend \`package.json\` with a binary entry ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
239
267
|
|
|
240
268
|
#### Commits to master
|
|
241
269
|
|
|
@@ -246,7 +274,7 @@
|
|
|
246
274
|
|
|
247
275
|
#### Pull requests
|
|
248
276
|
|
|
249
|
-
- [#3](https://github.com/zendesk/node-publisher/pull/3) Fix
|
|
277
|
+
- [#3](https://github.com/zendesk/node-publisher/pull/3) Fix \`offline-github-changelog\` command not found error ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
250
278
|
|
|
251
279
|
#### Commits to master
|
|
252
280
|
|
|
@@ -257,7 +285,7 @@
|
|
|
257
285
|
|
|
258
286
|
#### Pull requests
|
|
259
287
|
|
|
260
|
-
- [#2](https://github.com/zendesk/node-publisher/pull/2) Fix rollback and own release ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
288
|
+
- [#2](https://github.com/zendesk/node-publisher/pull/2) Fix rollback and own release ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
261
289
|
- [#1](https://github.com/zendesk/node-publisher/pull/1) Initial PR ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
262
290
|
|
|
263
291
|
#### Commits to master
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-publisher",
|
|
3
|
+
"version": "3.2.0",
|
|
3
4
|
"description": "A configurable release automation tool inspired by create-react-app and Travis CI.",
|
|
4
5
|
"author": "Attila Večerek <avecerek@zendesk.com>",
|
|
5
6
|
"homepage": "https://github.com/zendesk/node-publisher#readme",
|
|
@@ -10,14 +11,11 @@
|
|
|
10
11
|
"bugs": {
|
|
11
12
|
"url": "https://github.com/zendesk/node-publisher/issues"
|
|
12
13
|
},
|
|
13
|
-
"version": "3.0.0",
|
|
14
14
|
"main": "src/index.js",
|
|
15
|
-
"bin":
|
|
16
|
-
"node-publisher": "./bin/node-publisher"
|
|
17
|
-
},
|
|
15
|
+
"bin": "./bin/node-publisher",
|
|
18
16
|
"scripts": {
|
|
19
17
|
"coverage": "jest --coverage",
|
|
20
|
-
"lint": "eslint
|
|
18
|
+
"lint": "eslint src/**/*.js bin/**",
|
|
21
19
|
"lint-staged": "lint-staged",
|
|
22
20
|
"release": "./bin/node-publisher release",
|
|
23
21
|
"test": "jest",
|
|
@@ -28,24 +26,24 @@
|
|
|
28
26
|
"commander": "2.15.1",
|
|
29
27
|
"inquirer": "6.5.0",
|
|
30
28
|
"js-yaml": "3.13.1",
|
|
31
|
-
"offline-github-changelog": "3.0
|
|
32
|
-
"semver": "
|
|
29
|
+
"offline-github-changelog": "3.1.0",
|
|
30
|
+
"semver": "7.7.2"
|
|
33
31
|
},
|
|
34
32
|
"devDependencies": {
|
|
35
|
-
"babel-eslint": "10.0
|
|
33
|
+
"babel-eslint": "10.1.0",
|
|
36
34
|
"eslint": "^6.0.0",
|
|
37
35
|
"eslint-config-prettier": "^6.0.0",
|
|
38
36
|
"eslint-config-standard": "^14.0.0",
|
|
39
37
|
"eslint-plugin-import": "^2.18.0",
|
|
40
|
-
"eslint-plugin-jest": "^
|
|
38
|
+
"eslint-plugin-jest": "^23.20.0",
|
|
41
39
|
"eslint-plugin-node": "^9.1.0",
|
|
42
40
|
"eslint-plugin-promise": "^4.2.0",
|
|
43
41
|
"eslint-plugin-standard": "^4.0.0",
|
|
44
|
-
"jest": "
|
|
42
|
+
"jest": "^27.0.0",
|
|
45
43
|
"lint-staged": "^9.0.0",
|
|
46
44
|
"pre-commit": "1.2.2",
|
|
47
45
|
"prettier": "1.18.2",
|
|
48
|
-
"prettier-package-json": "2.0
|
|
46
|
+
"prettier-package-json": "2.8.0"
|
|
49
47
|
},
|
|
50
48
|
"keywords": [
|
|
51
49
|
"lerna",
|
|
@@ -54,7 +52,7 @@
|
|
|
54
52
|
"yarn"
|
|
55
53
|
],
|
|
56
54
|
"engines": {
|
|
57
|
-
"node": ">=
|
|
55
|
+
"node": ">=20"
|
|
58
56
|
},
|
|
59
57
|
"publishConfig": {
|
|
60
58
|
"access": "public",
|
|
@@ -77,5 +75,6 @@
|
|
|
77
75
|
"git add"
|
|
78
76
|
]
|
|
79
77
|
},
|
|
78
|
+
"packageManager": "yarn@1.22.21",
|
|
80
79
|
"pre-commit": "lint-staged"
|
|
81
80
|
}
|
package/src/client/yarn.js
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
|
+
const { execSync } = require('child_process');
|
|
2
|
+
|
|
3
|
+
const getYarnVersion = () => {
|
|
4
|
+
try {
|
|
5
|
+
const output = execSync('yarn --version', { encoding: 'utf8' });
|
|
6
|
+
return output.trim();
|
|
7
|
+
} catch (error) {
|
|
8
|
+
// Default to yarn v1 if version detection fails
|
|
9
|
+
return '1.0.0';
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const isYarnV2OrHigher = () => {
|
|
14
|
+
const version = getYarnVersion();
|
|
15
|
+
const majorVersion = parseInt(version.split('.')[0], 10);
|
|
16
|
+
return majorVersion >= 2;
|
|
17
|
+
};
|
|
18
|
+
|
|
1
19
|
const publish = ({ nextVersion, execCommand }) => {
|
|
2
|
-
|
|
20
|
+
if (isYarnV2OrHigher()) {
|
|
21
|
+
execCommand(`yarn npm publish --tag ${nextVersion}`);
|
|
22
|
+
} else {
|
|
23
|
+
execCommand(`yarn publish --new-version ${nextVersion}`);
|
|
24
|
+
}
|
|
3
25
|
};
|
|
4
26
|
|
|
5
27
|
module.exports = {
|
package/src/client/yarn.spec.js
CHANGED
|
@@ -1,32 +1,106 @@
|
|
|
1
1
|
const { publish } = require('./yarn');
|
|
2
2
|
|
|
3
|
+
// Mock execSync to control yarn version detection
|
|
4
|
+
jest.mock('child_process', () => ({
|
|
5
|
+
execSync: jest.fn()
|
|
6
|
+
}));
|
|
7
|
+
|
|
8
|
+
const { execSync } = require('child_process');
|
|
9
|
+
|
|
3
10
|
describe('publish', () => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
preid: undefined,
|
|
8
|
-
execCommand: jest.fn()
|
|
9
|
-
};
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
jest.clearAllMocks();
|
|
13
|
+
});
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
describe('with yarn v1', () => {
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
execSync.mockReturnValue('1.22.10');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe('without preid', () => {
|
|
21
|
+
const options = {
|
|
22
|
+
nextVersion: 'patch',
|
|
23
|
+
preid: undefined,
|
|
24
|
+
execCommand: jest.fn()
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
it('publishes new version using yarn v1 syntax', () => {
|
|
28
|
+
expect(() => publish(options)).not.toThrow();
|
|
29
|
+
expect(options.execCommand.mock.calls[0][0]).toBe(
|
|
30
|
+
'yarn publish --new-version patch'
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe('with preid', () => {
|
|
36
|
+
const options = {
|
|
37
|
+
nextVersion: 'major',
|
|
38
|
+
preid: 'alpha',
|
|
39
|
+
execCommand: jest.fn()
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
it('publishes new version using yarn v1 syntax', () => {
|
|
43
|
+
expect(() => publish(options)).not.toThrow();
|
|
44
|
+
expect(options.execCommand.mock.calls[0][0]).toBe(
|
|
45
|
+
'yarn publish --new-version major'
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('with yarn v2+', () => {
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
execSync.mockReturnValue('4.1.0');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe('without preid', () => {
|
|
57
|
+
const options = {
|
|
58
|
+
nextVersion: 'patch',
|
|
59
|
+
preid: undefined,
|
|
60
|
+
execCommand: jest.fn()
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
it('publishes new version using yarn v2+ syntax', () => {
|
|
64
|
+
expect(() => publish(options)).not.toThrow();
|
|
65
|
+
expect(options.execCommand.mock.calls[0][0]).toBe(
|
|
66
|
+
'yarn npm publish --tag patch'
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe('with preid', () => {
|
|
72
|
+
const options = {
|
|
73
|
+
nextVersion: 'major',
|
|
74
|
+
preid: 'alpha',
|
|
75
|
+
execCommand: jest.fn()
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
it('publishes new version using yarn v2+ syntax', () => {
|
|
79
|
+
expect(() => publish(options)).not.toThrow();
|
|
80
|
+
expect(options.execCommand.mock.calls[0][0]).toBe(
|
|
81
|
+
'yarn npm publish --tag major'
|
|
82
|
+
);
|
|
83
|
+
});
|
|
16
84
|
});
|
|
17
85
|
});
|
|
18
86
|
|
|
19
|
-
describe('
|
|
87
|
+
describe('when yarn version detection fails', () => {
|
|
88
|
+
beforeEach(() => {
|
|
89
|
+
execSync.mockImplementation(() => {
|
|
90
|
+
throw new Error('Command failed');
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
20
94
|
const options = {
|
|
21
|
-
nextVersion: '
|
|
22
|
-
preid:
|
|
95
|
+
nextVersion: 'patch',
|
|
96
|
+
preid: undefined,
|
|
23
97
|
execCommand: jest.fn()
|
|
24
98
|
};
|
|
25
99
|
|
|
26
|
-
it('
|
|
100
|
+
it('defaults to yarn v1 syntax', () => {
|
|
27
101
|
expect(() => publish(options)).not.toThrow();
|
|
28
102
|
expect(options.execCommand.mock.calls[0][0]).toBe(
|
|
29
|
-
'yarn publish --new-version
|
|
103
|
+
'yarn publish --new-version patch'
|
|
30
104
|
);
|
|
31
105
|
});
|
|
32
106
|
});
|
|
@@ -25,10 +25,8 @@ const gitBranches = () => {
|
|
|
25
25
|
const prioritizeDefaultBranch = branches => {
|
|
26
26
|
const index = branches.indexOf(DEFAULT_BRANCH);
|
|
27
27
|
|
|
28
|
-
return index === -1
|
|
29
|
-
|
|
30
|
-
: branches.splice(index, 1).concat(branches);
|
|
31
|
-
}
|
|
28
|
+
return index === -1 ? branches : branches.splice(index, 1).concat(branches);
|
|
29
|
+
};
|
|
32
30
|
|
|
33
31
|
const question = () => ({
|
|
34
32
|
type: 'list',
|
|
@@ -49,7 +47,7 @@ async function releaseBranchStep() {
|
|
|
49
47
|
const releaseCommand =
|
|
50
48
|
releaseBranch === 'master'
|
|
51
49
|
? 'node-publisher release'
|
|
52
|
-
: `node-publisher release --
|
|
50
|
+
: `node-publisher release --branch=${releaseBranch}`;
|
|
53
51
|
|
|
54
52
|
addScript('release', releaseCommand);
|
|
55
53
|
}
|
package/src/utils/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
const path = require(
|
|
2
|
-
const fs = require(
|
|
3
|
-
const command = require(
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const command = require("./command");
|
|
4
4
|
const {
|
|
5
5
|
DEFAULT_CONFIG_PATH,
|
|
6
6
|
DEFAULT_BRANCH,
|
|
7
7
|
VALID_TEST_RUNNERS,
|
|
8
8
|
DEFAULT_TEST_RUNNER
|
|
9
|
-
} = require(
|
|
10
|
-
const { npmClient, publishClient } = require(
|
|
11
|
-
const { readReleaseConfig, buildReleaseConfig } = require(
|
|
12
|
-
const { packageJson } = require(
|
|
9
|
+
} = require("./constants");
|
|
10
|
+
const { npmClient, publishClient } = require("./client");
|
|
11
|
+
const { readReleaseConfig, buildReleaseConfig } = require("./config");
|
|
12
|
+
const { packageJson } = require("./package");
|
|
13
13
|
const {
|
|
14
14
|
validateNodeVersion,
|
|
15
15
|
validatePkgRoot,
|
|
16
16
|
validateTestRunner,
|
|
17
17
|
validateLerna,
|
|
18
18
|
hasBuildScript
|
|
19
|
-
} = require(
|
|
19
|
+
} = require("./validations");
|
|
20
20
|
|
|
21
21
|
const buildReleaseEnvironment = ({
|
|
22
22
|
branch = DEFAULT_BRANCH,
|
|
@@ -40,7 +40,7 @@ const buildReleaseEnvironment = ({
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
const client = publishClient();
|
|
43
|
-
if (client ===
|
|
43
|
+
if (client === "lerna") {
|
|
44
44
|
validateLerna();
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -60,7 +60,7 @@ const loadReleaseConfig = env => {
|
|
|
60
60
|
: path.resolve(process.env.PWD, env.configPath);
|
|
61
61
|
|
|
62
62
|
if (fs.existsSync(configPath)) {
|
|
63
|
-
return readReleaseConfig(fs.readFileSync(configPath,
|
|
63
|
+
return readReleaseConfig(fs.readFileSync(configPath, "utf8"));
|
|
64
64
|
} else if (env.configPath !== DEFAULT_CONFIG_PATH) {
|
|
65
65
|
throw new Error(
|
|
66
66
|
`The configuration file \`${env.configPath}\` does not exist.`
|
|
@@ -82,14 +82,14 @@ const execCommands = configCommands => {
|
|
|
82
82
|
|
|
83
83
|
const currentCommitId = () =>
|
|
84
84
|
command
|
|
85
|
-
.exec(
|
|
85
|
+
.exec("git rev-parse HEAD", {})
|
|
86
86
|
.toString()
|
|
87
87
|
.trim();
|
|
88
88
|
|
|
89
89
|
const rollbackCommit = commitId => command.exec(`git reset --hard ${commitId}`);
|
|
90
90
|
|
|
91
91
|
const versionTransformer = (version, _answers, flags) =>
|
|
92
|
-
flags.isFinal && version[0] !==
|
|
92
|
+
flags.isFinal && version[0] !== "v" ? `v${version}` : version;
|
|
93
93
|
|
|
94
94
|
module.exports = {
|
|
95
95
|
buildReleaseEnvironment,
|