@sap-ux/cf-deploy-config-inquirer 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 +64 -0
- package/dist/i18n.d.ts +15 -0
- package/dist/i18n.js +43 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +48 -0
- package/dist/logger-helper.d.ts +20 -0
- package/dist/logger-helper.js +27 -0
- package/dist/prompts/index.d.ts +2 -0
- package/dist/prompts/index.js +18 -0
- package/dist/prompts/prompt-helpers.d.ts +16 -0
- package/dist/prompts/prompt-helpers.js +50 -0
- package/dist/prompts/prompts.d.ts +11 -0
- package/dist/prompts/prompts.js +145 -0
- package/dist/prompts/validators.d.ts +12 -0
- package/dist/prompts/validators.js +50 -0
- package/dist/translations/cf-deploy-config-inquirer.i18n.json +22 -0
- package/dist/types.d.ts +81 -0
- package/dist/types.js +16 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# @sap-ux/cf-deploy-config-inquirer
|
|
2
|
+
|
|
3
|
+
Prompts module that can provide prompts for Cloud Foundry deployment config writer.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
Npm
|
|
7
|
+
`npm install --save @sap-ux/cf-deploy-config-inquirer`
|
|
8
|
+
|
|
9
|
+
Yarn
|
|
10
|
+
`yarn add @sap-ux/cf-deploy-config-inquirer`
|
|
11
|
+
|
|
12
|
+
Pnpm
|
|
13
|
+
`pnpm add @sap-ux/cf-deploy-config-inquirer`
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## Explainer
|
|
17
|
+
|
|
18
|
+
Prompts may be retrieved using `getPrompts` and then executed in another prompting module that supports `inquirer` type prompts.
|
|
19
|
+
|
|
20
|
+
`getPrompts` is provided to allow consumers to access cloud foundry prompts. There may be cases where these can be transformed to support other prompting frameworks. Most prompt configuration is possible via `CfDeployConfigPromptOptions` and calling `prompt`. This is the recommended approach.
|
|
21
|
+
|
|
22
|
+
Configurability of prompts is entirely controlled using the `CfDeployConfigPromptOptions` parameter.
|
|
23
|
+
|
|
24
|
+
See [Inquirer.js](https://www.npmjs.com/package/inquirer) for valid default properties.
|
|
25
|
+
|
|
26
|
+
### Cloud Foundry Deploy Config Inquirer usage example:
|
|
27
|
+
|
|
28
|
+
```TypeScript
|
|
29
|
+
import type { InquirerAdapter } from '@sap-ux/inquirer-common';
|
|
30
|
+
import type { CfDeployConfigAnswers, CfDeployConfigPromptOptions } from '@sap-ux/cf-deploy-config-inquirer';
|
|
31
|
+
import { prompt as cfDeployConfigPrompt, promptNames } from '@sap-ux/cf-deploy-config-inquirer';
|
|
32
|
+
|
|
33
|
+
const promptOptions = {
|
|
34
|
+
[promptNames.destinationName]: {
|
|
35
|
+
defaultValue: 'defaultDestination',
|
|
36
|
+
hint: false
|
|
37
|
+
},
|
|
38
|
+
[promptNames.addManagedAppRouter]: true,
|
|
39
|
+
[promptNames.overwrite]: true
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Pass an Inquirer prompt function https://www.npmjs.com/package/inquirer#methods
|
|
44
|
+
*/
|
|
45
|
+
const inqAdaptor = {
|
|
46
|
+
prompt: this.prompt.bind(this) // the inquirer prompting function, here we use the generators reference
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const cfDeployConfigAnswers: CfDeployConfigAnswers = await cfDeployConfigPrompt(
|
|
50
|
+
inqAdaptor as InquirerAdapter,
|
|
51
|
+
promptOpts
|
|
52
|
+
);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
Read [License](./LICENSE).
|
|
58
|
+
|
|
59
|
+
## Keywords
|
|
60
|
+
SAP UI5 Application
|
|
61
|
+
Inquirer
|
|
62
|
+
Prompting
|
|
63
|
+
Generator
|
|
64
|
+
Deployment
|
package/dist/i18n.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TOptions } from 'i18next';
|
|
2
|
+
export declare const defaultProjectNumber = 1;
|
|
3
|
+
/**
|
|
4
|
+
* Initialize i18next with the translations for this module.
|
|
5
|
+
*/
|
|
6
|
+
export declare function initI18nCfDeployConfigInquirer(): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
|
|
9
|
+
*
|
|
10
|
+
* @param key i18n key
|
|
11
|
+
* @param options additional options
|
|
12
|
+
* @returns {string} localized string stored for the given key
|
|
13
|
+
*/
|
|
14
|
+
export declare function t(key: string, options?: TOptions): string;
|
|
15
|
+
//# sourceMappingURL=i18n.d.ts.map
|
package/dist/i18n.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.defaultProjectNumber = void 0;
|
|
7
|
+
exports.initI18nCfDeployConfigInquirer = initI18nCfDeployConfigInquirer;
|
|
8
|
+
exports.t = t;
|
|
9
|
+
const i18next_1 = __importDefault(require("i18next"));
|
|
10
|
+
const cf_deploy_config_inquirer_i18n_json_1 = __importDefault(require("./translations/cf-deploy-config-inquirer.i18n.json"));
|
|
11
|
+
const cfInquirerNamespace = 'cf-deploy-config-inquirer';
|
|
12
|
+
exports.defaultProjectNumber = 1;
|
|
13
|
+
/**
|
|
14
|
+
* Initialize i18next with the translations for this module.
|
|
15
|
+
*/
|
|
16
|
+
async function initI18nCfDeployConfigInquirer() {
|
|
17
|
+
await i18next_1.default.init({
|
|
18
|
+
lng: 'en',
|
|
19
|
+
fallbackLng: 'en',
|
|
20
|
+
interpolation: {
|
|
21
|
+
defaultVariables: {
|
|
22
|
+
defaultProjectNumber: exports.defaultProjectNumber
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}, () => i18next_1.default.addResourceBundle('en', cfInquirerNamespace, cf_deploy_config_inquirer_i18n_json_1.default));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
|
|
29
|
+
*
|
|
30
|
+
* @param key i18n key
|
|
31
|
+
* @param options additional options
|
|
32
|
+
* @returns {string} localized string stored for the given key
|
|
33
|
+
*/
|
|
34
|
+
function t(key, options) {
|
|
35
|
+
if (!options?.ns) {
|
|
36
|
+
options = Object.assign(options ?? {}, { ns: cfInquirerNamespace });
|
|
37
|
+
}
|
|
38
|
+
return i18next_1.default.t(key, options);
|
|
39
|
+
}
|
|
40
|
+
initI18nCfDeployConfigInquirer().catch(() => {
|
|
41
|
+
// Needed for lint
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=i18n.js.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CfDeployConfigPromptOptions, CfDeployConfigQuestions, CfSystemChoice, CfDeployConfigAnswers } from './types';
|
|
2
|
+
import { promptNames } from './types';
|
|
3
|
+
import type { InquirerAdapter } from '@sap-ux/inquirer-common';
|
|
4
|
+
import type { Logger } from '@sap-ux/logger';
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves Cloud Foundry deployment configuration prompts.
|
|
7
|
+
*
|
|
8
|
+
* This function returns a list of cf deployment questions based on the provided application root and prompt options.
|
|
9
|
+
*
|
|
10
|
+
* @param {CfDeployConfigPromptOptions} promptOptions - The configuration options for prompting during cf target deployment.
|
|
11
|
+
* @param logger - The logger instance to use for logging.
|
|
12
|
+
* @returns {Promise<CfDeployConfigQuestions[]>} A promise that resolves to an array of questions for cf target prompting.
|
|
13
|
+
*/
|
|
14
|
+
declare function getPrompts(promptOptions: CfDeployConfigPromptOptions, logger?: Logger): Promise<CfDeployConfigQuestions[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Prompt for cf inquirer inputs.
|
|
17
|
+
*
|
|
18
|
+
* @param adapter - optionally provide references to a calling inquirer instance, this supports integration to Yeoman generators, for example
|
|
19
|
+
* @param promptOptions - options that can control some of the prompt behavior. See {@link CfDeployConfigPromptOptions} for details
|
|
20
|
+
* @param logger - logger instance to use for logging
|
|
21
|
+
* @returns the prompt answers
|
|
22
|
+
*/
|
|
23
|
+
declare function prompt(adapter: InquirerAdapter, promptOptions: CfDeployConfigPromptOptions, logger?: Logger): Promise<CfDeployConfigAnswers>;
|
|
24
|
+
export { getPrompts, CfDeployConfigPromptOptions, CfSystemChoice, promptNames, prompt };
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
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.promptNames = void 0;
|
|
7
|
+
exports.getPrompts = getPrompts;
|
|
8
|
+
exports.prompt = prompt;
|
|
9
|
+
const prompts_1 = require("./prompts");
|
|
10
|
+
const types_1 = require("./types");
|
|
11
|
+
Object.defineProperty(exports, "promptNames", { enumerable: true, get: function () { return types_1.promptNames; } });
|
|
12
|
+
const i18n_1 = require("./i18n");
|
|
13
|
+
const inquirer_autocomplete_prompt_1 = __importDefault(require("inquirer-autocomplete-prompt"));
|
|
14
|
+
const logger_helper_1 = __importDefault(require("./logger-helper"));
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves Cloud Foundry deployment configuration prompts.
|
|
17
|
+
*
|
|
18
|
+
* This function returns a list of cf deployment questions based on the provided application root and prompt options.
|
|
19
|
+
*
|
|
20
|
+
* @param {CfDeployConfigPromptOptions} promptOptions - The configuration options for prompting during cf target deployment.
|
|
21
|
+
* @param logger - The logger instance to use for logging.
|
|
22
|
+
* @returns {Promise<CfDeployConfigQuestions[]>} A promise that resolves to an array of questions for cf target prompting.
|
|
23
|
+
*/
|
|
24
|
+
async function getPrompts(promptOptions, logger) {
|
|
25
|
+
if (logger) {
|
|
26
|
+
logger_helper_1.default.logger = logger;
|
|
27
|
+
}
|
|
28
|
+
await (0, i18n_1.initI18nCfDeployConfigInquirer)();
|
|
29
|
+
return (0, prompts_1.getQuestions)(promptOptions, logger_helper_1.default.logger);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Prompt for cf inquirer inputs.
|
|
33
|
+
*
|
|
34
|
+
* @param adapter - optionally provide references to a calling inquirer instance, this supports integration to Yeoman generators, for example
|
|
35
|
+
* @param promptOptions - options that can control some of the prompt behavior. See {@link CfDeployConfigPromptOptions} for details
|
|
36
|
+
* @param logger - logger instance to use for logging
|
|
37
|
+
* @returns the prompt answers
|
|
38
|
+
*/
|
|
39
|
+
async function prompt(adapter, promptOptions, logger) {
|
|
40
|
+
const cfPrompts = await getPrompts(promptOptions, logger);
|
|
41
|
+
if (adapter?.promptModule && promptOptions[types_1.promptNames.destinationName]?.useAutocomplete) {
|
|
42
|
+
const pm = adapter.promptModule;
|
|
43
|
+
pm.registerPrompt('autocomplete', inquirer_autocomplete_prompt_1.default);
|
|
44
|
+
}
|
|
45
|
+
const answers = await adapter.prompt(cfPrompts);
|
|
46
|
+
return answers;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Logger } from '@sap-ux/logger';
|
|
2
|
+
/**
|
|
3
|
+
* Static logger prevents passing of logger references through all functions, as this is a cross-cutting concern.
|
|
4
|
+
*/
|
|
5
|
+
export default class LoggerHelper {
|
|
6
|
+
private static _logger;
|
|
7
|
+
/**
|
|
8
|
+
* Get the logger.
|
|
9
|
+
*
|
|
10
|
+
* @returns the logger
|
|
11
|
+
*/
|
|
12
|
+
static get logger(): Logger;
|
|
13
|
+
/**
|
|
14
|
+
* Set the logger.
|
|
15
|
+
*
|
|
16
|
+
* @param value the logger to set
|
|
17
|
+
*/
|
|
18
|
+
static set logger(value: Logger);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=logger-helper.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const logger_1 = require("@sap-ux/logger");
|
|
4
|
+
/**
|
|
5
|
+
* Static logger prevents passing of logger references through all functions, as this is a cross-cutting concern.
|
|
6
|
+
*/
|
|
7
|
+
class LoggerHelper {
|
|
8
|
+
static _logger = new logger_1.ToolsLogger({ logPrefix: '@sap-ux/cf-deploy-config-inquirer' });
|
|
9
|
+
/**
|
|
10
|
+
* Get the logger.
|
|
11
|
+
*
|
|
12
|
+
* @returns the logger
|
|
13
|
+
*/
|
|
14
|
+
static get logger() {
|
|
15
|
+
return LoggerHelper._logger;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Set the logger.
|
|
19
|
+
*
|
|
20
|
+
* @param value the logger to set
|
|
21
|
+
*/
|
|
22
|
+
static set logger(value) {
|
|
23
|
+
LoggerHelper._logger = value;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.default = LoggerHelper;
|
|
27
|
+
//# sourceMappingURL=logger-helper.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
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("./prompts"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CfSystemChoice } from '../types';
|
|
2
|
+
import { type Destinations } from '@sap-ux/btp-utils';
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves an array of Cloud Foundry system choices.
|
|
5
|
+
*
|
|
6
|
+
* @param {Destinations} [destinations] - Optional destinations object retrieved from BTP.
|
|
7
|
+
* @returns {Promise<CfSystemChoice[]>} - List of system choices formatted for selection prompts.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getCfSystemChoices(destinations?: Destinations): Promise<CfSystemChoice[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves and caches the list of available BTP destinations if running in BAS.
|
|
12
|
+
*
|
|
13
|
+
* @returns {Promise<Destinations | undefined>} - A promise resolving to a list of destinations or undefined if not in BAS.
|
|
14
|
+
*/
|
|
15
|
+
export declare function fetchBTPDestinations(): Promise<Destinations | undefined>;
|
|
16
|
+
//# sourceMappingURL=prompt-helpers.d.ts.map
|
|
@@ -0,0 +1,50 @@
|
|
|
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.getCfSystemChoices = getCfSystemChoices;
|
|
7
|
+
exports.fetchBTPDestinations = fetchBTPDestinations;
|
|
8
|
+
const btp_utils_1 = require("@sap-ux/btp-utils");
|
|
9
|
+
const logger_helper_1 = __importDefault(require("../logger-helper"));
|
|
10
|
+
const i18n_1 = require("../i18n");
|
|
11
|
+
/**
|
|
12
|
+
* Generates a sorted list of Cloud Foundry system destination choices from provided destinations.
|
|
13
|
+
*
|
|
14
|
+
* @param {Destinations} [destinations] - Object containing destination details retrieved from BTP.
|
|
15
|
+
* @returns {CfSystemChoice[]} - Array of destination choices formatted for selection prompts.
|
|
16
|
+
*/
|
|
17
|
+
function createDestinationChoices(destinations = {}) {
|
|
18
|
+
return Object.values(destinations)
|
|
19
|
+
.filter((destination) => destination && typeof destination.Name === 'string' && typeof destination.Host === 'string')
|
|
20
|
+
.sort((a, b) => a.Name.localeCompare(b.Name, undefined, { numeric: true, caseFirst: 'lower' }))
|
|
21
|
+
.map((destination) => ({
|
|
22
|
+
name: `${(0, btp_utils_1.getDisplayName)(destination) ?? 'Unknown'} - ${destination.Host}`,
|
|
23
|
+
value: destination.Name,
|
|
24
|
+
scp: (0, btp_utils_1.isAbapEnvironmentOnBtp)(destination) || false,
|
|
25
|
+
url: destination.Host
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Retrieves an array of Cloud Foundry system choices.
|
|
30
|
+
*
|
|
31
|
+
* @param {Destinations} [destinations] - Optional destinations object retrieved from BTP.
|
|
32
|
+
* @returns {Promise<CfSystemChoice[]>} - List of system choices formatted for selection prompts.
|
|
33
|
+
*/
|
|
34
|
+
async function getCfSystemChoices(destinations) {
|
|
35
|
+
return destinations ? createDestinationChoices(destinations) : [];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves and caches the list of available BTP destinations if running in BAS.
|
|
39
|
+
*
|
|
40
|
+
* @returns {Promise<Destinations | undefined>} - A promise resolving to a list of destinations or undefined if not in BAS.
|
|
41
|
+
*/
|
|
42
|
+
async function fetchBTPDestinations() {
|
|
43
|
+
if ((0, btp_utils_1.isAppStudio)()) {
|
|
44
|
+
const destinations = await (0, btp_utils_1.listDestinations)();
|
|
45
|
+
return destinations;
|
|
46
|
+
}
|
|
47
|
+
logger_helper_1.default.logger.warn((0, i18n_1.t)('warning.btpDestinationListWarning'));
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=prompt-helpers.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CfDeployConfigPromptOptions, CfDeployConfigQuestions } from '../types';
|
|
2
|
+
import type { Logger } from '@sap-ux/logger';
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves a list of deployment questions based on the application root and prompt options.
|
|
5
|
+
*
|
|
6
|
+
* @param {CfDeployConfigPromptOptions} promptOptions - The configuration options for prompting during cf target deployment.
|
|
7
|
+
* @param {Logger} [log] - The logger instance to use for logging.
|
|
8
|
+
* @returns {CfDeployConfigQuestions[]} Returns an array of questions related to cf deployment configuration.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getQuestions(promptOptions: CfDeployConfigPromptOptions, log?: Logger): Promise<CfDeployConfigQuestions[]>;
|
|
11
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1,145 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.getQuestions = getQuestions;
|
|
27
|
+
const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
28
|
+
const i18n_1 = require("../i18n");
|
|
29
|
+
const types_1 = require("../types");
|
|
30
|
+
const validators = __importStar(require("./validators"));
|
|
31
|
+
const btp_utils_1 = require("@sap-ux/btp-utils");
|
|
32
|
+
const prompt_helpers_1 = require("./prompt-helpers");
|
|
33
|
+
/**
|
|
34
|
+
* Retrieves the prompt configuration for selecting a Cloud Foundry destination name.
|
|
35
|
+
*
|
|
36
|
+
* This function generates a prompt that allows users to specify a destination name. The prompt can be rendered as a list or
|
|
37
|
+
* an input field depending on the provided options. If the environment supports
|
|
38
|
+
* autocomplete, it can provide suggestions based on existing destinations.
|
|
39
|
+
*
|
|
40
|
+
* @param {DestinationNamePromptOptions} destinationOptions - The options for configuring
|
|
41
|
+
* the destination name prompt.
|
|
42
|
+
* @param {string} destinationOptions.destination - The Cloud Foundry destination name
|
|
43
|
+
* to be used.
|
|
44
|
+
* @param {string} destinationOptions.defaultValue - The default destination value for CF.
|
|
45
|
+
* @param {boolean} [destinationOptions.addDestinationHintMessage] - A flag to indicate
|
|
46
|
+
* whether to show a hint for the destination name.
|
|
47
|
+
* @param {CfSystemChoice[]} [destinationOptions.additionalChoiceList] - Additional choices
|
|
48
|
+
* available for the destination. If additional choices are provided and the environment is VsCode, the prompt
|
|
49
|
+
* type will render as a list instead of an input field.
|
|
50
|
+
* @param {boolean} [destinationOptions.useAutocomplete] - A flag to indicate whether
|
|
51
|
+
* to use an autocomplete feature for the destination name input.
|
|
52
|
+
* @param {boolean} [destinationOptions.addBTPDestinationList] - A flag to indicate whether to include BTP destination choices.
|
|
53
|
+
* @returns {Promise<CfDeployConfigQuestions>} A promise that resolves to the configuration
|
|
54
|
+
* of the prompt, which includes the question and any related options for rendering
|
|
55
|
+
* the prompt in a user interface.
|
|
56
|
+
*/
|
|
57
|
+
async function getDestinationNamePrompt(destinationOptions) {
|
|
58
|
+
const { hint = false, additionalChoiceList = [], defaultValue, useAutocomplete = false, addBTPDestinationList = true } = destinationOptions;
|
|
59
|
+
const isBAS = (0, btp_utils_1.isAppStudio)();
|
|
60
|
+
const destinations = addBTPDestinationList ? await (0, prompt_helpers_1.fetchBTPDestinations)() : {};
|
|
61
|
+
const destinationList = [...additionalChoiceList, ...(await (0, prompt_helpers_1.getCfSystemChoices)(destinations))];
|
|
62
|
+
// If BAS is used or additional choices are provided, the prompt should be a list
|
|
63
|
+
// If VsCode is used and additional choices are not provided, the prompt should be an input field
|
|
64
|
+
// If VsCode is used and additional choices are provided, the prompt should be a list
|
|
65
|
+
const basePromptType = isBAS || additionalChoiceList.length ? 'list' : 'input';
|
|
66
|
+
// If autocomplete is enabled and there are destination choices, the prompt should be an autocomplete
|
|
67
|
+
const promptType = useAutocomplete && destinationList.length ? 'autocomplete' : basePromptType;
|
|
68
|
+
return {
|
|
69
|
+
guiOptions: {
|
|
70
|
+
mandatory: !isBAS,
|
|
71
|
+
breadcrumb: (0, i18n_1.t)('prompts.destinationNameMessage')
|
|
72
|
+
},
|
|
73
|
+
type: promptType,
|
|
74
|
+
default: () => defaultValue,
|
|
75
|
+
name: types_1.promptNames.destinationName,
|
|
76
|
+
message: () => (hint ? (0, i18n_1.t)('prompts.directBindingDestinationHint') : (0, i18n_1.t)('prompts.destinationNameMessage')),
|
|
77
|
+
validate: (destination) => {
|
|
78
|
+
return validators.validateDestinationQuestion(destination, !destination && isBAS);
|
|
79
|
+
},
|
|
80
|
+
source: (prevAnswers, input) => (0, inquirer_common_1.searchChoices)(input, destinationList),
|
|
81
|
+
choices: () => destinationList
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Creates a prompt for managing application router during cf deployment.
|
|
86
|
+
*
|
|
87
|
+
*
|
|
88
|
+
* This function returns a confirmation question that asks whether to add a managed application router
|
|
89
|
+
* to the cf deployment. The prompt only appears if no mta file is found.
|
|
90
|
+
*
|
|
91
|
+
* @returns {ConfirmQuestion<CfDeployConfigAnswers>} Returns a confirmation question object for configuring the application router.
|
|
92
|
+
*/
|
|
93
|
+
function getAddManagedRouterPrompt() {
|
|
94
|
+
return {
|
|
95
|
+
type: 'confirm',
|
|
96
|
+
name: types_1.promptNames.addManagedAppRouter,
|
|
97
|
+
guiOptions: {
|
|
98
|
+
breadcrumb: (0, i18n_1.t)('prompts.addApplicationRouterBreadcrumbMessage')
|
|
99
|
+
},
|
|
100
|
+
message: () => (0, i18n_1.t)('prompts.generateManagedApplicationToRouterMessage'),
|
|
101
|
+
default: () => true
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
*
|
|
106
|
+
* @returns A confirmation question object which overwrites destination.
|
|
107
|
+
*/
|
|
108
|
+
function getOverwritePrompt() {
|
|
109
|
+
return {
|
|
110
|
+
type: 'confirm',
|
|
111
|
+
name: types_1.promptNames.overwrite,
|
|
112
|
+
guiOptions: {
|
|
113
|
+
hint: (0, i18n_1.t)('prompts.overwriteHintMessage')
|
|
114
|
+
},
|
|
115
|
+
default: () => {
|
|
116
|
+
return true;
|
|
117
|
+
},
|
|
118
|
+
message: () => (0, i18n_1.t)('prompts.overwriteMessage')
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Retrieves a list of deployment questions based on the application root and prompt options.
|
|
123
|
+
*
|
|
124
|
+
* @param {CfDeployConfigPromptOptions} promptOptions - The configuration options for prompting during cf target deployment.
|
|
125
|
+
* @param {Logger} [log] - The logger instance to use for logging.
|
|
126
|
+
* @returns {CfDeployConfigQuestions[]} Returns an array of questions related to cf deployment configuration.
|
|
127
|
+
*/
|
|
128
|
+
async function getQuestions(promptOptions, log) {
|
|
129
|
+
const destinationOptions = promptOptions[types_1.promptNames.destinationName];
|
|
130
|
+
const addOverwriteQuestion = promptOptions[types_1.promptNames.overwrite] ?? false;
|
|
131
|
+
const addManagedAppRouter = promptOptions[types_1.promptNames.addManagedAppRouter] ?? false;
|
|
132
|
+
const questions = [];
|
|
133
|
+
// Collect questions into an array
|
|
134
|
+
questions.push(await getDestinationNamePrompt(destinationOptions));
|
|
135
|
+
if (addManagedAppRouter) {
|
|
136
|
+
log?.info((0, i18n_1.t)('info.addManagedAppRouter'));
|
|
137
|
+
questions.push(getAddManagedRouterPrompt());
|
|
138
|
+
}
|
|
139
|
+
if (addOverwriteQuestion) {
|
|
140
|
+
log?.info((0, i18n_1.t)('info.overwriteDestination'));
|
|
141
|
+
questions.push(getOverwritePrompt());
|
|
142
|
+
}
|
|
143
|
+
return questions;
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CfSystemChoice } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Validates the destination name or input string. If `allowEmptyChoice` is true,
|
|
4
|
+
* the validation will pass immediately. Otherwise, the input will be validated
|
|
5
|
+
* against rules (non-empty, valid characters, length check).
|
|
6
|
+
*
|
|
7
|
+
* @param {string} input - The destination name or input string to validate.
|
|
8
|
+
* @param {boolean} allowEmptyChoice - Whether to allow an empty input as a valid choice.
|
|
9
|
+
* @returns {boolean|string} `true` if the input is valid or empty choices are allowed, otherwise an error message.
|
|
10
|
+
*/
|
|
11
|
+
export declare function validateDestinationQuestion(input: string | CfSystemChoice, allowEmptyChoice?: boolean): boolean | string;
|
|
12
|
+
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateDestinationQuestion = validateDestinationQuestion;
|
|
4
|
+
const i18n_1 = require("../i18n");
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param input The input string to check for emptiness.
|
|
8
|
+
* @returns returns true if the input string is not empty, otherwise false.
|
|
9
|
+
*/
|
|
10
|
+
function isNotEmpty(input) {
|
|
11
|
+
return !!input?.trim();
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Validates the input string for the following:
|
|
15
|
+
* - It must not be empty after trimming whitespace.
|
|
16
|
+
* - It must contain only alphanumeric characters, underscores, or dashes.
|
|
17
|
+
* - It must not exceed 200 characters.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} input - The input string to validate.
|
|
20
|
+
* @returns {boolean|string} `true` if the input is valid, otherwise an error message.
|
|
21
|
+
*/
|
|
22
|
+
function validateInput(input) {
|
|
23
|
+
if (!isNotEmpty(input)) {
|
|
24
|
+
return (0, i18n_1.t)('errors.emptyDestinationNameError');
|
|
25
|
+
}
|
|
26
|
+
const result = /^[a-z0-9_-]+$/i.test(input);
|
|
27
|
+
if (!result) {
|
|
28
|
+
return (0, i18n_1.t)('errors.destinationNameError');
|
|
29
|
+
}
|
|
30
|
+
if (input.length > 200) {
|
|
31
|
+
return (0, i18n_1.t)('errors.destinationNameLengthError');
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Validates the destination name or input string. If `allowEmptyChoice` is true,
|
|
37
|
+
* the validation will pass immediately. Otherwise, the input will be validated
|
|
38
|
+
* against rules (non-empty, valid characters, length check).
|
|
39
|
+
*
|
|
40
|
+
* @param {string} input - The destination name or input string to validate.
|
|
41
|
+
* @param {boolean} allowEmptyChoice - Whether to allow an empty input as a valid choice.
|
|
42
|
+
* @returns {boolean|string} `true` if the input is valid or empty choices are allowed, otherwise an error message.
|
|
43
|
+
*/
|
|
44
|
+
function validateDestinationQuestion(input, allowEmptyChoice = false) {
|
|
45
|
+
if (allowEmptyChoice) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
return typeof input === 'string' ? validateInput(input) : true;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=validators.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"prompts": {
|
|
3
|
+
"destinationNameMessage": "Destination name",
|
|
4
|
+
"addApplicationRouterBreadcrumbMessage": "Add to Router",
|
|
5
|
+
"generateManagedApplicationToRouterMessage": "Add application to managed application router?",
|
|
6
|
+
"directBindingDestinationHint": "Destination name - The app router is configured to use direct service binding",
|
|
7
|
+
"overwriteMessage": "Editing the deployment configuration will overwrite existing configuration, are you sure you want to continue?",
|
|
8
|
+
"overwriteHintMessage": "Deployment config will abort if you choose no. Click Finish to abort."
|
|
9
|
+
},
|
|
10
|
+
"errors": {
|
|
11
|
+
"emptyDestinationNameError": "You must provide a destination name in order to continue.",
|
|
12
|
+
"destinationNameError": "The destination name must only contain letters, digits, dashes and underscores.",
|
|
13
|
+
"destinationNameLengthError": "Destination name cannot contain more than 200 characters"
|
|
14
|
+
},
|
|
15
|
+
"warning": {
|
|
16
|
+
"btpDestinationListWarning": "BTP destinations are only retrieved on BAS"
|
|
17
|
+
},
|
|
18
|
+
"info": {
|
|
19
|
+
"addManagedAppRouter": "Add managed application router is enabled",
|
|
20
|
+
"overwriteDestination": "Overwriting destination is enabled"
|
|
21
|
+
}
|
|
22
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { YUIQuestion } from '@sap-ux/inquirer-common';
|
|
2
|
+
import type { AutocompleteQuestionOptions } from 'inquirer-autocomplete-prompt';
|
|
3
|
+
/**
|
|
4
|
+
* Enum defining prompt names for Cloud Foundry (CF) deployment configuration.
|
|
5
|
+
*/
|
|
6
|
+
export declare enum promptNames {
|
|
7
|
+
/** The prompt to specify the destination name for CF deployment. */
|
|
8
|
+
destinationName = "destinationName",
|
|
9
|
+
/** The prompt to specify if a managed app router should be added to the deployment. */
|
|
10
|
+
addManagedAppRouter = "addManagedAppRouter",
|
|
11
|
+
/** The prompt for confirming destination overwrite. */
|
|
12
|
+
overwrite = "overwriteDestinationName"
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Configuration options for the 'destinationName' prompt used in deployment settings.
|
|
16
|
+
*/
|
|
17
|
+
export type DestinationNamePromptOptions = {
|
|
18
|
+
/** Default value to suggest for the destination name. */
|
|
19
|
+
defaultValue: string;
|
|
20
|
+
/** Flag to indicate if a hint message should be shown to indicate the app router is configured.*/
|
|
21
|
+
hint?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* List of additional destination choices available for the prompt.
|
|
24
|
+
* - In BAS environments, this list will be appended to BTP destination options.
|
|
25
|
+
* - If `additionalChoiceList` is provided and the environment is VS Code,
|
|
26
|
+
* the prompt will render as a list, allowing users to select from the provided choices instead of input.
|
|
27
|
+
*/
|
|
28
|
+
additionalChoiceList?: CfSystemChoice[];
|
|
29
|
+
/**
|
|
30
|
+
* Indicates BTP destination list choices should be available for the prompt.
|
|
31
|
+
* If `addBTPDestinationList` is set to true, the prompt will include BTP destination choices else it will not.
|
|
32
|
+
* By default, this is set to true.
|
|
33
|
+
*/
|
|
34
|
+
addBTPDestinationList?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Flag to indicate if the destination prompt should use auto completion
|
|
37
|
+
*/
|
|
38
|
+
useAutocomplete?: boolean;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Defines options for boolean-type prompts in CF deployment configuration.
|
|
42
|
+
*/
|
|
43
|
+
type booleanValuePromptOptions = Record<promptNames.overwrite, boolean> & Record<promptNames.addManagedAppRouter, boolean>;
|
|
44
|
+
/**
|
|
45
|
+
* Defines options for string-type prompts in CF deployment configuration.
|
|
46
|
+
*/
|
|
47
|
+
type stringValuePromptOptions = Record<promptNames.destinationName, DestinationNamePromptOptions>;
|
|
48
|
+
/**
|
|
49
|
+
* Configuration options for CF deployment prompts.
|
|
50
|
+
*/
|
|
51
|
+
export type CfDeployConfigPromptOptions = Partial<stringValuePromptOptions & booleanValuePromptOptions>;
|
|
52
|
+
/**
|
|
53
|
+
* Represents a question in the CF deployment configuration.
|
|
54
|
+
* Extends `YUIQuestion` with optional autocomplete functionality.
|
|
55
|
+
*/
|
|
56
|
+
export type CfDeployConfigQuestions = YUIQuestion<CfDeployConfigAnswers> & Partial<Pick<AutocompleteQuestionOptions, 'source'>>;
|
|
57
|
+
/**
|
|
58
|
+
* User responses for CF deployment configuration.
|
|
59
|
+
*/
|
|
60
|
+
export interface CfDeployConfigAnswers {
|
|
61
|
+
/** The selected Cloud Foundry destination. */
|
|
62
|
+
destinationName?: string;
|
|
63
|
+
/** Indicates whether the user opted to include a managed application router. */
|
|
64
|
+
addManagedRouter?: boolean;
|
|
65
|
+
overwrite?: boolean;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Interface for selectable system choices within prompts.
|
|
69
|
+
*/
|
|
70
|
+
export interface CfSystemChoice {
|
|
71
|
+
/** Display name of the system choice. */
|
|
72
|
+
name: string;
|
|
73
|
+
/** Value associated with the system choice. */
|
|
74
|
+
value: string;
|
|
75
|
+
/** Flag indicating if the system choice is an scp destination. */
|
|
76
|
+
scp: boolean;
|
|
77
|
+
/** URL associated with the system choice. */
|
|
78
|
+
url: string;
|
|
79
|
+
}
|
|
80
|
+
export {};
|
|
81
|
+
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.promptNames = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Enum defining prompt names for Cloud Foundry (CF) deployment configuration.
|
|
6
|
+
*/
|
|
7
|
+
var promptNames;
|
|
8
|
+
(function (promptNames) {
|
|
9
|
+
/** The prompt to specify the destination name for CF deployment. */
|
|
10
|
+
promptNames["destinationName"] = "destinationName";
|
|
11
|
+
/** The prompt to specify if a managed app router should be added to the deployment. */
|
|
12
|
+
promptNames["addManagedAppRouter"] = "addManagedAppRouter";
|
|
13
|
+
/** The prompt for confirming destination overwrite. */
|
|
14
|
+
promptNames["overwrite"] = "overwriteDestinationName";
|
|
15
|
+
})(promptNames || (exports.promptNames = promptNames = {}));
|
|
16
|
+
//# sourceMappingURL=types.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sap-ux/cf-deploy-config-inquirer",
|
|
3
|
+
"description": "Prompts module that can provide prompts for cf deployment config writer",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
8
|
+
"directory": "packages/cf-deploy-config-inquirer"
|
|
9
|
+
},
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Acf-deploy-config-inquirer"
|
|
12
|
+
},
|
|
13
|
+
"license": "Apache-2.0",
|
|
14
|
+
"main": "dist/index.js",
|
|
15
|
+
"files": [
|
|
16
|
+
"LICENSE",
|
|
17
|
+
"dist",
|
|
18
|
+
"!dist/*.map",
|
|
19
|
+
"!dist/**/*.map"
|
|
20
|
+
],
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"i18next": "23.5.1",
|
|
23
|
+
"inquirer-autocomplete-prompt": "2.0.1",
|
|
24
|
+
"@sap-ux/inquirer-common": "0.4.6",
|
|
25
|
+
"@sap-ux/btp-utils": "0.15.2",
|
|
26
|
+
"@sap-ux/logger": "0.6.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@sap-devx/yeoman-ui-types": "1.14.4",
|
|
30
|
+
"@types/inquirer-autocomplete-prompt": "2.0.1",
|
|
31
|
+
"@types/inquirer": "8.2.6",
|
|
32
|
+
"inquirer": "8.2.6"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=18.x"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsc --build",
|
|
39
|
+
"clean": "rimraf --glob dist test/test-output coverage *.tsbuildinfo",
|
|
40
|
+
"watch": "tsc --watch",
|
|
41
|
+
"lint": "eslint . --ext .ts",
|
|
42
|
+
"lint:fix": "eslint . --ext .ts --fix",
|
|
43
|
+
"test": "jest --ci --forceExit --detectOpenHandles --colors --passWithNoTests",
|
|
44
|
+
"test-u": "jest --ci --forceExit --detectOpenHandles --colors -u",
|
|
45
|
+
"link": "pnpm link --global",
|
|
46
|
+
"unlink": "pnpm unlink --global"
|
|
47
|
+
}
|
|
48
|
+
}
|