Skip to content

Commit

Permalink
fix(all): changed build process to generate TypeScript definition fil…
Browse files Browse the repository at this point in the history
…es and more.
  • Loading branch information
Vheissu committed Mar 3, 2016
1 parent ccb31f7 commit f4db5f9
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 47 deletions.
2 changes: 1 addition & 1 deletion build/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ if(validBumpTypes.indexOf(bump) === -1) {

module.exports = {
bump: bump
};
};
21 changes: 18 additions & 3 deletions build/babel-options.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
var path = require('path');
var paths = require('./paths');

module.exports = {
filename: '',
filenameRelative: '',
modules: '',
sourceMap: true,
sourceMapName: '',
sourceRoot: '',
moduleRoot: '',
moduleRoot: path.resolve('src').replace(/\\/g, '/'),
moduleIds: false,
experimental: false,
comments: false,
Expand All @@ -16,5 +19,17 @@ module.exports = {
optional: [
"es7.decorators",
"es7.classProperties"
]
};
],
plugins: [
"babel-dts-generator"
],
extra: {
dts: {
packageName: paths.packageName,
typings: '',
suppressModulePath: true,
suppressComments: false,
memberOutputFilter: /^_.*/
}
}
};
8 changes: 6 additions & 2 deletions build/paths.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
var path = require('path');
var fs = require('fs');

var appRoot = 'src/';
var pkg = JSON.parse(fs.readFileSync('./package.json', 'utf-8'));

module.exports = {
root: appRoot,
Expand All @@ -9,6 +11,8 @@ module.exports = {
style: 'styles/**/*.css',
output: 'dist/',
doc:'./doc',
tests: 'test/**/*.js',
e2eSpecsSrc: 'test/e2e/src/*.js',
e2eSpecsDist: 'test/e2e/dist/'
};
e2eSpecsDist: 'test/e2e/dist/',
packageName: pkg.name
};
45 changes: 40 additions & 5 deletions build/tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,69 @@ var to5 = require('gulp-babel');
var paths = require('../paths');
var compilerOptions = require('../babel-options');
var assign = Object.assign || require('object.assign');
var through2 = require('through2');
var concat = require('gulp-concat');
var insert = require('gulp-insert');
var rename = require('gulp-rename');
var tools = require('aurelia-tools');

var jsName = paths.packageName + '.js';

gulp.task('build-index', function(){
var importsToAdd = [];

gulp.task('build-es6', function () {
return gulp.src(paths.source)
.pipe(tools.sortFiles())
.pipe(through2.obj(function(file, enc, callback) {
file.contents = new Buffer(tools.extractImports(file.contents.toString("utf8"), importsToAdd));
this.push(file);
return callback();
}))
.pipe(concat(jsName))
.pipe(insert.transform(function(contents) {
return tools.createImportBlock(importsToAdd) + contents;
}))
.pipe(gulp.dest(paths.output));
});

gulp.task('build-es6', function () {
return gulp.src(paths.output + jsName)
.pipe(gulp.dest(paths.output + 'es6'));
});

gulp.task('build-commonjs', function () {
return gulp.src(paths.source)
return gulp.src(paths.output + jsName)
.pipe(to5(assign({}, compilerOptions, {modules:'common'})))
.pipe(gulp.dest(paths.output + 'commonjs'));
});

gulp.task('build-amd', function () {
return gulp.src(paths.source)
return gulp.src(paths.output + jsName)
.pipe(to5(assign({}, compilerOptions, {modules:'amd'})))
.pipe(gulp.dest(paths.output + 'amd'));
});

gulp.task('build-system', function () {
return gulp.src(paths.source)
return gulp.src(paths.output + jsName)
.pipe(to5(assign({}, compilerOptions, {modules:'system'})))
.pipe(gulp.dest(paths.output + 'system'));
});

gulp.task('build-dts', function(){
return gulp.src(paths.output + paths.packageName + '.d.ts')
.pipe(rename(paths.packageName + '.d.ts'))
.pipe(gulp.dest(paths.output + 'es6'))
.pipe(gulp.dest(paths.output + 'commonjs'))
.pipe(gulp.dest(paths.output + 'amd'))
.pipe(gulp.dest(paths.output + 'system'));
});

gulp.task('build', function(callback) {
return runSequence(
'clean',
'build-index',
['build-es6', 'build-commonjs', 'build-amd', 'build-system'],
'build-dts',
callback
);
});
});
2 changes: 1 addition & 1 deletion build/tasks/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ gulp.task('update-own-deps', function(){

gulp.task('build-dev-env', function () {
tools.buildDevEnv();
});
});
33 changes: 26 additions & 7 deletions build/tasks/doc.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
var gulp = require('gulp');
var tools = require('aurelia-tools');
var paths = require('../paths');
var yuidoc = require('gulp-yuidoc');
var typedoc = require('gulp-typedoc');
var typedocExtractor = require('gulp-typedoc-extractor');
var runSequence = require('run-sequence');

gulp.task('doc-generate', function(){
return gulp.src(paths.source)
.pipe(yuidoc.parser(null, 'api.json'))
return gulp.src([paths.output + '*.d.ts', paths.doc + '/core-js.d.ts', './jspm_packages/npm/*/*.d.ts'])
.pipe(typedoc({
target: 'es6',
includeDeclarations: true,
json: paths.doc + '/api.json',
name: paths.packageName + '-docs',
mode: 'modules',
excludeExternals: true,
ignoreCompilerErrors: false,
version: true
}));
});

