@ixon-cdk/core 1.13.0-next.1 → 1.13.0-next.3
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/package.json +1 -1
- package/template/template.service.js +45 -25
package/package.json
CHANGED
|
@@ -183,22 +183,35 @@ module.exports = class TemplateService {
|
|
|
183
183
|
});
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
async add(componentName, componentPrefix) {
|
|
186
|
+
async add(componentName, componentPrefix, templateName, variantName) {
|
|
187
187
|
let schema;
|
|
188
188
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
189
|
+
if (templateName) {
|
|
190
|
+
const result = Object.keys(this._schemas).find(
|
|
191
|
+
key => this._schemas[key].name === templateName,
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
if (result) {
|
|
195
|
+
schema = this._schemas[result];
|
|
196
|
+
console.log(`Using template: ${schema.name}`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (!schema) {
|
|
201
|
+
const result = await prompts({
|
|
202
|
+
type: 'select',
|
|
203
|
+
name: 'templateName',
|
|
204
|
+
message: 'Pick a template',
|
|
205
|
+
choices: Object.keys(this._schemas).map(key => ({
|
|
206
|
+
title: this._schemas[key].name,
|
|
207
|
+
value: key,
|
|
208
|
+
})),
|
|
209
|
+
initial: 0,
|
|
210
|
+
});
|
|
199
211
|
|
|
200
|
-
|
|
201
|
-
|
|
212
|
+
if (result) {
|
|
213
|
+
schema = this._schemas[result.templateName];
|
|
214
|
+
}
|
|
202
215
|
}
|
|
203
216
|
|
|
204
217
|
if (schema) {
|
|
@@ -209,19 +222,26 @@ module.exports = class TemplateService {
|
|
|
209
222
|
let variantIdx = null;
|
|
210
223
|
|
|
211
224
|
if (schema.variants) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
225
|
+
if (variantName) {
|
|
226
|
+
variantIdx = schema.variants.findIndex(v => v.name === variantName);
|
|
227
|
+
console.log(`Using variant: ${schema.variants[variantIdx].name}`);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (variantIdx < 0) {
|
|
231
|
+
const _result = await prompts({
|
|
232
|
+
type: 'select',
|
|
233
|
+
name: 'variantIdx',
|
|
234
|
+
message: 'Pick a variant',
|
|
235
|
+
choices: schema.variants.map((variant, index) => ({
|
|
236
|
+
title: variant.name,
|
|
237
|
+
value: index,
|
|
238
|
+
})),
|
|
239
|
+
initial: 0,
|
|
240
|
+
});
|
|
222
241
|
|
|
223
|
-
|
|
224
|
-
|
|
242
|
+
if (_result) {
|
|
243
|
+
variantIdx = _result.variantIdx;
|
|
244
|
+
}
|
|
225
245
|
}
|
|
226
246
|
|
|
227
247
|
if (variantIdx === undefined) {
|