Skip to content

Commit

Permalink
feat(update): add ng update as alias of ng init
Browse files Browse the repository at this point in the history
  • Loading branch information
filipesilva committed Jan 20, 2017
1 parent f4b5773 commit 11fe6e6
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 15 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ The CLI supports routing in several ways:

The `--routing` option also generates a default component with the same name as the module.

- You can use the `--routing` option with `ng new` or `ng init` to create a `app-routing.module.ts` file when you create or initialize a project.
- You can use the `--routing` option with `ng new` to create a `app-routing.module.ts` file when you create or initialize a project.


### Creating a build
Expand Down Expand Up @@ -441,12 +441,12 @@ Local project package:
rm -rf node_modules dist # use rmdir on Windows
npm install --save-dev angular-cli@latest
npm install
ng init
ng update
```

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 `ng update` 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).

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 `ng update` finishes.

**The main cause of errors after an update is failing to incorporate these updates into your code**.

Expand Down
2 changes: 1 addition & 1 deletion docs/design/docker-deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ 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 (`ng new`).
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.
Expand Down
2 changes: 1 addition & 1 deletion docs/documentation/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ your app.

### Additional Commands
* [ng new](new)
* [ng init](init)
* [ng update](update)
* [ng serve](serve)
* [ng generate](generate)
* [ng test](test)
Expand Down
4 changes: 2 additions & 2 deletions docs/documentation/init.md → docs/documentation/update.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ng init
# ng update

## Overview
`ng init [name]` initializes, or re-initializes, an angular application.
`ng update [name]` updates, initializes, or re-initializes, an angular application.

Initialization is done in-place, meaning that the generated application is initialized in the current directory.

Expand Down
2 changes: 1 addition & 1 deletion packages/angular-cli/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const Command = require('../ember-cli/lib/models/command');
const InitCommand: any = Command.extend({
name: 'init',
description: 'Creates a new angular-cli project in the current folder.',
aliases: ['i'],
aliases: ['u', 'update', 'i'],
works: 'everywhere',

availableOptions: [
Expand Down
19 changes: 13 additions & 6 deletions tests/acceptance/init.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var existsSync = require('exists-sync');

var defaultIgnoredFiles = Blueprint.ignoredFiles;

describe('Acceptance: ng init', function () {
describe('Acceptance: ng update', function () {
this.timeout(20000);

beforeEach(function () {
Expand Down Expand Up @@ -100,18 +100,25 @@ describe('Acceptance: ng init', function () {
});
}

it('ng init', function () {
it('ng init does the same as ng update', function () {
return ng([
'init',
'--skip-npm'
]).then(confirmBlueprinted);
});

it('ng init with mobile flag does throw exception', function () {
it('ng update', function () {
return ng([
'init',
'--skip-npm'
]).then(confirmBlueprinted);
});

it('ng update with mobile flag does throw exception', function () {
expect(ng(['init', '--mobile'])).to.throw;
});

it('ng init can run in created folder', function () {
it('ng update can run in created folder', function () {
return tmp.setup('./tmp/foo')
.then(function () {
process.chdir('./tmp/foo');
Expand Down Expand Up @@ -186,15 +193,15 @@ describe('Acceptance: ng init', function () {
.then(confirmBlueprinted);
});

it('ng init --inline-template does not generate a template file', () => {
it('ng update --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');
expect(existsSync(templateFile)).to.equal(false);
});
});

it('ng init --inline-style does not gener a style file', () => {
it('ng update --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');
Expand Down

0 comments on commit 11fe6e6

Please sign in to comment.