repackaging: all the repackaging changes squashed
This commit is contained in:
@ -1,42 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var glob = require('glob');
|
||||
var JasmineRunner = require('jasmine');
|
||||
var path = require('path');
|
||||
// require('es6-shim/es6-shim.js');
|
||||
require('zone.js/dist/zone-node.js');
|
||||
require('zone.js/dist/long-stack-trace-zone.js');
|
||||
require('zone.js/dist/async-test.js');
|
||||
require('zone.js/dist/fake-async-test.js');
|
||||
require('reflect-metadata/Reflect');
|
||||
|
||||
var jrunner = new JasmineRunner();
|
||||
|
||||
// Tun on full stack traces in errors to help debugging
|
||||
Error.stackTraceLimit = Infinity;
|
||||
|
||||
jrunner.jasmine.DEFAULT_TIMEOUT_INTERVAL = 100;
|
||||
|
||||
// Support passing multiple globs
|
||||
var globsIndex = process.argv.indexOf('--');
|
||||
var args;
|
||||
if (globsIndex < 0) {
|
||||
args = [process.argv[2]];
|
||||
} else {
|
||||
args = process.argv.slice(globsIndex + 1);
|
||||
}
|
||||
|
||||
var specFiles = args.map(function(globstr) { return glob.sync(globstr); })
|
||||
.reduce(function(specFiles, paths) { return specFiles.concat(paths); }, []);
|
||||
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 100;
|
||||
|
||||
jrunner.configureDefaultReporter({showColors: process.argv.indexOf('--no-color') === -1});
|
||||
|
||||
jrunner.onComplete(function(passed) { process.exit(passed ? 0 : 1); });
|
||||
jrunner.projectBaseDir = path.resolve(__dirname, '../../');
|
||||
jrunner.specDir = '';
|
||||
jrunner.addSpecFiles(specFiles);
|
||||
require('./test-cjs-main.js');
|
||||
require('zone.js/dist/jasmine-patch.js');
|
||||
jrunner.execute();
|
72
tools/cjs-jasmine/index.ts
Normal file
72
tools/cjs-jasmine/index.ts
Normal file
@ -0,0 +1,72 @@
|
||||
'use strict';
|
||||
|
||||
var glob = require('glob');
|
||||
var JasmineRunner = require('jasmine');
|
||||
var path = require('path');
|
||||
// require('es6-shim/es6-shim.js');
|
||||
require('zone.js/dist/zone-node.js');
|
||||
require('zone.js/dist/long-stack-trace-zone.js');
|
||||
require('zone.js/dist/async-test.js');
|
||||
require('zone.js/dist/fake-async-test.js');
|
||||
require('reflect-metadata/Reflect');
|
||||
|
||||
var jrunner = new JasmineRunner();
|
||||
var distAll = process.cwd() + '/dist/all';
|
||||
function distAllRequire(moduleId) {
|
||||
return require(path.join(distAll, moduleId));
|
||||
}
|
||||
|
||||
|
||||
// Tun on full stack traces in errors to help debugging
|
||||
Error['stackTraceLimit'] = Infinity;
|
||||
|
||||
jrunner.jasmine.DEFAULT_TIMEOUT_INTERVAL = 100;
|
||||
|
||||
// Support passing multiple globs
|
||||
var globsIndex = process.argv.indexOf('--');
|
||||
var args;
|
||||
if (globsIndex < 0) {
|
||||
args = [process.argv[2]];
|
||||
} else {
|
||||
args = process.argv.slice(globsIndex + 1);
|
||||
}
|
||||
|
||||
var specFiles = args.map(function(globstr) {
|
||||
return glob.sync(globstr, {
|
||||
cwd: distAll,
|
||||
ignore: [
|
||||
// the following code and tests are not compatible with CJS/node environment
|
||||
'@angular/platform-browser/**',
|
||||
'@angular/platform-browser-dynamic/**',
|
||||
'@angular/core/test/zone/**',
|
||||
'@angular/core/test/fake_async_spec.*',
|
||||
'@angular/common/test/forms/**',
|
||||
'@angular/router/test/route_config/route_config_spec.*',
|
||||
'@angular/router/test/integration/bootstrap_spec.*',
|
||||
'@angular/integration_test/symbol_inspector/**',
|
||||
'@angular/upgrade/**',
|
||||
'@angular/examples/**',
|
||||
'angular1_router/**',
|
||||
'payload_tests/**'
|
||||
]
|
||||
});
|
||||
}).reduce(function(specFiles, paths) {
|
||||
return specFiles.concat(paths);
|
||||
}, []);
|
||||
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 100;
|
||||
|
||||
jrunner.configureDefaultReporter({showColors: process.argv.indexOf('--no-color') === -1});
|
||||
|
||||
jrunner.onComplete(function(passed) { process.exit(passed ? 0 : 1); });
|
||||
jrunner.projectBaseDir = path.resolve(__dirname, '../../');
|
||||
jrunner.specDir = '';
|
||||
require('./test-cjs-main.js');
|
||||
require('zone.js/dist/jasmine-patch.js');
|
||||
distAllRequire('@angular/platform-server/src/parse5_adapter.js').Parse5DomAdapter.makeCurrent();
|
||||
specFiles.forEach((file) => {
|
||||
var r = distAllRequire(file);
|
||||
if (r.main) r.main();
|
||||
});
|
||||
jrunner.execute();
|
||||
|
@ -1,5 +0,0 @@
|
||||
var testingPlatformServer = require('../../dist/js/cjs/angular2/platform/testing/server.js');
|
||||
var testing = require('../../dist/js/cjs/angular2/testing.js');
|
||||
|
||||
testing.setBaseTestProviders(testingPlatformServer.TEST_SERVER_PLATFORM_PROVIDERS,
|
||||
testingPlatformServer.TEST_SERVER_APPLICATION_PROVIDERS);
|
5
tools/cjs-jasmine/test-cjs-main.ts
Normal file
5
tools/cjs-jasmine/test-cjs-main.ts
Normal file
@ -0,0 +1,5 @@
|
||||
var testingPlatformServer = require('../../all/@angular/platform-server/testing/server.js');
|
||||
var testing = require('../../all/@angular/core/testing');
|
||||
|
||||
testing.setBaseTestProviders(testingPlatformServer.TEST_SERVER_PLATFORM_PROVIDERS,
|
||||
testingPlatformServer.TEST_SERVER_APPLICATION_PROVIDERS);
|
29
tools/cjs-jasmine/tsconfig-output_emitter_codegen.json
Normal file
29
tools/cjs-jasmine/tsconfig-output_emitter_codegen.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"declaration": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "../../dist/all/@angular",
|
||||
"paths": {
|
||||
"@angular/core": ["../../dist/all/@angular/core/index.d.ts"],
|
||||
"@angular/core/*": ["../../dist/all/@angular/core/*"],
|
||||
"@angular/compiler/*": ["../../dist/all/@angular/compiler/*"]
|
||||
},
|
||||
"rootDir": "../../dist/all/@angular",
|
||||
"sourceMap": true,
|
||||
"sourceRoot": ".",
|
||||
"target": "es5"
|
||||
},
|
||||
"files": [
|
||||
"../../modules/@angular/typings/es6-collections/es6-collections.d.ts",
|
||||
"../../modules/@angular/typings/es6-promise/es6-promise.d.ts",
|
||||
"../../modules/@angular/typings/node/node.d.ts",
|
||||
"../../dist/all/@angular/compiler/test/output/output_emitter_codegen_typed.ts",
|
||||
"../../dist/all/@angular/compiler/test/output/output_emitter_codegen_untyped.ts",
|
||||
"../../dist/all/@angular/compiler/test/offline_compiler_codegen_untyped.ts",
|
||||
"../../dist/all/@angular/compiler/test/offline_compiler_codegen_typed.ts"
|
||||
]
|
||||
}
|
@ -5,20 +5,19 @@
|
||||
import * as ts from 'typescript';
|
||||
import * as path from 'path';
|
||||
|
||||
import * as compiler from 'angular2/compiler';
|
||||
import * as compiler from '@angular/compiler';
|
||||
import {StaticReflector} from './static_reflector';
|
||||
import {CompileMetadataResolver} from 'angular2/src/compiler/metadata_resolver';
|
||||
import {HtmlParser} from 'angular2/src/compiler/html_parser';
|
||||
import {DirectiveNormalizer} from 'angular2/src/compiler/directive_normalizer';
|
||||
import {Lexer} from 'angular2/src/compiler/expression_parser/lexer';
|
||||
import {Parser} from 'angular2/src/compiler/expression_parser/parser';
|
||||
import {TemplateParser} from 'angular2/src/compiler/template_parser';
|
||||
import {DomElementSchemaRegistry} from 'angular2/src/compiler/schema/dom_element_schema_registry';
|
||||
import {StyleCompiler} from 'angular2/src/compiler/style_compiler';
|
||||
import {ViewCompiler} from 'angular2/src/compiler/view_compiler/view_compiler';
|
||||
import {TypeScriptEmitter} from 'angular2/src/compiler/output/ts_emitter';
|
||||
import {RouterLinkTransform} from 'angular2/src/router/directives/router_link_transform';
|
||||
import {Parse5DomAdapter} from 'angular2/platform/server';
|
||||
import {CompileMetadataResolver} from '@angular/compiler/src/metadata_resolver';
|
||||
import {HtmlParser} from '@angular/compiler/src/html_parser';
|
||||
import {DirectiveNormalizer} from '@angular/compiler/src/directive_normalizer';
|
||||
import {Lexer} from '@angular/compiler/src/expression_parser/lexer';
|
||||
import {Parser} from '@angular/compiler/src/expression_parser/parser';
|
||||
import {TemplateParser} from '@angular/compiler/src/template_parser';
|
||||
import {DomElementSchemaRegistry} from '@angular/compiler/src/schema/dom_element_schema_registry';
|
||||
import {StyleCompiler} from '@angular/compiler/src/style_compiler';
|
||||
import {ViewCompiler} from '@angular/compiler/src/view_compiler/view_compiler';
|
||||
import {TypeScriptEmitter} from '@angular/compiler/src/output/ts_emitter';
|
||||
import {Parse5DomAdapter} from '@angular/platform-server';
|
||||
|
||||
import {MetadataCollector} from 'ts-metadata-collector';
|
||||
import {NodeReflectorHost} from './reflector_host';
|
||||
@ -125,7 +124,7 @@ export class CodeGenerator {
|
||||
const normalizer = new DirectiveNormalizer(xhr, urlResolver, htmlParser);
|
||||
const parser = new Parser(new Lexer());
|
||||
const tmplParser = new TemplateParser(parser, new DomElementSchemaRegistry(), htmlParser,
|
||||
/*console*/ null, [new RouterLinkTransform(parser)]);
|
||||
/*console*/ null, []);
|
||||
const offlineCompiler = new compiler.OfflineCompiler(
|
||||
normalizer, tmplParser, new StyleCompiler(urlResolver),
|
||||
new ViewCompiler(new compiler.CompilerConfig(true, true, true)), new TypeScriptEmitter());
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {StringMapWrapper, ListWrapper} from 'angular2/src/facade/collection';
|
||||
import {StringMapWrapper, ListWrapper} from '@angular/facade/src/collection';
|
||||
import {
|
||||
isArray,
|
||||
isPresent,
|
||||
@ -6,7 +6,7 @@ import {
|
||||
isPrimitive,
|
||||
isStringMap,
|
||||
FunctionWrapper
|
||||
} from 'angular2/src/facade/lang';
|
||||
} from '@angular/facade/src/lang';
|
||||
import {
|
||||
AttributeMetadata,
|
||||
DirectiveMetadata,
|
||||
@ -22,10 +22,10 @@ import {
|
||||
ViewChildrenMetadata,
|
||||
ViewQueryMetadata,
|
||||
QueryMetadata,
|
||||
} from 'angular2/src/core/metadata';
|
||||
import {ReflectorReader} from 'angular2/src/core/reflection/reflector_reader';
|
||||
import {reflector} from 'angular2/src/core/reflection/reflection';
|
||||
import {Provider} from 'angular2/src/core/di/provider';
|
||||
} from '@angular/core';
|
||||
import {ReflectorReader} from '@angular/core/src/reflection/reflector_reader';
|
||||
import {reflector} from '@angular/core';
|
||||
import {Provider} from '@angular/core';
|
||||
import {
|
||||
HostMetadata,
|
||||
OptionalMetadata,
|
||||
@ -33,7 +33,7 @@ import {
|
||||
SelfMetadata,
|
||||
SkipSelfMetadata,
|
||||
InjectMetadata,
|
||||
} from "angular2/src/core/di/metadata";
|
||||
} from "@angular/core";
|
||||
|
||||
/**
|
||||
* The host of the static resolver is expected to be able to provide module metadata in the form of
|
||||
|
@ -1,8 +1,8 @@
|
||||
/// <reference path="../../typings/jasmine/jasmine.d.ts" />
|
||||
|
||||
import {describe, it, iit, expect, ddescribe, beforeEach} from 'angular2/testing_internal';
|
||||
import {isBlank} from 'angular2/src/facade/lang';
|
||||
import {ListWrapper} from 'angular2/src/facade/collection';
|
||||
import {describe, it, iit, expect, ddescribe, beforeEach} from '@angular/core/testing/testing_internal';
|
||||
import {isBlank} from '@angular/facade/src/lang';
|
||||
import {ListWrapper} from '@angular/facade/src/collection';
|
||||
|
||||
import {StaticReflector, StaticReflectorHost, StaticSymbol} from './static_reflector';
|
||||
|
||||
|
@ -7,7 +7,8 @@
|
||||
"sourceMap": true,
|
||||
"baseUrl": "../../..",
|
||||
"paths": {
|
||||
"angular2/*": ["dist/js/cjs/angular2/*"],
|
||||
"@angular/*": ["dist/all/@angular/*"],
|
||||
"@angular/core": ["dist/all/@angular/core/"],
|
||||
"ts-metadata-collector": ["dist/tools/metadata"]
|
||||
},
|
||||
"experimentalDecorators": true,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Component} from 'angular2/core';
|
||||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'my-comp',
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {Component, Inject} from 'angular2/core';
|
||||
import {FORM_DIRECTIVES} from 'angular2/common';
|
||||
import {Component, Inject} from '@angular/core';
|
||||
import {FORM_DIRECTIVES} from '@angular/common';
|
||||
import {MyComp} from './a/multiple_components';
|
||||
|
||||
@Component({selector: 'basic', templateUrl: './basic.html', directives: [MyComp, FORM_DIRECTIVES]})
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {coreBootstrap, ReflectiveInjector} from 'angular2/core';
|
||||
import {browserPlatform, BROWSER_APP_PROVIDERS} from 'angular2/platform/browser';
|
||||
import {coreBootstrap, ReflectiveInjector} from '@angular/core';
|
||||
import {browserPlatform, BROWSER_APP_PROVIDERS} from '@angular/platform-browser';
|
||||
import {BasicNgFactory} from './basic.ngfactory';
|
||||
import {Basic} from './basic';
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {Component, Inject, OpaqueToken} from 'angular2/core';
|
||||
import {NgIf} from 'angular2/common';
|
||||
import {Component, Inject, OpaqueToken} from '@angular/core';
|
||||
import {NgIf} from '@angular/common';
|
||||
|
||||
export const SOME_OPAQUE_TOKEN = new OpaqueToken('opaqueToken');
|
||||
|
||||
|
@ -19,7 +19,8 @@
|
||||
*/
|
||||
"baseUrl": "../../..",
|
||||
"paths": {
|
||||
"angular2/*": ["dist/js/cjs/angular2/*"],
|
||||
"@angular/*": ["dist/all/@angular/*"],
|
||||
"@angular/core": ["dist/all/@angular/core/"],
|
||||
"rxjs/*": ["node_modules/rxjs/*"],
|
||||
"ts-metadata-collector": ["dist/tools/metadata"]
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ var createErrorFormatter = function (basePath, emitter, SourceMapConsumer) {
|
||||
});
|
||||
return process.cwd() + "/modules/" + original.source + ":" + original.line + ":" + original.column;
|
||||
} catch (e) {
|
||||
log.warn('SourceMap position not found for trace: %s', msg);
|
||||
console.warn('SourceMap position not found for trace: %s', msg);
|
||||
}
|
||||
}
|
||||
return path + ':' + line + ':' + column;
|
||||
@ -56,4 +56,4 @@ var InternalAngularReporter = function (config, emitter) {
|
||||
}
|
||||
InternalAngularReporter.$inject = ['config', 'emitter']
|
||||
|
||||
module.exports = {'reporter:internal-angular': ['type', InternalAngularReporter]};
|
||||
module.exports = {'reporter:internal-angular': ['type', InternalAngularReporter]};
|
||||
|
@ -4,7 +4,13 @@ var checkNpm = require('./check-node-modules.js');
|
||||
|
||||
var purgeIfStale = (process.argv.indexOf('--purge') !== -1);
|
||||
|
||||
if (process.env.TRAVIS && !purgeIfStale) {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
// check-node-modules will exit(1) if we don't need to install to short-circuit `npm install`
|
||||
// see .travis.yml's `install` block to see the reason for this
|
||||
process.exit(checkNpm(true, purgeIfStale) ? 1 : 0);
|
||||
var nodeModulesOK = checkNpm(true, purgeIfStale);
|
||||
|
||||
process.exit( nodeModulesOK || purgeIfStale ? 0 : 1);
|
||||
|
||||
|
@ -109,12 +109,30 @@ const CORE = [
|
||||
'ContentChildrenMetadata.constructor(_selector:Type|string, {descendants=false,read=null}:{descendants?:boolean, read?:any})',
|
||||
'CyclicDependencyError',
|
||||
'CyclicDependencyError.constructor(injector:ReflectiveInjector, key:ReflectiveKey)',
|
||||
'DefaultIterableDiffer',
|
||||
'DefaultIterableDiffer.check(collection:any):boolean',
|
||||
'DefaultIterableDiffer.collection:any',
|
||||
'DefaultIterableDiffer.constructor(_trackByFn:TrackByFn)',
|
||||
'DefaultIterableDiffer.diff(collection:any):DefaultIterableDiffer',
|
||||
'DefaultIterableDiffer.forEachAddedItem(fn:Function):any',
|
||||
'DefaultIterableDiffer.forEachIdentityChange(fn:Function):any',
|
||||
'DefaultIterableDiffer.forEachItem(fn:Function):any',
|
||||
'DefaultIterableDiffer.forEachMovedItem(fn:Function):any',
|
||||
'DefaultIterableDiffer.forEachPreviousItem(fn:Function):any',
|
||||
'DefaultIterableDiffer.forEachRemovedItem(fn:Function):any',
|
||||
'DefaultIterableDiffer.isDirty:boolean',
|
||||
'DefaultIterableDiffer.length:number',
|
||||
'DefaultIterableDiffer.onDestroy():any',
|
||||
'DefaultIterableDiffer.toString():string',
|
||||
'WtfScopeFn',
|
||||
'DebugNode',
|
||||
'DebugNode.componentInstance:any',
|
||||
'DebugNode.constructor(nativeNode:any, parent:DebugNode, _debugInfo:RenderDebugInfo)',
|
||||
'DebugNode.getLocal(name:string):any',
|
||||
'DebugNode.inject(token:any):any',
|
||||
'DebugNode.injector:Injector',
|
||||
'DebugNode.listeners:EventListener[]',
|
||||
'DebugNode.locals:{[key:string]:any}',
|
||||
'DebugNode.nativeNode:any',
|
||||
'DebugNode.parent:DebugElement',
|
||||
'DebugNode.providerTokens:any[]',
|
||||
@ -1076,7 +1094,7 @@ const INSTRUMENTATION = [
|
||||
|
||||
const UPGRADE = [
|
||||
'UpgradeAdapter',
|
||||
'UpgradeAdapter.addProvider(provider:Type|Provider|any[]):void',
|
||||
'UpgradeAdapter.addProvider(provider:Type|{[k:string]:any}|any[]):void',
|
||||
'UpgradeAdapter.bootstrap(element:Element, modules:any[], config:IAngularBootstrapConfig):UpgradeAdapterRef',
|
||||
'UpgradeAdapter.downgradeNg2Component(type:Type):Function',
|
||||
'UpgradeAdapter.downgradeNg2Provider(token:any):Function',
|
||||
@ -1209,7 +1227,7 @@ const BROWSER = [
|
||||
'Title.getTitle():string',
|
||||
'Title.setTitle(newTitle:string):any',
|
||||
'bootstrapStatic(appComponentType:Type, customProviders:Array<any>, initReflector:Function):Promise<ComponentRef<any>>',
|
||||
'const BROWSER_APP_PROVIDERS:Array<any>',
|
||||
'const BROWSER_APP_DYNAMIC_PROVIDERS:Array<any>',
|
||||
'const BROWSER_PROVIDERS:Array<any>',
|
||||
'const ELEMENT_PROBE_PROVIDERS:any[]',
|
||||
'const ELEMENT_PROBE_PROVIDERS_PROD_MODE:any[]',
|
||||
@ -1220,24 +1238,29 @@ const BROWSER = [
|
||||
];
|
||||
|
||||
describe('public API', () => {
|
||||
it("should check core.ts", () => { checkPublicApi("modules/angular2/core.ts", CORE); });
|
||||
it("should check common.ts", () => { checkPublicApi("modules/angular2/common.ts", COMMON); });
|
||||
it("should check compiler.ts",
|
||||
() => { checkPublicApi("modules/angular2/compiler.ts", COMPILER); });
|
||||
it("should check instrumentation.ts",
|
||||
() => { checkPublicApi("modules/angular2/instrumentation.ts", INSTRUMENTATION); });
|
||||
it("should check upgrade.ts", () => { checkPublicApi("modules/angular2/upgrade.ts", UPGRADE); });
|
||||
it("should check browser.ts",
|
||||
() => { checkPublicApi("modules/angular2/platform/browser_static.ts", BROWSER); });
|
||||
check("@angular/core", CORE);
|
||||
// check("@angular/common", COMMON);
|
||||
// check("@angular/compiler", COMPILER);
|
||||
// check("@angular/instrumentation.ts", INSTRUMENTATION);
|
||||
// check("@angular/upgrade", UPGRADE);
|
||||
// check("@angular/platform-browser-static", BROWSER);
|
||||
});
|
||||
|
||||
function check(file: string, expected: string[]) {
|
||||
it('should check' + file, () => checkPublicApi(file, expected));
|
||||
}
|
||||
|
||||
function checkPublicApi(file: string, expected: string[]) {
|
||||
const sortedActual = publicApi(file).sort();
|
||||
const sortedActual = publicApi('modules/' + file + '/index.ts').sort();
|
||||
const sortedExpected = expected.sort();
|
||||
const missing = sortedActual.filter((i) => sortedExpected.indexOf(i) < 0);
|
||||
const extra = sortedExpected.filter((i) => sortedActual.indexOf(i) < 0);
|
||||
|
||||
if (missing.length > 0) {
|
||||
console.log('=================================================================');
|
||||
console.log('=================================================================');
|
||||
console.log('=================================================================');
|
||||
console.log('=================================================================');
|
||||
console.log("Missing:");
|
||||
missing.forEach((m) => console.log(m));
|
||||
}
|
||||
|
84
tools/tsc-watch/index.ts
Normal file
84
tools/tsc-watch/index.ts
Normal file
@ -0,0 +1,84 @@
|
||||
import {spawn} from 'child_process';
|
||||
import {TscWatch, TSC, reportError} from './tsc_watch';
|
||||
import {writeFileSync, mkdirSync, existsSync} from 'fs';
|
||||
export * from './tsc_watch';
|
||||
import 'reflect-metadata';
|
||||
|
||||
const OFFLINE_COMPILE = [
|
||||
'output/output_emitter_codegen_untyped',
|
||||
'output/output_emitter_codegen_typed',
|
||||
'offline_compiler_codegen_untyped',
|
||||
'offline_compiler_codegen_typed'
|
||||
]
|
||||
|
||||
function processOutputEmitterCodeGen():Promise<number> {
|
||||
return new Promise((resolve, reject) => {
|
||||
var outDir = 'dist/all/@angular/compiler/test/';
|
||||
var promises = [];
|
||||
console.log('Processing codegen...');
|
||||
OFFLINE_COMPILE.forEach((file: string) => {
|
||||
var codegen = require('../../all/@angular/compiler/test/' + file + '.js');
|
||||
if (codegen.emit) {
|
||||
console.log(` ${file} has changed, regenerating...`);
|
||||
promises.push(Promise.resolve(codegen.emit()).then((code) => {
|
||||
writeFileSync(outDir + file + '.ts', code);
|
||||
}));
|
||||
}
|
||||
});
|
||||
if (promises.length) {
|
||||
Promise.all(promises).then(() => {
|
||||
var args = ['--project', 'tools/cjs-jasmine/tsconfig-output_emitter_codegen.json'];
|
||||
console.log(' compiling changes: tsc ' + args.join(' '));
|
||||
var tsc = spawn(TSC, args, {stdio: 'pipe'});
|
||||
tsc.stdout.on('data', (data) => process.stdout.write(data));
|
||||
tsc.stderr.on('data', (data) => process.stderr.write(data));
|
||||
tsc.on('close', (code) => code ? reject('Tsc exited with: ' + code) : resolve(code));
|
||||
}).catch(reportError);
|
||||
} else {
|
||||
resolve(0);
|
||||
}
|
||||
}).catch(reportError);
|
||||
}
|
||||
|
||||
function md(dir: string, folders: string[]) {
|
||||
if (folders.length) {
|
||||
var next = folders.shift();
|
||||
var path = dir + '/' + next;
|
||||
if (!existsSync(path)) {
|
||||
mkdirSync(path);
|
||||
}
|
||||
md(path, folders);
|
||||
}
|
||||
}
|
||||
|
||||
var tscWatch: TscWatch = null;
|
||||
var platform = process.argv.length >= 3 ? process.argv[2] : null;
|
||||
var watch: boolean = process.argv.length >= 4 ? !!process.argv[3] : false;
|
||||
|
||||
if (platform == 'node') {
|
||||
tscWatch = new TscWatch({
|
||||
tsconfig: 'modules/tsconfig.json',
|
||||
start: 'File change detected. Starting incremental compilation...',
|
||||
error: 'error',
|
||||
complete: 'Compilation complete. Watching for file changes.',
|
||||
onChangeCmds: [
|
||||
processOutputEmitterCodeGen,
|
||||
['node', 'dist/tools/cjs-jasmine', '--', '{@angular,benchpress}/**/*_spec.js']
|
||||
]
|
||||
});
|
||||
} else if (platform == 'browser') {
|
||||
tscWatch = new TscWatch({
|
||||
tsconfig: 'modules/tsconfig.json',
|
||||
start: 'File change detected. Starting incremental compilation...',
|
||||
error: 'error',
|
||||
complete: 'Compilation complete. Watching for file changes.',
|
||||
onStartCmds: [
|
||||
['node', 'node_modules/karma/bin/karma', 'start', '--no-auto-watch', 'karma-js.conf.js']
|
||||
],
|
||||
onChangeCmds: [
|
||||
['node', 'node_modules/karma/bin/karma', 'run', 'karma-js.conf.js']
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
watch ? tscWatch.watch() : tscWatch.run();
|
157
tools/tsc-watch/tsc_watch.ts
Normal file
157
tools/tsc-watch/tsc_watch.ts
Normal file
@ -0,0 +1,157 @@
|
||||
import {spawn} from 'child_process';
|
||||
import {resolve} from 'url';
|
||||
|
||||
enum State {
|
||||
idle, waiting, error
|
||||
}
|
||||
|
||||
export const TSC = 'node_modules/typescript/bin/tsc';
|
||||
export type Command = (stdIn, stdErr) => Promise<number>;
|
||||
|
||||
export class TscWatch {
|
||||
private tsconfig:string;
|
||||
private start:string|RegExp;
|
||||
private error:string|RegExp;
|
||||
private complete:string|RegExp;
|
||||
private onStartCmds:Array<string[]|Command>;
|
||||
private onChangeCmds:Array<string[]|Command>;
|
||||
private state:State;
|
||||
private triggered:Promise<number> = null;
|
||||
private runOnce: boolean = false;
|
||||
|
||||
constructor({tsconfig, start, error, complete, onStartCmds=null, onChangeCmds=null}:
|
||||
{tsconfig:string, error:string|RegExp, start:string, complete:string,
|
||||
onStartCmds?:Array<string[]|Command>, onChangeCmds?:Array<string[]|Command>})
|
||||
{
|
||||
console.log('Watching:', tsconfig, 'in', process.cwd());
|
||||
this.tsconfig = tsconfig;
|
||||
this.start = start;
|
||||
this.error = error;
|
||||
this.complete = complete;
|
||||
this.onStartCmds = onStartCmds || [];
|
||||
this.onChangeCmds = onChangeCmds || [];
|
||||
}
|
||||
|
||||
watch() {
|
||||
var args = [TSC, '--project', this.tsconfig];
|
||||
if (!this.runOnce) args.push('--watch');
|
||||
var tsc = this.runCmd(args, {}, (d) => this.consumeLine(d, false), (d) => this.consumeLine(d, true));
|
||||
if (this.runOnce) {
|
||||
tsc.then(() => this.triggerCmds(), code => process.exit(code));
|
||||
}
|
||||
this.state = State.waiting;
|
||||
this.onStartCmds.forEach((cmd) => this.runCmd(cmd, () => null, () => null));
|
||||
}
|
||||
|
||||
private runCmd(argsOrCmd: string[]|Command, env?,
|
||||
stdOut = pipeStdOut, stdErr = pipeStdErr):Promise<number>
|
||||
{
|
||||
if (typeof argsOrCmd == 'function') {
|
||||
return (argsOrCmd as Command)(stdErr, stdOut);
|
||||
} else if (argsOrCmd instanceof Array) {
|
||||
var args = argsOrCmd as Array<string>;
|
||||
return <any>new Promise((resolve, reject) => {
|
||||
var [cmd, ...options] = args;
|
||||
console.log('=====>', cmd, options.join(' '));
|
||||
var childProcess = spawn(cmd, options, {stdio: 'pipe'});
|
||||
childProcess.stdout.on('data', stdOut);
|
||||
childProcess.stderr.on('data', stdErr);
|
||||
var onExit = () => childProcess.kill();
|
||||
childProcess.on('close', (code: number) => {
|
||||
process.removeListener('exit', onExit);
|
||||
console.log('EXIT:', code, '<=====', args.join(' '));
|
||||
code ? reject(code) : resolve(code);
|
||||
});
|
||||
process.on('exit', onExit);
|
||||
}).catch(reportError);
|
||||
} else {
|
||||
throw new Error('Expecting function or an array of strings...');
|
||||
}
|
||||
}
|
||||
|
||||
run() {
|
||||
this.runOnce = true;
|
||||
this.watch();
|
||||
}
|
||||
|
||||
consumeLine(buffer:Buffer, isStdError:boolean) {
|
||||
var line = '' + buffer;
|
||||
if (contains(line, this.start)) {
|
||||
console.log('==============================================================================');
|
||||
stdOut(buffer, isStdError);
|
||||
this.state = State.waiting;
|
||||
} else if (contains(line, this.error)) {
|
||||
stdOut(buffer, isStdError);
|
||||
this.state = State.error;
|
||||
} else if (contains(line, this.complete)) {
|
||||
stdOut(buffer, isStdError);
|
||||
console.log('------------------------------------------------------------------------------');
|
||||
if (this.state == State.error) {
|
||||
console.log('Errors found.... (response not triggered)');
|
||||
if (this.runOnce) process.exit(1);
|
||||
this.state = State.idle;
|
||||
} else {
|
||||
if (this.triggered) {
|
||||
this.triggered.then(() => this.triggerCmds(), (e) => {console.log("Error while running commands....", e)});
|
||||
} else {
|
||||
this.triggerCmds();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
stdOut(buffer, isStdError);
|
||||
}
|
||||
}
|
||||
|
||||
triggerCmds() {
|
||||
var cmdPromise:Promise<number> = Promise.resolve();
|
||||
this.onChangeCmds.forEach((cmd:string[]|Command) => {
|
||||
cmdPromise = cmdPromise.then(() => {
|
||||
return this.runCmd(<string[]>cmd);
|
||||
})
|
||||
});
|
||||
cmdPromise.then(() => this.triggered = null, (code) => {
|
||||
if (this.runOnce) {
|
||||
if (typeof code != 'number') {
|
||||
console.error('Error occurred while executing commands', code);
|
||||
process.exit(1);
|
||||
}
|
||||
process.exit(code);
|
||||
} else {
|
||||
this.triggered = null;
|
||||
}
|
||||
});
|
||||
this.triggered = cmdPromise;
|
||||
}
|
||||
}
|
||||
|
||||
function stdOut(data:Buffer, isStdError:boolean) {
|
||||
if (isStdError) {
|
||||
process.stderr.write(data);
|
||||
} else {
|
||||
process.stdout.write(data);
|
||||
}
|
||||
}
|
||||
|
||||
function contains(line: string, text: string| RegExp): boolean {
|
||||
if (typeof text == 'string') {
|
||||
return line.indexOf(text as string) != -1;
|
||||
} else if (text instanceof RegExp) {
|
||||
return (text as RegExp).test(line);
|
||||
} else {
|
||||
throw new Error('Unknown: ' + text);
|
||||
}
|
||||
}
|
||||
|
||||
export function reportError(e) {
|
||||
if (e.message && e.stack) {
|
||||
console.error(e.message);
|
||||
console.error(e.stack);
|
||||
} else {
|
||||
console.error(e);
|
||||
}
|
||||
// process.exit(1);
|
||||
return Promise.reject(e);
|
||||
}
|
||||
|
||||
function pipeStdOut(d) { process.stdout.write(d); }
|
||||
function pipeStdErr(d) { process.stderr.write(d); }
|
@ -1,13 +1,21 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"noImplicitAny": false,
|
||||
"outDir": "../dist/tools",
|
||||
"rootDir": ".",
|
||||
"sourceMap": false
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"declaration": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "../dist/tools/",
|
||||
"paths": {
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
"rootDir": ".",
|
||||
"sourceMap": true,
|
||||
"inlineSources": true,
|
||||
"target": "es5"
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"compiler_cli"
|
||||
]
|
||||
}
|
||||
|
Reference in New Issue
Block a user