From f4d94a7f8562d1be16d6f4c915e9ec69df400804 Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Wed, 14 Dec 2016 20:46:25 -0800 Subject: [PATCH 01/10] . --- package.json | 8 +- packages/@ngtools/webpack/src/plugin.ts | 284 +++++------------- .../models/webpack-build-typescript.ts | 8 + tests/e2e/setup/010-build.ts | 35 ++- tests/e2e/setup/500-create-project.ts | 31 +- tests/e2e/utils/project.ts | 31 +- tests/e2e_runner.js | 4 +- 7 files changed, 161 insertions(+), 240 deletions(-) diff --git a/package.json b/package.json index f63207cd1da4..55e569703698 100644 --- a/package.json +++ b/package.json @@ -42,10 +42,10 @@ "homepage": "https://github.com/angular/angular-cli", "dependencies": { "@angular-cli/ast-tools": "^1.0.0", - "@angular/compiler": "2.2.3", - "@angular/compiler-cli": "2.2.3", - "@angular/core": "2.2.3", - "@angular/tsc-wrapped": "0.4.0", + "@angular/compiler": "~2.3.1", + "@angular/compiler-cli": "~2.3.1", + "@angular/core": "~2.3.1", + "@angular/tsc-wrapped": "~0.5.0", "async": "^2.1.4", "autoprefixer": "^6.5.3", "chalk": "^1.1.3", diff --git a/packages/@ngtools/webpack/src/plugin.ts b/packages/@ngtools/webpack/src/plugin.ts index bedf13c604b6..58331b890c51 100644 --- a/packages/@ngtools/webpack/src/plugin.ts +++ b/packages/@ngtools/webpack/src/plugin.ts @@ -2,11 +2,9 @@ import * as fs from 'fs'; import * as path from 'path'; import * as ts from 'typescript'; -import {NgModule} from '@angular/core'; -import * as ngCompiler from '@angular/compiler-cli'; -import {tsc} from '@angular/tsc-wrapped/src/tsc'; +import {__NGTOOLS_PRIVATE_API_2} from '@angular/compiler-cli'; +import {AngularCompilerOptions} from '@angular/tsc-wrapped'; -import {patchReflectorHost} from './reflector_host'; import {WebpackResourceLoader} from './resource_loader'; import {createResolveDependenciesFromContextMap} from './utils'; import {WebpackCompilerHost} from './compiler_host'; @@ -29,47 +27,22 @@ export interface AotPluginOptions { i18nFile?: string; i18nFormat?: string; locale?: string; -} - -export interface LazyRoute { - moduleRoute: ModuleRoute; - absolutePath: string; - absoluteGenDirPath: string; -} - - -export interface LazyRouteMap { - [path: string]: LazyRoute; -} - - -export class ModuleRoute { - constructor(public readonly path: string, public readonly className: string = null) {} - - toString() { - return `${this.path}#${this.className}`; - } - - static fromString(entry: string): ModuleRoute { - const split = entry.split('#'); - return new ModuleRoute(split[0], split[1]); - } + // We do not have an include because tsconfig can be used for that. + exclude?: string | string[]; } export class AotPlugin implements Tapable { - private _entryModule: ModuleRoute; private _compilerOptions: ts.CompilerOptions; - private _angularCompilerOptions: ngCompiler.AngularCompilerOptions; + private _angularCompilerOptions: AngularCompilerOptions; private _program: ts.Program; - private _reflector: ngCompiler.StaticReflector; - private _reflectorHost: ngCompiler.ReflectorHost; private _rootFilePath: string[]; private _compilerHost: WebpackCompilerHost; private _resourceLoader: WebpackResourceLoader; private _lazyRoutes: { [route: string]: string }; private _tsConfigPath: string; + private _entryModule: string; private _donePromise: Promise; private _compiler: any = null; @@ -93,7 +66,12 @@ export class AotPlugin implements Tapable { get compilerHost() { return this._compilerHost; } get compilerOptions() { return this._compilerOptions; } get done() { return this._donePromise; } - get entryModule() { return this._entryModule; } + get entryModule() { + const splitted = this._entryModule.split('#'); + const path = splitted[0]; + const className = splitted[1] || 'default'; + return {path, className}; + } get genDir() { return this._genDir; } get program() { return this._program; } get skipCodeGeneration() { return this._skipCodeGeneration; } @@ -119,19 +97,52 @@ export class AotPlugin implements Tapable { basePath = path.resolve(process.cwd(), options.basePath); } - const tsConfig = tsc.readConfiguration(this._tsConfigPath, basePath); - this._rootFilePath = tsConfig.parsed.fileNames - .filter(fileName => !/\.spec\.ts$/.test(fileName)); + let tsConfigJson: any = null; + try { + tsConfigJson = JSON.parse(fs.readFileSync(this._tsConfigPath, 'utf8')); + } catch (err) { + throw new Error(`An error happened while parsing ${this._tsConfigPath} JSON: ${err}.`); + } + const tsConfig = ts.parseJsonConfigFileContent( + tsConfigJson, ts.sys, basePath, null, this._tsConfigPath); + + let fileNames = tsConfig.fileNames; + if (options.hasOwnProperty('exclude')) { + let exclude: string[] = typeof options.exclude == 'string' + ? [options.exclude as string] : (options.exclude as string[]); + + exclude.forEach((pattern: string) => { + pattern = pattern + // Replace characters that are used normally in regexes, except stars. + .replace(/[\-\[\]\/{}()+?.\\^$|]/g, '\\$&') + // Two stars replacement. + .replace(/\*\*/g, '(?:.*)') + .replace(/\*/g, '(?:[^/]*)') + .replace(/^/, `(${basePath})?`); + + const re = new RegExp('^' + pattern + '$'); + fileNames = fileNames.filter(x => !x.match(re)); + }) + } else { + fileNames = fileNames.filter(fileName => !/\.spec\.ts$/.test(fileName)); + } + this._rootFilePath = fileNames; // Check the genDir. let genDir = basePath; - if (tsConfig.ngOptions.hasOwnProperty('genDir')) { - genDir = tsConfig.ngOptions.genDir; - } - this._compilerOptions = tsConfig.parsed.options; + this._compilerOptions = tsConfig.options; + this._angularCompilerOptions = Object.assign( + { genDir }, + this._compilerOptions, + tsConfig.raw['angularCompilerOptions'], + { basePath } + ); + + if (this._angularCompilerOptions.hasOwnProperty('genDir')) { + genDir = this._angularCompilerOptions.genDir; + } - this._angularCompilerOptions = Object.assign({}, tsConfig.ngOptions, { basePath, genDir }); this._basePath = basePath; this._genDir = genDir; @@ -147,21 +158,16 @@ export class AotPlugin implements Tapable { this._rootFilePath, this._compilerOptions, this._compilerHost); if (options.entryModule) { - this._entryModule = ModuleRoute.fromString(options.entryModule); + this._entryModule = options.entryModule; } else { if (options.mainPath) { - const entryModuleString = resolveEntryModuleFromMain(options.mainPath, this._compilerHost, + this._entryModule = resolveEntryModuleFromMain(options.mainPath, this._compilerHost, this._program); - this._entryModule = ModuleRoute.fromString(entryModuleString); } else { - this._entryModule = ModuleRoute.fromString((tsConfig.ngOptions as any).entryModule); + this._entryModule = (tsConfig.raw['angularCompilerOptions'] as any).entryModule; } } - this._reflectorHost = new ngCompiler.ReflectorHost( - this._program, this._compilerHost, this._angularCompilerOptions); - this._reflector = new ngCompiler.StaticReflector(this._reflectorHost); - if (options.hasOwnProperty('i18nFile')) { this._i18nFile = options.i18nFile; } @@ -253,20 +259,18 @@ export class AotPlugin implements Tapable { } // Create the Code Generator. - const codeGenerator = ngCompiler.CodeGenerator.create( - this._angularCompilerOptions, - i18nOptions, - this._program, - this._compilerHost, - new ngCompiler.NodeReflectorHostContext(this._compilerHost), - this._resourceLoader - ); - - // We need to temporarily patch the CodeGenerator until either it's patched or allows us - // to pass in our own ReflectorHost. - // TODO: remove this. - patchReflectorHost(codeGenerator); - return codeGenerator.codegen({ transitiveModules: true }); + return __NGTOOLS_PRIVATE_API_2.codeGen({ + basePath: this._basePath, + compilerOptions: this._compilerOptions, + program: this._program, + host: this._compilerHost, + angularCompilerOptions: this._angularCompilerOptions, + i18nFormat: null, + i18nFile: null, + locale: null, + + readResource: (path: string) => this._resourceLoader.get(path) + }); }) .then(() => { // Create a new Program, based on the old one. This will trigger a resolution of all @@ -298,155 +302,25 @@ export class AotPlugin implements Tapable { .then(() => { // Process the lazy routes this._lazyRoutes = {}; - const allLazyRoutes = this._processNgModule(this._entryModule, null); + const allLazyRoutes = __NGTOOLS_PRIVATE_API_2.listLazyRoutes({ + program: this._program, + host: this._compilerHost, + angularCompilerOptions: this._angularCompilerOptions, + entryModule: this._entryModule.toString() + }); Object.keys(allLazyRoutes) .forEach(k => { const lazyRoute = allLazyRoutes[k]; if (this.skipCodeGeneration) { - this._lazyRoutes[k] = lazyRoute.absolutePath + '.ts'; + this._lazyRoutes[k] = lazyRoute; } else { - this._lazyRoutes[k + '.ngfactory'] = lazyRoute.absoluteGenDirPath + '.ngfactory.ts'; + const lr = path.relative(this.basePath, lazyRoute.replace(/\.ts$/, '.ngfactory.ts')); + this._lazyRoutes[k + '.ngfactory'] = path.join(this.genDir, lr); } }); }) - .then(() => cb(), (err: any) => { cb(err); }); - } - - private _resolveModulePath(module: ModuleRoute, containingFile: string) { - if (module.path.startsWith('.')) { - return path.join(path.dirname(containingFile), module.path); - } - return module.path; - } - - private _processNgModule(module: ModuleRoute, containingFile: string | null): LazyRouteMap { - const modulePath = containingFile ? module.path : ('./' + path.basename(module.path)); - if (containingFile === null) { - containingFile = module.path + '.ts'; - } - const relativeModulePath = this._resolveModulePath(module, containingFile); - - const staticSymbol = this._reflectorHost - .findDeclaration(modulePath, module.className, containingFile); - const entryNgModuleMetadata = this.getNgModuleMetadata(staticSymbol); - const loadChildrenRoute: LazyRoute[] = this.extractLoadChildren(entryNgModuleMetadata) - .map(route => { - const moduleRoute = ModuleRoute.fromString(route); - const resolvedModule = ts.resolveModuleName(moduleRoute.path, - relativeModulePath, this._compilerOptions, this._compilerHost); - - if (!resolvedModule.resolvedModule) { - throw new Error(`Could not resolve route "${route}" from file "${relativeModulePath}".`); - } - - const relativePath = path.relative(this.basePath, - resolvedModule.resolvedModule.resolvedFileName).replace(/\.ts$/, ''); - - const absolutePath = path.join(this.basePath, relativePath); - const absoluteGenDirPath = path.join(this._genDir, relativePath); - - return { - moduleRoute, - absoluteGenDirPath, - absolutePath - }; + .then(() => cb(), (err: any) => { + compilation.errors.push(err); }); - const resultMap: LazyRouteMap = loadChildrenRoute - .reduce((acc: LazyRouteMap, curr: LazyRoute) => { - const key = curr.moduleRoute.path; - if (acc[key]) { - if (acc[key].absolutePath != curr.absolutePath) { - throw new Error(`Duplicated path in loadChildren detected: "${key}" is used in 2 ` + - 'loadChildren, but they point to different modules. Webpack cannot distinguish ' + - 'between the two based on context and would fail to load the proper one.'); - } - } else { - acc[key] = curr; - } - return acc; - }, {}); - - // Also concatenate every child of child modules. - for (const lazyRoute of loadChildrenRoute) { - const mr = lazyRoute.moduleRoute; - const children = this._processNgModule(mr, relativeModulePath); - Object.keys(children).forEach(p => { - const child = children[p]; - const key = child.moduleRoute.path; - if (resultMap[key]) { - if (resultMap[key].absolutePath != child.absolutePath) { - throw new Error(`Duplicated path in loadChildren detected: "${key}" is used in 2 ` + - 'loadChildren, but they point to different modules. Webpack cannot distinguish ' + - 'between the two based on context and would fail to load the proper one.'); - } - } else { - resultMap[key] = child; - } - }); - } - return resultMap; - } - - private getNgModuleMetadata(staticSymbol: ngCompiler.StaticSymbol) { - const ngModules = this._reflector.annotations(staticSymbol).filter(s => s instanceof NgModule); - if (ngModules.length === 0) { - throw new Error(`${staticSymbol.name} is not an NgModule`); - } - return ngModules[0]; - } - - private extractLoadChildren(ngModuleDecorator: any): any[] { - const routes = (ngModuleDecorator.imports || []).reduce((mem: any[], m: any) => { - return mem.concat(this.collectRoutes(m.providers)); - }, this.collectRoutes(ngModuleDecorator.providers)); - return this.collectLoadChildren(routes) - .concat((ngModuleDecorator.imports || []) - // Also recursively extractLoadChildren of modules we import. - .map((staticSymbol: any) => { - if (staticSymbol instanceof StaticSymbol) { - const entryNgModuleMetadata = this.getNgModuleMetadata(staticSymbol); - return this.extractLoadChildren(entryNgModuleMetadata); - } else { - return []; - } - }) - // Poor man's flat map. - .reduce((acc: any[], i: any) => acc.concat(i), [])) - .filter(x => !!x); - } - - private collectRoutes(providers: any[]): any[] { - if (!providers) { - return []; - } - const ROUTES = this._reflectorHost.findDeclaration( - '@angular/router/src/router_config_loader', 'ROUTES', undefined); - - return providers.reduce((m, p) => { - if (p.provide === ROUTES) { - return m.concat(p.useValue); - } else if (Array.isArray(p)) { - return m.concat(this.collectRoutes(p)); - } else { - return m; - } - }, []); - } - - private collectLoadChildren(routes: any[]): any[] { - if (!routes) { - return []; - } - return routes.reduce((m, r) => { - if (r.loadChildren) { - return m.concat(r.loadChildren); - } else if (Array.isArray(r)) { - return m.concat(this.collectLoadChildren(r)); - } else if (r.children) { - return m.concat(this.collectLoadChildren(r.children)); - } else { - return m; - } - }, []); } } diff --git a/packages/angular-cli/models/webpack-build-typescript.ts b/packages/angular-cli/models/webpack-build-typescript.ts index 40de6bb09dd9..39d195f4a5b0 100644 --- a/packages/angular-cli/models/webpack-build-typescript.ts +++ b/packages/angular-cli/models/webpack-build-typescript.ts @@ -23,6 +23,10 @@ export const getWebpackNonAotConfigPartial = function(projectRoot: string, appCo new AotPlugin({ tsConfigPath: path.resolve(projectRoot, appConfig.root, appConfig.tsconfig), mainPath: path.join(projectRoot, appConfig.root, appConfig.main), + exclude: [ + path.join(projectRoot, appConfig.root, appConfig.test), + '**/*.spec.ts' + ], skipCodeGeneration: true }), ] @@ -48,6 +52,10 @@ export const getWebpackAotConfigPartial = function(projectRoot: string, appConfi i18nFile: i18nFile, i18nFormat: i18nFormat, locale: locale + exclude: [ + path.join(projectRoot, appConfig.root, appConfig.test), + '**/*.spec.ts' + ] }), ] }; diff --git a/tests/e2e/setup/010-build.ts b/tests/e2e/setup/010-build.ts index 230a2cb41ab8..70306b6ff811 100644 --- a/tests/e2e/setup/010-build.ts +++ b/tests/e2e/setup/010-build.ts @@ -1,10 +1,13 @@ +import {join} from 'path'; +import {getGlobalVariable} from '../utils/env'; import {npm} from '../utils/process'; import {updateJsonFile} from '../utils/project'; -import {join} from 'path'; const packages = require('../../../lib/packages'); export default function() { + const argv = getGlobalVariable('argv'); + return npm('run', 'build') .then(() => console.log('Updating package.json from dist...')) .then(() => Promise.all(Object.keys(packages).map(pkgName => { @@ -17,5 +20,33 @@ export default function() { } }); }); - }))); + }))) + .then(() => { + if (!argv.nightly && !argv['ng-sha']) { + return; + } + + console.log('Updating package.json from dist for nightly Angular packages...'); + const label = argv['ng-sha'] ? `#2.0.0-${argv['ng-sha']}` : ''; + + return Promise.all(Object.keys(packages).map(pkgName => { + return updateJsonFile(join(packages[pkgName].dist, 'package.json'), json => { + Object.keys(json['dependencies'] || {}) + .filter(name => name.match(/^@angular\//)) + .forEach(name => { + const pkgName = name.split(/\//)[1]; + json['dependencies'][`@angular/${pkgName}`] + = `github:angular/${pkgName}-builds${label}`; + }); + + Object.keys(json['devDependencies'] || {}) + .filter(name => name.match(/^@angular\//)) + .forEach(name => { + const pkgName = name.split(/\//)[1]; + json['devDependencies'][`@angular/${pkgName}`] + = `github:angular/${pkgName}-builds${label}`; + }); + }); + })); + }); } diff --git a/tests/e2e/setup/500-create-project.ts b/tests/e2e/setup/500-create-project.ts index 87e0555dcdb2..db7a6bd1bad1 100644 --- a/tests/e2e/setup/500-create-project.ts +++ b/tests/e2e/setup/500-create-project.ts @@ -38,22 +38,25 @@ export default function() { }); })) .then(() => { - if (argv.nightly) { + if (argv.nightly || argv['ng-sha']) { + const label = argv['ng-sha'] ? `#2.0.0-${argv['ng-sha']}` : ''; return updateJsonFile('package.json', json => { // Install over the project with nightly builds. - const angularPackages = [ - 'core', - 'common', - 'compiler', - 'forms', - 'http', - 'router', - 'platform-browser', - 'platform-browser-dynamic' - ]; - angularPackages.forEach(pkgName => { - json['dependencies'][`@angular/${pkgName}`] = `github:angular/${pkgName}-builds`; - }); + Object.keys(json['dependencies'] || {}) + .filter(name => name.match(/^@angular\//)) + .forEach(name => { + const pkgName = name.split(/\//)[1]; + json['dependencies'][`@angular/${pkgName}`] + = `github:angular/${pkgName}-builds${label}`; + }); + + Object.keys(json['devDependencies'] || {}) + .filter(name => name.match(/^@angular\//)) + .forEach(name => { + const pkgName = name.split(/\//)[1]; + json['devDependencies'][`@angular/${pkgName}`] + = `github:angular/${pkgName}-builds${label}`; + }); }); } }) diff --git a/tests/e2e/utils/project.ts b/tests/e2e/utils/project.ts index 45569278d1ad..5dbc4bcc1aeb 100644 --- a/tests/e2e/utils/project.ts +++ b/tests/e2e/utils/project.ts @@ -42,22 +42,25 @@ export function createProject(name: string, ...args: string[]) { })) .then(() => { const argv: any = getGlobalVariable('argv'); - if (argv.nightly) { + if (argv.nightly || argv['ng-sha']) { + const label = argv['ng-sha'] ? `#2.0.0-${argv['ng-sha']}` : ''; return updateJsonFile('package.json', json => { // Install over the project with nightly builds. - const angularPackages = [ - 'core', - 'common', - 'compiler', - 'forms', - 'http', - 'router', - 'platform-browser', - 'platform-browser-dynamic' - ]; - angularPackages.forEach(pkgName => { - json['dependencies'][`@angular/${pkgName}`] = `github:angular/${pkgName}-builds`; - }); + Object.keys(json['dependencies'] || {}) + .filter(name => name.match(/^@angular\//)) + .forEach(name => { + const pkgName = name.split(/\//)[1]; + json['dependencies'][`@angular/${pkgName}`] + = `github:angular/${pkgName}-builds${label}`; + }); + + Object.keys(json['devDependencies'] || {}) + .filter(name => name.match(/^@angular\//)) + .forEach(name => { + const pkgName = name.split(/\//)[1]; + json['devDependencies'][`@angular/${pkgName}`] + = `github:angular/${pkgName}-builds${label}`; + }); }); } }) diff --git a/tests/e2e_runner.js b/tests/e2e_runner.js index ba4d9882f656..5b869dd03517 100644 --- a/tests/e2e_runner.js +++ b/tests/e2e_runner.js @@ -26,6 +26,8 @@ const setGlobalVariable = require('./e2e/utils/env').setGlobalVariable; * --debug If a test fails, block the thread so the temporary directory isn't deleted. * --noproject Skip creating a project or using one. * --nolink Skip linking your local angular-cli directory. Can save a few seconds. + * --ng-sha=SHA Use a specific ng-sha. Similar to nightly but point to a master SHA instead + * of using the latest. * --nightly Install angular nightly builds over the test project. * --reuse=/path Use a path instead of create a new project. That project should have been * created, and npm installed. Ideally you want a project created by a previous @@ -34,7 +36,7 @@ const setGlobalVariable = require('./e2e/utils/env').setGlobalVariable; */ const argv = minimist(process.argv.slice(2), { 'boolean': ['debug', 'nolink', 'nightly', 'noproject'], - 'string': ['reuse'] + 'string': ['reuse', 'ng-sha'] }); From 3dd9c1771d004f85fd086dd79fca702e0ef04f24 Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Wed, 14 Dec 2016 21:24:24 -0800 Subject: [PATCH 02/10] . --- packages/@ngtools/webpack/package.json | 6 +++--- packages/@ngtools/webpack/src/plugin.ts | 20 ++++++------------- .../blueprints/ng2/files/package.json | 16 +++++++-------- .../models/webpack-build-typescript.ts | 4 ++-- packages/angular-cli/package.json | 6 +++--- .../not/so/source/tsconfig.json | 1 - .../webpack/test-app-weird/package.json | 18 ++++++++--------- .../e2e/assets/webpack/test-app/package.json | 18 ++++++++--------- .../e2e/assets/webpack/test-app/tsconfig.json | 1 + 9 files changed, 41 insertions(+), 49 deletions(-) diff --git a/packages/@ngtools/webpack/package.json b/packages/@ngtools/webpack/package.json index 865b2a9863bb..ac20edc2c91b 100644 --- a/packages/@ngtools/webpack/package.json +++ b/packages/@ngtools/webpack/package.json @@ -31,9 +31,9 @@ "source-map": "^0.5.6" }, "peerDependencies": { - "@angular/compiler": "2.2.3", - "@angular/compiler-cli": "2.2.3", - "@angular/core": "2.2.3", + "@angular/compiler": "~2.3.1", + "@angular/compiler-cli": "~2.3.1", + "@angular/core": "~2.3.1", "@angular/tsc-wrapped": "0.4.0", "typescript": "^2.0.2", "reflect-metadata": "^0.1.8", diff --git a/packages/@ngtools/webpack/src/plugin.ts b/packages/@ngtools/webpack/src/plugin.ts index 58331b890c51..b42f505bb27b 100644 --- a/packages/@ngtools/webpack/src/plugin.ts +++ b/packages/@ngtools/webpack/src/plugin.ts @@ -9,7 +9,6 @@ import {WebpackResourceLoader} from './resource_loader'; import {createResolveDependenciesFromContextMap} from './utils'; import {WebpackCompilerHost} from './compiler_host'; import {resolveEntryModuleFromMain} from './entry_resolver'; -import {StaticSymbol} from '@angular/compiler-cli'; import {Tapable} from './webpack'; import {PathsPlugin} from './paths-plugin'; @@ -122,7 +121,7 @@ export class AotPlugin implements Tapable { const re = new RegExp('^' + pattern + '$'); fileNames = fileNames.filter(x => !x.match(re)); - }) + }); } else { fileNames = fileNames.filter(fileName => !/\.spec\.ts$/.test(fileName)); } @@ -140,7 +139,7 @@ export class AotPlugin implements Tapable { ); if (this._angularCompilerOptions.hasOwnProperty('genDir')) { - genDir = this._angularCompilerOptions.genDir; + genDir = path.join(basePath, this._angularCompilerOptions.genDir); } this._basePath = basePath; @@ -245,13 +244,6 @@ export class AotPlugin implements Tapable { this._resourceLoader = new WebpackResourceLoader(compilation); - const i18nOptions: ngCompiler.NgcCliOptions = { - i18nFile: this.i18nFile, - i18nFormat: this.i18nFormat, - locale: this.locale, - basePath: this.basePath - }; - this._donePromise = Promise.resolve() .then(() => { if (this._skipCodeGeneration) { @@ -265,9 +257,9 @@ export class AotPlugin implements Tapable { program: this._program, host: this._compilerHost, angularCompilerOptions: this._angularCompilerOptions, - i18nFormat: null, - i18nFile: null, - locale: null, + i18nFile: this.i18nFile, + i18nFormat: this.i18nFormat, + locale: this.locale, readResource: (path: string) => this._resourceLoader.get(path) }); @@ -306,7 +298,7 @@ export class AotPlugin implements Tapable { program: this._program, host: this._compilerHost, angularCompilerOptions: this._angularCompilerOptions, - entryModule: this._entryModule.toString() + entryModule: this._entryModule }); Object.keys(allLazyRoutes) .forEach(k => { diff --git a/packages/angular-cli/blueprints/ng2/files/package.json b/packages/angular-cli/blueprints/ng2/files/package.json index 2bd259ef1f0c..9b213d1548c5 100644 --- a/packages/angular-cli/blueprints/ng2/files/package.json +++ b/packages/angular-cli/blueprints/ng2/files/package.json @@ -13,13 +13,13 @@ }, "private": true, "dependencies": { - "@angular/common": "2.2.3", - "@angular/compiler": "2.2.3", - "@angular/core": "2.2.3", - "@angular/forms": "2.2.3", - "@angular/http": "2.2.3", - "@angular/platform-browser": "2.2.3", - "@angular/platform-browser-dynamic": "2.2.3", + "@angular/common": "~2.3.1", + "@angular/compiler": "~2.3.1", + "@angular/core": "~2.3.1", + "@angular/forms": "~2.3.1", + "@angular/http": "~2.3.1", + "@angular/platform-browser": "~2.3.1", + "@angular/platform-browser-dynamic": "~2.3.1", "@angular/router": "3.2.3", "core-js": "^2.4.1", "rxjs": "5.0.0-beta.12", @@ -27,7 +27,7 @@ "zone.js": "^0.6.23" }, "devDependencies": { - "@angular/compiler-cli": "2.2.3", + "@angular/compiler-cli": "~2.3.1", "@types/jasmine": "2.5.38", "@types/node": "^6.0.42", "angular-cli": "<%= version %>", diff --git a/packages/angular-cli/models/webpack-build-typescript.ts b/packages/angular-cli/models/webpack-build-typescript.ts index 39d195f4a5b0..67940af47ab8 100644 --- a/packages/angular-cli/models/webpack-build-typescript.ts +++ b/packages/angular-cli/models/webpack-build-typescript.ts @@ -51,12 +51,12 @@ export const getWebpackAotConfigPartial = function(projectRoot: string, appConfi mainPath: path.join(projectRoot, appConfig.root, appConfig.main), i18nFile: i18nFile, i18nFormat: i18nFormat, - locale: locale + locale: locale, exclude: [ path.join(projectRoot, appConfig.root, appConfig.test), '**/*.spec.ts' ] - }), + }) ] }; }; diff --git a/packages/angular-cli/package.json b/packages/angular-cli/package.json index c554acd35c3b..669496611686 100644 --- a/packages/angular-cli/package.json +++ b/packages/angular-cli/package.json @@ -27,9 +27,9 @@ "dependencies": { "@angular-cli/ast-tools": "^1.0.1", "@angular-cli/base-href-webpack": "^1.0.0", - "@angular/compiler": "2.2.3", - "@angular/compiler-cli": "2.2.3", - "@angular/core": "2.2.3", + "@angular/compiler": "~2.3.1", + "@angular/compiler-cli": "~2.3.1", + "@angular/core": "~2.3.1", "@ngtools/webpack": "^1.0.0", "async": "^2.1.4", "autoprefixer": "^6.5.3", diff --git a/tests/e2e/assets/webpack/test-app-weird/not/so/source/tsconfig.json b/tests/e2e/assets/webpack/test-app-weird/not/so/source/tsconfig.json index 74a0d8f522a4..721113e471d8 100644 --- a/tests/e2e/assets/webpack/test-app-weird/not/so/source/tsconfig.json +++ b/tests/e2e/assets/webpack/test-app-weird/not/so/source/tsconfig.json @@ -1,6 +1,5 @@ { "compilerOptions": { - "baseUrl": "", "module": "es2015", "moduleResolution": "node", "target": "es5", diff --git a/tests/e2e/assets/webpack/test-app-weird/package.json b/tests/e2e/assets/webpack/test-app-weird/package.json index 58992bd35b1c..9bc69037ef58 100644 --- a/tests/e2e/assets/webpack/test-app-weird/package.json +++ b/tests/e2e/assets/webpack/test-app-weird/package.json @@ -2,15 +2,15 @@ "name": "test", "license": "MIT", "dependencies": { - "@angular/common": "2.2.1", - "@angular/compiler": "2.2.1", - "@angular/compiler-cli": "2.2.1", - "@angular/core": "2.2.1", - "@angular/http": "2.2.1", - "@angular/platform-browser": "2.2.1", - "@angular/platform-browser-dynamic": "2.2.1", - "@angular/platform-server": "2.2.1", - "@angular/router": "3.2.1", + "@angular/common": "~2.3.1", + "@angular/compiler": "~2.3.1", + "@angular/compiler-cli": "~2.3.1", + "@angular/core": "~2.3.1", + "@angular/http": "~2.3.1", + "@angular/platform-browser": "~2.3.1", + "@angular/platform-browser-dynamic": "~2.3.1", + "@angular/platform-server": "~2.3.1", + "@angular/router": "~3.2.3", "@ngtools/webpack": "0.0.0", "core-js": "^2.4.1", "rxjs": "^5.0.0-beta.12", diff --git a/tests/e2e/assets/webpack/test-app/package.json b/tests/e2e/assets/webpack/test-app/package.json index 1cd7c2e4be78..9bc69037ef58 100644 --- a/tests/e2e/assets/webpack/test-app/package.json +++ b/tests/e2e/assets/webpack/test-app/package.json @@ -2,15 +2,15 @@ "name": "test", "license": "MIT", "dependencies": { - "@angular/common": "2.2.3", - "@angular/compiler": "2.2.3", - "@angular/compiler-cli": "2.2.3", - "@angular/core": "2.2.3", - "@angular/http": "2.2.3", - "@angular/platform-browser": "2.2.3", - "@angular/platform-browser-dynamic": "2.2.3", - "@angular/platform-server": "2.2.3", - "@angular/router": "3.2.3", + "@angular/common": "~2.3.1", + "@angular/compiler": "~2.3.1", + "@angular/compiler-cli": "~2.3.1", + "@angular/core": "~2.3.1", + "@angular/http": "~2.3.1", + "@angular/platform-browser": "~2.3.1", + "@angular/platform-browser-dynamic": "~2.3.1", + "@angular/platform-server": "~2.3.1", + "@angular/router": "~3.2.3", "@ngtools/webpack": "0.0.0", "core-js": "^2.4.1", "rxjs": "^5.0.0-beta.12", diff --git a/tests/e2e/assets/webpack/test-app/tsconfig.json b/tests/e2e/assets/webpack/test-app/tsconfig.json index 585586e38d21..9f2725a20b0f 100644 --- a/tests/e2e/assets/webpack/test-app/tsconfig.json +++ b/tests/e2e/assets/webpack/test-app/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": "", "module": "es2015", "moduleResolution": "node", "target": "es5", From 6c5e97860b81e4d5a91e3715ea28dc2df0755b0c Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Thu, 15 Dec 2016 10:47:40 -0800 Subject: [PATCH 03/10] . --- packages/@ngtools/webpack/src/plugin.ts | 3 ++- packages/angular-cli/commands/build.ts | 1 + tests/e2e/assets/webpack/test-app/package.json | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/@ngtools/webpack/src/plugin.ts b/packages/@ngtools/webpack/src/plugin.ts index b42f505bb27b..dc68e1737cd4 100644 --- a/packages/@ngtools/webpack/src/plugin.ts +++ b/packages/@ngtools/webpack/src/plugin.ts @@ -139,7 +139,8 @@ export class AotPlugin implements Tapable { ); if (this._angularCompilerOptions.hasOwnProperty('genDir')) { - genDir = path.join(basePath, this._angularCompilerOptions.genDir); + genDir = path.resolve(basePath, this._angularCompilerOptions.genDir); + this._angularCompilerOptions.genDir = genDir; } this._basePath = basePath; diff --git a/packages/angular-cli/commands/build.ts b/packages/angular-cli/commands/build.ts index 821b74e10d81..e80048d9133e 100644 --- a/packages/angular-cli/commands/build.ts +++ b/packages/angular-cli/commands/build.ts @@ -59,6 +59,7 @@ const BuildCommand = Command.extend({ } const project = this.project; + const ui = this.ui; const buildTask = commandOptions.watch ? new WebpackBuildWatch({ diff --git a/tests/e2e/assets/webpack/test-app/package.json b/tests/e2e/assets/webpack/test-app/package.json index 9bc69037ef58..968f1661d29c 100644 --- a/tests/e2e/assets/webpack/test-app/package.json +++ b/tests/e2e/assets/webpack/test-app/package.json @@ -22,6 +22,6 @@ "raw-loader": "^0.5.1", "sass-loader": "^3.2.0", "typescript": "~2.0.3", - "webpack": "2.1.0-beta.22" + "webpack": "2.1.0-beta.25" } } From 28cea8972ac38fcb2f37074d121398bd11d34eaf Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Thu, 15 Dec 2016 11:19:12 -0800 Subject: [PATCH 04/10] refuse cowardly to build or serve on angular v2.3.0 or below --- packages/angular-cli/commands/build.ts | 4 ++++ packages/angular-cli/commands/serve.ts | 3 +++ packages/angular-cli/upgrade/version.ts | 32 +++++++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/packages/angular-cli/commands/build.ts b/packages/angular-cli/commands/build.ts index e80048d9133e..b8128da21e78 100644 --- a/packages/angular-cli/commands/build.ts +++ b/packages/angular-cli/commands/build.ts @@ -1,3 +1,4 @@ +import {Version} from '../upgrade/version'; const Command = require('../ember-cli/lib/models/command'); import WebpackBuild from '../tasks/build-webpack'; import WebpackBuildWatch from '../tasks/build-webpack-watch'; @@ -60,6 +61,9 @@ const BuildCommand = Command.extend({ const project = this.project; + // Check angular version. + Version.assertAngularVersionIs2_3_1OrBetter(project.root); + const ui = this.ui; const buildTask = commandOptions.watch ? new WebpackBuildWatch({ diff --git a/packages/angular-cli/commands/serve.ts b/packages/angular-cli/commands/serve.ts index 38836cf50e46..2e563535cc95 100644 --- a/packages/angular-cli/commands/serve.ts +++ b/packages/angular-cli/commands/serve.ts @@ -4,6 +4,7 @@ const SilentError = require('silent-error'); const PortFinder = require('portfinder'); const Command = require('../ember-cli/lib/models/command'); import ServeWebpackTask from '../tasks/serve-webpack'; +import {Version} from '../upgrade/version'; PortFinder.basePort = 49152; @@ -121,6 +122,8 @@ const ServeCommand = Command.extend({ } } + // Check angular version. + Version.assertAngularVersionIs2_3_1OrBetter(this.project.root); commandOptions.liveReloadHost = commandOptions.liveReloadHost || commandOptions.host; return this._checkExpressPort(commandOptions) diff --git a/packages/angular-cli/upgrade/version.ts b/packages/angular-cli/upgrade/version.ts index ac380c68500b..9ac0f0d5932e 100644 --- a/packages/angular-cli/upgrade/version.ts +++ b/packages/angular-cli/upgrade/version.ts @@ -45,6 +45,8 @@ export class Version { isReleaseCandidate() { return this.qualifier == 'rc'; } isKnown() { return this._version !== null; } + isLocal() { return this.isKnown() ? path.isAbsolute(this._version) : false; } + get major() { return this._parse()[0] || 0; } get minor() { return this._parse()[1] || 0; } get patch() { return this._parse()[2] || 0; } @@ -91,6 +93,36 @@ export class Version { } } + static assertAngularVersionIs2_3_1OrBetter(projectRoot: string) { + const angularCorePath = path.join(projectRoot, 'node_modules/@angular/core'); + const pkgJson = existsSync(angularCorePath) + ? JSON.parse(readFileSync(path.join(angularCorePath, 'package.json'), 'utf8')) + : null; + + // Just check @angular/core. + if (pkgJson && pkgJson['version']) { + const v = new Version(pkgJson['version']); + if (v.isLocal()) { + console.warn(yellow('Using a local version of angular. Proceeding with care...')); + } else { + if (v.major != 2 || ((v.minor == 3 && v.patch == 0) || v.minor < 3)) { + console.error(bold(red(stripIndents` + This version of CLI is only compatible with angular version 2.3.1 or better. Please + upgrade your angular version, e.g. by running: + + npm install @angular/core@latest + ` + '\n'))); + process.exit(3); + } + } + } else { + console.error(bold(red(stripIndents` + You seem to not be dependending on "@angular/core". This is an error. + `))); + process.exit(2); + } + } + static assertPostWebpackVersion() { if (this.isPreWebpack()) { console.error(bold(red('\n' + stripIndents` From 65a7d1eb1d2d5cae52703ef921bfaec27d0b1310 Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Thu, 15 Dec 2016 12:08:15 -0800 Subject: [PATCH 05/10] fixing more tests --- packages/@ngtools/webpack/src/refactor.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/@ngtools/webpack/src/refactor.ts b/packages/@ngtools/webpack/src/refactor.ts index 9ae55c401fd6..3ad8fc76d922 100644 --- a/packages/@ngtools/webpack/src/refactor.ts +++ b/packages/@ngtools/webpack/src/refactor.ts @@ -16,7 +16,12 @@ function resolve(filePath: string, host: ts.CompilerHost, program: ts.Program) { if (path.isAbsolute(filePath)) { return filePath; } - return path.join(program.getCompilerOptions().baseUrl || process.cwd(), filePath); + const compilerOptions = program.getCompilerOptions(); + const basePath = compilerOptions.baseUrl || compilerOptions.rootDir; + if (!basePath) { + throw new Error(`Trying to resolve '${filePath}' without a basePath.`); + } + return path.join(basePath, filePath); } From aeb2b01760663175302fbd1107ab54e29fe7c3f2 Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Thu, 15 Dec 2016 12:46:09 -0800 Subject: [PATCH 06/10] no progress on serve --- tests/e2e/utils/project.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/utils/project.ts b/tests/e2e/utils/project.ts index 5dbc4bcc1aeb..5adb061ba38c 100644 --- a/tests/e2e/utils/project.ts +++ b/tests/e2e/utils/project.ts @@ -26,7 +26,7 @@ export function updateTsConfig(fn: (json: any) => any | void) { export function ngServe(...args: string[]) { return silentExecAndWaitForOutputToMatch('ng', - ['serve', ...args], /webpack: bundle is now VALID/); + ['serve', '--no-progress', ...args], /webpack: bundle is now VALID/); } From 1ef30f9b7a0619c533f8948a92313d6c658cb1fa Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Thu, 15 Dec 2016 13:16:29 -0800 Subject: [PATCH 07/10] fix regexes for windows --- packages/@ngtools/webpack/src/plugin.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/@ngtools/webpack/src/plugin.ts b/packages/@ngtools/webpack/src/plugin.ts index dc68e1737cd4..a18eb2934c1c 100644 --- a/packages/@ngtools/webpack/src/plugin.ts +++ b/packages/@ngtools/webpack/src/plugin.ts @@ -112,12 +112,13 @@ export class AotPlugin implements Tapable { exclude.forEach((pattern: string) => { pattern = pattern - // Replace characters that are used normally in regexes, except stars. + // Escape characters that are used normally in regexes, except stars. .replace(/[\-\[\]\/{}()+?.\\^$|]/g, '\\$&') // Two stars replacement. .replace(/\*\*/g, '(?:.*)') - .replace(/\*/g, '(?:[^/]*)') - .replace(/^/, `(${basePath})?`); + .replace(/\*/g, '(?:[^/\\\\]*)') + // Escape every characters from the basePath. + .replace(/^/, `(${basePath.replace(/[\-\[\]\/{}()+?.\\^$|*]/g, '\\$&')})?`); const re = new RegExp('^' + pattern + '$'); fileNames = fileNames.filter(x => !x.match(re)); From 2a5c89677d8bb72a6e2767b3b89b80c0bc3d6f91 Mon Sep 17 00:00:00 2001 From: Angular Date: Thu, 15 Dec 2016 13:56:27 -0800 Subject: [PATCH 08/10] fixing windows again --- packages/@ngtools/webpack/src/plugin.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/@ngtools/webpack/src/plugin.ts b/packages/@ngtools/webpack/src/plugin.ts index a18eb2934c1c..037c7f7619b0 100644 --- a/packages/@ngtools/webpack/src/plugin.ts +++ b/packages/@ngtools/webpack/src/plugin.ts @@ -112,16 +112,19 @@ export class AotPlugin implements Tapable { exclude.forEach((pattern: string) => { pattern = pattern + // Replace windows path separators to forward slashes. + .replace(/\\/g, '/') // Escape characters that are used normally in regexes, except stars. - .replace(/[\-\[\]\/{}()+?.\\^$|]/g, '\\$&') + .replace(/[\-\[\]{}()+?.\\^$|]/g, '\\$&') // Two stars replacement. .replace(/\*\*/g, '(?:.*)') - .replace(/\*/g, '(?:[^/\\\\]*)') - // Escape every characters from the basePath. - .replace(/^/, `(${basePath.replace(/[\-\[\]\/{}()+?.\\^$|*]/g, '\\$&')})?`); + // One star replacement. + .replace(/\*/g, '(?:[^/]*)') + // Escape characters from the basePath and make sure it's forward slashes. + .replace(/^/, `(${basePath.replace(/\\/g, '/').replace(/[\-\[\]\/{}()+?.\\^$|*]/g, '\\$&')})?`); const re = new RegExp('^' + pattern + '$'); - fileNames = fileNames.filter(x => !x.match(re)); + fileNames = fileNames.filter(x => !x.replace(/\\/g, '/').match(re)); }); } else { fileNames = fileNames.filter(fileName => !/\.spec\.ts$/.test(fileName)); From b7cb87869b85a52d50983ed38d660b84ac480a42 Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Thu, 15 Dec 2016 14:04:47 -0800 Subject: [PATCH 09/10] linting errors --- packages/@ngtools/webpack/src/plugin.ts | 32 +++++++++++++------------ 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/packages/@ngtools/webpack/src/plugin.ts b/packages/@ngtools/webpack/src/plugin.ts index 037c7f7619b0..6e7ccccb6964 100644 --- a/packages/@ngtools/webpack/src/plugin.ts +++ b/packages/@ngtools/webpack/src/plugin.ts @@ -111,21 +111,23 @@ export class AotPlugin implements Tapable { ? [options.exclude as string] : (options.exclude as string[]); exclude.forEach((pattern: string) => { - pattern = pattern - // Replace windows path separators to forward slashes. - .replace(/\\/g, '/') - // Escape characters that are used normally in regexes, except stars. - .replace(/[\-\[\]{}()+?.\\^$|]/g, '\\$&') - // Two stars replacement. - .replace(/\*\*/g, '(?:.*)') - // One star replacement. - .replace(/\*/g, '(?:[^/]*)') - // Escape characters from the basePath and make sure it's forward slashes. - .replace(/^/, `(${basePath.replace(/\\/g, '/').replace(/[\-\[\]\/{}()+?.\\^$|*]/g, '\\$&')})?`); - - const re = new RegExp('^' + pattern + '$'); - fileNames = fileNames.filter(x => !x.replace(/\\/g, '/').match(re)); - }); + const basePathPattern = '(' + basePath.replace(/\\/g, '/') + .replace(/[\-\[\]\/{}()+?.\\^$|*]/g, '\\$&') + ')?'; + pattern = pattern + // Replace windows path separators to forward slashes. + .replace(/\\/g, '/') + // Escape characters that are used normally in regexes, except stars. + .replace(/[\-\[\]{}()+?.\\^$|]/g, '\\$&') + // Two stars replacement. + .replace(/\*\*/g, '(?:.*)') + // One star replacement. + .replace(/\*/g, '(?:[^/]*)') + // Escape characters from the basePath and make sure it's forward slashes. + .replace(/^/, basePathPattern); + + const re = new RegExp('^' + pattern + '$'); + fileNames = fileNames.filter(x => !x.replace(/\\/g, '/').match(re)); + }); } else { fileNames = fileNames.filter(fileName => !/\.spec\.ts$/.test(fileName)); } From 32ad030b0a163406c5af8b3c2001a87a4de46d36 Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Thu, 15 Dec 2016 14:35:36 -0800 Subject: [PATCH 10/10] comments --- package.json | 2 +- packages/@angular-cli/ast-tools/package.json | 2 +- packages/@ngtools/webpack/package.json | 2 +- packages/@ngtools/webpack/src/plugin.ts | 4 ++-- packages/angular-cli/blueprints/ng2/files/package.json | 4 ++-- packages/angular-cli/commands/build.ts | 2 +- packages/angular-cli/commands/serve.ts | 2 +- packages/angular-cli/upgrade/version.ts | 4 ++-- tests/e2e/assets/webpack/test-app-weird/package.json | 4 ++-- tests/e2e/assets/webpack/test-app/package.json | 4 ++-- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 55e569703698..67cdf2a24509 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,7 @@ "resolve": "^1.1.7", "rimraf": "^2.5.3", "rsvp": "^3.0.17", - "rxjs": "5.0.0-beta.12", + "rxjs": "5.0.0-rc.4", "sass-loader": "^4.0.1", "script-loader": "^0.7.0", "semver": "^5.1.0", diff --git a/packages/@angular-cli/ast-tools/package.json b/packages/@angular-cli/ast-tools/package.json index 90430e794519..dd2c6366c0de 100644 --- a/packages/@angular-cli/ast-tools/package.json +++ b/packages/@angular-cli/ast-tools/package.json @@ -25,7 +25,7 @@ }, "dependencies": { "@angular/tsc-wrapped": "^0.3.0", - "rxjs": "5.0.0-beta.12", + "rxjs": "5.0.0-rc.4", "denodeify": "^1.2.1", "typescript": "~2.0.3" } diff --git a/packages/@ngtools/webpack/package.json b/packages/@ngtools/webpack/package.json index ac20edc2c91b..0744ba0c3541 100644 --- a/packages/@ngtools/webpack/package.json +++ b/packages/@ngtools/webpack/package.json @@ -34,7 +34,7 @@ "@angular/compiler": "~2.3.1", "@angular/compiler-cli": "~2.3.1", "@angular/core": "~2.3.1", - "@angular/tsc-wrapped": "0.4.0", + "@angular/tsc-wrapped": "~0.5.0", "typescript": "^2.0.2", "reflect-metadata": "^0.1.8", "webpack": "^2.1.0-beta.25" diff --git a/packages/@ngtools/webpack/src/plugin.ts b/packages/@ngtools/webpack/src/plugin.ts index 6e7ccccb6964..5870f4b56e97 100644 --- a/packages/@ngtools/webpack/src/plugin.ts +++ b/packages/@ngtools/webpack/src/plugin.ts @@ -27,7 +27,7 @@ export interface AotPluginOptions { i18nFormat?: string; locale?: string; - // We do not have an include because tsconfig can be used for that. + // Use tsconfig to include path globs. exclude?: string | string[]; } @@ -114,7 +114,7 @@ export class AotPlugin implements Tapable { const basePathPattern = '(' + basePath.replace(/\\/g, '/') .replace(/[\-\[\]\/{}()+?.\\^$|*]/g, '\\$&') + ')?'; pattern = pattern - // Replace windows path separators to forward slashes. + // Replace windows path separators with forward slashes. .replace(/\\/g, '/') // Escape characters that are used normally in regexes, except stars. .replace(/[\-\[\]{}()+?.\\^$|]/g, '\\$&') diff --git a/packages/angular-cli/blueprints/ng2/files/package.json b/packages/angular-cli/blueprints/ng2/files/package.json index 9b213d1548c5..1bbbb1f52530 100644 --- a/packages/angular-cli/blueprints/ng2/files/package.json +++ b/packages/angular-cli/blueprints/ng2/files/package.json @@ -22,9 +22,9 @@ "@angular/platform-browser-dynamic": "~2.3.1", "@angular/router": "3.2.3", "core-js": "^2.4.1", - "rxjs": "5.0.0-beta.12", + "rxjs": "5.0.0-rc.4", "ts-helpers": "^1.1.1", - "zone.js": "^0.6.23" + "zone.js": "^0.7.2" }, "devDependencies": { "@angular/compiler-cli": "~2.3.1", diff --git a/packages/angular-cli/commands/build.ts b/packages/angular-cli/commands/build.ts index b8128da21e78..6584be61078d 100644 --- a/packages/angular-cli/commands/build.ts +++ b/packages/angular-cli/commands/build.ts @@ -62,7 +62,7 @@ const BuildCommand = Command.extend({ const project = this.project; // Check angular version. - Version.assertAngularVersionIs2_3_1OrBetter(project.root); + Version.assertAngularVersionIs2_3_1OrHigher(project.root); const ui = this.ui; const buildTask = commandOptions.watch ? diff --git a/packages/angular-cli/commands/serve.ts b/packages/angular-cli/commands/serve.ts index 2e563535cc95..abb0013f8e3d 100644 --- a/packages/angular-cli/commands/serve.ts +++ b/packages/angular-cli/commands/serve.ts @@ -123,7 +123,7 @@ const ServeCommand = Command.extend({ } // Check angular version. - Version.assertAngularVersionIs2_3_1OrBetter(this.project.root); + Version.assertAngularVersionIs2_3_1OrHigher(this.project.root); commandOptions.liveReloadHost = commandOptions.liveReloadHost || commandOptions.host; return this._checkExpressPort(commandOptions) diff --git a/packages/angular-cli/upgrade/version.ts b/packages/angular-cli/upgrade/version.ts index 9ac0f0d5932e..15decc70923f 100644 --- a/packages/angular-cli/upgrade/version.ts +++ b/packages/angular-cli/upgrade/version.ts @@ -45,7 +45,7 @@ export class Version { isReleaseCandidate() { return this.qualifier == 'rc'; } isKnown() { return this._version !== null; } - isLocal() { return this.isKnown() ? path.isAbsolute(this._version) : false; } + isLocal() { return this.isKnown() && path.isAbsolute(this._version); } get major() { return this._parse()[0] || 0; } get minor() { return this._parse()[1] || 0; } @@ -93,7 +93,7 @@ export class Version { } } - static assertAngularVersionIs2_3_1OrBetter(projectRoot: string) { + static assertAngularVersionIs2_3_1OrHigher(projectRoot: string) { const angularCorePath = path.join(projectRoot, 'node_modules/@angular/core'); const pkgJson = existsSync(angularCorePath) ? JSON.parse(readFileSync(path.join(angularCorePath, 'package.json'), 'utf8')) diff --git a/tests/e2e/assets/webpack/test-app-weird/package.json b/tests/e2e/assets/webpack/test-app-weird/package.json index 9bc69037ef58..8e70c25f017b 100644 --- a/tests/e2e/assets/webpack/test-app-weird/package.json +++ b/tests/e2e/assets/webpack/test-app-weird/package.json @@ -13,8 +13,8 @@ "@angular/router": "~3.2.3", "@ngtools/webpack": "0.0.0", "core-js": "^2.4.1", - "rxjs": "^5.0.0-beta.12", - "zone.js": "^0.6.21" + "rxjs": "5.0.0-rc.4", + "zone.js": "^0.7.2" }, "devDependencies": { "node-sass": "^3.7.0", diff --git a/tests/e2e/assets/webpack/test-app/package.json b/tests/e2e/assets/webpack/test-app/package.json index 968f1661d29c..97e03f5e8f6a 100644 --- a/tests/e2e/assets/webpack/test-app/package.json +++ b/tests/e2e/assets/webpack/test-app/package.json @@ -13,8 +13,8 @@ "@angular/router": "~3.2.3", "@ngtools/webpack": "0.0.0", "core-js": "^2.4.1", - "rxjs": "^5.0.0-beta.12", - "zone.js": "^0.6.21" + "rxjs": "5.0.0-rc.4", + "zone.js": "^0.7.2" }, "devDependencies": { "node-sass": "^3.7.0",