Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 97a1616

Browse files
Splaktarandrewseguin
authored andcommitted
build(release): fix breaking changes from prompt-sync update (#11736)
1 parent 244619a commit 97a1616

File tree

1 file changed

+37
-41
lines changed

1 file changed

+37
-41
lines changed

release.js

Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
const strip = require('cli-color/strip');
77
const fs = require('fs');
88
const path = require('path');
9-
const prompt = require('prompt-sync');
9+
const prompt = require('prompt-sync')({sigint: true});
1010
const child_process = require('child_process');
1111
const pkg = require('./package.json');
1212
let oldVersion = pkg.version;
@@ -20,12 +20,10 @@
2020
let newVersion;
2121

2222
header();
23-
write(`Is this a dry-run? ${"[yes/no]".cyan} `);
24-
const dryRun = prompt() !== 'no';
23+
const dryRun = prompt(`Is this a dry-run? [${"yes".cyan}/no] `, 'yes') !== 'no';
2524

2625
if (dryRun) {
27-
write(`What would you like the old version to be? (default: ${oldVersion.cyan}) `);
28-
oldVersion = prompt() || oldVersion;
26+
oldVersion = prompt(`What would you like the old version to be? (default: ${oldVersion.cyan}) `, oldVersion);
2927
build();
3028
} else if (validate()) {
3129
build();
@@ -120,22 +118,20 @@
120118
log('What should the next version be?');
121119
for (key in options) { log((+key + 1) + ') ' + options[ key ].cyan); }
122120
log('');
123-
write('Please select a new version: ');
124-
const type = prompt();
121+
const type = prompt('Please select a new version: ');
125122

126123
if (options[ type - 1 ]) version = options[ type - 1 ];
127124
else if (type.match(/^\d+\.\d+\.\d+(-rc\.?\d+)?$/)) version = type;
128125
else throw new Error('Your entry was invalid.');
129126

130127
log('');
131128
log('The new version will be ' + version.cyan + '.');
132-
write(`Is this correct? ${"[yes/no]".cyan} `);
133-
return prompt() === 'yes' ? version : getNewVersion();
129+
return prompt(`Is this correct? [${"yes".cyan}/no] `, 'yes') === 'yes' ? version : getNewVersion();
134130

135131
function getVersionOptions (version) {
136132
return version.match(/-rc\.?\d+$/)
137-
? [increment(version, 'rc'), increment(version, 'minor')]
138-
: [increment(version, 'patch'), addRC(increment(version, 'minor'))];
133+
? [increment(version, 'rc'), increment(version, 'minor')]
134+
: [increment(version, 'patch'), addRC(increment(version, 'minor'))];
139135

140136
function increment (versionString, type) {
141137
const version = parseVersion(versionString);
@@ -181,9 +177,9 @@
181177
/** adds git tag for release and pushes to github */
182178
function tagRelease () {
183179
pushCmds.push(
184-
`git tag v${newVersion} -f`,
185-
`git push ${origin} HEAD`,
186-
`git push --tags ${origin}`
180+
`git tag v${newVersion} -f`,
181+
`git push ${origin} HEAD`,
182+
`git push --tags ${origin}`
187183
);
188184
}
189185

@@ -229,16 +225,16 @@
229225
'gulp build-all-modules --mode=default',
230226
'gulp build-all-modules --mode=closure',
231227
'rm -rf dist/demos'
232-
]);
228+
]);
233229
done();
234230
start('Copy files into bower repo...');
235231
// copy files over to bower repo
236232
exec([
237-
'cp -Rf ../dist/* ./',
238-
'git add -A',
239-
`git commit -m "release: version ${newVersion}"`,
240-
'rm -rf ../dist'
241-
], options);
233+
'cp -Rf ../dist/* ./',
234+
'git add -A',
235+
`git commit -m "release: version ${newVersion}"`,
236+
'rm -rf ../dist'
237+
], options);
242238
done();
243239
// add steps to push script
244240
pushCmds.push(
@@ -265,18 +261,18 @@
265261

266262
// build files for bower
267263
exec([
268-
'rm -rf dist',
269-
'gulp docs'
264+
'rm -rf dist',
265+
'gulp docs'
270266
]);
271267
replaceFilePaths();
272268

273269
// copy files over to site repo
274270
exec([
275-
`cp -Rf ../dist/docs ${newVersion}`,
276-
'rm -rf latest && cp -Rf ../dist/docs latest',
277-
'git add -A',
278-
`git commit -m "release: version ${newVersion}"`,
279-
'rm -rf ../dist'
271+
`cp -Rf ../dist/docs ${newVersion}`,
272+
'rm -rf latest && cp -Rf ../dist/docs latest',
273+
'git add -A',
274+
`git commit -m "release: version ${newVersion}"`,
275+
'rm -rf ../dist'
280276
], options);
281277
replaceBaseHref(newVersion);
282278
replaceBaseHref('latest');
@@ -288,11 +284,11 @@
288284

289285
// add steps to push script
290286
pushCmds.push(
291-
comment('push the site'),
292-
'cd ' + options.cwd,
293-
'git pull --rebase --strategy=ours',
294-
'git push',
295-
'cd ..'
287+
comment('push the site'),
288+
'cd ' + options.cwd,
289+
'git pull --rebase --strategy=ours',
290+
'git push',
291+
'cd ..'
296292
);
297293

298294
function updateFirebaseJson () {
@@ -353,15 +349,15 @@
353349
/** copies the changelog back over to master branch */
354350
function updateMaster () {
355351
pushCmds.push(
356-
comment('update package.json in master'),
357-
'git checkout master',
358-
`git pull --rebase ${origin} master --strategy=theirs`,
359-
`git checkout release/${newVersion} -- CHANGELOG.md`,
360-
`node -e "const newVersion = '${newVersion}'; ${stringifyFunction(buildCommand)}"`,
361-
'git add CHANGELOG.md',
362-
'git add package.json',
363-
`git commit -m "update version number in package.json to ${newVersion}"`,
364-
`git push ${origin} master`
352+
comment('update package.json in master'),
353+
'git checkout master',
354+
`git pull --rebase ${origin} master --strategy=theirs`,
355+
`git checkout release/${newVersion} -- CHANGELOG.md`,
356+
`node -e "const newVersion = '${newVersion}'; ${stringifyFunction(buildCommand)}"`,
357+
'git add CHANGELOG.md',
358+
'git add package.json',
359+
`git commit -m "update version number in package.json to ${newVersion}"`,
360+
`git push ${origin} master`
365361
);
366362

367363
function buildCommand () {

0 commit comments

Comments
 (0)