@pega/custom-dx-components 24.2.12 → 24.2.14
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/src/constants.js +2 -0
- package/src/tasks/create-lib/index.js +85 -1
- package/src/tasks/create-version/index.js +60 -16
- package/src/tasks/delete-lib/index.js +43 -14
- package/src/tasks/delete-version/index.js +30 -9
- package/src/tasks/import-archive/index.js +27 -14
- package/src/tasks/import-comp/index.js +144 -82
- package/src/tasks/init/template/package.json.mustache +1 -1
- package/src/tasks/publish/index.js +34 -18
- package/src/tasks/publish-lib/index.js +19 -2
- package/src/tasks/set-perm/index.js +14 -2
- package/src/tasks/switch-lib/index.js +83 -34
- package/src/tasks/switch-version/index.js +69 -14
- package/src/tasks/validator/index.js +11 -6
- package/src/util.js +99 -2
|
@@ -14,7 +14,10 @@ import {
|
|
|
14
14
|
addDebugLog,
|
|
15
15
|
checkLibraryAndArchives,
|
|
16
16
|
getConfigDefaults,
|
|
17
|
-
getComponents
|
|
17
|
+
getComponents,
|
|
18
|
+
getUseInputConfig,
|
|
19
|
+
getInputConfigForCommand,
|
|
20
|
+
convertYNToBoolean
|
|
18
21
|
} from '../../util.js';
|
|
19
22
|
import { TASKS_CONFIG_JSON_FILENAME } from '../../constants.js';
|
|
20
23
|
import { getFilePathQuestions, getFileNameQuestions, updateSavedFilePath } from './helper.js';
|
|
@@ -156,6 +159,8 @@ addDebugLog("renameComponent", `library: ${library}, componentKey: ${componentKe
|
|
|
156
159
|
export const importComp = async(filePath, fileName, askValidate) => {
|
|
157
160
|
addDebugLog("importComp", `filePath: ${filePath}, fileName: ${fileName}`, "");
|
|
158
161
|
|
|
162
|
+
const useInputConfig = getUseInputConfig();
|
|
163
|
+
|
|
159
164
|
const currentDirectory = process.cwd();
|
|
160
165
|
// const compDirectory = join(currentDirectory, "src", "components");
|
|
161
166
|
|
|
@@ -166,6 +171,8 @@ addDebugLog("importComp", `filePath: ${filePath}, fileName: ${fileName}`, "");
|
|
|
166
171
|
let configData;
|
|
167
172
|
let newName = "";
|
|
168
173
|
let newLabel = "";
|
|
174
|
+
let proceedAs;
|
|
175
|
+
|
|
169
176
|
|
|
170
177
|
if (fs.existsSync(copyDir)) {
|
|
171
178
|
configData = fs.readFileSync(join(copyDir, "/config.json"), { encoding: 'utf8' });
|
|
@@ -178,66 +185,96 @@ addDebugLog("importComp", `filePath: ${filePath}, fileName: ${fileName}`, "");
|
|
|
178
185
|
|
|
179
186
|
if (currentCompList && currentCompList.includes(potentialCompKey)) {
|
|
180
187
|
console.log(`\nComponent ${chalk.yellow(`${potentialCompKey}`)} already exists.`);
|
|
181
|
-
const proceedAnswers = await inquirer.prompt([
|
|
182
188
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
if (useInputConfig) {
|
|
192
|
+
const inputConfig = await getInputConfigForCommand("importComponent");
|
|
193
|
+
proceedAs = inputConfig.proceedIfExists;
|
|
194
|
+
|
|
195
|
+
newName = inputConfig?.newComponentName;
|
|
196
|
+
newLabel = inputConfig?.newComponentLabel;
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
switch (proceedAs) {
|
|
200
|
+
case 'No import':
|
|
201
|
+
// removed copied
|
|
202
|
+
// fs.rmSync(copyDir, { recursive: true, force: true, maxRetries: 2 });
|
|
203
|
+
process.exit();
|
|
204
|
+
break;
|
|
205
|
+
case 'Overwrite':
|
|
206
|
+
// remove existing
|
|
207
|
+
const existingComp = await getComponentDirectoryPath(potentialCompKey);
|
|
208
|
+
fs.rmSync(existingComp, { recursive: true, force: true, maxRetries: 2 });
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
const proceedAnswers = await inquirer.prompt([
|
|
215
|
+
|
|
216
|
+
{
|
|
217
|
+
name: 'proceedAs',
|
|
218
|
+
type: 'rawlist',
|
|
219
|
+
message: `Proceed as ?`,
|
|
220
|
+
default: 'No import',
|
|
221
|
+
choices: ['No import', 'Overwrite', 'New name']
|
|
195
222
|
},
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
223
|
+
{
|
|
224
|
+
name: 'componentName',
|
|
225
|
+
message: 'Enter component name (required)',
|
|
226
|
+
when(answers) {
|
|
227
|
+
return answers.proceedAs === 'New name';
|
|
228
|
+
},
|
|
229
|
+
validate: value => {
|
|
230
|
+
/* value should not be empty
|
|
231
|
+
It should not have spaces
|
|
232
|
+
It should not start with a number
|
|
233
|
+
Only case-insensitive alphanumeric values are allowed
|
|
234
|
+
*/
|
|
235
|
+
if (value && !/^\d/.test(value) && value === sanitize(value)) {
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
return 'Only alphanumeric values are allowed, starting with alphabets, no spaces.';
|
|
204
239
|
}
|
|
205
|
-
return 'Only alphanumeric values are allowed, starting with alphabets, no spaces.';
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
name: 'componentLabel',
|
|
210
|
-
message: 'Enter component label for display (required)',
|
|
211
|
-
when(answers) {
|
|
212
|
-
return answers.proceedAs === 'New name';
|
|
213
240
|
},
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
241
|
+
{
|
|
242
|
+
name: 'componentLabel',
|
|
243
|
+
message: 'Enter component label for display (required)',
|
|
244
|
+
when(answers) {
|
|
245
|
+
return answers.proceedAs === 'New name';
|
|
246
|
+
},
|
|
247
|
+
validate: value => {
|
|
248
|
+
if (value) {
|
|
249
|
+
return true;
|
|
250
|
+
}
|
|
251
|
+
return 'Please provide value for label';
|
|
217
252
|
}
|
|
218
|
-
return 'Please provide value for label';
|
|
219
253
|
}
|
|
254
|
+
]);
|
|
255
|
+
|
|
256
|
+
proceedAs = proceedAnswers.proceedAs;
|
|
257
|
+
|
|
258
|
+
switch (proceedAs) {
|
|
259
|
+
case 'No import':
|
|
260
|
+
// removed copied
|
|
261
|
+
// fs.rmSync(copyDir, { recursive: true, force: true, maxRetries: 2 });
|
|
262
|
+
process.exit();
|
|
263
|
+
break;
|
|
264
|
+
case 'Overwrite':
|
|
265
|
+
// remove existing
|
|
266
|
+
const existingComp = await getComponentDirectoryPath(potentialCompKey);
|
|
267
|
+
fs.rmSync(existingComp, { recursive: true, force: true, maxRetries: 2 });
|
|
268
|
+
break;
|
|
269
|
+
case 'New name':
|
|
270
|
+
newName = proceedAnswers.componentName;
|
|
271
|
+
newLabel = proceedAnswers.componentLabel;
|
|
272
|
+
break;
|
|
220
273
|
}
|
|
221
|
-
]);
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
switch (proceedAnswers.proceedAs) {
|
|
225
|
-
case 'No import':
|
|
226
|
-
// removed copied
|
|
227
|
-
// fs.rmSync(copyDir, { recursive: true, force: true, maxRetries: 2 });
|
|
228
|
-
process.exit();
|
|
229
|
-
break;
|
|
230
|
-
case 'Overwrite':
|
|
231
|
-
// remove existing
|
|
232
|
-
const existingComp = await getComponentDirectoryPath(potentialCompKey);
|
|
233
|
-
fs.rmSync(existingComp, { recursive: true, force: true, maxRetries: 2 });
|
|
234
|
-
break;
|
|
235
|
-
case 'New name':
|
|
236
|
-
newName = proceedAnswers.componentName;
|
|
237
|
-
newLabel = proceedAnswers.componentLabel;
|
|
238
|
-
break;
|
|
239
274
|
}
|
|
240
275
|
|
|
276
|
+
|
|
277
|
+
|
|
241
278
|
}
|
|
242
279
|
}
|
|
243
280
|
|
|
@@ -251,30 +288,39 @@ addDebugLog("importComp", `filePath: ${filePath}, fileName: ${fileName}`, "");
|
|
|
251
288
|
console.log(`\n${chalk.green(`${fileName}`)} has been imported as ${chalk.green(`${newCompKey}`)}\n`);
|
|
252
289
|
|
|
253
290
|
if (askValidate) {
|
|
254
|
-
const validateAnswers = await inquirer.prompt([
|
|
255
|
-
{
|
|
256
|
-
name: 'doValidate',
|
|
257
|
-
type: 'confirm',
|
|
258
|
-
message: `Validate ${chalk.yellow(`${newCompKey}`)}`,
|
|
259
|
-
default: true
|
|
260
|
-
}]);
|
|
261
|
-
|
|
262
|
-
if (validateAnswers.doValidate) {
|
|
263
|
-
const args = [ '','', '', `${newCompKey}`];
|
|
264
|
-
let myOptions = {};
|
|
265
|
-
myOptions["params"] = args;
|
|
266
|
-
|
|
267
|
-
await buildComponent(myOptions);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
|
|
272
291
|
|
|
292
|
+
if (useInputConfig) {
|
|
293
|
+
const inputConfig = await getInputConfigForCommand("importComponent");
|
|
294
|
+
if (convertYNToBoolean(inputConfig.doValidation)) {
|
|
295
|
+
const args = [ '','', '', `${newCompKey}`];
|
|
296
|
+
let myOptions = {};
|
|
297
|
+
myOptions["params"] = args;
|
|
273
298
|
|
|
274
|
-
|
|
299
|
+
await buildComponent(myOptions);
|
|
300
|
+
}
|
|
275
301
|
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
const validateAnswers = await inquirer.prompt([
|
|
305
|
+
{
|
|
306
|
+
name: 'doValidate',
|
|
307
|
+
type: 'confirm',
|
|
308
|
+
message: `Validate ${chalk.yellow(`${newCompKey}`)}`,
|
|
309
|
+
default: true
|
|
310
|
+
}]);
|
|
311
|
+
|
|
312
|
+
if (validateAnswers.doValidate) {
|
|
313
|
+
const args = [ '','', '', `${newCompKey}`];
|
|
314
|
+
let myOptions = {};
|
|
315
|
+
myOptions["params"] = args;
|
|
316
|
+
|
|
317
|
+
await buildComponent(myOptions);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
276
320
|
|
|
321
|
+
}
|
|
277
322
|
|
|
323
|
+
}
|
|
278
324
|
|
|
279
325
|
}
|
|
280
326
|
|
|
@@ -321,6 +367,8 @@ export default async options => {
|
|
|
321
367
|
await checkLibraryAndArchives();
|
|
322
368
|
await checkPathAccess(pegaConfigJsonPath);
|
|
323
369
|
|
|
370
|
+
const useInputConfig = getUseInputConfig();
|
|
371
|
+
|
|
324
372
|
addDebugLog("importComponent", "", "+");
|
|
325
373
|
|
|
326
374
|
if (options.params.length >= 5) {
|
|
@@ -340,22 +388,36 @@ addDebugLog("importComponent", "", "+");
|
|
|
340
388
|
}
|
|
341
389
|
else {
|
|
342
390
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
391
|
+
let filePath;
|
|
392
|
+
let fileName;
|
|
393
|
+
|
|
394
|
+
if (useInputConfig) {
|
|
395
|
+
const inputConfig = await getInputConfigForCommand("importComponent");
|
|
396
|
+
filePath = inputConfig.fileLocation;
|
|
397
|
+
fileName = inputConfig.fileName;
|
|
398
|
+
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
const filePathQuestions = await getFilePathQuestions();
|
|
402
|
+
const filePathAnswers = await inquirer.prompt(filePathQuestions);
|
|
403
|
+
({ filePath } = filePathAnswers);
|
|
404
|
+
|
|
405
|
+
const compFileList = await getComponentList(filePath);
|
|
406
|
+
|
|
407
|
+
if (!compFileList || compFileList.length === 0) {
|
|
408
|
+
console.log(chalk.red.bold(`No component files exist at path: ${filePath}`));
|
|
409
|
+
process.exit();
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
await updateSavedFilePath(filePath);
|
|
346
413
|
|
|
347
|
-
|
|
414
|
+
const fileNameQuestions = await getFileNameQuestions(compFileList);
|
|
415
|
+
const fileNameAnswers = await inquirer.prompt(fileNameQuestions);
|
|
416
|
+
({fileName} = fileNameAnswers);
|
|
348
417
|
|
|
349
|
-
if (!compFileList || compFileList.length === 0) {
|
|
350
|
-
console.log(chalk.red.bold(`No component files exist at path: ${filePath}`));
|
|
351
|
-
process.exit();
|
|
352
418
|
}
|
|
353
419
|
|
|
354
|
-
await updateSavedFilePath(filePath);
|
|
355
420
|
|
|
356
|
-
const fileNameQuestions = await getFileNameQuestions(compFileList);
|
|
357
|
-
const fileNameAnswers = await inquirer.prompt(fileNameQuestions);
|
|
358
|
-
const {fileName} = fileNameAnswers;
|
|
359
421
|
|
|
360
422
|
await importComp( filePath, fileName, true);
|
|
361
423
|
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
},
|
|
102
102
|
"devDependencies": {
|
|
103
103
|
"@pega/configs": "^0.15.1",
|
|
104
|
-
"@pega/custom-dx-components": "~24.2.
|
|
104
|
+
"@pega/custom-dx-components": "~24.2.14",
|
|
105
105
|
"@pega/pcore-pconnect-typedefs": "3.2.1",
|
|
106
106
|
"@storybook/addon-actions": "^7.6.19",
|
|
107
107
|
"@storybook/addon-essentials": "^7.6.19",
|
|
@@ -6,7 +6,7 @@ import fs from 'fs';
|
|
|
6
6
|
import validate from '../validator/index.js';
|
|
7
7
|
import bundleComponent from '../bundle/index.js';
|
|
8
8
|
import { lintComponent } from '../linter/index.js';
|
|
9
|
-
import { getComponentDirectoryPath, showVersion, getLibraryBased, addDebugLog, getPegaServerConfig, updateServerConfigRuleSetAndVersion, checkLibraryAndArchives, getConfigDevBuild, checkJWTExpiration, getConfigDefaults } from '../../util.js';
|
|
9
|
+
import { getComponentDirectoryPath, showVersion, getLibraryBased, getUseInputConfig, addDebugLog, getPegaServerConfig, updateServerConfigRuleSetAndVersion, checkLibraryAndArchives, getConfigDevBuild, checkJWTExpiration, getConfigDefaults, getInputConfigForCommand } from '../../util.js';
|
|
10
10
|
|
|
11
11
|
import { getPublishComponentQuestions, publishComponentToServer, zipComponent } from './helper.js';
|
|
12
12
|
import { default as buildLibrary } from '../build-lib/index.js';
|
|
@@ -21,6 +21,7 @@ export default async options => {
|
|
|
21
21
|
await showVersion();
|
|
22
22
|
await checkLibraryAndArchives();
|
|
23
23
|
const isLibraryBased = getLibraryBased();
|
|
24
|
+
const useInputConfig = getUseInputConfig();
|
|
24
25
|
|
|
25
26
|
addDebugLog("publish", "", "+");
|
|
26
27
|
|
|
@@ -37,34 +38,49 @@ addDebugLog("publish", "", "+");
|
|
|
37
38
|
const currentVersion = orgLib.buildVersion;
|
|
38
39
|
|
|
39
40
|
|
|
41
|
+
if (useInputConfig) {
|
|
42
|
+
const inputConfig = await getInputConfigForCommand("publish");
|
|
43
|
+
|
|
44
|
+
console.log("Input config: ");
|
|
45
|
+
console.log(inputConfig);
|
|
46
|
+
|
|
47
|
+
if (inputConfig.okToPublish ) {
|
|
48
|
+
if (devBuild || (!devBuild && inputConfig.okToPublishPermanent)) {
|
|
49
|
+
okToPublish = true;
|
|
50
|
+
}
|
|
40
51
|
|
|
41
|
-
const publishThisVersion = await inquirer.prompt([
|
|
42
|
-
{
|
|
43
|
-
name: 'confirmPublish',
|
|
44
|
-
type: 'confirm',
|
|
45
|
-
message: `Publish ${chalk.bold.green(`${orgLib.displayLibVersion}`)}, proceed ?`,
|
|
46
|
-
default: true
|
|
47
52
|
}
|
|
48
|
-
]);
|
|
49
53
|
|
|
50
|
-
if (publishThisVersion.confirmPublish) {
|
|
51
|
-
okToPublish = true;
|
|
52
54
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
okToPublish = false;
|
|
56
|
-
console.log("");
|
|
57
|
-
const publishAnswers = await inquirer.prompt([
|
|
55
|
+
else {
|
|
56
|
+
const publishThisVersion = await inquirer.prompt([
|
|
58
57
|
{
|
|
59
58
|
name: 'confirmPublish',
|
|
60
59
|
type: 'confirm',
|
|
61
|
-
message: `
|
|
62
|
-
default:
|
|
60
|
+
message: `Publish ${chalk.bold.green(`${orgLib.displayLibVersion}`)}, proceed ?`,
|
|
61
|
+
default: true
|
|
63
62
|
}
|
|
64
63
|
]);
|
|
65
|
-
|
|
64
|
+
|
|
65
|
+
if (publishThisVersion.confirmPublish) {
|
|
66
66
|
okToPublish = true;
|
|
67
67
|
}
|
|
68
|
+
|
|
69
|
+
if (okToPublish && !devBuild) {
|
|
70
|
+
okToPublish = false;
|
|
71
|
+
console.log("");
|
|
72
|
+
const publishAnswers = await inquirer.prompt([
|
|
73
|
+
{
|
|
74
|
+
name: 'confirmPublish',
|
|
75
|
+
type: 'confirm',
|
|
76
|
+
message: `You are about to publish a ${chalk.bold.yellow('PRODUCTION')} version which can ${chalk.bold.yellow('NOT')} be deleted, proceed ?`,
|
|
77
|
+
default: false
|
|
78
|
+
}
|
|
79
|
+
]);
|
|
80
|
+
if (publishAnswers.confirmPublish) {
|
|
81
|
+
okToPublish = true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
68
84
|
}
|
|
69
85
|
|
|
70
86
|
if (okToPublish) {
|
|
@@ -4,7 +4,7 @@ import chalk from 'chalk';
|
|
|
4
4
|
|
|
5
5
|
import validate from '../validator/index.js';
|
|
6
6
|
import { lintComponent } from '../linter/index.js';
|
|
7
|
-
import { getComponentDirectoryPath, showVersion, getC11NB2STokenAndStaticServer, getLocalLibraryVersions, getLibraryBased, deletePublishExtras, addDebugLog, checkLibraryAndArchives, checkJWTExpiration, getConfigDefaults } from '../../util.js';
|
|
7
|
+
import { getComponentDirectoryPath, showVersion, getC11NB2STokenAndStaticServer, getLocalLibraryVersions, getLibraryBased, deletePublishExtras, addDebugLog, checkLibraryAndArchives, checkJWTExpiration, getConfigDefaults, getUseInputConfig, getInputConfigForCommand } from '../../util.js';
|
|
8
8
|
|
|
9
9
|
import { publishLib, listLibJSONResponse, deleteLibVersion } from '@pega/constellation-dx-components-build-utils/index.js';
|
|
10
10
|
|
|
@@ -178,6 +178,11 @@ addDebugLog("publishLibrary", "", "+");
|
|
|
178
178
|
({version} = versionAnswers);
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
+
const useInputConfig = getUseInputConfig();
|
|
182
|
+
let inputConfig = {};
|
|
183
|
+
if (useInputConfig) {
|
|
184
|
+
inputConfig = await getInputConfigForCommand("publish");
|
|
185
|
+
}
|
|
181
186
|
|
|
182
187
|
let okToPublish = true;
|
|
183
188
|
|
|
@@ -190,6 +195,8 @@ addDebugLog("publishLibrary", "", "+");
|
|
|
190
195
|
|
|
191
196
|
if (!version.includes("-dev") && !internalPublish) {
|
|
192
197
|
okToPublish = false;
|
|
198
|
+
|
|
199
|
+
|
|
193
200
|
const publishAnswers = await inquirer.prompt([
|
|
194
201
|
|
|
195
202
|
{
|
|
@@ -204,6 +211,9 @@ addDebugLog("publishLibrary", "", "+");
|
|
|
204
211
|
}
|
|
205
212
|
}
|
|
206
213
|
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
207
217
|
if (noRealPublish) {
|
|
208
218
|
// this is as far as JEST test can go since need server for rest and don't want to use server.
|
|
209
219
|
console.log("OK to publish.");
|
|
@@ -218,8 +228,15 @@ addDebugLog("publishLibrary", "", "+");
|
|
|
218
228
|
|
|
219
229
|
await deletePublishExtras(libraryName, version);
|
|
220
230
|
|
|
231
|
+
if (useInputConfig) {
|
|
232
|
+
if (inputConfig.okToOverride) {
|
|
233
|
+
// to override
|
|
234
|
+
overrideExisting = true;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
221
237
|
|
|
222
|
-
|
|
238
|
+
|
|
239
|
+
if (libVersionExists && !overrideExisting) {
|
|
223
240
|
console.log("\nLibrary " + chalk.bold.yellow(`${libraryName}/${version}`) + " already exists.");
|
|
224
241
|
const questions = [
|
|
225
242
|
{
|
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
setConfigDevBuild,
|
|
14
14
|
updateConfigVersion,
|
|
15
15
|
checkLibraryAndArchives,
|
|
16
|
+
getUseInputConfig,
|
|
17
|
+
getInputConfigForCommand,
|
|
16
18
|
forceDefaultsUpdate } from '../../util.js';
|
|
17
19
|
import { showCurrentStatus } from '../show-status/index.js';
|
|
18
20
|
|
|
@@ -126,6 +128,8 @@ addDebugLog("setPermanent", "", "");
|
|
|
126
128
|
|
|
127
129
|
export default async options => {
|
|
128
130
|
const isLibraryBased = getLibraryBased();
|
|
131
|
+
const useInputConfig = getUseInputConfig();
|
|
132
|
+
|
|
129
133
|
if (!isLibraryBased) {
|
|
130
134
|
console.log(`Command only supported for ${chalk.bold.green('library mode')} components.`);
|
|
131
135
|
process.exit();
|
|
@@ -136,9 +140,17 @@ addDebugLog("setPerm", "", "+");
|
|
|
136
140
|
await checkLibraryAndArchives();
|
|
137
141
|
|
|
138
142
|
let inputYN = "";
|
|
143
|
+
if (useInputConfig) {
|
|
144
|
+
const inputConfig = await getInputConfigForCommand("setPermanent");
|
|
145
|
+
inputYN = inputConfig.makePermanent;
|
|
146
|
+
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
|
|
150
|
+
if (options.params.length >= 4) {
|
|
151
|
+
inputYN = options.params[3];
|
|
152
|
+
}
|
|
139
153
|
|
|
140
|
-
if (options.params.length >= 4) {
|
|
141
|
-
inputYN = options.params[3];
|
|
142
154
|
}
|
|
143
155
|
|
|
144
156
|
// await showCurrentStatus();
|
|
@@ -17,7 +17,11 @@ import {
|
|
|
17
17
|
forceDefaultsUpdate,
|
|
18
18
|
getHaveDependencyDifference,
|
|
19
19
|
cleanUpTemp,
|
|
20
|
-
getLibraryArchiveDirectories
|
|
20
|
+
getLibraryArchiveDirectories,
|
|
21
|
+
getUseInputConfig,
|
|
22
|
+
getInputConfigForCommand,
|
|
23
|
+
convertYNToBoolean,
|
|
24
|
+
hasArchives
|
|
21
25
|
} from '../../util.js';
|
|
22
26
|
|
|
23
27
|
import { getSwitchLibraryComponentQuestions, getSwitchVersionComponentQuestions } from './helper.js';
|
|
@@ -27,6 +31,8 @@ import { arch } from 'os';
|
|
|
27
31
|
|
|
28
32
|
export default async options => {
|
|
29
33
|
const isLibraryBased = getLibraryBased();
|
|
34
|
+
const useInputConfig = getUseInputConfig();
|
|
35
|
+
|
|
30
36
|
if (!isLibraryBased) {
|
|
31
37
|
console.log(`Command only supported for ${chalk.bold.green('library mode')} components.`);
|
|
32
38
|
process.exit();
|
|
@@ -48,61 +54,104 @@ addDebugLog("switchLibrary", "", "+");
|
|
|
48
54
|
const currentDirectory = process.cwd();
|
|
49
55
|
const componentDirectory = join (currentDirectory, "src", "components");
|
|
50
56
|
|
|
51
|
-
|
|
52
|
-
if (options.params.length >= 6) {
|
|
53
|
-
newOrgLib = options.params[3];
|
|
54
|
-
version = options.params[4];
|
|
57
|
+
const orgLib = getConfigDefaults();
|
|
55
58
|
|
|
56
|
-
const okToCont = options.params[5];
|
|
57
|
-
okToContinue = !!(okToCont === 'Y' || okToCont === 'y' || okToCont === true || okToCont === 'true');
|
|
58
59
|
|
|
60
|
+
// if we have choosen to use INPUT CONFIG FILE
|
|
61
|
+
// process and no inputs
|
|
62
|
+
if (useInputConfig) {
|
|
63
|
+
const inputConfig = await getInputConfigForCommand("switchLib");
|
|
59
64
|
|
|
60
|
-
|
|
65
|
+
if (convertYNToBoolean(inputConfig.okToContinue)) {
|
|
66
|
+
const newLibraryName = inputConfig.libraryName;
|
|
67
|
+
newOrgLib = `${orgLib.organization}_${newLibraryName}`;
|
|
68
|
+
version = inputConfig.libraryVersion;
|
|
69
|
+
const isPermanent = inputConfig.isPermanent;
|
|
70
|
+
const permBuild = convertYNToBoolean(isPermanent);
|
|
61
71
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
72
|
+
const hasArch = await hasArchives();
|
|
73
|
+
if (hasArch) {
|
|
74
|
+
if (orgLib.currentOrgLib === newOrgLib) {
|
|
75
|
+
console.log(`${chalk.bold.red(`Your current library is already ${orgLib.displayLibVersion}`)}`);
|
|
76
|
+
process.exit();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
console.log(`${chalk.bold.red(`No libraries exist.`)}`);
|
|
81
|
+
console.log("You need to create a library first via 'npm run createLib'.\n")
|
|
82
|
+
process.exit();
|
|
83
|
+
}
|
|
69
84
|
|
|
70
|
-
|
|
85
|
+
// version here includes -dev if appropriate
|
|
86
|
+
if (!permBuild) {
|
|
87
|
+
version = version.concat("-dev");
|
|
88
|
+
}
|
|
71
89
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
console.log(chalk.red(`No other available libraries to switch to.`));
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
75
92
|
process.exit();
|
|
76
93
|
}
|
|
77
94
|
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
// params are in different order then questions, because want of VS Code pluggin
|
|
98
|
+
if (options.params.length >= 6) {
|
|
99
|
+
newOrgLib = options.params[3];
|
|
100
|
+
version = options.params[4];
|
|
78
101
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
({ okToContinue, newOrgLib } = answers);
|
|
102
|
+
const okToCont = options.params[5];
|
|
103
|
+
okToContinue = !!(okToCont === 'Y' || okToCont === 'y' || okToCont === true || okToCont === 'true');
|
|
82
104
|
|
|
83
|
-
if (!answers.okToContinue) {
|
|
84
|
-
process.exit()
|
|
85
|
-
}
|
|
86
105
|
|
|
87
|
-
if (newOrgLib === ""|| newOrgLib === undefined ) {
|
|
88
|
-
newOrgLib = inputOrgLib;
|
|
89
106
|
}
|
|
107
|
+
else {
|
|
90
108
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
109
|
+
if (options.params.length >= 5) {
|
|
110
|
+
inputOrgLib = options.params[3];
|
|
111
|
+
version = options.params[4];
|
|
112
|
+
}
|
|
113
|
+
else if (options.params.length >= 4) {
|
|
114
|
+
inputOrgLib = options.params[3];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const orgLib = getConfigDefaults();
|
|
96
118
|
|
|
119
|
+
const archVersionList = await getLibraryArchiveDirectories(orgLib.currentOrgLib);
|
|
120
|
+
if (archVersionList.length === 0) {
|
|
121
|
+
console.log(chalk.red(`No other available libraries to switch to.`));
|
|
122
|
+
process.exit();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
const questions = await getSwitchLibraryComponentQuestions(archVersionList, inputOrgLib);
|
|
127
|
+
const answers = await inquirer.prompt(questions);
|
|
128
|
+
({ okToContinue, newOrgLib } = answers);
|
|
129
|
+
|
|
130
|
+
if (!answers.okToContinue) {
|
|
131
|
+
process.exit()
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (newOrgLib === ""|| newOrgLib === undefined ) {
|
|
135
|
+
newOrgLib = inputOrgLib;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (version === "" || version === undefined) {
|
|
139
|
+
const nextQuestion = await getSwitchVersionComponentQuestions(newOrgLib);
|
|
140
|
+
const nextAnswers = await inquirer.prompt(nextQuestion);
|
|
141
|
+
({ version } = nextAnswers);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
}
|
|
97
145
|
}
|
|
98
146
|
|
|
99
|
-
// in this scenario, version contains "-dev", if appropriate
|
|
100
147
|
|
|
101
|
-
|
|
148
|
+
|
|
149
|
+
// in this scenario, version contains "-dev", if appropriate
|
|
102
150
|
const newVersion = version;
|
|
103
151
|
const existingOrgLib = orgLib.currentOrgLib;
|
|
104
152
|
let oldVersion = orgLib.buildVersion;
|
|
105
153
|
|
|
154
|
+
|
|
106
155
|
const switchToFileName = `${newOrgLib}_${newVersion}.zip`;
|
|
107
156
|
|
|
108
157
|
console.log("");
|