@pega/dx-component-builder-sdk 0.1.20 → 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/build-all/helper.js +1 -6
- package/src/tasks/create/index.js +9 -8
- package/src/tasks/delete/helper.js +6 -8
- package/src/tasks/delete/index.js +0 -2
- package/src/tasks/delete-all/helper.js +3 -5
- package/src/tasks/delete-all/index.js +0 -2
- package/src/tasks/generate-missing-companions/index.js +1 -3
- package/src/tasks/list/helper.js +1 -1
- package/src/tasks/list/index.js +0 -1
- package/src/tasks/map/map.js +2 -16
- package/src/tasks/map-all/helper.js +0 -8
- package/src/tasks/map-all/index.js +0 -4
- package/src/tasks/override/index.js +8 -11
- package/src/tasks/publish/helper.js +6 -3
- package/src/tasks/publish/index.js +5 -1
- package/src/tasks/publish-all/helper.js +7 -4
- package/src/tasks/publish-all/index.js +5 -1
- package/src/tasks/validator/index.js +1 -3
- package/src/util.js +12 -58
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);
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import https from 'https';
|
|
4
3
|
|
|
5
|
-
import fetch from 'node-fetch';
|
|
6
4
|
import AdmZip from 'adm-zip';
|
|
7
5
|
import chalk from 'chalk';
|
|
8
6
|
|
|
9
7
|
import {
|
|
10
|
-
constructCompleteUrl,
|
|
11
8
|
getComponentDirectoryPath,
|
|
12
|
-
getComponents,
|
|
13
9
|
getComponentsObj,
|
|
14
10
|
getPegaServerConfig,
|
|
15
|
-
validateRulesetVersion,
|
|
16
11
|
getOptionsCategory,
|
|
17
12
|
} from '../../util.js';
|
|
18
|
-
import {
|
|
13
|
+
import { COMPONENT_SCHEMA, CATEGORY_CUSTOM } from '../../constants.js';
|
|
19
14
|
|
|
20
15
|
|
|
21
16
|
export const getBuildCategory = async (options) => {
|
|
@@ -8,13 +8,13 @@ import inquirer from 'inquirer';
|
|
|
8
8
|
import ncp from 'ncp';
|
|
9
9
|
import chalk from 'chalk';
|
|
10
10
|
|
|
11
|
-
import { checkPathAccess,
|
|
11
|
+
import { checkPathAccess, showVersion } from '../../util.js';
|
|
12
12
|
import { CATEGORY_CONSTELLATION,
|
|
13
13
|
SDK_CONFIG_JSON_FILENAME,
|
|
14
14
|
DXCB_CONFIG,
|
|
15
15
|
DXCB_COMPONENT_DEFAULTS,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
CUSTOM_TEMPLATES,
|
|
17
|
+
CUSTOM_TEMPLATE_PATH } from '../../constants.js';
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
@@ -169,9 +169,10 @@ export const validateCompile = async (
|
|
|
169
169
|
let pegaConfig = await getPegaConfig();
|
|
170
170
|
let templateParentDir = `./templates/${framework}`;
|
|
171
171
|
if (pegaConfig[DXCB_CONFIG] &&
|
|
172
|
-
pegaConfig[DXCB_CONFIG][
|
|
173
|
-
pegaConfig[DXCB_CONFIG][CUSTOM_TEMPLATE_PATH]
|
|
174
|
-
|
|
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];
|
|
175
176
|
}
|
|
176
177
|
|
|
177
178
|
const templateDir = `${templateParentDir}/${typeLC}/${sSubType}`;
|
|
@@ -359,7 +360,7 @@ export default async options => {
|
|
|
359
360
|
},
|
|
360
361
|
{
|
|
361
362
|
name: 'componentName',
|
|
362
|
-
message: 'Enter component name (required)',
|
|
363
|
+
message: 'Enter component name (required, no spaces)',
|
|
363
364
|
validate: value => {
|
|
364
365
|
/* value should not be empty
|
|
365
366
|
It should not have spaces
|
|
@@ -416,7 +417,7 @@ export default async options => {
|
|
|
416
417
|
},
|
|
417
418
|
{
|
|
418
419
|
name: 'description',
|
|
419
|
-
message: 'Enter description for the component',
|
|
420
|
+
message: 'Enter description for the component (defaults to label)',
|
|
420
421
|
default: componentDefaults.description,
|
|
421
422
|
/* if left blank and no defaults, mustache will use componentLabel, because description is used in app studio and
|
|
422
423
|
shouldn't be blank */
|
|
@@ -5,13 +5,10 @@ import ora from 'ora';
|
|
|
5
5
|
|
|
6
6
|
import { LIST_COMPONENT_SERVICE_REST_ENDPOINT, COMPONENT_SCHEMA, CATEGORY_CONSTELLATION, CATEGORY_CUSTOM, CATEGORY_OVERRIDE } from '../../constants.js';
|
|
7
7
|
import {
|
|
8
|
-
constructCompleteUrl,
|
|
9
8
|
deleteLocalComponent,
|
|
10
9
|
deleteServerComponent,
|
|
11
10
|
getComponentsObj,
|
|
12
|
-
getPegaServerConfig
|
|
13
|
-
nodeFetch,
|
|
14
|
-
getOptionsCategory
|
|
11
|
+
getPegaServerConfig
|
|
15
12
|
} from '../../util.js';
|
|
16
13
|
import { getComponentsFromServer } from '../list/helper.js';
|
|
17
14
|
|
|
@@ -74,19 +71,20 @@ export const deleteLocalComponents = async (sourceOfComponents, category = CATEG
|
|
|
74
71
|
await deleteLocalComponent(answers.componentKey, CATEGORY_CONSTELLATION);
|
|
75
72
|
}
|
|
76
73
|
|
|
77
|
-
if (category === CATEGORY_OVERRIDE) {
|
|
74
|
+
if (category === CATEGORY_OVERRIDE || category === CATEGORY_CUSTOM) {
|
|
78
75
|
// need to remove the map as well
|
|
79
76
|
if (answers.componentKey != undefined) {
|
|
80
77
|
await deleteFromComponentMap(answers.componentKey, category);
|
|
81
78
|
}
|
|
82
79
|
else {
|
|
83
|
-
console.log(chalk.bold.
|
|
80
|
+
console.log(chalk.bold.yellow(`No component in map: ` + componentName));
|
|
84
81
|
}
|
|
85
82
|
|
|
86
83
|
}
|
|
87
84
|
}
|
|
88
85
|
} else {
|
|
89
|
-
|
|
86
|
+
const categoryLC = category.toLowerCase();
|
|
87
|
+
console.log(chalk.bold.redBright(`No ${categoryLC} components in ${sourceOfComponents}`));
|
|
90
88
|
}
|
|
91
89
|
};
|
|
92
90
|
|
|
@@ -143,7 +141,7 @@ export const deleteServerComponents = async (sourceOfComponents, answers) => {
|
|
|
143
141
|
await deleteFromComponentMap(componentKey.value);
|
|
144
142
|
}
|
|
145
143
|
else {
|
|
146
|
-
console.log(chalk.bold.
|
|
144
|
+
console.log(chalk.bold.yellow(`No component in map: ` + componentName));
|
|
147
145
|
}
|
|
148
146
|
|
|
149
147
|
} else {
|
|
@@ -2,16 +2,13 @@ import chalk from 'chalk';
|
|
|
2
2
|
import inquirer from 'inquirer';
|
|
3
3
|
import ora from 'ora';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { COMPONENT_SCHEMA, CATEGORY_CONSTELLATION, CATEGORY_CUSTOM, CATEGORY_OVERRIDE } from '../..//constants.js';
|
|
6
6
|
import {
|
|
7
|
-
constructCompleteUrl,
|
|
8
7
|
deleteLocalComponent,
|
|
9
8
|
deleteServerComponent,
|
|
10
|
-
getComponents,
|
|
11
9
|
getComponentsObj,
|
|
12
10
|
getPegaServerConfig,
|
|
13
11
|
validateRulesetVersion,
|
|
14
|
-
nodeFetch,
|
|
15
12
|
getOptionsCategory
|
|
16
13
|
} from '../../util.js';
|
|
17
14
|
import { getComponentsFromServer } from '../list/helper.js';
|
|
@@ -98,7 +95,8 @@ export const deleteLocalComponents = async (sourceOfComponents, category = CATEG
|
|
|
98
95
|
}
|
|
99
96
|
}
|
|
100
97
|
} else {
|
|
101
|
-
|
|
98
|
+
const categoryLC = category.toLowerCase();
|
|
99
|
+
console.log(chalk.bold.redBright(`No ${categoryLC} components in ${sourceOfComponents}`));
|
|
102
100
|
}
|
|
103
101
|
};
|
|
104
102
|
|
|
@@ -5,12 +5,10 @@ import chalk from 'chalk';
|
|
|
5
5
|
import { validateCompile } from '../create/index.js';
|
|
6
6
|
import {
|
|
7
7
|
showVersion,
|
|
8
|
-
getComponents,
|
|
9
|
-
getComponentsObj,
|
|
10
8
|
getComponentDirectoryPath,
|
|
11
9
|
getComponentsAndSubDirectory
|
|
12
10
|
} from '../../util.js';
|
|
13
|
-
import {CATEGORY_CONSTELLATION, CATEGORY_CUSTOM
|
|
11
|
+
import {CATEGORY_CONSTELLATION, CATEGORY_CUSTOM } from '../..//constants.js';
|
|
14
12
|
import { or } from 'ajv/dist/compile/codegen/index.js';
|
|
15
13
|
|
|
16
14
|
export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
|
package/src/tasks/list/helper.js
CHANGED
|
@@ -5,7 +5,7 @@ import chalk from 'chalk';
|
|
|
5
5
|
import fetch from 'node-fetch';
|
|
6
6
|
|
|
7
7
|
import { LIST_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH, COMPONENT_SCHEMA, CATEGORY_CUSTOM } from '../../constants.js';
|
|
8
|
-
import { constructCompleteUrl, getComponents, getPegaServerConfig
|
|
8
|
+
import { constructCompleteUrl, getComponents, getPegaServerConfig } from '../../util.js';
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
export const SOURCE_OF_COMPONENT_TYPES = {
|
package/src/tasks/list/index.js
CHANGED
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("/';");
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import https from 'https';
|
|
4
|
-
|
|
5
|
-
import fetch from 'node-fetch';
|
|
6
|
-
import AdmZip from 'adm-zip';
|
|
7
|
-
import chalk from 'chalk';
|
|
8
1
|
|
|
9
2
|
import {
|
|
10
|
-
getComponentDirectoryPath,
|
|
11
3
|
getOptionsCategory
|
|
12
4
|
} from '../../util.js';
|
|
13
5
|
import { COMPONENT_SCHEMA, CATEGORY_CONSTELLATION, CATEGORY_CUSTOM } from '../../constants.js';
|
|
@@ -2,12 +2,8 @@ import inquirer from 'inquirer';
|
|
|
2
2
|
import Listr from 'listr';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
|
|
5
|
-
import validate from '../validator/index.js';
|
|
6
5
|
import { showVersion, getOptionsCategory, getComponentsObj } from '../../util.js';
|
|
7
6
|
import { updateComponentMap } from '../map/map.js';
|
|
8
|
-
import { CATEGORY_CUSTOM } from '../../constants.js';
|
|
9
|
-
|
|
10
|
-
|
|
11
7
|
import { getBuildCategory } from './helper.js';
|
|
12
8
|
|
|
13
9
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
-
import { URL, fileURLToPath } from 'url';
|
|
3
2
|
import fs from 'fs';
|
|
4
3
|
import { promisify } from 'util';
|
|
5
|
-
import { createRequire } from "module";
|
|
6
4
|
import { join } from 'path';
|
|
7
5
|
|
|
8
6
|
import inquirer from 'inquirer';
|
|
@@ -10,21 +8,19 @@ import ncp from 'ncp';
|
|
|
10
8
|
import chalk from 'chalk';
|
|
11
9
|
import { updateComponentMap } from '../map/map.js';
|
|
12
10
|
|
|
13
|
-
import { checkPathAccess,
|
|
11
|
+
import { checkPathAccess, showVersion, getPegaConfig } from '../../util.js';
|
|
14
12
|
import {
|
|
15
|
-
convertIntoPascalCase,
|
|
16
|
-
compileMustacheTemplate,
|
|
17
13
|
getComponentDirectoryPath,
|
|
18
14
|
getComponents,
|
|
19
|
-
getComponentDefaults
|
|
20
|
-
sanitize,
|
|
21
|
-
validateSemver
|
|
15
|
+
getComponentDefaults
|
|
22
16
|
} from '../../util.js';
|
|
17
|
+
|
|
23
18
|
import { COMPONENT_SCHEMA,
|
|
24
19
|
CATEGORY_OVERRIDE,
|
|
25
20
|
SDK_CONFIG_JSON_FILENAME,
|
|
26
21
|
DXCB_CONFIG,
|
|
27
22
|
DXCB_COMPONENT_DEFAULTS,
|
|
23
|
+
CUSTOM_TEMPLATES,
|
|
28
24
|
OVERRIDE_TEMPLATE_PATH,
|
|
29
25
|
OVERRIDE_LIB_PATH } from '../../constants.js';
|
|
30
26
|
|
|
@@ -115,9 +111,10 @@ const validateCompile = async (
|
|
|
115
111
|
let templateParentDir = OVERRIDE_LIB_PATH;
|
|
116
112
|
|
|
117
113
|
if (pegaConfig[DXCB_CONFIG] &&
|
|
118
|
-
pegaConfig[DXCB_CONFIG][
|
|
119
|
-
pegaConfig[DXCB_CONFIG][OVERRIDE_TEMPLATE_PATH]
|
|
120
|
-
|
|
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];
|
|
121
118
|
}
|
|
122
119
|
|
|
123
120
|
|
|
@@ -9,14 +9,17 @@ import chalk from 'chalk';
|
|
|
9
9
|
import {
|
|
10
10
|
constructCompleteUrl,
|
|
11
11
|
getComponentDirectoryPath,
|
|
12
|
-
getComponents,
|
|
13
12
|
getComponentsObj,
|
|
14
|
-
getComponentsAndSubDirectory,
|
|
15
13
|
getPegaServerConfig,
|
|
16
14
|
validateRulesetVersion,
|
|
17
15
|
getOptionsCategory
|
|
18
16
|
} from '../../util.js';
|
|
19
|
-
|
|
17
|
+
|
|
18
|
+
import { PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT,
|
|
19
|
+
TOKEN_PATH,
|
|
20
|
+
COMPONENT_SCHEMA,
|
|
21
|
+
CATEGORY_CONSTELLATION,
|
|
22
|
+
CATEGORY_CUSTOM } from '../../constants.js';
|
|
20
23
|
|
|
21
24
|
|
|
22
25
|
export const mapConfigJsonToCompanion = async ( componentKey ) => {
|
|
@@ -10,7 +10,11 @@ import { lintComponent } from '../linter/index.js';
|
|
|
10
10
|
import { CATEGORY_CONSTELLATION, CATEGORY_CUSTOM } from '../../constants.js';
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
import { getPublishComponentQuestions,
|
|
13
|
+
import { getPublishComponentQuestions,
|
|
14
|
+
publishComponentToServer,
|
|
15
|
+
zipComponent,
|
|
16
|
+
getBuildCategory,
|
|
17
|
+
mapConfigJsonToCompanion } from './helper.js';
|
|
14
18
|
|
|
15
19
|
|
|
16
20
|
export default async options => {
|
|
@@ -9,14 +9,17 @@ import chalk from 'chalk';
|
|
|
9
9
|
import {
|
|
10
10
|
constructCompleteUrl,
|
|
11
11
|
getComponentDirectoryPath,
|
|
12
|
-
getComponents,
|
|
13
12
|
getComponentsObj,
|
|
14
|
-
getComponentsAndSubDirectory,
|
|
15
|
-
getPegaServerConfig,
|
|
16
13
|
validateRulesetVersion,
|
|
14
|
+
getPegaServerConfig,
|
|
17
15
|
getOptionsCategory
|
|
18
16
|
} from '../../util.js';
|
|
19
|
-
|
|
17
|
+
|
|
18
|
+
import { PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT,
|
|
19
|
+
TOKEN_PATH,
|
|
20
|
+
COMPONENT_SCHEMA,
|
|
21
|
+
CATEGORY_CONSTELLATION,
|
|
22
|
+
CATEGORY_CUSTOM } from '../../constants.js';
|
|
20
23
|
|
|
21
24
|
|
|
22
25
|
export const mapConfigJsonToCompanion = async ( componentKey ) => {
|
|
@@ -10,7 +10,11 @@ import { lintComponent } from '../linter/index.js';
|
|
|
10
10
|
import { CATEGORY_CONSTELLATION, CATEGORY_CUSTOM } from '../../constants.js';
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
import { getPublishComponentQuestions,
|
|
13
|
+
import { getPublishComponentQuestions,
|
|
14
|
+
publishComponentToServer,
|
|
15
|
+
zipComponent,
|
|
16
|
+
getBuildCategory,
|
|
17
|
+
mapConfigJsonToCompanion } from './helper.js';
|
|
14
18
|
|
|
15
19
|
|
|
16
20
|
|
|
@@ -7,11 +7,9 @@ import Ajv from 'ajv';
|
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
COMPONENT_SCHEMA,
|
|
10
|
-
COMPONENT_PREFIX_FIELD_PATH,
|
|
11
|
-
COMPONENT_PREFIX_TEMPLATE_PATH,
|
|
12
|
-
COMPONENT_PREFIX_WIDGET_PATH,
|
|
13
10
|
CATEGORY_CUSTOM,
|
|
14
11
|
CATEGORY_OVERRIDE } from '../../constants.js';
|
|
12
|
+
|
|
15
13
|
import {
|
|
16
14
|
getComponentDirectoryPath,
|
|
17
15
|
getComponents,
|
package/src/util.js
CHANGED
|
@@ -4,7 +4,6 @@ import { promisify } from 'util';
|
|
|
4
4
|
import https from 'https';
|
|
5
5
|
import inquirer from 'inquirer';
|
|
6
6
|
import { createRequire } from "module";
|
|
7
|
-
import { URL, fileURLToPath } from 'url';
|
|
8
7
|
|
|
9
8
|
import chalk from 'chalk';
|
|
10
9
|
import mustache from 'mustache';
|
|
@@ -35,7 +34,9 @@ import {
|
|
|
35
34
|
CATEGORY_OVERRIDE,
|
|
36
35
|
CATEGORY_CONSTELLATION,
|
|
37
36
|
COMPONENT_DIRECTORY_PREFIX_CUSTOM,
|
|
38
|
-
DXCB_COMPONENT_DEFAULTS
|
|
37
|
+
DXCB_COMPONENT_DEFAULTS,
|
|
38
|
+
SERVER_CONFIG,
|
|
39
|
+
SERVER_REST_URL
|
|
39
40
|
} from './constants.js';
|
|
40
41
|
|
|
41
42
|
|
|
@@ -65,14 +66,8 @@ export const deleteLocalComponent = async (componentKey, category = CATEGORY_CUS
|
|
|
65
66
|
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
66
67
|
data = JSON.parse(data);
|
|
67
68
|
|
|
68
|
-
if (!data[DXCB_CONFIG] || !data[DXCB_CONFIG][COMPONENTS_DIRECTORY_PATH]) {
|
|
69
|
-
console.error(
|
|
70
|
-
`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
|
|
71
|
-
);
|
|
72
|
-
process.exit(1);
|
|
73
|
-
}
|
|
74
69
|
|
|
75
|
-
const directory = join(currentDirectory,
|
|
70
|
+
const directory = join(currentDirectory, COMPONENTS_DIRECTORY_PATH, categoryDirectory, componentKey);
|
|
76
71
|
|
|
77
72
|
// test for the directory
|
|
78
73
|
if (fs.existsSync(directory)) {
|
|
@@ -82,7 +77,8 @@ export const deleteLocalComponent = async (componentKey, category = CATEGORY_CUS
|
|
|
82
77
|
throw err;
|
|
83
78
|
}
|
|
84
79
|
|
|
85
|
-
|
|
80
|
+
const sCat = (category === CATEGORY_CONSTELLATION) ? `custom ${category}` : category;
|
|
81
|
+
console.log(`${chalk.red.bold(componentKey)} is deleted from Local ${sCat} `);
|
|
86
82
|
|
|
87
83
|
|
|
88
84
|
});
|
|
@@ -177,15 +173,7 @@ export const getComponents = async (showSeparator = false, category = CATEGORY_C
|
|
|
177
173
|
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
178
174
|
data = JSON.parse(data);
|
|
179
175
|
|
|
180
|
-
|
|
181
|
-
console.error(
|
|
182
|
-
`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
|
|
183
|
-
);
|
|
184
|
-
process.exit(1);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const directory = join(currentDirectory, data[DXCB_CONFIG][COMPONENTS_DIRECTORY_PATH], categoryDirectory);
|
|
176
|
+
const directory = join(currentDirectory, COMPONENTS_DIRECTORY_PATH, categoryDirectory);
|
|
189
177
|
let compList = new Array();
|
|
190
178
|
|
|
191
179
|
switch (category) {
|
|
@@ -271,20 +259,6 @@ export const getDirectoryFiles = async (directory) => {
|
|
|
271
259
|
.map(dirent => dirent.name);
|
|
272
260
|
}
|
|
273
261
|
|
|
274
|
-
/*
|
|
275
|
-
export const createBlankConfigExt = async (directory, name) => {
|
|
276
|
-
|
|
277
|
-
let fileData = "{";
|
|
278
|
-
fileData = fileData.concat("\n\t");
|
|
279
|
-
fileData = fileData.concat("\"name\" : \"");
|
|
280
|
-
fileData = fileData.concat(`${name}`);
|
|
281
|
-
fileData = fileData.concat("\", \n\t");
|
|
282
|
-
fileData = fileData.concat("\"properties\" : [ ] \n");
|
|
283
|
-
fileData = fileData.concat("}");
|
|
284
|
-
return fs.writeFileSync( join(directory, "/config-ext.json"), fileData, { encoding: 'utf8' });
|
|
285
|
-
}
|
|
286
|
-
*/
|
|
287
|
-
|
|
288
262
|
|
|
289
263
|
export const getComponentsObj = async (showSeparator = false, category = CATEGORY_CUSTOM) => {
|
|
290
264
|
const currentDirectory = process.cwd();
|
|
@@ -296,14 +270,7 @@ export const getComponentsObj = async (showSeparator = false, category = CATEGOR
|
|
|
296
270
|
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
297
271
|
data = JSON.parse(data);
|
|
298
272
|
|
|
299
|
-
|
|
300
|
-
console.error(
|
|
301
|
-
`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
|
|
302
|
-
);
|
|
303
|
-
process.exit(1);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
const directory = join(currentDirectory, data[DXCB_CONFIG][COMPONENTS_DIRECTORY_PATH], categoryDirectory);
|
|
273
|
+
const directory = join(currentDirectory, COMPONENTS_DIRECTORY_PATH, categoryDirectory);
|
|
307
274
|
let compList = new Array();
|
|
308
275
|
|
|
309
276
|
switch (category) {
|
|
@@ -456,14 +423,7 @@ export const getComponentsAndSubDirectory = async (category = CATEGORY_CUSTOM) =
|
|
|
456
423
|
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
457
424
|
data = JSON.parse(data);
|
|
458
425
|
|
|
459
|
-
|
|
460
|
-
console.error(
|
|
461
|
-
`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
|
|
462
|
-
);
|
|
463
|
-
process.exit(1);
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
const directory = join(currentDirectory, data[DXCB_CONFIG][COMPONENTS_DIRECTORY_PATH], categoryDirectory);
|
|
426
|
+
const directory = join(currentDirectory, COMPONENTS_DIRECTORY_PATH, categoryDirectory);
|
|
467
427
|
|
|
468
428
|
const fieldComps = await getSubComponentsAndDir(directory, FIELD_PATH);
|
|
469
429
|
const templateComps = await getSubComponentsAndDir(directory, TEMPLATE_PATH);
|
|
@@ -513,7 +473,8 @@ export const getPegaConfig = async () => {
|
|
|
513
473
|
|
|
514
474
|
export const getPegaServerConfig = async () => {
|
|
515
475
|
const config = await getPegaConfig();
|
|
516
|
-
|
|
476
|
+
const server = config[SERVER_CONFIG][SERVER_REST_URL];
|
|
477
|
+
return { ...config[DXCB_CONFIG][DXCB_PUBLISH_ACCESS], server };
|
|
517
478
|
};
|
|
518
479
|
|
|
519
480
|
export const getComponentDefaults = async () => {
|
|
@@ -531,14 +492,7 @@ export const getComponentDirectoryPath = async (componentKey, category = CATEGOR
|
|
|
531
492
|
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
532
493
|
data = JSON.parse(data);
|
|
533
494
|
|
|
534
|
-
|
|
535
|
-
console.error(
|
|
536
|
-
`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
|
|
537
|
-
);
|
|
538
|
-
process.exit(1);
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
return join(currentDirectory, data[DXCB_CONFIG][COMPONENTS_DIRECTORY_PATH], categoryDirectory, componentKey);
|
|
495
|
+
return join(currentDirectory, COMPONENTS_DIRECTORY_PATH, categoryDirectory, componentKey);
|
|
542
496
|
};
|
|
543
497
|
|
|
544
498
|
|