@sap-ux/ui5-library-reference-inquirer 0.2.37 → 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/choices.js +4 -13
- package/dist/i18n.js +4 -15
- package/dist/index.js +13 -26
- package/dist/prompts/helpers.js +1 -2
- package/dist/prompts/prompts.js +5 -5
- package/package.json +3 -3
package/dist/choices.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
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.getLibraryChoices = exports.getProjectChoices = void 0;
|
|
13
4
|
const path_1 = require("path");
|
|
@@ -17,7 +8,7 @@ const path_1 = require("path");
|
|
|
17
8
|
* @param apps array of applications found in the workspace folders.
|
|
18
9
|
* @returns list of projects
|
|
19
10
|
*/
|
|
20
|
-
const getProjectChoices = (apps) =>
|
|
11
|
+
const getProjectChoices = async (apps) => {
|
|
21
12
|
const projectChoices = [];
|
|
22
13
|
if (apps) {
|
|
23
14
|
for (const app of apps) {
|
|
@@ -26,7 +17,7 @@ const getProjectChoices = (apps) => __awaiter(void 0, void 0, void 0, function*
|
|
|
26
17
|
}
|
|
27
18
|
}
|
|
28
19
|
return projectChoices;
|
|
29
|
-
}
|
|
20
|
+
};
|
|
30
21
|
exports.getProjectChoices = getProjectChoices;
|
|
31
22
|
/**
|
|
32
23
|
* Creates the library choice options.
|
|
@@ -34,7 +25,7 @@ exports.getProjectChoices = getProjectChoices;
|
|
|
34
25
|
* @param libs - array of libraries found in the workspace folders.
|
|
35
26
|
* @returns list of libraries
|
|
36
27
|
*/
|
|
37
|
-
const getLibraryChoices = (libs) =>
|
|
28
|
+
const getLibraryChoices = async (libs) => {
|
|
38
29
|
const libraryChoices = [];
|
|
39
30
|
if (libs) {
|
|
40
31
|
for (const lib of libs) {
|
|
@@ -43,6 +34,6 @@ const getLibraryChoices = (libs) => __awaiter(void 0, void 0, void 0, function*
|
|
|
43
34
|
}
|
|
44
35
|
}
|
|
45
36
|
return libraryChoices;
|
|
46
|
-
}
|
|
37
|
+
};
|
|
47
38
|
exports.getLibraryChoices = getLibraryChoices;
|
|
48
39
|
//# sourceMappingURL=choices.js.map
|
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-reference-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_reference_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_reference_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
|
};
|
|
@@ -24,18 +15,16 @@ const choices_1 = require("./choices");
|
|
|
24
15
|
* @param promptOptions - options that can control some of the prompt behaviour
|
|
25
16
|
* @returns the prompts used to provide input for ui5 library generation
|
|
26
17
|
*/
|
|
27
|
-
function getPrompts(wsFolders, promptOptions) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return (0, prompts_1.getQuestions)(projectChoices, libraryChoices, promptOptions);
|
|
38
|
-
});
|
|
18
|
+
async function getPrompts(wsFolders, promptOptions) {
|
|
19
|
+
const options = {
|
|
20
|
+
wsFolders: wsFolders,
|
|
21
|
+
artifacts: ['applications', 'libraries']
|
|
22
|
+
};
|
|
23
|
+
const fioriArtifacts = await (0, project_access_1.findFioriArtifacts)(options);
|
|
24
|
+
const reuseLibs = await (0, project_access_1.getReuseLibs)(fioriArtifacts?.libraries);
|
|
25
|
+
const projectChoices = await (0, choices_1.getProjectChoices)(fioriArtifacts?.applications);
|
|
26
|
+
const libraryChoices = await (0, choices_1.getLibraryChoices)(reuseLibs);
|
|
27
|
+
return (0, prompts_1.getQuestions)(projectChoices, libraryChoices, promptOptions);
|
|
39
28
|
}
|
|
40
29
|
exports.getPrompts = getPrompts;
|
|
41
30
|
/**
|
|
@@ -46,11 +35,9 @@ exports.getPrompts = getPrompts;
|
|
|
46
35
|
* @param promptOptions - options that can control some of the prompt behaviour
|
|
47
36
|
* @returns the prompt answers
|
|
48
37
|
*/
|
|
49
|
-
function prompt(wsFolders, adapter, promptOptions) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return adapter ? adapter.prompt(ui5LibPrompts) : inquirer_1.default.prompt(ui5LibPrompts);
|
|
53
|
-
});
|
|
38
|
+
async function prompt(wsFolders, adapter, promptOptions) {
|
|
39
|
+
const ui5LibPrompts = await exports.getPrompts(wsFolders, promptOptions);
|
|
40
|
+
return adapter ? adapter.prompt(ui5LibPrompts) : inquirer_1.default.prompt(ui5LibPrompts);
|
|
54
41
|
}
|
|
55
42
|
exports.prompt = prompt;
|
|
56
43
|
//# sourceMappingURL=index.js.map
|
package/dist/prompts/helpers.js
CHANGED
|
@@ -13,9 +13,8 @@ function hidePrompts(prompts, promptOptions) {
|
|
|
13
13
|
const questions = [];
|
|
14
14
|
if (promptOptions) {
|
|
15
15
|
Object.keys(prompts).forEach((key) => {
|
|
16
|
-
var _a;
|
|
17
16
|
const promptKey = key;
|
|
18
|
-
if (!
|
|
17
|
+
if (!promptOptions?.[promptKey]?.hide) {
|
|
19
18
|
questions.push(prompts[promptKey]);
|
|
20
19
|
}
|
|
21
20
|
});
|
package/dist/prompts/prompts.js
CHANGED
|
@@ -47,10 +47,10 @@ function getTargetProjectFolderPrompt(projectChoices) {
|
|
|
47
47
|
message: (0, i18n_1.t)('prompts.targetProjectFolderLabel'),
|
|
48
48
|
choices: projectChoices,
|
|
49
49
|
default: () => {
|
|
50
|
-
return
|
|
50
|
+
return projectChoices?.length ? 0 : undefined;
|
|
51
51
|
},
|
|
52
52
|
validate: () => {
|
|
53
|
-
return !
|
|
53
|
+
return !projectChoices?.length ? (0, i18n_1.t)('error.noProjectsFound') : true;
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
}
|
|
@@ -95,13 +95,13 @@ function getReferenceLibrariesPrompt(reuseLibs) {
|
|
|
95
95
|
return missingDeps ? msg : undefined;
|
|
96
96
|
},
|
|
97
97
|
validate: (answer) => {
|
|
98
|
-
if (!
|
|
98
|
+
if (!reuseLibs?.length) {
|
|
99
99
|
return (0, i18n_1.t)('error.noLibsFound');
|
|
100
100
|
}
|
|
101
|
-
else if (
|
|
101
|
+
else if (answer?.length < 1) {
|
|
102
102
|
return (0, i18n_1.t)('error.noLibSelected');
|
|
103
103
|
}
|
|
104
|
-
else if (answer
|
|
104
|
+
else if (answer?.length) {
|
|
105
105
|
missingDeps = (0, project_access_1.checkDependencies)(answer, reuseLibs.map((libs) => libs.value));
|
|
106
106
|
}
|
|
107
107
|
return true;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/ui5-library-reference-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",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"i18next": "23.5.1",
|
|
23
|
-
"@sap-ux/inquirer-common": "0.
|
|
24
|
-
"@sap-ux/project-access": "1.
|
|
23
|
+
"@sap-ux/inquirer-common": "0.4.0",
|
|
24
|
+
"@sap-ux/project-access": "1.23.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"inquirer": "8.2.6",
|