@sap-ux/deploy-config-sub-generator 0.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/LICENSE +201 -0
- package/README.md +18 -0
- package/generators/app/index.d.ts +57 -0
- package/generators/app/index.js +168 -0
- package/generators/app/prompting.d.ts +40 -0
- package/generators/app/prompting.js +47 -0
- package/generators/app/utils.d.ts +20 -0
- package/generators/app/utils.js +41 -0
- package/generators/prompts/deploy-target.d.ts +17 -0
- package/generators/prompts/deploy-target.js +38 -0
- package/generators/prompts/index.d.ts +3 -0
- package/generators/prompts/index.js +8 -0
- package/generators/prompts/sub-gen.d.ts +39 -0
- package/generators/prompts/sub-gen.js +82 -0
- package/generators/translations/deploy-config-sub-generator.i18n.json +12 -0
- package/generators/types/index.d.ts +141 -0
- package/generators/types/index.js +3 -0
- package/generators/utils/config.d.ts +17 -0
- package/generators/utils/config.js +41 -0
- package/generators/utils/constants.d.ts +6 -0
- package/generators/utils/constants.js +11 -0
- package/generators/utils/environment.d.ts +34 -0
- package/generators/utils/environment.js +67 -0
- package/generators/utils/i18n.d.ts +14 -0
- package/generators/utils/i18n.js +36 -0
- package/generators/utils/index.d.ts +6 -0
- package/generators/utils/index.js +22 -0
- package/generators/utils/targets.d.ts +16 -0
- package/generators/utils/targets.js +44 -0
- package/package.json +78 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { FioriToolsProxyConfigBackend } from '@sap-ux/ui5-config';
|
|
2
|
+
import type { Editor } from 'mem-fs-editor';
|
|
3
|
+
import type { ApiHubConfig } from '@sap-ux/cf-deploy-config-sub-generator';
|
|
4
|
+
import type { AbapDeployConfigAnswersInternal } from '@sap-ux/abap-deploy-config-sub-generator';
|
|
5
|
+
import type { CommonPromptOptions, PromptDefaultValue } from '@sap-ux/inquirer-common';
|
|
6
|
+
import type { Question } from 'inquirer';
|
|
7
|
+
import type { DeployConfigOptions, Target } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves the combined sub generator prompts.
|
|
10
|
+
*
|
|
11
|
+
* @param fs - instance of fs
|
|
12
|
+
* @param options - deploy config options
|
|
13
|
+
* @param promptOpts - options for prompts
|
|
14
|
+
* @param promptOpts.launchDeployConfigAsSubGenerator - whether the generator is launched as a sub generator
|
|
15
|
+
* @param promptOpts.launchStandaloneFromYui - whether the generator is launched standalone from YUI
|
|
16
|
+
* @param promptOpts.extensionPromptOpts - extension prompt options
|
|
17
|
+
* @param promptOpts.supportedTargets - supported deployment targets
|
|
18
|
+
* @param promptOpts.backendConfig - backend configuration
|
|
19
|
+
* @param promptOpts.cfDestination - CF destination
|
|
20
|
+
* @param promptOpts.isCap - whether the project is a CAP project
|
|
21
|
+
* @param promptOpts.apiHubConfig - API Hub configuration
|
|
22
|
+
* @param promptOpts.isLibrary - whether the project is a library
|
|
23
|
+
* @returns - deployment configuration answers
|
|
24
|
+
*/
|
|
25
|
+
export declare function getSubGenPrompts(fs: Editor, options: DeployConfigOptions, { launchDeployConfigAsSubGenerator, launchStandaloneFromYui, extensionPromptOpts, supportedTargets, backendConfig, cfDestination, isCap, apiHubConfig, isLibrary }: {
|
|
26
|
+
launchDeployConfigAsSubGenerator: boolean;
|
|
27
|
+
launchStandaloneFromYui: boolean;
|
|
28
|
+
extensionPromptOpts?: Record<string, CommonPromptOptions & PromptDefaultValue<string | boolean>>;
|
|
29
|
+
supportedTargets: Target[];
|
|
30
|
+
backendConfig: FioriToolsProxyConfigBackend;
|
|
31
|
+
cfDestination: string;
|
|
32
|
+
isCap: boolean;
|
|
33
|
+
apiHubConfig: ApiHubConfig;
|
|
34
|
+
isLibrary: boolean;
|
|
35
|
+
}): Promise<{
|
|
36
|
+
questions: Question[];
|
|
37
|
+
abapAnswers: Partial<AbapDeployConfigAnswersInternal>;
|
|
38
|
+
}>;
|
|
39
|
+
//# sourceMappingURL=sub-gen.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSubGenPrompts = void 0;
|
|
4
|
+
const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const deploy_config_generator_shared_1 = require("@sap-ux/deploy-config-generator-shared");
|
|
8
|
+
const abap_deploy_config_sub_generator_1 = require("@sap-ux/abap-deploy-config-sub-generator");
|
|
9
|
+
const cf_deploy_config_sub_generator_1 = require("@sap-ux/cf-deploy-config-sub-generator");
|
|
10
|
+
const project_access_1 = require("@sap-ux/project-access");
|
|
11
|
+
const deploy_target_1 = require("./deploy-target");
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves the combined sub generator prompts.
|
|
14
|
+
*
|
|
15
|
+
* @param fs - instance of fs
|
|
16
|
+
* @param options - deploy config options
|
|
17
|
+
* @param promptOpts - options for prompts
|
|
18
|
+
* @param promptOpts.launchDeployConfigAsSubGenerator - whether the generator is launched as a sub generator
|
|
19
|
+
* @param promptOpts.launchStandaloneFromYui - whether the generator is launched standalone from YUI
|
|
20
|
+
* @param promptOpts.extensionPromptOpts - extension prompt options
|
|
21
|
+
* @param promptOpts.supportedTargets - supported deployment targets
|
|
22
|
+
* @param promptOpts.backendConfig - backend configuration
|
|
23
|
+
* @param promptOpts.cfDestination - CF destination
|
|
24
|
+
* @param promptOpts.isCap - whether the project is a CAP project
|
|
25
|
+
* @param promptOpts.apiHubConfig - API Hub configuration
|
|
26
|
+
* @param promptOpts.isLibrary - whether the project is a library
|
|
27
|
+
* @returns - deployment configuration answers
|
|
28
|
+
*/
|
|
29
|
+
async function getSubGenPrompts(fs, options, { launchDeployConfigAsSubGenerator, launchStandaloneFromYui, extensionPromptOpts, supportedTargets, backendConfig, cfDestination, isCap, apiHubConfig, isLibrary }) {
|
|
30
|
+
deploy_config_generator_shared_1.DeploymentGenerator.logger?.debug((0, utils_1.t)('debug.loadingPrompts'));
|
|
31
|
+
const configExists = fs.exists((0, path_1.join)(options.appRootPath, options.config || project_access_1.FileName.UI5DeployYaml));
|
|
32
|
+
const showOverwrite = (0, deploy_config_generator_shared_1.showOverwriteQuestion)(configExists, launchDeployConfigAsSubGenerator, launchStandaloneFromYui, options.overwrite);
|
|
33
|
+
const indexGenerationAllowed = !isLibrary && launchStandaloneFromYui && !(await (0, abap_deploy_config_sub_generator_1.indexHtmlExists)(fs, options.appRootPath));
|
|
34
|
+
// ABAP prompts
|
|
35
|
+
const { prompts: abapPrompts, answers: abapAnswers } = await (0, abap_deploy_config_sub_generator_1.getAbapQuestions)({
|
|
36
|
+
appRootPath: options.appRootPath,
|
|
37
|
+
connectedSystem: options.connectedSystem,
|
|
38
|
+
backendConfig,
|
|
39
|
+
configFile: options.config,
|
|
40
|
+
indexGenerationAllowed,
|
|
41
|
+
showOverwriteQuestion: showOverwrite,
|
|
42
|
+
logger: deploy_config_generator_shared_1.DeploymentGenerator.logger
|
|
43
|
+
});
|
|
44
|
+
// CF prompts
|
|
45
|
+
const cfPrompts = await (0, cf_deploy_config_sub_generator_1.getCFQuestions)({
|
|
46
|
+
projectRoot: options.projectRoot,
|
|
47
|
+
isAbapDirectServiceBinding: options.isAbapDirectServiceBinding,
|
|
48
|
+
cfDestination: cfDestination,
|
|
49
|
+
isCap: isCap,
|
|
50
|
+
addOverwrite: showOverwrite,
|
|
51
|
+
apiHubConfig: apiHubConfig
|
|
52
|
+
});
|
|
53
|
+
// Combine all prompts
|
|
54
|
+
const questions = combineAllPrompts(options.projectRoot, {
|
|
55
|
+
supportedTargets,
|
|
56
|
+
abapPrompts,
|
|
57
|
+
cfPrompts,
|
|
58
|
+
extensionPromptOpts,
|
|
59
|
+
launchStandaloneFromYui
|
|
60
|
+
});
|
|
61
|
+
return { questions, abapAnswers: abapAnswers };
|
|
62
|
+
}
|
|
63
|
+
exports.getSubGenPrompts = getSubGenPrompts;
|
|
64
|
+
/**
|
|
65
|
+
* Merges all prompts for deployment configuration.
|
|
66
|
+
*
|
|
67
|
+
* @param projectRoot - the project root path
|
|
68
|
+
* @param opts - the prompt opts for the deployment configuration prompts
|
|
69
|
+
* @param opts.supportedTargets - the support deployment targets
|
|
70
|
+
* @param opts.abapPrompts - abap specific prompts
|
|
71
|
+
* @param opts.cfPrompts - cf specific prompts
|
|
72
|
+
* @param opts.extensionPromptOpts - extension prompt options
|
|
73
|
+
* @param opts.launchStandaloneFromYui - whether the generator is launched standalone from YUI
|
|
74
|
+
* @returns - all the different prompts combined
|
|
75
|
+
*/
|
|
76
|
+
function combineAllPrompts(projectRoot, { supportedTargets, abapPrompts, cfPrompts, extensionPromptOpts, launchStandaloneFromYui }) {
|
|
77
|
+
const questions = (0, deploy_target_1.getDeployTargetQuestion)(supportedTargets, projectRoot, extensionPromptOpts, launchStandaloneFromYui);
|
|
78
|
+
questions.push(...(0, inquirer_common_1.withCondition)(abapPrompts, (answers) => answers.targetName === deploy_config_generator_shared_1.TargetName.ABAP));
|
|
79
|
+
questions.push(...(0, inquirer_common_1.withCondition)(cfPrompts, (answers) => answers.targetName === deploy_config_generator_shared_1.TargetName.CF));
|
|
80
|
+
return questions;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=sub-gen.js.map
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type Generator from 'yeoman-generator';
|
|
2
|
+
import type { Answers } from 'inquirer';
|
|
3
|
+
import type { AppWizard, Prompts } from '@sap-devx/yeoman-ui-types';
|
|
4
|
+
import type { ApiHubConfig } from '@sap-ux/cf-deploy-config-writer';
|
|
5
|
+
import type { LogWrapper, VSCodeInstance } from '@sap-ux/fiori-generator-shared';
|
|
6
|
+
import type { OdataServiceAnswers } from '@sap-ux/odata-service-inquirer';
|
|
7
|
+
import type { FioriToolsProxyConfigBackend } from '@sap-ux/ui5-config';
|
|
8
|
+
import type { CommonPromptOptions } from '@sap-ux/inquirer-common';
|
|
9
|
+
export interface DeployConfigOptions extends Generator.GeneratorOptions {
|
|
10
|
+
/**
|
|
11
|
+
* The target deployment
|
|
12
|
+
*/
|
|
13
|
+
target?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Instance of the AppWizard
|
|
16
|
+
*/
|
|
17
|
+
appWizard: AppWizard;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the deploy config should be launched as a sub generator
|
|
20
|
+
* All prompts (CF & ABAP) wil be combined into one step
|
|
21
|
+
*/
|
|
22
|
+
launchDeployConfigAsSubGenerator?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Host URL passed from the generator
|
|
25
|
+
*/
|
|
26
|
+
appGenServiceHost: string;
|
|
27
|
+
/**
|
|
28
|
+
* Service path passed from the generator
|
|
29
|
+
*/
|
|
30
|
+
appGenServicePath: string;
|
|
31
|
+
/**
|
|
32
|
+
* Client passed from the generator
|
|
33
|
+
*/
|
|
34
|
+
appGenClient: string;
|
|
35
|
+
/**
|
|
36
|
+
* The connected system from the generator
|
|
37
|
+
*/
|
|
38
|
+
connectedSystem?: OdataServiceAnswers['connectedSystem'];
|
|
39
|
+
/**
|
|
40
|
+
* Name of the project
|
|
41
|
+
*/
|
|
42
|
+
projectName: string;
|
|
43
|
+
/**
|
|
44
|
+
* Path to the root of the project (target folder)
|
|
45
|
+
*/
|
|
46
|
+
projectPath: string;
|
|
47
|
+
/**
|
|
48
|
+
* Telemetry data to be added to the deployment telemetry event
|
|
49
|
+
*/
|
|
50
|
+
telemetryData?: Record<string, string>;
|
|
51
|
+
/**
|
|
52
|
+
* API Hub configuration
|
|
53
|
+
*/
|
|
54
|
+
apiHubConfig?: ApiHubConfig;
|
|
55
|
+
/**
|
|
56
|
+
* Instance of the logger
|
|
57
|
+
*/
|
|
58
|
+
logWrapper?: LogWrapper;
|
|
59
|
+
/**
|
|
60
|
+
* Optional data passed from extension e.g Application Modeler
|
|
61
|
+
*/
|
|
62
|
+
data: {
|
|
63
|
+
/**
|
|
64
|
+
* Project folder root
|
|
65
|
+
*/
|
|
66
|
+
destinationRoot: string;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The deployment target (CF or ABAP)
|
|
71
|
+
*/
|
|
72
|
+
export interface Target {
|
|
73
|
+
name: string;
|
|
74
|
+
description: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The deployment configuration generator.
|
|
78
|
+
*/
|
|
79
|
+
export interface DeployConfigGenerator {
|
|
80
|
+
/**
|
|
81
|
+
* Instance of the Application Wizard
|
|
82
|
+
*/
|
|
83
|
+
appWizard: AppWizard;
|
|
84
|
+
/**
|
|
85
|
+
* Instance of vscode
|
|
86
|
+
*/
|
|
87
|
+
vscode: VSCodeInstance;
|
|
88
|
+
/**
|
|
89
|
+
* Options loaded from extension generators
|
|
90
|
+
*/
|
|
91
|
+
extensionPromptOpts?: Record<string, CommonPromptOptions>;
|
|
92
|
+
/**
|
|
93
|
+
* The generator namespace that will be used for calling subgens
|
|
94
|
+
*/
|
|
95
|
+
genNamespace: string;
|
|
96
|
+
/**
|
|
97
|
+
* Indicates the generator should be launched as a sub generator and combine all prompts into one step
|
|
98
|
+
*/
|
|
99
|
+
launchDeployConfigAsSubGenerator: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Indicates the generator is launched standalone from YUI
|
|
102
|
+
*/
|
|
103
|
+
launchStandaloneFromYui: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* The target deployment e.g CF or ABAP
|
|
106
|
+
*/
|
|
107
|
+
target: string | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* The deploy config prompts
|
|
110
|
+
*/
|
|
111
|
+
prompts: Prompts;
|
|
112
|
+
/**
|
|
113
|
+
* The deploy config answers
|
|
114
|
+
*/
|
|
115
|
+
answers?: Answers;
|
|
116
|
+
/**
|
|
117
|
+
* The bas destination
|
|
118
|
+
*/
|
|
119
|
+
cfDestination: string;
|
|
120
|
+
/**
|
|
121
|
+
* The path to the mta file
|
|
122
|
+
*/
|
|
123
|
+
mtaPath?: string;
|
|
124
|
+
/**
|
|
125
|
+
* The API Hub configuration
|
|
126
|
+
*/
|
|
127
|
+
apiHubConfig: ApiHubConfig;
|
|
128
|
+
/**
|
|
129
|
+
* The backend configuration,
|
|
130
|
+
*/
|
|
131
|
+
backendConfig: FioriToolsProxyConfigBackend;
|
|
132
|
+
/**
|
|
133
|
+
* Whether the project is CAP
|
|
134
|
+
*/
|
|
135
|
+
isCap: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Whether the project is a library
|
|
138
|
+
*/
|
|
139
|
+
isLibrary: boolean;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FioriToolsProxyConfigBackend } from '@sap-ux/ui5-config';
|
|
2
|
+
import type { Editor } from 'mem-fs-editor';
|
|
3
|
+
import type { DeployConfigOptions } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves backend configuration from either the base config (ui5.yaml) or from the options passed in.
|
|
6
|
+
*
|
|
7
|
+
* @param fs - file system editor
|
|
8
|
+
* @param options - options passed in
|
|
9
|
+
* @param launchStandaloneFromYui - flag to indicate if this generator is launched in YUI standalone
|
|
10
|
+
* @param projectRoot - project root
|
|
11
|
+
* @returns - backend configuration
|
|
12
|
+
*/
|
|
13
|
+
export declare function getBackendConfig(fs: Editor, options: DeployConfigOptions, launchStandaloneFromYui: boolean, projectRoot: string): Promise<{
|
|
14
|
+
backendConfig: FioriToolsProxyConfigBackend;
|
|
15
|
+
isLibrary: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBackendConfig = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const abap_deploy_config_sub_generator_1 = require("@sap-ux/abap-deploy-config-sub-generator");
|
|
6
|
+
const ui5_config_1 = require("@sap-ux/ui5-config");
|
|
7
|
+
const project_access_1 = require("@sap-ux/project-access");
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves backend configuration from either the base config (ui5.yaml) or from the options passed in.
|
|
10
|
+
*
|
|
11
|
+
* @param fs - file system editor
|
|
12
|
+
* @param options - options passed in
|
|
13
|
+
* @param launchStandaloneFromYui - flag to indicate if this generator is launched in YUI standalone
|
|
14
|
+
* @param projectRoot - project root
|
|
15
|
+
* @returns - backend configuration
|
|
16
|
+
*/
|
|
17
|
+
async function getBackendConfig(fs, options, launchStandaloneFromYui, projectRoot) {
|
|
18
|
+
let backendConfig;
|
|
19
|
+
let isLibrary = false;
|
|
20
|
+
// This is called when this generator is called as a subgenerator from
|
|
21
|
+
// application generator or application modeler launcher (i.e. this.launchDeployConfigAsSubGenerator === true).
|
|
22
|
+
if (launchStandaloneFromYui) {
|
|
23
|
+
// Launched from app modeler where deploy config might already exist
|
|
24
|
+
// need to retrieve backendConfig information.
|
|
25
|
+
const ui5Config = await ui5_config_1.UI5Config.newInstance(fs.read((0, path_1.join)(projectRoot, options.base ?? project_access_1.FileName.Ui5Yaml)));
|
|
26
|
+
backendConfig = ui5Config.getBackendConfigsFromFioriToolsProxydMiddleware()[0];
|
|
27
|
+
isLibrary = ui5Config.getType() === abap_deploy_config_sub_generator_1.DeployProjectType.Library;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
// Launched as subgenerator from app gen
|
|
31
|
+
backendConfig = {
|
|
32
|
+
destination: options.connectedSystem?.destination?.Name,
|
|
33
|
+
url: options.appGenServiceHost,
|
|
34
|
+
client: options.appGenClient,
|
|
35
|
+
scp: !!options.connectedSystem?.backendSystem?.serviceKeys || false
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return { backendConfig, isLibrary };
|
|
39
|
+
}
|
|
40
|
+
exports.getBackendConfig = getBackendConfig;
|
|
41
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Target } from '../types';
|
|
2
|
+
export declare const generatorNamespace: (bundledRootGeneratorName: string, subGenName: string) => string;
|
|
3
|
+
export declare const abapChoice: Target;
|
|
4
|
+
export declare const cfChoice: Target;
|
|
5
|
+
export declare const generatorTitle = "Deployment Configuration Generator";
|
|
6
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generatorTitle = exports.cfChoice = exports.abapChoice = exports.generatorNamespace = void 0;
|
|
4
|
+
// When deployment generator is bundled the namespacing is relative to the root generator
|
|
5
|
+
const deploy_config_generator_shared_1 = require("@sap-ux/deploy-config-generator-shared");
|
|
6
|
+
const generatorNamespace = (bundledRootGeneratorName, subGenName) => `${bundledRootGeneratorName}_${subGenName}`;
|
|
7
|
+
exports.generatorNamespace = generatorNamespace;
|
|
8
|
+
exports.abapChoice = { name: deploy_config_generator_shared_1.TargetName.ABAP, description: 'ABAP' };
|
|
9
|
+
exports.cfChoice = { name: deploy_config_generator_shared_1.TargetName.CF, description: 'Cloud Foundry' };
|
|
10
|
+
exports.generatorTitle = 'Deployment Configuration Generator';
|
|
11
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type ApiHubConfig } from '@sap-ux/cf-deploy-config-sub-generator';
|
|
2
|
+
import type { Editor } from 'mem-fs-editor';
|
|
3
|
+
/**
|
|
4
|
+
* Check if the MTA is installed.
|
|
5
|
+
*
|
|
6
|
+
* @param choice - the choice (CF or ABAP)
|
|
7
|
+
* @param projectPath - path to the project
|
|
8
|
+
* @returns - true if the MTA is installed, otherwise an error message
|
|
9
|
+
*/
|
|
10
|
+
export declare function isMTAInstalled(choice: string, projectPath: string): boolean | string;
|
|
11
|
+
/**
|
|
12
|
+
* Get the Api Hub Enterprise Key value from the node env if available.
|
|
13
|
+
*
|
|
14
|
+
* @returns The api hub enterprise config or undefined if the key is not found.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getEnvApiHubConfig(): ApiHubConfig | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the destination name for API Hub Enterprise.
|
|
19
|
+
*
|
|
20
|
+
* @param memFs - reference to a mem-fs editor
|
|
21
|
+
* @param opts -options representing the project app path and service path
|
|
22
|
+
* @param opts.appPath - path to project
|
|
23
|
+
* @param opts.servicePath - service path
|
|
24
|
+
* @param apiHubConfig - API Hub Config
|
|
25
|
+
* @returns - destination name
|
|
26
|
+
*/
|
|
27
|
+
export declare function getApiHubOptions(memFs: Editor, { appPath, servicePath }: {
|
|
28
|
+
appPath: string;
|
|
29
|
+
servicePath: string | undefined;
|
|
30
|
+
}, apiHubConfig?: ApiHubConfig): Promise<{
|
|
31
|
+
destinationName: string | undefined;
|
|
32
|
+
servicePath: string | undefined;
|
|
33
|
+
}>;
|
|
34
|
+
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getApiHubOptions = exports.getEnvApiHubConfig = exports.isMTAInstalled = void 0;
|
|
4
|
+
// Legacy package, dependent on external dependencies for async operations and no 'type: module' defined in package.json
|
|
5
|
+
const hasbin = require("hasbin");
|
|
6
|
+
const cf_deploy_config_sub_generator_1 = require("@sap-ux/cf-deploy-config-sub-generator");
|
|
7
|
+
const deploy_config_generator_shared_1 = require("@sap-ux/deploy-config-generator-shared");
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
/**
|
|
11
|
+
* Check if the MTA is installed.
|
|
12
|
+
*
|
|
13
|
+
* @param choice - the choice (CF or ABAP)
|
|
14
|
+
* @param projectPath - path to the project
|
|
15
|
+
* @returns - true if the MTA is installed, otherwise an error message
|
|
16
|
+
*/
|
|
17
|
+
function isMTAInstalled(choice, projectPath) {
|
|
18
|
+
if ((choice === 'cf' && !hasbin.sync(deploy_config_generator_shared_1.mtaExecutable)) ||
|
|
19
|
+
(choice === 'abap' && !hasbin.sync(deploy_config_generator_shared_1.mtaExecutable) && (0, fs_1.existsSync)((0, path_1.join)(projectPath, 'mta.yaml')))) {
|
|
20
|
+
deploy_config_generator_shared_1.ErrorHandler.getErrorMsgFromType(deploy_config_generator_shared_1.ERROR_TYPE.NO_MTA_BIN);
|
|
21
|
+
return ' ';
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
exports.isMTAInstalled = isMTAInstalled;
|
|
26
|
+
/**
|
|
27
|
+
* Get the Api Hub Enterprise Key value from the node env if available.
|
|
28
|
+
*
|
|
29
|
+
* @returns The api hub enterprise config or undefined if the key is not found.
|
|
30
|
+
*/
|
|
31
|
+
function getEnvApiHubConfig() {
|
|
32
|
+
const apiHubKey = process.env['API_HUB_API_KEY'];
|
|
33
|
+
const apiHubType = process.env['API_HUB_TYPE'];
|
|
34
|
+
// Legacy apps .env file will not define a type variable
|
|
35
|
+
return apiHubKey
|
|
36
|
+
? {
|
|
37
|
+
apiHubKey,
|
|
38
|
+
apiHubType: apiHubType === "API_HUB_ENTERPRISE" /* ApiHubType.apiHubEnterprise */ ? "API_HUB_ENTERPRISE" /* ApiHubType.apiHubEnterprise */ : "API_HUB" /* ApiHubType.apiHub */
|
|
39
|
+
}
|
|
40
|
+
: undefined;
|
|
41
|
+
}
|
|
42
|
+
exports.getEnvApiHubConfig = getEnvApiHubConfig;
|
|
43
|
+
/**
|
|
44
|
+
* Returns the destination name for API Hub Enterprise.
|
|
45
|
+
*
|
|
46
|
+
* @param memFs - reference to a mem-fs editor
|
|
47
|
+
* @param opts -options representing the project app path and service path
|
|
48
|
+
* @param opts.appPath - path to project
|
|
49
|
+
* @param opts.servicePath - service path
|
|
50
|
+
* @param apiHubConfig - API Hub Config
|
|
51
|
+
* @returns - destination name
|
|
52
|
+
*/
|
|
53
|
+
async function getApiHubOptions(memFs, { appPath, servicePath }, apiHubConfig) {
|
|
54
|
+
let destinationName;
|
|
55
|
+
if (apiHubConfig?.apiHubType === "API_HUB_ENTERPRISE" /* ApiHubType.apiHubEnterprise */) {
|
|
56
|
+
// appGenDestination may not have been passed in options e.g. launched from app modeler
|
|
57
|
+
if (!servicePath) {
|
|
58
|
+
// Load service path from manifest.json file
|
|
59
|
+
const manifest = await (0, cf_deploy_config_sub_generator_1.loadManifest)(memFs, appPath);
|
|
60
|
+
servicePath = manifest?.['sap.app'].dataSources?.mainService?.uri;
|
|
61
|
+
}
|
|
62
|
+
destinationName = (0, deploy_config_generator_shared_1.generateDestinationName)(cf_deploy_config_sub_generator_1.API_BUSINESS_HUB_ENTERPRISE_PREFIX, servicePath);
|
|
63
|
+
}
|
|
64
|
+
return { destinationName, servicePath };
|
|
65
|
+
}
|
|
66
|
+
exports.getApiHubOptions = getApiHubOptions;
|
|
67
|
+
//# sourceMappingURL=environment.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TOptions } from 'i18next';
|
|
2
|
+
/**
|
|
3
|
+
* Initialize i18next with the translations for this module.
|
|
4
|
+
*/
|
|
5
|
+
export declare function initI18n(): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
|
|
8
|
+
*
|
|
9
|
+
* @param key i18n key
|
|
10
|
+
* @param options additional options
|
|
11
|
+
* @returns {string} localized string stored for the given key
|
|
12
|
+
*/
|
|
13
|
+
export declare function t(key: string, options?: TOptions): string;
|
|
14
|
+
//# sourceMappingURL=i18n.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.t = exports.initI18n = void 0;
|
|
7
|
+
const i18next_1 = __importDefault(require("i18next"));
|
|
8
|
+
const deploy_config_sub_generator_i18n_json_1 = __importDefault(require("../translations/deploy-config-sub-generator.i18n.json"));
|
|
9
|
+
const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
10
|
+
const deployConfigSubGen = 'deploy-config-sub-generator';
|
|
11
|
+
/**
|
|
12
|
+
* Initialize i18next with the translations for this module.
|
|
13
|
+
*/
|
|
14
|
+
async function initI18n() {
|
|
15
|
+
await i18next_1.default.init({ lng: 'en', fallbackLng: 'en' }, () => i18next_1.default.addResourceBundle('en', deployConfigSubGen, deploy_config_sub_generator_i18n_json_1.default));
|
|
16
|
+
(0, inquirer_common_1.addi18nResourceBundle)();
|
|
17
|
+
}
|
|
18
|
+
exports.initI18n = initI18n;
|
|
19
|
+
/**
|
|
20
|
+
* Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
|
|
21
|
+
*
|
|
22
|
+
* @param key i18n key
|
|
23
|
+
* @param options additional options
|
|
24
|
+
* @returns {string} localized string stored for the given key
|
|
25
|
+
*/
|
|
26
|
+
function t(key, options) {
|
|
27
|
+
if (!options?.ns) {
|
|
28
|
+
options = Object.assign(options ?? {}, { ns: deployConfigSubGen });
|
|
29
|
+
}
|
|
30
|
+
return i18next_1.default.t(key, options);
|
|
31
|
+
}
|
|
32
|
+
exports.t = t;
|
|
33
|
+
initI18n().catch(() => {
|
|
34
|
+
// Needed for lint
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=i18n.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./config"), exports);
|
|
18
|
+
__exportStar(require("./constants"), exports);
|
|
19
|
+
__exportStar(require("./i18n"), exports);
|
|
20
|
+
__exportStar(require("./environment"), exports);
|
|
21
|
+
__exportStar(require("./targets"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Editor } from 'mem-fs-editor';
|
|
2
|
+
import type { Target } from '../types';
|
|
3
|
+
import type { ApiHubConfig } from '@sap-ux/cf-deploy-config-sub-generator';
|
|
4
|
+
/**
|
|
5
|
+
* Generate a list of targets i.e. CF | ABAP and order based on the project type i.e. library, CF, abap or CAP.
|
|
6
|
+
*
|
|
7
|
+
* @param fs - reference to a mem-fs editor
|
|
8
|
+
* @param projectPath - project path
|
|
9
|
+
* @param isCap - is the target project a CAP project
|
|
10
|
+
* @param hasMtaConfig - does the target project contain MTA Config
|
|
11
|
+
* @param apiHubConfig - API Hub configuration
|
|
12
|
+
* @param configFile - config file to read UI5 properties, default to ui5.yaml
|
|
13
|
+
* @returns a list of Target options i.e. CF | ABAP
|
|
14
|
+
*/
|
|
15
|
+
export declare function getSupportedTargets(fs: Editor, projectPath: string, isCap?: boolean, hasMtaConfig?: boolean, apiHubConfig?: ApiHubConfig, configFile?: "ui5.yaml"): Promise<Target[]>;
|
|
16
|
+
//# sourceMappingURL=targets.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSupportedTargets = void 0;
|
|
4
|
+
const abap_deploy_config_sub_generator_1 = require("@sap-ux/abap-deploy-config-sub-generator");
|
|
5
|
+
const project_access_1 = require("@sap-ux/project-access");
|
|
6
|
+
const ui5_config_1 = require("@sap-ux/ui5-config");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const constants_1 = require("./constants");
|
|
9
|
+
/**
|
|
10
|
+
* Generate a list of targets i.e. CF | ABAP and order based on the project type i.e. library, CF, abap or CAP.
|
|
11
|
+
*
|
|
12
|
+
* @param fs - reference to a mem-fs editor
|
|
13
|
+
* @param projectPath - project path
|
|
14
|
+
* @param isCap - is the target project a CAP project
|
|
15
|
+
* @param hasMtaConfig - does the target project contain MTA Config
|
|
16
|
+
* @param apiHubConfig - API Hub configuration
|
|
17
|
+
* @param configFile - config file to read UI5 properties, default to ui5.yaml
|
|
18
|
+
* @returns a list of Target options i.e. CF | ABAP
|
|
19
|
+
*/
|
|
20
|
+
async function getSupportedTargets(fs, projectPath, isCap = false, hasMtaConfig = false, apiHubConfig, configFile = project_access_1.FileName.Ui5Yaml) {
|
|
21
|
+
const isApiHubEnt = apiHubConfig?.apiHubType === "API_HUB_ENTERPRISE" /* ApiHubType.apiHubEnterprise */;
|
|
22
|
+
const isProjectExtension = fs.exists((0, path_1.join)(projectPath, '.extconfig.json'));
|
|
23
|
+
let isLibrary = false;
|
|
24
|
+
try {
|
|
25
|
+
const ui5Config = await ui5_config_1.UI5Config.newInstance(fs.read((0, path_1.join)(projectPath, configFile)));
|
|
26
|
+
isLibrary = ui5Config.getType() === abap_deploy_config_sub_generator_1.DeployProjectType.Library;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
// Ignore error, ui5.yaml may not be written yet
|
|
30
|
+
}
|
|
31
|
+
if (isApiHubEnt || isCap) {
|
|
32
|
+
return [constants_1.cfChoice];
|
|
33
|
+
}
|
|
34
|
+
else if (isLibrary || isProjectExtension) {
|
|
35
|
+
return [constants_1.abapChoice]; // Extension projects, Library and systems using Reentrance tickets for auth
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
// If there's an mta.yaml in the hierarchy, it's probably a CF project
|
|
39
|
+
// Offer that first and let the user decide
|
|
40
|
+
return hasMtaConfig ? [constants_1.cfChoice, constants_1.abapChoice] : [constants_1.abapChoice, constants_1.cfChoice];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.getSupportedTargets = getSupportedTargets;
|
|
44
|
+
//# sourceMappingURL=targets.js.map
|