Skip to content

Commit 729e38a

Browse files
committed
feat(build): add npm publish script
Also fixes gulpfile: - `runSequence` needs to be called with `done` callback - `es5build` should only run when the task executes…
1 parent 6e923cb commit 729e38a

File tree

9 files changed

+123
-83
lines changed

9 files changed

+123
-83
lines changed

gulpfile.js

Lines changed: 48 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -253,16 +253,19 @@ gulp.task('build/transpile.js.dev.es6', transpile(gulp, gulpPlugins, {
253253
srcFolderInsertion: CONFIG.srcFolderInsertion.js
254254
}));
255255

256-
gulp.task('build/transpile.js.dev.es5', es5build({
257-
src: CONFIG.dest.js.dev.es6,
258-
dest: CONFIG.dest.js.dev.es5,
259-
modules: 'instantiate'
260-
}));
256+
gulp.task('build/transpile.js.dev.es5', function() {
257+
return es5build({
258+
src: CONFIG.dest.js.dev.es6,
259+
dest: CONFIG.dest.js.dev.es5,
260+
modules: 'instantiate'
261+
});
262+
});
261263

262-
gulp.task('build/transpile.js.dev', function() {
263-
return runSequence(
264+
gulp.task('build/transpile.js.dev', function(done) {
265+
runSequence(
264266
'build/transpile.js.dev.es6',
265-
'build/transpile.js.dev.es5'
267+
'build/transpile.js.dev.es5',
268+
done
266269
);
267270
});
268271

@@ -275,16 +278,19 @@ gulp.task('build/transpile.js.prod.es6', transpile(gulp, gulpPlugins, {
275278
srcFolderInsertion: CONFIG.srcFolderInsertion.js
276279
}));
277280

278-
gulp.task('build/transpile.js.prod.es5', es5build({
279-
src: CONFIG.dest.js.prod.es6,
280-
dest: CONFIG.dest.js.prod.es5,
281-
modules: 'instantiate'
282-
}));
281+
gulp.task('build/transpile.js.prod.es5', function() {
282+
return es5build({
283+
src: CONFIG.dest.js.prod.es6,
284+
dest: CONFIG.dest.js.prod.es5,
285+
modules: 'instantiate'
286+
});
287+
});
283288

284-
gulp.task('build/transpile.js.prod', function() {
285-
return runSequence(
289+
gulp.task('build/transpile.js.prod', function(done) {
290+
runSequence(
286291
'build/transpile.js.prod.es6',
287-
'build/transpile.js.prod.es5'
292+
'build/transpile.js.prod.es5',
293+
done
288294
);
289295
});
290296

@@ -344,11 +350,19 @@ gulp.task('build/html.dart', html(gulp, gulpPlugins, {
344350

345351
gulp.task('build/copy.js.dev', function() {
346352
return gulp.src(CONFIG.copy.js)
353+
.pipe(gulpPlugins.template({
354+
'channel': 'dev',
355+
'packageJson': require('./package.json')
356+
}))
347357
.pipe(gulp.dest(CONFIG.dest.js.dev.es6));
348358
});
349359

350360
gulp.task('build/copy.js.prod', function() {
351361
return gulp.src(CONFIG.copy.js)
362+
.pipe(gulpPlugins.template({
363+
'channel': 'prod',
364+
'packageJson': require('./package.json')
365+
}))
352366
.pipe(gulp.dest(CONFIG.dest.js.prod.es6));
353367
});
354368

@@ -522,40 +536,45 @@ gulp.task('ci', function(done) {
522536
runSequence(
523537
'test.transpiler.unittest',
524538
'test.js/ci',
525-
'test.dart/ci'
539+
'test.dart/ci',
540+
done
526541
);
527542
});
528543

529544
// -----------------
530545
// orchestrated targets
531-
gulp.task('build.dart', function() {
532-
return runSequence(
546+
gulp.task('build.dart', function(done) {
547+
runSequence(
533548
['build/deps.js.dart2js', 'build/transpile.dart', 'build/html.dart'],
534549
'build/pubspec.dart',
535550
'build/multicopy.dart',
536551
'build/pubbuild.dart',
537552
'build/analyze.dart',
538-
'build/format.dart'
553+
'build/format.dart',
554+
done
539555
);
540556
});
541557

542-
gulp.task('build.js.dev', function() {
543-
return runSequence(
558+
gulp.task('build.js.dev', function(done) {
559+
runSequence(
544560
['build/deps.js.dev', 'build/transpile.js.dev', 'build/html.js.dev', 'build/copy.js.dev'],
545-
'build/multicopy.js.dev'
561+
'build/multicopy.js.dev',
562+
done
546563
);
547564
});
548565

549-
gulp.task('build.js.prod', function() {
550-
return runSequence(
566+
gulp.task('build.js.prod', function(done) {
567+
runSequence(
551568
['build/deps.js.prod', 'build/transpile.js.prod', 'build/html.js.prod', 'build/copy.js.prod'],
552-
'build/multicopy.js.prod'
569+
'build/multicopy.js.prod',
570+
done
553571
);
554572
});
555573

556-
gulp.task('build.cjs', function() {
557-
return runSequence(
558-
['build/transpile/tools.cjs', 'build/transpile/e2eTest.cjs']
574+
gulp.task('build.cjs', function(done) {
575+
runSequence(
576+
['build/transpile/tools.cjs', 'build/transpile/e2eTest.cjs'],
577+
done
559578
);
560579
});
561580

modules/angular2/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ Angular2
33

44
The sources for this package are in the main [Angular2](https://github.com/angular/angular) repo. Please file issues and pull requests against that repo. This is the repository for the upcoming 2.0 version. If you're looking for the current official version of Angular you should go to [angular/angular.js](https://github.com/angular/angular.js)
55

6+
Angular2 has 2 versions:
7+
8+
1. a development version that includes runtime type assertions: See `ng2dev` npm tag
9+
2. a production version that does not include runtime type assertions: See `ng2prod` npm tag
10+
611
All sources are in ES6 format and have the suffix `.es6`. They don't depend on any runtime
712
and can be used by any modern ES6 -> ES5 transpiler.
813

modules/angular2/package.json

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
11
{
2-
"name": "angular2",
3-
"version": "2.0.0-alpha.1",
2+
"name": "angular",
3+
"version": "<%= packageJson.version %>.<%= channel %>",
44
"description": "Angular 2 - a web framework for modern web apps",
5-
"homepage": "https://github.com/angular/angular",
6-
"bugs": "https://github.com/angular/angular/issues",
7-
"contributors": {
8-
"Alex Eagle": "[email protected]",
9-
"Chirayu Krishnappa": "[email protected]",
10-
"Jeff Cross": "[email protected]",
11-
"Misko Hevery": "[email protected]",
12-
"Rado Kirov": "[email protected]",
13-
"Tobias Bosch": "[email protected]",
14-
"Victor Savkin": "[email protected]",
15-
"Yegor Jbanov": "[email protected]"
16-
},
17-
"license": "Apache-2.0",
5+
"homepage": "<%= packageJson.homepage %>",
6+
"bugs": "<%= packageJson.bugs %>",
7+
"contributors": <%= JSON.stringify(packageJson.contributors) %>,
8+
"license": "<%= packageJson.license %>",
189
"dependencies": {
19-
"zone": "0.4.*",
20-
"rtts-assert": "2.0.0-alpha.1"
10+
<% if (channel==='dev') { %>
11+
"ng-rtts-assert": "<%= packageJson.version %>",
12+
<% } %>
13+
"zone.js": "0.4.*"
2114
},
2215
"devDependencies": {
2316
"yargs": "2.3.*",

modules/angular2/pubspec.yaml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
name: angular2
2-
version: 2.0.0-alpha.1
2+
version: <%= packageJson.version %>
33
authors:
4-
- Alex Eagle <[email protected]>
5-
- Chirayu Krishnappa <[email protected]>
6-
- Jeff Cross <[email protected]>
7-
- Misko Hevery <[email protected]>
8-
- Rado Kirov <[email protected]>
9-
- Tobias Bosch <[email protected]>
10-
- Victor Savkin <[email protected]>
11-
- Yegor Jbanov <[email protected]>
4+
<%= Object.keys(packageJson.contributors).map(function(name) {
5+
return '- '+name+' <'+packageJson.contributors[name]+'>';
6+
}).join('\n') %>
127
description: Angular 2 for Dart - a web framework for modern web apps
13-
homepage: https://github.com/angular/angular
8+
homepage: <%= packageJson.homepage %>
149
environment:
1510
sdk: '>=1.4.0'
1611
dependencies:

modules/rtts_assert/package.json

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
{
2-
"name": "rtts-assert",
3-
"version": "2.0.0-alpha.1",
4-
"description": "A type assertion library for Traceur.",
5-
"homepage": "https://github.com/angular/angular",
6-
"bugs": "https://github.com/angular/angular/issues",
7-
"contributors": {
8-
"Alex Eagle": "[email protected]",
9-
"Chirayu Krishnappa": "[email protected]",
10-
"Jeff Cross": "[email protected]",
11-
"Misko Hevery": "[email protected]",
12-
"Rado Kirov": "[email protected]",
13-
"Tobias Bosch": "[email protected]",
14-
"Victor Savkin": "[email protected]",
15-
"Yegor Jbanov": "[email protected]"
16-
},
17-
"license": "Apache-2.0",
2+
"name": "ng-rtts-assert",
3+
"version": "<%= packageJson.version %>",
4+
"description": "A run-time type assertion library for JavaScript",
5+
"homepage": "<%= packageJson.homepage %>",
6+
"bugs": "<%= packageJson.bugs %>",
7+
"contributors": <%= JSON.stringify(packageJson.contributors) %>,
8+
"license": "<%= packageJson.license %>",
189
"devDependencies": {
1910
"yargs": "2.3.*",
2011
"gulp-sourcemaps": "1.3.*",

package.json

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
{
22
"name": "angular",
3-
"version": "0.0.0",
4-
"description": "Angular",
3+
"version": "2.0.0-alpha.5",
4+
"description": "Angular 2 - a web framework for modern web apps",
5+
"homepage": "https://github.com/angular/angular",
6+
"bugs": "https://github.com/angular/angular/issues",
7+
"contributors": {
8+
"Alex Eagle": "[email protected]",
9+
"Chirayu Krishnappa": "[email protected]",
10+
"Jeff Cross": "[email protected]",
11+
"Misko Hevery": "[email protected]",
12+
"Rado Kirov": "[email protected]",
13+
"Tobias Bosch": "[email protected]",
14+
"Victor Savkin": "[email protected]",
15+
"Yegor Jbanov": "[email protected]"
16+
},
17+
"license": "Apache-2.0",
518
"repository": {
619
"type": "git",
720
"url": "https://github.com/angular/angular.git"
821
},
9-
"bugs": "https://github.com/angular/angular/issues",
1022
"scripts": {
1123
"test": "echo \"Error: no test specified\" && exit 1"
1224
},
13-
"author": "Tobias Bosch <[email protected]>",
14-
"license": "Apache-2.0",
1525
"dependencies": {
1626
"es6-module-loader": "^0.9.2",
1727
"systemjs": "^0.9.1",
@@ -22,9 +32,6 @@
2232
"node-uuid": "1.4.x"
2333
},
2434
"devDependencies": {
25-
"yargs": "2.3.*",
26-
"gulp-sourcemaps": "1.3.*",
27-
"gulp-traceur": "0.16.*",
2835
"angular": "1.3.5",
2936
"bower": "^1.3.12",
3037
"canonical-path": "0.0.2",
@@ -36,11 +43,13 @@
3643
"gulp": "^3.8.8",
3744
"gulp-changed": "^1.0.0",
3845
"gulp-connect": "~1.0.5",
39-
"gulp-ejs": "^0.3.1",
4046
"gulp-jasmine": "^1.0.1",
4147
"gulp-load-plugins": "^0.7.1",
4248
"gulp-rename": "^1.2.0",
4349
"gulp-shell": "^0.2.10",
50+
"gulp-sourcemaps": "1.3.*",
51+
"gulp-template": "^3.0.0",
52+
"gulp-traceur": "0.16.*",
4453
"gulp-webserver": "^0.8.7",
4554
"karma": "^0.12.23",
4655
"karma-chrome-launcher": "^0.1.4",
@@ -55,6 +64,7 @@
5564
"q": "^1.0.1",
5665
"run-sequence": "^0.3.6",
5766
"sprintf-js": "1.0.*",
58-
"through2": "^0.6.1"
67+
"through2": "^0.6.1",
68+
"yargs": "2.3.*"
5969
}
6070
}

scripts/publish/npm_publish.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
set -ex
3+
4+
ROOT_DIR=$(cd $(dirname $0)/../..; pwd)
5+
cd $ROOT_DIR
6+
gulp clean
7+
gulp build.js.prod build.js.dev
8+
9+
function angular {
10+
CHANNEL=$1
11+
cd $ROOT_DIR/dist/js/$CHANNEL/es6/angular2
12+
rm -fr test
13+
npm publish ./ --tag "ng2$CHANNEL"
14+
}
15+
16+
function rttsAssert {
17+
cd $ROOT_DIR/dist/js/prod/es6/rtts_assert
18+
rm -fr test
19+
npm publish ./
20+
}
21+
22+
rttsAssert
23+
angular dev
24+
angular prod

tools/build/es5build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ if (!module.parent) {
4747

4848
function run(config) {
4949
var src = ['!node_modules', '!node_modules/**', './**/*.es6'];
50-
gulp.src(src, {cwd: config.src})
50+
return gulp.src(src, {cwd: config.src})
5151
.pipe(rename(function(file) {
5252
file.extname = file.extname.replace('.es6', '.js');
5353
}))

tools/build/pubspec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ module.exports = function(gulp, plugins, config) {
99
var files = [];
1010
var pubSpecCopy = util.streamToPromise(gulp.src(config.src)
1111
.pipe(plugins.changed(config.dest)) // Only forward files that changed.
12+
.pipe(plugins.template({
13+
'packageJson': require('../../package.json')
14+
}))
1215
.pipe(through2.obj(function(file, enc, done) {
1316
files.push(path.resolve(process.cwd(), config.dest, file.relative));
1417
this.push(file);

0 commit comments

Comments
 (0)