Permalink
Browse files

chore(project): add ts support

  • Loading branch information...
doktordirk committed Mar 21, 2016
1 parent fb13b40 commit 058196623407dc303e224fb19976ba6f5bf0a2fb
Showing with 60 additions and 1 deletion.
  1. +4 −1 build/paths.js
  2. +49 −0 build/tasks/build.js
  3. +7 −0 package.json
@@ -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,
@@ -10,5 +12,6 @@ module.exports = {
output: 'dist/',
doc:'./doc',
e2eSpecsSrc: 'test/e2e/src/*.js',
e2eSpecsDist: 'test/e2e/dist/'
e2eSpecsDist: 'test/e2e/dist/',
packageName: pkg.name
};
@@ -4,6 +4,36 @@ 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 del = require('del');
var vinylPaths = require('vinyl-paths');

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

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

return gulp.src([
paths.root + '*.js',
paths.root + '**/*.js',
'!' + paths.root + 'index.js'
])
.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(to5(assign({}, compilerOptions.commonjs())))
.pipe(gulp.dest(paths.output))
});

gulp.task('build-es2015', function() {
return gulp.src(paths.source)
@@ -29,10 +59,29 @@ gulp.task('build-system', function() {
.pipe(gulp.dest(paths.output + 'system'));
});

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

gulp.task('remove-dts-folder', function() {
var tdsFolder = paths.packageName;
return gulp.src([tdsFolder])
.pipe(vinylPaths(del));
});

gulp.task('build', function(callback) {
return runSequence(
'clean',
['build-es2015', 'build-commonjs', 'build-amd', 'build-system'],
'build-index',
'build-dts',
'remove-dts-folder',
callback
);
});
@@ -58,6 +58,7 @@
},
"devDependencies": {
"aurelia-tools": "^0.1.20",
"babel-dts-generator": "^0.4.7",
"babel-eslint": "^4.1.3",
"babel-plugin-syntax-flow": "^6.5.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
@@ -76,8 +77,13 @@
"gulp": "^3.8.10",
"gulp-babel": "^6.1.2",
"gulp-bump": "^2.0.1",
"gulp-concat": "^2.6.0",
"gulp-eslint": "^1.1.1",
"gulp-remark": "^1.1.5",
"gulp-insert": "^0.5.0",
"gulp-rename": "^1.2.2",
"gulp-typedoc": "^1.2.1",
"gulp-typedoc-extractor": "0.0.8",
"jasmine-core": "^2.1.3",
"karma": "^0.13.15",
"karma-babel-preprocessor": "^6.0.1",
@@ -96,6 +102,7 @@
"require-dir": "^0.1.0",
"run-sequence": "^1.0.2",
"snyk": "^1.8.4",
"through2": "^2.0.0",
"vinyl-paths": "^2.1.0",
"yargs": "^4.3.2"
}

0 comments on commit 0581966

Please sign in to comment.