@bigcommerce/stencil-cli 7.1.2 → 7.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/bin/stencil-release.js +11 -2
- package/lib/release/release.js +15 -9
- package/package.json +1 -1
package/bin/stencil-release.js
CHANGED
|
@@ -7,7 +7,16 @@ const program = require('../lib/commander');
|
|
|
7
7
|
const { checkNodeVersion } = require('../lib/cliCommon');
|
|
8
8
|
const { printCliResultErrorAndExit } = require('../lib/cliCommon');
|
|
9
9
|
|
|
10
|
-
program
|
|
10
|
+
program
|
|
11
|
+
.version(PACKAGE_INFO.version)
|
|
12
|
+
.option('-b, --branch [name]', 'specify the main branch name')
|
|
13
|
+
.parse(process.argv);
|
|
11
14
|
|
|
12
15
|
checkNodeVersion();
|
|
13
|
-
|
|
16
|
+
|
|
17
|
+
const cliOptions = program.opts();
|
|
18
|
+
const options = {
|
|
19
|
+
branch: cliOptions.branch || 'master',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
new StencilRelease().run(options).catch(printCliResultErrorAndExit);
|
package/lib/release/release.js
CHANGED
|
@@ -31,9 +31,9 @@ class StencilRelease {
|
|
|
31
31
|
this._octokit = octokit;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
async run() {
|
|
34
|
+
async run(cliOptions) {
|
|
35
35
|
const gitData = await this.getGitData();
|
|
36
|
-
this.checkGitData(gitData);
|
|
36
|
+
this.checkGitData(gitData, cliOptions);
|
|
37
37
|
|
|
38
38
|
const version = await this._themeConfigManager.getVersion();
|
|
39
39
|
this.checkCurrentVersion(version);
|
|
@@ -42,7 +42,11 @@ class StencilRelease {
|
|
|
42
42
|
|
|
43
43
|
await this.saveGithubToken(answers.githubToken);
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
const options = {
|
|
46
|
+
...answers,
|
|
47
|
+
...cliOptions,
|
|
48
|
+
};
|
|
49
|
+
await this.doRelease(options);
|
|
46
50
|
|
|
47
51
|
this._logger.log('done'.green);
|
|
48
52
|
|
|
@@ -86,13 +90,15 @@ class StencilRelease {
|
|
|
86
90
|
* @param gitData.ahead
|
|
87
91
|
* @returns {boolean}
|
|
88
92
|
*/
|
|
89
|
-
checkGitData(gitData) {
|
|
93
|
+
checkGitData(gitData, options) {
|
|
90
94
|
if (gitData.remotes.length === 0) {
|
|
91
95
|
throw new Error('No git remote repository found');
|
|
92
96
|
}
|
|
93
97
|
|
|
94
|
-
if (gitData.current !==
|
|
95
|
-
throw new Error(
|
|
98
|
+
if (gitData.current !== options.branch) {
|
|
99
|
+
throw new Error(
|
|
100
|
+
`Not on ${options.branch} branch, please checkout ${options.branch} branch to proceed`,
|
|
101
|
+
);
|
|
96
102
|
}
|
|
97
103
|
|
|
98
104
|
if (gitData.dirty) {
|
|
@@ -143,7 +149,7 @@ class StencilRelease {
|
|
|
143
149
|
const bundlePath = await this.bundleTheme();
|
|
144
150
|
|
|
145
151
|
try {
|
|
146
|
-
await this.commitAndPush(options.version, options.remote);
|
|
152
|
+
await this.commitAndPush(options.version, options.remote, options.branch);
|
|
147
153
|
|
|
148
154
|
if (options.createGithubRelease) {
|
|
149
155
|
await this.createGithubRelease(
|
|
@@ -207,13 +213,13 @@ class StencilRelease {
|
|
|
207
213
|
return bundle.initBundle();
|
|
208
214
|
}
|
|
209
215
|
|
|
210
|
-
async commitAndPush(version, remote) {
|
|
216
|
+
async commitAndPush(version, remote, branch) {
|
|
211
217
|
await this._git.add(['config.json', 'package.json', 'package-lock.json', 'CHANGELOG.md']);
|
|
212
218
|
const summary = await this._git.commit(`Releasing ${version}`);
|
|
213
219
|
|
|
214
220
|
this._logger.log(`Pushing Changes to ${remote.name}...`);
|
|
215
221
|
|
|
216
|
-
await this._git.push(remote.name,
|
|
222
|
+
await this._git.push(remote.name, branch);
|
|
217
223
|
|
|
218
224
|
return summary.commit;
|
|
219
225
|
}
|