diff --git a/CHANGELOG.md b/CHANGELOG.md index d84eff3468be..ff9b20b7ae72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,37 @@ + +# [1.0.0-rc.2](https://github.com/angular/angular-cli/compare/v1.0.0-rc.1...v1.0.0-rc.2) (2017-03-13) + +### Bug Fixes + +* **@angular/cli:** add missing alias for guard blueprint ([#5339](https://github.com/angular/angular-cli/issues/5339)) ([9b70fda](https://github.com/angular/angular-cli/commit/9b70fda)), closes [#5336](https://github.com/angular/angular-cli/issues/5336) +* **@angular/cli:** Align tsconfig output dir to out-tsc. Add out-tsc to .gitignore ([e9372d3](https://github.com/angular/angular-cli/commit/e9372d3)), closes [#5220](https://github.com/angular/angular-cli/issues/5220) +* **@angular/cli:** don't break deployUrl with scheme ([501e974](https://github.com/angular/angular-cli/commit/501e974)), closes [#5254](https://github.com/angular/angular-cli/issues/5254) +* **@angular/cli:** eject command removes EOF ([7461528](https://github.com/angular/angular-cli/commit/7461528)), closes [#5387](https://github.com/angular/angular-cli/issues/5387) +* **@angular/cli:** enforce loglevel warn for npm-install ([07e93c0](https://github.com/angular/angular-cli/commit/07e93c0)), closes [#5010](https://github.com/angular/angular-cli/issues/5010) +* **@angular/cli:** ensure lint generates well-formed machine output ([c99cf96](https://github.com/angular/angular-cli/commit/c99cf96)), closes [#5259](https://github.com/angular/angular-cli/issues/5259) [#5224](https://github.com/angular/angular-cli/issues/5224) +* **@angular/cli:** fix e2e after eject ([3b39843](https://github.com/angular/angular-cli/commit/3b39843)), closes [#4957](https://github.com/angular/angular-cli/issues/4957) +* **@angular/cli:** Fix filtering files on completion ([cf14a15](https://github.com/angular/angular-cli/commit/cf14a15)), closes [#4664](https://github.com/angular/angular-cli/issues/4664) [#4972](https://github.com/angular/angular-cli/issues/4972) +* **@angular/cli:** fix ide import errors ([8a1b1f9](https://github.com/angular/angular-cli/commit/8a1b1f9)) +* **@angular/cli:** fix issue with console prompt bailing early ([#5218](https://github.com/angular/angular-cli/issues/5218)) ([3515c3b](https://github.com/angular/angular-cli/commit/3515c3b)), closes [#4614](https://github.com/angular/angular-cli/issues/4614) [#5127](https://github.com/angular/angular-cli/issues/5127) +* **@angular/cli:** fix TS2.1 typeroots ([#5251](https://github.com/angular/angular-cli/issues/5251)) ([1c2f361](https://github.com/angular/angular-cli/commit/1c2f361)), closes [#5082](https://github.com/angular/angular-cli/issues/5082) +* **@angular/cli:** Fixing aliases for blueprint help ([b6cc79c](https://github.com/angular/angular-cli/commit/b6cc79c)) +* **@angular/cli:** Fixing generate help command fix ([7f0333a](https://github.com/angular/angular-cli/commit/7f0333a)) +* **@angular/cli:** Fixing set prefix issue ([#5301](https://github.com/angular/angular-cli/issues/5301)) ([1f8363a](https://github.com/angular/angular-cli/commit/1f8363a)) +* **@angular/cli:** Fixing setting enums ([7e2c04f](https://github.com/angular/angular-cli/commit/7e2c04f)) +* **@angular/cli:** karma config is default for test command ([#5263](https://github.com/angular/angular-cli/issues/5263)) ([c2a8569](https://github.com/angular/angular-cli/commit/c2a8569)) +* **@angular/cli:** Log xi18n errors ([a54115c](https://github.com/angular/angular-cli/commit/a54115c)), closes [#5129](https://github.com/angular/angular-cli/issues/5129) [#5223](https://github.com/angular/angular-cli/issues/5223) +* **@angular/cli:** make flag values case insensitive ([#5355](https://github.com/angular/angular-cli/issues/5355)) ([8d8ddfc](https://github.com/angular/angular-cli/commit/8d8ddfc)), closes [#5344](https://github.com/angular/angular-cli/issues/5344) +* **@angular/cli:** only adjust root relative stylesheet urls ([1e7d519](https://github.com/angular/angular-cli/commit/1e7d519)), closes [#5238](https://github.com/angular/angular-cli/issues/5238) +* **@angular/cli:** remove outdated test command option `--build` ([fcb1f35](https://github.com/angular/angular-cli/commit/fcb1f35)), closes [#5235](https://github.com/angular/angular-cli/issues/5235) +* **@angular/cli:** remove providers from routing modules ([#5349](https://github.com/angular/angular-cli/issues/5349)) ([c8e5359](https://github.com/angular/angular-cli/commit/c8e5359)) +* **@angular/cli:** rephrased warning message ([e314135](https://github.com/angular/angular-cli/commit/e314135)), closes [#5006](https://github.com/angular/angular-cli/issues/5006) +* **@angular/cli:** use inheritance for ng4 ([7c3ce6b](https://github.com/angular/angular-cli/commit/7c3ce6b)), closes [#5111](https://github.com/angular/angular-cli/issues/5111) +* **@angular/cli:** yarn install does not support --quiet ([#5310](https://github.com/angular/angular-cli/issues/5310)) ([5e54a01](https://github.com/angular/angular-cli/commit/5e54a01)) +* **@angular/cli:** bump to tslint 4.5.0 ([a78a727](https://github.com/angular/angular-cli/commit/a78a727)), closes [#5099](https://github.com/angular/angular-cli/issues/5099) +* **@angular/cli:** use standard stackTraceLimit ([#5284](https://github.com/angular/angular-cli/issues/5284)) ([5c9c653](https://github.com/angular/angular-cli/commit/5c9c653)) + + + # [1.0.0-rc.1](https://github.com/angular/angular-cli/compare/v1.0.0-rc.0...v1.0.0-rc.1) (2017-03-03) diff --git a/README.md b/README.md index 784ae23dc072..d8069cd4d5a6 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@ CLI for Angular applications based on the [ember-cli](http://www.ember-cli.com/) ## Note The CLI is now in Release Candidate (RC). -If you are updating from a beta version, check out our [RC.0 Update Guide] -(https://github.com/angular/angular-cli/wiki/stories-rc.0-update). +If you are updating from a beta version, check out our [RC Update Guide] +(https://github.com/angular/angular-cli/wiki/stories-rc-update). If you wish to collaborate, check out [our issue list](https://github.com/angular/angular-cli/issues). @@ -57,10 +57,10 @@ ng 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 : +You can configure the default HTTP host and port used by the development server with two command-line options : ```bash -ng serve --host 0.0.0.0 --port 4201 --live-reload-port 49153 +ng serve --host 0.0.0.0 --port 4201 ``` ### Generating Components, Directives, Pipes and Services @@ -88,6 +88,7 @@ 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` +Guard | `ng g guard my-new-guard` Interface | `ng g interface my-new-interface` Enum | `ng g enum my-new-enum` Module | `ng g module my-module` @@ -111,7 +112,7 @@ npm install -g @angular/cli@latest Local project package: ```bash -rm -rf node_modules dist # use rmdir on Windows +rm -rf node_modules dist # use rmdir /S/Q node_modules dist in Windows Command Prompt; use rm -r -fo node_modules,dist in Windows PowerShell npm install --save-dev @angular/cli@latest npm install ``` diff --git a/docs/documentation/build.md b/docs/documentation/build.md index fdf4a7335883..31f41dd2a9f0 100644 --- a/docs/documentation/build.md +++ b/docs/documentation/build.md @@ -65,36 +65,46 @@ All builds make use of bundling, and using the `--prod` flag in `ng build --pro or `ng serve --prod` will also make use of uglifying and tree-shaking functionality. ## Options -`--watch` (`-w`) rebuild when files change +`--aot` Build using Ahead of Time compilation. -`--target` (`-t`) define the build target +`--app` Specifies app name or index to use. -`--environment` (`-e`) defines the build environment +`--base-href` (`-bh`) Base url for the application being built. -`--prod` flag to set build target and environment to production +`--deploy-url` (`-d`) URL where files will be deployed. -`--dev` flag to set build target and environment to development +`--dev` Build target and environment to development. `--output-path` (`-op`) path where output will be placed -`--aot` flag whether to build using Ahead of Time compilation +`--environment` (`-e`) Defines the build environment. -`--sourcemap` (`-sm`) output sourcemaps +`--extract-css` (`-ec`) Extract css from global styles onto css files instead of js ones. -`--vendor-chunk` (`-vb`) use a separate bundle containing only vendor libraries +`--i18n-file` Localization file to use for i18n. -`--base-href` (`-bh`) base url for the application being built +`--i18n-format` Format of the localization file specified with --i18n-file. -`--deploy-url` (`-d`) url where files will be deployed +`--locale` Locale to use for i18n. -`--verbose` (`-v`) adds more details to output logging +`--output-hashing` Define the output filename cache-busting hashing mode. -`--progress` (`-pr`) log progress to the console while building +`--output-path` (`-op`) Path where output will be placed. -`--extract-css` (`-ec`) extract css from global styles onto css files instead of js ones +`--poll` Enable and define the file watching poll time period (milliseconds). -`--output-hashing` define the output filename cache-busting hashing mode +`--prod` Build target and environment to production. -`--stats-json` generates a `stats.json` file which can be analyzed using tools such as: `webpack-bundle-analyzer` or https://webpack.github.io/analyse +`--progress` (`-pr`) Log progress to the console while building. -`--poll` enable and define the file watching poll time period (milliseconds) +`--sourcemap` (`-sm`) Output sourcemaps. + +`--stats-json` Generates a `stats.json` file which can be analyzed using tools such as: `webpack-bundle-analyzer` or https://webpack.github.io/analyse. + +`--target` (`-t`) Defines the build target. + +`--vendor-chunk` (`-vc`) Use a separate bundle containing only vendor libraries. + +`--verbose` (`-v`) Adds more details to output logging. + +`--watch` (`-w`) Run build when files change. diff --git a/docs/documentation/config.md b/docs/documentation/config.md index 892021cf7c8f..ec7b6b3d3591 100644 --- a/docs/documentation/config.md +++ b/docs/documentation/config.md @@ -1,4 +1,18 @@ -`ng get` -`ng set` +# ng get + +## Overview +`ng get [key]` Get a value from the configuration. + +## Options +`--global` Get the value in the global configuration (in your home directory). + + +# ng set + +## Overview +`ng set [key]=[value]` Set a value in the configuration. + +## Options +`--global` Set the value in the global configuration rather than in your project's. \ No newline at end of file diff --git a/docs/documentation/doc.md b/docs/documentation/doc.md index 11f92a220a05..44c3f2927a95 100644 --- a/docs/documentation/doc.md +++ b/docs/documentation/doc.md @@ -3,4 +3,4 @@ # ng doc ## Overview -`ng doc [search term]` searches documentation on [angular.io](https://angular.io) +`ng doc [search term]` Opens the official Angular documentation for a given keyword on [angular.io](https://angular.io). diff --git a/docs/documentation/e2e.md b/docs/documentation/e2e.md index 48a0446f6663..58fefdbf0153 100644 --- a/docs/documentation/e2e.md +++ b/docs/documentation/e2e.md @@ -16,14 +16,10 @@ End-to-end tests are run via [Protractor](https://angular.github.io/protractor/) ## Options `--config` (`-c`) use a specific config file. Defaults to the protractor config file in `.angular-cli.json`. -`--specs` (`-sp`) override specs in the protractor config. -Can send in multiple specs by repeating flag (`ng e2e --specs=spec1.ts --specs=spec2.ts`). +`--element-explorer` (`-ee`) Start Protractor's [Element Explorer](https://github.com/angular/protractor/blob/master/docs/debugging.md#testing-out-protractor-interactively) for debugging. -`--element-explorer` (`-ee`) start Protractor's -[Element Explorer](https://github.com/angular/protractor/blob/master/docs/debugging.md#testing-out-protractor-interactively) -for debugging. +`--serve` Compile and Serve the app. All serve options are also available. The live-reload option defaults to false, and the default port will be random. -`--webdriver-update` (`-wu`) try to update webdriver. +`--specs` Override specs in the protractor config. Can send in multiple specs by repeating flag (ng e2e --specs=spec1.ts --specs=spec2.ts). -`--serve` (`-s`) compile and serve the app. -All non-reload related serve options are also available (e.g. `--port=4400`). \ No newline at end of file +`--webdriver-update` (`-wu`) (Default: true) Try to update webdriver. \ No newline at end of file diff --git a/docs/documentation/generate/class.md b/docs/documentation/generate/class.md index 6dc57ad014ba..e63471f033bb 100644 --- a/docs/documentation/generate/class.md +++ b/docs/documentation/generate/class.md @@ -6,4 +6,6 @@ `ng generate class [name]` generates a class ## Options -`--spec` specifies if a spec file is generated +`--app` Specifies app name or index to use. + +`--spec` Specifies if a spec file is generated. diff --git a/docs/documentation/generate/component.md b/docs/documentation/generate/component.md index 5898a3db40e7..5a53bcd0acef 100644 --- a/docs/documentation/generate/component.md +++ b/docs/documentation/generate/component.md @@ -6,22 +6,24 @@ `ng generate component [name]` generates a component ## Options -`--flat` flag to indicate if a dir is created +`--app` Specifies app name or index to use. -`--inline-template` (`-it`) specifies if the template will be in the ts file +`--change-detection` (`-cd`) Specifies the change detection strategy. -`--inline-style` (`-is`) specifies if the style will be in the ts file +`--flat` Flag to indicate if a dir is created. -`--prefix` specifies whether to use the prefix +`--export` Specifies if declaring module exports the component. -`--spec` specifies if a spec file is generated +`--inline-style` (`-is`) Specifies if the style will be in the ts file. -`--view-encapsulation` (`-ve`) specifies the view encapsulation strategy +`--inline-template` (`-it`) Specifies if the template will be in the ts file. -`--change-detection` (`-cd`) specifies the change detection strategy +`--module` (`-m`) Allows specification of the declaring module. -`--skip-import` allows for skipping the module import +`--prefix` Specifies whether to use the prefix. -`--module` (`-m`) allows specification of the declaring module +`--skip-import` Allows for skipping the module import. -`--export` specifies if declaring module exports the component +`--spec` Specifies if a spec file is generated. + +`--view-encapsulation` (`-ve`) Specifies the view encapsulation strategy. \ No newline at end of file diff --git a/docs/documentation/generate/directive.md b/docs/documentation/generate/directive.md index 8ad626b3066f..b63ac06391c9 100644 --- a/docs/documentation/generate/directive.md +++ b/docs/documentation/generate/directive.md @@ -6,14 +6,16 @@ `ng generate directive [name]` generates a directive ## Options -`--flat` flag to indicate if a dir is created +`--app` Specifies app name or index to use. -`--prefix` specifies whether to use the prefix +`--export` Specifies if declaring module exports the component. -`--spec` specifies if a spec file is generated +`--flat` Flag to indicate if a dir is created. -`--skip-import` allows for skipping the module import +`--module` (`-m`) Allows specification of the declaring module. -`--module` (`-m`) allows specification of the declaring module +`--prefix` Specifies whether to use the prefix. -`--export` specifies if declaring module exports the directive +`--skip-import` Allows for skipping the module import. + +`--spec` Specifies if a spec file is generated. diff --git a/docs/documentation/generate/enum.md b/docs/documentation/generate/enum.md index 3542a4681960..8102cdbb1c9d 100644 --- a/docs/documentation/generate/enum.md +++ b/docs/documentation/generate/enum.md @@ -4,3 +4,6 @@ ## Overview `ng generate enum [name]` generates an enumeration + +## Options +`--app` Specifies app name or index to use. diff --git a/docs/documentation/generate/guard.md b/docs/documentation/generate/guard.md index 192efbd0f424..3a78fbcb7ef1 100644 --- a/docs/documentation/generate/guard.md +++ b/docs/documentation/generate/guard.md @@ -4,8 +4,10 @@ `ng generate guard [name]` generates a guard ## Options -`--flat` flag to indicate if a dir is created +`--app` Specifies app name or index to use. -`--spec` specifies if a spec file is generated +`--flat` Indicate if a dir is created. -`--module` (`-m`) allows specification of the declaring module +`--module` (`-m`) Allows specification of the declaring module. + +`--spec` Specifies if a spec file is generated. \ No newline at end of file diff --git a/docs/documentation/generate/interface.md b/docs/documentation/generate/interface.md index e88ed5325b06..57a798de5d74 100644 --- a/docs/documentation/generate/interface.md +++ b/docs/documentation/generate/interface.md @@ -5,6 +5,7 @@ ## Overview `ng generate interface [name] ` generates an interface -## Arguments +## Options +`--app` Specifies app name or index to use. -`type` optional string to specify the type of interface +`type` Optional String to specify the type of interface. diff --git a/docs/documentation/generate/module.md b/docs/documentation/generate/module.md index 763d52e3d59f..18be4219556d 100644 --- a/docs/documentation/generate/module.md +++ b/docs/documentation/generate/module.md @@ -6,9 +6,10 @@ `ng generate module [name]` generates an NgModule ## Options +`--app` Specifies app name or index to use. -`--flat` flag to indicate if a dir is created +`--flat` Flag to indicate if a dir is created. -`--spec` specifies if a spec file is generated +`--spec` Specifies if a spec file is generated. -`--routing` specifies if a routing module file should be generated +`--routing` Specifies if a routing module file should be generated. diff --git a/docs/documentation/generate/pipe.md b/docs/documentation/generate/pipe.md index b576743cb372..7446b069522e 100644 --- a/docs/documentation/generate/pipe.md +++ b/docs/documentation/generate/pipe.md @@ -6,12 +6,14 @@ `ng generate pipe [name]` generates a pipe ## Options -`--flat` flag to indicate if a dir is created +`--app` Specifies app name or index to use. -`--spec` specifies if a spec file is generated +`--export` Specifies if declaring module exports the pipe. -`--skip-import` allows for skipping the module import +`--flat` Flag to indicate if a dir is created. -`--module` (`-m`) allows specification of the declaring module +`--module` (`-m`) Allows specification of the declaring module. -`--export` specifies if declaring module exports the pipe +`--skip-import` Allows for skipping the module import. + +`--spec` Specifies if a spec file is generated. \ No newline at end of file diff --git a/docs/documentation/generate/service.md b/docs/documentation/generate/service.md index 28a9d848abb4..9d7d3a02af85 100644 --- a/docs/documentation/generate/service.md +++ b/docs/documentation/generate/service.md @@ -6,8 +6,10 @@ `ng generate service [name]` generates a service ## Options -`--flat` flag to indicate if a dir is created +`--app` Specifies app name or index to use. -`--spec` specifies if a spec file is generated +`--flat` Flag to indicate if a dir is created. -`--module` (`-m`) allows specification of the declaring module +`--module` (`-m`) Allows you to specify the module where the service should be provided + +`--spec` Specifies if a spec file is generated. diff --git a/docs/documentation/home.md b/docs/documentation/home.md index c56fee1226b4..de912fc3a752 100644 --- a/docs/documentation/home.md +++ b/docs/documentation/home.md @@ -50,9 +50,10 @@ End-to-end tests are run via [Protractor](https://angular.github.io/protractor/) * [ng e2e](e2e) * [ng build](build) * [ng get/ng set](config) -* [ng docs](docs) +* [ng doc](doc) * [ng eject](eject) +* [ng xi18n](xi18n) ### Additional Information There are several [stories](stories) which will walk you through setting up -additional aspects of Angular applciations. +additional aspects of Angular applications. diff --git a/docs/documentation/lint.md b/docs/documentation/lint.md index 16ee05dd9dc2..7d1cd8729f83 100644 --- a/docs/documentation/lint.md +++ b/docs/documentation/lint.md @@ -7,8 +7,8 @@ ## Options -`--fix` will attempt to fix lint errors +`--fix` Fixes linting errors (may overwrite linted files). -`--force` will always return error code 0 even with lint errors +`--force` Succeeds even if there was linting errors. -`--format` (`-t`) the output formatter to use +`--format` (`-t`) Output format (prose, json, stylish, verbose, pmd, msbuild, checkstyle, vso, fileslist). diff --git a/docs/documentation/new.md b/docs/documentation/new.md index 3f4d5361e63e..616908532988 100644 --- a/docs/documentation/new.md +++ b/docs/documentation/new.md @@ -8,22 +8,32 @@ Default applications are created in a directory of the same name, with an initialized Angular application. ## Options -`--dry-run` (`-d`) run through without making any changes +`--directory` (`-dir`) The directory name to create the app in. -`--skip-install` (`-si`) skip installing packages +`--dry-run` (`-d`) Run through without making any changes. -`--skip-git` (`-sg`) skip initializing a git repository +`--inline-style` (`is`) Should have an inline style. -`--directory` (`-dir`) the directory name to create the app in +`--inline-template` (`it`) Should have an inline template. -`--source-dir` (`-sd`) the name of the source directory +`--link-cli` Automatically link the `@angular/cli` package. -`--style` the style file default extension +`--ng4` Create a project with Angular 4 in the template. -`--prefix` (`p`) the prefix to use for all component selectors +`--prefix` (`p`) The prefix to use for all component selectors. -`--routing` flag to indicate whether to generate a routing module +`--routing` Generate a routing module. -`--inline-style` (`is`) flag to indicate if the app component should have an inline style +`--skip-commit` Skip committing the first commit to git. -`--inline-template` (`it`) flag to indicate if the app component should have an inline template +`--skip-git` (`-sg`) Skip initializing a git repository. + +`--skip-install` (`-si`) Skip installing packages. + +`--skip-tests` Skip creating spec files. + +`--source-dir` (`-sd`) The name of the source directory. + +`--style` The style file default extension. + +`--verbose` Adds more details to output logging. \ No newline at end of file diff --git a/docs/documentation/serve.md b/docs/documentation/serve.md index b0a3665798cf..6d722294bdc7 100644 --- a/docs/documentation/serve.md +++ b/docs/documentation/serve.md @@ -5,55 +5,26 @@ ## Overview `ng serve` builds the application and starts a web server -## Options -`--watch` (`-w`) rebuild when files change - -`--port` (`-p`) port to serve the application on - -`--host` (`-H`) host where to listen - -`--proxy-config` (`-pc`) proxy configuration file - -`--live-reload` (`-lr`) flag to turn off live reloading - -`--live-reload-client` specify the URL that the live reload browser client will use - -`--ssl` flag to turn on SSL - -`--ssl-key` path to the SSL key - -`--ssl-cert` path to the SSL cert +All the build Options are available in serve, below are the additional options. -`--open` (`-o`) opens the app in the default browser - -`--hmr` use hot module reload - -`--target` (`-t`) define the build target - -`--environment` (`-e`) defines the build environment - -`--prod` flag to set build target and environment to production - -`--dev` flag to set build target and environment to development - -`--output-path` (`-po`) path where output will be placed - -`--aot` flag whether to build using Ahead of Time compilation +## Options +`--host` (`-H`) Listens only on localhost by default. -`--sourcemap` (`-sm`) output sourcemaps +`--hmr` Enable hot module replacement. -`--vendor-chunk` (`-vb`) use a separate bundle containing only vendor libraries +`--live-reload` (`-lr`) Whether to reload the page on change, using live-reload. -`--base-href` (`-bh`) base url for the application being built +`--live-reload-client` Specify the URL that the live reload browser client will use. -`--deploy-url` (`-d`) url where files will be deployed +`--open` (`-o`) Opens the url in default browser. -`--verbose` (`-v`) adds more details to output logging +`--port` (`-p`) Port to listen to for serving. -`--progress` (`-pr`) log progress to the console while building +`--ssl` Serve using HTTPS. -`--extract-css` (`-ec`) extract css from global styles onto css files instead of js ones +`--ssl-cert` SSL certificate to use for serving HTTPS. -`--output-hashing` define the output filename cache-busting hashing mode +`--ssl-key` SSL key to use for serving HTTPS. -`--poll` enable and define the file watching poll time period (milliseconds) +## Note +When running `ng serve`, the compiled output is served from memory, not from disk. This means that the application being served is not located on disk in the `dist` folder. \ No newline at end of file diff --git a/docs/documentation/stories.md b/docs/documentation/stories.md index 05314e28bc06..558df442ccf9 100644 --- a/docs/documentation/stories.md +++ b/docs/documentation/stories.md @@ -2,7 +2,7 @@ # Stories describing how to do more with the CLI - - [RC.0 Update](stories/rc.0-update) + - [RC Update](stories/rc-update) - [Asset Configuration](stories/asset-configuration) - [Autocompletion](stories/autocompletion) - [CSS Preprocessors](stories/css-preprocessors) @@ -15,8 +15,10 @@ - [Bootstrap](stories/include-bootstrap) - [Font Awesome](stories/include-font-awesome) - [Moving Into the CLI](stories/moving-into-the-cli) - - [Movine Out of the CLI](stories/moving-out-of-the-cli) + - [Moving Out of the CLI](stories/moving-out-of-the-cli) - [Proxy](stories/proxy) - [Routing](stories/routing) - [3rd Party Lib](stories/third-party-lib) - [Corporate Proxy](stories/using-corporate-proxy) + - [Internationalization (i18n)](stories/internationalization) + - [Serve from Disk](stories/disk-serve) diff --git a/docs/documentation/stories/disk-serve.md b/docs/documentation/stories/disk-serve.md new file mode 100644 index 000000000000..b3f4663b630b --- /dev/null +++ b/docs/documentation/stories/disk-serve.md @@ -0,0 +1,23 @@ +# Serve from Disk + +The CLI supports running a live browser reload experience to users by running `ng serve`. This will compile the application upon file saves and reload the browser with the newly compiled application. This is done by hosting the application in memory and serving it via [webpack-dev-server](https://webpack.js.org/guides/development/#webpack-dev-server). + +If you wish to get a similar experience with the application output to disk please use the steps below. This practice will allow you to ensure that serving the contents of your `dist` dir will be closer to how your application will behave when it is deployed. + +## Environment Setup +### Install a web server +You will not be using webpack-dev-server, so you will need to install a web server for the browser to request the application. There are many to choose from but a good one to try is [lite-server](https://github.com/johnpapa/lite-server) as it will auto-reload your browser when new files are output. + +## Usage +You will need two terminals to get the live-reload experience. The first will run the build in a watch mode to compile the application to the `dist` folder. The second will run the web server against the `dist` folder. The combination of these two processes will mimic the same behavior of ng serve. + +### 1st terminal - Start the build +```bash +ng build --watch +``` + +### 2nd terminal - Start the web server +```bash +lite-server --baseDir="dist" +``` +When using `lite-server` the default browser will open to the appropriate URL. diff --git a/docs/documentation/stories/global-styles.md b/docs/documentation/stories/global-styles.md index c6ca901bdd42..b5313fcb82cc 100644 --- a/docs/documentation/stories/global-styles.md +++ b/docs/documentation/stories/global-styles.md @@ -26,3 +26,27 @@ You can also rename the output and lazy load it by using the object format: { "input": "pre-rename-style.scss", "output": "renamed-style" }, ], ``` + +In Sass and Stylus you can also make use of the `includePaths` functionality for both component and +global styles, which allows you to add extra base paths that will be checked for imports. + +To add paths, use the `stylePreprocessorOptions` entry in angular-cli.json `app` object: + +``` +"stylePreprocessorOptions": { + "includePaths": [ + "style-paths" + ] +}, +``` + +Files in that folder, e.g. `src/style-paths/_variables.scss`, can be imported from anywhere in your +project without the need for a relative path: + +``` +// src/app/app.component.scss +// A relative path works +@import '../style-paths/variables'; +// But now this works as well +@import 'variables'; +``` \ No newline at end of file diff --git a/docs/documentation/stories/include-angular-flex.md b/docs/documentation/stories/include-angular-flex.md index 77e256c08ffe..25a0aaf5c1d6 100644 --- a/docs/documentation/stories/include-angular-flex.md +++ b/docs/documentation/stories/include-angular-flex.md @@ -17,7 +17,7 @@ import { FlexLayoutModule } from '@angular/flex-layout'; @NgModule({ imports: [ ... - FlexLayoutModule.forRoot() + FlexLayoutModule ], ... }) @@ -74,4 +74,4 @@ Among what you should see are - a light yellow header that is the entire width o - [Installation](https://github.com/angular/flex-layout#installation) - [API Overview](https://github.com/angular/flex-layout/wiki/API-Overview) - - [Demo](https://tburleson-layouts-demos.firebaseapp.com/#/docs) \ No newline at end of file + - [Demo](https://tburleson-layouts-demos.firebaseapp.com/#/docs) diff --git a/docs/documentation/stories/include-angular-material.md b/docs/documentation/stories/include-angular-material.md index d2e30afe514b..83ab16131cf1 100644 --- a/docs/documentation/stories/include-angular-material.md +++ b/docs/documentation/stories/include-angular-material.md @@ -24,7 +24,7 @@ import { MaterialModule } from '@angular/material'; @NgModule({ imports: [ ... - MaterialModule.forRoot() + MaterialModule ], ... }) diff --git a/docs/documentation/stories/internationalization.md b/docs/documentation/stories/internationalization.md new file mode 100644 index 000000000000..259d90d048fd --- /dev/null +++ b/docs/documentation/stories/internationalization.md @@ -0,0 +1,72 @@ +# Internationalization (i18n) + +If you are working on internationalization, the CLI can help you with the following steps: +- extraction +- serve +- build + +The first thing that you have to do is to setup your application to use i18n. +To do that you can follow [the cookbook on angular.io](https://angular.io/docs/ts/latest/cookbook/i18n.html). + +### Extraction +When your app is ready, you can extract the strings to translate from your templates with the +`ng xi18n` command. + +By default it will create a file named `messages.xlf` in your `src` folder. +You can use [parameters from the xi18n command](../xi18n) to change the format, +the name, the location and the source locale of the extracted file. + +For example to create a file in the `src/locale` folder you would use: +```sh +ng xi18n --output-path src/locale +``` + +### Serve +Now that you have generated a messages bundle source file, you can translate it. +Let's say that your file containing the french translations is named `messages.fr.xlf` +and is located in the `src/locale` folder. +If you want to use it when you serve your application you can use the 3 following commands: +- `--i18n-file` Localization file to use for i18n. +- `--i18n-format` Format of the localization file specified with --i18n-file. +- `--locale` Locale to use for i18n. + +In our case we can load the french translations with the following command: +```sh +ng serve --aot --locale fr --i18n-format xlf --i18n-file src/locale/messages.fr.xlf +``` + +Our application is exactly the same but the `LOCALE_ID` has been provided with "fr", +`TRANSLATIONS_FORMAT` with "xlf" and `TRANSLATIONS` with the content of `messages.fr.xlf`. +All the strings flagged for i18n have been replaced with their french translations. + +Note: this only works for AOT, if you want to use i18n in JIT you will have to update +your bootstrap file yourself. + +### Build +To build your application with a specific locale you can use the exact same commands +that you used for `serve`: +```sh +ng build --aot --locale fr --i18n-format xlf --i18n-file src/i18n/messages.fr.xlf +``` + +When you build your application for a specific locale, it is probably a good idea to change +the output path with the command `--output-path` in order to save the files to a different location. + +```sh +ng build --aot --output-path dist/fr --locale fr --i18n-format xlf --i18n-file src/i18n/messages.fr.xlf +``` + +If you end up serving this specific version from a subdirectory, you can also change +the base url used by your application with the command `--base-href`. + +For example if the french version of your application is served from https://myapp.com/fr/ +then you would build the french version like this: + +```sh +ng build --aot --output-path dist/fr --base-href fr --locale fr --i18n-format xlf --i18n-file src/i18n/messages.fr.xlf +``` + +If you need more details about how to create scripts to generate the app in multiple +languages and how to setup Apache 2 to serve them from different subdirectories, +you can read [this great tutorial](https://medium.com/@feloy/deploying-an-i18n-angular-app-with-angular-cli-fc788f17e358#.1xq4iy6fp) +by Philippe Martin. \ No newline at end of file diff --git a/docs/documentation/stories/rc.0-update.md b/docs/documentation/stories/rc-update.md similarity index 97% rename from docs/documentation/stories/rc.0-update.md rename to docs/documentation/stories/rc-update.md index 19c6d2c6b0c3..697f2e016def 100644 --- a/docs/documentation/stories/rc.0-update.md +++ b/docs/documentation/stories/rc-update.md @@ -1,4 +1,4 @@ -# Angular CLI RC.0 migration guide +# Angular CLI RC migration guide In this migration guide we'll be looking at some of the major changes to CLI projects in the last two months. @@ -19,7 +19,7 @@ The new [Stories](https://github.com/angular/angular-cli/wiki/stories) section c scenarios, so be sure to have a look! Below are the changes between a project generated two months ago, with `1.0.0-beta.24` and -a `1.0.0-rc.0` project. +a `1.0.0-rc.1` project. If you kept your project up to date you might have a lot of these already. You can find more details about changes between versions in [CHANGELOG.md](https://github.com/angular/angular-cli/blob/master/CHANGELOG.md). @@ -272,8 +272,13 @@ There is an additional root-level `tsconfig.json` that is used for IDE integrati "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, + "target": "es5", + "typeRoots": [ + "node_modules/@types" + ], "lib": [ - "es2016" + "es2016", + "dom" ] } } @@ -315,16 +320,17 @@ Packages in `dependencies`: - `@angular/*` packages now have a `^2.4.0` minimum (`^3.4.0` for router) - `core-js` remains unchanged at `^2.4.1` - `rxjs` to `^5.1.0` +- `ts-helpers` was **removed** - `zone.js` to `^0.7.6` -Packages in `dependencies`: +Packages in `devDependencies`: - `@angular/cli` at `1.0.0-rc.0` replaces `angular-cli` - `@angular/compiler-cli` is also at `^2.4.0` - `@types/jasmine` remains unchanged and pinned at `2.5.38` - `@types/node` was updated to `~6.0.60` - `codelyzer` was updated to `~2.0.0` - `jasmine-core` was updated to `~2.5.2` -- `jasmine-spec-reporter` was **removed** +- `jasmine-spec-reporter` was updated to `~3.2.0` - `karma` was updated to `~1.4.1` - `karma-chrome-launcher` was updated to `~2.0.0` - `karma-cli` was updated to `~1.0.1` @@ -348,6 +354,7 @@ We also updated the scripts section to make it more simple: "scripts": { "ng": "ng", "start": "ng serve", + "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" @@ -455,5 +462,3 @@ Add these new rules: ``` Update `no-inferrable-types` to `"no-inferrable-types": [true, "ignore-params"]`. - - diff --git a/docs/documentation/stories/routing.md b/docs/documentation/stories/routing.md index 5d5b3b0c7239..504a62e6f07e 100644 --- a/docs/documentation/stories/routing.md +++ b/docs/documentation/stories/routing.md @@ -8,6 +8,4 @@ The CLI supports routing in several ways: The file includes an empty `Routes` object that you can fill with routes to different components and/or modules. - The `--routing` option also generates a default component with the same name as the module. - -- You can use the `--routing` option with `ng new` to create a `app-routing.module.ts` file when you create or initialize a project. \ No newline at end of file +- You can use the `--routing` option with `ng new` to create a `app-routing.module.ts` file when you create or initialize a project. diff --git a/docs/documentation/test.md b/docs/documentation/test.md index edebf772c59b..18c3c633b282 100644 --- a/docs/documentation/test.md +++ b/docs/documentation/test.md @@ -16,18 +16,28 @@ Tests will execute after a build is executed via [Karma](http://karma-runner.git You can run tests with coverage via `--code-coverage`. The coverage report will be in the `coverage/` directory. ## Options -`--watch` (`-w`) flag to run builds when files change +`--app` Specifies app name or index to use. -`--browsers` override which browsers tests are run against +`--browsers` Override which browsers tests are run against. -`--colors` enable or disable colors in the output (reporters and logs) +`--code-coverage` Coverage report will be in the coverage/ directory. -`--log-level` level of logging +`--colors` Enable or disable colors in the output (reporters and logs). -`--port` port where the web server will be listening +`--config` Use a specific config file. Defaults to the protractor config file in angular-cli.json. -`--reporters` list of reporters to use +`--log-level` Level of logging. -`--build` flag to build prior to running tests +`--poll` Enable and define the file watching poll time period (milliseconds). -`--poll` enable and define the file watching poll time period (milliseconds) +`--port` Port where the web server will be listening. + +`--progress` Log progress to the console while in progress. + +`--reporters` List of reporters to use. + +`--single-run` Run tests a single time. + +`--sourcemap` Output sourcemaps. + +`--watch` (`-w`) Run build when files change. \ No newline at end of file diff --git a/docs/documentation/xi18n.md b/docs/documentation/xi18n.md new file mode 100644 index 000000000000..fa2285d7be78 --- /dev/null +++ b/docs/documentation/xi18n.md @@ -0,0 +1,21 @@ + + +# ng xi18n + +## Overview +`ng xi18n` Extracts i18n messages from the templates. + +## Options +`--i18n-format` (`-f`) Output format for the generated file: either `xmb` or `xlf`. + +`--output-path` (`-op`) Path where output will be placed. + +`--locale` (`-l`) Specifies the source language of the application. + +`--outfile` (`-of`) Name of the file to output. + +`--verbose` Adds more details to output logging. + +`--progress` Log progress to the console while running. + +`--app` (`-a`) Specifies app name to use. \ No newline at end of file diff --git a/lib/bootstrap-local.js b/lib/bootstrap-local.js index a4043c34437f..645c540267e9 100644 --- a/lib/bootstrap-local.js +++ b/lib/bootstrap-local.js @@ -6,6 +6,8 @@ const path = require('path'); const ts = require('typescript'); +Error.stackTraceLimit = Infinity; + global.angularCliIsLocal = true; global.angularCliPackages = require('./packages'); diff --git a/package.json b/package.json index ed1f5b972552..ca4f36bba85f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@angular/cli", - "version": "1.0.0-rc.1", + "version": "1.0.0-rc.2", "description": "CLI tool for Angular", "main": "packages/@angular/cli/lib/cli/index.js", "trackingCode": "UA-8594346-19", diff --git a/packages/@angular/cli/blueprints/class/index.ts b/packages/@angular/cli/blueprints/class/index.ts index 0b4ffe85eeb7..72486aa0ba0f 100644 --- a/packages/@angular/cli/blueprints/class/index.ts +++ b/packages/@angular/cli/blueprints/class/index.ts @@ -8,6 +8,7 @@ const getFiles = Blueprint.prototype.files; export default Blueprint.extend({ description: '', + aliases: ['cl'], availableOptions: [ { diff --git a/packages/@angular/cli/blueprints/component/index.ts b/packages/@angular/cli/blueprints/component/index.ts index ef5d9bcbd45c..45fc2f41d514 100644 --- a/packages/@angular/cli/blueprints/component/index.ts +++ b/packages/@angular/cli/blueprints/component/index.ts @@ -12,8 +12,30 @@ const getFiles = Blueprint.prototype.files; const stringUtils = require('ember-cli-string-utils'); const astUtils = require('../../utilities/ast-utils'); +const viewEncapsulationMap: any = { + 'emulated': 'Emulated', + 'native': 'Native', + 'none': 'None' +}; + +const changeDetectionMap: any = { + 'default': 'Default', + 'onpush': 'OnPush' +}; + +function correctCase(options: any) { + if (options.viewEncapsulation) { + options.viewEncapsulation = viewEncapsulationMap[options.viewEncapsulation.toLowerCase()]; + } + + if (options.changeDetection) { + options.changeDetection = changeDetectionMap[options.changeDetection.toLowerCase()]; + } +} + export default Blueprint.extend({ description: '', + aliases: ['c'], availableOptions: [ { @@ -95,8 +117,7 @@ export default Blueprint.extend({ } } else { try { - this.pathToModule = findParentModule( - this.project.root, appConfig.root, this.dynamicPath.dir); + this.pathToModule = findParentModule(this.project.root, appConfig.root, this.generatePath); } catch (e) { if (!options.skipImport) { throw `Error locating module for declaration\n\t${e}`; @@ -147,6 +168,8 @@ export default Blueprint.extend({ options.changeDetection = options.changeDetection !== undefined ? options.changeDetection : CliConfig.getValue('defaults.component.changeDetection'); + correctCase(options); + return { dynamicPath: this.dynamicPath.dir.replace(this.dynamicPath.appRoot, ''), flat: options.flat, diff --git a/packages/@angular/cli/blueprints/directive/index.ts b/packages/@angular/cli/blueprints/directive/index.ts index d5b02d81d22e..691dbd0876b5 100644 --- a/packages/@angular/cli/blueprints/directive/index.ts +++ b/packages/@angular/cli/blueprints/directive/index.ts @@ -14,6 +14,7 @@ const getFiles = Blueprint.prototype.files; export default Blueprint.extend({ description: '', + aliases: ['d'], availableOptions: [ { @@ -70,8 +71,7 @@ export default Blueprint.extend({ } } else { try { - this.pathToModule = findParentModule - (this.project.root, appConfig.root, this.dynamicPath.dir); + this.pathToModule = findParentModule(this.project.root, appConfig.root, this.generatePath); } catch (e) { if (!options.skipImport) { throw `Error locating module for declaration\n\t${e}`; diff --git a/packages/@angular/cli/blueprints/enum/index.ts b/packages/@angular/cli/blueprints/enum/index.ts index 94ddb8d5f4ab..eb0475fcd299 100644 --- a/packages/@angular/cli/blueprints/enum/index.ts +++ b/packages/@angular/cli/blueprints/enum/index.ts @@ -6,6 +6,7 @@ const Blueprint = require('../../ember-cli/lib/models/blueprint'); export default Blueprint.extend({ description: '', + aliases: ['e'], availableOptions: [ { diff --git a/packages/@angular/cli/blueprints/guard/index.ts b/packages/@angular/cli/blueprints/guard/index.ts index 52652086ff09..04ab6977b5d0 100644 --- a/packages/@angular/cli/blueprints/guard/index.ts +++ b/packages/@angular/cli/blueprints/guard/index.ts @@ -14,6 +14,7 @@ const getFiles = Blueprint.prototype.files; export default Blueprint.extend({ description: '', + aliases: ['g'], availableOptions: [ { diff --git a/packages/@angular/cli/blueprints/interface/index.ts b/packages/@angular/cli/blueprints/interface/index.ts index 46f73c7cba7b..2c6cea3bba55 100644 --- a/packages/@angular/cli/blueprints/interface/index.ts +++ b/packages/@angular/cli/blueprints/interface/index.ts @@ -7,6 +7,7 @@ const Blueprint = require('../../ember-cli/lib/models/blueprint'); export default Blueprint.extend({ description: '', + aliases: ['i'], anonymousOptions: [ '' diff --git a/packages/@angular/cli/blueprints/module/files/__path__/__name__-routing.module.ts b/packages/@angular/cli/blueprints/module/files/__path__/__name__-routing.module.ts index 2d4459211035..9d822650edbb 100644 --- a/packages/@angular/cli/blueprints/module/files/__path__/__name__-routing.module.ts +++ b/packages/@angular/cli/blueprints/module/files/__path__/__name__-routing.module.ts @@ -5,7 +5,6 @@ const routes: Routes = []; @NgModule({ imports: [RouterModule.forChild(routes)], - exports: [RouterModule], - providers: [] + exports: [RouterModule] }) export class <%= classifiedModuleName %>RoutingModule { } diff --git a/packages/@angular/cli/blueprints/module/index.ts b/packages/@angular/cli/blueprints/module/index.ts index 3332033cc503..0fd1326fa591 100644 --- a/packages/@angular/cli/blueprints/module/index.ts +++ b/packages/@angular/cli/blueprints/module/index.ts @@ -8,6 +8,7 @@ const getFiles = Blueprint.prototype.files; export default Blueprint.extend({ description: '', + aliases: ['m'], availableOptions: [ { diff --git a/packages/@angular/cli/blueprints/ng/files/README.md b/packages/@angular/cli/blueprints/ng/files/README.md index 69fb9c4a7b2b..2280408509ad 100755 --- a/packages/@angular/cli/blueprints/ng/files/README.md +++ b/packages/@angular/cli/blueprints/ng/files/README.md @@ -3,6 +3,7 @@ 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 diff --git a/packages/@angular/cli/blueprints/ng/files/__path__/app/app-routing.module.ts b/packages/@angular/cli/blueprints/ng/files/__path__/app/app-routing.module.ts index 03f6daa60bec..5b7d25b9a403 100644 --- a/packages/@angular/cli/blueprints/ng/files/__path__/app/app-routing.module.ts +++ b/packages/@angular/cli/blueprints/ng/files/__path__/app/app-routing.module.ts @@ -10,7 +10,6 @@ const routes: Routes = [ @NgModule({ imports: [RouterModule.forRoot(routes)], - exports: [RouterModule], - providers: [] + exports: [RouterModule] }) export class AppRoutingModule { } diff --git a/packages/@angular/cli/blueprints/ng/files/__path__/tsconfig.app.json b/packages/@angular/cli/blueprints/ng/files/__path__/tsconfig.app.json index 493162c0438c..f40bd2db7ea3 100644 --- a/packages/@angular/cli/blueprints/ng/files/__path__/tsconfig.app.json +++ b/packages/@angular/cli/blueprints/ng/files/__path__/tsconfig.app.json @@ -1,22 +1,18 @@ {<% if (ng4) { %> "extends": "<%= relativeRootPath %>/tsconfig.json", - "compilerOptions": { - "lib": [ - "es2016", - "dom" - ],<% } else { %> + "compilerOptions": {<% } else { %> "compilerOptions": { "sourceMap": true, "declaration": false, "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, + "target": "es5", "lib": [ "es2016", "dom" ],<% } %> "outDir": "<%= relativeRootPath %>/out-tsc/app", - "target": "es5", "module": "es2015", "baseUrl": "", "types": [] diff --git a/packages/@angular/cli/blueprints/ng/files/__path__/tsconfig.spec.json b/packages/@angular/cli/blueprints/ng/files/__path__/tsconfig.spec.json index dfbeeb249854..5dc8eeb57474 100644 --- a/packages/@angular/cli/blueprints/ng/files/__path__/tsconfig.spec.json +++ b/packages/@angular/cli/blueprints/ng/files/__path__/tsconfig.spec.json @@ -12,7 +12,7 @@ ],<% } %> "outDir": "<%= relativeRootPath %>/out-tsc/spec", "module": "commonjs", - "target": "es6", + "target": "es5", "baseUrl": "", "types": [ "jasmine", diff --git a/packages/@angular/cli/blueprints/ng/files/e2e/tsconfig.e2e.json b/packages/@angular/cli/blueprints/ng/files/e2e/tsconfig.e2e.json index 7697b8b04eb4..674dd643c913 100644 --- a/packages/@angular/cli/blueprints/ng/files/e2e/tsconfig.e2e.json +++ b/packages/@angular/cli/blueprints/ng/files/e2e/tsconfig.e2e.json @@ -10,9 +10,9 @@ "lib": [ "es2016" ],<% } %> - "outDir": "../dist/out-tsc-e2e", + "outDir": "../out-tsc/e2e", "module": "commonjs", - "target": "es6", + "target": "es5", "types":[ "jasmine", "node" diff --git a/packages/@angular/cli/blueprints/ng/files/gitignore b/packages/@angular/cli/blueprints/ng/files/gitignore index 8ce873857363..6708ebc05606 100755 --- a/packages/@angular/cli/blueprints/ng/files/gitignore +++ b/packages/@angular/cli/blueprints/ng/files/gitignore @@ -3,6 +3,7 @@ # compiled output /dist /tmp +/out-tsc # dependencies /node_modules @@ -36,6 +37,6 @@ testem.log /e2e/*.js /e2e/*.map -#System Files +# System Files .DS_Store Thumbs.db diff --git a/packages/@angular/cli/blueprints/ng/files/package.json b/packages/@angular/cli/blueprints/ng/files/package.json index f35a9e6c93a6..fc2f3609964d 100644 --- a/packages/@angular/cli/blueprints/ng/files/package.json +++ b/packages/@angular/cli/blueprints/ng/files/package.json @@ -40,7 +40,7 @@ "karma-coverage-istanbul-reporter": "^0.2.0", "protractor": "~5.1.0", "ts-node": "~2.0.0", - "tslint": "~4.4.2", + "tslint": "~4.5.0", "typescript": "<%= ng4 ? '~2.1.0' : '~2.0.0' %>" } } diff --git a/packages/@angular/cli/blueprints/ng/files/tsconfig.json b/packages/@angular/cli/blueprints/ng/files/tsconfig.json index 7a9d9e8c58ab..a35a8ee3a40d 100644 --- a/packages/@angular/cli/blueprints/ng/files/tsconfig.json +++ b/packages/@angular/cli/blueprints/ng/files/tsconfig.json @@ -2,12 +2,16 @@ "compileOnSave": false, "compilerOptions": { "outDir": "./dist/out-tsc", + "baseUrl": "src", "sourceMap": true, "declaration": false, "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es5", + "typeRoots": [ + "node_modules/@types" + ], "lib": [ "es2016", "dom" diff --git a/packages/@angular/cli/blueprints/pipe/index.ts b/packages/@angular/cli/blueprints/pipe/index.ts index 9cf81773a420..95676266a57d 100644 --- a/packages/@angular/cli/blueprints/pipe/index.ts +++ b/packages/@angular/cli/blueprints/pipe/index.ts @@ -14,6 +14,7 @@ const getFiles = Blueprint.prototype.files; export default Blueprint.extend({ description: '', + aliases: ['p'], availableOptions: [ { @@ -65,8 +66,7 @@ export default Blueprint.extend({ } } else { try { - this.pathToModule = findParentModule - (this.project.root, appConfig.root, this.dynamicPath.dir); + this.pathToModule = findParentModule(this.project.root, appConfig.root, this.generatePath); } catch (e) { if (!options.skipImport) { throw `Error locating module for declaration\n\t${e}`; diff --git a/packages/@angular/cli/blueprints/service/index.ts b/packages/@angular/cli/blueprints/service/index.ts index bb41938f3532..5443238603e1 100644 --- a/packages/@angular/cli/blueprints/service/index.ts +++ b/packages/@angular/cli/blueprints/service/index.ts @@ -14,6 +14,7 @@ const getFiles = Blueprint.prototype.files; export default Blueprint.extend({ description: '', + aliases: ['s'], availableOptions: [ { diff --git a/packages/@angular/cli/commands/completion.ts b/packages/@angular/cli/commands/completion.ts index 1147c7e48f6b..b755ab49ee0d 100644 --- a/packages/@angular/cli/commands/completion.ts +++ b/packages/@angular/cli/commands/completion.ts @@ -78,7 +78,7 @@ const CompletionCommand = Command.extend({ commandOptions.all = !commandOptions.bash && !commandOptions.zsh; const commandFiles = fs.readdirSync(__dirname) - .filter(file => file.match(/\.ts$/) && !file.match(/\.run.ts$/)) + .filter(file => file.match(/\.(j|t)s$/) && !file.match(/\.d.ts$/)) .map(file => path.parse(file).name) .filter(file => { return commandsToIgnore.indexOf(file) < 0; diff --git a/packages/@angular/cli/commands/generate.ts b/packages/@angular/cli/commands/generate.ts index 830a93a2d35d..c0581c46c526 100644 --- a/packages/@angular/cli/commands/generate.ts +++ b/packages/@angular/cli/commands/generate.ts @@ -26,13 +26,13 @@ const GenerateCommand = EmberGenerateCommand.extend({ // map the blueprint name to allow for aliases rawArgs[0] = mapBlueprintName(rawArgs[0]); - if (rawArgs[0] !== '--help' && - !fs.existsSync(path.join(__dirname, '..', 'blueprints', rawArgs[0]))) { + const isHelp: boolean = ['--help', '-h'].indexOf(rawArgs[0]) > -1; + if (!isHelp && !fs.existsSync(path.join(__dirname, '..', 'blueprints', rawArgs[0]))) { SilentError.debugOrThrow('@angular/cli/commands/generate', `Invalid blueprint: ${rawArgs[0]}`); } - if (!rawArgs[1]) { + if (!isHelp && !rawArgs[1]) { SilentError.debugOrThrow('@angular/cli/commands/generate', `The \`ng generate ${rawArgs[0]}\` command requires a name to be specified.`); } @@ -57,6 +57,7 @@ const aliasMap: { [alias: string]: string } = { 'c': 'component', 'd': 'directive', 'e': 'enum', + 'g': 'guard', 'i': 'interface', 'm': 'module', 'p': 'pipe', diff --git a/packages/@angular/cli/commands/set.ts b/packages/@angular/cli/commands/set.ts index f5de2ba9f056..f916aaf60615 100644 --- a/packages/@angular/cli/commands/set.ts +++ b/packages/@angular/cli/commands/set.ts @@ -64,7 +64,7 @@ const SetCommand = Command.extend({ case 'number': value = this.asNumber(rawValue); break; case 'string': value = rawValue; break; - default: value = JSON.parse(rawValue); + default: value = parseValue(rawValue, jsonPath); } config.set(jsonPath, value); @@ -74,4 +74,12 @@ const SetCommand = Command.extend({ } }); +function parseValue(rawValue: string, path: string) { + try { + return JSON.parse(rawValue); + } catch (error) { + throw new SilentError(`No node found at path ${path}`); + } +} + export default SetCommand; diff --git a/packages/@angular/cli/commands/test.ts b/packages/@angular/cli/commands/test.ts index 6c95597b1eb6..655612009d3a 100644 --- a/packages/@angular/cli/commands/test.ts +++ b/packages/@angular/cli/commands/test.ts @@ -15,7 +15,6 @@ export interface TestOptions { log?: string; port?: number; reporters?: string; - build?: boolean; sourcemap?: boolean; progress?: boolean; config: string; @@ -45,7 +44,7 @@ const TestCommand = EmberTestCommand.extend({ type: String, aliases: ['c'], description: oneLine`Use a specific config file. - Defaults to the protractor config file in angular-cli.json.` + Defaults to the karma config file in .angular-cli.json.` }, { name: 'single-run', @@ -85,12 +84,6 @@ const TestCommand = EmberTestCommand.extend({ type: String, description: 'List of reporters to use.' }, - { - name: 'build', - type: Boolean, - default: true, - description: 'Build prior to running tests.' - }, { name: 'sourcemap', type: Boolean, diff --git a/packages/@angular/cli/ember-cli/lib/ui/index.js b/packages/@angular/cli/ember-cli/lib/ui/index.js index 7837f04e0f52..3e749d1a0166 100644 --- a/packages/@angular/cli/ember-cli/lib/ui/index.js +++ b/packages/@angular/cli/ember-cli/lib/ui/index.js @@ -174,12 +174,10 @@ UI.prototype.prompt = function(questions, callback) { // If no callback was provided, automatically return a promise if (callback) { - inquirer.prompt(questions, callback); - } else { - return new Promise(function(resolve) { - inquirer.prompt(questions, resolve); - }); + return inquirer.prompt(questions, callback); } + + return inquirer.prompt(questions); }; /** diff --git a/packages/@angular/cli/ember-cli/lib/utilities/printable-properties.js b/packages/@angular/cli/ember-cli/lib/utilities/printable-properties.js index 21b6b5b63f07..2fe13f045493 100644 --- a/packages/@angular/cli/ember-cli/lib/utilities/printable-properties.js +++ b/packages/@angular/cli/ember-cli/lib/utilities/printable-properties.js @@ -10,6 +10,7 @@ var commandProperties = [ ]; var blueprintProperties = [ 'name', + 'aliases', 'description', 'availableOptions', 'anonymousOptions', diff --git a/packages/@angular/cli/lib/cli/index.js b/packages/@angular/cli/lib/cli/index.js index 10952734a829..3e0f3c056be9 100644 --- a/packages/@angular/cli/lib/cli/index.js +++ b/packages/@angular/cli/lib/cli/index.js @@ -12,7 +12,6 @@ const UI = require('../../ember-cli/lib/ui'); const Watcher = require('../../ember-cli/lib/models/watcher'); const path = require('path'); -Error.stackTraceLimit = Infinity; module.exports = function(options) { diff --git a/packages/@angular/cli/lib/config/schema.json b/packages/@angular/cli/lib/config/schema.json index 2b7515cb56a7..1f0d464a59f2 100644 --- a/packages/@angular/cli/lib/config/schema.json +++ b/packages/@angular/cli/lib/config/schema.json @@ -337,11 +337,13 @@ }, "viewEncapsulation": { "description": "Specifies the view encapsulation strategy.", - "enum": ["Emulated", "Native", "None"] + "enum": ["Emulated", "Native", "None"], + "type": "string" }, "changeDetection": { "description": "Specifies the change detection strategy.", - "enum": ["Default", "OnPush"] + "enum": ["Default", "OnPush"], + "type": "string" } } }, diff --git a/packages/@angular/cli/models/webpack-configs/styles.ts b/packages/@angular/cli/models/webpack-configs/styles.ts index fa53e3165b85..c4722e60e566 100644 --- a/packages/@angular/cli/models/webpack-configs/styles.ts +++ b/packages/@angular/cli/models/webpack-configs/styles.ts @@ -44,17 +44,23 @@ export function getStylesConfig(wco: WebpackConfigOptions) { const cssnanoPlugin = cssnano({ safe: true, autoprefixer: false }); // Convert absolute resource URLs to account for base-href and deploy-url. - const baseHref = wco.buildOptions.baseHref; - const deployUrl = wco.buildOptions.deployUrl; + const baseHref = wco.buildOptions.baseHref || ''; + const deployUrl = wco.buildOptions.deployUrl || ''; const postcssUrlOptions = { url: (URL: string) => { - // Only convert absolute URLs, which CSS-Loader won't process into require(). - if (!URL.startsWith('/')) { + // Only convert root relative URLs, which CSS-Loader won't process into require(). + if (!URL.startsWith('/') || URL.startsWith('//')) { return URL; } - // Join together base-href, deploy-url and the original URL. - // Also dedupe multiple slashes into single ones. - return `/${baseHref || ''}/${deployUrl || ''}/${URL}`.replace(/\/\/+/g, '/'); + + if (deployUrl.match(/:\/\//)) { + // If deployUrl contains a scheme, ignore baseHref use deployUrl as is. + return `${deployUrl.replace(/\/$/, '')}${URL}`; + } else { + // Join together base-href, deploy-url and the original URL. + // Also dedupe multiple slashes into single ones. + return `/${baseHref}/${deployUrl}/${URL}`.replace(/\/\/+/g, '/'); + } } }; const urlPlugin = postcssUrl(postcssUrlOptions); diff --git a/packages/@angular/cli/package.json b/packages/@angular/cli/package.json index c4c545cb90d6..5be43c2c98fa 100644 --- a/packages/@angular/cli/package.json +++ b/packages/@angular/cli/package.json @@ -1,6 +1,6 @@ { "name": "@angular/cli", - "version": "1.0.0-rc.1", + "version": "1.0.0-rc.2", "description": "CLI tool for Angular", "main": "lib/cli/index.js", "trackingCode": "UA-8594346-19", @@ -32,7 +32,7 @@ "@angular/core": ">=2.3.1 <5.0.0 || >=4.0.0-beta <5.0.0", "@angular/tsc-wrapped": ">=0.5.0 <5.0.0 || >=4.0.0-beta <5.0.0", "@ngtools/json-schema": "1.0.5", - "@ngtools/webpack": "1.2.12", + "@ngtools/webpack": "1.2.13", "autoprefixer": "^6.5.3", "chalk": "^1.1.3", "common-tags": "^1.3.1", diff --git a/packages/@angular/cli/tasks/eject.ts b/packages/@angular/cli/tasks/eject.ts index 4292a55fb96a..d1fe967b56af 100644 --- a/packages/@angular/cli/tasks/eject.ts +++ b/packages/@angular/cli/tasks/eject.ts @@ -431,34 +431,41 @@ export default Task.extend({ const scripts = packageJson['scripts']; if (scripts['build'] && scripts['build'] !== 'ng build' && !force) { throw new SilentError(oneLine` - Your package.json scripts needs to not contain a build script as it will be overwritten. + Your package.json scripts must not contain a build script as it will be overwritten. `); } if (scripts['start'] && scripts['start'] !== 'ng serve' && !force) { throw new SilentError(oneLine` - Your package.json scripts needs to not contain a start script as it will be overwritten. + Your package.json scripts must not contain a start script as it will be overwritten. + `); + } + if (scripts['pree2e'] && scripts['prepree2e'] !== 'npm start' && !force) { + throw new SilentError(oneLine` + Your package.json scripts needs to not contain a prepree2e script as it will be + overwritten. `); } if (scripts['pree2e'] && scripts['pree2e'] !== pree2eNpmScript && !force) { throw new SilentError(oneLine` - Your package.json scripts needs to not contain a pree2e script as it will be + Your package.json scripts must not contain a pree2e script as it will be overwritten. `); } if (scripts['e2e'] && scripts['e2e'] !== 'ng e2e' && !force) { throw new SilentError(oneLine` - Your package.json scripts needs to not contain a e2e script as it will be overwritten. + Your package.json scripts must not contain a e2e script as it will be overwritten. `); } if (scripts['test'] && scripts['test'] !== 'ng test' && !force) { throw new SilentError(oneLine` - Your package.json scripts needs to not contain a test script as it will be overwritten. + Your package.json scripts must not contain a test script as it will be overwritten. `); } packageJson['scripts']['build'] = 'webpack'; - packageJson['scripts']['start'] = 'webpack-dev-server'; + packageJson['scripts']['start'] = 'webpack-dev-server --port=4200'; packageJson['scripts']['test'] = 'karma start ./karma.conf.js'; + packageJson['scripts']['prepree2e'] = 'npm start'; packageJson['scripts']['pree2e'] = pree2eNpmScript; packageJson['scripts']['e2e'] = 'protractor ./protractor.conf.js'; @@ -494,7 +501,7 @@ export default Task.extend({ packageJson['devDependencies'][packageName] = ourPackageJson['dependencies'][packageName]; }); - return writeFile('package.json', JSON.stringify(packageJson, null, 2)); + return writeFile('package.json', JSON.stringify(packageJson, null, 2) + '\n'); }) .then(() => JSON.parse(ts.sys.readFile(tsConfigPath))) .then((tsConfigJson: any) => { @@ -505,7 +512,7 @@ export default Task.extend({ '**/*.spec.ts' ]; } - return writeFile(tsConfigPath, JSON.stringify(tsConfigJson, null, 2)); + return writeFile(tsConfigPath, JSON.stringify(tsConfigJson, null, 2) + '\n'); }) // Output the webpack.config.js. .then(() => writeFile('webpack.config.js', webpackConfigStr)) diff --git a/packages/@angular/cli/tasks/extract-i18n.ts b/packages/@angular/cli/tasks/extract-i18n.ts index 278223162a35..eac76cb69b56 100644 --- a/packages/@angular/cli/tasks/extract-i18n.ts +++ b/packages/@angular/cli/tasks/extract-i18n.ts @@ -54,7 +54,6 @@ export const Extracti18nTask = Task.extend({ this.ui.writeError('\nAn error occured during the i18n extraction:\n' + ((err && err.stack) || err)); } - throw err; }); } }); diff --git a/packages/@angular/cli/tasks/lint.ts b/packages/@angular/cli/tasks/lint.ts index ef63b2dc3d4e..12cf4c4c9725 100644 --- a/packages/@angular/cli/tasks/lint.ts +++ b/packages/@angular/cli/tasks/lint.ts @@ -33,11 +33,8 @@ export default Task.extend({ const Linter = tslint.Linter; const Configuration = tslint.Configuration; - let errors = 0; - let results = ''; - - lintConfigs - .forEach((config) => { + const result = lintConfigs + .map((config) => { const program: ts.Program = Linter.createProgram(config.project); const files = getFilesToLint(program, config, Linter); @@ -56,19 +53,37 @@ export default Task.extend({ linter.lint(file, fileContents, configLoad.results); }); - const result = linter.getResult(); - errors += result.failureCount; - results = results.concat(result.output.trim().concat('\n')); + return linter.getResult(); + }) + .reduce((total, current) => { + const failures = current.failures + .filter((cf: any) => !total.failures.some((ef: any) => ef.equals(cf))); + total.failures = total.failures.concat(...failures); + + if (current.fixes) { + total.fixes = (total.fixes || []).concat(...current.fixes); + } + return total; + }, { + failures: [], + fixes: undefined }); + const Formatter = tslint.findFormatter(commandOptions.format); + const formatter = new Formatter(); + + const output = formatter.format(result.failures, result.fixes); + if (output) { + ui.writeLine(output); + } + // print formatter output directly for non human-readable formats if (['prose', 'verbose', 'stylish'].indexOf(commandOptions.format) == -1) { - ui.writeLine(results.trim()); - return (errors == 0 || commandOptions.force) ? Promise.resolve(0) : Promise.resolve(2); + return (result.failures.length == 0 || commandOptions.force) + ? Promise.resolve(0) : Promise.resolve(2); } - if (errors > 0) { - ui.writeLine(results.trim()); + if (result.failures.length > 0) { ui.writeLine(chalk.red('Lint errors found in the listed files.')); return commandOptions.force ? Promise.resolve(0) : Promise.resolve(2); } diff --git a/packages/@angular/cli/tasks/npm-install.ts b/packages/@angular/cli/tasks/npm-install.ts index 923432c96249..c7a846590cb7 100644 --- a/packages/@angular/cli/tasks/npm-install.ts +++ b/packages/@angular/cli/tasks/npm-install.ts @@ -13,7 +13,11 @@ export default Task.extend({ return new Promise(function(resolve, reject) { ui.writeLine(chalk.green(`Installing packages for tooling via ${packageManager}.`)); - exec(`${packageManager} install`, + let installCommand = `${packageManager} --quiet install`; + if (packageManager === 'yarn') { + installCommand = `${packageManager} install`; + } + exec(installCommand, (err: NodeJS.ErrnoException, _stdout: string, stderr: string) => { if (err) { ui.writeLine(stderr); diff --git a/packages/@angular/cli/utilities/find-parent-module.ts b/packages/@angular/cli/utilities/find-parent-module.ts index 3236167121cf..61be86780b5e 100644 --- a/packages/@angular/cli/utilities/find-parent-module.ts +++ b/packages/@angular/cli/utilities/find-parent-module.ts @@ -13,6 +13,10 @@ export default function findParentModule( let pathToCheck = path.join(sourceRoot, currentDir); while (pathToCheck.length >= sourceRoot.length) { + if (!fs.existsSync(pathToCheck)) { + pathToCheck = path.dirname(pathToCheck); + continue; + } // TODO: refactor to not be based upon file name const files = fs.readdirSync(pathToCheck) .filter(fileName => !fileName.endsWith('routing.module.ts')) diff --git a/packages/@ngtools/json-schema/package.json b/packages/@ngtools/json-schema/package.json index da3317464c87..24717c22c3a6 100644 --- a/packages/@ngtools/json-schema/package.json +++ b/packages/@ngtools/json-schema/package.json @@ -1,6 +1,6 @@ { "name": "@ngtools/json-schema", - "version": "1.0.6", + "version": "1.0.7", "description": "Schema validating and reading for configurations, similar to Angular CLI config.", "main": "./src/index.js", "typings": "src/index.d.ts", diff --git a/packages/@ngtools/json-schema/src/schema-class-factory.ts b/packages/@ngtools/json-schema/src/schema-class-factory.ts index eebde99abf8c..effe0b0ab903 100644 --- a/packages/@ngtools/json-schema/src/schema-class-factory.ts +++ b/packages/@ngtools/json-schema/src/schema-class-factory.ts @@ -51,7 +51,13 @@ function _getSchemaNodeForPath(rootMetaData: SchemaTreeNode, let fragments = _parseJsonPath(path); // TODO: make this work with union (oneOf) schemas return fragments.reduce((md: SchemaTreeNode, current: string) => { - return md && md.children && md.children[current]; + if (md && md.children) { + return md.children[current]; + } else if (md && md.items) { + return md.items[parseInt(current, 10)]; + } else { + return md; + } }, rootMetaData); } diff --git a/packages/@ngtools/webpack/package.json b/packages/@ngtools/webpack/package.json index d06c23942a2f..e04d30bc7c9d 100644 --- a/packages/@ngtools/webpack/package.json +++ b/packages/@ngtools/webpack/package.json @@ -1,6 +1,6 @@ { "name": "@ngtools/webpack", - "version": "1.2.12", + "version": "1.2.13", "description": "Webpack plugin that AoT compiles your Angular components and modules.", "main": "./src/index.js", "typings": "src/index.d.ts", diff --git a/packages/@ngtools/webpack/src/extract_i18n_plugin.ts b/packages/@ngtools/webpack/src/extract_i18n_plugin.ts index 10a087343abd..06168b9b3f24 100644 --- a/packages/@ngtools/webpack/src/extract_i18n_plugin.ts +++ b/packages/@ngtools/webpack/src/extract_i18n_plugin.ts @@ -181,8 +181,8 @@ export class ExtractI18nPlugin implements Tapable { }); }) .then(() => cb(), (err: any) => { - compilation.errors.push(err); - cb(); + this._compilation.errors.push(err); + cb(err); }); } diff --git a/scripts/test-commit-messages.js b/scripts/test-commit-messages.js index 6408b82672bb..97c121077e24 100644 --- a/scripts/test-commit-messages.js +++ b/scripts/test-commit-messages.js @@ -32,7 +32,7 @@ logger // Note: This is based on the gulp task found in the angular/angular repository exec( - 'git fetch origin master && git log --reverse --format=%s origin/master.. --no-merges', + 'git fetch origin master:master && git log --reverse --format=%s master.. --no-merges', (error, stdout, stderr) => { if (error) { logger.fatal(stderr); diff --git a/tests/e2e/tests/build/css-urls.ts b/tests/e2e/tests/build/css-urls.ts index 4248769cfc48..80a49862f662 100644 --- a/tests/e2e/tests/build/css-urls.ts +++ b/tests/e2e/tests/build/css-urls.ts @@ -47,7 +47,14 @@ export default function () { .then(() => expectToFail(() => expectFileToExist('dist/component-img-absolute.svg'))) .then(() => expectFileMatchToExist('./dist', /global-img-relative\.[0-9a-f]{20}\.svg/)) .then(() => expectFileMatchToExist('./dist', /component-img-relative\.[0-9a-f]{20}\.svg/)) - // Also check with base-href and deploy-url flags. + // Check urls with scheme are used as is. + .then(() => ng('build', '--base-href=/base/', '--deploy-url=http://deploy.url/', + '--extract-css')) + .then(() => expectFileToMatch('dist/styles.bundle.css', + /url\(\'http:\/\/deploy\.url\/assets\/global-img-absolute\.svg\'\)/)) + .then(() => expectFileToMatch('dist/main.bundle.js', + /url\(\'http:\/\/deploy\.url\/assets\/component-img-absolute\.svg\'\)/)) + // Check with base-href and deploy-url flags. .then(() => ng('build', '--base-href=/base/', '--deploy-url=deploy/', '--extract-css', '--aot')) .then(() => expectFileToMatch('dist/styles.bundle.css', diff --git a/tests/e2e/tests/commands/completion/completion.ts b/tests/e2e/tests/commands/completion/completion.ts new file mode 100644 index 000000000000..b88821e8c3ab --- /dev/null +++ b/tests/e2e/tests/commands/completion/completion.ts @@ -0,0 +1,9 @@ +import {silentNg} from '../../../utils/process'; + + +export default function() { + return Promise.resolve() + .then(() => silentNg('completion')) + .then(() => process.chdir('/')) + .then(() => silentNg('completion')); +} diff --git a/tests/e2e/tests/commands/get/get.ts b/tests/e2e/tests/commands/get/get.ts new file mode 100644 index 000000000000..b66fb2e9ceb1 --- /dev/null +++ b/tests/e2e/tests/commands/get/get.ts @@ -0,0 +1,13 @@ +import {ng} from '../../../utils/process'; +import {expectToFail} from '../../../utils/utils'; + +export default function() { + return Promise.resolve() + .then(() => expectToFail(() => ng('get', 'apps.zzz.prefix'))) + .then(() => ng('get', 'apps.0.prefix')) + .then(({ stdout }) => { + if (!stdout.match(/app/)) { + throw new Error(`Expected "app", received "${JSON.stringify(stdout)}".`); + } + }); +} diff --git a/tests/e2e/tests/commands/set/set.ts b/tests/e2e/tests/commands/set/set.ts new file mode 100644 index 000000000000..da82c129e46b --- /dev/null +++ b/tests/e2e/tests/commands/set/set.ts @@ -0,0 +1,14 @@ +import {ng} from '../../../utils/process'; +import {expectToFail} from '../../../utils/utils'; + +export default function() { + return Promise.resolve() + .then(() => expectToFail(() => ng('set', 'apps.zzz.prefix'))) + .then(() => ng('set', 'apps.0.prefix' , 'new-prefix')) + .then(() => ng('get', 'apps.0.prefix')) + .then(({ stdout }) => { + if (!stdout.match(/new-prefix/)) { + throw new Error(`Expected "new-prefix", received "${JSON.stringify(stdout)}".`); + } + }); +} diff --git a/tests/e2e/tests/generate/component/component-flag-case.ts b/tests/e2e/tests/generate/component/component-flag-case.ts new file mode 100644 index 000000000000..dbbee3525756 --- /dev/null +++ b/tests/e2e/tests/generate/component/component-flag-case.ts @@ -0,0 +1,15 @@ +import {join} from 'path'; +import {ng} from '../../../utils/process'; +import {expectFileToMatch} from '../../../utils/fs'; + + +export default function() { + const compDir = join('src', 'app', 'test'); + + return Promise.resolve() + .then(() => ng('generate', 'component', 'test', '-cd', 'onpush', '-ve', 'emulated')) + .then(() => expectFileToMatch(join(compDir, 'test.component.ts'), + /changeDetection: ChangeDetectionStrategy.OnPush/)) + .then(() => expectFileToMatch(join(compDir, 'test.component.ts'), + /encapsulation: ViewEncapsulation.Emulated/)); +} diff --git a/tests/e2e/tests/generate/component/component-in-existing-module-dir.ts b/tests/e2e/tests/generate/component/component-in-existing-module-dir.ts new file mode 100644 index 000000000000..bb98447bb4a1 --- /dev/null +++ b/tests/e2e/tests/generate/component/component-in-existing-module-dir.ts @@ -0,0 +1,12 @@ +import { join } from 'path'; +import { ng } from '../../../utils/process'; +import { expectFileToMatch } from '../../../utils/fs'; + +export default function () { + const modulePath = join('src', 'app', 'foo', 'foo.module.ts'); + + return Promise.resolve() + .then(() => ng('generate', 'module', 'foo')) + .then(() => ng('generate', 'component', 'foo')) + .then(() => expectFileToMatch(modulePath, /import { FooComponent } from '.\/foo.component'/)); +} diff --git a/tests/e2e/tests/generate/directive/directive-in-existing-module-dir.ts b/tests/e2e/tests/generate/directive/directive-in-existing-module-dir.ts new file mode 100644 index 000000000000..7dd270fe81a1 --- /dev/null +++ b/tests/e2e/tests/generate/directive/directive-in-existing-module-dir.ts @@ -0,0 +1,12 @@ +import { join } from 'path'; +import { ng } from '../../../utils/process'; +import { expectFileToMatch } from '../../../utils/fs'; + +export default function () { + const modulePath = join('src', 'app', 'foo', 'foo.module.ts'); + + return Promise.resolve() + .then(() => ng('generate', 'module', 'foo')) + .then(() => ng('generate', 'directive', 'foo', '--no-flat')) + .then(() => expectFileToMatch(modulePath, /import { FooDirective } from '.\/foo.directive'/)); +} diff --git a/tests/e2e/tests/generate/pipe/pipe-in-existing-module-dir.ts b/tests/e2e/tests/generate/pipe/pipe-in-existing-module-dir.ts new file mode 100644 index 000000000000..2055643a1b5b --- /dev/null +++ b/tests/e2e/tests/generate/pipe/pipe-in-existing-module-dir.ts @@ -0,0 +1,12 @@ +import { join } from 'path'; +import { ng } from '../../../utils/process'; +import { expectFileToMatch } from '../../../utils/fs'; + +export default function () { + const modulePath = join('src', 'app', 'foo', 'foo.module.ts'); + + return Promise.resolve() + .then(() => ng('generate', 'module', 'foo')) + .then(() => ng('generate', 'pipe', 'foo', '--no-flat')) + .then(() => expectFileToMatch(modulePath, /import { FooPipe } from '.\/foo.pipe'/)); +}