@pega/custom-dx-components 0.242.28 → 0.242.29
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/cli.js +30 -0
- package/src/constants.js +3 -2
- package/src/tasks/build-comp/helper.js +6 -4
- package/src/tasks/bundle/builder/index.js +8 -6
- package/src/tasks/create/index.js +4 -2
- package/src/tasks/create-all/index.js +5 -3
- package/src/tasks/create-lib/index.js +4 -6
- package/src/tasks/create-version/helper.js +1 -0
- package/src/tasks/create-version/index.js +10 -6
- package/src/tasks/delete/index.js +1 -1
- package/src/tasks/delete-all/index.js +1 -1
- package/src/tasks/delete-lib/index.js +55 -32
- package/src/tasks/delete-pub/index.js +3 -2
- package/src/tasks/delete-version/index.js +45 -0
- package/src/tasks/export-archive/helper.js +85 -0
- package/src/tasks/export-archive/index.js +224 -0
- package/src/tasks/import-archive/helper.js +51 -0
- package/src/tasks/import-archive/index.js +301 -0
- package/src/tasks/index.js +5 -0
- package/src/tasks/init/template/package.json.mustache +20 -12
- package/src/tasks/list/helper.js +2 -2
- package/src/tasks/list/index.js +1 -1
- package/src/tasks/list-lib/index.js +8 -10
- package/src/tasks/list-pub/index.js +3 -3
- package/src/tasks/move/helper.js +56 -0
- package/src/tasks/move/index.js +441 -0
- package/src/tasks/promote-webpack/index.js +2 -3
- package/src/tasks/publish/index.js +1 -2
- package/src/tasks/publish-all/index.js +2 -2
- package/src/tasks/publish-lib/index.js +8 -4
- package/src/tasks/rename-lib/index.js +2 -3
- package/src/tasks/revert-webpack/index.js +2 -3
- package/src/tasks/show-status/index.js +2 -3
- package/src/tasks/store/index.js +53 -0
- package/src/tasks/switch-lib/index.js +4 -4
- package/src/tasks/switch-version/index.js +10 -6
- package/src/util.js +229 -177
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -16,6 +16,9 @@ import {
|
|
|
16
16
|
deleteAllComponents,
|
|
17
17
|
deleteLibrary,
|
|
18
18
|
deletePublished,
|
|
19
|
+
deleteVersion,
|
|
20
|
+
importArchive,
|
|
21
|
+
exportArchive,
|
|
19
22
|
initProject,
|
|
20
23
|
listComponents,
|
|
21
24
|
listLibrary,
|
|
@@ -24,10 +27,12 @@ import {
|
|
|
24
27
|
publishAllComponents,
|
|
25
28
|
publishLibrary,
|
|
26
29
|
renameComponent,
|
|
30
|
+
moveComponent,
|
|
27
31
|
renameLibrary,
|
|
28
32
|
revertWebPack,
|
|
29
33
|
promoteWebPack,
|
|
30
34
|
showStatus,
|
|
35
|
+
storeComponents,
|
|
31
36
|
updateComponent,
|
|
32
37
|
validate,
|
|
33
38
|
upgrade,
|
|
@@ -52,16 +57,21 @@ const TASKS = {
|
|
|
52
57
|
PUBLISH_LIB: 'publishLibrary',
|
|
53
58
|
RENAME: 'rename',
|
|
54
59
|
RENAME_LIB: 'renameLibrary',
|
|
60
|
+
MOVE: 'moveComponent',
|
|
55
61
|
LIST: 'list',
|
|
56
62
|
LIST_LIB: 'listLibrary',
|
|
57
63
|
LIST_PUB: 'listPublished',
|
|
58
64
|
SHOW_STATUS: 'showStatus',
|
|
65
|
+
STORE: 'storeComponents',
|
|
59
66
|
VALIDATE_SCHEMA: 'validateSchema',
|
|
60
67
|
UPDATE: 'update',
|
|
61
68
|
DELETE: 'delete',
|
|
62
69
|
DELETE_ALL: 'deleteAll',
|
|
63
70
|
DELETE_LIBRARY: 'deleteLibrary',
|
|
64
71
|
DELETE_PUB: 'deletePublished',
|
|
72
|
+
DELETE_VERSION: 'deleteVersion',
|
|
73
|
+
IMPORT_ARCHIVE: 'importArchive',
|
|
74
|
+
EXPORT_ARCHIVE: 'exportArchive',
|
|
65
75
|
AUTHENTICATE: 'authenticate',
|
|
66
76
|
UPGRADE: 'upgrade',
|
|
67
77
|
BUILD_JEST_ASSETS: 'buildJestAssets'
|
|
@@ -146,6 +156,10 @@ export default async (args = []) => {
|
|
|
146
156
|
renameLibrary(options);
|
|
147
157
|
break;
|
|
148
158
|
}
|
|
159
|
+
case TASKS.MOVE: {
|
|
160
|
+
moveComponent(options);
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
149
163
|
case TASKS.BUILD: {
|
|
150
164
|
buildComponent(options);
|
|
151
165
|
break;
|
|
@@ -174,6 +188,18 @@ export default async (args = []) => {
|
|
|
174
188
|
showStatus(options);
|
|
175
189
|
break;
|
|
176
190
|
}
|
|
191
|
+
case TASKS.STORE: {
|
|
192
|
+
storeComponents(options);
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
case TASKS.IMPORT_ARCHIVE: {
|
|
196
|
+
importArchive(options);
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
case TASKS.EXPORT_ARCHIVE: {
|
|
200
|
+
exportArchive(options);
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
177
203
|
case TASKS.VALIDATE_SCHEMA: {
|
|
178
204
|
validate(options);
|
|
179
205
|
break;
|
|
@@ -198,6 +224,10 @@ export default async (args = []) => {
|
|
|
198
224
|
deletePublished(options);
|
|
199
225
|
break;
|
|
200
226
|
}
|
|
227
|
+
case TASKS.DELETE_VERSION: {
|
|
228
|
+
deleteVersion(options);
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
201
231
|
case TASKS.AUTHENTICATE: {
|
|
202
232
|
authenticate(options);
|
|
203
233
|
break;
|
package/src/constants.js
CHANGED
|
@@ -9,10 +9,11 @@ export const COMPONENTS_DIRECTORY_PATH = 'components-directory-path';
|
|
|
9
9
|
export const COMPONENTS_PATH = 'component';
|
|
10
10
|
export const TOKEN_PATH = 'node_modules/@pega/custom-dx-components/.access_token';
|
|
11
11
|
export const OOTB_COMPONENTS = 'node_modules/@pega/custom-dx-components/.ootb_components';
|
|
12
|
-
export const LIBRARY_BASED = '
|
|
12
|
+
export const LIBRARY_BASED = 'libraryMode';
|
|
13
13
|
export const SHARED_DIRECTORY = 'shared';
|
|
14
14
|
export const SHOW_DEBUG = 'showDebug';
|
|
15
|
-
export const ARCHIVES_PATH = '
|
|
15
|
+
export const ARCHIVES_PATH = 'store';
|
|
16
|
+
export const TEMP_PATH = 'store/temp';
|
|
16
17
|
export const COMPONENTS_CONFIG_FILE_NAME = 'componentsconfig.json';
|
|
17
18
|
|
|
18
19
|
/* REST end points */
|
|
@@ -15,12 +15,14 @@ import {
|
|
|
15
15
|
} from '../../util.js';
|
|
16
16
|
import { PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH } from '../../constants.js';
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
// validate and validateAll will be called when libraryBased, but using same code
|
|
20
|
-
// so need different label
|
|
21
|
-
const buildLabel = isLibraryBased ? "validate" : "build";
|
|
18
|
+
|
|
22
19
|
|
|
23
20
|
export const getPublishComponentQuestions = async componentKey => {
|
|
21
|
+
const isLibraryBased = getLibraryBased();
|
|
22
|
+
// validate and validateAll will be called when libraryBased, but using same code
|
|
23
|
+
// so need different label
|
|
24
|
+
const buildLabel = isLibraryBased ? "validate" : "build";
|
|
25
|
+
|
|
24
26
|
const components = await getComponents();
|
|
25
27
|
|
|
26
28
|
if (components.length === 0) {
|
|
@@ -6,11 +6,7 @@ import printBuildError from 'react-dev-utils/printBuildError.js';
|
|
|
6
6
|
import { getUseWebPackPromotion, addDebugLog} from '../../../util.js';
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
// used by promote and revert webPack commands, do not change
|
|
11
|
-
const configFactory = (
|
|
12
|
-
await import(`${usePromoted ? `../../../../../../../webpack.config.js` : `./webpack.config.js`}`)
|
|
13
|
-
).default
|
|
9
|
+
|
|
14
10
|
|
|
15
11
|
|
|
16
12
|
import paths from './paths.js';
|
|
@@ -138,7 +134,7 @@ addDebugLog("bundle build", `config: ${JSON.stringify(config)}, \npreviousFileSi
|
|
|
138
134
|
});
|
|
139
135
|
}
|
|
140
136
|
|
|
141
|
-
export default ({
|
|
137
|
+
export default async ({
|
|
142
138
|
inputFile,
|
|
143
139
|
outputFile,
|
|
144
140
|
componentKey,
|
|
@@ -148,6 +144,12 @@ export default ({
|
|
|
148
144
|
devBuild,
|
|
149
145
|
showStats
|
|
150
146
|
}) => {
|
|
147
|
+
const usePromoted = await getUseWebPackPromotion();
|
|
148
|
+
// used by promote and revert webPack commands, do not change
|
|
149
|
+
const configFactory = (
|
|
150
|
+
await import(`${usePromoted ? `../../../../../../../webpack.config.js` : `./webpack.config.js`}`)
|
|
151
|
+
).default
|
|
152
|
+
|
|
151
153
|
// Generate configuration
|
|
152
154
|
const config = configFactory(Env, {
|
|
153
155
|
inputFile,
|
|
@@ -34,7 +34,6 @@ const copyComponentTemplate = async options => {
|
|
|
34
34
|
});
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
const isLibraryBased = getLibraryBased();
|
|
38
37
|
|
|
39
38
|
const compileMustacheTemplates = async (
|
|
40
39
|
componentDirectory,
|
|
@@ -53,6 +52,7 @@ const compileMustacheTemplates = async (
|
|
|
53
52
|
) => {
|
|
54
53
|
const files = fs.readdirSync(componentDirectory);
|
|
55
54
|
const componentClassName = convertIntoPascalCase(componentKey);
|
|
55
|
+
const isLibraryBased = getLibraryBased();
|
|
56
56
|
|
|
57
57
|
const isTemplate = type === 'Template';
|
|
58
58
|
const isBool = subtype === 'Boolean';
|
|
@@ -174,6 +174,7 @@ const validateCompile = async (
|
|
|
174
174
|
options
|
|
175
175
|
) => {
|
|
176
176
|
|
|
177
|
+
const isLibraryBased = getLibraryBased();
|
|
177
178
|
let sSubType = subtype;
|
|
178
179
|
if (Array.isArray(subtype)) {
|
|
179
180
|
sSubType = subtype.join("-");
|
|
@@ -269,6 +270,7 @@ export default async options => {
|
|
|
269
270
|
await showVersion();
|
|
270
271
|
|
|
271
272
|
await checkLibraryAndArchives();
|
|
273
|
+
const isLibraryBased = getLibraryBased();
|
|
272
274
|
|
|
273
275
|
|
|
274
276
|
addDebugLog("create", "", "+");
|
|
@@ -411,7 +413,7 @@ addDebugLog("create", "", "+");
|
|
|
411
413
|
},
|
|
412
414
|
{
|
|
413
415
|
name: 'description',
|
|
414
|
-
message: 'Enter description for the component',
|
|
416
|
+
message: 'Enter description for the component (default is label)',
|
|
415
417
|
default: componentDefaults.description
|
|
416
418
|
}
|
|
417
419
|
];
|
|
@@ -34,7 +34,7 @@ const pegaConfigJsonPath = path.join(path.resolve(), TASKS_CONFIG_JSON_FILENAME)
|
|
|
34
34
|
|
|
35
35
|
const copy = promisify(ncp);
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
|
|
39
39
|
const copyComponentTemplate = async (options) => {
|
|
40
40
|
if (options.targetDirectory) {
|
|
@@ -59,6 +59,7 @@ export const compileMustacheTemplates = async (
|
|
|
59
59
|
) => {
|
|
60
60
|
const files = fs.readdirSync(componentDirectory);
|
|
61
61
|
const componentClassName = convertIntoPascalCase(componentKey);
|
|
62
|
+
const isLibraryBased = getLibraryBased();
|
|
62
63
|
|
|
63
64
|
const isTemplate = type === 'Template';
|
|
64
65
|
|
|
@@ -175,7 +176,7 @@ export const validateCompile = async (
|
|
|
175
176
|
sSubType = subtype.join('-');
|
|
176
177
|
}
|
|
177
178
|
|
|
178
|
-
|
|
179
|
+
const isLibraryBased = getLibraryBased();
|
|
179
180
|
framework = convertIntoPascalCase(CATEGORY_CONSTELLATION);
|
|
180
181
|
|
|
181
182
|
const templateParentDir = `./templates/${framework}`;
|
|
@@ -358,9 +359,10 @@ export const validateCompileAll = async ({ prefix, library, version, allowedAppl
|
|
|
358
359
|
|
|
359
360
|
export default async (options) => {
|
|
360
361
|
await showVersion();
|
|
361
|
-
|
|
362
362
|
await checkLibraryAndArchives();
|
|
363
363
|
|
|
364
|
+
const isLibraryBased = getLibraryBased();
|
|
365
|
+
|
|
364
366
|
addDebugLog("createAll", "", "+");
|
|
365
367
|
|
|
366
368
|
await checkPathAccess(pegaConfigJsonPath);
|
|
@@ -20,10 +20,8 @@ import {
|
|
|
20
20
|
import { getCreateLibComponentQuestions, getOkToProceedQuestion } from './helper.js';
|
|
21
21
|
import { showCurrentStatus } from '../show-status/index.js';
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
const isLibraryBased = getLibraryBased();
|
|
25
|
-
|
|
26
23
|
export default async options => {
|
|
24
|
+
const isLibraryBased = getLibraryBased();
|
|
27
25
|
if (!isLibraryBased) {
|
|
28
26
|
console.log(`Command only supported for ${chalk.bold.green('library based')} components.`);
|
|
29
27
|
process.exit();
|
|
@@ -41,7 +39,7 @@ addDebugLog("createLibrary", "", "+");
|
|
|
41
39
|
|
|
42
40
|
if (hasArch) {
|
|
43
41
|
console.log(chalk.bold.yellow('\nBe sure to SAVE all changes before creating a new library, unsaved changes will be LOST.'))
|
|
44
|
-
console.log(chalk.bold.yellow('Current library/version will be
|
|
42
|
+
console.log(chalk.bold.yellow('Current library/version will be stored and the newly created library/version will be your default.'))
|
|
45
43
|
|
|
46
44
|
const okQuestion = await getOkToProceedQuestion();
|
|
47
45
|
const okAnswers = await inquirer.prompt(okQuestion);
|
|
@@ -65,8 +63,8 @@ addDebugLog("createLibrary", "", "+");
|
|
|
65
63
|
|
|
66
64
|
|
|
67
65
|
|
|
68
|
-
// if have
|
|
69
|
-
//
|
|
66
|
+
// if have store, then that means there is a current library, so
|
|
67
|
+
// store it before clearing out /src/components
|
|
70
68
|
|
|
71
69
|
if (hasArch) {
|
|
72
70
|
|
|
@@ -14,16 +14,17 @@ import {
|
|
|
14
14
|
zipVersionAndArchive,
|
|
15
15
|
setConfigDevBuild,
|
|
16
16
|
checkLibraryAndArchives,
|
|
17
|
-
getConfigDefaults
|
|
17
|
+
getConfigDefaults,
|
|
18
|
+
forceDefaultsUpdate
|
|
18
19
|
} from '../../util.js';
|
|
19
20
|
|
|
20
21
|
import { getCreateVersionComponentQuestions, updateAllComponentsConfig } from './helper.js';
|
|
21
|
-
|
|
22
|
-
const isLibraryBased = getLibraryBased();
|
|
22
|
+
import { showCurrentStatus } from '../show-status/index.js';
|
|
23
23
|
|
|
24
24
|
export default async options => {
|
|
25
|
+
const isLibraryBased = getLibraryBased();
|
|
25
26
|
if (!isLibraryBased) {
|
|
26
|
-
console.log(`Command only supported for ${chalk.bold.green('library
|
|
27
|
+
console.log(`Command only supported for ${chalk.bold.green('library mode')} components.`);
|
|
27
28
|
process.exit();
|
|
28
29
|
}
|
|
29
30
|
|
|
@@ -67,7 +68,7 @@ addDebugLog("createVersion", "", "+");
|
|
|
67
68
|
version = version.concat("-dev");
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
//
|
|
71
|
+
// store existing
|
|
71
72
|
await zipVersionAndArchive(existingOrgLib, oldVersion);
|
|
72
73
|
|
|
73
74
|
if (copyExisting) {
|
|
@@ -98,9 +99,12 @@ addDebugLog("createVersion", `make new directory: ${componentDirectory}`, "");
|
|
|
98
99
|
|
|
99
100
|
|
|
100
101
|
|
|
101
|
-
console.log(`${chalk.bold.green(`\nLibrary ${existingOrgLib}/${oldVersion} has been
|
|
102
|
+
console.log(`${chalk.bold.green(`\nLibrary ${existingOrgLib}/${oldVersion} has been stored.`)}`);
|
|
102
103
|
console.log(`${chalk.bold.green(`Library ${existingOrgLib}/${version} has been created!\n`)}`);
|
|
103
104
|
|
|
105
|
+
await forceDefaultsUpdate();
|
|
106
|
+
await showCurrentStatus();
|
|
107
|
+
|
|
104
108
|
|
|
105
109
|
addDebugLog("createVersion", "END", "-");
|
|
106
110
|
|
|
@@ -4,7 +4,6 @@ import { showVersion, getLibraryBased, addDebugLog, checkLibraryAndArchives } fr
|
|
|
4
4
|
|
|
5
5
|
import { deleteLocalComponents, SOURCE_OF_COMPONENT_TYPES, deleteServerComponents, getDeleteComponentsQuestions } from './helper.js';
|
|
6
6
|
|
|
7
|
-
const isLibraryBased = getLibraryBased();
|
|
8
7
|
|
|
9
8
|
const deleteComponentsFn = async (sourceOfComponents, answers, options) => {
|
|
10
9
|
addDebugLog("deleteComponentsFn", `sourceOfComponents: ${sourceOfComponents}`, "");
|
|
@@ -27,6 +26,7 @@ addDebugLog("deleteComponentsFn", `sourceOfComponents: ${sourceOfComponents}`, "
|
|
|
27
26
|
export default async (options) => {
|
|
28
27
|
await showVersion();
|
|
29
28
|
await checkLibraryAndArchives();
|
|
29
|
+
const isLibraryBased = getLibraryBased();
|
|
30
30
|
|
|
31
31
|
addDebugLog("delete", "", "+");
|
|
32
32
|
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
getDeleteComponentsQuestions
|
|
10
10
|
} from './helper.js';
|
|
11
11
|
|
|
12
|
-
const isLibraryBased = getLibraryBased();
|
|
13
12
|
|
|
14
13
|
const deleteComponentsFn = async (sourceOfComponents, answers, options) => {
|
|
15
14
|
addDebugLog('deleteComponentsFn', `sourceOfComponents: ${sourceOfComponents}`, '');
|
|
@@ -32,6 +31,7 @@ const deleteComponentsFn = async (sourceOfComponents, answers, options) => {
|
|
|
32
31
|
export default async options => {
|
|
33
32
|
await showVersion();
|
|
34
33
|
await checkLibraryAndArchives();
|
|
34
|
+
const isLibraryBased = getLibraryBased();
|
|
35
35
|
|
|
36
36
|
addDebugLog('deleteAll', '', '+');
|
|
37
37
|
|
|
@@ -20,41 +20,22 @@ import {
|
|
|
20
20
|
import { getDeleteLibraryQuestions, getLibraryVersionQuestion } from './helper.js';
|
|
21
21
|
import { showCurrentStatus } from '../show-status/index.js';
|
|
22
22
|
|
|
23
|
-
const isLibraryBased = getLibraryBased();
|
|
24
23
|
|
|
25
|
-
export default async (options) => {
|
|
26
|
-
if (!isLibraryBased) {
|
|
27
|
-
console.log(`Command only supported for ${chalk.bold.green('library based')} components.`)
|
|
28
|
-
process.exit();
|
|
29
|
-
}
|
|
30
24
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
addDebugLog("deleteLibrary", "", "+");
|
|
35
|
-
|
|
36
|
-
let sourceOfLibrary;
|
|
37
|
-
let organization;
|
|
38
|
-
let library;
|
|
39
|
-
let version;
|
|
40
|
-
let devBuild;
|
|
25
|
+
export const deleteLibraryVersion = async (libraryName, version = "") => {
|
|
26
|
+
addDebugLog("deleteLibraryVersion", "", "+");
|
|
41
27
|
|
|
28
|
+
const isLibraryBased = getLibraryBased();
|
|
42
29
|
const compDef = getConfigDefaults();
|
|
43
|
-
let libraryName;
|
|
44
30
|
let libVersions = [];
|
|
45
31
|
let confirmDeletion;
|
|
46
32
|
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
33
|
+
if (!isLibraryBased) {
|
|
34
|
+
console.log(`Command only supported for ${chalk.bold.green('library mode')} components.`);
|
|
35
|
+
process.exit();
|
|
51
36
|
}
|
|
52
|
-
else {
|
|
53
|
-
|
|
54
|
-
const questions = await getDeleteLibraryQuestions();
|
|
55
|
-
const answers = await inquirer.prompt(questions);
|
|
56
|
-
({ libraryName } = answers);
|
|
57
37
|
|
|
38
|
+
if (version === "") {
|
|
58
39
|
try {
|
|
59
40
|
libVersions = await getLibraryArchivesVersions(libraryName, "");
|
|
60
41
|
}
|
|
@@ -99,10 +80,10 @@ addDebugLog("deleteLibrary", "", "+");
|
|
|
99
80
|
|
|
100
81
|
}
|
|
101
82
|
else {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
addDebugLog("
|
|
105
|
-
|
|
83
|
+
// No library with that name
|
|
84
|
+
console.log(chalk.redBright(`No local library named: ${libraryName} exists.`));
|
|
85
|
+
addDebugLog("deleteLibraryVersion", "END", "-");
|
|
86
|
+
process.exit();
|
|
106
87
|
|
|
107
88
|
}
|
|
108
89
|
|
|
@@ -125,7 +106,7 @@ addDebugLog("deleteLibrary", "END", "-");
|
|
|
125
106
|
await deleteLocalComponent(component);
|
|
126
107
|
}
|
|
127
108
|
|
|
128
|
-
// switch to another version, if no versions to switch to then delete /
|
|
109
|
+
// switch to another version, if no versions to switch to then delete /store so will be back to state of nothing
|
|
129
110
|
const archiveLibraries = await getLibraryArchiveDirectories("");
|
|
130
111
|
if (archiveLibraries && archiveLibraries.length > 0) {
|
|
131
112
|
if (archiveLibraries.includes(libraryName)) {
|
|
@@ -135,6 +116,8 @@ addDebugLog("deleteLibrary", "END", "-");
|
|
|
135
116
|
await restoreFromArchive(switchToFileName, libraryName, lastVersion);
|
|
136
117
|
|
|
137
118
|
await forceDefaultsUpdate();
|
|
119
|
+
const configDef = getConfigDefaults();
|
|
120
|
+
console.log(`\nSwitched to ${chalk.green(`${configDef.displayLibVersion}`)}`);
|
|
138
121
|
await showCurrentStatus();
|
|
139
122
|
|
|
140
123
|
}
|
|
@@ -146,18 +129,58 @@ addDebugLog("deleteLibrary", "END", "-");
|
|
|
146
129
|
const switchToFileName = `${newLib}_${lastVersion}.zip`;
|
|
147
130
|
await restoreFromArchive(switchToFileName, newLib, lastVersion);
|
|
148
131
|
|
|
132
|
+
|
|
149
133
|
await forceDefaultsUpdate();
|
|
134
|
+
const configDef = getConfigDefaults();
|
|
135
|
+
console.log(`\nSwitched to ${chalk.green(`${configDef.displayLibVersion}`)}`);
|
|
150
136
|
await showCurrentStatus();
|
|
151
137
|
|
|
152
138
|
}
|
|
153
139
|
}
|
|
154
140
|
else {
|
|
155
|
-
// no libraries, so remove "/
|
|
141
|
+
// no libraries, so remove "/store"
|
|
156
142
|
await deleteArchives();
|
|
157
143
|
}
|
|
158
144
|
|
|
159
145
|
}
|
|
160
146
|
|
|
147
|
+
addDebugLog("deleteLibraryVersion", "END", "-");
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export default async (options) => {
|
|
152
|
+
const isLibraryBased = getLibraryBased();
|
|
153
|
+
if (!isLibraryBased) {
|
|
154
|
+
console.log(`Command only supported for ${chalk.bold.green('library based')} components.`)
|
|
155
|
+
process.exit();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
await showVersion();
|
|
159
|
+
await checkLibraryAndArchives();
|
|
160
|
+
|
|
161
|
+
addDebugLog("deleteLibrary", "", "+");
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
let version = "";
|
|
165
|
+
|
|
166
|
+
const compDef = getConfigDefaults();
|
|
167
|
+
let libraryName;
|
|
168
|
+
|
|
169
|
+
if (options.params.length >= 5) {
|
|
170
|
+
libraryName = options.params[3];
|
|
171
|
+
version = options.params[4];
|
|
172
|
+
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
|
|
176
|
+
const questions = await getDeleteLibraryQuestions();
|
|
177
|
+
const answers = await inquirer.prompt(questions);
|
|
178
|
+
({ libraryName } = answers);
|
|
179
|
+
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
await deleteLibraryVersion(libraryName, version);
|
|
183
|
+
|
|
161
184
|
|
|
162
185
|
|
|
163
186
|
addDebugLog("deleteLibrary", "END", "-");
|
|
@@ -7,11 +7,12 @@ import { deleteLib } from '@pega/constellation-dx-components-build-utils/index.j
|
|
|
7
7
|
|
|
8
8
|
import { getDeleteLibraryQuestions, getLibraryVersionQuestion, SOURCE_OF_COMPONENT_TYPES } from './helper.js';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
|
|
12
12
|
export default async (options) => {
|
|
13
|
+
const isLibraryBased = getLibraryBased();
|
|
13
14
|
if (!isLibraryBased) {
|
|
14
|
-
console.log(`Command only supported for ${chalk.bold.green('library
|
|
15
|
+
console.log(`Command only supported for ${chalk.bold.green('library mode')} components.`)
|
|
15
16
|
process.exit();
|
|
16
17
|
}
|
|
17
18
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
showVersion,
|
|
6
|
+
getLibraryBased,
|
|
7
|
+
checkLibraryAndArchives,
|
|
8
|
+
getConfigDefaults,
|
|
9
|
+
addDebugLog
|
|
10
|
+
} from '../../util.js';
|
|
11
|
+
|
|
12
|
+
import { deleteLibraryVersion } from '../delete-lib/index.js';
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export default async (options) => {
|
|
16
|
+
const isLibraryBased = getLibraryBased();
|
|
17
|
+
if (!isLibraryBased) {
|
|
18
|
+
console.log(`Command only supported for ${chalk.bold.green('library mode')} components.`)
|
|
19
|
+
process.exit();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
await showVersion();
|
|
23
|
+
await checkLibraryAndArchives();
|
|
24
|
+
|
|
25
|
+
addDebugLog("deleteVersion", "", "+");
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
let version = "";
|
|
29
|
+
|
|
30
|
+
const configDef = getConfigDefaults();
|
|
31
|
+
let libraryName;
|
|
32
|
+
|
|
33
|
+
if (options.params.length >= 4) {
|
|
34
|
+
version = options.params[3];
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
await deleteLibraryVersion(configDef.currentOrgLib, version);
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
addDebugLog("deleteVersion", "END", "-");
|
|
43
|
+
|
|
44
|
+
return true;
|
|
45
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { addDebugLog, getConfigDefaults, getLibraryArchiveDirectories, getLibraryArchivesVersions } from '../../util.js';
|
|
5
|
+
|
|
6
|
+
export const SOURCE_OF_COMPONENT_TYPES = {
|
|
7
|
+
SERVER: 'Server',
|
|
8
|
+
LOCAL: 'Local'
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export const getFilePathQuestions = async () => {
|
|
13
|
+
addDebugLog("getFilePathQuestions", "", "");
|
|
14
|
+
|
|
15
|
+
console.log("\nFile path examples:");
|
|
16
|
+
if (path.sep === "/") {
|
|
17
|
+
console.log("\tMac OS/Unix:\t/Users/name/...");
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
console.log("\tWindows:\tC:\\Users\\name\\...\n");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const currentDirectory = process.cwd();
|
|
24
|
+
const arPathParts = currentDirectory.split(path.sep);
|
|
25
|
+
let defaultPath = join(arPathParts[0], arPathParts[1], arPathParts[2], "Downloads");
|
|
26
|
+
if (path.sep === "/") {
|
|
27
|
+
defaultPath = "/".concat(defaultPath);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
return [
|
|
32
|
+
{
|
|
33
|
+
name: 'filePath',
|
|
34
|
+
message: 'Enter full file path of zip file location:',
|
|
35
|
+
default: defaultPath
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const getFileNameQuestions = async (zipFileList) => {
|
|
41
|
+
addDebugLog("getFileNameQuestions", "", "");
|
|
42
|
+
|
|
43
|
+
return [
|
|
44
|
+
{
|
|
45
|
+
name: 'fileName',
|
|
46
|
+
type: 'rawlist',
|
|
47
|
+
message: `Select zip file`,
|
|
48
|
+
choices: zipFileList
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const getLibraryQuestion = async () => {
|
|
54
|
+
addDebugLog("getLibraryQuestion", "", "");
|
|
55
|
+
const componentDefaults = getConfigDefaults();
|
|
56
|
+
const orgLib = getConfigDefaults();
|
|
57
|
+
const currentOrgLib = `${orgLib.organization}_${orgLib.library}`;
|
|
58
|
+
|
|
59
|
+
const archVersionList = await getLibraryArchiveDirectories("");
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
return [
|
|
63
|
+
{
|
|
64
|
+
name: 'orgLibName',
|
|
65
|
+
type: 'rawlist',
|
|
66
|
+
message: `Select a library (current library is ${chalk.bold.green(`${currentOrgLib}`)}) `,
|
|
67
|
+
choices: archVersionList
|
|
68
|
+
}
|
|
69
|
+
];
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const getLibraryVersionQuestion = async (newOrgLib) => {
|
|
73
|
+
addDebugLog("getLibraryVersionQuestion", "", "");
|
|
74
|
+
|
|
75
|
+
const archVersionList = await getLibraryArchivesVersions(newOrgLib, "0.0.0");
|
|
76
|
+
|
|
77
|
+
return [
|
|
78
|
+
{
|
|
79
|
+
name: 'selectedVersion',
|
|
80
|
+
type: 'rawlist',
|
|
81
|
+
message: `Select a version `,
|
|
82
|
+
choices: archVersionList
|
|
83
|
+
}
|
|
84
|
+
];
|
|
85
|
+
};
|