@pega/custom-dx-components 2.0.24 → 8.8.1

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.
Files changed (44) hide show
  1. package/package.json +1 -1
  2. package/src/auth.js +5 -5
  3. package/src/cli.js +18 -0
  4. package/src/constants.js +35 -1
  5. package/src/tasks/authenticate/index.js +72 -31
  6. package/src/tasks/build/helper.js +3 -3
  7. package/src/tasks/build-all/helper.js +69 -0
  8. package/src/tasks/build-all/index.js +79 -0
  9. package/src/tasks/create/templates/Constellation/Field/Boolean/styles.js.mustache +1 -1
  10. package/src/tasks/create/templates/Constellation/Field/Date/styles.js.mustache +1 -1
  11. package/src/tasks/create/templates/Constellation/Field/DateTime/styles.js.mustache +1 -1
  12. package/src/tasks/create/templates/Constellation/Field/Decimal/styles.js.mustache +1 -1
  13. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/styles.js.mustache +1 -1
  14. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/styles.js.mustache +1 -1
  15. package/src/tasks/create/templates/Constellation/Field/Integer/styles.js.mustache +1 -1
  16. package/src/tasks/create/templates/Constellation/Field/Picklist/styles.js.mustache +1 -1
  17. package/src/tasks/create/templates/Constellation/Field/Text/config.json.mustache +14 -0
  18. package/src/tasks/create/templates/Constellation/Field/Text/styles.js.mustache +1 -1
  19. package/src/tasks/create/templates/Constellation/Field/Text-Email/styles.js.mustache +1 -1
  20. package/src/tasks/create/templates/Constellation/Field/Text-Input/styles.js.mustache +1 -1
  21. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/styles.js.mustache +1 -1
  22. package/src/tasks/create/templates/Constellation/Field/Text-Phone/styles.js.mustache +1 -1
  23. package/src/tasks/create/templates/Constellation/Field/Text-URL/styles.js.mustache +1 -1
  24. package/src/tasks/create/templates/Constellation/Field/TimeofDay/styles.js.mustache +1 -1
  25. package/src/tasks/create/templates/Constellation/Template/DETAILS/styles.js.mustache +1 -1
  26. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/styles.js.mustache +1 -1
  27. package/src/tasks/create/templates/Constellation/Template/FORM/styles.js.mustache +1 -1
  28. package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +4 -1
  29. package/src/tasks/create/templates/Constellation/Template/FORM-region/styles.js.mustache +1 -1
  30. package/src/tasks/create/templates/Constellation/Template/PAGE/styles.js.mustache +1 -1
  31. package/src/tasks/create-all/index.js +400 -0
  32. package/src/tasks/index.js +3 -0
  33. package/src/tasks/init/template/package.json.mustache +5 -2
  34. package/src/tasks/list/helper.js +19 -6
  35. package/src/tasks/publish/helper.js +3 -3
  36. package/src/tasks/publish-all/helper.js +20 -6
  37. package/src/tasks/publish-all/index.js +29 -18
  38. package/src/tasks/rename/index.js +315 -0
  39. package/src/tasks/validator/index.js +182 -7
  40. package/src/util.js +66 -3
  41. package/src/tasks/create/template/config.json.mustache +0 -62
  42. package/src/tasks/create/template/demo.stories.jsx.mustache +0 -44
  43. package/src/tasks/create/template/index.jsx.mustache +0 -55
  44. package/src/tasks/create/template/styles.js.mustache +0 -7
@@ -2,6 +2,6 @@ import styled, { css } from 'styled-components';
2
2
 
3
3
  export default styled.div(() => {
4
4
  return css`
5
- margin: 8px 0;
5
+ margin: 0px 0px;
6
6
  `;
7
7
  });
@@ -2,6 +2,6 @@ import styled, { css } from 'styled-components';
2
2
 
3
3
  export default styled.div(() => {
4
4
  return css`
5
- margin: 8px 0;
5
+ margin: 0px 0px;
6
6
  `;
7
7
  });
@@ -2,6 +2,6 @@ import styled, { css } from 'styled-components';
2
2
 
