index.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. "use strict";
  2. /**
  3. * @license
  4. * Copyright Google LLC 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.dev/license
  8. */
  9. Object.defineProperty(exports, "__esModule", { value: true });
  10. exports.default = default_1;
  11. const schematics_1 = require("@angular-devkit/schematics");
  12. const tasks_1 = require("@angular-devkit/schematics/tasks");
  13. function default_1(options) {
  14. if (!options.directory) {
  15. // If scoped project (i.e. "@foo/bar"), convert directory to "foo/bar".
  16. options.directory = options.name.startsWith('@') ? options.name.slice(1) : options.name;
  17. }
  18. const workspaceOptions = {
  19. name: options.name,
  20. version: options.version,
  21. newProjectRoot: options.newProjectRoot,
  22. minimal: options.minimal,
  23. strict: options.strict,
  24. packageManager: options.packageManager,
  25. };
  26. const applicationOptions = {
  27. projectRoot: '',
  28. name: options.name,
  29. inlineStyle: options.inlineStyle,
  30. inlineTemplate: options.inlineTemplate,
  31. prefix: options.prefix,
  32. viewEncapsulation: options.viewEncapsulation,
  33. routing: options.routing,
  34. style: options.style,
  35. skipTests: options.skipTests,
  36. skipPackageJson: false,
  37. // always 'skipInstall' here, so that we do it after the move
  38. skipInstall: true,
  39. strict: options.strict,
  40. minimal: options.minimal,
  41. standalone: options.standalone,
  42. ssr: options.ssr,
  43. zoneless: options.zoneless,
  44. };
  45. return (0, schematics_1.chain)([
  46. (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.empty)(), [
  47. (0, schematics_1.schematic)('workspace', workspaceOptions),
  48. options.createApplication ? (0, schematics_1.schematic)('application', applicationOptions) : schematics_1.noop,
  49. (0, schematics_1.move)(options.directory),
  50. ])),
  51. (_host, context) => {
  52. let packageTask;
  53. if (!options.skipInstall) {
  54. packageTask = context.addTask(new tasks_1.NodePackageInstallTask({
  55. workingDirectory: options.directory,
  56. packageManager: options.packageManager,
  57. }));
  58. }
  59. if (!options.skipGit) {
  60. const commit = typeof options.commit == 'object' ? options.commit : options.commit ? {} : false;
  61. context.addTask(new tasks_1.RepositoryInitializerTask(options.directory, commit), packageTask ? [packageTask] : []);
  62. }
  63. },
  64. ]);
  65. }