@pega/custom-dx-components 0.8.1 → 0.8.2
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
CHANGED
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@pega/configs": "^0.5.3",
|
|
69
|
-
"@pega/custom-dx-components": "^0.8.
|
|
69
|
+
"@pega/custom-dx-components": "^0.8.2",
|
|
70
70
|
"@pega/eslint-config": "^0.3.2",
|
|
71
71
|
"@storybook/addon-actions": "^6.5.12",
|
|
72
72
|
"@storybook/addon-essentials": "^6.5.12",
|
package/src/tasks/list/helper.js
CHANGED
|
@@ -7,7 +7,15 @@ import ora from 'ora';
|
|
|
7
7
|
|
|
8
8
|
import inquirer from 'inquirer';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
LIST_COMPONENT_SERVICE_REST_ENDPOINT,
|
|
12
|
+
LP_LIST_COMPONENT_SERVICE_REST_ENDPOINT,
|
|
13
|
+
TOKEN_PATH,
|
|
14
|
+
COMPONENT_SCHEMA,
|
|
15
|
+
TASKS_CONFIG_JSON_FILENAME,
|
|
16
|
+
COMPONENTS_DIRECTORY_PATH,
|
|
17
|
+
COMPONENTS_PATH
|
|
18
|
+
} from '../../constants.js';
|
|
11
19
|
import { constructCompleteUrl, getComponents, getPegaServerConfig, getHttpsAgent, sanitize } from '../../util.js';
|
|
12
20
|
|
|
13
21
|
export const SOURCE_OF_COMPONENT_TYPES = {
|
|
@@ -15,24 +23,6 @@ export const SOURCE_OF_COMPONENT_TYPES = {
|
|
|
15
23
|
LOCAL: 'Local'
|
|
16
24
|
};
|
|
17
25
|
|
|
18
|
-
const currentDirectory = process.cwd();
|
|
19
|
-
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
20
|
-
|
|
21
|
-
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
22
|
-
data = data && JSON.parse(data);
|
|
23
|
-
|
|
24
|
-
if (!data[COMPONENTS_DIRECTORY_PATH]) {
|
|
25
|
-
console.error(
|
|
26
|
-
`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
|
|
27
|
-
);
|
|
28
|
-
process.exit(1);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const componentData = data[COMPONENTS_PATH];
|
|
32
|
-
|
|
33
|
-
let { library } = componentData;
|
|
34
|
-
let { organization } = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'));
|
|
35
|
-
|
|
36
26
|
export const getListComponentsQuestions = async (options) => {
|
|
37
27
|
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
38
28
|
|
|
@@ -52,13 +42,28 @@ export const getListComponentsQuestions = async (options) => {
|
|
|
52
42
|
|
|
53
43
|
export const getLaunchPadFilterQuestions = async () => {
|
|
54
44
|
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
45
|
+
const currentDirectory = process.cwd();
|
|
46
|
+
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
47
|
+
|
|
48
|
+
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
49
|
+
data = data && JSON.parse(data);
|
|
50
|
+
|
|
51
|
+
if (!data[COMPONENTS_DIRECTORY_PATH]) {
|
|
52
|
+
console.error(`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const componentData = data[COMPONENTS_PATH];
|
|
57
|
+
|
|
58
|
+
let { library } = componentData;
|
|
59
|
+
let { organization } = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'));
|
|
55
60
|
|
|
56
61
|
return [
|
|
57
62
|
{
|
|
58
63
|
name: 'organization',
|
|
59
64
|
message: 'Enter component organization (required)',
|
|
60
65
|
default: organization,
|
|
61
|
-
validate: value => {
|
|
66
|
+
validate: (value) => {
|
|
62
67
|
if (value) {
|
|
63
68
|
return true;
|
|
64
69
|
}
|
|
@@ -69,7 +74,7 @@ export const getLaunchPadFilterQuestions = async () => {
|
|
|
69
74
|
name: 'library',
|
|
70
75
|
message: 'Enter library name (required)',
|
|
71
76
|
default: library,
|
|
72
|
-
validate: value => {
|
|
77
|
+
validate: (value) => {
|
|
73
78
|
if (value) {
|
|
74
79
|
return true;
|
|
75
80
|
}
|
|
@@ -77,7 +82,7 @@ export const getLaunchPadFilterQuestions = async () => {
|
|
|
77
82
|
}
|
|
78
83
|
}
|
|
79
84
|
];
|
|
80
|
-
}
|
|
85
|
+
};
|
|
81
86
|
|
|
82
87
|
export const listLocalComponents = async (sourceOfComponents) => {
|
|
83
88
|
let localComponents = await getComponents();
|
|
@@ -168,8 +173,6 @@ export const getComponentsFromServer = async (library, organization) => {
|
|
|
168
173
|
isLaunchpad ? LP_LIST_COMPONENT_SERVICE_REST_ENDPOINT : LIST_COMPONENT_SERVICE_REST_ENDPOINT
|
|
169
174
|
);
|
|
170
175
|
|
|
171
|
-
|
|
172
|
-
|
|
173
176
|
return new Promise((resolve, reject) => {
|
|
174
177
|
try {
|
|
175
178
|
fs.readFile(TOKEN_PATH, 'utf8', (err, data) => {
|
|
@@ -187,9 +190,12 @@ export const getComponentsFromServer = async (library, organization) => {
|
|
|
187
190
|
|
|
188
191
|
fetchComponentsFromLaunchpad(url, headers)
|
|
189
192
|
.then((response) => {
|
|
190
|
-
response = response.filter(
|
|
191
|
-
|
|
192
|
-
|
|
193
|
+
response = response.filter(
|
|
194
|
+
(component) =>
|
|
195
|
+
(component.library === library || library === '*') && (component.organization === organization || organization === '*')
|
|
196
|
+
);
|
|
197
|
+
resolve(response);
|
|
198
|
+
})
|
|
193
199
|
.catch((e) => reject(e));
|
|
194
200
|
} else {
|
|
195
201
|
headers.Authorization = `${tokenType} ${accessToken}`;
|