new-impl.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. "use strict";
  2. /**
  3. * @license
  4. * Copyright Google Inc. All Rights Reserved.
  5. *
  6. * Use of this source code is governed by an MIT-style license that can be
  7. * found in the LICENSE file at https://angular.io/license
  8. */
  9. Object.defineProperty(exports, "__esModule", { value: true });
  10. const schematic_command_1 = require("../models/schematic-command");
  11. class NewCommand extends schematic_command_1.SchematicCommand {
  12. constructor() {
  13. super(...arguments);
  14. this.allowMissingWorkspace = true;
  15. this.schematicName = 'ng-new';
  16. }
  17. async initialize(options) {
  18. if (options.collection) {
  19. this.collectionName = options.collection;
  20. }
  21. else {
  22. this.collectionName = this.parseCollectionName(options);
  23. }
  24. return super.initialize(options);
  25. }
  26. async run(options) {
  27. // Register the version of the CLI in the registry.
  28. const packageJson = require('../package.json');
  29. const version = packageJson.version;
  30. this._workflow.registry.addSmartDefaultProvider('ng-cli-version', () => version);
  31. return this.runSchematic({
  32. collectionName: this.collectionName,
  33. schematicName: this.schematicName,
  34. schematicOptions: options['--'] || [],
  35. debug: !!options.debug,
  36. dryRun: !!options.dryRun,
  37. force: !!options.force,
  38. });
  39. }
  40. parseCollectionName(options) {
  41. return options.collection || this.getDefaultSchematicCollection();
  42. }
  43. }
  44. exports.NewCommand = NewCommand;