1 | "use strict";
|
2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4 | return new (P || (P = Promise))(function (resolve, reject) {
|
5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9 | });
|
10 | };
|
11 | Object.defineProperty(exports, "__esModule", { value: true });
|
12 | exports.moveDefaultProjectToStart = exports.askForProjectName = exports.shouldGenerateSpec = exports.shouldAskForProject = void 0;
|
13 | const inquirer = require("inquirer");
|
14 | const get_value_or_default_1 = require("../compiler/helpers/get-value-or-default");
|
15 | const questions_1 = require("../questions/questions");
|
16 | function shouldAskForProject(schematic, configurationProjects, appName) {
|
17 | return (['app', 'sub-app', 'library', 'lib'].includes(schematic) === false &&
|
18 | configurationProjects &&
|
19 | Object.entries(configurationProjects).length !== 0 &&
|
20 | !appName);
|
21 | }
|
22 | exports.shouldAskForProject = shouldAskForProject;
|
23 | function shouldGenerateSpec(configuration, schematic, appName, specValue, specPassedAsInput) {
|
24 | if (specPassedAsInput === true || specPassedAsInput === undefined) {
|
25 |
|
26 | return specValue;
|
27 | }
|
28 | let specConfiguration = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'generateOptions.spec', appName || '');
|
29 | if (typeof specConfiguration === 'boolean') {
|
30 | return specConfiguration;
|
31 | }
|
32 | if (typeof specConfiguration === 'object' &&
|
33 | specConfiguration[schematic] !== undefined) {
|
34 | return specConfiguration[schematic];
|
35 | }
|
36 | if (typeof specConfiguration === 'object' && appName) {
|
37 |
|
38 |
|
39 | specConfiguration = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'generateOptions.spec', '');
|
40 | if (typeof specConfiguration === 'boolean') {
|
41 | return specConfiguration;
|
42 | }
|
43 | if (typeof specConfiguration === 'object' &&
|
44 | specConfiguration[schematic] !== undefined) {
|
45 | return specConfiguration[schematic];
|
46 | }
|
47 | }
|
48 | return specValue;
|
49 | }
|
50 | exports.shouldGenerateSpec = shouldGenerateSpec;
|
51 | function askForProjectName(promptQuestion, projects) {
|
52 | return __awaiter(this, void 0, void 0, function* () {
|
53 | const questions = [
|
54 | (0, questions_1.generateSelect)('appName')(promptQuestion)(projects),
|
55 | ];
|
56 | const prompt = inquirer.createPromptModule();
|
57 | return prompt(questions);
|
58 | });
|
59 | }
|
60 | exports.askForProjectName = askForProjectName;
|
61 | function moveDefaultProjectToStart(configuration, defaultProjectName, defaultLabel) {
|
62 | let projects = configuration.projects != null ? Object.keys(configuration.projects) : [];
|
63 | if (configuration.sourceRoot !== 'src') {
|
64 | projects = projects.filter((p) => p !== defaultProjectName.replace(defaultLabel, ''));
|
65 | }
|
66 | projects.unshift(defaultProjectName);
|
67 | return projects;
|
68 | }
|
69 | exports.moveDefaultProjectToStart = moveDefaultProjectToStart;
|