@pega/custom-dx-components 2.0.24 → 8.5.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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/custom-dx-components",
3
- "version": "2.0.24",
3
+ "version": "8.5.1",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
package/src/auth.js CHANGED
@@ -58,8 +58,8 @@ class PegaAuth {
58
58
 
59
59
  // For PKCE the authorize includes a code_challenge & code_challenge_method as well
60
60
  async #buildAuthorizeUrl(state) {
61
- const { serverType, clientId, redirectUri, authorizeUri, authService, sessionIndex, appAlias, userIdentifier, password, noPKCE } =
62
- this.config;
61
+ const { serverType, clientId, redirectUri, authorizeUri, authService, sessionIndex, appAlias,
62
+ userIdentifier, password, noPKCE, isolationId } = this.config;
63
63
 
64
64
  if (!noPKCE) {
65
65
  // Generate random string of 64 chars for verifier. RFC 7636 says from 43-128 chars
@@ -93,7 +93,7 @@ class PegaAuth {
93
93
  (sessionIndex && this.config.sessionIndexAttempts < 3 ? `&session_index=${sessionIndex}` : '') +
94
94
  (userIdentifier
95
95
  ? `&UserIdentifier=${encodeURIComponent(userIdentifier)}${password ? `&Password=${encodeURIComponent(this.#atob(password))}` : ''}` : '')
96
- : '');
96
+ : `&isolationID=${isolationId}`);
97
97
 
98
98
  let pkceArgs = '';
99
99
  if (!noPKCE) {
@@ -285,10 +285,10 @@ class PegaAuth {
285
285
  const nSlash = redirectUri.indexOf('/', nLocalhost + 10);
286
286
  const nPort = parseInt(redirectUri.substring(nLocalhost + 10, nSlash));
287
287
  if (-1 !== nLocalhost) {
288
- const options = isHttp ? {} : {
288
+ const options = key && cert && !isHttp ? {
289
289
  key: fs.readFileSync(key),
290
290
  cert: fs.readFileSync(cert)
291
- };
291
+ } : {};
292
292
  const server = (isHttp ? http : https).createServer(options, (req, res) => {
293
293
  const { method, url } = req;
294
294
  const { winTitle, winBodyHtml } = this.config;
package/src/cli.js CHANGED
@@ -4,13 +4,16 @@ import chalk from 'chalk';
4
4
  import {
5
5
  authenticate,
6
6
  buildComponent,
7
+ buildAllComponents,
7
8
  createComponent,
9
+ createAllComponents,
8
10
  deleteComponent,
9
11
  deleteAllComponents,
10
12
  initProject,
11
13
  listComponents,
12
14
  publishComponent,
13
15
  publishAllComponents,
16
+ renameComponent,
14
17
  updateComponent,
15
18
  validate,
16
19
  upgrade
@@ -19,9 +22,12 @@ import {
19
22
  const TASKS = {
20
23
  INIT: 'init',
21
24
  CREATE: 'create',
25
+ CREATE_ALL: 'createAll',
22
26
  BUILD: 'buildComponent',
27
+ BUILD_ALL: 'buildAllComponents',
23
28
  PUBLISH: 'publish',
24
29
  PUBLISH_All: 'publishAll',
30
+ RENAME: 'rename',
25
31
  LIST: 'list',
26
32
  VALIDATE_SCHEMA: 'validateSchema',
27
33
  UPDATE: 'update',
@@ -62,6 +68,10 @@ export default async (args = []) => {
62
68
  createComponent(options);
63
69
  break;
64
70
  }
71
+ case TASKS.CREATE_ALL: {
72
+ createAllComponents(options);
73
+ break;
74
+ }
65
75
  case TASKS.PUBLISH: {
66
76
  publishComponent(options);
67
77
  break;
@@ -70,10 +80,18 @@ export default async (args = []) => {
70
80
  publishAllComponents(options);
71
81
  break;
72
82
  }
83
+ case TASKS.RENAME: {
84
+ renameComponent(options);
85
+ break;
86
+ }
73
87
  case TASKS.BUILD: {
74
88
  buildComponent(options);
75
89
  break;
76
90
  }
91
+ case TASKS.BUILD_ALL: {
92
+ buildAllComponents(options);
93
+ break;
94
+ }
77
95
  case TASKS.LIST: {
78
96
  listComponents(options);
79
97
  break;
package/src/constants.js CHANGED
@@ -2,6 +2,7 @@
2
2
  export const TASKS_CONFIG_JSON_FILENAME = 'tasks.config.json';
3
3
  export const BUILD_CONFIG_JSON_FILENAME = 'build.config.json';
4
4
  export const COMPONENTS_DIRECTORY_PATH = 'components-directory-path';
5
+ export const COMPONENTS_PATH = 'component'
5
6
  export const TOKEN_PATH = 'node_modules/@pega/custom-dx-components/.access_token';
6
7
  export const OOTB_COMPONENTS = 'node_modules/@pega/custom-dx-components/.ootb_components';
7
8
 
@@ -14,6 +15,18 @@ export const INF_TOKEN_URL_V1 = 'PRRestService/oauth2/v1/token';
14
15
  export const INF_AUTHORIZE_URL_V1 = 'PRRestService/oauth2/v1/authorize';
15
16
  export const LP_TOKEN_URL = 'uas/oauth/token';
16
17
  export const LP_AUTHORIZE_URL = 'uas/oauth/authorize';
18
+ export const LP_LIST_COMPONENT_SERVICE_REST_ENDPOINT = 'pegalaunchpad/c11n/v103/app/appstudiox/componentslist';
19
+
20
+
21
+ export const FIELD_PATH = '/field';
22
+ export const TEMPLATE_PATH = '/template';
23
+ export const WIDGET_PATH = '/widget';
24
+
25
+ export const COMPONENT_PREFIX_FIELD_PATH = "field/";
26
+ export const COMPONENT_PREFIX_TEMPLATE_PATH = "template/";
27
+ export const COMPONENT_PREFIX_WIDGET_PATH = "widget/";
28
+
29
+ export const CATEGORY_CONSTELLATION = "constellation";
17
30
 
18
31
  export const AUTHENTICATE_SCHEMA = {
19
32
  serverType: [
@@ -138,7 +151,28 @@ export const COMPONENT_SCHEMA = {
138
151
  value: 'Picklist'
139
152
  }
140
153
  ],
141
- template: ['DETAILS', 'DETAILS-region', 'FORM', 'FORM-region', 'PAGE'],
154
+ template: [
155
+ {
156
+ name: 'DETAILS',
157
+ value: 'DETAILS'
158
+ },
159
+ {
160
+ name: 'DETAILS region',
161
+ value: 'DETAILS-region'
162
+ },
163
+ {
164
+ name: 'FORM',
165
+ value: 'FORM'
166
+ },
167
+ {
168
+ name: 'FORM region',
169
+ value: 'FORM-region'
170
+ },
171
+ {
172
+ name: 'PAGE',
173
+ value: 'PAGE'
174
+ }
175
+ ],
142
176
  widget: [
143
177
  {
144
178
  name: 'CASE',
@@ -1,5 +1,5 @@
1
1
  import path from 'path';
2
- import fs from 'fs';
2
+ import fs from 'node:fs';
3
3
 
4
4
  import chalk from 'chalk';
5
5
  import inquirer from 'inquirer';
@@ -18,13 +18,37 @@ let server = null;
18
18
  const generateAccessToken = async config => {
19
19
 
20
20
  let authSuccess = false;
21
- const { serverType, isolationId, grantType, clientId, clientSecret, user, password } = config;
21
+ const { serverType, authService, isolationId, grantType, clientId, clientSecret, user, password } = config;
22
+ // Try to gracefully deal with missing trailing slashes for server (and later conditionally for redirectUri)
22
23
  const server = config.server.endsWith('/') ? config.server : `${config.server}/`;
23
24
 
24
25
  return new Promise((resolve, reject) => {
25
26
  const sTokenUri = `${server}${serverType === 'infinity' ? INF_TOKEN_URL_V1 : LP_TOKEN_URL}`;
26
27
  const sAuthorizeUri = `${server}${serverType === 'infinity' ? INF_AUTHORIZE_URL_V1 : LP_AUTHORIZE_URL}`;
27
28
  // console.log(`grantType: ${config.grantType}`);
29
+ const browserAuthSuccessMarkup = `<div style="width: 300px; padding: 10px;">
30
+ <svg xmlns="http://www. w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 311 68" version="1.1">
31
+ <title>Logo</title>
32
+ <defs/>
33
+ <g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
34
+ <g id="Logo">
35
+ <g id="pega_logo_horizontal_positive_rgb">
36
+ <path d="M136.36,17.098 L136.173,17.009 C136.154,16.998 133.96,16.01 132.245,17.815 L132.026,18.046 L135.539,19.768 L136.36,17.098 Z M152.441,36.389 C152.441,36.389 150.91,39.13 150.224,40.143 C149.535,41.164 147.38,41.798 145.517,40.908 C144.665,40.503 136.694,35.854 133.644,36.12 C118.205,37.466 113.999,31.105 113.503,30.527 C113.005,29.949 112.077,30.218 112.74,31.355 C116.127,37.163 126.15,39.856 126.15,39.856 C128.771,46.172 129.085,50.597 129.085,50.597 C126.489,48.574 123.687,46.869 120.714,45.453 C112.768,40.121 100.329,33.518 83.207,29.379 C84.191,15.797 91.044,-3.837 123.092,0.806 C123.092,0.806 129.522,1.86 133.809,4.824 C133.809,4.824 132.779,5.904 131.425,7.256 C130.071,8.605 131.569,9.471 131.569,9.471 L138.338,14.792 C138.417,17.607 138.533,18.396 140.651,20.944 C142.769,23.487 151.004,32.112 152.081,33.266 C153.329,34.6 152.441,36.389 152.441,36.389 Z M78.633,9.915 C76.938,16.897 77.068,23.049 77.939,28.221 C76.33,27.901 74.697,27.594 73.014,27.32 C37.94,21.612 27.361,38.899 31.455,52.916 C19.86,57.274 8.963,62.263 0.214,67.162 C13.98,34.146 43.896,5.087 69.145,1.268 C77.389,0.181 79.708,5.529 78.633,9.915 L78.633,9.915 Z" id="Fill-1" fill="#1F2555"/>
37
+ <path d="M83.492,40.09 C97.157,39.01 110.054,40.381 120.713,45.453 C112.768,40.121 100.329,33.518 83.206,29.379 C82.864,34.111 83.23,38.107 83.492,40.09 Z M81.52,40.262 C66.209,41.723 48.105,46.663 31.455,52.916 C27.361,38.899 37.941,21.612 73.014,27.32 C74.697,27.594 76.33,27.901 77.938,28.221 C78.77,33.166 80.276,37.228 81.52,40.262 L81.52,40.262 Z" id="Fill-2" fill="#00A6A7"/>
38
+ <path d="M286.63,35.039 L291.379,23.446 L296.129,35.039 L286.63,35.039 Z M287.854,14 L272.536,50 L280.553,50 L283.819,41.985 L298.938,41.985 L302.204,50 L310.427,50 L295.108,14 L287.854,14 Z M188.647,26.704 C188.647,29.787 186.335,32.153 182.375,32.153 L176.1,32.153 L176.1,21.149 L182.219,21.149 C186.181,21.149 188.647,23.052 188.647,26.601 L188.647,26.704 Z M182.889,14 L168.18,14 L168.18,50 L176.1,50 L176.1,39.2 L182.115,39.2 C190.19,39.2 196.673,34.878 196.673,26.547 L196.673,26.444 C196.673,19.09 191.48,14 182.889,14 Z M239.764,18.02 C235.989,21.708 234.075,26.376 234.075,31.896 C234.075,37.421 235.953,42.054 239.663,45.675 C243.366,49.292 248.022,51.123 253.503,51.123 C259.992,51.123 265.064,49.159 268.587,45.284 L268.769,45.08 L268.769,28.556 L253.112,28.556 L253.112,35.244 L261.279,35.244 L261.279,41.993 C259.164,43.252 256.525,43.891 253.429,43.891 C250.221,43.891 247.454,42.792 245.203,40.62 C242.958,38.458 241.819,35.527 241.819,31.926 C241.819,28.322 242.992,25.379 245.304,23.18 C247.624,20.972 250.538,19.852 253.966,19.852 C255.769,19.852 257.366,20.074 258.711,20.512 C259.973,20.922 261.251,21.667 262.517,22.712 L266.897,17.183 C264.586,15.147 260.427,12.467 253.503,12.467 C248.162,12.467 243.539,14.336 239.764,18.02 Z M210.336,35.604 L225.842,35.604 L225.842,28.556 L210.336,28.556 L210.336,21.042 L229.623,21.042 L229.623,14 L202.466,14 L202.466,50 L229.879,50 L229.879,42.955 L210.336,42.955 L210.336,35.604 L210.336,35.604 Z" id="Fill-3" fill="#1F2555"/>
39
+ </g>
40
+ </g>
41
+ </g>
42
+ </svg>
43
+ </div>
44
+ <div style="font-size: 2em; font-family: Arial; padding: 10px">
45
+ Authentication is complete!!
46
+ </div>
47
+ <div style="font-size: 13m; font-family: Arial; padding: 10px">
48
+ This browser tab or window may be closed.
49
+ </div>
50
+ <div style="padding: 10px;">
51
+ </div>`;
28
52
 
29
53
  const authCodeConfig = grantType === 'authCode' ? {
30
54
  authorizeUri: sAuthorizeUri,
@@ -32,12 +56,13 @@ const generateAccessToken = async config => {
32
56
  cert: config.cert,
33
57
  key: config.key,
34
58
  winTitle: 'DX Component Dev',
35
- winBodyHtml: `Authentication is complete. This browser window may be closed.`
59
+ winBodyHtml: browserAuthSuccessMarkup
36
60
  } : {};
37
61
 
38
62
  // Build auth config structure
39
63
  const authConfig = {
40
64
  serverType: serverType,
65
+ authService: authService,
41
66
  grantType: grantType,
42
67
  tokenUri: sTokenUri,
43
68
  clientId: clientId,
@@ -46,7 +71,6 @@ const generateAccessToken = async config => {
46
71
  ...authCodeConfig
47
72
  };
48
73
  if (serverType === 'infinity') {
49
- authConfig.authService = 'pega';
50
74
  if (grantType !== 'clientCreds' && user && password) {
51
75
  authConfig.userIdentifier = user;
52
76
  authConfig.password = Buffer.from(password).toString('base64');
@@ -54,32 +78,43 @@ const generateAccessToken = async config => {
54
78
  }
55
79
  if (serverType === 'launchpad') {
56
80
  authConfig.isolationId = isolationId;
57
- // authConfig.noPKCE = true;
81
+ authConfig.noPKCE = true;
58
82
  }
59
- const auth = new PegaAuth(authConfig);
60
- // console.log(`...about to invoke auth.login\n${JSON.stringify(authConfig)}`);
61
-
62
- auth.login()
63
- .then((token) => {
64
- if (token?.token_type) {
65
- fs.writeFile(TOKEN_PATH, JSON.stringify(token), err => {
66
- if (err) {
67
- console.error(err);
68
- return reject(authSuccess);
69
- }
70
- console.log(`${chalk.bold.green('Authenticated successfully !!')}`);
71
- authSuccess = true;
72
- return resolve(authSuccess);
73
- });
74
- } else {
75
- console.log(`${chalk.bold.red('Authentication failed:' + JSON.stringify(token.errors ? token.errors : token))}`);
83
+
84
+ try {
85
+ const auth = new PegaAuth(authConfig);
86
+ if (grantType === 'authCode') {
87
+ console.log(`${chalk.green('Awaiting authorization to complete (Ctrl-C to exit). You may need to enter credentials within your default browser.')}`);
88
+ }
89
+ // console.log(`authConfig: ${JSON.stringify(authConfig)}`);
90
+
91
+ auth.login()
92
+ .then((token) => {
93
+ if (token?.token_type) {
94
+ fs.writeFile(TOKEN_PATH, JSON.stringify(token), err => {
95
+ if (err) {
96
+ console.error(err);
97
+ return reject(authSuccess);
98
+ }
99
+ console.log(`${chalk.bold.green('Authenticated successfully !!')}`);
100
+ authSuccess = true;
101
+ return resolve(authSuccess);
102
+ });
103
+ } else {
104
+ console.log(`${chalk.bold.red('Authentication failed:' + JSON.stringify(token.errors ? token.errors : token))}`);
105
+ return reject(authSuccess);
106
+ }
107
+ })
108
+ .catch((e) => {
109
+ console.log(`${chalk.bold.red('Authentication failed:' + e)}`);
76
110
  return reject(authSuccess);
77
- }
78
- })
79
- .catch((e) => {
80
- console.log(`${chalk.bold.red(e)}`);
81
- return reject(authSuccess);
82
- });
111
+ });
112
+
113
+ } catch (e) {
114
+ console.log(`Authentication failed: Problem initializing OAuth library`);
115
+ return reject(authSuccess);
116
+ }
117
+
83
118
  });
84
119
  };
85
120
 
@@ -110,13 +145,17 @@ export default async options => {
110
145
  // console.log(`questions: ${JSON.stringify(questions)}`);
111
146
  const answers = await inquirer.prompt(questions);
112
147
  const aProps = ['serverType', 'server', 'isolationId', 'clientId', 'grantType', 'clientSecret', 'user', 'password'];
148
+ serverConfig.authService = serverConfig.authService || 'pega';
113
149
  const isLaunchPad = answers.serverType === "launchpad";
114
150
  let bWriteUpdate = false;
115
151
  for (let i = 0; i < aProps.length; i += 1) {
116
152
  const prop = aProps[i];
117
- if (serverConfig[prop] !== answers[prop]) {
118
- // console.log(`property ${prop} changed from ${serverConfig[prop]} to ${answers[prop]}`);
119
- serverConfig[prop] = answers[prop];
153
+ const configValue = serverConfig[prop];
154
+ const answerValue = answers[prop];
155
+ // Treat an empty serverConfig property value as same as an undefined answer response
156
+ if (configValue !== answerValue && !(configValue === '' && answerValue === undefined)) {
157
+ // console.log(`property ${prop} changed from ${configValue} to ${answerValue}`);
158
+ serverConfig[prop] = answerValue;
120
159
  if (prop !== 'password' || isPwdNonEmpty) {
121
160
  bWriteUpdate = true;
122
161
  }
@@ -127,6 +166,7 @@ export default async options => {
127
166
  // console.log(`serverConfig: ${JSON.stringify(serverConfig)}`);
128
167
  authOK = await generateAccessToken(serverConfig);
129
168
  } catch (e) {
169
+ console.log(`${chalk.bold.red('Authentication failed:' + JSON.stringify(e))}`);
130
170
  }
131
171
 
132
172
  if (authOK & bWriteUpdate) {
@@ -138,6 +178,7 @@ export default async options => {
138
178
  let updCfg = null;
139
179
  try {
140
180
  updCfg = JSON.stringify(data, null, 2);
181
+ // console.log(`updated config: ${updCfg}`);
141
182
  fs.writeFileSync(pegaConfigJsonPath, updCfg, err => {
142
183
  if (err) throw err;
143
184
  });
@@ -103,7 +103,7 @@ export const publishComponentToServer = async data => {
103
103
  const respData = JSON.parse(resp);
104
104
  if (status === 401) {
105
105
  throw new Error(
106
- 'Error occured in authentication. Please regenerate using authenticate'
106
+ 'Error occurred in authentication. Please regenerate using authenticate'
107
107
  );
108
108
  // console.log(accessTokenUri, refreshToken);
109
109
  /* TODO - Handle refresh_token */
@@ -115,9 +115,9 @@ export const publishComponentToServer = async data => {
115
115
  })
116
116
  .catch(e => Promise.reject(`${chalk.bold.red(e)}`));
117
117
  } else {
118
- throw new Error(`Error occured in authentication. Please regenerate using authenticate`);
118
+ throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
119
119
  }
120
120
  } catch (err) {
121
- throw new Error(`Error occured in authentication. Please regenerate using authenticate`);
121
+ throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
122
122
  }
123
123
  };
@@ -0,0 +1,69 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+
4
+ import AdmZip from 'adm-zip';
5
+ import chalk from 'chalk';
6
+
7
+ import {
8
+ getComponentDirectoryPath,
9
+ getComponents,
10
+ getPegaServerConfig
11
+ } from '../../util.js';
12
+ import { COMPONENT_SCHEMA } from '../../constants.js';
13
+
14
+ export const cleanUp = async () => {
15
+ fs.rm('dist/components', { recursive: true }, err => {
16
+ if (err) {
17
+ throw err;
18
+ }
19
+ });
20
+
21
+ fs.rm('lib', { recursive: true }, err => {
22
+ if (err) {
23
+ throw err;
24
+ }
25
+ });
26
+ }
27
+
28
+
29
+
30
+ export const getBuildComponentQuestions = async () => {
31
+ const components = await getComponents();
32
+ const defaultPegaConfig = await getPegaServerConfig();
33
+
34
+ if (components.length == 0) {
35
+ console.log(chalk.bold.yellow(`No components to build`));
36
+ process.exit(1);
37
+ }
38
+
39
+ return [
40
+ {
41
+ name: 'devBuild',
42
+ message: 'Generate development build ?',
43
+ default: defaultPegaConfig.devBuild
44
+ }
45
+ ];
46
+ };
47
+
48
+
49
+
50
+ export const zipComponent = async (componentKey) => {
51
+ const srcDirectory = await getComponentDirectoryPath(componentKey);
52
+ const buildDirectory = await path.join(path.resolve(), 'dist/components', componentKey);
53
+ const configJson = `${srcDirectory}/config.json`;
54
+
55
+ const zip = new AdmZip();
56
+
57
+ zip.addLocalFolder(srcDirectory, 'src/');
58
+ zip.addLocalFile(configJson);
59
+ zip.addLocalFolder(buildDirectory);
60
+ const zipContent = zip.toBuffer().toString('base64');
61
+
62
+ const configContent = Buffer.from(fs.readFileSync(`${srcDirectory}/config.json`)).toString();
63
+ // fs.rmd('dist/components', { recursive: true }, err => {
64
+ // if (err) {
65
+ // throw err;
66
+ // }
67
+ // });
68
+ return { zipContent, configContent };
69
+ };
@@ -0,0 +1,79 @@
1
+ import inquirer from 'inquirer';
2
+ import Listr from 'listr';
3
+ import chalk from 'chalk';
4
+
5
+ import validate from '../validator/index.js';
6
+
7
+ import bundleComponent from '../bundle/index.js';
8
+ import lintComponent from '../linter/index.js';
9
+ import { getBuildComponentQuestions, cleanUp } from './helper.js';
10
+ import { getComponentDirectoryPath, showVersion, getComponentsObj } from '../../util.js';
11
+
12
+ import { CATEGORY_CONSTELLATION } from '../../constants.js';
13
+
14
+
15
+ export function getCustomTasks(componentKey, sourceMap, devBuild) {
16
+
17
+ const customTasks = new Listr(
18
+ [
19
+ {
20
+ title: 'Validate config schema',
21
+ task: async () => {
22
+ await validate(componentKey);
23
+ }
24
+ },
25
+ {
26
+ title: 'Lint component',
27
+ task: async () => {
28
+ const targetDirectory = await getComponentDirectoryPath(componentKey);
29
+ // console.log(`in buildComponent Lint component task: componentKey: ${componentKey} targetDirectory: ${targetDirectory}`);
30
+ await lintComponent(targetDirectory);
31
+ }
32
+ },
33
+ {
34
+ title: 'Bundle component',
35
+ task: async () => await bundleComponent(componentKey, sourceMap, devBuild),
36
+ }
37
+ ],
38
+ {
39
+ exitOnError: true
40
+ }
41
+ );
42
+
43
+ return customTasks;
44
+ }
45
+
46
+
47
+
48
+
49
+ export default async options => {
50
+ showVersion();
51
+
52
+ let category = CATEGORY_CONSTELLATION;
53
+
54
+ const components = await getComponentsObj();
55
+ const questions = await getBuildComponentQuestions();
56
+ const answers = await inquirer.prompt(questions);
57
+ const { sourceMap, devBuild } = answers;
58
+
59
+
60
+
61
+ var componentKey;
62
+
63
+
64
+ for (var index in components) {
65
+ componentKey = components[index].value;
66
+ console.log(chalk.bold.green("Building: " + components[index].name));
67
+
68
+ let myCustomTasks = getCustomTasks(componentKey, sourceMap, devBuild );
69
+
70
+ await myCustomTasks.run().catch(err => {
71
+ console.log(chalk.bold.red(err.toString()));
72
+ });
73
+ }
74
+
75
+
76
+ cleanUp();
77
+
78
+ return true;
79
+ };
@@ -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
  });
@@ -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
  });
@@ -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
  });
@@ -37,6 +37,20 @@
37
37
  "name": "required",
38
38
  "label": "Required",
39
39
  "format": "REQUIRED"
40
+ },
41
+ {
42
+ "label": "Advanced",
43
+ "format": "GROUP",
44
+ "collapsible": true,
45
+ "properties": [
46
+ {
47
+ "name": "testId",
48
+ "label": "Test ID",
49
+ "format": "TEXT",
50
+ "ignorePattern": "[^-_\\p{N}\\p{L}]",
51
+ "includeAnnotations": false
52
+ }
53
+ ]
40
54
  }
41
55
  ],
42
56
  "defaultConfig": {
@@ -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
  });
@@ -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
  });
@@ -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
  });