gulp.task('doc-extract', function(){
return gulp.src([paths.doc + '/api.json'])
.pipe(typedocExtractor(paths.packageName))
.pipe(gulp.dest(paths.doc));
});

gulp.task('doc', ['doc-generate'], function(){
tools.transformAPIModel(paths.doc);
})
gulp.task('doc', function(callback){
return runSequence(
'doc-generate',
'doc-extract',
callback
);
});
12 changes: 6 additions & 6 deletions build/tasks/lint.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
var gulp = require('gulp');
var paths = require('../paths');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var eslint = require('gulp-eslint');

gulp.task('lint', function() {
return gulp.src(paths.source)
.pipe(jshint())
.pipe(jshint.reporter(stylish));
});
return gulp.src([paths.source, paths.tests])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
2 changes: 1 addition & 1 deletion build/tasks/prepare-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ gulp.task('prepare-release', function(callback){
'changelog',
callback
);
});
});
2 changes: 1 addition & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ System.config({
]
},
paths: {
"*": "dist/*",
"github:*": "jspm_packages/github/*",
"npm:*": "jspm_packages/npm/*",
"aurelia-configuration/*": "dist/*.js"
Expand All @@ -18,6 +17,7 @@ System.config({
"aurelia-dependency-injection": "npm:[email protected]",
"aurelia-loader": "npm:[email protected]",
"aurelia-pal-browser": "npm:[email protected]",
"aurelia-path": "npm:[email protected]",
"babel": "npm:[email protected]",
"babel-runtime": "npm:[email protected]",
"core-js": "npm:[email protected]",
Expand Down
60 changes: 40 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,44 +23,64 @@
},
"jspm": {
"registry": "npm",
"main": "index",
"main": "aurelia-configuration",
"format": "amd",
"directories": {
"lib": "dist/amd"
},
"peerDependencies": {
"aurelia-dependency-injection": "^1.0.0-beta.1.1.4",
"aurelia-loader": "^1.0.0-beta.1.1.1",
"aurelia-path": "^1.0.0-beta.1.1.0"
},
"dependencies": {
"aurelia-dependency-injection": "^1.0.0-beta.1.1.4",
"aurelia-loader": "^1.0.0-beta.1.1.1"
"aurelia-loader": "^1.0.0-beta.1.1.1",
"aurelia-path": "^1.0.0-beta.1.1.0"
},
"devDependencies": {
"aurelia-pal-browser": "^1.0.0-beta.1.1.4",
"babel": "npm:babel-core@^5.8.24",
"babel-runtime": "npm:babel-runtime@^5.8.24",
"core-js": "npm:core-js@^1.1.4"
"babel": "^5.8.24",
"babel-runtime": "^5.8.24",
"core-js": "^2.0.3"
}
},
"dependencies": {
"aurelia-dependency-injection": "^1.0.0-beta.1.1.4",
"aurelia-loader": "^1.0.0-beta.1.1.1",
"aurelia-path": "^1.0.0-beta.1.1.0"
},
"devDependencies": {
"aurelia-tools": "^0.1.18",
"conventional-changelog": "^0.4.2",
"aurelia-tools": "0.1.16",
"babel-dts-generator": "0.2.18",
"babel-eslint": "^4.1.1",
"conventional-changelog": "0.0.11",
"del": "^1.1.0",
"gulp": "^3.9.1",
"gulp-babel": "^5.3.0",
"gulp": "^3.8.10",
"gulp-babel": "^5.2.1",
"gulp-bump": "^0.3.1",
"gulp-changed": "^1.1.0",
"gulp-jshint": "^1.9.0",
"gulp-yuidoc": "^0.1.2",
"gulp-concat": "^2.6.0",
"gulp-coveralls": "0.1.4",
"gulp-eslint": "^1.0.0",
"gulp-insert": "^0.4.0",
"gulp-rename": "^1.2.2",
"gulp-typedoc": "^1.2.1",
"gulp-typedoc-extractor": "^0.0.8",
"isparta": "4.0.0",
"istanbul": "github:gotwarlost/istanbul#source-map",
"jasmine-core": "^2.1.3",
"jshint-stylish": "^1.0.0",
"jspm": "^0.16.15",
"karma": "^0.13.21",
"karma-babel-preprocessor": "^5.2.1",
"karma-chrome-launcher": "^0.2.1",
"karma-coverage": "douglasduteil/karma-coverage#next",
"jspm": "0.16.15",
"karma": "^0.13.15",
"karma-babel-preprocessor": "^5.2.2",
"karma-chrome-launcher": "^0.1.7",
"karma-coverage": "github:douglasduteil/karma-coverage#next",
"karma-jasmine": "^0.3.5",
"karma-jspm": "2.0.1-beta.2",
"karma-jspm": "^2.0.1",
"karma-sourcemap-loader": "0.3.6",
"object.assign": "^1.0.3",
"require-dir": "^0.1.0",
"run-sequence": "^1.0.2",
"through2": "^2.0.0",
"vinyl": "^0.5.1",
"vinyl-paths": "^1.0.0",
"yargs": "^2.1.1"
}
Expand Down

0 comments on commit f4db5f9

Please sign in to comment.