@pega/dx-component-builder-sdk 0.1.21 → 0.1.22
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 +5 -1
- package/src/tasks/authenticate/index.js +5 -4
- package/src/tasks/create/index.js +7 -5
- package/src/tasks/delete/helper.js +5 -4
- package/src/tasks/delete-all/helper.js +2 -1
- package/src/tasks/map/map.js +2 -16
- package/src/tasks/override/index.js +5 -3
- package/src/util.js +12 -43
package/package.json
CHANGED
package/src/constants.js
CHANGED
|
@@ -5,7 +5,7 @@ export const SDK_LOCAL_COMPONENT_MAP_FILENAME = "sdk-local-component-map.js";
|
|
|
5
5
|
export const DXCB_CONFIG = 'dxcbConfig';
|
|
6
6
|
export const DXCB_PUBLISH_ACCESS = 'publishAccess';
|
|
7
7
|
export const DXCB_COMPONENT_DEFAULTS = 'componentDefaults';
|
|
8
|
-
export const COMPONENTS_DIRECTORY_PATH = 'components
|
|
8
|
+
export const COMPONENTS_DIRECTORY_PATH = 'src/components';
|
|
9
9
|
export const TOKEN_PATH = '../.access_token';
|
|
10
10
|
export const OOTB_COMPONENTS = '../.ootb_components';
|
|
11
11
|
export const FIELD_PATH = '/field';
|
|
@@ -19,6 +19,7 @@ export const COMPONENT_PREFIX_WIDGET_PATH = "widget/";
|
|
|
19
19
|
export const COMPONENT_PREFIX_DSE_PATH = "designSystemExtension/";
|
|
20
20
|
export const COMPONENT_PREFIX_INFRA_PATH = "infra/";
|
|
21
21
|
|
|
22
|
+
export const CUSTOM_TEMPLATES = "componentTemplates";
|
|
22
23
|
export const CUSTOM_TEMPLATE_PATH = 'customTemplatesPath';
|
|
23
24
|
export const OVERRIDE_TEMPLATE_PATH = 'overrideTemplatesPath';
|
|
24
25
|
export const OVERRIDE_LIB_PATH = 'node_modules/@pega/react-sdk-overrides/lib';
|
|
@@ -36,6 +37,9 @@ export const OOTB_COMPONENT_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/ootb_c
|
|
|
36
37
|
export const DELETE_COMPONENT_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/delete_component';
|
|
37
38
|
export const TOKEN_URL_V1 = 'PRRestService/oauth2/v1/token';
|
|
38
39
|
|
|
40
|
+
export const SERVER_CONFIG = "serverConfig";
|
|
41
|
+
export const SERVER_REST_URL = "infinityRestServerUrl";
|
|
42
|
+
|
|
39
43
|
export const COMPONENT_SCHEMA = {
|
|
40
44
|
framework: [
|
|
41
45
|
{
|
|
@@ -6,8 +6,8 @@ import chalk from 'chalk';
|
|
|
6
6
|
import inquirer from 'inquirer';
|
|
7
7
|
import fetch from 'node-fetch';
|
|
8
8
|
|
|
9
|
-
import { checkPathAccess, getTokenUrl, showVersion } from '../../util.js';
|
|
10
|
-
import { TOKEN_PATH, SDK_CONFIG_JSON_FILENAME,
|
|
9
|
+
import { checkPathAccess, getPegaServerConfig, getTokenUrl, showVersion } from '../../util.js';
|
|
10
|
+
import { TOKEN_PATH, SDK_CONFIG_JSON_FILENAME, SERVER_CONFIG, SERVER_REST_URL } from '../../constants.js';
|
|
11
11
|
|
|
12
12
|
import { getAuthQuestions } from './helper.js';
|
|
13
13
|
|
|
@@ -63,14 +63,15 @@ export default async options => {
|
|
|
63
63
|
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
64
64
|
data = data && JSON.parse(data);
|
|
65
65
|
|
|
66
|
-
if (!data[
|
|
66
|
+
if (!data[SERVER_CONFIG] || !data[SERVER_CONFIG][SERVER_REST_URL]) {
|
|
67
67
|
console.error(
|
|
68
68
|
`${chalk.red.bold('ERROR')} Could not able find publish access path in config.json`
|
|
69
69
|
);
|
|
70
70
|
process.exit(1);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
const serverConfig = data[
|
|
73
|
+
//const serverConfig = data[SERVER_CONFIG][SERVER_REST_URL];
|
|
74
|
+
const serverConfig = await getPegaServerConfig();
|
|
74
75
|
const params = options.params;
|
|
75
76
|
|
|
76
77
|
const questions = await getAuthQuestions(params);
|
|
@@ -13,6 +13,7 @@ import { CATEGORY_CONSTELLATION,
|
|
|
13
13
|
SDK_CONFIG_JSON_FILENAME,
|
|
14
14
|
DXCB_CONFIG,
|
|
15
15
|
DXCB_COMPONENT_DEFAULTS,
|
|
16
|
+
CUSTOM_TEMPLATES,
|
|
16
17
|
CUSTOM_TEMPLATE_PATH } from '../../constants.js';
|
|
17
18
|
|
|
18
19
|
|
|
@@ -168,9 +169,10 @@ export const validateCompile = async (
|
|
|
168
169
|
let pegaConfig = await getPegaConfig();
|
|
169
170
|
let templateParentDir = `./templates/${framework}`;
|
|
170
171
|
if (pegaConfig[DXCB_CONFIG] &&
|
|
171
|
-
pegaConfig[DXCB_CONFIG][
|
|
172
|
-
pegaConfig[DXCB_CONFIG][CUSTOM_TEMPLATE_PATH]
|
|
173
|
-
|
|
172
|
+
pegaConfig[DXCB_CONFIG][CUSTOM_TEMPLATES] &&
|
|
173
|
+
pegaConfig[DXCB_CONFIG][CUSTOM_TEMPLATES][CUSTOM_TEMPLATE_PATH] &&
|
|
174
|
+
pegaConfig[DXCB_CONFIG][CUSTOM_TEMPLATES][CUSTOM_TEMPLATE_PATH] != "") {
|
|
175
|
+
templateParentDir = pegaConfig[DXCB_CONFIG][CUSTOM_TEMPLATES][CUSTOM_TEMPLATE_PATH];
|
|
174
176
|
}
|
|
175
177
|
|
|
176
178
|
const templateDir = `${templateParentDir}/${typeLC}/${sSubType}`;
|
|
@@ -358,7 +360,7 @@ export default async options => {
|
|
|
358
360
|
},
|
|
359
361
|
{
|
|
360
362
|
name: 'componentName',
|
|
361
|
-
message: 'Enter component name (required)',
|
|
363
|
+
message: 'Enter component name (required, no spaces)',
|
|
362
364
|
validate: value => {
|
|
363
365
|
/* value should not be empty
|
|
364
366
|
It should not have spaces
|
|
@@ -415,7 +417,7 @@ export default async options => {
|
|
|
415
417
|
},
|
|
416
418
|
{
|
|
417
419
|
name: 'description',
|
|
418
|
-
message: 'Enter description for the component',
|
|
420
|
+
message: 'Enter description for the component (defaults to label)',
|
|
419
421
|
default: componentDefaults.description,
|
|
420
422
|
/* if left blank and no defaults, mustache will use componentLabel, because description is used in app studio and
|
|
421
423
|
shouldn't be blank */
|
|
@@ -71,19 +71,20 @@ export const deleteLocalComponents = async (sourceOfComponents, category = CATEG
|
|
|
71
71
|
await deleteLocalComponent(answers.componentKey, CATEGORY_CONSTELLATION);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
if (category === CATEGORY_OVERRIDE) {
|
|
74
|
+
if (category === CATEGORY_OVERRIDE || category === CATEGORY_CUSTOM) {
|
|
75
75
|
// need to remove the map as well
|
|
76
76
|
if (answers.componentKey != undefined) {
|
|
77
77
|
await deleteFromComponentMap(answers.componentKey, category);
|
|
78
78
|
}
|
|
79
79
|
else {
|
|
80
|
-
console.log(chalk.bold.
|
|
80
|
+
console.log(chalk.bold.yellow(`No component in map: ` + componentName));
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
} else {
|
|
86
|
-
|
|
86
|
+
const categoryLC = category.toLowerCase();
|
|
87
|
+
console.log(chalk.bold.redBright(`No ${categoryLC} components in ${sourceOfComponents}`));
|
|
87
88
|
}
|
|
88
89
|
};
|
|
89
90
|
|
|
@@ -140,7 +141,7 @@ export const deleteServerComponents = async (sourceOfComponents, answers) => {
|
|
|
140
141
|
await deleteFromComponentMap(componentKey.value);
|
|
141
142
|
}
|
|
142
143
|
else {
|
|
143
|
-
console.log(chalk.bold.
|
|
144
|
+
console.log(chalk.bold.yellow(`No component in map: ` + componentName));
|
|
144
145
|
}
|
|
145
146
|
|
|
146
147
|
} else {
|
|
@@ -95,7 +95,8 @@ export const deleteLocalComponents = async (sourceOfComponents, category = CATEG
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
} else {
|
|
98
|
-
|
|
98
|
+
const categoryLC = category.toLowerCase();
|
|
99
|
+
console.log(chalk.bold.redBright(`No ${categoryLC} components in ${sourceOfComponents}`));
|
|
99
100
|
}
|
|
100
101
|
};
|
|
101
102
|
|
package/src/tasks/map/map.js
CHANGED
|
@@ -35,14 +35,7 @@ export const updateComponentMap = async (componentKey, category = CATEGORY_CUSTO
|
|
|
35
35
|
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
36
36
|
data = JSON.parse(data);
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
console.error(
|
|
40
|
-
`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
|
|
41
|
-
);
|
|
42
|
-
process.exit(1);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
let importComponent = join(data[DXCB_CONFIG][COMPONENTS_DIRECTORY_PATH], categoryDirectory, componentKey);
|
|
38
|
+
let importComponent = join(COMPONENTS_DIRECTORY_PATH, categoryDirectory, componentKey);
|
|
46
39
|
importComponent = "./".concat(importComponent);
|
|
47
40
|
|
|
48
41
|
let importFull = "import ".concat(componentName).concat(" from '").concat(importComponent).concat("/';");
|
|
@@ -86,14 +79,7 @@ export const deleteFromComponentMap = async (componentKey, category = CATEGORY_C
|
|
|
86
79
|
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
87
80
|
data = JSON.parse(data);
|
|
88
81
|
|
|
89
|
-
|
|
90
|
-
console.error(
|
|
91
|
-
`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
|
|
92
|
-
);
|
|
93
|
-
process.exit(1);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
let importComponent = join(data[DXCB_CONFIG][COMPONENTS_DIRECTORY_PATH], categoryDirectory, componentKey);
|
|
82
|
+
let importComponent = join(COMPONENTS_DIRECTORY_PATH, categoryDirectory, componentKey);
|
|
97
83
|
importComponent = "./".concat(importComponent);
|
|
98
84
|
|
|
99
85
|
let importFull = "import ".concat(componentName).concat(" from '").concat(importComponent).concat("/';");
|
|
@@ -20,6 +20,7 @@ import { COMPONENT_SCHEMA,
|
|
|
20
20
|
SDK_CONFIG_JSON_FILENAME,
|
|
21
21
|
DXCB_CONFIG,
|
|
22
22
|
DXCB_COMPONENT_DEFAULTS,
|
|
23
|
+
CUSTOM_TEMPLATES,
|
|
23
24
|
OVERRIDE_TEMPLATE_PATH,
|
|
24
25
|
OVERRIDE_LIB_PATH } from '../../constants.js';
|
|
25
26
|
|
|
@@ -110,9 +111,10 @@ const validateCompile = async (
|
|
|
110
111
|
let templateParentDir = OVERRIDE_LIB_PATH;
|
|
111
112
|
|
|
112
113
|
if (pegaConfig[DXCB_CONFIG] &&
|
|
113
|
-
pegaConfig[DXCB_CONFIG][
|
|
114
|
-
pegaConfig[DXCB_CONFIG][OVERRIDE_TEMPLATE_PATH]
|
|
115
|
-
|
|
114
|
+
pegaConfig[DXCB_CONFIG][CUSTOM_TEMPLATES] &&
|
|
115
|
+
pegaConfig[DXCB_CONFIG][CUSTOM_TEMPLATES][OVERRIDE_TEMPLATE_PATH] &&
|
|
116
|
+
pegaConfig[DXCB_CONFIG][CUSTOM_TEMPLATES][OVERRIDE_TEMPLATE_PATH] != "") {
|
|
117
|
+
templateParentDir = pegaConfig[DXCB_CONFIG][CUSTOM_TEMPLATES][OVERRIDE_TEMPLATE_PATH];
|
|
116
118
|
}
|
|
117
119
|
|
|
118
120
|
|
package/src/util.js
CHANGED
|
@@ -34,7 +34,9 @@ import {
|
|
|
34
34
|
CATEGORY_OVERRIDE,
|
|
35
35
|
CATEGORY_CONSTELLATION,
|
|
36
36
|
COMPONENT_DIRECTORY_PREFIX_CUSTOM,
|
|
37
|
-
DXCB_COMPONENT_DEFAULTS
|
|
37
|
+
DXCB_COMPONENT_DEFAULTS,
|
|
38
|
+
SERVER_CONFIG,
|
|
39
|
+
SERVER_REST_URL
|
|
38
40
|
} from './constants.js';
|
|
39
41
|
|
|
40
42
|
|
|
@@ -64,14 +66,8 @@ export const deleteLocalComponent = async (componentKey, category = CATEGORY_CUS
|
|
|
64
66
|
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
65
67
|
data = JSON.parse(data);
|
|
66
68
|
|
|
67
|
-
if (!data[DXCB_CONFIG] || !data[DXCB_CONFIG][COMPONENTS_DIRECTORY_PATH]) {
|
|
68
|
-
console.error(
|
|
69
|
-
`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
|
|
70
|
-
);
|
|
71
|
-
process.exit(1);
|
|
72
|
-
}
|
|
73
69
|
|
|
74
|
-
const directory = join(currentDirectory,
|
|
70
|
+
const directory = join(currentDirectory, COMPONENTS_DIRECTORY_PATH, categoryDirectory, componentKey);
|
|
75
71
|
|
|
76
72
|
// test for the directory
|
|
77
73
|
if (fs.existsSync(directory)) {
|
|
@@ -81,7 +77,8 @@ export const deleteLocalComponent = async (componentKey, category = CATEGORY_CUS
|
|
|
81
77
|
throw err;
|
|
82
78
|
}
|
|
83
79
|
|
|
84
|
-
|
|
80
|
+
const sCat = (category === CATEGORY_CONSTELLATION) ? `custom ${category}` : category;
|
|
81
|
+
console.log(`${chalk.red.bold(componentKey)} is deleted from Local ${sCat} `);
|
|
85
82
|
|
|
86
83
|
|
|
87
84
|
});
|
|
@@ -176,15 +173,7 @@ export const getComponents = async (showSeparator = false, category = CATEGORY_C
|
|
|
176
173
|
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
177
174
|
data = JSON.parse(data);
|
|
178
175
|
|
|
179
|
-
|
|
180
|
-
console.error(
|
|
181
|
-
`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
|
|
182
|
-
);
|
|
183
|
-
process.exit(1);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const directory = join(currentDirectory, data[DXCB_CONFIG][COMPONENTS_DIRECTORY_PATH], categoryDirectory);
|
|
176
|
+
const directory = join(currentDirectory, COMPONENTS_DIRECTORY_PATH, categoryDirectory);
|
|
188
177
|
let compList = new Array();
|
|
189
178
|
|
|
190
179
|
switch (category) {
|
|
@@ -281,14 +270,7 @@ export const getComponentsObj = async (showSeparator = false, category = CATEGOR
|
|
|
281
270
|
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
282
271
|
data = JSON.parse(data);
|
|
283
272
|
|
|
284
|
-
|
|
285
|
-
console.error(
|
|
286
|
-
`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
|
|
287
|
-
);
|
|
288
|
-
process.exit(1);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
const directory = join(currentDirectory, data[DXCB_CONFIG][COMPONENTS_DIRECTORY_PATH], categoryDirectory);
|
|
273
|
+
const directory = join(currentDirectory, COMPONENTS_DIRECTORY_PATH, categoryDirectory);
|
|
292
274
|
let compList = new Array();
|
|
293
275
|
|
|
294
276
|
switch (category) {
|
|
@@ -441,14 +423,7 @@ export const getComponentsAndSubDirectory = async (category = CATEGORY_CUSTOM) =
|
|
|
441
423
|
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
442
424
|
data = JSON.parse(data);
|
|
443
425
|
|
|
444
|
-
|
|
445
|
-
console.error(
|
|
446
|
-
`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
|
|
447
|
-
);
|
|
448
|
-
process.exit(1);
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
const directory = join(currentDirectory, data[DXCB_CONFIG][COMPONENTS_DIRECTORY_PATH], categoryDirectory);
|
|
426
|
+
const directory = join(currentDirectory, COMPONENTS_DIRECTORY_PATH, categoryDirectory);
|
|
452
427
|
|
|
453
428
|
const fieldComps = await getSubComponentsAndDir(directory, FIELD_PATH);
|
|
454
429
|
const templateComps = await getSubComponentsAndDir(directory, TEMPLATE_PATH);
|
|
@@ -498,7 +473,8 @@ export const getPegaConfig = async () => {
|
|
|
498
473
|
|
|
499
474
|
export const getPegaServerConfig = async () => {
|
|
500
475
|
const config = await getPegaConfig();
|
|
501
|
-
|
|
476
|
+
const server = config[SERVER_CONFIG][SERVER_REST_URL];
|
|
477
|
+
return { ...config[DXCB_CONFIG][DXCB_PUBLISH_ACCESS], server };
|
|
502
478
|
};
|
|
503
479
|
|
|
504
480
|
export const getComponentDefaults = async () => {
|
|
@@ -516,14 +492,7 @@ export const getComponentDirectoryPath = async (componentKey, category = CATEGOR
|
|
|
516
492
|
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
517
493
|
data = JSON.parse(data);
|
|
518
494
|
|
|
519
|
-
|
|
520
|
-
console.error(
|
|
521
|
-
`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
|
|
522
|
-
);
|
|
523
|
-
process.exit(1);
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
return join(currentDirectory, data[DXCB_CONFIG][COMPONENTS_DIRECTORY_PATH], categoryDirectory, componentKey);
|
|
495
|
+
return join(currentDirectory, COMPONENTS_DIRECTORY_PATH, categoryDirectory, componentKey);
|
|
527
496
|
};
|
|
528
497
|
|
|
529
498
|
|