@sap-ux/ui5-application-inquirer 0.19.5 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/i18n.js +15 -25
- package/dist/index.d.ts +4 -4
- package/dist/index.js +16 -25
- package/dist/prompts/index.d.ts +1 -1
- package/dist/prompts/index.js +35 -41
- package/dist/prompts/prompt-helpers.d.ts +1 -1
- package/dist/prompts/prompt-helpers.js +20 -26
- package/dist/prompts/prompts1.d.ts +2 -2
- package/dist/prompts/prompts1.js +64 -76
- package/dist/prompts/prompts2.d.ts +1 -1
- package/dist/prompts/prompts2.js +20 -26
- package/dist/prompts/validators.js +7 -10
- package/dist/types.js +2 -5
- package/package.json +10 -8
package/dist/i18n.js
CHANGED
|
@@ -1,36 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.i18n = exports.defaultProjectNumber = void 0;
|
|
7
|
-
exports.initI18nUi5AppInquirer = initI18nUi5AppInquirer;
|
|
8
|
-
exports.t = t;
|
|
9
|
-
const i18next_1 = __importDefault(require("i18next"));
|
|
10
|
-
const ui5_application_inquirer_i18n_json_1 = __importDefault(require("./translations/ui5-application-inquirer.i18n.json"));
|
|
11
|
-
const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
12
|
-
const project_input_validator_1 = require("@sap-ux/project-input-validator");
|
|
1
|
+
import i18next from 'i18next';
|
|
2
|
+
import translations from './translations/ui5-application-inquirer.i18n.json' with { type: 'json' };
|
|
3
|
+
import { addi18nResourceBundle as addi18nResourceBundleInquirerCommon } from '@sap-ux/inquirer-common';
|
|
4
|
+
import { addi18nResourceBundle as addi18nResourceBundleProjectInputValidator } from '@sap-ux/project-input-validator';
|
|
13
5
|
const ui5AppInquirerNamespace = 'ui5-application-inquirer';
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
export const defaultProjectNumber = 1;
|
|
7
|
+
export const i18n = i18next.createInstance();
|
|
16
8
|
/**
|
|
17
9
|
* Initialize i18next with the translations for this module.
|
|
18
10
|
*/
|
|
19
|
-
async function initI18nUi5AppInquirer() {
|
|
20
|
-
await
|
|
11
|
+
export async function initI18nUi5AppInquirer() {
|
|
12
|
+
await i18n.init({
|
|
21
13
|
lng: 'en',
|
|
22
14
|
fallbackLng: 'en',
|
|
23
15
|
interpolation: {
|
|
24
16
|
defaultVariables: {
|
|
25
|
-
defaultProjectNumber
|
|
17
|
+
defaultProjectNumber
|
|
26
18
|
}
|
|
27
19
|
},
|
|
28
20
|
showSupportNotice: false
|
|
29
21
|
});
|
|
30
|
-
|
|
22
|
+
i18n.addResourceBundle('en', ui5AppInquirerNamespace, translations);
|
|
31
23
|
// Add bundles on which this module depends (this is a temp workaround as the init from the imported modules is not called)
|
|
32
|
-
(
|
|
33
|
-
(
|
|
24
|
+
addi18nResourceBundleProjectInputValidator();
|
|
25
|
+
addi18nResourceBundleInquirerCommon();
|
|
34
26
|
}
|
|
35
27
|
/**
|
|
36
28
|
* Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
|
|
@@ -39,13 +31,11 @@ async function initI18nUi5AppInquirer() {
|
|
|
39
31
|
* @param options additional options
|
|
40
32
|
* @returns {string} localized string stored for the given key
|
|
41
33
|
*/
|
|
42
|
-
function t(key, options) {
|
|
34
|
+
export function t(key, options) {
|
|
43
35
|
if (!options?.ns) {
|
|
44
36
|
options = Object.assign(options ?? {}, { ns: ui5AppInquirerNamespace });
|
|
45
37
|
}
|
|
46
|
-
return
|
|
38
|
+
return i18n.t(key, options);
|
|
47
39
|
}
|
|
48
|
-
initI18nUi5AppInquirer().catch(() =>
|
|
49
|
-
// Needed for lint
|
|
50
|
-
});
|
|
40
|
+
void initI18nUi5AppInquirer().catch(() => undefined);
|
|
51
41
|
//# sourceMappingURL=i18n.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type CdsUi5PluginInfo } from '@sap-ux/project-access';
|
|
2
2
|
import type { InquirerAdapter, PromptDefaultValue } from '@sap-ux/inquirer-common';
|
|
3
|
-
import type { UI5ApplicationAnswers, UI5ApplicationPromptOptions, UI5ApplicationQuestion } from './types';
|
|
4
|
-
import { promptNames } from './types';
|
|
3
|
+
import type { UI5ApplicationAnswers, UI5ApplicationPromptOptions, UI5ApplicationQuestion } from './types.js';
|
|
4
|
+
import { promptNames } from './types.js';
|
|
5
5
|
/**
|
|
6
6
|
* Get the inquirer prompts for ui5 library inquirer.
|
|
7
7
|
*
|
|
@@ -22,6 +22,6 @@ declare function getPrompts(promptOptions?: UI5ApplicationPromptOptions, capCdsI
|
|
|
22
22
|
*/
|
|
23
23
|
declare function prompt(adapter: InquirerAdapter, promptOptions?: UI5ApplicationPromptOptions, capCdsInfo?: CdsUi5PluginInfo, isYUI?: boolean): Promise<UI5ApplicationAnswers>;
|
|
24
24
|
export { getPrompts, prompt, promptNames, type CdsUi5PluginInfo, type InquirerAdapter, type PromptDefaultValue, type UI5ApplicationAnswers, type UI5ApplicationPromptOptions };
|
|
25
|
-
export type { UI5ApplicationCommonPromptOptions } from './types';
|
|
26
|
-
export { defaultAppName } from './prompts/prompt-helpers';
|
|
25
|
+
export type { UI5ApplicationCommonPromptOptions } from './types.js';
|
|
26
|
+
export { defaultAppName } from './prompts/prompt-helpers.js';
|
|
27
27
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.getPrompts = getPrompts;
|
|
8
|
-
exports.prompt = prompt;
|
|
9
|
-
const ui5_info_1 = require("@sap-ux/ui5-info");
|
|
10
|
-
const inquirer_autocomplete_prompt_1 = __importDefault(require("inquirer-autocomplete-prompt"));
|
|
11
|
-
const isNil_1 = __importDefault(require("lodash/isNil"));
|
|
12
|
-
const prompts_1 = require("./prompts");
|
|
13
|
-
const types_1 = require("./types");
|
|
14
|
-
Object.defineProperty(exports, "promptNames", { enumerable: true, get: function () { return types_1.promptNames; } });
|
|
15
|
-
const i18n_1 = require("./i18n");
|
|
1
|
+
import { getDefaultUI5Theme, getUI5Versions } from '@sap-ux/ui5-info';
|
|
2
|
+
import autocomplete from 'inquirer-autocomplete-prompt';
|
|
3
|
+
import isNil from 'lodash/isNil.js';
|
|
4
|
+
import { getQuestions } from './prompts/index.js';
|
|
5
|
+
import { promptNames } from './types.js';
|
|
6
|
+
import { initI18nUi5AppInquirer } from './i18n.js';
|
|
16
7
|
/**
|
|
17
8
|
* Get the inquirer prompts for ui5 library inquirer.
|
|
18
9
|
*
|
|
@@ -23,15 +14,15 @@ const i18n_1 = require("./i18n");
|
|
|
23
14
|
*/
|
|
24
15
|
async function getPrompts(promptOptions, capCdsInfo, isYUI = false) {
|
|
25
16
|
// prompt texts must be loaded before the prompts are created, wait for the i18n bundle to be initialized
|
|
26
|
-
await
|
|
17
|
+
await initI18nUi5AppInquirer();
|
|
27
18
|
const filterOptions = {
|
|
28
19
|
useCache: true,
|
|
29
20
|
includeMaintained: true,
|
|
30
21
|
includeDefault: true,
|
|
31
22
|
minSupportedUI5Version: promptOptions?.ui5Version?.minUI5Version ?? undefined
|
|
32
23
|
};
|
|
33
|
-
const ui5Versions = await
|
|
34
|
-
return
|
|
24
|
+
const ui5Versions = await getUI5Versions(filterOptions);
|
|
25
|
+
return getQuestions(ui5Versions, promptOptions, capCdsInfo, isYUI);
|
|
35
26
|
}
|
|
36
27
|
/**
|
|
37
28
|
* Prompt for ui5 application writer inputs.
|
|
@@ -46,7 +37,7 @@ async function prompt(adapter, promptOptions, capCdsInfo, isYUI = false) {
|
|
|
46
37
|
const ui5AppPrompts = await getPrompts(promptOptions, capCdsInfo, isYUI);
|
|
47
38
|
if (adapter?.promptModule && promptOptions?.ui5Version?.useAutocomplete) {
|
|
48
39
|
const pm = adapter.promptModule;
|
|
49
|
-
pm.registerPrompt('autocomplete',
|
|
40
|
+
pm.registerPrompt('autocomplete', autocomplete);
|
|
50
41
|
}
|
|
51
42
|
const answers = await adapter.prompt(ui5AppPrompts);
|
|
52
43
|
// Apply default values to prompts in case they have not been executed
|
|
@@ -73,11 +64,11 @@ function applyPromptOptionDefaults(answers, ui5AppPrompts, promptOptions) {
|
|
|
73
64
|
const defaultValueOrFunc = promptOpt.default;
|
|
74
65
|
// A prompt option for ui5Theme is not supported (as its dependant on the ui5Version) and is special cased
|
|
75
66
|
// `enableTypeScript` is dependent on the CdsUi5PluginInfo and is special cased
|
|
76
|
-
if ((
|
|
77
|
-
((defaultValueOrFunc ?? promptKey ===
|
|
67
|
+
if (isNil(answers[promptKey]) &&
|
|
68
|
+
((defaultValueOrFunc ?? promptKey === promptNames.ui5Theme) || promptOpt.advancedOption === true)) {
|
|
78
69
|
let defaultValue;
|
|
79
|
-
if (promptKey ===
|
|
80
|
-
defaultValue =
|
|
70
|
+
if (promptKey === promptNames.ui5Theme) {
|
|
71
|
+
defaultValue = getDefaultUI5Theme(answers.ui5Version);
|
|
81
72
|
}
|
|
82
73
|
else if (defaultValueOrFunc !== undefined) {
|
|
83
74
|
defaultValue = getDefaultValue(answers, defaultValueOrFunc);
|
|
@@ -111,6 +102,6 @@ function getDefaultValue(answers, promptDefault) {
|
|
|
111
102
|
}
|
|
112
103
|
return undefined;
|
|
113
104
|
}
|
|
114
|
-
|
|
115
|
-
|
|
105
|
+
export { getPrompts, prompt, promptNames };
|
|
106
|
+
export { defaultAppName } from './prompts/prompt-helpers.js';
|
|
116
107
|
//# sourceMappingURL=index.js.map
|
package/dist/prompts/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { UI5ApplicationPromptOptions, UI5ApplicationQuestion } from '../types';
|
|
1
|
+
import type { UI5ApplicationPromptOptions, UI5ApplicationQuestion } from '../types.js';
|
|
2
2
|
import type { UI5Version } from '@sap-ux/ui5-info';
|
|
3
3
|
import type { CdsUi5PluginInfo } from '@sap-ux/project-access';
|
|
4
4
|
/**
|
package/dist/prompts/index.js
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
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.getQuestions = getQuestions;
|
|
7
1
|
// Nullish coalescing operator lint warnings disabled as its not appropriate in most cases where empty strings are not considered valid
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { withCondition, extendWithOptions } from '@sap-ux/inquirer-common';
|
|
5
|
+
import { getNamePrompt, getTitlePrompt, getNamespacePrompt, getDescriptionPrompt, getTargetFolderPrompt, getUI5VersionPrompt, getEnableTypeScriptPrompt, getAddDeployConfigPrompt, getAddFlpConfigPrompt, getEnableVirtualEndpoints } from './prompts1.js';
|
|
6
|
+
import { getShowAdvancedPrompt, getUI5ThemePrompt, getEnableEsLintPrompt, getSkipAnnotationsPrompt } from './prompts2.js';
|
|
7
|
+
import { validateFioriAppProjectFolder } from '@sap-ux/project-input-validator';
|
|
8
|
+
import { promptNames } from '../types.js';
|
|
9
|
+
import { hidePrompts } from './prompt-helpers.js';
|
|
16
10
|
/**
|
|
17
11
|
* Get the prompts that will provide input for UI5 application writing.
|
|
18
12
|
*
|
|
@@ -22,45 +16,45 @@ const prompt_helpers_1 = require("./prompt-helpers");
|
|
|
22
16
|
* @param [isYUI] - optional, default is `false`. Changes the behaviour of some validation since YUI does not re-validate prompts that may be inter-dependant.
|
|
23
17
|
* @returns the prompts
|
|
24
18
|
*/
|
|
25
|
-
async function getQuestions(ui5Versions, promptOptions, capCdsInfo, isYUI = false) {
|
|
19
|
+
export async function getQuestions(ui5Versions, promptOptions, capCdsInfo, isYUI = false) {
|
|
26
20
|
// Set shared defaults
|
|
27
|
-
const appName = typeof promptOptions?.[
|
|
28
|
-
? promptOptions[
|
|
29
|
-
: promptOptions?.[
|
|
30
|
-
let targetDir = typeof promptOptions?.[
|
|
31
|
-
? promptOptions[
|
|
32
|
-
: (promptOptions?.[
|
|
33
|
-
const shouldValidateFioriAppFolder = promptOptions?.[
|
|
21
|
+
const appName = typeof promptOptions?.[promptNames.name]?.default === 'string'
|
|
22
|
+
? promptOptions[promptNames.name].default
|
|
23
|
+
: promptOptions?.[promptNames.name]?.defaultValue;
|
|
24
|
+
let targetDir = typeof promptOptions?.[promptNames.targetFolder]?.default === 'string'
|
|
25
|
+
? promptOptions[promptNames.targetFolder].default // Default functions will be applied later, these replace the existing defaults
|
|
26
|
+
: (promptOptions?.[promptNames.targetFolder]?.defaultValue ?? process.cwd());
|
|
27
|
+
const shouldValidateFioriAppFolder = promptOptions?.[promptNames.targetFolder]?.validateFioriAppFolder;
|
|
34
28
|
if (shouldValidateFioriAppFolder) {
|
|
35
|
-
const isValidFolder = await
|
|
29
|
+
const isValidFolder = await validateFioriAppProjectFolder(targetDir);
|
|
36
30
|
if (isValidFolder !== true) {
|
|
37
|
-
targetDir =
|
|
31
|
+
targetDir = join(os.homedir(), 'projects');
|
|
38
32
|
}
|
|
39
33
|
}
|
|
40
34
|
const isCapProject = !!capCdsInfo;
|
|
41
35
|
const keyedPrompts = {
|
|
42
|
-
[
|
|
43
|
-
[
|
|
44
|
-
[
|
|
45
|
-
[
|
|
46
|
-
[
|
|
47
|
-
[
|
|
48
|
-
[
|
|
49
|
-
[
|
|
50
|
-
[
|
|
51
|
-
[
|
|
52
|
-
[
|
|
53
|
-
[
|
|
54
|
-
[
|
|
55
|
-
[
|
|
36
|
+
[promptNames.name]: getNamePrompt(targetDir, isCapProject, appName, isYUI),
|
|
37
|
+
[promptNames.title]: getTitlePrompt(),
|
|
38
|
+
[promptNames.namespace]: getNamespacePrompt(appName),
|
|
39
|
+
[promptNames.description]: getDescriptionPrompt(),
|
|
40
|
+
[promptNames.targetFolder]: getTargetFolderPrompt(targetDir, shouldValidateFioriAppFolder, isYUI),
|
|
41
|
+
[promptNames.ui5Version]: getUI5VersionPrompt(ui5Versions, promptOptions?.ui5Version),
|
|
42
|
+
[promptNames.enableTypeScript]: getEnableTypeScriptPrompt(),
|
|
43
|
+
[promptNames.addDeployConfig]: getAddDeployConfigPrompt(targetDir, promptOptions?.addDeployConfig, isCapProject),
|
|
44
|
+
[promptNames.addFlpConfig]: getAddFlpConfigPrompt(promptOptions?.addFlpConfig),
|
|
45
|
+
[promptNames.enableVirtualEndpoints]: getEnableVirtualEndpoints(),
|
|
46
|
+
[promptNames.showAdvanced]: getShowAdvancedPrompt(),
|
|
47
|
+
[promptNames.ui5Theme]: getUI5ThemePrompt(),
|
|
48
|
+
[promptNames.enableEslint]: getEnableEsLintPrompt(),
|
|
49
|
+
[promptNames.skipAnnotations]: getSkipAnnotationsPrompt()
|
|
56
50
|
};
|
|
57
51
|
// Hide not applicable prompts based on passed options or if this is a CAP project
|
|
58
|
-
let questions =
|
|
52
|
+
let questions = hidePrompts(keyedPrompts, promptOptions, capCdsInfo);
|
|
59
53
|
// Add an additional condition to 'advanced' prompts so they can be shown/hidden at runtime
|
|
60
54
|
applyAdvancedOption(questions, promptOptions);
|
|
61
55
|
// Apply extended `validate`, `additionalMessages` or override `default` prompt properties
|
|
62
56
|
if (promptOptions) {
|
|
63
|
-
questions =
|
|
57
|
+
questions = extendWithOptions(questions, promptOptions);
|
|
64
58
|
}
|
|
65
59
|
return questions;
|
|
66
60
|
}
|
|
@@ -71,6 +65,6 @@ async function getQuestions(ui5Versions, promptOptions, capCdsInfo, isYUI = fals
|
|
|
71
65
|
* @param promptOptions the prompt options which specify which prompts should be grouped as advanced options
|
|
72
66
|
*/
|
|
73
67
|
function applyAdvancedOption(questions, promptOptions) {
|
|
74
|
-
|
|
68
|
+
withCondition(questions.filter(({ name }) => promptOptions?.[name]?.advancedOption), (answers) => answers.showAdvanced ?? false);
|
|
75
69
|
}
|
|
76
70
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { promptNames, type UI5ApplicationPromptOptions, type UI5ApplicationQuestion } from '../types';
|
|
1
|
+
import { promptNames, type UI5ApplicationPromptOptions, type UI5ApplicationQuestion } from '../types.js';
|
|
2
2
|
import type { CdsUi5PluginInfo } from '@sap-ux/project-access';
|
|
3
3
|
/**
|
|
4
4
|
* Tests if a directory with the specified `appName` exists at the path specified by `targetPath`.
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const ui5_info_1 = require("@sap-ux/ui5-info");
|
|
8
|
-
const node_fs_1 = require("node:fs");
|
|
9
|
-
const node_path_1 = require("node:path");
|
|
10
|
-
const semver_1 = require("semver");
|
|
11
|
-
const i18n_1 = require("../i18n");
|
|
12
|
-
const types_1 = require("../types");
|
|
1
|
+
import { latestVersionString } from '@sap-ux/ui5-info';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { coerce, gte } from 'semver';
|
|
5
|
+
import { defaultProjectNumber, t } from '../i18n.js';
|
|
6
|
+
import { promptNames } from '../types.js';
|
|
13
7
|
/**
|
|
14
8
|
* Tests if a directory with the specified `appName` exists at the path specified by `targetPath`.
|
|
15
9
|
*
|
|
@@ -17,8 +11,8 @@ const types_1 = require("../types");
|
|
|
17
11
|
* @param targetPath directory path where application directory would be created
|
|
18
12
|
* @returns true, if the combined path exists otherwise false
|
|
19
13
|
*/
|
|
20
|
-
function appPathExists(appName, targetPath) {
|
|
21
|
-
return
|
|
14
|
+
export function appPathExists(appName, targetPath) {
|
|
15
|
+
return existsSync(join(targetPath ?? process.cwd(), appName.trim()));
|
|
22
16
|
}
|
|
23
17
|
/**
|
|
24
18
|
* Generate a default application name that does not exist at the specified path.
|
|
@@ -27,15 +21,15 @@ function appPathExists(appName, targetPath) {
|
|
|
27
21
|
* @param baseAppName optional base name to use instead of the default i18n name; when provided and the path already exists, an incrementing numeric suffix is appended starting at 1 (e.g. `myapp1`, `myapp2`, …)
|
|
28
22
|
* @returns a suggested application name that can be created at the specified target path
|
|
29
23
|
*/
|
|
30
|
-
function defaultAppName(targetPath, baseAppName) {
|
|
31
|
-
let defProjNum =
|
|
32
|
-
let defaultName = baseAppName ||
|
|
33
|
-
while (
|
|
24
|
+
export function defaultAppName(targetPath, baseAppName) {
|
|
25
|
+
let defProjNum = defaultProjectNumber;
|
|
26
|
+
let defaultName = baseAppName || t('prompts.name.default');
|
|
27
|
+
while (appPathExists(`${defaultName}`, targetPath)) {
|
|
34
28
|
if (baseAppName) {
|
|
35
29
|
defaultName = `${baseAppName}${defProjNum++}`;
|
|
36
30
|
}
|
|
37
31
|
else {
|
|
38
|
-
defaultName =
|
|
32
|
+
defaultName = t('prompts.name.default', { defaultProjectNumber: ++defProjNum });
|
|
39
33
|
}
|
|
40
34
|
// Dont loop forever, user will need to provide input otherwise
|
|
41
35
|
if (defProjNum > 999) {
|
|
@@ -52,13 +46,13 @@ function defaultAppName(targetPath, baseAppName) {
|
|
|
52
46
|
* @param minVersion the minimum version to test against
|
|
53
47
|
* @returns - true if the specified version is greater than or equal to the minimum version, or the version is not a coercible semver
|
|
54
48
|
*/
|
|
55
|
-
function isVersionIncluded(version, minVersion) {
|
|
49
|
+
export function isVersionIncluded(version, minVersion) {
|
|
56
50
|
// Extract a usable version, `snapshot`, `latest` etc will be ignored
|
|
57
|
-
const ui5SemVer =
|
|
51
|
+
const ui5SemVer = coerce(version);
|
|
58
52
|
if (ui5SemVer) {
|
|
59
|
-
return
|
|
53
|
+
return gte(ui5SemVer, minVersion);
|
|
60
54
|
}
|
|
61
|
-
return version ===
|
|
55
|
+
return version === latestVersionString;
|
|
62
56
|
}
|
|
63
57
|
/**
|
|
64
58
|
* Will remove prompts from the specified prompts based on prompt options
|
|
@@ -70,7 +64,7 @@ function isVersionIncluded(version, minVersion) {
|
|
|
70
64
|
* @param capCdsInfo CDS UI5 plugin information
|
|
71
65
|
* @returns the updated questions
|
|
72
66
|
*/
|
|
73
|
-
function hidePrompts(prompts, promptOptions, capCdsInfo) {
|
|
67
|
+
export function hidePrompts(prompts, promptOptions, capCdsInfo) {
|
|
74
68
|
const questions = [];
|
|
75
69
|
const isCapProject = !!capCdsInfo;
|
|
76
70
|
if (promptOptions ?? isCapProject) {
|
|
@@ -81,10 +75,10 @@ function hidePrompts(prompts, promptOptions, capCdsInfo) {
|
|
|
81
75
|
const hidePrompt = typeof promptOpt?.hide === 'function' ? promptOpt.hide(isCapProject) : (promptOpt?.hide ?? false);
|
|
82
76
|
if (!hidePrompt &&
|
|
83
77
|
// Target directory is determined by the CAP project. `enableEsLint` and `targetFolder` are not available for CAP projects
|
|
84
|
-
!([
|
|
78
|
+
!([promptNames.targetFolder, promptNames.enableEslint].includes(promptNames[promptKey]) &&
|
|
85
79
|
isCapProject) &&
|
|
86
80
|
// `enableTypeScript` and `enableVirtualEndpoints` should not be shown for certain CAP projects i.e CAP Java
|
|
87
|
-
!([
|
|
81
|
+
!([promptNames.enableTypeScript, promptNames.enableVirtualEndpoints].includes(promptNames[promptKey]) && (capCdsInfo ? !capCdsInfo?.hasMinCdsVersion : false))) {
|
|
88
82
|
questions.push(prompts[promptKey]);
|
|
89
83
|
}
|
|
90
84
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { promptNames } from '../types';
|
|
1
|
+
import { promptNames } from '../types.js';
|
|
2
2
|
import type { UI5Version } from '@sap-ux/ui5-info';
|
|
3
|
-
import type { UI5ApplicationPromptOptions, UI5ApplicationQuestion } from '../types';
|
|
3
|
+
import type { UI5ApplicationPromptOptions, UI5ApplicationQuestion } from '../types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Gets the `name` prompt.
|
|
6
6
|
*
|
package/dist/prompts/prompts1.js
CHANGED
|
@@ -1,23 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.getEnableTypeScriptPrompt = getEnableTypeScriptPrompt;
|
|
10
|
-
exports.getAddDeployConfigPrompt = getAddDeployConfigPrompt;
|
|
11
|
-
exports.getAddFlpConfigPrompt = getAddFlpConfigPrompt;
|
|
12
|
-
exports.getEnableVirtualEndpoints = getEnableVirtualEndpoints;
|
|
13
|
-
const node_path_1 = require("node:path");
|
|
14
|
-
const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
15
|
-
const project_access_1 = require("@sap-ux/project-access");
|
|
16
|
-
const project_input_validator_1 = require("@sap-ux/project-input-validator");
|
|
17
|
-
const i18n_1 = require("../i18n");
|
|
18
|
-
const types_1 = require("../types");
|
|
19
|
-
const prompt_helpers_1 = require("./prompt-helpers");
|
|
20
|
-
const validators_1 = require("./validators");
|
|
1
|
+
import { isAbsolute, resolve } from 'node:path';
|
|
2
|
+
import { searchChoices, ui5VersionsGrouped, getDefaultUI5VersionChoice } from '@sap-ux/inquirer-common';
|
|
3
|
+
import { getMtaPath } from '@sap-ux/project-access';
|
|
4
|
+
import { validateModuleName, validateNamespace, validateFioriAppTargetFolder } from '@sap-ux/project-input-validator';
|
|
5
|
+
import { t } from '../i18n.js';
|
|
6
|
+
import { promptNames } from '../types.js';
|
|
7
|
+
import { defaultAppName } from './prompt-helpers.js';
|
|
8
|
+
import { validateAppName } from './validators.js';
|
|
21
9
|
/**
|
|
22
10
|
* Gets the `name` prompt.
|
|
23
11
|
*
|
|
@@ -27,27 +15,27 @@ const validators_1 = require("./validators");
|
|
|
27
15
|
* @param isYUI If true, do not use `targetFolder` value when validating the name for existence, since YUI will not re-validate when `targetFolder` is updated.
|
|
28
16
|
* @returns the UI5 application `name` prompt
|
|
29
17
|
*/
|
|
30
|
-
function getNamePrompt(targetDir, isCapProject, appName, isYUI) {
|
|
18
|
+
export function getNamePrompt(targetDir, isCapProject, appName, isYUI) {
|
|
31
19
|
return {
|
|
32
20
|
type: 'input',
|
|
33
21
|
guiOptions: {
|
|
34
22
|
applyDefaultWhenDirty: true,
|
|
35
|
-
hint:
|
|
23
|
+
hint: t('prompts.name.tooltip'),
|
|
36
24
|
mandatory: true,
|
|
37
25
|
breadcrumb: true
|
|
38
26
|
},
|
|
39
|
-
name:
|
|
40
|
-
message:
|
|
41
|
-
default: (answers) => answers.name || appName ||
|
|
27
|
+
name: promptNames.name,
|
|
28
|
+
message: t('prompts.name.message'),
|
|
29
|
+
default: (answers) => answers.name || appName || defaultAppName(targetDir),
|
|
42
30
|
validate: (name, answers) => {
|
|
43
31
|
// In a CLI context, we need to validate the name within the default target folder - that it does not already exist.
|
|
44
32
|
// Also as CAP project folder is set and can't be updated, we need to validate the app name doest not already exist within the CAP project.
|
|
45
33
|
const shouldValidateNamePath = !isYUI || isCapProject;
|
|
46
34
|
if (shouldValidateNamePath) {
|
|
47
|
-
return
|
|
35
|
+
return validateAppName(name, answers.targetFolder || targetDir);
|
|
48
36
|
}
|
|
49
37
|
else {
|
|
50
|
-
return
|
|
38
|
+
return validateModuleName(name);
|
|
51
39
|
}
|
|
52
40
|
}
|
|
53
41
|
};
|
|
@@ -57,16 +45,16 @@ function getNamePrompt(targetDir, isCapProject, appName, isYUI) {
|
|
|
57
45
|
*
|
|
58
46
|
* @returns the `title` prompt
|
|
59
47
|
*/
|
|
60
|
-
function getTitlePrompt() {
|
|
48
|
+
export function getTitlePrompt() {
|
|
61
49
|
return {
|
|
62
50
|
type: 'input',
|
|
63
51
|
guiOptions: {
|
|
64
|
-
hint:
|
|
52
|
+
hint: t('prompts.title.tooltip'),
|
|
65
53
|
breadcrumb: true
|
|
66
54
|
},
|
|
67
|
-
name:
|
|
68
|
-
message:
|
|
69
|
-
default: (answers) => answers.title ||
|
|
55
|
+
name: promptNames.title,
|
|
56
|
+
message: t('prompts.title.message'),
|
|
57
|
+
default: (answers) => answers.title || t('prompts.title.default')
|
|
70
58
|
};
|
|
71
59
|
}
|
|
72
60
|
/**
|
|
@@ -75,19 +63,19 @@ function getTitlePrompt() {
|
|
|
75
63
|
* @param appName the application is used as part of namespace validation to determine max combined length
|
|
76
64
|
* @returns the `namespace` prompt
|
|
77
65
|
*/
|
|
78
|
-
function getNamespacePrompt(appName) {
|
|
66
|
+
export function getNamespacePrompt(appName) {
|
|
79
67
|
return {
|
|
80
68
|
type: 'input',
|
|
81
69
|
guiOptions: {
|
|
82
|
-
hint:
|
|
70
|
+
hint: t('prompts.namespace.tooltip'),
|
|
83
71
|
breadcrumb: true
|
|
84
72
|
},
|
|
85
|
-
name:
|
|
86
|
-
message:
|
|
73
|
+
name: promptNames.namespace,
|
|
74
|
+
message: t('prompts.namespace.message'),
|
|
87
75
|
default: (answers) => answers.namespace ?? '',
|
|
88
76
|
validate: (namespace, answers) => {
|
|
89
77
|
if (namespace) {
|
|
90
|
-
return
|
|
78
|
+
return validateNamespace(namespace, answers.name || appName);
|
|
91
79
|
}
|
|
92
80
|
return true;
|
|
93
81
|
}
|
|
@@ -98,16 +86,16 @@ function getNamespacePrompt(appName) {
|
|
|
98
86
|
*
|
|
99
87
|
* @returns the `description` prompt
|
|
100
88
|
*/
|
|
101
|
-
function getDescriptionPrompt() {
|
|
89
|
+
export function getDescriptionPrompt() {
|
|
102
90
|
return {
|
|
103
91
|
type: 'input',
|
|
104
|
-
name:
|
|
92
|
+
name: promptNames.description,
|
|
105
93
|
guiOptions: {
|
|
106
|
-
hint:
|
|
94
|
+
hint: t('prompts.description.tooltip'),
|
|
107
95
|
breadcrumb: true
|
|
108
96
|
},
|
|
109
|
-
message:
|
|
110
|
-
default: (answers) => answers.description ||
|
|
97
|
+
message: t('prompts.description.message'),
|
|
98
|
+
default: (answers) => answers.description || t('prompts.description.default')
|
|
111
99
|
};
|
|
112
100
|
}
|
|
113
101
|
/**
|
|
@@ -118,27 +106,27 @@ function getDescriptionPrompt() {
|
|
|
118
106
|
* @param isYUI if true, input is returned unchanged (YUI folder browser already supplies absolute paths)
|
|
119
107
|
* @returns the `targetFolder` prompt
|
|
120
108
|
*/
|
|
121
|
-
function getTargetFolderPrompt(targetDir, validateFioriAppFolder, isYUI) {
|
|
109
|
+
export function getTargetFolderPrompt(targetDir, validateFioriAppFolder, isYUI) {
|
|
122
110
|
return {
|
|
123
111
|
type: 'input',
|
|
124
|
-
name:
|
|
125
|
-
message:
|
|
112
|
+
name: promptNames.targetFolder,
|
|
113
|
+
message: t('prompts.targetFolder.message'),
|
|
126
114
|
guiType: 'folder-browser',
|
|
127
115
|
guiOptions: {
|
|
128
116
|
applyDefaultWhenDirty: true,
|
|
129
117
|
mandatory: true,
|
|
130
|
-
breadcrumb:
|
|
118
|
+
breadcrumb: t('prompts.targetFolder.breadcrumb')
|
|
131
119
|
},
|
|
132
120
|
default: (answers) => answers.targetFolder || targetDir,
|
|
133
121
|
filter: (input) => {
|
|
134
122
|
if (isYUI) {
|
|
135
123
|
return input;
|
|
136
124
|
}
|
|
137
|
-
return input && !
|
|
125
|
+
return input && !isAbsolute(input) ? resolve(input) : input;
|
|
138
126
|
},
|
|
139
127
|
validate: async (target, { name = '' }) => {
|
|
140
128
|
if (name.length > 2) {
|
|
141
|
-
return await
|
|
129
|
+
return await validateFioriAppTargetFolder(target, name, validateFioriAppFolder);
|
|
142
130
|
}
|
|
143
131
|
return false;
|
|
144
132
|
}
|
|
@@ -152,21 +140,21 @@ function getTargetFolderPrompt(targetDir, validateFioriAppFolder, isYUI) {
|
|
|
152
140
|
* @param ui5VersionPromptOptions UI5 version prompt options
|
|
153
141
|
* @returns the `ui5Version` prompt
|
|
154
142
|
*/
|
|
155
|
-
function getUI5VersionPrompt(ui5Versions = [], ui5VersionPromptOptions) {
|
|
143
|
+
export function getUI5VersionPrompt(ui5Versions = [], ui5VersionPromptOptions) {
|
|
156
144
|
// Set the default to be closest to the passed value or the default as defined by ui5 version service
|
|
157
|
-
const defaultChoice =
|
|
158
|
-
const ui5VersionChoices =
|
|
145
|
+
const defaultChoice = getDefaultUI5VersionChoice(ui5Versions, ui5VersionPromptOptions?.defaultChoice);
|
|
146
|
+
const ui5VersionChoices = ui5VersionsGrouped(ui5Versions, ui5VersionPromptOptions?.includeSeparators, defaultChoice, !!ui5VersionPromptOptions?.defaultChoice && ui5VersionPromptOptions.defaultChoice.value === defaultChoice?.value);
|
|
159
147
|
return {
|
|
160
148
|
when: () => !!ui5VersionChoices,
|
|
161
149
|
type: ui5VersionPromptOptions?.useAutocomplete ? 'autocomplete' : 'list',
|
|
162
|
-
name:
|
|
150
|
+
name: promptNames.ui5Version,
|
|
163
151
|
guiOptions: {
|
|
164
|
-
hint:
|
|
165
|
-
breadcrumb:
|
|
152
|
+
hint: t('prompts.ui5Version.tooltip'),
|
|
153
|
+
breadcrumb: t('prompts.ui5Version.breadcrumb')
|
|
166
154
|
},
|
|
167
155
|
choices: () => ui5VersionChoices,
|
|
168
|
-
source: (prevAnswers, input) =>
|
|
169
|
-
message:
|
|
156
|
+
source: (prevAnswers, input) => searchChoices(input, ui5VersionChoices),
|
|
157
|
+
message: t('prompts.ui5Version.message'),
|
|
170
158
|
default: () => {
|
|
171
159
|
return defaultChoice?.value;
|
|
172
160
|
}
|
|
@@ -177,11 +165,11 @@ function getUI5VersionPrompt(ui5Versions = [], ui5VersionPromptOptions) {
|
|
|
177
165
|
*
|
|
178
166
|
* @returns The `enableTypeScript` prompt
|
|
179
167
|
*/
|
|
180
|
-
function getEnableTypeScriptPrompt() {
|
|
168
|
+
export function getEnableTypeScriptPrompt() {
|
|
181
169
|
return {
|
|
182
170
|
type: 'confirm',
|
|
183
|
-
name:
|
|
184
|
-
message:
|
|
171
|
+
name: promptNames.enableTypeScript,
|
|
172
|
+
message: t('prompts.enableTypeScript.message'),
|
|
185
173
|
default: false,
|
|
186
174
|
guiOptions: {
|
|
187
175
|
breadcrumb: true
|
|
@@ -196,31 +184,31 @@ function getEnableTypeScriptPrompt() {
|
|
|
196
184
|
* @param isCapProject is this a CAP project
|
|
197
185
|
* @returns the `addDeployConfig` prompt
|
|
198
186
|
*/
|
|
199
|
-
function getAddDeployConfigPrompt(targetDir, addDeployConfigOptions, isCapProject = false) {
|
|
187
|
+
export function getAddDeployConfigPrompt(targetDir, addDeployConfigOptions, isCapProject = false) {
|
|
200
188
|
let mtaPath; // cache mta path discovery
|
|
201
189
|
return {
|
|
202
190
|
type: 'confirm',
|
|
203
|
-
name:
|
|
191
|
+
name: promptNames.addDeployConfig,
|
|
204
192
|
guiOptions: {
|
|
205
|
-
breadcrumb:
|
|
193
|
+
breadcrumb: t('prompts.addDeployConfig.breadcrumb')
|
|
206
194
|
},
|
|
207
195
|
// If the target directory is a CAP project then only offer `addDeployConfig (addToMta)` if an mta file is found
|
|
208
196
|
when: async (answers) => {
|
|
209
|
-
mtaPath = (await
|
|
197
|
+
mtaPath = (await getMtaPath(answers?.targetFolder || targetDir))?.mtaPath;
|
|
210
198
|
return !!(mtaPath && isCapProject) || !isCapProject;
|
|
211
199
|
},
|
|
212
200
|
message: () => {
|
|
213
201
|
return mtaPath
|
|
214
|
-
?
|
|
202
|
+
? t('prompts.addDeployConfig.mtaMessage', {
|
|
215
203
|
path: mtaPath,
|
|
216
204
|
interpolation: { escapeValue: false }
|
|
217
205
|
})
|
|
218
|
-
:
|
|
206
|
+
: t('prompts.addDeployConfig.message');
|
|
219
207
|
},
|
|
220
208
|
default: async () => !!mtaPath,
|
|
221
209
|
validate: (addDeployConfig) => {
|
|
222
210
|
if (typeof addDeployConfigOptions?.validatorCallback === 'function') {
|
|
223
|
-
addDeployConfigOptions.validatorCallback(addDeployConfig,
|
|
211
|
+
addDeployConfigOptions.validatorCallback(addDeployConfig, promptNames.addDeployConfig);
|
|
224
212
|
}
|
|
225
213
|
return true;
|
|
226
214
|
}
|
|
@@ -232,18 +220,18 @@ function getAddDeployConfigPrompt(targetDir, addDeployConfigOptions, isCapProjec
|
|
|
232
220
|
* @param addFlpConfigOptions the
|
|
233
221
|
* @returns The `addFlpConfig` prompt
|
|
234
222
|
*/
|
|
235
|
-
function getAddFlpConfigPrompt(addFlpConfigOptions) {
|
|
223
|
+
export function getAddFlpConfigPrompt(addFlpConfigOptions) {
|
|
236
224
|
return {
|
|
237
225
|
type: 'confirm',
|
|
238
|
-
name:
|
|
226
|
+
name: promptNames.addFlpConfig,
|
|
239
227
|
guiOptions: {
|
|
240
|
-
breadcrumb:
|
|
228
|
+
breadcrumb: t('prompts.addFlpConfig.breadcrumb')
|
|
241
229
|
},
|
|
242
|
-
message: () =>
|
|
230
|
+
message: () => t('prompts.addFlpConfig.message'),
|
|
243
231
|
default: false,
|
|
244
232
|
validate: (addFlpConfig) => {
|
|
245
233
|
if (typeof addFlpConfigOptions?.validatorCallback === 'function') {
|
|
246
|
-
addFlpConfigOptions.validatorCallback(addFlpConfig,
|
|
234
|
+
addFlpConfigOptions.validatorCallback(addFlpConfig, promptNames.addFlpConfig);
|
|
247
235
|
}
|
|
248
236
|
return true;
|
|
249
237
|
}
|
|
@@ -254,15 +242,15 @@ function getAddFlpConfigPrompt(addFlpConfigOptions) {
|
|
|
254
242
|
*
|
|
255
243
|
* @returns the `enableVirtualEndpoints` prompt
|
|
256
244
|
*/
|
|
257
|
-
function getEnableVirtualEndpoints() {
|
|
245
|
+
export function getEnableVirtualEndpoints() {
|
|
258
246
|
return {
|
|
259
247
|
type: 'confirm',
|
|
260
|
-
name:
|
|
248
|
+
name: promptNames.enableVirtualEndpoints,
|
|
261
249
|
guiOptions: {
|
|
262
|
-
hint:
|
|
263
|
-
breadcrumb:
|
|
250
|
+
hint: t('prompts.enableVirtualEndpoints.tooltip'),
|
|
251
|
+
breadcrumb: t('prompts.enableVirtualEndpoints.breadcrumb')
|
|
264
252
|
},
|
|
265
|
-
message: () =>
|
|
253
|
+
message: () => t('prompts.enableVirtualEndpoints.message'),
|
|
266
254
|
default: true
|
|
267
255
|
};
|
|
268
256
|
}
|
package/dist/prompts/prompts2.js
CHANGED
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
exports.getEnableEsLintPrompt = getEnableEsLintPrompt;
|
|
6
|
-
exports.getSkipAnnotationsPrompt = getSkipAnnotationsPrompt;
|
|
7
|
-
const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
8
|
-
const ui5_info_1 = require("@sap-ux/ui5-info");
|
|
9
|
-
const i18n_1 = require("../i18n");
|
|
10
|
-
const types_1 = require("../types");
|
|
1
|
+
import { getUI5ThemesChoices } from '@sap-ux/inquirer-common';
|
|
2
|
+
import { defaultVersion, getDefaultUI5Theme } from '@sap-ux/ui5-info';
|
|
3
|
+
import { t } from '../i18n.js';
|
|
4
|
+
import { promptNames } from '../types.js';
|
|
11
5
|
/**
|
|
12
6
|
* Get the `showAdvanced` prompt.
|
|
13
7
|
*
|
|
14
8
|
* @returns The `showAdvanced` prompt
|
|
15
9
|
*/
|
|
16
|
-
function getShowAdvancedPrompt() {
|
|
10
|
+
export function getShowAdvancedPrompt() {
|
|
17
11
|
return {
|
|
18
12
|
type: 'confirm',
|
|
19
13
|
name: 'showAdvanced',
|
|
20
|
-
message:
|
|
14
|
+
message: t('prompts.showAdvanced.message'),
|
|
21
15
|
guiOptions: {
|
|
22
|
-
hint:
|
|
16
|
+
hint: t('prompts.showAdvanced.tooltip')
|
|
23
17
|
},
|
|
24
18
|
default: false
|
|
25
19
|
};
|
|
@@ -29,18 +23,18 @@ function getShowAdvancedPrompt() {
|
|
|
29
23
|
*
|
|
30
24
|
* @returns The `ui5Theme` prompt
|
|
31
25
|
*/
|
|
32
|
-
function getUI5ThemePrompt() {
|
|
26
|
+
export function getUI5ThemePrompt() {
|
|
33
27
|
return {
|
|
34
28
|
type: 'list',
|
|
35
|
-
name:
|
|
36
|
-
message:
|
|
29
|
+
name: promptNames.ui5Theme,
|
|
30
|
+
message: t('prompts.ui5Theme.message'),
|
|
37
31
|
guiOptions: {
|
|
38
32
|
applyDefaultWhenDirty: true,
|
|
39
33
|
breadcrumb: true
|
|
40
34
|
},
|
|
41
|
-
choices: async ({ ui5Version =
|
|
35
|
+
choices: async ({ ui5Version = defaultVersion }) => await getUI5ThemesChoices(ui5Version),
|
|
42
36
|
default: ({ ui5Theme, ui5Version }) => {
|
|
43
|
-
ui5Theme ??=
|
|
37
|
+
ui5Theme ??= getDefaultUI5Theme(ui5Version);
|
|
44
38
|
return ui5Theme;
|
|
45
39
|
}
|
|
46
40
|
};
|
|
@@ -50,14 +44,14 @@ function getUI5ThemePrompt() {
|
|
|
50
44
|
*
|
|
51
45
|
* @returns The `enableEslint` prompt
|
|
52
46
|
*/
|
|
53
|
-
function getEnableEsLintPrompt() {
|
|
47
|
+
export function getEnableEsLintPrompt() {
|
|
54
48
|
return {
|
|
55
49
|
type: 'confirm',
|
|
56
|
-
name:
|
|
57
|
-
message:
|
|
50
|
+
name: promptNames.enableEslint,
|
|
51
|
+
message: t('prompts.enableEslint.message'),
|
|
58
52
|
default: true,
|
|
59
53
|
guiOptions: {
|
|
60
|
-
breadcrumb:
|
|
54
|
+
breadcrumb: t('prompts.enableEslint.breadcrumb')
|
|
61
55
|
}
|
|
62
56
|
};
|
|
63
57
|
}
|
|
@@ -67,14 +61,14 @@ function getEnableEsLintPrompt() {
|
|
|
67
61
|
*
|
|
68
62
|
* @returns The `skipAnnotations` prompt
|
|
69
63
|
*/
|
|
70
|
-
function getSkipAnnotationsPrompt() {
|
|
64
|
+
export function getSkipAnnotationsPrompt() {
|
|
71
65
|
return {
|
|
72
66
|
type: 'confirm',
|
|
73
|
-
name:
|
|
74
|
-
message:
|
|
67
|
+
name: promptNames.skipAnnotations,
|
|
68
|
+
message: t('prompts.skipAnnotations.message'),
|
|
75
69
|
default: false,
|
|
76
70
|
guiOptions: {
|
|
77
|
-
breadcrumb:
|
|
71
|
+
breadcrumb: t('prompts.skipAnnotations.breadcrumb')
|
|
78
72
|
}
|
|
79
73
|
};
|
|
80
74
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const project_input_validator_1 = require("@sap-ux/project-input-validator");
|
|
5
|
-
const prompt_helpers_1 = require("./prompt-helpers");
|
|
6
|
-
const i18n_1 = require("../i18n");
|
|
1
|
+
import { validateModuleName } from '@sap-ux/project-input-validator';
|
|
2
|
+
import { appPathExists } from './prompt-helpers.js';
|
|
3
|
+
import { t } from '../i18n.js';
|
|
7
4
|
/**
|
|
8
5
|
* Returns true (valid) if the specified projectName is a valid module name
|
|
9
6
|
* and if an application folder (directory) at the specified path does not exist.
|
|
@@ -12,14 +9,14 @@ const i18n_1 = require("../i18n");
|
|
|
12
9
|
* @param targetDir the directory path where the directory named `appName` would be created
|
|
13
10
|
* @returns true, if valid, or a string message indicating the reason why the input is invalid
|
|
14
11
|
*/
|
|
15
|
-
function validateAppName(appName, targetDir) {
|
|
16
|
-
const nameValidationResult =
|
|
12
|
+
export function validateAppName(appName, targetDir) {
|
|
13
|
+
const nameValidationResult = validateModuleName(appName);
|
|
17
14
|
if (nameValidationResult !== true) {
|
|
18
15
|
return nameValidationResult;
|
|
19
16
|
}
|
|
20
|
-
const existing =
|
|
17
|
+
const existing = appPathExists(appName, targetDir);
|
|
21
18
|
if (existing) {
|
|
22
|
-
return
|
|
19
|
+
return t('validators.appFolderExistsAtPath', { path: targetDir });
|
|
23
20
|
}
|
|
24
21
|
return true;
|
|
25
22
|
}
|
package/dist/types.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.promptNames = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Enumeration of prompt names used by UI5ApplicationInquirerPromptOptions
|
|
6
3
|
*
|
|
7
4
|
*/
|
|
8
|
-
var promptNames;
|
|
5
|
+
export var promptNames;
|
|
9
6
|
(function (promptNames) {
|
|
10
7
|
/**
|
|
11
8
|
* Application name
|
|
@@ -39,5 +36,5 @@ var promptNames;
|
|
|
39
36
|
promptNames["enableTypeScript"] = "enableTypeScript";
|
|
40
37
|
promptNames["enableVirtualEndpoints"] = "enableVirtualEndpoints";
|
|
41
38
|
promptNames["showAdvanced"] = "showAdvanced";
|
|
42
|
-
})(promptNames || (
|
|
39
|
+
})(promptNames || (promptNames = {}));
|
|
43
40
|
//# sourceMappingURL=types.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/ui5-application-inquirer",
|
|
3
3
|
"description": "Prompts module that can prompt users for inputs required for UI5 application writing",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.0",
|
|
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+label%3Abug+label%3Aui5-application-inquirer"
|
|
12
12
|
},
|
|
13
|
+
"type": "module",
|
|
13
14
|
"license": "Apache-2.0",
|
|
14
15
|
"main": "dist/index.js",
|
|
15
16
|
"files": [
|
|
@@ -23,19 +24,20 @@
|
|
|
23
24
|
"inquirer-autocomplete-prompt": "2.0.1",
|
|
24
25
|
"lodash": "4.18.1",
|
|
25
26
|
"semver": "7.7.4",
|
|
26
|
-
"@sap-ux/inquirer-common": "0.
|
|
27
|
-
"@sap-ux/project-access": "
|
|
28
|
-
"@sap-ux/project-input-validator": "0.
|
|
29
|
-
"@sap-ux/ui5-info": "0.
|
|
27
|
+
"@sap-ux/inquirer-common": "1.0.0",
|
|
28
|
+
"@sap-ux/project-access": "2.0.0",
|
|
29
|
+
"@sap-ux/project-input-validator": "1.0.0",
|
|
30
|
+
"@sap-ux/ui5-info": "1.0.0"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
33
|
+
"@jest/globals": "30.3.0",
|
|
32
34
|
"@sap-devx/yeoman-ui-types": "1.25.0",
|
|
33
35
|
"@types/inquirer-autocomplete-prompt": "2.0.2",
|
|
34
36
|
"@types/inquirer": "8.2.6",
|
|
35
37
|
"@types/lodash": "4.17.24",
|
|
36
38
|
"@types/semver": "7.7.1",
|
|
37
39
|
"inquirer": "8.2.7",
|
|
38
|
-
"@sap-ux/cap-config-writer": "0.
|
|
40
|
+
"@sap-ux/cap-config-writer": "1.0.0"
|
|
39
41
|
},
|
|
40
42
|
"engines": {
|
|
41
43
|
"node": ">=22.x"
|
|
@@ -46,8 +48,8 @@
|
|
|
46
48
|
"watch": "tsc --watch",
|
|
47
49
|
"lint": "eslint",
|
|
48
50
|
"lint:fix": "eslint --fix",
|
|
49
|
-
"test": "jest --ci --forceExit --detectOpenHandles --colors",
|
|
50
|
-
"test-u": "jest --ci --forceExit --detectOpenHandles --colors -u",
|
|
51
|
+
"test": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors",
|
|
52
|
+
"test-u": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors -u",
|
|
51
53
|
"link": "pnpm link --global",
|
|
52
54
|
"unlink": "pnpm unlink --global"
|
|
53
55
|
}
|