mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
chore(release): add prompt for release to select release type (#10244)
* chore(release): add inquirer to prompt for release * chore(release): wip get release working again and test also adds nightly back in * chore(release): WIP remove commented code
This commit is contained in:
@ -93,6 +93,7 @@
|
|||||||
"gulp-util": "3.0.7",
|
"gulp-util": "3.0.7",
|
||||||
"gulp-watch": "4.3.9",
|
"gulp-watch": "4.3.9",
|
||||||
"html-entities": "1.2.0",
|
"html-entities": "1.2.0",
|
||||||
|
"inquirer": "3.0.1",
|
||||||
"ionic-cz-conventional-changelog": "1.0.0",
|
"ionic-cz-conventional-changelog": "1.0.0",
|
||||||
"ionic-native": "^2.2.6",
|
"ionic-native": "^2.2.6",
|
||||||
"jasmine-core": "2.5.2",
|
"jasmine-core": "2.5.2",
|
||||||
|
1
scripts/gulp/declarations.d.ts
vendored
1
scripts/gulp/declarations.d.ts
vendored
@ -14,6 +14,7 @@ declare module 'gulp-server-livereload';
|
|||||||
declare module 'gulp-tslint';
|
declare module 'gulp-tslint';
|
||||||
declare module 'gulp-typescript';
|
declare module 'gulp-typescript';
|
||||||
declare module 'html-entities';
|
declare module 'html-entities';
|
||||||
|
declare module 'inquirer';
|
||||||
declare module 'path';
|
declare module 'path';
|
||||||
declare module 'rollup';
|
declare module 'rollup';
|
||||||
declare module 'rollup-plugin-commonjs';
|
declare module 'rollup-plugin-commonjs';
|
||||||
|
@ -2,7 +2,8 @@ import { exec, spawnSync, spawn } from 'child_process';
|
|||||||
import { writeFileSync } from 'fs';
|
import { writeFileSync } from 'fs';
|
||||||
import * as changelog from 'conventional-changelog';
|
import * as changelog from 'conventional-changelog';
|
||||||
import * as GithubApi from 'github';
|
import * as GithubApi from 'github';
|
||||||
import { dest, src, task } from 'gulp';
|
import { dest, src, start, task } from 'gulp';
|
||||||
|
import { prompt } from 'inquirer';
|
||||||
import { rollup } from 'rollup';
|
import { rollup } from 'rollup';
|
||||||
import * as commonjs from 'rollup-plugin-commonjs';
|
import * as commonjs from 'rollup-plugin-commonjs';
|
||||||
import * as nodeResolve from 'rollup-plugin-node-resolve';
|
import * as nodeResolve from 'rollup-plugin-node-resolve';
|
||||||
@ -13,7 +14,9 @@ import { obj } from 'through2';
|
|||||||
import { DIST_BUILD_UMD_BUNDLE_ENTRYPOINT, DIST_BUILD_ROOT, DIST_BUNDLE_ROOT, PROJECT_ROOT, SCRIPTS_ROOT, SRC_ROOT } from '../constants';
|
import { DIST_BUILD_UMD_BUNDLE_ENTRYPOINT, DIST_BUILD_ROOT, DIST_BUNDLE_ROOT, PROJECT_ROOT, SCRIPTS_ROOT, SRC_ROOT } from '../constants';
|
||||||
import { compileSass, copyFonts, createTimestamp, setSassIonicVersion, writePolyfills } from '../util';
|
import { compileSass, copyFonts, createTimestamp, setSassIonicVersion, writePolyfills } from '../util';
|
||||||
|
|
||||||
|
var promptAnswers;
|
||||||
|
|
||||||
|
// Nightly: releases a nightly version
|
||||||
task('nightly', (done: (err: any) => void) => {
|
task('nightly', (done: (err: any) => void) => {
|
||||||
runSequence('release.pullLatest',
|
runSequence('release.pullLatest',
|
||||||
'validate',
|
'validate',
|
||||||
@ -22,27 +25,51 @@ task('nightly', (done: (err: any) => void) => {
|
|||||||
done);
|
done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Release: prompt, update, publish
|
||||||
task('release', (done: (err: any) => void) => {
|
task('release', (done: (err: any) => void) => {
|
||||||
runSequence('release.pullLatest',
|
runSequence('release.pullLatest',
|
||||||
'validate',
|
'validate',
|
||||||
'release.prepareReleasePackage',
|
'release.prepareReleasePackage',
|
||||||
'release.copyProdVersion',
|
'release.promptVersion',
|
||||||
'release.prepareChangelog',
|
'release.update',
|
||||||
'release.publishNpmRelease',
|
'release.publish',
|
||||||
'release.publishGithubRelease',
|
|
||||||
done);
|
done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Release.test: prompt and update
|
||||||
task('release.test', (done: (err: any) => void) => {
|
task('release.test', (done: (err: any) => void) => {
|
||||||
runSequence('validate',
|
runSequence('validate',
|
||||||
'release.prepareReleasePackage',
|
'release.prepareReleasePackage',
|
||||||
'release.copyProdVersion',
|
'release.promptVersion',
|
||||||
|
'release.update',
|
||||||
done);
|
done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Release.update: update package.json and changelog
|
||||||
|
task('release.update', (done: (err: any) => void) => {
|
||||||
|
if (promptAnswers.confirmRelease === 'yes') {
|
||||||
|
runSequence('release.copyProdVersion',
|
||||||
|
'release.prepareChangelog',
|
||||||
|
done);
|
||||||
|
} else {
|
||||||
|
console.log('Did not run release.update tasks, aborted release');
|
||||||
|
done(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Release.publish: publish to GitHub and npm
|
||||||
|
task('release.publish', (done: (err: any) => void) => {
|
||||||
|
if (promptAnswers.confirmRelease === 'yes') {
|
||||||
|
runSequence('release.publishNpmRelease',
|
||||||
|
'release.publishGithubRelease',
|
||||||
|
done);
|
||||||
|
} else {
|
||||||
|
console.log('Did not run release.publish tasks, aborted release');
|
||||||
|
done(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
task('release.publishGithubRelease', (done: Function) => {
|
task('release.publishGithubRelease', (done: Function) => {
|
||||||
|
|
||||||
const packageJSON = require('../../../package.json');
|
const packageJSON = require('../../../package.json');
|
||||||
|
|
||||||
const github = new GithubApi({
|
const github = new GithubApi({
|
||||||
@ -85,11 +112,73 @@ task('release.publishNpmRelease', (done: Function) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
task('release.promptVersion', (done: Function) => {
|
||||||
|
prompt([
|
||||||
|
{
|
||||||
|
type: 'list',
|
||||||
|
name: 'release',
|
||||||
|
message: 'What type of release is this?',
|
||||||
|
choices: [
|
||||||
|
{
|
||||||
|
name: 'Major: Incompatible API changes',
|
||||||
|
value: 'major'
|
||||||
|
}, {
|
||||||
|
name: 'Minor: Backwards-compatible functionality',
|
||||||
|
value: 'minor'
|
||||||
|
}, {
|
||||||
|
name: 'Patch: Backwards-compatible bug fixes',
|
||||||
|
value: 'patch'
|
||||||
|
}, {
|
||||||
|
name: 'Premajor',
|
||||||
|
value: 'premajor'
|
||||||
|
}, {
|
||||||
|
name: 'Preminor',
|
||||||
|
value: 'preminor'
|
||||||
|
}, {
|
||||||
|
name: 'Prepatch',
|
||||||
|
value: 'prepatch'
|
||||||
|
}, {
|
||||||
|
name: 'Prerelease',
|
||||||
|
value: 'prerelease'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}, {
|
||||||
|
type: 'list',
|
||||||
|
name: 'confirmRelease',
|
||||||
|
default: 'no',
|
||||||
|
choices: [
|
||||||
|
{
|
||||||
|
name: 'Yes',
|
||||||
|
value: 'yes'
|
||||||
|
}, {
|
||||||
|
name: 'Abort release',
|
||||||
|
value: 'no'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
message: function(answers) {
|
||||||
|
var SEP = '---------------------------------';
|
||||||
|
console.log('\n' + SEP + '\n' + getVersion(answers) + '\n' + SEP + '\n');
|
||||||
|
return 'Are you sure you want to proceed with the release version above?';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]).then(function (answers) {
|
||||||
|
// Continue with the release if version was confirmed
|
||||||
|
promptAnswers = answers;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function getVersion(answers) {
|
||||||
|
const sourcePackageJSON = require(`${PROJECT_ROOT}/package.json`);
|
||||||
|
|
||||||
|
return semver.inc(sourcePackageJSON.version, answers.release, true);
|
||||||
|
}
|
||||||
|
|
||||||
task('release.copyProdVersion', () => {
|
task('release.copyProdVersion', () => {
|
||||||
// Increment the version and update the source package file
|
// Increment the version and update the source package file
|
||||||
const sourcePackageJSON = require(`${PROJECT_ROOT}/package.json`);
|
const sourcePackageJSON = require(`${PROJECT_ROOT}/package.json`);
|
||||||
|
|
||||||
sourcePackageJSON.version = semver.inc(sourcePackageJSON.version, 'major', true);
|
sourcePackageJSON.version = semver.inc(sourcePackageJSON.version, promptAnswers.release, true);
|
||||||
|
|
||||||
const sourcePrettyPrintedJson = JSON.stringify(sourcePackageJSON, null, 2);
|
const sourcePrettyPrintedJson = JSON.stringify(sourcePackageJSON, null, 2);
|
||||||
writeFileSync(`${PROJECT_ROOT}/package.json`, sourcePrettyPrintedJson);
|
writeFileSync(`${PROJECT_ROOT}/package.json`, sourcePrettyPrintedJson);
|
||||||
|
Reference in New Issue
Block a user