From 238d64a4991eb272ae03d89c4339da305919d2a7 Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Thu, 9 Jun 2016 22:32:33 +0200 Subject: [PATCH 01/38] feat(universal): add support for Angular Universal add the possibility to scaffold a universal project with --universal --- .travis.yml | 18 ++ README.md | 17 +- package.json | 19 +- .../angular-cli/blueprints/component/index.js | 23 +- .../angular-cli/blueprints/directive/index.js | 29 +-- .../ng2/files/__path__/app/index.ts | 4 +- .../blueprints/ng2/files/__path__/index.html | 1 + .../ng2/files/__path__/tsconfig.json | 3 +- .../blueprints/ng2/files/angular-cli.json | 7 +- .../blueprints/ng2/files/package.json | 33 ++- packages/angular-cli/blueprints/ng2/index.js | 25 +- packages/angular-cli/blueprints/pipe/index.js | 29 +-- .../files/__path__/app/app.browser.module.ts | 39 ++++ .../files/__path__/app/app.node.module.ts | 39 ++++ .../universal/files/__path__/client.ts | 24 ++ .../universal/files/__path__/server.ts | 76 ++++++ .../angular-cli/blueprints/universal/index.js | 32 +++ packages/angular-cli/commands/init.ts | 2 + packages/angular-cli/commands/new.ts | 1 + packages/angular-cli/lib/config/schema.d.ts | 2 + packages/angular-cli/lib/config/schema.json | 6 + packages/angular-cli/models/index.ts | 1 + .../models/webpack-build-common.ts | 6 +- .../angular-cli/models/webpack-build-node.ts | 217 ++++++++++++++++++ .../models/webpack-build-production.ts | 39 +++- packages/angular-cli/models/webpack-config.ts | 17 +- packages/angular-cli/package.json | 16 +- .../angular-cli/tasks/build-webpack-watch.ts | 6 +- packages/angular-cli/tasks/build-webpack.ts | 9 +- packages/angular-cli/tasks/serve-webpack.ts | 40 +++- .../tasks/server/universal-dev-server.ts | 68 ++++++ .../utilities/dynamic-path-parser.js | 10 +- .../utilities/find-parent-module.ts | 13 +- tests/acceptance/init.spec.js | 30 ++- tests/e2e/setup/500-create-project.ts | 5 +- tests/e2e/tests/build/aot.ts | 18 +- tests/e2e/tests/build/dev-build.ts | 25 +- tests/e2e/tests/build/environment.ts | 22 +- tests/e2e/tests/build/output-dir.ts | 14 +- tests/e2e/tests/build/prod-build.ts | 34 ++- tests/e2e/tests/build/styles/less.ts | 17 +- tests/e2e/tests/build/styles/scss.ts | 22 +- tests/e2e/tests/build/styles/styles-array.ts | 12 +- tests/e2e/tests/misc/proxy.ts | 7 +- tests/e2e/tests/misc/ssl-default.ts | 6 + tests/e2e/tests/misc/ssl-with-cert.ts | 6 + tests/e2e/tests/test/e2e.ts | 14 +- tests/e2e/tests/third-party/bootstrap.ts | 13 +- tests/e2e/utils/fs.ts | 15 ++ tests/e2e/utils/project.ts | 8 +- tests/e2e/utils/utils.ts | 8 + 51 files changed, 945 insertions(+), 202 deletions(-) create mode 100644 packages/angular-cli/blueprints/universal/files/__path__/app/app.browser.module.ts create mode 100644 packages/angular-cli/blueprints/universal/files/__path__/app/app.node.module.ts create mode 100644 packages/angular-cli/blueprints/universal/files/__path__/client.ts create mode 100644 packages/angular-cli/blueprints/universal/files/__path__/server.ts create mode 100644 packages/angular-cli/blueprints/universal/index.js create mode 100644 packages/angular-cli/models/webpack-build-node.ts create mode 100644 packages/angular-cli/tasks/server/universal-dev-server.ts diff --git a/.travis.yml b/.travis.yml index f821a853b7c7..1fe9c14d1ced 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,6 +46,24 @@ matrix: - node_js: "6" os: osx env: NODE_SCRIPT=tests/e2e_runner.js + - node_js: "4" + os: osx + env: UNIVERSAL=true NODE_SCRIPT=tests/e2e_runner.js + - node_js: "5" + os: osx + env: UNIVERSAL=true NODE_SCRIPT=tests/e2e_runner.js + - node_js: "6" + os: osx + env: UNIVERSAL=true NODE_SCRIPT=tests/e2e_runner.js + - node_js: "4" + os: linux + env: UNIVERSAL=true NODE_SCRIPT=tests/e2e_runner.js + - node_js: "5" + os: linux + env: UNIVERSAL=true NODE_SCRIPT=tests/e2e_runner.js + - node_js: "6" + os: linux + env: UNIVERSAL=true NODE_SCRIPT=tests/e2e_runner.js before_install: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi diff --git a/README.md b/README.md index ee679fa6f58d..a0414704c2a3 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ with NPM 3 or higher. * [Deploying the App via GitHub Pages](#deploying-the-app-via-github-pages) * [Linting and formatting code](#linting-and-formatting-code) * [Support for offline applications](#support-for-offline-applications) +* [Support for server side rendering](#support-for-server-side-rendering) * [Commands autocompletion](#commands-autocompletion) * [Project assets](#project-assets) * [Global styles](#global-styles) @@ -268,7 +269,21 @@ You can modify the these scripts in `package.json` to run whatever tool you pref **The `--mobile` flag has been disabled temporarily. Sorry for the inconvenience.** -~~Angular-CLI includes support for offline applications via the `--` flag on `ng new`. Support is experimental, please see the angular/mobile-toolkit project and https://mobile.angular.io/ for documentation on how to make use of this functionality.~~ +~~Angular-CLI includes support for offline applications via the `--mobile` flag on `ng new`. Support is experimental, +please see the angular/mobile-toolkit project and https://mobile.angular.io/ for documentation on how to make use of this functionality.~~ + +### Support for server side rendering + +**Angular-CLI includes Angular Universal via the `--universal` flag on `ng new` and `ng init`.** + +**Angular Universal** helps you to seo optimize your application and offers a better user experience through server side rendering. +Please see the **angular/universal** project and https://universal.angular.io/ for documentation on how to make use of this functionality. + +#### Update an existing Project + +`cd path/to/project` and init your project with the universal option `ng init --universal`. Take every Pipe, Directive, Component, Module and Routes from `./src/app/app.module.ts` +and move them to `./src/app/app.browser.module.ts` and `./src/app/app.node.module.ts`. Try `ng serve`, if your application looks like before, then you can delete the files +`./src/app/app.module.ts` and `./src/main.ts`. **Have fun with Angular Universal!** ### Commands autocompletion diff --git a/package.json b/package.json index 5a6a66fc3fea..33c2b27dfe91 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { - "name": "angular-cli", - "version": "1.0.0-beta.19-3", - "description": "CLI tool for Angular", + "name": "universal-cli", + "version": "1.0.0-beta.1", + "description": "CLI tool for Angular with Angular Universal support", "main": "packages/angular-cli/lib/cli/index.js", - "trackingCode": "UA-8594346-19", + "trackingCode": "xx-xxxxxxx-xx", "bin": { "ng": "./bin/ng" }, @@ -20,6 +20,7 @@ "test:cli": "node tests/runner", "test:inspect": "node --inspect --debug-brk tests/runner", "test:packages": "node scripts/run-packages-spec.js", + "test:universal": "UNIVERSAL=true node tests/e2e_runner.js", "build-config-interface": "dtsgen packages/angular-cli/lib/config/schema.json --out packages/angular-cli/lib/config/schema.d.ts", "eslint": "eslint .", "tslint": "tslint \"**/*.ts\" -c tslint.json -e \"**/blueprints/*/files/**/*.ts\" -e \"node_modules/**\" -e \"tmp/**\" -e \"dist/**\"", @@ -27,7 +28,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/angular/angular-cli.git" + "url": "https://github.com/devCrossNet/angular-cli.git" }, "engines": { "node": ">= 4.1.0", @@ -36,13 +37,14 @@ "author": "Angular Authors", "contributors": [ "Rody Haddad (http://rodyhaddad.com/)", - "Igor Minar " + "Igor Minar ", + "Johannes Werner " ], "license": "MIT", "bugs": { - "url": "https://github.com/angular/angular-cli/issues" + "url": "https://github.com/devCrossNet/angular-cli/issues" }, - "homepage": "https://github.com/angular/angular-cli", + "homepage": "https://github.com/devCrossNet/angular-cli", "dependencies": { "@angular-cli/ast-tools": "^1.0.0", "@angular/common": "~2.1.0", @@ -95,6 +97,7 @@ "node-sass": "^3.10.1", "node-uuid": "^1.4.3", "nopt": "^3.0.1", + "nodemon": "^1.11.0", "npm-run-all": "^3.0.0", "offline-plugin": "^3.4.1", "opn": "4.0.1", diff --git a/packages/angular-cli/blueprints/component/index.js b/packages/angular-cli/blueprints/component/index.js index 523427fc2226..6466228478e9 100644 --- a/packages/angular-cli/blueprints/component/index.js +++ b/packages/angular-cli/blueprints/component/index.js @@ -21,9 +21,9 @@ module.exports = { { name: 'change-detection', type: String, aliases: ['cd'] } ], - beforeInstall: function() { + beforeInstall: function () { try { - this.pathToModule = findParentModule(this.project, this.dynamicPath.dir); + this.modulePaths = findParentModule(this.project, this.dynamicPath.dir); } catch(e) { throw `Error locating module for declaration\n\t${e}`; } @@ -128,7 +128,7 @@ module.exports = { }; }, - afterInstall: function(options) { + afterInstall: function (options) { if (options.dryRun) { return; } @@ -136,14 +136,17 @@ module.exports = { const returns = []; const className = stringUtils.classify(`${options.entity.name}Component`); const fileName = stringUtils.dasherize(`${options.entity.name}.component`); - const componentDir = path.relative(path.dirname(this.pathToModule), this.generatePath); - const importPath = componentDir ? `./${componentDir}/${fileName}` : `./${fileName}`; - if (!options['skip-import']) { - returns.push( - astUtils.addDeclarationToModule(this.pathToModule, className, importPath) - .then(change => change.apply(NodeHost))); - } + this.modulePaths.forEach((pathToModule) => { + const componentDir = path.relative(path.dirname(pathToModule), this.generatePath); + const importPath = componentDir ? `./${componentDir}/${fileName}` : `./${fileName}`; + + if (!options['skip-import']) { + returns.push( + astUtils.addDeclarationToModule(pathToModule, className, importPath) + .then(change => change.apply(NodeHost))); + } + }); return Promise.all(returns); } diff --git a/packages/angular-cli/blueprints/directive/index.js b/packages/angular-cli/blueprints/directive/index.js index edf0af1548c3..37bb8c1b8f75 100644 --- a/packages/angular-cli/blueprints/directive/index.js +++ b/packages/angular-cli/blueprints/directive/index.js @@ -16,9 +16,9 @@ module.exports = { { name: 'spec', type: Boolean } ], - beforeInstall: function() { + beforeInstall: function () { try { - this.pathToModule = findParentModule(this.project, this.dynamicPath.dir); + this.modulePaths = findParentModule(this.project, this.dynamicPath.dir); } catch(e) { throw `Error locating module for declaration\n\t${e}`; } @@ -77,7 +77,7 @@ module.exports = { }; }, - afterInstall: function(options) { + afterInstall: function (options) { if (options.dryRun) { return; } @@ -85,16 +85,19 @@ module.exports = { const returns = []; const className = stringUtils.classify(`${options.entity.name}Directive`); const fileName = stringUtils.dasherize(`${options.entity.name}.directive`); - const fullGeneratePath = path.join(this.project.root, this.generatePath); - const moduleDir = path.parse(this.pathToModule).dir; - const relativeDir = path.relative(moduleDir, fullGeneratePath); - const importPath = relativeDir ? `./${relativeDir}/${fileName}` : `./${fileName}`; - - if (!options['skip-import']) { - returns.push( - astUtils.addDeclarationToModule(this.pathToModule, className, importPath) - .then(change => change.apply(NodeHost))); - } + + this.modulePaths.forEach((pathToModule) => { + const fullGeneratePath = path.join(this.project.root, this.generatePath); + const moduleDir = path.parse(pathToModule).dir; + const relativeDir = path.relative(moduleDir, fullGeneratePath); + const importPath = relativeDir ? `./${relativeDir}/${fileName}` : `./${fileName}`; + + if (!options['skip-import']) { + returns.push( + astUtils.addDeclarationToModule(pathToModule, className, importPath) + .then(change => change.apply(NodeHost))); + } + }); return Promise.all(returns); } diff --git a/packages/angular-cli/blueprints/ng2/files/__path__/app/index.ts b/packages/angular-cli/blueprints/ng2/files/__path__/app/index.ts index 875bdb2f254f..1e84369cbdfb 100644 --- a/packages/angular-cli/blueprints/ng2/files/__path__/app/index.ts +++ b/packages/angular-cli/blueprints/ng2/files/__path__/app/index.ts @@ -1,2 +1,2 @@ -export * from './app.component'; -export * from './app.module'; +export * from './app.component';<% if(!universal) { %> +export * from './app.module';<% } %> diff --git a/packages/angular-cli/blueprints/ng2/files/__path__/index.html b/packages/angular-cli/blueprints/ng2/files/__path__/index.html index 1f8c4ad70d2d..4706edbde256 100644 --- a/packages/angular-cli/blueprints/ng2/files/__path__/index.html +++ b/packages/angular-cli/blueprints/ng2/files/__path__/index.html @@ -22,6 +22,7 @@ <% } %> + <% if (universal) { %><% } %> <<%= prefix %>-root>Loading...-root> diff --git a/packages/angular-cli/blueprints/ng2/files/__path__/tsconfig.json b/packages/angular-cli/blueprints/ng2/files/__path__/tsconfig.json index 731b5d49c7ab..4c324a0f67ba 100644 --- a/packages/angular-cli/blueprints/ng2/files/__path__/tsconfig.json +++ b/packages/angular-cli/blueprints/ng2/files/__path__/tsconfig.json @@ -12,6 +12,7 @@ "target": "es5", "typeRoots": [ "<%= relativeRootPath %>/node_modules/@types" - ] + ]<% if(universal) { %>, + "types": [ "node" ]<% } %> } } diff --git a/packages/angular-cli/blueprints/ng2/files/angular-cli.json b/packages/angular-cli/blueprints/ng2/files/angular-cli.json index 4fd88b98c1cf..a4db4e224694 100644 --- a/packages/angular-cli/blueprints/ng2/files/angular-cli.json +++ b/packages/angular-cli/blueprints/ng2/files/angular-cli.json @@ -11,12 +11,15 @@ "assets", "favicon.ico" ], - "index": "index.html", - "main": "main.ts", + "index": "index.html",<% if(!universal) { %> + "main": "main.ts",<% } %><% if(universal) { %> + "main": "client.ts", + "nodeMain": "server.ts",<% } %> "test": "test.ts", "tsconfig": "tsconfig.json", "prefix": "<%= prefix %>", "mobile": <%= isMobile %>, + "universal": <%= universal %>, "styles": [ "styles.<%= styleExt %>" ], diff --git a/packages/angular-cli/blueprints/ng2/files/package.json b/packages/angular-cli/blueprints/ng2/files/package.json index ba8506a9b1be..06455ea47097 100644 --- a/packages/angular-cli/blueprints/ng2/files/package.json +++ b/packages/angular-cli/blueprints/ng2/files/package.json @@ -12,14 +12,20 @@ }, "private": true, "dependencies": { - "@angular/common": "~2.1.0", - "@angular/compiler": "~2.1.0", - "@angular/core": "~2.1.0", - "@angular/forms": "~2.1.0", - "@angular/http": "~2.1.0", - "@angular/platform-browser": "~2.1.0", - "@angular/platform-browser-dynamic": "~2.1.0", - "@angular/router": "~3.1.0", + "@angular/common": "2.1.0", + "@angular/compiler": "2.1.0", + "@angular/core": "2.1.0", + "@angular/forms": "2.1.0", + "@angular/http": "2.1.0", + "@angular/platform-browser": "2.1.0", + "@angular/platform-browser-dynamic": "2.1.0", + "@angular/router": "3.1.0",<% if(universal) { %> + "@angular/platform-server": "2.1.0", + "angular2-platform-node": "2.0.11", + "angular2-universal": "2.0.11", + "angular2-universal-polyfills": "2.0.11", + "angular2-express-engine": "2.0.11", + "express": "^4.14.0",<% } %> "core-js": "^2.4.1", "rxjs": "5.0.0-beta.12", "ts-helpers": "^1.1.1", @@ -33,8 +39,15 @@ "angular2-universal-polyfills": "0.4.1", "preboot": "2.1.2", "parse5": "1.5.1",<% } %> - "@types/jasmine": "^2.2.30", - "@types/node": "^6.0.42", + "@types/jasmine": "^2.2.30",<% if(universal) { %> + "@types/body-parser": "0.0.29", + "@types/compression": "0.0.29", + "@types/cookie-parser": "^1.3.29", + "@types/express": "^4.0.29", + "@types/express-serve-static-core": "^4.0.29", + "@types/mime": "0.0.28", + "@types/node": "^4.0.30", + "@types/serve-static": "^1.7.27",<% } %> "angular-cli": "<%= version %>", "codelyzer": "~1.0.0-beta.3", "jasmine-core": "2.4.1", diff --git a/packages/angular-cli/blueprints/ng2/index.js b/packages/angular-cli/blueprints/ng2/index.js index 3ab5dd53ea42..cba9b7031cf6 100644 --- a/packages/angular-cli/blueprints/ng2/index.js +++ b/packages/angular-cli/blueprints/ng2/index.js @@ -1,5 +1,5 @@ -const Blueprint = require('../../ember-cli/lib/models/blueprint'); -const path = require('path'); +const Blueprint = require('ember-cli/lib/models/blueprint'); +const path = require('path'); const stringUtils = require('ember-cli-string-utils'); const getFiles = Blueprint.prototype.files; @@ -11,6 +11,7 @@ module.exports = { { name: 'prefix', type: String, default: 'app', aliases: ['p'] }, { name: 'style', type: String, default: 'css' }, { name: 'mobile', type: Boolean, default: false }, + { name: 'universal', type: Boolean, default: false }, { name: 'routing', type: Boolean, default: false }, { name: 'inline-style', type: Boolean, default: false, aliases: ['is'] }, { name: 'inline-template', type: Boolean, default: false, aliases: ['it'] } @@ -23,12 +24,20 @@ module.exports = { }, afterInstall: function (options) { + var bluePrints = []; + if (options.mobile) { - return Blueprint.load(path.join(__dirname, '../mobile')).install(options); + bluePrints.push(Blueprint.load(path.join(__dirname, '../mobile')).install(options)); + } + if (options.universal) { + Blueprint.load(path.join(__dirname, '../ng2')); + bluePrints.push(Blueprint.load(path.join(__dirname, '../universal')).install(options)); } + + return Promise.all(bluePrints); }, - locals: function(options) { + locals: function (options) { this.styleExt = options.style; this.version = require(path.resolve(__dirname, '../../package.json')).version; @@ -54,13 +63,14 @@ module.exports = { styleExt: this.styleExt, relativeRootPath: relativeRootPath, isMobile: options.mobile, + universal: options.universal, routing: options.routing, inlineStyle: options.inlineStyle, inlineTemplate: options.inlineTemplate }; }, - files: function() { + files: function () { var fileList = getFiles.call(this); if (this.options && !this.options.routing) { @@ -73,6 +83,11 @@ module.exports = { fileList = fileList.filter(p => p.indexOf('app.component.__styleext__') < 0); } + if (this.options && this.options.universal) { + fileList = fileList.filter(p => p.indexOf('main.ts') < 0); + fileList = fileList.filter(p => p.indexOf('app.module.ts') < 0); + } + return fileList; }, diff --git a/packages/angular-cli/blueprints/pipe/index.js b/packages/angular-cli/blueprints/pipe/index.js index 2fa51ddad727..5a31c99387ee 100644 --- a/packages/angular-cli/blueprints/pipe/index.js +++ b/packages/angular-cli/blueprints/pipe/index.js @@ -15,9 +15,9 @@ module.exports = { { name: 'spec', type: Boolean } ], - beforeInstall: function() { + beforeInstall: function () { try { - this.pathToModule = findParentModule(this.project, this.dynamicPath.dir); + this.modulePaths = findParentModule(this.project, this.dynamicPath.dir); } catch(e) { throw `Error locating module for declaration\n\t${e}`; } @@ -65,7 +65,7 @@ module.exports = { }; }, - afterInstall: function(options) { + afterInstall: function (options) { if (options.dryRun) { return; } @@ -73,16 +73,19 @@ module.exports = { const returns = []; const className = stringUtils.classify(`${options.entity.name}Pipe`); const fileName = stringUtils.dasherize(`${options.entity.name}.pipe`); - const fullGeneratePath = path.join(this.project.root, this.generatePath); - const moduleDir = path.parse(this.pathToModule).dir; - const relativeDir = path.relative(moduleDir, fullGeneratePath); - const importPath = relativeDir ? `./${relativeDir}/${fileName}` : `./${fileName}`; - - if (!options['skip-import']) { - returns.push( - astUtils.addDeclarationToModule(this.pathToModule, className, importPath) - .then(change => change.apply(NodeHost))); - } + + this.modulePaths.forEach((pathToModule) => { + const fullGeneratePath = path.join(this.project.root, this.generatePath); + const moduleDir = path.parse(pathToModule).dir; + const relativeDir = path.relative(moduleDir, fullGeneratePath); + const importPath = relativeDir ? `./${relativeDir}/${fileName}` : `./${fileName}`; + + if (!options['skip-import']) { + returns.push( + astUtils.addDeclarationToModule(pathToModule, className, importPath) + .then(change => change.apply(NodeHost))); + } + }); return Promise.all(returns); } diff --git a/packages/angular-cli/blueprints/universal/files/__path__/app/app.browser.module.ts b/packages/angular-cli/blueprints/universal/files/__path__/app/app.browser.module.ts new file mode 100644 index 000000000000..70d9d9525f80 --- /dev/null +++ b/packages/angular-cli/blueprints/universal/files/__path__/app/app.browser.module.ts @@ -0,0 +1,39 @@ +/** + * This file and `main.node.ts` are identical, at the moment(!) + * By splitting these, you're able to create logic, imports, etc that are "Platform" specific. + * If you want your code to be completely Universal and don't need that + * You can also just have 1 file, that is imported into both + * client.ts and server.ts + */ + +import { NgModule } from '@angular/core'; +import { UniversalModule } from 'angular2-universal'; +import { FormsModule } from '@angular/forms'; +import { AppComponent } from './index'; +// import { RouterModule } from '@angular/router'; +// import { appRoutes } from './app/app.routing'; + +/** + * Top-level NgModule "container" + */ +@NgModule({ + /** Root App Component */ + bootstrap: [ AppComponent ], + /** Our Components */ + declarations: [ AppComponent ], + imports: [ + /** + * NOTE: Needs to be your first import (!) + * BrowserModule, HttpModule, and JsonpModule are included + */ + UniversalModule, + FormsModule + /** + * using routes + */ + // RouterModule.forRoot(appRoutes) + ] +}) +export class AppModule { + +} diff --git a/packages/angular-cli/blueprints/universal/files/__path__/app/app.node.module.ts b/packages/angular-cli/blueprints/universal/files/__path__/app/app.node.module.ts new file mode 100644 index 000000000000..89298579c259 --- /dev/null +++ b/packages/angular-cli/blueprints/universal/files/__path__/app/app.node.module.ts @@ -0,0 +1,39 @@ +/** + * This file and `main.browser.ts` are identical, at the moment(!) + * By splitting these, you're able to create logic, imports, etc that are "Platform" specific. + * If you want your code to be completely Universal and don't need that + * You can also just have 1 file, that is imported into both + * client.ts and server.ts + */ + +import { NgModule } from '@angular/core'; +import { UniversalModule } from 'angular2-universal'; +import { FormsModule } from '@angular/forms'; +import { AppComponent } from './index'; +// import { RouterModule } from '@angular/router'; +// import { appRoutes } from './app/app.routing'; + +/** + * Top-level NgModule "container" + */ +@NgModule({ + /** Root App Component */ + bootstrap: [ AppComponent ], + /** Our Components */ + declarations: [ AppComponent ], + imports: [ + /** + * NOTE: Needs to be your first import (!) + * NodeModule, NodeHttpModule, NodeJsonpModule are included + */ + UniversalModule, + FormsModule + /** + * using routes + */ + // RouterModule.forRoot(appRoutes) + ] +}) +export class AppModule { + +} diff --git a/packages/angular-cli/blueprints/universal/files/__path__/client.ts b/packages/angular-cli/blueprints/universal/files/__path__/client.ts new file mode 100644 index 000000000000..9b771050f951 --- /dev/null +++ b/packages/angular-cli/blueprints/universal/files/__path__/client.ts @@ -0,0 +1,24 @@ +/** + * the polyfills must be the first thing imported + */ +import 'angular2-universal-polyfills'; +import { enableProdMode } from '@angular/core'; +import { environment } from './environments/environment'; +import { platformUniversalDynamic } from 'angular2-universal'; +import { AppModule } from './app/app.browser.module'; + +/** + * enable prod mode for production environments + */ +if (environment.production) { + enableProdMode(); +} + +const platformRef = platformUniversalDynamic(); + +/** + * bootstrap Angular 2 on document ready + */ +document.addEventListener('DOMContentLoaded', () => { + platformRef.bootstrapModule(AppModule); +}); diff --git a/packages/angular-cli/blueprints/universal/files/__path__/server.ts b/packages/angular-cli/blueprints/universal/files/__path__/server.ts new file mode 100644 index 000000000000..6b880b2eb3f8 --- /dev/null +++ b/packages/angular-cli/blueprints/universal/files/__path__/server.ts @@ -0,0 +1,76 @@ +/** + * the polyfills must be the first thing imported + */ +import 'angular2-universal-polyfills'; +import * as path from 'path'; +import * as express from 'express'; +import { enableProdMode } from '@angular/core'; +import { createEngine } from 'angular2-express-engine'; +import { AppModule } from './app/app.node.module'; +import { environment } from './environments/environment'; + +const app = express(); +const ROOT = path.join(path.resolve(__dirname, '..')); +const port = process.env.PORT || 4200; + +/** + * enable prod mode for production environments + */ +if (environment.production) { + enableProdMode(); +} + +/** + * Express View + */ +app.engine('.html', createEngine({})); +app.set('views', __dirname); +app.set('view engine', 'html'); + +/** + * serve static files + */ +app.use(express.static(path.join(ROOT, 'dist'), {index: false})); + +/** + * place your api routes here + */ +// app.use('/api', api); + +/** + * bootstrap universal app + * @param req + * @param res + */ +function ngApp(req: any, res: any) { + res.render('index', { + req, + res, + ngModule: AppModule, + preboot: false, + baseUrl: '/', + requestUrl: req.originalUrl, + originUrl: req.hostname + }); +} + +/** + * use universal for specific routes + */ +app.get('/', ngApp); +app.get('/about', ngApp); +app.get('/about/*', ngApp); + +/** + * if you want to use universal for all routes, you can use the '*' wildcard + */ +// app.get('*', ngApp); + +app.get('*', function(req: any, res: any) { + res.setHeader('Content-Type', 'application/json'); + const pojo = { status: 404, message: 'No Content' }; + const json = JSON.stringify(pojo, null, 2); + res.status(404).send(json); +}); + +app.listen(port); diff --git a/packages/angular-cli/blueprints/universal/index.js b/packages/angular-cli/blueprints/universal/index.js new file mode 100644 index 000000000000..ff091e6806a3 --- /dev/null +++ b/packages/angular-cli/blueprints/universal/index.js @@ -0,0 +1,32 @@ +const stringUtils = require('ember-cli-string-utils'); + +module.exports = { + description: '', + + availableOptions: [ + { name: 'source-dir', type: String, default: 'src', aliases: ['sd'] }, + { name: 'prefix', type: String, default: 'app', aliases: ['p'] } + ], + + locals: function (options) { + const fullAppName = stringUtils.dasherize(options.entity.name) + .replace(/-(.)/g, (_, l) => ' ' + l.toUpperCase()) + .replace(/^./, (l) => l.toUpperCase()); + + return { + jsComponentName: stringUtils.classify(options.entity.name), + fullAppName: fullAppName, + sourceDir: options.sourceDir, + prefix: options.prefix + }; + }, + + fileMapTokens: function (options) { + // Return custom template variables here. + return { + __path__: () => { + return options.locals.sourceDir; + } + }; + } +}; diff --git a/packages/angular-cli/commands/init.ts b/packages/angular-cli/commands/init.ts index cf7bd381b1ad..54380b5d9ffb 100644 --- a/packages/angular-cli/commands/init.ts +++ b/packages/angular-cli/commands/init.ts @@ -26,6 +26,7 @@ const InitCommand: any = Command.extend({ { name: 'style', type: String, default: 'css' }, { name: 'prefix', type: String, default: 'app', aliases: ['p'] }, { name: 'mobile', type: Boolean, default: false }, + { name: 'universal', type: Boolean, default: false }, { name: 'routing', type: Boolean, default: false }, { name: 'inline-style', type: Boolean, default: false, aliases: ['is'] }, { name: 'inline-template', type: Boolean, default: false, aliases: ['it'] } @@ -103,6 +104,7 @@ const InitCommand: any = Command.extend({ style: commandOptions.style, prefix: commandOptions.prefix, mobile: commandOptions.mobile, + universal: commandOptions.universal, routing: commandOptions.routing, inlineStyle: commandOptions.inlineStyle, inlineTemplate: commandOptions.inlineTemplate, diff --git a/packages/angular-cli/commands/new.ts b/packages/angular-cli/commands/new.ts index 81ee12b2cdca..02f69fc3aeb5 100644 --- a/packages/angular-cli/commands/new.ts +++ b/packages/angular-cli/commands/new.ts @@ -24,6 +24,7 @@ const NewCommand = Command.extend({ { name: 'style', type: String, default: 'css' }, { name: 'prefix', type: String, default: 'app', aliases: ['p'] }, { name: 'mobile', type: Boolean, default: false }, + { name: 'universal', type: Boolean, default: false }, { name: 'routing', type: Boolean, default: false }, { name: 'inline-style', type: Boolean, default: false, aliases: ['is'] }, { name: 'inline-template', type: Boolean, default: false, aliases: ['it'] } diff --git a/packages/angular-cli/lib/config/schema.d.ts b/packages/angular-cli/lib/config/schema.d.ts index 1f5ea0d0d526..16add78f0cbc 100644 --- a/packages/angular-cli/lib/config/schema.d.ts +++ b/packages/angular-cli/lib/config/schema.d.ts @@ -15,10 +15,12 @@ export interface CliConfig { assets?: string; index?: string; main?: string; + nodeMain?: string; test?: string; tsconfig?: string; prefix?: string; mobile?: boolean; + universal?: boolean; /** * Global styles to be included in the build. */ diff --git a/packages/angular-cli/lib/config/schema.json b/packages/angular-cli/lib/config/schema.json index 37668441c0b0..3a64f1cad4df 100644 --- a/packages/angular-cli/lib/config/schema.json +++ b/packages/angular-cli/lib/config/schema.json @@ -46,6 +46,9 @@ "main": { "type": "string" }, + "nodeMain": { + "type": "string" + }, "test": { "type": "string" }, @@ -58,6 +61,9 @@ "mobile": { "type": "boolean" }, + "universal": { + "type": "boolean" + }, "styles": { "description": "Global styles to be included in the build.", "type": "array", diff --git a/packages/angular-cli/models/index.ts b/packages/angular-cli/models/index.ts index b4205cf32e91..b42f1ec12afb 100644 --- a/packages/angular-cli/models/index.ts +++ b/packages/angular-cli/models/index.ts @@ -3,3 +3,4 @@ export * from './webpack-build-production'; export * from './webpack-build-development'; export * from './webpack-build-mobile'; export * from './webpack-build-utils'; +export * from './webpack-build-node'; diff --git a/packages/angular-cli/models/webpack-build-common.ts b/packages/angular-cli/models/webpack-build-common.ts index 6d1bbe01c76f..0fc9446d73d4 100644 --- a/packages/angular-cli/models/webpack-build-common.ts +++ b/packages/angular-cli/models/webpack-build-common.ts @@ -22,10 +22,10 @@ export function getWebpackCommonConfig( const scripts = appConfig.scripts ? appConfig.scripts.map((script: string) => path.resolve(appRoot, script)) : []; + const entryName: string = path.basename(appMain).replace('.ts', ''); - let entry: { [key: string]: string[] } = { - main: [appMain] - }; + let entry: { [key: string]: string[] } = {}; + entry[entryName] = [appMain]; // Only add styles/scripts if there's actually entries there if (appConfig.styles.length > 0) { entry['styles'] = styles; } diff --git a/packages/angular-cli/models/webpack-build-node.ts b/packages/angular-cli/models/webpack-build-node.ts new file mode 100644 index 000000000000..8e26ee637c2c --- /dev/null +++ b/packages/angular-cli/models/webpack-build-node.ts @@ -0,0 +1,217 @@ +import * as path from 'path'; +import * as webpack from 'webpack'; +const webpackMerge = require('webpack-merge'); +const CompressionPlugin = require('compression-webpack-plugin'); +const ExtractTextPlugin = require('extract-text-webpack-plugin'); + +export function getWebpackNodeConfig(projectRoot: string, environment: string, appConfig: any) { + const checkNodeImport = function (context: any, request: any, cb: any) { + if (!path.isAbsolute(request) && request.charAt(0) !== '.') { + cb(null, 'commonjs ' + request); + return; + } + cb(); + }; + const appRoot = path.resolve(projectRoot, appConfig.root); + const nodeMain = path.resolve(appRoot, appConfig.nodeMain); + const styles = appConfig.styles + ? appConfig.styles.map((style: string) => path.resolve(appRoot, style)) + : []; + const scripts = appConfig.scripts + ? appConfig.scripts.map((script: string) => path.resolve(appRoot, script)) + : []; + const entryName: string = path.basename(nodeMain).replace('.ts', ''); + let entry: { [key: string]: string[] } = {}; + entry[entryName] = [nodeMain]; + + const commonConfig: any = { + resolve: { + extensions: ['.ts', '.js'], + modules: [path.resolve(projectRoot, 'node_modules')] + }, + context: path.resolve(__dirname, './'), + output: { + path: path.resolve(projectRoot, appConfig.outDir), + filename: '[name].bundle.js', + libraryTarget: 'commonjs2' + }, + module: { + rules: [ + { + enforce: 'pre', + test: /\.js$/, + loader: 'source-map-loader', + exclude: [ + /node_modules/ + ] + }, + { + test: /\.ts$/, + loaders: [{ + loader: 'awesome-typescript-loader', + query: { + useForkChecker: true, + tsconfig: path.resolve(appRoot, appConfig.tsconfig) + } + }, { + loader: 'angular2-template-loader' + }], + exclude: [/\.(spec|e2e)\.ts$/] + }, + // in main, load css as raw text + { + exclude: styles, + test: /\.css$/, + loaders: ['raw-loader', 'postcss-loader'] + }, { + exclude: styles, + test: /\.styl$/, + loaders: ['raw-loader', 'postcss-loader', 'stylus-loader'] + }, + { + exclude: styles, + test: /\.less$/, + loaders: ['raw-loader', 'postcss-loader', 'less-loader'] + }, { + exclude: styles, + test: /\.scss$|\.sass$/, + loaders: ['raw-loader', 'postcss-loader', 'sass-loader'] + }, + + + // load global scripts using script-loader + {include: scripts, test: /\.js$/, loader: 'script-loader'}, + + {test: /\.json$/, loader: 'json-loader'}, + {test: /\.(jpg|png|gif)$/, loader: 'url-loader?limit=10000'}, + {test: /\.html$/, loader: 'raw-loader'}, + + {test: /\.(otf|ttf|woff|woff2)$/, loader: 'url?limit=10000'}, + {test: /\.(eot|svg)$/, loader: 'file'} + ] + }, + plugins: [ + new webpack.ContextReplacementPlugin( + // The (\\|\/) piece accounts for path separators in *nix and Windows + /angular(\\|\/)core(\\|\/)src(\\|\/)linker/, + path.resolve(__dirname, './src'), + {} + ), + new webpack.NormalModuleReplacementPlugin( + // This plugin is responsible for swapping the environment files. + // Since it takes a RegExp as first parameter, we need to escape the path. + // See https://webpack.github.io/docs/list-of-plugins.html#normalmodulereplacementplugin + new RegExp(path.resolve(appRoot, appConfig.environments['source']) + .replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&')), + path.resolve(appRoot, appConfig.environments[environment]) + ), + ], + entry: entry, + target: 'node', + externals: checkNodeImport, + node: { + global: true, + __dirname: false, + __filename: true, + process: true, + Buffer: true + } + }; + const devConfig: any = { + devtool: 'inline-source-map', + module: { + rules: [ + // outside of main, load it via style-loader for development builds + { + include: styles, + test: /\.css$/, + loaders: [ + 'style-loader', + 'css-loader?sourcemap', + 'postcss-loader' + ] + }, { + include: styles, + test: /\.styl$/, + loaders: [ + 'style-loader', + 'css-loader?sourcemap', + 'postcss-loader', + 'stylus-loader?sourcemap' + ] + }, { + include: styles, + test: /\.less$/, + loaders: [ + 'style-loader', + 'css-loader?sourcemap', + 'postcss-loader', + 'less-loader?sourcemap' + ] + }, { + include: styles, + test: /\.scss$|\.sass$/, + loaders: [ + 'style-loader', + 'css-loader?sourcemap', + 'postcss-loader', + 'sass-loader?sourcemap' + ] + }, + ] + } + }; + const prodConfig: any = { + devtool: 'source-map', + module: { + rules: [ + // outside of main, load it via extract-text-plugin for production builds + { + include: styles, + test: /\.css$/, + loaders: ExtractTextPlugin.extract([ + 'css-loader?sourcemap&minimize', 'postcss-loader' + ]) + }, { + include: styles, + test: /\.styl$/, + loaders: ExtractTextPlugin.extract([ + 'css-loader?sourcemap&minimize', 'postcss-loader', 'stylus-loader?sourcemap' + ]) + }, { + include: styles, + test: /\.less$/, + loaders: ExtractTextPlugin.extract([ + 'css-loader?sourcemap&minimize', 'postcss-loader', 'less-loader?sourcemap' + ]) + }, { + include: styles, + test: /\.scss$|\.sass$/, + loaders: ExtractTextPlugin.extract([ + 'css-loader?sourcemap&minimize', 'postcss-loader', 'sass-loader?sourcemap' + ]) + }, + ] + }, + plugins: [ + new webpack.optimize.UglifyJsPlugin({ + mangle: {screw_ie8: true}, + compress: {screw_ie8: true}, + sourceMap: true + }), + new CompressionPlugin({ + asset: '[path].gz[query]', + algorithm: 'gzip', + test: /\.js$|\.html$/, + threshold: 10240, + minRatio: 0.8 + }) + ] + }; + + if (environment === 'prod') { + return webpackMerge(commonConfig, prodConfig); + } else { + return webpackMerge(commonConfig, devConfig); + } +} diff --git a/packages/angular-cli/models/webpack-build-production.ts b/packages/angular-cli/models/webpack-build-production.ts index e925035a7395..9a535caeb240 100644 --- a/packages/angular-cli/models/webpack-build-production.ts +++ b/packages/angular-cli/models/webpack-build-production.ts @@ -2,6 +2,7 @@ import * as path from 'path'; const WebpackMd5Hash = require('webpack-md5-hash'); const CompressionPlugin = require('compression-webpack-plugin'); import * as webpack from 'webpack'; +const webpackMerge = require('webpack-merge'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); declare module 'webpack' { @@ -17,10 +18,28 @@ declare module 'webpack' { export const getWebpackProdConfigPartial = function(projectRoot: string, appConfig: any) { const appRoot = path.resolve(projectRoot, appConfig.root); const styles = appConfig.styles - ? appConfig.styles.map((style: string) => path.resolve(appRoot, style)) - : []; + ? appConfig.styles.map((style: string) => path.resolve(appRoot, style)) + : []; const cssLoaders = ['css-loader?sourcemap&minimize', 'postcss-loader']; - return { + + let universalPartial: any = {}; + + if (appConfig.universal === true) { + universalPartial.module = { + rules: [ + { + test: /index\.html$/, + loader: 'string-replace', + query: { + search: '', + replace: '' + } + } + ] + }; + } + + const baseConfig: any = { devtool: 'source-map', output: { path: path.resolve(projectRoot, appConfig.outDir), @@ -31,7 +50,7 @@ export const getWebpackProdConfigPartial = function(projectRoot: string, appConf module: { rules: [ // outside of main, load it via extract-text-plugin for production builds -        { + { include: styles, test: /\.css$/, loaders: ExtractTextPlugin.extract(cssLoaders) @@ -62,11 +81,11 @@ export const getWebpackProdConfigPartial = function(projectRoot: string, appConf sourceMap: true }), new CompressionPlugin({ - asset: '[path].gz[query]', - algorithm: 'gzip', - test: /\.js$|\.html$/, - threshold: 10240, - minRatio: 0.8 + asset: '[path].gz[query]', + algorithm: 'gzip', + test: /\.js$|\.html$/, + threshold: 10240, + minRatio: 0.8 }), new webpack.LoaderOptionsPlugin({ options: { @@ -77,4 +96,6 @@ export const getWebpackProdConfigPartial = function(projectRoot: string, appConf }) ] }; + + return webpackMerge(baseConfig, universalPartial); }; diff --git a/packages/angular-cli/models/webpack-config.ts b/packages/angular-cli/models/webpack-config.ts index 6317fef937a3..a3b90e16b542 100644 --- a/packages/angular-cli/models/webpack-config.ts +++ b/packages/angular-cli/models/webpack-config.ts @@ -9,13 +9,14 @@ import { getWebpackDevConfigPartial, getWebpackProdConfigPartial, getWebpackMobileConfigPartial, - getWebpackMobileProdConfigPartial + getWebpackMobileProdConfigPartial, + getWebpackNodeConfig } from './'; export class NgCliWebpackConfig { // TODO: When webpack2 types are finished lets replace all these any types // so this is more maintainable in the future for devs - public config: any; + public configs: any[] = []; constructor( public ngCliProject: any, @@ -30,6 +31,10 @@ export class NgCliWebpackConfig { appConfig.outDir = outputDir || appConfig.outDir; + if (appConfig.universal === true && isAoT === true) { + throw new Error('AoT is not supported in universal yet.'); + } + let baseConfig = getWebpackCommonConfig( this.ngCliProject.root, environment, @@ -51,11 +56,15 @@ export class NgCliWebpackConfig { } } - this.config = webpackMerge( + this.configs.push(webpackMerge( baseConfig, targetConfigPartial, typescriptConfigPartial - ); + )); + + if (appConfig.universal === true) { + this.configs.push(getWebpackNodeConfig(this.ngCliProject.root, environment, appConfig)); + } } getTargetConfig(projectRoot: string, appConfig: any): any { diff --git a/packages/angular-cli/package.json b/packages/angular-cli/package.json index a9ab3b575c09..d42c19cab830 100644 --- a/packages/angular-cli/package.json +++ b/packages/angular-cli/package.json @@ -1,9 +1,9 @@ { - "name": "angular-cli", - "version": "1.0.0-beta.19-3", - "description": "CLI tool for Angular", + "name": "universal-cli", + "version": "1.0.0-beta.1", + "description": "CLI tool for Angular with Angular Universal support", "main": "lib/cli/index.js", - "trackingCode": "UA-8594346-19", + "trackingCode": "", "bin": { "ng": "./bin/ng" }, @@ -12,7 +12,7 @@ ], "repository": { "type": "git", - "url": "https://github.com/angular/angular-cli.git" + "url": "https://github.com/devCrossNet/angular-cli.git" }, "engines": { "node": ">= 4.1.0", @@ -21,9 +21,9 @@ "author": "Angular Authors", "license": "MIT", "bugs": { - "url": "https://github.com/angular/angular-cli/issues" + "url": "https://github.com/devCrossNet/angular-cli/issues" }, - "homepage": "https://github.com/angular/angular-cli", + "homepage": "https://github.com/devCrossNet/angular-cli", "dependencies": { "@angular-cli/ast-tools": "^1.0.1", "@angular-cli/base-href-webpack": "^1.0.0", @@ -76,6 +76,7 @@ "mkdirp": "^0.5.1", "node-modules-path": "^1.0.0", "node-sass": "^3.10.1", + "nodemon": "^1.10.0", "node-uuid": "^1.4.3", "nopt": "^3.0.1", "npm-run-all": "^3.0.0", @@ -104,6 +105,7 @@ "style-loader": "^0.13.1", "stylus": "^0.54.5", "stylus-loader": "^2.1.0", + "tiny-lr": "^0.2.1", "temp": "0.8.3", "through": "^2.3.6", "ts-loader": "^0.8.2", diff --git a/packages/angular-cli/tasks/build-webpack-watch.ts b/packages/angular-cli/tasks/build-webpack-watch.ts index 45a1f6e55a55..b75d52e31953 100644 --- a/packages/angular-cli/tasks/build-webpack-watch.ts +++ b/packages/angular-cli/tasks/build-webpack-watch.ts @@ -18,15 +18,15 @@ export default Task.extend({ const outputDir = runTaskOptions.outputPath || CliConfig.fromProject().config.apps[0].outDir; rimraf.sync(path.resolve(project.root, outputDir)); - const config = new NgCliWebpackConfig( + const configs = new NgCliWebpackConfig( project, runTaskOptions.target, runTaskOptions.environment, outputDir, runTaskOptions.baseHref, runTaskOptions.aot - ).config; - const webpackCompiler: any = webpack(config); + ).configs; + const webpackCompiler: any = webpack(configs); webpackCompiler.apply(new ProgressPlugin({ profile: true diff --git a/packages/angular-cli/tasks/build-webpack.ts b/packages/angular-cli/tasks/build-webpack.ts index e47564863eeb..3a8430225081 100644 --- a/packages/angular-cli/tasks/build-webpack.ts +++ b/packages/angular-cli/tasks/build-webpack.ts @@ -17,18 +17,19 @@ export default Task.extend({ const outputDir = runTaskOptions.outputPath || CliConfig.fromProject().config.apps[0].outDir; rimraf.sync(path.resolve(project.root, outputDir)); - const config = new NgCliWebpackConfig( + + const configs = new NgCliWebpackConfig( project, runTaskOptions.target, runTaskOptions.environment, outputDir, runTaskOptions.baseHref, runTaskOptions.aot - ).config; + ).configs; - const webpackCompiler: any = webpack(config); + const webpackCompiler: any = webpack(configs); - const ProgressPlugin = require('webpack/lib/ProgressPlugin'); + const ProgressPlugin = require('webpack/lib/ProgressPlugin'); webpackCompiler.apply(new ProgressPlugin({ profile: true diff --git a/packages/angular-cli/tasks/serve-webpack.ts b/packages/angular-cli/tasks/serve-webpack.ts index 798d4e38f69a..2250430edf26 100644 --- a/packages/angular-cli/tasks/serve-webpack.ts +++ b/packages/angular-cli/tasks/serve-webpack.ts @@ -11,30 +11,35 @@ import { NgCliWebpackConfig } from '../models/webpack-config'; import { ServeTaskOptions } from '../commands/serve'; import { CliConfig } from '../models/config'; import { oneLine } from 'common-tags'; +import { UniversalDevServer } from './server/universal-dev-server'; import * as url from 'url'; const opn = require('opn'); export default Task.extend({ - run: function(commandOptions: ServeTaskOptions) { + run: function (commandOptions: ServeTaskOptions) { const ui = this.ui; let webpackCompiler: any; - let config = new NgCliWebpackConfig( + let configs = new NgCliWebpackConfig( this.project, commandOptions.target, commandOptions.environment, undefined, undefined, commandOptions.aot - ).config; + ).configs; + + const appConfig = CliConfig.fromProject().config.apps[0]; // This allows for live reload of page when changes are made to repo. // https://webpack.github.io/docs/webpack-dev-server.html#inline-mode - config.entry.main.unshift( - `webpack-dev-server/client?http://${commandOptions.host}:${commandOptions.port}/` - ); - webpackCompiler = webpack(config); + if (appConfig.universal === false) { + configs[0].entry['main'] + .unshift(`webpack-dev-server/client?http://${commandOptions.host}:${commandOptions.port}/`); + } + + webpackCompiler = webpack(configs); webpackCompiler.apply(new ProgressPlugin({ profile: true, @@ -68,7 +73,7 @@ export default Task.extend({ const webpackDevServerConfiguration: IWebpackDevServerConfigurationOptions = { contentBase: path.resolve( this.project.root, - `./${CliConfig.fromProject().config.apps[0].root}` + `./${appConfig.root}` ), headers: { 'Access-Control-Allow-Origin': '*' }, historyApiFallback: { @@ -90,16 +95,29 @@ export default Task.extend({ webpackDevServerConfiguration.cert = sslCert; } - ui.writeLine(chalk.green(oneLine` + + let server: any; + if (appConfig.universal === true) { + ui.writeLine(chalk.green(oneLine` + ** + NG Universal Development Server is running on + http${commandOptions.ssl ? 's' : ''}://${commandOptions.host}:${commandOptions.port}. + ** + `)); + webpackDevServerConfiguration.filename = appConfig.nodeMain; + server = new UniversalDevServer(webpackCompiler, webpackDevServerConfiguration); + } else { + ui.writeLine(chalk.green(oneLine` ** NG Live Development Server is running on http${commandOptions.ssl ? 's' : ''}://${commandOptions.host}:${commandOptions.port}. ** `)); + server = new WebpackDevServer(webpackCompiler, webpackDevServerConfiguration); + } - const server = new WebpackDevServer(webpackCompiler, webpackDevServerConfiguration); return new Promise((resolve, reject) => { - server.listen(commandOptions.port, `${commandOptions.host}`, function(err: any, stats: any) { + server.listen(commandOptions.port, `${commandOptions.host}`, function (err: any, stats: any) { if (err) { console.error(err.stack || err); if (err.details) { console.error(err.details); } diff --git a/packages/angular-cli/tasks/server/universal-dev-server.ts b/packages/angular-cli/tasks/server/universal-dev-server.ts new file mode 100644 index 000000000000..0a0e68133dca --- /dev/null +++ b/packages/angular-cli/tasks/server/universal-dev-server.ts @@ -0,0 +1,68 @@ +import * as path from 'path'; +import { webpackOutputOptions } from '../../models/webpack-build-utils'; +const nodemon = require('nodemon'); +const tinyLr = require('tiny-lr'); + +export class UniversalDevServer { + private appPath: string = ''; + private nodemonConfig: any; + private demon: any; + private liveServer: any; + + constructor(private webpackCompiler: any, private webpackDevServerConfiguration: any) { + this.appPath = path.join( + webpackDevServerConfiguration.contentBase, + `../dist/${webpackDevServerConfiguration.filename.replace('.ts', '.bundle.js')}` + ); + this.liveServer = new tinyLr.Server(); + this.liveServer.listen(); + } + + public listen(port: number, host: string, callBack: any) { + this.nodemonConfig = { + script: this.appPath, + runOnChangeOnly: true, + env: { 'PORT': port }, + verbose: true, + ext: 'noop', + watch: ['noop/'], + ignore: ['*'], + stdout: false, + stderr: false + }; + + this.demon = nodemon(this.nodemonConfig); + this.demon + .on('restart', () => { + setTimeout(() => { + this.liveServer.changed({ + body: { + files: ['LiveReload files'] + } + }); + }, 500); + }) + .on('stdout', (stdout: any) => { + console.log(stdout.toString().trim()); + }) + .on('stderr', (stderr: any) => { + console.log(stderr.toString()); + }); + + this.webpackCompiler.plugin('done', () => { + this.demon.restart(); + }); + this.webpackCompiler.watch(this.webpackDevServerConfiguration, (err: any, stats: any) => { + if (err) { + console.error(err.stack || err); + process.stdout.write('webpack: bundle is now INVALID.'); + if (err.details) { console.error(err.details); } + } + + process.stdout.write(stats.toString(webpackOutputOptions) + '\n'); + process.stdout.write('webpack: bundle is now VALID\n'); + + callBack(err, stats); + }); + } +} diff --git a/packages/angular-cli/utilities/dynamic-path-parser.js b/packages/angular-cli/utilities/dynamic-path-parser.js index e362da26f864..6c12096e6e7d 100644 --- a/packages/angular-cli/utilities/dynamic-path-parser.js +++ b/packages/angular-cli/utilities/dynamic-path-parser.js @@ -11,13 +11,13 @@ module.exports = function dynamicPathParser(project, entityName) { var rootPath = path.join(projectRoot, appRoot); var outputPath = path.join(rootPath, entityName); - + if (entityName.indexOf(path.sep) === 0) { outputPath = path.join(rootPath, entityName.substr(1)); } else if (cwd.indexOf(rootPath) >= 0) { outputPath = path.join(cwd, entityName); } - + if (!fs.existsSync(outputPath)) { // Verify the path exists on disk. var parsedOutputPath = path.parse(outputPath); @@ -33,12 +33,12 @@ module.exports = function dynamicPathParser(project, entityName) { } else if (fs.existsSync(withPlus)) { return withPlus; } - + throw `Invalid path: "${withoutPlus}"" is not a valid path.` }, parsedOutputPath.root); outputPath = path.join(newPath, parsedOutputPath.name); } - + if (outputPath.indexOf(rootPath) < 0) { throw `Invalid path: "${entityName}" cannot be ` + `above the "${appRoot}" directory`; @@ -47,7 +47,7 @@ module.exports = function dynamicPathParser(project, entityName) { var adjustedPath = outputPath.replace(projectRoot, ''); var parsedPath = path.parse(adjustedPath); - + if (parsedPath.dir.indexOf(path.sep) === 0) { parsedPath.dir = parsedPath.dir.substr(1); } diff --git a/packages/angular-cli/utilities/find-parent-module.ts b/packages/angular-cli/utilities/find-parent-module.ts index 7a2273e19068..a46d65995a61 100644 --- a/packages/angular-cli/utilities/find-parent-module.ts +++ b/packages/angular-cli/utilities/find-parent-module.ts @@ -2,11 +2,12 @@ import * as fs from 'fs'; import * as path from 'path'; const SilentError = require('silent-error'); -export default function findParentModule(project: any, currentDir: string): string { - const sourceRoot = path.join(project.root, project.ngConfig.apps[0].root, 'app'); +export default function findParentModule(project: any, currentDir: string): string[] { + const root = 'app'; + const sourceRoot = path.join(project.root, project.ngConfig.apps[0].root, root); // trim currentDir - currentDir = currentDir.replace(path.join(project.ngConfig.apps[0].root, 'app'), ''); + currentDir = currentDir.replace(path.join(project.ngConfig.apps[0].root, root), ''); let pathToCheck = path.join(sourceRoot, currentDir); @@ -17,10 +18,8 @@ export default function findParentModule(project: any, currentDir: string): stri .filter(fileName => fileName.endsWith('.module.ts')) .filter(fileName => fs.statSync(path.join(pathToCheck, fileName)).isFile()); - if (files.length === 1) { - return path.join(pathToCheck, files[0]); - } else if (files.length > 1) { - throw new SilentError(`Multiple module files found: ${pathToCheck.replace(sourceRoot, '')}`); + if (files.length > 0) { + return files.map(file => path.join(pathToCheck, file)); } // move to parent directory diff --git a/tests/acceptance/init.spec.js b/tests/acceptance/init.spec.js index 629767618e44..351f2af430f1 100644 --- a/tests/acceptance/init.spec.js +++ b/tests/acceptance/init.spec.js @@ -36,13 +36,20 @@ describe('Acceptance: ng init', function () { return tmp.teardown('./tmp'); }); - function confirmBlueprinted(isMobile, routing) { + function confirmBlueprinted(additionalFolders, routing) { routing = !!routing; - var blueprintPath = path.join(root, 'blueprints', 'ng2', 'files'); - var mobileBlueprintPath = path.join(root, 'blueprints', 'mobile', 'files'); - var expected = unique(walkSync(blueprintPath).concat(isMobile ? walkSync(mobileBlueprintPath) : []).sort()); + var blueprintPath = path.join(root, 'blueprints', 'ng2', 'files'); + var expected = walkSync(blueprintPath); var actual = walkSync('.').sort(); + additionalFolders = additionalFolders || []; + + additionalFolders.forEach((folder) => { + expected = expected.concat(walkSync(path.join(root, 'blueprints', folder, 'files'))); + }); + + expected = unique(expected.sort()); + forEach(Blueprint.renamedFiles, function (destFile, srcFile) { expected[expected.indexOf(srcFile)] = destFile; }); @@ -53,10 +60,14 @@ describe('Acceptance: ng init', function () { expected[index] = expected[index].replace(/__path__/g, 'src'); }); - if (isMobile) { + if (additionalFolders.indexOf('mobile') > -1) { expected = expected.filter(p => p.indexOf('app.component.html') < 0); expected = expected.filter(p => p.indexOf('app.component.css') < 0); } + if (additionalFolders.indexOf('universal') > -1) { + expected = expected.filter(p => p.indexOf('main.ts') < 0); + expected = expected.filter(p => p.indexOf('app.module.ts') < 0); + } if (!routing) { expected = expected.filter(p => p.indexOf('app-routing.module.ts') < 0); @@ -112,6 +123,15 @@ describe('Acceptance: ng init', function () { expect(ng(['init', '--mobile'])).to.throw; }); + it('ng init --universal', () => { + return ng([ + 'init', + '--skip-npm', + '--skip-bower', + '--universal' + ]).then(() => confirmBlueprinted(['universal'])); + }); + it('ng init can run in created folder', function () { return tmp.setup('./tmp/foo') .then(function () { diff --git a/tests/e2e/setup/500-create-project.ts b/tests/e2e/setup/500-create-project.ts index 2e39507af4f4..4a4ac9b1bbd4 100644 --- a/tests/e2e/setup/500-create-project.ts +++ b/tests/e2e/setup/500-create-project.ts @@ -1,6 +1,6 @@ import {join} from 'path'; import {git, ng, silentNpm} from '../utils/process'; -import {isMobileTest} from '../utils/utils'; +import {isMobileTest, isUniversalTest} from '../utils/utils'; import {expectFileToExist} from '../utils/fs'; import {updateTsConfig, updateJsonFile} from '../utils/project'; import {gitClean, gitCommit} from '../utils/git'; @@ -23,7 +23,8 @@ export default function(argv: any) { } else { // Otherwise create a project from scratch. createProject = Promise.resolve() - .then(() => ng('new', 'test-project', '--skip-npm', isMobileTest() ? '--mobile' : undefined)) + .then(() => ng('new', 'test-project', '--skip-npm', isMobileTest() ? '--mobile' : undefined, + isUniversalTest() ? '--universal' : undefined)) .then(() => expectFileToExist(join(process.cwd(), 'test-project'))) .then(() => process.chdir('./test-project')); } diff --git a/tests/e2e/tests/build/aot.ts b/tests/e2e/tests/build/aot.ts index 0cfe62bc7364..488884681d5b 100644 --- a/tests/e2e/tests/build/aot.ts +++ b/tests/e2e/tests/build/aot.ts @@ -1,8 +1,14 @@ -import {ng} from '../../utils/process'; -import {expectFileToMatch} from '../../utils/fs'; +import { ng } from '../../utils/process'; +import { expectFileToMatch } from '../../utils/fs'; +import { isUniversalTest, expectToFail } from '../../utils/utils'; -export default function() { - return ng('build', '--aot') - .then(() => expectFileToMatch('dist/main.bundle.js', - /bootstrapModuleFactory.*\/\* AppModuleNgFactory \*\//)); +export default function () { + if (isUniversalTest()) { + return Promise.resolve() + .then(() => expectToFail(() => ng('build', '--aot'))); + } else { + return ng('build', '--aot') + .then(() => expectFileToMatch('dist/main.bundle.js', + /bootstrapModuleFactory.*\/\* AppModuleNgFactory \*\//)); + } } diff --git a/tests/e2e/tests/build/dev-build.ts b/tests/e2e/tests/build/dev-build.ts index f6f96df9deb1..8fecc07cb413 100644 --- a/tests/e2e/tests/build/dev-build.ts +++ b/tests/e2e/tests/build/dev-build.ts @@ -1,10 +1,23 @@ -import {ng} from '../../utils/process'; -import {expectFileToMatch} from '../../utils/fs'; -import {expectGitToBeClean} from '../../utils/git'; +import { ng } from '../../utils/process'; +import { expectFileToMatch, expectFileToExist } from '../../utils/fs'; +import { expectGitToBeClean } from '../../utils/git'; +import { getAppMain, isUniversalTest } from '../../utils/utils'; -export default function() { +export default function () { return ng('build', '--env=dev') - .then(() => expectFileToMatch('dist/index.html', 'main.bundle.js')) - .then(() => expectGitToBeClean()); + .then(() => expectFileToMatch('dist/index.html', getAppMain() + '.bundle.js')) + .then(() => expectGitToBeClean()) + .then(() => { + if (!isUniversalTest()) { + return; + } + + return Promise.resolve() + .then(() => expectFileToExist('dist/server.bundle.js')) + .then(() => expectFileToMatch( + 'dist/index.html', + 'livereload.js') + ); + }); } diff --git a/tests/e2e/tests/build/environment.ts b/tests/e2e/tests/build/environment.ts index 734461a2e0a5..0520b7f80830 100644 --- a/tests/e2e/tests/build/environment.ts +++ b/tests/e2e/tests/build/environment.ts @@ -1,13 +1,23 @@ -import {ng} from '../../utils/process'; -import {expectFileToMatch} from '../../utils/fs'; -import {expectGitToBeClean} from '../../utils/git'; -import {expectToFail} from '../../utils/utils'; +import { ng } from '../../utils/process'; +import { expectFileToMatch } from '../../utils/fs'; +import { expectGitToBeClean } from '../../utils/git'; +import { expectToFail, getAppMain, isUniversalTest } from '../../utils/utils'; -export default function() { +export default function () { // Try a prod build. return ng('build', '--env=prod') - .then(() => expectFileToMatch('dist/main.bundle.js', 'production: true')) + .then(() => expectFileToMatch(`dist/${getAppMain()}.bundle.js`, 'production: true')) + .then(() => { + if (!isUniversalTest()) { + return; + } + + return Promise.resolve() + .then(() => { + expectFileToMatch('dist/server.bundle.js', 'production: true'); + }); + }) .then(() => expectGitToBeClean()) // Build fails on invalid build target diff --git a/tests/e2e/tests/build/output-dir.ts b/tests/e2e/tests/build/output-dir.ts index 0e34c8450fb9..55efb39c989e 100644 --- a/tests/e2e/tests/build/output-dir.ts +++ b/tests/e2e/tests/build/output-dir.ts @@ -1,14 +1,14 @@ -import {ng} from '../../utils/process'; -import {expectFileToExist} from '../../utils/fs'; -import {expectToFail} from '../../utils/utils'; -import {expectGitToBeClean} from '../../utils/git'; -import {updateJsonFile} from '../../utils/project'; +import { ng } from '../../utils/process'; +import { expectFileToExist } from '../../utils/fs'; +import { expectToFail, getAppMain } from '../../utils/utils'; +import { expectGitToBeClean } from '../../utils/git'; +import { updateJsonFile } from '../../utils/project'; export default function() { return ng('build', '-o', './build-output') .then(() => expectFileToExist('./build-output/index.html')) - .then(() => expectFileToExist('./build-output/main.bundle.js')) + .then(() => expectFileToExist(`./build-output/${getAppMain()}.bundle.js`)) .then(() => expectToFail(expectGitToBeClean)) .then(() => updateJsonFile('angular-cli.json', configJson => { const app = configJson['apps'][0]; @@ -16,6 +16,6 @@ export default function() { })) .then(() => ng('build')) .then(() => expectFileToExist('./config-build-output/index.html')) - .then(() => expectFileToExist('./config-build-output/main.bundle.js')) + .then(() => expectFileToExist(`./config-build-output/${getAppMain()}.bundle.js`)) .then(() => expectToFail(expectGitToBeClean)); } diff --git a/tests/e2e/tests/build/prod-build.ts b/tests/e2e/tests/build/prod-build.ts index f4d798b70485..4779f5114660 100644 --- a/tests/e2e/tests/build/prod-build.ts +++ b/tests/e2e/tests/build/prod-build.ts @@ -1,9 +1,8 @@ -import {join} from 'path'; -import {isMobileTest} from '../../utils/utils'; -import {expectFileToExist, expectFileToMatch} from '../../utils/fs'; -import {ng} from '../../utils/process'; -import {expectGitToBeClean} from '../../utils/git'; - +import { join } from 'path'; +import { isMobileTest, isUniversalTest } from '../../utils/utils'; +import { expectFileToExist, expectFileToMatch, expectFileToNotMatch } from '../../utils/fs'; +import { ng } from '../../utils/process'; +import { expectGitToBeClean } from '../../utils/git'; function mobileOnlyChecks() { @@ -20,23 +19,36 @@ function mobileOnlyChecks() { // App Manifest .then(() => expectFileToExist('dist/manifest.webapp')) .then(() => expectFileToMatch('dist/index.html', - '')) + '')) // Icons folder .then(() => expectFileToExist('dist/icons')); } - -export default function() { +export default function () { // Can't use the `ng` helper because somewhere the environment gets // stuck to the first build done return ng('build', '--prod') .then(() => expectFileToExist(join(process.cwd(), 'dist'))) // Check for cache busting hash script src - .then(() => expectFileToMatch('dist/index.html', /main\.[0-9a-f]{20}\.bundle\.js/)) + .then(() => expectFileToMatch('dist/index.html', /(main|client)\.[0-9a-f]{20}\.bundle\.js/)) .then(() => expectFileToMatch('dist/index.html', /styles\.[0-9a-f]{32}\.bundle\.css/)) // Check that the process didn't change local files. .then(() => expectGitToBeClean()) - .then(() => mobileOnlyChecks()); + .then(() => mobileOnlyChecks()) + .then(() => { + if (!isUniversalTest()) { + return; + } + + return Promise.resolve() + .then(() => expectFileToExist('dist/server.bundle.js')) + .then(() => { + expectFileToNotMatch( + 'dist/index.html', + '' + ); + }); + }); } diff --git a/tests/e2e/tests/build/styles/less.ts b/tests/e2e/tests/build/styles/less.ts index 279742be2ceb..c285dbf903f5 100644 --- a/tests/e2e/tests/build/styles/less.ts +++ b/tests/e2e/tests/build/styles/less.ts @@ -5,29 +5,30 @@ import { moveFile, replaceInFile } from '../../../utils/fs'; -import {ng} from '../../../utils/process'; -import {stripIndents} from 'common-tags'; -import {isMobileTest} from '../../../utils/utils'; +import { ng } from '../../../utils/process'; +import { stripIndents } from 'common-tags'; +import { isMobileTest, getAppMain } from '../../../utils/utils'; -export default function() { +export default function () { if (isMobileTest()) { return; } return writeMultipleFiles({ - 'src/app/app.component.less': stripIndents` + 'src/app/app.component.less': stripIndents` .outer { .inner { background: #fff; } } ` - }) + }) .then(() => deleteFile('src/app/app.component.css')) .then(() => replaceInFile('src/app/app.component.ts', - './app.component.css', './app.component.less')) + './app.component.css', './app.component.less')) .then(() => ng('build')) - .then(() => expectFileToMatch('dist/main.bundle.js', /.outer.*.inner.*background:\s*#[fF]+/)) + .then(() => expectFileToMatch(`dist/${getAppMain()}.bundle.js`, + /.outer.*.inner.*background:\s*#[fF]+/)) .then(() => moveFile('src/app/app.component.less', 'src/app/app.component.css')); } diff --git a/tests/e2e/tests/build/styles/scss.ts b/tests/e2e/tests/build/styles/scss.ts index 52d7d46fbd42..3eadef921b60 100644 --- a/tests/e2e/tests/build/styles/scss.ts +++ b/tests/e2e/tests/build/styles/scss.ts @@ -5,18 +5,18 @@ import { moveFile, replaceInFile } from '../../../utils/fs'; -import {ng} from '../../../utils/process'; -import {stripIndents} from 'common-tags'; -import {isMobileTest} from '../../../utils/utils'; +import { ng } from '../../../utils/process'; +import { stripIndents } from 'common-tags'; +import { isMobileTest, getAppMain } from '../../../utils/utils'; -export default function() { +export default function () { if (isMobileTest()) { return; } return writeMultipleFiles({ - 'src/app/app.component.scss': stripIndents` + 'src/app/app.component.scss': stripIndents` @import "app.component.partial"; .outer { @@ -25,17 +25,19 @@ export default function() { } } `, - 'src/app/app.component.partial.scss': stripIndents` + 'src/app/app.component.partial.scss': stripIndents` .partial { @extend .outer; } ` - }) + }) .then(() => deleteFile('src/app/app.component.css')) .then(() => replaceInFile('src/app/app.component.ts', - './app.component.css', './app.component.scss')) + './app.component.css', './app.component.scss')) .then(() => ng('build')) - .then(() => expectFileToMatch('dist/main.bundle.js', /\.outer.*\.inner.*background.*#def/)) - .then(() => expectFileToMatch('dist/main.bundle.js', /\.partial.*\.inner.*background.*#def/)) + .then(() => expectFileToMatch(`dist/${getAppMain()}.bundle.js`, + /\.outer.*\.inner.*background.*#def/)) + .then(() => expectFileToMatch(`dist/${getAppMain()}.bundle.js`, + /\.partial.*\.inner.*background.*#def/)) .then(() => moveFile('src/app/app.component.scss', 'src/app/app.component.css')); } diff --git a/tests/e2e/tests/build/styles/styles-array.ts b/tests/e2e/tests/build/styles/styles-array.ts index 184adc165f78..5b7eec481f5e 100644 --- a/tests/e2e/tests/build/styles/styles-array.ts +++ b/tests/e2e/tests/build/styles/styles-array.ts @@ -1,11 +1,11 @@ import * as glob from 'glob'; -import {writeMultipleFiles, expectFileToMatch} from '../../../utils/fs'; -import {ng} from '../../../utils/process'; -import {updateJsonFile} from '../../../utils/project'; +import { writeMultipleFiles, expectFileToMatch } from '../../../utils/fs'; +import { ng } from '../../../utils/process'; +import { updateJsonFile } from '../../../utils/project'; -export default function() { +export default function () { return writeMultipleFiles({ 'src/styles.css': ` @import './imported-styles.css'; @@ -51,7 +51,7 @@ export default function() { .then((styles) => expectFileToMatch(styles, /body\s*\{\s*background-color:\s*blue\s*\}/) .then(() => expectFileToMatch(styles, /p\s*\{\s*background-color:\s*red\s*\}/) - .then(() => expectFileToMatch(styles, /.outer.*.inner.*background:\s*#[fF]+/)) - .then(() => expectFileToMatch(styles, /.upper.*.lower.*background.*#def/))) + .then(() => expectFileToMatch(styles, /.outer.*.inner.*background:\s*#[fF]+/)) + .then(() => expectFileToMatch(styles, /.upper.*.lower.*background.*#def/))) ); } diff --git a/tests/e2e/tests/misc/proxy.ts b/tests/e2e/tests/misc/proxy.ts index 26e058c863b3..63546f234786 100644 --- a/tests/e2e/tests/misc/proxy.ts +++ b/tests/e2e/tests/misc/proxy.ts @@ -5,10 +5,15 @@ import {writeFile} from '../../utils/fs'; import {request} from '../../utils/http'; import {killAllProcesses, ng} from '../../utils/process'; import {ngServe} from '../../utils/project'; -import {expectToFail} from '../../utils/utils'; +import {expectToFail, isUniversalTest} from '../../utils/utils'; export default function() { + /** This test is disabled for universal */ + if (isUniversalTest()) { + return Promise.resolve(); + } + // Create an express app that serves as a proxy. const app = express(); const server = http.createServer(app); diff --git a/tests/e2e/tests/misc/ssl-default.ts b/tests/e2e/tests/misc/ssl-default.ts index e16ec54291c9..bd5efadacafe 100644 --- a/tests/e2e/tests/misc/ssl-default.ts +++ b/tests/e2e/tests/misc/ssl-default.ts @@ -1,9 +1,15 @@ import { request } from '../../utils/http'; import { killAllProcesses } from '../../utils/process'; import { ngServe } from '../../utils/project'; +import { isUniversalTest } from '../../utils/utils'; export default function() { + /** This test is disabled for universal */ + if (isUniversalTest()) { + return Promise.resolve(); + } + return Promise.resolve() .then(() => ngServe('--ssl', 'true')) .then(() => request('https://localhost:4200/')) diff --git a/tests/e2e/tests/misc/ssl-with-cert.ts b/tests/e2e/tests/misc/ssl-with-cert.ts index 3930c91625fb..b4114efbf123 100644 --- a/tests/e2e/tests/misc/ssl-with-cert.ts +++ b/tests/e2e/tests/misc/ssl-with-cert.ts @@ -2,9 +2,15 @@ import { request } from '../../utils/http'; import { assetDir } from '../../utils/assets'; import { killAllProcesses } from '../../utils/process'; import { ngServe } from '../../utils/project'; +import { isUniversalTest } from '../../utils/utils'; export default function() { + /** This test is disabled for universal */ + if (isUniversalTest()) { + return Promise.resolve(); + } + return Promise.resolve() .then(() => ngServe( '--ssl', 'true', diff --git a/tests/e2e/tests/test/e2e.ts b/tests/e2e/tests/test/e2e.ts index ca66091906c7..5ea54dbc47f2 100644 --- a/tests/e2e/tests/test/e2e.ts +++ b/tests/e2e/tests/test/e2e.ts @@ -1,6 +1,6 @@ -import {ng, killAllProcesses} from '../../utils/process'; -import {expectToFail} from '../../utils/utils'; -import {ngServe} from '../../utils/project'; +import { ng, killAllProcesses } from '../../utils/process'; +import { expectToFail, isUniversalTest } from '../../utils/utils'; +import { ngServe } from '../../utils/project'; function _runServeAndE2e(...args: string[]) { @@ -12,10 +12,14 @@ function _runServeAndE2e(...args: string[]) { }); } -export default function() { +export default function () { + /** Serve test disabled for universal */ + if (isUniversalTest()) { + return expectToFail(() => ng('e2e')); + } // This is supposed to fail without serving first... return expectToFail(() => ng('e2e')) - // These should work. + // These should work. .then(() => _runServeAndE2e()) .then(() => _runServeAndE2e('--prod')) .then(() => _runServeAndE2e('--aot')) diff --git a/tests/e2e/tests/third-party/bootstrap.ts b/tests/e2e/tests/third-party/bootstrap.ts index 68e015c6f474..ee995f3aa4bb 100644 --- a/tests/e2e/tests/third-party/bootstrap.ts +++ b/tests/e2e/tests/third-party/bootstrap.ts @@ -1,10 +1,11 @@ -import {npm, ng} from '../../utils/process'; -import {updateJsonFile} from '../../utils/project'; -import {expectFileToMatch} from '../../utils/fs'; -import {oneLineTrim} from 'common-tags'; +import { npm, ng } from '../../utils/process'; +import { updateJsonFile } from '../../utils/project'; +import { expectFileToMatch } from '../../utils/fs'; +import { oneLineTrim } from 'common-tags'; +import { getAppMain } from '../../utils/utils'; -export default function() { +export default function () { return Promise.resolve() .then(() => npm('install', 'bootstrap@next')) .then(() => updateJsonFile('angular-cli.json', configJson => { @@ -25,6 +26,6 @@ export default function() { - + `)); } diff --git a/tests/e2e/utils/fs.ts b/tests/e2e/utils/fs.ts index 9e0f05b02e87..acd7294332d6 100644 --- a/tests/e2e/utils/fs.ts +++ b/tests/e2e/utils/fs.ts @@ -138,6 +138,21 @@ export function expectFileToMatch(fileName: string, regEx: RegExp | string) { }); } +export function expectFileToNotMatch(fileName: string, regEx: RegExp | string) { + return readFile(fileName) + .then(content => { + if (typeof regEx == 'string') { + if (content.indexOf(regEx) > -1) { + throw new Error(`File "${fileName}" did contain "${regEx}"...`); + } + } else { + if (content.match(regEx)) { + throw new Error(`File "${fileName}" did match regex ${regEx}...`); + } + } + }); +} + export function expectFileSizeToBeUnder(fileName: string, sizeInBytes: number) { return readFile(fileName) .then(content => { diff --git a/tests/e2e/utils/project.ts b/tests/e2e/utils/project.ts index befb308e048b..b9aa09a41fab 100644 --- a/tests/e2e/utils/project.ts +++ b/tests/e2e/utils/project.ts @@ -1,8 +1,8 @@ -import {readFile, writeFile} from './fs'; -import {silentExecAndWaitForOutputToMatch} from './process'; +import { readFile, writeFile } from './fs'; +import { silentExecAndWaitForOutputToMatch } from './process'; -const tsConfigPath = 'src/tsconfig.json'; +const tsConfigPath = 'src/tsconfig.json'; export function updateJsonFile(filePath: string, fn: (json: any) => any | void) { return readFile(filePath) @@ -14,12 +14,10 @@ export function updateJsonFile(filePath: string, fn: (json: any) => any | void) }); } - export function updateTsConfig(fn: (json: any) => any | void) { return updateJsonFile(tsConfigPath, fn); } - export function ngServe(...args: string[]) { return silentExecAndWaitForOutputToMatch('ng', ['serve', ...args], /webpack: bundle is now VALID/); diff --git a/tests/e2e/utils/utils.ts b/tests/e2e/utils/utils.ts index f1c92420181b..89af5299366e 100644 --- a/tests/e2e/utils/utils.ts +++ b/tests/e2e/utils/utils.ts @@ -10,6 +10,14 @@ export function isMobileTest() { return !!process.env['MOBILE_TEST']; } +export function isUniversalTest() { + return !!process.env['UNIVERSAL']; +} + +export function getAppMain() { + return isUniversalTest() ? 'client' : 'main'; +} + export function wait(msecs: number) { return new Promise((resolve) => { setTimeout(resolve, msecs); From 90588bf0aa0738e9cb0271ca7465c64f08866752 Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Sun, 6 Nov 2016 16:09:54 +0100 Subject: [PATCH 02/38] changed package name to universal-cli --- package.json | 2 +- packages/angular-cli/blueprints/ng2/files/karma.conf.js | 2 +- packages/angular-cli/blueprints/ng2/files/package.json | 2 +- packages/angular-cli/commands/version.ts | 3 ++- packages/angular-cli/lib/cli/index.js | 2 +- packages/angular-cli/package.json | 5 +++-- packages/angular-cli/tasks/link-cli.ts | 6 +++--- packages/angular-cli/tasks/server/universal-dev-server.ts | 2 +- tests/e2e/setup/500-create-project.ts | 7 +++++++ 9 files changed, 20 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 33c2b27dfe91..9b7022f1763f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "universal-cli", - "version": "1.0.0-beta.1", + "version": "1.0.0-alpha.universal.1", "description": "CLI tool for Angular with Angular Universal support", "main": "packages/angular-cli/lib/cli/index.js", "trackingCode": "xx-xxxxxxx-xx", diff --git a/packages/angular-cli/blueprints/ng2/files/karma.conf.js b/packages/angular-cli/blueprints/ng2/files/karma.conf.js index 2ec744bb0530..53397b496adc 100644 --- a/packages/angular-cli/blueprints/ng2/files/karma.conf.js +++ b/packages/angular-cli/blueprints/ng2/files/karma.conf.js @@ -9,7 +9,7 @@ module.exports = function (config) { require('karma-jasmine'), require('karma-chrome-launcher'), require('karma-remap-istanbul'), - require('angular-cli/plugins/karma') + require('universal-cli/plugins/karma') ], files: [ { pattern: './<%= sourceDir %>/test.ts', watched: false } diff --git a/packages/angular-cli/blueprints/ng2/files/package.json b/packages/angular-cli/blueprints/ng2/files/package.json index 06455ea47097..c64bf4742598 100644 --- a/packages/angular-cli/blueprints/ng2/files/package.json +++ b/packages/angular-cli/blueprints/ng2/files/package.json @@ -48,7 +48,7 @@ "@types/mime": "0.0.28", "@types/node": "^4.0.30", "@types/serve-static": "^1.7.27",<% } %> - "angular-cli": "<%= version %>", + "universal-cli": "<%= version %>", "codelyzer": "~1.0.0-beta.3", "jasmine-core": "2.4.1", "jasmine-spec-reporter": "2.5.0", diff --git a/packages/angular-cli/commands/version.ts b/packages/angular-cli/commands/version.ts index b455d22f821a..ae327dcbb2f1 100644 --- a/packages/angular-cli/commands/version.ts +++ b/packages/angular-cli/commands/version.ts @@ -33,7 +33,8 @@ const VersionCommand = Command.extend({ ngCliVersion = `local (v${pkg.version}, branch: ${gitBranch})`; } - this.printVersion('angular-cli', ngCliVersion); + this.printVersion('universal-cli', ngCliVersion); + this.printVersion('angular-cli', pkg.cliVersion); for (const module of Object.keys(versions)) { if (options.verbose || alwaysPrint.indexOf(module) > -1) { diff --git a/packages/angular-cli/lib/cli/index.js b/packages/angular-cli/lib/cli/index.js index c94d8af20601..e6eb95ff1e87 100644 --- a/packages/angular-cli/lib/cli/index.js +++ b/packages/angular-cli/lib/cli/index.js @@ -43,7 +43,7 @@ module.exports = function(options) { options.cli = { name: 'ng', root: path.join(__dirname, '..', '..'), - npmPackage: 'angular-cli' + npmPackage: 'universal-cli' }; // ensure the environemnt variable for dynamic paths diff --git a/packages/angular-cli/package.json b/packages/angular-cli/package.json index d42c19cab830..1f791d8c3562 100644 --- a/packages/angular-cli/package.json +++ b/packages/angular-cli/package.json @@ -1,9 +1,10 @@ { "name": "universal-cli", - "version": "1.0.0-beta.1", + "version": "1.0.0-alpha.universal.1", + "cliVersion": "1.0.0-beta.19-3", "description": "CLI tool for Angular with Angular Universal support", "main": "lib/cli/index.js", - "trackingCode": "", + "trackingCode": "xx-xxxxxxx-xx", "bin": { "ng": "./bin/ng" }, diff --git a/packages/angular-cli/tasks/link-cli.ts b/packages/angular-cli/tasks/link-cli.ts index cb2ee1175e68..a2e786c2264b 100644 --- a/packages/angular-cli/tasks/link-cli.ts +++ b/packages/angular-cli/tasks/link-cli.ts @@ -7,12 +7,12 @@ export default Task.extend({ const ui = this.ui; return new Promise(function(resolve, reject) { - exec('npm link angular-cli', (err) => { + exec('npm link universal-cli', (err) => { if (err) { - ui.writeLine(chalk.red('Couldn\'t do \'npm link angular-cli\'.')); + ui.writeLine(chalk.red('Couldn\'t do \'npm link universal-cli\'.')); reject(); } else { - ui.writeLine(chalk.green('Successfully linked to angular-cli.')); + ui.writeLine(chalk.green('Successfully linked to universal-cli.')); resolve(); } }); diff --git a/packages/angular-cli/tasks/server/universal-dev-server.ts b/packages/angular-cli/tasks/server/universal-dev-server.ts index 0a0e68133dca..651c146eb557 100644 --- a/packages/angular-cli/tasks/server/universal-dev-server.ts +++ b/packages/angular-cli/tasks/server/universal-dev-server.ts @@ -40,7 +40,7 @@ export class UniversalDevServer { files: ['LiveReload files'] } }); - }, 500); + }, 800); }) .on('stdout', (stdout: any) => { console.log(stdout.toString().trim()); diff --git a/tests/e2e/setup/500-create-project.ts b/tests/e2e/setup/500-create-project.ts index 4a4ac9b1bbd4..15756fd6bef2 100644 --- a/tests/e2e/setup/500-create-project.ts +++ b/tests/e2e/setup/500-create-project.ts @@ -51,6 +51,13 @@ export default function(argv: any) { 'platform-browser-dynamic' ]; angularPackages.forEach(pkgName => { + /** + * change package name to angular-cli because + * there is no universal-cli package at /angular + */ + if (pkgName === 'universal-cli') { + pkgName = 'angular-cli'; + } json['dependencies'][`@angular/${pkgName}`] = `github:angular/${pkgName}-builds`; }); }); From 2f6572fb1a1a5cf9b2a2bc78117d30e6f9037405 Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Tue, 8 Nov 2016 13:21:56 +0100 Subject: [PATCH 03/38] v1.0.0-alpha.universal.1 --- CHANGELOG.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43bf0bbb9fc1..b8054ef938f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,37 @@ + +# [1.0.0-alpha.universal.1](https://github.com/devCrossNet/angular-cli/compare/v1.0.0-beta.19...v1.0.0-alpha.universal.1) (2016-11-08) + + +### Bug Fixes + +* **aot:** remove the genDir plugin option. ([0e91dfe](https://github.com/devCrossNet/angular-cli/commit/0e91dfe)), closes [#2849](https://github.com/devCrossNet/angular-cli/issues/2849) [#2876](https://github.com/devCrossNet/angular-cli/issues/2876) +* **aot:** Use the proper path when statically analyzing lazy routes. ([#2992](https://github.com/devCrossNet/angular-cli/issues/2992)) ([88131a0](https://github.com/devCrossNet/angular-cli/commit/88131a0)), closes [#2452](https://github.com/devCrossNet/angular-cli/issues/2452) [#2735](https://github.com/devCrossNet/angular-cli/issues/2735) [#2900](https://github.com/devCrossNet/angular-cli/issues/2900) +* **build:** correct forkChecker option for ATS. ([#3011](https://github.com/devCrossNet/angular-cli/issues/3011)) ([a987cf5](https://github.com/devCrossNet/angular-cli/commit/a987cf5)) +* **build:** enable chunkhash in inline.js ([30cc482](https://github.com/devCrossNet/angular-cli/commit/30cc482)), closes [#2899](https://github.com/devCrossNet/angular-cli/issues/2899) +* **build:** show full error stats ([#2879](https://github.com/devCrossNet/angular-cli/issues/2879)) ([d59fa1f](https://github.com/devCrossNet/angular-cli/commit/d59fa1f)) +* **e2e:** fix broken test pipeline ([#2999](https://github.com/devCrossNet/angular-cli/issues/2999)) ([37a1225](https://github.com/devCrossNet/angular-cli/commit/37a1225)) +* **generate:** stop default browser error from ng new --routing ([a45a1f2](https://github.com/devCrossNet/angular-cli/commit/a45a1f2)), closes [#2794](https://github.com/devCrossNet/angular-cli/issues/2794) +* **package:** add some more metadata to webpack package.json ([c2dbf88](https://github.com/devCrossNet/angular-cli/commit/c2dbf88)), closes [#2854](https://github.com/devCrossNet/angular-cli/issues/2854) +* **serve:** added accept html headers option to webpack-dev-server ([#2990](https://github.com/devCrossNet/angular-cli/issues/2990)) ([86f2a1b](https://github.com/devCrossNet/angular-cli/commit/86f2a1b)), closes [#2989](https://github.com/devCrossNet/angular-cli/issues/2989) +* **test:** catches module loading errors ([f09439c](https://github.com/devCrossNet/angular-cli/commit/f09439c)), closes [#2640](https://github.com/devCrossNet/angular-cli/issues/2640) [#2785](https://github.com/devCrossNet/angular-cli/issues/2785) +* bypass Watchman check ([#2846](https://github.com/devCrossNet/angular-cli/issues/2846)) ([9aa1099](https://github.com/devCrossNet/angular-cli/commit/9aa1099)), closes [#2791](https://github.com/devCrossNet/angular-cli/issues/2791) + + +### Features + +* **build:** add loaders for fonts ([3497373](https://github.com/devCrossNet/angular-cli/commit/3497373)), closes [#1765](https://github.com/devCrossNet/angular-cli/issues/1765) +* **build:** use appConfig.index to set output index file ([d3fd8b0](https://github.com/devCrossNet/angular-cli/commit/d3fd8b0)), closes [#2241](https://github.com/devCrossNet/angular-cli/issues/2241) [#2767](https://github.com/devCrossNet/angular-cli/issues/2767) +* **build:** use static files for css ([a6415cc](https://github.com/devCrossNet/angular-cli/commit/a6415cc)), closes [#2148](https://github.com/devCrossNet/angular-cli/issues/2148) [#2020](https://github.com/devCrossNet/angular-cli/issues/2020) [#2826](https://github.com/devCrossNet/angular-cli/issues/2826) [#2646](https://github.com/devCrossNet/angular-cli/issues/2646) +* **universal:** add support for Angular Universal ([1ee46ed](https://github.com/devCrossNet/angular-cli/commit/1ee46ed)) + + +### BREAKING CHANGES + +* aot: Using relative paths might lead to path clashing. We +now properly output an error in this case. + + + # [1.0.0-beta.19](https://github.com/angular/angular-cli/compare/v1.0.0-beta.18...v1.0.0-beta.19) (2016-10-28) From 3bcef75f241c6db22c8476c3ef4cf16b7697fe53 Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Sat, 12 Nov 2016 12:24:32 +0100 Subject: [PATCH 04/38] refactor: change angular-cli to universal-cli --- lib/packages.js | 4 ++-- package.json | 1 + packages/angular-cli/blueprints/ng2/index.js | 2 +- tests/e2e/setup/500-create-project.ts | 14 +++++++------- tests/e2e/utils/process.ts | 14 +++++++------- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/lib/packages.js b/lib/packages.js index 69b9b378d821..bedc19db971b 100644 --- a/lib/packages.js +++ b/lib/packages.js @@ -14,7 +14,7 @@ const packages = fs.readdirSync(packageRoot) let pkgJson = JSON.parse(fs.readFileSync(path.join(pkg.root, 'package.json'), 'utf8')); let name = pkgJson['name']; packages[name] = { - dist: path.join(__dirname, '../dist', pkg.name), + dist: path.join(__dirname, '../dist', (pkg.name === 'universal-cli' ? 'angular-cli' : pkg.name)), packageJson: path.join(pkg.root, 'package.json'), root: pkg.root, relative: path.relative(path.dirname(__dirname), pkg.root), @@ -23,4 +23,4 @@ const packages = fs.readdirSync(packageRoot) return packages; }, {}); -module.exports = packages; \ No newline at end of file +module.exports = packages; diff --git a/package.json b/package.json index 9b7022f1763f..fcb96d38a1ea 100644 --- a/package.json +++ b/package.json @@ -125,6 +125,7 @@ "style-loader": "^0.13.1", "stylus": "^0.54.5", "stylus-loader": "^2.1.0", + "tiny-lr": "^0.2.1", "temp": "0.8.3", "through": "^2.3.6", "ts-loader": "^0.8.2", diff --git a/packages/angular-cli/blueprints/ng2/index.js b/packages/angular-cli/blueprints/ng2/index.js index cba9b7031cf6..b6b07598e943 100644 --- a/packages/angular-cli/blueprints/ng2/index.js +++ b/packages/angular-cli/blueprints/ng2/index.js @@ -1,4 +1,4 @@ -const Blueprint = require('ember-cli/lib/models/blueprint'); +const Blueprint = require('../../ember-cli/lib/models/blueprint'); const path = require('path'); const stringUtils = require('ember-cli-string-utils'); const getFiles = Blueprint.prototype.files; diff --git a/tests/e2e/setup/500-create-project.ts b/tests/e2e/setup/500-create-project.ts index 15756fd6bef2..dc7706582ed0 100644 --- a/tests/e2e/setup/500-create-project.ts +++ b/tests/e2e/setup/500-create-project.ts @@ -1,15 +1,15 @@ -import {join} from 'path'; -import {git, ng, silentNpm} from '../utils/process'; -import {isMobileTest, isUniversalTest} from '../utils/utils'; -import {expectFileToExist} from '../utils/fs'; -import {updateTsConfig, updateJsonFile} from '../utils/project'; -import {gitClean, gitCommit} from '../utils/git'; +import { join } from 'path'; +import { git, ng, silentNpm } from '../utils/process'; +import { isMobileTest, isUniversalTest } from '../utils/utils'; +import { expectFileToExist } from '../utils/fs'; +import { updateTsConfig, updateJsonFile } from '../utils/project'; +import { gitClean, gitCommit } from '../utils/git'; let packages = require('../../../lib/packages'); -export default function(argv: any) { +export default function (argv: any) { let createProject = null; // This is a dangerous flag, but is useful for testing packages only. diff --git a/tests/e2e/utils/process.ts b/tests/e2e/utils/process.ts index 4746453ec424..00ed9a319ff7 100644 --- a/tests/e2e/utils/process.ts +++ b/tests/e2e/utils/process.ts @@ -104,30 +104,30 @@ export function ng(...args: string[]) { if (args[0] == 'build') { return silentNg(...args); } else { - return _exec({}, 'ng', args); + return _exec({}, '/usr/local/bin/ng', args); } } export function silentNg(...args: string[]) { - return _exec({silent: true}, 'ng', args); + return _exec({silent: true}, '/usr/local/bin/ng', args); } export function silentNpm(...args: string[]) { - return _exec({silent: true}, 'npm', args); + return _exec({silent: true}, '/usr/local/bin/npm', args); } export function npm(...args: string[]) { - return _exec({}, 'npm', args); + return _exec({}, '/usr/local/bin/npm', args); } export function node(...args: string[]) { - return _exec({}, 'node', args); + return _exec({}, '/usr/local/bin/node', args); } export function git(...args: string[]) { - return _exec({}, 'git', args); + return _exec({}, '/usr/bin/git', args); } export function silentGit(...args: string[]) { - return _exec({silent: true}, 'git', args); + return _exec({silent: true}, '/usr/bin/git', args); } From 5e36db800d972a9190a32e5846f7276aae6cb25b Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Sat, 12 Nov 2016 12:25:22 +0100 Subject: [PATCH 05/38] chore(readme): universal-cli update --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a0414704c2a3..c3d8d6e88d20 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ -## Angular-CLI +## Universal-CLI +Universal-CLI is fork from Angular-CLI. It supports Angular Universal see: [Support for server side rendering](#support-for-server-side-rendering). +It is a separate package because the Core-CLI team is not able to maintain non-core functionality. + +I am looking for maintainers, please let me know if you're interested in supporting `universal-cli`. [![Join the chat at https://gitter.im/angular/angular-cli](https://badges.gitter.im/angular/angular-cli.svg)](https://gitter.im/angular/angular-cli?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) @@ -13,7 +17,7 @@ Prototype of a CLI for Angular 2 applications based on the [ember-cli](http://ww This project is very much still a work in progress. -The CLI is now in beta. +The CLI is now in alpha. If you wish to collaborate while the project is still young, check out [our issue list](https://github.com/angular/angular-cli/issues). Before submitting new issues, have a look at [issues marked with the `type: faq` label](https://github.com/angular/angular-cli/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3A%22type%3A%20faq%22%20). @@ -62,7 +66,7 @@ with NPM 3 or higher. **BEFORE YOU INSTALL:** please read the [prerequisites](#prerequisites) ```bash -npm install -g angular-cli +npm install -g universal-cli ``` ## Usage From cdfe1a08b1e250a07277c4e44472b9545569ccb6 Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Tue, 8 Nov 2016 15:21:15 +0100 Subject: [PATCH 06/38] feat(universal): add custom webpack config add two custom webpack config files for server and client --- .../blueprints/ng2/files/angular-cli.json | 6 ++- .../universal/files/webpack.client.ts | 1 + .../universal/files/webpack.server.ts | 1 + packages/angular-cli/lib/config/schema.d.ts | 9 +++- packages/angular-cli/lib/config/schema.json | 13 ++++++ packages/angular-cli/models/webpack-config.ts | 46 ++++++++++++------- 6 files changed, 58 insertions(+), 18 deletions(-) create mode 100644 packages/angular-cli/blueprints/universal/files/webpack.client.ts create mode 100644 packages/angular-cli/blueprints/universal/files/webpack.server.ts diff --git a/packages/angular-cli/blueprints/ng2/files/angular-cli.json b/packages/angular-cli/blueprints/ng2/files/angular-cli.json index a4db4e224694..2540853f3c96 100644 --- a/packages/angular-cli/blueprints/ng2/files/angular-cli.json +++ b/packages/angular-cli/blueprints/ng2/files/angular-cli.json @@ -28,7 +28,11 @@ "source": "environments/environment.ts", "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" - } + }<% if(universal) { %>, + "webpackCustom": { + "client": "webpack.client.ts", + "server": "webpack.server.ts" + }<% } %> } ], "addons": [], diff --git a/packages/angular-cli/blueprints/universal/files/webpack.client.ts b/packages/angular-cli/blueprints/universal/files/webpack.client.ts new file mode 100644 index 000000000000..f053ebf7976e --- /dev/null +++ b/packages/angular-cli/blueprints/universal/files/webpack.client.ts @@ -0,0 +1 @@ +module.exports = {}; diff --git a/packages/angular-cli/blueprints/universal/files/webpack.server.ts b/packages/angular-cli/blueprints/universal/files/webpack.server.ts new file mode 100644 index 000000000000..f053ebf7976e --- /dev/null +++ b/packages/angular-cli/blueprints/universal/files/webpack.server.ts @@ -0,0 +1 @@ +module.exports = {}; diff --git a/packages/angular-cli/lib/config/schema.d.ts b/packages/angular-cli/lib/config/schema.d.ts index 16add78f0cbc..370a8ddeba5c 100644 --- a/packages/angular-cli/lib/config/schema.d.ts +++ b/packages/angular-cli/lib/config/schema.d.ts @@ -12,7 +12,7 @@ export interface CliConfig { apps?: { root?: string; outDir?: string; - assets?: string; + assets?: string[]; index?: string; main?: string; nodeMain?: string; @@ -35,6 +35,13 @@ export interface CliConfig { environments?: { [name: string]: any; }; + /** + * Name and corresponding file for custom webpack config. + */ + webpackCustom?: { + client?: string; + server?: string; + }; }[]; /** * Configuration reserved for installed third party addons. diff --git a/packages/angular-cli/lib/config/schema.json b/packages/angular-cli/lib/config/schema.json index 3a64f1cad4df..67b289f014d4 100644 --- a/packages/angular-cli/lib/config/schema.json +++ b/packages/angular-cli/lib/config/schema.json @@ -84,6 +84,19 @@ "description": "Name and corresponding file for environment config.", "type": "object", "additionalProperties": true + }, + "webpackCustom": { + "description": "Name and corresponding file for custom webpack config.", + "type": "object", + "properties": { + "client": { + "type": "string" + }, + "server": { + "type": "string" + } + }, + "additionalProperties": false } }, "additionalProperties": false diff --git a/packages/angular-cli/models/webpack-config.ts b/packages/angular-cli/models/webpack-config.ts index a3b90e16b542..3e9c890f5b8f 100644 --- a/packages/angular-cli/models/webpack-config.ts +++ b/packages/angular-cli/models/webpack-config.ts @@ -12,20 +12,19 @@ import { getWebpackMobileProdConfigPartial, getWebpackNodeConfig } from './'; +import * as path from 'path'; export class NgCliWebpackConfig { // TODO: When webpack2 types are finished lets replace all these any types // so this is more maintainable in the future for devs public configs: any[] = []; - constructor( - public ngCliProject: any, - public target: string, - public environment: string, - outputDir?: string, - baseHref?: string, - isAoT = false - ) { + constructor(public ngCliProject: any, + public target: string, + public environment: string, + outputDir?: string, + baseHref?: string, + isAoT = false) { const config: CliConfig = CliConfig.fromProject(); const appConfig = config.config.apps[0]; @@ -49,21 +48,36 @@ export class NgCliWebpackConfig { if (appConfig.mobile) { let mobileConfigPartial = getWebpackMobileConfigPartial(this.ngCliProject.root, appConfig); let mobileProdConfigPartial = getWebpackMobileProdConfigPartial(this.ngCliProject.root, - appConfig); + appConfig); baseConfig = webpackMerge(baseConfig, mobileConfigPartial); if (this.target == 'production') { targetConfigPartial = webpackMerge(targetConfigPartial, mobileProdConfigPartial); } } - this.configs.push(webpackMerge( - baseConfig, - targetConfigPartial, - typescriptConfigPartial - )); - if (appConfig.universal === true) { - this.configs.push(getWebpackNodeConfig(this.ngCliProject.root, environment, appConfig)); + const customClientConfig = require(path.join(this.ngCliProject.root, + appConfig.webpackCustom.client)); + const customServerConfig = require(path.join(this.ngCliProject.root, + appConfig.webpackCustom.server)); + + this.configs.push(webpackMerge( + baseConfig, + targetConfigPartial, + typescriptConfigPartial, + customClientConfig + )); + + this.configs.push(webpackMerge( + getWebpackNodeConfig(this.ngCliProject.root, environment, appConfig), + customServerConfig + )); + } else { + this.configs.push(webpackMerge( + baseConfig, + targetConfigPartial, + typescriptConfigPartial + )); } } From 37770d56a6493258fe4755b4a46d5c5361da1aa1 Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Sat, 12 Nov 2016 13:00:12 +0100 Subject: [PATCH 07/38] fix(universal): add polyfills.ts closes #1 --- .../angular-cli/blueprints/universal/files/__path__/client.ts | 1 + .../angular-cli/blueprints/universal/files/__path__/server.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/angular-cli/blueprints/universal/files/__path__/client.ts b/packages/angular-cli/blueprints/universal/files/__path__/client.ts index 9b771050f951..bf16e9b9a28a 100644 --- a/packages/angular-cli/blueprints/universal/files/__path__/client.ts +++ b/packages/angular-cli/blueprints/universal/files/__path__/client.ts @@ -2,6 +2,7 @@ * the polyfills must be the first thing imported */ import 'angular2-universal-polyfills'; +import './polyfills.ts'; import { enableProdMode } from '@angular/core'; import { environment } from './environments/environment'; import { platformUniversalDynamic } from 'angular2-universal'; diff --git a/packages/angular-cli/blueprints/universal/files/__path__/server.ts b/packages/angular-cli/blueprints/universal/files/__path__/server.ts index 6b880b2eb3f8..3c72ffdafb02 100644 --- a/packages/angular-cli/blueprints/universal/files/__path__/server.ts +++ b/packages/angular-cli/blueprints/universal/files/__path__/server.ts @@ -2,6 +2,7 @@ * the polyfills must be the first thing imported */ import 'angular2-universal-polyfills'; +import './polyfills.ts'; import * as path from 'path'; import * as express from 'express'; import { enableProdMode } from '@angular/core'; From 61d3abfc79e4321583036948bc9cf8c6331282ca Mon Sep 17 00:00:00 2001 From: John Brandes Date: Sat, 12 Nov 2016 22:45:01 +0100 Subject: [PATCH 08/38] perf(universal): add compression express middleware (#4) --- packages/angular-cli/blueprints/ng2/files/package.json | 1 + .../blueprints/universal/files/__path__/server.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/angular-cli/blueprints/ng2/files/package.json b/packages/angular-cli/blueprints/ng2/files/package.json index c64bf4742598..a93325cfa0dc 100644 --- a/packages/angular-cli/blueprints/ng2/files/package.json +++ b/packages/angular-cli/blueprints/ng2/files/package.json @@ -25,6 +25,7 @@ "angular2-universal": "2.0.11", "angular2-universal-polyfills": "2.0.11", "angular2-express-engine": "2.0.11", + "compression": "1.6.2", "express": "^4.14.0",<% } %> "core-js": "^2.4.1", "rxjs": "5.0.0-beta.12", diff --git a/packages/angular-cli/blueprints/universal/files/__path__/server.ts b/packages/angular-cli/blueprints/universal/files/__path__/server.ts index 3c72ffdafb02..ed496e2123ed 100644 --- a/packages/angular-cli/blueprints/universal/files/__path__/server.ts +++ b/packages/angular-cli/blueprints/universal/files/__path__/server.ts @@ -8,6 +8,7 @@ import * as express from 'express'; import { enableProdMode } from '@angular/core'; import { createEngine } from 'angular2-express-engine'; import { AppModule } from './app/app.node.module'; +import * as compression from 'compression'; import { environment } from './environments/environment'; const app = express(); @@ -28,6 +29,11 @@ app.engine('.html', createEngine({})); app.set('views', __dirname); app.set('view engine', 'html'); +/** + * Enable compression + */ +app.use(compression()); + /** * serve static files */ @@ -74,4 +80,6 @@ app.get('*', function(req: any, res: any) { res.status(404).send(json); }); -app.listen(port); +app.listen(port, () => { + console.log(`Listening on port {port}`); +}); From 78d785d97b844f099d56284d1c50c4b55ff09de1 Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Sat, 12 Nov 2016 23:04:05 +0100 Subject: [PATCH 09/38] chore(readme): update badges --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c3d8d6e88d20..a1b309e7e39d 100644 --- a/README.md +++ b/README.md @@ -491,11 +491,11 @@ and the [npm-link cheatsheet](http://browsenpm.org/help#linkinganynpmpackageloca MIT -[travis-badge]: https://travis-ci.org/angular/angular-cli.svg?branch=master -[travis-badge-url]: https://travis-ci.org/angular/angular-cli -[david-badge]: https://david-dm.org/angular/angular-cli.svg -[david-badge-url]: https://david-dm.org/angular/angular-cli -[david-dev-badge]: https://david-dm.org/angular/angular-cli/dev-status.svg -[david-dev-badge-url]: https://david-dm.org/angular/angular-cli?type=dev -[npm-badge]: https://img.shields.io/npm/v/angular-cli.svg -[npm-badge-url]: https://www.npmjs.com/package/angular-cli +[travis-badge]: https://travis-ci.org/devCrossNet/angular-cli.svg?branch=master +[travis-badge-url]: https://travis-ci.org/devCrossNet/angular-cli +[david-badge]: https://david-dm.org/devCrossNet/angular-cli.svg +[david-badge-url]: https://david-dm.org/devCrossNet/angular-cli +[david-dev-badge]: https://david-dm.org/devCrossNet/angular-cli/dev-status.svg +[david-dev-badge-url]: https://david-dm.org/devCrossNet/angular-cli?type=dev +[npm-badge]: https://img.shields.io/npm/v/universal-cli.svg +[npm-badge-url]: https://www.npmjs.com/package/universal-cli From d4a6f1553fe07bdae1341ff5914885471d1da246 Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Sun, 13 Nov 2016 14:50:50 +0100 Subject: [PATCH 10/38] chore(ci): add different versions of Angular for universal and non universal projects, revert process.ts to relative paths --- .../angular-cli/blueprints/ng2/files/package.json | 12 ++++++++++-- tests/e2e/utils/process.ts | 14 +++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/packages/angular-cli/blueprints/ng2/files/package.json b/packages/angular-cli/blueprints/ng2/files/package.json index a93325cfa0dc..5fbe7a43fcfa 100644 --- a/packages/angular-cli/blueprints/ng2/files/package.json +++ b/packages/angular-cli/blueprints/ng2/files/package.json @@ -11,7 +11,15 @@ "e2e": "protractor" }, "private": true, - "dependencies": { + "dependencies": {<% if(!universal) { %> + "@angular/common": "~2.1.0", + "@angular/compiler": "~2.1.0", + "@angular/core": "~2.1.0", + "@angular/forms": "~2.1.0", + "@angular/http": "~2.1.0", + "@angular/platform-browser": "~2.1.0", + "@angular/platform-browser-dynamic": "~2.1.0", + "@angular/router": "~3.1.0",<% } %><% if(universal) { %> "@angular/common": "2.1.0", "@angular/compiler": "2.1.0", "@angular/core": "2.1.0", @@ -19,7 +27,7 @@ "@angular/http": "2.1.0", "@angular/platform-browser": "2.1.0", "@angular/platform-browser-dynamic": "2.1.0", - "@angular/router": "3.1.0",<% if(universal) { %> + "@angular/router": "3.1.0", "@angular/platform-server": "2.1.0", "angular2-platform-node": "2.0.11", "angular2-universal": "2.0.11", diff --git a/tests/e2e/utils/process.ts b/tests/e2e/utils/process.ts index 00ed9a319ff7..4746453ec424 100644 --- a/tests/e2e/utils/process.ts +++ b/tests/e2e/utils/process.ts @@ -104,30 +104,30 @@ export function ng(...args: string[]) { if (args[0] == 'build') { return silentNg(...args); } else { - return _exec({}, '/usr/local/bin/ng', args); + return _exec({}, 'ng', args); } } export function silentNg(...args: string[]) { - return _exec({silent: true}, '/usr/local/bin/ng', args); + return _exec({silent: true}, 'ng', args); } export function silentNpm(...args: string[]) { - return _exec({silent: true}, '/usr/local/bin/npm', args); + return _exec({silent: true}, 'npm', args); } export function npm(...args: string[]) { - return _exec({}, '/usr/local/bin/npm', args); + return _exec({}, 'npm', args); } export function node(...args: string[]) { - return _exec({}, '/usr/local/bin/node', args); + return _exec({}, 'node', args); } export function git(...args: string[]) { - return _exec({}, '/usr/bin/git', args); + return _exec({}, 'git', args); } export function silentGit(...args: string[]) { - return _exec({silent: true}, '/usr/bin/git', args); + return _exec({silent: true}, 'git', args); } From 3449c4be2a95609276e7b14b9b0e983f19030ef5 Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Sat, 19 Nov 2016 17:52:33 +0100 Subject: [PATCH 11/38] test(universal): update e2e tests --- .../universal/files/__path__/server.ts | 2 +- tests/e2e/tests/build/sourcemap.ts | 8 ++- tests/e2e/tests/misc/lazy-module.ts | 69 ++++++++++++------- 3 files changed, 50 insertions(+), 29 deletions(-) diff --git a/packages/angular-cli/blueprints/universal/files/__path__/server.ts b/packages/angular-cli/blueprints/universal/files/__path__/server.ts index ed496e2123ed..3b4553e955bb 100644 --- a/packages/angular-cli/blueprints/universal/files/__path__/server.ts +++ b/packages/angular-cli/blueprints/universal/files/__path__/server.ts @@ -81,5 +81,5 @@ app.get('*', function(req: any, res: any) { }); app.listen(port, () => { - console.log(`Listening on port {port}`); + console.log(`Listening on port ${port}`); }); diff --git a/tests/e2e/tests/build/sourcemap.ts b/tests/e2e/tests/build/sourcemap.ts index 7029ff872f24..0457ff3d8f4e 100644 --- a/tests/e2e/tests/build/sourcemap.ts +++ b/tests/e2e/tests/build/sourcemap.ts @@ -1,11 +1,13 @@ import {ng} from '../../utils/process'; import {expectFileToExist} from '../../utils/fs'; -import {expectToFail} from '../../utils/utils'; +import { expectToFail, isUniversalTest } from '../../utils/utils'; export default function() { + const bundleMap = isUniversalTest() ? 'client.bundle.map' : 'main.bundle.map'; + return ng('build') - .then(() => expectFileToExist('dist/main.bundle.map')) + .then(() => expectFileToExist(`dist/${bundleMap}`)) .then(() => ng('build', '--no-sourcemap')) - .then(() => expectToFail(() => expectFileToExist('dist/main.bundle.map'))); + .then(() => expectToFail(() => expectFileToExist(`dist/${bundleMap}`))); } diff --git a/tests/e2e/tests/misc/lazy-module.ts b/tests/e2e/tests/misc/lazy-module.ts index 4fff6b80ae04..488217ad35c5 100644 --- a/tests/e2e/tests/misc/lazy-module.ts +++ b/tests/e2e/tests/misc/lazy-module.ts @@ -1,33 +1,52 @@ -import {readdirSync} from 'fs'; -import {oneLine} from 'common-tags'; +import { readdirSync } from 'fs'; +import { oneLine } from 'common-tags'; -import {ng} from '../../utils/process'; -import {addImportToModule} from '../../utils/ast'; +import { ng } from '../../utils/process'; +import { addImportToModule } from '../../utils/ast'; +import { isUniversalTest } from '../../utils/utils'; -export default function(argv: any) { +export default function (argv: any) { let oldNumberOfFiles = 0; - return Promise.resolve() - .then(() => ng('build')) - .then(() => oldNumberOfFiles = readdirSync('dist').length) - .then(() => ng('generate', 'module', 'lazy', '--routing')) - .then(() => addImportToModule('src/app/app.module.ts', oneLine` + if (isUniversalTest()) { + return Promise.resolve() + .then(() => ng('build')) + .then(() => oldNumberOfFiles = readdirSync('dist').length) + .then(() => ng('generate', 'module', 'lazy', '--routing')) + .then(() => addImportToModule('src/app/app.browser.module.ts', oneLine` RouterModule.forRoot([{ path: "lazy", loadChildren: "app/lazy/lazy.module#LazyModule" }]), RouterModule.forRoot([{ path: "lazy1", loadChildren: "./lazy/lazy.module#LazyModule" }]) `, '@angular/router')) - .then(() => ng('build')) - .then(() => readdirSync('dist').length) - .then(currentNumberOfDistFiles => { - if (oldNumberOfFiles >= currentNumberOfDistFiles) { - throw new Error('A bundle for the lazy module was not created.'); - } - }) - // Check for AoT and lazy routes. - .then(() => ng('build', '--aot')) - .then(() => readdirSync('dist').length) - .then(currentNumberOfDistFiles => { - if (oldNumberOfFiles >= currentNumberOfDistFiles) { - throw new Error('A bundle for the lazy module was not created.'); - } - }); + .then(() => ng('build')) + .then(() => readdirSync('dist').length) + .then(currentNumberOfDistFiles => { + if (oldNumberOfFiles >= currentNumberOfDistFiles) { + throw new Error('A bundle for the lazy module was not created.'); + } + }); + } else { + return Promise.resolve() + .then(() => ng('build')) + .then(() => oldNumberOfFiles = readdirSync('dist').length) + .then(() => ng('generate', 'module', 'lazy', '--routing')) + .then(() => addImportToModule('src/app/app.module.ts', oneLine` + RouterModule.forRoot([{ path: "lazy", loadChildren: "app/lazy/lazy.module#LazyModule" }]), + RouterModule.forRoot([{ path: "lazy1", loadChildren: "./lazy/lazy.module#LazyModule" }]) + `, '@angular/router')) + .then(() => ng('build')) + .then(() => readdirSync('dist').length) + .then(currentNumberOfDistFiles => { + if (oldNumberOfFiles >= currentNumberOfDistFiles) { + throw new Error('A bundle for the lazy module was not created.'); + } + }) + // Check for AoT and lazy routes. + .then(() => ng('build', '--aot')) + .then(() => readdirSync('dist').length) + .then(currentNumberOfDistFiles => { + if (oldNumberOfFiles >= currentNumberOfDistFiles) { + throw new Error('A bundle for the lazy module was not created.'); + } + }); + } } From f6ef5a1b20b8f736fe2eaec66e2a4ebb37a8b6a9 Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Sun, 20 Nov 2016 16:16:25 +0100 Subject: [PATCH 12/38] test(universal): add e2e test for serve command closes #11 --- tests/e2e/tests/build/sourcemap.ts | 8 +++----- tests/e2e/tests/misc/universal-serve.ts | 23 +++++++++++++++++++++++ tests/e2e/tests/test/e2e.ts | 16 +++++++++++++--- tests/e2e/utils/process.ts | 6 +++++- tests/e2e/utils/project.ts | 5 +++++ 5 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 tests/e2e/tests/misc/universal-serve.ts diff --git a/tests/e2e/tests/build/sourcemap.ts b/tests/e2e/tests/build/sourcemap.ts index 0457ff3d8f4e..64ae9e1d7dc3 100644 --- a/tests/e2e/tests/build/sourcemap.ts +++ b/tests/e2e/tests/build/sourcemap.ts @@ -1,13 +1,11 @@ import {ng} from '../../utils/process'; import {expectFileToExist} from '../../utils/fs'; -import { expectToFail, isUniversalTest } from '../../utils/utils'; +import { expectToFail, getAppMain } from '../../utils/utils'; export default function() { - const bundleMap = isUniversalTest() ? 'client.bundle.map' : 'main.bundle.map'; - return ng('build') - .then(() => expectFileToExist(`dist/${bundleMap}`)) + .then(() => expectFileToExist(`dist/${getAppMain()}.bundle.map`)) .then(() => ng('build', '--no-sourcemap')) - .then(() => expectToFail(() => expectFileToExist(`dist/${bundleMap}`))); + .then(() => expectToFail(() => expectFileToExist(`dist/${getAppMain()}.bundle.map`))); } diff --git a/tests/e2e/tests/misc/universal-serve.ts b/tests/e2e/tests/misc/universal-serve.ts new file mode 100644 index 000000000000..6e3e42eea3b6 --- /dev/null +++ b/tests/e2e/tests/misc/universal-serve.ts @@ -0,0 +1,23 @@ +import { request } from '../../utils/http'; +import { killAllProcesses } from '../../utils/process'; +import { ngUniversalServe } from '../../utils/project'; +import { isUniversalTest } from '../../utils/utils'; + + +export default function () { + if (!isUniversalTest()) { + return Promise.resolve(); + } + return Promise.resolve() + .then(() => ngUniversalServe()) + .then(() => request('http://localhost:4200')) + .then(body => { + if (!body.match(/app works!/)) { + throw new Error('Response does not match expected value.'); + } + }) + .then(() => killAllProcesses(), (err) => { + killAllProcesses(); + throw err; + }); +} diff --git a/tests/e2e/tests/test/e2e.ts b/tests/e2e/tests/test/e2e.ts index 5ea54dbc47f2..6ca7bfc3df8e 100644 --- a/tests/e2e/tests/test/e2e.ts +++ b/tests/e2e/tests/test/e2e.ts @@ -1,6 +1,6 @@ import { ng, killAllProcesses } from '../../utils/process'; import { expectToFail, isUniversalTest } from '../../utils/utils'; -import { ngServe } from '../../utils/project'; +import { ngServe, ngUniversalServe } from '../../utils/project'; function _runServeAndE2e(...args: string[]) { @@ -12,10 +12,20 @@ function _runServeAndE2e(...args: string[]) { }); } +function _runUniversalServeAndE2e(...args: string[]) { + return ngUniversalServe(...args) + .then(() => ng('e2e')) + .then(() => killAllProcesses(), (err: any) => { + killAllProcesses(); + throw err; + }); +} + export default function () { - /** Serve test disabled for universal */ + /** AOT test disabled for universal */ if (isUniversalTest()) { - return expectToFail(() => ng('e2e')); + return expectToFail(() => ng('e2e')) + .then(() => _runUniversalServeAndE2e('--prod')); } // This is supposed to fail without serving first... return expectToFail(() => ng('e2e')) diff --git a/tests/e2e/utils/process.ts b/tests/e2e/utils/process.ts index 4746453ec424..0c88a35ceba4 100644 --- a/tests/e2e/utils/process.ts +++ b/tests/e2e/utils/process.ts @@ -1,5 +1,5 @@ import * as child_process from 'child_process'; -import {blue, white, yellow} from 'chalk'; +import { blue, white, yellow } from 'chalk'; const treeKill = require('tree-kill'); @@ -74,6 +74,10 @@ function _exec(options: ExecOptions, cmd: string, args: string[]): Promise { + reject({message: 'timed out after 60 seconds.'}); + }, 60000); + childProcess.stdout.on('data', (data: Buffer) => { if (data.toString().match(options.waitForMatch)) { resolve(stdout); diff --git a/tests/e2e/utils/project.ts b/tests/e2e/utils/project.ts index b9aa09a41fab..fef8435d160f 100644 --- a/tests/e2e/utils/project.ts +++ b/tests/e2e/utils/project.ts @@ -22,3 +22,8 @@ export function ngServe(...args: string[]) { return silentExecAndWaitForOutputToMatch('ng', ['serve', ...args], /webpack: bundle is now VALID/); } + +export function ngUniversalServe(...args: string[]) { + return silentExecAndWaitForOutputToMatch('ng', + ['serve', ...args], /Listening on port 4200/); +} From 0afcbb4905caf19c3cb03356222da520978b94d6 Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Sun, 20 Nov 2016 16:17:40 +0100 Subject: [PATCH 13/38] refactor(universal): use polyfills.ts for managing universal polyfills closes #14 --- .../angular-cli/blueprints/ng2/files/__path__/polyfills.ts | 6 ++++-- .../blueprints/universal/files/__path__/client.ts | 1 - .../blueprints/universal/files/__path__/server.ts | 1 - 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/angular-cli/blueprints/ng2/files/__path__/polyfills.ts b/packages/angular-cli/blueprints/ng2/files/__path__/polyfills.ts index 3b4c55b09656..96564549cf9a 100644 --- a/packages/angular-cli/blueprints/ng2/files/__path__/polyfills.ts +++ b/packages/angular-cli/blueprints/ng2/files/__path__/polyfills.ts @@ -1,5 +1,7 @@ // This file includes polyfills needed by Angular 2 and is loaded before // the app. You can add your own extra polyfills to this file. +<% if(universal) { %> +import 'angular2-universal-polyfills';<% } %> import 'core-js/es6/symbol'; import 'core-js/es6/object'; import 'core-js/es6/function'; @@ -15,5 +17,5 @@ import 'core-js/es6/map'; import 'core-js/es6/set'; import 'core-js/es6/reflect'; -import 'core-js/es7/reflect'; -import 'zone.js/dist/zone'; +import 'core-js/es7/reflect';<% if(!universal) { %> +import 'zone.js/dist/zone';<% } %> diff --git a/packages/angular-cli/blueprints/universal/files/__path__/client.ts b/packages/angular-cli/blueprints/universal/files/__path__/client.ts index bf16e9b9a28a..dfdc2940f970 100644 --- a/packages/angular-cli/blueprints/universal/files/__path__/client.ts +++ b/packages/angular-cli/blueprints/universal/files/__path__/client.ts @@ -1,7 +1,6 @@ /** * the polyfills must be the first thing imported */ -import 'angular2-universal-polyfills'; import './polyfills.ts'; import { enableProdMode } from '@angular/core'; import { environment } from './environments/environment'; diff --git a/packages/angular-cli/blueprints/universal/files/__path__/server.ts b/packages/angular-cli/blueprints/universal/files/__path__/server.ts index 3b4553e955bb..5851804fbd8c 100644 --- a/packages/angular-cli/blueprints/universal/files/__path__/server.ts +++ b/packages/angular-cli/blueprints/universal/files/__path__/server.ts @@ -1,7 +1,6 @@ /** * the polyfills must be the first thing imported */ -import 'angular2-universal-polyfills'; import './polyfills.ts'; import * as path from 'path'; import * as express from 'express'; From 5275ae290b41c9e49f0e55a3d7cec62028984ecf Mon Sep 17 00:00:00 2001 From: John Brandes Date: Sun, 20 Nov 2016 18:41:12 +0100 Subject: [PATCH 14/38] feat(universal): Server routes --- .../universal/files/__path__/server.routes.ts | 14 +++++++++++++ .../universal/files/__path__/server.ts | 20 +++++++++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 packages/angular-cli/blueprints/universal/files/__path__/server.routes.ts diff --git a/packages/angular-cli/blueprints/universal/files/__path__/server.routes.ts b/packages/angular-cli/blueprints/universal/files/__path__/server.routes.ts new file mode 100644 index 000000000000..4011f826c7fe --- /dev/null +++ b/packages/angular-cli/blueprints/universal/files/__path__/server.routes.ts @@ -0,0 +1,14 @@ +/** + * Server-side routes. Only the listed routes support html5pushstate. + * Has to match client side routes. + * + * Index (/) route does not have to be listed here. + * + * @example + * export const routes: string[] = [ + * 'home', 'about' + * ]; + **/ +export const routes: string[] = [ + +]; diff --git a/packages/angular-cli/blueprints/universal/files/__path__/server.ts b/packages/angular-cli/blueprints/universal/files/__path__/server.ts index 5851804fbd8c..bd5ff05d5983 100644 --- a/packages/angular-cli/blueprints/universal/files/__path__/server.ts +++ b/packages/angular-cli/blueprints/universal/files/__path__/server.ts @@ -4,13 +4,16 @@ import './polyfills.ts'; import * as path from 'path'; import * as express from 'express'; -import { enableProdMode } from '@angular/core'; +import * as compression from 'compression'; import { createEngine } from 'angular2-express-engine'; +import { enableProdMode } from '@angular/core'; import { AppModule } from './app/app.node.module'; -import * as compression from 'compression'; import { environment } from './environments/environment'; +import { routes } from './server.routes'; + +// App -const app = express(); +const app = express(); const ROOT = path.join(path.resolve(__dirname, '..')); const port = process.env.PORT || 4200; @@ -64,17 +67,18 @@ function ngApp(req: any, res: any) { * use universal for specific routes */ app.get('/', ngApp); -app.get('/about', ngApp); -app.get('/about/*', ngApp); +routes.forEach(route => { + app.get(`/${route}`, ngApp); + app.get(`/${route}/*`, ngApp); +}); /** * if you want to use universal for all routes, you can use the '*' wildcard */ -// app.get('*', ngApp); -app.get('*', function(req: any, res: any) { +app.get('*', function (req: any, res: any) { res.setHeader('Content-Type', 'application/json'); - const pojo = { status: 404, message: 'No Content' }; + const pojo = {status: 404, message: 'No Content'}; const json = JSON.stringify(pojo, null, 2); res.status(404).send(json); }); From 4fc76db55f192480e5593993b4bda7bcb3c60bb7 Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Thu, 24 Nov 2016 22:04:37 +0100 Subject: [PATCH 15/38] chore(readme): add slack channel closes #18 --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index a1b309e7e39d..da448f41e8a3 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,9 @@ It is a separate package because the Core-CLI team is not able to maintain non-c I am looking for maintainers, please let me know if you're interested in supporting `universal-cli`. +### Slack +Feel free to ask questions related to Angular Universal and Universal-CLI at [angular-universal.slack.com](https://angular-universal.slack.com) + [![Join the chat at https://gitter.im/angular/angular-cli](https://badges.gitter.im/angular/angular-cli.svg)](https://gitter.im/angular/angular-cli?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status][travis-badge]][travis-badge-url] From 4459577c39b10049bfd913ad33d04701824fc655 Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Thu, 24 Nov 2016 22:15:15 +0100 Subject: [PATCH 16/38] chore(docs): add docs for npm publish closes #16 --- docs/publish.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 docs/publish.md diff --git a/docs/publish.md b/docs/publish.md new file mode 100644 index 000000000000..ab869bce6f93 --- /dev/null +++ b/docs/publish.md @@ -0,0 +1,15 @@ +#Change versions +- There is a main `package.json` which should keep with the latest angular-cli version (e.g. `1.0.0-beta.17`). +- There is one `package.json` per packages. Update the version of every packages independently. +- Run the CHANGELOG script. + - `node ./scripts/publish/changelog.js OLD_VERSION_TAG` + - (for example, `v1.0.0-beta.17`) +- Create a commit. The commit message should be only the version number starting with a v. +- Create a tag. The tag should be only the version number starting with a v. +- Push to upstream with tags. + - `git push master` + - `git push --tags` +- Publish to npm + - `cd ./dist/angular-cli` + - `npm publish --tag experimental` (install it with `npm install -g universal-cli@experimental` and test it) + - `npm publish` (the new version is now available at npm) \ No newline at end of file From 65c49dcb0cf48f9ff9b34b0cdf85a09cbf5a143b Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Thu, 24 Nov 2016 21:56:47 +0100 Subject: [PATCH 17/38] refactor(ng): rename binary to ung closes #15 --- README.md | 104 +++++++++--------- bin/{ng => ung} | 2 +- docs/design/docker-deploy.md | 40 +++---- docs/design/third-party-libraries.md | 30 ++--- package.json | 2 +- packages/angular-cli/bin/{ng => ung} | 0 .../blueprints/ng2/files/package.json | 4 +- packages/angular-cli/commands/generate.ts | 2 +- packages/angular-cli/commands/init.ts | 4 +- packages/angular-cli/commands/new.ts | 8 +- packages/angular-cli/lib/cli/index.js | 8 +- packages/angular-cli/package.json | 2 +- packages/angular-cli/utilities/completion.sh | 12 +- tests/acceptance/destroy.spec.js | 6 +- tests/acceptance/generate-class.spec.js | 8 +- tests/acceptance/generate-component.spec.js | 4 +- tests/acceptance/generate-directive.spec.js | 4 +- tests/acceptance/generate-module.spec.js | 12 +- tests/acceptance/generate-pipe.spec.js | 22 ++-- tests/acceptance/generate-route.spec.js | 12 +- tests/acceptance/generate-service.spec.js | 22 ++-- tests/acceptance/github-pages-deploy.spec.js | 2 +- tests/acceptance/init.spec.js | 14 +-- tests/acceptance/new.spec.js | 26 ++--- tests/e2e/setup/100-npm-link.ts | 2 +- tests/e2e/utils/process.ts | 4 +- tests/e2e/utils/project.ts | 4 +- 27 files changed, 180 insertions(+), 180 deletions(-) rename bin/{ng => ung} (76%) rename packages/angular-cli/bin/{ng => ung} (100%) diff --git a/README.md b/README.md index da448f41e8a3..ba5117d05364 100644 --- a/README.md +++ b/README.md @@ -75,52 +75,52 @@ npm install -g universal-cli ## Usage ```bash -ng --help +ung --help ``` ### Generating and serving an Angular2 project via a development server ```bash -ng new PROJECT_NAME +ung new PROJECT_NAME cd PROJECT_NAME -ng serve +ung serve ``` Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. You can configure the default HTTP port and the one used by the LiveReload server with two command-line options : ```bash -ng serve --host 0.0.0.0 --port 4201 --live-reload-port 49153 +ung serve --host 0.0.0.0 --port 4201 --live-reload-port 49153 ``` ### Generating Components, Directives, Pipes and Services -You can use the `ng generate` (or just `ng g`) command to generate Angular components: +You can use the `ung generate` (or just `ung g`) command to generate Angular components: ```bash -ng generate component my-new-component -ng g component my-new-component # using the alias +ung generate component my-new-component +ung g component my-new-component # using the alias # components support relative path generation # if in the directory src/app/feature/ and you run -ng g component new-cmp +ung g component new-cmp # your component will be generated in src/app/feature/new-cmp # but if you were to run -ng g component ../newer-cmp +ung g component ../newer-cmp # your component will be generated in src/app/newer-cmp ``` You can find all possible blueprints in the table below: Scaffold | Usage --- | --- -Component | `ng g component my-new-component` -Directive | `ng g directive my-new-directive` -Pipe | `ng g pipe my-new-pipe` -Service | `ng g service my-new-service` -Class | `ng g class my-new-class` -Interface | `ng g interface my-new-interface` -Enum | `ng g enum my-new-enum` -Module | `ng g module my-module` +Component | `ung g component my-new-component` +Directive | `ung g directive my-new-directive` +Pipe | `ung g pipe my-new-pipe` +Service | `ung g service my-new-service` +Class | `ung g class my-new-class` +Interface | `ung g interface my-new-interface` +Enum | `ung g enum my-new-enum` +Module | `ung g module my-module` ### Generating a route @@ -131,14 +131,14 @@ You can read the official documentation for the new Router here: https://angular ### Creating a build ```bash -ng build +ung build ``` The build artifacts will be stored in the `dist/` directory. ### Build Targets and Environment Files -`ng build` can specify both a build target (`--target=production` or `--target=development`) and an +`ung build` can specify both a build target (`--target=production` or `--target=development`) and an environment file to be used with that build (`--environment=dev` or `--environment=prod`). By default, the development build target and environment are used. @@ -157,14 +157,14 @@ it will default to `dev` for `development` and `prod` for `production`. ```bash # these are equivalent -ng build --target=production --environment=prod -ng build --prod --env=prod -ng build --prod +ung build --target=production --environment=prod +ung build --prod --env=prod +ung build --prod # and so are these -ng build --target=development --environment=dev -ng build --dev --e=dev -ng build --dev -ng build +ung build --target=development --environment=dev +ung build --dev --e=dev +ung build --dev +ung build ``` You can also add your own env files other than `dev` and `prod` by doing the following: @@ -178,19 +178,19 @@ When building you can modify base tag (``) in your index.html wit ```bash # Sets base tag href to /myUrl/ in your index.html -ng build --base-href /myUrl/ -ng build --bh /myUrl/ +ung build --base-href /myUrl/ +ung build --bh /myUrl/ ``` ### Bundling -All builds make use of bundling, and using the `--prod` flag in `ng build --prod` -or `ng serve --prod` will also make use of uglifying and tree-shaking functionality. +All builds make use of bundling, and using the `--prod` flag in `ung build --prod` +or `ung serve --prod` will also make use of uglifying and tree-shaking functionality. ### Running unit tests ```bash -ng test +ung test ``` Tests will execute after a build is executed via [Karma](http://karma-runner.github.io/0.13/index.html), and it will automatically watch your files for changes. You can run tests a single time via `--watch=false` or `--single-run`. @@ -198,10 +198,10 @@ Tests will execute after a build is executed via [Karma](http://karma-runner.git ### Running end-to-end tests ```bash -ng e2e +ung e2e ``` -Before running the tests make sure you are serving the app via `ng serve`. +Before running the tests make sure you are serving the app via `ung serve`. End-to-end tests are run via [Protractor](https://angular.github.io/protractor/). @@ -238,7 +238,7 @@ now run it with `npm start` You can deploy your apps quickly via: ```bash -ng github-pages:deploy --message "Optional commit message" +ung github-pages:deploy --message "Optional commit message" ``` This will do the following: @@ -258,7 +258,7 @@ To simplify the authentication, be sure to [setup your ssh keys](https://help.gi If you are deploying a [user or organization page](https://help.github.com/articles/user-organization-and-project-pages/), you can instead use the following command: ```bash -ng github-pages:deploy --user-page --message "Optional commit message" +ung github-pages:deploy --user-page --message "Optional commit message" ``` This command pushes the app to the `master` branch on the github repo instead @@ -267,7 +267,7 @@ of pushing to `gh-pages`, since user and organization pages require this. ### Linting and formatting code -You can lint your app code by running `ng lint`. +You can lint your app code by running `ung lint`. This will use the `lint` npm script that in generated projects uses `tslint`. You can modify the these scripts in `package.json` to run whatever tool you prefer. @@ -276,20 +276,20 @@ You can modify the these scripts in `package.json` to run whatever tool you pref **The `--mobile` flag has been disabled temporarily. Sorry for the inconvenience.** -~~Angular-CLI includes support for offline applications via the `--mobile` flag on `ng new`. Support is experimental, +~~Angular-CLI includes support for offline applications via the `--mobile` flag on `ung new`. Support is experimental, please see the angular/mobile-toolkit project and https://mobile.angular.io/ for documentation on how to make use of this functionality.~~ ### Support for server side rendering -**Angular-CLI includes Angular Universal via the `--universal` flag on `ng new` and `ng init`.** +**Angular-CLI includes Angular Universal via the `--universal` flag on `ung new` and `ung init`.** **Angular Universal** helps you to seo optimize your application and offers a better user experience through server side rendering. Please see the **angular/universal** project and https://universal.angular.io/ for documentation on how to make use of this functionality. #### Update an existing Project -`cd path/to/project` and init your project with the universal option `ng init --universal`. Take every Pipe, Directive, Component, Module and Routes from `./src/app/app.module.ts` -and move them to `./src/app/app.browser.module.ts` and `./src/app/app.node.module.ts`. Try `ng serve`, if your application looks like before, then you can delete the files +`cd path/to/project` and init your project with the universal option `ung init --universal`. Take every Pipe, Directive, Component, Module and Routes from `./src/app/app.module.ts` +and move them to `./src/app/app.browser.module.ts` and `./src/app/app.node.module.ts`. Try `ung serve`, if your application looks like before, then you can delete the files `./src/app/app.module.ts` and `./src/main.ts`. **Have fun with Angular Universal!** ### Commands autocompletion @@ -298,19 +298,19 @@ To turn on auto completion use the following commands: For bash: ```bash -ng completion 1>> ~/.bashrc 2>>&1 +ung completion 1>> ~/.bashrc 2>>&1 source ~/.bashrc ``` For zsh: ```bash -ng completion 1>> ~/.zshrc 2>>&1 +ung completion 1>> ~/.zshrc 2>>&1 source ~/.zshrc ``` Windows users using gitbash: ```bash -ng completion 1>> ~/.bash_profile 2>>&1 +ung completion 1>> ~/.bash_profile 2>>&1 source ~/.bash_profile ``` @@ -358,13 +358,13 @@ When generating a new project you can also define which extension you want for style files: ```bash -ng new sassy-project --style=sass +ung new sassy-project --style=sass ``` Or set the default style on an existing project: ```bash -ng set defaults.styleExt scss +ung set defaults.styleExt scss ``` ### 3rd Party Library Installation @@ -422,7 +422,7 @@ Finally add the Bootstrap CSS to the `apps[0].styles` array: ], ``` -Restart `ng serve` if you're running it, and Bootstrap 4 should be working on +Restart `ung serve` if you're running it, and Bootstrap 4 should be working on your app. ### Updating angular-cli @@ -441,12 +441,12 @@ Local project package: rm -rf node_modules dist tmp npm install --save-dev angular-cli@latest npm install -ng init +ung init ``` -Running `ng init` will check for changes in all the auto-generated files created by `ng new` and allow you to update yours. You are offered four choices for each changed file: `y` (overwrite), `n` (don't overwrite), `d` (show diff between your file and the updated file) and `h` (help). +Running `ung init` will check for changes in all the auto-generated files created by `ung new` and allow you to update yours. You are offered four choices for each changed file: `y` (overwrite), `n` (don't overwrite), `d` (show diff between your file and the updated file) and `h` (help). -Carefully read the diffs for each code file, and either accept the changes or incorporate them manually after `ng init` finishes. +Carefully read the diffs for each code file, and either accept the changes or incorporate them manually after `ung init` finishes. **The main cause of errors after an update is failing to incorporate these updates into your code**. @@ -471,10 +471,10 @@ allowing you to quickly test any changes you make to the cli project. Now you can use `angular-cli` via the command line: ```bash -ng new foo +ung new foo cd foo npm link angular-cli -ng serve +ung serve ``` `npm link angular-cli` is needed because by default the globally installed `angular-cli` just loads @@ -483,7 +483,7 @@ the local `angular-cli` from the project which was fetched remotely from npm. Now the `angular-cli` you cloned before is in three places: The folder you cloned it into, npm's folder where it stores global packages and the `angular-cli` project you just created. -You can also use `ng new foo --link-cli` to automatically link the `angular-cli` package. +You can also use `ung new foo --link-cli` to automatically link the `angular-cli` package. Please read the official [npm-link documentation](https://www.npmjs.org/doc/cli/npm-link.html) and the [npm-link cheatsheet](http://browsenpm.org/help#linkinganynpmpackagelocally) for more information. diff --git a/bin/ng b/bin/ung similarity index 76% rename from bin/ng rename to bin/ung index 5e770a2caa95..d99e97baa291 100755 --- a/bin/ng +++ b/bin/ung @@ -5,4 +5,4 @@ process.title = 'angular-cli'; require('../lib/bootstrap-local'); -require('../packages/angular-cli/bin/ng'); +require('../packages/angular-cli/bin/ung'); diff --git a/docs/design/docker-deploy.md b/docs/design/docker-deploy.md index 256368594ab0..06835e87f121 100644 --- a/docs/design/docker-deploy.md +++ b/docs/design/docker-deploy.md @@ -15,11 +15,11 @@ Provide tasks for common Docker workflows: 1. Requires user to have Docker CLI tools installed. (See also: ["Implementation Approaches"](#implementation-approaches)) -1. User is free to use the Angular CLI without Docker (and vice versa). By default, do not generate Docker files upon creation of a new project (`ng new`, `ng init`). +1. User is free to use the Angular CLI without Docker (and vice versa). By default, do not generate Docker files upon creation of a new project (`ung new`, `ung init`). 1. Don't recreate the wheel. Docker CLI tools are very full featured on their own. Implement the common Docker use cases that make it convenient for Angular applications. 1. Don't inhibit users from using the standalone Docker CLI tools for other use cases. 1. Assumes 1:1 Dockerfile with the Angular project. Support for multiple services under the same project is outside the scope of this initial design. -1. Generated starter Dockerfile will use an Nginx base image for the default server. The built ng app and Nginx configuration for HTML5 Fallback will be copied into the image. +1. Generated starter Dockerfile will use an Nginx base image for the default server. The built ung app and Nginx configuration for HTML5 Fallback will be copied into the image. 1. User is free to modify and customize all generated files directly without involvement by the Angular CLI. 1. Image builds will support all Docker build options. 1. Container deploys will support all Docker run options. @@ -37,22 +37,22 @@ Provide tasks for common Docker workflows: Initialize the project for Docker builds and deploys: ``` -$ ng docker init [--environment env] +$ ung docker init [--environment env] ``` Build and push a Docker image of the Angular app to the registry: ``` -$ ng docker push [--registry url] +$ ung docker push [--registry url] ``` Deploy and run the Angular app on a Docker Machine: ``` -$ ng docker deploy [--environment env] +$ ung docker deploy [--environment env] ``` ### Command - Docker Init -The command `ng docker init` generates starter `Dockerfile`, `.dockerignore`, and `docker-compose.yml` files for builds and and deploys. +The command `ung docker init` generates starter `Dockerfile`, `.dockerignore`, and `docker-compose.yml` files for builds and and deploys. Most users will start with one local 'default' Docker Machine (Mac/Win), or a local native Docker environment on Linux, where they will perform builds and run containers for development testing. Without additional arguments, this command prepares the Angular project for working with that default environment. @@ -70,7 +70,7 @@ Most users will start with one local 'default' Docker Machine (Mac/Win), or a lo **Example - Init default environment:** ```bash -$ ng docker:init --image-org my-username +$ ung docker:init --image-org my-username Generated 'Dockerfile' Generated '.dockerignore' @@ -79,10 +79,10 @@ Generated 'docker-compose.yml' Docker is ready! You can build and push a Docker image of your application to a docker registry using: - $ ng docker push + $ ung docker push Build and run your application using: - $ ng docker deploy + $ ung docker deploy ``` **Other requirements:** @@ -153,16 +153,16 @@ services: The `\${NG_APP_IMAGE}` is a Compose variable, not an Angilar CLI var. It will be substituted during a `docker deploy` command with an environment variable of the desired tag. (See [Compose Variable Substitution](https://docs.docker.com/compose/compose-file/#variable-substitution) for more info) -Separate `docker-compose-{environment}.yml` files are used to deploy to different [environments](https://docs.docker.com/compose/extends/#example-use-case), for use with the `ng docker deploy` command. +Separate `docker-compose-{environment}.yml` files are used to deploy to different [environments](https://docs.docker.com/compose/extends/#example-use-case), for use with the `ung docker deploy` command. ### Command - Docker Push -The command `ng docker push` builds a Docker image of the Angular app from the `Dockerfile`, and pushes the image with a new tag to a registry address. +The command `ung docker push` builds a Docker image of the Angular app from the `Dockerfile`, and pushes the image with a new tag to a registry address. Example - Build and push (with auth): ```bash -$ ng docker push --tag 1.0.0 --tag-latest +$ ung docker push --tag 1.0.0 --tag-latest Building image... Tagging "1.0.0"... Tagging "latest" @@ -194,7 +194,7 @@ The `--no-cache`, `--force-rm`, and `--pull` are [compose build options](https:/ Try an initial push. If an authentication failure occurs, attempt to login via `docker login`, or with `aws ecr get-login` (if the registry address matches `/\.dkr\.ecr\./`). Proxy the CLI input to the login commands. Avoid storing any authentication values in ngConfig. -The `serviceName`, `registryAddress`, `orgName`, and `imageName` defaults will first be retrieved from ngConfig, which were saved during the initial `ng docker init` command. If any of these values do not exist, warn the user with instructions to add via `ng docker init` or `ng set name=value`. +The `serviceName`, `registryAddress`, `orgName`, and `imageName` defaults will first be retrieved from ngConfig, which were saved during the initial `ung docker init` command. If any of these values do not exist, warn the user with instructions to add via `ung docker init` or `ung set name=value`. #### Internal Steps @@ -210,13 +210,13 @@ The `serviceName`, `registryAddress`, `orgName`, and `imageName` defaults will f ### Command - Docker Deploy -The command `ng docker deploy` will deploy an environment's compose configuration to a Docker Machine. It starts the containers in the background and leaves them running. +The command `ung docker deploy` will deploy an environment's compose configuration to a Docker Machine. It starts the containers in the background and leaves them running. -Consider a command alias: `ng docker run`. +Consider a command alias: `ung docker run`. Example - Default environment deploy: ```bash -$ ng docker deploy +$ ung docker deploy Building... Deploying to default environment... Deploy complete! @@ -224,13 +224,13 @@ Deploy complete! Example - Deploying to a named environment, without builds: ```bash -$ ng docker:deploy --environment stage -$ ng docker:deploy --environment prod --tag 1.0.1 +$ ung docker:deploy --environment stage +$ ung docker:deploy --environment prod --tag 1.0.1 ``` Example - Deploying a specific service from the compose file: ```bash -$ ng docker deploy --services my-ng-app +$ ung docker deploy --services my-ng-app ``` #### Options @@ -299,7 +299,7 @@ Example ngConfig model for saved docker command state (per project): ## Other Enhancements * Ability to list the configured deploy environments. -* Autocomplete environment names for `ng docker deploy`. +* Autocomplete environment names for `ung docker deploy`. * New command wrappers for `docker-compose logs`, and `docker exec` commands. * Create an Angular development environment image with everything packaged inside. Users can run the container with local volume mounts, and toolset will watch/rebuild for local file changes. Only requires Docker to be installed to get started with Angular development. There are some Node.js complexities to solve when adding new package.json dependencies, and many users report issues with file watchers and docker volume mounts. * Deployment support to other container scheduling systems: Kubernetes, Marathon/Mesos, AWS ECS and Beanstalk, Azure Service Fabric, etc. diff --git a/docs/design/third-party-libraries.md b/docs/design/third-party-libraries.md index db25c5303d2d..8c35dc9fa3d6 100644 --- a/docs/design/third-party-libraries.md +++ b/docs/design/third-party-libraries.md @@ -2,12 +2,12 @@ # Abstract -The current `ng install` process is faulty; third parties have to add a `bundles/` directory +The current `ung install` process is faulty; third parties have to add a `bundles/` directory with metadata that we expect. This document explores ways to improve on the process. # Requirements -The following use cases need to be supported by `ng install`: +The following use cases need to be supported by `ung install`: 1. Support for _any_ thirdparties, ultimately falling back to running `npm install` only and doing nothing else, if necessary. @@ -31,29 +31,29 @@ to proper map the imports and move them to `tmp` before compiling, then to `dist Here's a few stories that should work right off: ```sh -$ ng new my-app && cd my-app/ -$ ng install jquery +$ ung new my-app && cd my-app/ +$ ung install jquery ``` ^(this makes jQuery available in the index) ```sh -$ ng install angularfire2 +$ ung install angularfire2 > Please specify your Firebase database URL [my-app.firebaseio.com]: _ ``` ^(makes firebase available and provided to the App) ```sh -$ ng install angularfire2 --dbUrl=my-firebase-db.example.com +$ ung install angularfire2 --dbUrl=my-firebase-db.example.com ``` ^(skip prompts for values passed on the command line) ```sh -$ ng install angularfire2 --quiet +$ ung install angularfire2 --quiet ``` ^(using `--quiet` to skip all prompts and use default values) ```sh -$ ng install less +$ ung install less ``` ^(now compiles CSS files with less for the appropriate extensions) @@ -75,7 +75,7 @@ The `install` task will perform the following subtasks: 1. **Run `package["angular-cli"].scripts["install"]` if it exists.** If the script fails, run `npm uninstall ${libName}` and fail the install process. 1. **Detect if a package named `angular/cli-wrapper-${libName}` exist in the angular - organization.** If so, run the steps above as if ng install angular/angular-${libName}. If + organization.** If so, run the steps above as if ung install angular/angular-${libName}. If this install fails, ignore the failure. These packages can be used to wrap libraries that we want to support but can't update @@ -151,13 +151,13 @@ needs to exist for toolings to be able to understand dependencies. These provide to the application. In order to blacklist providers from being global, the user can use the `--no-global-providers` -flag during installation, or can change the dependencies by using `ng providers`. As an example: +flag during installation, or can change the dependencies by using `ung providers`. As an example: ```bash -ng new my-todo-app -ng generate component database -ng install --no-global-providers angularfirebase2 -ng providers database angularfirebase2 +ung new my-todo-app +ung generate component database +ung install --no-global-providers angularfirebase2 +ung providers database angularfirebase2 ``` Or, alternatively, the user can add its own providers and dependencies to its components. @@ -186,7 +186,7 @@ to leave the liberty to the user to change the SystemJS configuration so that it We will not use SystemJS bundles in development. This is for better debugging, future proofing (when moving the build system) and better CDN support, as many of the loaded files will end up -being pulled from a CDN in production. During the `ng build` process for production, the +being pulled from a CDN in production. During the `ung build` process for production, the SystemJS configuration script will be rebuilt to fetch from the CDN. # Upgrade Strategy diff --git a/package.json b/package.json index 84e133f0c5d7..9d6ea6637855 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "packages/angular-cli/lib/cli/index.js", "trackingCode": "xx-xxxxxxx-xx", "bin": { - "ng": "./bin/ng" + "ung": "./bin/ung" }, "keywords": [], "scripts": { diff --git a/packages/angular-cli/bin/ng b/packages/angular-cli/bin/ung similarity index 100% rename from packages/angular-cli/bin/ng rename to packages/angular-cli/bin/ung diff --git a/packages/angular-cli/blueprints/ng2/files/package.json b/packages/angular-cli/blueprints/ng2/files/package.json index d09128f27899..3d2fb4478855 100644 --- a/packages/angular-cli/blueprints/ng2/files/package.json +++ b/packages/angular-cli/blueprints/ng2/files/package.json @@ -4,9 +4,9 @@ "license": "MIT", "angular-cli": {}, "scripts": { - "start": "ng serve", + "start": "ung serve", "lint": "tslint \"<%= sourceDir %>/**/*.ts\"", - "test": "ng test", + "test": "ung test", "pree2e": "webdriver-manager update", "e2e": "protractor" }, diff --git a/packages/angular-cli/commands/generate.ts b/packages/angular-cli/commands/generate.ts index 94adafed29c8..8bc3a01aec89 100644 --- a/packages/angular-cli/commands/generate.ts +++ b/packages/angular-cli/commands/generate.ts @@ -26,7 +26,7 @@ const GenerateCommand = EmberGenerateCommand.extend({ if (!rawArgs[1]) { SilentError.debugOrThrow('angular-cli/commands/generate', - `The \`ng generate ${rawArgs[0]}\` command requires a name to be specified.`); + `The \`ung generate ${rawArgs[0]}\` command requires a name to be specified.`); } // Override default help to hide ember blueprints diff --git a/packages/angular-cli/commands/init.ts b/packages/angular-cli/commands/init.ts index 54380b5d9ffb..1473f8fa58aa 100644 --- a/packages/angular-cli/commands/init.ts +++ b/packages/angular-cli/commands/init.ts @@ -87,9 +87,9 @@ const InitCommand: any = Command.extend({ const packageName = commandOptions.name !== '.' && commandOptions.name || project.name(); if (!packageName) { - const message = 'The `ng ' + this.name + '` command requires a ' + + const message = 'The `ung ' + this.name + '` command requires a ' + 'package.json in current folder with name attribute or a specified name via arguments. ' + - 'For more details, use `ng help`.'; + 'For more details, use `ung help`.'; return Promise.reject(new SilentError(message)); } diff --git a/packages/angular-cli/commands/new.ts b/packages/angular-cli/commands/new.ts index 02f69fc3aeb5..816ced709582 100644 --- a/packages/angular-cli/commands/new.ts +++ b/packages/angular-cli/commands/new.ts @@ -9,7 +9,7 @@ const validProjectName = require('../ember-cli/lib/utilities/valid-project-name' const NewCommand = Command.extend({ name: 'new', - description: `Creates a new directory and runs ${chalk.green('ng init')} in it.`, + description: `Creates a new directory and runs ${chalk.green('ung init')} in it.`, works: 'outsideProject', availableOptions: [ @@ -35,8 +35,8 @@ const NewCommand = Command.extend({ if (!packageName) { return Promise.reject(new SilentError( - `The "ng ${this.name}" command requires a name argument to be specified. ` + - `For more details, use "ng help".`)); + `The "ung ${this.name}" command requires a name argument to be specified. ` + + `For more details, use "ung help".`)); } commandOptions.name = packageName; @@ -46,7 +46,7 @@ const NewCommand = Command.extend({ if (packageName === '.') { return Promise.reject(new SilentError( - `Trying to generate an application structure in this directory? Use "ng init" ` + + `Trying to generate an application structure in this directory? Use "ung init" ` + `instead.`)); } diff --git a/packages/angular-cli/lib/cli/index.js b/packages/angular-cli/lib/cli/index.js index e6eb95ff1e87..eac23e44caed 100644 --- a/packages/angular-cli/lib/cli/index.js +++ b/packages/angular-cli/lib/cli/index.js @@ -24,11 +24,11 @@ module.exports = function(options) { process.stdout.write = function (line) { line = line.toString(); if (line.match(/ember-cli-(inject-)?live-reload/)) { - // don't replace 'ember-cli-live-reload' on ng init diffs + // don't replace 'ember-cli-live-reload' on ung init diffs return oldStdoutWrite.apply(process.stdout, arguments); } line = line.replace(/ember-cli(?!.com)/g, 'angular-cli') - .replace(/\bember\b(?!-cli.com)/g, 'ng'); + .replace(/\bember\b(?!-cli.com)/g, 'ung'); return oldStdoutWrite.apply(process.stdout, arguments); }; @@ -36,12 +36,12 @@ module.exports = function(options) { process.stderr.write = function (line) { line = line.toString() .replace(/ember-cli(?!.com)/g, 'angular-cli') - .replace(/\bember\b(?!-cli.com)/g, 'ng'); + .replace(/\bember\b(?!-cli.com)/g, 'ung'); return oldStderrWrite.apply(process.stdout, arguments); }; options.cli = { - name: 'ng', + name: 'ung', root: path.join(__dirname, '..', '..'), npmPackage: 'universal-cli' }; diff --git a/packages/angular-cli/package.json b/packages/angular-cli/package.json index 88da1e3e0bbd..37d5732cece8 100644 --- a/packages/angular-cli/package.json +++ b/packages/angular-cli/package.json @@ -6,7 +6,7 @@ "main": "lib/cli/index.js", "trackingCode": "xx-xxxxxxx-xx", "bin": { - "ng": "./bin/ng" + "ung": "./bin/ung" }, "keywords": [ "ember-addon" diff --git a/packages/angular-cli/utilities/completion.sh b/packages/angular-cli/utilities/completion.sh index 555233b7ec8f..6ea9c15cd1f8 100644 --- a/packages/angular-cli/utilities/completion.sh +++ b/packages/angular-cli/utilities/completion.sh @@ -1,9 +1,9 @@ ###-begin-ng-completion### # -# ng command completion script +# ung command completion script # -# Installation: ng completion 1>> ~/.bashrc 2>>&1 -# or ng completion 1>> ~/.zshrc 2>>&1 +# Installation: ung completion 1>> ~/.bashrc 2>>&1 +# or ung completion 1>> ~/.zshrc 2>>&1 # ng_opts='b build completion doc e2e g generate get github-pages:deploy gh-pages:deploy h help i init install lint make-this-awesome new s serve server set t test v version -h --help' @@ -48,7 +48,7 @@ if test ".$(type -t complete 2>/dev/null || true)" = ".builtin"; then return 0 } - complete -o default -F _ng_completion ng + complete -o default -F _ng_completion ung elif test ".$(type -w compctl 2>/dev/null || true)" = ".compctl: builtin" ; then _ng_completion () { local words cword opts @@ -76,9 +76,9 @@ elif test ".$(type -w compctl 2>/dev/null || true)" = ".compctl: builtin" ; then unset shwordsplit } - compctl -K _ng_completion ng + compctl -K _ng_completion ung else - echo "Shell builtin command 'complete' or 'compctl' is redefined; cannot perform ng completion." + echo "Shell builtin command 'complete' or 'compctl' is redefined; cannot perform ung completion." return 1 fi diff --git a/tests/acceptance/destroy.spec.js b/tests/acceptance/destroy.spec.js index fac5327d4533..7b5c9b91ba2c 100644 --- a/tests/acceptance/destroy.spec.js +++ b/tests/acceptance/destroy.spec.js @@ -5,7 +5,7 @@ const tmp = require('../helpers/tmp'); const SilentError = require('silent-error'); const expect = require('chai').expect; -describe('Acceptance: ng destroy', function () { +describe('Acceptance: ung destroy', function () { beforeEach(function () { this.timeout(10000); return tmp.setup('./tmp').then(function () { @@ -21,7 +21,7 @@ describe('Acceptance: ng destroy', function () { it('without args should fail', function () { return ng(['destroy']).then(() => { - throw new SilentError('ng destroy should fail.'); + throw new SilentError('ung destroy should fail.'); }, (err) => { expect(err.message).to.equal('The destroy command is not supported by Angular-CLI.'); }); @@ -29,7 +29,7 @@ describe('Acceptance: ng destroy', function () { it('with args should fail', function () { return ng(['destroy', 'something']).then(() => { - throw new SilentError('ng destroy something should fail.'); + throw new SilentError('ung destroy something should fail.'); }, (err) => { expect(err.message).to.equal('The destroy command is not supported by Angular-CLI.'); }); diff --git a/tests/acceptance/generate-class.spec.js b/tests/acceptance/generate-class.spec.js index 0c173d90127d..531425e817c3 100644 --- a/tests/acceptance/generate-class.spec.js +++ b/tests/acceptance/generate-class.spec.js @@ -10,7 +10,7 @@ const root = process.cwd(); const testPath = path.join(root, 'tmp', 'foo', 'src', 'app'); -describe('Acceptance: ng generate class', function () { +describe('Acceptance: ung generate class', function () { beforeEach(function () { this.timeout(10000); return tmp.setup('./tmp').then(function () { @@ -24,21 +24,21 @@ describe('Acceptance: ng generate class', function () { return tmp.teardown('./tmp'); }); - it('ng generate class my-class', function () { + it('ung generate class my-class', function () { return ng(['generate', 'class', 'my-class']).then(() => { expect(existsSync(path.join(testPath, 'my-class.ts'))).to.equal(true); expect(existsSync(path.join(testPath, 'my-class.spec.ts'))).to.equal(false); }); }); - it('ng generate class my-class --no-spec', function () { + it('ung generate class my-class --no-spec', function () { return ng(['generate', 'class', 'my-class', '--no-spec']).then(() => { expect(existsSync(path.join(testPath, 'my-class.ts'))).to.equal(true); expect(existsSync(path.join(testPath, 'my-class.spec.ts'))).to.equal(false); }); }); - it('ng generate class my-class.model', function () { + it('ung generate class my-class.model', function () { return ng(['generate', 'class', 'my-class.model']).then(() => { expect(existsSync(path.join(testPath, 'my-class.model.ts'))).to.equal(true); }); diff --git a/tests/acceptance/generate-component.spec.js b/tests/acceptance/generate-component.spec.js index 20bd25460bbe..99ffc1feb9d4 100644 --- a/tests/acceptance/generate-component.spec.js +++ b/tests/acceptance/generate-component.spec.js @@ -14,7 +14,7 @@ const denodeify = require('denodeify'); const readFile = denodeify(fs.readFile); -describe('Acceptance: ng generate component', function () { +describe('Acceptance: ung generate component', function () { beforeEach(function () { this.timeout(10000); return tmp.setup('./tmp').then(function () { @@ -124,7 +124,7 @@ describe('Acceptance: ng generate component', function () { it('..' + path.sep + 'my-comp from root dir will fail', () => { return ng(['generate', 'component', '..' + path.sep + 'my-comp']).then(() => { - throw new SilentError(`ng generate component ..${path.sep}my-comp from root dir should fail.`); + throw new SilentError(`ung generate component ..${path.sep}my-comp from root dir should fail.`); }, (err) => { expect(err).to.equal(`Invalid path: "..${path.sep}my-comp" cannot be above the "src${path.sep}app" directory`); }); diff --git a/tests/acceptance/generate-directive.spec.js b/tests/acceptance/generate-directive.spec.js index efeca10e03be..c6ec7cc4983a 100644 --- a/tests/acceptance/generate-directive.spec.js +++ b/tests/acceptance/generate-directive.spec.js @@ -14,7 +14,7 @@ const denodeify = require('denodeify'); const readFile = denodeify(fs.readFile); -describe('Acceptance: ng generate directive', function () { +describe('Acceptance: ung generate directive', function () { beforeEach(function () { return tmp.setup('./tmp').then(function () { process.chdir('./tmp'); @@ -162,7 +162,7 @@ describe('Acceptance: ng generate directive', function () { it('..' + path.sep + 'my-dir from root dir will fail', () => { return ng(['generate', 'directive', '..' + path.sep + 'my-dir']).then(() => { - throw new SilentError(`ng generate directive ..${path.sep}my-dir from root dir should fail.`); + throw new SilentError(`ung generate directive ..${path.sep}my-dir from root dir should fail.`); }, (err) => { expect(err).to.equal(`Invalid path: "..${path.sep}my-dir" cannot be above the "src${path.sep}app" directory`); }); diff --git a/tests/acceptance/generate-module.spec.js b/tests/acceptance/generate-module.spec.js index fef9a2ed5091..dfd359af5099 100644 --- a/tests/acceptance/generate-module.spec.js +++ b/tests/acceptance/generate-module.spec.js @@ -10,7 +10,7 @@ const root = process.cwd(); const testPath = path.join(root, 'tmp', 'foo', 'src', 'app'); -describe('Acceptance: ng generate module', function () { +describe('Acceptance: ung generate module', function () { beforeEach(function () { return tmp.setup('./tmp').then(function () { process.chdir('./tmp'); @@ -27,32 +27,32 @@ describe('Acceptance: ng generate module', function () { it('will fail if no name is specified', function () { return ng(['generate', 'module']).catch((error) => { - expect(error).to.equal('The `ng generate module` command requires a name to be specified.'); + expect(error).to.equal('The `ung generate module` command requires a name to be specified.'); }); }); - it('ng generate module my-module', function () { + it('ung generate module my-module', function () { return ng(['generate', 'module', 'my-module']).then(() => { expect(existsSync(path.join(testPath, 'my-module', 'my-module.module.ts'))).to.equal(true); expect(existsSync(path.join(testPath, 'my-module', 'my-module.module.spec.ts'))).to.equal(false); }); }); - it('ng generate module my-module --spec', function () { + it('ung generate module my-module --spec', function () { return ng(['generate', 'module', 'my-module', '--spec']).then(() => { expect(existsSync(path.join(testPath, 'my-module', 'my-module.module.ts'))).to.equal(true); expect(existsSync(path.join(testPath, 'my-module', 'my-module.module.spec.ts'))).to.equal(true); }); }); - it('ng generate module TwoWord', function () { + it('ung generate module TwoWord', function () { return ng(['generate', 'module', 'TwoWord']).then(() => { expect(existsSync(path.join(testPath, 'two-word', 'two-word.module.ts'))).to.equal(true); expect(existsSync(path.join(testPath, 'two-word', 'two-word.module.spec.ts'))).to.equal(false); }); }); - it('ng generate module parent/child', function () { + it('ung generate module parent/child', function () { return ng(['generate', 'module', 'parent']).then(() => ng(['generate', 'module', 'parent/child']).then(() => { expect(existsSync(path.join(testPath, 'parent/child', 'child.module.ts'))).to.equal(true); diff --git a/tests/acceptance/generate-pipe.spec.js b/tests/acceptance/generate-pipe.spec.js index 767df23995bf..ddedf588d926 100644 --- a/tests/acceptance/generate-pipe.spec.js +++ b/tests/acceptance/generate-pipe.spec.js @@ -15,7 +15,7 @@ const denodeify = require('denodeify'); const readFile = denodeify(fs.readFile); -describe('Acceptance: ng generate pipe', function () { +describe('Acceptance: ung generate pipe', function () { beforeEach(function () { return tmp.setup('./tmp').then(function () { process.chdir('./tmp'); @@ -30,7 +30,7 @@ describe('Acceptance: ng generate pipe', function () { return tmp.teardown('./tmp'); }); - it('ng generate pipe my-pipe', function () { + it('ung generate pipe my-pipe', function () { const appRoot = path.join(root, 'tmp/foo'); const testPath = path.join(appRoot, 'src/app/my-pipe.pipe.ts'); const testSpecPath = path.join(appRoot, 'src/app/my-pipe.pipe.spec.ts'); @@ -47,7 +47,7 @@ describe('Acceptance: ng generate pipe', function () { }); }); - it('ng generate pipe my-pipe --no-spec', function () { + it('ung generate pipe my-pipe --no-spec', function () { const appRoot = path.join(root, 'tmp/foo'); const testPath = path.join(appRoot, 'src/app/my-pipe.pipe.ts'); const testSpecPath = path.join(appRoot, 'src/app/my-pipe.pipe.spec.ts'); @@ -59,7 +59,7 @@ describe('Acceptance: ng generate pipe', function () { }); }); - it('ng generate pipe test' + path.sep + 'my-pipe', function () { + it('ung generate pipe test' + path.sep + 'my-pipe', function () { fs.mkdirsSync(path.join(root, 'tmp', 'foo', 'src', 'app', 'test')); return ng(['generate', 'pipe', 'test' + path.sep + 'my-pipe']).then(() => { var testPath = path.join(root, 'tmp', 'foo', 'src', 'app', 'test', 'my-pipe.pipe.ts'); @@ -67,14 +67,14 @@ describe('Acceptance: ng generate pipe', function () { }); }); - it('ng generate pipe test' + path.sep + '..' + path.sep + 'my-pipe', function () { + it('ung generate pipe test' + path.sep + '..' + path.sep + 'my-pipe', function () { return ng(['generate', 'pipe', 'test' + path.sep + '..' + path.sep + 'my-pipe']).then(() => { var testPath = path.join(root, 'tmp', 'foo', 'src', 'app', 'my-pipe.pipe.ts'); expect(existsSync(testPath)).to.equal(true); }); }); - it('ng generate pipe my-pipe from a child dir', () => { + it('ung generate pipe my-pipe from a child dir', () => { fs.mkdirsSync(path.join(root, 'tmp', 'foo', 'src', 'app', '1')); return new Promise(function (resolve) { process.chdir('./src'); @@ -92,7 +92,7 @@ describe('Acceptance: ng generate pipe', function () { }, err => console.log('ERR: ', err)); }); - it('ng generate pipe child-dir' + path.sep + 'my-pipe from a child dir', () => { + it('ung generate pipe child-dir' + path.sep + 'my-pipe from a child dir', () => { fs.mkdirsSync(path.join(root, 'tmp', 'foo', 'src', 'app', '1', 'child-dir')); return new Promise(function (resolve) { process.chdir('./src'); @@ -111,7 +111,7 @@ describe('Acceptance: ng generate pipe', function () { }, err => console.log('ERR: ', err)); }); - it('ng generate pipe child-dir' + path.sep + '..' + path.sep + 'my-pipe from a child dir', () => { + it('ung generate pipe child-dir' + path.sep + '..' + path.sep + 'my-pipe from a child dir', () => { fs.mkdirsSync(path.join(root, 'tmp', 'foo', 'src', 'app', '1')); return new Promise(function (resolve) { process.chdir('./src'); @@ -129,7 +129,7 @@ describe('Acceptance: ng generate pipe', function () { }, err => console.log('ERR: ', err)); }); - it('ng generate pipe ' + path.sep + 'my-pipe from a child dir, gens under ' + + it('ung generate pipe ' + path.sep + 'my-pipe from a child dir, gens under ' + path.join('src', 'app'), () => { fs.mkdirsSync(path.join(root, 'tmp', 'foo', 'src', 'app', '1')); @@ -149,9 +149,9 @@ describe('Acceptance: ng generate pipe', function () { }, err => console.log('ERR: ', err)); }); - it('ng generate pipe ..' + path.sep + 'my-pipe from root dir will fail', () => { + it('ung generate pipe ..' + path.sep + 'my-pipe from root dir will fail', () => { return ng(['generate', 'pipe', '..' + path.sep + 'my-pipe']).then(() => { - throw new SilentError(`ng generate pipe ..${path.sep}my-pipe from root dir should fail.`); + throw new SilentError(`ung generate pipe ..${path.sep}my-pipe from root dir should fail.`); }, (err) => { expect(err).to.equal(`Invalid path: "..${path.sep}my-pipe" cannot be above the "src${path.sep}app" directory`); }); diff --git a/tests/acceptance/generate-route.spec.js b/tests/acceptance/generate-route.spec.js index afe616bf5d26..573dc620009b 100644 --- a/tests/acceptance/generate-route.spec.js +++ b/tests/acceptance/generate-route.spec.js @@ -16,7 +16,7 @@ function fileExpectations(expectation) { expect(existsSync(path.join(testPath, dir, 'my-route.component.ts'))).to.equal(expectation); } -xdescribe('Acceptance: ng generate route', function () { +xdescribe('Acceptance: ung generate route', function () { beforeEach(function () { return tmp.setup('./tmp').then(function () { process.chdir('./tmp'); @@ -31,19 +31,19 @@ xdescribe('Acceptance: ng generate route', function () { return tmp.teardown('./tmp'); }); - it('ng generate route my-route', function () { + it('ung generate route my-route', function () { return ng(['generate', 'route', 'my-route']).then(() => { fileExpectations(true, true); }); }); - it('ng generate route +my-route', function () { + it('ung generate route +my-route', function () { return ng(['generate', 'route', '+my-route']).then(() => { fileExpectations(true, true); }); }); - it('ng generate route +my-route/my-other', () => { + it('ung generate route +my-route/my-other', () => { return ng(['generate', 'route', '+my-route']) .then(() => ng(['generate', 'route', '+my-route/my-other', '--default'])) .then(() => ng(['generate', 'route', '+my-route/+my-other/my-third', '--default'])) @@ -67,7 +67,7 @@ xdescribe('Acceptance: ng generate route', function () { }); }); - it('ng generate route details --path /details/:id', () => { + it('ung generate route details --path /details/:id', () => { return ng(['generate', 'route', 'details', '--path', '/details/:id']) .then(() => { const appContent = fs.readFileSync(path.join(testPath, 'foo.component.ts'), 'utf-8'); @@ -75,7 +75,7 @@ xdescribe('Acceptance: ng generate route', function () { }); }); - it('ng generate route my-route --dry-run does not modify files', () => { + it('ung generate route my-route --dry-run does not modify files', () => { var parentComponentPath = path.join(testPath, 'foo.component.ts'); var parentComponentHtmlPath = path.join(testPath, 'foo.component.html') diff --git a/tests/acceptance/generate-service.spec.js b/tests/acceptance/generate-service.spec.js index 7d407c575554..506d98dde384 100644 --- a/tests/acceptance/generate-service.spec.js +++ b/tests/acceptance/generate-service.spec.js @@ -14,7 +14,7 @@ const denodeify = require('denodeify'); const readFile = denodeify(fs.readFile); -describe('Acceptance: ng generate service', function () { +describe('Acceptance: ung generate service', function () { beforeEach(function () { return tmp.setup('./tmp').then(function () { process.chdir('./tmp'); @@ -29,7 +29,7 @@ describe('Acceptance: ng generate service', function () { return tmp.teardown('./tmp'); }); - it('ng generate service my-svc', function () { + it('ung generate service my-svc', function () { const appRoot = path.join(root, 'tmp/foo'); const testPath = path.join(appRoot, 'src/app/my-svc.service.ts'); const testSpecPath = path.join(appRoot, 'src/app/my-svc.service.spec.ts'); @@ -47,7 +47,7 @@ describe('Acceptance: ng generate service', function () { }); }); - it('ng generate service my-svc --no-spec', function () { + it('ung generate service my-svc --no-spec', function () { const appRoot = path.join(root, 'tmp/foo'); const testPath = path.join(appRoot, 'src/app/my-svc.service.ts'); const testSpecPath = path.join(appRoot, 'src/app/my-svc.service.spec.ts'); @@ -65,7 +65,7 @@ describe('Acceptance: ng generate service', function () { }); }); - it('ng generate service test' + path.sep + 'my-svc', function () { + it('ung generate service test' + path.sep + 'my-svc', function () { fs.mkdirsSync(path.join(root, 'tmp', 'foo', 'src', 'app', 'test')); return ng(['generate', 'service', 'test' + path.sep + 'my-svc']).then(() => { var testPath = path.join(root, 'tmp', 'foo', 'src', 'app', 'test', 'my-svc.service.ts'); @@ -73,14 +73,14 @@ describe('Acceptance: ng generate service', function () { }); }); - it('ng generate service test' + path.sep + '..' + path.sep + 'my-svc', function () { + it('ung generate service test' + path.sep + '..' + path.sep + 'my-svc', function () { return ng(['generate', 'service', 'test' + path.sep + '..' + path.sep + 'my-svc']).then(() => { var testPath = path.join(root, 'tmp', 'foo', 'src', 'app', 'my-svc.service.ts'); expect(existsSync(testPath)).to.equal(true); }); }); - it('ng generate service my-svc from a child dir', () => { + it('ung generate service my-svc from a child dir', () => { fs.mkdirsSync(path.join(root, 'tmp', 'foo', 'src', 'app', '1')); return new Promise(function (resolve) { process.chdir('./src'); @@ -98,7 +98,7 @@ describe('Acceptance: ng generate service', function () { }); }); - it('ng generate service child-dir' + path.sep + 'my-svc from a child dir', () => { + it('ung generate service child-dir' + path.sep + 'my-svc from a child dir', () => { fs.mkdirsSync(path.join(root, 'tmp', 'foo', 'src', 'app', '1', 'child-dir')); return new Promise(function (resolve) { process.chdir('./src'); @@ -117,7 +117,7 @@ describe('Acceptance: ng generate service', function () { }); }); - it('ng generate service child-dir' + path.sep + '..' + path.sep + 'my-svc from a child dir', + it('ung generate service child-dir' + path.sep + '..' + path.sep + 'my-svc from a child dir', () => { fs.mkdirsSync(path.join(root, 'tmp', 'foo', 'src', 'app', '1')); return new Promise(function (resolve) { @@ -138,7 +138,7 @@ describe('Acceptance: ng generate service', function () { }); }); - it('ng generate service ' + path.sep + 'my-svc from a child dir, gens under ' + + it('ung generate service ' + path.sep + 'my-svc from a child dir, gens under ' + path.join('src', 'app'), () => { fs.mkdirsSync(path.join(root, 'tmp', 'foo', 'src', 'app', '1')); @@ -158,9 +158,9 @@ describe('Acceptance: ng generate service', function () { }); }); - it('ng generate service ..' + path.sep + 'my-svc from root dir will fail', () => { + it('ung generate service ..' + path.sep + 'my-svc from root dir will fail', () => { return ng(['generate', 'service', '..' + path.sep + 'my-svc']).then(() => { - throw new SilentError(`ng generate service ..${path.sep}my-svc from root dir should fail.`); + throw new SilentError(`ung generate service ..${path.sep}my-svc from root dir should fail.`); }, (err) => { expect(err).to.equal(`Invalid path: "..${path.sep}my-svc" cannot be above the "src${path.sep}app" directory`); }); diff --git a/tests/acceptance/github-pages-deploy.spec.js b/tests/acceptance/github-pages-deploy.spec.js index dff59065bac3..a7458a8302bf 100644 --- a/tests/acceptance/github-pages-deploy.spec.js +++ b/tests/acceptance/github-pages-deploy.spec.js @@ -16,7 +16,7 @@ const expect = chai.expect; const fsWriteFile = Promise.denodeify(fs.writeFile); const fsMkdir = Promise.denodeify(fs.mkdir); -describe('Acceptance: ng github-pages:deploy', function() { +describe('Acceptance: ung github-pages:deploy', function() { let execStub; let project = 'foo', initialBranch = 'master', diff --git a/tests/acceptance/init.spec.js b/tests/acceptance/init.spec.js index 351f2af430f1..0d8072fe5307 100644 --- a/tests/acceptance/init.spec.js +++ b/tests/acceptance/init.spec.js @@ -20,7 +20,7 @@ var existsSync = require('exists-sync'); var defaultIgnoredFiles = Blueprint.ignoredFiles; -describe('Acceptance: ng init', function () { +describe('Acceptance: ung init', function () { this.timeout(20000); beforeEach(function () { @@ -111,7 +111,7 @@ describe('Acceptance: ng init', function () { }); } - it('ng init', function () { + it('ung init', function () { return ng([ 'init', '--skip-npm', @@ -119,11 +119,11 @@ describe('Acceptance: ng init', function () { ]).then(confirmBlueprinted); }); - it('ng init with mobile flag does throw exception', function () { + it('ung init with mobile flag does throw exception', function () { expect(ng(['init', '--mobile'])).to.throw; }); - it('ng init --universal', () => { + it('ung init --universal', () => { return ng([ 'init', '--skip-npm', @@ -132,7 +132,7 @@ describe('Acceptance: ng init', function () { ]).then(() => confirmBlueprinted(['universal'])); }); - it('ng init can run in created folder', function () { + it('ung init can run in created folder', function () { return tmp.setup('./tmp/foo') .then(function () { process.chdir('./tmp/foo'); @@ -208,7 +208,7 @@ describe('Acceptance: ng init', function () { .then(confirmBlueprinted); }); - it('ng init --inline-template does not generate a template file', () => { + it('ung init --inline-template does not generate a template file', () => { return ng(['init', '--skip-npm', '--skip-git', '--inline-template']) .then(() => { const templateFile = path.join('src', 'app', 'app.component.html'); @@ -216,7 +216,7 @@ describe('Acceptance: ng init', function () { }); }); - it('ng init --inline-style does not gener a style file', () => { + it('ung init --inline-style does not gener a style file', () => { return ng(['init', '--skip-npm', '--skip-git', '--inline-style']) .then(() => { const styleFile = path.join('src', 'app', 'app.component.css'); diff --git a/tests/acceptance/new.spec.js b/tests/acceptance/new.spec.js index 02f60bb66f96..65f6d7087bfd 100644 --- a/tests/acceptance/new.spec.js +++ b/tests/acceptance/new.spec.js @@ -14,7 +14,7 @@ var util = require('util'); var EOL = require('os').EOL; var SilentError = require('silent-error'); -describe('Acceptance: ng new', function () { +describe('Acceptance: ung new', function () { beforeEach(function () { return tmp.setup('./tmp').then(function () { process.chdir('./tmp'); @@ -56,19 +56,19 @@ describe('Acceptance: ng new', function () { return confirmBlueprintedForDir('blueprints/ng2'); } - it('ng new foo, where foo does not yet exist, works', function () { + it('ung new foo, where foo does not yet exist, works', function () { return ng(['new', 'foo', '--skip-npm', '--skip-bower']).then(confirmBlueprinted); }); - it('ng new with empty app does throw exception', function () { + it('ung new with empty app does throw exception', function () { expect(ng(['new', ''])).to.throw; }); - it('ng new without app name does throw exception', function () { + it('ung new without app name does throw exception', function () { expect(ng(['new', ''])).to.throw; }); - it('ng new with app name creates new directory and has a dasherized package name', function () { + it('ung new with app name creates new directory and has a dasherized package name', function () { return ng(['new', 'FooApp', '--skip-npm', '--skip-bower', '--skip-git']).then(function () { expect(!existsSync('FooApp')); @@ -77,7 +77,7 @@ describe('Acceptance: ng new', function () { }); }); - it('ng new has a .editorconfig file', function () { + it('ung new has a .editorconfig file', function () { return ng(['new', 'FooApp', '--skip-npm', '--skip-bower', '--skip-git']).then(function () { expect(!existsSync('FooApp')); @@ -86,11 +86,11 @@ describe('Acceptance: ng new', function () { }); }); - it('Cannot run ng new, inside of angular-cli project', function () { + it('Cannot run ung new, inside of angular-cli project', function () { return ng(['new', 'foo', '--skip-npm', '--skip-bower', '--skip-git']) .then(function () { return ng(['new', 'foo', '--skip-npm', '--skip-bower', '--skip-git']).then(() => { - throw new SilentError('Cannot run ng new, inside of ember-cli project should fail.'); + throw new SilentError('Cannot run ung new, inside of ember-cli project should fail.'); }, () => { expect(!existsSync('foo')); }) @@ -98,13 +98,13 @@ describe('Acceptance: ng new', function () { .then(confirmBlueprinted); }); - it('ng new without skip-git flag creates .git dir', function () { + it('ung new without skip-git flag creates .git dir', function () { return ng(['new', 'foo', '--skip-npm', '--skip-bower']).then(function () { expect(existsSync('.git')); }); }); - it('ng new with --dry-run does not create new directory', function () { + it('ung new with --dry-run does not create new directory', function () { return ng(['new', 'foo', '--dry-run']).then(function () { var cwd = process.cwd(); expect(cwd).to.not.match(/foo/, 'does not change cwd to foo in a dry run'); @@ -113,7 +113,7 @@ describe('Acceptance: ng new', function () { }); }); - it('ng new with --directory uses given directory name and has correct package name', function () { + it('ung new with --directory uses given directory name and has correct package name', function () { return ng(['new', 'foo', '--skip-npm', '--skip-bower', '--skip-git', '--directory=bar']) .then(function () { var cwd = process.cwd(); @@ -128,7 +128,7 @@ describe('Acceptance: ng new', function () { }); }); - it('ng new --inline-template does not generate a template file', () => { + it('ung new --inline-template does not generate a template file', () => { return ng(['new', 'foo', '--skip-npm', '--skip-git', '--inline-template']) .then(() => { const templateFile = path.join('src', 'app', 'app.component.html'); @@ -136,7 +136,7 @@ describe('Acceptance: ng new', function () { }); }); - it('ng new --inline-style does not gener a style file', () => { + it('ung new --inline-style does not gener a style file', () => { return ng(['new', 'foo', '--skip-npm', '--skip-git', '--inline-style']) .then(() => { const styleFile = path.join('src', 'app', 'app.component.css'); diff --git a/tests/e2e/setup/100-npm-link.ts b/tests/e2e/setup/100-npm-link.ts index 396b974d94ec..14848ba55b19 100644 --- a/tests/e2e/setup/100-npm-link.ts +++ b/tests/e2e/setup/100-npm-link.ts @@ -34,5 +34,5 @@ export default function (argv: any) { .then(() => npm('link')) .then(() => process.chdir(oldCwd)); }) - .then(() => exec(process.platform.startsWith('win') ? 'where' : 'which', 'ng')); + .then(() => exec(process.platform.startsWith('win') ? 'where' : 'which', 'ung')); } diff --git a/tests/e2e/utils/process.ts b/tests/e2e/utils/process.ts index 0c88a35ceba4..feb06556ee82 100644 --- a/tests/e2e/utils/process.ts +++ b/tests/e2e/utils/process.ts @@ -108,12 +108,12 @@ export function ng(...args: string[]) { if (args[0] == 'build') { return silentNg(...args); } else { - return _exec({}, 'ng', args); + return _exec({}, 'ung', args); } } export function silentNg(...args: string[]) { - return _exec({silent: true}, 'ng', args); + return _exec({silent: true}, 'ung', args); } export function silentNpm(...args: string[]) { diff --git a/tests/e2e/utils/project.ts b/tests/e2e/utils/project.ts index fef8435d160f..7b83571dae35 100644 --- a/tests/e2e/utils/project.ts +++ b/tests/e2e/utils/project.ts @@ -19,11 +19,11 @@ export function updateTsConfig(fn: (json: any) => any | void) { } export function ngServe(...args: string[]) { - return silentExecAndWaitForOutputToMatch('ng', + return silentExecAndWaitForOutputToMatch('ung', ['serve', ...args], /webpack: bundle is now VALID/); } export function ngUniversalServe(...args: string[]) { - return silentExecAndWaitForOutputToMatch('ng', + return silentExecAndWaitForOutputToMatch('ung', ['serve', ...args], /Listening on port 4200/); } From 38bde3cf048709cac0286d7b17f6aaf1e681d8fa Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Sat, 26 Nov 2016 13:21:59 +0100 Subject: [PATCH 18/38] v1.0.0-alpha.universal.2 --- CHANGELOG.md | 51 +++++++++++++++---------------- docs/publish.md | 1 + package.json | 2 +- packages/angular-cli/package.json | 2 +- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc99701fcfb6..c30f0a06b01b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,41 +1,40 @@ - -# [1.0.0-beta.20](https://github.com/angular/angular-cli/compare/v1.0.0-beta.19...v1.0.0-beta.20-1) (2016-11-16) + +# [1.0.0-alpha.universal.2](https://github.com/devCrossNet/angular-cli/compare/v1.0.0-beta.19...v1.0.0-alpha.universal.2) (2016-11-26) ### Bug Fixes -* **@ngtools/webpack:** fixed relative path for AoT. ([#3114](https://github.com/angular/angular-cli/issues/3114)) ([27a034d](https://github.com/angular/angular-cli/commit/27a034d)) -* **aot:** exclude spec files from aot ([#2758](https://github.com/angular/angular-cli/issues/2758)) ([215e555](https://github.com/angular/angular-cli/commit/215e555)) -* **aot:** output the sources in the sourcemap. ([#3107](https://github.com/angular/angular-cli/issues/3107)) ([7127dba](https://github.com/angular/angular-cli/commit/7127dba)) -* **aot:** remove the genDir plugin option. ([0e91dfe](https://github.com/angular/angular-cli/commit/0e91dfe)), closes [#2849](https://github.com/angular/angular-cli/issues/2849) [#2876](https://github.com/angular/angular-cli/issues/2876) -* **aot:** Use the proper path when statically analyzing lazy routes. ([#2992](https://github.com/angular/angular-cli/issues/2992)) ([88131a0](https://github.com/angular/angular-cli/commit/88131a0)), closes [#2452](https://github.com/angular/angular-cli/issues/2452) [#2735](https://github.com/angular/angular-cli/issues/2735) [#2900](https://github.com/angular/angular-cli/issues/2900) -* **build:** correct forkChecker option for ATS. ([#3011](https://github.com/angular/angular-cli/issues/3011)) ([a987cf5](https://github.com/angular/angular-cli/commit/a987cf5)) -* **build:** enable chunkhash in inline.js ([30cc482](https://github.com/angular/angular-cli/commit/30cc482)), closes [#2899](https://github.com/angular/angular-cli/issues/2899) -* **build:** show full error stats ([#2879](https://github.com/angular/angular-cli/issues/2879)) ([d59fa1f](https://github.com/angular/angular-cli/commit/d59fa1f)) -* **deps:** explicitely add portfinder ([#2831](https://github.com/angular/angular-cli/issues/2831)) ([2d8f162](https://github.com/angular/angular-cli/commit/2d8f162)), closes [#2755](https://github.com/angular/angular-cli/issues/2755) [#2769](https://github.com/angular/angular-cli/issues/2769) -* **e2e:** fix broken test pipeline ([#2999](https://github.com/angular/angular-cli/issues/2999)) ([37a1225](https://github.com/angular/angular-cli/commit/37a1225)) -* **generate:** fix module component path if module is created in child folder ([#3066](https://github.com/angular/angular-cli/issues/3066)) ([38d5f2c](https://github.com/angular/angular-cli/commit/38d5f2c)), closes [#3063](https://github.com/angular/angular-cli/issues/3063) -* **generate:** stop default browser error from ng new --routing ([a45a1f2](https://github.com/angular/angular-cli/commit/a45a1f2)), closes [#2794](https://github.com/angular/angular-cli/issues/2794) -* **package:** add some more metadata to webpack package.json ([c2dbf88](https://github.com/angular/angular-cli/commit/c2dbf88)), closes [#2854](https://github.com/angular/angular-cli/issues/2854) -* **serve:** added accept html headers option to webpack-dev-server ([#2990](https://github.com/angular/angular-cli/issues/2990)) ([86f2a1b](https://github.com/angular/angular-cli/commit/86f2a1b)), closes [#2989](https://github.com/angular/angular-cli/issues/2989) -* **test:** catches module loading errors ([f09439c](https://github.com/angular/angular-cli/commit/f09439c)), closes [#2640](https://github.com/angular/angular-cli/issues/2640) [#2785](https://github.com/angular/angular-cli/issues/2785) -* **version:** update version of [@angular](https://github.com/angular) packages. ([#3145](https://github.com/angular/angular-cli/issues/3145)) ([a2f0a1a](https://github.com/angular/angular-cli/commit/a2f0a1a)) -* bypass Watchman check ([#2846](https://github.com/angular/angular-cli/issues/2846)) ([9aa1099](https://github.com/angular/angular-cli/commit/9aa1099)), closes [#2791](https://github.com/angular/angular-cli/issues/2791) +* **@ngtools/webpack:** fixed relative path for AoT. ([#3114](https://github.com/devCrossNet/angular-cli/issues/3114)) ([27a034d](https://github.com/devCrossNet/angular-cli/commit/27a034d)) +* **angular-cli:** add necessary dependencies. ([#3152](https://github.com/devCrossNet/angular-cli/issues/3152)) ([8f574e4](https://github.com/devCrossNet/angular-cli/commit/8f574e4)), closes [#3148](https://github.com/devCrossNet/angular-cli/issues/3148) +* **angular-cli:** add necessary dependency. ([f7704b0](https://github.com/devCrossNet/angular-cli/commit/f7704b0)) +* **angular-cli:** change version of webpack plugin. ([07e96ea](https://github.com/devCrossNet/angular-cli/commit/07e96ea)) +* **aot:** exclude spec files from aot ([#2758](https://github.com/devCrossNet/angular-cli/issues/2758)) ([215e555](https://github.com/devCrossNet/angular-cli/commit/215e555)) +* **aot:** output the sources in the sourcemap. ([#3107](https://github.com/devCrossNet/angular-cli/issues/3107)) ([7127dba](https://github.com/devCrossNet/angular-cli/commit/7127dba)) +* **deps:** explicitely add portfinder ([#2831](https://github.com/devCrossNet/angular-cli/issues/2831)) ([2d8f162](https://github.com/devCrossNet/angular-cli/commit/2d8f162)), closes [#2755](https://github.com/devCrossNet/angular-cli/issues/2755) [#2769](https://github.com/devCrossNet/angular-cli/issues/2769) +* **generate:** fix module component path if module is created in child folder ([#3066](https://github.com/devCrossNet/angular-cli/issues/3066)) ([38d5f2c](https://github.com/devCrossNet/angular-cli/commit/38d5f2c)), closes [#3063](https://github.com/devCrossNet/angular-cli/issues/3063) +* **generate:** revert change to component dir in generate module, as it caused component declaration to go to parent module ([#3158](https://github.com/devCrossNet/angular-cli/issues/3158)) ([71bf855](https://github.com/devCrossNet/angular-cli/commit/71bf855)) +* **github-pages-deploy:** Show more accurate url ([#3160](https://github.com/devCrossNet/angular-cli/issues/3160)) ([a431389](https://github.com/devCrossNet/angular-cli/commit/a431389)) +* **universal:** add polyfills.ts ([37770d5](https://github.com/devCrossNet/angular-cli/commit/37770d5)), closes [#1](https://github.com/devCrossNet/angular-cli/issues/1) +* **version:** update version of [@angular](https://github.com/angular) packages. ([#3145](https://github.com/devCrossNet/angular-cli/issues/3145)) ([a2f0a1a](https://github.com/devCrossNet/angular-cli/commit/a2f0a1a)) ### Features -* **build:** add loaders for fonts ([3497373](https://github.com/angular/angular-cli/commit/3497373)), closes [#1765](https://github.com/angular/angular-cli/issues/1765) -* **build:** use appConfig.index to set output index file ([d3fd8b0](https://github.com/angular/angular-cli/commit/d3fd8b0)), closes [#2241](https://github.com/angular/angular-cli/issues/2241) [#2767](https://github.com/angular/angular-cli/issues/2767) -* **build:** use static files for css ([a6415cc](https://github.com/angular/angular-cli/commit/a6415cc)), closes [#2148](https://github.com/angular/angular-cli/issues/2148) [#2020](https://github.com/angular/angular-cli/issues/2020) [#2826](https://github.com/angular/angular-cli/issues/2826) [#2646](https://github.com/angular/angular-cli/issues/2646) -* **serve:** allow CORS access while running ng serve ([#2872](https://github.com/angular/angular-cli/issues/2872)) ([#3009](https://github.com/angular/angular-cli/issues/3009)) ([7c834a8](https://github.com/angular/angular-cli/commit/7c834a8)) +* **build:** add sourcemap option ([#3113](https://github.com/devCrossNet/angular-cli/issues/3113)) ([6f9d2c1](https://github.com/devCrossNet/angular-cli/commit/6f9d2c1)) +* **serve:** allow CORS access while running ung serve ([#2872](https://github.com/devCrossNet/angular-cli/issues/2872)) ([#3009](https://github.com/devCrossNet/angular-cli/issues/3009)) ([7c834a8](https://github.com/devCrossNet/angular-cli/commit/7c834a8)) +* **universal:** add custom webpack config ([cdfe1a0](https://github.com/devCrossNet/angular-cli/commit/cdfe1a0)) +* **universal:** Server routes ([5275ae2](https://github.com/devCrossNet/angular-cli/commit/5275ae2)) -### BREAKING CHANGES +### Performance Improvements -* aot: Using relative paths might lead to path clashing. We -now properly output an error in this case. +* **universal:** add compression express middleware ([#4](https://github.com/devCrossNet/angular-cli/issues/4)) ([61d3abf](https://github.com/devCrossNet/angular-cli/commit/61d3abf)) + + + +### BREAKING CHANGES +* binary `ng` renamed to `ung` diff --git a/docs/publish.md b/docs/publish.md index ab869bce6f93..0178fb33e8af 100644 --- a/docs/publish.md +++ b/docs/publish.md @@ -10,6 +10,7 @@ - `git push master` - `git push --tags` - Publish to npm + - `npm run build` - `cd ./dist/angular-cli` - `npm publish --tag experimental` (install it with `npm install -g universal-cli@experimental` and test it) - `npm publish` (the new version is now available at npm) \ No newline at end of file diff --git a/package.json b/package.json index 9d6ea6637855..16adf99d047c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "universal-cli", - "version": "1.0.0-alpha.universal.1", + "version": "1.0.0-alpha.universal.2", "description": "CLI tool for Angular with Angular Universal support", "main": "packages/angular-cli/lib/cli/index.js", "trackingCode": "xx-xxxxxxx-xx", diff --git a/packages/angular-cli/package.json b/packages/angular-cli/package.json index 37d5732cece8..ea4582d9ce6f 100644 --- a/packages/angular-cli/package.json +++ b/packages/angular-cli/package.json @@ -1,6 +1,6 @@ { "name": "universal-cli", - "version": "1.0.0-alpha.universal.1", + "version": "1.0.0-alpha.universal.2", "cliVersion": "1.0.0-beta.20-1", "description": "CLI tool for Angular with Angular Universal support", "main": "lib/cli/index.js", From c6d170eb9af5c650a60c6270a29fc65b24418a69 Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Sat, 26 Nov 2016 13:44:31 +0100 Subject: [PATCH 19/38] v1.0.0-alpha.universal.2-1 --- package.json | 2 +- packages/angular-cli/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 16adf99d047c..b4d140669783 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "universal-cli", - "version": "1.0.0-alpha.universal.2", + "version": "1.0.0-alpha.universal.2-1", "description": "CLI tool for Angular with Angular Universal support", "main": "packages/angular-cli/lib/cli/index.js", "trackingCode": "xx-xxxxxxx-xx", diff --git a/packages/angular-cli/package.json b/packages/angular-cli/package.json index ea4582d9ce6f..fd227a7a53ba 100644 --- a/packages/angular-cli/package.json +++ b/packages/angular-cli/package.json @@ -1,6 +1,6 @@ { "name": "universal-cli", - "version": "1.0.0-alpha.universal.2", + "version": "1.0.0-alpha.universal.2-1", "cliVersion": "1.0.0-beta.20-1", "description": "CLI tool for Angular with Angular Universal support", "main": "lib/cli/index.js", From 61ca3056ef9cbf6a37fa2c9abe29b578183ab153 Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Sat, 26 Nov 2016 13:55:17 +0100 Subject: [PATCH 20/38] v1.0.0-alpha.universal.2-2 --- package.json | 2 +- packages/angular-cli/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b4d140669783..3f878cd674b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "universal-cli", - "version": "1.0.0-alpha.universal.2-1", + "version": "1.0.0-alpha.universal.2-2", "description": "CLI tool for Angular with Angular Universal support", "main": "packages/angular-cli/lib/cli/index.js", "trackingCode": "xx-xxxxxxx-xx", diff --git a/packages/angular-cli/package.json b/packages/angular-cli/package.json index fd227a7a53ba..5cbf6abb5ab7 100644 --- a/packages/angular-cli/package.json +++ b/packages/angular-cli/package.json @@ -1,6 +1,6 @@ { "name": "universal-cli", - "version": "1.0.0-alpha.universal.2-1", + "version": "1.0.0-alpha.universal.2-2", "cliVersion": "1.0.0-beta.20-1", "description": "CLI tool for Angular with Angular Universal support", "main": "lib/cli/index.js", From 47b34a25a5c4f7f08b7b59c3fc68edc4d2e9824a Mon Sep 17 00:00:00 2001 From: Fumio SAGAWA Date: Wed, 30 Nov 2016 01:43:29 +0900 Subject: [PATCH 21/38] fix(universal): remove duplicate entry from package.json closes #26 --- packages/angular-cli/blueprints/ng2/files/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/angular-cli/blueprints/ng2/files/package.json b/packages/angular-cli/blueprints/ng2/files/package.json index 3d2fb4478855..d80a0b392f5a 100644 --- a/packages/angular-cli/blueprints/ng2/files/package.json +++ b/packages/angular-cli/blueprints/ng2/files/package.json @@ -57,7 +57,6 @@ "@types/express": "^4.0.29", "@types/express-serve-static-core": "^4.0.29", "@types/mime": "0.0.28", - "@types/node": "^6.0.42", "@types/serve-static": "^1.7.27",<% } %> "universal-cli": "<%= version %>", "codelyzer": "~1.0.0-beta.3", From 43c76235b8d091e03c38c534e962682ed39bc008 Mon Sep 17 00:00:00 2001 From: rxjs-space Date: Sat, 3 Dec 2016 23:04:49 +0800 Subject: [PATCH 22/38] chore(docs): show '--universal' early in the doc closes #28 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ba5117d05364..1cf6022c5e93 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ ## Universal-CLI -Universal-CLI is fork from Angular-CLI. It supports Angular Universal see: [Support for server side rendering](#support-for-server-side-rendering). +Universal-CLI is fork from Angular-CLI. It supports Angular Universal (with `--universal` flag after `ung new` or `ung init`), see [Support for server side rendering](#support-for-server-side-rendering) for detail. It is a separate package because the Core-CLI team is not able to maintain non-core functionality. I am looking for maintainers, please let me know if you're interested in supporting `universal-cli`. From 37c835789f6f095172a78dc80b6f0e6dfc3fb8ec Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Sat, 3 Dec 2016 21:30:35 +0100 Subject: [PATCH 23/38] fix(init): The option '--universal' is not registered with the init command rename angular-cli package to universal-cli rename ng2 addOn to ung addOn closes #27, #24 --- .eslintignore | 4 +- .github/ISSUE_TEMPLATE.md | 2 +- CONTRIBUTING.md | 12 +- README.md | 48 +- bin/ung | 4 +- docs/publish.md | 4 +- lib/bootstrap-local.js | 8 +- lib/packages.js | 2 +- package.json | 12 +- .../blueprints/ng2/files/README.md | 31 - .../ember-cli/lib/models/blueprint.js | 1571 ---------------- .../utilities/INITIAL_COMMIT_MESSAGE.txt | 8 - packages/ast-tools/src/change.spec.ts | 2 +- .../addon/index.js | 2 +- .../{angular-cli => universal-cli}/bin/ung | 6 +- .../class/files/__path__/__name__.spec.ts | 0 .../class/files/__path__/__name__.ts | 0 .../blueprints/class/index.js | 0 .../__path__/__name__.component.__styleext__ | 0 .../files/__path__/__name__.component.html | 0 .../files/__path__/__name__.component.spec.ts | 0 .../files/__path__/__name__.component.ts | 0 .../blueprints/component/index.js | 0 .../files/__path__/__name__.directive.spec.ts | 0 .../files/__path__/__name__.directive.ts | 0 .../blueprints/directive/index.js | 0 .../enum/files/__path__/__name__.enum.ts | 0 .../blueprints/enum/index.js | 0 .../interface/files/__path__/__name__.ts | 0 .../blueprints/interface/index.js | 0 .../__path__/icons/android-chrome-144x144.png | Bin .../__path__/icons/android-chrome-192x192.png | Bin .../__path__/icons/android-chrome-36x36.png | Bin .../__path__/icons/android-chrome-48x48.png | Bin .../__path__/icons/android-chrome-72x72.png | Bin .../__path__/icons/android-chrome-96x96.png | Bin .../icons/apple-touch-icon-114x114.png | Bin .../icons/apple-touch-icon-120x120.png | Bin .../icons/apple-touch-icon-144x144.png | Bin .../icons/apple-touch-icon-152x152.png | Bin .../icons/apple-touch-icon-180x180.png | Bin .../__path__/icons/apple-touch-icon-57x57.png | Bin .../__path__/icons/apple-touch-icon-60x60.png | Bin .../__path__/icons/apple-touch-icon-72x72.png | Bin .../__path__/icons/apple-touch-icon-76x76.png | Bin .../icons/apple-touch-icon-precomposed.png | Bin .../files/__path__/icons/apple-touch-icon.png | Bin .../files/__path__/icons/favicon-16x16.png | Bin .../files/__path__/icons/favicon-32x32.png | Bin .../files/__path__/icons/favicon-96x96.png | Bin .../mobile/files/__path__/icons/icon.png | Bin .../files/__path__/icons/mstile-144x144.png | Bin .../files/__path__/icons/mstile-150x150.png | Bin .../files/__path__/icons/mstile-310x150.png | Bin .../files/__path__/icons/mstile-310x310.png | Bin .../files/__path__/icons/mstile-70x70.png | Bin .../__path__/icons/safari-pinned-tab.svg | 0 .../mobile/files/__path__/main-app-shell.ts | 0 .../mobile/files/__path__/manifest.webapp | 0 .../blueprints/mobile/index.js | 0 .../files/__path__/__name__-routing.module.ts | 0 .../files/__path__/__name__.module.spec.ts | 0 .../module/files/__path__/__name__.module.ts | 0 .../blueprints/module/index.js | 0 .../blueprints/ng2/files/.editorconfig | 0 .../blueprints/ng2/files/README.md | 31 + .../files/__path__/app/app-routing.module.ts | 0 .../__path__/app/app.component.__styleext__ | 0 .../ng2/files/__path__/app/app.component.html | 0 .../files/__path__/app/app.component.spec.ts | 0 .../ng2/files/__path__/app/app.component.ts | 0 .../ng2/files/__path__/app/app.module.ts | 0 .../ng2/files/__path__/app/index.ts | 0 .../ng2/files/__path__/assets/.gitkeep | 0 .../__path__/environments/environment.prod.ts | 0 .../__path__/environments/environment.ts | 2 +- .../blueprints/ng2/files/__path__/favicon.ico | Bin .../blueprints/ng2/files/__path__/index.html | 0 .../blueprints/ng2/files/__path__/main.ts | 0 .../ng2/files/__path__/polyfills.ts | 0 .../ng2/files/__path__/styles.__styleext__ | 0 .../blueprints/ng2/files/__path__/test.ts | 0 .../ng2/files/__path__/tsconfig.json | 0 .../ng2/files/__path__/typings.d.ts | 0 .../blueprints/ng2/files/angular-cli.json | 0 .../blueprints/ng2/files/e2e/app.e2e-spec.ts | 0 .../blueprints/ng2/files/e2e/app.po.ts | 0 .../blueprints/ng2/files/e2e/tsconfig.json | 0 .../blueprints/ng2/files/gitignore | 0 .../blueprints/ng2/files/karma.conf.js | 4 +- .../blueprints/ng2/files/package.json | 0 .../blueprints/ng2/files/protractor.conf.js | 0 .../blueprints/ng2/files/tslint.json | 0 .../blueprints/ng2/index.js | 2 +- .../pipe/files/__path__/__name__.pipe.spec.ts | 0 .../pipe/files/__path__/__name__.pipe.ts | 0 .../blueprints/pipe/index.js | 0 .../files/__path__/__name__.service.spec.ts | 0 .../files/__path__/__name__.service.ts | 0 .../blueprints/service/index.js | 0 .../files/__path__/app/app.browser.module.ts | 0 .../files/__path__/app/app.node.module.ts | 0 .../universal/files/__path__/client.ts | 0 .../universal/files/__path__/server.routes.ts | 0 .../universal/files/__path__/server.ts | 0 .../universal/files/webpack.client.ts | 0 .../universal/files/webpack.server.ts | 0 .../blueprints/universal/index.js | 0 .../commands/build.ts | 0 .../commands/completion.ts | 0 .../commands/destroy.ts | 5 +- .../commands/doc.ts | 0 .../commands/e2e.ts | 0 .../commands/easter-egg.ts | 0 .../commands/generate.ts | 5 +- .../commands/get.ts | 0 .../commands/github-pages-deploy.ts | 0 .../commands/help.ts | 0 .../commands/init.ts | 37 +- .../commands/lint.ts | 0 .../commands/new.ts | 0 .../commands/serve.ts | 0 .../commands/set.ts | 0 .../commands/test.ts | 0 .../commands/version.ts | 2 +- .../custom-typings.d.ts | 0 .../ember-cli/LICENSE.md | 0 .../ember-cli/lib/cli/cli.js | 0 .../ember-cli/lib/cli/index.js | 0 .../ember-cli/lib/cli/lookup-command.js | 0 .../ember-cli/lib/commands/generate.js | 0 .../ember-cli/lib/commands/test.js | 0 .../ember-cli/lib/commands/unknown.js | 0 .../ember-cli/lib/ext/core-object.js | 0 .../ember-cli/lib/ext/promise.js | 0 .../ember-cli/lib/models/addon-discovery.js | 0 .../ember-cli/lib/models/addon.js | 0 .../ember-cli/lib/models/addons-factory.js | 0 .../ember-cli/lib/models/blueprint.js | 1585 +++++++++++++++++ .../ember-cli/lib/models/command.js | 2 +- .../ember-cli/lib/models/edit-file-diff.js | 0 .../ember-cli/lib/models/file-info.js | 0 .../lib/models/installation-checker.js | 0 .../ember-cli/lib/models/project.js | 0 .../ember-cli/lib/models/task.js | 0 .../ember-cli/lib/models/update-checker.js | 0 .../ember-cli/lib/models/watcher.js | 0 .../tasks/create-and-step-into-directory.js | 0 .../lib/tasks/destroy-from-blueprint.js | 0 .../lib/tasks/generate-from-blueprint.js | 0 .../ember-cli/lib/tasks/git-init.js | 0 .../ember-cli/lib/tasks/install-blueprint.js | 0 .../ember-cli/lib/tasks/npm-install.js | 0 .../ember-cli/lib/tasks/npm-task.js | 0 .../ember-cli/lib/tasks/npm-uninstall.js | 0 .../ember-cli/lib/tasks/update.js | 0 .../ember-cli/lib/ui/index.js | 0 .../ember-cli/lib/ui/write-error.js | 0 .../lib/utilities/COMMIT_MESSAGE.txt | 0 .../ember-cli/lib/utilities/DAG.js | 0 .../lib/utilities/attempt-never-index.js | 0 .../ember-cli/lib/utilities/deprecate.js | 0 .../ember-cli/lib/utilities/doc-generator.js | 0 .../lib/utilities/find-build-file.js | 0 .../lib/utilities/get-option-args.js | 0 .../lib/utilities/get-package-base-name.js | 0 .../ember-cli/lib/utilities/json-generator.js | 0 .../ember-cli/lib/utilities/markdown-color.js | 0 .../lib/utilities/merge-blueprint-options.js | 0 .../ember-cli/lib/utilities/mk-tmp-dir-in.js | 0 .../utilities/normalize-blueprint-option.js | 0 .../ember-cli/lib/utilities/npm.js | 0 .../ember-cli/lib/utilities/open-editor.js | 0 .../ember-cli/lib/utilities/parse-options.js | 0 .../ember-cli/lib/utilities/path.js | 0 .../lib/utilities/platform-checker.js | 0 .../ember-cli/lib/utilities/print-command.js | 0 .../lib/utilities/printable-properties.js | 0 .../lib/utilities/require-as-hash.js | 0 .../ember-cli/lib/utilities/require-local.js | 0 .../ember-cli/lib/utilities/root-command.js | 0 .../ember-cli/lib/utilities/sequence.js | 0 .../lib/utilities/valid-project-name.js | 0 .../ember-cli/lib/utilities/version-utils.js | 0 .../ember-cli/lib/utilities/windows-admin.js | 0 .../lib/cli/index.js | 6 +- .../lib/config/schema.d.ts | 0 .../lib/config/schema.json | 0 .../models/config.ts | 4 +- .../models/config/config.ts | 0 .../models/error.ts | 0 .../models/find-lazy-modules.ts | 0 .../models/index.ts | 0 .../json-schema/schema-class-factory.ts | 0 .../models/json-schema/schema-tree.ts | 0 .../models/json-schema/serializer.ts | 0 .../models/webpack-build-common.ts | 0 .../models/webpack-build-development.ts | 0 .../models/webpack-build-mobile.ts | 0 .../models/webpack-build-node.ts | 0 .../models/webpack-build-production.ts | 0 .../models/webpack-build-test.js | 0 .../models/webpack-build-typescript.ts | 0 .../models/webpack-build-utils.ts | 0 .../models/webpack-config.ts | 0 .../package.json | 6 +- .../plugins/glob-copy-webpack-plugin.ts | 0 .../plugins/karma.js | 10 +- .../tasks/build-webpack-watch.ts | 0 .../tasks/build-webpack.ts | 0 .../tasks/create-github-repo.ts | 0 .../tasks/doc.ts | 0 .../tasks/e2e.ts | 0 .../tasks/git-init.js | 0 .../tasks/link-cli.ts | 0 .../tasks/lint.ts | 0 .../tasks/npm-install.ts | 0 .../tasks/serve-webpack.ts | 2 +- .../tasks/server/universal-dev-server.ts | 0 .../tasks/test.ts | 0 .../tsconfig.json | 2 +- .../upgrade/version.ts | 2 +- .../utilities/INITIAL_COMMIT_MESSAGE.txt | 7 + .../utilities/ast-utils.ts | 0 .../utilities/change.ts | 0 .../utilities/completion.sh | 0 .../utilities/dynamic-path-parser.js | 0 .../utilities/find-parent-module.ts | 0 .../utilities/get-dependent-files.ts | 0 .../utilities/module-resolver.ts | 0 .../utilities/prerender-webpack-plugin.ts | 0 .../utilities/route-utils.ts | 0 .../utilities/sw-install.js | 0 plugins/karma.js | 6 +- scripts/publish/build.js | 4 +- tests/acceptance/destroy.spec.js | 6 +- tests/acceptance/dynamic-path-parser.spec.js | 10 +- tests/acceptance/find-lazy-module.spec.ts | 2 +- tests/acceptance/generate-component.spec.js | 2 +- tests/acceptance/generate-directive.spec.js | 2 +- tests/acceptance/generate-pipe.spec.js | 2 +- tests/acceptance/generate-service.spec.js | 2 +- tests/acceptance/get-dependent-files.spec.ts | 4 +- tests/acceptance/github-pages-deploy.spec.js | 2 +- tests/acceptance/init.spec.js | 4 +- tests/acceptance/module-resolver.spec.ts | 4 +- tests/acceptance/new.spec.js | 6 +- tests/e2e/setup/000-pwd.ts | 2 +- tests/e2e/setup/100-npm-link.ts | 2 +- tests/e2e/setup/200-create-tmp-dir.ts | 2 +- tests/e2e/setup/500-create-project.ts | 2 +- tests/e2e_runner.js | 2 +- tests/helpers/mock-ui.js | 4 +- tests/helpers/ng.js | 2 +- tests/helpers/tmp.js | 2 +- tests/models/config.spec.ts | 2 +- tests/models/find-lazy-modules.spec.ts | 2 +- tsconfig.json | 4 +- 258 files changed, 1768 insertions(+), 1744 deletions(-) delete mode 100755 packages/angular-cli/blueprints/ng2/files/README.md delete mode 100644 packages/angular-cli/ember-cli/lib/models/blueprint.js delete mode 100644 packages/angular-cli/utilities/INITIAL_COMMIT_MESSAGE.txt rename packages/{angular-cli => universal-cli}/addon/index.js (98%) rename packages/{angular-cli => universal-cli}/bin/ung (90%) rename packages/{angular-cli => universal-cli}/blueprints/class/files/__path__/__name__.spec.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/class/files/__path__/__name__.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/class/index.js (100%) rename packages/{angular-cli => universal-cli}/blueprints/component/files/__path__/__name__.component.__styleext__ (100%) rename packages/{angular-cli => universal-cli}/blueprints/component/files/__path__/__name__.component.html (100%) rename packages/{angular-cli => universal-cli}/blueprints/component/files/__path__/__name__.component.spec.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/component/files/__path__/__name__.component.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/component/index.js (100%) rename packages/{angular-cli => universal-cli}/blueprints/directive/files/__path__/__name__.directive.spec.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/directive/files/__path__/__name__.directive.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/directive/index.js (100%) rename packages/{angular-cli => universal-cli}/blueprints/enum/files/__path__/__name__.enum.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/enum/index.js (100%) rename packages/{angular-cli => universal-cli}/blueprints/interface/files/__path__/__name__.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/interface/index.js (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/android-chrome-144x144.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/android-chrome-192x192.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/android-chrome-36x36.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/android-chrome-48x48.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/android-chrome-72x72.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/android-chrome-96x96.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/apple-touch-icon-114x114.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/apple-touch-icon-120x120.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/apple-touch-icon-144x144.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/apple-touch-icon-152x152.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/apple-touch-icon-180x180.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/apple-touch-icon-57x57.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/apple-touch-icon-60x60.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/apple-touch-icon-72x72.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/apple-touch-icon-76x76.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/apple-touch-icon-precomposed.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/apple-touch-icon.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/favicon-16x16.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/favicon-32x32.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/favicon-96x96.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/icon.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/mstile-144x144.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/mstile-150x150.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/mstile-310x150.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/mstile-310x310.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/mstile-70x70.png (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/icons/safari-pinned-tab.svg (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/main-app-shell.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/files/__path__/manifest.webapp (100%) rename packages/{angular-cli => universal-cli}/blueprints/mobile/index.js (100%) rename packages/{angular-cli => universal-cli}/blueprints/module/files/__path__/__name__-routing.module.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/module/files/__path__/__name__.module.spec.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/module/files/__path__/__name__.module.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/module/index.js (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/.editorconfig (100%) create mode 100755 packages/universal-cli/blueprints/ng2/files/README.md rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/__path__/app/app-routing.module.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/__path__/app/app.component.__styleext__ (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/__path__/app/app.component.html (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/__path__/app/app.component.spec.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/__path__/app/app.component.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/__path__/app/app.module.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/__path__/app/index.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/__path__/assets/.gitkeep (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/__path__/environments/environment.prod.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/__path__/environments/environment.ts (80%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/__path__/favicon.ico (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/__path__/index.html (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/__path__/main.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/__path__/polyfills.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/__path__/styles.__styleext__ (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/__path__/test.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/__path__/tsconfig.json (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/__path__/typings.d.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/angular-cli.json (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/e2e/app.e2e-spec.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/e2e/app.po.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/e2e/tsconfig.json (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/gitignore (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/karma.conf.js (91%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/package.json (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/protractor.conf.js (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/files/tslint.json (100%) rename packages/{angular-cli => universal-cli}/blueprints/ng2/index.js (98%) rename packages/{angular-cli => universal-cli}/blueprints/pipe/files/__path__/__name__.pipe.spec.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/pipe/files/__path__/__name__.pipe.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/pipe/index.js (100%) rename packages/{angular-cli => universal-cli}/blueprints/service/files/__path__/__name__.service.spec.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/service/files/__path__/__name__.service.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/service/index.js (100%) rename packages/{angular-cli => universal-cli}/blueprints/universal/files/__path__/app/app.browser.module.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/universal/files/__path__/app/app.node.module.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/universal/files/__path__/client.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/universal/files/__path__/server.routes.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/universal/files/__path__/server.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/universal/files/webpack.client.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/universal/files/webpack.server.ts (100%) rename packages/{angular-cli => universal-cli}/blueprints/universal/index.js (100%) rename packages/{angular-cli => universal-cli}/commands/build.ts (100%) rename packages/{angular-cli => universal-cli}/commands/completion.ts (100%) rename packages/{angular-cli => universal-cli}/commands/destroy.ts (71%) rename packages/{angular-cli => universal-cli}/commands/doc.ts (100%) rename packages/{angular-cli => universal-cli}/commands/e2e.ts (100%) rename packages/{angular-cli => universal-cli}/commands/easter-egg.ts (100%) rename packages/{angular-cli => universal-cli}/commands/generate.ts (91%) rename packages/{angular-cli => universal-cli}/commands/get.ts (100%) rename packages/{angular-cli => universal-cli}/commands/github-pages-deploy.ts (100%) rename packages/{angular-cli => universal-cli}/commands/help.ts (100%) rename packages/{angular-cli => universal-cli}/commands/init.ts (77%) rename packages/{angular-cli => universal-cli}/commands/lint.ts (100%) rename packages/{angular-cli => universal-cli}/commands/new.ts (100%) rename packages/{angular-cli => universal-cli}/commands/serve.ts (100%) rename packages/{angular-cli => universal-cli}/commands/set.ts (100%) rename packages/{angular-cli => universal-cli}/commands/test.ts (100%) rename packages/{angular-cli => universal-cli}/commands/version.ts (96%) rename packages/{angular-cli => universal-cli}/custom-typings.d.ts (100%) rename packages/{angular-cli => universal-cli}/ember-cli/LICENSE.md (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/cli/cli.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/cli/index.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/cli/lookup-command.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/commands/generate.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/commands/test.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/commands/unknown.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/ext/core-object.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/ext/promise.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/models/addon-discovery.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/models/addon.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/models/addons-factory.js (100%) create mode 100644 packages/universal-cli/ember-cli/lib/models/blueprint.js rename packages/{angular-cli => universal-cli}/ember-cli/lib/models/command.js (99%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/models/edit-file-diff.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/models/file-info.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/models/installation-checker.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/models/project.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/models/task.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/models/update-checker.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/models/watcher.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/tasks/create-and-step-into-directory.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/tasks/destroy-from-blueprint.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/tasks/generate-from-blueprint.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/tasks/git-init.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/tasks/install-blueprint.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/tasks/npm-install.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/tasks/npm-task.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/tasks/npm-uninstall.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/tasks/update.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/ui/index.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/ui/write-error.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/COMMIT_MESSAGE.txt (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/DAG.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/attempt-never-index.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/deprecate.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/doc-generator.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/find-build-file.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/get-option-args.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/get-package-base-name.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/json-generator.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/markdown-color.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/merge-blueprint-options.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/mk-tmp-dir-in.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/normalize-blueprint-option.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/npm.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/open-editor.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/parse-options.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/path.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/platform-checker.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/print-command.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/printable-properties.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/require-as-hash.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/require-local.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/root-command.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/sequence.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/valid-project-name.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/version-utils.js (100%) rename packages/{angular-cli => universal-cli}/ember-cli/lib/utilities/windows-admin.js (100%) rename packages/{angular-cli => universal-cli}/lib/cli/index.js (92%) rename packages/{angular-cli => universal-cli}/lib/config/schema.d.ts (100%) rename packages/{angular-cli => universal-cli}/lib/config/schema.json (100%) rename packages/{angular-cli => universal-cli}/models/config.ts (95%) rename packages/{angular-cli => universal-cli}/models/config/config.ts (100%) rename packages/{angular-cli => universal-cli}/models/error.ts (100%) rename packages/{angular-cli => universal-cli}/models/find-lazy-modules.ts (100%) rename packages/{angular-cli => universal-cli}/models/index.ts (100%) rename packages/{angular-cli => universal-cli}/models/json-schema/schema-class-factory.ts (100%) rename packages/{angular-cli => universal-cli}/models/json-schema/schema-tree.ts (100%) rename packages/{angular-cli => universal-cli}/models/json-schema/serializer.ts (100%) rename packages/{angular-cli => universal-cli}/models/webpack-build-common.ts (100%) rename packages/{angular-cli => universal-cli}/models/webpack-build-development.ts (100%) rename packages/{angular-cli => universal-cli}/models/webpack-build-mobile.ts (100%) rename packages/{angular-cli => universal-cli}/models/webpack-build-node.ts (100%) rename packages/{angular-cli => universal-cli}/models/webpack-build-production.ts (100%) rename packages/{angular-cli => universal-cli}/models/webpack-build-test.js (100%) rename packages/{angular-cli => universal-cli}/models/webpack-build-typescript.ts (100%) rename packages/{angular-cli => universal-cli}/models/webpack-build-utils.ts (100%) rename packages/{angular-cli => universal-cli}/models/webpack-config.ts (100%) rename packages/{angular-cli => universal-cli}/package.json (94%) rename packages/{angular-cli => universal-cli}/plugins/glob-copy-webpack-plugin.ts (100%) rename packages/{angular-cli => universal-cli}/plugins/karma.js (84%) rename packages/{angular-cli => universal-cli}/tasks/build-webpack-watch.ts (100%) rename packages/{angular-cli => universal-cli}/tasks/build-webpack.ts (100%) rename packages/{angular-cli => universal-cli}/tasks/create-github-repo.ts (100%) rename packages/{angular-cli => universal-cli}/tasks/doc.ts (100%) rename packages/{angular-cli => universal-cli}/tasks/e2e.ts (100%) rename packages/{angular-cli => universal-cli}/tasks/git-init.js (100%) rename packages/{angular-cli => universal-cli}/tasks/link-cli.ts (100%) rename packages/{angular-cli => universal-cli}/tasks/lint.ts (100%) rename packages/{angular-cli => universal-cli}/tasks/npm-install.ts (100%) rename packages/{angular-cli => universal-cli}/tasks/serve-webpack.ts (98%) rename packages/{angular-cli => universal-cli}/tasks/server/universal-dev-server.ts (100%) rename packages/{angular-cli => universal-cli}/tasks/test.ts (100%) rename packages/{angular-cli => universal-cli}/tsconfig.json (94%) rename packages/{angular-cli => universal-cli}/upgrade/version.ts (97%) create mode 100644 packages/universal-cli/utilities/INITIAL_COMMIT_MESSAGE.txt rename packages/{angular-cli => universal-cli}/utilities/ast-utils.ts (100%) rename packages/{angular-cli => universal-cli}/utilities/change.ts (100%) rename packages/{angular-cli => universal-cli}/utilities/completion.sh (100%) rename packages/{angular-cli => universal-cli}/utilities/dynamic-path-parser.js (100%) rename packages/{angular-cli => universal-cli}/utilities/find-parent-module.ts (100%) rename packages/{angular-cli => universal-cli}/utilities/get-dependent-files.ts (100%) rename packages/{angular-cli => universal-cli}/utilities/module-resolver.ts (100%) rename packages/{angular-cli => universal-cli}/utilities/prerender-webpack-plugin.ts (100%) rename packages/{angular-cli => universal-cli}/utilities/route-utils.ts (100%) rename packages/{angular-cli => universal-cli}/utilities/sw-install.js (100%) diff --git a/.eslintignore b/.eslintignore index f07735d14909..2f22ee7a858c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -5,7 +5,7 @@ tmp/ typings/ # Ignore all blueprint files. We e2e tests those later on. -packages/angular-cli/blueprints/*/files/ +packages/universal-cli/blueprints/*/files/ # Ignore ember cli. -packages/angular-cli/ember-cli/ \ No newline at end of file +packages/universal-cli/ember-cli/ diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index fa7c45bbb104..d63ca452e4b5 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -6,7 +6,7 @@ ### Versions. -> Please run `ng --version`. If there's nothing outputted, please run in a Terminal: `node --version` and paste the result here: +> Please run `ung --version`. If there's nothing outputted, please run in a Terminal: `node --version` and paste the result here: ### Repro steps. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7cc888d2c931..b79a3db72d5a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ -# Contributing to angular-cli +# Contributing to universal-cli -We would love for you to contribute to angular-cli and help make it even better +We would love for you to contribute to universal-cli and help make it even better than it is today! As a contributor, here are the guidelines we would like you to follow: @@ -18,7 +18,7 @@ Help us keep Angular open and inclusive. Please read and follow our [Code of Con ## Got a Question or Problem? -If you have questions about how to *use* Angular CLI, please direct them to [StackOverflow][stackoverflow]. Please note that angular-cli is still in early developer preview, and the core team's capacity to answer usage questions is limited. We are also available on [Gitter][gitter]. +If you have questions about how to *use* Angular CLI, please direct them to [StackOverflow][stackoverflow]. Please note that universal-cli is still in early developer preview, and the core team's capacity to answer usage questions is limited. We are also available on [Gitter][gitter]. ## Found an Issue? If you find a bug in the source code or a mistake in the documentation, you can help us by @@ -57,13 +57,13 @@ chances of your issue being dealt with quickly: * **Suggest a Fix** - if you can't fix the bug yourself, perhaps you can point to what might be causing the problem (line of code or commit) -You can file new issues by providing the above information [here](https://github.com/angular/angular-cli/issues/new). +You can file new issues by providing the above information [here](https://github.com/angular/universal-cli/issues/new). ### Submitting a Pull Request (PR) Before you submit your Pull Request (PR) consider the following guidelines: -* Search [GitHub](https://github.com/angular/angular-cli/pulls) for an open or closed PR +* Search [GitHub](https://github.com/angular/universal-cli/pulls) for an open or closed PR that relates to your submission. You don't want to duplicate effort. * Please sign our [Contributor License Agreement (CLA)](#cla) before sending PRs. We cannot accept code without this. @@ -92,7 +92,7 @@ Before you submit your Pull Request (PR) consider the following guidelines: git push origin my-fix-branch ``` -* In GitHub, send a pull request to `angular-cli:master`. +* In GitHub, send a pull request to `universal-cli:master`. * If we suggest changes then: * Make the required updates. * Re-run the Angular CLI test suites for JS and Dart to ensure tests are still passing. diff --git a/README.md b/README.md index 1cf6022c5e93..f8baf11b11d6 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,9 @@ Prototype of a CLI for Angular 2 applications based on the [ember-cli](http://ww This project is very much still a work in progress. The CLI is now in alpha. -If you wish to collaborate while the project is still young, check out [our issue list](https://github.com/angular/angular-cli/issues). +If you wish to collaborate while the project is still young, check out [our issue list](https://github.com/devCrossNet/angular-cli/issues). -Before submitting new issues, have a look at [issues marked with the `type: faq` label](https://github.com/angular/angular-cli/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3A%22type%3A%20faq%22%20). +Before submitting new issues, have a look at [issues marked with the `type: faq` label](https://github.com/devCrossNet/angular-cli/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3A%22type%3A%20faq%22%20). ## Webpack update @@ -31,7 +31,7 @@ We changed the build system between beta.10 and beta.14, from SystemJS to Webpac And with it comes a lot of benefits. To take advantage of these, your app built with the old beta will need to migrate. -You can update your `beta.10` projects to `beta.14` by following [these instructions](https://github.com/angular/angular-cli/wiki/Upgrading-from-Beta.10-to-Beta.14). +You can update your `beta.10` projects to `beta.14` by following [these instructions](https://github.com/devCrossNet/angular-cli/wiki/Upgrading-from-Beta.10-to-Beta.14). ## Prerequisites @@ -62,8 +62,8 @@ with NPM 3 or higher. * [CSS preprocessor integration](#css-preprocessor-integration) * [3rd Party Library Installation](#3rd-party-library-installation) * [Global Library Installation](#global-library-installation) -* [Updating angular-cli](#updating-angular-cli) -* [Development Hints for hacking on angular-cli](#development-hints-for-hacking-on-angular-cli) +* [Updating universal-cli](#updating-universal-cli) +* [Development Hints for hacking on universal-cli](#development-hints-for-hacking-on-universal-cli) ## Installation @@ -281,7 +281,7 @@ please see the angular/mobile-toolkit project and https://mobile.angular.io/ for ### Support for server side rendering -**Angular-CLI includes Angular Universal via the `--universal` flag on `ung new` and `ung init`.** +**Universal-CLI includes Angular Universal via the `--universal` flag on `ung new` and `ung init`.** **Angular Universal** helps you to seo optimize your application and offers a better user experience through server side rendering. Please see the **angular/universal** project and https://universal.angular.io/ for documentation on how to make use of this functionality. @@ -336,7 +336,7 @@ You can add more global styles via the `apps[0].styles` property in `angular-cli ### CSS Preprocessor integration -Angular-CLI supports all major CSS preprocessors: +Universal-CLI supports all major CSS preprocessors: - sass/scss ([http://sass-lang.com/](http://sass-lang.com/)) - less ([http://lesscss.org/](http://lesscss.org/)) - stylus ([http://stylus-lang.com/](http://stylus-lang.com/)) @@ -425,21 +425,21 @@ Finally add the Bootstrap CSS to the `apps[0].styles` array: Restart `ung serve` if you're running it, and Bootstrap 4 should be working on your app. -### Updating angular-cli +### Updating universal-cli -To update `angular-cli` to a new version, you must update both the global package and your project's local package. +To update `universal-cli` to a new version, you must update both the global package and your project's local package. Global package: ```bash -npm uninstall -g angular-cli +npm uninstall -g universal-cli npm cache clean -npm install -g angular-cli@latest +npm install -g universal-cli ``` Local project package: ```bash rm -rf node_modules dist tmp -npm install --save-dev angular-cli@latest +npm install --save-dev universal-cli npm install ung init ``` @@ -450,40 +450,40 @@ Carefully read the diffs for each code file, and either accept the changes or in **The main cause of errors after an update is failing to incorporate these updates into your code**. -You can find more details about changes between versions in [CHANGELOG.md](https://github.com/angular/angular-cli/blob/master/CHANGELOG.md). +You can find more details about changes between versions in [CHANGELOG.md](https://github.com/devCrossNet/angular-cli/blob/master/CHANGELOG.md). -## Development Hints for hacking on angular-cli +## Development Hints for hacking on universal-cli ### Working with master ```bash -git clone https://github.com/angular/angular-cli.git +git clone https://github.com/devCrossNet/angular-cli.git cd angular-cli npm link ``` `npm link` is very similar to `npm install -g` except that instead of downloading the package from the repo, the just cloned `angular-cli/` folder becomes the global package. -Any changes to the files in the `angular-cli/` folder will immediately affect the global `angular-cli` package, +Any changes to the files in the `angular-cli/` folder will immediately affect the global `universal-cli` package, allowing you to quickly test any changes you make to the cli project. -Now you can use `angular-cli` via the command line: +Now you can use `universal-cli` via the command line: ```bash ung new foo cd foo -npm link angular-cli +npm link universal-cli ung serve ``` -`npm link angular-cli` is needed because by default the globally installed `angular-cli` just loads -the local `angular-cli` from the project which was fetched remotely from npm. -`npm link angular-cli` symlinks the global `angular-cli` package to the local `angular-cli` package. -Now the `angular-cli` you cloned before is in three places: -The folder you cloned it into, npm's folder where it stores global packages and the `angular-cli` project you just created. +`npm link universal-cli` is needed because by default the globally installed `universal-cli` just loads +the local `universal-cli` from the project which was fetched remotely from npm. +`npm link universal-cli` symlinks the global `universal-cli` package to the local `universal-cli` package. +Now the `universal-cli` you cloned before is in three places: +The folder you cloned it into, npm's folder where it stores global packages and the `universal-cli` project you just created. -You can also use `ung new foo --link-cli` to automatically link the `angular-cli` package. +You can also use `ung new foo --link-cli` to automatically link the `universal-cli` package. Please read the official [npm-link documentation](https://www.npmjs.org/doc/cli/npm-link.html) and the [npm-link cheatsheet](http://browsenpm.org/help#linkinganynpmpackagelocally) for more information. diff --git a/bin/ung b/bin/ung index d99e97baa291..4b117b0385ba 100755 --- a/bin/ung +++ b/bin/ung @@ -2,7 +2,7 @@ 'use strict'; // Provide a title to the process in `ps` -process.title = 'angular-cli'; +process.title = 'universal-cli'; require('../lib/bootstrap-local'); -require('../packages/angular-cli/bin/ung'); +require('../packages/universal-cli/bin/ung'); diff --git a/docs/publish.md b/docs/publish.md index 0178fb33e8af..70a76656624e 100644 --- a/docs/publish.md +++ b/docs/publish.md @@ -1,5 +1,5 @@ #Change versions -- There is a main `package.json` which should keep with the latest angular-cli version (e.g. `1.0.0-beta.17`). +- There is a main `package.json` which should keep with the latest universal-cli version (e.g. `1.0.0-beta.17`). - There is one `package.json` per packages. Update the version of every packages independently. - Run the CHANGELOG script. - `node ./scripts/publish/changelog.js OLD_VERSION_TAG` @@ -11,6 +11,6 @@ - `git push --tags` - Publish to npm - `npm run build` - - `cd ./dist/angular-cli` + - `cd ./dist/universal-cli` - `npm publish --tag experimental` (install it with `npm install -g universal-cli@experimental` and test it) - `npm publish` (the new version is now available at npm) \ No newline at end of file diff --git a/lib/bootstrap-local.js b/lib/bootstrap-local.js index 802e55ebae0e..a7cf31a48b4b 100644 --- a/lib/bootstrap-local.js +++ b/lib/bootstrap-local.js @@ -15,8 +15,8 @@ const oldRequireTs = require.extensions['.ts']; require.extensions['.ts'] = function(m, filename) { // If we're in node module, either call the old hook or simply compile the // file without transpilation. We do not touch node_modules/**. - // We do touch `angular-cli` files anywhere though. - if (!filename.match(/angular-cli/) && filename.match(/node_modules/)) { + // We do touch `universal-cli` files anywhere though. + if (!filename.match(/universal-cli/) && filename.match(/node_modules/)) { if (oldRequireTs) { return oldRequireTs(m, filename); } @@ -54,9 +54,9 @@ if (!__dirname.match(new RegExp(`\\${path.sep}node_modules\\${path.sep}`))) { Module._load = function (request, parent) { if (request in packages) { return oldLoad.call(this, packages[request].main, parent); - } else if (request.startsWith('angular-cli/')) { + } else if (request.startsWith('universal-cli/')) { // We allow deep imports (for now). - // TODO: move tests to inside angular-cli package so they don't have to deep import. + // TODO: move tests to inside universal-cli package so they don't have to deep import. const dir = path.dirname(parent.filename); const newRequest = path.relative(dir, path.join(__dirname, '../packages', request)); return oldLoad.call(this, newRequest, parent); diff --git a/lib/packages.js b/lib/packages.js index bedc19db971b..e3fbbb2de867 100644 --- a/lib/packages.js +++ b/lib/packages.js @@ -14,7 +14,7 @@ const packages = fs.readdirSync(packageRoot) let pkgJson = JSON.parse(fs.readFileSync(path.join(pkg.root, 'package.json'), 'utf8')); let name = pkgJson['name']; packages[name] = { - dist: path.join(__dirname, '../dist', (pkg.name === 'universal-cli' ? 'angular-cli' : pkg.name)), + dist: path.join(__dirname, '../dist', pkg.name), packageJson: path.join(pkg.root, 'package.json'), root: pkg.root, relative: path.relative(path.dirname(__dirname), pkg.root), diff --git a/package.json b/package.json index 3f878cd674b1..e7934aaa1ba3 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "universal-cli", "version": "1.0.0-alpha.universal.2-2", "description": "CLI tool for Angular with Angular Universal support", - "main": "packages/angular-cli/lib/cli/index.js", + "main": "packages/universal-cli/lib/cli/index.js", "trackingCode": "xx-xxxxxxx-xx", "bin": { "ung": "./bin/ung" @@ -21,14 +21,14 @@ "test:inspect": "node --inspect --debug-brk tests/runner", "test:packages": "node scripts/run-packages-spec.js", "test:universal": "UNIVERSAL=true node tests/e2e_runner.js", - "build-config-interface": "dtsgen packages/angular-cli/lib/config/schema.json --out packages/angular-cli/lib/config/schema.d.ts", + "build-config-interface": "dtsgen packages/universal-cli/lib/config/schema.json --out packages/universal-cli/lib/config/schema.d.ts", "eslint": "eslint .", "tslint": "tslint \"**/*.ts\" -c tslint.json -e \"**/blueprints/*/files/**/*.ts\" -e \"node_modules/**\" -e \"tmp/**\" -e \"dist/**\"", "lint": "npm-run-all -c eslint tslint" }, "repository": { "type": "git", - "url": "https://github.com/devCrossNet/angular-cli.git" + "url": "https://github.com/devCrossNet/universal-cli.git" }, "engines": { "node": ">= 4.1.0", @@ -42,9 +42,9 @@ ], "license": "MIT", "bugs": { - "url": "https://github.com/devCrossNet/angular-cli/issues" + "url": "https://github.com/devCrossNet/universal-cli/issues" }, - "homepage": "https://github.com/devCrossNet/angular-cli", + "homepage": "https://github.com/devCrossNet/universal-cli", "dependencies": { "@angular-cli/ast-tools": "^1.0.0", "@angular/compiler": "^2.1.0", @@ -142,7 +142,7 @@ }, "ember-addon": { "paths": [ - "./packages/angular-cli/lib/addon" + "./packages/universal-cli/lib/addon" ] }, "devDependencies": { diff --git a/packages/angular-cli/blueprints/ng2/files/README.md b/packages/angular-cli/blueprints/ng2/files/README.md deleted file mode 100755 index d22077cb38de..000000000000 --- a/packages/angular-cli/blueprints/ng2/files/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# <%= jsComponentName %> - -This project was generated with [angular-cli](https://github.com/angular/angular-cli) version <%= version %>. - -## Development server -Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. - -## Code scaffolding - -Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive/pipe/service/class`. - -## Build - -Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build. - -## Running unit tests - -Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). - -## Running end-to-end tests - -Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). -Before running the tests make sure you are serving the app via `ng serve`. - -## Deploying to Github Pages - -Run `ng github-pages:deploy` to deploy to Github Pages. - -## Further help - -To get more help on the `angular-cli` use `ng --help` or go check out the [Angular-CLI README](https://github.com/angular/angular-cli/blob/master/README.md). diff --git a/packages/angular-cli/ember-cli/lib/models/blueprint.js b/packages/angular-cli/ember-cli/lib/models/blueprint.js deleted file mode 100644 index f167fdbdfbcb..000000000000 --- a/packages/angular-cli/ember-cli/lib/models/blueprint.js +++ /dev/null @@ -1,1571 +0,0 @@ -'use strict'; - -/** -@module ember-cli -*/ -var FileInfo = require('./file-info'); -var Promise = require('../ext/promise'); -var chalk = require('chalk'); -var MarkdownColor = require('../utilities/markdown-color'); -var printableProperties = require('../utilities/printable-properties').blueprint; -var sequence = require('../utilities/sequence'); -var printCommand = require('../utilities/print-command'); -var fs = require('fs-extra'); -var existsSync = require('exists-sync'); -var inflector = require('inflection'); -var minimatch = require('minimatch'); -var path = require('path'); -var stat = Promise.denodeify(fs.stat); -var stringUtils = require('ember-cli-string-utils'); -var compact = require('lodash/compact'); -var intersect = require('lodash/intersection'); -var uniq = require('lodash/uniq'); -var zipObject = require('lodash/zipObject'); -var includes = require('lodash/includes'); -var any = require('lodash/some'); -var cloneDeep = require('lodash/cloneDeep'); -var keys = require('lodash/keys'); -var merge = require('lodash/merge'); -var values = require('lodash/values'); -var walkSync = require('walk-sync'); -var writeFile = Promise.denodeify(fs.outputFile); -var removeFile = Promise.denodeify(fs.remove); -var SilentError = require('silent-error'); -var CoreObject = require('../ext/core-object'); -var EOL = require('os').EOL; -var debug = require('debug')('ember-cli:blueprint'); -var normalizeEntityName = require('ember-cli-normalize-entity-name'); - -module.exports = Blueprint; - -/** - A blueprint is a bundle of template files with optional install - logic. - - Blueprints follow a simple structure. Let's take the built-in - `controller` blueprint as an example: - - ``` - blueprints/controller - ├── files - │ ├── app - │ │ └── __path__ - │ │ └── __name__.js - └── index.js - - blueprints/controller-test - ├── files - │ └── tests - │ └── unit - │ └── controllers - │ └── __test__.js - └── index.js - ``` - - ## Files - - `files` contains templates for the all the files to be - installed into the target directory. - - The `__name__` token is subtituted with the dasherized - entity name at install time. For example, when the user - invokes `ember generate controller foo` then `__name__` becomes - `foo`. When the `--pod` flag is used, for example `ember - generate controller foo --pod` then `__name__` becomes - `controller`. - - The `__path__` token is substituted with the blueprint - name at install time. For example, when the user invokes - `ember generate controller foo` then `__path__` becomes - `controller`. When the `--pod` flag is used, for example - `ember generate controller foo --pod` then `__path__` - becomes `foo` (or `/foo` if the - podModulePrefix is defined). This token is primarily for - pod support, and is only necessary if the blueprint can be - used in pod structure. If the blueprint does not require pod - support, simply use the blueprint name instead of the - `__path__` token. - - The `__test__` token is substituted with the dasherized - entity name and appended with `-test` at install time. - This token is primarily for pod support and only necessary - if the blueprint requires support for a pod structure. If - the blueprint does not require pod support, simply use the - `__name__` token instead. - - ## Template Variables (AKA Locals) - - Variables can be inserted into templates with - `<%= someVariableName %>`. - - For example, the built-in `util` blueprint - `files/app/utils/__name__.js` looks like this: - - ```js - export default function <%= camelizedModuleName %>() { - return true; - } - ``` - - `<%= camelizedModuleName %>` is replaced with the real - value at install time. - - The following template variables are provided by default: - - - `dasherizedPackageName` - - `classifiedPackageName` - - `dasherizedModuleName` - - `classifiedModuleName` - - `camelizedModuleName` - - `packageName` is the project name as found in the project's - `package.json`. - - `moduleName` is the name of the entity being generated. - - The mechanism for providing custom template variables is - described below. - - ## Index.js - - Custom installation and uninstallation behaviour can be added - by overriding the hooks documented below. `index.js` should - export a plain object, which will extend the prototype of the - `Blueprint` class. If needed, the original `Blueprint` prototype - can be accessed through the `_super` property. - - ```js - module.exports = { - locals: function(options) { - // Return custom template variables here. - return {}; - }, - - normalizeEntityName: function(entityName) { - // Normalize and validate entity name here. - return entityName; - }, - - fileMapTokens: function(options) ( - // Return custom tokens to be replaced in your files - return { - __token__: function(options){ - // logic to determine value goes here - return 'value'; - } - } - }, - - filesPath: function(options) { - return path.join(this.path, 'files'); - }, - - beforeInstall: function(options) {}, - afterInstall: function(options) {}, - beforeUninstall: function(options) {}, - afterUninstall: function(options) {} - - }; - ``` - - ## Blueprint Hooks - - As shown above, the following hooks are available to - blueprint authors: - - - `locals` - - `normalizeEntityName` - - `fileMapTokens` - - `filesPath` - - `beforeInstall` - - `afterInstall` - - `beforeUninstall` - - `afterUninstall` - - ### locals - - Use `locals` to add custom tempate variables. The method - receives one argument: `options`. Options is an object - containing general and entity-specific options. - - When the following is called on the command line: - - ```sh - ember generate controller foo --type=array --dry-run - ``` - - The object passed to `locals` looks like this: - - ```js - { - entity: { - name: 'foo', - options: { - type: 'array' - } - }, - dryRun: true - } - ``` - - This hook must return an object or a Promise which resolves to an object. - The resolved object will be merged with the aforementioned default locals. - - ### normalizeEntityName - - Use the `normalizeEntityName` hook to add custom normalization and - validation of the provided entity name. The default hook does not - make any changes to the entity name, but makes sure an entity name - is present and that it doesn't have a trailing slash. - - This hook receives the entity name as its first argument. The string - returned by this hook will be used as the new entity name. - - ### fileMapTokens - - Use `fileMapTokens` to add custom fileMap tokens for use - in the `mapFile` method. The hook must return an object in the - following pattern: - - ```js - { - __token__: function(options){ - // logic to determine value goes here - return 'value'; - } - } - ``` - - It will be merged with the default `fileMapTokens`, and can be used - to override any of the default tokens. - - Tokens are used in the files folder (see `files`), and get replaced with - values when the `mapFile` method is called. - - ### filesPath - - Use `filesPath` to define where the blueprint files to install are located. - This can be used to customize which set of files to install based on options - or environmental variables. It defaults to the `files` directory within the - blueprint's folder. - - ### beforeInstall & beforeUninstall - - Called before any of the template files are processed and receives - the the `options` and `locals` hashes as parameters. Typically used for - validating any additional command line options or for any asynchronous - setup that is needed. As an example, the `controller` blueprint validates - its `--type` option in this hook. If you need to run any asynchronous code, - wrap it in a promise and return that promise from these hooks. This will - ensure that your code is executed correctly. - - ### afterInstall & afterUninstall - - The `afterInstall` and `afterUninstall` hooks receives the same - arguments as `locals`. Use it to perform any custom work after the - files are processed. For example, the built-in `route` blueprint - uses these hooks to add and remove relevant route declarations in - `app/router.js`. - - ### Overriding Install - - If you don't want your blueprint to install the contents of - `files` you can override the `install` method. It receives the - same `options` object described above and must return a promise. - See the built-in `resource` blueprint for an example of this. - - @class Blueprint - @constructor - @extends CoreObject - @param {String} [blueprintPath] -*/ -function Blueprint(blueprintPath) { - this.path = blueprintPath; - this.name = path.basename(blueprintPath); -} - -Blueprint.__proto__ = CoreObject; -Blueprint.prototype.constructor = Blueprint; - -Blueprint.prototype.availableOptions = []; -Blueprint.prototype.anonymousOptions = ['name']; - -/** - Hook to specify the path to the blueprint's files. By default this is - `path.join(this.path, 'files)`. - - @method filesPath - @param {Object} options - @return {String} Path to the blueprints files directory. -*/ - -Blueprint.prototype.filesPath = function() { - return path.join(this.path, 'files'); -}; - -/** - Used to retrieve files for blueprint. The `file` param is an - optional string that is turned into a glob. - - @method files - @return {Array} Contents of the blueprint's files directory -*/ -Blueprint.prototype.files = function() { - if (this._files) { return this._files; } - - var filesPath = this.filesPath(this.options); - if (existsSync(filesPath)) { - this._files = walkSync(filesPath); - } else { - this._files = []; - } - - return this._files; -}; - -/** - @method srcPath - @param {String} file - @return {String} Resolved path to the file -*/ -Blueprint.prototype.srcPath = function(file) { - return path.resolve(this.filesPath(this.options), file); -}; - -/** - Hook for normalizing entity name - @method normalizeEntityName - @param {String} entityName - @return {null} -*/ -Blueprint.prototype.normalizeEntityName = function(entityName) { - return normalizeEntityName(entityName); -}; - -/** - Write a status and message to the UI - @private - @method _writeStatusToUI - @param {Function} chalkColor - @param {String} keyword - @param {String} message -*/ -Blueprint.prototype._writeStatusToUI = function(chalkColor, keyword, message) { - if (this.ui) { - this.ui.writeLine(' ' + chalkColor(keyword) + ' ' + message); - } -}; - -/** - @private - @method _writeFile - @param {Object} info - @return {Promise} -*/ -Blueprint.prototype._writeFile = function(info) { - if (!this.dryRun) { - return writeFile(info.outputPath, info.render()); - } -}; - -/** - Actions lookup - @private -*/ - -Blueprint.prototype._actions = { - write: function(info) { - this._writeStatusToUI(chalk.green, 'create', info.displayPath); - return this._writeFile(info); - }, - skip: function(info) { - var label = 'skip'; - - if (info.resolution === 'identical') { - label = 'identical'; - } - - this._writeStatusToUI(chalk.yellow, label, info.displayPath); - }, - - overwrite: function(info) { - this._writeStatusToUI(chalk.yellow, 'overwrite', info.displayPath); - return this._writeFile(info); - }, - - edit: function(info) { - this._writeStatusToUI(chalk.green, 'edited', info.displayPath); - }, - - remove: function(info) { - this._writeStatusToUI(chalk.red, 'remove', info.displayPath); - if (!this.dryRun) { - return removeFile(info.outputPath); - } - } -}; - -/** - Calls an action. - @private - @method _commit - @param {Object} result - @return {Promise} - @throws {Error} Action doesn't exist. -*/ -Blueprint.prototype._commit = function(result) { - var action = this._actions[result.action]; - - if (action) { - return action.call(this, result); - } else { - throw new Error('Tried to call action \"' + result.action + '\" but it does not exist'); - } -}; - -/** - Prints warning for pod unsupported. - @private - @method _checkForPod -*/ -Blueprint.prototype._checkForPod = function(verbose) { - if (!this.hasPathToken && this.pod && verbose) { - this.ui.writeLine(chalk.yellow('You specified the pod flag, but this' + - ' blueprint does not support pod structure. It will be generated with' + - ' the default structure.')); - } -}; - -/** - @private - @method _normalizeEntityName - @param {Object} entity -*/ -Blueprint.prototype._normalizeEntityName = function(entity) { - if (entity) { - entity.name = this.normalizeEntityName(entity.name); - } -}; - -/** - @private - @method _checkInRepoAddonExists - @param {String} inRepoAddon -*/ -Blueprint.prototype._checkInRepoAddonExists = function(inRepoAddon) { - if (inRepoAddon) { - if (!inRepoAddonExists(inRepoAddon, this.project.root)) { - throw new SilentError('You specified the in-repo-addon flag, but the' + - ' in-repo-addon \'' + inRepoAddon + '\' does not exist. Please' + - ' check the name and try again.'); - } - } -}; - -/** - @private - @method _process - @param {Object} options - @param {Function} beforeHook - @param {Function} process - @param {Function} afterHook -*/ -Blueprint.prototype._process = function(options, beforeHook, process, afterHook) { - var self = this; - var intoDir = options.target; - - return this._locals(options).then(function (locals) { - return Promise.resolve() - .then(beforeHook.bind(self, options, locals)) - .then(process.bind(self, intoDir, locals)).map(self._commit.bind(self)) - .then(afterHook.bind(self, options)); - }); -}; - -/** - @method install - @param {Object} options - @return {Promise} -*/ -Blueprint.prototype.install = function(options) { - var ui = this.ui = options.ui; - var dryRun = this.dryRun = options.dryRun; - this.project = options.project; - this.pod = options.pod; - this.options = options; - this.hasPathToken = hasPathToken(this.files()); - - podDeprecations(this.project.config(), ui); - - ui.writeLine('installing ' + this.name); - - if (dryRun) { - ui.writeLine(chalk.yellow('You specified the dry-run flag, so no' + - ' changes will be written.')); - } - - this._normalizeEntityName(options.entity); - this._checkForPod(options.verbose); - this._checkInRepoAddonExists(options.inRepoAddon); - - debug('START: processing blueprint: `%s`', this.name); - var start = new Date(); - return this._process( - options, - this.beforeInstall, - this.processFiles, - this.afterInstall).finally(function() { - debug('END: processing blueprint: `%s` in (%dms)', this.name, new Date() - start); - }.bind(this)); -}; - -/** - @method uninstall - @param {Object} options - @return {Promise} -*/ -Blueprint.prototype.uninstall = function(options) { - var ui = this.ui = options.ui; - var dryRun = this.dryRun = options.dryRun; - this.project = options.project; - this.pod = options.pod; - this.options = options; - this.hasPathToken = hasPathToken(this.files()); - - podDeprecations(this.project.config(), ui); - - ui.writeLine('uninstalling ' + this.name); - - if (dryRun) { - ui.writeLine(chalk.yellow('You specified the dry-run flag, so no' + - ' files will be deleted.')); - } - - this._normalizeEntityName(options.entity); - this._checkForPod(options.verbose); - - return this._process( - options, - this.beforeUninstall, - this.processFilesForUninstall, - this.afterUninstall); -}; - -/** - Hook for running operations before install. - @method beforeInstall - @return {Promise|null} -*/ -Blueprint.prototype.beforeInstall = function() {}; - -/** - Hook for running operations after install. - @method afterInstall - @return {Promise|null} -*/ -Blueprint.prototype.afterInstall = function() {}; - -/** - Hook for running operations before uninstall. - @method beforeUninstall - @return {Promise|null} -*/ -Blueprint.prototype.beforeUninstall = function() {}; - -/** - Hook for running operations after uninstall. - @method afterUninstall - @return {Promise|null} -*/ -Blueprint.prototype.afterUninstall = function() {}; - -/** - Hook for adding additional locals - @method locals - @return {Object|null} -*/ -Blueprint.prototype.locals = function() {}; - -/** - Hook to add additional or override existing fileMapTokens. - @method fileMapTokens - @return {Object|null} -*/ -Blueprint.prototype.fileMapTokens = function() { -}; - -/** - @private - @method _fileMapTokens - @param {Object} options - @return {Object} -*/ -Blueprint.prototype._fileMapTokens = function(options) { - var standardTokens = { - __name__: function(options) { - if (options.pod && options.hasPathToken) { - return options.blueprintName; - } - return options.dasherizedModuleName; - }, - __path__: function(options) { - var blueprintName = options.blueprintName; - - if (blueprintName.match(/-test/)) { - blueprintName = options.blueprintName.slice(0, options.blueprintName.indexOf('-test')); - } - if (options.pod && options.hasPathToken) { - return path.join(options.podPath, options.dasherizedModuleName); - } - return inflector.pluralize(blueprintName); - }, - __root__: function(options) { - if (options.inRepoAddon) { - return path.join('lib',options.inRepoAddon, 'addon'); - } - if (options.inDummy) { - return path.join('tests','dummy','app'); - } - if (options.inAddon) { - return 'addon'; - } - return 'app'; - }, - __test__: function(options) { - if (options.pod && options.hasPathToken) { - return options.blueprintName; - } - return options.dasherizedModuleName + '-test'; - } - }; - - var customTokens = this.fileMapTokens(options) || options.fileMapTokens || {}; - return merge(standardTokens, customTokens); -}; - -/** - Used to generate fileMap tokens for mapFile. - - @method generateFileMap - @param {Object} fileMapVariables - @return {Object} -*/ -Blueprint.prototype.generateFileMap = function(fileMapVariables) { - var tokens = this._fileMapTokens(fileMapVariables); - var fileMapValues = values(tokens); - var tokenValues = fileMapValues.map(function(token) { return token(fileMapVariables); }); - var tokenKeys = keys(tokens); - return zipObject(tokenKeys,tokenValues); -}; - -/** - @method buildFileInfo - @param {Function} destPath - @param {Object} templateVariables - @param {String} file - @return {FileInfo} -*/ -Blueprint.prototype.buildFileInfo = function(destPath, templateVariables, file) { - var mappedPath = this.mapFile(file, templateVariables); - - return new FileInfo({ - action: 'write', - outputPath: destPath(mappedPath), - displayPath: path.normalize(mappedPath), - inputPath: this.srcPath(file), - templateVariables: templateVariables, - ui: this.ui - }); -}; - -/** - @method isUpdate - @return {Boolean} -*/ -Blueprint.prototype.isUpdate = function() { - if (this.project && this.project.isEmberCLIProject) { - return this.project.isEmberCLIProject(); - } -}; - -/** - @private - @method _getFileInfos - @param {Array} files - @param {String} intoDir - @param {Object} templateVariables - @return {Array} file infos -*/ -Blueprint.prototype._getFileInfos = function(files, intoDir, templateVariables) { - return files.map(this.buildFileInfo.bind(this, destPath.bind(null, intoDir), templateVariables)); -}; - -/** - Add update files to ignored files - @private - @method _ignoreUpdateFiles -*/ -Blueprint.prototype._ignoreUpdateFiles = function() { - if (this.isUpdate()) { - Blueprint.ignoredFiles = Blueprint.ignoredFiles.concat(Blueprint.ignoredUpdateFiles); - } -}; - -/** - @private - @method _getFilesForInstall - @param {Array} targetFiles - @return {Array} files -*/ -Blueprint.prototype._getFilesForInstall = function(targetFiles) { - var files = this.files(); - - // if we've defined targetFiles, get file info on ones that match - return targetFiles && targetFiles.length > 0 && intersect(files, targetFiles) || files; -}; - -/** - @private - @method _checkForNoMatch - @param {Array} fileInfos - @param {String} rawArgs -*/ -Blueprint.prototype._checkForNoMatch = function(fileInfos, rawArgs) { - if (fileInfos.filter(isFilePath).length < 1 && rawArgs) { - this.ui.writeLine(chalk.yellow('The globPattern \"' + rawArgs + - '\" did not match any files, so no file updates will be made.')); - } -}; - -function finishProcessingForInstall(infos) { - infos.forEach(markIdenticalToBeSkipped); - - var infosNeedingConfirmation = infos.reduce(gatherConfirmationMessages, []); - - return sequence(infosNeedingConfirmation).returns(infos); -} - -function finishProcessingForUninstall(infos) { - infos.forEach(markToBeRemoved); - return infos; -} - -/** - @method processFiles - @param {String} intoDir - @param {Object} templateVariables -*/ -Blueprint.prototype.processFiles = function(intoDir, templateVariables) { - var files = this._getFilesForInstall(templateVariables.targetFiles); - var fileInfos = this._getFileInfos(files, intoDir, templateVariables); - this._checkForNoMatch(fileInfos, templateVariables.rawArgs); - - this._ignoreUpdateFiles(); - - return Promise.filter(fileInfos, isValidFile). - map(prepareConfirm). - then(finishProcessingForInstall); -}; - -/** - @method processFilesForUninstall - @param {String} intoDir - @param {Object} templateVariables -*/ -Blueprint.prototype.processFilesForUninstall = function(intoDir, templateVariables) { - var fileInfos = this._getFileInfos(this.files(), intoDir, templateVariables); - - this._ignoreUpdateFiles(); - - return Promise.filter(fileInfos, isValidFile). - then(finishProcessingForUninstall); -}; - - -/** - @method mapFile - @param {String} file - @return {String} -*/ -Blueprint.prototype.mapFile = function(file, locals) { - var pattern, i; - var fileMap = locals.fileMap || { __name__: locals.dasherizedModuleName }; - file = Blueprint.renamedFiles[file] || file; - for (i in fileMap) { - pattern = new RegExp(i, 'g'); - file = file.replace(pattern, fileMap[i]); - } - return file; -}; - -/** - Looks for a __root__ token in the files folder. Must be present for - the blueprint to support addon tokens. The `server`, `blueprints`, and `test` - - @private - @method supportsAddon - @return {Boolean} -*/ -Blueprint.prototype.supportsAddon = function() { - return this.files().join().match(/__root__/); -}; - -/** - @private - @method _generateFileMapVariables - @param {Object} options - @return {Object} -*/ -Blueprint.prototype._generateFileMapVariables = function(moduleName, locals, options) { - var originBlueprintName = options.originBlueprintName || this.name; - var podModulePrefix = this.project.config().podModulePrefix || ''; - var podPath = podModulePrefix.substr(podModulePrefix.lastIndexOf('/') + 1); - var inAddon = this.project.isEmberCLIAddon() || !!options.inRepoAddon; - var inDummy = this.project.isEmberCLIAddon() ? options.dummy : false; - - return { - pod: this.pod, - podPath: podPath, - hasPathToken: this.hasPathToken, - inAddon: inAddon, - inRepoAddon: options.inRepoAddon, - inDummy: inDummy, - blueprintName: this.name, - originBlueprintName: originBlueprintName, - dasherizedModuleName: stringUtils.dasherize(moduleName), - locals: locals - }; -}; - -/** - @private - @method _locals - @param {Object} options - @return {Object} -*/ -Blueprint.prototype._locals = function(options) { - var packageName = options.project.name(); - var moduleName = options.entity && options.entity.name || packageName; - var sanitizedModuleName = moduleName.replace(/\//g, '-'); - - return new Promise(function(resolve) { - resolve(this.locals(options)); - }.bind(this)).then(function (customLocals) { - var fileMapVariables = this._generateFileMapVariables(moduleName, customLocals, options); - var fileMap = this.generateFileMap(fileMapVariables); - var standardLocals = { - dasherizedPackageName: stringUtils.dasherize(packageName), - classifiedPackageName: stringUtils.classify(packageName), - dasherizedModuleName: stringUtils.dasherize(moduleName), - classifiedModuleName: stringUtils.classify(sanitizedModuleName), - camelizedModuleName: stringUtils.camelize(sanitizedModuleName), - decamelizedModuleName: stringUtils.decamelize(sanitizedModuleName), - fileMap: fileMap, - hasPathToken: this.hasPathToken, - targetFiles: options.targetFiles, - rawArgs: options.rawArgs - }; - - return merge({}, standardLocals, customLocals); - }.bind(this)); -}; - -/** - Used to add a package to the project's `package.json`. - - Generally, this would be done from the `afterInstall` hook, to - ensure that a package that is required by a given blueprint is - available. - - @method addPackageToProject - @param {String} packageName - @param {String} target - @return {Promise} -*/ -Blueprint.prototype.addPackageToProject = function(packageName, target) { - var packageObject = {name: packageName}; - - if (target) { - packageObject.target = target; - } - - return this.addPackagesToProject([packageObject]); -}; - -/** - Used to add multiple packages to the project's `package.json`. - - Generally, this would be done from the `afterInstall` hook, to - ensure that a package that is required by a given blueprint is - available. - - Expects each array item to be an object with a `name`. Each object - may optionally have a `target` to specify a specific version. - - @method addPackagesToProject - @param {Array} packages - @return {Promise} -*/ -Blueprint.prototype.addPackagesToProject = function(packages) { - var task = this.taskFor('npm-install'); - var installText = (packages.length > 1) ? 'install packages' : 'install package'; - var packageNames = []; - var packageArray = []; - - for (var i = 0; i < packages.length; i++) { - packageNames.push(packages[i].name); - - var packageNameAndVersion = packages[i].name; - - if (packages[i].target) { - packageNameAndVersion += '@' + packages[i].target; - } - - packageArray.push(packageNameAndVersion); - } - - this._writeStatusToUI(chalk.green, installText, packageNames.join(', ')); - - return task.run({ - 'save-dev': true, - verbose: false, - packages: packageArray - }); -}; - -/** - Used to remove a package from the project's `package.json`. - - Generally, this would be done from the `afterInstall` hook, to - ensure that any package conflicts can be resolved before the - addon is used. - - @method removePackageFromProject - @param {String} packageName - @return {Promise} -*/ -Blueprint.prototype.removePackageFromProject = function(packageName) { - var packageObject = {name: packageName}; - - return this.removePackagesFromProject([packageObject]); -}; - -/** - Used to remove multiple packages from the project's `package.json`. - - Generally, this would be done from the `afterInstall` hook, to - ensure that any package conflicts can be resolved before the - addon is used. - - Expects each array item to be an object with a `name` property. - - @method removePackagesFromProject - @param {Array} packages - @return {Promise} -*/ -Blueprint.prototype.removePackagesFromProject = function(packages) { - var task = this.taskFor('npm-uninstall'); - var installText = (packages.length > 1) ? 'uninstall packages' : 'uninstall package'; - var packageNames = []; - var packageArray = []; - - for (var i = 0; i < packages.length; i++) { - packageNames.push(packages[i].name); - - var packageNameAndVersion = packages[i].name; - - packageArray.push(packageNameAndVersion); - } - - this._writeStatusToUI(chalk.green, installText, packageNames.join(', ')); - - return task.run({ - 'save-dev': true, - verbose: false, - packages: packageArray - }); -}; - -/** - Used to add a package to the projects `bower.json`. - - Generally, this would be done from the `afterInstall` hook, to - ensure that a package that is required by a given blueprint is - available. - - `localPackageName` and `target` may be thought of as equivalent - to the key-value pairs in the `dependency` or `devDepencency` - objects contained within a bower.json file. - - Examples: - - addBowerPackageToProject('jquery', '~1.11.1'); - addBowerPackageToProject('old_jquery', 'jquery#~1.9.1'); - addBowerPackageToProject('bootstrap-3', 'http://twitter.github.io/bootstrap/assets/bootstrap'); - - @method addBowerPackageToProject - @param {String} localPackageName - @param {String} target - @param {Object} installOptions - @return {Promise} -*/ -Blueprint.prototype.addBowerPackageToProject = function(localPackageName, target, installOptions) { - // var lpn = localPackageName; - // var tar = target; - // if (localPackageName.indexOf('#') >= 0) { - // if (arguments.length === 1) { - // var parts = localPackageName.split('#'); - // lpn = parts[0]; - // tar = parts[1]; - // this.ui.writeDeprecateLine('passing ' + localPackageName + - // ' directly to `addBowerPackageToProject` will soon be unsupported. \n' + - // 'You may want to replace this with ' + - // '`addBowerPackageToProject(\'' + lpn + '\', \'' + tar + '\')`'); - // } else { - // this.ui.writeDeprecateLine('passing ' + localPackageName + - // ' directly to `addBowerPackageToProject` will soon be unsupported'); - // } - // } - // var packageObject = bowEpParser.json2decomposed(lpn, tar); - // return this.addBowerPackagesToProject([packageObject], installOptions); - return Promise.resolve(); -}; - -/** - Used to add an array of packages to the projects `bower.json`. - - Generally, this would be done from the `afterInstall` hook, to - ensure that a package that is required by a given blueprint is - available. - - Expects each array item to be an object with a `name`. Each object - may optionally have a `target` to specify a specific version. - - @method addBowerPackagesToProject - @param {Array} packages - @param {Object} installOptions - @return {Promise} -*/ -Blueprint.prototype.addBowerPackagesToProject = function(packages, installOptions) { - var task = this.taskFor('bower-install'); - var installText = (packages.length > 1) ? 'install bower packages' : 'install bower package'; - var packageNames = []; - var packageNamesAndVersions = packages.map(function (pkg) { - pkg.source = pkg.source || pkg.name; - packageNames.push(pkg.name); - return pkg; - }).map(bowEpParser.compose); - - this._writeStatusToUI(chalk.green, installText, packageNames.join(', ')); - - return task.run({ - verbose: true, - packages: packageNamesAndVersions, - installOptions: installOptions - }); -}; - -/** - Used to retrieve a task with the given name. Passes the new task - the standard information available (like `ui`, `analytics`, `project`, etc). - - @method taskFor - @param dasherizedName - @public -*/ -Blueprint.prototype.taskFor = function(dasherizedName) { - var Task = require('../tasks/' + dasherizedName); - - return new Task({ - ui: this.ui, - project: this.project, - analytics: this.analytics - }); -}; - -/* - - Inserts the given content into a file. If the `contentsToInsert` string is already - present in the current contents, the file will not be changed unless `force` option - is passed. - - If `options.before` is specified, `contentsToInsert` will be inserted before - the first instance of that string. If `options.after` is specified, the - contents will be inserted after the first instance of that string. - If the string specified by options.before or options.after is not in the file, - no change will be made. - - If neither `options.before` nor `options.after` are present, `contentsToInsert` - will be inserted at the end of the file. - - Example: - ``` - // app/router.js - Router.map(function() { - }); - - insertIntoFile('app/router.js', - ' this.route("admin");', - {after:'Router.map(function() {'+EOL}); - - // new app/router.js - Router.map(function() { - this.route("admin"); - }); - ``` - - @method insertIntoFile - @param {String} pathRelativeToProjectRoot - @param {String} contentsToInsert - @param {Object} options - @return {Promise} -*/ -Blueprint.prototype.insertIntoFile = function(pathRelativeToProjectRoot, contentsToInsert, providedOptions) { - var fullPath = path.join(this.project.root, pathRelativeToProjectRoot); - var originalContents = ''; - - if (existsSync(fullPath)) { - originalContents = fs.readFileSync(fullPath, { encoding: 'utf8' }); - } - - var contentsToWrite = originalContents; - - var options = providedOptions || {}; - var alreadyPresent = originalContents.indexOf(contentsToInsert) > -1; - var insert = !alreadyPresent; - var insertBehavior = 'end'; - - if (options.before) { insertBehavior = 'before'; } - if (options.after) { insertBehavior = 'after'; } - - if (options.force) { insert = true; } - - if (insert) { - if (insertBehavior === 'end') { - contentsToWrite += contentsToInsert; - } else { - var contentMarker = options[insertBehavior]; - var contentMarkerIndex = contentsToWrite.indexOf(contentMarker); - - if (contentMarkerIndex !== -1) { - var insertIndex = contentMarkerIndex; - if (insertBehavior === 'after') { insertIndex += contentMarker.length; } - - contentsToWrite = contentsToWrite.slice(0, insertIndex) + - contentsToInsert + EOL + - contentsToWrite.slice(insertIndex); - } - } - } - - var returnValue = { - path: fullPath, - originalContents: originalContents, - contents: contentsToWrite, - inserted: false - }; - - if (contentsToWrite !== originalContents) { - returnValue.inserted = true; - - return writeFile(fullPath, contentsToWrite) - .then(function() { - return returnValue; - }); - } else { - return Promise.resolve(returnValue); - } -}; - -Blueprint.prototype._printCommand = printCommand; - -Blueprint.prototype.printBasicHelp = function(verbose) { - var initialMargin = ' '; - var output = initialMargin; - if (this.overridden) { - output += chalk.grey('(overridden) ' + this.name); - } else { - output += this.name; - - output += this._printCommand(initialMargin, true); - - if (verbose) { - output += EOL + this.printDetailedHelp(this.availableOptions); - } - } - - return output; -}; - -Blueprint.prototype.printDetailedHelp = function() { - var markdownColor = new MarkdownColor(); - var filePath = getDetailedHelpPath(this.path); - - if (existsSync(filePath)) { - return markdownColor.renderFile(filePath, { indent: ' ' }); - } - return ''; -}; - -Blueprint.prototype.getJson = function(verbose) { - var json = {}; - - printableProperties.forEachWithProperty(function(key) { - var value = this[key]; - if (key === 'availableOptions') { - value = cloneDeep(value); - value.forEach(function(option) { - if (typeof option.type === 'function') { - option.type = option.type.name; - } - }); - } - json[key] = value; - }, this); - - if (verbose) { - var detailedHelp = this.printDetailedHelp(this.availableOptions); - if (detailedHelp) { - json.detailedHelp = detailedHelp; - } - } - - return json; -}; - -/** - Used to retrieve a blueprint with the given name. - - @method lookupBlueprint - @param dasherizedName - @public -*/ -Blueprint.prototype.lookupBlueprint = function(dasherizedName) { - var projectPaths = this.project ? this.project.blueprintLookupPaths() : []; - - return Blueprint.lookup(dasherizedName, { - paths: projectPaths - }); -}; - -/** - @static - @method lookup - @namespace Blueprint - @param {String} [name] - @param {Object} [options] - @param {Array} [options.paths] Extra paths to search for blueprints - @param {Object} [options.properties] Properties - @return {Blueprint} -*/ -Blueprint.lookup = function(name, options) { - options = options || {}; - - var lookupPaths = generateLookupPaths(options.paths); - - var lookupPath; - var blueprintPath; - - for (var i = 0; (lookupPath = lookupPaths[i]); i++) { - blueprintPath = path.resolve(lookupPath, name); - - if (existsSync(blueprintPath)) { - return Blueprint.load(blueprintPath); - } - } - - if (!options.ignoreMissing) { - throw new SilentError('Unknown blueprint: ' + name); - } -}; - -/** - Loads a blueprint from given path. - @static - @method load - @namespace Blueprint - @param {String} blueprintPath - @return {Blueprint} blueprint instance -*/ -Blueprint.load = function(blueprintPath) { - var constructorPath = path.resolve(blueprintPath, 'index.js'); - var blueprintModule; - var Constructor = Blueprint; - - if (fs.lstatSync(blueprintPath).isDirectory()) { - - if (existsSync(constructorPath)) { - blueprintModule = require(constructorPath); - - if (typeof blueprintModule === 'function') { - Constructor = blueprintModule; - } else { - Constructor = Blueprint.extend(blueprintModule); - } - } - - return new Constructor(blueprintPath); - } - - return; -}; - -/** - @static - @method list - @namespace Blueprint - @param {Object} [options] - @param {Array} [options.paths] Extra paths to search for blueprints - @return {Blueprint} -*/ -Blueprint.list = function(options) { - options = options || {}; - - var lookupPaths = generateLookupPaths(options.paths); - var seen = []; - - return lookupPaths.map(function(lookupPath) { - var blueprints = dir(lookupPath); - var packagePath = path.join(lookupPath, '../package.json'); - var source; - - if (existsSync(packagePath)) { - source = require(packagePath).name; - } else { - source = path.basename(path.join(lookupPath, '..')); - } - - blueprints = blueprints.map(function(blueprintPath) { - var blueprint = Blueprint.load(blueprintPath); - var name; - - if (blueprint) { - name = blueprint.name; - blueprint.overridden = includes(seen, name); - seen.push(name); - - return blueprint; - } - - return; - }); - - return { - source: source, - blueprints: compact(blueprints) - }; - }); -}; - -/** - @static - @property renameFiles -*/ -Blueprint.renamedFiles = { - 'gitignore': '.gitignore' -}; - -/** - @static - @property ignoredFiles -*/ -Blueprint.ignoredFiles = [ - '.DS_Store' -]; - -/** - @static - @property ignoredUpdateFiles -*/ -Blueprint.ignoredUpdateFiles = [ - '.gitkeep', - 'app.css' -]; - -/** - @static - @property defaultLookupPaths -*/ -Blueprint.defaultLookupPaths = function() { - return [ - path.resolve(__dirname, '..', '..', 'blueprints') - ]; -}; - -/** - @private - @method prepareConfirm - @param {FileInfo} info - @return {Promise} -*/ -function prepareConfirm(info) { - return info.checkForConflict().then(function(resolution) { - info.resolution = resolution; - return info; - }); -} - -/** - @private - @method markIdenticalToBeSkipped - @param {FileInfo} info -*/ -function markIdenticalToBeSkipped(info) { - if (info.resolution === 'identical') { - info.action = 'skip'; - } -} - -/** - @private - @method markToBeRemoved - @param {FileInfo} info -*/ -function markToBeRemoved(info) { - info.action = 'remove'; -} - -/** - @private - @method gatherConfirmationMessages - @param {Array} collection - @param {FileInfo} info - @return {Array} -*/ -function gatherConfirmationMessages(collection, info) { - if (info.resolution === 'confirm') { - collection.push(info.confirmOverwriteTask()); - } - return collection; -} - -/** - @private - @method isFile - @param {FileInfo} info - @return {Boolean} -*/ -function isFile(info) { - return stat(info.inputPath).invoke('isFile'); -} - -/** - @private - @method isIgnored - @param {FileInfo} info - @return {Boolean} -*/ -function isIgnored(info) { - var fn = info.inputPath; - - return any(Blueprint.ignoredFiles, function(ignoredFile) { - return minimatch(fn, ignoredFile, { matchBase: true }); - }); -} - -/** - Combines provided lookup paths with defaults and removes - duplicates. - - @private - @method generateLookupPaths - @param {Array} lookupPaths - @return {Array} -*/ -function generateLookupPaths(lookupPaths) { - lookupPaths = lookupPaths || []; - lookupPaths = lookupPaths.concat(Blueprint.defaultLookupPaths()); - return uniq(lookupPaths); -} - -/** - Looks for a __path__ token in the files folder. Must be present for - the blueprint to support pod tokens. - - @private - @method hasPathToken - @param {files} files - @return {Boolean} -*/ -function hasPathToken(files) { - return files.join().match(/__path__/); -} - -function inRepoAddonExists(name, root) { - var addonPath = path.join(root, 'lib', name); - return existsSync(addonPath); -} - -function podDeprecations(config, ui) { - /* - var podModulePrefix = config.podModulePrefix || ''; - var podPath = podModulePrefix.substr(podModulePrefix.lastIndexOf('/') + 1); - // Disabled until we are ready to deprecate podModulePrefix - deprecateUI(ui)('`podModulePrefix` is deprecated and will be removed from future versions of ember-cli.'+ - ' Please move existing pods from \'app/' + podPath + '/\' to \'app/\'.', config.podModulePrefix); - */ - if (config.usePodsByDefault) { - ui.writeDeprecateLine('`usePodsByDefault` is no longer supported in \'config/environment.js\',' + - ' use `usePods` in \'.ember-cli\' instead.'); - } -} - -/** - @private - @method destPath - @param {String} intoDir - @param {String} file - @return {String} new path -*/ -function destPath(intoDir, file) { - return path.join(intoDir, file); -} - -/** - @private - @method isValidFile - @param {Object} fileInfo - @return {Promise} -*/ -function isValidFile(fileInfo) { - if (isIgnored(fileInfo)) { - return Promise.resolve(false); - } else { - return isFile(fileInfo); - } -} - -/** - @private - @method isFilePath - @param {Object} fileInfo - @return {Promise} -*/ -function isFilePath(fileInfo) { - return fs.statSync(fileInfo.inputPath).isFile(); -} - -/** - @private - @method dir - @returns {Array} list of files in the given directory or and empty array if no directory exists -*/ -function dir(fullPath) { - if (existsSync(fullPath)) { - return fs.readdirSync(fullPath).map(function(fileName) { - return path.join(fullPath, fileName); - }); - } else { - return []; - } -} - -/** - @private - @method getDetailedHelpPath - @param {String} thisPath - @return {String} help path -*/ -function getDetailedHelpPath(thisPath) { - return path.join(thisPath, './HELP.md'); -} diff --git a/packages/angular-cli/utilities/INITIAL_COMMIT_MESSAGE.txt b/packages/angular-cli/utilities/INITIAL_COMMIT_MESSAGE.txt deleted file mode 100644 index 0c4e93225506..000000000000 --- a/packages/angular-cli/utilities/INITIAL_COMMIT_MESSAGE.txt +++ /dev/null @@ -1,8 +0,0 @@ -chore: initial commit from angular-cli - _ _ _ - __ _ _ __ __ _ _ _| | __ _ _ __ ___| (_) - / _ | _ \ / _ | | | | |/ _ | __|____ / __| | | - | (_| | | | | (_| | |_| | | (_| | | |_____| (__| | | - \____|_| |_|\__ |\____|_|\____|_| \___|_|_| - |___/ - \ No newline at end of file diff --git a/packages/ast-tools/src/change.spec.ts b/packages/ast-tools/src/change.spec.ts index 1a3cc1833bcf..bc3c494cf9ba 100644 --- a/packages/ast-tools/src/change.spec.ts +++ b/packages/ast-tools/src/change.spec.ts @@ -8,7 +8,7 @@ import {InsertChange, NodeHost, RemoveChange, ReplaceChange} from './change'; import fs = require('fs'); let path = require('path'); -let Promise = require('angular-cli/ember-cli/lib/ext/promise'); +let Promise = require('universal-cli/ember-cli/lib/ext/promise'); const readFile = Promise.denodeify(fs.readFile); diff --git a/packages/angular-cli/addon/index.js b/packages/universal-cli/addon/index.js similarity index 98% rename from packages/angular-cli/addon/index.js rename to packages/universal-cli/addon/index.js index 8b294f9a2718..14a2a7a36953 100644 --- a/packages/angular-cli/addon/index.js +++ b/packages/universal-cli/addon/index.js @@ -5,7 +5,7 @@ const config = require('../models/config'); const path = require('path'); module.exports = { - name: 'ng2', + name: 'ung', config: function () { this.project.ngConfigObj = this.project.ngConfigObj || config.CliConfig.fromProject(); diff --git a/packages/angular-cli/bin/ung b/packages/universal-cli/bin/ung similarity index 90% rename from packages/angular-cli/bin/ung rename to packages/universal-cli/bin/ung index 7739921364c4..51b16d800585 100755 --- a/packages/angular-cli/bin/ung +++ b/packages/universal-cli/bin/ung @@ -2,7 +2,7 @@ 'use strict'; // Provide a title to the process in `ps` -process.title = 'angular-cli'; +process.title = 'universal-cli'; const resolve = require('resolve'); const packageJson = require('../package.json'); @@ -10,14 +10,14 @@ const Leek = require('leek'); const Version = require('../upgrade/version').Version; -resolve('angular-cli', { basedir: process.cwd() }, +resolve('universal-cli', { basedir: process.cwd() }, function (error, projectLocalCli) { var cli; if (error) { // If there is an error, resolve could not find the ng-cli // library from a package.json. Instead, include it from a relative // path to this script file (which is likely a globally installed - // npm package). Most common cause for hitting this is `ng new` + // npm package). Most common cause for hitting this is `ung new` cli = require('../lib/cli'); } else { // Verify that package's version. diff --git a/packages/angular-cli/blueprints/class/files/__path__/__name__.spec.ts b/packages/universal-cli/blueprints/class/files/__path__/__name__.spec.ts similarity index 100% rename from packages/angular-cli/blueprints/class/files/__path__/__name__.spec.ts rename to packages/universal-cli/blueprints/class/files/__path__/__name__.spec.ts diff --git a/packages/angular-cli/blueprints/class/files/__path__/__name__.ts b/packages/universal-cli/blueprints/class/files/__path__/__name__.ts similarity index 100% rename from packages/angular-cli/blueprints/class/files/__path__/__name__.ts rename to packages/universal-cli/blueprints/class/files/__path__/__name__.ts diff --git a/packages/angular-cli/blueprints/class/index.js b/packages/universal-cli/blueprints/class/index.js similarity index 100% rename from packages/angular-cli/blueprints/class/index.js rename to packages/universal-cli/blueprints/class/index.js diff --git a/packages/angular-cli/blueprints/component/files/__path__/__name__.component.__styleext__ b/packages/universal-cli/blueprints/component/files/__path__/__name__.component.__styleext__ similarity index 100% rename from packages/angular-cli/blueprints/component/files/__path__/__name__.component.__styleext__ rename to packages/universal-cli/blueprints/component/files/__path__/__name__.component.__styleext__ diff --git a/packages/angular-cli/blueprints/component/files/__path__/__name__.component.html b/packages/universal-cli/blueprints/component/files/__path__/__name__.component.html similarity index 100% rename from packages/angular-cli/blueprints/component/files/__path__/__name__.component.html rename to packages/universal-cli/blueprints/component/files/__path__/__name__.component.html diff --git a/packages/angular-cli/blueprints/component/files/__path__/__name__.component.spec.ts b/packages/universal-cli/blueprints/component/files/__path__/__name__.component.spec.ts similarity index 100% rename from packages/angular-cli/blueprints/component/files/__path__/__name__.component.spec.ts rename to packages/universal-cli/blueprints/component/files/__path__/__name__.component.spec.ts diff --git a/packages/angular-cli/blueprints/component/files/__path__/__name__.component.ts b/packages/universal-cli/blueprints/component/files/__path__/__name__.component.ts similarity index 100% rename from packages/angular-cli/blueprints/component/files/__path__/__name__.component.ts rename to packages/universal-cli/blueprints/component/files/__path__/__name__.component.ts diff --git a/packages/angular-cli/blueprints/component/index.js b/packages/universal-cli/blueprints/component/index.js similarity index 100% rename from packages/angular-cli/blueprints/component/index.js rename to packages/universal-cli/blueprints/component/index.js diff --git a/packages/angular-cli/blueprints/directive/files/__path__/__name__.directive.spec.ts b/packages/universal-cli/blueprints/directive/files/__path__/__name__.directive.spec.ts similarity index 100% rename from packages/angular-cli/blueprints/directive/files/__path__/__name__.directive.spec.ts rename to packages/universal-cli/blueprints/directive/files/__path__/__name__.directive.spec.ts diff --git a/packages/angular-cli/blueprints/directive/files/__path__/__name__.directive.ts b/packages/universal-cli/blueprints/directive/files/__path__/__name__.directive.ts similarity index 100% rename from packages/angular-cli/blueprints/directive/files/__path__/__name__.directive.ts rename to packages/universal-cli/blueprints/directive/files/__path__/__name__.directive.ts diff --git a/packages/angular-cli/blueprints/directive/index.js b/packages/universal-cli/blueprints/directive/index.js similarity index 100% rename from packages/angular-cli/blueprints/directive/index.js rename to packages/universal-cli/blueprints/directive/index.js diff --git a/packages/angular-cli/blueprints/enum/files/__path__/__name__.enum.ts b/packages/universal-cli/blueprints/enum/files/__path__/__name__.enum.ts similarity index 100% rename from packages/angular-cli/blueprints/enum/files/__path__/__name__.enum.ts rename to packages/universal-cli/blueprints/enum/files/__path__/__name__.enum.ts diff --git a/packages/angular-cli/blueprints/enum/index.js b/packages/universal-cli/blueprints/enum/index.js similarity index 100% rename from packages/angular-cli/blueprints/enum/index.js rename to packages/universal-cli/blueprints/enum/index.js diff --git a/packages/angular-cli/blueprints/interface/files/__path__/__name__.ts b/packages/universal-cli/blueprints/interface/files/__path__/__name__.ts similarity index 100% rename from packages/angular-cli/blueprints/interface/files/__path__/__name__.ts rename to packages/universal-cli/blueprints/interface/files/__path__/__name__.ts diff --git a/packages/angular-cli/blueprints/interface/index.js b/packages/universal-cli/blueprints/interface/index.js similarity index 100% rename from packages/angular-cli/blueprints/interface/index.js rename to packages/universal-cli/blueprints/interface/index.js diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/android-chrome-144x144.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/android-chrome-144x144.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/android-chrome-144x144.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/android-chrome-144x144.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/android-chrome-192x192.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/android-chrome-192x192.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/android-chrome-192x192.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/android-chrome-192x192.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/android-chrome-36x36.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/android-chrome-36x36.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/android-chrome-36x36.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/android-chrome-36x36.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/android-chrome-48x48.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/android-chrome-48x48.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/android-chrome-48x48.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/android-chrome-48x48.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/android-chrome-72x72.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/android-chrome-72x72.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/android-chrome-72x72.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/android-chrome-72x72.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/android-chrome-96x96.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/android-chrome-96x96.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/android-chrome-96x96.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/android-chrome-96x96.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-114x114.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-114x114.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-114x114.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-114x114.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-120x120.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-120x120.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-120x120.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-120x120.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-144x144.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-144x144.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-144x144.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-144x144.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-152x152.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-152x152.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-152x152.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-152x152.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-180x180.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-180x180.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-180x180.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-180x180.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-57x57.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-57x57.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-57x57.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-57x57.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-60x60.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-60x60.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-60x60.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-60x60.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-72x72.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-72x72.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-72x72.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-72x72.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-76x76.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-76x76.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-76x76.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-76x76.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-precomposed.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-precomposed.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-precomposed.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon-precomposed.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/apple-touch-icon.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/favicon-16x16.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/favicon-16x16.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/favicon-16x16.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/favicon-16x16.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/favicon-32x32.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/favicon-32x32.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/favicon-32x32.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/favicon-32x32.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/favicon-96x96.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/favicon-96x96.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/favicon-96x96.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/favicon-96x96.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/icon.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/icon.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/icon.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/icon.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/mstile-144x144.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/mstile-144x144.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/mstile-144x144.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/mstile-144x144.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/mstile-150x150.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/mstile-150x150.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/mstile-150x150.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/mstile-150x150.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/mstile-310x150.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/mstile-310x150.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/mstile-310x150.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/mstile-310x150.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/mstile-310x310.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/mstile-310x310.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/mstile-310x310.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/mstile-310x310.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/mstile-70x70.png b/packages/universal-cli/blueprints/mobile/files/__path__/icons/mstile-70x70.png similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/mstile-70x70.png rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/mstile-70x70.png diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/icons/safari-pinned-tab.svg b/packages/universal-cli/blueprints/mobile/files/__path__/icons/safari-pinned-tab.svg similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/icons/safari-pinned-tab.svg rename to packages/universal-cli/blueprints/mobile/files/__path__/icons/safari-pinned-tab.svg diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/main-app-shell.ts b/packages/universal-cli/blueprints/mobile/files/__path__/main-app-shell.ts similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/main-app-shell.ts rename to packages/universal-cli/blueprints/mobile/files/__path__/main-app-shell.ts diff --git a/packages/angular-cli/blueprints/mobile/files/__path__/manifest.webapp b/packages/universal-cli/blueprints/mobile/files/__path__/manifest.webapp similarity index 100% rename from packages/angular-cli/blueprints/mobile/files/__path__/manifest.webapp rename to packages/universal-cli/blueprints/mobile/files/__path__/manifest.webapp diff --git a/packages/angular-cli/blueprints/mobile/index.js b/packages/universal-cli/blueprints/mobile/index.js similarity index 100% rename from packages/angular-cli/blueprints/mobile/index.js rename to packages/universal-cli/blueprints/mobile/index.js diff --git a/packages/angular-cli/blueprints/module/files/__path__/__name__-routing.module.ts b/packages/universal-cli/blueprints/module/files/__path__/__name__-routing.module.ts similarity index 100% rename from packages/angular-cli/blueprints/module/files/__path__/__name__-routing.module.ts rename to packages/universal-cli/blueprints/module/files/__path__/__name__-routing.module.ts diff --git a/packages/angular-cli/blueprints/module/files/__path__/__name__.module.spec.ts b/packages/universal-cli/blueprints/module/files/__path__/__name__.module.spec.ts similarity index 100% rename from packages/angular-cli/blueprints/module/files/__path__/__name__.module.spec.ts rename to packages/universal-cli/blueprints/module/files/__path__/__name__.module.spec.ts diff --git a/packages/angular-cli/blueprints/module/files/__path__/__name__.module.ts b/packages/universal-cli/blueprints/module/files/__path__/__name__.module.ts similarity index 100% rename from packages/angular-cli/blueprints/module/files/__path__/__name__.module.ts rename to packages/universal-cli/blueprints/module/files/__path__/__name__.module.ts diff --git a/packages/angular-cli/blueprints/module/index.js b/packages/universal-cli/blueprints/module/index.js similarity index 100% rename from packages/angular-cli/blueprints/module/index.js rename to packages/universal-cli/blueprints/module/index.js diff --git a/packages/angular-cli/blueprints/ng2/files/.editorconfig b/packages/universal-cli/blueprints/ng2/files/.editorconfig similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/.editorconfig rename to packages/universal-cli/blueprints/ng2/files/.editorconfig diff --git a/packages/universal-cli/blueprints/ng2/files/README.md b/packages/universal-cli/blueprints/ng2/files/README.md new file mode 100755 index 000000000000..b5e01930cc3d --- /dev/null +++ b/packages/universal-cli/blueprints/ng2/files/README.md @@ -0,0 +1,31 @@ +# <%= jsComponentName %> + +This project was generated with [universal-cli](https://github.com/devCrossNet/angular-cli) version <%= version %>. + +## Development server +Run `ung serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. + +## Code scaffolding + +Run `ung generate component component-name` to generate a new component. You can also use `ung generate directive/pipe/service/class`. + +## Build + +Run `ung build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build. + +## Running unit tests + +Run `ung test` to execute the unit tests via [Karma](https://karma-runner.github.io). + +## Running end-to-end tests + +Run `ung e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). +Before running the tests make sure you are serving the app via `ung serve`. + +## Deploying to Github Pages + +Run `ung github-pages:deploy` to deploy to Github Pages. + +## Further help + +To get more help on the `universal-cli` use `ung --help` or go check out the [Universal-CLI README](https://github.com/devCrossNet/angular-cli/blob/master/README.md). diff --git a/packages/angular-cli/blueprints/ng2/files/__path__/app/app-routing.module.ts b/packages/universal-cli/blueprints/ng2/files/__path__/app/app-routing.module.ts similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/__path__/app/app-routing.module.ts rename to packages/universal-cli/blueprints/ng2/files/__path__/app/app-routing.module.ts diff --git a/packages/angular-cli/blueprints/ng2/files/__path__/app/app.component.__styleext__ b/packages/universal-cli/blueprints/ng2/files/__path__/app/app.component.__styleext__ similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/__path__/app/app.component.__styleext__ rename to packages/universal-cli/blueprints/ng2/files/__path__/app/app.component.__styleext__ diff --git a/packages/angular-cli/blueprints/ng2/files/__path__/app/app.component.html b/packages/universal-cli/blueprints/ng2/files/__path__/app/app.component.html similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/__path__/app/app.component.html rename to packages/universal-cli/blueprints/ng2/files/__path__/app/app.component.html diff --git a/packages/angular-cli/blueprints/ng2/files/__path__/app/app.component.spec.ts b/packages/universal-cli/blueprints/ng2/files/__path__/app/app.component.spec.ts similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/__path__/app/app.component.spec.ts rename to packages/universal-cli/blueprints/ng2/files/__path__/app/app.component.spec.ts diff --git a/packages/angular-cli/blueprints/ng2/files/__path__/app/app.component.ts b/packages/universal-cli/blueprints/ng2/files/__path__/app/app.component.ts similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/__path__/app/app.component.ts rename to packages/universal-cli/blueprints/ng2/files/__path__/app/app.component.ts diff --git a/packages/angular-cli/blueprints/ng2/files/__path__/app/app.module.ts b/packages/universal-cli/blueprints/ng2/files/__path__/app/app.module.ts similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/__path__/app/app.module.ts rename to packages/universal-cli/blueprints/ng2/files/__path__/app/app.module.ts diff --git a/packages/angular-cli/blueprints/ng2/files/__path__/app/index.ts b/packages/universal-cli/blueprints/ng2/files/__path__/app/index.ts similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/__path__/app/index.ts rename to packages/universal-cli/blueprints/ng2/files/__path__/app/index.ts diff --git a/packages/angular-cli/blueprints/ng2/files/__path__/assets/.gitkeep b/packages/universal-cli/blueprints/ng2/files/__path__/assets/.gitkeep similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/__path__/assets/.gitkeep rename to packages/universal-cli/blueprints/ng2/files/__path__/assets/.gitkeep diff --git a/packages/angular-cli/blueprints/ng2/files/__path__/environments/environment.prod.ts b/packages/universal-cli/blueprints/ng2/files/__path__/environments/environment.prod.ts similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/__path__/environments/environment.prod.ts rename to packages/universal-cli/blueprints/ng2/files/__path__/environments/environment.prod.ts diff --git a/packages/angular-cli/blueprints/ng2/files/__path__/environments/environment.ts b/packages/universal-cli/blueprints/ng2/files/__path__/environments/environment.ts similarity index 80% rename from packages/angular-cli/blueprints/ng2/files/__path__/environments/environment.ts rename to packages/universal-cli/blueprints/ng2/files/__path__/environments/environment.ts index 00313f16648e..2c3e356cabe2 100644 --- a/packages/angular-cli/blueprints/ng2/files/__path__/environments/environment.ts +++ b/packages/universal-cli/blueprints/ng2/files/__path__/environments/environment.ts @@ -1,6 +1,6 @@ // The file contents for the current environment will overwrite these during build. // The build system defaults to the dev environment which uses `environment.ts`, but if you do -// `ng build --env=prod` then `environment.prod.ts` will be used instead. +// `ung build --env=prod` then `environment.prod.ts` will be used instead. // The list of which env maps to which file can be found in `angular-cli.json`. export const environment = { diff --git a/packages/angular-cli/blueprints/ng2/files/__path__/favicon.ico b/packages/universal-cli/blueprints/ng2/files/__path__/favicon.ico similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/__path__/favicon.ico rename to packages/universal-cli/blueprints/ng2/files/__path__/favicon.ico diff --git a/packages/angular-cli/blueprints/ng2/files/__path__/index.html b/packages/universal-cli/blueprints/ng2/files/__path__/index.html similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/__path__/index.html rename to packages/universal-cli/blueprints/ng2/files/__path__/index.html diff --git a/packages/angular-cli/blueprints/ng2/files/__path__/main.ts b/packages/universal-cli/blueprints/ng2/files/__path__/main.ts similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/__path__/main.ts rename to packages/universal-cli/blueprints/ng2/files/__path__/main.ts diff --git a/packages/angular-cli/blueprints/ng2/files/__path__/polyfills.ts b/packages/universal-cli/blueprints/ng2/files/__path__/polyfills.ts similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/__path__/polyfills.ts rename to packages/universal-cli/blueprints/ng2/files/__path__/polyfills.ts diff --git a/packages/angular-cli/blueprints/ng2/files/__path__/styles.__styleext__ b/packages/universal-cli/blueprints/ng2/files/__path__/styles.__styleext__ similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/__path__/styles.__styleext__ rename to packages/universal-cli/blueprints/ng2/files/__path__/styles.__styleext__ diff --git a/packages/angular-cli/blueprints/ng2/files/__path__/test.ts b/packages/universal-cli/blueprints/ng2/files/__path__/test.ts similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/__path__/test.ts rename to packages/universal-cli/blueprints/ng2/files/__path__/test.ts diff --git a/packages/angular-cli/blueprints/ng2/files/__path__/tsconfig.json b/packages/universal-cli/blueprints/ng2/files/__path__/tsconfig.json similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/__path__/tsconfig.json rename to packages/universal-cli/blueprints/ng2/files/__path__/tsconfig.json diff --git a/packages/angular-cli/blueprints/ng2/files/__path__/typings.d.ts b/packages/universal-cli/blueprints/ng2/files/__path__/typings.d.ts similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/__path__/typings.d.ts rename to packages/universal-cli/blueprints/ng2/files/__path__/typings.d.ts diff --git a/packages/angular-cli/blueprints/ng2/files/angular-cli.json b/packages/universal-cli/blueprints/ng2/files/angular-cli.json similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/angular-cli.json rename to packages/universal-cli/blueprints/ng2/files/angular-cli.json diff --git a/packages/angular-cli/blueprints/ng2/files/e2e/app.e2e-spec.ts b/packages/universal-cli/blueprints/ng2/files/e2e/app.e2e-spec.ts similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/e2e/app.e2e-spec.ts rename to packages/universal-cli/blueprints/ng2/files/e2e/app.e2e-spec.ts diff --git a/packages/angular-cli/blueprints/ng2/files/e2e/app.po.ts b/packages/universal-cli/blueprints/ng2/files/e2e/app.po.ts similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/e2e/app.po.ts rename to packages/universal-cli/blueprints/ng2/files/e2e/app.po.ts diff --git a/packages/angular-cli/blueprints/ng2/files/e2e/tsconfig.json b/packages/universal-cli/blueprints/ng2/files/e2e/tsconfig.json similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/e2e/tsconfig.json rename to packages/universal-cli/blueprints/ng2/files/e2e/tsconfig.json diff --git a/packages/angular-cli/blueprints/ng2/files/gitignore b/packages/universal-cli/blueprints/ng2/files/gitignore similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/gitignore rename to packages/universal-cli/blueprints/ng2/files/gitignore diff --git a/packages/angular-cli/blueprints/ng2/files/karma.conf.js b/packages/universal-cli/blueprints/ng2/files/karma.conf.js similarity index 91% rename from packages/angular-cli/blueprints/ng2/files/karma.conf.js rename to packages/universal-cli/blueprints/ng2/files/karma.conf.js index 53397b496adc..bdb6c61e365a 100644 --- a/packages/angular-cli/blueprints/ng2/files/karma.conf.js +++ b/packages/universal-cli/blueprints/ng2/files/karma.conf.js @@ -4,7 +4,7 @@ module.exports = function (config) { config.set({ basePath: '', - frameworks: ['jasmine', 'angular-cli'], + frameworks: ['jasmine', 'universal-cli'], plugins: [ require('karma-jasmine'), require('karma-chrome-launcher'), @@ -15,7 +15,7 @@ module.exports = function (config) { { pattern: './<%= sourceDir %>/test.ts', watched: false } ], preprocessors: { - './<%= sourceDir %>/test.ts': ['angular-cli'] + './<%= sourceDir %>/test.ts': ['universal-cli'] }, mime: { 'text/x-typescript': ['ts','tsx'] diff --git a/packages/angular-cli/blueprints/ng2/files/package.json b/packages/universal-cli/blueprints/ng2/files/package.json similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/package.json rename to packages/universal-cli/blueprints/ng2/files/package.json diff --git a/packages/angular-cli/blueprints/ng2/files/protractor.conf.js b/packages/universal-cli/blueprints/ng2/files/protractor.conf.js similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/protractor.conf.js rename to packages/universal-cli/blueprints/ng2/files/protractor.conf.js diff --git a/packages/angular-cli/blueprints/ng2/files/tslint.json b/packages/universal-cli/blueprints/ng2/files/tslint.json similarity index 100% rename from packages/angular-cli/blueprints/ng2/files/tslint.json rename to packages/universal-cli/blueprints/ng2/files/tslint.json diff --git a/packages/angular-cli/blueprints/ng2/index.js b/packages/universal-cli/blueprints/ng2/index.js similarity index 98% rename from packages/angular-cli/blueprints/ng2/index.js rename to packages/universal-cli/blueprints/ng2/index.js index b6b07598e943..2e5d88305365 100644 --- a/packages/angular-cli/blueprints/ng2/index.js +++ b/packages/universal-cli/blueprints/ng2/index.js @@ -17,7 +17,7 @@ module.exports = { { name: 'inline-template', type: Boolean, default: false, aliases: ['it'] } ], - beforeInstall: function(options) { + beforeInstall: function (options) { if (options.ignoredUpdateFiles && options.ignoredUpdateFiles.length > 0) { return Blueprint.ignoredUpdateFiles = Blueprint.ignoredUpdateFiles.concat(options.ignoredUpdateFiles); } diff --git a/packages/angular-cli/blueprints/pipe/files/__path__/__name__.pipe.spec.ts b/packages/universal-cli/blueprints/pipe/files/__path__/__name__.pipe.spec.ts similarity index 100% rename from packages/angular-cli/blueprints/pipe/files/__path__/__name__.pipe.spec.ts rename to packages/universal-cli/blueprints/pipe/files/__path__/__name__.pipe.spec.ts diff --git a/packages/angular-cli/blueprints/pipe/files/__path__/__name__.pipe.ts b/packages/universal-cli/blueprints/pipe/files/__path__/__name__.pipe.ts similarity index 100% rename from packages/angular-cli/blueprints/pipe/files/__path__/__name__.pipe.ts rename to packages/universal-cli/blueprints/pipe/files/__path__/__name__.pipe.ts diff --git a/packages/angular-cli/blueprints/pipe/index.js b/packages/universal-cli/blueprints/pipe/index.js similarity index 100% rename from packages/angular-cli/blueprints/pipe/index.js rename to packages/universal-cli/blueprints/pipe/index.js diff --git a/packages/angular-cli/blueprints/service/files/__path__/__name__.service.spec.ts b/packages/universal-cli/blueprints/service/files/__path__/__name__.service.spec.ts similarity index 100% rename from packages/angular-cli/blueprints/service/files/__path__/__name__.service.spec.ts rename to packages/universal-cli/blueprints/service/files/__path__/__name__.service.spec.ts diff --git a/packages/angular-cli/blueprints/service/files/__path__/__name__.service.ts b/packages/universal-cli/blueprints/service/files/__path__/__name__.service.ts similarity index 100% rename from packages/angular-cli/blueprints/service/files/__path__/__name__.service.ts rename to packages/universal-cli/blueprints/service/files/__path__/__name__.service.ts diff --git a/packages/angular-cli/blueprints/service/index.js b/packages/universal-cli/blueprints/service/index.js similarity index 100% rename from packages/angular-cli/blueprints/service/index.js rename to packages/universal-cli/blueprints/service/index.js diff --git a/packages/angular-cli/blueprints/universal/files/__path__/app/app.browser.module.ts b/packages/universal-cli/blueprints/universal/files/__path__/app/app.browser.module.ts similarity index 100% rename from packages/angular-cli/blueprints/universal/files/__path__/app/app.browser.module.ts rename to packages/universal-cli/blueprints/universal/files/__path__/app/app.browser.module.ts diff --git a/packages/angular-cli/blueprints/universal/files/__path__/app/app.node.module.ts b/packages/universal-cli/blueprints/universal/files/__path__/app/app.node.module.ts similarity index 100% rename from packages/angular-cli/blueprints/universal/files/__path__/app/app.node.module.ts rename to packages/universal-cli/blueprints/universal/files/__path__/app/app.node.module.ts diff --git a/packages/angular-cli/blueprints/universal/files/__path__/client.ts b/packages/universal-cli/blueprints/universal/files/__path__/client.ts similarity index 100% rename from packages/angular-cli/blueprints/universal/files/__path__/client.ts rename to packages/universal-cli/blueprints/universal/files/__path__/client.ts diff --git a/packages/angular-cli/blueprints/universal/files/__path__/server.routes.ts b/packages/universal-cli/blueprints/universal/files/__path__/server.routes.ts similarity index 100% rename from packages/angular-cli/blueprints/universal/files/__path__/server.routes.ts rename to packages/universal-cli/blueprints/universal/files/__path__/server.routes.ts diff --git a/packages/angular-cli/blueprints/universal/files/__path__/server.ts b/packages/universal-cli/blueprints/universal/files/__path__/server.ts similarity index 100% rename from packages/angular-cli/blueprints/universal/files/__path__/server.ts rename to packages/universal-cli/blueprints/universal/files/__path__/server.ts diff --git a/packages/angular-cli/blueprints/universal/files/webpack.client.ts b/packages/universal-cli/blueprints/universal/files/webpack.client.ts similarity index 100% rename from packages/angular-cli/blueprints/universal/files/webpack.client.ts rename to packages/universal-cli/blueprints/universal/files/webpack.client.ts diff --git a/packages/angular-cli/blueprints/universal/files/webpack.server.ts b/packages/universal-cli/blueprints/universal/files/webpack.server.ts similarity index 100% rename from packages/angular-cli/blueprints/universal/files/webpack.server.ts rename to packages/universal-cli/blueprints/universal/files/webpack.server.ts diff --git a/packages/angular-cli/blueprints/universal/index.js b/packages/universal-cli/blueprints/universal/index.js similarity index 100% rename from packages/angular-cli/blueprints/universal/index.js rename to packages/universal-cli/blueprints/universal/index.js diff --git a/packages/angular-cli/commands/build.ts b/packages/universal-cli/commands/build.ts similarity index 100% rename from packages/angular-cli/commands/build.ts rename to packages/universal-cli/commands/build.ts diff --git a/packages/angular-cli/commands/completion.ts b/packages/universal-cli/commands/completion.ts similarity index 100% rename from packages/angular-cli/commands/completion.ts rename to packages/universal-cli/commands/completion.ts diff --git a/packages/angular-cli/commands/destroy.ts b/packages/universal-cli/commands/destroy.ts similarity index 71% rename from packages/angular-cli/commands/destroy.ts rename to packages/universal-cli/commands/destroy.ts index 57745599d2fe..cccd9f07e30c 100644 --- a/packages/angular-cli/commands/destroy.ts +++ b/packages/universal-cli/commands/destroy.ts @@ -12,7 +12,10 @@ const DestroyCommand = Command.extend({ ], run: function() { - return Promise.reject(new SilentError('The destroy command is not supported by Angular-CLI.')); + console.log('RUN'); + return Promise.reject( + new SilentError('The destroy command is not supported by Universal-CLI.') + ); } }); diff --git a/packages/angular-cli/commands/doc.ts b/packages/universal-cli/commands/doc.ts similarity index 100% rename from packages/angular-cli/commands/doc.ts rename to packages/universal-cli/commands/doc.ts diff --git a/packages/angular-cli/commands/e2e.ts b/packages/universal-cli/commands/e2e.ts similarity index 100% rename from packages/angular-cli/commands/e2e.ts rename to packages/universal-cli/commands/e2e.ts diff --git a/packages/angular-cli/commands/easter-egg.ts b/packages/universal-cli/commands/easter-egg.ts similarity index 100% rename from packages/angular-cli/commands/easter-egg.ts rename to packages/universal-cli/commands/easter-egg.ts diff --git a/packages/angular-cli/commands/generate.ts b/packages/universal-cli/commands/generate.ts similarity index 91% rename from packages/angular-cli/commands/generate.ts rename to packages/universal-cli/commands/generate.ts index 8bc3a01aec89..09355515b21f 100644 --- a/packages/angular-cli/commands/generate.ts +++ b/packages/universal-cli/commands/generate.ts @@ -21,11 +21,12 @@ const GenerateCommand = EmberGenerateCommand.extend({ if (rawArgs[0] !== '--help' && !fs.existsSync(path.join(__dirname, '..', 'blueprints', rawArgs[0]))) { - SilentError.debugOrThrow('angular-cli/commands/generate', `Invalid blueprint: ${rawArgs[0]}`); + SilentError + .debugOrThrow('universal-cli/commands/generate', `Invalid blueprint: ${rawArgs[0]}`); } if (!rawArgs[1]) { - SilentError.debugOrThrow('angular-cli/commands/generate', + SilentError.debugOrThrow('universal-cli/commands/generate', `The \`ung generate ${rawArgs[0]}\` command requires a name to be specified.`); } diff --git a/packages/angular-cli/commands/get.ts b/packages/universal-cli/commands/get.ts similarity index 100% rename from packages/angular-cli/commands/get.ts rename to packages/universal-cli/commands/get.ts diff --git a/packages/angular-cli/commands/github-pages-deploy.ts b/packages/universal-cli/commands/github-pages-deploy.ts similarity index 100% rename from packages/angular-cli/commands/github-pages-deploy.ts rename to packages/universal-cli/commands/github-pages-deploy.ts diff --git a/packages/angular-cli/commands/help.ts b/packages/universal-cli/commands/help.ts similarity index 100% rename from packages/angular-cli/commands/help.ts rename to packages/universal-cli/commands/help.ts diff --git a/packages/angular-cli/commands/init.ts b/packages/universal-cli/commands/init.ts similarity index 77% rename from packages/angular-cli/commands/init.ts rename to packages/universal-cli/commands/init.ts index 1473f8fa58aa..e99a647dfcc6 100644 --- a/packages/angular-cli/commands/init.ts +++ b/packages/universal-cli/commands/init.ts @@ -11,25 +11,25 @@ const GitInit = require('../tasks/git-init'); const InitCommand: any = Command.extend({ name: 'init', - description: 'Creates a new angular-cli project in the current folder.', + description: 'Creates a new universal-cli project in the current folder.', aliases: ['i'], works: 'everywhere', availableOptions: [ - { name: 'dry-run', type: Boolean, default: false, aliases: ['d'] }, - { name: 'verbose', type: Boolean, default: false, aliases: ['v'] }, - { name: 'link-cli', type: Boolean, default: false, aliases: ['lc'] }, - { name: 'skip-npm', type: Boolean, default: false, aliases: ['sn'] }, - { name: 'skip-bower', type: Boolean, default: true, aliases: ['sb'] }, - { name: 'name', type: String, default: '', aliases: ['n'] }, - { name: 'source-dir', type: String, default: 'src', aliases: ['sd'] }, - { name: 'style', type: String, default: 'css' }, - { name: 'prefix', type: String, default: 'app', aliases: ['p'] }, - { name: 'mobile', type: Boolean, default: false }, - { name: 'universal', type: Boolean, default: false }, - { name: 'routing', type: Boolean, default: false }, - { name: 'inline-style', type: Boolean, default: false, aliases: ['is'] }, - { name: 'inline-template', type: Boolean, default: false, aliases: ['it'] } + {name: 'dry-run', type: Boolean, default: false, aliases: ['d']}, + {name: 'verbose', type: Boolean, default: false, aliases: ['v']}, + {name: 'link-cli', type: Boolean, default: false, aliases: ['lc']}, + {name: 'skip-npm', type: Boolean, default: false, aliases: ['sn']}, + {name: 'skip-bower', type: Boolean, default: true, aliases: ['sb']}, + {name: 'name', type: String, default: '', aliases: ['n']}, + {name: 'source-dir', type: String, default: 'src', aliases: ['sd']}, + {name: 'style', type: String, default: 'css'}, + {name: 'prefix', type: String, default: 'app', aliases: ['p']}, + {name: 'mobile', type: Boolean, default: false}, + {name: 'universal', type: Boolean, default: false}, + {name: 'routing', type: Boolean, default: false}, + {name: 'inline-style', type: Boolean, default: false, aliases: ['is']}, + {name: 'inline-template', type: Boolean, default: false, aliases: ['it']} ], anonymousOptions: [''], @@ -40,6 +40,13 @@ const InitCommand: any = Command.extend({ commandOptions.skipBower = true; } + this.project.addons = this.project.addons.filter((addon: any) => { + if (this.analytics.version === undefined) { + return true; + } + return addon.pkg.version === this.analytics.version; + }); + const installBlueprint = new this.tasks.InstallBlueprint({ ui: this.ui, analytics: this.analytics, diff --git a/packages/angular-cli/commands/lint.ts b/packages/universal-cli/commands/lint.ts similarity index 100% rename from packages/angular-cli/commands/lint.ts rename to packages/universal-cli/commands/lint.ts diff --git a/packages/angular-cli/commands/new.ts b/packages/universal-cli/commands/new.ts similarity index 100% rename from packages/angular-cli/commands/new.ts rename to packages/universal-cli/commands/new.ts diff --git a/packages/angular-cli/commands/serve.ts b/packages/universal-cli/commands/serve.ts similarity index 100% rename from packages/angular-cli/commands/serve.ts rename to packages/universal-cli/commands/serve.ts diff --git a/packages/angular-cli/commands/set.ts b/packages/universal-cli/commands/set.ts similarity index 100% rename from packages/angular-cli/commands/set.ts rename to packages/universal-cli/commands/set.ts diff --git a/packages/angular-cli/commands/test.ts b/packages/universal-cli/commands/test.ts similarity index 100% rename from packages/angular-cli/commands/test.ts rename to packages/universal-cli/commands/test.ts diff --git a/packages/angular-cli/commands/version.ts b/packages/universal-cli/commands/version.ts similarity index 96% rename from packages/angular-cli/commands/version.ts rename to packages/universal-cli/commands/version.ts index ae327dcbb2f1..2c8d1ead0022 100644 --- a/packages/angular-cli/commands/version.ts +++ b/packages/universal-cli/commands/version.ts @@ -4,7 +4,7 @@ import * as child_process from 'child_process'; const VersionCommand = Command.extend({ name: 'version', - description: 'outputs angular-cli version', + description: 'outputs universal-cli version', aliases: ['v', '--version', '-v'], works: 'everywhere', diff --git a/packages/angular-cli/custom-typings.d.ts b/packages/universal-cli/custom-typings.d.ts similarity index 100% rename from packages/angular-cli/custom-typings.d.ts rename to packages/universal-cli/custom-typings.d.ts diff --git a/packages/angular-cli/ember-cli/LICENSE.md b/packages/universal-cli/ember-cli/LICENSE.md similarity index 100% rename from packages/angular-cli/ember-cli/LICENSE.md rename to packages/universal-cli/ember-cli/LICENSE.md diff --git a/packages/angular-cli/ember-cli/lib/cli/cli.js b/packages/universal-cli/ember-cli/lib/cli/cli.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/cli/cli.js rename to packages/universal-cli/ember-cli/lib/cli/cli.js diff --git a/packages/angular-cli/ember-cli/lib/cli/index.js b/packages/universal-cli/ember-cli/lib/cli/index.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/cli/index.js rename to packages/universal-cli/ember-cli/lib/cli/index.js diff --git a/packages/angular-cli/ember-cli/lib/cli/lookup-command.js b/packages/universal-cli/ember-cli/lib/cli/lookup-command.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/cli/lookup-command.js rename to packages/universal-cli/ember-cli/lib/cli/lookup-command.js diff --git a/packages/angular-cli/ember-cli/lib/commands/generate.js b/packages/universal-cli/ember-cli/lib/commands/generate.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/commands/generate.js rename to packages/universal-cli/ember-cli/lib/commands/generate.js diff --git a/packages/angular-cli/ember-cli/lib/commands/test.js b/packages/universal-cli/ember-cli/lib/commands/test.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/commands/test.js rename to packages/universal-cli/ember-cli/lib/commands/test.js diff --git a/packages/angular-cli/ember-cli/lib/commands/unknown.js b/packages/universal-cli/ember-cli/lib/commands/unknown.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/commands/unknown.js rename to packages/universal-cli/ember-cli/lib/commands/unknown.js diff --git a/packages/angular-cli/ember-cli/lib/ext/core-object.js b/packages/universal-cli/ember-cli/lib/ext/core-object.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/ext/core-object.js rename to packages/universal-cli/ember-cli/lib/ext/core-object.js diff --git a/packages/angular-cli/ember-cli/lib/ext/promise.js b/packages/universal-cli/ember-cli/lib/ext/promise.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/ext/promise.js rename to packages/universal-cli/ember-cli/lib/ext/promise.js diff --git a/packages/angular-cli/ember-cli/lib/models/addon-discovery.js b/packages/universal-cli/ember-cli/lib/models/addon-discovery.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/models/addon-discovery.js rename to packages/universal-cli/ember-cli/lib/models/addon-discovery.js diff --git a/packages/angular-cli/ember-cli/lib/models/addon.js b/packages/universal-cli/ember-cli/lib/models/addon.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/models/addon.js rename to packages/universal-cli/ember-cli/lib/models/addon.js diff --git a/packages/angular-cli/ember-cli/lib/models/addons-factory.js b/packages/universal-cli/ember-cli/lib/models/addons-factory.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/models/addons-factory.js rename to packages/universal-cli/ember-cli/lib/models/addons-factory.js diff --git a/packages/universal-cli/ember-cli/lib/models/blueprint.js b/packages/universal-cli/ember-cli/lib/models/blueprint.js new file mode 100644 index 000000000000..9227a3a148e7 --- /dev/null +++ b/packages/universal-cli/ember-cli/lib/models/blueprint.js @@ -0,0 +1,1585 @@ +'use strict'; + +/** + @module ember-cli + */ +var FileInfo = require('./file-info'); +var Promise = require('../ext/promise'); +var chalk = require('chalk'); +var MarkdownColor = require('../utilities/markdown-color'); +var printableProperties = require('../utilities/printable-properties').blueprint; +var sequence = require('../utilities/sequence'); +var printCommand = require('../utilities/print-command'); +var fs = require('fs-extra'); +var existsSync = require('exists-sync'); +var inflector = require('inflection'); +var minimatch = require('minimatch'); +var path = require('path'); +var stat = Promise.denodeify(fs.stat); +var stringUtils = require('ember-cli-string-utils'); +var compact = require('lodash/compact'); +var intersect = require('lodash/intersection'); +var uniq = require('lodash/uniq'); +var zipObject = require('lodash/zipObject'); +var includes = require('lodash/includes'); +var any = require('lodash/some'); +var cloneDeep = require('lodash/cloneDeep'); +var keys = require('lodash/keys'); +var merge = require('lodash/merge'); +var values = require('lodash/values'); +var walkSync = require('walk-sync'); +var writeFile = Promise.denodeify(fs.outputFile); +var removeFile = Promise.denodeify(fs.remove); +var SilentError = require('silent-error'); +var CoreObject = require('../ext/core-object'); +var EOL = require('os').EOL; +var debug = require('debug')('ember-cli:blueprint'); +var normalizeEntityName = require('ember-cli-normalize-entity-name'); + +module.exports = Blueprint; + +/** + A blueprint is a bundle of template files with optional install + logic. + + Blueprints follow a simple structure. Let's take the built-in + `controller` blueprint as an example: + + ``` + blueprints/controller + ├── files + │ ├── app + │ │ └── __path__ + │ │ └── __name__.js + └── index.js + + blueprints/controller-test + ├── files + │ └── tests + │ └── unit + │ └── controllers + │ └── __test__.js + └── index.js + ``` + + ## Files + + `files` contains templates for the all the files to be + installed into the target directory. + + The `__name__` token is subtituted with the dasherized + entity name at install time. For example, when the user + invokes `ember generate controller foo` then `__name__` becomes + `foo`. When the `--pod` flag is used, for example `ember + generate controller foo --pod` then `__name__` becomes + `controller`. + + The `__path__` token is substituted with the blueprint + name at install time. For example, when the user invokes + `ember generate controller foo` then `__path__` becomes + `controller`. When the `--pod` flag is used, for example + `ember generate controller foo --pod` then `__path__` + becomes `foo` (or `/foo` if the + podModulePrefix is defined). This token is primarily for + pod support, and is only necessary if the blueprint can be + used in pod structure. If the blueprint does not require pod + support, simply use the blueprint name instead of the + `__path__` token. + + The `__test__` token is substituted with the dasherized + entity name and appended with `-test` at install time. + This token is primarily for pod support and only necessary + if the blueprint requires support for a pod structure. If + the blueprint does not require pod support, simply use the + `__name__` token instead. + + ## Template Variables (AKA Locals) + + Variables can be inserted into templates with + `<%= someVariableName %>`. + + For example, the built-in `util` blueprint + `files/app/utils/__name__.js` looks like this: + + ```js + export default function <%= camelizedModuleName %>() { + return true; + } + ``` + + `<%= camelizedModuleName %>` is replaced with the real + value at install time. + + The following template variables are provided by default: + + - `dasherizedPackageName` + - `classifiedPackageName` + - `dasherizedModuleName` + - `classifiedModuleName` + - `camelizedModuleName` + + `packageName` is the project name as found in the project's + `package.json`. + + `moduleName` is the name of the entity being generated. + + The mechanism for providing custom template variables is + described below. + + ## Index.js + + Custom installation and uninstallation behaviour can be added + by overriding the hooks documented below. `index.js` should + export a plain object, which will extend the prototype of the + `Blueprint` class. If needed, the original `Blueprint` prototype + can be accessed through the `_super` property. + + ```js + module.exports = { + locals: function(options) { + // Return custom template variables here. + return {}; + }, + + normalizeEntityName: function(entityName) { + // Normalize and validate entity name here. + return entityName; + }, + + fileMapTokens: function(options) ( + // Return custom tokens to be replaced in your files + return { + __token__: function(options){ + // logic to determine value goes here + return 'value'; + } + } + }, + + filesPath: function(options) { + return path.join(this.path, 'files'); + }, + + beforeInstall: function(options) {}, + afterInstall: function(options) {}, + beforeUninstall: function(options) {}, + afterUninstall: function(options) {} + + }; + ``` + + ## Blueprint Hooks + + As shown above, the following hooks are available to + blueprint authors: + + - `locals` + - `normalizeEntityName` + - `fileMapTokens` + - `filesPath` + - `beforeInstall` + - `afterInstall` + - `beforeUninstall` + - `afterUninstall` + + ### locals + + Use `locals` to add custom tempate variables. The method + receives one argument: `options`. Options is an object + containing general and entity-specific options. + + When the following is called on the command line: + + ```sh + ember generate controller foo --type=array --dry-run + ``` + + The object passed to `locals` looks like this: + + ```js + { + entity: { + name: 'foo', + options: { + type: 'array' + } + }, + dryRun: true + } + ``` + + This hook must return an object or a Promise which resolves to an object. + The resolved object will be merged with the aforementioned default locals. + + ### normalizeEntityName + + Use the `normalizeEntityName` hook to add custom normalization and + validation of the provided entity name. The default hook does not + make any changes to the entity name, but makes sure an entity name + is present and that it doesn't have a trailing slash. + + This hook receives the entity name as its first argument. The string + returned by this hook will be used as the new entity name. + + ### fileMapTokens + + Use `fileMapTokens` to add custom fileMap tokens for use + in the `mapFile` method. The hook must return an object in the + following pattern: + + ```js + { + __token__: function(options){ + // logic to determine value goes here + return 'value'; + } + } + ``` + + It will be merged with the default `fileMapTokens`, and can be used + to override any of the default tokens. + + Tokens are used in the files folder (see `files`), and get replaced with + values when the `mapFile` method is called. + + ### filesPath + + Use `filesPath` to define where the blueprint files to install are located. + This can be used to customize which set of files to install based on options + or environmental variables. It defaults to the `files` directory within the + blueprint's folder. + + ### beforeInstall & beforeUninstall + + Called before any of the template files are processed and receives + the the `options` and `locals` hashes as parameters. Typically used for + validating any additional command line options or for any asynchronous + setup that is needed. As an example, the `controller` blueprint validates + its `--type` option in this hook. If you need to run any asynchronous code, + wrap it in a promise and return that promise from these hooks. This will + ensure that your code is executed correctly. + + ### afterInstall & afterUninstall + + The `afterInstall` and `afterUninstall` hooks receives the same + arguments as `locals`. Use it to perform any custom work after the + files are processed. For example, the built-in `route` blueprint + uses these hooks to add and remove relevant route declarations in + `app/router.js`. + + ### Overriding Install + + If you don't want your blueprint to install the contents of + `files` you can override the `install` method. It receives the + same `options` object described above and must return a promise. + See the built-in `resource` blueprint for an example of this. + + @class Blueprint + @constructor + @extends CoreObject + @param {String} [blueprintPath] + */ +function Blueprint(blueprintPath) { + this.path = blueprintPath; + this.name = path.basename(blueprintPath); +} + +Blueprint.__proto__ = CoreObject; +Blueprint.prototype.constructor = Blueprint; + +Blueprint.prototype.availableOptions = []; +Blueprint.prototype.anonymousOptions = ['name']; + +/** + Hook to specify the path to the blueprint's files. By default this is + `path.join(this.path, 'files)`. + + @method filesPath + @param {Object} options + @return {String} Path to the blueprints files directory. + */ + +Blueprint.prototype.filesPath = function () { + return path.join(this.path, 'files'); +}; + +/** + Used to retrieve files for blueprint. The `file` param is an + optional string that is turned into a glob. + + @method files + @return {Array} Contents of the blueprint's files directory + */ +Blueprint.prototype.files = function () { + if (this._files) { + return this._files; + } + + var filesPath = this.filesPath(this.options); + if (existsSync(filesPath)) { + this._files = walkSync(filesPath); + } else { + this._files = []; + } + + return this._files; +}; + +/** + @method srcPath + @param {String} file + @return {String} Resolved path to the file + */ +Blueprint.prototype.srcPath = function (file) { + return path.resolve(this.filesPath(this.options), file); +}; + +/** + Hook for normalizing entity name + @method normalizeEntityName + @param {String} entityName + @return {null} + */ +Blueprint.prototype.normalizeEntityName = function (entityName) { + return normalizeEntityName(entityName); +}; + +/** + Write a status and message to the UI + @private + @method _writeStatusToUI + @param {Function} chalkColor + @param {String} keyword + @param {String} message + */ +Blueprint.prototype._writeStatusToUI = function (chalkColor, keyword, message) { + if (this.ui) { + this.ui.writeLine(' ' + chalkColor(keyword) + ' ' + message); + } +}; + +/** + @private + @method _writeFile + @param {Object} info + @return {Promise} + */ +Blueprint.prototype._writeFile = function (info) { + if (!this.dryRun) { + return writeFile(info.outputPath, info.render()); + } +}; + +/** + Actions lookup + @private + */ + +Blueprint.prototype._actions = { + write: function (info) { + this._writeStatusToUI(chalk.green, 'create', info.displayPath); + return this._writeFile(info); + }, + skip: function (info) { + var label = 'skip'; + + if (info.resolution === 'identical') { + label = 'identical'; + } + + this._writeStatusToUI(chalk.yellow, label, info.displayPath); + }, + + overwrite: function (info) { + this._writeStatusToUI(chalk.yellow, 'overwrite', info.displayPath); + return this._writeFile(info); + }, + + edit: function (info) { + this._writeStatusToUI(chalk.green, 'edited', info.displayPath); + }, + + remove: function (info) { + this._writeStatusToUI(chalk.red, 'remove', info.displayPath); + if (!this.dryRun) { + return removeFile(info.outputPath); + } + } +}; + +/** + Calls an action. + @private + @method _commit + @param {Object} result + @return {Promise} + @throws {Error} Action doesn't exist. + */ +Blueprint.prototype._commit = function (result) { + var action = this._actions[result.action]; + + if (action) { + return action.call(this, result); + } else { + throw new Error('Tried to call action \"' + result.action + '\" but it does not exist'); + } +}; + +/** + Prints warning for pod unsupported. + @private + @method _checkForPod + */ +Blueprint.prototype._checkForPod = function (verbose) { + if (!this.hasPathToken && this.pod && verbose) { + this.ui.writeLine(chalk.yellow('You specified the pod flag, but this' + + ' blueprint does not support pod structure. It will be generated with' + + ' the default structure.')); + } +}; + +/** + @private + @method _normalizeEntityName + @param {Object} entity + */ +Blueprint.prototype._normalizeEntityName = function (entity) { + if (entity) { + entity.name = this.normalizeEntityName(entity.name); + } +}; + +/** + @private + @method _checkInRepoAddonExists + @param {String} inRepoAddon + */ +Blueprint.prototype._checkInRepoAddonExists = function (inRepoAddon) { + if (inRepoAddon) { + if (!inRepoAddonExists(inRepoAddon, this.project.root)) { + throw new SilentError('You specified the in-repo-addon flag, but the' + + ' in-repo-addon \'' + inRepoAddon + '\' does not exist. Please' + + ' check the name and try again.'); + } + } +}; + +/** + @private + @method _process + @param {Object} options + @param {Function} beforeHook + @param {Function} process + @param {Function} afterHook + */ +Blueprint.prototype._process = function (options, beforeHook, process, afterHook) { + var self = this; + var intoDir = options.target; + + return this._locals(options).then(function (locals) { + return Promise.resolve() + .then(beforeHook.bind(self, options, locals)) + .then(process.bind(self, intoDir, locals)).map(self._commit.bind(self)) + .then(afterHook.bind(self, options)); + }); +}; + +/** + @method install + @param {Object} options + @return {Promise} + */ +Blueprint.prototype.install = function (options) { + var ui = this.ui = options.ui; + var dryRun = this.dryRun = options.dryRun; + this.project = options.project; + this.pod = options.pod; + this.options = options; + this.hasPathToken = hasPathToken(this.files()); + + podDeprecations(this.project.config(), ui); + + ui.writeLine('installing ' + this.name); + + if (dryRun) { + ui.writeLine(chalk.yellow('You specified the dry-run flag, so no' + + ' changes will be written.')); + } + + this._normalizeEntityName(options.entity); + this._checkForPod(options.verbose); + this._checkInRepoAddonExists(options.inRepoAddon); + + debug('START: processing blueprint: `%s`', this.name); + var start = new Date(); + return this._process( + options, + this.beforeInstall, + this.processFiles, + this.afterInstall).finally(function () { + debug('END: processing blueprint: `%s` in (%dms)', this.name, new Date() - start); + }.bind(this)); +}; + +/** + @method uninstall + @param {Object} options + @return {Promise} + */ +Blueprint.prototype.uninstall = function (options) { + var ui = this.ui = options.ui; + var dryRun = this.dryRun = options.dryRun; + this.project = options.project; + this.pod = options.pod; + this.options = options; + this.hasPathToken = hasPathToken(this.files()); + + podDeprecations(this.project.config(), ui); + + ui.writeLine('uninstalling ' + this.name); + + if (dryRun) { + ui.writeLine(chalk.yellow('You specified the dry-run flag, so no' + + ' files will be deleted.')); + } + + this._normalizeEntityName(options.entity); + this._checkForPod(options.verbose); + + return this._process( + options, + this.beforeUninstall, + this.processFilesForUninstall, + this.afterUninstall); +}; + +/** + Hook for running operations before install. + @method beforeInstall + @return {Promise|null} + */ +Blueprint.prototype.beforeInstall = function () { +}; + +/** + Hook for running operations after install. + @method afterInstall + @return {Promise|null} + */ +Blueprint.prototype.afterInstall = function () { +}; + +/** + Hook for running operations before uninstall. + @method beforeUninstall + @return {Promise|null} + */ +Blueprint.prototype.beforeUninstall = function () { +}; + +/** + Hook for running operations after uninstall. + @method afterUninstall + @return {Promise|null} + */ +Blueprint.prototype.afterUninstall = function () { +}; + +/** + Hook for adding additional locals + @method locals + @return {Object|null} + */ +Blueprint.prototype.locals = function () { +}; + +/** + Hook to add additional or override existing fileMapTokens. + @method fileMapTokens + @return {Object|null} + */ +Blueprint.prototype.fileMapTokens = function () { +}; + +/** + @private + @method _fileMapTokens + @param {Object} options + @return {Object} + */ +Blueprint.prototype._fileMapTokens = function (options) { + var standardTokens = { + __name__: function (options) { + if (options.pod && options.hasPathToken) { + return options.blueprintName; + } + return options.dasherizedModuleName; + }, + __path__: function (options) { + var blueprintName = options.blueprintName; + + if (blueprintName.match(/-test/)) { + blueprintName = options.blueprintName.slice(0, options.blueprintName.indexOf('-test')); + } + if (options.pod && options.hasPathToken) { + return path.join(options.podPath, options.dasherizedModuleName); + } + return inflector.pluralize(blueprintName); + }, + __root__: function (options) { + if (options.inRepoAddon) { + return path.join('lib', options.inRepoAddon, 'addon'); + } + if (options.inDummy) { + return path.join('tests', 'dummy', 'app'); + } + if (options.inAddon) { + return 'addon'; + } + return 'app'; + }, + __test__: function (options) { + if (options.pod && options.hasPathToken) { + return options.blueprintName; + } + return options.dasherizedModuleName + '-test'; + } + }; + + var customTokens = this.fileMapTokens(options) || options.fileMapTokens || {}; + return merge(standardTokens, customTokens); +}; + +/** + Used to generate fileMap tokens for mapFile. + + @method generateFileMap + @param {Object} fileMapVariables + @return {Object} + */ +Blueprint.prototype.generateFileMap = function (fileMapVariables) { + var tokens = this._fileMapTokens(fileMapVariables); + var fileMapValues = values(tokens); + var tokenValues = fileMapValues.map(function (token) { + return token(fileMapVariables); + }); + var tokenKeys = keys(tokens); + return zipObject(tokenKeys, tokenValues); +}; + +/** + @method buildFileInfo + @param {Function} destPath + @param {Object} templateVariables + @param {String} file + @return {FileInfo} + */ +Blueprint.prototype.buildFileInfo = function (destPath, templateVariables, file) { + var mappedPath = this.mapFile(file, templateVariables); + + return new FileInfo({ + action: 'write', + outputPath: destPath(mappedPath), + displayPath: path.normalize(mappedPath), + inputPath: this.srcPath(file), + templateVariables: templateVariables, + ui: this.ui + }); +}; + +/** + @method isUpdate + @return {Boolean} + */ +Blueprint.prototype.isUpdate = function () { + if (this.project && this.project.isEmberCLIProject) { + return this.project.isEmberCLIProject(); + } +}; + +/** + @private + @method _getFileInfos + @param {Array} files + @param {String} intoDir + @param {Object} templateVariables + @return {Array} file infos + */ +Blueprint.prototype._getFileInfos = function (files, intoDir, templateVariables) { + return files.map(this.buildFileInfo.bind(this, destPath.bind(null, intoDir), templateVariables)); +}; + +/** + Add update files to ignored files + @private + @method _ignoreUpdateFiles + */ +Blueprint.prototype._ignoreUpdateFiles = function () { + if (this.isUpdate()) { + Blueprint.ignoredFiles = Blueprint.ignoredFiles.concat(Blueprint.ignoredUpdateFiles); + } +}; + +/** + @private + @method _getFilesForInstall + @param {Array} targetFiles + @return {Array} files + */ +Blueprint.prototype._getFilesForInstall = function (targetFiles) { + var files = this.files(); + + // if we've defined targetFiles, get file info on ones that match + return targetFiles && targetFiles.length > 0 && intersect(files, targetFiles) || files; +}; + +/** + @private + @method _checkForNoMatch + @param {Array} fileInfos + @param {String} rawArgs + */ +Blueprint.prototype._checkForNoMatch = function (fileInfos, rawArgs) { + if (fileInfos.filter(isFilePath).length < 1 && rawArgs) { + this.ui.writeLine(chalk.yellow('The globPattern \"' + rawArgs + + '\" did not match any files, so no file updates will be made.')); + } +}; + +function finishProcessingForInstall(infos) { + infos.forEach(markIdenticalToBeSkipped); + + var infosNeedingConfirmation = infos.reduce(gatherConfirmationMessages, []); + + return sequence(infosNeedingConfirmation).returns(infos); +} + +function finishProcessingForUninstall(infos) { + infos.forEach(markToBeRemoved); + return infos; +} + +/** + @method processFiles + @param {String} intoDir + @param {Object} templateVariables + */ +Blueprint.prototype.processFiles = function (intoDir, templateVariables) { + var files = this._getFilesForInstall(templateVariables.targetFiles); + var fileInfos = this._getFileInfos(files, intoDir, templateVariables); + this._checkForNoMatch(fileInfos, templateVariables.rawArgs); + + this._ignoreUpdateFiles(); + + return Promise.filter(fileInfos, isValidFile).map(prepareConfirm).then(finishProcessingForInstall); +}; + +/** + @method processFilesForUninstall + @param {String} intoDir + @param {Object} templateVariables + */ +Blueprint.prototype.processFilesForUninstall = function (intoDir, templateVariables) { + var fileInfos = this._getFileInfos(this.files(), intoDir, templateVariables); + + this._ignoreUpdateFiles(); + + return Promise.filter(fileInfos, isValidFile).then(finishProcessingForUninstall); +}; + + +/** + @method mapFile + @param {String} file + @return {String} + */ +Blueprint.prototype.mapFile = function (file, locals) { + var pattern, i; + var fileMap = locals.fileMap || {__name__: locals.dasherizedModuleName}; + file = Blueprint.renamedFiles[file] || file; + for (i in fileMap) { + pattern = new RegExp(i, 'g'); + file = file.replace(pattern, fileMap[i]); + } + return file; +}; + +/** + Looks for a __root__ token in the files folder. Must be present for + the blueprint to support addon tokens. The `server`, `blueprints`, and `test` + + @private + @method supportsAddon + @return {Boolean} + */ +Blueprint.prototype.supportsAddon = function () { + return this.files().join().match(/__root__/); +}; + +/** + @private + @method _generateFileMapVariables + @param {Object} options + @return {Object} + */ +Blueprint.prototype._generateFileMapVariables = function (moduleName, locals, options) { + var originBlueprintName = options.originBlueprintName || this.name; + var podModulePrefix = this.project.config().podModulePrefix || ''; + var podPath = podModulePrefix.substr(podModulePrefix.lastIndexOf('/') + 1); + var inAddon = this.project.isEmberCLIAddon() || !!options.inRepoAddon; + var inDummy = this.project.isEmberCLIAddon() ? options.dummy : false; + + return { + pod: this.pod, + podPath: podPath, + hasPathToken: this.hasPathToken, + inAddon: inAddon, + inRepoAddon: options.inRepoAddon, + inDummy: inDummy, + blueprintName: this.name, + originBlueprintName: originBlueprintName, + dasherizedModuleName: stringUtils.dasherize(moduleName), + locals: locals + }; +}; + +/** + @private + @method _locals + @param {Object} options + @return {Object} + */ +Blueprint.prototype._locals = function (options) { + var packageName = options.project.name(); + var moduleName = options.entity && options.entity.name || packageName; + var sanitizedModuleName = moduleName.replace(/\//g, '-'); + + return new Promise(function (resolve) { + resolve(this.locals(options)); + }.bind(this)).then(function (customLocals) { + var fileMapVariables = this._generateFileMapVariables(moduleName, customLocals, options); + var fileMap = this.generateFileMap(fileMapVariables); + var standardLocals = { + dasherizedPackageName: stringUtils.dasherize(packageName), + classifiedPackageName: stringUtils.classify(packageName), + dasherizedModuleName: stringUtils.dasherize(moduleName), + classifiedModuleName: stringUtils.classify(sanitizedModuleName), + camelizedModuleName: stringUtils.camelize(sanitizedModuleName), + decamelizedModuleName: stringUtils.decamelize(sanitizedModuleName), + fileMap: fileMap, + hasPathToken: this.hasPathToken, + targetFiles: options.targetFiles, + rawArgs: options.rawArgs + }; + + return merge({}, standardLocals, customLocals); + }.bind(this)); +}; + +/** + Used to add a package to the project's `package.json`. + + Generally, this would be done from the `afterInstall` hook, to + ensure that a package that is required by a given blueprint is + available. + + @method addPackageToProject + @param {String} packageName + @param {String} target + @return {Promise} + */ +Blueprint.prototype.addPackageToProject = function (packageName, target) { + var packageObject = {name: packageName}; + + if (target) { + packageObject.target = target; + } + + return this.addPackagesToProject([packageObject]); +}; + +/** + Used to add multiple packages to the project's `package.json`. + + Generally, this would be done from the `afterInstall` hook, to + ensure that a package that is required by a given blueprint is + available. + + Expects each array item to be an object with a `name`. Each object + may optionally have a `target` to specify a specific version. + + @method addPackagesToProject + @param {Array} packages + @return {Promise} + */ +Blueprint.prototype.addPackagesToProject = function (packages) { + var task = this.taskFor('npm-install'); + var installText = (packages.length > 1) ? 'install packages' : 'install package'; + var packageNames = []; + var packageArray = []; + + for (var i = 0; i < packages.length; i++) { + packageNames.push(packages[i].name); + + var packageNameAndVersion = packages[i].name; + + if (packages[i].target) { + packageNameAndVersion += '@' + packages[i].target; + } + + packageArray.push(packageNameAndVersion); + } + + this._writeStatusToUI(chalk.green, installText, packageNames.join(', ')); + + return task.run({ + 'save-dev': true, + verbose: false, + packages: packageArray + }); +}; + +/** + Used to remove a package from the project's `package.json`. + + Generally, this would be done from the `afterInstall` hook, to + ensure that any package conflicts can be resolved before the + addon is used. + + @method removePackageFromProject + @param {String} packageName + @return {Promise} + */ +Blueprint.prototype.removePackageFromProject = function (packageName) { + var packageObject = {name: packageName}; + + return this.removePackagesFromProject([packageObject]); +}; + +/** + Used to remove multiple packages from the project's `package.json`. + + Generally, this would be done from the `afterInstall` hook, to + ensure that any package conflicts can be resolved before the + addon is used. + + Expects each array item to be an object with a `name` property. + + @method removePackagesFromProject + @param {Array} packages + @return {Promise} + */ +Blueprint.prototype.removePackagesFromProject = function (packages) { + var task = this.taskFor('npm-uninstall'); + var installText = (packages.length > 1) ? 'uninstall packages' : 'uninstall package'; + var packageNames = []; + var packageArray = []; + + for (var i = 0; i < packages.length; i++) { + packageNames.push(packages[i].name); + + var packageNameAndVersion = packages[i].name; + + packageArray.push(packageNameAndVersion); + } + + this._writeStatusToUI(chalk.green, installText, packageNames.join(', ')); + + return task.run({ + 'save-dev': true, + verbose: false, + packages: packageArray + }); +}; + +/** + Used to add a package to the projects `bower.json`. + + Generally, this would be done from the `afterInstall` hook, to + ensure that a package that is required by a given blueprint is + available. + + `localPackageName` and `target` may be thought of as equivalent + to the key-value pairs in the `dependency` or `devDepencency` + objects contained within a bower.json file. + + Examples: + + addBowerPackageToProject('jquery', '~1.11.1'); + addBowerPackageToProject('old_jquery', 'jquery#~1.9.1'); + addBowerPackageToProject('bootstrap-3', 'http://twitter.github.io/bootstrap/assets/bootstrap'); + + @method addBowerPackageToProject + @param {String} localPackageName + @param {String} target + @param {Object} installOptions + @return {Promise} + */ +Blueprint.prototype.addBowerPackageToProject = function (localPackageName, target, installOptions) { + // var lpn = localPackageName; + // var tar = target; + // if (localPackageName.indexOf('#') >= 0) { + // if (arguments.length === 1) { + // var parts = localPackageName.split('#'); + // lpn = parts[0]; + // tar = parts[1]; + // this.ui.writeDeprecateLine('passing ' + localPackageName + + // ' directly to `addBowerPackageToProject` will soon be unsupported. \n' + + // 'You may want to replace this with ' + + // '`addBowerPackageToProject(\'' + lpn + '\', \'' + tar + '\')`'); + // } else { + // this.ui.writeDeprecateLine('passing ' + localPackageName + + // ' directly to `addBowerPackageToProject` will soon be unsupported'); + // } + // } + // var packageObject = bowEpParser.json2decomposed(lpn, tar); + // return this.addBowerPackagesToProject([packageObject], installOptions); + return Promise.resolve(); +}; + +/** + Used to add an array of packages to the projects `bower.json`. + + Generally, this would be done from the `afterInstall` hook, to + ensure that a package that is required by a given blueprint is + available. + + Expects each array item to be an object with a `name`. Each object + may optionally have a `target` to specify a specific version. + + @method addBowerPackagesToProject + @param {Array} packages + @param {Object} installOptions + @return {Promise} + */ +Blueprint.prototype.addBowerPackagesToProject = function (packages, installOptions) { + var task = this.taskFor('bower-install'); + var installText = (packages.length > 1) ? 'install bower packages' : 'install bower package'; + var packageNames = []; + var packageNamesAndVersions = packages.map(function (pkg) { + pkg.source = pkg.source || pkg.name; + packageNames.push(pkg.name); + return pkg; + }).map(bowEpParser.compose); + + this._writeStatusToUI(chalk.green, installText, packageNames.join(', ')); + + return task.run({ + verbose: true, + packages: packageNamesAndVersions, + installOptions: installOptions + }); +}; + +/** + Used to retrieve a task with the given name. Passes the new task + the standard information available (like `ui`, `analytics`, `project`, etc). + + @method taskFor + @param dasherizedName + @public + */ +Blueprint.prototype.taskFor = function (dasherizedName) { + var Task = require('../tasks/' + dasherizedName); + + return new Task({ + ui: this.ui, + project: this.project, + analytics: this.analytics + }); +}; + +/* + + Inserts the given content into a file. If the `contentsToInsert` string is already + present in the current contents, the file will not be changed unless `force` option + is passed. + + If `options.before` is specified, `contentsToInsert` will be inserted before + the first instance of that string. If `options.after` is specified, the + contents will be inserted after the first instance of that string. + If the string specified by options.before or options.after is not in the file, + no change will be made. + + If neither `options.before` nor `options.after` are present, `contentsToInsert` + will be inserted at the end of the file. + + Example: + ``` + // app/router.js + Router.map(function() { + }); + + insertIntoFile('app/router.js', + ' this.route("admin");', + {after:'Router.map(function() {'+EOL}); + + // new app/router.js + Router.map(function() { + this.route("admin"); + }); + ``` + + @method insertIntoFile + @param {String} pathRelativeToProjectRoot + @param {String} contentsToInsert + @param {Object} options + @return {Promise} + */ +Blueprint.prototype.insertIntoFile = function (pathRelativeToProjectRoot, contentsToInsert, providedOptions) { + var fullPath = path.join(this.project.root, pathRelativeToProjectRoot); + var originalContents = ''; + + if (existsSync(fullPath)) { + originalContents = fs.readFileSync(fullPath, {encoding: 'utf8'}); + } + + var contentsToWrite = originalContents; + + var options = providedOptions || {}; + var alreadyPresent = originalContents.indexOf(contentsToInsert) > -1; + var insert = !alreadyPresent; + var insertBehavior = 'end'; + + if (options.before) { + insertBehavior = 'before'; + } + if (options.after) { + insertBehavior = 'after'; + } + + if (options.force) { + insert = true; + } + + if (insert) { + if (insertBehavior === 'end') { + contentsToWrite += contentsToInsert; + } else { + var contentMarker = options[insertBehavior]; + var contentMarkerIndex = contentsToWrite.indexOf(contentMarker); + + if (contentMarkerIndex !== -1) { + var insertIndex = contentMarkerIndex; + if (insertBehavior === 'after') { + insertIndex += contentMarker.length; + } + + contentsToWrite = contentsToWrite.slice(0, insertIndex) + + contentsToInsert + EOL + + contentsToWrite.slice(insertIndex); + } + } + } + + var returnValue = { + path: fullPath, + originalContents: originalContents, + contents: contentsToWrite, + inserted: false + }; + + if (contentsToWrite !== originalContents) { + returnValue.inserted = true; + + return writeFile(fullPath, contentsToWrite) + .then(function () { + return returnValue; + }); + } else { + return Promise.resolve(returnValue); + } +}; + +Blueprint.prototype._printCommand = printCommand; + +Blueprint.prototype.printBasicHelp = function (verbose) { + var initialMargin = ' '; + var output = initialMargin; + if (this.overridden) { + output += chalk.grey('(overridden) ' + this.name); + } else { + output += this.name; + + output += this._printCommand(initialMargin, true); + + if (verbose) { + output += EOL + this.printDetailedHelp(this.availableOptions); + } + } + + return output; +}; + +Blueprint.prototype.printDetailedHelp = function () { + var markdownColor = new MarkdownColor(); + var filePath = getDetailedHelpPath(this.path); + + if (existsSync(filePath)) { + return markdownColor.renderFile(filePath, {indent: ' '}); + } + return ''; +}; + +Blueprint.prototype.getJson = function (verbose) { + var json = {}; + + printableProperties.forEachWithProperty(function (key) { + var value = this[key]; + if (key === 'availableOptions') { + value = cloneDeep(value); + value.forEach(function (option) { + if (typeof option.type === 'function') { + option.type = option.type.name; + } + }); + } + json[key] = value; + }, this); + + if (verbose) { + var detailedHelp = this.printDetailedHelp(this.availableOptions); + if (detailedHelp) { + json.detailedHelp = detailedHelp; + } + } + + return json; +}; + +/** + Used to retrieve a blueprint with the given name. + + @method lookupBlueprint + @param dasherizedName + @public + */ +Blueprint.prototype.lookupBlueprint = function (dasherizedName) { + var projectPaths = this.project ? this.project.blueprintLookupPaths() : []; + + return Blueprint.lookup(dasherizedName, { + paths: projectPaths + }); +}; + +/** + @static + @method lookup + @namespace Blueprint + @param {String} [name] + @param {Object} [options] + @param {Array} [options.paths] Extra paths to search for blueprints + @param {Object} [options.properties] Properties + @return {Blueprint} + */ +Blueprint.lookup = function (name, options) { + options = options || {}; + + var lookupPaths = generateLookupPaths(options.paths); + + var lookupPath; + var blueprintPath; + + for (var i = 0; (lookupPath = lookupPaths[i]); i++) { + blueprintPath = path.resolve(lookupPath, name); + + if (existsSync(blueprintPath)) { + return Blueprint.load(blueprintPath); + } + } + + if (!options.ignoreMissing) { + throw new SilentError('Unknown blueprint: ' + name); + } +}; + +/** + Loads a blueprint from given path. + @static + @method load + @namespace Blueprint + @param {String} blueprintPath + @return {Blueprint} blueprint instance + */ +Blueprint.load = function (blueprintPath) { + var constructorPath = path.resolve(blueprintPath, 'index.js'); + var blueprintModule; + var Constructor = Blueprint; + + if (fs.lstatSync(blueprintPath).isDirectory()) { + + if (existsSync(constructorPath)) { + blueprintModule = require(constructorPath); + + if (typeof blueprintModule === 'function') { + Constructor = blueprintModule; + } else { + Constructor = Blueprint.extend(blueprintModule); + } + } + + return new Constructor(blueprintPath); + } + + return; +}; + +/** + @static + @method list + @namespace Blueprint + @param {Object} [options] + @param {Array} [options.paths] Extra paths to search for blueprints + @return {Blueprint} + */ +Blueprint.list = function (options) { + options = options || {}; + + var lookupPaths = generateLookupPaths(options.paths); + var seen = []; + + return lookupPaths.map(function (lookupPath) { + var blueprints = dir(lookupPath); + var packagePath = path.join(lookupPath, '../package.json'); + var source; + + if (existsSync(packagePath)) { + source = require(packagePath).name; + } else { + source = path.basename(path.join(lookupPath, '..')); + } + + blueprints = blueprints.map(function (blueprintPath) { + var blueprint = Blueprint.load(blueprintPath); + var name; + + if (blueprint) { + name = blueprint.name; + blueprint.overridden = includes(seen, name); + seen.push(name); + + return blueprint; + } + + return; + }); + + return { + source: source, + blueprints: compact(blueprints) + }; + }); +}; + +/** + @static + @property renameFiles + */ +Blueprint.renamedFiles = { + 'gitignore': '.gitignore' +}; + +/** + @static + @property ignoredFiles + */ +Blueprint.ignoredFiles = [ + '.DS_Store' +]; + +/** + @static + @property ignoredUpdateFiles + */ +Blueprint.ignoredUpdateFiles = [ + '.gitkeep', + 'app.css' +]; + +/** + @static + @property defaultLookupPaths + */ +Blueprint.defaultLookupPaths = function () { + return [ + path.resolve(__dirname, '..', '..', 'blueprints') + ]; +}; + +/** + @private + @method prepareConfirm + @param {FileInfo} info + @return {Promise} + */ +function prepareConfirm(info) { + return info.checkForConflict().then(function (resolution) { + info.resolution = resolution; + return info; + }); +} + +/** + @private + @method markIdenticalToBeSkipped + @param {FileInfo} info + */ +function markIdenticalToBeSkipped(info) { + if (info.resolution === 'identical') { + info.action = 'skip'; + } +} + +/** + @private + @method markToBeRemoved + @param {FileInfo} info + */ +function markToBeRemoved(info) { + info.action = 'remove'; +} + +/** + @private + @method gatherConfirmationMessages + @param {Array} collection + @param {FileInfo} info + @return {Array} + */ +function gatherConfirmationMessages(collection, info) { + if (info.resolution === 'confirm') { + collection.push(info.confirmOverwriteTask()); + } + return collection; +} + +/** + @private + @method isFile + @param {FileInfo} info + @return {Boolean} + */ +function isFile(info) { + return stat(info.inputPath).invoke('isFile'); +} + +/** + @private + @method isIgnored + @param {FileInfo} info + @return {Boolean} + */ +function isIgnored(info) { + var fn = info.inputPath; + + return any(Blueprint.ignoredFiles, function (ignoredFile) { + return minimatch(fn, ignoredFile, {matchBase: true}); + }); +} + +/** + Combines provided lookup paths with defaults and removes + duplicates. + + @private + @method generateLookupPaths + @param {Array} lookupPaths + @return {Array} + */ +function generateLookupPaths(lookupPaths) { + lookupPaths = lookupPaths || []; + lookupPaths = lookupPaths.concat(Blueprint.defaultLookupPaths()); + return uniq(lookupPaths); +} + +/** + Looks for a __path__ token in the files folder. Must be present for + the blueprint to support pod tokens. + + @private + @method hasPathToken + @param {files} files + @return {Boolean} + */ +function hasPathToken(files) { + return files.join().match(/__path__/); +} + +function inRepoAddonExists(name, root) { + var addonPath = path.join(root, 'lib', name); + return existsSync(addonPath); +} + +function podDeprecations(config, ui) { + /* + var podModulePrefix = config.podModulePrefix || ''; + var podPath = podModulePrefix.substr(podModulePrefix.lastIndexOf('/') + 1); + // Disabled until we are ready to deprecate podModulePrefix + deprecateUI(ui)('`podModulePrefix` is deprecated and will be removed from future versions of ember-cli.'+ + ' Please move existing pods from \'app/' + podPath + '/\' to \'app/\'.', config.podModulePrefix); + */ + if (config.usePodsByDefault) { + ui.writeDeprecateLine('`usePodsByDefault` is no longer supported in \'config/environment.js\',' + + ' use `usePods` in \'.ember-cli\' instead.'); + } +} + +/** + @private + @method destPath + @param {String} intoDir + @param {String} file + @return {String} new path + */ +function destPath(intoDir, file) { + return path.join(intoDir, file); +} + +/** + @private + @method isValidFile + @param {Object} fileInfo + @return {Promise} + */ +function isValidFile(fileInfo) { + if (isIgnored(fileInfo)) { + return Promise.resolve(false); + } else { + return isFile(fileInfo); + } +} + +/** + @private + @method isFilePath + @param {Object} fileInfo + @return {Promise} + */ +function isFilePath(fileInfo) { + return fs.statSync(fileInfo.inputPath).isFile(); +} + +/** + @private + @method dir + @returns {Array} list of files in the given directory or and empty array if no directory exists + */ +function dir(fullPath) { + if (existsSync(fullPath)) { + return fs.readdirSync(fullPath).map(function (fileName) { + return path.join(fullPath, fileName); + }); + } else { + return []; + } +} + +/** + @private + @method getDetailedHelpPath + @param {String} thisPath + @return {String} help path + */ +function getDetailedHelpPath(thisPath) { + return path.join(thisPath, './HELP.md'); +} diff --git a/packages/angular-cli/ember-cli/lib/models/command.js b/packages/universal-cli/ember-cli/lib/models/command.js similarity index 99% rename from packages/angular-cli/ember-cli/lib/models/command.js rename to packages/universal-cli/ember-cli/lib/models/command.js index ea960753c3d9..af2d8478dc7f 100644 --- a/packages/angular-cli/ember-cli/lib/models/command.js +++ b/packages/universal-cli/ember-cli/lib/models/command.js @@ -293,7 +293,7 @@ Command.prototype.parseAlias = function(option, alias) { try { aliasValue = JSON.parse(alias); } catch (e) { - var debug = require('debug')('angular-cli/ember-cli/models/command'); + var debug = require('debug')('universal-cli/ember-cli/models/command'); debug(e); } } diff --git a/packages/angular-cli/ember-cli/lib/models/edit-file-diff.js b/packages/universal-cli/ember-cli/lib/models/edit-file-diff.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/models/edit-file-diff.js rename to packages/universal-cli/ember-cli/lib/models/edit-file-diff.js diff --git a/packages/angular-cli/ember-cli/lib/models/file-info.js b/packages/universal-cli/ember-cli/lib/models/file-info.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/models/file-info.js rename to packages/universal-cli/ember-cli/lib/models/file-info.js diff --git a/packages/angular-cli/ember-cli/lib/models/installation-checker.js b/packages/universal-cli/ember-cli/lib/models/installation-checker.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/models/installation-checker.js rename to packages/universal-cli/ember-cli/lib/models/installation-checker.js diff --git a/packages/angular-cli/ember-cli/lib/models/project.js b/packages/universal-cli/ember-cli/lib/models/project.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/models/project.js rename to packages/universal-cli/ember-cli/lib/models/project.js diff --git a/packages/angular-cli/ember-cli/lib/models/task.js b/packages/universal-cli/ember-cli/lib/models/task.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/models/task.js rename to packages/universal-cli/ember-cli/lib/models/task.js diff --git a/packages/angular-cli/ember-cli/lib/models/update-checker.js b/packages/universal-cli/ember-cli/lib/models/update-checker.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/models/update-checker.js rename to packages/universal-cli/ember-cli/lib/models/update-checker.js diff --git a/packages/angular-cli/ember-cli/lib/models/watcher.js b/packages/universal-cli/ember-cli/lib/models/watcher.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/models/watcher.js rename to packages/universal-cli/ember-cli/lib/models/watcher.js diff --git a/packages/angular-cli/ember-cli/lib/tasks/create-and-step-into-directory.js b/packages/universal-cli/ember-cli/lib/tasks/create-and-step-into-directory.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/tasks/create-and-step-into-directory.js rename to packages/universal-cli/ember-cli/lib/tasks/create-and-step-into-directory.js diff --git a/packages/angular-cli/ember-cli/lib/tasks/destroy-from-blueprint.js b/packages/universal-cli/ember-cli/lib/tasks/destroy-from-blueprint.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/tasks/destroy-from-blueprint.js rename to packages/universal-cli/ember-cli/lib/tasks/destroy-from-blueprint.js diff --git a/packages/angular-cli/ember-cli/lib/tasks/generate-from-blueprint.js b/packages/universal-cli/ember-cli/lib/tasks/generate-from-blueprint.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/tasks/generate-from-blueprint.js rename to packages/universal-cli/ember-cli/lib/tasks/generate-from-blueprint.js diff --git a/packages/angular-cli/ember-cli/lib/tasks/git-init.js b/packages/universal-cli/ember-cli/lib/tasks/git-init.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/tasks/git-init.js rename to packages/universal-cli/ember-cli/lib/tasks/git-init.js diff --git a/packages/angular-cli/ember-cli/lib/tasks/install-blueprint.js b/packages/universal-cli/ember-cli/lib/tasks/install-blueprint.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/tasks/install-blueprint.js rename to packages/universal-cli/ember-cli/lib/tasks/install-blueprint.js diff --git a/packages/angular-cli/ember-cli/lib/tasks/npm-install.js b/packages/universal-cli/ember-cli/lib/tasks/npm-install.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/tasks/npm-install.js rename to packages/universal-cli/ember-cli/lib/tasks/npm-install.js diff --git a/packages/angular-cli/ember-cli/lib/tasks/npm-task.js b/packages/universal-cli/ember-cli/lib/tasks/npm-task.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/tasks/npm-task.js rename to packages/universal-cli/ember-cli/lib/tasks/npm-task.js diff --git a/packages/angular-cli/ember-cli/lib/tasks/npm-uninstall.js b/packages/universal-cli/ember-cli/lib/tasks/npm-uninstall.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/tasks/npm-uninstall.js rename to packages/universal-cli/ember-cli/lib/tasks/npm-uninstall.js diff --git a/packages/angular-cli/ember-cli/lib/tasks/update.js b/packages/universal-cli/ember-cli/lib/tasks/update.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/tasks/update.js rename to packages/universal-cli/ember-cli/lib/tasks/update.js diff --git a/packages/angular-cli/ember-cli/lib/ui/index.js b/packages/universal-cli/ember-cli/lib/ui/index.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/ui/index.js rename to packages/universal-cli/ember-cli/lib/ui/index.js diff --git a/packages/angular-cli/ember-cli/lib/ui/write-error.js b/packages/universal-cli/ember-cli/lib/ui/write-error.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/ui/write-error.js rename to packages/universal-cli/ember-cli/lib/ui/write-error.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/COMMIT_MESSAGE.txt b/packages/universal-cli/ember-cli/lib/utilities/COMMIT_MESSAGE.txt similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/COMMIT_MESSAGE.txt rename to packages/universal-cli/ember-cli/lib/utilities/COMMIT_MESSAGE.txt diff --git a/packages/angular-cli/ember-cli/lib/utilities/DAG.js b/packages/universal-cli/ember-cli/lib/utilities/DAG.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/DAG.js rename to packages/universal-cli/ember-cli/lib/utilities/DAG.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/attempt-never-index.js b/packages/universal-cli/ember-cli/lib/utilities/attempt-never-index.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/attempt-never-index.js rename to packages/universal-cli/ember-cli/lib/utilities/attempt-never-index.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/deprecate.js b/packages/universal-cli/ember-cli/lib/utilities/deprecate.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/deprecate.js rename to packages/universal-cli/ember-cli/lib/utilities/deprecate.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/doc-generator.js b/packages/universal-cli/ember-cli/lib/utilities/doc-generator.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/doc-generator.js rename to packages/universal-cli/ember-cli/lib/utilities/doc-generator.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/find-build-file.js b/packages/universal-cli/ember-cli/lib/utilities/find-build-file.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/find-build-file.js rename to packages/universal-cli/ember-cli/lib/utilities/find-build-file.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/get-option-args.js b/packages/universal-cli/ember-cli/lib/utilities/get-option-args.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/get-option-args.js rename to packages/universal-cli/ember-cli/lib/utilities/get-option-args.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/get-package-base-name.js b/packages/universal-cli/ember-cli/lib/utilities/get-package-base-name.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/get-package-base-name.js rename to packages/universal-cli/ember-cli/lib/utilities/get-package-base-name.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/json-generator.js b/packages/universal-cli/ember-cli/lib/utilities/json-generator.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/json-generator.js rename to packages/universal-cli/ember-cli/lib/utilities/json-generator.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/markdown-color.js b/packages/universal-cli/ember-cli/lib/utilities/markdown-color.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/markdown-color.js rename to packages/universal-cli/ember-cli/lib/utilities/markdown-color.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/merge-blueprint-options.js b/packages/universal-cli/ember-cli/lib/utilities/merge-blueprint-options.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/merge-blueprint-options.js rename to packages/universal-cli/ember-cli/lib/utilities/merge-blueprint-options.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/mk-tmp-dir-in.js b/packages/universal-cli/ember-cli/lib/utilities/mk-tmp-dir-in.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/mk-tmp-dir-in.js rename to packages/universal-cli/ember-cli/lib/utilities/mk-tmp-dir-in.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/normalize-blueprint-option.js b/packages/universal-cli/ember-cli/lib/utilities/normalize-blueprint-option.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/normalize-blueprint-option.js rename to packages/universal-cli/ember-cli/lib/utilities/normalize-blueprint-option.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/npm.js b/packages/universal-cli/ember-cli/lib/utilities/npm.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/npm.js rename to packages/universal-cli/ember-cli/lib/utilities/npm.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/open-editor.js b/packages/universal-cli/ember-cli/lib/utilities/open-editor.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/open-editor.js rename to packages/universal-cli/ember-cli/lib/utilities/open-editor.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/parse-options.js b/packages/universal-cli/ember-cli/lib/utilities/parse-options.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/parse-options.js rename to packages/universal-cli/ember-cli/lib/utilities/parse-options.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/path.js b/packages/universal-cli/ember-cli/lib/utilities/path.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/path.js rename to packages/universal-cli/ember-cli/lib/utilities/path.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/platform-checker.js b/packages/universal-cli/ember-cli/lib/utilities/platform-checker.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/platform-checker.js rename to packages/universal-cli/ember-cli/lib/utilities/platform-checker.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/print-command.js b/packages/universal-cli/ember-cli/lib/utilities/print-command.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/print-command.js rename to packages/universal-cli/ember-cli/lib/utilities/print-command.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/printable-properties.js b/packages/universal-cli/ember-cli/lib/utilities/printable-properties.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/printable-properties.js rename to packages/universal-cli/ember-cli/lib/utilities/printable-properties.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/require-as-hash.js b/packages/universal-cli/ember-cli/lib/utilities/require-as-hash.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/require-as-hash.js rename to packages/universal-cli/ember-cli/lib/utilities/require-as-hash.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/require-local.js b/packages/universal-cli/ember-cli/lib/utilities/require-local.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/require-local.js rename to packages/universal-cli/ember-cli/lib/utilities/require-local.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/root-command.js b/packages/universal-cli/ember-cli/lib/utilities/root-command.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/root-command.js rename to packages/universal-cli/ember-cli/lib/utilities/root-command.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/sequence.js b/packages/universal-cli/ember-cli/lib/utilities/sequence.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/sequence.js rename to packages/universal-cli/ember-cli/lib/utilities/sequence.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/valid-project-name.js b/packages/universal-cli/ember-cli/lib/utilities/valid-project-name.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/valid-project-name.js rename to packages/universal-cli/ember-cli/lib/utilities/valid-project-name.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/version-utils.js b/packages/universal-cli/ember-cli/lib/utilities/version-utils.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/version-utils.js rename to packages/universal-cli/ember-cli/lib/utilities/version-utils.js diff --git a/packages/angular-cli/ember-cli/lib/utilities/windows-admin.js b/packages/universal-cli/ember-cli/lib/utilities/windows-admin.js similarity index 100% rename from packages/angular-cli/ember-cli/lib/utilities/windows-admin.js rename to packages/universal-cli/ember-cli/lib/utilities/windows-admin.js diff --git a/packages/angular-cli/lib/cli/index.js b/packages/universal-cli/lib/cli/index.js similarity index 92% rename from packages/angular-cli/lib/cli/index.js rename to packages/universal-cli/lib/cli/index.js index eac23e44caed..cc93732f6a3f 100644 --- a/packages/angular-cli/lib/cli/index.js +++ b/packages/universal-cli/lib/cli/index.js @@ -10,7 +10,7 @@ Error.stackTraceLimit = Infinity; module.exports = function(options) { - // patch UI to not print Ember-CLI warnings (which don't apply to Angular-CLI) + // patch UI to not print Ember-CLI warnings (which don't apply to Universal-CLI) UI.prototype.writeWarnLine = function () { } // patch Watcher to always default to node, not checking for Watchman @@ -27,7 +27,7 @@ module.exports = function(options) { // don't replace 'ember-cli-live-reload' on ung init diffs return oldStdoutWrite.apply(process.stdout, arguments); } - line = line.replace(/ember-cli(?!.com)/g, 'angular-cli') + line = line.replace(/ember-cli(?!.com)/g, 'universal-cli') .replace(/\bember\b(?!-cli.com)/g, 'ung'); return oldStdoutWrite.apply(process.stdout, arguments); }; @@ -35,7 +35,7 @@ module.exports = function(options) { const oldStderrWrite = process.stderr.write; process.stderr.write = function (line) { line = line.toString() - .replace(/ember-cli(?!.com)/g, 'angular-cli') + .replace(/ember-cli(?!.com)/g, 'universal-cli') .replace(/\bember\b(?!-cli.com)/g, 'ung'); return oldStderrWrite.apply(process.stdout, arguments); }; diff --git a/packages/angular-cli/lib/config/schema.d.ts b/packages/universal-cli/lib/config/schema.d.ts similarity index 100% rename from packages/angular-cli/lib/config/schema.d.ts rename to packages/universal-cli/lib/config/schema.d.ts diff --git a/packages/angular-cli/lib/config/schema.json b/packages/universal-cli/lib/config/schema.json similarity index 100% rename from packages/angular-cli/lib/config/schema.json rename to packages/universal-cli/lib/config/schema.json diff --git a/packages/angular-cli/models/config.ts b/packages/universal-cli/models/config.ts similarity index 95% rename from packages/angular-cli/models/config.ts rename to packages/universal-cli/models/config.ts index f98e113f070a..dc5a8a6b602c 100644 --- a/packages/angular-cli/models/config.ts +++ b/packages/universal-cli/models/config.ts @@ -30,7 +30,7 @@ function getUserHome() { export class CliConfig extends CliConfigBase { static configFilePath(projectPath?: string): string { - // Find the configuration, either where specified, in the angular-cli project + // Find the configuration, either where specified, in the universal-cli project // (if it's in node_modules) or from the current process. return (projectPath && _findUp(CLI_CONFIG_FILE_NAME, projectPath)) || _findUp(CLI_CONFIG_FILE_NAME, process.cwd()) @@ -59,7 +59,7 @@ export class CliConfig extends CliConfigBase { console.error(chalk.yellow(oneLine` The "defaults.prefix" and "defaults.sourceDir" properties of angular-cli.json are deprecated in favor of "apps[0].root" and "apps[0].prefix".\n - Please update in order to avoid errors in future versions of angular-cli. + Please update in order to avoid errors in future versions of universal-cli. `)); } diff --git a/packages/angular-cli/models/config/config.ts b/packages/universal-cli/models/config/config.ts similarity index 100% rename from packages/angular-cli/models/config/config.ts rename to packages/universal-cli/models/config/config.ts diff --git a/packages/angular-cli/models/error.ts b/packages/universal-cli/models/error.ts similarity index 100% rename from packages/angular-cli/models/error.ts rename to packages/universal-cli/models/error.ts diff --git a/packages/angular-cli/models/find-lazy-modules.ts b/packages/universal-cli/models/find-lazy-modules.ts similarity index 100% rename from packages/angular-cli/models/find-lazy-modules.ts rename to packages/universal-cli/models/find-lazy-modules.ts diff --git a/packages/angular-cli/models/index.ts b/packages/universal-cli/models/index.ts similarity index 100% rename from packages/angular-cli/models/index.ts rename to packages/universal-cli/models/index.ts diff --git a/packages/angular-cli/models/json-schema/schema-class-factory.ts b/packages/universal-cli/models/json-schema/schema-class-factory.ts similarity index 100% rename from packages/angular-cli/models/json-schema/schema-class-factory.ts rename to packages/universal-cli/models/json-schema/schema-class-factory.ts diff --git a/packages/angular-cli/models/json-schema/schema-tree.ts b/packages/universal-cli/models/json-schema/schema-tree.ts similarity index 100% rename from packages/angular-cli/models/json-schema/schema-tree.ts rename to packages/universal-cli/models/json-schema/schema-tree.ts diff --git a/packages/angular-cli/models/json-schema/serializer.ts b/packages/universal-cli/models/json-schema/serializer.ts similarity index 100% rename from packages/angular-cli/models/json-schema/serializer.ts rename to packages/universal-cli/models/json-schema/serializer.ts diff --git a/packages/angular-cli/models/webpack-build-common.ts b/packages/universal-cli/models/webpack-build-common.ts similarity index 100% rename from packages/angular-cli/models/webpack-build-common.ts rename to packages/universal-cli/models/webpack-build-common.ts diff --git a/packages/angular-cli/models/webpack-build-development.ts b/packages/universal-cli/models/webpack-build-development.ts similarity index 100% rename from packages/angular-cli/models/webpack-build-development.ts rename to packages/universal-cli/models/webpack-build-development.ts diff --git a/packages/angular-cli/models/webpack-build-mobile.ts b/packages/universal-cli/models/webpack-build-mobile.ts similarity index 100% rename from packages/angular-cli/models/webpack-build-mobile.ts rename to packages/universal-cli/models/webpack-build-mobile.ts diff --git a/packages/angular-cli/models/webpack-build-node.ts b/packages/universal-cli/models/webpack-build-node.ts similarity index 100% rename from packages/angular-cli/models/webpack-build-node.ts rename to packages/universal-cli/models/webpack-build-node.ts diff --git a/packages/angular-cli/models/webpack-build-production.ts b/packages/universal-cli/models/webpack-build-production.ts similarity index 100% rename from packages/angular-cli/models/webpack-build-production.ts rename to packages/universal-cli/models/webpack-build-production.ts diff --git a/packages/angular-cli/models/webpack-build-test.js b/packages/universal-cli/models/webpack-build-test.js similarity index 100% rename from packages/angular-cli/models/webpack-build-test.js rename to packages/universal-cli/models/webpack-build-test.js diff --git a/packages/angular-cli/models/webpack-build-typescript.ts b/packages/universal-cli/models/webpack-build-typescript.ts similarity index 100% rename from packages/angular-cli/models/webpack-build-typescript.ts rename to packages/universal-cli/models/webpack-build-typescript.ts diff --git a/packages/angular-cli/models/webpack-build-utils.ts b/packages/universal-cli/models/webpack-build-utils.ts similarity index 100% rename from packages/angular-cli/models/webpack-build-utils.ts rename to packages/universal-cli/models/webpack-build-utils.ts diff --git a/packages/angular-cli/models/webpack-config.ts b/packages/universal-cli/models/webpack-config.ts similarity index 100% rename from packages/angular-cli/models/webpack-config.ts rename to packages/universal-cli/models/webpack-config.ts diff --git a/packages/angular-cli/package.json b/packages/universal-cli/package.json similarity index 94% rename from packages/angular-cli/package.json rename to packages/universal-cli/package.json index 5cbf6abb5ab7..77185eecd229 100644 --- a/packages/angular-cli/package.json +++ b/packages/universal-cli/package.json @@ -13,7 +13,7 @@ ], "repository": { "type": "git", - "url": "https://github.com/devCrossNet/angular-cli.git" + "url": "https://github.com/devCrossNet/universal-cli.git" }, "engines": { "node": ">= 4.1.0", @@ -22,9 +22,9 @@ "author": "Angular Authors", "license": "MIT", "bugs": { - "url": "https://github.com/devCrossNet/angular-cli/issues" + "url": "https://github.com/devCrossNet/universal-cli/issues" }, - "homepage": "https://github.com/devCrossNet/angular-cli", + "homepage": "https://github.com/devCrossNet/universal-cli", "dependencies": { "@angular-cli/ast-tools": "^1.0.1", "@angular-cli/base-href-webpack": "^1.0.0", diff --git a/packages/angular-cli/plugins/glob-copy-webpack-plugin.ts b/packages/universal-cli/plugins/glob-copy-webpack-plugin.ts similarity index 100% rename from packages/angular-cli/plugins/glob-copy-webpack-plugin.ts rename to packages/universal-cli/plugins/glob-copy-webpack-plugin.ts diff --git a/packages/angular-cli/plugins/karma.js b/packages/universal-cli/plugins/karma.js similarity index 84% rename from packages/angular-cli/plugins/karma.js rename to packages/universal-cli/plugins/karma.js index 4f8ff7088ac9..81261c56dbc2 100644 --- a/packages/angular-cli/plugins/karma.js +++ b/packages/universal-cli/plugins/karma.js @@ -37,11 +37,11 @@ const init = (config) => { config.webpack = Object.assign(webpackConfig, config.webpack); config.webpackMiddleware = Object.assign(webpackMiddlewareConfig, config.webpackMiddleware); - // replace the angular-cli preprocessor with webpack+sourcemap + // replace the universal-cli preprocessor with webpack+sourcemap Object.keys(config.preprocessors) - .filter((file) => config.preprocessors[file].indexOf('angular-cli') !== -1) + .filter((file) => config.preprocessors[file].indexOf('universal-cli') !== -1) .map((file) => config.preprocessors[file]) - .map((arr) => arr.splice(arr.indexOf('angular-cli'), 1, 'webpack', 'sourcemap')); + .map((arr) => arr.splice(arr.indexOf('universal-cli'), 1, 'webpack', 'sourcemap')); } init.$inject = ['config']; @@ -52,6 +52,6 @@ preprocessor.$inject = []; // also export karma-webpack and karma-sourcemap-loader module.exports = Object.assign({ - 'framework:angular-cli': ['factory', init], - 'preprocessor:angular-cli': ['factory', preprocessor] + 'framework:universal-cli': ['factory', init], + 'preprocessor:universal-cli': ['factory', preprocessor] }, require('karma-webpack'), require('karma-sourcemap-loader')); diff --git a/packages/angular-cli/tasks/build-webpack-watch.ts b/packages/universal-cli/tasks/build-webpack-watch.ts similarity index 100% rename from packages/angular-cli/tasks/build-webpack-watch.ts rename to packages/universal-cli/tasks/build-webpack-watch.ts diff --git a/packages/angular-cli/tasks/build-webpack.ts b/packages/universal-cli/tasks/build-webpack.ts similarity index 100% rename from packages/angular-cli/tasks/build-webpack.ts rename to packages/universal-cli/tasks/build-webpack.ts diff --git a/packages/angular-cli/tasks/create-github-repo.ts b/packages/universal-cli/tasks/create-github-repo.ts similarity index 100% rename from packages/angular-cli/tasks/create-github-repo.ts rename to packages/universal-cli/tasks/create-github-repo.ts diff --git a/packages/angular-cli/tasks/doc.ts b/packages/universal-cli/tasks/doc.ts similarity index 100% rename from packages/angular-cli/tasks/doc.ts rename to packages/universal-cli/tasks/doc.ts diff --git a/packages/angular-cli/tasks/e2e.ts b/packages/universal-cli/tasks/e2e.ts similarity index 100% rename from packages/angular-cli/tasks/e2e.ts rename to packages/universal-cli/tasks/e2e.ts diff --git a/packages/angular-cli/tasks/git-init.js b/packages/universal-cli/tasks/git-init.js similarity index 100% rename from packages/angular-cli/tasks/git-init.js rename to packages/universal-cli/tasks/git-init.js diff --git a/packages/angular-cli/tasks/link-cli.ts b/packages/universal-cli/tasks/link-cli.ts similarity index 100% rename from packages/angular-cli/tasks/link-cli.ts rename to packages/universal-cli/tasks/link-cli.ts diff --git a/packages/angular-cli/tasks/lint.ts b/packages/universal-cli/tasks/lint.ts similarity index 100% rename from packages/angular-cli/tasks/lint.ts rename to packages/universal-cli/tasks/lint.ts diff --git a/packages/angular-cli/tasks/npm-install.ts b/packages/universal-cli/tasks/npm-install.ts similarity index 100% rename from packages/angular-cli/tasks/npm-install.ts rename to packages/universal-cli/tasks/npm-install.ts diff --git a/packages/angular-cli/tasks/serve-webpack.ts b/packages/universal-cli/tasks/serve-webpack.ts similarity index 98% rename from packages/angular-cli/tasks/serve-webpack.ts rename to packages/universal-cli/tasks/serve-webpack.ts index 91ed715f9885..116235a8bc4b 100644 --- a/packages/angular-cli/tasks/serve-webpack.ts +++ b/packages/universal-cli/tasks/serve-webpack.ts @@ -101,7 +101,7 @@ export default Task.extend({ if (appConfig.universal === true) { ui.writeLine(chalk.green(oneLine` ** - NG Universal Development Server is running on + Universal-cli Development Server is running on http${commandOptions.ssl ? 's' : ''}://${commandOptions.host}:${commandOptions.port}. ** `)); diff --git a/packages/angular-cli/tasks/server/universal-dev-server.ts b/packages/universal-cli/tasks/server/universal-dev-server.ts similarity index 100% rename from packages/angular-cli/tasks/server/universal-dev-server.ts rename to packages/universal-cli/tasks/server/universal-dev-server.ts diff --git a/packages/angular-cli/tasks/test.ts b/packages/universal-cli/tasks/test.ts similarity index 100% rename from packages/angular-cli/tasks/test.ts rename to packages/universal-cli/tasks/test.ts diff --git a/packages/angular-cli/tsconfig.json b/packages/universal-cli/tsconfig.json similarity index 94% rename from packages/angular-cli/tsconfig.json rename to packages/universal-cli/tsconfig.json index 9623f183e150..288e85c81bf4 100644 --- a/packages/angular-cli/tsconfig.json +++ b/packages/universal-cli/tsconfig.json @@ -8,7 +8,7 @@ "moduleResolution": "node", "noEmitOnError": true, "noImplicitAny": true, - "outDir": "../../dist/angular-cli", + "outDir": "../../dist/universal-cli", "rootDir": ".", "sourceMap": true, "sourceRoot": "/", diff --git a/packages/angular-cli/upgrade/version.ts b/packages/universal-cli/upgrade/version.ts similarity index 97% rename from packages/angular-cli/upgrade/version.ts rename to packages/universal-cli/upgrade/version.ts index ac380c68500b..7f2d4aa5b8ec 100644 --- a/packages/angular-cli/upgrade/version.ts +++ b/packages/universal-cli/upgrade/version.ts @@ -99,7 +99,7 @@ export class Version { workflow, a faster build, and smaller bundles. To get more info, including a step-by-step guide to upgrade the CLI, follow this link: - https://github.com/angular/angular-cli/wiki/Upgrading-from-Beta.10-to-Beta.14 + https://github.com/devCrossNet/angular-cli/wiki/Upgrading-from-Beta.10-to-Beta.14 ` + '\n'))); process.exit(1); } else { diff --git a/packages/universal-cli/utilities/INITIAL_COMMIT_MESSAGE.txt b/packages/universal-cli/utilities/INITIAL_COMMIT_MESSAGE.txt new file mode 100644 index 000000000000..0ae1bd205d28 --- /dev/null +++ b/packages/universal-cli/utilities/INITIAL_COMMIT_MESSAGE.txt @@ -0,0 +1,7 @@ +chore: initial commit from universal-cli + .__ .__ .__ .__ + __ __ ____ |__|__ __ ___________ ___________ | | ____ | | |__| +| | \/ \| \ \/ // __ \_ __ \/ ___/\__ \ | | ______ _/ ___\| | | | +| | / | \ |\ /\ ___/| | \/\___ \ / __ \| |__ /_____/ \ \___| |_| | +|____/|___| /__| \_/ \___ >__| /____ >(____ /____/ \___ >____/__| + \/ \/ \/ \/ \/ diff --git a/packages/angular-cli/utilities/ast-utils.ts b/packages/universal-cli/utilities/ast-utils.ts similarity index 100% rename from packages/angular-cli/utilities/ast-utils.ts rename to packages/universal-cli/utilities/ast-utils.ts diff --git a/packages/angular-cli/utilities/change.ts b/packages/universal-cli/utilities/change.ts similarity index 100% rename from packages/angular-cli/utilities/change.ts rename to packages/universal-cli/utilities/change.ts diff --git a/packages/angular-cli/utilities/completion.sh b/packages/universal-cli/utilities/completion.sh similarity index 100% rename from packages/angular-cli/utilities/completion.sh rename to packages/universal-cli/utilities/completion.sh diff --git a/packages/angular-cli/utilities/dynamic-path-parser.js b/packages/universal-cli/utilities/dynamic-path-parser.js similarity index 100% rename from packages/angular-cli/utilities/dynamic-path-parser.js rename to packages/universal-cli/utilities/dynamic-path-parser.js diff --git a/packages/angular-cli/utilities/find-parent-module.ts b/packages/universal-cli/utilities/find-parent-module.ts similarity index 100% rename from packages/angular-cli/utilities/find-parent-module.ts rename to packages/universal-cli/utilities/find-parent-module.ts diff --git a/packages/angular-cli/utilities/get-dependent-files.ts b/packages/universal-cli/utilities/get-dependent-files.ts similarity index 100% rename from packages/angular-cli/utilities/get-dependent-files.ts rename to packages/universal-cli/utilities/get-dependent-files.ts diff --git a/packages/angular-cli/utilities/module-resolver.ts b/packages/universal-cli/utilities/module-resolver.ts similarity index 100% rename from packages/angular-cli/utilities/module-resolver.ts rename to packages/universal-cli/utilities/module-resolver.ts diff --git a/packages/angular-cli/utilities/prerender-webpack-plugin.ts b/packages/universal-cli/utilities/prerender-webpack-plugin.ts similarity index 100% rename from packages/angular-cli/utilities/prerender-webpack-plugin.ts rename to packages/universal-cli/utilities/prerender-webpack-plugin.ts diff --git a/packages/angular-cli/utilities/route-utils.ts b/packages/universal-cli/utilities/route-utils.ts similarity index 100% rename from packages/angular-cli/utilities/route-utils.ts rename to packages/universal-cli/utilities/route-utils.ts diff --git a/packages/angular-cli/utilities/sw-install.js b/packages/universal-cli/utilities/sw-install.js similarity index 100% rename from packages/angular-cli/utilities/sw-install.js rename to packages/universal-cli/utilities/sw-install.js diff --git a/plugins/karma.js b/plugins/karma.js index af2a8200130c..fb1fb237047e 100644 --- a/plugins/karma.js +++ b/plugins/karma.js @@ -1,4 +1,4 @@ -// This file is necessary when using a linked angular-cli to this repo, meaning that -// require('angular-cli/plugins/karma') will load this file, and we just forward to +// This file is necessary when using a linked universal-cli to this repo, meaning that +// require('universal-cli/plugins/karma') will load this file, and we just forward to // the actual published file. -module.exports = require('../packages/angular-cli/plugins/karma'); +module.exports = require('../packages/universal-cli/plugins/karma'); diff --git a/scripts/publish/build.js b/scripts/publish/build.js index c617c3efccdc..424fe619525f 100755 --- a/scripts/publish/build.js +++ b/scripts/publish/build.js @@ -80,7 +80,7 @@ Promise.resolve() return files .map((fileName) => path.relative(packagesRoot, fileName)) .filter((fileName) => { - if (/^angular-cli[\\\/]blueprints/.test(fileName)) { + if (/^universal-cli[\\\/]blueprints/.test(fileName)) { return true; } if (/\.d\.ts$/.test(fileName)) { @@ -136,7 +136,7 @@ Promise.resolve() 'CHANGELOG.md', 'CONTRIBUTING.md', 'LICENSE', 'README.md' ].map(fileName => { console.log(`Copying ${fileName}...`); - return copy(fileName, path.join('dist/angular-cli', fileName)); + return copy(fileName, path.join('dist/universal-cli', fileName)); })); }) .then(() => process.exit(0), (err) => { diff --git a/tests/acceptance/destroy.spec.js b/tests/acceptance/destroy.spec.js index 7b5c9b91ba2c..f8846daeb8b4 100644 --- a/tests/acceptance/destroy.spec.js +++ b/tests/acceptance/destroy.spec.js @@ -16,14 +16,14 @@ describe('Acceptance: ung destroy', function () { }); afterEach(function () { - return tmp.teardown('./tmp'); + // return tmp.teardown('./tmp'); }); it('without args should fail', function () { return ng(['destroy']).then(() => { throw new SilentError('ung destroy should fail.'); }, (err) => { - expect(err.message).to.equal('The destroy command is not supported by Angular-CLI.'); + expect(err.message).to.equal('The destroy command is not supported by Universal-CLI.'); }); }); @@ -31,7 +31,7 @@ describe('Acceptance: ung destroy', function () { return ng(['destroy', 'something']).then(() => { throw new SilentError('ung destroy something should fail.'); }, (err) => { - expect(err.message).to.equal('The destroy command is not supported by Angular-CLI.'); + expect(err.message).to.equal('The destroy command is not supported by Universal-CLI.'); }); }); }); diff --git a/tests/acceptance/dynamic-path-parser.spec.js b/tests/acceptance/dynamic-path-parser.spec.js index 5124976ad26b..76a53aa6055c 100644 --- a/tests/acceptance/dynamic-path-parser.spec.js +++ b/tests/acceptance/dynamic-path-parser.spec.js @@ -2,7 +2,7 @@ var expect = require('chai').expect; var path = require('path'); -var dynamicPathParser = require('../../packages/angular-cli/utilities/dynamic-path-parser'); +var dynamicPathParser = require('../../packages/universal-cli/utilities/dynamic-path-parser'); var mockFs = require('mock-fs'); var appDir = `src${path.sep}app`; @@ -14,12 +14,12 @@ describe('dynamic path parser', () => { var root = 'src'; beforeEach(() => { project = { - root: rootName, + root: rootName, ngConfig: { apps: [{ root: root }] - } + } }; var mockFolder = {}; mockFolder[rootName] = { @@ -32,7 +32,7 @@ describe('dynamic path parser', () => { }; mockFs(mockFolder); }); - + afterEach(() => { mockFs.restore(); }); @@ -122,7 +122,7 @@ describe('dynamic path parser', () => { expect(result.dir).to.equal(`${appDir}${path.sep}child-dir`); expect(result.name).to.equal(entityName); }); - + it('auto look for dirs with a "+" when not specified', () => { var mockFolder = {}; mockFolder[rootName] = { diff --git a/tests/acceptance/find-lazy-module.spec.ts b/tests/acceptance/find-lazy-module.spec.ts index 647e3f5bf9c3..28e8e2d5a0aa 100644 --- a/tests/acceptance/find-lazy-module.spec.ts +++ b/tests/acceptance/find-lazy-module.spec.ts @@ -3,7 +3,7 @@ import {stripIndents} from 'common-tags'; import {expect} from 'chai'; import {join} from 'path'; -import {findLazyModules} from 'angular-cli/models/find-lazy-modules'; +import {findLazyModules} from 'universal-cli/models/find-lazy-modules'; describe('find-lazy-module', () => { diff --git a/tests/acceptance/generate-component.spec.js b/tests/acceptance/generate-component.spec.js index 99ffc1feb9d4..63d8acf678b5 100644 --- a/tests/acceptance/generate-component.spec.js +++ b/tests/acceptance/generate-component.spec.js @@ -7,7 +7,7 @@ var expect = require('chai').expect; var path = require('path'); var tmp = require('../helpers/tmp'); var root = process.cwd(); -var Promise = require('angular-cli/ember-cli/lib/ext/promise'); +var Promise = require('universal-cli/ember-cli/lib/ext/promise'); var SilentError = require('silent-error'); const denodeify = require('denodeify'); diff --git a/tests/acceptance/generate-directive.spec.js b/tests/acceptance/generate-directive.spec.js index c6ec7cc4983a..1cf4f045cb13 100644 --- a/tests/acceptance/generate-directive.spec.js +++ b/tests/acceptance/generate-directive.spec.js @@ -7,7 +7,7 @@ var expect = require('chai').expect; var path = require('path'); var tmp = require('../helpers/tmp'); var root = process.cwd(); -var Promise = require('angular-cli/ember-cli/lib/ext/promise'); +var Promise = require('universal-cli/ember-cli/lib/ext/promise'); var SilentError = require('silent-error'); const denodeify = require('denodeify'); diff --git a/tests/acceptance/generate-pipe.spec.js b/tests/acceptance/generate-pipe.spec.js index ddedf588d926..61d558844cb7 100644 --- a/tests/acceptance/generate-pipe.spec.js +++ b/tests/acceptance/generate-pipe.spec.js @@ -8,7 +8,7 @@ var expect = require('chai').expect; var path = require('path'); var tmp = require('../helpers/tmp'); var root = process.cwd(); -var Promise = require('angular-cli/ember-cli/lib/ext/promise'); +var Promise = require('universal-cli/ember-cli/lib/ext/promise'); var SilentError = require('silent-error'); const denodeify = require('denodeify'); diff --git a/tests/acceptance/generate-service.spec.js b/tests/acceptance/generate-service.spec.js index 506d98dde384..9e005f58b542 100644 --- a/tests/acceptance/generate-service.spec.js +++ b/tests/acceptance/generate-service.spec.js @@ -7,7 +7,7 @@ var expect = require('chai').expect; var path = require('path'); var tmp = require('../helpers/tmp'); var root = process.cwd(); -var Promise = require('angular-cli/ember-cli/lib/ext/promise'); +var Promise = require('universal-cli/ember-cli/lib/ext/promise'); var SilentError = require('silent-error'); const denodeify = require('denodeify'); diff --git a/tests/acceptance/get-dependent-files.spec.ts b/tests/acceptance/get-dependent-files.spec.ts index 0795f26c5844..fd573f508f39 100644 --- a/tests/acceptance/get-dependent-files.spec.ts +++ b/tests/acceptance/get-dependent-files.spec.ts @@ -1,11 +1,11 @@ 'use strict'; -// This needs to be first so fs module can be mocked correctly. +// This needs to be first so fs module can be mocked correctly. let mockFs = require('mock-fs'); import { expect, assert } from 'chai'; import * as path from 'path'; import * as ts from 'typescript'; -import * as dependentFilesUtils from 'angular-cli/utilities/get-dependent-files'; +import * as dependentFilesUtils from 'universal-cli/utilities/get-dependent-files'; describe('Get Dependent Files: ', () => { let rootPath = 'src/app'; diff --git a/tests/acceptance/github-pages-deploy.spec.js b/tests/acceptance/github-pages-deploy.spec.js index a7458a8302bf..3cd4c6310bf6 100644 --- a/tests/acceptance/github-pages-deploy.spec.js +++ b/tests/acceptance/github-pages-deploy.spec.js @@ -3,7 +3,7 @@ var ng = require('../helpers/ng'); var tmp = require('../helpers/tmp'); -var Promise = require('angular-cli/ember-cli/lib/ext/promise'); +var Promise = require('universal-cli/ember-cli/lib/ext/promise'); var fs = require('fs'); var path = require('path'); var chai = require('chai'); diff --git a/tests/acceptance/init.spec.js b/tests/acceptance/init.spec.js index 0d8072fe5307..9ec88abc3811 100644 --- a/tests/acceptance/init.spec.js +++ b/tests/acceptance/init.spec.js @@ -4,10 +4,10 @@ var ng = require('../helpers/ng'); var expect = require('chai').expect; var walkSync = require('walk-sync'); var glob = require('glob'); -var Blueprint = require('angular-cli/ember-cli/lib/models/blueprint'); +var Blueprint = require('universal-cli/ember-cli/lib/models/blueprint'); var path = require('path'); var tmp = require('../helpers/tmp'); -var root = path.join(__dirname, '../../packages/angular-cli'); +var root = path.join(__dirname, '../../packages/universal-cli'); var util = require('util'); var minimatch = require('minimatch'); var intersect = require('lodash/intersection'); diff --git a/tests/acceptance/module-resolver.spec.ts b/tests/acceptance/module-resolver.spec.ts index 4db9a7767d81..d62c2b0aeae9 100644 --- a/tests/acceptance/module-resolver.spec.ts +++ b/tests/acceptance/module-resolver.spec.ts @@ -4,10 +4,10 @@ const mockFs = require('mock-fs'); import * as ts from 'typescript'; import * as path from 'path'; -import * as dependentFilesUtils from 'angular-cli/utilities/get-dependent-files'; +import * as dependentFilesUtils from 'universal-cli/utilities/get-dependent-files'; import { expect } from 'chai'; -import { ModuleResolver } from 'angular-cli/utilities/module-resolver'; +import { ModuleResolver } from 'universal-cli/utilities/module-resolver'; describe('ModuleResolver', () => { let rootPath = 'src/app'; diff --git a/tests/acceptance/new.spec.js b/tests/acceptance/new.spec.js index 65f6d7087bfd..65ddb2c8a541 100644 --- a/tests/acceptance/new.spec.js +++ b/tests/acceptance/new.spec.js @@ -6,7 +6,7 @@ var existsSync = require('exists-sync'); var expect = require('chai').expect; var forEach = require('lodash/forEach'); var walkSync = require('walk-sync'); -var Blueprint = require('angular-cli/ember-cli/lib/models/blueprint'); +var Blueprint = require('universal-cli/ember-cli/lib/models/blueprint'); var path = require('path'); var tmp = require('../helpers/tmp'); var root = process.cwd(); @@ -39,7 +39,7 @@ describe('Acceptance: ung new', function () { }); expected.forEach(function (file, index) { - expected[index] = file.replace(/__name__/g, 'angular-cli'); + expected[index] = file.replace(/__name__/g, 'universal-cli'); }); expected.sort(); @@ -86,7 +86,7 @@ describe('Acceptance: ung new', function () { }); }); - it('Cannot run ung new, inside of angular-cli project', function () { + it('Cannot run ung new, inside of universal-cli project', function () { return ng(['new', 'foo', '--skip-npm', '--skip-bower', '--skip-git']) .then(function () { return ng(['new', 'foo', '--skip-npm', '--skip-bower', '--skip-git']).then(() => { diff --git a/tests/e2e/setup/000-pwd.ts b/tests/e2e/setup/000-pwd.ts index 7b663227f9a7..441911b64f2f 100644 --- a/tests/e2e/setup/000-pwd.ts +++ b/tests/e2e/setup/000-pwd.ts @@ -2,6 +2,6 @@ import {join} from 'path'; export default function() { - // Setup to use the local angular-cli copy. + // Setup to use the local universal-cli copy. process.chdir(join(__dirname, '../..')); } diff --git a/tests/e2e/setup/100-npm-link.ts b/tests/e2e/setup/100-npm-link.ts index 14848ba55b19..e31729a59dc5 100644 --- a/tests/e2e/setup/100-npm-link.ts +++ b/tests/e2e/setup/100-npm-link.ts @@ -12,7 +12,7 @@ export default function (argv: any) { return; } - const distAngularCli = join(__dirname, '../../../dist/angular-cli'); + const distAngularCli = join(__dirname, '../../../dist/universal-cli'); const oldCwd = process.cwd(); process.chdir(distAngularCli); diff --git a/tests/e2e/setup/200-create-tmp-dir.ts b/tests/e2e/setup/200-create-tmp-dir.ts index 8cd88ec70a11..34a56df994ff 100644 --- a/tests/e2e/setup/200-create-tmp-dir.ts +++ b/tests/e2e/setup/200-create-tmp-dir.ts @@ -5,7 +5,7 @@ const temp = require('temp'); export default function(argv: any) { // Get to a temporary directory. - let tempRoot = argv.reuse || temp.mkdirSync('angular-cli-e2e-'); + let tempRoot = argv.reuse || temp.mkdirSync('universal-cli-e2e-'); console.log(` Using "${tempRoot}" as temporary directory for a new project.`); setGlobalVariable('tmp-root', tempRoot); process.chdir(tempRoot); diff --git a/tests/e2e/setup/500-create-project.ts b/tests/e2e/setup/500-create-project.ts index dc7706582ed0..808c4be8d45c 100644 --- a/tests/e2e/setup/500-create-project.ts +++ b/tests/e2e/setup/500-create-project.ts @@ -10,7 +10,7 @@ let packages = require('../../../lib/packages'); export default function (argv: any) { - let createProject = null; + let createProject: any = null; // This is a dangerous flag, but is useful for testing packages only. if (argv.noproject) { diff --git a/tests/e2e_runner.js b/tests/e2e_runner.js index b66eee1495b8..1f50da7b958a 100644 --- a/tests/e2e_runner.js +++ b/tests/e2e_runner.js @@ -23,7 +23,7 @@ const white = chalk.white; * Here's a short description of those flags: * --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. + * --nolink Skip linking your local universal-cli directory. Can save a few seconds. * --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 diff --git a/tests/helpers/mock-ui.js b/tests/helpers/mock-ui.js index 07f322998037..6838f5b890ad 100644 --- a/tests/helpers/mock-ui.js +++ b/tests/helpers/mock-ui.js @@ -1,8 +1,8 @@ 'use strict'; -var UI = require('angular-cli/ember-cli/lib/ui'); +var UI = require('universal-cli/ember-cli/lib/ui'); var through = require('through'); -var Promise = require('angular-cli/ember-cli/lib/ext/promise'); +var Promise = require('universal-cli/ember-cli/lib/ext/promise'); module.exports = MockUI; function MockUI() { diff --git a/tests/helpers/ng.js b/tests/helpers/ng.js index 2e67ce2a9159..ef5e4278801e 100644 --- a/tests/helpers/ng.js +++ b/tests/helpers/ng.js @@ -2,7 +2,7 @@ var MockUI = require('./mock-ui'); var MockAnalytics = require('./mock-analytics'); -var Cli = require('angular-cli/lib/cli'); +var Cli = require('universal-cli/lib/cli'); module.exports = function ng(args) { var cli; diff --git a/tests/helpers/tmp.js b/tests/helpers/tmp.js index 733e7a3a8ef4..13aee38c5b67 100644 --- a/tests/helpers/tmp.js +++ b/tests/helpers/tmp.js @@ -2,7 +2,7 @@ var fs = require('fs-extra'); var existsSync = require('exists-sync'); -var Promise = require('angular-cli/ember-cli/lib/ext/promise'); +var Promise = require('universal-cli/ember-cli/lib/ext/promise'); var remove = Promise.denodeify(fs.remove); var root = process.cwd(); diff --git a/tests/models/config.spec.ts b/tests/models/config.spec.ts index ece9ee4f5969..1d738af87ee9 100644 --- a/tests/models/config.spec.ts +++ b/tests/models/config.spec.ts @@ -1,4 +1,4 @@ -import {CliConfig} from 'angular-cli/models/config/config'; +import {CliConfig} from 'universal-cli/models/config/config'; import * as fs from 'fs'; import * as path from 'path'; import {CliConfig as ConfigInterface} from './spec-schema'; diff --git a/tests/models/find-lazy-modules.spec.ts b/tests/models/find-lazy-modules.spec.ts index 75f80cffd32f..eb3e606de3d4 100644 --- a/tests/models/find-lazy-modules.spec.ts +++ b/tests/models/find-lazy-modules.spec.ts @@ -1,7 +1,7 @@ const mockFs = require('mock-fs'); const expect = require('chai').expect; import * as path from 'path'; -import {findLoadChildren, findLazyModules} from 'angular-cli/models/find-lazy-modules'; +import {findLoadChildren, findLazyModules} from 'universal-cli/models/find-lazy-modules'; describe('find-lazy-modules', () => { beforeEach(() => { diff --git a/tsconfig.json b/tsconfig.json index 1055b93bdb0f..5b347e108311 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,14 +22,14 @@ "node" ], "paths": { - "angular-cli/*": [ "./packages/angular-cli/*" ], + "universal-cli/*": [ "./packages/universal-cli/*" ], "@angular-cli/ast-tools": [ "./packages/ast-tools/src" ], "@angular-cli/base-href-webpack": [ "./packages/base-href-webpack/src" ], "@ngtools/webpack": [ "./packages/webpack/src" ] } }, "exclude": [ - "packages/angular-cli/blueprints/*/files/**/*", + "packages/universal-cli/blueprints/*/files/**/*", "dist/**/*", "node_modules/**/*", "tmp/**/*" From 1a37905685436b44ec5c2b1fb5cc5793492c0baa Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Sat, 3 Dec 2016 22:32:16 +0100 Subject: [PATCH 24/38] chore(docs): rename repository to devCrossNet/universal-cli closes #22 --- README.md | 28 +++++++++---------- .../blueprints/ng2/files/README.md | 4 +-- packages/universal-cli/upgrade/version.ts | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index f8baf11b11d6..9988c90338b1 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,9 @@ Prototype of a CLI for Angular 2 applications based on the [ember-cli](http://ww This project is very much still a work in progress. The CLI is now in alpha. -If you wish to collaborate while the project is still young, check out [our issue list](https://github.com/devCrossNet/angular-cli/issues). +If you wish to collaborate while the project is still young, check out [our issue list](https://github.com/devCrossNet/universal-cli/issues). -Before submitting new issues, have a look at [issues marked with the `type: faq` label](https://github.com/devCrossNet/angular-cli/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3A%22type%3A%20faq%22%20). +Before submitting new issues, have a look at [issues marked with the `type: faq` label](https://github.com/devCrossNet/universal-cli/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3A%22type%3A%20faq%22%20). ## Webpack update @@ -31,7 +31,7 @@ We changed the build system between beta.10 and beta.14, from SystemJS to Webpac And with it comes a lot of benefits. To take advantage of these, your app built with the old beta will need to migrate. -You can update your `beta.10` projects to `beta.14` by following [these instructions](https://github.com/devCrossNet/angular-cli/wiki/Upgrading-from-Beta.10-to-Beta.14). +You can update your `beta.10` projects to `beta.14` by following [these instructions](https://github.com/devCrossNet/universal-cli/wiki/Upgrading-from-Beta.10-to-Beta.14). ## Prerequisites @@ -450,7 +450,7 @@ Carefully read the diffs for each code file, and either accept the changes or in **The main cause of errors after an update is failing to incorporate these updates into your code**. -You can find more details about changes between versions in [CHANGELOG.md](https://github.com/devCrossNet/angular-cli/blob/master/CHANGELOG.md). +You can find more details about changes between versions in [CHANGELOG.md](https://github.com/devCrossNet/universal-cli/blob/master/CHANGELOG.md). ## Development Hints for hacking on universal-cli @@ -458,14 +458,14 @@ You can find more details about changes between versions in [CHANGELOG.md](https ### Working with master ```bash -git clone https://github.com/devCrossNet/angular-cli.git -cd angular-cli +git clone https://github.com/devCrossNet/universal-cli.git +cd universal-cli npm link ``` `npm link` is very similar to `npm install -g` except that instead of downloading the package -from the repo, the just cloned `angular-cli/` folder becomes the global package. -Any changes to the files in the `angular-cli/` folder will immediately affect the global `universal-cli` package, +from the repo, the just cloned `universal-cli/` folder becomes the global package. +Any changes to the files in the `universal-cli/` folder will immediately affect the global `universal-cli` package, allowing you to quickly test any changes you make to the cli project. Now you can use `universal-cli` via the command line: @@ -494,11 +494,11 @@ and the [npm-link cheatsheet](http://browsenpm.org/help#linkinganynpmpackageloca MIT -[travis-badge]: https://travis-ci.org/devCrossNet/angular-cli.svg?branch=master -[travis-badge-url]: https://travis-ci.org/devCrossNet/angular-cli -[david-badge]: https://david-dm.org/devCrossNet/angular-cli.svg -[david-badge-url]: https://david-dm.org/devCrossNet/angular-cli -[david-dev-badge]: https://david-dm.org/devCrossNet/angular-cli/dev-status.svg -[david-dev-badge-url]: https://david-dm.org/devCrossNet/angular-cli?type=dev +[travis-badge]: https://travis-ci.org/devCrossNet/universal-cli.svg?branch=master +[travis-badge-url]: https://travis-ci.org/devCrossNet/universal-cli +[david-badge]: https://david-dm.org/devCrossNet/universal-cli.svg +[david-badge-url]: https://david-dm.org/devCrossNet/universal-cli +[david-dev-badge]: https://david-dm.org/devCrossNet/universal-cli/dev-status.svg +[david-dev-badge-url]: https://david-dm.org/devCrossNet/universal-cli?type=dev [npm-badge]: https://img.shields.io/npm/v/universal-cli.svg [npm-badge-url]: https://www.npmjs.com/package/universal-cli diff --git a/packages/universal-cli/blueprints/ng2/files/README.md b/packages/universal-cli/blueprints/ng2/files/README.md index b5e01930cc3d..1fabd5a79f3e 100755 --- a/packages/universal-cli/blueprints/ng2/files/README.md +++ b/packages/universal-cli/blueprints/ng2/files/README.md @@ -1,6 +1,6 @@ # <%= jsComponentName %> -This project was generated with [universal-cli](https://github.com/devCrossNet/angular-cli) version <%= version %>. +This project was generated with [universal-cli](https://github.com/devCrossNet/universal-cli) version <%= version %>. ## Development server Run `ung serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. @@ -28,4 +28,4 @@ Run `ung github-pages:deploy` to deploy to Github Pages. ## Further help -To get more help on the `universal-cli` use `ung --help` or go check out the [Universal-CLI README](https://github.com/devCrossNet/angular-cli/blob/master/README.md). +To get more help on the `universal-cli` use `ung --help` or go check out the [Universal-CLI README](https://github.com/devCrossNet/universal-cli/blob/master/README.md). diff --git a/packages/universal-cli/upgrade/version.ts b/packages/universal-cli/upgrade/version.ts index 7f2d4aa5b8ec..f0c7bd423918 100644 --- a/packages/universal-cli/upgrade/version.ts +++ b/packages/universal-cli/upgrade/version.ts @@ -99,7 +99,7 @@ export class Version { workflow, a faster build, and smaller bundles. To get more info, including a step-by-step guide to upgrade the CLI, follow this link: - https://github.com/devCrossNet/angular-cli/wiki/Upgrading-from-Beta.10-to-Beta.14 + https://github.com/devCrossNet/universal-cli/wiki/Upgrading-from-Beta.10-to-Beta.14 ` + '\n'))); process.exit(1); } else { From f73bb43e232c47f15b6f74d59eea5f8f133871d2 Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Sun, 4 Dec 2016 01:54:19 +0100 Subject: [PATCH 25/38] refactor(universal): separate client and server build add dist/client and dist/server folder and just expose the client folder, closes #19 --- .../blueprints/ng2/files/angular-cli.json | 2 +- .../universal/files/__path__/server.ts | 4 +-- .../models/webpack-build-node.ts | 3 +- .../tasks/server/universal-dev-server.ts | 2 +- tests/e2e/tests/build/aot.ts | 4 +-- tests/e2e/tests/build/base-href.ts | 9 +++--- tests/e2e/tests/build/dev-build.ts | 8 ++--- tests/e2e/tests/build/environment.ts | 11 +++++-- tests/e2e/tests/build/prod-build.ts | 22 ++++++++++---- tests/e2e/tests/build/sourcemap.ts | 15 ++++++---- tests/e2e/tests/build/styles/less.ts | 4 +-- tests/e2e/tests/build/styles/scss.ts | 6 ++-- tests/e2e/tests/build/styles/styles-array.ts | 29 +++++++++++++++---- tests/e2e/tests/misc/assets.ts | 14 ++++----- tests/e2e/tests/misc/lazy-module.ts | 4 +-- tests/e2e/tests/mobile/prod-features.ts | 10 +++---- tests/e2e/tests/third-party/bootstrap.ts | 16 ++++++---- tests/e2e/utils/utils.ts | 4 +++ 18 files changed, 106 insertions(+), 61 deletions(-) diff --git a/packages/universal-cli/blueprints/ng2/files/angular-cli.json b/packages/universal-cli/blueprints/ng2/files/angular-cli.json index 2540853f3c96..2fe5efd02441 100644 --- a/packages/universal-cli/blueprints/ng2/files/angular-cli.json +++ b/packages/universal-cli/blueprints/ng2/files/angular-cli.json @@ -6,7 +6,7 @@ "apps": [ { "root": "<%= sourceDir %>", - "outDir": "dist", + "outDir": "dist<% if(universal) { %>/client<% } %>", "assets": [ "assets", "favicon.ico" diff --git a/packages/universal-cli/blueprints/universal/files/__path__/server.ts b/packages/universal-cli/blueprints/universal/files/__path__/server.ts index bd5ff05d5983..db692b91616a 100644 --- a/packages/universal-cli/blueprints/universal/files/__path__/server.ts +++ b/packages/universal-cli/blueprints/universal/files/__path__/server.ts @@ -28,7 +28,7 @@ if (environment.production) { * Express View */ app.engine('.html', createEngine({})); -app.set('views', __dirname); +app.set('views', path.join(ROOT, 'client')); app.set('view engine', 'html'); /** @@ -39,7 +39,7 @@ app.use(compression()); /** * serve static files */ -app.use(express.static(path.join(ROOT, 'dist'), {index: false})); +app.use('/', express.static(path.join(ROOT, 'client'), {index: false})); /** * place your api routes here diff --git a/packages/universal-cli/models/webpack-build-node.ts b/packages/universal-cli/models/webpack-build-node.ts index 8e26ee637c2c..165ff7d825c1 100644 --- a/packages/universal-cli/models/webpack-build-node.ts +++ b/packages/universal-cli/models/webpack-build-node.ts @@ -31,7 +31,7 @@ export function getWebpackNodeConfig(projectRoot: string, environment: string, a }, context: path.resolve(__dirname, './'), output: { - path: path.resolve(projectRoot, appConfig.outDir), + path: path.resolve(projectRoot, appConfig.outDir, '../server'), filename: '[name].bundle.js', libraryTarget: 'commonjs2' }, @@ -111,6 +111,7 @@ export function getWebpackNodeConfig(projectRoot: string, environment: string, a externals: checkNodeImport, node: { global: true, + crypto: true, __dirname: false, __filename: true, process: true, diff --git a/packages/universal-cli/tasks/server/universal-dev-server.ts b/packages/universal-cli/tasks/server/universal-dev-server.ts index 651c146eb557..798176058066 100644 --- a/packages/universal-cli/tasks/server/universal-dev-server.ts +++ b/packages/universal-cli/tasks/server/universal-dev-server.ts @@ -12,7 +12,7 @@ export class UniversalDevServer { constructor(private webpackCompiler: any, private webpackDevServerConfiguration: any) { this.appPath = path.join( webpackDevServerConfiguration.contentBase, - `../dist/${webpackDevServerConfiguration.filename.replace('.ts', '.bundle.js')}` + `../dist/server/${webpackDevServerConfiguration.filename.replace('.ts', '.bundle.js')}` ); this.liveServer = new tinyLr.Server(); this.liveServer.listen(); diff --git a/tests/e2e/tests/build/aot.ts b/tests/e2e/tests/build/aot.ts index 488884681d5b..e06d2fc16bdf 100644 --- a/tests/e2e/tests/build/aot.ts +++ b/tests/e2e/tests/build/aot.ts @@ -1,6 +1,6 @@ import { ng } from '../../utils/process'; import { expectFileToMatch } from '../../utils/fs'; -import { isUniversalTest, expectToFail } from '../../utils/utils'; +import { isUniversalTest, expectToFail, getClientDist } from '../../utils/utils'; export default function () { if (isUniversalTest()) { @@ -8,7 +8,7 @@ export default function () { .then(() => expectToFail(() => ng('build', '--aot'))); } else { return ng('build', '--aot') - .then(() => expectFileToMatch('dist/main.bundle.js', + .then(() => expectFileToMatch(`${getClientDist()}main.bundle.js`, /bootstrapModuleFactory.*\/\* AppModuleNgFactory \*\//)); } } diff --git a/tests/e2e/tests/build/base-href.ts b/tests/e2e/tests/build/base-href.ts index c8ff910a1a20..515a990113bd 100644 --- a/tests/e2e/tests/build/base-href.ts +++ b/tests/e2e/tests/build/base-href.ts @@ -1,8 +1,9 @@ -import {ng} from '../../utils/process'; -import {expectFileToMatch} from '../../utils/fs'; +import { ng } from '../../utils/process'; +import { expectFileToMatch } from '../../utils/fs'; +import { getClientDist } from '../../utils/utils'; -export default function() { +export default function () { return ng('build', '--base-href', '/myUrl') - .then(() => expectFileToMatch('dist/index.html', //)); + .then(() => expectFileToMatch(`${getClientDist()}index.html`, //)); } diff --git a/tests/e2e/tests/build/dev-build.ts b/tests/e2e/tests/build/dev-build.ts index 8fecc07cb413..6d591b0c4b0f 100644 --- a/tests/e2e/tests/build/dev-build.ts +++ b/tests/e2e/tests/build/dev-build.ts @@ -1,12 +1,12 @@ import { ng } from '../../utils/process'; import { expectFileToMatch, expectFileToExist } from '../../utils/fs'; import { expectGitToBeClean } from '../../utils/git'; -import { getAppMain, isUniversalTest } from '../../utils/utils'; +import { getAppMain, isUniversalTest, getClientDist } from '../../utils/utils'; export default function () { return ng('build', '--env=dev') - .then(() => expectFileToMatch('dist/index.html', getAppMain() + '.bundle.js')) + .then(() => expectFileToMatch(`${getClientDist()}index.html`, getAppMain() + '.bundle.js')) .then(() => expectGitToBeClean()) .then(() => { if (!isUniversalTest()) { @@ -14,9 +14,9 @@ export default function () { } return Promise.resolve() - .then(() => expectFileToExist('dist/server.bundle.js')) + .then(() => expectFileToExist('dist/server/server.bundle.js')) .then(() => expectFileToMatch( - 'dist/index.html', + `${getClientDist()}index.html`, 'livereload.js') ); }); diff --git a/tests/e2e/tests/build/environment.ts b/tests/e2e/tests/build/environment.ts index 0520b7f80830..a59fe577455d 100644 --- a/tests/e2e/tests/build/environment.ts +++ b/tests/e2e/tests/build/environment.ts @@ -1,13 +1,18 @@ import { ng } from '../../utils/process'; import { expectFileToMatch } from '../../utils/fs'; import { expectGitToBeClean } from '../../utils/git'; -import { expectToFail, getAppMain, isUniversalTest } from '../../utils/utils'; +import { expectToFail, getAppMain, isUniversalTest, getClientDist } from '../../utils/utils'; export default function () { // Try a prod build. return ng('build', '--env=prod') - .then(() => expectFileToMatch(`dist/${getAppMain()}.bundle.js`, 'production: true')) + .then(() => + expectFileToMatch( + `${getClientDist()}${getAppMain()}.bundle.js`, + 'production: true' + ) + ) .then(() => { if (!isUniversalTest()) { return; @@ -15,7 +20,7 @@ export default function () { return Promise.resolve() .then(() => { - expectFileToMatch('dist/server.bundle.js', 'production: true'); + expectFileToMatch('dist/server/server.bundle.js', 'production: true'); }); }) .then(() => expectGitToBeClean()) diff --git a/tests/e2e/tests/build/prod-build.ts b/tests/e2e/tests/build/prod-build.ts index 4779f5114660..711aa0971466 100644 --- a/tests/e2e/tests/build/prod-build.ts +++ b/tests/e2e/tests/build/prod-build.ts @@ -1,5 +1,5 @@ import { join } from 'path'; -import { isMobileTest, isUniversalTest } from '../../utils/utils'; +import { isMobileTest, isUniversalTest, getClientDist } from '../../utils/utils'; import { expectFileToExist, expectFileToMatch, expectFileToNotMatch } from '../../utils/fs'; import { ng } from '../../utils/process'; import { expectGitToBeClean } from '../../utils/git'; @@ -14,7 +14,11 @@ function mobileOnlyChecks() { return Promise.resolve() // Service Worker .then(() => expectFileToExist('dist/sw.js')) - .then(() => expectFileToMatch('dist/index.html', /sw-install\.[0-9a-f]{20}\.bundle\.js/)) + .then(() => expectFileToMatch( + `${getClientDist()}index.html`, + /sw-install\.[0-9a-f]{20}\.bundle\.js/ + ) + ) // App Manifest .then(() => expectFileToExist('dist/manifest.webapp')) @@ -31,8 +35,14 @@ export default function () { return ng('build', '--prod') .then(() => expectFileToExist(join(process.cwd(), 'dist'))) // Check for cache busting hash script src - .then(() => expectFileToMatch('dist/index.html', /(main|client)\.[0-9a-f]{20}\.bundle\.js/)) - .then(() => expectFileToMatch('dist/index.html', /styles\.[0-9a-f]{32}\.bundle\.css/)) + .then(() => expectFileToMatch( + `${getClientDist()}index.html`, + /(main|client)\.[0-9a-f]{20}\.bundle\.js/) + ) + .then(() => expectFileToMatch( + `${getClientDist()}index.html`, + /styles\.[0-9a-f]{32}\.bundle\.css/) + ) // Check that the process didn't change local files. .then(() => expectGitToBeClean()) @@ -43,10 +53,10 @@ export default function () { } return Promise.resolve() - .then(() => expectFileToExist('dist/server.bundle.js')) + .then(() => expectFileToExist('dist/server/server.bundle.js')) .then(() => { expectFileToNotMatch( - 'dist/index.html', + `${getClientDist()}index.html`, '' ); }); diff --git a/tests/e2e/tests/build/sourcemap.ts b/tests/e2e/tests/build/sourcemap.ts index 64ae9e1d7dc3..de3265b56523 100644 --- a/tests/e2e/tests/build/sourcemap.ts +++ b/tests/e2e/tests/build/sourcemap.ts @@ -1,11 +1,14 @@ -import {ng} from '../../utils/process'; -import {expectFileToExist} from '../../utils/fs'; -import { expectToFail, getAppMain } from '../../utils/utils'; +import { ng } from '../../utils/process'; +import { expectFileToExist } from '../../utils/fs'; +import { expectToFail, getAppMain, getClientDist } from '../../utils/utils'; -export default function() { +export default function () { return ng('build') - .then(() => expectFileToExist(`dist/${getAppMain()}.bundle.map`)) + .then(() => expectFileToExist(`${getClientDist()}${getAppMain()}.bundle.map`)) .then(() => ng('build', '--no-sourcemap')) - .then(() => expectToFail(() => expectFileToExist(`dist/${getAppMain()}.bundle.map`))); + .then(() => expectToFail(() => expectFileToExist( + `${getClientDist()}${getAppMain()}.bundle.map` + )) + ); } diff --git a/tests/e2e/tests/build/styles/less.ts b/tests/e2e/tests/build/styles/less.ts index c285dbf903f5..a6b108e395bf 100644 --- a/tests/e2e/tests/build/styles/less.ts +++ b/tests/e2e/tests/build/styles/less.ts @@ -7,7 +7,7 @@ import { } from '../../../utils/fs'; import { ng } from '../../../utils/process'; import { stripIndents } from 'common-tags'; -import { isMobileTest, getAppMain } from '../../../utils/utils'; +import { isMobileTest, getAppMain, getClientDist } from '../../../utils/utils'; export default function () { @@ -28,7 +28,7 @@ export default function () { .then(() => replaceInFile('src/app/app.component.ts', './app.component.css', './app.component.less')) .then(() => ng('build')) - .then(() => expectFileToMatch(`dist/${getAppMain()}.bundle.js`, + .then(() => expectFileToMatch(`${getClientDist()}${getAppMain()}.bundle.js`, /.outer.*.inner.*background:\s*#[fF]+/)) .then(() => moveFile('src/app/app.component.less', 'src/app/app.component.css')); } diff --git a/tests/e2e/tests/build/styles/scss.ts b/tests/e2e/tests/build/styles/scss.ts index 3eadef921b60..64926a731200 100644 --- a/tests/e2e/tests/build/styles/scss.ts +++ b/tests/e2e/tests/build/styles/scss.ts @@ -7,7 +7,7 @@ import { } from '../../../utils/fs'; import { ng } from '../../../utils/process'; import { stripIndents } from 'common-tags'; -import { isMobileTest, getAppMain } from '../../../utils/utils'; +import { isMobileTest, getAppMain, getClientDist } from '../../../utils/utils'; export default function () { @@ -35,9 +35,9 @@ export default function () { .then(() => replaceInFile('src/app/app.component.ts', './app.component.css', './app.component.scss')) .then(() => ng('build')) - .then(() => expectFileToMatch(`dist/${getAppMain()}.bundle.js`, + .then(() => expectFileToMatch(`${getClientDist()}${getAppMain()}.bundle.js`, /\.outer.*\.inner.*background.*#def/)) - .then(() => expectFileToMatch(`dist/${getAppMain()}.bundle.js`, + .then(() => expectFileToMatch(`${getClientDist()}${getAppMain()}.bundle.js`, /\.partial.*\.inner.*background.*#def/)) .then(() => moveFile('src/app/app.component.scss', 'src/app/app.component.css')); } diff --git a/tests/e2e/tests/build/styles/styles-array.ts b/tests/e2e/tests/build/styles/styles-array.ts index 5b7eec481f5e..4399ada2e26e 100644 --- a/tests/e2e/tests/build/styles/styles-array.ts +++ b/tests/e2e/tests/build/styles/styles-array.ts @@ -3,6 +3,7 @@ import * as glob from 'glob'; import { writeMultipleFiles, expectFileToMatch } from '../../../utils/fs'; import { ng } from '../../../utils/process'; import { updateJsonFile } from '../../../utils/project'; +import { getClientDist } from '../../../utils/utils'; export default function () { @@ -38,16 +39,32 @@ export default function () { app['styles'].push('styles.scss'); })) .then(() => ng('build')) - .then(() => expectFileToMatch('dist/styles.bundle.js', 'body { background-color: blue; }')) - .then(() => expectFileToMatch('dist/styles.bundle.js', 'p { background-color: red; }')) .then(() => expectFileToMatch( - 'dist/styles.bundle.js', + `${getClientDist()}styles.bundle.js`, + 'body { background-color: blue; }' + ) + ) + .then(() => expectFileToMatch( + `${getClientDist()}styles.bundle.js`, + 'p { background-color: red; }' + ) + ) + .then(() => expectFileToMatch( + `${getClientDist()}styles.bundle.js`, 'div { -webkit-box-flex: 1; -ms-flex: 1; flex: 1 }')) - .then(() => expectFileToMatch('dist/styles.bundle.js', /.outer.*.inner.*background:\s*#[fF]+/)) - .then(() => expectFileToMatch('dist/styles.bundle.js', /.upper.*.lower.*background.*#def/)) + .then(() => expectFileToMatch( + `${getClientDist()}styles.bundle.js`, + /.outer.*.inner.*background:\s*#[fF]+/ + ) + ) + .then(() => expectFileToMatch( + `${getClientDist()}styles.bundle.js`, + /.upper.*.lower.*background.*#def/ + ) + ) .then(() => ng('build', '--prod')) - .then(() => glob.sync('dist/styles.*.bundle.css').find(file => !!file)) + .then(() => glob.sync(`${getClientDist()}styles.*.bundle.css`).find(file => !!file)) .then((styles) => expectFileToMatch(styles, /body\s*\{\s*background-color:\s*blue\s*\}/) .then(() => expectFileToMatch(styles, /p\s*\{\s*background-color:\s*red\s*\}/) diff --git a/tests/e2e/tests/misc/assets.ts b/tests/e2e/tests/misc/assets.ts index 9dd9504cfac2..5ed88444c893 100644 --- a/tests/e2e/tests/misc/assets.ts +++ b/tests/e2e/tests/misc/assets.ts @@ -1,22 +1,22 @@ import {writeFile, expectFileToExist, expectFileToMatch} from '../../utils/fs'; import {ng} from '../../utils/process'; import {updateJsonFile} from '../../utils/project'; -import {expectToFail} from '../../utils/utils'; +import { expectToFail, getClientDist } from '../../utils/utils'; export default function() { return writeFile('src/assets/.file', '') .then(() => writeFile('src/assets/test.abc', 'hello world')) .then(() => ng('build')) - .then(() => expectFileToExist('dist/favicon.ico')) - .then(() => expectFileToExist('dist/assets/.file')) - .then(() => expectFileToMatch('dist/assets/test.abc', 'hello world')) - .then(() => expectToFail(() => expectFileToExist('dist/assets/.gitkeep'))) + .then(() => expectFileToExist(`${getClientDist()}favicon.ico`)) + .then(() => expectFileToExist(`${getClientDist()}assets/.file`)) + .then(() => expectFileToMatch(`${getClientDist()}assets/test.abc`, 'hello world')) + .then(() => expectToFail(() => expectFileToExist(`${getClientDist()}assets/.gitkeep`))) // doesn't break beta.16 projects .then(() => updateJsonFile('angular-cli.json', configJson => { const app = configJson['apps'][0]; app['assets'] = 'assets'; })) - .then(() => expectFileToExist('dist/assets/.file')) - .then(() => expectFileToMatch('dist/assets/test.abc', 'hello world')); + .then(() => expectFileToExist(`${getClientDist()}assets/.file`)) + .then(() => expectFileToMatch(`${getClientDist()}assets/test.abc`, 'hello world')); } diff --git a/tests/e2e/tests/misc/lazy-module.ts b/tests/e2e/tests/misc/lazy-module.ts index 488217ad35c5..658a3b5df862 100644 --- a/tests/e2e/tests/misc/lazy-module.ts +++ b/tests/e2e/tests/misc/lazy-module.ts @@ -11,14 +11,14 @@ export default function (argv: any) { if (isUniversalTest()) { return Promise.resolve() .then(() => ng('build')) - .then(() => oldNumberOfFiles = readdirSync('dist').length) + .then(() => oldNumberOfFiles = readdirSync('dist/client').length) .then(() => ng('generate', 'module', 'lazy', '--routing')) .then(() => addImportToModule('src/app/app.browser.module.ts', oneLine` RouterModule.forRoot([{ path: "lazy", loadChildren: "app/lazy/lazy.module#LazyModule" }]), RouterModule.forRoot([{ path: "lazy1", loadChildren: "./lazy/lazy.module#LazyModule" }]) `, '@angular/router')) .then(() => ng('build')) - .then(() => readdirSync('dist').length) + .then(() => readdirSync('dist/client').length) .then(currentNumberOfDistFiles => { if (oldNumberOfFiles >= currentNumberOfDistFiles) { throw new Error('A bundle for the lazy module was not created.'); diff --git a/tests/e2e/tests/mobile/prod-features.ts b/tests/e2e/tests/mobile/prod-features.ts index e649c9a53f69..1b53a4b90b36 100644 --- a/tests/e2e/tests/mobile/prod-features.ts +++ b/tests/e2e/tests/mobile/prod-features.ts @@ -1,4 +1,4 @@ -import {isMobileTest, expectToFail} from '../../utils/utils'; +import { isMobileTest, expectToFail, getClientDist } from '../../utils/utils'; import {expectFileToMatch, expectFileToExist} from '../../utils/fs'; @@ -9,12 +9,12 @@ export default function() { return Promise.resolve() // Service Worker - .then(() => expectToFail(() => expectFileToMatch('dist/index.html', + .then(() => expectToFail(() => expectFileToMatch(`${getClientDist()}index.html`, 'if (\'serviceWorker\' in navigator) {'))) - .then(() => expectToFail(() => expectFileToExist('dist/worker.js'))) + .then(() => expectToFail(() => expectFileToExist(`${getClientDist()}worker.js`))) // Asynchronous bundle - .then(() => expectToFail(() => expectFileToMatch('dist/index.html', + .then(() => expectToFail(() => expectFileToMatch(`${getClientDist()}index.html`, ''))) - .then(() => expectToFail(() => expectFileToExist('dist/app-concat.js'))); + .then(() => expectToFail(() => expectFileToExist(`${getClientDist()}app-concat.js`))); } diff --git a/tests/e2e/tests/third-party/bootstrap.ts b/tests/e2e/tests/third-party/bootstrap.ts index ee995f3aa4bb..747254ce6039 100644 --- a/tests/e2e/tests/third-party/bootstrap.ts +++ b/tests/e2e/tests/third-party/bootstrap.ts @@ -2,7 +2,7 @@ import { npm, ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; import { expectFileToMatch } from '../../utils/fs'; import { oneLineTrim } from 'common-tags'; -import { getAppMain } from '../../utils/utils'; +import { getAppMain, getClientDist } from '../../utils/utils'; export default function () { @@ -18,11 +18,15 @@ export default function () { ); })) .then(() => ng('build')) - .then(() => expectFileToMatch('dist/scripts.bundle.js', '/*!\\n * jQuery JavaScript')) - .then(() => expectFileToMatch('dist/scripts.bundle.js', '/*! tether ')) - .then(() => expectFileToMatch('dist/scripts.bundle.js', '/*!\\n * Bootstrap')) - .then(() => expectFileToMatch('dist/styles.bundle.js', '/*!\\n * Bootstrap')) - .then(() => expectFileToMatch('dist/index.html', oneLineTrim` + .then(() => expectFileToMatch( + `${getClientDist()}scripts.bundle.js`, + '/*!\\n * jQuery JavaScript' + ) + ) + .then(() => expectFileToMatch(`${getClientDist()}scripts.bundle.js`, '/*! tether ')) + .then(() => expectFileToMatch(`${getClientDist()}scripts.bundle.js`, '/*!\\n * Bootstrap')) + .then(() => expectFileToMatch(`${getClientDist()}styles.bundle.js`, '/*!\\n * Bootstrap')) + .then(() => expectFileToMatch(`${getClientDist()}index.html`, oneLineTrim` diff --git a/tests/e2e/utils/utils.ts b/tests/e2e/utils/utils.ts index 89af5299366e..cd0b86e46253 100644 --- a/tests/e2e/utils/utils.ts +++ b/tests/e2e/utils/utils.ts @@ -18,6 +18,10 @@ export function getAppMain() { return isUniversalTest() ? 'client' : 'main'; } +export function getClientDist() { + return isUniversalTest() ? 'dist/client/' : 'dist/'; +} + export function wait(msecs: number) { return new Promise((resolve) => { setTimeout(resolve, msecs); From ef2104f25d389bfe8a8dd8ef5b49b5e23c6c0c8d Mon Sep 17 00:00:00 2001 From: David Rouyer Date: Mon, 19 Dec 2016 13:41:15 +0100 Subject: [PATCH 26/38] feat(cli): update to angular-cli beta >= 21 closes #21 --- package.json | 2 +- packages/@ngtools/webpack/src/plugin.ts | 26 +++- .../universal/files/__path__/client.ts | 2 +- .../universal/files/__path__/server.ts | 2 +- .../ember-cli/lib/models/update-checker.js | 104 --------------- .../ember-cli/lib/tasks/update.js | 118 ------------------ .../ember-cli/lib/utilities/npm.js | 38 ------ .../models/webpack-build-typescript.ts | 7 +- packages/universal-cli/tasks/serve-webpack.ts | 8 +- tests/acceptance/new.spec.ts | 5 +- .../not/so/source/tsconfig.json | 1 + .../webpack/test-app-weird/package.json | 22 ++-- tests/e2e/tests/build/aot-i18n.ts | 10 +- 13 files changed, 56 insertions(+), 289 deletions(-) delete mode 100644 packages/universal-cli/ember-cli/lib/models/update-checker.js delete mode 100644 packages/universal-cli/ember-cli/lib/tasks/update.js delete mode 100644 packages/universal-cli/ember-cli/lib/utilities/npm.js diff --git a/package.json b/package.json index 45761509ed2e..3598c4d217cd 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,6 @@ "node-sass": "^3.10.1", "nopt": "^3.0.1", "nodemon": "^1.11.0", - "npm-run-all": "^3.0.0", "offline-plugin": "^3.4.1", "opn": "4.0.1", "ora": "^0.2.0", @@ -117,6 +116,7 @@ "source-map": "^0.5.6", "source-map-loader": "^0.1.5", "sourcemap-istanbul-instrumenter-loader": "^0.2.0", + "string-replace-webpack-plugin": "0.0.4", "style-loader": "^0.13.1", "stylus": "^0.54.5", "stylus-loader": "^2.1.0", diff --git a/packages/@ngtools/webpack/src/plugin.ts b/packages/@ngtools/webpack/src/plugin.ts index 4ac9b891de69..bedf13c604b6 100644 --- a/packages/@ngtools/webpack/src/plugin.ts +++ b/packages/@ngtools/webpack/src/plugin.ts @@ -25,8 +25,10 @@ export interface AotPluginOptions { entryModule?: string; mainPath?: string; typeChecking?: boolean; - skipCodeGeneration?: boolean; + i18nFile?: string; + i18nFormat?: string; + locale?: string; } @@ -78,6 +80,9 @@ export class AotPlugin implements Tapable { private _basePath: string; private _genDir: string; + private _i18nFile: string; + private _i18nFormat: string; + private _locale: string; constructor(options: AotPluginOptions) { this._setupOptions(options); @@ -93,6 +98,9 @@ export class AotPlugin implements Tapable { get program() { return this._program; } get skipCodeGeneration() { return this._skipCodeGeneration; } get typeCheck() { return this._typeCheck; } + get i18nFile() { return this._i18nFile; } + get i18nFormat() { return this._i18nFormat; } + get locale() { return this._locale; } private _setupOptions(options: AotPluginOptions) { // Fill in the missing options. @@ -153,6 +161,16 @@ export class AotPlugin implements Tapable { 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; + } + if (options.hasOwnProperty('i18nFormat')) { + this._i18nFormat = options.i18nFormat; + } + if (options.hasOwnProperty('locale')) { + this._locale = options.locale; + } } // registration hook for webpack plugin @@ -222,9 +240,9 @@ export class AotPlugin implements Tapable { this._resourceLoader = new WebpackResourceLoader(compilation); const i18nOptions: ngCompiler.NgcCliOptions = { - i18nFile: undefined, - i18nFormat: undefined, - locale: undefined, + i18nFile: this.i18nFile, + i18nFormat: this.i18nFormat, + locale: this.locale, basePath: this.basePath }; diff --git a/packages/universal-cli/blueprints/universal/files/__path__/client.ts b/packages/universal-cli/blueprints/universal/files/__path__/client.ts index d60b4ec3b240..6e1dff147e6b 100644 --- a/packages/universal-cli/blueprints/universal/files/__path__/client.ts +++ b/packages/universal-cli/blueprints/universal/files/__path__/client.ts @@ -1,8 +1,8 @@ -import './__2.1.1.workaround.ts'; // temporary until 2.1.1 things are patched in Core /** * the polyfills must be the first thing imported */ import './polyfills.ts'; +import './__2.1.1.workaround.ts'; // temporary until 2.1.1 things are patched in Core import { enableProdMode } from '@angular/core'; import { environment } from './environments/environment'; import { platformUniversalDynamic } from 'angular2-universal'; diff --git a/packages/universal-cli/blueprints/universal/files/__path__/server.ts b/packages/universal-cli/blueprints/universal/files/__path__/server.ts index cfb761bcf6e9..d9cd7b7067c3 100644 --- a/packages/universal-cli/blueprints/universal/files/__path__/server.ts +++ b/packages/universal-cli/blueprints/universal/files/__path__/server.ts @@ -1,8 +1,8 @@ -import './__2.1.1.workaround.ts'; // temporary until 2.1.1 things are patched in Core /** * the polyfills must be the first thing imported */ import './polyfills.ts'; +import './__2.1.1.workaround.ts'; // temporary until 2.1.1 things are patched in Core import * as path from 'path'; import * as express from 'express'; import * as compression from 'compression'; diff --git a/packages/universal-cli/ember-cli/lib/models/update-checker.js b/packages/universal-cli/ember-cli/lib/models/update-checker.js deleted file mode 100644 index 2fa371c075b4..000000000000 --- a/packages/universal-cli/ember-cli/lib/models/update-checker.js +++ /dev/null @@ -1,104 +0,0 @@ -'use strict'; - -var Promise = require('../ext/promise'); -var versionUtils = require('../utilities/version-utils'); -var chalk = require('chalk'); -var debug = require('debug')('ember-cli:update-checker'); -var emberCLIVersion = versionUtils.emberCLIVersion; - -module.exports = UpdateChecker; - -function UpdateChecker(ui, settings, localVersion) { - this.ui = ui; - this.settings = settings; - this.localVersion = localVersion || emberCLIVersion(); - this.versionConfig = null; - - debug('version: %s', this.localVersion); - debug('version: %o', this.settings); -} - -/** -* Checks local config or npm for most recent version of ember-cli -*/ -UpdateChecker.prototype.checkForUpdates = function() { - // if 'checkForUpdates' is true, check for an updated ember-cli version - debug('checkingcheckForUpdates: %o', this.settings.checkingcheckForUpdates); - if (this.settings.checkForUpdates) { - return this.doCheck().then(function(updateInfo) { - debug('updatedNeeded %o', updateInfo.updateNeeded); - if (updateInfo.updateNeeded) { - this.ui.writeLine(''); - this.ui.writeLine('A new version of ember-cli is available (' + - updateInfo.newestVersion + ').'); - } - return updateInfo; - }.bind(this)); - } else { - return Promise.resolve({ - updateNeeded: false - }); - } -}; - -UpdateChecker.prototype.doCheck = function() { - this.versionConfig = this.versionConfig || new (require('configstore'))('ember-cli-version'); - var lastVersionCheckAt = this.versionConfig.get('lastVersionCheckAt'); - var now = new Date().getTime(); - - return new Promise(function(resolve, reject) { - // if the last check was less than a day ago, don't remotely check version - if (lastVersionCheckAt && lastVersionCheckAt > (now - 86400000)) { - resolve(this.versionConfig.get('newestVersion')); - } - - reject(); - }.bind(this)).catch(function() { - return this.checkNPM(); - }.bind(this)).then(function(version) { - var isDevBuild = versionUtils.isDevelopment(this.localVersion); - var updateNeeded = false; - - if (!isDevBuild) { - updateNeeded = version && require('semver').lt(this.localVersion, version); - } - - return { - updateNeeded: updateNeeded, - newestVersion: version - }; - }.bind(this)); -}; - -UpdateChecker.prototype.checkNPM = function() { - // use npm to determine the currently availabe ember-cli version - var loadNPM = Promise.denodeify(require('npm').load); - var fetchEmberCliVersion = function(npm) { - return Promise.denodeify(npm.commands.view)(['ember-cli', 'version']); - }; - var extractVersion = function(data) { return Object.keys(data)[0]; }; - - return loadNPM({ - 'loglevel': 'silent', - 'fetch-retries': 1, - 'cache-min': 1, - 'cache-max': 0 - }) - .then(fetchEmberCliVersion) - .then(extractVersion) - .then(this.saveVersionInformation.bind(this)) - .catch(function() { - this.ui.writeLine(chalk.red('An error occurred while checking for Ember CLI updates. ' + - 'Please verify your internet connectivity and npm configurations.')); - return false; - }.bind(this)); -}; - -UpdateChecker.prototype.saveVersionInformation = function(version) { - var versionConfig = this.versionConfig; - var now = new Date().getTime(); - - // save version so we don't have to check again for another day - versionConfig.set('newestVersion', version); - versionConfig.set('lastVersionCheckAt', now); -}; diff --git a/packages/universal-cli/ember-cli/lib/tasks/update.js b/packages/universal-cli/ember-cli/lib/tasks/update.js deleted file mode 100644 index df64550200ae..000000000000 --- a/packages/universal-cli/ember-cli/lib/tasks/update.js +++ /dev/null @@ -1,118 +0,0 @@ -'use strict'; - -var Promise = require('../ext/promise'); -var chalk = require('chalk'); -var Task = require('../models/task'); -var fs = require('fs'); -var path = require('path'); - -function npmInstall(npm) { - return Promise.denodeify(npm.commands.install)(['ember-cli']); -} - -module.exports = Task.extend({ - init: function() { - this.npm = this.npm || require('npm'); - }, - - run: function(options, updateInfo) { - var env = options.environment || 'development'; - - process.env.EMBER_ENV = process.env.EMBER_ENV || env; - - this.ui.writeLine(''); - this.ui.writeLine(chalk.yellow('A new version of ember-cli is available (' + - updateInfo.newestVersion + ').')); - - var updatePrompt = { - type: 'confirm', - name: 'answer', - message: 'Are you sure you want to update ember-cli?', - choices: [ - { key: 'y', name: 'Yes, update', value: 'yes' }, - { key: 'n', name: 'No, cancel', value: 'no' } - ] - }; - - return this.ui.prompt(updatePrompt).then(function(response) { - if (response.answer === true) { - return this.runNpmUpdate(updateInfo.newestVersion); - } - }.bind(this)); - }, - - runNpmUpdate: function(newestVersion) { - this.ui.startProgress(chalk.green('Updating ember-cli'), chalk.green('.')); - - // first, run `npm install -g ember-cli` - var npm = this.npm; - var loadNPM = Promise.denodeify(npm.load); - - var stopProgress = (function() { - this.ui.stopProgress(); - }.bind(this)); - - var reportFailure = (function(reason) { - this.ui.writeLine('There was an error – possibly a permissions issue. You ' + - 'may need to manually run ' + - chalk.green('npm install -g ember-cli') + '.'); - throw reason; - }.bind(this)); - - var updateDependencies = (function() { - var pkg = this.project.pkg; - var packagePath = path.join(this.project.root, 'package.json'); - - if (!pkg) { - this.ui.write('There was an error locating your package.json file.'); - return false; - } - - pkg.devDependencies['ember-cli'] = newestVersion; - fs.writeFileSync(packagePath, JSON.stringify(pkg, null, 2)); - this.ui.writeLine(''); - this.ui.writeLine(chalk.green('✓ ember-cli was successfully updated!')); - - return this.showEmberInitPrompt(); - }.bind(this)); - - return loadNPM({ - loglevel: 'silent', - global: true - }) - .then(npmInstall) - .then(updateDependencies) - .catch(reportFailure) - .finally(stopProgress); - }, - - showEmberInitPrompt: function() { - this.ui.writeLine('To complete the update, you need to run ' + - chalk.green('ember init') + ' in your project directory.'); - - var initPrompt = { - type: 'confirm', - name: 'answer', - message: 'Would you like to run ' + chalk.green('ember init') + ' now?', - choices: [ - { key: 'y', name: 'Yes', value: 'yes' }, - { key: 'n', name: 'No', value: 'no' } - ] - }; - - return this.ui.prompt(initPrompt).then(function(response) { - if (response.answer === true) { - var InitCommand = this.commands.Init; - - var initCommand = new InitCommand({ - ui: this.ui, - analytics: this.analytics, - tasks: this.tasks, - project: this.project - }); - - return initCommand.run({}, []); - } - }.bind(this)); - } -}); diff --git a/packages/universal-cli/ember-cli/lib/utilities/npm.js b/packages/universal-cli/ember-cli/lib/utilities/npm.js deleted file mode 100644 index a5be7e82466b..000000000000 --- a/packages/universal-cli/ember-cli/lib/utilities/npm.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; - -var Promise = require('../ext/promise'); - -// - -/** - Runs the npm command `command` with the supplied args and load options. - - Please note that the loaded module appears to retain some state, so do not - expect multiple invocations within the same process to work without quirks. - This problem is likely fixable. - - @method npm - @param {String} command The npm command to run. - @param {Array} npmArgs The arguments passed to the npm command. - @param {Array} options The options passed when loading npm. - @param {Module} [npm] A reference to the npm module. -*/ -module.exports = function npm(command, npmArgs, options/*, npm*/) { - var lib; - if (arguments.length === 4) { - lib = arguments[3]; - } else { - lib = require('npm'); - } - - var load = Promise.denodeify(lib.load); - - return load(options) - .then(function() { - // if install is denodeified outside load.then(), - // it throws "Call npm.load(config, cb) before using this command." - var operation = Promise.denodeify(lib.commands[command]); - - return operation(npmArgs || []); - }); -}; diff --git a/packages/universal-cli/models/webpack-build-typescript.ts b/packages/universal-cli/models/webpack-build-typescript.ts index f7f09a7745a0..40de6bb09dd9 100644 --- a/packages/universal-cli/models/webpack-build-typescript.ts +++ b/packages/universal-cli/models/webpack-build-typescript.ts @@ -44,8 +44,11 @@ export const getWebpackAotConfigPartial = function(projectRoot: string, appConfi plugins: [ new AotPlugin({ tsConfigPath: path.resolve(projectRoot, appConfig.root, appConfig.tsconfig), - mainPath: path.join(projectRoot, appConfig.root, appConfig.main) - }) + mainPath: path.join(projectRoot, appConfig.root, appConfig.main), + i18nFile: i18nFile, + i18nFormat: i18nFormat, + locale: locale + }), ] }; }; diff --git a/packages/universal-cli/tasks/serve-webpack.ts b/packages/universal-cli/tasks/serve-webpack.ts index 4c48a86cc512..b75498575d0c 100644 --- a/packages/universal-cli/tasks/serve-webpack.ts +++ b/packages/universal-cli/tasks/serve-webpack.ts @@ -54,11 +54,15 @@ export default Task.extend({ entryPoints.push('webpack/hot/dev-server'); configs[0].plugins.push(new webpack.HotModuleReplacementPlugin()); } - configs[0].entry.main.unshift(...entryPoints); + + const appConfig = CliConfig.fromProject().config.apps[0]; + + if (appConfig.universal === false) { + configs[0].entry.main.unshift(...entryPoints); + } webpackCompiler = webpack(configs); const statsConfig = getWebpackStatsConfig(serveTaskOptions.verbose); - const appConfig = CliConfig.fromProject().config.apps[0]; let proxyConfig = {}; if (serveTaskOptions.proxyConfig) { diff --git a/tests/acceptance/new.spec.ts b/tests/acceptance/new.spec.ts index 86e07b0fa198..cb488126185e 100644 --- a/tests/acceptance/new.spec.ts +++ b/tests/acceptance/new.spec.ts @@ -4,7 +4,7 @@ const existsSync = require('exists-sync'); const expect = require('chai').expect; const forEach = require('lodash/forEach'); const walkSync = require('walk-sync'); -const Blueprint = require('angular-cli/ember-cli/lib/models/blueprint'); +const Blueprint = require('universal-cli/ember-cli/lib/models/blueprint'); const path = require('path'); const tmp = require('../helpers/tmp'); const root = process.cwd(); @@ -138,7 +138,8 @@ describe('Acceptance: ung new', function () { }); }); - it('ung new with --directory uses given directory name and has correct package name', function () { + it('ung new with --directory uses given directory name and has correct package name', + function () { return ng(['new', 'foo', '--skip-npm', '--skip-bower', '--skip-git', '--directory=bar']) .then(function () { const cwd = process.cwd(); 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 721113e471d8..74a0d8f522a4 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,5 +1,6 @@ { "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 9b766d3f7fbf..58992bd35b1c 100644 --- a/tests/e2e/assets/webpack/test-app-weird/package.json +++ b/tests/e2e/assets/webpack/test-app-weird/package.json @@ -2,19 +2,19 @@ "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.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", "@ngtools/webpack": "0.0.0", "core-js": "^2.4.1", - "rxjs": "5.0.0-beta.12", - "zone.js": "^0.6.23" + "rxjs": "^5.0.0-beta.12", + "zone.js": "^0.6.21" }, "devDependencies": { "node-sass": "^3.7.0", diff --git a/tests/e2e/tests/build/aot-i18n.ts b/tests/e2e/tests/build/aot-i18n.ts index a78605adbb23..427a761464cb 100644 --- a/tests/e2e/tests/build/aot-i18n.ts +++ b/tests/e2e/tests/build/aot-i18n.ts @@ -1,12 +1,12 @@ import {ng} from '../../utils/process'; import {expectFileToMatch, writeFile, createDir, appendToFile} from '../../utils/fs'; -import {isUniversalTest, expectToFail} from '../../utils/utils'; +import {expectToFail, isUniversalTest} from '../../utils/utils'; export default function() { - if (isUniversalTest()) { - return Promise.resolve() - .then(() => expectToFail(() => ng('build', '--aot'))); - } else { + if (isUniversalTest()) { + return Promise.resolve() + .then(() => expectToFail(() => ng('build', '--aot'))); + } else { return Promise.resolve() .then(() => createDir('src/locale')) .then(() => writeFile('src/locale/messages.fr.xlf', ` From fa74f3f24f9f8cad3cba3b724af5d8366368767a Mon Sep 17 00:00:00 2001 From: David Rouyer Date: Thu, 29 Dec 2016 11:43:26 +0100 Subject: [PATCH 27/38] fix(deps): upgrade node-sass & sass-loader closes #44 --- package.json | 4 ++-- packages/universal-cli/package.json | 4 ++-- tests/e2e/assets/webpack/test-app-weird/package.json | 4 ++-- tests/e2e/assets/webpack/test-app/package.json | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 3598c4d217cd..6d331cddf5e1 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,7 @@ "markdown-it-terminal": "0.0.3", "minimatch": "^3.0.3", "node-modules-path": "^1.0.0", - "node-sass": "^3.10.1", + "node-sass": "^4.1.1", "nopt": "^3.0.1", "nodemon": "^1.11.0", "offline-plugin": "^3.4.1", @@ -109,7 +109,7 @@ "rimraf": "^2.5.3", "rsvp": "^3.0.17", "rxjs": "5.0.0-beta.12", - "sass-loader": "^4.0.1", + "sass-loader": "^4.1.1", "script-loader": "^0.7.0", "semver": "^5.1.0", "silent-error": "^1.0.0", diff --git a/packages/universal-cli/package.json b/packages/universal-cli/package.json index 50a599539469..c7700d4eae83 100644 --- a/packages/universal-cli/package.json +++ b/packages/universal-cli/package.json @@ -68,7 +68,7 @@ "markdown-it-terminal": "0.0.3", "minimatch": "^3.0.3", "node-modules-path": "^1.0.0", - "node-sass": "^3.10.1", + "node-sass": "^4.1.1", "nodemon": "^1.10.0", "nopt": "^3.0.1", "offline-plugin": "^3.4.1", @@ -84,7 +84,7 @@ "resolve": "^1.1.7", "rimraf": "^2.5.3", "rsvp": "^3.0.17", - "sass-loader": "^4.0.1", + "sass-loader": "^4.1.1", "script-loader": "^0.7.0", "semver": "^5.1.0", "silent-error": "^1.0.0", diff --git a/tests/e2e/assets/webpack/test-app-weird/package.json b/tests/e2e/assets/webpack/test-app-weird/package.json index 58992bd35b1c..1500e6833b03 100644 --- a/tests/e2e/assets/webpack/test-app-weird/package.json +++ b/tests/e2e/assets/webpack/test-app-weird/package.json @@ -17,10 +17,10 @@ "zone.js": "^0.6.21" }, "devDependencies": { - "node-sass": "^3.7.0", + "node-sass": "^4.1.1", "performance-now": "^0.2.0", "raw-loader": "^0.5.1", - "sass-loader": "^3.2.0", + "sass-loader": "^4.1.1", "typescript": "~2.0.3", "webpack": "2.1.0-beta.22" } diff --git a/tests/e2e/assets/webpack/test-app/package.json b/tests/e2e/assets/webpack/test-app/package.json index 45e8f827fb20..e629f21c9007 100644 --- a/tests/e2e/assets/webpack/test-app/package.json +++ b/tests/e2e/assets/webpack/test-app/package.json @@ -17,10 +17,10 @@ "zone.js": "^0.6.23" }, "devDependencies": { - "node-sass": "^3.7.0", + "node-sass": "^4.1.1", "performance-now": "^0.2.0", "raw-loader": "^0.5.1", - "sass-loader": "^3.2.0", + "sass-loader": "^4.1.1", "typescript": "~2.0.3", "webpack": "2.1.0-beta.25" } From 758f1ea73f13395e3a08007cbdaf898c71a3dfa1 Mon Sep 17 00:00:00 2001 From: David Rouyer Date: Thu, 29 Dec 2016 14:46:36 +0100 Subject: [PATCH 28/38] fix(deps): lock @ngtools/webpack version --- packages/universal-cli/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/universal-cli/package.json b/packages/universal-cli/package.json index c7700d4eae83..b72c3364a998 100644 --- a/packages/universal-cli/package.json +++ b/packages/universal-cli/package.json @@ -31,7 +31,7 @@ "@angular/compiler": "2.2.3", "@angular/compiler-cli": "2.2.3", "@angular/core": "2.2.3", - "@ngtools/webpack": "^1.0.0", + "@ngtools/webpack": "1.1.9", "async": "^2.1.4", "autoprefixer": "^6.5.3", "chalk": "^1.1.3", From 5225a94e936add7c3fe1091585b2ae4e93e95140 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 29 Dec 2016 17:45:25 +0100 Subject: [PATCH 29/38] v1.0.0-alpha.universal.3 --- CHANGELOG.md | 69 +++++++++++++++++++++++++++++ package.json | 2 +- packages/universal-cli/package.json | 2 +- 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c30f0a06b01b..d45bc87f4b08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,72 @@ + +# [1.0.0-alpha.universal.3](https://github.com/devCrossNet/universal-cli/compare/v1.0.0-alpha.universal.2-2...v1.0.0-alpha.universal.3) (2016-12-29) + + +### Bug Fixes + +* **@ngtools/webpack:** fixed path resolution for entry modules and lazy routes ([#3332](https://github.com/devCrossNet/universal-cli/issues/3332)) ([45d5154](https://github.com/devCrossNet/universal-cli/commit/45d5154)) +* **@ngtools/webpack:** keep the decorators in. ([#3583](https://github.com/devCrossNet/universal-cli/issues/3583)) ([db25183](https://github.com/devCrossNet/universal-cli/commit/db25183)) +* **@ngtools/webpack:** performance improvement. ([#3360](https://github.com/devCrossNet/universal-cli/issues/3360)) ([4dcfe27](https://github.com/devCrossNet/universal-cli/commit/4dcfe27)) +* **@ngtools/webpack:** report errors during codegen ([#3608](https://github.com/devCrossNet/universal-cli/issues/3608)) ([0f604ac](https://github.com/devCrossNet/universal-cli/commit/0f604ac)) +* **@ngtools/webpack:** use tsconfig declaration flag to report decl errors ([#3499](https://github.com/devCrossNet/universal-cli/issues/3499)) ([c46de15](https://github.com/devCrossNet/universal-cli/commit/c46de15)) +* **aot:** lock the angular version to 2.2.1. ([#3242](https://github.com/devCrossNet/universal-cli/issues/3242)) ([6e8a848](https://github.com/devCrossNet/universal-cli/commit/6e8a848)) +* **blueprints:** remove app root barrel ([#3530](https://github.com/devCrossNet/universal-cli/issues/3530)) ([3329d46](https://github.com/devCrossNet/universal-cli/commit/3329d46)), closes [#3369](https://github.com/devCrossNet/universal-cli/issues/3369) +* **build:** added autoprefixer to prod ([1648d51](https://github.com/devCrossNet/universal-cli/commit/1648d51)), closes [#3156](https://github.com/devCrossNet/universal-cli/issues/3156) [#3164](https://github.com/devCrossNet/universal-cli/issues/3164) +* **build:** don't inline sourcemaps ([#3262](https://github.com/devCrossNet/universal-cli/issues/3262)) ([859d905](https://github.com/devCrossNet/universal-cli/commit/859d905)) +* **build:** pin [@types](https://github.com/types)/lodash ([#3465](https://github.com/devCrossNet/universal-cli/issues/3465)) ([9b65481](https://github.com/devCrossNet/universal-cli/commit/9b65481)) +* **build:** use custom index value when copying to 404.html during github deploy ([#3201](https://github.com/devCrossNet/universal-cli/issues/3201)) ([b1cbf17](https://github.com/devCrossNet/universal-cli/commit/b1cbf17)) +* **completion:** Update with the new help command ([#3479](https://github.com/devCrossNet/universal-cli/issues/3479)) ([0b5dc74](https://github.com/devCrossNet/universal-cli/commit/0b5dc74)) +* **dependencies:** reduce the dependencies further. ([#3488](https://github.com/devCrossNet/universal-cli/issues/3488)) ([901a64f](https://github.com/devCrossNet/universal-cli/commit/901a64f)) +* **deploy:** clean up gh-pages obsolete files ([#3081](https://github.com/devCrossNet/universal-cli/issues/3081)) ([#3333](https://github.com/devCrossNet/universal-cli/issues/3333)) ([51869fb](https://github.com/devCrossNet/universal-cli/commit/51869fb)) +* **deploy:** gh-pages checkout initial branch on error ([#3378](https://github.com/devCrossNet/universal-cli/issues/3378)) ([c5cd095](https://github.com/devCrossNet/universal-cli/commit/c5cd095)), closes [#3030](https://github.com/devCrossNet/universal-cli/issues/3030) [#2663](https://github.com/devCrossNet/universal-cli/issues/2663) [#1259](https://github.com/devCrossNet/universal-cli/issues/1259) +* **deploy:** gh-pages deploy fail after repo create ([#3386](https://github.com/devCrossNet/universal-cli/issues/3386)) ([0a68cc5](https://github.com/devCrossNet/universal-cli/commit/0a68cc5)), closes [#3385](https://github.com/devCrossNet/universal-cli/issues/3385) +* **deps:** lock [@ngtools](https://github.com/ngtools)/webpack version ([758f1ea](https://github.com/devCrossNet/universal-cli/commit/758f1ea)) +* **deps:** upgrade node-sass & sass-loader ([fa74f3f](https://github.com/devCrossNet/universal-cli/commit/fa74f3f)), closes [#44](https://github.com/devCrossNet/universal-cli/issues/44) +* **editorconfig:** use off instead of 0 for max line length ([#3186](https://github.com/devCrossNet/universal-cli/issues/3186)) ([f833d25](https://github.com/devCrossNet/universal-cli/commit/f833d25)) +* **gitignore:** No longer ignore VSCode settings ([#3477](https://github.com/devCrossNet/universal-cli/issues/3477)) ([8d88446](https://github.com/devCrossNet/universal-cli/commit/8d88446)) +* **help:** fix `ng help ` ([#3442](https://github.com/devCrossNet/universal-cli/issues/3442)) ([51659b9](https://github.com/devCrossNet/universal-cli/commit/51659b9)) +* **init:** The option '--universal' is not registered with the init command ([37c8357](https://github.com/devCrossNet/universal-cli/commit/37c8357)), closes [#27](https://github.com/devCrossNet/universal-cli/issues/27) [#24](https://github.com/devCrossNet/universal-cli/issues/24) +* **new:** Make sure the project name is valid. ([#3478](https://github.com/devCrossNet/universal-cli/issues/3478)) ([e836f92](https://github.com/devCrossNet/universal-cli/commit/e836f92)) +* **ngtools/webpack:** move the generate directory to a separate dir ([#3256](https://github.com/devCrossNet/universal-cli/issues/3256)) ([d1037df](https://github.com/devCrossNet/universal-cli/commit/d1037df)) +* **test:** exclude non spec files from test.ts ([#3538](https://github.com/devCrossNet/universal-cli/issues/3538)) ([bcb324f](https://github.com/devCrossNet/universal-cli/commit/bcb324f)) +* **universal:** remove duplicate entry from package.json ([47b34a2](https://github.com/devCrossNet/universal-cli/commit/47b34a2)), closes [#26](https://github.com/devCrossNet/universal-cli/issues/26) +* **version:** bump ast-tools and webpack versions to correct mismatch with published packages ([54ef738](https://github.com/devCrossNet/universal-cli/commit/54ef738)) +* **webpack:** correctly load component stylesheets ([#3511](https://github.com/devCrossNet/universal-cli/issues/3511)) ([d4da7bd](https://github.com/devCrossNet/universal-cli/commit/d4da7bd)) +* **webpack:** fix some problems with errors not reported. ([#3444](https://github.com/devCrossNet/universal-cli/issues/3444)) ([09f9aa9](https://github.com/devCrossNet/universal-cli/commit/09f9aa9)) +* change apiFilter querystring to query in ng doc([#3383](https://github.com/devCrossNet/universal-cli/issues/3383)) ([5b2a0fb](https://github.com/devCrossNet/universal-cli/commit/5b2a0fb)), closes [#3363](https://github.com/devCrossNet/universal-cli/issues/3363) +* **webpack:** remove usage of __dirname from the config. ([#3422](https://github.com/devCrossNet/universal-cli/issues/3422)) ([8597786](https://github.com/devCrossNet/universal-cli/commit/8597786)) + + +### Features + +* **angular:** Update Angular2 version to 2.2.3 ([#3295](https://github.com/devCrossNet/universal-cli/issues/3295)) ([ed305a2](https://github.com/devCrossNet/universal-cli/commit/ed305a2)) +* **build:** add --verbose and --progress flags ([#2858](https://github.com/devCrossNet/universal-cli/issues/2858)) ([f6f24e7](https://github.com/devCrossNet/universal-cli/commit/f6f24e7)), closes [#1836](https://github.com/devCrossNet/universal-cli/issues/1836) [#2012](https://github.com/devCrossNet/universal-cli/issues/2012) +* **build:** add lazy styles/scripts ([#3402](https://github.com/devCrossNet/universal-cli/issues/3402)) ([20bb864](https://github.com/devCrossNet/universal-cli/commit/20bb864)), closes [#3401](https://github.com/devCrossNet/universal-cli/issues/3401) [#3400](https://github.com/devCrossNet/universal-cli/issues/3400) +* Make CLI available without install ([761e86f](https://github.com/devCrossNet/universal-cli/commit/761e86f)), closes [#3126](https://github.com/devCrossNet/universal-cli/issues/3126) +* **build:** auto generate vendor chunk ([#3117](https://github.com/devCrossNet/universal-cli/issues/3117)) ([bf9c8f1](https://github.com/devCrossNet/universal-cli/commit/bf9c8f1)) +* **cli:** update to angular-cli beta >= 21 ([ef2104f](https://github.com/devCrossNet/universal-cli/commit/ef2104f)), closes [#21](https://github.com/devCrossNet/universal-cli/issues/21) +* **deps:** Unblock the version of Angular to >= 2.3 ([#3569](https://github.com/devCrossNet/universal-cli/issues/3569)) ([bd03100](https://github.com/devCrossNet/universal-cli/commit/bd03100)) +* **generate:** change generate --prefix option type from Boolean to string ([#3457](https://github.com/devCrossNet/universal-cli/issues/3457)) ([8d5a915](https://github.com/devCrossNet/universal-cli/commit/8d5a915)) +* **i18n:** add i18n command line options ([#3098](https://github.com/devCrossNet/universal-cli/issues/3098)) ([2a0a42d](https://github.com/devCrossNet/universal-cli/commit/2a0a42d)) +* **module:** component optional when generating module ([#3389](https://github.com/devCrossNet/universal-cli/issues/3389)) ([2fb2d13](https://github.com/devCrossNet/universal-cli/commit/2fb2d13)) +* **new:** include routing in spec and inline template when called with `--routing` ([#3252](https://github.com/devCrossNet/universal-cli/issues/3252)) ([53ab4df](https://github.com/devCrossNet/universal-cli/commit/53ab4df)) +* **serve:** add --hmr flag for HotModuleReplacement support ([#3330](https://github.com/devCrossNet/universal-cli/issues/3330)) ([46efa9e](https://github.com/devCrossNet/universal-cli/commit/46efa9e)) +* **serve:** Add support to open with ssl. ([#3432](https://github.com/devCrossNet/universal-cli/issues/3432)) ([83dfc96](https://github.com/devCrossNet/universal-cli/commit/83dfc96)) + + +### Performance Improvements + +* **install time:** Remove dependency to zopfli. ([#3414](https://github.com/devCrossNet/universal-cli/issues/3414)) ([e6364a9](https://github.com/devCrossNet/universal-cli/commit/e6364a9)) + + +### BREAKING CHANGES + +* blueprints: The app root module and component must now be imported directly. (e.g., use `import { AppModule } from './app/app.module';` instead of `import { AppModule } from './app/';`) +* build: `ng build/serve` now generates `vendor.bundle.js` by +default. + + + # [1.0.0-alpha.universal.2](https://github.com/devCrossNet/angular-cli/compare/v1.0.0-beta.19...v1.0.0-alpha.universal.2) (2016-11-26) diff --git a/package.json b/package.json index 6d331cddf5e1..7f0536725bb1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "universal-cli", - "version": "1.0.0-alpha.universal.2-2", + "version": "1.0.0-alpha.universal.3", "description": "CLI tool for Angular with Angular Universal support", "main": "packages/universal-cli/lib/cli/index.js", "trackingCode": "xx-xxxxxxx-xx", diff --git a/packages/universal-cli/package.json b/packages/universal-cli/package.json index b72c3364a998..0bf021c4e78e 100644 --- a/packages/universal-cli/package.json +++ b/packages/universal-cli/package.json @@ -1,6 +1,6 @@ { "name": "universal-cli", - "version": "1.0.0-alpha.universal.2-2", + "version": "1.0.0-alpha.universal.3", "cliVersion": "1.0.0-beta.23", "description": "CLI tool for Angular with Angular Universal support", "main": "lib/cli/index.js", From f36cfd41e1781e19389f7654d9ae478ab4950ed7 Mon Sep 17 00:00:00 2001 From: Jose Zamudio Date: Wed, 8 Feb 2017 01:12:06 -0800 Subject: [PATCH 30/38] fix(readme): change ng to ung --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 785131cc51f8..a157988f30b1 100644 --- a/README.md +++ b/README.md @@ -75,11 +75,7 @@ npm install -g universal-cli ## Usage ```bash -<<<<<<< HEAD ung --help -======= -ng help ->>>>>>> upstream/master ``` ### Generating and serving an Angular2 project via a development server From 325a63d6535be0101fe0a0ae6fbc3735f6696ad9 Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Wed, 8 Feb 2017 15:38:07 +0100 Subject: [PATCH 31/38] chore(deps): update dependencies --- package.json | 9 +++++---- .../universal-cli/blueprints/ng2/files/__path__/test.ts | 1 + packages/universal-cli/package.json | 9 +++++---- tests/e2e/utils/project.ts | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 7f0536725bb1..bb3b4b9fb387 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ }, "homepage": "https://github.com/devCrossNet/universal-cli", "dependencies": { - "@angular-cli/ast-tools": "^1.0.0", + "@angular-cli/ast-tools": "1.0.10", "@angular/compiler": "2.2.3", "@angular/compiler-cli": "2.2.3", "@angular/core": "2.2.3", @@ -66,7 +66,7 @@ "ember-cli-string-utils": "^1.0.0", "enhanced-resolve": "^2.3.0", "exists-sync": "0.0.3", - "extract-text-webpack-plugin": "^2.0.0-beta.4", + "extract-text-webpack-plugin": "2.0.0-beta.4", "file-loader": "^0.8.5", "findup": "0.1.5", "fs-extra": "^0.30.0", @@ -134,7 +134,8 @@ "webpack-md5-hash": "0.0.5", "webpack-merge": "^0.14.0", "webpack-sources": "^0.1.3", - "yam": "0.0.18" + "yam": "0.0.18", + "zone.js": "0.6.23" }, "ember-addon": { "paths": [ @@ -150,7 +151,7 @@ "@types/fs-extra": "^0.0.31", "@types/glob": "^5.0.29", "@types/jasmine": "^2.2.32", - "@types/lodash": "^4.14.43", + "@types/lodash": "4.14.50", "@types/mock-fs": "3.6.28", "@types/node": "^6.0.36", "@types/request": "0.0.30", diff --git a/packages/universal-cli/blueprints/ng2/files/__path__/test.ts b/packages/universal-cli/blueprints/ng2/files/__path__/test.ts index be44dc587f3a..f1fc7a814880 100644 --- a/packages/universal-cli/blueprints/ng2/files/__path__/test.ts +++ b/packages/universal-cli/blueprints/ng2/files/__path__/test.ts @@ -1,4 +1,5 @@ import './polyfills.ts'; +<% if(universal) { %>import './__2.1.1.workaround.ts';<% } %> import 'zone.js/dist/long-stack-trace-zone'; import 'zone.js/dist/proxy.js'; diff --git a/packages/universal-cli/package.json b/packages/universal-cli/package.json index 0bf021c4e78e..c9ea4aef1e8c 100644 --- a/packages/universal-cli/package.json +++ b/packages/universal-cli/package.json @@ -26,8 +26,8 @@ }, "homepage": "https://github.com/devCrossNet/universal-cli", "dependencies": { - "@angular-cli/ast-tools": "^1.0.1", - "@angular-cli/base-href-webpack": "^1.0.0", + "@angular-cli/ast-tools": "1.0.10", + "@angular-cli/base-href-webpack": "1.0.0", "@angular/compiler": "2.2.3", "@angular/compiler-cli": "2.2.3", "@angular/core": "2.2.3", @@ -45,7 +45,7 @@ "ember-cli-preprocess-registry": "^2.0.0", "ember-cli-string-utils": "^1.0.0", "exists-sync": "0.0.3", - "extract-text-webpack-plugin": "^2.0.0-beta.4", + "extract-text-webpack-plugin": "2.0.0-beta.4", "file-loader": "^0.8.5", "findup": "0.1.5", "fs-extra": "^0.30.0", @@ -108,7 +108,8 @@ "webpack-md5-hash": "0.0.5", "webpack-merge": "^0.14.0", "webpack-sources": "^0.1.3", - "yam": "0.0.18" + "yam": "0.0.18", + "zone.js": "0.6.23" }, "ember-addon": { "paths": [ diff --git a/tests/e2e/utils/project.ts b/tests/e2e/utils/project.ts index fda1bd67a5f6..acdfdcfc2120 100644 --- a/tests/e2e/utils/project.ts +++ b/tests/e2e/utils/project.ts @@ -22,7 +22,7 @@ export function updateTsConfig(fn: (json: any) => any | void) { export function ngServe(...args: string[]) { return silentExecAndWaitForOutputToMatch('ung', - ['serve', '--no-progress', ...args], /webpack: bundle is now VALID/); + ['serve', '--no-progress', ...args], /(VALID|successfully)/); } From a10409f11b54413b4919811f7fd6b9101de36889 Mon Sep 17 00:00:00 2001 From: David Rouyer Date: Wed, 8 Feb 2017 19:31:58 +0100 Subject: [PATCH 32/38] fix(lint): use noUnusedParameters and noUnusedLocals instead of no-unused-variable & fix lint errors --- packages/@ngtools/webpack/src/plugin.ts | 4 ++-- packages/@ngtools/webpack/src/refactor.ts | 2 +- packages/universal-cli/lib/webpack/compression-plugin.ts | 4 ++-- packages/universal-cli/models/json-schema/schema-tree.ts | 4 ++-- packages/universal-cli/tasks/server/universal-dev-server.ts | 2 +- tsconfig.json | 2 ++ tslint.json | 1 - 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/@ngtools/webpack/src/plugin.ts b/packages/@ngtools/webpack/src/plugin.ts index bedf13c604b6..e76d445cdd49 100644 --- a/packages/@ngtools/webpack/src/plugin.ts +++ b/packages/@ngtools/webpack/src/plugin.ts @@ -75,8 +75,8 @@ export class AotPlugin implements Tapable { private _compiler: any = null; private _compilation: any = null; - private _typeCheck: boolean = true; - private _skipCodeGeneration: boolean = false; + private _typeCheck = true; + private _skipCodeGeneration = false; private _basePath: string; private _genDir: string; diff --git a/packages/@ngtools/webpack/src/refactor.ts b/packages/@ngtools/webpack/src/refactor.ts index 9ae55c401fd6..47c50d0e6227 100644 --- a/packages/@ngtools/webpack/src/refactor.ts +++ b/packages/@ngtools/webpack/src/refactor.ts @@ -25,7 +25,7 @@ export class TypeScriptFileRefactor { private _sourceFile: ts.SourceFile; private _sourceString: any; private _sourceText: string; - private _changed: boolean = false; + private _changed = false; get fileName() { return this._fileName; } get sourceFile() { return this._sourceFile; } diff --git a/packages/universal-cli/lib/webpack/compression-plugin.ts b/packages/universal-cli/lib/webpack/compression-plugin.ts index 32c627f17f58..6bae1ea0f697 100644 --- a/packages/universal-cli/lib/webpack/compression-plugin.ts +++ b/packages/universal-cli/lib/webpack/compression-plugin.ts @@ -26,8 +26,8 @@ export class CompressionPlugin { private algorithm: Function; private compressionOptions: any = {}; private test: RegExp[]; - private threshold: number = 0; - private minRatio: number = 0.8; + private threshold = 0; + private minRatio = 0.8; constructor(options: CompressionPluginOptions = {}) { if (options.hasOwnProperty('asset')) { diff --git a/packages/universal-cli/models/json-schema/schema-tree.ts b/packages/universal-cli/models/json-schema/schema-tree.ts index 2dd120a22788..86a5d66fa4fc 100644 --- a/packages/universal-cli/models/json-schema/schema-tree.ts +++ b/packages/universal-cli/models/json-schema/schema-tree.ts @@ -30,8 +30,8 @@ export abstract class SchemaTreeNode { // Hierarchy objects protected _parent: SchemaTreeNode; - protected _defined: boolean = false; - protected _dirty: boolean = false; + protected _defined = false; + protected _dirty = false; protected _schema: Schema; protected _name: string; diff --git a/packages/universal-cli/tasks/server/universal-dev-server.ts b/packages/universal-cli/tasks/server/universal-dev-server.ts index 798176058066..b762ab984efb 100644 --- a/packages/universal-cli/tasks/server/universal-dev-server.ts +++ b/packages/universal-cli/tasks/server/universal-dev-server.ts @@ -4,7 +4,7 @@ const nodemon = require('nodemon'); const tinyLr = require('tiny-lr'); export class UniversalDevServer { - private appPath: string = ''; + private appPath = ''; private nodemonConfig: any; private demon: any; private liveServer: any; diff --git a/tsconfig.json b/tsconfig.json index 5b347e108311..8c45a865e1ee 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,8 @@ "moduleResolution": "node", "noEmitOnError": true, "noImplicitAny": true, + "noUnusedParameters": true, + "noUnusedLocals": true, "outDir": "./dist", "rootDir": ".", "sourceMap": true, diff --git a/tslint.json b/tslint.json index 6cb5eba50936..76d10b577016 100644 --- a/tslint.json +++ b/tslint.json @@ -19,7 +19,6 @@ "no-trailing-whitespace": true, "no-bitwise": true, "no-unused-expression": true, - "no-unused-variable": true, "no-var-keyword": true, "one-line": [ true, From e303f205ecc5f424f3cd66741ee1eee76c47f2d1 Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Thu, 9 Feb 2017 11:36:09 +0100 Subject: [PATCH 33/38] fix(deps): remove zone from cli deps --- package.json | 3 +-- packages/universal-cli/package.json | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index bb3b4b9fb387..29d069cfd085 100644 --- a/package.json +++ b/package.json @@ -134,8 +134,7 @@ "webpack-md5-hash": "0.0.5", "webpack-merge": "^0.14.0", "webpack-sources": "^0.1.3", - "yam": "0.0.18", - "zone.js": "0.6.23" + "yam": "0.0.18" }, "ember-addon": { "paths": [ diff --git a/packages/universal-cli/package.json b/packages/universal-cli/package.json index c9ea4aef1e8c..d6b4b3427257 100644 --- a/packages/universal-cli/package.json +++ b/packages/universal-cli/package.json @@ -108,8 +108,7 @@ "webpack-md5-hash": "0.0.5", "webpack-merge": "^0.14.0", "webpack-sources": "^0.1.3", - "yam": "0.0.18", - "zone.js": "0.6.23" + "yam": "0.0.18" }, "ember-addon": { "paths": [ From 773fd0aad74fe1b8d44f37afcb2d64f653ca6e18 Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Thu, 9 Feb 2017 13:05:35 +0100 Subject: [PATCH 34/38] chore(travis): remove node 4 from config; disable email notifications --- .travis.yml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index fab1629b7078..0d3fbaa714c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,9 +20,6 @@ matrix: - node_js: "6" os: linux env: SCRIPT=build - - node_js: "4" - os: linux - env: NODE_SCRIPT=tests/e2e_runner.js - node_js: "6" os: linux env: SCRIPT=test @@ -43,18 +40,12 @@ matrix: - node_js: "7" os: linux env: NODE_SCRIPT=tests/e2e_runner.js - - node_js: "4" - os: osx - env: UNIVERSAL=true NODE_SCRIPT=tests/e2e_runner.js - node_js: "5" os: osx env: UNIVERSAL=true NODE_SCRIPT=tests/e2e_runner.js - node_js: "6" os: osx env: UNIVERSAL=true NODE_SCRIPT=tests/e2e_runner.js - - node_js: "4" - os: linux - env: UNIVERSAL=true NODE_SCRIPT=tests/e2e_runner.js - node_js: "5" os: linux env: UNIVERSAL=true NODE_SCRIPT=tests/e2e_runner.js @@ -71,7 +62,6 @@ before_install: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sh -e /etc/init.d/xvfb start; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export CHROME_BIN=chromium-browser; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then echo "--no-sandbox" > ~/.config/chromium-flags.conf; fi - - if [[ "$TARGET" == "mobile" ]]; then export MOBILE_TEST=true; fi - npm install -g npm - npm config set spin false - npm config set progress false @@ -82,3 +72,6 @@ install: script: - if [[ "$SCRIPT" ]]; then npm run-script $SCRIPT; fi - if [[ "$NODE_SCRIPT" ]]; then node $NODE_SCRIPT; fi + +notifications: + email: false From cf50ae9fa3d040767983a763c75fcdaa2582de5a Mon Sep 17 00:00:00 2001 From: FrozenPandaz Date: Mon, 13 Feb 2017 09:02:14 -0500 Subject: [PATCH 35/38] fix(deps): @types/jasmine 2.5.42 is broken (#73) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 29d069cfd085..fb4d227cd72e 100644 --- a/package.json +++ b/package.json @@ -149,7 +149,7 @@ "@types/express": "^4.0.32", "@types/fs-extra": "^0.0.31", "@types/glob": "^5.0.29", - "@types/jasmine": "^2.2.32", + "@types/jasmine": "2.5.41", "@types/lodash": "4.14.50", "@types/mock-fs": "3.6.28", "@types/node": "^6.0.36", From 738b1d66d99877132da0f5a87cb86b56e3f28b12 Mon Sep 17 00:00:00 2001 From: Jason Jean Date: Thu, 2 Mar 2017 20:37:51 -0500 Subject: [PATCH 36/38] Support AoT on Client Side (#72) * feat(cli): support aot on client side * fix(cli): include altered app.module * fix(cli): reversed condition for exports vs bootstrap * feat(cli): add common module to app.module * fix(tests): re-enabled aot tests * chore(format): added semicolon * chore(lint): remove trailing whitespace * use app main * fix(tests): use app main * fix(tests): add getMainAppModule util and create accurate regexp for aot * fix(tests): generate the whole regex --- .../ng2/files/__path__/app/app.module.ts | 14 +++-- .../universal-cli/blueprints/ng2/index.js | 1 - .../files/__path__/app/app.browser.module.ts | 7 +-- .../files/__path__/app/app.node.module.ts | 8 +-- .../universal/files/__path__/client.ts | 8 +-- .../universal/files/__path__/server.ts | 4 +- .../universal-cli/models/webpack-config.ts | 4 +- tests/acceptance/init.spec.js | 1 - tests/e2e/tests/build/aot-i18n.ts | 55 +++++++++---------- tests/e2e/tests/build/aot.ts | 13 ++--- tests/e2e/utils/utils.ts | 6 ++ 11 files changed, 58 insertions(+), 63 deletions(-) diff --git a/packages/universal-cli/blueprints/ng2/files/__path__/app/app.module.ts b/packages/universal-cli/blueprints/ng2/files/__path__/app/app.module.ts index 51485d6538e3..21486bfbe784 100644 --- a/packages/universal-cli/blueprints/ng2/files/__path__/app/app.module.ts +++ b/packages/universal-cli/blueprints/ng2/files/__path__/app/app.module.ts @@ -1,4 +1,6 @@ -import { BrowserModule } from '@angular/platform-browser'; +<% if(!universal) { %> +import { BrowserModule } from '@angular/platform-browser';<% } else { %> +import { CommonModule } from '@angular/common';<% } %> import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { HttpModule } from '@angular/http';<% if (routing) { %> @@ -10,13 +12,15 @@ import { AppComponent } from './app.component'; declarations: [ AppComponent ], - imports: [ - BrowserModule, + imports: [<% if(!universal) { %> + BrowserModule,<% } else { %> + CommonModule,<% } %> FormsModule, HttpModule<% if (routing) { %>, AppRoutingModule<% } %> ], - providers: [], - bootstrap: [AppComponent] + providers: [],<% if(universal) { %> + exports: [AppComponent]<% } else { %> + bootstrap: [AppComponent]<% } %> }) export class AppModule { } diff --git a/packages/universal-cli/blueprints/ng2/index.js b/packages/universal-cli/blueprints/ng2/index.js index 2e5d88305365..f994cd0f9870 100644 --- a/packages/universal-cli/blueprints/ng2/index.js +++ b/packages/universal-cli/blueprints/ng2/index.js @@ -85,7 +85,6 @@ module.exports = { if (this.options && this.options.universal) { fileList = fileList.filter(p => p.indexOf('main.ts') < 0); - fileList = fileList.filter(p => p.indexOf('app.module.ts') < 0); } return fileList; diff --git a/packages/universal-cli/blueprints/universal/files/__path__/app/app.browser.module.ts b/packages/universal-cli/blueprints/universal/files/__path__/app/app.browser.module.ts index 70d9d9525f80..063c9e20b255 100644 --- a/packages/universal-cli/blueprints/universal/files/__path__/app/app.browser.module.ts +++ b/packages/universal-cli/blueprints/universal/files/__path__/app/app.browser.module.ts @@ -9,6 +9,7 @@ import { NgModule } from '@angular/core'; import { UniversalModule } from 'angular2-universal'; import { FormsModule } from '@angular/forms'; +import { AppModule } from './app.module'; import { AppComponent } from './index'; // import { RouterModule } from '@angular/router'; // import { appRoutes } from './app/app.routing'; @@ -19,21 +20,19 @@ import { AppComponent } from './index'; @NgModule({ /** Root App Component */ bootstrap: [ AppComponent ], - /** Our Components */ - declarations: [ AppComponent ], imports: [ /** * NOTE: Needs to be your first import (!) * BrowserModule, HttpModule, and JsonpModule are included */ UniversalModule, - FormsModule + AppModule /** * using routes */ // RouterModule.forRoot(appRoutes) ] }) -export class AppModule { +export class BrowserAppModule { } diff --git a/packages/universal-cli/blueprints/universal/files/__path__/app/app.node.module.ts b/packages/universal-cli/blueprints/universal/files/__path__/app/app.node.module.ts index 89298579c259..8257d956ea9d 100644 --- a/packages/universal-cli/blueprints/universal/files/__path__/app/app.node.module.ts +++ b/packages/universal-cli/blueprints/universal/files/__path__/app/app.node.module.ts @@ -8,7 +8,7 @@ import { NgModule } from '@angular/core'; import { UniversalModule } from 'angular2-universal'; -import { FormsModule } from '@angular/forms'; +import { AppModule } from './app.module'; import { AppComponent } from './index'; // import { RouterModule } from '@angular/router'; // import { appRoutes } from './app/app.routing'; @@ -19,21 +19,19 @@ import { AppComponent } from './index'; @NgModule({ /** Root App Component */ bootstrap: [ AppComponent ], - /** Our Components */ - declarations: [ AppComponent ], imports: [ /** * NOTE: Needs to be your first import (!) * NodeModule, NodeHttpModule, NodeJsonpModule are included */ UniversalModule, - FormsModule + AppModule /** * using routes */ // RouterModule.forRoot(appRoutes) ] }) -export class AppModule { +export class NodeAppModule { } diff --git a/packages/universal-cli/blueprints/universal/files/__path__/client.ts b/packages/universal-cli/blueprints/universal/files/__path__/client.ts index 6e1dff147e6b..323be2847c1c 100644 --- a/packages/universal-cli/blueprints/universal/files/__path__/client.ts +++ b/packages/universal-cli/blueprints/universal/files/__path__/client.ts @@ -5,8 +5,8 @@ import './polyfills.ts'; import './__2.1.1.workaround.ts'; // temporary until 2.1.1 things are patched in Core import { enableProdMode } from '@angular/core'; import { environment } from './environments/environment'; -import { platformUniversalDynamic } from 'angular2-universal'; -import { AppModule } from './app/app.browser.module'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { BrowserAppModule } from './app/app.browser.module'; /** * enable prod mode for production environments @@ -15,6 +15,4 @@ if (environment.production) { enableProdMode(); } -const platformRef = platformUniversalDynamic(); - -platformRef.bootstrapModule(AppModule); +platformBrowserDynamic().bootstrapModule(BrowserAppModule); diff --git a/packages/universal-cli/blueprints/universal/files/__path__/server.ts b/packages/universal-cli/blueprints/universal/files/__path__/server.ts index d9cd7b7067c3..93108419e767 100644 --- a/packages/universal-cli/blueprints/universal/files/__path__/server.ts +++ b/packages/universal-cli/blueprints/universal/files/__path__/server.ts @@ -8,7 +8,7 @@ import * as express from 'express'; import * as compression from 'compression'; import { createEngine } from 'angular2-express-engine'; import { enableProdMode } from '@angular/core'; -import { AppModule } from './app/app.node.module'; +import { NodeAppModule } from './app/app.node.module'; import { environment } from './environments/environment'; import { routes } from './server.routes'; @@ -56,7 +56,7 @@ function ngApp(req: any, res: any) { res.render('index', { req, res, - ngModule: AppModule, + ngModule: NodeAppModule, preboot: false, baseUrl: '/', requestUrl: req.originalUrl, diff --git a/packages/universal-cli/models/webpack-config.ts b/packages/universal-cli/models/webpack-config.ts index 561bd986af5f..f37af7b7f28e 100644 --- a/packages/universal-cli/models/webpack-config.ts +++ b/packages/universal-cli/models/webpack-config.ts @@ -40,7 +40,7 @@ export class NgCliWebpackConfig { appConfig.outDir = outputDir || appConfig.outDir; if (appConfig.universal === true && isAoT === true) { - throw new Error('AoT is not supported in universal yet.'); + console.warn('For now, AoT is only supported on client side.'); } let baseConfig = getWebpackCommonConfig( @@ -84,7 +84,7 @@ export class NgCliWebpackConfig { )); this.configs.push(webpackMerge( - typescriptConfigPartial, + getWebpackNonAotConfigPartial(this.ngCliProject.root, appConfig), getWebpackNodeConfig( this.ngCliProject.root, environment, diff --git a/tests/acceptance/init.spec.js b/tests/acceptance/init.spec.js index 9ec88abc3811..003dd8e38561 100644 --- a/tests/acceptance/init.spec.js +++ b/tests/acceptance/init.spec.js @@ -66,7 +66,6 @@ describe('Acceptance: ung init', function () { } if (additionalFolders.indexOf('universal') > -1) { expected = expected.filter(p => p.indexOf('main.ts') < 0); - expected = expected.filter(p => p.indexOf('app.module.ts') < 0); } if (!routing) { diff --git a/tests/e2e/tests/build/aot-i18n.ts b/tests/e2e/tests/build/aot-i18n.ts index 427a761464cb..2ba04a8ce605 100644 --- a/tests/e2e/tests/build/aot-i18n.ts +++ b/tests/e2e/tests/build/aot-i18n.ts @@ -1,34 +1,31 @@ import {ng} from '../../utils/process'; import {expectFileToMatch, writeFile, createDir, appendToFile} from '../../utils/fs'; -import {expectToFail, isUniversalTest} from '../../utils/utils'; +import {expectToFail, getAppMain, getClientDist} from '../../utils/utils'; export default function() { - if (isUniversalTest()) { - return Promise.resolve() - .then(() => expectToFail(() => ng('build', '--aot'))); - } else { - return Promise.resolve() - .then(() => createDir('src/locale')) - .then(() => writeFile('src/locale/messages.fr.xlf', ` - - - - - - Hello i18n! - Bonjour i18n! - An introduction header for this sample - - - - `)) - .then(() => appendToFile('src/app/app.component.html', - '

Hello i18n!

')) - .then(() => ng('build', '--aot', '--i18n-file', 'src/locale/messages.fr.xlf', '--i18n-format', - 'xlf', '--locale', 'fr')) - .then(() => expectFileToMatch('dist/main.bundle.js', /Bonjour i18n!/)) - .then(() => ng('build', '--aot')) - .then(() => expectToFail(() => expectFileToMatch('dist/main.bundle.js', /Bonjour i18n!/))) - .then(() => expectFileToMatch('dist/main.bundle.js', /Hello i18n!/)); - } + return Promise.resolve() + .then(() => createDir('src/locale')) + .then(() => writeFile('src/locale/messages.fr.xlf', ` + + + + + + Hello i18n! + Bonjour i18n! + An introduction header for this sample + + + + `)) + .then(() => appendToFile('src/app/app.component.html', + '

Hello i18n!

')) + .then(() => ng('build', '--aot', '--i18n-file', 'src/locale/messages.fr.xlf', '--i18n-format', + 'xlf', '--locale', 'fr')) + .then(() => expectFileToMatch(`${getClientDist()}${getAppMain()}.bundle.js`, /Bonjour i18n!/)) + .then(() => ng('build', '--aot')) + .then(() => expectToFail(() => { + return expectFileToMatch(`${getClientDist()}${getAppMain()}.bundle.js`, /Bonjour i18n!/); + })) + .then(() => expectFileToMatch(`${getClientDist()}${getAppMain()}.bundle.js`, /Hello i18n!/)); } diff --git a/tests/e2e/tests/build/aot.ts b/tests/e2e/tests/build/aot.ts index e06d2fc16bdf..29574a8063d5 100644 --- a/tests/e2e/tests/build/aot.ts +++ b/tests/e2e/tests/build/aot.ts @@ -1,14 +1,9 @@ import { ng } from '../../utils/process'; import { expectFileToMatch } from '../../utils/fs'; -import { isUniversalTest, expectToFail, getClientDist } from '../../utils/utils'; +import { getClientDist, getAppMain, getMainAppModuleRegex } from '../../utils/utils'; export default function () { - if (isUniversalTest()) { - return Promise.resolve() - .then(() => expectToFail(() => ng('build', '--aot'))); - } else { - return ng('build', '--aot') - .then(() => expectFileToMatch(`${getClientDist()}main.bundle.js`, - /bootstrapModuleFactory.*\/\* AppModuleNgFactory \*\//)); - } + return ng('build', '--aot') + .then(() => expectFileToMatch(`${getClientDist()}${getAppMain()}.bundle.js`, + getMainAppModuleRegex())); } diff --git a/tests/e2e/utils/utils.ts b/tests/e2e/utils/utils.ts index cd0b86e46253..1ae4fc15bb45 100644 --- a/tests/e2e/utils/utils.ts +++ b/tests/e2e/utils/utils.ts @@ -22,6 +22,12 @@ export function getClientDist() { return isUniversalTest() ? 'dist/client/' : 'dist/'; } +export function getMainAppModuleRegex() { + return isUniversalTest() ? + /bootstrapModuleFactory.*\/\* BrowserAppModuleNgFactory \*\// : + /bootstrapModuleFactory.*\/\* AppModuleNgFactory \*\//; +} + export function wait(msecs: number) { return new Promise((resolve) => { setTimeout(resolve, msecs); From e8715f86fc8aeb0bac630b811f59ece9cceded85 Mon Sep 17 00:00:00 2001 From: Jason Jean Date: Thu, 9 Mar 2017 15:10:54 -0500 Subject: [PATCH 37/38] fix(@angular/cli): lock codelyzer version --- packages/universal-cli/blueprints/ng2/files/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/universal-cli/blueprints/ng2/files/package.json b/packages/universal-cli/blueprints/ng2/files/package.json index 8cafcb3635d1..ffb0befcedb3 100644 --- a/packages/universal-cli/blueprints/ng2/files/package.json +++ b/packages/universal-cli/blueprints/ng2/files/package.json @@ -51,7 +51,7 @@ "@types/mime": "0.0.28", "@types/serve-static": "^1.7.27",<% } %> "universal-cli": "<%= version %>", - "codelyzer": "~2.0.0-beta.1", + "codelyzer": "2.0.0", "jasmine-core": "2.5.2", "jasmine-spec-reporter": "2.5.0", "karma": "1.2.0", From d4da9dce06ce67c83601df93593a5ea742d2fd5c Mon Sep 17 00:00:00 2001 From: Johannes Werner Date: Thu, 3 Aug 2017 09:34:45 +0200 Subject: [PATCH 38/38] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a157988f30b1..68613766e806 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ -## Universal-CLI +# this project is no longer maintained! + + +### Universal-CLI Universal-CLI is fork from Angular-CLI. It supports Angular Universal (with `--universal` flag after `ung new` or `ung init`), see [Support for server side rendering](#support-for-server-side-rendering) for detail. It is a separate package because the Core-CLI team is not able to maintain non-core functionality.