|
19 | 19 | var dryRun;
|
20 | 20 |
|
21 | 21 | header();
|
22 |
| - write('Is this a dry-run? {{"[yes/no]".cyan}} '); |
| 22 | + write(`Is this a dry-run? ${"[yes/no]".cyan} `); |
23 | 23 | dryRun = prompt() !== 'no';
|
24 | 24 |
|
25 | 25 | if (dryRun) {
|
26 |
| - write('What would you like the old version to be? (default: {{oldVersion.cyan}}) '); |
| 26 | + write(`What would you like the old version to be? (default: ${oldVersion.cyan}) `); |
27 | 27 | oldVersion = prompt() || oldVersion;
|
28 | 28 | build();
|
29 | 29 | } else if (validate()) {
|
|
50 | 50 |
|
51 | 51 | line();
|
52 | 52 | log('Your repo is ready to be pushed.');
|
53 |
| - log('Please look over {{"CHANGELOG.md".cyan}} and make any changes.'); |
54 |
| - log('When you are ready, please run "{{"./push".cyan}}" to finish the process.'); |
| 53 | + log(`Please look over ${"CHANGELOG.md".cyan} and make any changes.`); |
| 54 | + log(`When you are ready, please run "${"./push".cyan}" to finish the process.`); |
55 | 55 | log('If you would like to cancel this release, please run "./abort"');
|
56 | 56 | }
|
57 | 57 |
|
|
74 | 74 |
|
75 | 75 | /** creates the version branch and adds abort steps */
|
76 | 76 | function checkoutVersionBranch () {
|
77 |
| - exec('git checkout -q -b release/{{newVersion}}'); |
78 |
| - abortCmds.push('git branch -D release/{{newVersion}}'); |
| 77 | + exec(`git branch -q -D release/${newVersion}`); |
| 78 | + exec(`git checkout -q -b release/${newVersion}`); |
| 79 | + abortCmds.push(`git branch -D release/${newVersion}`); |
79 | 80 | }
|
80 | 81 |
|
81 | 82 | /** writes the new version to package.json */
|
82 | 83 | function updateVersion () {
|
83 |
| - start('Updating {{"package.json".cyan}} version from {{oldVersion.cyan}} to {{newVersion.cyan}}...'); |
| 84 | + start(`Updating ${"package.json".cyan} version from ${oldVersion.cyan} to ${newVersion.cyan}...`); |
84 | 85 | pkg.version = newVersion;
|
85 | 86 | fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2));
|
86 | 87 | done();
|
|
90 | 91 |
|
91 | 92 | /** generates the changelog from the commits since the last release */
|
92 | 93 | function createChangelog () {
|
93 |
| - start('Generating changelog from {{oldVersion.cyan}} to {{newVersion.cyan}}...'); |
94 |
| - exec([ |
95 |
| - 'git fetch --tags', |
96 |
| - 'git checkout v{{lastMajorVer}} -- CHANGELOG.md', |
97 |
| - 'gulp changelog --sha=$(git merge-base v{{lastMajorVer}} HEAD)' |
98 |
| - ]); |
| 94 | + start(`Generating changelog from ${oldVersion.cyan} to ${newVersion.cyan}...`); |
| 95 | + |
| 96 | + exec('git fetch --tags'); |
| 97 | + exec(`git checkout v${lastMajorVer} -- CHANGELOG.md`); |
| 98 | + exec(`gulp changelog --sha=$(git merge-base v${lastMajorVer} HEAD)`); |
| 99 | + |
99 | 100 | done();
|
| 101 | + |
100 | 102 | abortCmds.push('git checkout CHANGELOG.md');
|
101 | 103 | pushCmds.push('git add CHANGELOG.md');
|
102 | 104 | }
|
|
110 | 112 | function getNewVersion () {
|
111 | 113 | header();
|
112 | 114 | var options = getVersionOptions(oldVersion), key, type, version;
|
113 |
| - log('The current version is {{oldVersion.cyan}}.'); |
| 115 | + log(`The current version is ${oldVersion.cyan}.`); |
114 | 116 | log('');
|
115 | 117 | log('What should the next version be?');
|
116 | 118 | for (key in options) { log((+key + 1) + ') ' + options[ key ].cyan); }
|
|
124 | 126 |
|
125 | 127 | log('');
|
126 | 128 | log('The new version will be ' + version.cyan + '.');
|
127 |
| - write('Is this correct? {{"[yes/no]".cyan}} '); |
| 129 | + write(`Is this correct? ${"[yes/no]".cyan} `); |
128 | 130 | return prompt() === 'yes' ? version : getNewVersion();
|
129 | 131 |
|
130 | 132 | function getVersionOptions (version) {
|
|
136 | 138 | var version = parseVersion(versionString);
|
137 | 139 | if (version.rc) {
|
138 | 140 | switch (type) {
|
139 |
| - case 'minor': |
140 |
| - version.rc = 0; |
141 |
| - break; |
142 |
| - case 'rc': |
143 |
| - version.rc++; |
144 |
| - break; |
| 141 | + case 'minor': version.rc = 0; break; |
| 142 | + case 'rc': version.rc++; break; |
145 | 143 | }
|
146 | 144 | } else {
|
147 | 145 | version[ type ]++;
|
148 | 146 | //-- reset any version numbers lower than the one changed
|
149 | 147 | switch (type) {
|
150 |
| - case 'minor': |
151 |
| - version.patch = 0; |
152 |
| - case 'patch': |
153 |
| - version.rc = 0; |
| 148 | + case 'minor': version.patch = 0; |
| 149 | + case 'patch': version.rc = 0; |
154 | 150 | }
|
155 | 151 | }
|
156 | 152 | return getVersionString(version);
|
|
182 | 178 | /** adds git tag for release and pushes to github */
|
183 | 179 | function tagRelease () {
|
184 | 180 | pushCmds.push(
|
185 |
| - 'git tag v{{newVersion}}', |
186 |
| - 'git push {{origin}} HEAD', |
| 181 | + `git tag v${newVersion} -f`, |
| 182 | + `git push ${origin} HEAD`, |
187 | 183 | 'git push --tags'
|
188 | 184 | );
|
189 | 185 | }
|
190 | 186 |
|
191 | 187 | /** amends the commit to include local changes (ie. changelog) */
|
192 | 188 | function commitChanges () {
|
193 | 189 | start('Committing changes...');
|
194 |
| - exec('git commit -am "release: version {{newVersion}}"'); |
| 190 | + exec(`git commit -am "release: version ${newVersion}"`); |
195 | 191 | done();
|
196 | 192 | pushCmds.push('git commit --amend --no-edit');
|
197 | 193 | }
|
198 | 194 |
|
199 | 195 | /** utility method for cloning github repos */
|
200 | 196 | function cloneRepo (repo) {
|
201 |
| - start('Cloning ' + repo.cyan + ' from Github...'); |
202 |
| - exec('rm -rf ' + repo); |
203 |
| - exec('git clone https://github.com/angular/' + repo + '.git --depth=1'); |
| 197 | + start(`Cloning ${repo.cyan} from Github...`); |
| 198 | + exec(`rm -rf ${repo}`); |
| 199 | + exec(`git clone https://github.com/angular/${repo}.git --depth=1`); |
204 | 200 | done();
|
205 |
| - cleanupCmds.push('rm -rf ' + repo); |
206 |
| - } |
207 |
| - |
208 |
| - // TODO: Remove this method and use template strings instead |
209 |
| - /** utility method for inserting variables into a string */ |
210 |
| - function fill (str) { |
211 |
| - return str.replace(/\{\{[^\}]+\}\}/g, function (match) { |
212 |
| - return eval(match.substr(2, match.length - 4)); |
213 |
| - }); |
| 201 | + cleanupCmds.push(`rm -rf ${repo}`); |
214 | 202 | }
|
215 | 203 |
|
216 | 204 | /** writes an array of commands to a bash script */
|
217 | 205 | function writeScript (name, cmds) {
|
218 |
| - fs.writeFileSync(name, '#!/usr/bin/env bash\n\n' + fill(cmds.join('\n'))); |
| 206 | + fs.writeFileSync(name, '#!/usr/bin/env bash\n\n' + cmds.join('\n')); |
219 | 207 | exec('chmod +x ' + name);
|
220 | 208 | }
|
221 | 209 |
|
|
233 | 221 | start('Building bower files...');
|
234 | 222 | //-- build files for bower
|
235 | 223 | exec([
|
236 |
| - 'rm -rf dist', |
237 |
| - 'gulp build', |
238 |
| - 'gulp build-all-modules --mode=default', |
239 |
| - 'gulp build-all-modules --mode=closure', |
240 |
| - 'rm -rf dist/demos', |
241 |
| - ]); |
| 224 | + 'rm -rf dist', |
| 225 | + 'gulp build', |
| 226 | + 'gulp build-all-modules --mode=default', |
| 227 | + 'gulp build-all-modules --mode=closure', |
| 228 | + 'rm -rf dist/demos', |
| 229 | + ]); |
242 | 230 | done();
|
243 | 231 | start('Copy files into bower repo...');
|
244 | 232 | //-- copy files over to bower repo
|
245 | 233 | exec([
|
246 | 234 | 'cp -Rf ../dist/* ./',
|
247 | 235 | 'git add -A',
|
248 |
| - 'git commit -m "release: version {{newVersion}}"', |
| 236 | + `git commit -m "release: version ${newVersion}"`, |
249 | 237 | 'rm -rf ../dist'
|
250 | 238 | ], options);
|
251 | 239 | done();
|
252 | 240 | //-- add steps to push script
|
253 | 241 | pushCmds.push(
|
254 |
| - comment('push to bower (master and tag) and publish to npm'), |
255 |
| - 'cd ' + options.cwd, |
256 |
| - 'cp ../CHANGELOG.md .', |
257 |
| - 'git add CHANGELOG.md', |
258 |
| - 'git commit --amend --no-edit', |
259 |
| - 'git tag -f v{{newVersion}}', |
260 |
| - 'git pull --rebase', |
261 |
| - 'git push', |
262 |
| - 'git push --tags', |
263 |
| - ( newVersion.indexOf('rc') < 0 ? 'npm publish' : '# skipped npm publish due to RC version' ), |
264 |
| - 'cd ..' |
| 242 | + comment('push to bower (master and tag) and publish to npm'), |
| 243 | + 'cd ' + options.cwd, |
| 244 | + 'cp ../CHANGELOG.md .', |
| 245 | + 'git add CHANGELOG.md', |
| 246 | + 'git commit --amend --no-edit', |
| 247 | + `git tag -f v${newVersion}`, |
| 248 | + 'git pull --rebase --strategy=ours', |
| 249 | + 'git push', |
| 250 | + 'git push --tags', |
| 251 | + ( newVersion.indexOf('rc') < 0 ? 'npm publish' : '# skipped npm publish due to RC version' ), |
| 252 | + 'cd ..' |
265 | 253 | );
|
266 | 254 | }
|
267 | 255 |
|
|
281 | 269 | //-- copy files over to site repo
|
282 | 270 | exec([
|
283 | 271 | 'rm -rf ./*-rc*',
|
284 |
| - 'cp -Rf ../dist/docs {{newVersion}}', |
| 272 | + `cp -Rf ../dist/docs ${newVersion}`, |
285 | 273 | 'rm -rf latest && cp -Rf ../dist/docs latest',
|
286 | 274 | 'git add -A',
|
287 |
| - 'git commit -m "release: version {{newVersion}}"', |
| 275 | + `git commit -m "release: version ${newVersion}"`, |
288 | 276 | 'rm -rf ../dist'
|
289 | 277 | ], options);
|
290 | 278 | replaceBaseHref(newVersion);
|
|
365 | 353 | function updateMaster () {
|
366 | 354 | pushCmds.push(
|
367 | 355 | comment('update package.json in master'),
|
368 |
| - 'git co master', |
369 |
| - 'git pull --rebase {{origin}} master', |
370 |
| - 'git checkout release/{{newVersion}} -- CHANGELOG.md', |
371 |
| - 'node -e "' + stringifyFunction(buildCommand) + '"', |
| 356 | + 'git checkout master', |
| 357 | + `git pull --rebase ${origin} master --strategy=theirs`, |
| 358 | + `git checkout release/${newVersion} -- CHANGELOG.md`, |
| 359 | + `node -e "${stringifyFunction(buildCommand)}"`, |
372 | 360 | 'git add CHANGELOG.md',
|
373 | 361 | 'git add package.json',
|
374 |
| - 'git commit -m "update version number in package.json to {{newVersion}}"', |
| 362 | + `git commit -m "update version number in package.json to ${newVersion}"`, |
375 | 363 | 'git push'
|
376 | 364 | );
|
| 365 | + |
377 | 366 | function buildCommand () {
|
378 | 367 | require('fs').writeFileSync('package.json', JSON.stringify(getUpdatedJson(), null, 2));
|
379 | 368 | function getUpdatedJson () {
|
380 |
| - var json = require('./package.json'); |
381 |
| - json.version = '{{newVersion}}'; |
| 369 | + var json = require('./package.json'); |
| 370 | + json.version = newVersion; |
382 | 371 | return json;
|
383 | 372 | }
|
384 | 373 | }
|
|
423 | 412 | try {
|
424 | 413 | var options = Object.create(defaultOptions);
|
425 | 414 | for (var key in userOptions) options[ key ] = userOptions[ key ];
|
426 |
| - return child_process.execSync(fill(cmd) + ' 2> /dev/null', options).toString().trim(); |
| 415 | + return child_process.execSync(cmd + ' 2> /dev/null', options).toString().trim(); |
427 | 416 | } catch (err) {
|
428 | 417 | return err;
|
429 | 418 | }
|
|
436 | 425 |
|
437 | 426 | /** prints the left side of a task while it is being performed */
|
438 | 427 | function start (msg) {
|
439 |
| - var parsedMsg = fill(msg), |
440 |
| - msgLength = strip(parsedMsg).length, |
| 428 | + var msgLength = strip(msg).length, |
441 | 429 | diff = lineWidth - 4 - msgLength;
|
442 |
| - write(parsedMsg + Array(diff + 1).join(' ')); |
| 430 | + write(msg + Array(diff + 1).join(' ')); |
443 | 431 | }
|
444 | 432 |
|
445 | 433 | /** outputs to the terminal with string variable replacement */
|
446 | 434 | function log (msg) {
|
447 | 435 | msg = msg || '';
|
448 |
| - console.log(fill(msg)); |
| 436 | + console.log(msg); |
449 | 437 | }
|
450 | 438 |
|
451 | 439 | /** writes a message without a newline */
|
452 | 440 | function write (msg) {
|
453 |
| - process.stdout.write(fill(msg)); |
| 441 | + process.stdout.write(msg); |
454 | 442 | }
|
455 | 443 |
|
456 | 444 | /** prints a horizontal line to the terminal */
|
|
0 commit comments