Skip to content

Commit

Permalink
chore(release): Release 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
happyhj committed Sep 21, 2017
1 parent 73f6d9b commit 8dcc768
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 82 deletions.
80 changes: 80 additions & 0 deletions config/release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
const fs = require("fs-extra");
const exec = require("sync-exec");
const pkg = require("../package.json");
const chalk = require("chalk");
function shell(cmd, ignore = false) {
let result = exec(cmd);
if (!result.stderr) {
!ignore && console.log(result.stdout);
console.log(chalk.gray(`# ${cmd}`));
} else {
if (!ignore) {
console.error(result.stderr);
throw new Error(result.stderr);
}
}
return result.stdout;
}
function restore(newVersion, version) {
pkg.version = version;
console.log(chalk.redBright("** Restore Tasks ** "));
console.log(chalk.red("- Restore package.json version"));
fs.writeJsonSync(__dirname + "/../package.json", pkg, {spaces: "\t"});
if (shell("git rev-parse HEAD") !== gitid) {
console.log(chalk.red("- Restore git log"));
shell("git reset HEAD^1");
}
console.log(chalk.red("- Remove remote version"));
shell(`git push upstream : ${newVersion}`, true);
}

const version = pkg.version;
const isRcBranch = /\d+\.\d+\.\d+-rc/.test(version);
const hasUpstream = (function() {
const result = shell("git remote show", true);
return !!~result.split("\n").indexOf("upstream");
})();
const hasDistfolder = (function() {
const result = fs.readFileSync(__dirname + "/../.gitignore",{encoding: "utf8"});
return result.split("\n").indexOf("dist/") === -1 || result.split("\n").indexOf("dist") === -1;
})();

if (isRcBranch && hasUpstream && hasDistfolder) {
const gitid = shell("git rev-parse HEAD");
const newVersion = version.substring(0, version.indexOf("-rc"));
try {
pkg.version = newVersion;

console.log(chalk.green(`1. Change package.json version to '${newVersion}'`));
fs.writeJsonSync(__dirname + "/../package.json", pkg, {spaces: "\t"});

console.log(chalk.green("2. Build"));
shell("npm run build");

console.log(chalk.green("3. Commit"));
shell(`git add --all`);
shell(`git commit -m "chore(release): Release ${newVersion}"`);

console.log(chalk.green(`4. Create local tag '${newVersion}'`));
shell(`git tag -d ${newVersion}`, true);
shell(`git tag ${newVersion}`);

console.log(chalk.green(`5. Push tag '${newVersion}'`));
shell(`git push upstream :${newVersion}`, true);
shell(`git push upstream ${newVersion}`);

console.log(chalk.green(`6. Deploy demo: '${newVersion}'`));
shell(`npm run demo:deploy`);

console.log(chalk.green(`7. Register npm with ${newVersion}. The registration procedure is as follows.`));
console.log(chalk.greenBright(` # npm login`));
console.log(chalk.greenBright(` # npm publish --access public`) + "\n");
console.log(chalk.redBright(`* Use 'npm unpublish ${pkg.name}#${newVersion}' if you want to erase deployed version.`));
} catch(e) {
restore(newVersion, version);
}
} else {
!isRcBranch && console.log("The version of 'package.json' must be named by X.X.X-rc to deploy. " + chalk.redBright("Change package.version"));
!hasUpstream && console.log("You can deploy when you have an 'upstream' remote repository. " + chalk.redBright("Add 'upstream' remote repository"));
!hasDistfolder && console.log("You can deploy when you include 'dist' folder. " + chalk.redBright("Remove 'dist' folder in .gitignore"));
}
2 changes: 1 addition & 1 deletion dist/persist-migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @egjs/persist JavaScript library
*
*
* @version 2.1.0-rc
* @version 2.1.0
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
Expand Down
2 changes: 1 addition & 1 deletion dist/persist-migrate.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions dist/persist.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @egjs/persist JavaScript library
*
*
* @version 2.1.0-rc
* @version 2.1.0
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
Expand Down Expand Up @@ -153,10 +153,10 @@ var _Persist2 = _interopRequireDefault(_Persist);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

_Persist2["default"].VERSION = "2.1.0-rc"; /**
* Copyright (c) 2015 NAVER Corp.
* egjs-persist projects are licensed under the MIT license
*/
_Persist2["default"].VERSION = "2.1.0"; /**
* Copyright (c) 2015 NAVER Corp.
* egjs-persist projects are licensed under the MIT license
*/

module.exports = _Persist2["default"];

Expand Down
4 changes: 2 additions & 2 deletions dist/persist.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8dcc768

Please sign in to comment.