[6a3a178] | 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.io/license
|
---|
| 8 | */
|
---|
| 9 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 10 | const schematics_1 = require("@angular-devkit/schematics");
|
---|
| 11 | const tasks_1 = require("@angular-devkit/schematics/tasks");
|
---|
| 12 | const validation_1 = require("../utility/validation");
|
---|
| 13 | function default_1(options) {
|
---|
| 14 | if (!options.name) {
|
---|
| 15 | throw new schematics_1.SchematicsException(`Invalid options, "name" is required.`);
|
---|
| 16 | }
|
---|
| 17 | validation_1.validateProjectName(options.name);
|
---|
| 18 | if (!options.directory) {
|
---|
| 19 | options.directory = options.name;
|
---|
| 20 | }
|
---|
| 21 | const workspaceOptions = {
|
---|
| 22 | name: options.name,
|
---|
| 23 | version: options.version,
|
---|
| 24 | newProjectRoot: options.newProjectRoot,
|
---|
| 25 | minimal: options.minimal,
|
---|
| 26 | strict: options.strict,
|
---|
| 27 | packageManager: options.packageManager,
|
---|
| 28 | };
|
---|
| 29 | const applicationOptions = {
|
---|
| 30 | projectRoot: '',
|
---|
| 31 | name: options.name,
|
---|
| 32 | inlineStyle: options.inlineStyle,
|
---|
| 33 | inlineTemplate: options.inlineTemplate,
|
---|
| 34 | prefix: options.prefix,
|
---|
| 35 | viewEncapsulation: options.viewEncapsulation,
|
---|
| 36 | routing: options.routing,
|
---|
| 37 | style: options.style,
|
---|
| 38 | skipTests: options.skipTests,
|
---|
| 39 | skipPackageJson: false,
|
---|
| 40 | // always 'skipInstall' here, so that we do it after the move
|
---|
| 41 | skipInstall: true,
|
---|
| 42 | strict: options.strict,
|
---|
| 43 | minimal: options.minimal,
|
---|
| 44 | legacyBrowsers: options.legacyBrowsers || undefined,
|
---|
| 45 | };
|
---|
| 46 | return schematics_1.chain([
|
---|
| 47 | schematics_1.mergeWith(schematics_1.apply(schematics_1.empty(), [
|
---|
| 48 | schematics_1.schematic('workspace', workspaceOptions),
|
---|
| 49 | options.createApplication ? schematics_1.schematic('application', applicationOptions) : schematics_1.noop,
|
---|
| 50 | schematics_1.move(options.directory),
|
---|
| 51 | ])),
|
---|
| 52 | (_host, context) => {
|
---|
| 53 | let packageTask;
|
---|
| 54 | if (!options.skipInstall) {
|
---|
| 55 | packageTask = context.addTask(new tasks_1.NodePackageInstallTask({
|
---|
| 56 | workingDirectory: options.directory,
|
---|
| 57 | packageManager: options.packageManager,
|
---|
| 58 | }));
|
---|
| 59 | if (options.linkCli) {
|
---|
| 60 | packageTask = context.addTask(new tasks_1.NodePackageLinkTask('@angular/cli', options.directory), [packageTask]);
|
---|
| 61 | }
|
---|
| 62 | }
|
---|
| 63 | if (!options.skipGit) {
|
---|
| 64 | const commit = typeof options.commit == 'object' ? options.commit : options.commit ? {} : false;
|
---|
| 65 | context.addTask(new tasks_1.RepositoryInitializerTask(options.directory, commit), packageTask ? [packageTask] : []);
|
---|
| 66 | }
|
---|
| 67 | },
|
---|
| 68 | ]);
|
---|
| 69 | }
|
---|
| 70 | exports.default = default_1;
|
---|