@pega/custom-dx-components 0.242.12 → 0.242.13

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 (22) hide show
  1. package/package.json +2 -2
  2. package/src/tasks/build-all/helper.js +28 -28
  3. package/src/tasks/build-comp/helper.js +46 -18
  4. package/src/tasks/build-comp/index.js +9 -2
  5. package/src/tasks/delete-lib/helper.js +22 -26
  6. package/src/tasks/init/template/package.json.mustache +8 -4
  7. package/src/tasks/publish/helper.js +27 -11
  8. package/src/tasks/publish/index.js +8 -2
  9. package/src/tasks/publish-all/helper.js +36 -39
  10. package/src/tasks/publish-lib/index.js +25 -13
  11. package/src/tasks/rename/index.js +10 -2
  12. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/HighlightRender.tsx +1 -1
  13. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyIconButtonURL/index.tsx +1 -0
  14. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPageWidget/index.tsx +1 -0
  15. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/HighlightRender.tsx +1 -1
  16. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/HighlightRender.tsx +1 -1
  17. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyIconButtonURL/index.tsx +1 -0
  18. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPageWidget/index.tsx +1 -0
  19. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/HighlightRender.tsx +1 -1
  20. package/tests/assets/components/create/Pega_DXIL_MyDetails.zip +0 -0
  21. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails.zip +0 -0
  22. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails.zip +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/custom-dx-components",
3
- "version": "0.242.12",
3
+ "version": "0.242.13",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
@@ -20,9 +20,9 @@
20
20
  "@babel/preset-react": "^7.23.3",
21
21
  "@pega/auth": "^0.1.6",
22
22
  "@pega/constellation-dx-components-build-utils": "^1.0.1-dev-0.10",
23
- "adm-zip": "^0.5.10",
24
23
  "ajv": "^8.12.0",
25
24
  "ajv-keywords": "^5.1.0",
25
+ "archiver": "^7.0.1",
26
26
  "arg": "^5.0.2",
27
27
  "babel-loader": "^9.1.3",
28
28
  "chalk": "^5.3.0",
@@ -1,15 +1,10 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
3
 
4
- import AdmZip from 'adm-zip';
4
+ import archiver from 'archiver';
5
5
  import chalk from 'chalk';
6
6
 
7
- import {
8
- getComponentDirectoryPath,
9
- getComponents,
10
- getPegaServerConfig
11
- } from '../../util.js';
12
- import { COMPONENT_SCHEMA } from '../../constants.js';
7
+ import { getComponentDirectoryPath, getComponents, getPegaServerConfig } from '../../util.js';
13
8
 
14
9
  export const cleanUp = async () => {
15
10
  if (fs.existsSync('dist/components')) {
@@ -27,16 +22,14 @@ export const cleanUp = async () => {
27
22
  }
28
23
  });
29
24
  }
30
- }
31
-
32
-
25
+ };
33
26
 
