Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit 00e08ef

Browse files
Transpile to ES6
Add support for ES6 transpilation. Change dependency injection in order to match the `class` and `constructor` keywords. Update istanbul to latest version as its previous versions do not support ES6. Remove bluebird.d.ts as it conflicts with Promises from TypeScript's ES6 d.ts. Remove bluebird as dependency - we will use native Promises from now on. Add support for Node.js 4 and 5 - both versions have limited support for ES6 features, so in order to support them we have to: - pass --harmony flag to Node.js - do not use some features like default values of method arguments. - do not use spread operator - it's implementation in Node.js 4 is limited only to arrays. Even this implementation has issues. So use `.apply` instead of using spread operator. Remove all other usages of spread operator (for objects). Add tests scripts for istanbul and mocha, as they both will need the `--harmony` flag as well, so we cannot execute them directly with Node.js 4 and 5. Instead we'll execute a custom script, that will start a new node process.
1 parent f07714f commit 00e08ef

29 files changed

+187
-803
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ node_modules
3434
coverage/**/*
3535
xunit.xml
3636
test-reports.xml
37+
!test-scripts/**

Gruntfile.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,7 @@ module.exports = function(grunt) {
3636
pkg: grunt.file.readJSON("package.json"),
3737

3838
ts: {
39-
options: {
40-
target: 'es5',
41-
module: 'commonjs',
42-
sourceMap: true,
43-
declaration: false,
44-
removeComments: false,
45-
noImplicitAny: true,
46-
experimentalDecorators: true,
47-
emitDecoratorMetadata: true
48-
},
39+
options: grunt.file.readJSON("tsconfig.json").compilerOptions,
4940

5041
devlib: {
5142
src: ["**/*.ts", "!node_modules/**/*.ts"],
@@ -124,7 +115,7 @@ module.exports = function(grunt) {
124115
},
125116

126117
clean: {
127-
src: ["test/**/*.js*", "**/*.js*", "!**/*.json", "!Gruntfile.js", "!node_modules/**/*", "!bin/common-lib.js", "!vendor/*.js", "*.tgz"]
118+
src: ["test/**/*.js*", "**/*.js*", "!**/*.json", "!Gruntfile.js", "!node_modules/**/*", "!bin/common-lib.js", "!vendor/*.js", "*.tgz", "!test-scripts/**/*"]
128119
}
129120
});
130121

appbuilder/services/npm-service.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ export class NpmService implements INpmService {
118118
}).future<void>()();
119119
}
120120

121-
public search(projectDir: string, keywords: string[], args: string[] = []): IFuture<IBasicPluginInformation[]> {
121+
public search(projectDir: string, keywords: string[], args?: string[]): IFuture<IBasicPluginInformation[]> {
122122
return ((): IBasicPluginInformation[] => {
123+
args = args === undefined ? [] : args;
123124
let result: IBasicPluginInformation[] = [];
124125
let commandArguments = _.concat(["search"], args, keywords);
125126
let spawnResult = this.executeNpmCommandCore(projectDir, commandArguments).wait();
@@ -296,7 +297,7 @@ export class NpmService implements INpmService {
296297
let defs = _.map(definitionFiles, def => this.getReferenceLine(fromWindowsRelativePathToUnix(path.relative(projectDir, def))));
297298

298299
this.$logger.trace(`Adding lines for definition files: ${definitionFiles.join(", ")}`);
299-
lines.push(...defs);
300+
lines = lines.concat(defs);
300301
}
301302
});
302303

@@ -320,7 +321,8 @@ export class NpmService implements INpmService {
320321
return `/// <reference path="${pathToReferencedFile}" />`;
321322
}
322323

323-
private getNpmArguments(command: string, npmArguments: string[] = []): string[] {
324+
private getNpmArguments(command: string, npmArguments?: string[]): string[] {
325+
npmArguments = npmArguments === undefined ? [] : npmArguments;
324326
return npmArguments.concat([command]);
325327
}
326328

codeGeneration/code-printer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ export class CodePrinter {
77
private static START_BLOCK_CHAR = "{";
88
private static END_BLOCK_CHAR = "}";
99

10-
public composeBlock(block: CodeGeneration.IBlock, indentSize: number = 0): string {
10+
public composeBlock(block: CodeGeneration.IBlock, indentSize?: number): string {
11+
indentSize = indentSize === undefined ? 0 : indentSize;
1112
let content = this.getIndentation(indentSize);
1213

1314
if(block.opener) {

decorators.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as Promise from "bluebird";
21
import * as fiberBootstrap from "./fiber-bootstrap";
32
import * as assert from "assert";
43
import {isFuture} from "./helpers";
@@ -47,6 +46,18 @@ export function exportedPromise(moduleName: string, postAction?: () => void): an
4746
}
4847

4948
function getPromise(originalValue: any, config?: { postActionMethod: () => void, shouldExecutePostAction?: boolean }): Promise<any> {
49+
let postAction = (data: any) => {
50+
if (config && config.postActionMethod && config.shouldExecutePostAction) {
51+
config.postActionMethod();
52+
}
53+
54+
if (data instanceof Error) {
55+
throw data;
56+
}
57+
58+
return data;
59+
};
60+
5061
return new Promise((onFulfilled: Function, onRejected: Function) => {
5162
if (isFuture(originalValue)) {
5263
fiberBootstrap.run(function () {
@@ -60,11 +71,7 @@ function getPromise(originalValue: any, config?: { postActionMethod: () => void,
6071
} else {
6172
onFulfilled(originalValue);
6273
}
63-
}).lastly(() => {
64-
if (config && config.postActionMethod && config.shouldExecutePostAction) {
65-
config.postActionMethod();
66-
}
67-
});
74+
}).then(postAction, postAction);
6875
}
6976

7077
export function exported(moduleName: string): any {

0 commit comments

Comments
 (0)