3
3
  export default styled.div(() => {
4
4
  return css`
5
- margin: 8px 0;
5
+ margin: 0px 0px;
6
6
  `;
7
7
  });
@@ -19,13 +19,16 @@ export default function {{COMPONENT_CLASS_NAME}}(props) {
19
19
  gridContainer.cols = gridRepeat;
20
20
  gridContainer.alignItems = 'start';
21
21
 
22
+ const flexContainer = {direction: 'column'};
23
+ flexContainer.gap = 2;
24
+
22
25
  return (
23
26
  <Styled{{COMPONENT_CLASS_NAME}}Wrapper>
24
27
  {{! pick new delimiteres for mustache }}
25
28
  {{=<% %>=}}
26
29
  <Grid container={gridContainer}>
27
30
  {children.map((child, i) => (
28
- <Flex container={{ direction: 'column'}} key={`r-${i + 1}`}>
31
+ <Flex container={flexContainer} key={`r-${i + 1}`}>
29
32
  {child}
30
33
  </Flex>
31
34
  ))}
@@ -2,6 +2,6 @@ import styled, { css } from 'styled-components';
2
2
 
3
3
  export default styled.div(() => {
4
4
  return css`
5
- margin: 8px 0;
5
+ margin: 0px 0px;
6
6
  `;
7
7
  });
@@ -2,6 +2,6 @@ import styled, { css } from 'styled-components';
2
2
 
3
3
  export default styled.div(() => {
4
4
  return css`
5
- margin: 0px 0;
5
+ margin: 0px 0px;
6
6
  `;
7
7
  });
@@ -0,0 +1,400 @@
1
+ import path from 'path';
2
+ import { URL, fileURLToPath } from 'url';
3
+ import fs from 'fs';
4
+ import { promisify } from 'util';
5
+ import { join } from 'path';
6
+
7
+ import inquirer from 'inquirer';
8
+ import ncp from 'ncp';
9
+ import chalk from 'chalk';
10
+
11
+ import { checkPathAccess, showVersion } from '../../util.js';
12
+
13
+
14
+ export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
15
+
16
+ import {
17
+ convertIntoPascalCase,
18
+ compileMustacheTemplate,
19
+ getComponentDirectoryPath,
20
+ getPegaConfig,
21
+ getComponents,
22
+ getComponentDefaults,
23
+ sanitize,
24
+ validateSemver
25
+ } from '../../util.js';
26
+ import {
27
+ COMPONENT_SCHEMA,
28
+ COMPONENTS_DIRECTORY_PATH,
29
+ TASKS_CONFIG_JSON_FILENAME,
30
+ COMPONENTS_PATH,
31
+ CATEGORY_CONSTELLATION
32
+ } from '../../constants.js';
33
+
34
+ const pegaConfigJsonPath = path.join(path.resolve(), TASKS_CONFIG_JSON_FILENAME);
35
+ //const pegaConfigInternalJsonPath = path.join(path.resolve(), DXCB_CONFIG_INTERNAL_JSON_FILENAME);
36
+
37
+ const copy = promisify(ncp);
38
+
39
+ const copyComponentTemplate = async options => {
40
+ if (options.targetDirectory) {
41
+ return copy(options.templateDirectory, options.targetDirectory, {
42
+ clobber: false
43
+ });
44
+ }
45
+ else {
46
+ return copy(options.templateDirectoryConstellation, options.targetDirectoryConstellation, {
47
+ clobber: false,
48
+ filter: (fileName) => {
49
+ // filter out the file config.json or config.json.mustache
50
+ if (fileName.indexOf("config.json") >= 0) return false;
51
+ else return true;
52
+ }
53
+ });
54
+ }
55
+
56
+ };
57
+
58
+ export const compileMustacheTemplates = async (
59
+ componentDirectory,
60
+ {
61
+ componentKey,
62
+ componentName,
63
+ componentLabel,
64
+ library,
65
+ version,
66
+ type,
67
+ subtype,
68
+ description,
69
+ organization,
70
+ allowedApplications
71
+ }
72
+ ) => {
73
+ const files = fs.readdirSync(componentDirectory);
74
+ const componentClassName = convertIntoPascalCase(componentKey);
75
+
76
+ const isTemplate = type === 'Template';
77
+ const isPicklist = subtype === 'Picklist';
78
+ const isBool = subtype === 'Boolean';
79
+ const isPhone = subtype === 'Phone';
80
+
81
+ if (Array.isArray(subtype) && subtype.length === 1) {
82
+ subtype = subtype.toString();
83
+ }
84
+
85
+ let mustacheSubType = subtype;
86
+
87
+ // overrides
88
+ if (typeof(mustacheSubType) == "string") {
89
+ switch (mustacheSubType) {
90
+ case "FORM-region" :
91
+ mustacheSubType = "FORM";
92
+ break;
93
+ case "DETAILS-region" :
94
+ mustacheSubType = "DETAILS";
95
+ break;
96
+ case "Text-Input" :
97
+ mustacheSubType = "Text";
98
+ break;
99
+ }
100
+
101
+ }
102
+
103
+ if (allowedApplications.trim() === '') {
104
+ allowedApplications = [];
105
+ } else {
106
+ if (allowedApplications.indexOf(',') !== -1) {
107
+ allowedApplications = allowedApplications.split(',');
108
+ }
109
+ allowedApplications = [].concat(allowedApplications);
110
+ }
111
+
112
+ allowedApplications = allowedApplications.filter(el => !!el.trim()).map(el => el.trim());
113
+ files.forEach(file => {
114
+ const filePath = path.join(componentDirectory, file);
115
+
116
+ const output = compileMustacheTemplate(filePath, {
117
+ COMPONENT_KEY: componentKey,
118
+ COMPONENT_NAME: componentName,
119
+ COMPONENT_LABEL: componentLabel,
120
+ COMPONENT_CLASS_NAME: componentClassName,
121
+ ORGANIZATION: organization,
122
+ VERSION: version,
123
+ LIBRARY: library,
124
+ ALLOWEDAPPS: JSON.stringify(allowedApplications),
125
+ TYPE: type,
126
+ SUB_TYPE: JSON.stringify(mustacheSubType),
127
+ DESCRIPTION: description || componentLabel,
128
+ IS_TEMPLATE: isTemplate,
129
+ IS_PICKLIST: isPicklist,
130
+ IS_BOOLEAN: isBool,
131
+ IS_PHONE: isPhone
132
+ });
133
+ fs.writeFileSync(filePath, output);
134
+ fs.renameSync(filePath, filePath.replace('.mustache', ''));
135
+ });
136
+ };
137
+
138
+
139
+ export const validateCompileAll = async (
140
+ {
141
+ prefix,
142
+ library,
143
+ version,
144
+ allowedApplications,
145
+ organization
146
+ },
147
+ options,
148
+
149
+ ) => {
150
+
151
+
152
+ for (let fieldIdx in COMPONENT_SCHEMA.subtype.field) {
153
+ const type = "Field";
154
+ const subtype = COMPONENT_SCHEMA.subtype.field[fieldIdx].value;
155
+ const prefixNoSpace = prefix.replace(/\s+/g, '');
156
+ const componentNameNoSpace = COMPONENT_SCHEMA.subtype.field[fieldIdx].name.replace(/\s+/g, '');
157
+ const componentName = "".concat(prefixNoSpace).concat(componentNameNoSpace);
158
+ const componentLabel = "".concat(prefix).concat(" ").concat(COMPONENT_SCHEMA.subtype.field[fieldIdx].name);
159
+ const description = componentLabel;
160
+
161
+ await validateCompile(
162
+ {
163
+ library,
164
+ organization,
165
+ componentName,
166
+ componentLabel,
167
+ version,
168
+ type,
169
+ subtype,
170
+ description,
171
+ allowedApplications
172
+ },
173
+ options
174
+ )
175
+ }
176
+
177
+ for (let templateIdx in COMPONENT_SCHEMA.subtype.template) {
178
+ const type = "Template";
179
+ const subtype = COMPONENT_SCHEMA.subtype.template[templateIdx].value;
180
+ const prefixNoSpace = prefix.replace(/\s+/g, '');
181
+ let templateNameOriginal = COMPONENT_SCHEMA.subtype.template[templateIdx].name;
182
+ let templateName = convertIntoPascalCase(COMPONENT_SCHEMA.subtype.template[templateIdx].name);
183
+ let templateLabel = convertIntoPascalCase(COMPONENT_SCHEMA.subtype.template[templateIdx].name);
184
+ if (templateNameOriginal.indexOf("region") >= 0) {
185
+ let templateNameBase = convertIntoPascalCase(templateNameOriginal.replace(" region", ""));
186
+ templateName = "TwoColumn".concat(templateNameBase);
187
+ templateLabel = "Two Column ".concat(templateNameBase);
188
+ }
189
+ const componentName = "".concat(prefixNoSpace).concat(templateName);
190
+ const componentLabel = "".concat(prefix).concat(" ").concat(templateLabel);
191
+ const description = componentLabel;
192
+
193
+ await validateCompile(
194
+ {
195
+ library,
196
+ organization,
197
+ componentName,
198
+ componentLabel,
199
+ version,
200
+ type,
201
+ subtype,
202
+ description,
203
+ allowedApplications
204
+ },
205
+ options
206
+ )
207
+ }
208
+
209
+
210
+ for (let widgetIdx in COMPONENT_SCHEMA.subtype.widget) {
211
+ const type = "Widget";
212
+ const subtype = COMPONENT_SCHEMA.subtype.widget[widgetIdx].value;
213
+ const prefixNoSpace = prefix.replace(/\s+/g, '');
214
+ let widgetNameOriginal = COMPONENT_SCHEMA.subtype.widget[widgetIdx].name;
215
+ let widgetName = convertIntoPascalCase(COMPONENT_SCHEMA.subtype.widget[widgetIdx].name).concat("Widget");
216
+ let widgetLabel = convertIntoPascalCase(COMPONENT_SCHEMA.subtype.widget[widgetIdx].name).concat(" Widget");
217
+ if (widgetName.indexOf("&") >= 0) {
218
+ widgetName = convertIntoPascalCase(widgetNameOriginal.replace(" & ", ""));
219
+ }
220
+ const componentName = "".concat(prefixNoSpace).concat(widgetName);
221
+ const componentLabel = "".concat(prefix).concat(" ").concat(widgetLabel);
222
+ const description = componentLabel;
223
+
224
+ await validateCompile(
225
+ {
226
+ library,
227
+ organization,
228
+ componentName,
229
+ componentLabel,
230
+ version,
231
+ type,
232
+ subtype,
233
+ description,
234
+ allowedApplications
235
+ },
236
+ options
237
+ )
238
+ }
239
+
240
+
241
+ }
242
+
243
+
244
+ export const validateCompile = async (
245
+ {
246
+ library,
247
+ organization,
248
+ componentName,
249
+ componentLabel,
250
+ version,
251
+ framework,
252
+ type,
253
+ subtype,
254
+ description,
255
+ allowedApplications
256
+ },
257
+ options
258
+ ) => {
259
+
260
+ let sSubType = subtype;
261
+ if (Array.isArray(subtype)) {
262
+ sSubType = subtype.join("-");
263
+ }
264
+
265
+ const typeLC = type.toLowerCase();
266
+
267
+ //await checkPathAccess(pegaConfigInternalJsonPath);
268
+
269
+ framework = convertIntoPascalCase(CATEGORY_CONSTELLATION);
270
+
271
+ let pegaConfig = await getPegaConfig();
272
+ let templateParentDir = `./templates/${framework}`;
273
+
274
+
275
+ const templateDir = `${templateParentDir}/${type}/${sSubType}`;
276
+ let templateDirectory = fileURLToPath(new URL(templateDir, import.meta.url));
277
+ templateDirectory = templateDirectory.replace("/create-all", "/create");
278
+
279
+ const componentKey = `${organization}_${library}_${componentName}`;
280
+
281
+ const targetDirectory = await getComponentDirectoryPath(componentKey);
282
+
283
+ const components = await getComponents(false);
284
+
285
+
286
+ if (components.includes(componentKey)) {
287
+ console.log(chalk.red(`${componentKey} component already exists in ${targetDirectory}`));
288
+
289
+ return;
290
+ }
291
+
292
+ // component
293
+ await copyComponentTemplate({
294
+ ...options,
295
+ targetDirectory,
296
+ templateDirectory
297
+ });
298
+ await compileMustacheTemplates(targetDirectory, {
299
+ componentKey,
300
+ componentName,
301
+ componentLabel,
302
+ library,
303
+ version,
304
+ type,
305
+ subtype,
306
+ description,
307
+ organization,
308
+ allowedApplications
309
+ });
310
+
311
+
312
+ console.log(chalk.green(`created ${componentKey} component in ${targetDirectory}`));
313
+
314
+
315
+
316
+ };
317
+
318
+ export default async options => {
319
+ showVersion();
320
+
321
+ await checkPathAccess(pegaConfigJsonPath);
322
+
323
+ let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
324
+ data = data && JSON.parse(data);
325
+
326
+ if (!data[COMPONENTS_DIRECTORY_PATH]) {
327
+ console.error(
328
+ `${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
329
+ );
330
+ process.exit(1);
331
+ }
332
+
333
+ const componentData = data[COMPONENTS_PATH];
334
+
335
+ const { library } = componentData;
336
+ const { organization } = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'));
337
+
338
+ let componentDefaults = await getComponentDefaults();
339
+ componentDefaults.library = library;
340
+
341
+
342
+ const questions = [
343
+ {
344
+ name: 'prefix',
345
+ message: 'Enter prefix label'
346
+ },
347
+ {
348
+ name: 'version',
349
+ message: 'Enter component version',
350
+ default: componentDefaults.version,
351
+ validate: value => {
352
+ if (validateSemver(value)) {
353
+ return true;
354
+ }
355
+ return 'Please provide semver compatible version e.g 0.0.1';
356
+ }
357
+ },
358
+ {
359
+ name: 'library',
360
+ message: 'Enter library name (required)',
361
+ default: componentDefaults.library,
362
+ validate: value => {
363
+ /* value should not be empty
364
+ It should not have spaces
365
+ It should not start with a number
366
+ Only case-insensitive alphanumeric values are allowed
367
+ */
368
+ if (value && !/^\d/.test(value) && value === sanitize(value)) {
369
+ return true;
370
+ }
371
+ return 'Only alphanumeric values are allowed, starting with alphabets';
372
+ }
373
+ },
374
+ {
375
+ name: 'allowedApplications',
376
+ message: 'Please enter the application names to be supported (comma-separated). ',
377
+ suffix: 'Keep empty for all applications'
378
+ }
379
+ ];
380
+
381
+ await inquirer.prompt(questions).then(async answers => {
382
+ const {
383
+ prefix,
384
+ library,
385
+ version,
386
+ allowedApplications
387
+ } = answers;
388
+ await validateCompileAll(
389
+ {
390
+ prefix,
391
+ library,
392
+ version,
393
+ allowedApplications,
394
+ organization
395
+ },
396
+ options
397
+ );
398
+ });
399
+
400
+ };
@@ -1,12 +1,15 @@
1
1
  export { default as createComponent } from './create/index.js';
2
+ export { default as createAllComponents } from './create-all/index.js';
2
3
  export { default as deleteComponent } from './delete/index.js';
3
4
  export { default as deleteAllComponents } from './delete-all/index.js';
4
5
  export { default as initProject } from './init/index.js';
5
6
  export { default as publishComponent } from './publish/index.js';
6
7
  export { default as publishAllComponents } from './publish-all/index.js';
8
+ export { default as renameComponent } from './rename/index.js';
7
9
  export { default as listComponents } from './list/index.js';
8
10
  export { default as updateComponent } from './update/index.js';
9
11
  export { default as validate } from './validator/index.js';
10
12
  export { default as authenticate } from './authenticate/index.js';
11
13
  export { default as upgrade } from './upgrade/index.js';
12
14
  export { default as buildComponent } from './build/index.js';
15
+ export { default as buildAllComponents } from './build-all/index.js';
@@ -5,15 +5,18 @@
5
5
  "organization": "{{organization}}",
6
6
  "main": "src/index.js",
7
7
  "scripts": {
8
- "start-storybook": "start-storybook --port 6040 --quiet",
8
+ "startStorybook": "start-storybook --port 6040 --quiet",
9
9
  "build": "tsc -b tsconfig.build.json",
10
10
  "lint": "run-p -cl lint:*",
11
11
  "fix": "run-p -cl fix:*",
12
12
  "authenticate": "custom-dx-components authenticate",
13
13
  "buildComponent": "custom-dx-components buildComponent",
14
+ "buildAllComponents": "custom-dx-components buildAllComponents",
14
15
  "create": "custom-dx-components create",
16
+ "createAll": "custom-dx-components createAll",
15
17
  "publish": "custom-dx-components publish",
16
18
  "publishAll": "custom-dx-components publishAll",
19
+ "rename": "custom-dx-components rename",
17
20
  "list": "custom-dx-components list",
18
21
  "validate-schema": "custom-dx-components validateSchema",
19
22
  "update": "custom-dx-components update",
@@ -54,7 +57,7 @@
54
57
  },
55
58
  "devDependencies": {
56
59
  "@pega/configs": "^0.3.4",
57
- "@pega/custom-dx-components": "^2.0.24",
60
+ "@pega/custom-dx-components": "^8.8.1",
58
61
  "@pega/eslint-config": "^0.3.2",
59
62
  "@storybook/addon-actions": "^6.5.12",
60
63
  "@storybook/addon-essentials": "^6.5.12",
@@ -4,7 +4,7 @@ import https from 'https';
4
4
  import chalk from 'chalk';
5
5
  import fetch from 'node-fetch';
6
6
 
7
- import { LIST_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH } from '../../constants.js';
7
+ import { LIST_COMPONENT_SERVICE_REST_ENDPOINT, LP_LIST_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH } from '../../constants.js';
8
8
  import { constructCompleteUrl, getComponents, getPegaServerConfig } from '../../util.js';
9
9
 
10
10
  export const SOURCE_OF_COMPONENT_TYPES = {
@@ -42,9 +42,10 @@ export const listLocalComponents = async sourceOfComponents => {
42
42
 
43
43
  export const getComponentsFromServer = async data => {
44
44
  const defaultPegaServerConfig = await getPegaServerConfig();
45
+ const isLaunchpad = defaultPegaServerConfig.serverType === 'launchpad';
45
46
  const url = constructCompleteUrl(
46
47
  defaultPegaServerConfig.server,
47
- LIST_COMPONENT_SERVICE_REST_ENDPOINT
48
+ isLaunchpad ? LP_LIST_COMPONENT_SERVICE_REST_ENDPOINT : LIST_COMPONENT_SERVICE_REST_ENDPOINT
48
49
  );
49
50
  return new Promise((resolve, reject) => {
50
51
  try {
@@ -63,12 +64,19 @@ export const getComponentsFromServer = async data => {
63
64
  refresh_token: refreshToken
64
65
  } = JSON.parse(data);
65
66
  let status = 500;
67
+
68
+ const headers = {
69
+ Authorization: `${tokenType} ${accessToken}`
70
+ }
71
+
72
+ if(isLaunchpad) {
73
+ headers.cookie = `Pega-AAT=${accessToken}`;
74
+ }
75
+
66
76
  fetch(url, {
67
77
  method: 'GET',
68
78
  agent: new https.Agent({ rejectUnauthorized: false }),
69
- headers: {
70
- Authorization: `${tokenType} ${accessToken}`
71
- }
79
+ headers
72
80
  })
73
81
  .then(response => {
74
82
  status = response.status;
@@ -100,8 +108,13 @@ export const getComponentsFromServer = async data => {
100
108
 
101
109
  export const displayServerComponents = async data => {
102
110
  const defaultPegaServerConfig = await getPegaServerConfig();
111
+ const isLaunchpad = defaultPegaServerConfig.serverType === 'launchpad';
103
112
  const parsedData = JSON.parse(data);
104
- const componentList = parsedData.pxResults?.map(({ label, pyRuleSet, pyRuleSetVersion }) => ({
113
+ const list = isLaunchpad ? parsedData.components : parsedData.pxResults;
114
+ /**
115
+ * TODO: Need to modify the components list mapping code to support Launchpad components
116
+ */
117
+ const componentList = list?.map(({ label, pyRuleSet, pyRuleSetVersion }) => ({
105
118
  'Rule name': label,
106
119
  'Ruleset name': pyRuleSet,
107
120
  'Ruleset version': pyRuleSetVersion
@@ -125,7 +125,7 @@ export const publishComponentToServer = async data => {
125
125
  const respData = JSON.parse(resp);
126
126
  if (status === 401) {
127
127
  throw new Error(
128
- 'Error occured in authentication. Please regenerate using authenticate'
128
+ 'Error occurred in authentication. Please regenerate using authenticate'
129
129
  );
130
130
  // console.log(accessTokenUri, refreshToken);
131
131
  /* TODO - Handle refresh_token */
@@ -137,9 +137,9 @@ export const publishComponentToServer = async data => {
137
137
  })
138
138
  .catch(e => Promise.reject(`${chalk.bold.red(e)}`));
139
139
  } else {
140
- throw new Error(`Error occured in authentication. Please regenerate using authenticate`);
140
+ throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
141
141
  }
142
142
  } catch (err) {
143
- throw new Error(`Error occured in authentication. Please regenerate using authenticate`);
143
+ throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
144
144
  }
145
145
  };
@@ -69,13 +69,27 @@ export const zipComponent = async componentKey => {
69
69
  const zipContent = zip.toBuffer().toString('base64');
70
70
 
71
71
  const configContent = Buffer.from(fs.readFileSync(`${srcDirectory}/config.json`)).toString();
72
- fs.rmdir('dist', { recursive: true }, err => {
72
+ //fs.rmdir('dist', { recursive: true }, err => {
73
+ // if (err) {
74
+ // throw err;
75
+ // }
76
+ //});
77
+ return { zipContent, configContent };
78
+ };
79
+
80
+ export const cleanUp = async () => {
81
+ fs.rm('dist/components', { recursive: true }, err => {
73
82
  if (err) {
74
83
  throw err;
75
84
  }
76
85
  });
77
- return { zipContent, configContent };
78
- };
86
+
87
+ fs.rm('lib', { recursive: true }, err => {
88
+ if (err) {
89
+ throw err;
90
+ }
91
+ });
92
+ }
79
93
 
80
94
  export const publishComponentToServer = async data => {
81
95
  const { configContent, zipContent, componentKey, rulesetName, rulesetVersion } = data;
@@ -119,7 +133,7 @@ export const publishComponentToServer = async data => {
119
133
  const respData = JSON.parse(resp);
120
134
  if (status === 401) {
121
135
  throw new Error(
122
- 'Error occured in authentication. Please regenerate using authenticate'
136
+ 'Error occurred in authentication. Please regenerate using authenticate'
123
137
  );
124
138
  // console.log(accessTokenUri, refreshToken);
125
139
  /* TODO - Handle refresh_token */
@@ -131,9 +145,9 @@ export const publishComponentToServer = async data => {
131
145
  })
132
146
  .catch(e => Promise.reject(`${chalk.bold.red(e)}`));
133
147
  } else {
134
- throw new Error(`Error occured in authentication. Please regenerate using authenticate`);
148
+ throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
135
149
  }
136
150
  } catch (err) {
137
- throw new Error(`Error occured in authentication. Please regenerate using authenticate`);
151
+ throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
138
152
  }
139
153
  };