diff --git a/.npmignore b/.npmignore index 49a8fd3..2501300 100644 --- a/.npmignore +++ b/.npmignore @@ -5,7 +5,7 @@ node_modules _artifact build -typings +/typings .bithoundrc .editorconfig .gitignore @@ -17,4 +17,5 @@ karma.conf.js system.config.js tsconfig.json tslint.json -typings.json \ No newline at end of file +typings.json +wallaby.js \ No newline at end of file diff --git a/README.md b/README.md index c5cf593..0406e21 100644 --- a/README.md +++ b/README.md @@ -121,4 +121,4 @@ gulp tdd ``` gulp prepare-release --bump major|minor|patch|prerelease (default: patch) ``` -Check out the [release workflow guide][releaseWorkflowWiki] in order to guide you creating a release and distributing it. \ No newline at end of file +Check out the [release workflow guide][releaseWorkflowWiki] in order to guide you creating a release and publishing it. \ No newline at end of file diff --git a/build/args.js b/build/args.js index d81db66..b856354 100644 --- a/build/args.js +++ b/build/args.js @@ -1,16 +1,18 @@ var yargs = require("yargs"); -var argv = yargs.argv, - validBumpTypes = "major|minor|patch|prerelease".split("|"), - bump = (argv.bump || "patch").toLowerCase(); +var argv = yargs + .alias("rel", "release") + .default("rel", false) -if (validBumpTypes.indexOf(bump) === -1) { - throw new Error(`Unrecognized bump "${bump}".`); -} + .choices("bump", ["major", "minor", "patch", "prerelease"]) + .default("bump", "patch") -var versionSuffix = (argv.versionSuffix || "rc" ).toLowerCase(); + .default("versionSuffix", "rc") + + .argv; module.exports = { - bump: bump, - versionSuffix: versionSuffix + bump: argv.bump, + versionSuffix: argv.versionSuffix, + isRelease: argv.rel }; \ No newline at end of file diff --git a/build/tasks/build.js b/build/tasks/build.js index fa715a5..98944b1 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -5,26 +5,39 @@ const sourcemaps = require("gulp-sourcemaps"); const plumber = require("gulp-plumber"); const merge = require("merge2"); +const args = require("../args"); const paths = require("../paths"); gulp.task("build", (cb) => { + if (args.isRelease) { + return runSeq( + ["lint", "compile:ts"], + "copy-dist", + cb); + } return runSeq( - ["compile:ts"], + ["lint", "compile:ts"], cb); }); gulp.task("rebuild", (cb) => { + if (args.isRelease) { + return runSeq( + "clean", + "build", + "copy-dist", + cb); + } return runSeq( "clean:artifact", "build", cb); }); -gulp.task("rebuild:rel", (cb) => { +gulp.task("ci", (cb) => { return runSeq( - "clean", - "build", - "copy-dist", + "rebuild", + "test", cb); }); @@ -33,36 +46,27 @@ gulp.task("compile:ts", () => { const tsProject = getTscProject(); const tsResult = gulp.src([...paths.src.typings, paths.src.ts, `!${paths.src.testTs}`]) .pipe(plumber()) - //.pipe(changed(paths.output.dist, { extension: ".js" })) - //.pipe(sourcemaps.init()) + //.pipe(changed(paths.output.dist, { extension: ".js" })) + .pipe(sourcemaps.init()) .pipe(tsc(tsProject)); return merge([ tsResult.js - //.pipe(sourcemaps.write(".")) + .pipe(sourcemaps.write(".")) .pipe(gulp.dest(`${paths.output.artifact}/amd`)), - tsResult.dts.pipe(gulp.dest(`${paths.output.artifact}/typings`)) - ]); + tsResult.dts + .pipe(gulp.dest(`${paths.output.artifact}/typings`)) + ]); +}); + +gulp.task("copy-dist", () => { + return gulp.src(`${paths.output.artifact}/**/*`) + .pipe(gulp.dest(`${paths.output.dist}`)); }); function getTscProject() { return tsc.createProject("tsconfig.json", { - typescript: require("typescript"), + typescript: require("typescript") //outFile: `${paths.packageName}.js` }); -} - -// copy-dist -gulp.task("copy-dist", () => { - return runSeq(["copy-dist:scripts", "copy-dist:dts"]); -}); - -gulp.task("copy-dist:scripts", () => { - return gulp.src(`${paths.output.artifact}/amd/**/*.js`) - .pipe(gulp.dest(`${paths.output.dist}/amd`)); -}); - -gulp.task("copy-dist:dts", () => { - return gulp.src(`${paths.output.artifact}/typings/**/*.d.ts`) - .pipe(gulp.dest(`${paths.output.dist}/typings`)); -}); \ No newline at end of file +} \ No newline at end of file diff --git a/build/tasks/dev.js b/build/tasks/dev.js index c1c04ed..a47e050 100644 --- a/build/tasks/dev.js +++ b/build/tasks/dev.js @@ -1,15 +1,26 @@ const gulp = require("gulp"); const util = require("gulp-util"); +const runSeq = require("run-sequence"); +const args = require("../args"); const paths = require("../paths"); gulp.task("watch", () => { - - // ts - gulp.watch(paths.src.ts, ["compile:ts"]) - .on("change", reportChange) - .on("error", swallowError); - + if (args.isRelease) { + // ts + gulp.watch(paths.src.ts, () => { + return runSeq( + "compile:ts", + "copy-dist" + ); + }).on("change", reportChange) + .on("error", swallowError); + } else { + // ts + gulp.watch(paths.src.ts, ["compile:ts"]) + .on("change", reportChange) + .on("error", swallowError); + } }); function reportChange(event) { diff --git a/build/tasks/prepare-release.js b/build/tasks/prepare-release.js index f7ba3ac..290264f 100644 --- a/build/tasks/prepare-release.js +++ b/build/tasks/prepare-release.js @@ -10,11 +10,9 @@ var paths = require("../paths"); var publishBranch; gulp.task("prepare-release", (cb) => { + args.isRelease = true; return runSequence( - "test", - "lint", - - "rebuild:rel", + "ci", "bump-version", //"doc", "changelog", @@ -31,13 +29,12 @@ gulp.task("perform-release", (cb) => { }); gulp.task("publish", (cb) => { + if (args.isRelease) { + return publish(null, "HEAD", cb); + } return publish("prerelease", "HEAD", cb); }); -gulp.task("publish:rel", (cb) => { - return publish(null, "HEAD", cb); -}); - // utils // ------------- diff --git a/doc/RELEASE-WORKFLOW.md b/doc/RELEASE-WORKFLOW.md index e923908..54aefc2 100644 --- a/doc/RELEASE-WORKFLOW.md +++ b/doc/RELEASE-WORKFLOW.md @@ -28,7 +28,7 @@ RC release process ## New Stable Release Stable release process - Checkout `master` - - Run `gulp publish:rel --bump major|minor|patch (default: patch)` + - Run `gulp publish --rel --bump major|minor|patch (default: patch)` - Merge `master => develop` @@ -44,7 +44,7 @@ gulp publish ### Publish Rel Quick publish a stable release, this will prepare release and commit. ``` -gulp publish:rel --bump major|minor|patch|prerelease (default: patch) +gulp publish --rel --bump major|minor|patch|prerelease (default: patch) ``` ### Prepare-Release