@sap-ux/ui5-library-inquirer 0.1.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 +57 -0
- package/dist/i18n.d.ts +14 -0
- package/dist/i18n.js +55 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +58 -0
- package/dist/prompts/index.d.ts +2 -0
- package/dist/prompts/index.js +18 -0
- package/dist/prompts/prompts.d.ts +12 -0
- package/dist/prompts/prompts.js +77 -0
- package/dist/prompts/utility.d.ts +21 -0
- package/dist/prompts/utility.js +85 -0
- package/dist/translations/ui5-library-inquirer.i18n.json +19 -0
- package/dist/types.d.ts +48 -0
- package/dist/types.js +3 -0
- package/package.json +49 -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,57 @@
|
|
|
1
|
+
# @sap-ux/ui5-library-inquirer
|
|
2
|
+
|
|
3
|
+
Provides Inquirer based prompting to allow input and validation of data required to generate a UI5 library
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
Npm
|
|
8
|
+
`npm install --save @sap-ux/ui5-library-inquirer`
|
|
9
|
+
|
|
10
|
+
Yarn
|
|
11
|
+
`yarn add @sap-ux/ui5-library-inquirer`
|
|
12
|
+
|
|
13
|
+
Pnpm
|
|
14
|
+
`pnpm add @sap-ux/ui5-library-inquirer`
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
Example with Yeoman generator :
|
|
19
|
+
|
|
20
|
+
```javascript
|
|
21
|
+
import Generator from 'yeoman-generator';
|
|
22
|
+
import { generate, type UI5LibConfig } from '@sap-ux/ui5-library-writer';
|
|
23
|
+
import { prompt, type UI5LibraryAnswers } from '@sap-ux/ui5-library-inquirer';
|
|
24
|
+
|
|
25
|
+
export default class UI5LibraryGenerator extends Generator {
|
|
26
|
+
answers: UI5LibraryAnswers = {};
|
|
27
|
+
|
|
28
|
+
constructor(args: string | string[], opts: Generator.GeneratorOptions) {
|
|
29
|
+
super(args, opts);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public async prompting(): Promise<void> {
|
|
33
|
+
const answers = await prompt();
|
|
34
|
+
Object.assign(this.answers, answers);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public async writing(): Promise<void> {
|
|
38
|
+
const ui5Lib: UI5LibConfig = {
|
|
39
|
+
libraryName: this.answers.libraryName,
|
|
40
|
+
namespace: this.answers.namespace,
|
|
41
|
+
framework: 'SAPUI5',
|
|
42
|
+
frameworkVersion: this.answers.ui5Version,
|
|
43
|
+
author: 'Fiori tools',
|
|
44
|
+
typescript: this.answers.enableTypescript
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
await generate(this.answers.targetFolder, ui5Lib, this.fs);
|
|
49
|
+
} catch (e) {}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Keywords
|
|
55
|
+
SAP Fiori Elements
|
|
56
|
+
Yeoman
|
|
57
|
+
Generator
|
package/dist/i18n.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TOptions } from 'i18next';
|
|
2
|
+
/**
|
|
3
|
+
* Initialize i18next with the translations for this module.
|
|
4
|
+
*/
|
|
5
|
+
export declare function initI18n(): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
|
|
8
|
+
*
|
|
9
|
+
* @param key i18n key
|
|
10
|
+
* @param options additional options
|
|
11
|
+
* @returns {string} localized string stored for the given key
|
|
12
|
+
*/
|
|
13
|
+
export declare function t(key: string, options?: TOptions): string;
|
|
14
|
+
//# sourceMappingURL=i18n.d.ts.map
|
package/dist/i18n.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.t = exports.initI18n = void 0;
|
|
16
|
+
const i18next_1 = __importDefault(require("i18next"));
|
|
17
|
+
const ui5_library_inquirer_i18n_json_1 = __importDefault(require("./translations/ui5-library-inquirer.i18n.json"));
|
|
18
|
+
const ui5LibI18nNamespace = 'ui5-library-inquirer';
|
|
19
|
+
/**
|
|
20
|
+
* Initialize i18next with the translations for this module.
|
|
21
|
+
*/
|
|
22
|
+
function initI18n() {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
yield i18next_1.default.init({
|
|
25
|
+
resources: {
|
|
26
|
+
en: {
|
|
27
|
+
[ui5LibI18nNamespace]: ui5_library_inquirer_i18n_json_1.default
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
lng: 'en',
|
|
31
|
+
fallbackLng: 'en',
|
|
32
|
+
defaultNS: ui5LibI18nNamespace,
|
|
33
|
+
ns: [ui5LibI18nNamespace]
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
exports.initI18n = initI18n;
|
|
38
|
+
/**
|
|
39
|
+
* Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
|
|
40
|
+
*
|
|
41
|
+
* @param key i18n key
|
|
42
|
+
* @param options additional options
|
|
43
|
+
* @returns {string} localized string stored for the given key
|
|
44
|
+
*/
|
|
45
|
+
function t(key, options) {
|
|
46
|
+
if (!(options === null || options === void 0 ? void 0 : options.ns)) {
|
|
47
|
+
options = Object.assign(options !== null && options !== void 0 ? options : {}, { ns: ui5LibI18nNamespace });
|
|
48
|
+
}
|
|
49
|
+
return i18next_1.default.t(key, options);
|
|
50
|
+
}
|
|
51
|
+
exports.t = t;
|
|
52
|
+
initI18n().catch(() => {
|
|
53
|
+
// Needed for lint
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=i18n.js.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Question } from 'inquirer';
|
|
2
|
+
import type { UI5LibraryAnswers, UI5LibraryPromptOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Get the inquirer prompts for ui5 library inquirer.
|
|
5
|
+
*
|
|
6
|
+
* @param promptOptions See {@link UI5LibraryPromptOptions} for details
|
|
7
|
+
* @returns the prompts used to provide input for ui5 library generation
|
|
8
|
+
*/
|
|
9
|
+
declare function getPrompts(promptOptions?: UI5LibraryPromptOptions): Promise<Question<UI5LibraryAnswers>[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Prompt for ui5 library generation inputs.
|
|
12
|
+
*
|
|
13
|
+
* @param promptOptions - options that can control some of the prompt behaviour. See {@link UI5LibraryPromptOptions} for details
|
|
14
|
+
* @returns the prompt answers
|
|
15
|
+
*/
|
|
16
|
+
declare function prompt(promptOptions?: UI5LibraryPromptOptions): Promise<UI5LibraryAnswers>;
|
|
17
|
+
export { getPrompts, prompt, type UI5LibraryPromptOptions, type UI5LibraryAnswers };
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.prompt = exports.getPrompts = void 0;
|
|
16
|
+
const ui5_info_1 = require("@sap-ux/ui5-info");
|
|
17
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
18
|
+
const prompts_1 = require("./prompts");
|
|
19
|
+
const inquirer_autocomplete_prompt_1 = __importDefault(require("inquirer-autocomplete-prompt"));
|
|
20
|
+
/**
|
|
21
|
+
* Get the inquirer prompts for ui5 library inquirer.
|
|
22
|
+
*
|
|
23
|
+
* @param promptOptions See {@link UI5LibraryPromptOptions} for details
|
|
24
|
+
* @returns the prompts used to provide input for ui5 library generation
|
|
25
|
+
*/
|
|
26
|
+
function getPrompts(promptOptions) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const filterOptions = {
|
|
29
|
+
useCache: true,
|
|
30
|
+
includeMaintained: true
|
|
31
|
+
};
|
|
32
|
+
const ui5Versions = yield (0, ui5_info_1.getUI5Versions)(filterOptions);
|
|
33
|
+
const ui5LibPromptInputs = {
|
|
34
|
+
targetFolder: promptOptions === null || promptOptions === void 0 ? void 0 : promptOptions.targetFolder,
|
|
35
|
+
includeSeparators: promptOptions === null || promptOptions === void 0 ? void 0 : promptOptions.includeSeparators,
|
|
36
|
+
useAutocomplete: promptOptions === null || promptOptions === void 0 ? void 0 : promptOptions.useAutocomplete
|
|
37
|
+
};
|
|
38
|
+
return (0, prompts_1.getQuestions)(ui5Versions, ui5LibPromptInputs);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
exports.getPrompts = getPrompts;
|
|
42
|
+
/**
|
|
43
|
+
* Prompt for ui5 library generation inputs.
|
|
44
|
+
*
|
|
45
|
+
* @param promptOptions - options that can control some of the prompt behaviour. See {@link UI5LibraryPromptOptions} for details
|
|
46
|
+
* @returns the prompt answers
|
|
47
|
+
*/
|
|
48
|
+
function prompt(promptOptions) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
const ui5LibPrompts = yield exports.getPrompts(promptOptions);
|
|
51
|
+
if (promptOptions === null || promptOptions === void 0 ? void 0 : promptOptions.useAutocomplete) {
|
|
52
|
+
inquirer_1.default.registerPrompt('autocomplete', inquirer_autocomplete_prompt_1.default);
|
|
53
|
+
}
|
|
54
|
+
return inquirer_1.default.prompt(ui5LibPrompts);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
exports.prompt = prompt;
|
|
58
|
+
//# sourceMappingURL=index.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,12 @@
|
|
|
1
|
+
import type { Question } from 'inquirer';
|
|
2
|
+
import type { UI5LibraryAnswers, UI5LibraryPromptOptions } from '../types';
|
|
3
|
+
import type { UI5Version } from '@sap-ux/ui5-info';
|
|
4
|
+
/**
|
|
5
|
+
* Get the prompts for UI5 library generation.
|
|
6
|
+
*
|
|
7
|
+
* @param ui5Versions - ui5 versions to prompt for selection
|
|
8
|
+
* @param options - optional inputs used to pre-populate some prompt choices, default values and other prompting options. See {@link UI5LibraryPromptOptions}.
|
|
9
|
+
* @returns the prompts
|
|
10
|
+
*/
|
|
11
|
+
export declare function getQuestions(ui5Versions: UI5Version[], options?: UI5LibraryPromptOptions): Question<UI5LibraryAnswers>[];
|
|
12
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getQuestions = void 0;
|
|
4
|
+
const i18n_1 = require("../i18n");
|
|
5
|
+
const utility_1 = require("./utility");
|
|
6
|
+
const project_input_validator_1 = require("@sap-ux/project-input-validator");
|
|
7
|
+
/**
|
|
8
|
+
* Get the prompts for UI5 library generation.
|
|
9
|
+
*
|
|
10
|
+
* @param ui5Versions - ui5 versions to prompt for selection
|
|
11
|
+
* @param options - optional inputs used to pre-populate some prompt choices, default values and other prompting options. See {@link UI5LibraryPromptOptions}.
|
|
12
|
+
* @returns the prompts
|
|
13
|
+
*/
|
|
14
|
+
function getQuestions(ui5Versions, options) {
|
|
15
|
+
var _a;
|
|
16
|
+
const ui5VersionChoices = (0, utility_1.ui5VersionsGrouped)(ui5Versions, options === null || options === void 0 ? void 0 : options.includeSeparators);
|
|
17
|
+
return [
|
|
18
|
+
{
|
|
19
|
+
type: 'input',
|
|
20
|
+
name: 'libraryName',
|
|
21
|
+
message: (0, i18n_1.t)('prompts.libraryNameLabel'),
|
|
22
|
+
guiOptions: {
|
|
23
|
+
mandatory: true,
|
|
24
|
+
breadcrumb: true
|
|
25
|
+
},
|
|
26
|
+
validate: (libraryName) => (0, project_input_validator_1.validateLibModuleName)(libraryName),
|
|
27
|
+
default: (0, i18n_1.t)('prompts.libraryNameDefault')
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: 'input',
|
|
31
|
+
name: 'namespace',
|
|
32
|
+
message: (0, i18n_1.t)('prompts.libraryNamespaceLabel'),
|
|
33
|
+
guiOptions: {
|
|
34
|
+
mandatory: true,
|
|
35
|
+
breadcrumb: true
|
|
36
|
+
},
|
|
37
|
+
validate: (namespace, answers) => (0, project_input_validator_1.validateNamespace)(namespace, answers === null || answers === void 0 ? void 0 : answers.libraryName, false),
|
|
38
|
+
default: (0, i18n_1.t)('prompts.libraryNamespaceDefault')
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: 'input',
|
|
42
|
+
name: 'targetFolder',
|
|
43
|
+
message: (0, i18n_1.t)('prompts.libraryFolderLabel'),
|
|
44
|
+
guiType: 'folder-browser',
|
|
45
|
+
guiOptions: {
|
|
46
|
+
applyDefaultWhenDirty: true,
|
|
47
|
+
mandatory: true,
|
|
48
|
+
breadcrumb: true
|
|
49
|
+
},
|
|
50
|
+
default: (_a = options === null || options === void 0 ? void 0 : options.targetFolder) !== null && _a !== void 0 ? _a : process.cwd(),
|
|
51
|
+
validate: (target, answers) => (0, project_input_validator_1.validateProjectFolder)(target, `${answers === null || answers === void 0 ? void 0 : answers.namespace}.${answers === null || answers === void 0 ? void 0 : answers.libraryName}`)
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
when: () => !!ui5VersionChoices,
|
|
55
|
+
type: (options === null || options === void 0 ? void 0 : options.useAutocomplete) ? 'autocomplete' : 'list',
|
|
56
|
+
name: 'ui5Version',
|
|
57
|
+
message: (0, i18n_1.t)('prompts.libraryUi5VersionLabel'),
|
|
58
|
+
guiOptions: {
|
|
59
|
+
hint: (0, i18n_1.t)('prompts.libraryUi5VersionTooltip'),
|
|
60
|
+
breadcrumb: true
|
|
61
|
+
},
|
|
62
|
+
choices: () => ui5VersionChoices,
|
|
63
|
+
source: (prevAnswers, input) => (0, utility_1.searchChoices)(input, ui5VersionChoices)
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
type: 'confirm',
|
|
67
|
+
name: 'enableTypescript',
|
|
68
|
+
message: (0, i18n_1.t)('prompts.libraryEnableTypeScriptLabel'),
|
|
69
|
+
guiOptions: {
|
|
70
|
+
breadcrumb: true
|
|
71
|
+
},
|
|
72
|
+
default: false
|
|
73
|
+
}
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
exports.getQuestions = getQuestions;
|
|
77
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Separator, type ListChoiceOptions } from 'inquirer';
|
|
2
|
+
import type { UI5Version } from '@sap-ux/ui5-info';
|
|
3
|
+
import type { UI5VersionChoice } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Finds the search value in the provided list using `fuzzy` search.
|
|
6
|
+
*
|
|
7
|
+
* @param searchVal - the string to search for
|
|
8
|
+
* @param searchList - the list in which to search by fuzzy matching the choice name
|
|
9
|
+
* @returns Inquirer choices filtered by the search value
|
|
10
|
+
*/
|
|
11
|
+
export declare function searchChoices(searchVal: string, searchList: ListChoiceOptions[]): ListChoiceOptions[];
|
|
12
|
+
/**
|
|
13
|
+
* Creates a list of UI5 Versions prompt choices, adding additional maintenance info for use in prompts
|
|
14
|
+
* and grouping according to maintenance status.
|
|
15
|
+
*
|
|
16
|
+
* @param versions ui5Versions
|
|
17
|
+
* @param includeSeparators Include a separator to visually identify groupings, if false then grouping info is included in each entry as additional name text
|
|
18
|
+
* @returns Array of ui5 version choices and separators if applicable, grouped by maintenance state
|
|
19
|
+
*/
|
|
20
|
+
export declare function ui5VersionsGrouped(versions: UI5Version[], includeSeparators?: boolean): (UI5VersionChoice | Separator)[];
|
|
21
|
+
//# sourceMappingURL=utility.d.ts.map
|
|
@@ -0,0 +1,85 @@
|
|
|
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.ui5VersionsGrouped = exports.searchChoices = void 0;
|
|
27
|
+
const inquirer_1 = require("inquirer");
|
|
28
|
+
const fuzzy = __importStar(require("fuzzy"));
|
|
29
|
+
const i18n_1 = require("../i18n");
|
|
30
|
+
/**
|
|
31
|
+
* Finds the search value in the provided list using `fuzzy` search.
|
|
32
|
+
*
|
|
33
|
+
* @param searchVal - the string to search for
|
|
34
|
+
* @param searchList - the list in which to search by fuzzy matching the choice name
|
|
35
|
+
* @returns Inquirer choices filtered by the search value
|
|
36
|
+
*/
|
|
37
|
+
function searchChoices(searchVal, searchList) {
|
|
38
|
+
return searchVal && searchList
|
|
39
|
+
? fuzzy
|
|
40
|
+
.filter(searchVal, searchList, {
|
|
41
|
+
// Only `choice.name` searching is supported, as this is what is presented to the user by Inquirer
|
|
42
|
+
extract: (choice) => { var _a; return (_a = choice.name) !== null && _a !== void 0 ? _a : ''; }
|
|
43
|
+
})
|
|
44
|
+
.map((el) => el.original)
|
|
45
|
+
: searchList;
|
|
46
|
+
}
|
|
47
|
+
exports.searchChoices = searchChoices;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a list of UI5 Versions prompt choices, adding additional maintenance info for use in prompts
|
|
50
|
+
* and grouping according to maintenance status.
|
|
51
|
+
*
|
|
52
|
+
* @param versions ui5Versions
|
|
53
|
+
* @param includeSeparators Include a separator to visually identify groupings, if false then grouping info is included in each entry as additional name text
|
|
54
|
+
* @returns Array of ui5 version choices and separators if applicable, grouped by maintenance state
|
|
55
|
+
*/
|
|
56
|
+
function ui5VersionsGrouped(versions, includeSeparators = false) {
|
|
57
|
+
if (!versions || (Array.isArray(versions) && versions.length === 0)) {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
const maintChoices = versions
|
|
61
|
+
.filter((v) => v.maintained === true)
|
|
62
|
+
.map((mainV) => ({
|
|
63
|
+
name: !includeSeparators
|
|
64
|
+
? `${mainV.version} - (${(0, i18n_1.t)('ui5VersionLabels.maintained')} ${(0, i18n_1.t)('ui5VersionLabels.version', {
|
|
65
|
+
count: 1
|
|
66
|
+
})})`
|
|
67
|
+
: mainV.version,
|
|
68
|
+
value: mainV.version
|
|
69
|
+
}));
|
|
70
|
+
const notMaintChoices = versions
|
|
71
|
+
.filter((v) => v.maintained === false)
|
|
72
|
+
.map((mainV) => ({
|
|
73
|
+
name: !includeSeparators
|
|
74
|
+
? `${mainV.version} - (${(0, i18n_1.t)('ui5VersionLabels.outOfMaintenance')} ${(0, i18n_1.t)('ui5VersionLabels.version', { count: 1 })})`
|
|
75
|
+
: mainV.version,
|
|
76
|
+
value: mainV.version
|
|
77
|
+
}));
|
|
78
|
+
if (includeSeparators) {
|
|
79
|
+
maintChoices.unshift(new inquirer_1.Separator(`${(0, i18n_1.t)('ui5VersionLabels.maintained')} ${(0, i18n_1.t)('ui5VersionLabels.version', { count: 0 })}`));
|
|
80
|
+
notMaintChoices.unshift(new inquirer_1.Separator(`${(0, i18n_1.t)('ui5VersionLabels.outOfMaintenance')} ${(0, i18n_1.t)('ui5VersionLabels.version', { count: 0 })}`));
|
|
81
|
+
}
|
|
82
|
+
return [...maintChoices, ...notMaintChoices];
|
|
83
|
+
}
|
|
84
|
+
exports.ui5VersionsGrouped = ui5VersionsGrouped;
|
|
85
|
+
//# sourceMappingURL=utility.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"prompts": {
|
|
3
|
+
"libraryNameLabel": "Library module name",
|
|
4
|
+
"libraryNameDefault": "library1",
|
|
5
|
+
"libraryNamespaceLabel": "Library namespace",
|
|
6
|
+
"libraryNamespaceDefault": "com.myorg",
|
|
7
|
+
"libraryUi5VersionLabel": "Minimum SAPUI5 version",
|
|
8
|
+
"libraryUi5VersionTooltip": "Represents the minimum version of SAPUI5 that this library requires",
|
|
9
|
+
"libraryEnableTypeScriptLabel": "Enable TypeScript (Experimental)",
|
|
10
|
+
"libraryFolderLabel": "Library folder path",
|
|
11
|
+
"libraryFolderTooltip": "The generated library's folder will be a combination of the library's namespace and module name"
|
|
12
|
+
},
|
|
13
|
+
"ui5VersionLabels": {
|
|
14
|
+
"maintained": "Maintained",
|
|
15
|
+
"outOfMaintenance": "Out of maintenance",
|
|
16
|
+
"version_one": "version",
|
|
17
|
+
"version_other": "versions"
|
|
18
|
+
}
|
|
19
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ConfirmQuestion as BaseConfirmQuestion, InputQuestion as BaseInputQuestion, ListQuestion as BaseListQuestion, Answers, ListChoiceOptions } from 'inquirer';
|
|
2
|
+
export interface UI5LibraryAnswers {
|
|
3
|
+
libraryName?: string;
|
|
4
|
+
namespace?: string;
|
|
5
|
+
targetFolder?: string;
|
|
6
|
+
ui5Version?: string;
|
|
7
|
+
enableTypescript?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface UI5LibraryPromptOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Optionally provide the target folder used as the `targetFolder` prompt default value
|
|
12
|
+
*/
|
|
13
|
+
targetFolder?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Optionally include an Inquirer Separator for grouped UI5 versions
|
|
16
|
+
*/
|
|
17
|
+
includeSeparators?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Optionally register the `inquirer-autocomplete-prompt` plugin and use for UI5 version searching
|
|
20
|
+
*/
|
|
21
|
+
useAutocomplete?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface UI5VersionChoice extends ListChoiceOptions {
|
|
24
|
+
value: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* Remove when YUI specific types are available from `"@sap-devx/yeoman-ui-types`
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
export interface GuiOptions {
|
|
32
|
+
hint?: string;
|
|
33
|
+
applyDefaultWhenDirty?: boolean;
|
|
34
|
+
breadcrumb?: boolean | string;
|
|
35
|
+
}
|
|
36
|
+
export interface ConfirmQuestion<A extends Answers = Answers> extends BaseConfirmQuestion<A> {
|
|
37
|
+
guiOptions?: GuiOptions;
|
|
38
|
+
}
|
|
39
|
+
export interface InputQuestion<A extends Answers = Answers> extends BaseInputQuestion<A> {
|
|
40
|
+
guiOptions?: GuiOptions;
|
|
41
|
+
}
|
|
42
|
+
export interface ListQuestion<A extends Answers = Answers> extends BaseListQuestion<A> {
|
|
43
|
+
guiOptions?: GuiOptions;
|
|
44
|
+
}
|
|
45
|
+
export interface FileBrowserQuestion<A extends Answers = Answers> extends InputQuestion<A> {
|
|
46
|
+
guiType: 'file-browser' | 'folder-browser';
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sap-ux/ui5-library-inquirer",
|
|
3
|
+
"description": "Prompts module that can provide prompts for UI5 library writer",
|
|
4
|
+
"version": "0.1.1",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
8
|
+
"directory": "packages/ui5-library-inquirer"
|
|
9
|
+
},
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aui5-library-inquirer"
|
|
12
|
+
},
|
|
13
|
+
"license": "Apache-2.0",
|
|
14
|
+
"main": "dist/index.js",
|
|
15
|
+
"files": [
|
|
16
|
+
"LICENSE",
|
|
17
|
+
"dist",
|
|
18
|
+
"templates",
|
|
19
|
+
"!dist/*.map",
|
|
20
|
+
"!dist/**/*.map"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"fuzzy": "0.1.3",
|
|
24
|
+
"i18next": "23.5.1",
|
|
25
|
+
"inquirer": "8.2.6",
|
|
26
|
+
"inquirer-autocomplete-prompt": "2.0.1",
|
|
27
|
+
"@sap-ux/project-input-validator": "0.2.1",
|
|
28
|
+
"@sap-ux/ui5-info": "0.2.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/inquirer-autocomplete-prompt": "2.0.1",
|
|
32
|
+
"@types/inquirer": "8.2.7"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"pnpm": ">=6.26.1 < 7.0.0 || >=7.1.0",
|
|
36
|
+
"node": ">=18.x"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc --build",
|
|
40
|
+
"clean": "rimraf --glob dist test/test-output coverage *.tsbuildinfo",
|
|
41
|
+
"watch": "tsc --watch",
|
|
42
|
+
"lint": "eslint . --ext .ts",
|
|
43
|
+
"lint:fix": "eslint . --ext .ts --fix",
|
|
44
|
+
"test": "jest --ci --forceExit --detectOpenHandles --colors --passWithNoTests",
|
|
45
|
+
"test-u": "jest --ci --forceExit --detectOpenHandles --colors -u",
|
|
46
|
+
"link": "pnpm link --global",
|
|
47
|
+
"unlink": "pnpm unlink --global"
|
|
48
|
+
}
|
|
49
|
+
}
|