Permalink
Browse files

feat(all): migrate to TS

  • Loading branch information...
StrahilKazlachev committed Jan 14, 2017
1 parent b216b05 commit 5a68ca31294a061d48a9a5e2502b19cc79b82cf7
View
@@ -1,13 +0,0 @@
-var yargs = require('yargs');
-
-var argv = yargs.argv,
- validBumpTypes = "major|minor|patch|prerelease".split("|"),
- bump = (argv.bump || 'patch').toLowerCase();
-
-if(validBumpTypes.indexOf(bump) === -1) {
- throw new Error('Unrecognized bump "' + bump + '".');
-}
-
-module.exports = {
- bump: bump
-};
View
@@ -1,65 +0,0 @@
-var path = require('path');
-var paths = require('./paths');
-
-exports.base = function() {
- var config = {
- filename: '',
- filenameRelative: '',
- sourceMap: true,
- sourceRoot: '',
- moduleRoot: path.resolve('src').replace(/\\/g, '/'),
- moduleIds: false,
- comments: false,
- compact: false,
- code: true,
- presets: [ 'es2015-loose', 'stage-1' ],
- plugins: [
- 'syntax-flow',
- 'transform-decorators-legacy',
- ]
- };
- if (!paths.useTypeScriptForDTS) {
- config.plugins.push(
- ['babel-dts-generator', {
- packageName: paths.packageName,
- typings: '',
- suppressModulePath: true,
- suppressComments: false,
- memberOutputFilter: /^_.*/,
- suppressAmbientDeclaration: true
- }]
- );
- };
- config.plugins.push('transform-flow-strip-types');
- return config;
-}
-
-exports.commonjs = function() {
- var options = exports.base();
- options.plugins.push('transform-es2015-modules-commonjs');
- return options;
-};
-
-exports.amd = function() {
- var options = exports.base();
- options.plugins.push('transform-es2015-modules-amd');
- return options;
-};
-
-exports.system = function() {
- var options = exports.base();
- options.plugins.push('transform-es2015-modules-systemjs');
- return options;
-};
-
-exports.es2015 = function() {
- var options = exports.base();
- options.presets = ['stage-1']
- return options;
-};
-
-exports['native-modules'] = function() {
- var options = exports.base();
- options.presets[0] = 'es2015-loose-native-modules';
- return options;
-}
View
@@ -1,52 +0,0 @@
-var path = require('path');
-var fs = require('fs');
-
-// hide warning //
-var emitter = require('events');
-emitter.defaultMaxListeners = 20;
-
-var appRoot = 'src/';
-var pkg = JSON.parse(fs.readFileSync('./package.json', 'utf-8'));
-
-var paths = {
- root: appRoot,
- source: appRoot + '**/*.js',
- html: appRoot + '**/*.html',
- style: 'styles/**/*.css',
- output: 'dist/',
- doc:'./doc',
- e2eSpecsSrc: 'test/e2e/src/*.js',
- e2eSpecsDist: 'test/e2e/dist/',
- packageName: pkg.name,
- useTypeScriptForDTS: false,
- importsToAdd: [],
- sort: true,
- styleSource: 'styles/input.less',
- styleOutput: 'styles'
-};
-
-paths.ignore = ['aurelia-dialog.js'];
-paths.files = [
- 'interfaces.js',
- 'dialog-options.js',
- 'dialog-result.js',
- 'dialog-cancel-error.js',
- 'ai-dialog-body.js',
- 'ai-dialog-footer.js',
- 'ai-dialog-header.js',
- 'ai-dialog.js',
- 'attach-focus.js',
- 'lifecycle.js',
- 'dialog-controller.js',
- 'renderer.js',
- 'dialog-renderer.js',
- 'dialog-service.js',
- 'dialog-configuration.js',
- 'aurelia-dialog.js'
- ].map(function(file){
- return paths.root + file;
-});
-
-paths.sample = 'sample';
-
-module.exports = paths;
View
@@ -1,159 +0,0 @@
-var gulp = require('gulp');
-var runSequence = require('run-sequence');
-var to5 = require('gulp-babel');
-var paths = require('../paths');
-var compilerOptions = require('../babel-options');
-var compilerTsOptions = require('../typescript-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 ts = require('gulp-typescript');
-var gutil = require('gulp-util');
-var gulpIgnore = require('gulp-ignore');
-var merge = require('merge2');
-var less = require('gulp-less');
-var minifyCSS = require('gulp-minify-css');
-var jsName = paths.packageName + '.js';
-var compileToModules = ['es2015', 'commonjs', 'amd', 'system', 'native-modules'];
-
-function cleanGeneratedCode() {
- return through2.obj(function(file, enc, callback) {
- file.contents = new Buffer(tools.cleanGeneratedCode(file.contents.toString('utf8')));
- this.push(file);
- return callback();
- });
-}
-
-function removeDTSPlugin(options) {
- var found = options.plugins.find(function(x){
- return x instanceof Array;
- });
-
- var index = options.plugins.indexOf(found);
- options.plugins.splice(index, 1);
- return options;
-}
-
-gulp.task('build-index', function() {
- var importsToAdd = paths.importsToAdd.slice();
-
- var src = gulp.src(paths.files);
-
- if (paths.sort) {
- src = src.pipe(tools.sortFiles());
- }
-
- if (paths.ignore) {
- paths.ignore.forEach(function(filename){
- src = src.pipe(gulpIgnore.exclude(filename));
- });
- }
-
- return src.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-es2015-temp', function () {
- return gulp.src(paths.output + jsName)
- .pipe(to5(assign({}, compilerOptions.commonjs())))
- .pipe(gulp.dest(paths.output + 'temp'));
-});
-
-function gulpFileFromString(filename, string) {
- var src = require('stream').Readable({ objectMode: true });
- src._read = function() {
- this.push(new gutil.File({ cwd: paths.appRoot, base: paths.output, path: filename, contents: new Buffer(string) }))
- this.push(null)
- }
- return src;
-}
-
-function srcForBabel() {
- return merge(
- gulp.src(paths.source),
- gulpFileFromString(paths.output + 'index.js', "export * from './" + paths.packageName + "';")
- );
-}
-
-function srcForTypeScript() {
- return gulp
- .src(paths.output + paths.packageName + '.js')
- .pipe(rename(function (path) {
- if (path.extname == '.js') {
- path.extname = '.ts';
- }
- }));
-}
-
-compileToModules.forEach(function(moduleType){
- gulp.task('build-babel-' + moduleType, function () {
- return srcForBabel()
- .pipe(to5(assign({}, removeDTSPlugin(compilerOptions[moduleType]()))))
- .pipe(cleanGeneratedCode())
- .pipe(gulp.dest(paths.output + moduleType));
- });
-
- if (moduleType === 'native-modules') return; // typescript doesn't support the combination of: es5 + native modules
-
- gulp.task('build-ts-' + moduleType, function () {
- var tsProject = ts.createProject(
- compilerTsOptions({ module: moduleType, target: moduleType == 'es2015' ? 'es2015' : 'es5' }), ts.reporter.defaultReporter());
- var tsResult = srcForTypeScript().pipe(ts(tsProject));
- return tsResult.js
- .pipe(gulp.dest(paths.output + moduleType));
- });
-});
-
-gulp.task('build-dts', function() {
- var tsProject = ts.createProject(
- compilerTsOptions({ removeComments: false, target: "es2015", module: "es2015" }), ts.reporter.defaultReporter());
- var tsResult = srcForTypeScript().pipe(ts(tsProject));
- return tsResult.dts
- .pipe(gulp.dest(paths.output));
-});
-
-gulp.task('build-css', function () {
- return gulp.src(paths.styleSource)
- .pipe(less())
- .pipe(minifyCSS({ keepBreaks: false }))
- .pipe(rename('output.css'))
- .pipe(gulp.dest(paths.styleOutput));
-});
-
-gulp.task('build', function(callback) {
- return runSequence(
- 'clean',
- 'build-index',
- 'build-es2015-temp',
- 'build-css',
- compileToModules
- .map(function(moduleType) { return 'build-babel-' + moduleType })
- .concat(paths.useTypeScriptForDTS ? ['build-dts'] : []),
- callback
- );
-});
-
-gulp.task('build-ts', function(callback) {
- return runSequence(
- 'clean',
- 'build-index',
- 'build-babel-native-modules',
- 'build-css',
- compileToModules
- .filter(function(moduleType) { return moduleType !== 'native-modules' })
- .map(function(moduleType) { return 'build-ts-' + moduleType })
- .concat(paths.useTypeScriptForDTS ? ['build-dts'] : []),
- callback
- );
-});
View
@@ -1,9 +0,0 @@
-var gulp = require('gulp');
-var paths = require('../paths');
-var del = require('del');
-var vinylPaths = require('vinyl-paths');
-
-gulp.task('clean', function() {
- return gulp.src([paths.output])
- .pipe(vinylPaths(del));
-});
View
@@ -1,10 +0,0 @@
-var gulp = require('gulp');
-var tools = require('aurelia-tools');
-
-gulp.task('update-own-deps', function(){
- tools.updateOwnDependenciesFromLocalRepositories();
-});
-
-gulp.task('build-dev-env', function () {
- tools.buildDevEnv();
-});
View
@@ -1,46 +0,0 @@
-var gulp = require('gulp');
-var paths = require('../paths');
-var typedoc = require('gulp-typedoc');
-var runSequence = require('run-sequence');
-var through2 = require('through2');
-
-gulp.task('doc-generate', function(){
- return gulp.src([paths.output + paths.packageName + '.d.ts'])
- .pipe(typedoc({
- target: 'es6',
- includeDeclarations: true,
- moduleResolution: 'node',
- json: paths.doc + '/api.json',
- name: paths.packageName + '-docs'
- mode: 'modules',
- excludeExternals: true,
- ignoreCompilerErrors: false,
- version: true
- }));
-});
-
-gulp.task('doc-shape', function(){
- return gulp.src([paths.doc + '/api.json'])
- .pipe(through2.obj(function(file, enc, callback) {
- var json = JSON.parse(file.contents.toString('utf8')).children[0];
-
- json = {
- name: paths.packageName,
- children: json.children,
- groups: json.groups
- };
-
- file.contents = new Buffer(JSON.stringify(json));
- this.push(file);
- return callback();
- }))
- .pipe(gulp.dest(paths.doc));
-});
-
-gulp.task('doc', function(callback){
- return runSequence(
- 'doc-generate',
- 'doc-shape',
- callback
- );
-});
View
@@ -1,10 +0,0 @@
-var gulp = require('gulp');
-var paths = require('../paths');
-var eslint = require('gulp-eslint');
-
-gulp.task('lint', function() {
- return gulp.src(paths.source)
- .pipe(eslint())
- .pipe(eslint.format())
- .pipe(eslint.failOnError());
-});
Oops, something went wrong.

0 comments on commit 5a68ca3

Please sign in to comment.