34
- export const getBuildComponentQuestions = async () => {
27
+ export const getBuildComponentQuestions = async () => {
35
28
  const components = await getComponents();
36
29
  const defaultPegaConfig = await getPegaServerConfig();
37
30
 
38
31
  if (components.length == 0) {
39
- console.log(chalk.redBright("No components to build"));
32
+ console.log(chalk.redBright('No components to build'));
40
33
  process.exit(1);
41
34
  }
42
35
 
@@ -50,32 +43,39 @@ export const getBuildComponentQuestions = async () => {
50
43
  ];
51
44
  };
52
45
 
53
-
54
-
55
- export const zipComponent = async (componentKey) => {
46
+ export const zipComponent = async componentKey => {
56
47
  const srcDirectory = await getComponentDirectoryPath(componentKey);
57
48
  const buildDirectory = await path.join(path.resolve(), 'dist/components', componentKey);
58
49
  const configJson = `${srcDirectory}/config.json`;
59
50
  const localizationJson = `${srcDirectory}/localizations.json`;
60
51
 
61
- const zip = new AdmZip();
52
+ const archive = archiver('zip', { zlib: { level: 9 } });
53
+ const zipChunks = [];
54
+ archive.on('data', chunk => zipChunks.push(chunk));
62
55
 
63
- zip.addLocalFolder(srcDirectory, 'src/');
64
- zip.addLocalFile(configJson);
56
+ // Add src directory
57
+ archive.directory(srcDirectory, 'src');
65
58
 
59
+ // Add config.json file
60
+ if (fs.existsSync(configJson)) {
61
+ archive.file(configJson, { name: path.basename(configJson) });
62
+ }
63
+
64
+ // Add localizations.json file if it exists
66
65
  if (fs.existsSync(localizationJson)) {
67
- zip.addLocalFile(localizationJson);
66
+ archive.file(localizationJson, { name: path.basename(localizationJson) });
68
67
  }
69
68
 
70
- zip.addLocalFolder(buildDirectory);
71
- const zipContent = zip.toBuffer().toString('base64');
69
+ // Add build directory
70
+ archive.directory(buildDirectory, false);
71
+
72
+ await archive.finalize();
73
+
74
+ const zipBuffer = Buffer.concat(zipChunks);
75
+ console.log(chalk.green(`component zipped with size: ${Math.ceil(zipBuffer.length / 1024)} KB`));
76
+ const zipContent = zipBuffer.toString('base64');
77
+
78
+ const configContent = Buffer.from(fs.readFileSync(configJson)).toString();
72
79
 
73
- const configContent = Buffer.from(fs.readFileSync(`${srcDirectory}/config.json`)).toString();
74
- // clean up now happens in function cleanUp
75
- // fs.rmd('dist/components', { recursive: true }, err => {
76
- // if (err) {
77
- // throw err;
78
- // }
79
- // });
80
80
  return { zipContent, configContent };
81
81
  };
@@ -2,13 +2,19 @@ import fs from 'fs';
2
2
  import path from 'path';
3
3
 
4
4
  import fetch from 'node-fetch';
5
- import AdmZip from 'adm-zip';
5
+ import archiver from 'archiver';
6
6
  import chalk from 'chalk';
7
7
 
8
- import { constructCompleteUrl, getComponentDirectoryPath, getComponents, getPegaServerConfig, getHttpsAgent } from '../../util.js';
8
+ import {
9
+ constructCompleteUrl,
10
+ getComponentDirectoryPath,
11
+ getComponents,
12
+ getPegaServerConfig,
13
+ getHttpsAgent
14
+ } from '../../util.js';
9
15
  import { PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH } from '../../constants.js';
10
16
 
11
- export const getPublishComponentQuestions = async () => {
17
+ export const getPublishComponentQuestions = async componentKey => {
12
18
  const components = await getComponents();
13
19
 
14
20
  if (components.length === 0) {
@@ -23,7 +29,9 @@ export const getPublishComponentQuestions = async () => {
23
29
  name: 'componentKey',
24
30
  type: 'rawlist',
25
31
  message: 'Select component to build',
26
- choices: components
32
+ choices: components,
33
+ default: componentKey,
34
+ when: () => !componentKey
27
35
  },
28
36
  {
29
37
  name: 'sourceMap',
@@ -41,27 +49,41 @@ export const getPublishComponentQuestions = async () => {
41
49
  ];
42
50
  };
43
51
 
44
- export const zipComponent = async (componentKey) => {
52
+ export const zipComponent = async componentKey => {
45
53
  const srcDirectory = await getComponentDirectoryPath(componentKey);
46
54
  const buildDirectory = await path.join(path.resolve(), 'dist/components', componentKey);
47
55
  const configJson = `${srcDirectory}/config.json`;
48
56
 
49
57
  const localizationJson = `${srcDirectory}/localizations.json`;
50
58
 
51
- const zip = new AdmZip();
59
+ const archive = archiver('zip', { zlib: { level: 9 } });
60
+ const zipChunks = [];
61
+ archive.on('data', chunk => zipChunks.push(chunk));
52
62
 
53
- zip.addLocalFolder(srcDirectory, 'src/');
54
- zip.addLocalFile(configJson);
63
+ // Add src directory
64
+ archive.directory(srcDirectory, 'src');
55
65
 
66
+ // Add config.json file
67
+ if (fs.existsSync(configJson)) {
68
+ archive.file(configJson, { name: path.basename(configJson) });
69
+ }
70
+
71
+ // Add localizations.json file if it exists
56
72
  if (fs.existsSync(localizationJson)) {
57
- zip.addLocalFile(localizationJson);
73
+ archive.file(localizationJson, { name: path.basename(localizationJson) });
58
74
  }
59
75
 
60
- zip.addLocalFolder(buildDirectory);
61
- const zipContent = zip.toBuffer().toString('base64');
76
+ // Add build directory
77
+ archive.directory(buildDirectory, false);
78
+
79
+ await archive.finalize();
62
80
 
81
+ const zipBuffer = Buffer.concat(zipChunks);
82
+ console.log(chalk.green(`component zipped with size: ${Math.ceil(zipBuffer.length / 1024)} KB`));
83
+ const zipContent = zipBuffer.toString('base64');
84
+
85
+ const configContent = Buffer.from(fs.readFileSync(configJson)).toString();
63
86
 
64
- const configContent = Buffer.from(fs.readFileSync(`${srcDirectory}/config.json`)).toString();
65
87
  if (fs.existsSync('dist/components')) {
66
88
  fs.rm('dist/components', { recursive: true }, err => {
67
89
  if (err) {
@@ -77,10 +99,11 @@ export const zipComponent = async (componentKey) => {
77
99
  }
78
100
  });
79
101
  }
102
+
80
103
  return { zipContent, configContent };
81
104
  };
82
105
 
83
- export const publishComponentToServer = async (data) => {
106
+ export const publishComponentToServer = async data => {
84
107
  const { configContent, zipContent, rulesetName, rulesetVersion } = data;
85
108
 
86
109
  const apiBody = {
@@ -93,7 +116,10 @@ export const publishComponentToServer = async (data) => {
93
116
  category: ''
94
117
  };
95
118
  const defaultPegaConfig = await getPegaServerConfig();
96
- const url = constructCompleteUrl(defaultPegaConfig.server, PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT);
119
+ const url = constructCompleteUrl(
120
+ defaultPegaConfig.server,
121
+ PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT
122
+ );
97
123
  try {
98
124
  const OauthData = fs.readFileSync(TOKEN_PATH, 'utf8');
99
125
  if (OauthData) {
@@ -107,14 +133,16 @@ export const publishComponentToServer = async (data) => {
107
133
  },
108
134
  body: JSON.stringify(apiBody)
109
135
  })
110
- .then((response) => {
136
+ .then(response => {
111
137
  status = response.status;
112
138
  return response.text();
113
139
  })
114
- .then((resp) => {
140
+ .then(resp => {
115
141
  const respData = JSON.parse(resp);
116
142
  if (status === 401) {
117
- throw new Error('Error occurred in authentication. Please regenerate using authenticate');
143
+ throw new Error(
144
+ 'Error occurred in authentication. Please regenerate using authenticate'
145
+ );
118
146
  // console.log(accessTokenUri, refreshToken);
119
147
  /* TODO - Handle refresh_token */
120
148
  } else if (status === 200) {
@@ -124,7 +152,7 @@ export const publishComponentToServer = async (data) => {
124
152
  }
125
153
  })
126
154
  // eslint-disable-next-line prefer-promise-reject-errors
127
- .catch((e) => Promise.reject(`${chalk.bold.red(e)}`));
155
+ .catch(e => Promise.reject(`${chalk.bold.red(e)}`));
128
156
  } else {
129
157
  throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
130
158
  }
@@ -29,9 +29,16 @@ export default async options => {
29
29
  content = { componentKey, sourceMap, devBuild};
30
30
  }
31
31
  else {
32
- const questions = await getPublishComponentQuestions();
32
+
33
+ // VS Code pluggin would send in the component
34
+ let paramComponentKey;
35
+ if (options.params.length == 4) {
36
+ paramComponentKey = options.params[3];
37
+ }
38
+
39
+ const questions = await getPublishComponentQuestions(paramComponentKey);
33
40
  const answers = await inquirer.prompt(questions);
34
- ({ componentKey, sourceMap, devBuild } = answers);
41
+ ({ componentKey = paramComponentKey, sourceMap, devBuild } = answers);
35
42
 
36
43
  content = {
37
44
  ...answers
@@ -1,22 +1,20 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
3
 
4
- import AdmZip from 'adm-zip';
5
4
  import chalk from 'chalk';
6
5
 
6
+ import { getPegaServerConfig, checkPathAccess, getComponentDefaults } from '../../util.js';
7
7
  import {
8
- getPegaServerConfig,
9
- checkPathAccess,
10
- getComponentDefaults,
11
- } from '../../util.js';
12
- import { TASKS_CONFIG_JSON_FILENAME, COMPONENTS_DIRECTORY_PATH, COMPONENTS_PATH } from '../../constants.js';
8
+ TASKS_CONFIG_JSON_FILENAME,
9
+ COMPONENTS_DIRECTORY_PATH,
10
+ COMPONENTS_PATH
11
+ } from '../../constants.js';
13
12
 
14
13
  export const SOURCE_OF_COMPONENT_TYPES = {
15
14
  SERVER: 'Server',
16
15
  LOCAL: 'Local'
17
16
  };
18
17
 
19
-
20
18
  const pegaConfigJsonPath = path.join(path.resolve(), TASKS_CONFIG_JSON_FILENAME);
21
19
 
22
20
  export const getOrgLib = async () => {
@@ -28,7 +26,9 @@ export const getOrgLib = async () => {
28
26
  data = data && JSON.parse(data);
29
27
 
30
28
  if (!data[COMPONENTS_DIRECTORY_PATH]) {
31
- console.error(`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`);
29
+ console.error(
30
+ `${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
31
+ );
32
32
  process.exit(1);
33
33
  }
34
34
 
@@ -36,40 +36,36 @@ export const getOrgLib = async () => {
36
36
 
37
37
  let library;
38
38
  ({ library } = componentData);
39
- let { organization } = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'));
39
+ const { organization } = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'));
40
40
 
41
41
  const componentDefaults = await getComponentDefaults();
42
42
  componentDefaults.library = library;
43
43
  componentDefaults.organization = organization;
44
44
 
45
45
  return componentDefaults;
46
- }
46
+ };
47
47
 
48
- export const getDeleteLibraryQuestions = async () => {
48
+ export const getDeleteLibraryQuestions = async () => {
49
49
  const defaultPegaConfig = await getPegaServerConfig();
50
50
 
51
-
52
51
  return [
53
52
  {
54
53
  name: 'sourceOfLibrary',
55
54
  type: 'rawlist',
56
55
  message: 'Delete library from Server or Local ?',
57
56
  choices: Object.values(SOURCE_OF_COMPONENT_TYPES),
58
- default: defaultPegaConfig.sourceOfComponents,
57
+ default: defaultPegaConfig.sourceOfComponents
59
58
  }
60
59
  ];
61
60
  };
62
61
 
63
-
64
- export const getLibraryVersionQuestion = async(libraryName, libVersions) => {
65
-
66
- return [
67
- {
68
- name: 'version',
69
- type: 'rawlist',
70
- message: `Select ${chalk.green.bold(`${libraryName}`)} library version (or ALL) to delete`,
71
- choices: libVersions
72
- }
73
- ];
74
-
75
- }
62
+ export const getLibraryVersionQuestion = async (libraryName, libVersions) => {
63
+ return [
64
+ {
65
+ name: 'version',
66
+ type: 'rawlist',
67
+ message: `Select ${chalk.green.bold(`${libraryName}`)} library version (or ALL) to delete`,
68
+ choices: libVersions
69
+ }
70
+ ];
71
+ };
@@ -63,8 +63,13 @@
63
63
  "@pega/cosmos-react-condition-builder": "7.0.0-build.6.0",
64
64
  "@pega/cosmos-react-core": "7.0.0-build.6.0",
65
65
  "@pega/cosmos-react-work": "7.0.0-build.6.0",
66
+ "ajv": "^8.12.0",
67
+ "ajv-keywords": "^5.1.0",
68
+ "archiver": "^7.0.1",
66
69
  "babel-loader": "^9.1.3",
70
+ "bl": "^6.0.12",
67
71
  "dayjs": "^1.11.11",
72
+ "fast-deep-equal": "3.1.3",
68
73
  "lodash": "^4.17.21",
69
74
  "lodash.get": "^4.4.2",
70
75
  "npm": "^10.8.1",
@@ -74,7 +79,6 @@
74
79
  "react-autosuggest": "^10.1.0",
75
80
  "react-dom": "^17.0.2",
76
81
  "react-is": "^18.3.1",
77
- "react-player": "^2.16.0",
78
82
  "react-redux": "^7.2.9",
79
83
  "serve": "^14.2.3",
80
84
  "shelljs": "^0.8.5",
@@ -89,8 +93,8 @@
89
93
  "@babel/preset-env": "^7.24.7",
90
94
  "@babel/preset-react": "^7.24.7",
91
95
  "@pega/configs": "^0.6.0",
92
- "@pega/custom-dx-components": "0.242.12",
93
- "@pega/pcore-pconnect-typedefs": "2.0.0",
96
+ "@pega/custom-dx-components": "0.242.13",
97
+ "@pega/pcore-pconnect-typedefs": "~3.0.0",
94
98
  "@storybook/addon-actions": "^7.6.7",
95
99
  "@storybook/addon-essentials": "^7.6.19",
96
100
  "@storybook/addon-knobs": "^7.1.1",
@@ -123,6 +127,6 @@
123
127
  "prettier": "3.1.1",
124
128
  "storybook": "^7.6.19",
125
129
  "stylelint": "^14.16.1",
126
- "typescript": "~4.9.5"
130
+ "typescript": "~5.2.2"
127
131
  }
128
132
  }
@@ -2,7 +2,7 @@ import fs from 'fs';
2
2
  import path from 'path';
3
3
 
4
4
  import fetch from 'node-fetch';
5
- import AdmZip from 'adm-zip';
5
+ import archiver from 'archiver';
6
6
  import chalk from 'chalk';
7
7
 
8
8
  import {
@@ -19,7 +19,7 @@ import {
19
19
  TOKEN_PATH
20
20
  } from '../../constants.js';
21
21
 
22
- export const getPublishComponentQuestions = async () => {
22
+ export const getPublishComponentQuestions = async componentKey => {
23
23
  const components = await getComponents();
24
24
 
25
25
  if (components.length === 0) {
@@ -34,7 +34,9 @@ export const getPublishComponentQuestions = async () => {
34
34
  name: 'componentKey',
35
35
  type: 'rawlist',
36
36
  message: 'Select component to publish',
37
- choices: components
37
+ choices: components,
38
+ default: componentKey,
39
+ when: () => !componentKey
38
40
  },
39
41
  {
40
42
  name: 'rulesetName',
@@ -86,19 +88,33 @@ export const zipComponent = async componentKey => {
86
88
  const configJson = `${srcDirectory}/config.json`;
87
89
  const localizationJson = `${srcDirectory}/localizations.json`;
88
90
 
89
- const zip = new AdmZip();
91
+ const archive = archiver('zip', { zlib: { level: 9 } });
92
+ const zipChunks = [];
93
+ archive.on('data', chunk => zipChunks.push(chunk));
90
94
 
91
- zip.addLocalFolder(srcDirectory, 'src/');
92
- zip.addLocalFile(configJson);
95
+ // Add src directory
96
+ archive.directory(srcDirectory, 'src');
93
97
 
98
+ // Add config.json file
99
+ if (fs.existsSync(configJson)) {
100
+ archive.file(configJson, { name: path.basename(configJson) });
101
+ }
102
+
103
+ // Add localizations.json file if it exists
94
104
  if (fs.existsSync(localizationJson)) {
95
- zip.addLocalFile(localizationJson);
105
+ archive.file(localizationJson, { name: path.basename(localizationJson) });
96
106
  }
97
107
 
98
- zip.addLocalFolder(buildDirectory);
99
- const zipContent = zip.toBuffer().toString('base64');
108
+ // Add build directory
109
+ archive.directory(buildDirectory, false);
110
+
111
+ await archive.finalize();
112
+
113
+ const zipBuffer = Buffer.concat(zipChunks);
114
+ console.log(chalk.green(`component zipped with size: ${Math.ceil(zipBuffer.length / 1024)} KB`));
115
+ const zipContent = zipBuffer.toString('base64');
100
116
 
101
- const configContent = Buffer.from(fs.readFileSync(`${srcDirectory}/config.json`)).toString();
117
+ const configContent = Buffer.from(fs.readFileSync(configJson)).toString();
102
118
 
103
119
  fs.rm('dist', { recursive: true }, err => {
104
120
  if (err) {
@@ -193,7 +209,7 @@ export const publishComponentToServer = async (data, doFetch) => {
193
209
  }
194
210
  })
195
211
  .catch(e => {
196
- if (e.code === 'ECONNREFUSED') {
212
+ if (e.code === 'ECONNREFUSED' || status === 401) {
197
213
  // eslint-disable-next-line prefer-promise-reject-errors
198
214
  Promise.reject(
199
215
  `${chalk.bold.red(
@@ -38,9 +38,15 @@ export default async options => {
38
38
 
39
39
  content = { componentKey, rulesetName, rulesetVersion, devBuild };
40
40
  } else {
41
- const questions = await getPublishComponentQuestions();
41
+ // VS Code pluggin would send in the component
42
+ let paramComponentKey;
43
+ if (options.params.length == 4) {
44
+ paramComponentKey = options.params[3];
45
+ }
46
+
47
+ const questions = await getPublishComponentQuestions(paramComponentKey);
42
48
  const answers = await inquirer.prompt(questions);
43
- ({ componentKey, sourceMap, devBuild } = answers);
49
+ ({ componentKey = paramComponentKey, sourceMap, devBuild } = answers);
44
50
 
45
51
  content = {
46
52
  ...answers
@@ -2,7 +2,7 @@ import fs from 'fs';
2
2
  import path from 'path';
3
3
 
4
4
  import fetch from 'node-fetch';
5
- import AdmZip from 'adm-zip';
5
+ import archiver from 'archiver';
6
6
  import chalk from 'chalk';
7
7
 
8
8
  import {
@@ -72,25 +72,34 @@ export const zipComponent = async componentKey => {
72
72
  const configJson = `${srcDirectory}/config.json`;
73
73
  const localizationJson = `${srcDirectory}/localizations.json`;
74
74
 
75
- const zip = new AdmZip();
75
+ const archive = archiver('zip', { zlib: { level: 9 } });
76
+ const zipChunks = [];
77
+ archive.on('data', chunk => zipChunks.push(chunk));
76
78
 
77
- zip.addLocalFolder(srcDirectory, 'src/');
78
- zip.addLocalFile(configJson);
79
+ // Add src directory
80
+ archive.directory(srcDirectory, 'src');
79
81
 
82
+ // Add config.json file
83
+ if (fs.existsSync(configJson)) {
84
+ archive.file(configJson, { name: path.basename(configJson) });
85
+ }
86
+
87
+ // Add localizations.json file if it exists
80
88
  if (fs.existsSync(localizationJson)) {
81
- zip.addLocalFile(localizationJson);
89
+ archive.file(localizationJson, { name: path.basename(localizationJson) });
82
90
  }
83
91
 
84
- zip.addLocalFolder(buildDirectory);
85
- const zipContent = zip.toBuffer().toString('base64');
92
+ // Add build directory
93
+ archive.directory(buildDirectory, false);
94
+
95
+ await archive.finalize();
96
+
97
+ const zipBuffer = Buffer.concat(zipChunks);
98
+ console.log(chalk.green(`component zipped with size: ${Math.ceil(zipBuffer.length / 1024)} KB`));
99
+ const zipContent = zipBuffer.toString('base64');
100
+
101
+ const configContent = Buffer.from(fs.readFileSync(configJson)).toString();
86
102
 
87
- const configContent = Buffer.from(fs.readFileSync(`${srcDirectory}/config.json`)).toString();
88
- // clean up now happens in function cleanUp
89
- // fs.rmdir('dist', { recursive: true }, err => {
90
- // if (err) {
91
- // throw err;
92
- // }
93
- // });
94
103
  return { zipContent, configContent };
95
104
  };
96
105
 
@@ -165,11 +174,10 @@ export const publishComponentToServer = async (data, doFetch) => {
165
174
  headers.Authorization = `${tokenType} ${accessToken}`;
166
175
  }
167
176
 
168
-
169
177
  const response = await fetch(url, {
170
178
  method: 'POST',
171
179
  agent: getHttpsAgent(defaultPegaConfig),
172
- headers: headers,
180
+ headers,
173
181
  body: JSON.stringify(apiBody)
174
182
  });
175
183
 
@@ -181,45 +189,34 @@ export const publishComponentToServer = async (data, doFetch) => {
181
189
  );
182
190
  // console.log(accessTokenUri, refreshToken);
183
191
  /* TODO - Handle refresh_token */
184
- }
185
- else if (status === 404){
192
+ } else if (status === 404) {
186
193
  throw new Error('404: Server resource not found');
187
- }
188
- else if (status === 405){
194
+ } else if (status === 405) {
189
195
  throw new Error('405: Server method not allowed');
190
- }
191
- else if (status === 408){
196
+ } else if (status === 408) {
192
197
  throw new Error('408: Server timed out');
193
- }
194
- else if (response.status === 403) {
195
- throw new Error(
196
- 'Error forbidden: User does not have privileges to Publish.'
197
- );
198
+ } else if (response.status === 403) {
199
+ throw new Error('Error forbidden: User does not have privileges to Publish.');
198
200
  }
199
201
  }
200
202
 
201
203
  try {
202
204
  const respData = isLaunchpad ? await response.text() : await response.json();
203
- console.log(
204
- chalk.bold.green(`Success : ${isLaunchpad ? respData : respData.message}`)
205
- );
205
+ console.log(chalk.bold.green(`Success : ${isLaunchpad ? respData : respData.message}`));
206
206
 
207
207
  if (status === 500) {
208
208
  status = 999;
209
209
  throw new Error(respData.message);
210
210
  }
211
- }
212
- catch (err) {
211
+ } catch (err) {
213
212
  if (status === 500) {
214
- throw new Error(
215
- `Error occurred in authentication. Please regenerate using authenticate`
216
- );
217
- }
218
- else if (status === 999) {
219
- throw new Error (err);
213
+ throw new Error(
214
+ `Error occurred in authentication. Please regenerate using authenticate`
215
+ );
216
+ } else if (status === 999) {
217
+ throw new Error(err);
220
218
  }
221
219
  }
222
-
223
220
  } else {
224
221
  throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
225
222
  }
@@ -107,6 +107,11 @@ export default async (options) => {
107
107
  }
108
108
  else {
109
109
 
110
+ if (options.params.length == 5) {
111
+ libraryName = options.params[3];
112
+ version = options.params[4];
113
+ }
114
+
110
115
  const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
111
116
 
112
117
  if (tokenAndStaticServer.C11NB2S === undefined) {
@@ -114,25 +119,32 @@ export default async (options) => {
114
119
  process.exit(1);
115
120
  }
116
121
 
117
- const compDef = await getOrgLib();
118
- organization = compDef.organization;
119
- library = compDef.library;
122
+ let libVersions = [];
123
+ if (!libraryName) {
124
+ const compDef = await getOrgLib();
125
+ organization = compDef.organization;
126
+ library = compDef.library;
120
127
 
121
- libraryName = organization.concat("_").concat(library);
128
+ libraryName = organization.concat("_").concat(library);
122
129
 
123
- console.log(`\nLibrary ${chalk.bold.green(libraryName)} `)
130
+ console.log(`\nLibrary ${chalk.bold.green(libraryName)} `)
124
131
 
125
- let libVersions = [];
126
- try {
127
- libVersions = await getLocalLibraryVersions(libraryName);
132
+
133
+ try {
134
+ libVersions = await getLocalLibraryVersions(libraryName);
135
+ }
136
+ catch (ex) {}
128
137
  }
129
- catch (ex) {}
130
138
 
131
- if (libVersions.length > 0) {
132
- const versionQuestions = await getLibraryVersionQuestion(libVersions);
133
- const versionAnswers = await inquirer.prompt(versionQuestions);
139
+ if (libVersions.length > 0 || version) {
140
+
141
+ if (!version) {
142
+ const versionQuestions = await getLibraryVersionQuestion(libVersions);
143
+ const versionAnswers = await inquirer.prompt(versionQuestions);
144
+
145
+ ({version} = versionAnswers);
146
+ }
134
147
 
135
- ({version} = versionAnswers);
136
148
 
137
149
  let okToPublish = true;
138
150
  if (!version.includes("-dev")) {
@@ -225,13 +225,21 @@ export default async options => {
225
225
 
226
226
  }
227
227
  else {
228
+
229
+ // VS Code pluggin would send in the component
230
+ let paramComponentKey;
231
+ if (options.params.length == 4) {
232
+ paramComponentKey = options.params[3];
233
+ }
234
+
228
235
  const questions = [
229
236
  {
230
237
  name: 'componentKey',
231
238
  type: 'rawlist',
232
239
  pageSize: 15,
233
240
  message: 'Select component to rename',
234
- choices: localComponents
241
+ choices: localComponents,
242
+ when: () => !paramComponentKey
235
243
  },
236
244
  {
237
245
  name: 'componentName',
@@ -312,7 +320,7 @@ export default async options => {
312
320
 
313
321
  await inquirer.prompt(questions).then(async answers => {
314
322
  const {
315
- componentKey,
323
+ componentKey = paramComponentKey,
316
324
  componentName,
317
325
  componentLabel,
318
326
  organization,
@@ -18,7 +18,7 @@ const HighlightRender = (props: HighlightRenderProps) => {
18
18
  field.config.displayAsStatus = true;
19
19
  }
20
20
 
21
- const configProps = getPConnect().resolveConfigProps(field.config);
21
+ const configProps: any = getPConnect().resolveConfigProps(field.config);
22
22
 
23
23
  // @ts-ignore
24
24
  const reactField = getPConnect().createComponent(field);
@@ -119,6 +119,7 @@ function PegaDxilMyIconButtonUrl(props: PegaDxilMyIconButtonUrlProps) {
119
119
  // only retrieve table data if table is shown
120
120
  if (showTable) {
121
121
  PCore.getDataPageUtils()
122
+ // @ts-ignore
122
123
  .getDataAsync(dataViewName, context, params, null, null)
123
124
  // @ts-ignore
124
125
  .then((response: any) => {
@@ -50,6 +50,7 @@ function PegaDxilMyPageWidget(props: PegaDxilMyPageWidgetProps) {
50
50
  useEffect(() => {
51
51
 
52
52
  PCore.getDataApiUtils()
53
+ // @ts-ignore
53
54
  .getData(dataViewName, {}, context)
54
55
  // @ts-ignore
55
56
  .then((response: any) => {
@@ -18,7 +18,7 @@ const HighlightRender = (props: HighlightRenderProps) => {
18
18
  field.config.displayAsStatus = true;
19
19
  }
20
20
 
21
- const configProps = getPConnect().resolveConfigProps(field.config);
21
+ const configProps: any = getPConnect().resolveConfigProps(field.config);
22
22
 
23
23
  // @ts-ignore
24
24
  const reactField = getPConnect().createComponent(field);
@@ -18,7 +18,7 @@ const HighlightRender = (props: HighlightRenderProps) => {
18
18
  field.config.displayAsStatus = true;
19
19
  }
20
20
 
21
- const configProps = getPConnect().resolveConfigProps(field.config);
21
+ const configProps: any = getPConnect().resolveConfigProps(field.config);
22
22
 
23
23
  // @ts-ignore
24
24
  const reactField = getPConnect().createComponent(field);
@@ -116,6 +116,7 @@ function PegaDxilMyIconButtonUrl(props: PegaDxilMyIconButtonUrlProps) {
116
116
  // only retrieve table data if table is shown
117
117
  if (showTable) {
118
118
  PCore.getDataPageUtils()
119
+ // @ts-ignore
119
120
  .getDataAsync(dataViewName, context, params, null, null)
120
121
  // @ts-ignore
121
122
  .then((response: any) => {
@@ -50,6 +50,7 @@ function PegaDxilMyPageWidget(props: PegaDxilMyPageWidgetProps) {
50
50
  useEffect(() => {
51
51
 
52
52
  PCore.getDataApiUtils()
53
+ // @ts-ignore
53
54
  .getData(dataViewName, {}, context)
54
55
  // @ts-ignore
55
56
  .then((response: any) => {
@@ -18,7 +18,7 @@ const HighlightRender = (props: HighlightRenderProps) => {
18
18
  field.config.displayAsStatus = true;
19
19
  }
20
20
 
21
- const configProps = getPConnect().resolveConfigProps(field.config);
21
+ const configProps: any = getPConnect().resolveConfigProps(field.config);
22
22
 
23
23
  // @ts-ignore
24
24
  const reactField = getPConnect().createComponent(field);