@sap-ux/generator-adp 0.10.12 → 1.0.0
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/add-annotations-to-odata/index.d.ts +3 -3
- package/generators/add-annotations-to-odata/index.js +15 -19
- package/generators/add-component-usages/index.d.ts +3 -3
- package/generators/add-component-usages/index.js +16 -20
- package/generators/add-new-model/index.d.ts +3 -3
- package/generators/add-new-model/index.js +24 -28
- package/generators/app/extension-project/index.d.ts +1 -1
- package/generators/app/extension-project/index.js +6 -9
- package/generators/app/index.d.ts +1 -1
- package/generators/app/index.js +129 -135
- package/generators/app/layer.js +5 -7
- package/generators/app/questions/attributes.d.ts +2 -2
- package/generators/app/questions/attributes.js +60 -65
- package/generators/app/questions/cf-services.js +48 -52
- package/generators/app/questions/configuration.d.ts +3 -3
- package/generators/app/questions/configuration.js +125 -129
- package/generators/app/questions/helper/additional-messages.js +29 -36
- package/generators/app/questions/helper/choices.js +16 -25
- package/generators/app/questions/helper/conditions.js +14 -23
- package/generators/app/questions/helper/default-values.js +8 -13
- package/generators/app/questions/helper/message.js +7 -11
- package/generators/app/questions/helper/tooltip.js +4 -7
- package/generators/app/questions/helper/validators.js +29 -39
- package/generators/app/questions/key-user.d.ts +1 -1
- package/generators/app/questions/key-user.js +40 -45
- package/generators/app/questions/target-env.d.ts +2 -2
- package/generators/app/questions/target-env.js +22 -27
- package/generators/app/types.js +13 -16
- package/generators/base/questions/credentials.d.ts +1 -1
- package/generators/base/questions/credentials.js +15 -18
- package/generators/base/sub-gen-auth-base.d.ts +3 -3
- package/generators/base/sub-gen-auth-base.js +24 -30
- package/generators/base/sub-gen-base.d.ts +5 -6
- package/generators/base/sub-gen-base.js +11 -17
- package/generators/change-data-source/index.d.ts +3 -3
- package/generators/change-data-source/index.js +8 -12
- package/generators/telemetry/collector.d.ts +1 -1
- package/generators/telemetry/collector.js +6 -10
- package/generators/telemetry/events.js +2 -5
- package/generators/telemetry/index.d.ts +2 -2
- package/generators/telemetry/index.js +2 -18
- package/generators/types.js +2 -5
- package/generators/utils/appWizardCache.d.ts +1 -1
- package/generators/utils/appWizardCache.js +7 -13
- package/generators/utils/deps.js +10 -45
- package/generators/utils/i18n.js +13 -23
- package/generators/utils/logger.js +4 -7
- package/generators/utils/opts.js +3 -6
- package/generators/utils/parse-json-input.d.ts +1 -1
- package/generators/utils/parse-json-input.js +5 -9
- package/generators/utils/steps.d.ts +1 -1
- package/generators/utils/steps.js +37 -48
- package/generators/utils/subgenHelpers.js +9 -14
- package/generators/utils/templates.js +7 -8
- package/generators/utils/type-guards.d.ts +1 -1
- package/generators/utils/type-guards.js +2 -6
- package/generators/utils/workspace.js +7 -13
- package/package.json +19 -17
package/generators/app/index.js
CHANGED
|
@@ -1,46 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const validators_1 = require("./questions/helper/validators");
|
|
33
|
-
const types_1 = require("./types");
|
|
34
|
-
const target_env_1 = require("./questions/target-env");
|
|
35
|
-
const key_user_1 = require("./questions/key-user");
|
|
36
|
-
const telemetry_2 = require("@sap-ux/telemetry");
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import Generator from 'yeoman-generator';
|
|
4
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
5
|
+
import { AppWizard, MessageType, Prompts as YeomanUiSteps } from '@sap-devx/yeoman-ui-types';
|
|
6
|
+
import { FlexLayer, SourceManifest, SupportedProject, SystemLookup, fetchPublicVersions, generate, generateCf, getCfBaseAppInbounds, getCfConfig, getConfig, getConfiguredProvider, getSupportedProject, getFormattedVersion, getLatestVersion, getYamlContent, isCfInstalled, isLoggedInCf, isMtaProject, loadApps, loadCfConfig, storeCredentials, getOrCreateServiceInstanceKeys } from '@sap-ux/adp-tooling';
|
|
7
|
+
import { getDefaultTargetFolder, isCli, isExtensionInstalled, sendTelemetry, setYeomanEnvConflicterForce, TelemetryHelper } from '@sap-ux/fiori-generator-shared';
|
|
8
|
+
import { ToolsLogger } from '@sap-ux/logger';
|
|
9
|
+
import { AdaptationProjectType } from '@sap-ux/axios-extension';
|
|
10
|
+
import { isInternalFeaturesSettingEnabled, isFeatureEnabled } from '@sap-ux/feature-toggle';
|
|
11
|
+
import { cacheClear, cacheGet, cachePut, initCache } from '../utils/appWizardCache.js';
|
|
12
|
+
import { getPackageInfo, installDependencies } from '../utils/deps.js';
|
|
13
|
+
import { initI18n, t } from '../utils/i18n.js';
|
|
14
|
+
import AdpGeneratorLogger from '../utils/logger.js';
|
|
15
|
+
import { setHeaderTitle } from '../utils/opts.js';
|
|
16
|
+
import { getFirstArgAsString, parseJsonInput } from '../utils/parse-json-input.js';
|
|
17
|
+
import { TelemetryCollector, EventName } from '../telemetry/index.js';
|
|
18
|
+
import { getDeployPage, getWizardPages, updateCfWizardSteps, updateFlpWizardSteps, updateWizardSteps, getKeyUserImportPage } from '../utils/steps.js';
|
|
19
|
+
import { addDeployGen, addExtProjectGen, addFlpGen } from '../utils/subgenHelpers.js';
|
|
20
|
+
import { getTemplatesOverwritePath } from '../utils/templates.js';
|
|
21
|
+
import { existsInWorkspace, handleWorkspaceFolderChoice, showWorkspaceFolderWarning } from '../utils/workspace.js';
|
|
22
|
+
import { getFlexLayer } from './layer.js';
|
|
23
|
+
import { getPrompts } from './questions/attributes.js';
|
|
24
|
+
import { CFServicesPrompter } from './questions/cf-services.js';
|
|
25
|
+
import { ConfigPrompter } from './questions/configuration.js';
|
|
26
|
+
import { getDefaultNamespace, getDefaultProjectName } from './questions/helper/default-values.js';
|
|
27
|
+
import { validateJsonInput } from './questions/helper/validators.js';
|
|
28
|
+
import { TargetEnv } from './types.js';
|
|
29
|
+
import { getProjectPathPrompt, getTargetEnvPrompt } from './questions/target-env.js';
|
|
30
|
+
import { KeyUserImportPrompter } from './questions/key-user.js';
|
|
31
|
+
import { initTelemetrySettings } from '@sap-ux/telemetry';
|
|
37
32
|
const generatorTitle = 'Adaptation Project';
|
|
38
33
|
/**
|
|
39
34
|
* Generator for creating an Adaptation Project.
|
|
40
35
|
*
|
|
41
36
|
* @extends Generator
|
|
42
37
|
*/
|
|
43
|
-
class
|
|
38
|
+
export default class extends Generator {
|
|
44
39
|
setPromptsCallback;
|
|
45
40
|
appWizard;
|
|
46
41
|
vscode;
|
|
@@ -163,24 +158,24 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
163
158
|
*/
|
|
164
159
|
constructor(args, opts) {
|
|
165
160
|
super(args, opts);
|
|
166
|
-
this.appWizard = opts.appWizard ??
|
|
161
|
+
this.appWizard = opts.appWizard ?? AppWizard.create(opts);
|
|
167
162
|
this.shouldInstallDeps = opts.shouldInstallDeps ?? true;
|
|
168
|
-
this.toolsLogger = new
|
|
163
|
+
this.toolsLogger = new ToolsLogger();
|
|
169
164
|
this.vscode = opts.vscode;
|
|
170
165
|
this._setupLogging();
|
|
171
166
|
this.options = opts;
|
|
172
|
-
this.isMtaYamlFound =
|
|
173
|
-
this.isCfFeatureEnabled =
|
|
167
|
+
this.isMtaYamlFound = isMtaProject(process.cwd());
|
|
168
|
+
this.isCfFeatureEnabled = isFeatureEnabled('sap.ux.appGenerator.testBetaFeatures.adpCfExperimental');
|
|
174
169
|
this.logger.debug(`isCfFeatureEnabled: ${this.isCfFeatureEnabled}`);
|
|
175
|
-
const jsonInputString =
|
|
176
|
-
this.jsonInput =
|
|
170
|
+
const jsonInputString = getFirstArgAsString(args);
|
|
171
|
+
this.jsonInput = parseJsonInput(jsonInputString, this.logger);
|
|
177
172
|
if (!this.jsonInput) {
|
|
178
173
|
this.env.lookup({
|
|
179
174
|
packagePatterns: ['@sap/generator-fiori', '@bas-dev/generator-extensibility-sub']
|
|
180
175
|
});
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
this.prompts = new
|
|
176
|
+
setHeaderTitle(opts, this.logger, generatorTitle);
|
|
177
|
+
initCache(this.logger, this.appWizard);
|
|
178
|
+
this.prompts = new YeomanUiSteps([]);
|
|
184
179
|
this.setPromptsCallback = (fn) => {
|
|
185
180
|
if (this.prompts) {
|
|
186
181
|
this.prompts.setCallback(fn);
|
|
@@ -190,18 +185,18 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
190
185
|
}
|
|
191
186
|
async initializing() {
|
|
192
187
|
// Force the generator to overwrite existing files without additional prompting
|
|
193
|
-
|
|
194
|
-
await
|
|
195
|
-
this.isCli =
|
|
196
|
-
this.layer =
|
|
197
|
-
this.isCustomerBase = this.layer ===
|
|
198
|
-
this.systemLookup = new
|
|
199
|
-
this.cfInstalled = await
|
|
200
|
-
this.cfConfig =
|
|
201
|
-
this.isCfLoggedIn = await
|
|
188
|
+
setYeomanEnvConflicterForce(this.env, this.options.force);
|
|
189
|
+
await initI18n();
|
|
190
|
+
this.isCli = isCli();
|
|
191
|
+
this.layer = getFlexLayer();
|
|
192
|
+
this.isCustomerBase = this.layer === FlexLayer.CUSTOMER_BASE;
|
|
193
|
+
this.systemLookup = new SystemLookup(this.logger);
|
|
194
|
+
this.cfInstalled = await isCfInstalled(this.logger);
|
|
195
|
+
this.cfConfig = loadCfConfig(this.logger);
|
|
196
|
+
this.isCfLoggedIn = await isLoggedInCf(this.cfConfig, this.logger);
|
|
202
197
|
this.logger.info(`isCfInstalled: ${this.cfInstalled}`);
|
|
203
|
-
const isInternalUsage =
|
|
204
|
-
await
|
|
198
|
+
const isInternalUsage = isInternalFeaturesSettingEnabled();
|
|
199
|
+
await initTelemetrySettings({
|
|
205
200
|
consumerModule: {
|
|
206
201
|
name: '@sap/generator-fiori:generator-adp',
|
|
207
202
|
version: this.rootGeneratorVersion()
|
|
@@ -209,12 +204,12 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
209
204
|
internalFeature: isInternalUsage,
|
|
210
205
|
watchTelemetrySettingStore: false
|
|
211
206
|
});
|
|
212
|
-
this.telemetryCollector = new
|
|
207
|
+
this.telemetryCollector = new TelemetryCollector();
|
|
213
208
|
if (!this.jsonInput) {
|
|
214
209
|
const shouldShowTargetEnv = this.cfInstalled && this.isCfFeatureEnabled;
|
|
215
|
-
this.prompts.splice(0, 0,
|
|
210
|
+
this.prompts.splice(0, 0, getWizardPages(shouldShowTargetEnv));
|
|
216
211
|
this.prompter = this._getOrCreatePrompter();
|
|
217
|
-
this.cfPrompter = new
|
|
212
|
+
this.cfPrompter = new CFServicesPrompter(isInternalUsage, this.isCfLoggedIn, this.logger);
|
|
218
213
|
}
|
|
219
214
|
}
|
|
220
215
|
async prompting() {
|
|
@@ -226,10 +221,10 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
226
221
|
await this._promptForCfEnvironment();
|
|
227
222
|
}
|
|
228
223
|
else {
|
|
229
|
-
const isExtensibilityExtInstalled =
|
|
224
|
+
const isExtensibilityExtInstalled = isExtensionInstalled(this.vscode, 'SAP.vscode-bas-extensibility');
|
|
230
225
|
const configQuestions = this.prompter.getPrompts({
|
|
231
226
|
projectType: {
|
|
232
|
-
default:
|
|
227
|
+
default: AdaptationProjectType.CLOUD_READY
|
|
233
228
|
},
|
|
234
229
|
projectTypeCli: { hide: !this.isCli },
|
|
235
230
|
projectTypeClassicLabel: { hide: this.isCli },
|
|
@@ -250,7 +245,7 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
250
245
|
layer: this.layer,
|
|
251
246
|
prompts: this.prompts
|
|
252
247
|
};
|
|
253
|
-
const defaultFolder =
|
|
248
|
+
const defaultFolder = getDefaultTargetFolder(this.options.vscode) ?? process.cwd();
|
|
254
249
|
const options = {
|
|
255
250
|
targetFolder: { default: defaultFolder, hide: this.shouldCreateExtProject },
|
|
256
251
|
ui5ValidationCli: { hide: !this.isCli },
|
|
@@ -262,12 +257,12 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
262
257
|
addDeployConfig: { hide: this.shouldCreateExtProject || !this.isCustomerBase },
|
|
263
258
|
importKeyUserChanges: { hide: this.shouldCreateExtProject }
|
|
264
259
|
};
|
|
265
|
-
const attributesQuestions =
|
|
260
|
+
const attributesQuestions = getPrompts(this.destinationPath(), optionalPromptsConfig, options);
|
|
266
261
|
this.attributeAnswers = await this.prompt(attributesQuestions);
|
|
267
262
|
// Steps need to be updated here to be available after back navigation in Yeoman UI.
|
|
268
263
|
this._updateWizardStepsAfterNavigation();
|
|
269
264
|
if (this.attributeAnswers.importKeyUserChanges) {
|
|
270
|
-
this.keyUserPrompter = new
|
|
265
|
+
this.keyUserPrompter = new KeyUserImportPrompter(this.systemLookup, this.configAnswers.application.id, this.prompter.provider, this.configAnswers.system, this.logger);
|
|
271
266
|
const keyUserQuestions = this.keyUserPrompter.getPrompts({
|
|
272
267
|
keyUserSystem: { default: this.configAnswers.system }
|
|
273
268
|
});
|
|
@@ -276,7 +271,7 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
276
271
|
this.logger.info(`Project Attributes: ${JSON.stringify(this.attributeAnswers, null, 2)}`);
|
|
277
272
|
if (this.attributeAnswers.addDeployConfig) {
|
|
278
273
|
const system = await this.systemLookup.getSystemByName(this.configAnswers.system);
|
|
279
|
-
await
|
|
274
|
+
await addDeployGen({
|
|
280
275
|
projectName: this.attributeAnswers.projectName,
|
|
281
276
|
projectPath: this.attributeAnswers.targetFolder,
|
|
282
277
|
connectedSystem: this.configAnswers.system,
|
|
@@ -285,7 +280,7 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
285
280
|
}, this.composeWith.bind(this), this.logger, this.appWizard);
|
|
286
281
|
}
|
|
287
282
|
if (this.attributeAnswers?.addFlpConfig) {
|
|
288
|
-
await
|
|
283
|
+
await addFlpGen({
|
|
289
284
|
vscode: this.vscode,
|
|
290
285
|
projectRootPath: this._getProjectPath(),
|
|
291
286
|
inbounds: this.prompter.baseAppInbounds,
|
|
@@ -297,7 +292,7 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
297
292
|
}
|
|
298
293
|
async writing() {
|
|
299
294
|
try {
|
|
300
|
-
this.toolsId = (
|
|
295
|
+
this.toolsId = uuidv4();
|
|
301
296
|
if (this.jsonInput) {
|
|
302
297
|
await this._initFromJson();
|
|
303
298
|
}
|
|
@@ -307,10 +302,10 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
307
302
|
return;
|
|
308
303
|
}
|
|
309
304
|
if (this.configAnswers.storeCredentials) {
|
|
310
|
-
await
|
|
305
|
+
await storeCredentials(this.configAnswers, this.systemLookup, this.logger);
|
|
311
306
|
}
|
|
312
307
|
if (this.shouldCreateExtProject) {
|
|
313
|
-
await
|
|
308
|
+
await addExtProjectGen({
|
|
314
309
|
configAnswers: this.configAnswers,
|
|
315
310
|
attributeAnswers: this.attributeAnswers,
|
|
316
311
|
systemLookup: this.systemLookup
|
|
@@ -322,8 +317,8 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
322
317
|
const manifest = this.jsonInput ? this.manifest : this.prompter.manifest;
|
|
323
318
|
const keyUserChanges = this.jsonInput ? this.jsonInput.keyUserChanges : this.keyUserPrompter?.changes;
|
|
324
319
|
const projectType = this._getProjectType();
|
|
325
|
-
const packageJson =
|
|
326
|
-
const config = await
|
|
320
|
+
const packageJson = getPackageInfo();
|
|
321
|
+
const config = await getConfig({
|
|
327
322
|
provider,
|
|
328
323
|
configAnswers: this.configAnswers,
|
|
329
324
|
attributeAnswers: this.attributeAnswers,
|
|
@@ -338,16 +333,16 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
338
333
|
keyUserChanges
|
|
339
334
|
});
|
|
340
335
|
if (config.options) {
|
|
341
|
-
config.options.templatePathOverwrite =
|
|
336
|
+
config.options.templatePathOverwrite = getTemplatesOverwritePath();
|
|
342
337
|
}
|
|
343
|
-
await
|
|
338
|
+
await generate(this._getProjectPath(), config, this.fs);
|
|
344
339
|
}
|
|
345
340
|
catch (e) {
|
|
346
341
|
this.logger.error(`Writing phase failed: ${e}`);
|
|
347
|
-
throw new Error(
|
|
342
|
+
throw new Error(t('error.updatingApp'));
|
|
348
343
|
}
|
|
349
344
|
finally {
|
|
350
|
-
|
|
345
|
+
cacheClear(this.appWizard, this.logger);
|
|
351
346
|
}
|
|
352
347
|
}
|
|
353
348
|
async install() {
|
|
@@ -355,7 +350,7 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
355
350
|
return;
|
|
356
351
|
}
|
|
357
352
|
try {
|
|
358
|
-
await
|
|
353
|
+
await installDependencies(this._getProjectPath());
|
|
359
354
|
}
|
|
360
355
|
catch (e) {
|
|
361
356
|
this.logger.error(`Installation of dependencies failed: ${e.message}`);
|
|
@@ -363,15 +358,15 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
363
358
|
}
|
|
364
359
|
async end() {
|
|
365
360
|
const projectPath = this._getProjectPath();
|
|
366
|
-
const data =
|
|
361
|
+
const data = TelemetryHelper.createTelemetryData({
|
|
367
362
|
appType: 'generator-adp',
|
|
368
363
|
...this.options.telemetryData,
|
|
369
364
|
...this.telemetryCollector.telemetryData
|
|
370
365
|
});
|
|
371
366
|
if (data) {
|
|
372
|
-
|
|
367
|
+
sendTelemetry(EventName.ADAPTATION_PROJECT_CREATED, data, projectPath)
|
|
373
368
|
.then(() => {
|
|
374
|
-
this.logger.log(`Event ${
|
|
369
|
+
this.logger.log(`Event ${EventName.ADAPTATION_PROJECT_CREATED} successfully sent`);
|
|
375
370
|
})
|
|
376
371
|
.catch((error) => {
|
|
377
372
|
this.logger.error(`Failed to send telemetry: ${error}`);
|
|
@@ -381,18 +376,18 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
381
376
|
return;
|
|
382
377
|
}
|
|
383
378
|
try {
|
|
384
|
-
if (!
|
|
385
|
-
const userChoice = await
|
|
379
|
+
if (!existsInWorkspace(this.vscode, projectPath)) {
|
|
380
|
+
const userChoice = await showWorkspaceFolderWarning(this.vscode, projectPath);
|
|
386
381
|
if (!userChoice) {
|
|
387
382
|
return;
|
|
388
383
|
}
|
|
389
|
-
await
|
|
384
|
+
await handleWorkspaceFolderChoice(this.vscode, projectPath, userChoice);
|
|
390
385
|
return;
|
|
391
386
|
}
|
|
392
387
|
await this.vscode?.commands?.executeCommand?.('sap.ux.application.info', { fsPath: projectPath });
|
|
393
388
|
}
|
|
394
389
|
catch (e) {
|
|
395
|
-
this.appWizard.showError(e.message,
|
|
390
|
+
this.appWizard.showError(e.message, MessageType.notification);
|
|
396
391
|
}
|
|
397
392
|
}
|
|
398
393
|
/**
|
|
@@ -401,12 +396,12 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
401
396
|
async _promptForCfProjectPath() {
|
|
402
397
|
if (this.isMtaYamlFound) {
|
|
403
398
|
const path = this.destinationRoot(process.cwd());
|
|
404
|
-
|
|
399
|
+
getYamlContent(join(path, 'mta.yaml'));
|
|
405
400
|
this.logger.log(`Project path information: ${path}`);
|
|
406
401
|
}
|
|
407
402
|
else {
|
|
408
|
-
const pathAnswers = await this.prompt([
|
|
409
|
-
const path = this.destinationRoot(
|
|
403
|
+
const pathAnswers = await this.prompt([getProjectPathPrompt(this.logger, this.vscode)]);
|
|
404
|
+
const path = this.destinationRoot(fs.realpathSync(pathAnswers.projectLocation, 'utf-8'));
|
|
410
405
|
this.logger.log(`Project path information: ${path}`);
|
|
411
406
|
}
|
|
412
407
|
}
|
|
@@ -426,15 +421,15 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
426
421
|
}
|
|
427
422
|
else {
|
|
428
423
|
telemetryData.projectType =
|
|
429
|
-
this._getProjectType() ===
|
|
424
|
+
this._getProjectType() === AdaptationProjectType.CLOUD_READY ? 'cloudReady' : 'onPremise';
|
|
430
425
|
telemetryData.baseAppTechnicalName = this.configAnswers?.application?.id ?? '';
|
|
431
426
|
}
|
|
432
427
|
if (this.jsonInput) {
|
|
433
|
-
telemetryData.ui5VersionSelected =
|
|
428
|
+
telemetryData.ui5VersionSelected = getLatestVersion(this.publicVersions);
|
|
434
429
|
}
|
|
435
430
|
else {
|
|
436
|
-
const version = this.attributeAnswers?.ui5Version ??
|
|
437
|
-
telemetryData.ui5VersionSelected =
|
|
431
|
+
const version = this.attributeAnswers?.ui5Version ?? getLatestVersion(this.prompter?.ui5?.publicVersions) ?? '';
|
|
432
|
+
telemetryData.ui5VersionSelected = getFormattedVersion(version);
|
|
438
433
|
}
|
|
439
434
|
telemetryData.systemUI5Version = this.prompter?.ui5?.systemVersion ?? '';
|
|
440
435
|
this.telemetryCollector.setBatch(telemetryData);
|
|
@@ -449,7 +444,7 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
449
444
|
await this._promptForTargetEnvironment();
|
|
450
445
|
}
|
|
451
446
|
else {
|
|
452
|
-
this.targetEnv =
|
|
447
|
+
this.targetEnv = TargetEnv.ABAP;
|
|
453
448
|
}
|
|
454
449
|
}
|
|
455
450
|
/**
|
|
@@ -457,12 +452,12 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
457
452
|
*/
|
|
458
453
|
async _promptForTargetEnvironment() {
|
|
459
454
|
const targetEnvAnswers = await this.prompt([
|
|
460
|
-
|
|
455
|
+
getTargetEnvPrompt(this.appWizard, this.cfInstalled, this.isCfLoggedIn, this.cfConfig)
|
|
461
456
|
]);
|
|
462
457
|
this.targetEnv = targetEnvAnswers.targetEnv;
|
|
463
|
-
this.isCfEnv = this.targetEnv ===
|
|
458
|
+
this.isCfEnv = this.targetEnv === TargetEnv.CF;
|
|
464
459
|
this.logger.info(`Target environment: ${this.targetEnv}`);
|
|
465
|
-
|
|
460
|
+
updateCfWizardSteps(this.isCfEnv, this.prompts);
|
|
466
461
|
this.logger.log(`Project organization information: ${JSON.stringify(this.cfConfig.org, null, 2)}`);
|
|
467
462
|
this.logger.log(`Project space information: ${JSON.stringify(this.cfConfig.space, null, 2)}`);
|
|
468
463
|
this.logger.log(`Project apiUrl information: ${JSON.stringify(this.cfConfig.url, null, 2)}`);
|
|
@@ -484,7 +479,7 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
484
479
|
importKeyUserChanges: { hide: true }
|
|
485
480
|
};
|
|
486
481
|
const projectPath = this.destinationPath();
|
|
487
|
-
const attributesQuestions =
|
|
482
|
+
const attributesQuestions = getPrompts(projectPath, {
|
|
488
483
|
ui5Versions: [],
|
|
489
484
|
isVersionDetected: false,
|
|
490
485
|
layer: this.layer,
|
|
@@ -501,11 +496,11 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
501
496
|
return;
|
|
502
497
|
}
|
|
503
498
|
try {
|
|
504
|
-
const cfInbounds = await
|
|
499
|
+
const cfInbounds = await getCfBaseAppInbounds(selectedApp.appId, selectedApp.appHostId, this.cfConfig, this.logger);
|
|
505
500
|
// Register FLP wizard pages now that we know if inbounds are available
|
|
506
|
-
|
|
501
|
+
updateFlpWizardSteps(!!cfInbounds, this.prompts, this.attributeAnswers.projectName, true);
|
|
507
502
|
if (cfInbounds) {
|
|
508
|
-
await
|
|
503
|
+
await addFlpGen({
|
|
509
504
|
vscode: this.vscode,
|
|
510
505
|
projectRootPath: this._getProjectPath(),
|
|
511
506
|
inbounds: cfInbounds,
|
|
@@ -525,12 +520,12 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
525
520
|
* @returns {ConfigPrompter} Cached config prompter if going back a page.
|
|
526
521
|
*/
|
|
527
522
|
_getOrCreatePrompter() {
|
|
528
|
-
const cached =
|
|
523
|
+
const cached = cacheGet(this.appWizard, 'prompter', this.logger);
|
|
529
524
|
if (cached) {
|
|
530
525
|
return cached;
|
|
531
526
|
}
|
|
532
|
-
const prompter = new
|
|
533
|
-
|
|
527
|
+
const prompter = new ConfigPrompter(this.systemLookup, this.layer, this.logger, this.telemetryCollector);
|
|
528
|
+
cachePut(this.appWizard, { prompter }, this.logger);
|
|
534
529
|
return prompter;
|
|
535
530
|
}
|
|
536
531
|
/**
|
|
@@ -538,8 +533,8 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
538
533
|
*/
|
|
539
534
|
async _generateAdpProjectArtifactsCF() {
|
|
540
535
|
const projectPath = this.destinationPath();
|
|
541
|
-
const publicVersions = await
|
|
542
|
-
this.telemetryCollector.setBatch({ ui5VersionSelected:
|
|
536
|
+
const publicVersions = await fetchPublicVersions(this.logger);
|
|
537
|
+
this.telemetryCollector.setBatch({ ui5VersionSelected: getLatestVersion(publicVersions) });
|
|
543
538
|
const manifest = this.cfPrompter.manifest;
|
|
544
539
|
if (!manifest) {
|
|
545
540
|
throw new Error('Manifest not found for base app.');
|
|
@@ -548,10 +543,10 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
548
543
|
const serviceInstanceGuid = this.cfPrompter.serviceInstanceGuid;
|
|
549
544
|
const backendUrls = this.cfPrompter.backendUrls;
|
|
550
545
|
const oauthPaths = this.cfPrompter.oauthPaths;
|
|
551
|
-
const serviceInfo = await
|
|
546
|
+
const serviceInfo = await getOrCreateServiceInstanceKeys({
|
|
552
547
|
names: [this.cfServicesAnswers.businessService ?? '']
|
|
553
548
|
}, this.logger);
|
|
554
|
-
const config =
|
|
549
|
+
const config = getCfConfig({
|
|
555
550
|
attributeAnswers: this.attributeAnswers,
|
|
556
551
|
cfServicesAnswers: this.cfServicesAnswers,
|
|
557
552
|
cfConfig: this.cfConfig,
|
|
@@ -563,15 +558,15 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
563
558
|
oauthPaths,
|
|
564
559
|
projectPath,
|
|
565
560
|
publicVersions,
|
|
566
|
-
packageJson:
|
|
561
|
+
packageJson: getPackageInfo(),
|
|
567
562
|
toolsId: this.toolsId,
|
|
568
563
|
serviceInfo,
|
|
569
564
|
spaceGuid: this.cfConfig.space.GUID
|
|
570
565
|
});
|
|
571
566
|
if (config.options) {
|
|
572
|
-
config.options.templatePathOverwrite =
|
|
567
|
+
config.options.templatePathOverwrite = getTemplatesOverwritePath();
|
|
573
568
|
}
|
|
574
|
-
await
|
|
569
|
+
await generateCf(projectPath, config, this.logger, this.fs);
|
|
575
570
|
}
|
|
576
571
|
/**
|
|
577
572
|
* Combines the target folder and project name.
|
|
@@ -580,12 +575,12 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
580
575
|
*/
|
|
581
576
|
_getProjectPath() {
|
|
582
577
|
if (this.isCfEnv) {
|
|
583
|
-
return
|
|
578
|
+
return join(this.destinationPath(), this.attributeAnswers.projectName);
|
|
584
579
|
}
|
|
585
580
|
if (this.shouldCreateExtProject) {
|
|
586
|
-
return
|
|
581
|
+
return join(process.cwd(), this.attributeAnswers.projectName);
|
|
587
582
|
}
|
|
588
|
-
return
|
|
583
|
+
return join(this.attributeAnswers.targetFolder, this.attributeAnswers.projectName);
|
|
589
584
|
}
|
|
590
585
|
/**
|
|
591
586
|
* Use this method to get the correct Adaptation project type, no matter how we start
|
|
@@ -600,8 +595,8 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
600
595
|
* Configures logging for the generator.
|
|
601
596
|
*/
|
|
602
597
|
_setupLogging() {
|
|
603
|
-
|
|
604
|
-
this.logger =
|
|
598
|
+
AdpGeneratorLogger.configureLogging(this.options.logger, this.rootGeneratorName(), this.log, this.options.vscode, this.options.logLevel, this.options.logWrapper);
|
|
599
|
+
this.logger = AdpGeneratorLogger.logger;
|
|
605
600
|
}
|
|
606
601
|
/**
|
|
607
602
|
* Initialize the project generator from a json.
|
|
@@ -610,40 +605,40 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
610
605
|
if (!this.jsonInput) {
|
|
611
606
|
return;
|
|
612
607
|
}
|
|
613
|
-
const { system, client, username = '', password = '', projectType, application: baseApplicationName, applicationTitle, targetFolder = '/home/user/projects', projectName =
|
|
614
|
-
await
|
|
608
|
+
const { system, client, username = '', password = '', projectType, application: baseApplicationName, applicationTitle, targetFolder = '/home/user/projects', projectName = getDefaultProjectName(targetFolder, `${baseApplicationName}.variant`), namespace = getDefaultNamespace(projectName, this.isCustomerBase) } = this.jsonInput;
|
|
609
|
+
await validateJsonInput(this.systemLookup, this.isCustomerBase, {
|
|
615
610
|
projectName,
|
|
616
611
|
targetFolder,
|
|
617
612
|
namespace,
|
|
618
613
|
system
|
|
619
614
|
});
|
|
620
|
-
this.publicVersions = await
|
|
615
|
+
this.publicVersions = await fetchPublicVersions(this.logger);
|
|
621
616
|
const providerOptions = {
|
|
622
617
|
system,
|
|
623
618
|
client,
|
|
624
619
|
username,
|
|
625
620
|
password
|
|
626
621
|
};
|
|
627
|
-
this.abapProvider = await
|
|
628
|
-
const supportedProject = await
|
|
629
|
-
let selectedProjectType =
|
|
630
|
-
if (supportedProject ===
|
|
631
|
-
const isInternalUsage =
|
|
622
|
+
this.abapProvider = await getConfiguredProvider(providerOptions, this.logger);
|
|
623
|
+
const supportedProject = await getSupportedProject(this.abapProvider);
|
|
624
|
+
let selectedProjectType = AdaptationProjectType.ON_PREMISE;
|
|
625
|
+
if (supportedProject === SupportedProject.CLOUD_READY_AND_ON_PREM) {
|
|
626
|
+
const isInternalUsage = isInternalFeaturesSettingEnabled();
|
|
632
627
|
selectedProjectType = isInternalUsage
|
|
633
|
-
?
|
|
634
|
-
: (projectType ??
|
|
628
|
+
? AdaptationProjectType.ON_PREMISE
|
|
629
|
+
: (projectType ?? AdaptationProjectType.CLOUD_READY);
|
|
635
630
|
}
|
|
636
|
-
else if (supportedProject ===
|
|
637
|
-
selectedProjectType =
|
|
631
|
+
else if (supportedProject === SupportedProject.CLOUD_READY) {
|
|
632
|
+
selectedProjectType = AdaptationProjectType.CLOUD_READY;
|
|
638
633
|
}
|
|
639
634
|
this.projectType = selectedProjectType;
|
|
640
|
-
const applications = await
|
|
635
|
+
const applications = await loadApps(this.abapProvider, this.isCustomerBase, supportedProject);
|
|
641
636
|
this.telemetryCollector.setBatch({ numberOfApplications: applications.length });
|
|
642
637
|
const application = applications.find((application) => application.id === baseApplicationName);
|
|
643
638
|
if (!application) {
|
|
644
|
-
throw new Error(
|
|
639
|
+
throw new Error(t('error.applicationNotFound', { appName: baseApplicationName }));
|
|
645
640
|
}
|
|
646
|
-
const sourceManifest = new
|
|
641
|
+
const sourceManifest = new SourceManifest(this.abapProvider, application.id);
|
|
647
642
|
this.manifest = await sourceManifest.getManifest();
|
|
648
643
|
this.configAnswers = {
|
|
649
644
|
system,
|
|
@@ -667,16 +662,15 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
667
662
|
*/
|
|
668
663
|
_updateWizardStepsAfterNavigation() {
|
|
669
664
|
const pages = this.prompts['items'];
|
|
670
|
-
const flpPagesExist = pages.some((p) => p.name ===
|
|
671
|
-
const deployPageExists = pages.some((p) => p.name ===
|
|
665
|
+
const flpPagesExist = pages.some((p) => p.name === t('yuiNavSteps.flpConfigName'));
|
|
666
|
+
const deployPageExists = pages.some((p) => p.name === t('yuiNavSteps.deployConfigName'));
|
|
672
667
|
if (!deployPageExists) {
|
|
673
|
-
|
|
668
|
+
updateWizardSteps(this.prompts, getDeployPage(), t('yuiNavSteps.projectAttributesName'), this.attributeAnswers.addDeployConfig);
|
|
674
669
|
}
|
|
675
|
-
|
|
670
|
+
updateWizardSteps(this.prompts, getKeyUserImportPage(), t('yuiNavSteps.projectAttributesName'), !!this.attributeAnswers.importKeyUserChanges);
|
|
676
671
|
if (!flpPagesExist) {
|
|
677
|
-
|
|
672
|
+
updateFlpWizardSteps(!!this.prompter.baseAppInbounds, this.prompts, this.attributeAnswers.projectName, !!this.attributeAnswers.addFlpConfig);
|
|
678
673
|
}
|
|
679
674
|
}
|
|
680
675
|
}
|
|
681
|
-
exports.default = default_1;
|
|
682
676
|
//# sourceMappingURL=index.js.map
|
package/generators/app/layer.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getFlexLayer = getFlexLayer;
|
|
4
|
-
const feature_toggle_1 = require("@sap-ux/feature-toggle");
|
|
1
|
+
import { FlexLayer } from '@sap-ux/adp-tooling';
|
|
2
|
+
import { isInternalFeaturesSettingEnabled } from '@sap-ux/feature-toggle';
|
|
5
3
|
/**
|
|
6
4
|
* Determines and returns the appropriate FlexLayer based on internal usage.
|
|
7
5
|
*
|
|
8
6
|
* @returns {FlexLayer} True if internal usage; otherwise, false.
|
|
9
7
|
*/
|
|
10
|
-
function getFlexLayer() {
|
|
11
|
-
const internal =
|
|
12
|
-
return internal ?
|
|
8
|
+
export function getFlexLayer() {
|
|
9
|
+
const internal = isInternalFeaturesSettingEnabled();
|
|
10
|
+
return internal ? FlexLayer.VENDOR : FlexLayer.CUSTOMER_BASE;
|
|
13
11
|
}
|
|
14
12
|
//# sourceMappingURL=layer.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { AttributesQuestion, AttributePromptOptions, AddDeployConfigPromptOptions, AddFlpConfigPromptOptions, OptionalPromptsConfig } from '../types';
|
|
1
|
+
import type { Prompts as YeomanUiSteps } from '@sap-devx/yeoman-ui-types';
|
|
2
|
+
import type { AttributesQuestion, AttributePromptOptions, AddDeployConfigPromptOptions, AddFlpConfigPromptOptions, OptionalPromptsConfig } from '../types.js';
|
|
3
3
|
import { AdaptationProjectType } from '@sap-ux/axios-extension';
|
|
4
4
|
/**
|
|
5
5
|
* Returns all project attribute prompts, filtering based on promptOptions.
|