From 83de0ed2ba8dd14afe9820bc917c9172669b34f9 Mon Sep 17 00:00:00 2001 From: Tim Lancina Date: Thu, 20 Aug 2015 15:29:42 -0500 Subject: [PATCH] npm publish gulp task --- gulpfile.js | 36 ++++++++++++++++++++++++++++++++---- package.json | 8 +++++++- scripts/npm/package.json | 16 ++++++++++++++++ 3 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 scripts/npm/package.json diff --git a/gulpfile.js b/gulpfile.js index 0698c03b28..78bca428f9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -52,8 +52,8 @@ var tscReporter = { }; var flagConfig = { - string: 'port', - alias: {'p': 'port'}, + string: ['port', 'version'], + alias: {'p': 'port', 'v': 'version'}, default: { port: 8000 } }; @@ -343,14 +343,42 @@ gulp.task('copy.scss', function() { .pipe(gulp.dest('dist/src/scss')); }) +gulp.task('src', function(done){ + runSequence( + 'clean', + ['bundle', 'sass', 'fonts', 'copy.ts', 'copy.scss'], + 'transpile.common', + done + ); +}) + gulp.task('publish', function(done) { + var v = flags.version; + if (!v) { + console.error("\nERR: You need to provide a version or tag.\ngulp publish -v {version}\n"); + return + } + if (v.indexOf("alpha") + v.indexOf("-") > -2) { + console.error("\n ERR: Just provide version number. Instead of 2.0.0-alpha.10, just enter 10\n"); + return + } + runSequence( 'clean', ['bundle', 'sass', 'fonts', 'copy.ts', 'copy.scss'], 'transpile.common', function() { - var packageJSONContents = '{\n "name": "ionic-framework",\n "version": "2.0.0-alpha.1",\n "license": "Apache-2.0",\n "repository": {\n "type": "git",\n "url": "https://github.com/driftyco/ionic2.git"\n }\n}\n'; - fs.writeFile("dist/package.json", packageJSONContents, done); + var packageJSONTemplate = _.template(fs.readFileSync('scripts/npm/package.json')); + packageJSONContents = packageJSONTemplate({ 'version': v }); + fs.writeFileSync("dist/package.json", packageJSONContents); + + // publish to npm + var exec = require('child_process').exec; + exec('cd dist && npm publish', function (err, stdout, stderr) { + console.log(stdout); + console.error(stderr); + done(); + }); } ) }) diff --git a/package.json b/package.json index 7b7102718c..4db984e410 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,14 @@ "type": "git", "url": "https://github.com/driftyco/ionic2.git" }, - "devDependencies": { + "dependencies": { "angular2": "2.0.0-alpha.35", + "reflect-metadata": "0.1.0", + "rtts_assert": "2.0.0-alpha.35", + "traceur-runtime": "0.0.59", + "zone.js": "0.5.2" + }, + "devDependencies": { "canonical-path": "0.0.2", "connect": "^3.3.4", "del": "~1.1.1", diff --git a/scripts/npm/package.json b/scripts/npm/package.json new file mode 100644 index 0000000000..e60c7951fc --- /dev/null +++ b/scripts/npm/package.json @@ -0,0 +1,16 @@ +{ + "name": "ionic-framework", + "version": "2.0.0-alpha.<%= version %>", + "license": "Apache-2.0", + "repository": { + "type": "git", + "url": "https://github.com/driftyco/ionic2.git" + }, + "dependencies": { + "angular2": "2.0.0-alpha.35", + "reflect-metadata": "0.1.0", + "rtts_assert": "2.0.0-alpha.35", + "traceur-runtime": "0.0.59", + "zone.js": "0.5.2" + } +}