diff --git a/docs/documentation/update.md b/docs/documentation/update.md deleted file mode 100644 index 59b36ee5b4f0..000000000000 --- a/docs/documentation/update.md +++ /dev/null @@ -1,29 +0,0 @@ - - -# ng update - -## Overview -`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. - -## Options -`--dry-run` (`-d`) run through without making any changes - -`--skip-install` (`-si`) skip installing packages - -`--skip-git` (`-sg`) skip initializing a git repository - -`--directory` (`-dir`) the directory name to create the app in - -`--source-dir` (`-sd`) the name of the source directory - -`--style` the style file default extension - -`--prefix` (`p`) the prefix to use for all component selectors - -`--routing` flag to indicate whether to generate a routing module - -`--inline-style` (`is`) flag to indicate if the app component should have an inline style - -`--inline-template` (`it`) flag to indicate if the app component should have an inline template \ No newline at end of file diff --git a/packages/@angular/cli/addon/index.js b/packages/@angular/cli/addon/index.js index 00cd26fe6672..35546a970444 100644 --- a/packages/@angular/cli/addon/index.js +++ b/packages/@angular/cli/addon/index.js @@ -24,7 +24,6 @@ module.exports = { 'new': require('../commands/new').default, 'generate': require('../commands/generate').default, 'destroy': require('../commands/destroy').default, - 'init': require('../commands/init').default, 'test': require('../commands/test').default, 'e2e': require('../commands/e2e').default, 'help': require('../commands/help').default, diff --git a/packages/@angular/cli/commands/completion.ts b/packages/@angular/cli/commands/completion.ts index 0751ee186c5f..620a943714c5 100644 --- a/packages/@angular/cli/commands/completion.ts +++ b/packages/@angular/cli/commands/completion.ts @@ -29,6 +29,7 @@ export interface CompletionCommandOptions { const commandsToIgnore = [ 'easter-egg', + 'init', 'destroy', 'github-pages-deploy' // errors because there is no base github-pages command ]; diff --git a/packages/@angular/cli/commands/help.ts b/packages/@angular/cli/commands/help.ts index af96d016e97e..f3940e06d699 100644 --- a/packages/@angular/cli/commands/help.ts +++ b/packages/@angular/cli/commands/help.ts @@ -7,6 +7,7 @@ const lookupCommand = require('../ember-cli/lib/cli/lookup-command'); const commandsToIgnore = [ 'easter-egg', + 'init', 'destroy' ]; diff --git a/packages/@angular/cli/commands/init.ts b/packages/@angular/cli/commands/init.ts index b036bc2cd93f..e8cb2979d996 100644 --- a/packages/@angular/cli/commands/init.ts +++ b/packages/@angular/cli/commands/init.ts @@ -3,7 +3,6 @@ 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: ['u', 'update', 'i'], works: 'everywhere', availableOptions: [ diff --git a/packages/@angular/cli/commands/new.ts b/packages/@angular/cli/commands/new.ts index 72420afb6f6e..a9b1cc2ee1d2 100644 --- a/packages/@angular/cli/commands/new.ts +++ b/packages/@angular/cli/commands/new.ts @@ -8,7 +8,7 @@ const SilentError = require('silent-error'); 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 a new Angular app.`, works: 'outsideProject', availableOptions: [ diff --git a/tests/acceptance/init.spec.js b/tests/acceptance/init.spec.js deleted file mode 100644 index bfef2e731697..000000000000 --- a/tests/acceptance/init.spec.js +++ /dev/null @@ -1,203 +0,0 @@ -'use strict'; - -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 path = require('path'); -var tmp = require('../helpers/tmp'); -var root = path.join(__dirname, '../../packages/@angular/cli'); -var util = require('util'); -var minimatch = require('minimatch'); -var intersect = require('lodash/intersection'); -var remove = require('lodash/remove'); -var unique = require('lodash/uniq'); -var forEach = require('lodash/forEach'); -var any = require('lodash/some'); -var EOL = require('os').EOL; -var existsSync = require('exists-sync'); - -var defaultIgnoredFiles = Blueprint.ignoredFiles; - -describe('Acceptance: ng update', function () { - this.timeout(20000); - - beforeEach(function () { - // Make a copy of defaultIgnoredFiles. - Blueprint.ignoredFiles = defaultIgnoredFiles.splice(0); - - return tmp.setup('./tmp').then(function () { - process.chdir('./tmp'); - }); - }); - - afterEach(function () { - return tmp.teardown('./tmp'); - }); - - function confirmBlueprinted(routing) { - routing = !!routing; - var blueprintPath = path.join(root, 'blueprints', 'ng2', 'files'); - var expected = unique(walkSync(blueprintPath).sort()); - var actual = walkSync('.').sort(); - - forEach(Blueprint.renamedFiles, function (destFile, srcFile) { - expected[expected.indexOf(srcFile)] = destFile; - }); - - expected.forEach(function (file, index) { - expected[index] = file.replace(/__name__/g, 'app'); - expected[index] = expected[index].replace(/__styleext__/g, 'css'); - expected[index] = expected[index].replace(/__path__/g, 'src'); - }); - - if (!routing) { - expected = expected.filter(p => p.indexOf('app-routing.module.ts') < 0); - } - - removeIgnored(expected); - removeIgnored(actual); - - expected.sort(); - - expect(expected).to.deep.equal( - actual, - EOL + ' expected: ' + util.inspect(expected) + EOL + ' but got: ' + util.inspect(actual)); - } - - function confirmGlobBlueprinted(pattern) { - var blueprintPath = path.join(root, 'blueprints', 'ng2', 'files'); - var actual = pickSync('.', pattern); - var expected = intersect(pickSync(blueprintPath, pattern), actual); - - removeIgnored(expected); - removeIgnored(actual); - - expected.sort(); - - expect(expected).to.deep.equal( - actual, - EOL + ' expected: ' + util.inspect(expected) + EOL + ' but got: ' + util.inspect(actual)); - } - - function pickSync(filePath, pattern) { - return glob.sync(path.join('**', pattern), { cwd: filePath, dot: true, mark: true, strict: true }) - .sort(); - } - - function removeIgnored(array) { - remove(array, function (fn) { - return any(Blueprint.ignoredFiles, function (ignoredFile) { - return minimatch(fn, ignoredFile, { matchBase: true }); - }); - }); - } - - it('ng init does the same as ng update', function () { - return ng([ - 'init', - '--skip-install' - ]).then(confirmBlueprinted); - }); - - it('ng update can run in created folder', function () { - return tmp.setup('./tmp/foo') - .then(function () { - process.chdir('./tmp/foo'); - }) - .then(function () { - return ng([ - 'init', - '--skip-install', - '--name', - 'tmp' - ]); - }) - .then(confirmBlueprinted) - .then(function () { - return tmp.teardown('./tmp/foo'); - }); - }); - - it('init an already init\'d folder', function () { - return ng(['init', '--skip-install']) - .then(function () { - return ng(['init', '--skip-install']); - }) - .then(confirmBlueprinted); - }); - - it('init a single file', function () { - return ng(['init', 'package.json', '--skip-install']) - .then(function () { - return 'package.json'; - }) - .then(confirmGlobBlueprinted); - }); - - it('init a single file on already init\'d folder', function () { - return ng(['init', '--skip-install']) - .then(function () { - return ng(['init', 'package.json', '--skip-install']); - }) - .then(confirmBlueprinted); - }); - - it('init multiple files by glob pattern', function () { - return ng(['init', 'src/**', '--skip-install']) - .then(function () { - return 'src/**'; - }) - .then(confirmGlobBlueprinted); - }); - - it('init multiple files by glob pattern on already init\'d folder', function () { - return ng(['init', '--skip-install']) - .then(function () { - return ng(['init', 'src/**', '--skip-install']); - }) - .then(confirmBlueprinted); - }); - - it('init multiple files by glob patterns', function () { - return ng(['init', 'src/**', 'package.json', '--skip-install']) - .then(function () { - return '{src/**,package.json}'; - }) - .then(confirmGlobBlueprinted); - }); - - it('init multiple files by glob patterns on already init\'d folder', function () { - return ng(['init', '--skip-install']) - .then(function () { - return ng(['init', 'src/**', 'package.json', '--skip-install']); - }) - .then(confirmBlueprinted); - }); - - it('ng update --inline-template does not generate a template file', () => { - return ng(['init', '--skip-install', '--skip-git', '--inline-template']) - .then(() => { - const templateFile = path.join('src', 'app', 'app.component.html'); - expect(existsSync(templateFile)).to.equal(false); - }); - }); - - it('ng update --inline-style does not gener a style file', () => { - return ng(['init', '--skip-install', '--skip-git', '--inline-style']) - .then(() => { - const styleFile = path.join('src', 'app', 'app.component.css'); - expect(existsSync(styleFile)).to.equal(false); - }); - }); - - it('should skip spec files when passed --skip-tests', () => { - return ng(['init', '--skip-install', '--skip-git', '--skip-tests']) - .then(() => { - const specFile = path.join('src', 'app', 'app.component.spec.ts'); - expect(existsSync(specFile)).to.equal(false); - }); - }); - -});