Skip to content

Commit a7c8c75

Browse files
committed
Initial change.
1 parent d67b319 commit a7c8c75

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1721
-1687
lines changed

.vscode/settings.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
// Controls the rendering size of tabs in characters. Accepted values: "auto", 2, 4, 6, etc. If set to "auto", the value will be guessed when a file is opened.
3+
"editor.tabSize": 2,
4+
// When enabled, will trim trailing whitespace when you save a file.
5+
"files.trimTrailingWhitespace": true,
6+
// Controls whether the editor should render whitespace characters
7+
"editor.renderWhitespace": true,
8+
"editor.insertSpaces": true,
9+
// Configure glob patterns for excluding files and folders in searches. Inherits all glob patterns from the file.exclude setting.
10+
"files.exclude": {
11+
"**/.git": true,
12+
"**/.DS_Store": true,
13+
"**/node_modules": true,
14+
"**/lib": true
15+
},
16+
// Configure glob patterns for excluding files and folders in searches. Inherits all glob patterns from the file.exclude setting.
17+
"search.exclude": {
18+
}
19+
}

gulpfile.js

Lines changed: 64 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,69 @@
11
'use strict';
22

3-
let build = require('./lib/index');
4-
5-
// Use the build tools to build the build tools.
6-
build.initializeTasks(
7-
require('gulp'),
8-
{
9-
build: {
10-
paths: {
11-
lessMatch: null,
12-
staticsMatch: null,
13-
htmlMatch: null
14-
},
15-
isLintingEnabled: true
3+
let gulp = require('gulp');
4+
let config = {
5+
paths: {
6+
libFolder: 'lib',
7+
sourceMatch: [
8+
'src/**/*.ts',
9+
'typings/tsd.d.ts'
10+
],
11+
testMatch: [
12+
'lib/**/*.test.js'
13+
]
14+
}
15+
}
16+
17+
gulp.task('build', () => {
18+
let ts = require('gulp-typescript');
19+
let plumber = require('gulp-plumber');
20+
let merge = require('merge2');
21+
let lint = require('gulp-tslint');
22+
let tsConfig = require('./tsconfig.json');
23+
let paths = config.paths;
24+
let errorCount = 0;
25+
let allStreams = [];
26+
let tsProject = ts.createProject(tsConfig.compilerOptions);
27+
let gutil = require('gulp-util');
28+
let chalk = require('chalk');
29+
let sourceStream = gulp.src(paths.sourceMatch);
30+
31+
sourceStream
32+
.pipe(lint({
33+
configuration: require('./tslint.json')
34+
}))
35+
.pipe(lint.report('full', {
36+
emitError: false
37+
}));
38+
39+
let tsResult = sourceStream
40+
.pipe(plumber({
41+
errorHandler: function(error) {
42+
// console.log(error);
43+
errorCount++;
44+
}
45+
}))
46+
.pipe(ts(tsProject, undefined, ts.reporter.longReporter()));
47+
48+
allStreams.push(tsResult.js.pipe(gulp.dest(paths.libFolder)));
49+
allStreams.push(tsResult.dts.pipe(gulp.dest(paths.libFolder)));
50+
51+
let mergedStream = merge(allStreams);
52+
53+
mergedStream.on('queueDrain', function() {
54+
if (errorCount) {
55+
// throw new gutil.PluginError('msg', `[gulp-typescript] TypeScript error(s): ${ chalk.red(errorCount) }`, { showStack: false });
1656
}
1757
});
1858

59+
return mergedStream;
60+
});
61+
62+
gulp.task('test', ['build'], () => {
63+
let mocha = require('gulp-mocha');
64+
65+
return gulp.src(config.paths.testMatch, { read: false })
66+
.pipe(mocha());
67+
});
68+
69+
gulp.task('default', ['build']);

karma.conf.js

Lines changed: 0 additions & 121 deletions
This file was deleted.

lib/GulpProxy.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export declare class GulpProxy {
2+
private _gulp;
3+
constructor(gulpInstance: any);
4+
task(): any;
5+
src(): any;
6+
dest(): any;
7+
}
8+
export default GulpProxy;

lib/GulpProxy.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var GulpProxy = (function () {
2+
function GulpProxy(gulpInstance) {
3+
this._gulp = gulpInstance;
4+
}
5+
GulpProxy.prototype.task = function () {
6+
throw 'You should not define gulp tasks, but instead subclass the GulpTask and override the executeTask method.';
7+
};
8+
GulpProxy.prototype.src = function () {
9+
return this._gulp.src.apply(this._gulp, arguments);
10+
};
11+
GulpProxy.prototype.dest = function () {
12+
return this._gulp.dest.apply(this._gulp, arguments);
13+
};
14+
return GulpProxy;
15+
})();
16+
exports.GulpProxy = GulpProxy;
17+
Object.defineProperty(exports, "__esModule", { value: true });
18+
exports.default = GulpProxy;

lib/GulpTask.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { ITask } from './ITask';
2+
import { IBuildConfig } from './IBuildConfig';
3+
export declare class GulpTask implements ITask {
4+
name: string;
5+
buildConfig: IBuildConfig;
6+
executeTask(gulp: any, completeCallback: (result?: any) => void): any;
7+
execute(config: IBuildConfig): Promise<any>;
8+
resolvePath(localPath: string): string;
9+
readConfig(localPath: string): string;
10+
}

lib/GulpTask.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
var logging_1 = require('./logging');
2+
var chalk = require('chalk');
3+
var GulpTask = (function () {
4+
function GulpTask() {
5+
this.name = 'unnamed gulp task';
6+
}
7+
GulpTask.prototype.executeTask = function (gulp, completeCallback) {
8+
throw 'The task subclass is missing the "executeTask" method.';
9+
};
10+
GulpTask.prototype.execute = function (config) {
11+
var _this = this;
12+
this.buildConfig = config;
13+
if (this.name) {
14+
logging_1.log("Starting subtask '" + chalk.cyan(this.name) + "'...");
15+
}
16+
return new Promise(function (resolve, reject) {
17+
var stream;
18+
try {
19+
stream = _this.executeTask(_this.buildConfig.gulp, function (result) {
20+
if (!result) {
21+
resolve();
22+
}
23+
else {
24+
reject(result);
25+
}
26+
});
27+
}
28+
catch (e) {
29+
console.log("The task " + _this.name + " threw an exception: " + e);
30+
reject(e);
31+
}
32+
if (stream) {
33+
stream
34+
.on('error', function (error) {
35+
reject(error);
36+
})
37+
.on('end', function () {
38+
debugger;
39+
resolve();
40+
});
41+
}
42+
});
43+
};
44+
GulpTask.prototype.resolvePath = function (localPath) {
45+
var path = require('path');
46+
return path.resolve(path.join(this.buildConfig.rootPath, localPath));
47+
};
48+
GulpTask.prototype.readConfig = function (localPath) {
49+
var fullPath = this.resolvePath(localPath);
50+
var result = null;
51+
var fs = require('fs');
52+
try {
53+
var content = fs.readFileSync(fullPath, 'utf8');
54+
result = JSON.parse(content);
55+
}
56+
catch (e) { }
57+
return result;
58+
};
59+
return GulpTask;
60+
})();
61+
exports.GulpTask = GulpTask;

lib/IBuildConfig.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export interface IBuildConfig {
2+
gulp?: any;
3+
rootPath?: string;
4+
libFolder?: string;
5+
libAMDFolder?: string;
6+
distFolder?: string;
7+
}
8+
export default IBuildConfig;

lib/ITask.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { IBuildConfig } from './IBuildConfig';
2+
export interface ITask {
3+
execute: (config: IBuildConfig) => Promise<any>;
4+
name?: string;
5+
}
6+
export default ITask;

0 commit comments

Comments
 (0)