@sap-ux/ui5-library-inquirer 0.2.15 → 0.3.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 +4 -15
- package/dist/index.js +19 -32
- package/dist/prompts/prompts.js +5 -6
- package/package.json +4 -4
package/dist/i18n.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -19,10 +10,8 @@ const ui5LibI18nNamespace = 'ui5-library-inquirer';
|
|
|
19
10
|
/**
|
|
20
11
|
* Initialize i18next with the translations for this module.
|
|
21
12
|
*/
|
|
22
|
-
function initI18n() {
|
|
23
|
-
|
|
24
|
-
yield i18next_1.default.init({ lng: 'en', fallbackLng: 'en' }, () => i18next_1.default.addResourceBundle('en', ui5LibI18nNamespace, ui5_library_inquirer_i18n_json_1.default));
|
|
25
|
-
});
|
|
13
|
+
async function initI18n() {
|
|
14
|
+
await i18next_1.default.init({ lng: 'en', fallbackLng: 'en' }, () => i18next_1.default.addResourceBundle('en', ui5LibI18nNamespace, ui5_library_inquirer_i18n_json_1.default));
|
|
26
15
|
}
|
|
27
16
|
exports.initI18n = initI18n;
|
|
28
17
|
/**
|
|
@@ -33,8 +22,8 @@ exports.initI18n = initI18n;
|
|
|
33
22
|
* @returns {string} localized string stored for the given key
|
|
34
23
|
*/
|
|
35
24
|
function t(key, options) {
|
|
36
|
-
if (!
|
|
37
|
-
options = Object.assign(options
|
|
25
|
+
if (!options?.ns) {
|
|
26
|
+
options = Object.assign(options ?? {}, { ns: ui5LibI18nNamespace });
|
|
38
27
|
}
|
|
39
28
|
return i18next_1.default.t(key, options);
|
|
40
29
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -23,20 +14,18 @@ const inquirer_autocomplete_prompt_1 = __importDefault(require("inquirer-autocom
|
|
|
23
14
|
* @param promptOptions See {@link UI5LibraryPromptOptions} for details
|
|
24
15
|
* @returns the prompts used to provide input for ui5 library generation
|
|
25
16
|
*/
|
|
26
|
-
function getPrompts(promptOptions) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return (0, prompts_1.getQuestions)(ui5Versions, ui5LibPromptInputs);
|
|
39
|
-
});
|
|
17
|
+
async function getPrompts(promptOptions) {
|
|
18
|
+
const filterOptions = {
|
|
19
|
+
useCache: true,
|
|
20
|
+
includeMaintained: true
|
|
21
|
+
};
|
|
22
|
+
const ui5Versions = await (0, ui5_info_1.getUI5Versions)(filterOptions);
|
|
23
|
+
const ui5LibPromptInputs = {
|
|
24
|
+
targetFolder: promptOptions?.targetFolder,
|
|
25
|
+
includeSeparators: promptOptions?.includeSeparators,
|
|
26
|
+
useAutocomplete: promptOptions?.useAutocomplete
|
|
27
|
+
};
|
|
28
|
+
return (0, prompts_1.getQuestions)(ui5Versions, ui5LibPromptInputs);
|
|
40
29
|
}
|
|
41
30
|
exports.getPrompts = getPrompts;
|
|
42
31
|
/**
|
|
@@ -46,15 +35,13 @@ exports.getPrompts = getPrompts;
|
|
|
46
35
|
* @param adapter - optionally provide references to a calling inquirer instance, this supports integration to Yeoman generators, for example
|
|
47
36
|
* @returns the prompt answers
|
|
48
37
|
*/
|
|
49
|
-
function prompt(promptOptions, adapter) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return adapter ? adapter.prompt(ui5LibPrompts) : inquirer_1.default.prompt(ui5LibPrompts);
|
|
57
|
-
});
|
|
38
|
+
async function prompt(promptOptions, adapter) {
|
|
39
|
+
const ui5LibPrompts = await exports.getPrompts(promptOptions);
|
|
40
|
+
const pm = adapter ? adapter.promptModule : inquirer_1.default;
|
|
41
|
+
if (pm && promptOptions?.useAutocomplete) {
|
|
42
|
+
pm.registerPrompt('autocomplete', inquirer_autocomplete_prompt_1.default);
|
|
43
|
+
}
|
|
44
|
+
return adapter ? adapter.prompt(ui5LibPrompts) : inquirer_1.default.prompt(ui5LibPrompts);
|
|
58
45
|
}
|
|
59
46
|
exports.prompt = prompt;
|
|
60
47
|
//# sourceMappingURL=index.js.map
|
package/dist/prompts/prompts.js
CHANGED
|
@@ -12,8 +12,7 @@ const i18n_1 = require("../i18n");
|
|
|
12
12
|
* @returns the prompts
|
|
13
13
|
*/
|
|
14
14
|
function getQuestions(ui5Versions, options) {
|
|
15
|
-
|
|
16
|
-
const ui5VersionChoices = (0, inquirer_common_1.ui5VersionsGrouped)(ui5Versions, options === null || options === void 0 ? void 0 : options.includeSeparators);
|
|
15
|
+
const ui5VersionChoices = (0, inquirer_common_1.ui5VersionsGrouped)(ui5Versions, options?.includeSeparators);
|
|
17
16
|
return [
|
|
18
17
|
{
|
|
19
18
|
type: 'input',
|
|
@@ -34,7 +33,7 @@ function getQuestions(ui5Versions, options) {
|
|
|
34
33
|
mandatory: true,
|
|
35
34
|
breadcrumb: true
|
|
36
35
|
},
|
|
37
|
-
validate: (namespace, answers) => (0, project_input_validator_1.validateNamespace)(namespace, answers
|
|
36
|
+
validate: (namespace, answers) => (0, project_input_validator_1.validateNamespace)(namespace, answers?.libraryName, false),
|
|
38
37
|
default: (0, i18n_1.t)('prompts.libraryNamespaceDefault')
|
|
39
38
|
},
|
|
40
39
|
{
|
|
@@ -47,12 +46,12 @@ function getQuestions(ui5Versions, options) {
|
|
|
47
46
|
mandatory: true,
|
|
48
47
|
breadcrumb: true
|
|
49
48
|
},
|
|
50
|
-
default:
|
|
51
|
-
validate: (target, answers) => (0, project_input_validator_1.validateProjectFolder)(target, `${answers
|
|
49
|
+
default: options?.targetFolder ?? process.cwd(),
|
|
50
|
+
validate: (target, answers) => (0, project_input_validator_1.validateProjectFolder)(target, `${answers?.namespace}.${answers?.libraryName}`)
|
|
52
51
|
},
|
|
53
52
|
{
|
|
54
53
|
when: () => !!ui5VersionChoices,
|
|
55
|
-
type:
|
|
54
|
+
type: options?.useAutocomplete ? 'autocomplete' : 'list',
|
|
56
55
|
name: 'ui5Version',
|
|
57
56
|
message: (0, i18n_1.t)('prompts.libraryUi5VersionLabel'),
|
|
58
57
|
guiOptions: {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/ui5-library-inquirer",
|
|
3
3
|
"description": "Prompts module that can provide prompts for UI5 library writer",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"i18next": "23.5.1",
|
|
24
24
|
"inquirer-autocomplete-prompt": "2.0.1",
|
|
25
|
-
"@sap-ux/inquirer-common": "0.
|
|
26
|
-
"@sap-ux/project-input-validator": "0.
|
|
27
|
-
"@sap-ux/ui5-info": "0.
|
|
25
|
+
"@sap-ux/inquirer-common": "0.4.0",
|
|
26
|
+
"@sap-ux/project-input-validator": "0.3.0",
|
|
27
|
+
"@sap-ux/ui5-info": "0.6.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"inquirer": "8.2.6",
|