@sap-ux/cf-deploy-config-sub-generator 0.3.7 → 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 +8 -8
- package/generators/app/index.js +65 -70
- package/generators/app/questions.js +31 -35
- package/generators/app/types.js +1 -2
- package/generators/app/utils.js +27 -32
- package/generators/app-router/constants.js +3 -6
- package/generators/app-router/index.d.ts +1 -1
- package/generators/app-router/index.js +29 -32
- package/generators/app-router/types.js +1 -2
- package/generators/telemetryEvents/index.js +2 -5
- package/generators/utils/constants.js +5 -8
- package/generators/utils/i18n.js +11 -21
- package/generators/utils/index.d.ts +2 -2
- package/generators/utils/index.js +2 -18
- package/package.json +14 -12
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { ApiHubType } from '@sap-ux/cf-deploy-config-writer';
|
|
2
1
|
import { DeploymentGenerator } from '@sap-ux/deploy-config-generator-shared';
|
|
3
|
-
import { DESTINATION_AUTHTYPE_NOTFOUND, API_BUSINESS_HUB_ENTERPRISE_PREFIX } from '../utils';
|
|
4
|
-
import { loadManifest } from './utils';
|
|
5
|
-
import { getCFQuestions } from './questions';
|
|
6
|
-
import type {
|
|
7
|
-
import { CfDeployConfigOptions } from './types';
|
|
8
|
-
import { type CfDeployConfigQuestions, type CfDeployConfigPromptOptions, CfDeployConfigAnswers } from '@sap-ux/cf-deploy-config-inquirer';
|
|
2
|
+
import { DESTINATION_AUTHTYPE_NOTFOUND, API_BUSINESS_HUB_ENTERPRISE_PREFIX } from '../utils/index.js';
|
|
3
|
+
import { loadManifest } from './utils.js';
|
|
4
|
+
import { getCFQuestions } from './questions.js';
|
|
5
|
+
import type { CfDeployConfigOptions } from './types.js';
|
|
9
6
|
/**
|
|
10
7
|
* Cloud Foundry deployment configuration generator.
|
|
11
8
|
*/
|
|
@@ -87,5 +84,8 @@ export default class extends DeploymentGenerator {
|
|
|
87
84
|
}
|
|
88
85
|
export { getCFQuestions, loadManifest };
|
|
89
86
|
export { API_BUSINESS_HUB_ENTERPRISE_PREFIX, DESTINATION_AUTHTYPE_NOTFOUND };
|
|
90
|
-
export {
|
|
87
|
+
export type { CfDeployConfigAnswers, CfDeployConfigQuestions, CfDeployConfigPromptOptions } from '@sap-ux/cf-deploy-config-inquirer';
|
|
88
|
+
export type { CfDeployConfigOptions } from './types.js';
|
|
89
|
+
export type { ApiHubConfig } from '@sap-ux/cf-deploy-config-writer';
|
|
90
|
+
export { ApiHubType } from '@sap-ux/cf-deploy-config-writer';
|
|
91
91
|
//# sourceMappingURL=index.d.ts.map
|
package/generators/app/index.js
CHANGED
|
@@ -1,29 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const utils_2 = require("./utils");
|
|
17
|
-
Object.defineProperty(exports, "loadManifest", { enumerable: true, get: function () { return utils_2.loadManifest; } });
|
|
18
|
-
const project_access_1 = require("@sap-ux/project-access");
|
|
19
|
-
const telemetryEvents_1 = require("../telemetryEvents");
|
|
20
|
-
const questions_1 = require("./questions");
|
|
21
|
-
Object.defineProperty(exports, "getCFQuestions", { enumerable: true, get: function () { return questions_1.getCFQuestions; } });
|
|
22
|
-
const cf_deploy_config_inquirer_1 = require("@sap-ux/cf-deploy-config-inquirer");
|
|
1
|
+
import { join, dirname } from 'node:path';
|
|
2
|
+
import { platform } from 'node:os';
|
|
3
|
+
import * as hasbin from 'hasbin';
|
|
4
|
+
import { AppWizard, MessageType } from '@sap-devx/yeoman-ui-types';
|
|
5
|
+
import { sendTelemetry, TelemetryHelper, isExtensionInstalled, YUI_EXTENSION_ID, YUI_MIN_VER_FILES_GENERATED_MSG, setYeomanEnvConflicterForce } from '@sap-ux/fiori-generator-shared';
|
|
6
|
+
import { isInternalFeaturesSettingEnabled } from '@sap-ux/feature-toggle';
|
|
7
|
+
import { isFullUrlDestination } from '@sap-ux/btp-utils';
|
|
8
|
+
import { generateAppConfig, generateCAPConfig, ApiHubType, useAbapDirectServiceBinding, DefaultMTADestination } from '@sap-ux/cf-deploy-config-writer';
|
|
9
|
+
import { DeploymentGenerator, showOverwriteQuestion, bail, handleErrorMessage, ErrorHandler, ERROR_TYPE, mtaExecutable, cdsExecutable, generateDestinationName, getDestination } from '@sap-ux/deploy-config-generator-shared';
|
|
10
|
+
import { t, initI18n, DESTINATION_AUTHTYPE_NOTFOUND, API_BUSINESS_HUB_ENTERPRISE_PREFIX } from '../utils/index.js';
|
|
11
|
+
import { loadManifest } from './utils.js';
|
|
12
|
+
import { getMtaPath, findCapProjectRoot, FileName } from '@sap-ux/project-access';
|
|
13
|
+
import { EventName } from '../telemetryEvents/index.js';
|
|
14
|
+
import { getCFQuestions, getCAPMTAQuestions } from './questions.js';
|
|
15
|
+
import { RouterModuleType } from '@sap-ux/cf-deploy-config-inquirer';
|
|
23
16
|
/**
|
|
24
17
|
* Cloud Foundry deployment configuration generator.
|
|
25
18
|
*/
|
|
26
|
-
class
|
|
19
|
+
export default class extends DeploymentGenerator {
|
|
27
20
|
appWizard;
|
|
28
21
|
vscode;
|
|
29
22
|
launchDeployConfigAsSubGenerator;
|
|
@@ -55,7 +48,7 @@ class default_1 extends deploy_config_generator_shared_1.DeploymentGenerator {
|
|
|
55
48
|
super(args, opts);
|
|
56
49
|
this.launchDeployConfigAsSubGenerator = opts.launchDeployConfigAsSubGenerator ?? false;
|
|
57
50
|
this.launchStandaloneFromYui = opts.launchStandaloneFromYui;
|
|
58
|
-
this.appWizard = opts.appWizard ??
|
|
51
|
+
this.appWizard = opts.appWizard ?? AppWizard.create(opts);
|
|
59
52
|
this.vscode = opts.vscode;
|
|
60
53
|
this.options = opts;
|
|
61
54
|
this.destinationName = opts.destinationName ?? '';
|
|
@@ -70,17 +63,17 @@ class default_1 extends deploy_config_generator_shared_1.DeploymentGenerator {
|
|
|
70
63
|
}
|
|
71
64
|
async initializing() {
|
|
72
65
|
await super.initializing();
|
|
73
|
-
await
|
|
74
|
-
|
|
66
|
+
await initI18n();
|
|
67
|
+
DeploymentGenerator.logger?.debug(t('cfGen.debug.initTelemetry'));
|
|
75
68
|
// hack to suppress yeoman's overwrite prompt when files already exist
|
|
76
69
|
// required when running the deploy config generator in standalone mode
|
|
77
|
-
|
|
78
|
-
await
|
|
70
|
+
setYeomanEnvConflicterForce(this.env, this.options.force);
|
|
71
|
+
await TelemetryHelper.initTelemetrySettings({
|
|
79
72
|
consumerModule: {
|
|
80
73
|
name: '@sap-ux/cf-deploy-config-sub-generator',
|
|
81
74
|
version: this.rootGeneratorVersion()
|
|
82
75
|
},
|
|
83
|
-
internalFeature:
|
|
76
|
+
internalFeature: isInternalFeaturesSettingEnabled(),
|
|
84
77
|
watchTelemetrySettingStore: false
|
|
85
78
|
});
|
|
86
79
|
// Note: the init phase has to be delayed when loaded as a sub-gen as the yaml configurations are not available.
|
|
@@ -90,13 +83,13 @@ class default_1 extends deploy_config_generator_shared_1.DeploymentGenerator {
|
|
|
90
83
|
}
|
|
91
84
|
async _init() {
|
|
92
85
|
// mta executable is required as mta-lib is used
|
|
93
|
-
if (!hasbin.sync(
|
|
86
|
+
if (!hasbin.sync(mtaExecutable)) {
|
|
94
87
|
this.abort = true;
|
|
95
|
-
|
|
88
|
+
handleErrorMessage(this.appWizard, { errorType: ERROR_TYPE.NO_MTA_BIN });
|
|
96
89
|
}
|
|
97
90
|
await this._processProjectPaths();
|
|
98
91
|
await this._processProjectConfigs();
|
|
99
|
-
this.isAbapDirectServiceBinding = await
|
|
92
|
+
this.isAbapDirectServiceBinding = await useAbapDirectServiceBinding(this.appPath, false, this.mtaPath);
|
|
100
93
|
// restricting local changes is only applicable for CAP flows
|
|
101
94
|
if (!this.isCap) {
|
|
102
95
|
this.lcapModeOnly = false;
|
|
@@ -107,25 +100,25 @@ class default_1 extends deploy_config_generator_shared_1.DeploymentGenerator {
|
|
|
107
100
|
* Checks if the project is a CAP project or contains an mta.
|
|
108
101
|
*/
|
|
109
102
|
async _processProjectPaths() {
|
|
110
|
-
const mtaPathResult = await
|
|
103
|
+
const mtaPathResult = await getMtaPath(this.appPath);
|
|
111
104
|
this.mtaPath = mtaPathResult?.mtaPath;
|
|
112
|
-
const capRoot = await
|
|
105
|
+
const capRoot = await findCapProjectRoot(this.appPath, true, this.fs);
|
|
113
106
|
if (capRoot) {
|
|
114
|
-
if (!hasbin.sync(
|
|
115
|
-
|
|
107
|
+
if (!hasbin.sync(cdsExecutable)) {
|
|
108
|
+
bail(ErrorHandler.getErrorMsgFromType(ERROR_TYPE.NO_CDS_BIN));
|
|
116
109
|
}
|
|
117
110
|
this.isCap = true;
|
|
118
111
|
this.projectRoot = capRoot;
|
|
119
112
|
try {
|
|
120
113
|
this.packageName =
|
|
121
|
-
this.fs.readJSON(
|
|
114
|
+
this.fs.readJSON(join(this.projectRoot, FileName.Package))?.name ?? '';
|
|
122
115
|
}
|
|
123
116
|
catch {
|
|
124
117
|
// Ignore errors while reading the package.json file, will be handled in the validators of the respective modules
|
|
125
118
|
}
|
|
126
119
|
}
|
|
127
120
|
else if (this.mtaPath) {
|
|
128
|
-
this.projectRoot =
|
|
121
|
+
this.projectRoot = dirname(this.mtaPath);
|
|
129
122
|
}
|
|
130
123
|
}
|
|
131
124
|
/**
|
|
@@ -133,12 +126,12 @@ class default_1 extends deploy_config_generator_shared_1.DeploymentGenerator {
|
|
|
133
126
|
* Checks if the base config file exists.
|
|
134
127
|
*/
|
|
135
128
|
async _processProjectConfigs() {
|
|
136
|
-
const baseConfigFile = this.options.base ??
|
|
137
|
-
const baseConfigExists = this.fs.exists(
|
|
129
|
+
const baseConfigFile = this.options.base ?? FileName.Ui5Yaml;
|
|
130
|
+
const baseConfigExists = this.fs.exists(join(this.appPath, baseConfigFile));
|
|
138
131
|
if (!baseConfigExists) {
|
|
139
|
-
|
|
132
|
+
bail(ErrorHandler.noBaseConfig(baseConfigFile));
|
|
140
133
|
}
|
|
141
|
-
this.deployConfigExists = this.fs.exists(
|
|
134
|
+
this.deployConfigExists = this.fs.exists(join(this.appPath, this.options.config ?? FileName.Ui5Yaml));
|
|
142
135
|
}
|
|
143
136
|
async prompting() {
|
|
144
137
|
if (this.abort) {
|
|
@@ -152,15 +145,15 @@ class default_1 extends deploy_config_generator_shared_1.DeploymentGenerator {
|
|
|
152
145
|
async _prompting() {
|
|
153
146
|
const isCAPMissingMTA = this.isCap && this.projectRoot && !this.mtaPath;
|
|
154
147
|
if (isCAPMissingMTA) {
|
|
155
|
-
|
|
156
|
-
this.appRouterAnswers = (await this.prompt(await
|
|
148
|
+
DeploymentGenerator.logger?.debug(t('cfGen.debug.capMissingMTA'));
|
|
149
|
+
this.appRouterAnswers = (await this.prompt(await getCAPMTAQuestions({ projectRoot: this.projectRoot ?? process.cwd() })));
|
|
157
150
|
if (this.appRouterAnswers.addCapMtaContinue !== true) {
|
|
158
151
|
this.abort = true;
|
|
159
152
|
return;
|
|
160
153
|
}
|
|
161
154
|
// Configure defaults
|
|
162
155
|
this.appRouterAnswers.mtaId = this.packageName; // Required for the MTA validation
|
|
163
|
-
this.destinationName =
|
|
156
|
+
this.destinationName = DefaultMTADestination;
|
|
164
157
|
this.options.overwrite = true; // Don't prompt the user to overwrite files we've just written!
|
|
165
158
|
this.answers = {};
|
|
166
159
|
this.answers.destinationName = this.destinationName;
|
|
@@ -177,13 +170,13 @@ class default_1 extends deploy_config_generator_shared_1.DeploymentGenerator {
|
|
|
177
170
|
*/
|
|
178
171
|
async _handleApiHubConfig() {
|
|
179
172
|
// generate a new instance dest name for api hub
|
|
180
|
-
if (this.apiHubConfig?.apiHubType ===
|
|
173
|
+
if (this.apiHubConfig?.apiHubType === ApiHubType.apiHubEnterprise) {
|
|
181
174
|
// full service path is only available from the manifest.json
|
|
182
175
|
if (!this.servicePath) {
|
|
183
|
-
const manifest = await
|
|
176
|
+
const manifest = await loadManifest(this.fs, this.appPath);
|
|
184
177
|
this.servicePath = manifest?.['sap.app']?.dataSources?.mainService?.uri;
|
|
185
178
|
}
|
|
186
|
-
this.destinationName =
|
|
179
|
+
this.destinationName = generateDestinationName(API_BUSINESS_HUB_ENTERPRISE_PREFIX, this.servicePath);
|
|
187
180
|
}
|
|
188
181
|
}
|
|
189
182
|
/**
|
|
@@ -192,12 +185,12 @@ class default_1 extends deploy_config_generator_shared_1.DeploymentGenerator {
|
|
|
192
185
|
* @returns {Promise<CfDeployConfigQuestions[]>} - Cloud Foundry deployment configuration questions
|
|
193
186
|
*/
|
|
194
187
|
async _getCFQuestions() {
|
|
195
|
-
return
|
|
188
|
+
return getCFQuestions({
|
|
196
189
|
projectRoot: this.projectRoot,
|
|
197
190
|
isAbapDirectServiceBinding: this.isAbapDirectServiceBinding,
|
|
198
191
|
cfDestination: this.destinationName,
|
|
199
192
|
isCap: this.isCap,
|
|
200
|
-
addOverwrite:
|
|
193
|
+
addOverwrite: showOverwriteQuestion(this.deployConfigExists, this.launchDeployConfigAsSubGenerator, this.launchStandaloneFromYui, this.options.overwrite),
|
|
201
194
|
apiHubConfig: this.apiHubConfig
|
|
202
195
|
});
|
|
203
196
|
}
|
|
@@ -206,18 +199,18 @@ class default_1 extends deploy_config_generator_shared_1.DeploymentGenerator {
|
|
|
206
199
|
*/
|
|
207
200
|
async _reconcileAnswersWithOptions() {
|
|
208
201
|
const destinationName = this.destinationName || this.answers.destinationName;
|
|
209
|
-
const destination = await
|
|
210
|
-
const isDestinationFullUrl = this.options.isFullUrlDest ?? (destination &&
|
|
202
|
+
const destination = await getDestination(destinationName);
|
|
203
|
+
const isDestinationFullUrl = this.options.isFullUrlDest ?? (destination && isFullUrlDestination(destination)) ?? false;
|
|
211
204
|
if (isDestinationFullUrl) {
|
|
212
|
-
|
|
205
|
+
DeploymentGenerator.logger?.warn(t('cfGen.warn.fullUrlDestination'));
|
|
213
206
|
}
|
|
214
207
|
const addManagedAppRouter = this.options.addManagedAppRouter ??
|
|
215
|
-
(this.options.routerType ===
|
|
216
|
-
this.answers.routerType ===
|
|
208
|
+
(this.options.routerType === RouterModuleType.Managed ||
|
|
209
|
+
this.answers.routerType === RouterModuleType.Managed);
|
|
217
210
|
const addAppFrontendRouter = this.options.addAppFrontendRouter ??
|
|
218
|
-
(this.options.routerType ===
|
|
219
|
-
this.answers.routerType ===
|
|
220
|
-
const destinationAuthentication = this.options.destinationAuthType ?? destination?.Authentication ??
|
|
211
|
+
(this.options.routerType === RouterModuleType.AppFront ||
|
|
212
|
+
this.answers.routerType === RouterModuleType.AppFront);
|
|
213
|
+
const destinationAuthentication = this.options.destinationAuthType ?? destination?.Authentication ?? DESTINATION_AUTHTYPE_NOTFOUND;
|
|
221
214
|
const overwrite = this.options.overwrite ?? this.answers.overwrite;
|
|
222
215
|
this.answers = {
|
|
223
216
|
destinationName,
|
|
@@ -245,14 +238,14 @@ class default_1 extends deploy_config_generator_shared_1.DeploymentGenerator {
|
|
|
245
238
|
try {
|
|
246
239
|
// Step1. (Optional) Generate CAP MTA with specific approuter type managed | standalone
|
|
247
240
|
if (this.appRouterAnswers) {
|
|
248
|
-
await
|
|
241
|
+
await generateCAPConfig(this.appRouterAnswers, this.fs, DeploymentGenerator.logger);
|
|
249
242
|
}
|
|
250
243
|
// Step2. Append HTML5 app to MTA
|
|
251
|
-
await
|
|
244
|
+
await generateAppConfig(this._getAppConfig(), this.fs, DeploymentGenerator.logger);
|
|
252
245
|
}
|
|
253
246
|
catch (error) {
|
|
254
247
|
this.abort = true;
|
|
255
|
-
|
|
248
|
+
handleErrorMessage(this.appWizard, { errorMsg: t('cfGen.error.writing', { error }) });
|
|
256
249
|
}
|
|
257
250
|
}
|
|
258
251
|
/**
|
|
@@ -290,11 +283,11 @@ class default_1 extends deploy_config_generator_shared_1.DeploymentGenerator {
|
|
|
290
283
|
}
|
|
291
284
|
}
|
|
292
285
|
catch (error) {
|
|
293
|
-
|
|
286
|
+
handleErrorMessage(this.appWizard, { errorMsg: t('cfGen.error.install', { error: error.message }) });
|
|
294
287
|
}
|
|
295
288
|
}
|
|
296
289
|
else {
|
|
297
|
-
|
|
290
|
+
DeploymentGenerator.logger?.info(t('cfGen.info.skippedInstallation'));
|
|
298
291
|
}
|
|
299
292
|
}
|
|
300
293
|
/**
|
|
@@ -303,7 +296,7 @@ class default_1 extends deploy_config_generator_shared_1.DeploymentGenerator {
|
|
|
303
296
|
* @param path - the path to run npm install
|
|
304
297
|
*/
|
|
305
298
|
async _runNpmInstall(path) {
|
|
306
|
-
const npm =
|
|
299
|
+
const npm = platform() === 'win32' ? 'npm.cmd' : 'npm';
|
|
307
300
|
// install dependencies
|
|
308
301
|
await this.spawnCommand(npm, ['install', '--no-audit', '--no-fund', '--silent', '--prefer-offline', '--no-progress'], {
|
|
309
302
|
cwd: path
|
|
@@ -315,25 +308,27 @@ class default_1 extends deploy_config_generator_shared_1.DeploymentGenerator {
|
|
|
315
308
|
return;
|
|
316
309
|
}
|
|
317
310
|
if ((this.options.launchStandaloneFromYui || !this.launchDeployConfigAsSubGenerator) &&
|
|
318
|
-
|
|
319
|
-
this.appWizard?.showInformation(
|
|
311
|
+
isExtensionInstalled(this.vscode, YUI_EXTENSION_ID, YUI_MIN_VER_FILES_GENERATED_MSG)) {
|
|
312
|
+
this.appWizard?.showInformation(t('cfGen.info.filesGenerated'), MessageType.notification);
|
|
320
313
|
}
|
|
321
314
|
await this._sendTelemetry();
|
|
322
315
|
}
|
|
323
316
|
catch (error) {
|
|
324
|
-
|
|
317
|
+
DeploymentGenerator.logger?.error(t('cfGen.error.end', { error }));
|
|
325
318
|
}
|
|
326
319
|
}
|
|
327
320
|
async _sendTelemetry() {
|
|
328
|
-
const telemetryData =
|
|
321
|
+
const telemetryData = TelemetryHelper.createTelemetryData({
|
|
329
322
|
DeployTarget: 'CF',
|
|
330
323
|
ManagedApprouter: this.answers.addManagedAppRouter,
|
|
331
324
|
AppFrontendRouter: this.answers.addAppFrontendRouter,
|
|
332
325
|
MTA: this.mtaPath ? 'true' : 'false',
|
|
333
326
|
...this.options.telemetryData
|
|
334
327
|
}) ?? {};
|
|
335
|
-
await
|
|
328
|
+
await sendTelemetry(EventName.DEPLOY_CONFIG, telemetryData, this.appPath);
|
|
336
329
|
}
|
|
337
330
|
}
|
|
338
|
-
|
|
331
|
+
export { getCFQuestions, loadManifest };
|
|
332
|
+
export { API_BUSINESS_HUB_ENTERPRISE_PREFIX, DESTINATION_AUTHTYPE_NOTFOUND };
|
|
333
|
+
export { ApiHubType } from '@sap-ux/cf-deploy-config-writer';
|
|
339
334
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
|
|
10
|
-
const utils_1 = require("./utils");
|
|
11
|
-
const utils_2 = require("../utils");
|
|
12
|
-
const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
1
|
+
import { isAppStudio } from '@sap-ux/btp-utils';
|
|
2
|
+
import { DeploymentGenerator, getConfirmMtaContinuePrompt } from '@sap-ux/deploy-config-generator-shared';
|
|
3
|
+
import { getMtaPath } from '@sap-ux/project-access';
|
|
4
|
+
import { appRouterPromptNames, getAppRouterPrompts, getPrompts, promptNames } from '@sap-ux/cf-deploy-config-inquirer';
|
|
5
|
+
import { getHostEnvironment, hostEnvironment } from '@sap-ux/fiori-generator-shared';
|
|
6
|
+
import { destinationQuestionDefaultOption, getCFChoices } from './utils.js';
|
|
7
|
+
import { t } from '../utils/index.js';
|
|
8
|
+
import { withCondition } from '@sap-ux/inquirer-common';
|
|
13
9
|
/**
|
|
14
10
|
* Fetches the Cloud Foundry deployment configuration questions.
|
|
15
11
|
*
|
|
@@ -23,10 +19,10 @@ const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
|
23
19
|
* @param options.promptOptions - additional prompt options.
|
|
24
20
|
* @returns the cf deploy config questions.
|
|
25
21
|
*/
|
|
26
|
-
async function getCFQuestions({ projectRoot, isAbapDirectServiceBinding, cfDestination, isCap, addOverwrite, apiHubConfig, promptOptions }) {
|
|
27
|
-
const isBAS =
|
|
28
|
-
const mtaYamlExists = !!(await
|
|
29
|
-
const cfChoices = await
|
|
22
|
+
export async function getCFQuestions({ projectRoot, isAbapDirectServiceBinding, cfDestination, isCap, addOverwrite, apiHubConfig, promptOptions }) {
|
|
23
|
+
const isBAS = isAppStudio();
|
|
24
|
+
const mtaYamlExists = !!(await getMtaPath(projectRoot));
|
|
25
|
+
const cfChoices = await getCFChoices({
|
|
30
26
|
projectRoot,
|
|
31
27
|
isCap,
|
|
32
28
|
cfDestination,
|
|
@@ -34,20 +30,20 @@ async function getCFQuestions({ projectRoot, isAbapDirectServiceBinding, cfDesti
|
|
|
34
30
|
apiHubConfigType: apiHubConfig?.apiHubType
|
|
35
31
|
});
|
|
36
32
|
const options = {
|
|
37
|
-
[
|
|
38
|
-
defaultValue:
|
|
33
|
+
[promptNames.destinationName]: {
|
|
34
|
+
defaultValue: destinationQuestionDefaultOption(isAbapDirectServiceBinding, isBAS, cfDestination),
|
|
39
35
|
hint: !!isAbapDirectServiceBinding,
|
|
40
|
-
useAutocomplete:
|
|
36
|
+
useAutocomplete: getHostEnvironment() === hostEnvironment.cli,
|
|
41
37
|
addBTPDestinationList: isBAS ? !isAbapDirectServiceBinding : false,
|
|
42
38
|
additionalChoiceList: cfChoices,
|
|
43
39
|
...promptOptions?.destinationName
|
|
44
40
|
},
|
|
45
|
-
[
|
|
46
|
-
[
|
|
47
|
-
[
|
|
41
|
+
[promptNames.addManagedAppRouter]: { hide: true, ...promptOptions?.addManagedAppRouter },
|
|
42
|
+
[promptNames.routerType]: { hide: mtaYamlExists || isCap, ...promptOptions?.routerType },
|
|
43
|
+
[promptNames.overwriteCfConfig]: { hide: !addOverwrite, ...promptOptions?.overwriteCfConfig }
|
|
48
44
|
};
|
|
49
|
-
|
|
50
|
-
return
|
|
45
|
+
DeploymentGenerator.logger?.debug(t('cfGen.debug.promptOptions', { options: JSON.stringify(options) }));
|
|
46
|
+
return getPrompts(options, DeploymentGenerator.logger);
|
|
51
47
|
}
|
|
52
48
|
/**
|
|
53
49
|
* Retrieve the CF Approuter questions, certain prompts are restricted to support CAP project.
|
|
@@ -59,15 +55,15 @@ async function getCFQuestions({ projectRoot, isAbapDirectServiceBinding, cfDesti
|
|
|
59
55
|
async function getCFApprouterQuestionsForCap({ projectRoot }) {
|
|
60
56
|
// Disable some prompts, not required for CAP flow
|
|
61
57
|
const appRouterPromptOptions = {
|
|
62
|
-
[
|
|
63
|
-
[
|
|
64
|
-
[
|
|
65
|
-
[
|
|
66
|
-
[
|
|
67
|
-
[
|
|
68
|
-
[
|
|
58
|
+
[appRouterPromptNames.mtaPath]: projectRoot,
|
|
59
|
+
[appRouterPromptNames.mtaId]: false, // CDS Flow will auto generate this based on the package.json name property
|
|
60
|
+
[appRouterPromptNames.mtaDescription]: false,
|
|
61
|
+
[appRouterPromptNames.mtaVersion]: false,
|
|
62
|
+
[appRouterPromptNames.routerType]: true,
|
|
63
|
+
[appRouterPromptNames.addConnectivityService]: true,
|
|
64
|
+
[appRouterPromptNames.addABAPServiceBinding]: false
|
|
69
65
|
};
|
|
70
|
-
return
|
|
66
|
+
return getAppRouterPrompts(appRouterPromptOptions);
|
|
71
67
|
}
|
|
72
68
|
/**
|
|
73
69
|
* Generate CF Approuter questions for CAP project with an existing HTML5 app and missing MTA configuration.
|
|
@@ -76,13 +72,13 @@ async function getCFApprouterQuestionsForCap({ projectRoot }) {
|
|
|
76
72
|
* @param options.projectRoot - the root path of the project.
|
|
77
73
|
* @returns the cf approuter config questions, restricting prompts being shown to the user
|
|
78
74
|
*/
|
|
79
|
-
async function getCAPMTAQuestions({ projectRoot }) {
|
|
75
|
+
export async function getCAPMTAQuestions({ projectRoot }) {
|
|
80
76
|
// If launched as root generator, add a prompt to allow user decide if they want to add an MTA config
|
|
81
77
|
let questions = (await getCFApprouterQuestionsForCap({
|
|
82
78
|
projectRoot
|
|
83
79
|
}));
|
|
84
|
-
questions =
|
|
85
|
-
questions.unshift(...
|
|
80
|
+
questions = withCondition(questions, (answers) => answers.addCapMtaContinue === true);
|
|
81
|
+
questions.unshift(...getConfirmMtaContinuePrompt());
|
|
86
82
|
return questions;
|
|
87
83
|
}
|
|
88
84
|
//# sourceMappingURL=questions.js.map
|
package/generators/app/types.js
CHANGED
package/generators/app/utils.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const project_access_1 = require("@sap-ux/project-access");
|
|
8
|
-
const deploy_config_generator_shared_1 = require("@sap-ux/deploy-config-generator-shared");
|
|
9
|
-
const cf_deploy_config_writer_1 = require("@sap-ux/cf-deploy-config-writer");
|
|
10
|
-
const node_path_1 = require("node:path");
|
|
11
|
-
const utils_1 = require("../utils");
|
|
1
|
+
import { isAppStudio } from '@sap-ux/btp-utils';
|
|
2
|
+
import { FileName, getMtaPath, getWebappPath } from '@sap-ux/project-access';
|
|
3
|
+
import { DeploymentGenerator, bail, ErrorHandler, ERROR_TYPE } from '@sap-ux/deploy-config-generator-shared';
|
|
4
|
+
import { ApiHubType, MtaConfig } from '@sap-ux/cf-deploy-config-writer';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { t, DEFAULT_MTA_DESTINATION, DESTINATION_CHOICE_NONE, DESTINATION_CHOICE_DIRECT_SERVICE_BINDING } from '../utils/index.js';
|
|
12
7
|
/**
|
|
13
8
|
* Get the destination choices from API Hub | Local Store | mta.yaml.
|
|
14
9
|
*
|
|
@@ -20,16 +15,16 @@ const utils_1 = require("../utils");
|
|
|
20
15
|
* @param options.apiHubConfigType - the API Hub configuration.
|
|
21
16
|
* @returns the cf deploy config questions.
|
|
22
17
|
*/
|
|
23
|
-
async function getCFChoices({ projectRoot, isAbapDirectServiceBinding, cfDestination, isCap, apiHubConfigType }) {
|
|
18
|
+
export async function getCFChoices({ projectRoot, isAbapDirectServiceBinding, cfDestination, isCap, apiHubConfigType }) {
|
|
24
19
|
let choices = [];
|
|
25
20
|
const abapBindingChoice = [
|
|
26
21
|
{
|
|
27
|
-
name:
|
|
28
|
-
value:
|
|
22
|
+
name: t('cfGen.prompts.abapBinding.name'),
|
|
23
|
+
value: DESTINATION_CHOICE_DIRECT_SERVICE_BINDING
|
|
29
24
|
}
|
|
30
25
|
];
|
|
31
26
|
// If API Hub Enterprise configuration is used, return the CF destination
|
|
32
|
-
if (apiHubConfigType ===
|
|
27
|
+
if (apiHubConfigType === ApiHubType.apiHubEnterprise) {
|
|
33
28
|
choices = [
|
|
34
29
|
{
|
|
35
30
|
name: cfDestination,
|
|
@@ -38,7 +33,7 @@ async function getCFChoices({ projectRoot, isAbapDirectServiceBinding, cfDestina
|
|
|
38
33
|
];
|
|
39
34
|
}
|
|
40
35
|
else {
|
|
41
|
-
const cfChoices = !isAbapDirectServiceBinding &&
|
|
36
|
+
const cfChoices = !isAbapDirectServiceBinding && isAppStudio()
|
|
42
37
|
? await getCFSystemChoices(projectRoot, isCap, cfDestination)
|
|
43
38
|
: [];
|
|
44
39
|
choices = isAbapDirectServiceBinding ? abapBindingChoice : cfChoices;
|
|
@@ -59,21 +54,21 @@ async function getCFSystemChoices(projectRoot, isCap, cfDestination) {
|
|
|
59
54
|
let mtaDestinations = [];
|
|
60
55
|
// Append mta destinations to support instance based destination flows
|
|
61
56
|
if (isCap) {
|
|
62
|
-
const mtaConfig = await
|
|
57
|
+
const mtaConfig = await MtaConfig.newInstance(projectRoot);
|
|
63
58
|
mtaDestinations = mtaConfig.getExposedDestinations();
|
|
64
59
|
if (mtaDestinations?.length) {
|
|
65
60
|
// Add default option
|
|
66
61
|
choices.push({
|
|
67
|
-
name:
|
|
68
|
-
value:
|
|
62
|
+
name: t('cfGen.prompts.capInstanceBasedDest.name'),
|
|
63
|
+
value: DEFAULT_MTA_DESTINATION
|
|
69
64
|
});
|
|
70
65
|
}
|
|
71
66
|
}
|
|
72
67
|
else {
|
|
73
|
-
const mtaResult = await
|
|
74
|
-
const mtaDir = mtaResult?.mtaPath?.split(
|
|
68
|
+
const mtaResult = await getMtaPath(projectRoot);
|
|
69
|
+
const mtaDir = mtaResult?.mtaPath?.split(FileName.MtaYaml)[0];
|
|
75
70
|
if (mtaDir) {
|
|
76
|
-
const mtaConfig = await
|
|
71
|
+
const mtaConfig = await MtaConfig.newInstance(mtaDir);
|
|
77
72
|
mtaDestinations = mtaConfig.getExposedDestinations(true);
|
|
78
73
|
}
|
|
79
74
|
}
|
|
@@ -82,17 +77,17 @@ async function getCFSystemChoices(projectRoot, isCap, cfDestination) {
|
|
|
82
77
|
// Load additional destinations exposed by the mta.yaml
|
|
83
78
|
mtaDestinations.forEach((dest) => {
|
|
84
79
|
choices.push({
|
|
85
|
-
name:
|
|
80
|
+
name: t('cfGen.prompts.instanceBasedDest.name', { destination: dest }),
|
|
86
81
|
value: dest
|
|
87
82
|
});
|
|
88
83
|
});
|
|
89
84
|
}
|
|
90
85
|
}
|
|
91
86
|
catch (error) {
|
|
92
|
-
|
|
87
|
+
DeploymentGenerator.logger?.debug(t('cfGen.error.mtaDestinations', { error }));
|
|
93
88
|
}
|
|
94
89
|
if (!cfDestination) {
|
|
95
|
-
choices.splice(0, 0, { name:
|
|
90
|
+
choices.splice(0, 0, { name: t('cfGen.prompts.none.name'), value: DESTINATION_CHOICE_NONE });
|
|
96
91
|
}
|
|
97
92
|
return choices;
|
|
98
93
|
}
|
|
@@ -104,7 +99,7 @@ async function getCFSystemChoices(projectRoot, isCap, cfDestination) {
|
|
|
104
99
|
* @param cfDestination - The pre-configured Cloud Foundry destination (if available).
|
|
105
100
|
* @returns {string} The default destination option.
|
|
106
101
|
*/
|
|
107
|
-
function destinationQuestionDefaultOption(isAbapDirectServiceBinding, isBAS, cfDestination) {
|
|
102
|
+
export function destinationQuestionDefaultOption(isAbapDirectServiceBinding, isBAS, cfDestination) {
|
|
108
103
|
let defaultDestination = '';
|
|
109
104
|
if (!isBAS) {
|
|
110
105
|
defaultDestination = cfDestination ?? '';
|
|
@@ -113,10 +108,10 @@ function destinationQuestionDefaultOption(isAbapDirectServiceBinding, isBAS, cfD
|
|
|
113
108
|
defaultDestination = cfDestination;
|
|
114
109
|
}
|
|
115
110
|
else if (isAbapDirectServiceBinding) {
|
|
116
|
-
defaultDestination =
|
|
111
|
+
defaultDestination = DESTINATION_CHOICE_DIRECT_SERVICE_BINDING;
|
|
117
112
|
}
|
|
118
113
|
else if (isBAS) {
|
|
119
|
-
defaultDestination =
|
|
114
|
+
defaultDestination = DESTINATION_CHOICE_NONE;
|
|
120
115
|
}
|
|
121
116
|
return defaultDestination;
|
|
122
117
|
}
|
|
@@ -127,14 +122,14 @@ function destinationQuestionDefaultOption(isAbapDirectServiceBinding, isBAS, cfD
|
|
|
127
122
|
* @param appPath - path to the project
|
|
128
123
|
* @returns manifest object
|
|
129
124
|
*/
|
|
130
|
-
async function loadManifest(fs, appPath) {
|
|
131
|
-
const manifestPath =
|
|
125
|
+
export async function loadManifest(fs, appPath) {
|
|
126
|
+
const manifestPath = join(await getWebappPath(appPath), FileName.Manifest);
|
|
132
127
|
const manifest = fs.readJSON(manifestPath);
|
|
133
128
|
if (!manifest) {
|
|
134
|
-
|
|
129
|
+
bail(ErrorHandler.getErrorMsgFromType(ERROR_TYPE.NO_MANIFEST));
|
|
135
130
|
}
|
|
136
131
|
if (!manifest['sap.app']?.id) {
|
|
137
|
-
|
|
132
|
+
bail(ErrorHandler.getErrorMsgFromType(ERROR_TYPE.NO_APP_NAME));
|
|
138
133
|
}
|
|
139
134
|
return manifest;
|
|
140
135
|
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.defaultMtaVersion = exports.prompts = exports.generatorTitle = void 0;
|
|
4
|
-
exports.generatorTitle = 'Application Router Generator';
|
|
5
|
-
exports.prompts = [
|
|
1
|
+
export const generatorTitle = 'Application Router Generator';
|
|
2
|
+
export const prompts = [
|
|
6
3
|
{
|
|
7
4
|
name: 'Application Router Configuration',
|
|
8
5
|
description: 'Configure the Cloud Foundry application router'
|
|
9
6
|
}
|
|
10
7
|
];
|
|
11
|
-
|
|
8
|
+
export const defaultMtaVersion = '0.0.1';
|
|
12
9
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const utils_1 = require("../utils");
|
|
11
|
-
const constants_1 = require("./constants");
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import * as hasbin from 'hasbin';
|
|
3
|
+
import { platform } from 'node:os';
|
|
4
|
+
import { AppWizard, Prompts } from '@sap-devx/yeoman-ui-types';
|
|
5
|
+
import { DeploymentGenerator, ERROR_TYPE, handleErrorMessage, mtaExecutable } from '@sap-ux/deploy-config-generator-shared';
|
|
6
|
+
import { getAppRouterPrompts, appRouterPromptNames } from '@sap-ux/cf-deploy-config-inquirer';
|
|
7
|
+
import { generateBaseConfig } from '@sap-ux/cf-deploy-config-writer';
|
|
8
|
+
import { t, initI18n } from '../utils/index.js';
|
|
9
|
+
import { defaultMtaVersion, generatorTitle, prompts } from './constants.js';
|
|
12
10
|
/**
|
|
13
11
|
* Generator for creating an application router.
|
|
14
12
|
*
|
|
15
13
|
* @extends DeploymentGenerator
|
|
16
14
|
*/
|
|
17
|
-
class
|
|
15
|
+
export default class extends DeploymentGenerator {
|
|
18
16
|
appWizard;
|
|
19
17
|
prompts;
|
|
20
18
|
answers;
|
|
@@ -28,10 +26,10 @@ class default_1 extends deploy_config_generator_shared_1.DeploymentGenerator {
|
|
|
28
26
|
*/
|
|
29
27
|
constructor(args, opts) {
|
|
30
28
|
super(args, opts);
|
|
31
|
-
this.appWizard = opts.appWizard ??
|
|
29
|
+
this.appWizard = opts.appWizard ?? AppWizard.create(opts);
|
|
32
30
|
this.options = opts;
|
|
33
|
-
this.appWizard.setHeaderTitle(
|
|
34
|
-
this.prompts = new
|
|
31
|
+
this.appWizard.setHeaderTitle(generatorTitle);
|
|
32
|
+
this.prompts = new Prompts(prompts);
|
|
35
33
|
this.setPromptsCallback = (fn) => {
|
|
36
34
|
if (this.prompts) {
|
|
37
35
|
this.prompts.setCallback(fn);
|
|
@@ -40,13 +38,13 @@ class default_1 extends deploy_config_generator_shared_1.DeploymentGenerator {
|
|
|
40
38
|
}
|
|
41
39
|
async initializing() {
|
|
42
40
|
await super.initializing();
|
|
43
|
-
await
|
|
41
|
+
await initI18n();
|
|
44
42
|
this._initFromProjectConfig();
|
|
45
43
|
}
|
|
46
44
|
_initFromProjectConfig() {
|
|
47
45
|
// mta executable is required as mta-lib is used
|
|
48
|
-
if (!hasbin.sync(
|
|
49
|
-
|
|
46
|
+
if (!hasbin.sync(mtaExecutable)) {
|
|
47
|
+
handleErrorMessage(this.appWizard, { errorType: ERROR_TYPE.NO_MTA_BIN });
|
|
50
48
|
this.abort = true;
|
|
51
49
|
}
|
|
52
50
|
}
|
|
@@ -56,23 +54,23 @@ class default_1 extends deploy_config_generator_shared_1.DeploymentGenerator {
|
|
|
56
54
|
}
|
|
57
55
|
// assign prompt options
|
|
58
56
|
const appRouterPromptOptions = {
|
|
59
|
-
[
|
|
60
|
-
[
|
|
61
|
-
[
|
|
62
|
-
[
|
|
63
|
-
[
|
|
64
|
-
[
|
|
65
|
-
[
|
|
57
|
+
[appRouterPromptNames.mtaPath]: this.destinationRoot() ?? process.cwd(),
|
|
58
|
+
[appRouterPromptNames.mtaId]: true,
|
|
59
|
+
[appRouterPromptNames.mtaDescription]: true,
|
|
60
|
+
[appRouterPromptNames.mtaVersion]: false, // prompt switched off as 0.0.1 is written by default
|
|
61
|
+
[appRouterPromptNames.routerType]: true,
|
|
62
|
+
[appRouterPromptNames.addConnectivityService]: true,
|
|
63
|
+
[appRouterPromptNames.addABAPServiceBinding]: true
|
|
66
64
|
};
|
|
67
|
-
const prompts = await
|
|
65
|
+
const prompts = await getAppRouterPrompts(appRouterPromptOptions);
|
|
68
66
|
this.answers = await this.prompt(prompts);
|
|
69
67
|
}
|
|
70
68
|
async writing() {
|
|
71
69
|
if (this.abort) {
|
|
72
70
|
return;
|
|
73
71
|
}
|
|
74
|
-
this.destinationRoot(
|
|
75
|
-
|
|
72
|
+
this.destinationRoot(join(this.answers.mtaPath, this.answers.mtaId));
|
|
73
|
+
DeploymentGenerator.logger?.debug(t('appRouterGen.debug.projectPath', { destinationPath: this.destinationRoot() }));
|
|
76
74
|
let abapServiceProvider;
|
|
77
75
|
if (this.answers.addABAPServiceBinding) {
|
|
78
76
|
abapServiceProvider = {
|
|
@@ -87,16 +85,16 @@ class default_1 extends deploy_config_generator_shared_1.DeploymentGenerator {
|
|
|
87
85
|
mtaId: this.answers.mtaId,
|
|
88
86
|
mtaPath: this.destinationRoot(),
|
|
89
87
|
mtaDescription: this.answers.mtaDescription,
|
|
90
|
-
mtaVersion:
|
|
88
|
+
mtaVersion: defaultMtaVersion
|
|
91
89
|
};
|
|
92
|
-
await
|
|
90
|
+
await generateBaseConfig(cfBaseConfig, this.fs, DeploymentGenerator.logger);
|
|
93
91
|
}
|
|
94
92
|
install() {
|
|
95
93
|
this._install();
|
|
96
94
|
}
|
|
97
95
|
_install() {
|
|
98
96
|
if (!this.abort && !this.options.skipInstall) {
|
|
99
|
-
const npm =
|
|
97
|
+
const npm = platform() === 'win32' ? 'npm.cmd' : 'npm';
|
|
100
98
|
// install dependencies in project root
|
|
101
99
|
this.spawnCommand(npm, ['install', '--no-audit', '--no-fund', '--silent', '--prefer-offline', '--no-progress'], {
|
|
102
100
|
cwd: this.destinationRoot()
|
|
@@ -104,5 +102,4 @@ class default_1 extends deploy_config_generator_shared_1.DeploymentGenerator {
|
|
|
104
102
|
}
|
|
105
103
|
}
|
|
106
104
|
}
|
|
107
|
-
exports.default = default_1;
|
|
108
105
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EventName = void 0;
|
|
4
|
-
var EventName;
|
|
1
|
+
export var EventName;
|
|
5
2
|
(function (EventName) {
|
|
6
3
|
EventName["DEPLOY_CONFIG"] = "DEPLOY_CONFIG";
|
|
7
|
-
})(EventName || (
|
|
4
|
+
})(EventName || (EventName = {}));
|
|
8
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.DESTINATION_AUTHTYPE_NOTFOUND = 'NotAvailable';
|
|
7
|
-
exports.DESTINATION_CHOICE_NONE = 'NONE';
|
|
8
|
-
exports.DESTINATION_CHOICE_DIRECT_SERVICE_BINDING = 'DIRECT_SERVICE_BINDING';
|
|
1
|
+
export const API_BUSINESS_HUB_ENTERPRISE_PREFIX = 'ABHE';
|
|
2
|
+
export const DEFAULT_MTA_DESTINATION = 'fiori-default-srv-api';
|
|
3
|
+
export const DESTINATION_AUTHTYPE_NOTFOUND = 'NotAvailable';
|
|
4
|
+
export const DESTINATION_CHOICE_NONE = 'NONE';
|
|
5
|
+
export const DESTINATION_CHOICE_DIRECT_SERVICE_BINDING = 'DIRECT_SERVICE_BINDING';
|
|
9
6
|
//# sourceMappingURL=constants.js.map
|
package/generators/utils/i18n.js
CHANGED
|
@@ -1,27 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.i18n = void 0;
|
|
7
|
-
exports.initI18n = initI18n;
|
|
8
|
-
exports.t = t;
|
|
9
|
-
const i18next_1 = __importDefault(require("i18next"));
|
|
10
|
-
const cf_deploy_config_sub_generator_i18n_json_1 = __importDefault(require("../translations/cf-deploy-config-sub-generator.i18n.json"));
|
|
11
|
-
const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
1
|
+
import i18next from 'i18next';
|
|
2
|
+
import translations from '../translations/cf-deploy-config-sub-generator.i18n.json' with { type: 'json' };
|
|
3
|
+
import { addi18nResourceBundle as addInquirerCommonTexts } from '@sap-ux/inquirer-common';
|
|
12
4
|
const cfAppRouterGenNs = 'cf-deploy-config-generator';
|
|
13
|
-
|
|
5
|
+
export const i18n = i18next.createInstance();
|
|
14
6
|
/**
|
|
15
7
|
* Initialize i18next with the translations for this module.
|
|
16
8
|
*/
|
|
17
|
-
async function initI18n() {
|
|
18
|
-
await
|
|
9
|
+
export async function initI18n() {
|
|
10
|
+
await i18n.init({
|
|
19
11
|
lng: 'en',
|
|
20
12
|
fallbackLng: 'en',
|
|
21
13
|
showSupportNotice: false
|
|
22
14
|
});
|
|
23
|
-
|
|
24
|
-
(
|
|
15
|
+
i18n.addResourceBundle('en', cfAppRouterGenNs, translations);
|
|
16
|
+
addInquirerCommonTexts();
|
|
25
17
|
}
|
|
26
18
|
/**
|
|
27
19
|
* Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
|
|
@@ -30,13 +22,11 @@ async function initI18n() {
|
|
|
30
22
|
* @param options additional options
|
|
31
23
|
* @returns {string} localized string stored for the given key
|
|
32
24
|
*/
|
|
33
|
-
function t(key, options) {
|
|
25
|
+
export function t(key, options) {
|
|
34
26
|
if (!options?.ns) {
|
|
35
27
|
options = Object.assign(options ?? {}, { ns: cfAppRouterGenNs });
|
|
36
28
|
}
|
|
37
|
-
return
|
|
29
|
+
return i18n.t(key, options);
|
|
38
30
|
}
|
|
39
|
-
initI18n().catch(() =>
|
|
40
|
-
// Needed for lint
|
|
41
|
-
});
|
|
31
|
+
void initI18n().catch(() => undefined);
|
|
42
32
|
//# sourceMappingURL=i18n.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './constants';
|
|
2
|
-
export * from './i18n';
|
|
1
|
+
export * from './constants.js';
|
|
2
|
+
export * from './i18n.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("./constants"), exports);
|
|
18
|
-
__exportStar(require("./i18n"), exports);
|
|
1
|
+
export * from './constants.js';
|
|
2
|
+
export * from './i18n.js';
|
|
19
3
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/cf-deploy-config-sub-generator",
|
|
3
3
|
"description": "Generators for configuring Cloud Foundry deployment configuration",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"bugs": {
|
|
11
11
|
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue"
|
|
12
12
|
},
|
|
13
|
+
"type": "module",
|
|
13
14
|
"license": "Apache-2.0",
|
|
14
15
|
"main": "generators/app/index.js",
|
|
15
16
|
"files": [
|
|
@@ -23,16 +24,17 @@
|
|
|
23
24
|
"hasbin": "1.2.3",
|
|
24
25
|
"i18next": "25.10.10",
|
|
25
26
|
"yeoman-generator": "5.10.0",
|
|
26
|
-
"@sap-ux/btp-utils": "
|
|
27
|
-
"@sap-ux/cf-deploy-config-writer": "0.
|
|
28
|
-
"@sap-ux/cf-deploy-config-inquirer": "0.
|
|
29
|
-
"@sap-ux/deploy-config-generator-shared": "0.
|
|
30
|
-
"@sap-ux/feature-toggle": "0.
|
|
31
|
-
"@sap-ux/fiori-generator-shared": "0.
|
|
32
|
-
"@sap-ux/inquirer-common": "0.
|
|
33
|
-
"@sap-ux/project-access": "
|
|
27
|
+
"@sap-ux/btp-utils": "2.0.0",
|
|
28
|
+
"@sap-ux/cf-deploy-config-writer": "1.0.1",
|
|
29
|
+
"@sap-ux/cf-deploy-config-inquirer": "1.0.1",
|
|
30
|
+
"@sap-ux/deploy-config-generator-shared": "1.0.1",
|
|
31
|
+
"@sap-ux/feature-toggle": "1.0.0",
|
|
32
|
+
"@sap-ux/fiori-generator-shared": "1.0.1",
|
|
33
|
+
"@sap-ux/inquirer-common": "1.0.1",
|
|
34
|
+
"@sap-ux/project-access": "2.0.1"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
37
|
+
"@jest/globals": "30.3.0",
|
|
36
38
|
"@types/hasbin": "1.2.2",
|
|
37
39
|
"@types/inquirer": "8.2.6",
|
|
38
40
|
"@types/js-yaml": "4.0.9",
|
|
@@ -45,7 +47,7 @@
|
|
|
45
47
|
"rimraf": "6.1.3",
|
|
46
48
|
"unionfs": "4.6.0",
|
|
47
49
|
"yeoman-test": "6.3.0",
|
|
48
|
-
"@sap-ux/logger": "0.
|
|
50
|
+
"@sap-ux/logger": "1.0.0"
|
|
49
51
|
},
|
|
50
52
|
"engines": {
|
|
51
53
|
"node": ">=22.x"
|
|
@@ -56,8 +58,8 @@
|
|
|
56
58
|
"watch": "tsc --watch",
|
|
57
59
|
"lint": "eslint",
|
|
58
60
|
"lint:fix": "eslint --fix",
|
|
59
|
-
"test": "jest --ci --forceExit --detectOpenHandles --colors",
|
|
60
|
-
"test-u": "jest --ci --forceExit --detectOpenHandles --colors -u",
|
|
61
|
+
"test": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors",
|
|
62
|
+
"test-u": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors -u",
|
|
61
63
|
"link": "pnpm link --global",
|
|
62
64
|
"unlink": "pnpm unlink --global"
|
|
63
65
|
}
|