"use strict"; /** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ Object.defineProperty(exports, "__esModule", { value: true }); const schematics_1 = require("@angular-devkit/schematics"); const tasks_1 = require("@angular-devkit/schematics/tasks"); function default_1(options) { if (!options.directory) { // If scoped project (i.e. "@foo/bar"), convert directory to "foo/bar". options.directory = options.name.startsWith('@') ? options.name.slice(1) : options.name; } const workspaceOptions = { name: options.name, version: options.version, newProjectRoot: options.newProjectRoot, minimal: options.minimal, strict: options.strict, packageManager: options.packageManager, }; const applicationOptions = { projectRoot: '', name: options.name, inlineStyle: options.inlineStyle, inlineTemplate: options.inlineTemplate, prefix: options.prefix, viewEncapsulation: options.viewEncapsulation, routing: options.routing, style: options.style, skipTests: options.skipTests, skipPackageJson: false, // always 'skipInstall' here, so that we do it after the move skipInstall: true, strict: options.strict, minimal: options.minimal, standalone: options.standalone, ssr: options.ssr, }; return (0, schematics_1.chain)([ (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.empty)(), [ (0, schematics_1.schematic)('workspace', workspaceOptions), options.createApplication ? (0, schematics_1.schematic)('application', applicationOptions) : schematics_1.noop, (0, schematics_1.move)(options.directory), ])), (_host, context) => { let packageTask; if (!options.skipInstall) { packageTask = context.addTask(new tasks_1.NodePackageInstallTask({ workingDirectory: options.directory, packageManager: options.packageManager, })); if (options.linkCli) { packageTask = context.addTask(new tasks_1.NodePackageLinkTask('@angular/cli', options.directory), [packageTask]); } } if (!options.skipGit) { const commit = typeof options.commit == 'object' ? options.commit : options.commit ? {} : false; context.addTask(new tasks_1.RepositoryInitializerTask(options.directory, commit), packageTask ? [packageTask] : []); } }, ]); } exports.default = default_1;