@sap-ux/fiori-app-sub-generator 0.15.21 → 1.0.1
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/generators/app/index.d.ts +1 -1
- package/generators/app/index.js +2 -4
- package/generators/app-headless/index.d.ts +2 -2
- package/generators/app-headless/index.js +17 -21
- package/generators/app-headless/resolve.js +11 -16
- package/generators/app-headless/transforms.d.ts +1 -1
- package/generators/app-headless/transforms.js +35 -38
- package/generators/fiori-app-generator/end.d.ts +1 -1
- package/generators/fiori-app-generator/end.js +23 -25
- package/generators/fiori-app-generator/fioriAppGenerator.d.ts +2 -2
- package/generators/fiori-app-generator/fioriAppGenerator.js +92 -99
- package/generators/fiori-app-generator/fioriAppGeneratorOptions.d.ts +1 -1
- package/generators/fiori-app-generator/fioriAppGeneratorOptions.js +1 -2
- package/generators/fiori-app-generator/index.d.ts +2 -2
- package/generators/fiori-app-generator/index.js +2 -18
- package/generators/fiori-app-generator/install.js +10 -13
- package/generators/fiori-app-generator/prompting.d.ts +1 -1
- package/generators/fiori-app-generator/prompting.js +60 -70
- package/generators/fiori-app-generator/subgenHelpers.d.ts +1 -1
- package/generators/fiori-app-generator/subgenHelpers.js +8 -12
- package/generators/fiori-app-generator/transforms.d.ts +2 -3
- package/generators/fiori-app-generator/transforms.js +63 -66
- package/generators/fiori-app-generator/writing.d.ts +1 -1
- package/generators/fiori-app-generator/writing.js +18 -22
- package/generators/index.d.ts +5 -5
- package/generators/index.js +5 -21
- package/generators/types/common.js +1 -2
- package/generators/types/constants.d.ts +1 -1
- package/generators/types/constants.js +59 -52
- package/generators/types/external.d.ts +5 -4
- package/generators/types/external.js +40 -45
- package/generators/types/index.d.ts +6 -6
- package/generators/types/index.js +6 -22
- package/generators/types/state.d.ts +2 -2
- package/generators/types/state.js +1 -2
- package/generators/types/telemetryEvents.js +1 -2
- package/generators/types/yeomanUiStepConfig.js +1 -2
- package/generators/utils/appWizardCache.d.ts +1 -1
- package/generators/utils/appWizardCache.js +9 -15
- package/generators/utils/command-runner.js +9 -13
- package/generators/utils/common.d.ts +3 -3
- package/generators/utils/common.js +64 -81
- package/generators/utils/eventHooks.js +6 -10
- package/generators/utils/i18n.js +15 -23
- package/generators/utils/index.d.ts +8 -8
- package/generators/utils/index.js +8 -24
- package/generators/utils/sapuxLayer.js +3 -6
- package/generators/utils/stepsHelper.d.ts +3 -4
- package/generators/utils/stepsHelper.js +10 -17
- package/generators/utils/telemetry.d.ts +1 -1
- package/generators/utils/telemetry.js +9 -12
- package/package.json +27 -25
|
@@ -1,41 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
const install_1 = require("./install");
|
|
22
|
-
const prompting_1 = require("./prompting");
|
|
23
|
-
const subgenHelpers_1 = require("./subgenHelpers");
|
|
24
|
-
const transforms_1 = require("./transforms");
|
|
25
|
-
const writing_1 = require("./writing");
|
|
26
|
-
exports.APP_GENERATOR_MODULE = '@sap/generator-fiori';
|
|
1
|
+
import { MessageType } from '@sap-devx/yeoman-ui-types';
|
|
2
|
+
import { isAppStudio } from '@sap-ux/btp-utils';
|
|
3
|
+
import { isInternalFeaturesSettingEnabled } from '@sap-ux/feature-toggle';
|
|
4
|
+
import { generate as generateFioriElementsApp } from '@sap-ux/fiori-elements-writer';
|
|
5
|
+
import { generate as generateFioriFreestyleApp } from '@sap-ux/fiori-freestyle-writer';
|
|
6
|
+
import { DefaultLogger, getHostEnvironment, hostEnvironment, sendTelemetry, TelemetryHelper, getFlpId } from '@sap-ux/fiori-generator-shared';
|
|
7
|
+
import { DatasourceType, getEntityRelatedPrompts } from '@sap-ux/odata-service-inquirer';
|
|
8
|
+
import { initTelemetrySettings } from '@sap-ux/telemetry';
|
|
9
|
+
import { getUI5Versions, latestVersionString } from '@sap-ux/ui5-info';
|
|
10
|
+
import { join } from 'node:path';
|
|
11
|
+
import Generator from 'yeoman-generator';
|
|
12
|
+
import { defaultNavActionDisplay, defaultNavActionTile, FIORI_STEPS, FloorplanFF, generatorName, STEP_DATASOURCE_AND_SERVICE, STEP_DEPLOY_CONFIG, STEP_FLP_CONFIG, STEP_PROJECT_ATTRIBUTES, FloorplanFE } from '../types/index.js';
|
|
13
|
+
import { addToCache, deleteCache, getAppId, getCdsUi5PluginInfo, getFromCache, getRequiredOdataVersion, getTelemetryBusinessHubType, getTelemetrySapSystemType, hasActiveStep, hasStep, initAppWizardCache, initI18nFioriAppSubGenerator, restoreServiceProviderLoggers, t, updateDependentStep } from '../utils/index.js';
|
|
14
|
+
import { runPostGenerationTasks } from './end.js';
|
|
15
|
+
import { installDependencies } from './install.js';
|
|
16
|
+
import { getViewQuestion, promptOdataServiceAnswers, promptUI5ApplicationAnswers } from './prompting.js';
|
|
17
|
+
import { addDeployGen, addFlpGen } from './subgenHelpers.js';
|
|
18
|
+
import { getTemplateType, transformState } from './transforms.js';
|
|
19
|
+
import { writeAppGenInfoFiles, writeAPIHubKeyFiles } from './writing.js';
|
|
20
|
+
export const APP_GENERATOR_MODULE = '@sap/generator-fiori';
|
|
27
21
|
/**
|
|
28
22
|
* The root generator for Fiori Elements and Fiori Freestyle generators.
|
|
29
23
|
* All common functionality is implemented here.
|
|
30
24
|
*/
|
|
31
|
-
class FioriAppGenerator extends
|
|
25
|
+
export class FioriAppGenerator extends Generator {
|
|
32
26
|
vscode;
|
|
33
27
|
// Performance measurement
|
|
34
28
|
generationTime0; // start of writing phase millisecond timestamp
|
|
35
29
|
appWizard;
|
|
36
30
|
state;
|
|
37
31
|
// The logger is static to allow convenient access from everywhere, cross-cutting concern
|
|
38
|
-
static _logger =
|
|
32
|
+
static _logger = DefaultLogger;
|
|
39
33
|
// Generator name for use in telemetry, readmes etc.
|
|
40
34
|
generatorVersion = this.rootGeneratorVersion();
|
|
41
35
|
// The configuration of steps in YUI and their interdependence
|
|
@@ -53,7 +47,7 @@ class FioriAppGenerator extends yeoman_generator_1.default {
|
|
|
53
47
|
unique: 'namespace'
|
|
54
48
|
});
|
|
55
49
|
this.vscode = opts['vscode'];
|
|
56
|
-
FioriAppGenerator._logger = this.options.logWrapper ??
|
|
50
|
+
FioriAppGenerator._logger = this.options.logWrapper ?? DefaultLogger;
|
|
57
51
|
// Init the generator state
|
|
58
52
|
this.state = opts.state ?? { project: {}, service: {} };
|
|
59
53
|
}
|
|
@@ -67,18 +61,18 @@ class FioriAppGenerator extends yeoman_generator_1.default {
|
|
|
67
61
|
}
|
|
68
62
|
async initializing() {
|
|
69
63
|
// Ensure i18n bundles are loaded, default loading is unreliable
|
|
70
|
-
await
|
|
64
|
+
await initI18nFioriAppSubGenerator();
|
|
71
65
|
// When running in YUI context back navigation is supported and state may be cached.
|
|
72
66
|
if (this.options.appWizard) {
|
|
73
67
|
this.appWizard = this.options.appWizard;
|
|
74
|
-
|
|
68
|
+
initAppWizardCache(FioriAppGenerator._logger, this.options.appWizard);
|
|
75
69
|
}
|
|
76
|
-
await
|
|
77
|
-
consumerModule: { name:
|
|
78
|
-
internalFeature:
|
|
70
|
+
await initTelemetrySettings({
|
|
71
|
+
consumerModule: { name: APP_GENERATOR_MODULE, version: this.rootGeneratorVersion() },
|
|
72
|
+
internalFeature: isInternalFeaturesSettingEnabled(),
|
|
79
73
|
watchTelemetrySettingStore: false
|
|
80
74
|
});
|
|
81
|
-
|
|
75
|
+
TelemetryHelper.createTelemetryData({
|
|
82
76
|
...this.options.telemetryData
|
|
83
77
|
});
|
|
84
78
|
/**
|
|
@@ -91,37 +85,37 @@ class FioriAppGenerator extends yeoman_generator_1.default {
|
|
|
91
85
|
};
|
|
92
86
|
// do not await as this is pre-loading the cache
|
|
93
87
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
94
|
-
|
|
88
|
+
getUI5Versions(filterOptions);
|
|
95
89
|
}
|
|
96
90
|
// Floorplans, externally configured either via adapters or headless config
|
|
97
91
|
if (this.options.floorplan) {
|
|
98
92
|
this.state.floorplan = this.options.floorplan;
|
|
99
93
|
}
|
|
100
94
|
// Configuration of steps in YUI and their interdependance
|
|
101
|
-
this.fioriSteps = this.options.fioriSteps ??
|
|
95
|
+
this.fioriSteps = this.options.fioriSteps ?? FIORI_STEPS;
|
|
102
96
|
this.yeomanUiStepConfig = this.options.yeomanUiStepConfig;
|
|
103
97
|
this.prompts = this.yeomanUiStepConfig?.activeSteps;
|
|
104
98
|
}
|
|
105
99
|
async prompting() {
|
|
106
100
|
try {
|
|
107
101
|
const generatorOptions = this.options;
|
|
108
|
-
const isFioriFreestyleTemplate = this.state.floorplan ===
|
|
109
|
-
if (
|
|
110
|
-
const cachedService =
|
|
111
|
-
|
|
102
|
+
const isFioriFreestyleTemplate = this.state.floorplan === FloorplanFF.FF_SIMPLE;
|
|
103
|
+
if (hasStep(this.fioriSteps, STEP_DATASOURCE_AND_SERVICE)) {
|
|
104
|
+
const cachedService = getFromCache(this.appWizard, 'service', FioriAppGenerator.logger);
|
|
105
|
+
restoreServiceProviderLoggers(FioriAppGenerator.logger, cachedService?.connectedSystem?.serviceProvider);
|
|
112
106
|
const options = {
|
|
113
107
|
capService: cachedService?.capService ?? this.state.service?.capService,
|
|
114
|
-
requiredOdataVersion:
|
|
108
|
+
requiredOdataVersion: getRequiredOdataVersion(this.state.floorplan),
|
|
115
109
|
allowNoDatasource: isFioriFreestyleTemplate,
|
|
116
110
|
promptOptions: generatorOptions.promptSettings?.['@sap/generator-fiori'],
|
|
117
111
|
showCollabDraftWarning: generatorOptions.showCollabDraftWarning,
|
|
118
112
|
workspaceFolders: generatorOptions.workspaceFolders
|
|
119
113
|
};
|
|
120
|
-
let serviceAnswers = await
|
|
114
|
+
let serviceAnswers = await promptOdataServiceAnswers(options, FioriAppGenerator.logger, this.env.adapter, cachedService?.connectedSystem);
|
|
121
115
|
/** Back button handling */
|
|
122
116
|
// Persist derived state to facilitate backwards navigation
|
|
123
|
-
if (
|
|
124
|
-
if (serviceAnswers.source ===
|
|
117
|
+
if (getHostEnvironment() !== hostEnvironment.cli) {
|
|
118
|
+
if (serviceAnswers.source === DatasourceType.none || serviceAnswers.edmx) {
|
|
125
119
|
// When navigating back YUI re-applies the answers from the previous steps up to the current step, however on Windows it removes some required properties
|
|
126
120
|
// of the service answers property: `ConnectedSystem`, so we need to re-apply them from our own cache.
|
|
127
121
|
if (cachedService?.connectedSystem &&
|
|
@@ -129,52 +123,52 @@ class FioriAppGenerator extends yeoman_generator_1.default {
|
|
|
129
123
|
JSON.stringify(cachedService?.connectedSystem?.backendSystem)) {
|
|
130
124
|
serviceAnswers.connectedSystem = cachedService?.connectedSystem;
|
|
131
125
|
}
|
|
132
|
-
|
|
126
|
+
addToCache(this.appWizard, { service: serviceAnswers }, FioriAppGenerator.logger);
|
|
133
127
|
}
|
|
134
128
|
else {
|
|
135
129
|
serviceAnswers =
|
|
136
|
-
|
|
130
|
+
getFromCache(this.appWizard, 'service', FioriAppGenerator.logger) ?? serviceAnswers;
|
|
137
131
|
}
|
|
138
|
-
if (!(serviceAnswers.source ===
|
|
139
|
-
FioriAppGenerator.logger?.error(
|
|
132
|
+
if (!(serviceAnswers.source === DatasourceType.none || serviceAnswers.edmx)) {
|
|
133
|
+
FioriAppGenerator.logger?.error(t('error.fatalError'));
|
|
140
134
|
}
|
|
141
135
|
}
|
|
142
|
-
|
|
136
|
+
restoreServiceProviderLoggers(FioriAppGenerator.logger, serviceAnswers?.connectedSystem?.serviceProvider);
|
|
143
137
|
/** END: Back button temp fix */
|
|
144
138
|
this.state.service = { ...this.state?.service, ...serviceAnswers };
|
|
145
139
|
}
|
|
146
140
|
// Freestyle templates require a view name
|
|
147
141
|
if (isFioriFreestyleTemplate) {
|
|
148
|
-
const viewNameAnswer = await this.prompt([
|
|
142
|
+
const viewNameAnswer = await this.prompt([getViewQuestion()]);
|
|
149
143
|
this.state.viewName = viewNameAnswer.viewName;
|
|
150
144
|
}
|
|
151
145
|
else if (this.state.service.edmx) {
|
|
152
146
|
// Fiori Elements templates require entity and related settings
|
|
153
|
-
const templateType =
|
|
147
|
+
const templateType = getTemplateType(this.state.floorplan);
|
|
154
148
|
const promptOptions = {
|
|
155
149
|
defaultMainEntityName: generatorOptions.preselectedEntityName,
|
|
156
|
-
useAutoComplete:
|
|
150
|
+
useAutoComplete: getHostEnvironment() === hostEnvironment.cli,
|
|
157
151
|
hideTableLayoutPrompts: generatorOptions.showLayoutPrompts === false, // Defaults to show layout prompts
|
|
158
|
-
...(templateType ===
|
|
152
|
+
...(templateType === FloorplanFE.FE_FPM && { displayPageBuildingBlockPrompt: true }) // If templateType is FPM, add displayPageBuildingBlockPrompt to promptOptions
|
|
159
153
|
};
|
|
160
|
-
const entityQuestions =
|
|
154
|
+
const entityQuestions = getEntityRelatedPrompts(this.state.service.edmx, templateType, !!this.state.service.capService, promptOptions, this.state.service.annotations?.[0], FioriAppGenerator.logger, getHostEnvironment() !== hostEnvironment.cli);
|
|
161
155
|
const entityRelatedAnswers = await this.prompt(entityQuestions);
|
|
162
156
|
// Some state may have been assigned by adaptors, and then certain prompts hidden, so we must merge the answers
|
|
163
157
|
this.state.entityRelatedConfig = Object.assign(this.state.entityRelatedConfig ?? {}, entityRelatedAnswers);
|
|
164
158
|
}
|
|
165
159
|
else {
|
|
166
160
|
// Not Freestyle and no entity related config is an error and we cannot proceed
|
|
167
|
-
FioriAppGenerator.logger.error(
|
|
168
|
-
this._exitOnError(
|
|
161
|
+
FioriAppGenerator.logger.error(t('error.edmxNotFound'));
|
|
162
|
+
this._exitOnError(t('error.edmxNotFound'));
|
|
169
163
|
}
|
|
170
164
|
// Pre-load the CAP project and get all relevant info in one call,
|
|
171
165
|
// this prevents re-reading from disc and parsing multiple times later
|
|
172
166
|
if (this.state.service.capService && !this.state.service.capService.cdsUi5PluginInfo) {
|
|
173
|
-
this.state.service.capService.cdsUi5PluginInfo = await
|
|
167
|
+
this.state.service.capService.cdsUi5PluginInfo = await getCdsUi5PluginInfo(this.state.service.capService.projectPath, this.fs, this.state.service.capService.cdsVersionInfo);
|
|
174
168
|
}
|
|
175
169
|
// get project information
|
|
176
|
-
if (
|
|
177
|
-
const { ui5AppAnswers, localUI5Version } = await
|
|
170
|
+
if (hasStep(this.fioriSteps, STEP_PROJECT_ATTRIBUTES)) {
|
|
171
|
+
const { ui5AppAnswers, localUI5Version } = await promptUI5ApplicationAnswers({
|
|
178
172
|
projectName: this.state.project?.name,
|
|
179
173
|
targetFolder: this.state.project?.targetFolder,
|
|
180
174
|
service: this.state.service,
|
|
@@ -188,101 +182,101 @@ class FioriAppGenerator extends yeoman_generator_1.default {
|
|
|
188
182
|
localUI5Version
|
|
189
183
|
});
|
|
190
184
|
// Some extensions may reference this before the writing phase where normally the flpAppId is set
|
|
191
|
-
this.state.project.flpAppId =
|
|
185
|
+
this.state.project.flpAppId = getFlpId(getAppId(this.state.project.name, ui5AppAnswers.namespace ?? ''), this.state.floorplan === FloorplanFF.FF_SIMPLE ? defaultNavActionDisplay : defaultNavActionTile);
|
|
192
186
|
}
|
|
193
187
|
if (this.state.project?.addDeployConfig) {
|
|
194
188
|
// Allows back nav where we have iinterdependent steps
|
|
195
189
|
// Re-add dependant steps on back nav
|
|
196
|
-
if (
|
|
197
|
-
!
|
|
198
|
-
|
|
190
|
+
if (hasStep(this.fioriSteps, STEP_DEPLOY_CONFIG) &&
|
|
191
|
+
!hasActiveStep(t('steps.deployConfig.title'), this.yeomanUiStepConfig.activeSteps)) {
|
|
192
|
+
updateDependentStep(t('steps.projectAttributesConfig.title'), [this.yeomanUiStepConfig], true, t('steps.deployConfig.title'));
|
|
199
193
|
}
|
|
200
|
-
await
|
|
194
|
+
await addDeployGen({
|
|
201
195
|
service: this.state.service,
|
|
202
196
|
projectName: this.state.project.name,
|
|
203
197
|
targetFolder: this.state.project.targetFolder,
|
|
204
|
-
applicationType: this.state.floorplan ===
|
|
198
|
+
applicationType: this.state.floorplan === FloorplanFF.FF_SIMPLE ? 'FF' : 'FE' // Telemetry data
|
|
205
199
|
}, this.composeWith.bind(this), FioriAppGenerator.logger, this.appWizard, generatorOptions.promptSettings?.['@sap-ux/deploy-config-sub-generator']);
|
|
206
200
|
}
|
|
207
201
|
if (this.state.project?.addFlpConfig) {
|
|
208
202
|
// Allows back nav where we have interdependent steps
|
|
209
203
|
// Re-add dependant steps on back nav
|
|
210
|
-
if (
|
|
211
|
-
!
|
|
212
|
-
|
|
204
|
+
if (hasStep(this.fioriSteps, STEP_FLP_CONFIG) &&
|
|
205
|
+
!hasActiveStep(t('steps.flpConfig.title'), this.yeomanUiStepConfig.activeSteps)) {
|
|
206
|
+
updateDependentStep(t('steps.projectAttributesConfig.title'), [this.yeomanUiStepConfig], true, t('steps.flpConfig.title'));
|
|
213
207
|
}
|
|
214
|
-
await
|
|
208
|
+
await addFlpGen({
|
|
215
209
|
projectName: this.state.project.name,
|
|
216
210
|
targetFolder: this.state.project.targetFolder,
|
|
217
211
|
title: this.state.project.title,
|
|
218
|
-
skipPrompt: !
|
|
212
|
+
skipPrompt: !hasStep(this.fioriSteps, STEP_FLP_CONFIG)
|
|
219
213
|
}, this.composeWith.bind(this), FioriAppGenerator.logger, generatorOptions.vscode, this.appWizard, generatorOptions.promptSettings?.['@sap-ux/flp-config-sub-generator']);
|
|
220
214
|
}
|
|
221
215
|
}
|
|
222
216
|
catch (error) {
|
|
223
217
|
// Fatal prompting error
|
|
224
|
-
FioriAppGenerator.logger.error(`${
|
|
218
|
+
FioriAppGenerator.logger.error(`${t('error.fatalError')} : ${error}`);
|
|
225
219
|
this._exitOnError(error);
|
|
226
220
|
}
|
|
227
221
|
}
|
|
228
222
|
async writing() {
|
|
229
223
|
try {
|
|
230
224
|
this.generationTime0 = performance.now();
|
|
231
|
-
|
|
225
|
+
TelemetryHelper.markAppGenStartTime();
|
|
232
226
|
const { service, project, floorplan } = this.state;
|
|
233
|
-
FioriAppGenerator.logger.info(
|
|
227
|
+
FioriAppGenerator.logger.info(t('logMessages.copyingTemplateFiles', { templateName: this.state.floorplan }));
|
|
234
228
|
// Set the template folder
|
|
235
229
|
// this.sourceRoot(join(__dirname, '..', '..', 'templates')); // Path must match webpacked template paths
|
|
236
|
-
const destRoot = this.destinationRoot(
|
|
230
|
+
const destRoot = this.destinationRoot(join(project.targetFolder, project.name));
|
|
237
231
|
const t1 = performance.now();
|
|
238
232
|
let appConfig;
|
|
239
233
|
// Determine which type of app to generate based on the selected floorplan (template type)
|
|
240
|
-
if (this.state.floorplan ===
|
|
241
|
-
const ffApp = await
|
|
242
|
-
await (
|
|
234
|
+
if (this.state.floorplan === FloorplanFF.FF_SIMPLE) {
|
|
235
|
+
const ffApp = await transformState(this.state, !!service.capService || this.options.generateIndexHtml);
|
|
236
|
+
await generateFioriFreestyleApp(destRoot, ffApp, this.fs);
|
|
243
237
|
appConfig = ffApp;
|
|
244
238
|
}
|
|
245
239
|
else {
|
|
246
|
-
const feApp = await
|
|
247
|
-
await (
|
|
240
|
+
const feApp = await transformState(this.state, !!service.capService || this.options.generateIndexHtml);
|
|
241
|
+
await generateFioriElementsApp(destRoot, feApp, this.fs);
|
|
248
242
|
appConfig = feApp;
|
|
249
243
|
}
|
|
250
244
|
const t2 = performance.now();
|
|
251
245
|
FioriAppGenerator.logger.debug(`Writing Fiori application files from template took ${Math.round(t2 - t1)} milliseconds.`);
|
|
252
|
-
|
|
253
|
-
Template:
|
|
246
|
+
TelemetryHelper.createTelemetryData({
|
|
247
|
+
Template: t(`floorplans.label.${floorplan}`, {
|
|
254
248
|
odataVersion: service.version
|
|
255
249
|
}),
|
|
256
250
|
DataSource: service.source,
|
|
257
|
-
UI5Version: project.ui5Version ||
|
|
251
|
+
UI5Version: project.ui5Version || latestVersionString,
|
|
258
252
|
Theme: project.ui5Theme,
|
|
259
253
|
AppGenVersion: this.generatorVersion,
|
|
260
254
|
AppGenSourceType: service.source,
|
|
261
|
-
AppGenSapSystemType: service.source ===
|
|
262
|
-
?
|
|
255
|
+
AppGenSapSystemType: service.source === DatasourceType.sapSystem && service.connectedSystem
|
|
256
|
+
? getTelemetrySapSystemType(service.connectedSystem)
|
|
263
257
|
: 'n/a',
|
|
264
|
-
AppGenBusinessHubType:
|
|
258
|
+
AppGenBusinessHubType: getTelemetryBusinessHubType(service.apiHubConfig?.apiHubType),
|
|
265
259
|
EnableEslint: project.enableEslint,
|
|
266
260
|
EnableTypeScript: project.enableTypeScript,
|
|
267
261
|
EnableVirtualEndpoints: project.enableVirtualEndpoints,
|
|
268
262
|
ToolsId: appConfig.app.sourceTemplate?.toolsId,
|
|
269
263
|
ValueHelpCount: service.valueListMetadata?.length ?? 0
|
|
270
264
|
});
|
|
271
|
-
if (service.apiHubConfig &&
|
|
272
|
-
|
|
265
|
+
if (service.apiHubConfig && isAppStudio()) {
|
|
266
|
+
writeAPIHubKeyFiles(this.fs, destRoot, service.apiHubConfig);
|
|
273
267
|
}
|
|
274
268
|
// Write after app, using values from the transformed state so defaults have been applied
|
|
275
269
|
const readMeUpdated = { ui5Version: appConfig.ui5?.minUI5Version };
|
|
276
|
-
await
|
|
270
|
+
await writeAppGenInfoFiles(this.state, generatorName, this.generatorVersion, destRoot, this.fs, readMeUpdated);
|
|
277
271
|
}
|
|
278
272
|
catch (error) {
|
|
279
|
-
FioriAppGenerator.logger.fatal(`${
|
|
273
|
+
FioriAppGenerator.logger.fatal(`${t('error.errorWritingApplicationFiles')} : ${error}`);
|
|
280
274
|
this._exitOnError(error);
|
|
281
275
|
}
|
|
282
276
|
}
|
|
283
277
|
async install() {
|
|
284
278
|
if (!this.options.skipInstall) {
|
|
285
|
-
await
|
|
279
|
+
await installDependencies({
|
|
286
280
|
appPackagePath: this.destinationPath(),
|
|
287
281
|
capService: this.state.service.capService,
|
|
288
282
|
// Assumption that npm workspaces will be enabled if cds ui5 plugin is a depenedency
|
|
@@ -294,12 +288,12 @@ class FioriAppGenerator extends yeoman_generator_1.default {
|
|
|
294
288
|
}, FioriAppGenerator.logger);
|
|
295
289
|
}
|
|
296
290
|
else {
|
|
297
|
-
FioriAppGenerator.logger.info(
|
|
291
|
+
FioriAppGenerator.logger.info(t('logMessages.installSkippedOptionSpecified'));
|
|
298
292
|
}
|
|
299
293
|
}
|
|
300
294
|
async end() {
|
|
301
|
-
|
|
302
|
-
await
|
|
295
|
+
deleteCache(this.appWizard, FioriAppGenerator.logger);
|
|
296
|
+
await runPostGenerationTasks({
|
|
303
297
|
service: {
|
|
304
298
|
backendSystem: this.state.service.connectedSystem?.backendSystem,
|
|
305
299
|
capService: this.state.service.capService,
|
|
@@ -323,12 +317,11 @@ class FioriAppGenerator extends yeoman_generator_1.default {
|
|
|
323
317
|
*/
|
|
324
318
|
_exitOnError(error) {
|
|
325
319
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
326
|
-
|
|
327
|
-
if (
|
|
328
|
-
this.appWizard?.showError(`${
|
|
320
|
+
sendTelemetry('GENERATION_WRITING_FAIL', TelemetryHelper.telemetryData);
|
|
321
|
+
if (getHostEnvironment() !== hostEnvironment.cli) {
|
|
322
|
+
this.appWizard?.showError(`${t('error.fatalError')} : ${error}`, MessageType.notification);
|
|
329
323
|
}
|
|
330
|
-
throw new Error(`${
|
|
324
|
+
throw new Error(`${t('error.fatalError')} : ${error}`);
|
|
331
325
|
}
|
|
332
326
|
}
|
|
333
|
-
exports.FioriAppGenerator = FioriAppGenerator;
|
|
334
327
|
//# sourceMappingURL=fioriAppGenerator.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AppWizard, Severity } from '@sap-devx/yeoman-ui-types';
|
|
2
2
|
import type Generator from 'yeoman-generator';
|
|
3
|
-
import type { FioriGeneratorSettings, FioriStep, Floorplan, FioriAppGeneratorPromptSettings, State, YeomanUiStepConfig } from '../types';
|
|
3
|
+
import type { FioriGeneratorSettings, FioriStep, Floorplan, FioriAppGeneratorPromptSettings, State, YeomanUiStepConfig } from '../types/index.js';
|
|
4
4
|
import type { UI5ApplicationPromptOptions } from '@sap-ux/ui5-application-inquirer';
|
|
5
5
|
/**
|
|
6
6
|
* Fiori generator specific options, for internal use only.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './fioriAppGenerator';
|
|
2
|
-
export * from './fioriAppGeneratorOptions';
|
|
1
|
+
export * from './fioriAppGenerator.js';
|
|
2
|
+
export * from './fioriAppGeneratorOptions.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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("./fioriAppGenerator"), exports);
|
|
18
|
-
__exportStar(require("./fioriAppGeneratorOptions"), exports);
|
|
1
|
+
export * from './fioriAppGenerator.js';
|
|
2
|
+
export * from './fioriAppGeneratorOptions.js';
|
|
19
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.installDependencies = installDependencies;
|
|
4
|
-
const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
1
|
+
import { TelemetryHelper, sendTelemetry } from '@sap-ux/fiori-generator-shared';
|
|
2
|
+
import { CommandRunner, t } from '../utils/index.js';
|
|
6
3
|
/**
|
|
7
4
|
* Install the dependencies for the specified project. In the case of CAP projects, the dependencies are installed to the root project
|
|
8
5
|
* if npm workspace option is used, otherwise they are installed to the app project only.
|
|
@@ -13,27 +10,27 @@ const utils_1 = require("../utils");
|
|
|
13
10
|
*/
|
|
14
11
|
async function installProjectDependencies(projectPath, log, capOptions) {
|
|
15
12
|
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
16
|
-
const runner = new
|
|
13
|
+
const runner = new CommandRunner(log);
|
|
17
14
|
const runArgs = [];
|
|
18
15
|
runArgs.unshift('install');
|
|
19
16
|
try {
|
|
20
|
-
log?.info(
|
|
17
|
+
log?.info(t('logMessages.installingDependencies', { path: projectPath }));
|
|
21
18
|
const t0 = performance.now();
|
|
22
19
|
await runner.run(npm, runArgs, { cwd: projectPath }, true);
|
|
23
|
-
|
|
20
|
+
TelemetryHelper.createTelemetryData({ installFailure: false });
|
|
24
21
|
if (capOptions?.useWorkspaces) {
|
|
25
22
|
// NPM workspaces are used, run full install at root of project
|
|
26
23
|
// This will trigger a second install, only one install should be needed for NPM workspaces
|
|
27
24
|
await runner.run(npm, ['install', '--no-audit', '--no-fund', '--silent', '--prefer-offline', '--no-progress'], { cwd: capOptions.rootPath }, true);
|
|
28
25
|
}
|
|
29
26
|
const t1 = performance.now();
|
|
30
|
-
log?.debug(
|
|
27
|
+
log?.debug(t('logMessages.dependenciesInstalled', { installTime: Math.round((t1 - t0) / 1000) }));
|
|
31
28
|
}
|
|
32
29
|
catch (error) {
|
|
33
|
-
log?.info(error ??
|
|
34
|
-
|
|
30
|
+
log?.info(error ?? t('logMessages.errorInstallingDependencies'));
|
|
31
|
+
TelemetryHelper.createTelemetryData({ installFailure: true });
|
|
35
32
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
36
|
-
|
|
33
|
+
sendTelemetry('GENERATION_INSTALL_FAIL', TelemetryHelper.telemetryData);
|
|
37
34
|
}
|
|
38
35
|
}
|
|
39
36
|
/**
|
|
@@ -49,7 +46,7 @@ async function installProjectDependencies(projectPath, log, capOptions) {
|
|
|
49
46
|
* @param logger The logger to use for output
|
|
50
47
|
* @returns Promise<void>
|
|
51
48
|
*/
|
|
52
|
-
async function installDependencies({ appPackagePath, capService, useNpmWorkspaces, ui5Version }, logger) {
|
|
49
|
+
export async function installDependencies({ appPackagePath, capService, useNpmWorkspaces, ui5Version }, logger) {
|
|
53
50
|
// Install additional libs to root CAP project
|
|
54
51
|
let capInstallOpts;
|
|
55
52
|
if (capService) {
|
|
@@ -3,7 +3,7 @@ import { type CapService, type ConnectedSystem, type OdataServicePromptOptions,
|
|
|
3
3
|
import type { UI5ApplicationAnswers, UI5ApplicationPromptOptions } from '@sap-ux/ui5-application-inquirer';
|
|
4
4
|
import type { Question } from 'inquirer';
|
|
5
5
|
import type { Adapter } from 'yeoman-environment';
|
|
6
|
-
import type { Floorplan, Project, Service, YeomanUiStepConfig } from '../types';
|
|
6
|
+
import type { Floorplan, Project, Service, YeomanUiStepConfig } from '../types/index.js';
|
|
7
7
|
declare const viewNamePromptName = "viewName";
|
|
8
8
|
export interface ViewNameAnswer {
|
|
9
9
|
[viewNamePromptName]: string;
|