@sap-ux/fiori-app-sub-generator 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/generators/app/index.d.ts +3 -0
- package/generators/app/index.js +5 -0
- package/generators/app-headless/index.d.ts +34 -0
- package/generators/app-headless/index.js +75 -0
- package/generators/app-headless/transforms.d.ts +9 -0
- package/generators/app-headless/transforms.js +208 -0
- package/generators/fiori-app-generator/end.d.ts +49 -0
- package/generators/fiori-app-generator/end.js +105 -0
- package/generators/fiori-app-generator/fioriAppGenerator.d.ts +45 -0
- package/generators/fiori-app-generator/fioriAppGenerator.js +319 -0
- package/generators/fiori-app-generator/fioriAppGeneratorOptions.d.ts +94 -0
- package/generators/fiori-app-generator/fioriAppGeneratorOptions.js +3 -0
- package/generators/fiori-app-generator/index.d.ts +3 -0
- package/generators/fiori-app-generator/index.js +19 -0
- package/generators/fiori-app-generator/install.d.ts +34 -0
- package/generators/fiori-app-generator/install.js +80 -0
- package/generators/fiori-app-generator/prompting.d.ts +84 -0
- package/generators/fiori-app-generator/prompting.js +303 -0
- package/generators/fiori-app-generator/subgenHelpers.d.ts +43 -0
- package/generators/fiori-app-generator/subgenHelpers.js +71 -0
- package/generators/fiori-app-generator/transforms.d.ts +38 -0
- package/generators/fiori-app-generator/transforms.js +278 -0
- package/generators/fiori-app-generator/writing.d.ts +27 -0
- package/generators/fiori-app-generator/writing.js +94 -0
- package/generators/index.d.ts +6 -0
- package/generators/index.js +22 -0
- package/generators/translations/fioriAppSubGenerator.i18n.json +119 -0
- package/generators/types/common.d.ts +46 -0
- package/generators/types/common.js +3 -0
- package/generators/types/constants.d.ts +60 -0
- package/generators/types/constants.js +98 -0
- package/generators/types/external.d.ts +261 -0
- package/generators/types/external.js +88 -0
- package/generators/types/index.d.ts +7 -0
- package/generators/types/index.js +23 -0
- package/generators/types/state.d.ts +149 -0
- package/generators/types/state.js +35 -0
- package/generators/types/telemetryEvents.d.ts +61 -0
- package/generators/types/telemetryEvents.js +3 -0
- package/generators/types/yeomanUiStepConfig.d.ts +13 -0
- package/generators/types/yeomanUiStepConfig.js +3 -0
- package/generators/utils/appWizardCache.d.ts +40 -0
- package/generators/utils/appWizardCache.js +72 -0
- package/generators/utils/command-runner.d.ts +30 -0
- package/generators/utils/command-runner.js +88 -0
- package/generators/utils/common.d.ts +147 -0
- package/generators/utils/common.js +286 -0
- package/generators/utils/eventHooks.d.ts +29 -0
- package/generators/utils/eventHooks.js +48 -0
- package/generators/utils/i18n.d.ts +16 -0
- package/generators/utils/i18n.js +54 -0
- package/generators/utils/index.d.ts +9 -0
- package/generators/utils/index.js +25 -0
- package/generators/utils/sapuxLayer.d.ts +15 -0
- package/generators/utils/sapuxLayer.js +24 -0
- package/generators/utils/stepsHelper.d.ts +47 -0
- package/generators/utils/stepsHelper.js +161 -0
- package/generators/utils/telemetry.d.ts +16 -0
- package/generators/utils/telemetry.js +41 -0
- package/package.json +84 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.installDependencies = installDependencies;
|
|
4
|
+
const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
/**
|
|
7
|
+
* The dependencies required for code assist for the root CAP project package.json.
|
|
8
|
+
* These are not written to the `app` package.json by the `@sap-ux/ui5-application-writer`, as is done for non-CAP projects.
|
|
9
|
+
*/
|
|
10
|
+
const codeAssistDeps = {
|
|
11
|
+
eslint: '7.32.0',
|
|
12
|
+
'@sap/eslint-plugin-ui5-jsdocs': '2.0.5',
|
|
13
|
+
'@sapui5/ts-types': '1.92.2'
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Install the dependencies for the specified project. In the case of CAP projects, the dependencies are installed to the root project
|
|
17
|
+
* if npm workspace option is used, otherwise they are installed to the app project only.
|
|
18
|
+
*
|
|
19
|
+
* @param projectPath
|
|
20
|
+
* @param log
|
|
21
|
+
* @param capOptions
|
|
22
|
+
*/
|
|
23
|
+
async function installProjectDependencies(projectPath, log, capOptions) {
|
|
24
|
+
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
25
|
+
const runner = new utils_1.CommandRunner(log);
|
|
26
|
+
const runArgs = [];
|
|
27
|
+
if (capOptions?.codeAssist) {
|
|
28
|
+
runArgs.push(...Object.keys(codeAssistDeps).map((dep) => `${dep}@${codeAssistDeps[dep]}`));
|
|
29
|
+
}
|
|
30
|
+
runArgs.unshift('install');
|
|
31
|
+
try {
|
|
32
|
+
log?.info((0, utils_1.t)('logMessages.installingDependencies', { path: projectPath }));
|
|
33
|
+
const t0 = performance.now();
|
|
34
|
+
await runner.run(npm, runArgs, { cwd: projectPath }, true);
|
|
35
|
+
fiori_generator_shared_1.TelemetryHelper.createTelemetryData({ installFailure: false });
|
|
36
|
+
if (capOptions?.useWorkspaces) {
|
|
37
|
+
// NPM workspaces are used, run full install at root of project
|
|
38
|
+
// This will trigger a second install, only one install should be needed for NPM workspaces
|
|
39
|
+
await runner.run(npm, ['install', '--no-audit', '--no-fund', '--silent', '--prefer-offline', '--no-progress'], { cwd: capOptions.rootPath }, true);
|
|
40
|
+
}
|
|
41
|
+
const t1 = performance.now();
|
|
42
|
+
log?.debug((0, utils_1.t)('logMessages.dependenciesInstalled', { installTime: Math.round((t1 - t0) / 1000) }));
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
log?.info(error ?? (0, utils_1.t)('logMessages.errorInstallingDependencies'));
|
|
46
|
+
fiori_generator_shared_1.TelemetryHelper.createTelemetryData({ installFailure: true });
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
48
|
+
(0, fiori_generator_shared_1.sendTelemetry)('GENERATION_INSTALL_FAIL', fiori_generator_shared_1.TelemetryHelper.telemetryData);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Perform the installation of dependencies for the specified project.
|
|
53
|
+
* If a CAP service is provided AND `useNpmWorkspaces` is false, the dependencies will be installed to the CAP root project,
|
|
54
|
+
* otherwise they will be installed to the specified app `packagePath`.
|
|
55
|
+
*
|
|
56
|
+
* @param param0
|
|
57
|
+
* @param param0.appPackagePath
|
|
58
|
+
* @param param0.capService
|
|
59
|
+
* @param param0.enableCodeAssist
|
|
60
|
+
* @param param0.useNpmWorkspaces
|
|
61
|
+
* @param param0.ui5Version
|
|
62
|
+
* @param logger The logger to use for output
|
|
63
|
+
* @returns Promise<void>
|
|
64
|
+
*/
|
|
65
|
+
async function installDependencies({ appPackagePath, capService, enableCodeAssist, useNpmWorkspaces, ui5Version }, logger) {
|
|
66
|
+
// Install additional libs to root CAP project
|
|
67
|
+
let capInstallOpts;
|
|
68
|
+
if (capService) {
|
|
69
|
+
capInstallOpts = {
|
|
70
|
+
codeAssist: enableCodeAssist,
|
|
71
|
+
rootPath: capService.projectPath,
|
|
72
|
+
// if NPM workspaces are used, depsInstallPath will be the CAP projectpackage.json. Otherwise the CAP app package.json.
|
|
73
|
+
depsInstallPath: useNpmWorkspaces ? capService.projectPath : appPackagePath,
|
|
74
|
+
useWorkspaces: useNpmWorkspaces,
|
|
75
|
+
ui5Version
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
await installProjectDependencies(capInstallOpts?.depsInstallPath ?? appPackagePath, logger, capInstallOpts);
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=install.js.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Logger } from '@sap-ux/logger';
|
|
2
|
+
import { type CapService, OdataVersion } from '@sap-ux/odata-service-inquirer';
|
|
3
|
+
import type { UI5ApplicationAnswers, UI5ApplicationPromptOptions } from '@sap-ux/ui5-application-inquirer';
|
|
4
|
+
import type { Question } from 'inquirer';
|
|
5
|
+
import type { Adapter } from 'yeoman-environment';
|
|
6
|
+
import type { FioriAppGeneratorPromptSettings, Floorplan, Project, PromptExtension, Service, YeomanUiStepConfig } from '../types';
|
|
7
|
+
declare const viewNamePromptName = "viewName";
|
|
8
|
+
export interface ViewNameAnswer {
|
|
9
|
+
[viewNamePromptName]: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const getViewQuestion: () => Question<ViewNameAnswer>;
|
|
12
|
+
/**
|
|
13
|
+
* Options for getting UI5 application answers
|
|
14
|
+
*/
|
|
15
|
+
type PromptUI5AppAnswersOptions = {
|
|
16
|
+
projectName?: Project['name'];
|
|
17
|
+
targetFolder?: Project['targetFolder'];
|
|
18
|
+
service: Partial<Service>;
|
|
19
|
+
promptSettings?: FioriAppGeneratorPromptSettings;
|
|
20
|
+
hideUI5VersionPrompt?: boolean;
|
|
21
|
+
floorplan: Floorplan;
|
|
22
|
+
promptExtension?: PromptExtension;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Creates the prompt options for UI5 application prompting and calls `prompt`.
|
|
26
|
+
* The answers to the questions are returned.
|
|
27
|
+
*
|
|
28
|
+
* @param param0
|
|
29
|
+
* @param param0.hideUI5VersionPrompt this will override the `hide` property of the ui5Version prompt setting if provided
|
|
30
|
+
* @param param0.service
|
|
31
|
+
* @param param0.projectName
|
|
32
|
+
* @param param0.targetFolder
|
|
33
|
+
* @param param0.promptSettings
|
|
34
|
+
* @param param0.floorplan
|
|
35
|
+
* @param param0.promptExtension
|
|
36
|
+
* @param yeomanUiStepConfig
|
|
37
|
+
* @param adapter
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
export declare function promptUI5ApplicationAnswers({ service, projectName, targetFolder, promptSettings, hideUI5VersionPrompt, floorplan, promptExtension }: PromptUI5AppAnswersOptions, yeomanUiStepConfig: YeomanUiStepConfig[], adapter: Adapter): Promise<{
|
|
41
|
+
ui5AppAnswers: UI5ApplicationAnswers;
|
|
42
|
+
localUI5Version: string | undefined;
|
|
43
|
+
}>;
|
|
44
|
+
/**
|
|
45
|
+
* Prompts the user for the OData service answers.
|
|
46
|
+
*
|
|
47
|
+
* @param options
|
|
48
|
+
* @param logger
|
|
49
|
+
* @param adapter
|
|
50
|
+
* @returns {Promise<Service>}
|
|
51
|
+
*/
|
|
52
|
+
export declare function promptOdataServiceAnswers(options: OdataServiceInquirerOptions, logger: Logger, adapter: Adapter): Promise<Service>;
|
|
53
|
+
/**
|
|
54
|
+
* Creates the `UIApplicationPromptOptions`.
|
|
55
|
+
* Note that setting 'default', the default prompt value or function, or 'hide', whether the prompt should be shown,
|
|
56
|
+
* to `undefined` should mean that the setting is ignored by the prompt.
|
|
57
|
+
*
|
|
58
|
+
* @param service
|
|
59
|
+
* @param appGenStepConfigList
|
|
60
|
+
* @param floorplan
|
|
61
|
+
* @param projectName
|
|
62
|
+
* @param targetFolder
|
|
63
|
+
* @param promptSettings
|
|
64
|
+
* @param extensions
|
|
65
|
+
* @returns {Promise<UI5ApplicationPromptOptions>} prompt options that may be used to configure UI5 application prompting
|
|
66
|
+
*/
|
|
67
|
+
export declare function createUI5ApplicationPromptOptions(service: Partial<Readonly<Service>>, appGenStepConfigList: YeomanUiStepConfig[], floorplan: Floorplan, projectName?: Project['name'], targetFolder?: Project['targetFolder'], promptSettings?: FioriAppGeneratorPromptSettings, extensions?: PromptExtension): Promise<UI5ApplicationPromptOptions>;
|
|
68
|
+
/**
|
|
69
|
+
* Convienience type for the options of the `createOdataServicePromptOptions` function.
|
|
70
|
+
*/
|
|
71
|
+
export interface OdataServiceInquirerOptions {
|
|
72
|
+
requiredOdataVersion?: OdataVersion;
|
|
73
|
+
allowNoDatasource?: boolean;
|
|
74
|
+
capService?: CapService;
|
|
75
|
+
/**
|
|
76
|
+
* Note: only some of the allowed prompt options are currently supported.
|
|
77
|
+
* Eventually all should be supported by merging the options with the prompt specific options.
|
|
78
|
+
*/
|
|
79
|
+
promptOptions?: FioriAppGeneratorPromptSettings;
|
|
80
|
+
showCollabDraftWarning?: boolean;
|
|
81
|
+
workspaceFolders?: string[];
|
|
82
|
+
}
|
|
83
|
+
export {};
|
|
84
|
+
//# sourceMappingURL=prompting.d.ts.map
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getViewQuestion = void 0;
|
|
7
|
+
exports.promptUI5ApplicationAnswers = promptUI5ApplicationAnswers;
|
|
8
|
+
exports.promptOdataServiceAnswers = promptOdataServiceAnswers;
|
|
9
|
+
exports.createUI5ApplicationPromptOptions = createUI5ApplicationPromptOptions;
|
|
10
|
+
const feature_toggle_1 = require("@sap-ux/feature-toggle");
|
|
11
|
+
const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
|
|
12
|
+
const odata_service_inquirer_1 = require("@sap-ux/odata-service-inquirer");
|
|
13
|
+
const telemetry_1 = require("@sap-ux/telemetry");
|
|
14
|
+
const ui5_application_inquirer_1 = require("@sap-ux/ui5-application-inquirer");
|
|
15
|
+
const ui5_info_1 = require("@sap-ux/ui5-info");
|
|
16
|
+
const merge_1 = __importDefault(require("lodash/merge"));
|
|
17
|
+
const path_1 = require("path");
|
|
18
|
+
const types_1 = require("../types");
|
|
19
|
+
const utils_1 = require("../utils");
|
|
20
|
+
/**
|
|
21
|
+
* Validates the view name.
|
|
22
|
+
* The view name must be a valid identifier and must not be empty.
|
|
23
|
+
* The view name must not exceed 120 characters.
|
|
24
|
+
* The view name must start with a letter and can contain letters, numbers, hyphens, and underscores.
|
|
25
|
+
*
|
|
26
|
+
* @param {string} name The view name to validate.
|
|
27
|
+
* @returns {boolean | string} true if the view name is valid, otherwise a string with the error message
|
|
28
|
+
*/
|
|
29
|
+
function validateViewName(name) {
|
|
30
|
+
// Validate input is not empty
|
|
31
|
+
if (!name) {
|
|
32
|
+
return (0, utils_1.t)('prompts.viewName.validationMessages.viewNameRequired');
|
|
33
|
+
}
|
|
34
|
+
// Validate view names matches the allowed pattern
|
|
35
|
+
const regExp = /^[a-zA-Z]+[a-zA-Z0-9-_]{0,120}$/;
|
|
36
|
+
const result = regExp.test(name);
|
|
37
|
+
if (name.length > 120) {
|
|
38
|
+
return (0, utils_1.t)('prompts.viewName.validationMessages.viewNameTooLong');
|
|
39
|
+
}
|
|
40
|
+
if (!result) {
|
|
41
|
+
return (0, utils_1.t)('prompts.viewName.validationMessages.viewNameInvalid');
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
const viewNamePromptName = 'viewName';
|
|
46
|
+
const getViewQuestion = () => {
|
|
47
|
+
return {
|
|
48
|
+
type: 'input',
|
|
49
|
+
name: viewNamePromptName,
|
|
50
|
+
message: (0, utils_1.t)('prompts.viewName.message'),
|
|
51
|
+
guiOptions: {
|
|
52
|
+
breadcrumb: true
|
|
53
|
+
},
|
|
54
|
+
default: 'View1',
|
|
55
|
+
validate: validateViewName
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
exports.getViewQuestion = getViewQuestion;
|
|
59
|
+
/**
|
|
60
|
+
* Creates the prompt options for UI5 application prompting and calls `prompt`.
|
|
61
|
+
* The answers to the questions are returned.
|
|
62
|
+
*
|
|
63
|
+
* @param param0
|
|
64
|
+
* @param param0.hideUI5VersionPrompt this will override the `hide` property of the ui5Version prompt setting if provided
|
|
65
|
+
* @param param0.service
|
|
66
|
+
* @param param0.projectName
|
|
67
|
+
* @param param0.targetFolder
|
|
68
|
+
* @param param0.promptSettings
|
|
69
|
+
* @param param0.floorplan
|
|
70
|
+
* @param param0.promptExtension
|
|
71
|
+
* @param yeomanUiStepConfig
|
|
72
|
+
* @param adapter
|
|
73
|
+
* @returns
|
|
74
|
+
*/
|
|
75
|
+
async function promptUI5ApplicationAnswers({ service, projectName, targetFolder, promptSettings, hideUI5VersionPrompt, floorplan, promptExtension }, yeomanUiStepConfig, adapter) {
|
|
76
|
+
let inquirerAdapter;
|
|
77
|
+
// type `any` will be replaced when we can import ESM modules
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
|
+
if (adapter?.actualAdapter) {
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
+
inquirerAdapter = adapter.actualAdapter;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
inquirerAdapter = adapter;
|
|
85
|
+
}
|
|
86
|
+
// Convert prompt related options to prompt settings
|
|
87
|
+
const pmptSettings = {
|
|
88
|
+
...promptSettings,
|
|
89
|
+
[ui5_application_inquirer_1.promptNames.ui5Version]: {
|
|
90
|
+
hide: hideUI5VersionPrompt ?? false
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const promptOptions = await createUI5ApplicationPromptOptions(service, yeomanUiStepConfig, floorplan, projectName, targetFolder, pmptSettings, promptExtension);
|
|
94
|
+
const ui5AppAnswers = await (0, ui5_application_inquirer_1.prompt)(inquirerAdapter, promptOptions, service.capService?.cdsUi5PluginInfo, (0, fiori_generator_shared_1.getHostEnvironment)() !== fiori_generator_shared_1.hostEnvironment.cli);
|
|
95
|
+
// Get the (latest) version available from npm, instead of UI5 versions service in case of unpublished versions
|
|
96
|
+
const localUI5Version = (await (0, ui5_info_1.getUI5Versions)({
|
|
97
|
+
minSupportedUI5Version: promptOptions.ui5Version?.minUI5Version,
|
|
98
|
+
onlyVersionNumbers: true,
|
|
99
|
+
onlyNpmVersion: true,
|
|
100
|
+
ui5SelectedVersion: ui5AppAnswers?.ui5Version ?? ui5_info_1.latestVersionString
|
|
101
|
+
}))[0]?.version;
|
|
102
|
+
return { ui5AppAnswers, localUI5Version };
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Prompts the user for the OData service answers.
|
|
106
|
+
*
|
|
107
|
+
* @param options
|
|
108
|
+
* @param logger
|
|
109
|
+
* @param adapter
|
|
110
|
+
* @returns {Promise<Service>}
|
|
111
|
+
*/
|
|
112
|
+
async function promptOdataServiceAnswers(options, logger, adapter) {
|
|
113
|
+
let inquirerAdapter;
|
|
114
|
+
// type `any` will be replaced when we can import ESM modules
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
116
|
+
if (adapter?.actualAdapter) {
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
118
|
+
inquirerAdapter = adapter.actualAdapter;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
inquirerAdapter = adapter;
|
|
122
|
+
}
|
|
123
|
+
const promptOptions = createOdataServicePromptOptions(options);
|
|
124
|
+
const answers = await (0, odata_service_inquirer_1.prompt)(inquirerAdapter, promptOptions, logger, (0, feature_toggle_1.isFeatureEnabled)(types_1.Features.enableGAIntegration), telemetry_1.ClientFactory.getTelemetryClient(), (0, fiori_generator_shared_1.getHostEnvironment)() !== fiori_generator_shared_1.hostEnvironment.cli);
|
|
125
|
+
const service = {
|
|
126
|
+
host: answers.origin,
|
|
127
|
+
client: answers.sapClient,
|
|
128
|
+
servicePath: answers.servicePath,
|
|
129
|
+
edmx: answers.metadata,
|
|
130
|
+
annotations: answers.annotations,
|
|
131
|
+
version: answers.odataVersion,
|
|
132
|
+
capService: answers.capService,
|
|
133
|
+
source: answers.datasourceType,
|
|
134
|
+
localEdmxFilePath: answers.metadataFilePath,
|
|
135
|
+
connectedSystem: answers.connectedSystem,
|
|
136
|
+
ignoreCertError: answers.ignoreCertError // TBI: ignoreCertError is not a property OdataServiceAnswers
|
|
137
|
+
};
|
|
138
|
+
return service;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Creates the `UIApplicationPromptOptions`.
|
|
142
|
+
* Note that setting 'default', the default prompt value or function, or 'hide', whether the prompt should be shown,
|
|
143
|
+
* to `undefined` should mean that the setting is ignored by the prompt.
|
|
144
|
+
*
|
|
145
|
+
* @param service
|
|
146
|
+
* @param appGenStepConfigList
|
|
147
|
+
* @param floorplan
|
|
148
|
+
* @param projectName
|
|
149
|
+
* @param targetFolder
|
|
150
|
+
* @param promptSettings
|
|
151
|
+
* @param extensions
|
|
152
|
+
* @returns {Promise<UI5ApplicationPromptOptions>} prompt options that may be used to configure UI5 application prompting
|
|
153
|
+
*/
|
|
154
|
+
async function createUI5ApplicationPromptOptions(service, appGenStepConfigList, floorplan, projectName, targetFolder, promptSettings, extensions) {
|
|
155
|
+
// prompt settings may be additionally provided e.g. set by adaptors
|
|
156
|
+
const ui5VersionPromptOptions = {
|
|
157
|
+
hide: promptSettings?.[ui5_application_inquirer_1.promptNames.ui5Version]?.hide ?? false,
|
|
158
|
+
minUI5Version: (0, utils_1.getMinSupportedUI5Version)(service.version ?? odata_service_inquirer_1.OdataVersion.v2, floorplan),
|
|
159
|
+
includeSeparators: (0, fiori_generator_shared_1.getHostEnvironment)() !== fiori_generator_shared_1.hostEnvironment.cli,
|
|
160
|
+
useAutocomplete: (0, fiori_generator_shared_1.getHostEnvironment)() === fiori_generator_shared_1.hostEnvironment.cli
|
|
161
|
+
};
|
|
162
|
+
const systemVersion = service.host ? await (0, ui5_info_1.getSapSystemUI5Version)(service.host) : undefined;
|
|
163
|
+
if (systemVersion) {
|
|
164
|
+
ui5VersionPromptOptions.defaultChoice = {
|
|
165
|
+
name: `${systemVersion} (Source system version)`,
|
|
166
|
+
value: systemVersion
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
let defaultTargetFolderOption;
|
|
170
|
+
if (service.capService?.projectPath) {
|
|
171
|
+
// CAP override
|
|
172
|
+
defaultTargetFolderOption = {
|
|
173
|
+
default: (0, path_1.join)(service.capService.projectPath, service.capService.appPath ?? '')
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
// Non-CAP combine project path with existing default logic
|
|
178
|
+
defaultTargetFolderOption = {
|
|
179
|
+
defaultValue: targetFolder,
|
|
180
|
+
validateFioriAppFolder: true
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
// Add more prompt options as required
|
|
184
|
+
const promptOptions = (0, merge_1.default)({
|
|
185
|
+
[ui5_application_inquirer_1.promptNames.name]: {
|
|
186
|
+
defaultValue: projectName
|
|
187
|
+
},
|
|
188
|
+
[ui5_application_inquirer_1.promptNames.targetFolder]: defaultTargetFolderOption,
|
|
189
|
+
[ui5_application_inquirer_1.promptNames.ui5Version]: ui5VersionPromptOptions,
|
|
190
|
+
[ui5_application_inquirer_1.promptNames.skipAnnotations]: {
|
|
191
|
+
hide: !service.capService
|
|
192
|
+
},
|
|
193
|
+
[ui5_application_inquirer_1.promptNames.addDeployConfig]: {
|
|
194
|
+
validatorCallback: (addDeployConfigAnswer) => {
|
|
195
|
+
(0, utils_1.validateNextStep)(addDeployConfigAnswer, (0, utils_1.t)('steps.projectAttributesConfig.title'), appGenStepConfigList, (0, utils_1.t)('steps.deployConfig.title'));
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
[ui5_application_inquirer_1.promptNames.addFlpConfig]: {
|
|
199
|
+
validatorCallback: (addFlpConfigAnswer) => {
|
|
200
|
+
(0, utils_1.validateNextStep)(addFlpConfigAnswer, (0, utils_1.t)('steps.projectAttributesConfig.title'), appGenStepConfigList, (0, utils_1.t)('steps.flpConfig.title'));
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
[ui5_application_inquirer_1.promptNames.enableTypeScript]: {
|
|
204
|
+
defaultValue: types_1.defaultPromptValues[ui5_application_inquirer_1.promptNames.enableTypeScript]
|
|
205
|
+
}
|
|
206
|
+
}, promptSettings);
|
|
207
|
+
// Configure the prompts which should be hidden behind the ad
|
|
208
|
+
const advancedPrompts = [
|
|
209
|
+
ui5_application_inquirer_1.promptNames.enableCodeAssist,
|
|
210
|
+
ui5_application_inquirer_1.promptNames.skipAnnotations,
|
|
211
|
+
ui5_application_inquirer_1.promptNames.enableEslint,
|
|
212
|
+
ui5_application_inquirer_1.promptNames.ui5Theme
|
|
213
|
+
];
|
|
214
|
+
advancedPrompts.forEach((advPromptKey) => {
|
|
215
|
+
const promptOpt = promptOptions[advPromptKey];
|
|
216
|
+
// Advanced options are hidden by default and so we must assign a default value or an answer may not be returned (since advanced options are not shown by default)
|
|
217
|
+
const defaultValue = types_1.defaultPromptValues[advPromptKey];
|
|
218
|
+
// We have a prompt option defined so update it with the advanced option
|
|
219
|
+
if (promptOpt) {
|
|
220
|
+
promptOpt.advancedOption = true;
|
|
221
|
+
// Set the default value if not already set and a default value is available
|
|
222
|
+
if (!promptOpt.default && defaultValue !== undefined) {
|
|
223
|
+
promptOpt.default = defaultValue;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
// No prompt option defined so create a new one
|
|
228
|
+
promptOptions[advPromptKey] = {
|
|
229
|
+
advancedOption: true
|
|
230
|
+
};
|
|
231
|
+
// Set the default value if default value is available
|
|
232
|
+
if (defaultValue !== undefined) {
|
|
233
|
+
promptOptions[advPromptKey].default = defaultValue;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
// Configure the generator extension settings by converting to prompt options
|
|
238
|
+
if (extensions) {
|
|
239
|
+
Object.entries(extensions).forEach(([key, ext]) => {
|
|
240
|
+
Object.assign(promptOptions[key] ??
|
|
241
|
+
Object.assign(promptOptions, { [key]: {} })[key], ext);
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return promptOptions;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Creates the prompt options for OData service prompting.
|
|
248
|
+
* Note that if a capService is provided, this takes precedence over the datasource type setting.
|
|
249
|
+
*
|
|
250
|
+
* @param options
|
|
251
|
+
* @param options.requiredOdataVersion will trigger warnings in prompts if the OData version is not supported.
|
|
252
|
+
* @param options.allowNoDatasource If true, the user will be able to select 'None' as the datasource type. Fiori Freestyle specific.
|
|
253
|
+
* @param options.capService If provided, the user will not be prompted for the CAP project and the default datasource type will be set to CAP project.
|
|
254
|
+
* @param options.promptOptions A limited set of prompt options that can be set by the caller.
|
|
255
|
+
* @param options.showCollabDraftWarning If true, a warning will be shown in the prompt if the service is a collaborative draft service.
|
|
256
|
+
* @returns
|
|
257
|
+
*/
|
|
258
|
+
function createOdataServicePromptOptions(options) {
|
|
259
|
+
let defaultDatasourceSelection;
|
|
260
|
+
const isYUI = (0, fiori_generator_shared_1.getHostEnvironment)() !== fiori_generator_shared_1.hostEnvironment.cli;
|
|
261
|
+
if (options.capService) {
|
|
262
|
+
defaultDatasourceSelection = odata_service_inquirer_1.DatasourceType.capProject;
|
|
263
|
+
}
|
|
264
|
+
else if (options.promptOptions?.systemSelection?.defaultChoice) {
|
|
265
|
+
defaultDatasourceSelection = odata_service_inquirer_1.DatasourceType.sapSystem;
|
|
266
|
+
}
|
|
267
|
+
return {
|
|
268
|
+
[odata_service_inquirer_1.promptNames.datasourceType]: {
|
|
269
|
+
default: defaultDatasourceSelection,
|
|
270
|
+
includeNone: !!options.allowNoDatasource
|
|
271
|
+
},
|
|
272
|
+
[odata_service_inquirer_1.promptNames.metadataFilePath]: {
|
|
273
|
+
requiredOdataVersion: options.requiredOdataVersion
|
|
274
|
+
},
|
|
275
|
+
[odata_service_inquirer_1.promptNames.capProject]: {
|
|
276
|
+
capSearchPaths: options.workspaceFolders ?? [],
|
|
277
|
+
defaultChoice: options.capService?.projectPath
|
|
278
|
+
},
|
|
279
|
+
[odata_service_inquirer_1.promptNames.capService]: {
|
|
280
|
+
defaultChoice: options.capService
|
|
281
|
+
},
|
|
282
|
+
[odata_service_inquirer_1.promptNames.serviceUrl]: {
|
|
283
|
+
requiredOdataVersion: options.requiredOdataVersion,
|
|
284
|
+
showCollaborativeDraftWarning: options.showCollabDraftWarning && isYUI
|
|
285
|
+
},
|
|
286
|
+
[odata_service_inquirer_1.promptNames.serviceSelection]: {
|
|
287
|
+
useAutoComplete: (0, fiori_generator_shared_1.getHostEnvironment)() === fiori_generator_shared_1.hostEnvironment.cli,
|
|
288
|
+
requiredOdataVersion: options.requiredOdataVersion,
|
|
289
|
+
showCollaborativeDraftWarning: options.showCollabDraftWarning && isYUI
|
|
290
|
+
},
|
|
291
|
+
[odata_service_inquirer_1.promptNames.systemSelection]: {
|
|
292
|
+
destinationFilters: {
|
|
293
|
+
odata_abap: true,
|
|
294
|
+
full_service_url: true,
|
|
295
|
+
partial_service_url: true
|
|
296
|
+
},
|
|
297
|
+
useAutoComplete: !isYUI,
|
|
298
|
+
includeCloudFoundryAbapEnvChoice: true,
|
|
299
|
+
...options.promptOptions?.systemSelection
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
//# sourceMappingURL=prompting.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { AppWizard } from '@sap-devx/yeoman-ui-types';
|
|
2
|
+
import type { ILogWrapper } from '@sap-ux/fiori-generator-shared';
|
|
3
|
+
import type Generator from 'yeoman-generator';
|
|
4
|
+
import { type Service } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* Add the '@sap/fiori:fiori-deployment' generator as a subgenerator.
|
|
7
|
+
*
|
|
8
|
+
* @param root0
|
|
9
|
+
* @param root0.service
|
|
10
|
+
* @param root0.projectName
|
|
11
|
+
* @param root0.targetFolder
|
|
12
|
+
* @param root0.applicationType
|
|
13
|
+
* @param composeWith
|
|
14
|
+
* @param logger
|
|
15
|
+
* @param appWizard
|
|
16
|
+
*/
|
|
17
|
+
export declare function addDeployGen({ service, projectName, targetFolder, applicationType }: {
|
|
18
|
+
service: Partial<Service>;
|
|
19
|
+
projectName: string;
|
|
20
|
+
targetFolder: string;
|
|
21
|
+
applicationType: string;
|
|
22
|
+
}, composeWith: Generator['composeWith'], logger: ILogWrapper, appWizard?: AppWizard): void;
|
|
23
|
+
/**
|
|
24
|
+
* Add the '@sap/fiori:flp-config' generator as a subgenerator using `composeWith`.
|
|
25
|
+
* Skipping the prompting (`skipPrompt`) will still write the config, but not ask for any input.
|
|
26
|
+
*
|
|
27
|
+
* @param options
|
|
28
|
+
* @param options.projectName
|
|
29
|
+
* @param options.targetFolder
|
|
30
|
+
* @param options.title
|
|
31
|
+
* @param options.skipPrompt The FLP config prompt step will be skipped, but the config will still br written
|
|
32
|
+
* @param composeWith
|
|
33
|
+
* @param logger
|
|
34
|
+
* @param appWizard
|
|
35
|
+
* @param vscode
|
|
36
|
+
*/
|
|
37
|
+
export declare function addFlpGen({ projectName, targetFolder, title, skipPrompt }: {
|
|
38
|
+
projectName: string;
|
|
39
|
+
targetFolder: string;
|
|
40
|
+
title: string;
|
|
41
|
+
skipPrompt: boolean;
|
|
42
|
+
}, composeWith: Generator['composeWith'], logger: ILogWrapper, appWizard?: AppWizard, vscode?: any): void;
|
|
43
|
+
//# sourceMappingURL=subgenHelpers.d.ts.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addDeployGen = addDeployGen;
|
|
4
|
+
exports.addFlpGen = addFlpGen;
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const types_1 = require("../types");
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
/**
|
|
9
|
+
* Add the '@sap/fiori:fiori-deployment' generator as a subgenerator.
|
|
10
|
+
*
|
|
11
|
+
* @param root0
|
|
12
|
+
* @param root0.service
|
|
13
|
+
* @param root0.projectName
|
|
14
|
+
* @param root0.targetFolder
|
|
15
|
+
* @param root0.applicationType
|
|
16
|
+
* @param composeWith
|
|
17
|
+
* @param logger
|
|
18
|
+
* @param appWizard
|
|
19
|
+
*/
|
|
20
|
+
function addDeployGen({ service, projectName, targetFolder, applicationType }, composeWith, logger, appWizard) {
|
|
21
|
+
composeWith('@sap/fiori:deploy-config', {
|
|
22
|
+
launchDeployConfigAsSubGenerator: true,
|
|
23
|
+
appGenServiceHost: service.host,
|
|
24
|
+
appGenServicePath: service.servicePath,
|
|
25
|
+
appGenClient: service.client,
|
|
26
|
+
connectedSystem: service.connectedSystem,
|
|
27
|
+
apiHubConfig: service.apiHubConfig || undefined,
|
|
28
|
+
appGenDestination: service.destinationName ?? service.connectedSystem?.destination?.Name,
|
|
29
|
+
projectName: projectName,
|
|
30
|
+
projectPath: targetFolder,
|
|
31
|
+
appWizard: appWizard,
|
|
32
|
+
telemetryData: { appType: applicationType },
|
|
33
|
+
logWrapper: logger
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Add the '@sap/fiori:flp-config' generator as a subgenerator using `composeWith`.
|
|
38
|
+
* Skipping the prompting (`skipPrompt`) will still write the config, but not ask for any input.
|
|
39
|
+
*
|
|
40
|
+
* @param options
|
|
41
|
+
* @param options.projectName
|
|
42
|
+
* @param options.targetFolder
|
|
43
|
+
* @param options.title
|
|
44
|
+
* @param options.skipPrompt The FLP config prompt step will be skipped, but the config will still br written
|
|
45
|
+
* @param composeWith
|
|
46
|
+
* @param logger
|
|
47
|
+
* @param appWizard
|
|
48
|
+
* @param vscode
|
|
49
|
+
*/
|
|
50
|
+
function addFlpGen({ projectName, targetFolder, title, skipPrompt }, composeWith, logger, appWizard, vscode) {
|
|
51
|
+
let flpConfigOptions = {
|
|
52
|
+
launchFlpConfigAsSubGenerator: true,
|
|
53
|
+
appWizard,
|
|
54
|
+
vscode,
|
|
55
|
+
appRootPath: (0, path_1.join)(targetFolder, projectName),
|
|
56
|
+
logWrapper: logger
|
|
57
|
+
};
|
|
58
|
+
if (skipPrompt) {
|
|
59
|
+
flpConfigOptions = {
|
|
60
|
+
...flpConfigOptions,
|
|
61
|
+
skipPrompt: true,
|
|
62
|
+
inboundConfig: {
|
|
63
|
+
semanticObject: (0, utils_1.getSemanticObject)(projectName),
|
|
64
|
+
action: types_1.defaultNavActionDisplay,
|
|
65
|
+
title
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
composeWith('@sap/fiori:flp-config', flpConfigOptions);
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=subgenHelpers.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Template as TemplateSettingsFE } from '@sap-ux/fiori-elements-writer';
|
|
2
|
+
import { TemplateType as TemplateTypeFE } from '@sap-ux/fiori-elements-writer';
|
|
3
|
+
import type { Template as TemplateSettingsFF } from '@sap-ux/fiori-freestyle-writer';
|
|
4
|
+
import { TemplateType as TemplateTypeFF } from '@sap-ux/fiori-freestyle-writer';
|
|
5
|
+
import type { BasicAppSettings } from '@sap-ux/fiori-freestyle-writer/dist/types';
|
|
6
|
+
import { type EntityRelatedAnswers } from '@sap-ux/odata-service-inquirer';
|
|
7
|
+
import type { Floorplan, State } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Get the writer template type from the Fiori App floorplan.
|
|
10
|
+
*
|
|
11
|
+
* @param floorplan
|
|
12
|
+
* @returns {TemplateTypeFE | TemplateTypeFF} - The template type
|
|
13
|
+
*/
|
|
14
|
+
export declare function getTemplateType(floorplan: Floorplan): TemplateTypeFE | TemplateTypeFF;
|
|
15
|
+
/**
|
|
16
|
+
* Transform the Fiori App floorplan to the type required by the open source ux-tools writer modules.
|
|
17
|
+
*
|
|
18
|
+
* @param floorplan
|
|
19
|
+
* @param entityRelatedConfig
|
|
20
|
+
* @param viewName
|
|
21
|
+
* @returns {Template} - The template configuration
|
|
22
|
+
*/
|
|
23
|
+
export declare function transformTemplateType(floorplan: Floorplan, entityRelatedConfig?: EntityRelatedAnswers, viewName?: string): TemplateSettingsFE<{}> | TemplateSettingsFF<BasicAppSettings>;
|
|
24
|
+
/**
|
|
25
|
+
* Transform Fiori Tools State to the type required by the open source ux-tools module.
|
|
26
|
+
* Process inputs to set correct defaults.
|
|
27
|
+
*
|
|
28
|
+
* @param param0
|
|
29
|
+
* @param param0.project
|
|
30
|
+
* @param param0.service
|
|
31
|
+
* @param param0.floorplan
|
|
32
|
+
* @param param0.entityRelatedConfig
|
|
33
|
+
* @param param0.viewName
|
|
34
|
+
* @param generateIndexHtml
|
|
35
|
+
* @returns {FioriElementsApp<T>} - The app configuration
|
|
36
|
+
*/
|
|
37
|
+
export declare function transformState<T>({ project, service, floorplan, entityRelatedConfig, viewName }: State, generateIndexHtml?: boolean): Promise<T>;
|
|
38
|
+
//# sourceMappingURL=transforms.d.ts.map
|