@pega/custom-dx-components 0.242.26 → 0.242.28
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 +2 -1
- package/src/cli.js +44 -2
- package/src/constants.js +2 -0
- package/src/tasks/build-all/helper.js +1 -1
- package/src/tasks/build-all/index.js +17 -3
- package/src/tasks/build-comp/helper.js +7 -4
- package/src/tasks/build-comp/index.js +15 -2
- package/src/tasks/build-jest-assets/index.js +1 -1
- package/src/tasks/build-lib/helper.js +2 -34
- package/src/tasks/build-lib/index.js +36 -85
- package/src/tasks/create/index.js +31 -19
- package/src/tasks/create-all/index.js +31 -16
- package/src/tasks/create-lib/helper.js +80 -0
- package/src/tasks/create-lib/index.js +109 -0
- package/src/tasks/create-version/helper.js +81 -0
- package/src/tasks/create-version/index.js +108 -0
- package/src/tasks/delete/index.js +7 -4
- package/src/tasks/delete-all/index.js +14 -9
- package/src/tasks/delete-lib/helper.js +19 -46
- package/src/tasks/delete-lib/index.js +107 -49
- package/src/tasks/delete-pub/helper.js +35 -0
- package/src/tasks/delete-pub/index.js +105 -0
- package/src/tasks/index.js +7 -0
- package/src/tasks/init/helper.js +5 -5
- package/src/tasks/init/template/package.json.mustache +15 -7
- package/src/tasks/list/helper.js +29 -8
- package/src/tasks/list/index.js +4 -9
- package/src/tasks/list-lib/helper.js +18 -53
- package/src/tasks/list-lib/index.js +68 -110
- package/src/tasks/list-pub/helper.js +42 -0
- package/src/tasks/list-pub/index.js +170 -0
- package/src/tasks/promote-webpack/index.js +1 -1
- package/src/tasks/publish/helper.js +44 -44
- package/src/tasks/publish/index.js +70 -5
- package/src/tasks/publish-all/index.js +10 -2
- package/src/tasks/publish-lib/helper.js +0 -38
- package/src/tasks/publish-lib/index.js +39 -13
- package/src/tasks/rename/index.js +25 -10
- package/src/tasks/rename-lib/index.js +8 -41
- package/src/tasks/revert-webpack/index.js +1 -1
- package/src/tasks/show-status/index.js +41 -0
- package/src/tasks/switch-lib/helper.js +81 -0
- package/src/tasks/switch-lib/index.js +134 -0
- package/src/tasks/switch-version/helper.js +92 -0
- package/src/tasks/switch-version/index.js +142 -0
- package/src/util.js +730 -61
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pega/custom-dx-components",
|
|
3
|
-
"version": "0.242.
|
|
3
|
+
"version": "0.242.28",
|
|
4
4
|
"description": "Utility for building custom UI components",
|
|
5
5
|
"bin": "./bin/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"terser-webpack-plugin": "5.3.10",
|
|
57
57
|
"ts-loader": "^9.5.1",
|
|
58
58
|
"typescript": "~5.2.2",
|
|
59
|
+
"unarchive": "^1.1.3",
|
|
59
60
|
"url-loader": "4.1.1",
|
|
60
61
|
"webpack": "5.89.0"
|
|
61
62
|
},
|
package/src/cli.js
CHANGED
|
@@ -8,12 +8,18 @@ import {
|
|
|
8
8
|
buildLibrary,
|
|
9
9
|
createComponent,
|
|
10
10
|
createAllComponents,
|
|
11
|
+
createLibrary,
|
|
12
|
+
switchLibrary,
|
|
13
|
+
createVersion,
|
|
14
|
+
switchVersion,
|
|
11
15
|
deleteComponent,
|
|
12
16
|
deleteAllComponents,
|
|
13
17
|
deleteLibrary,
|
|
18
|
+
deletePublished,
|
|
14
19
|
initProject,
|
|
15
20
|
listComponents,
|
|
16
21
|
listLibrary,
|
|
22
|
+
listPublished,
|
|
17
23
|
publishComponent,
|
|
18
24
|
publishAllComponents,
|
|
19
25
|
publishLibrary,
|
|
@@ -21,6 +27,7 @@ import {
|
|
|
21
27
|
renameLibrary,
|
|
22
28
|
revertWebPack,
|
|
23
29
|
promoteWebPack,
|
|
30
|
+
showStatus,
|
|
24
31
|
updateComponent,
|
|
25
32
|
validate,
|
|
26
33
|
upgrade,
|
|
@@ -31,6 +38,10 @@ const TASKS = {
|
|
|
31
38
|
INIT: 'init',
|
|
32
39
|
CREATE: 'create',
|
|
33
40
|
CREATE_ALL: 'createAll',
|
|
41
|
+
CREATE_LIB: 'createLibrary',
|
|
42
|
+
SWITCH_LIB: 'switchLibrary',
|
|
43
|
+
CREATE_VERSION: 'createVersion',
|
|
44
|
+
SWITCH_VERSION: 'switchVersion',
|
|
34
45
|
BUILD: 'buildComponent',
|
|
35
46
|
BUILD_ALL: 'buildAllComponents',
|
|
36
47
|
BUILD_LIB: 'buildLibrary',
|
|
@@ -43,11 +54,14 @@ const TASKS = {
|
|
|
43
54
|
RENAME_LIB: 'renameLibrary',
|
|
44
55
|
LIST: 'list',
|
|
45
56
|
LIST_LIB: 'listLibrary',
|
|
57
|
+
LIST_PUB: 'listPublished',
|
|
58
|
+
SHOW_STATUS: 'showStatus',
|
|
46
59
|
VALIDATE_SCHEMA: 'validateSchema',
|
|
47
60
|
UPDATE: 'update',
|
|
48
61
|
DELETE: 'delete',
|
|
49
|
-
DELETE_ALL:
|
|
50
|
-
DELETE_LIBRARY:
|
|
62
|
+
DELETE_ALL: 'deleteAll',
|
|
63
|
+
DELETE_LIBRARY: 'deleteLibrary',
|
|
64
|
+
DELETE_PUB: 'deletePublished',
|
|
51
65
|
AUTHENTICATE: 'authenticate',
|
|
52
66
|
UPGRADE: 'upgrade',
|
|
53
67
|
BUILD_JEST_ASSETS: 'buildJestAssets'
|
|
@@ -88,6 +102,22 @@ export default async (args = []) => {
|
|
|
88
102
|
createAllComponents(options);
|
|
89
103
|
break;
|
|
90
104
|
}
|
|
105
|
+
case TASKS.CREATE_LIB: {
|
|
106
|
+
createLibrary(options);
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
case TASKS.SWITCH_LIB: {
|
|
110
|
+
switchLibrary(options);
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
case TASKS.CREATE_VERSION: {
|
|
114
|
+
createVersion(options);
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
case TASKS.SWITCH_VERSION: {
|
|
118
|
+
switchVersion(options);
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
91
121
|
case TASKS.PROMOTE_WEBPACK: {
|
|
92
122
|
promoteWebPack(options);
|
|
93
123
|
break;
|
|
@@ -136,6 +166,14 @@ export default async (args = []) => {
|
|
|
136
166
|
listLibrary(options);
|
|
137
167
|
break;
|
|
138
168
|
}
|
|
169
|
+
case TASKS.LIST_PUB: {
|
|
170
|
+
listPublished(options);
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
case TASKS.SHOW_STATUS: {
|
|
174
|
+
showStatus(options);
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
139
177
|
case TASKS.VALIDATE_SCHEMA: {
|
|
140
178
|
validate(options);
|
|
141
179
|
break;
|
|
@@ -156,6 +194,10 @@ export default async (args = []) => {
|
|
|
156
194
|
deleteLibrary(options);
|
|
157
195
|
break;
|
|
158
196
|
}
|
|
197
|
+
case TASKS.DELETE_PUB: {
|
|
198
|
+
deletePublished(options);
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
159
201
|
case TASKS.AUTHENTICATE: {
|
|
160
202
|
authenticate(options);
|
|
161
203
|
break;
|
package/src/constants.js
CHANGED
|
@@ -12,6 +12,8 @@ export const OOTB_COMPONENTS = 'node_modules/@pega/custom-dx-components/.ootb_co
|
|
|
12
12
|
export const LIBRARY_BASED = 'libraryBased';
|
|
13
13
|
export const SHARED_DIRECTORY = 'shared';
|
|
14
14
|
export const SHOW_DEBUG = 'showDebug';
|
|
15
|
+
export const ARCHIVES_PATH = 'archives';
|
|
16
|
+
export const COMPONENTS_CONFIG_FILE_NAME = 'componentsconfig.json';
|
|
15
17
|
|
|
16
18
|
/* REST end points */
|
|
17
19
|
export const PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/publish_component';
|
|
@@ -5,7 +5,16 @@ import chalk from 'chalk';
|
|
|
5
5
|
import validate from '../validator/index.js';
|
|
6
6
|
import bundleComponent from '../bundle/index.js';
|
|
7
7
|
import { lintComponent } from '../linter/index.js';
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
getComponentDirectoryPath,
|
|
10
|
+
showVersion,
|
|
11
|
+
getComponents,
|
|
12
|
+
addDebugLog,
|
|
13
|
+
cleanUp,
|
|
14
|
+
getLibraryBased,
|
|
15
|
+
checkLibraryAndArchives,
|
|
16
|
+
getConfigDefaults,
|
|
17
|
+
zipVersionAndArchive } from '../../util.js';
|
|
9
18
|
|
|
10
19
|
import { getBuildComponentQuestions } from './helper.js';
|
|
11
20
|
|
|
@@ -42,8 +51,9 @@ addDebugLog("getCustomTasks", `componentKey: ${componentKey}, sourceMap: ${sourc
|
|
|
42
51
|
|
|
43
52
|
export default async options => {
|
|
44
53
|
await showVersion();
|
|
54
|
+
await checkLibraryAndArchives();
|
|
45
55
|
|
|
46
|
-
const isLibraryBased =
|
|
56
|
+
const isLibraryBased = getLibraryBased();
|
|
47
57
|
|
|
48
58
|
addDebugLog("buildAllComponents", "", "+");
|
|
49
59
|
const components = await getComponents();
|
|
@@ -91,10 +101,14 @@ addDebugLog("buildAllComponents", "", "+");
|
|
|
91
101
|
// if skipBuild, then do a build here as opposed to every step (v1 is every step, v2, just once)
|
|
92
102
|
if (skipBuild && firstComponent) {
|
|
93
103
|
console.log();
|
|
94
|
-
console.log(chalk.bold.green("
|
|
104
|
+
console.log(chalk.bold.green("Validation compile..."));
|
|
95
105
|
await bundleComponent(firstComponent, sourceMap, devBuild, showStats);
|
|
106
|
+
const confDef = getConfigDefaults();
|
|
107
|
+
await zipVersionAndArchive(confDef.currentOrgLib, confDef.buildVersion);
|
|
96
108
|
}
|
|
97
109
|
|
|
110
|
+
|
|
111
|
+
|
|
98
112
|
// once done, remove leftover directories
|
|
99
113
|
await cleanUp();
|
|
100
114
|
|
|
@@ -15,23 +15,26 @@ import {
|
|
|
15
15
|
} from '../../util.js';
|
|
16
16
|
import { PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH } from '../../constants.js';
|
|
17
17
|
|
|
18
|
+
const isLibraryBased = getLibraryBased();
|
|
19
|
+
// validate and validateAll will be called when libraryBased, but using same code
|
|
20
|
+
// so need different label
|
|
21
|
+
const buildLabel = isLibraryBased ? "validate" : "build";
|
|
22
|
+
|
|
18
23
|
export const getPublishComponentQuestions = async componentKey => {
|
|
19
24
|
const components = await getComponents();
|
|
20
25
|
|
|
21
26
|
if (components.length === 0) {
|
|
22
|
-
console.log(chalk.redBright(
|
|
27
|
+
console.log(chalk.redBright(`No components to ${buildLabel}`));
|
|
23
28
|
process.exit();
|
|
24
29
|
}
|
|
25
30
|
|
|
26
31
|
const defaultPegaConfig = await getPegaServerConfig();
|
|
27
32
|
|
|
28
|
-
const isLibraryBased = await getLibraryBased();
|
|
29
|
-
|
|
30
33
|
return [
|
|
31
34
|
{
|
|
32
35
|
name: 'componentKey',
|
|
33
36
|
type: 'rawlist',
|
|
34
|
-
message:
|
|
37
|
+
message: `Select component to ${buildLabel}`,
|
|
35
38
|
choices: components,
|
|
36
39
|
default: componentKey,
|
|
37
40
|
when: () => !componentKey
|
|
@@ -7,10 +7,20 @@ import validate from '../validator/index.js';
|
|
|
7
7
|
import bundleComponent from '../bundle/index.js';
|
|
8
8
|
import lintComponent from '../linter/index.js';
|
|
9
9
|
import { getPublishComponentQuestions } from './helper.js';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
getComponentDirectoryPath,
|
|
12
|
+
showVersion,
|
|
13
|
+
addDebugLog,
|
|
14
|
+
cleanUp,
|
|
15
|
+
getLibraryBased,
|
|
16
|
+
checkLibraryAndArchives,
|
|
17
|
+
getConfigDefaults,
|
|
18
|
+
zipVersionAndArchive } from '../../util.js';
|
|
19
|
+
|
|
11
20
|
|
|
12
21
|
export default async options => {
|
|
13
22
|
await showVersion();
|
|
23
|
+
await checkLibraryAndArchives();
|
|
14
24
|
|
|
15
25
|
addDebugLog("buildComponent", "", "+");
|
|
16
26
|
|
|
@@ -43,7 +53,7 @@ addDebugLog("buildComponent", "", "+");
|
|
|
43
53
|
const answers = await inquirer.prompt(questions);
|
|
44
54
|
({ componentKey = paramComponentKey, sourceMap, devBuild } = answers);
|
|
45
55
|
|
|
46
|
-
const isLibraryBased =
|
|
56
|
+
const isLibraryBased = getLibraryBased();
|
|
47
57
|
|
|
48
58
|
if (isLibraryBased) {
|
|
49
59
|
devBuild = false;
|
|
@@ -91,6 +101,9 @@ addDebugLog("buildComponent", "", "+");
|
|
|
91
101
|
process.exit(1);
|
|
92
102
|
});
|
|
93
103
|
|
|
104
|
+
const confDef = getConfigDefaults();
|
|
105
|
+
await zipVersionAndArchive(confDef.currentOrgLib, confDef.buildVersion);
|
|
106
|
+
|
|
94
107
|
// remove dist/lib stuff
|
|
95
108
|
await cleanUp();
|
|
96
109
|
|
|
@@ -201,7 +201,7 @@ export default async options => {
|
|
|
201
201
|
if (buildAssets) {
|
|
202
202
|
// get current server type
|
|
203
203
|
const savedServerType = await getServerType();
|
|
204
|
-
const savedLibraryBased =
|
|
204
|
+
const savedLibraryBased = getLibraryBased();
|
|
205
205
|
|
|
206
206
|
await setLibraryBased(false);
|
|
207
207
|
|
|
@@ -5,51 +5,19 @@ import chalk from 'chalk';
|
|
|
5
5
|
import {
|
|
6
6
|
getComponents,
|
|
7
7
|
getPegaServerConfig,
|
|
8
|
-
checkPathAccess,
|
|
9
|
-
getComponentDefaults,
|
|
10
8
|
validateSemver,
|
|
11
9
|
addDebugLog,
|
|
12
10
|
getLibraryBased
|
|
13
11
|
} from '../../util.js';
|
|
14
|
-
import { TASKS_CONFIG_JSON_FILENAME
|
|
12
|
+
import { TASKS_CONFIG_JSON_FILENAME } from '../../constants.js';
|
|
15
13
|
|
|
16
|
-
const pegaConfigJsonPath = path.join(path.resolve(), TASKS_CONFIG_JSON_FILENAME);
|
|
17
|
-
|
|
18
|
-
export const getOrgLib = async () => {
|
|
19
|
-
addDebugLog("getOrgLib", "", "+");
|
|
20
|
-
const defaultPegaConfig = await getPegaServerConfig();
|
|
21
|
-
|
|
22
|
-
await checkPathAccess(pegaConfigJsonPath);
|
|
23
|
-
|
|
24
|
-
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
25
|
-
data = data && JSON.parse(data);
|
|
26
|
-
|
|
27
|
-
if (!data[COMPONENTS_DIRECTORY_PATH]) {
|
|
28
|
-
console.error(`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`);
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const componentData = data[COMPONENTS_PATH];
|
|
33
|
-
|
|
34
|
-
let library;
|
|
35
|
-
({ library } = componentData);
|
|
36
|
-
let { organization } = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'));
|
|
37
|
-
|
|
38
|
-
const componentDefaults = await getComponentDefaults();
|
|
39
|
-
componentDefaults.library = library;
|
|
40
|
-
componentDefaults.organization = organization;
|
|
41
|
-
addDebugLog("getOrgLib", `componentsDefaults: ${JSON.stringify(componentDefaults)}`, "");
|
|
42
|
-
addDebugLog("getOrgLib", "END", "-");
|
|
43
|
-
|
|
44
|
-
return componentDefaults;
|
|
45
|
-
}
|
|
46
14
|
|
|
47
15
|
export const getBuildComponentQuestions = async (defaultVersion) => {
|
|
48
16
|
addDebugLog("getBuildComoponentQuestions", `defaultVerion: ${defaultVersion}`, "");
|
|
49
17
|
const components = await getComponents();
|
|
50
18
|
const defaultPegaConfig = await getPegaServerConfig();
|
|
51
19
|
|
|
52
|
-
const isLibraryBased =
|
|
20
|
+
const isLibraryBased = getLibraryBased();
|
|
53
21
|
|
|
54
22
|
|
|
55
23
|
if (components.length == 0) {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import fs from 'fs';
|
|
3
1
|
|
|
4
2
|
import inquirer from 'inquirer';
|
|
5
3
|
import { Listr } from 'listr2';
|
|
@@ -13,87 +11,19 @@ import {
|
|
|
13
11
|
getComponentDirectoryPath,
|
|
14
12
|
showVersion,
|
|
15
13
|
getComponents,
|
|
16
|
-
getLibraryBased,
|
|
17
14
|
getC11NB2STokenAndStaticServer,
|
|
18
15
|
updateComponentDefaultVersion,
|
|
19
|
-
|
|
16
|
+
updateConfigVersion,
|
|
20
17
|
addDebugLog,
|
|
21
|
-
cleanUp
|
|
18
|
+
cleanUp,
|
|
19
|
+
checkLibraryAndArchives,
|
|
20
|
+
getConfigDevBuild,
|
|
21
|
+
checkJWTExpiration,
|
|
22
|
+
getConfigDefaults
|
|
22
23
|
} from '../../util.js';
|
|
23
24
|
import bundleComponent from '../bundle/index.js';
|
|
24
25
|
|
|
25
|
-
import { getBuildComponentQuestions
|
|
26
|
-
|
|
27
|
-
const isLibraryBased = await getLibraryBased();
|
|
28
|
-
|
|
29
|
-
export const updateConfigVersion = async (componentKey, buildVersion, currentOrgLib, token) => {
|
|
30
|
-
addDebugLog("updateConfigVersion", `componentKey: ${componentKey}, buildVersion: ${buildVersion}, currentOrgLib: ${currentOrgLib}`, "");
|
|
31
|
-
const componentDirectory = await getComponentDirectoryPath(componentKey);
|
|
32
|
-
const configFileName = 'config.json';
|
|
33
|
-
|
|
34
|
-
const configFile = path.join(componentDirectory, configFileName);
|
|
35
|
-
let configData;
|
|
36
|
-
try {
|
|
37
|
-
configData = fs.readFileSync(path.resolve(configFile), 'utf8');
|
|
38
|
-
} catch (err) {
|
|
39
|
-
// for now, if now file just end
|
|
40
|
-
console.log(`${chalk.bold.yellow(`Config file not available for: ${componentKey}`)}`);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const currentDate = new Date(Date.now());
|
|
44
|
-
const dateStamp = currentDate.toDateString();
|
|
45
|
-
const aboutData = await getAboutData(currentOrgLib, buildVersion, dateStamp);
|
|
46
|
-
|
|
47
|
-
let data;
|
|
48
|
-
try {
|
|
49
|
-
data = JSON.parse(configData);
|
|
50
|
-
|
|
51
|
-
//find "About" and create or update
|
|
52
|
-
const properties = data.properties;
|
|
53
|
-
if (properties) {
|
|
54
|
-
let foundProp = null;
|
|
55
|
-
|
|
56
|
-
// check to see if PegaAboutData exists. If customer decides to put
|
|
57
|
-
// data under PegaAboutData, we won't change the order
|
|
58
|
-
// otherise, will put at bottom
|
|
59
|
-
for (let i in properties) {
|
|
60
|
-
if (properties[i].name && properties[i].name === "PegaAboutData") {
|
|
61
|
-
foundProp = properties[i];
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (foundProp) {
|
|
67
|
-
foundProp.label = aboutData;
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
// don't have "About"
|
|
71
|
-
const aboutLabelJSON = {
|
|
72
|
-
"format": "LABEL",
|
|
73
|
-
"label": "About",
|
|
74
|
-
"name": "PegaAboutLabel",
|
|
75
|
-
"variant": "h3"
|
|
76
|
-
};
|
|
77
|
-
const aboutDataJSON = {
|
|
78
|
-
"format": "LABEL",
|
|
79
|
-
"label": aboutData,
|
|
80
|
-
"name": "PegaAboutData",
|
|
81
|
-
"variant": "primary"
|
|
82
|
-
}
|
|
83
|
-
properties.push(aboutLabelJSON);
|
|
84
|
-
properties.push(aboutDataJSON);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
} catch (er) {
|
|
88
|
-
throw new Error(`Invalid schema json in config.json: ${er}`);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
data.version = buildVersion;
|
|
92
|
-
data.buildDate = dateStamp;
|
|
93
|
-
|
|
94
|
-
// write back file
|
|
95
|
-
fs.writeFileSync(configFile, JSON.stringify(data, null, 4), { encoding: 'utf8' });
|
|
96
|
-
};
|
|
26
|
+
import { getBuildComponentQuestions } from './helper.js';
|
|
97
27
|
|
|
98
28
|
export function getCustomTasks(componentKey, devBuild, buildVersion, currentOrgLib, token) {
|
|
99
29
|
addDebugLog("getCustomTasks", `componentKey: ${componentKey}, devBuild: ${devBuild}, buildVersion: ${buildVersion}, currentOrgLib: ${currentOrgLib}`,"");
|
|
@@ -135,12 +65,23 @@ addDebugLog("localBuildLibrary", `organization: ${organization}, library: ${libr
|
|
|
135
65
|
process.exit(1);
|
|
136
66
|
}
|
|
137
67
|
|
|
68
|
+
if (!components || components.length === 0) {
|
|
69
|
+
console.log(
|
|
70
|
+
chalk.redBright(
|
|
71
|
+
'No components to build/publish.'
|
|
72
|
+
)
|
|
73
|
+
);
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
|
|
138
77
|
const buildLibName = organization.concat('_').concat(library);
|
|
139
78
|
|
|
140
79
|
await updateComponentDefaultVersion(version);
|
|
141
80
|
|
|
142
81
|
const buildVersion = devBuild && version.indexOf('-dev') < 0 ? version.concat('-dev') : version;
|
|
143
82
|
|
|
83
|
+
|
|
84
|
+
|
|
144
85
|
for await (const componentKey of components) {
|
|
145
86
|
console.log(chalk.bold.green(`Building ${componentKey}`));
|
|
146
87
|
|
|
@@ -179,23 +120,26 @@ addDebugLog("buildLib", "services call", "");
|
|
|
179
120
|
tokenAndStaticServer.C11NB2S,
|
|
180
121
|
tokenAndStaticServer.appStaticContentServer
|
|
181
122
|
);
|
|
182
|
-
addDebugLog("
|
|
123
|
+
addDebugLog("buildLib", "services end", "");
|
|
183
124
|
|
|
184
125
|
}
|
|
185
126
|
|
|
186
127
|
export default async options => {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
128
|
+
|
|
129
|
+
if (options.params.length != 4) {
|
|
130
|
+
// internal so already called
|
|
131
|
+
await showVersion();
|
|
132
|
+
await checkLibraryAndArchives();
|
|
133
|
+
await checkJWTExpiration();
|
|
190
134
|
}
|
|
191
135
|
|
|
192
|
-
await showVersion();
|
|
193
136
|
addDebugLog("buildLibrary", "", "+");
|
|
194
137
|
|
|
195
|
-
const compDef =
|
|
138
|
+
const compDef = getConfigDefaults();
|
|
196
139
|
const organization = compDef.organization;
|
|
197
140
|
const library = compDef.library;
|
|
198
|
-
const currentOrgLib = organization.concat('_').concat(library);
|
|
141
|
+
// const currentOrgLib = organization.concat('_').concat(library);
|
|
142
|
+
const currentOrgLib = compDef.currentOrgLib;
|
|
199
143
|
|
|
200
144
|
let version;
|
|
201
145
|
let devBuild;
|
|
@@ -204,7 +148,14 @@ addDebugLog("buildLibrary", "", "+");
|
|
|
204
148
|
version = options.params[3];
|
|
205
149
|
const dBuild = options.params[4];
|
|
206
150
|
devBuild = !!(dBuild === 'Y' || dBuild === 'y' || dBuild === true || dBuild === 'true');
|
|
207
|
-
}
|
|
151
|
+
}
|
|
152
|
+
else if (options.params.length === 4) {
|
|
153
|
+
// internally called from publish
|
|
154
|
+
const orgLib = getConfigDefaults();
|
|
155
|
+
version = orgLib.version;
|
|
156
|
+
devBuild = await getConfigDevBuild();
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
208
159
|
console.log(`\nLibrary ${chalk.bold.green(currentOrgLib)} `);
|
|
209
160
|
const questions = await getBuildComponentQuestions(compDef.version);
|
|
210
161
|
const answers = await inquirer.prompt(questions);
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
compileMustacheTemplate,
|
|
13
13
|
getComponentDirectoryPath,
|
|
14
14
|
getComponents,
|
|
15
|
-
getComponentDefaults,
|
|
16
15
|
getPegaServerConfig,
|
|
17
16
|
sanitize,
|
|
18
17
|
validateSemver,
|
|
@@ -21,7 +20,9 @@ import {
|
|
|
21
20
|
updateComponentDefaultVersion,
|
|
22
21
|
copyFileToShared,
|
|
23
22
|
getLibraryBased,
|
|
24
|
-
addDebugLog
|
|
23
|
+
addDebugLog,
|
|
24
|
+
checkLibraryAndArchives,
|
|
25
|
+
getConfigDefaults
|
|
25
26
|
} from '../../util.js';
|
|
26
27
|
import { COMPONENT_SCHEMA, SHARED_FILE_NAMES } from '../../constants.js';
|
|
27
28
|
|
|
@@ -33,7 +34,7 @@ const copyComponentTemplate = async options => {
|
|
|
33
34
|
});
|
|
34
35
|
};
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
const isLibraryBased = getLibraryBased();
|
|
37
38
|
|
|
38
39
|
const compileMustacheTemplates = async (
|
|
39
40
|
componentDirectory,
|
|
@@ -183,19 +184,30 @@ const validateCompile = async (
|
|
|
183
184
|
framework = "Constellation";
|
|
184
185
|
}
|
|
185
186
|
|
|
186
|
-
|
|
187
|
+
const orgLib = getConfigDefaults();
|
|
188
|
+
if (isLibraryBased) {
|
|
189
|
+
// library comes from config
|
|
190
|
+
library = orgLib.library;
|
|
191
|
+
}
|
|
187
192
|
|
|
188
193
|
// check of library or version has changed from default, if so, update componentDefaults
|
|
189
|
-
const
|
|
190
|
-
|
|
194
|
+
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
195
|
+
|
|
196
|
+
// update defaults when changes
|
|
197
|
+
if (orgLib.library == null || orgLib.library !== library) {
|
|
191
198
|
await updateComponentDefaultLibrary(library);
|
|
192
199
|
}
|
|
193
|
-
if (componentDefaults.version == null || componentDefaults.version !== version) {
|
|
194
|
-
await updateComponentDefaultVersion(version);
|
|
195
|
-
}
|
|
196
200
|
|
|
201
|
+
// library based, get version from defaults
|
|
202
|
+
if (isLibraryBased) {
|
|
203
|
+
version = orgLib.buildVersion;
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
if (orgLib.version == null || orgLib.version !== version) {
|
|
207
|
+
await updateComponentDefaultVersion(version);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
197
210
|
|
|
198
|
-
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
199
211
|
const isLaunchpad = defaultPegaServerConfig.serverType === 'launchpad';
|
|
200
212
|
let originalFramework = framework;
|
|
201
213
|
|
|
@@ -219,15 +231,10 @@ const validateCompile = async (
|
|
|
219
231
|
|
|
220
232
|
}
|
|
221
233
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
234
|
if (organization == null) {
|
|
226
235
|
({ organization } = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8')));
|
|
227
236
|
}
|
|
228
237
|
|
|
229
|
-
|
|
230
|
-
|
|
231
238
|
const componentKey = `${organization}_${library}_${componentName}`;
|
|
232
239
|
const targetDirectory = await getComponentDirectoryPath(componentKey);
|
|
233
240
|
|
|
@@ -261,6 +268,8 @@ const validateCompile = async (
|
|
|
261
268
|
export default async options => {
|
|
262
269
|
await showVersion();
|
|
263
270
|
|
|
271
|
+
await checkLibraryAndArchives();
|
|
272
|
+
|
|
264
273
|
|
|
265
274
|
addDebugLog("create", "", "+");
|
|
266
275
|
|
|
@@ -293,7 +302,7 @@ addDebugLog("create", "", "+");
|
|
|
293
302
|
options
|
|
294
303
|
);
|
|
295
304
|
} else {
|
|
296
|
-
const componentDefaults =
|
|
305
|
+
const componentDefaults = getConfigDefaults();
|
|
297
306
|
const questions = [
|
|
298
307
|
{
|
|
299
308
|
name: 'type',
|
|
@@ -351,7 +360,7 @@ addDebugLog("create", "", "+");
|
|
|
351
360
|
if (value && !/^\d/.test(value) && value === sanitize(value)) {
|
|
352
361
|
return true;
|
|
353
362
|
}
|
|
354
|
-
return 'Only alphanumeric values are allowed, starting with alphabets';
|
|
363
|
+
return 'Only alphanumeric values are allowed, starting with alphabets, no spaces.';
|
|
355
364
|
}
|
|
356
365
|
},
|
|
357
366
|
{
|
|
@@ -373,7 +382,8 @@ addDebugLog("create", "", "+");
|
|
|
373
382
|
return true;
|
|
374
383
|
}
|
|
375
384
|
return 'Please provide semver compatible version e.g 0.0.1';
|
|
376
|
-
}
|
|
385
|
+
},
|
|
386
|
+
when: () => !isLibraryBased
|
|
377
387
|
},
|
|
378
388
|
{
|
|
379
389
|
name: 'library',
|
|
@@ -389,7 +399,9 @@ addDebugLog("create", "", "+");
|
|
|
389
399
|
return true;
|
|
390
400
|
}
|
|
391
401
|
return 'Only alphanumeric values are allowed, starting with alphabets';
|
|
392
|
-
}
|
|
402
|
+
},
|
|
403
|
+
when: () => !isLibraryBased
|
|
404
|
+
|
|
393
405
|
},
|
|
394
406
|
{
|
|
395
407
|
name: 'allowedApplications',
|