node-publisher 3.1.0 → 3.2.1
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 +40 -15
- package/package.json +9 -9
- package/src/client/yarn.js +24 -1
- package/src/client/yarn.spec.js +88 -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,8 +1,33 @@
|
|
|
1
|
+
### v3.2.0 (2025-07-10)
|
|
2
|
+
|
|
3
|
+
#### Pull requests
|
|
4
|
+
|
|
5
|
+
- [#61](https://github.com/zendesk/node-publisher/pull/61) Update node version ([Daria Radu](mailto:daria.radu@zendesk.com), [Sune Simonsen](mailto:sune@we-knowhow.dk))
|
|
6
|
+
- [#60](https://github.com/zendesk/node-publisher/pull/60) Run different publish command based on yarn version ([Daria Radu](mailto:daria.radu@zendesk.com))
|
|
7
|
+
- [#59](https://github.com/zendesk/node-publisher/pull/59) Fix custom release branch setup to the correct parameter ([Daria Radu](mailto:daria.radu@zendesk.com))
|
|
8
|
+
|
|
9
|
+
#### Commits to master
|
|
10
|
+
|
|
11
|
+
- [v3.2.0](https://github.com/zendesk/node-publisher/commit/989ecec13e467b13217ff482f422bafe61e61dbf) ([Sune Simonsen](mailto:sune@we-knowhow.dk))
|
|
12
|
+
- [Update changelog](https://github.com/zendesk/node-publisher/commit/e19ff455cae89cbd2796c00699ca4debaded6fac) ([Sune Simonsen](mailto:sune@we-knowhow.dk))
|
|
13
|
+
|
|
14
|
+
### v3.1.0 (2024-01-24)
|
|
15
|
+
|
|
16
|
+
#### Pull requests
|
|
17
|
+
|
|
18
|
+
- [#55](https://github.com/zendesk/node-publisher/pull/55) Upgrade offline-github-changelog to fix duplicate authors ([Sune Simonsen](mailto:sune@we-knowhow.dk))
|
|
19
|
+
- [#54](https://github.com/zendesk/node-publisher/pull/54) Make local installs work with yarn v4 ([Sune Simonsen](mailto:sune@we-knowhow.dk))
|
|
20
|
+
|
|
21
|
+
#### Commits to master
|
|
22
|
+
|
|
23
|
+
- [v3.1.0](https://github.com/zendesk/node-publisher/commit/5a1605e05a331211d8533533aba481aa724263ab) ([Sune Simonsen](mailto:sune@we-knowhow.dk))
|
|
24
|
+
- [Update changelog](https://github.com/zendesk/node-publisher/commit/f06d6612e0a3fc350ba06b9925c42852e92c32c8) ([Sune Simonsen](mailto:sune@we-knowhow.dk))
|
|
25
|
+
|
|
1
26
|
### v3.0.0 (2022-12-06)
|
|
2
27
|
|
|
3
28
|
#### Pull requests
|
|
4
29
|
|
|
5
|
-
- [#47](https://github.com/zendesk/node-publisher/pull/47) Upgrade offline-github-changelog \(Major\) ([Sune Simonsen](mailto:sune@we-knowhow.dk)
|
|
30
|
+
- [#47](https://github.com/zendesk/node-publisher/pull/47) Upgrade offline-github-changelog \(Major\) ([Sune Simonsen](mailto:sune@we-knowhow.dk))
|
|
6
31
|
- [#46](https://github.com/zendesk/node-publisher/pull/46) Upgrade offline-github-changelog ([Sune Simonsen](mailto:sune@we-knowhow.dk))
|
|
7
32
|
|
|
8
33
|
#### Commits to master
|
|
@@ -33,7 +58,7 @@
|
|
|
33
58
|
|
|
34
59
|
#### Pull requests
|
|
35
60
|
|
|
36
|
-
- [#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)
|
|
61
|
+
- [#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))
|
|
37
62
|
|
|
38
63
|
#### Commits to master
|
|
39
64
|
|
|
@@ -45,7 +70,7 @@
|
|
|
45
70
|
#### Pull requests
|
|
46
71
|
|
|
47
72
|
- [#44](https://github.com/zendesk/node-publisher/pull/44) Upgrade offline-github-changelog to the latest version ([Sune Simonsen](mailto:sune@we-knowhow.dk))
|
|
48
|
-
- [#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), [
|
|
73
|
+
- [#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))
|
|
49
74
|
- [#43](https://github.com/zendesk/node-publisher/pull/43) Use node version from .nvmrc in GHA workflow ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
50
75
|
|
|
51
76
|
#### Commits to master
|
|
@@ -58,7 +83,7 @@
|
|
|
58
83
|
#### Pull requests
|
|
59
84
|
|
|
60
85
|
- [#41](https://github.com/zendesk/node-publisher/pull/41) Fix reading the contents of .nvmrc ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
61
|
-
- [#40](https://github.com/zendesk/node-publisher/pull/40) Remove dependency on NVM ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
86
|
+
- [#40](https://github.com/zendesk/node-publisher/pull/40) Remove dependency on NVM ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
62
87
|
|
|
63
88
|
#### Commits to master
|
|
64
89
|
|
|
@@ -71,11 +96,11 @@
|
|
|
71
96
|
|
|
72
97
|
- [#37](https://github.com/zendesk/node-publisher/pull/37) Update jest ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
73
98
|
- [#36](https://github.com/zendesk/node-publisher/pull/36) Update lint-staged ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
74
|
-
- [#33](https://github.com/zendesk/node-publisher/pull/33) Update dependencies ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
99
|
+
- [#33](https://github.com/zendesk/node-publisher/pull/33) Update dependencies ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
75
100
|
- [#35](https://github.com/zendesk/node-publisher/pull/35) Fix the generated config for custom release branches ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
76
101
|
- [#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))
|
|
77
|
-
- [#32](https://github.com/zendesk/node-publisher/pull/32) Implement a setup script, take 2 ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
78
|
-
- [#31](https://github.com/zendesk/node-publisher/pull/31) Address security alerts ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
102
|
+
- [#32](https://github.com/zendesk/node-publisher/pull/32) Implement a setup script, take 2 ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
103
|
+
- [#31](https://github.com/zendesk/node-publisher/pull/31) Address security alerts ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
79
104
|
|
|
80
105
|
#### Commits to master
|
|
81
106
|
|
|
@@ -87,7 +112,7 @@
|
|
|
87
112
|
#### Pull requests
|
|
88
113
|
|
|
89
114
|
- [#30](https://github.com/zendesk/node-publisher/pull/30) Fix the build step not committing the changes ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
90
|
-
- [#28](https://github.com/zendesk/node-publisher/pull/28) Add --branch release param ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
115
|
+
- [#28](https://github.com/zendesk/node-publisher/pull/28) Add --branch release param ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
91
116
|
|
|
92
117
|
#### Commits to master
|
|
93
118
|
|
|
@@ -98,7 +123,7 @@
|
|
|
98
123
|
|
|
99
124
|
#### Pull requests
|
|
100
125
|
|
|
101
|
-
- [#26](https://github.com/zendesk/node-publisher/pull/26) Support multiple release configurations ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
126
|
+
- [#26](https://github.com/zendesk/node-publisher/pull/26) Support multiple release configurations ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
102
127
|
|
|
103
128
|
#### Commits to master
|
|
104
129
|
|
|
@@ -109,7 +134,7 @@
|
|
|
109
134
|
|
|
110
135
|
#### Pull requests
|
|
111
136
|
|
|
112
|
-
- [#27](https://github.com/zendesk/node-publisher/pull/27) Remove version constraints and add prerelease option ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
137
|
+
- [#27](https://github.com/zendesk/node-publisher/pull/27) Remove version constraints and add prerelease option ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
113
138
|
|
|
114
139
|
#### Commits to master
|
|
115
140
|
|
|
@@ -120,7 +145,7 @@
|
|
|
120
145
|
|
|
121
146
|
#### Pull requests
|
|
122
147
|
|
|
123
|
-
- [#24](https://github.com/zendesk/node-publisher/pull/24) Add details to package.json + minor adjustments ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
148
|
+
- [#24](https://github.com/zendesk/node-publisher/pull/24) Add details to package.json + minor adjustments ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
124
149
|
- [#23](https://github.com/zendesk/node-publisher/pull/23) Fix small typo in readme ([Marc Høegh](mailto:Anifacted@users.noreply.github.com))
|
|
125
150
|
|
|
126
151
|
#### Commits to master
|
|
@@ -134,8 +159,8 @@
|
|
|
134
159
|
|
|
135
160
|
- [#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))
|
|
136
161
|
- [#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))
|
|
137
|
-
- [#20](https://github.com/zendesk/node-publisher/pull/20) Remove private repo configuration ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
138
|
-
- [#18](https://github.com/zendesk/node-publisher/pull/18) Update README ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
162
|
+
- [#20](https://github.com/zendesk/node-publisher/pull/20) Remove private repo configuration ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
163
|
+
- [#18](https://github.com/zendesk/node-publisher/pull/18) Update README ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
139
164
|
|
|
140
165
|
#### Commits to master
|
|
141
166
|
|
|
@@ -180,7 +205,7 @@
|
|
|
180
205
|
|
|
181
206
|
#### Pull requests
|
|
182
207
|
|
|
183
|
-
- [#14](https://github.com/zendesk/node-publisher/pull/14) Add test runner whitelist ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
208
|
+
- [#14](https://github.com/zendesk/node-publisher/pull/14) Add test runner whitelist ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
184
209
|
|
|
185
210
|
#### Commits to master
|
|
186
211
|
|
|
@@ -273,7 +298,7 @@
|
|
|
273
298
|
|
|
274
299
|
#### Pull requests
|
|
275
300
|
|
|
276
|
-
- [#2](https://github.com/zendesk/node-publisher/pull/2) Fix rollback and own release ([Attila Večerek](mailto:avecerek@zendesk.com)
|
|
301
|
+
- [#2](https://github.com/zendesk/node-publisher/pull/2) Fix rollback and own release ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
277
302
|
- [#1](https://github.com/zendesk/node-publisher/pull/1) Initial PR ([Attila Večerek](mailto:avecerek@zendesk.com))
|
|
278
303
|
|
|
279
304
|
#### Commits to master
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-publisher",
|
|
3
|
+
"version": "3.2.1",
|
|
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,12 +11,11 @@
|
|
|
10
11
|
"bugs": {
|
|
11
12
|
"url": "https://github.com/zendesk/node-publisher/issues"
|
|
12
13
|
},
|
|
13
|
-
"version": "3.1.0",
|
|
14
14
|
"main": "src/index.js",
|
|
15
15
|
"bin": "./bin/node-publisher",
|
|
16
16
|
"scripts": {
|
|
17
17
|
"coverage": "jest --coverage",
|
|
18
|
-
"lint": "eslint
|
|
18
|
+
"lint": "eslint src/**/*.js bin/**",
|
|
19
19
|
"lint-staged": "lint-staged",
|
|
20
20
|
"release": "./bin/node-publisher release",
|
|
21
21
|
"test": "jest",
|
|
@@ -26,24 +26,24 @@
|
|
|
26
26
|
"commander": "2.15.1",
|
|
27
27
|
"inquirer": "6.5.0",
|
|
28
28
|
"js-yaml": "3.13.1",
|
|
29
|
-
"offline-github-changelog": "3.0
|
|
30
|
-
"semver": "
|
|
29
|
+
"offline-github-changelog": "3.1.0",
|
|
30
|
+
"semver": "7.7.2"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"babel-eslint": "10.0
|
|
33
|
+
"babel-eslint": "10.1.0",
|
|
34
34
|
"eslint": "^6.0.0",
|
|
35
35
|
"eslint-config-prettier": "^6.0.0",
|
|
36
36
|
"eslint-config-standard": "^14.0.0",
|
|
37
37
|
"eslint-plugin-import": "^2.18.0",
|
|
38
|
-
"eslint-plugin-jest": "^
|
|
38
|
+
"eslint-plugin-jest": "^23.20.0",
|
|
39
39
|
"eslint-plugin-node": "^9.1.0",
|
|
40
40
|
"eslint-plugin-promise": "^4.2.0",
|
|
41
41
|
"eslint-plugin-standard": "^4.0.0",
|
|
42
|
-
"jest": "
|
|
42
|
+
"jest": "^27.0.0",
|
|
43
43
|
"lint-staged": "^9.0.0",
|
|
44
44
|
"pre-commit": "1.2.2",
|
|
45
45
|
"prettier": "1.18.2",
|
|
46
|
-
"prettier-package-json": "2.0
|
|
46
|
+
"prettier-package-json": "2.8.0"
|
|
47
47
|
},
|
|
48
48
|
"keywords": [
|
|
49
49
|
"lerna",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"yarn"
|
|
53
53
|
],
|
|
54
54
|
"engines": {
|
|
55
|
-
"node": ">=
|
|
55
|
+
"node": ">=20"
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public",
|
package/src/client/yarn.js
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
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 version ${nextVersion}`);
|
|
22
|
+
execCommand(`yarn npm publish`);
|
|
23
|
+
} else {
|
|
24
|
+
execCommand(`yarn publish --new-version ${nextVersion}`);
|
|
25
|
+
}
|
|
3
26
|
};
|
|
4
27
|
|
|
5
28
|
module.exports = {
|
package/src/client/yarn.spec.js
CHANGED
|
@@ -1,32 +1,104 @@
|
|
|
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('yarn version patch');
|
|
66
|
+
expect(options.execCommand.mock.calls[1][0]).toBe('yarn npm publish');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe('with preid', () => {
|
|
71
|
+
const options = {
|
|
72
|
+
nextVersion: 'major',
|
|
73
|
+
preid: 'alpha',
|
|
74
|
+
execCommand: jest.fn()
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
it('publishes new version using yarn v2+ syntax', () => {
|
|
78
|
+
expect(() => publish(options)).not.toThrow();
|
|
79
|
+
expect(options.execCommand.mock.calls[0][0]).toBe('yarn version major');
|
|
80
|
+
expect(options.execCommand.mock.calls[1][0]).toBe('yarn npm publish');
|
|
81
|
+
});
|
|
16
82
|
});
|
|
17
83
|
});
|
|
18
84
|
|
|
19
|
-
describe('
|
|
85
|
+
describe('when yarn version detection fails', () => {
|
|
86
|
+
beforeEach(() => {
|
|
87
|
+
execSync.mockImplementation(() => {
|
|
88
|
+
throw new Error('Command failed');
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
20
92
|
const options = {
|
|
21
|
-
nextVersion: '
|
|
22
|
-
preid:
|
|
93
|
+
nextVersion: 'patch',
|
|
94
|
+
preid: undefined,
|
|
23
95
|
execCommand: jest.fn()
|
|
24
96
|
};
|
|
25
97
|
|
|
26
|
-
it('
|
|
98
|
+
it('defaults to yarn v1 syntax', () => {
|
|
27
99
|
expect(() => publish(options)).not.toThrow();
|
|
28
100
|
expect(options.execCommand.mock.calls[0][0]).toBe(
|
|
29
|
-
'yarn publish --new-version
|
|
101
|
+
'yarn publish --new-version patch'
|
|
30
102
|
);
|
|
31
103
|
});
|
|
32
104
|
});
|
|
@@ -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,
|