@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,286 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFlpId = exports.getSemanticObject = void 0;
|
|
4
|
+
exports.getODataVersion = getODataVersion;
|
|
5
|
+
exports.getAppId = getAppId;
|
|
6
|
+
exports.buildSapClientParam = buildSapClientParam;
|
|
7
|
+
exports.getRequiredOdataVersion = getRequiredOdataVersion;
|
|
8
|
+
exports.getMinSupportedUI5Version = getMinSupportedUI5Version;
|
|
9
|
+
exports.generateToolsId = generateToolsId;
|
|
10
|
+
exports.getCdsUi5PluginInfo = getCdsUi5PluginInfo;
|
|
11
|
+
exports.getCdsAnnotations = getCdsAnnotations;
|
|
12
|
+
exports.isBTPHosted = isBTPHosted;
|
|
13
|
+
exports.getReadMeDataSourceLabel = getReadMeDataSourceLabel;
|
|
14
|
+
exports.getLaunchText = getLaunchText;
|
|
15
|
+
exports.generateLaunchConfig = generateLaunchConfig;
|
|
16
|
+
exports.convertCapRuntimeToCapProjectType = convertCapRuntimeToCapProjectType;
|
|
17
|
+
exports.getAnnotations = getAnnotations;
|
|
18
|
+
const annotation_converter_1 = require("@sap-ux/annotation-converter");
|
|
19
|
+
const btp_utils_1 = require("@sap-ux/btp-utils");
|
|
20
|
+
const cap_config_writer_1 = require("@sap-ux/cap-config-writer");
|
|
21
|
+
const edmx_parser_1 = require("@sap-ux/edmx-parser");
|
|
22
|
+
const fiori_elements_writer_1 = require("@sap-ux/fiori-elements-writer");
|
|
23
|
+
const fiori_tools_settings_1 = require("@sap-ux/fiori-tools-settings");
|
|
24
|
+
const launch_config_1 = require("@sap-ux/launch-config");
|
|
25
|
+
const odata_service_inquirer_1 = require("@sap-ux/odata-service-inquirer");
|
|
26
|
+
const project_access_1 = require("@sap-ux/project-access");
|
|
27
|
+
const path_1 = require("path");
|
|
28
|
+
const uuid_1 = require("uuid");
|
|
29
|
+
const constants_1 = require("../types/constants");
|
|
30
|
+
const external_1 = require("../types/external");
|
|
31
|
+
const i18n_1 = require("./i18n");
|
|
32
|
+
/**
|
|
33
|
+
* Parse the specified edmx string for validitiy and return the ODataVersion of the specified edmx string.
|
|
34
|
+
*
|
|
35
|
+
* @param edmx
|
|
36
|
+
* @returns ODataVersion, odata version
|
|
37
|
+
* @throws Error, if invalid edmx
|
|
38
|
+
*/
|
|
39
|
+
function getODataVersion(edmx) {
|
|
40
|
+
try {
|
|
41
|
+
const convertedMetadata = (0, annotation_converter_1.convert)((0, edmx_parser_1.parse)(edmx));
|
|
42
|
+
return convertedMetadata.version.startsWith('4') ? odata_service_inquirer_1.OdataVersion.v4 : odata_service_inquirer_1.OdataVersion.v2;
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
throw Error((0, i18n_1.t)('error.appConfigUnparseableEdmx'));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get AppId from provided namespace and name.
|
|
50
|
+
*
|
|
51
|
+
* @param name
|
|
52
|
+
* @param namespace
|
|
53
|
+
* @returns AppId
|
|
54
|
+
*/
|
|
55
|
+
function getAppId(name, namespace) {
|
|
56
|
+
const fullyQualifiedProjectName = [namespace, name].filter((x) => !!x).join('.');
|
|
57
|
+
return fullyQualifiedProjectName.replace(/[_-]/g, '');
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Creates a value suitable for use as a semantic object for navigation intents.
|
|
61
|
+
* Removes specific characters that would break the navigation.
|
|
62
|
+
*
|
|
63
|
+
* @param appId
|
|
64
|
+
* @returns
|
|
65
|
+
*/
|
|
66
|
+
const getSemanticObject = (appId) => {
|
|
67
|
+
const semanticObject = appId.replace(/[-_.#]/g, '');
|
|
68
|
+
return semanticObject.length > 30 ? semanticObject.substring(0, 30) : semanticObject;
|
|
69
|
+
};
|
|
70
|
+
exports.getSemanticObject = getSemanticObject;
|
|
71
|
+
const getFlpId = (appId, action) => {
|
|
72
|
+
return `${(0, exports.getSemanticObject)(appId)}${action ? '-' + action : ''}`;
|
|
73
|
+
};
|
|
74
|
+
exports.getFlpId = getFlpId;
|
|
75
|
+
/**
|
|
76
|
+
* Builds the sap-client parameter for the URL.
|
|
77
|
+
* If sapClient is not provided, returns an empty string.
|
|
78
|
+
*
|
|
79
|
+
* @param sapClient
|
|
80
|
+
* @returns sap-client parameter
|
|
81
|
+
*/
|
|
82
|
+
function buildSapClientParam(sapClient) {
|
|
83
|
+
return sapClient ? `sap-client=${sapClient}` : '';
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* If a floorplan only supports single odata version, get that version.
|
|
87
|
+
* Otherwise returns undefined, indicating multiple versions are supported.
|
|
88
|
+
*
|
|
89
|
+
* @param floorplan a floorplan value
|
|
90
|
+
* @returns - array of supported odata versions or undefined if all are supported
|
|
91
|
+
*/
|
|
92
|
+
function getRequiredOdataVersion(floorplan) {
|
|
93
|
+
const supportedVers = external_1.FloorplanAttributes[floorplan].supportedODataVersion;
|
|
94
|
+
return supportedVers.length === 1 ? supportedVers[0] : undefined;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Gets the min supported version of UI5 for the floorplan and odata version specified.
|
|
98
|
+
*
|
|
99
|
+
* @param version - odata version
|
|
100
|
+
* @param floorplan - floorplan value
|
|
101
|
+
* @returns min supported version
|
|
102
|
+
*/
|
|
103
|
+
function getMinSupportedUI5Version(version, floorplan) {
|
|
104
|
+
let minUI5Version;
|
|
105
|
+
if (floorplan && floorplan !== external_1.FloorplanFF.FF_SIMPLE) {
|
|
106
|
+
const templateType = external_1.FloorplanAttributes[floorplan].templateType;
|
|
107
|
+
minUI5Version = fiori_elements_writer_1.TemplateTypeAttributes[templateType].minimumUi5Version[version];
|
|
108
|
+
}
|
|
109
|
+
return minUI5Version ?? (version === odata_service_inquirer_1.OdataVersion.v4 ? constants_1.minSupportedUi5VersionV4 : constants_1.minSupportedUi5Version);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Generates a v4 uuid. While not strictly necessary to wrap uuid it means we can enforce
|
|
113
|
+
* additional options or change implementation easily in future.
|
|
114
|
+
*
|
|
115
|
+
* @returns a uuid v4 string
|
|
116
|
+
*/
|
|
117
|
+
function generateToolsId() {
|
|
118
|
+
return (0, uuid_1.v4)();
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Retrieves information related to cds version and checks if the CAP UI5 plugin is enabled.
|
|
122
|
+
*
|
|
123
|
+
* @param capProjectPath The path to the CAP project.
|
|
124
|
+
* @param fs The file system editor.
|
|
125
|
+
* @param cdsVersionInfo If provided will be used instead of parsing the package.json file to determine the cds version.
|
|
126
|
+
* @returns A promise that resolves to an object containing cdsinformation,
|
|
127
|
+
* or `undefined` if the CAP UI5 plugin is not enabled.
|
|
128
|
+
*/
|
|
129
|
+
async function getCdsUi5PluginInfo(capProjectPath, fs, cdsVersionInfo) {
|
|
130
|
+
// If the project is a Java project, do not pass cdsVersionInfo.
|
|
131
|
+
// This ensures that hasMinCdsVersion is false for Java project, preventing getEnableNPMWorkspacesPrompt from being invoked for Java projects.
|
|
132
|
+
const cdsVersion = (await (0, project_access_1.isCapJavaProject)(capProjectPath)) ? undefined : cdsVersionInfo;
|
|
133
|
+
const capCdsInfo = await (0, cap_config_writer_1.checkCdsUi5PluginEnabled)(capProjectPath, fs, true, cdsVersion);
|
|
134
|
+
return capCdsInfo === false ? undefined : capCdsInfo;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Returns CDS annotations information.
|
|
138
|
+
*
|
|
139
|
+
* @param {CapService} capService - The CAP service object containing information about the service.
|
|
140
|
+
* @param {string} projectName - The name of the project, which is the module name.
|
|
141
|
+
* @returns {Promise<CdsAnnotationsInfo>} A promise that resolves to an object containing CDS annotations information.
|
|
142
|
+
*/
|
|
143
|
+
async function getCdsAnnotations(capService, projectName) {
|
|
144
|
+
const { appPath: capAppPath = 'app', projectPath, serviceCdsPath, serviceName } = capService;
|
|
145
|
+
if (serviceCdsPath) {
|
|
146
|
+
// Construct the annotation path and service cds URI
|
|
147
|
+
const annotationPath = (0, path_1.join)(capAppPath, projectName, 'annotation.cds').replace(/\\/g, '/');
|
|
148
|
+
const serviceCdsUri = await (0, project_access_1.toReferenceUri)(projectPath, annotationPath, serviceCdsPath);
|
|
149
|
+
// Create the contents of the annotation CDS file
|
|
150
|
+
const annotationCdsContents = `using ${serviceName} as service from '${serviceCdsUri}';`;
|
|
151
|
+
// Return an object with the necessary information for cds files
|
|
152
|
+
return {
|
|
153
|
+
cdsFileContents: annotationCdsContents,
|
|
154
|
+
projectPath: projectPath,
|
|
155
|
+
appPath: capAppPath,
|
|
156
|
+
projectName: projectName
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Determine if the specified connected system is hosted on BTP.
|
|
162
|
+
* If a backend system uses service keys, or a destination is an ABAP environment on BTP, then it is considered to be hosted on BTP.
|
|
163
|
+
*
|
|
164
|
+
* @param connectedSystem - The connected system object.
|
|
165
|
+
* @returns {boolean} `true` if the connected system is hosted on BTP, otherwise `false`.
|
|
166
|
+
*/
|
|
167
|
+
function isBTPHosted(connectedSystem) {
|
|
168
|
+
return (!!connectedSystem?.backendSystem?.serviceKeys ||
|
|
169
|
+
(connectedSystem?.destination ? (0, btp_utils_1.isAbapEnvironmentOnBtp)(connectedSystem.destination) : false));
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Retrieves the data source label.
|
|
173
|
+
*
|
|
174
|
+
* @param {DatasourceType} source - The data source type (`DatasourceType.sapSystem` or `DatasourceType.businessHub`).
|
|
175
|
+
* @param scp
|
|
176
|
+
* @param {ApiHubType} apiHubType - The API hub type for business hubs.
|
|
177
|
+
* @returns {string} The formatted data source label.
|
|
178
|
+
*/
|
|
179
|
+
function getReadMeDataSourceLabel(source, scp = false, apiHubType) {
|
|
180
|
+
let dataSourceLabel;
|
|
181
|
+
if (source === odata_service_inquirer_1.DatasourceType.sapSystem) {
|
|
182
|
+
const labelDatasourceType = (0, i18n_1.t)(`readme.label.datasourceType.${odata_service_inquirer_1.DatasourceType.sapSystem}`);
|
|
183
|
+
const labelSystemType = (0, i18n_1.t)(`readme.label.sapSystemType.${scp ? "abapOnBtp" /* SapSystemSourceType.SCP */ : "onPrem" /* SapSystemSourceType.ON_PREM */}`);
|
|
184
|
+
dataSourceLabel = `${labelDatasourceType} (${labelSystemType})`;
|
|
185
|
+
}
|
|
186
|
+
else if (source === odata_service_inquirer_1.DatasourceType.businessHub && apiHubType === "API_HUB_ENTERPRISE" /* ApiHubType.apiHubEnterprise */) {
|
|
187
|
+
dataSourceLabel = (0, i18n_1.t)('readme.label.datasourceType.apiBusinessHubEnterprise');
|
|
188
|
+
}
|
|
189
|
+
return dataSourceLabel ?? (0, i18n_1.t)(`readme.label.datasourceType.${source}`);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Generates the launch text for the application based on the CAP service information and project details.
|
|
193
|
+
*
|
|
194
|
+
* @param {CapServiceCdsInfo} capService - The CAP (Cloud Application Programming) service information.
|
|
195
|
+
* @param {string} name - The name of the project.
|
|
196
|
+
* @param {boolean} useNpmWorkspaceAppRef - For CAP projects, indicates whether (root CAP project) npm workspaces app ref should be used when launching.
|
|
197
|
+
* @param {string} namespace - The namespace of the project.
|
|
198
|
+
* @returns {string} The launch text for the application. If CAP service information is provided, it returns a custom launch text based on the CAP service type,
|
|
199
|
+
* project name, and optionally the application ID if NPM workspaces or CDS UI5 plugin is enabled.
|
|
200
|
+
* If CAP service information is not available, it returns a default launch text.
|
|
201
|
+
*/
|
|
202
|
+
async function getLaunchText(capService, name, useNpmWorkspaceAppRef, namespace) {
|
|
203
|
+
if (capService) {
|
|
204
|
+
const appId = capService?.cdsUi5PluginInfo?.isCdsUi5PluginEnabled || useNpmWorkspaceAppRef // May be a case where isCdsUi5PluginEnabled is false but we know it will be enabled by the time the app is launched
|
|
205
|
+
? getAppId(name, namespace)
|
|
206
|
+
: undefined;
|
|
207
|
+
return (0, cap_config_writer_1.getAppLaunchText)(capService.capType ?? 'Node.js', name, appId);
|
|
208
|
+
}
|
|
209
|
+
return (0, i18n_1.t)('readme.texts.runInstruction');
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Generates the launch configuration for a project based on the provided options.
|
|
213
|
+
*
|
|
214
|
+
* @param {GenerateLaunchConfigOptions} options - An object containing configuration options for the project.
|
|
215
|
+
* @param {OdataVersion} options.odataVersion - The version of the OData service (e.g. v2 or v4) used by the project.
|
|
216
|
+
* @param {DatasourceType} options.source - The type of data source the project uses (e.g. metadata file or OData source URL).
|
|
217
|
+
* @param {string} options.sapClientParam - The SAP client parameter.
|
|
218
|
+
* @param {string} options.targetFolder - The file path to the project where the launch configuration should be created.
|
|
219
|
+
* @param {string} options.projectName - The name of the project.
|
|
220
|
+
* @param {string} options.appId - The application ID for the project.
|
|
221
|
+
* @param {Editor} fs - The file system editor.
|
|
222
|
+
* @param {any} vscode - The Visual Studio Code object.
|
|
223
|
+
* @param {Logger} [log] - An optional logger instance.
|
|
224
|
+
* @param {boolean} [writeToAppOnly] - A flag indicating whether to write the configuration only to the app folder.
|
|
225
|
+
* @returns {void}
|
|
226
|
+
*/
|
|
227
|
+
async function generateLaunchConfig(options, fs, vscode, log, writeToAppOnly = false) {
|
|
228
|
+
try {
|
|
229
|
+
if (vscode) {
|
|
230
|
+
const addStartCmd = options.datasourceType !== odata_service_inquirer_1.DatasourceType.metadataFile;
|
|
231
|
+
const projectPath = (0, path_1.join)(options.targetFolder, options.projectName);
|
|
232
|
+
const debugOptions = {
|
|
233
|
+
vscode: vscode,
|
|
234
|
+
addStartCmd,
|
|
235
|
+
sapClientParam: options.sapClientParam,
|
|
236
|
+
flpAppId: options.flpAppId ?? '',
|
|
237
|
+
flpSandboxAvailable: true,
|
|
238
|
+
isAppStudio: (0, btp_utils_1.isAppStudio)(),
|
|
239
|
+
writeToAppOnly
|
|
240
|
+
};
|
|
241
|
+
if (options.odataVersion) {
|
|
242
|
+
debugOptions.odataVersion = options.odataVersion === odata_service_inquirer_1.OdataVersion.v2 ? '2.0' : '4.0';
|
|
243
|
+
}
|
|
244
|
+
const fioriOptions = {
|
|
245
|
+
name: (0, path_1.basename)(options.projectName),
|
|
246
|
+
projectRoot: projectPath,
|
|
247
|
+
debugOptions
|
|
248
|
+
};
|
|
249
|
+
await (0, launch_config_1.createLaunchConfig)(projectPath, fioriOptions, fs, log);
|
|
250
|
+
(0, fiori_tools_settings_1.writeApplicationInfoSettings)(projectPath);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
catch (err) {
|
|
254
|
+
log?.error(`${(0, i18n_1.t)('error.errorWritingApplicationFiles')} : ${err}`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Convert between the CAPProjectType project type from the `@sap-ux/project-access' package and the CAP Runtime type from the `@sap-ux/odata-service-inquirer' package.
|
|
259
|
+
*
|
|
260
|
+
* @param {CapRuntime} capRuntime - The CAP runtime type. Default is 'Node.js'.
|
|
261
|
+
* @returns {CapProjectType} The CAP project type.
|
|
262
|
+
*/
|
|
263
|
+
function convertCapRuntimeToCapProjectType(capRuntime = 'Node.js') {
|
|
264
|
+
return capRuntime === 'Java' ? 'CAPJava' : 'CAPNodejs';
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Get the annotations for the project based on the provided CAP service or transforms the annotations to the correct type otherwise.
|
|
268
|
+
*
|
|
269
|
+
* @param {string} projectName - The name of the project for which annotations are being retrieved.
|
|
270
|
+
* @param {Annotations} annotations - The EDMX annotations object containing technical name and XML definitions.
|
|
271
|
+
* @param {CapService} capService - The CAP service instance used to retrieve CDS annotations.
|
|
272
|
+
* @returns {Promise<CdsAnnotationsInfo | EdmxAnnotationsInfo>} A promise that resolves to either CDS annotations info or EDMX annotations info.
|
|
273
|
+
*/
|
|
274
|
+
async function getAnnotations(projectName, annotations, capService) {
|
|
275
|
+
// Add annotations to fiori app
|
|
276
|
+
if (capService) {
|
|
277
|
+
return getCdsAnnotations(capService, projectName);
|
|
278
|
+
}
|
|
279
|
+
if (annotations) {
|
|
280
|
+
return {
|
|
281
|
+
technicalName: annotations.TechnicalName,
|
|
282
|
+
xml: annotations.Definitions
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ILogWrapper } from '@sap-ux/fiori-generator-shared';
|
|
2
|
+
export interface HookParameters {
|
|
3
|
+
fsPath: string;
|
|
4
|
+
}
|
|
5
|
+
export interface VSCodeInstance {
|
|
6
|
+
commands: {
|
|
7
|
+
executeCommand: (command: string, ...rest: any[]) => Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare const DEFAULT_POST_APP_GEN_COMMAND = "sap.ux.application.generated.handler";
|
|
11
|
+
export interface GeneratorContext {
|
|
12
|
+
hookParameters: HookParameters;
|
|
13
|
+
vscodeInstance?: VSCodeInstance;
|
|
14
|
+
options?: {
|
|
15
|
+
followUpCommand?: string;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export type Event = 'app-generated';
|
|
20
|
+
/**
|
|
21
|
+
* Run the post generation events. This can be used to run any follow up commands.
|
|
22
|
+
*
|
|
23
|
+
* @param event The event to run
|
|
24
|
+
* @param context Additional information required to run the commands
|
|
25
|
+
* @param logger The logger to use
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
export declare function runHooks(event: Event, context: GeneratorContext, logger?: ILogWrapper): Promise<void>;
|
|
29
|
+
//# sourceMappingURL=eventHooks.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_POST_APP_GEN_COMMAND = void 0;
|
|
4
|
+
exports.runHooks = runHooks;
|
|
5
|
+
const i18n_1 = require("./i18n");
|
|
6
|
+
exports.DEFAULT_POST_APP_GEN_COMMAND = 'sap.ux.application.generated.handler';
|
|
7
|
+
/**
|
|
8
|
+
* Run the post generation events. This can be used to run any follow up commands.
|
|
9
|
+
*
|
|
10
|
+
* @param event The event to run
|
|
11
|
+
* @param context Additional information required to run the commands
|
|
12
|
+
* @param logger The logger to use
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
async function runHooks(event, context, logger) {
|
|
16
|
+
if (event === 'app-generated') {
|
|
17
|
+
return postGenerationHook(context, logger);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
return Promise.reject(new Error((0, i18n_1.t)('error.unsupportedPostGenerationEvent', { event })));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Run the commands defined by the GeneratorContext.
|
|
25
|
+
*
|
|
26
|
+
* @param context - information required to run the commands
|
|
27
|
+
* @param logger - the logger to use
|
|
28
|
+
*/
|
|
29
|
+
async function postGenerationHook(context, logger) {
|
|
30
|
+
if (context.vscodeInstance) {
|
|
31
|
+
try {
|
|
32
|
+
const command = context.options?.followUpCommand ?? exports.DEFAULT_POST_APP_GEN_COMMAND;
|
|
33
|
+
logger?.info((0, i18n_1.t)('logMessages.attemptingToExecutePostGenerationCommand', { command }));
|
|
34
|
+
await context.vscodeInstance.commands?.executeCommand?.(command, context.hookParameters);
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
// Log if we can, can't handle exceptions here
|
|
38
|
+
try {
|
|
39
|
+
const warningMsg = e.toString().replace('Error: command', 'Command'); // remove 'Error' from this message
|
|
40
|
+
logger?.warn(warningMsg);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// }
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=eventHooks.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { TOptions } from 'i18next';
|
|
2
|
+
export declare const fioriAppSubGeneratorNs = "fiori-app-sub-generator";
|
|
3
|
+
export declare const defaultProjectNumber = 1;
|
|
4
|
+
/**
|
|
5
|
+
* Initialize i18next with the translations for this module.
|
|
6
|
+
*/
|
|
7
|
+
export declare function initI18nFioriAppSubGenerator(): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
|
|
10
|
+
*
|
|
11
|
+
* @param key i18n key
|
|
12
|
+
* @param options additional options
|
|
13
|
+
* @returns {string} localized string stored for the given key
|
|
14
|
+
*/
|
|
15
|
+
export declare function t(key: string, options?: TOptions): string;
|
|
16
|
+
//# sourceMappingURL=i18n.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
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.defaultProjectNumber = exports.fioriAppSubGeneratorNs = void 0;
|
|
7
|
+
exports.initI18nFioriAppSubGenerator = initI18nFioriAppSubGenerator;
|
|
8
|
+
exports.t = t;
|
|
9
|
+
const i18next_1 = __importDefault(require("i18next"));
|
|
10
|
+
const fioriAppSubGenerator_i18n_json_1 = __importDefault(require("../translations/fioriAppSubGenerator.i18n.json"));
|
|
11
|
+
exports.fioriAppSubGeneratorNs = 'fiori-app-sub-generator';
|
|
12
|
+
exports.defaultProjectNumber = 1;
|
|
13
|
+
/**
|
|
14
|
+
* Initialize i18next with the translations for this module.
|
|
15
|
+
*/
|
|
16
|
+
async function initI18nFioriAppSubGenerator() {
|
|
17
|
+
await i18next_1.default.init({
|
|
18
|
+
resources: {
|
|
19
|
+
en: {
|
|
20
|
+
[exports.fioriAppSubGeneratorNs]: fioriAppSubGenerator_i18n_json_1.default
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
lng: 'en',
|
|
24
|
+
fallbackLng: 'en',
|
|
25
|
+
defaultNS: exports.fioriAppSubGeneratorNs,
|
|
26
|
+
ns: [exports.fioriAppSubGeneratorNs],
|
|
27
|
+
interpolation: {
|
|
28
|
+
format: function odataVersionFormatter(odataVersion) {
|
|
29
|
+
return odataVersion ? ` V${odataVersion}` : '';
|
|
30
|
+
},
|
|
31
|
+
defaultVariables: {
|
|
32
|
+
defaultProjectNumber: exports.defaultProjectNumber
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
missingInterpolationHandler: () => '' // Called when interpolation values are undefined, prevents outputting of `{{undefinedProperty}}`
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
|
|
40
|
+
*
|
|
41
|
+
* @param key i18n key
|
|
42
|
+
* @param options additional options
|
|
43
|
+
* @returns {string} localized string stored for the given key
|
|
44
|
+
*/
|
|
45
|
+
function t(key, options) {
|
|
46
|
+
if (!options?.ns) {
|
|
47
|
+
options = Object.assign(options ?? {}, { ns: exports.fioriAppSubGeneratorNs });
|
|
48
|
+
}
|
|
49
|
+
return i18next_1.default.t(key, options);
|
|
50
|
+
}
|
|
51
|
+
initI18nFioriAppSubGenerator().catch(() => {
|
|
52
|
+
// Needed for lint
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=i18n.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './i18n';
|
|
2
|
+
export * from './telemetry';
|
|
3
|
+
export * from './common';
|
|
4
|
+
export * from './stepsHelper';
|
|
5
|
+
export * from './command-runner';
|
|
6
|
+
export * from './eventHooks';
|
|
7
|
+
export * from './sapuxLayer';
|
|
8
|
+
export * from './appWizardCache';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./i18n"), exports);
|
|
18
|
+
__exportStar(require("./telemetry"), exports);
|
|
19
|
+
__exportStar(require("./common"), exports);
|
|
20
|
+
__exportStar(require("./stepsHelper"), exports);
|
|
21
|
+
__exportStar(require("./command-runner"), exports);
|
|
22
|
+
__exportStar(require("./eventHooks"), exports);
|
|
23
|
+
__exportStar(require("./sapuxLayer"), exports);
|
|
24
|
+
__exportStar(require("./appWizardCache"), exports);
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { UI5FlexLayer } from '@sap-ux/project-access';
|
|
2
|
+
/**
|
|
3
|
+
* Determines the SAP UX layer based on isCap enabled or not.
|
|
4
|
+
*
|
|
5
|
+
* If the project is a CAP project, this function will return `undefined`.
|
|
6
|
+
* For non-CAP projects, it checks whether internal features are enabled and returns the corresponding
|
|
7
|
+
* SAP UX layer:
|
|
8
|
+
* - `UI5FlexLayer.VENDOR` if internal features are enabled,
|
|
9
|
+
* - `UI5FlexLayer.CUSTOMER_BASE` if they are not.
|
|
10
|
+
*
|
|
11
|
+
* @param {boolean} isCap - Indicates if the project is a CAP project.
|
|
12
|
+
* @returns {UI5FlexLayer | undefined} - The assigned SAP UX layer or `undefined` for CAP projects.
|
|
13
|
+
*/
|
|
14
|
+
export declare function assignSapUxLayerValue(isCap?: boolean): UI5FlexLayer | undefined;
|
|
15
|
+
//# sourceMappingURL=sapuxLayer.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assignSapUxLayerValue = assignSapUxLayerValue;
|
|
4
|
+
const feature_toggle_1 = require("@sap-ux/feature-toggle");
|
|
5
|
+
/**
|
|
6
|
+
* Determines the SAP UX layer based on isCap enabled or not.
|
|
7
|
+
*
|
|
8
|
+
* If the project is a CAP project, this function will return `undefined`.
|
|
9
|
+
* For non-CAP projects, it checks whether internal features are enabled and returns the corresponding
|
|
10
|
+
* SAP UX layer:
|
|
11
|
+
* - `UI5FlexLayer.VENDOR` if internal features are enabled,
|
|
12
|
+
* - `UI5FlexLayer.CUSTOMER_BASE` if they are not.
|
|
13
|
+
*
|
|
14
|
+
* @param {boolean} isCap - Indicates if the project is a CAP project.
|
|
15
|
+
* @returns {UI5FlexLayer | undefined} - The assigned SAP UX layer or `undefined` for CAP projects.
|
|
16
|
+
*/
|
|
17
|
+
function assignSapUxLayerValue(isCap = false) {
|
|
18
|
+
if (isCap) {
|
|
19
|
+
// Skip for CAP projects
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
return (0, feature_toggle_1.isInternalFeaturesSettingEnabled)() ? 'VENDOR' : 'CUSTOMER_BASE';
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=sapuxLayer.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { IPrompt as YeomanUiStep } from '@sap-devx/yeoman-ui-types';
|
|
2
|
+
import { Prompts as YeomanUiSteps } from '@sap-devx/yeoman-ui-types';
|
|
3
|
+
import type { FioriStep, YeomanUiStepConfig } from '../types/yeomanUiStepConfig';
|
|
4
|
+
/**
|
|
5
|
+
* Update the dependent step in the active steps of the Yeoman UI steps. Ultimately this will result in a new step being added to the Application Wizard.
|
|
6
|
+
*
|
|
7
|
+
* @param currentStepName The name (title) of the step that is being toggled. Not the step key.
|
|
8
|
+
* @param stepConfigList
|
|
9
|
+
* @param action Add dependent step if true, remove if false.
|
|
10
|
+
* @param dependentStepName
|
|
11
|
+
*/
|
|
12
|
+
export declare function updateDependentStep(currentStepName: string, stepConfigList: YeomanUiStepConfig[], action: boolean, dependentStepName?: string): void;
|
|
13
|
+
/**
|
|
14
|
+
* Check if a step is considered active in the Yeoman UI steps.
|
|
15
|
+
*
|
|
16
|
+
* @param stepName The name (title) of the step to check. Not the step key.
|
|
17
|
+
* @param yuiSteps
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
export declare function hasActiveStep(stepName: string, yuiSteps: YeomanUiSteps): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Check if a step is present in the steps array. Non-present steps are not added to the Application Wizard, essentially skipping them.
|
|
23
|
+
*
|
|
24
|
+
* @param steps
|
|
25
|
+
* @param stepKey
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
export declare function hasStep(steps: FioriStep[], stepKey: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Get the Yeoman UI step configuration.
|
|
31
|
+
*
|
|
32
|
+
* @param stepsArr
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
export declare function getYeomanUiStepConfig(stepsArr: YeomanUiStep[]): YeomanUiStepConfig;
|
|
36
|
+
/**
|
|
37
|
+
* Used in Inquirer prompt validators to dynamically add or remove dependent steps to the Application Wizard.
|
|
38
|
+
* For example, may be used when a user checks `addDeployConfig` to add that deployment config step to the wizard.
|
|
39
|
+
*
|
|
40
|
+
* @param addDependentStep
|
|
41
|
+
* @param currentStepName
|
|
42
|
+
* @param appGenStepConfigList
|
|
43
|
+
* @param dependentStepName
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
export declare function validateNextStep(addDependentStep: boolean, currentStepName: string, appGenStepConfigList?: YeomanUiStepConfig[], dependentStepName?: string): boolean;
|
|
47
|
+
//# sourceMappingURL=stepsHelper.d.ts.map
|