@pega/custom-dx-components 2.0.23 → 2.0.25

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 (122) hide show
  1. package/README.md +1 -1
  2. package/package.json +3 -6
  3. package/src/cli.js +0 -18
  4. package/src/constants.js +2 -32
  5. package/src/tasks/authenticate/helper.js +5 -63
  6. package/src/tasks/authenticate/index.js +50 -107
  7. package/src/tasks/create/index.js +63 -59
  8. package/src/tasks/create/templates/Constellation/Field/Boolean/boolean-format.js.mustache +1 -1
  9. package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +16 -33
  10. package/src/tasks/create/templates/Constellation/Field/Boolean/index.jsx.mustache +2 -1
  11. package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +67 -179
  12. package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +17 -46
  13. package/src/tasks/create/templates/Constellation/Field/Date/index.jsx.mustache +1 -3
  14. package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +1 -0
  15. package/src/tasks/create/templates/Constellation/Field/DateTime/{date-utils.js.mustache → date-utils.js} +0 -1
  16. package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +0 -1
  17. package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +17 -46
  18. package/src/tasks/create/templates/Constellation/Field/DateTime/index.jsx.mustache +0 -2
  19. package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +17 -22
  20. package/src/tasks/create/templates/Constellation/Field/Decimal/index.jsx.mustache +1 -2
  21. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +17 -26
  22. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.jsx.mustache +4 -3
  23. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +17 -22
  24. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.jsx.mustache +2 -8
  25. package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +17 -22
  26. package/src/tasks/create/templates/Constellation/Field/Integer/index.jsx.mustache +1 -2
  27. package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +16 -50
  28. package/src/tasks/create/templates/Constellation/Field/Picklist/index.jsx.mustache +1 -44
  29. package/src/tasks/create/templates/Constellation/Field/Picklist/picklist.js.mustache +43 -0
  30. package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +16 -23
  31. package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +17 -21
  32. package/src/tasks/create/templates/Constellation/Field/Text-Email/index.jsx.mustache +2 -44
  33. package/src/tasks/create/templates/Constellation/Field/Text-Email/text-email.js.mustache +43 -0
  34. package/src/tasks/create/templates/Constellation/Field/Text-Input/{StatusWork.jsx → StatusWork.js} +1 -0
  35. package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +17 -21
  36. package/src/tasks/create/templates/Constellation/Field/Text-Input/index.jsx.mustache +3 -46
  37. package/src/tasks/create/templates/Constellation/Field/Text-Input/text-input.js.mustache +43 -0
  38. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +17 -21
  39. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.jsx.mustache +2 -44
  40. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/text-paragraph.js.mustache +43 -0
  41. package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +17 -19
  42. package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +3 -47
  43. package/src/tasks/create/templates/Constellation/Field/Text-Phone/text-phone.js.mustache +43 -0
  44. package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +17 -19
  45. package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +1 -1
  46. package/src/tasks/create/templates/Constellation/Field/Text-URL/{text-url.jsx.mustache → text-url.js.mustache} +1 -2
  47. package/src/tasks/create/templates/Constellation/Field/TimeofDay/demo.stories.jsx.mustache +17 -30
  48. package/src/tasks/create/templates/Constellation/Field/TimeofDay/time-of-day.js.mustache +0 -1
  49. package/src/tasks/create/templates/Constellation/Template/DETAILS/index.jsx.mustache +29 -14
  50. package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +77 -3
  51. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +29 -14
  52. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +74 -3
  53. package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +10 -6
  54. package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +8 -10
  55. package/src/tasks/create/templates/Constellation/Template/PAGE/{GetNextWork.jsx.mustache → GetNextWork.js.mustache} +0 -6
  56. package/src/tasks/create/templates/Constellation/Template/PAGE/index.jsx.mustache +7 -9
  57. package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +1 -4
  58. package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +0 -1
  59. package/src/tasks/create/templates/Constellation/Widget/PAGE/index.jsx.mustache +8 -8
  60. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Avatar.jsx.mustache → Avatar.js.mustache} +0 -2
  61. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Operator.jsx.mustache → Operator.js.mustache} +1 -2
  62. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +9 -9
  63. package/src/tasks/delete/helper.js +0 -4
  64. package/src/tasks/delete/index.js +0 -4
  65. package/src/tasks/index.js +0 -3
  66. package/src/tasks/init/index.js +3 -3
  67. package/src/tasks/init/template/.eslintrc.json +5 -186
  68. package/src/tasks/init/template/README.md +59 -75
  69. package/src/tasks/init/template/package.json.mustache +6 -21
  70. package/src/tasks/init/template/tasks.config.json +2 -5
  71. package/src/tasks/list/index.js +0 -4
  72. package/src/tasks/{bundle → publish/bundle}/builder/webpack.config.js +2 -0
  73. package/src/tasks/{bundle → publish/bundle}/index.js +2 -2
  74. package/src/tasks/publish/index.js +1 -14
  75. package/src/util.js +6 -11
  76. package/src/auth.js +0 -563
  77. package/src/tasks/build/helper.js +0 -123
  78. package/src/tasks/build/index.js +0 -54
  79. package/src/tasks/create/templates/Constellation/Field/Boolean/mock.stories.js.mustache +0 -21
  80. package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +0 -61
  81. package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +0 -41
  82. package/src/tasks/create/templates/Constellation/Field/Date/mock.stories.js.mustache +0 -23
  83. package/src/tasks/create/templates/Constellation/Field/DateTime/mock.stories.js.mustache +0 -23
  84. package/src/tasks/create/templates/Constellation/Field/Decimal/mock.stories.js.mustache +0 -21
  85. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/mock.stories.js.mustache +0 -23
  86. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/mock.stories.js.mustache +0 -21
  87. package/src/tasks/create/templates/Constellation/Field/Integer/mock.stories.js.mustache +0 -21
  88. package/src/tasks/create/templates/Constellation/Field/Picklist/mock.stories.js.mustache +0 -67
  89. package/src/tasks/create/templates/Constellation/Field/Text/mock.stories.js.mustache +0 -13
  90. package/src/tasks/create/templates/Constellation/Field/Text-Email/mock.stories.js.mustache +0 -22
  91. package/src/tasks/create/templates/Constellation/Field/Text-Input/mock.stories.js.mustache +0 -21
  92. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/mock.stories.js.mustache +0 -20
  93. package/src/tasks/create/templates/Constellation/Field/Text-Phone/mock.stories.js.mustache +0 -37
  94. package/src/tasks/create/templates/Constellation/Field/Text-URL/mock.stories.js.mustache +0 -22
  95. package/src/tasks/create/templates/Constellation/Field/TimeofDay/mock.stories.js.mustache +0 -20
  96. package/src/tasks/create/templates/Constellation/Template/DETAILS/StatusWork.jsx.mustache +0 -26
  97. package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.jsx.mustache +0 -118
  98. package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.stories.js.mustache +0 -179
  99. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/StatusWork.jsx.mustache +0 -26
  100. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +0 -123
  101. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.stories.js.mustache +0 -215
  102. package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +0 -93
  103. package/src/tasks/create/templates/Constellation/Template/FORM/mock.stories.js.mustache +0 -125
  104. package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +0 -100
  105. package/src/tasks/create/templates/Constellation/Template/FORM-region/mock.stories.js.mustache +0 -131
  106. package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.jsx.mustache +0 -101
  107. package/src/tasks/create/templates/Constellation/Template/PAGE/mock.stories.js.mustache +0 -94
  108. package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.jsx.mustache +0 -78
  109. package/src/tasks/create/templates/Constellation/Widget/CASE/mock.stories.js.mustache +0 -390
  110. package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.jsx.mustache +0 -30
  111. package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +0 -23
  112. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.jsx.mustache +0 -68
  113. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/mock.stories.js.mustache +0 -51
  114. package/src/tasks/delete-all/helper.js +0 -175
  115. package/src/tasks/delete-all/index.js +0 -49
  116. package/src/tasks/init/template/.eslintignore +0 -8
  117. package/src/tasks/linter/index.js +0 -46
  118. package/src/tasks/publish-all/helper.js +0 -139
  119. package/src/tasks/publish-all/index.js +0 -84
  120. /package/src/tasks/{bundle → publish/bundle}/builder/index.js +0 -0
  121. /package/src/tasks/{bundle → publish/bundle}/builder/modules.js +0 -0
  122. /package/src/tasks/{bundle → publish/bundle}/builder/paths.js +0 -0
package/README.md CHANGED
@@ -8,7 +8,7 @@ This project provides you with an environment to extend Constellation by giving
8
8
 
9
9
  Ensure you have access to the following in your system:
10
10
 
11
- - Pega Infinity Server version 8.7 or later
11
+ - Pega Infinity Server version 8.8 or later
12
12
 
13
13
  - Git version 2.30 or later
14
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/custom-dx-components",
3
- "version": "2.0.23",
3
+ "version": "2.0.25",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
@@ -23,22 +23,18 @@
23
23
  "babel-loader": "^8.2.5",
24
24
  "chalk": "^5.0.1",
25
25
  "compression-webpack-plugin": "^10.0.0",
26
- "crypto": "^1.0.1",
27
26
  "css-loader": "6.7.1",
28
27
  "css-minimizer-webpack-plugin": "^4.1.0",
29
- "eslint": "^8.4.1",
30
28
  "execa": "^6.1.0",
31
29
  "file-loader": "6.2.0",
32
30
  "fs-extra": "^10.1.0",
33
31
  "gitignore": "^0.7.0",
34
- "http": "^0.0.1-security",
35
32
  "inquirer": "^9.1.1",
36
33
  "listr": "^0.14.3",
37
34
  "mini-css-extract-plugin": "2.6.1",
38
35
  "mustache": "^4.2.0",
39
36
  "ncp": "^2.0.0",
40
37
  "node-fetch": "^3.2.10",
41
- "open": "^8.4.2",
42
38
  "ora": "^6.1.2",
43
39
  "pascalcase": "^2.0.0",
44
40
  "postcss": "^8.4.16",
@@ -54,7 +50,7 @@
54
50
  "ts-loader": "^9.3.1",
55
51
  "typescript": "^4.8.3",
56
52
  "url-loader": "4.1.1",
57
- "webpack": "5.76.1"
53
+ "webpack": "^5.81.0"
58
54
  },
59
55
  "author": "Custom component dev",
60
56
  "license": "SEE LICENSE IN LICENSE",
@@ -65,6 +61,7 @@
65
61
  "devDependencies": {
66
62
  "@pega/configs": "^0.3.3",
67
63
  "cspell": "^6.9.0",
64
+ "eslint": "^8.23.1",
68
65
  "prettier": "2.7.1"
69
66
  }
70
67
  }
package/src/cli.js CHANGED
@@ -3,14 +3,11 @@ import chalk from 'chalk';
3
3
 
4
4
  import {
5
5
  authenticate,
6
- buildComponent,
7
6
  createComponent,
8
7
  deleteComponent,
9
- deleteAllComponents,
10
8
  initProject,
11
9
  listComponents,
12
10
  publishComponent,
13
- publishAllComponents,
14
11
  updateComponent,
15
12
  validate,
16
13
  upgrade
@@ -19,14 +16,11 @@ import {
19
16
  const TASKS = {
20
17
  INIT: 'init',
21
18
  CREATE: 'create',
22
- BUILD: 'buildComponent',
23
19
  PUBLISH: 'publish',
24
- PUBLISH_All: 'publishAll',
25
20
  LIST: 'list',
26
21
  VALIDATE_SCHEMA: 'validateSchema',
27
22
  UPDATE: 'update',
28
23
  DELETE: 'delete',
29
- DELETE_ALL: "deleteAll",
30
24
  AUTHENTICATE: 'authenticate',
31
25
  UPGRADE: 'upgrade'
32
26
  };
@@ -66,14 +60,6 @@ export default async (args = []) => {
66
60
  publishComponent(options);
67
61
  break;
68
62
  }
69
- case TASKS.PUBLISH_All: {
70
- publishAllComponents(options);
71
- break;
72
- }
73
- case TASKS.BUILD: {
74
- buildComponent(options);
75
- break;
76
- }
77
63
  case TASKS.LIST: {
78
64
  listComponents(options);
79
65
  break;
@@ -90,10 +76,6 @@ export default async (args = []) => {
90
76
  deleteComponent(options);
91
77
  break;
92
78
  }
93
- case TASKS.DELETE_ALL: {
94
- deleteAllComponents(options);
95
- break;
96
- }
97
79
  case TASKS.AUTHENTICATE: {
98
80
  authenticate(options);
99
81
  break;
package/src/constants.js CHANGED
@@ -10,37 +10,7 @@ export const PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/pub
10
10
  export const LIST_COMPONENT_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/list_component';
11
11
  export const OOTB_COMPONENT_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/ootb_component';
12
12
  export const DELETE_COMPONENT_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/delete_component';
13
- export const INF_TOKEN_URL_V1 = 'PRRestService/oauth2/v1/token';
14
- export const INF_AUTHORIZE_URL_V1 = 'PRRestService/oauth2/v1/authorize';
15
- export const LP_TOKEN_URL = 'uas/oauth/token';
16
- export const LP_AUTHORIZE_URL = 'uas/oauth/authorize';
17
-
18
- export const AUTHENTICATE_SCHEMA = {
19
- serverType: [
20
- {
21
- name: 'Infinity',
22
- value: 'infinity'
23
- },
24
- {
25
- name: 'Launchpad',
26
- value: 'launchpad'
27
- }
28
- ],
29
- grantType: [
30
- {
31
- name: 'Authorization code',
32
- value: 'authCode'
33
- },
34
- {
35
- name: 'Password credentials',
36
- value: 'passwordCreds'
37
- },
38
- {
39
- name: 'Client credentials',
40
- value: 'clientCreds'
41
- }
42
- ]
43
- };
13
+ export const TOKEN_URL_V1 = 'PRRestService/oauth2/v1/token';
44
14
 
45
15
  export const COMPONENT_SCHEMA = {
46
16
  framework: [
@@ -138,7 +108,7 @@ export const COMPONENT_SCHEMA = {
138
108
  value: 'Picklist'
139
109
  }
140
110
  ],
141
- template: ['DETAILS', 'DETAILS-region', 'FORM', 'FORM-region', 'PAGE'],
111
+ template: ['DETAILS', 'DETAILS-region', 'FORM', 'FORM-region', 'PAGE' ],
142
112
  widget: [
143
113
  {
144
114
  name: 'CASE',
@@ -1,76 +1,24 @@
1
1
  /* eslint-disable import/prefer-default-export */
2
2
  import { getPegaServerConfig } from '../../util.js';
3
3
 
4
- import { AUTHENTICATE_SCHEMA } from '../../constants.js';
5
-
6
4
  export const getAuthQuestions = async () => {
7
5
  const defaultPegaConfig = await getPegaServerConfig();
8
6
 
9
7
  return [
10
- {
11
- name: 'serverType',
12
- type: 'rawlist',
13
- message: 'Enter Pega server type',
14
- default: answers => {
15
- return defaultPegaConfig.serverType;
16
- },
17
- choices: AUTHENTICATE_SCHEMA.serverType,
18
- validate: value => {
19
- if (value.trim()) {
20
- return true;
21
- }
22
- return 'Pega server type cannot be empty';
23
- },
24
- when: answers => {
25
- if (!defaultPegaConfig.serverType) {
26
- answers.serverType = "infinity";
27
- }
28
- else if (!defaultPegaConfig.askServerType) {
29
- answers.serverType = defaultPegaConfig.serverType;
30
- }
31
- return (defaultPegaConfig.askServerType ? true : false);
32
- }
33
- },
34
8
  {
35
9
  name: 'server',
36
10
  message: 'Enter pega server url',
37
11
  default: defaultPegaConfig.server
38
12
  },
39
- {
40
- name: 'isolationId',
41
- message: 'Enter isolation id',
42
- default: defaultPegaConfig.isolationId,
43
- when: answers => {
44
- return answers.serverType === "launchpad";
45
- }
46
- },
47
- {
48
- name: 'grantType',
49
- type: 'rawlist',
50
- message: 'Enter OAuth 2.0 grant type',
51
- default: defaultPegaConfig.grantType,
52
- choices: answers => {
53
- return AUTHENTICATE_SCHEMA.grantType.filter(gt => !(answers.serverType === "launchpad" && gt.value === "passwordCreds"));
54
- },
55
- validate: value => {
56
- if (value.trim()) {
57
- return true;
58
- }
59
- return 'Grant type cannot be empty';
60
- }
61
- },
62
13
  {
63
14
  name: 'user',
64
15
  message: 'Enter user id',
65
16
  default: defaultPegaConfig.user,
66
- validate: (value, answers) => {
67
- if (value.trim() || answers.grantType === "authCode") {
17
+ validate: value => {
18
+ if (value.trim()) {
68
19
  return true;
69
20
  }
70
21
  return 'Username cannot be empty';
71
- },
72
- when: answers => {
73
- return (answers.serverType === "infinity" && answers.grantType !== "clientCreds");
74
22
  }
75
23
  },
76
24
  {
@@ -78,14 +26,11 @@ export const getAuthQuestions = async () => {
78
26
  type: 'password',
79
27
  message: 'Enter password',
80
28
  default: defaultPegaConfig.password,
81
- validate: (value, answers) => {
82
- if (value.trim() || answers.grantType === "authCode") {
29
+ validate: value => {
30
+ if (value.trim()) {
83
31
  return true;
84
32
  }
85
33
  return 'Password cannot be empty';
86
- },
87
- when: answers => {
88
- return (answers.user && (answers.serverType === "infinity" && answers.grantType !== "clientCreds"));
89
34
  }
90
35
  },
91
36
  {
@@ -104,14 +49,11 @@ export const getAuthQuestions = async () => {
104
49
  type: 'password',
105
50
  message: 'Enter clientSecret',
106
51
  default: defaultPegaConfig.clientSecret,
107
- validate: (value, answers) => {
52
+ validate: value => {
108
53
  if (value.trim()) {
109
54
  return true;
110
55
  }
111
56
  return 'clientSecret cannot be empty';
112
- },
113
- when: answers => {
114
- return (answers.grantType !== "authCode");
115
57
  }
116
58
  }
117
59
  ];
@@ -1,138 +1,81 @@
1
1
  import path from 'path';
2
2
  import fs from 'fs';
3
+ import https from 'https';
3
4
 
4
5
  import chalk from 'chalk';
5
6
  import inquirer from 'inquirer';
7
+ import fetch from 'node-fetch';
6
8
 
7
- import { checkPathAccess, showVersion } from '../../util.js';
8
- import { TOKEN_PATH, INF_TOKEN_URL_V1, INF_AUTHORIZE_URL_V1, LP_TOKEN_URL, LP_AUTHORIZE_URL } from '../../constants.js';
9
+ import { checkPathAccess, getTokenUrl } from '../../util.js';
10
+ import { TOKEN_PATH } from '../../constants.js';
9
11
 
10
12
  import { getAuthQuestions } from './helper.js';
11
- import PegaAuth from '../../auth.js';
12
13
 
13
14
  export const TASKS_CONFIG_JSON_FILENAME = 'tasks.config.json';
14
15
 
15
16
  const pegaConfigJsonPath = path.join(path.resolve(), TASKS_CONFIG_JSON_FILENAME);
16
- let server = null;
17
17
 
18
18
  const generateAccessToken = async config => {
19
-
20
- let authSuccess = false;
21
- const { serverType, isolationId, grantType, clientId, clientSecret, user, password } = config;
22
- const server = config.server.endsWith('/') ? config.server : `${config.server}/`;
23
-
24
- return new Promise((resolve, reject) => {
25
- const sTokenUri = `${server}${serverType === 'infinity' ? INF_TOKEN_URL_V1 : LP_TOKEN_URL}`;
26
- const sAuthorizeUri = `${server}${serverType === 'infinity' ? INF_AUTHORIZE_URL_V1 : LP_AUTHORIZE_URL}`;
27
- // console.log(`grantType: ${config.grantType}`);
28
-
29
- // Build auth config structure
30
- const authConfig = {
31
- serverType: serverType,
32
- grantType: grantType,
33
- authorizeUri: sAuthorizeUri,
34
- tokenUri: sTokenUri,
35
- clientId: clientId,
36
- clientSecret: clientSecret,
37
- winTitle: 'DXCB',
38
- winBodyHtml: `Authentication is complete. This browser window may be closed.`
39
- };
40
- if (serverType === 'infinity') {
41
- authConfig.authService = 'pega';
42
- if (grantType !== 'clientCreds' && user && password) {
43
- authConfig.userIdentifier = user;
44
- authConfig.password = Buffer.from(password).toString('base64');
19
+ const formData = new URLSearchParams();
20
+ formData.append('client_id', config.clientId);
21
+ formData.append('client_secret', config.clientSecret);
22
+ formData.append('username', config.user);
23
+ formData.append('password', config.password);
24
+ formData.append('grant_type', 'password');
25
+
26
+ const accessTokenUri = await getTokenUrl(config.server);
27
+ fetch(accessTokenUri, {
28
+ agent: new https.Agent({ rejectUnauthorized: false }),
29
+ method: 'POST',
30
+ headers: { 'content-type': 'application/x-www-form-urlencoded' },
31
+ body: formData.toString()
32
+ })
33
+ .then(response => {
34
+ if (response.ok && response.status === 200) {
35
+ return response.json();
36
+ } else {
37
+ throw new Error(`Failed with status: ${response.status}`);
45
38
  }
46
- }
47
- if (serverType === 'launchpad') {
48
- authConfig.isolationId = isolationId;
49
- // authConfig.noPKCE = true;
50
- }
51
- if (grantType === 'authCode') {
52
- authConfig.redirectUri = 'http://localhost:4010/';
53
- }
54
- const auth = new PegaAuth(authConfig);
55
- // console.log(`...about to infoke auth.login\n${JSON.stringify(authConfig)}`);
56
-
57
- auth.login()
58
- .then((token) => {
59
- if (token?.token_type) {
60
- fs.writeFile(TOKEN_PATH, JSON.stringify(token), err => {
61
- if (err) {
62
- console.error(err);
63
- return reject(authSuccess);
64
- }
65
- console.log(`${chalk.bold.green('Authenticated successfully !!')}`);
66
- authSuccess = true;
67
- return resolve(authSuccess);
68
- });
69
- } else {
70
- console.log(`${chalk.bold.red('Authentication failed:' + JSON.stringify(token.errors ? token.errors : token))}`);
71
- return reject(authSuccess);
72
- }
73
- })
74
- .catch((e) => {
75
- console.log(`${chalk.bold.red(e)}`);
76
- return reject(authSuccess);
77
- });
78
- });
39
+ })
40
+ .then(data => {
41
+ if (data && data.errors) {
42
+ const errMessages = data.errors;
43
+ errMessages.forEach(msgArr => {
44
+ throw new Error(`Failed with error - ${JSON.stringify(msgArr.message)}`);
45
+ });
46
+ }
47
+ if (data.token_type) {
48
+ fs.writeFile(TOKEN_PATH, JSON.stringify(data), err => {
49
+ if (err) {
50
+ console.error(err);
51
+ }
52
+ console.log(`${chalk.bold.green('Authenticated successfully !!')}`);
53
+ });
54
+ }
55
+ })
56
+ .catch(e => console.log(`${chalk.bold.red(e)}`));
79
57
  };
80
58
 
81
59
  export default async options => {
82
-
83
- let authOK = false;
84
-
85
- showVersion();
86
-
87
60
  await checkPathAccess(pegaConfigJsonPath);
88
61
 
89
- let cfgData = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
90
- let data = null;
91
- if (cfgData) {
92
- try {
93
- data = JSON.parse(cfgData);
94
- } catch (e) {
95
- console.log(`${chalk.red('Invalid JSON within tasks.config.json')}`);
96
- process.exit(1);
97
- }
98
- }
62
+ let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
63
+ data = data && JSON.parse(data);
99
64
 
100
65
  const serverConfig = data['server-config'];
101
66
  const params = options.params;
102
67
 
103
68
  const questions = await getAuthQuestions(params);
104
69
  const answers = await inquirer.prompt(questions);
105
- serverConfig.serverType = answers.serverType;
106
70
  serverConfig.server = answers.server;
107
- // Isolation id only needed for launchpad
108
- if (answers.serverType === 'launchpad') {
109
- serverConfig.isolationId = answers.isolationId;
110
- }
111
- serverConfig.grantType = answers.grantType;
112
- if (answers.serverType === 'infinity' && answers.user && answers.password) {
113
- serverConfig.user = answers.user;
114
- serverConfig.password = answers.password;
115
- }
71
+ serverConfig.user = answers.user;
72
+ serverConfig.password = answers.password;
116
73
  serverConfig.clientId = answers.clientId;
117
74
  serverConfig.clientSecret = answers.clientSecret;
75
+ await generateAccessToken(serverConfig);
118
76
 
119
- try {
120
- authOK = await generateAccessToken(serverConfig);
121
- } catch (e) {
122
- }
123
-
124
- if (authOK) {
125
- console.log(`${chalk.green('Writing updated config...')}`);
126
- let updCfg = null;
127
- try {
128
- updCfg = JSON.stringify(data, null, 2);
129
- fs.writeFileSync(pegaConfigJsonPath, updCfg, err => {
130
- if (err) throw err;
131
- });
132
- } catch (e) {
133
-
134
- }
135
- }
136
-
137
- process.exit(1);
77
+ data = JSON.stringify(data, null, 2);
78
+ fs.writeFile(pegaConfigJsonPath, data, err => {
79
+ if (err) throw err;
80
+ });
138
81
  };
@@ -14,8 +14,7 @@ import {
14
14
  getComponents,
15
15
  getComponentDefaults,
16
16
  sanitize,
17
- validateSemver,
18
- showVersion
17
+ validateSemver
19
18
  } from '../../util.js';
20
19
  import { COMPONENT_SCHEMA } from '../../constants.js';
21
20
 
@@ -88,7 +87,7 @@ const compileMustacheTemplates = async (
88
87
  ALLOWEDAPPS: JSON.stringify(allowedApplications),
89
88
  TYPE: type,
90
89
  SUB_TYPE: JSON.stringify(mustacheSubType),
91
- DESCRIPTION: description || componentLabel,
90
+ DESCRIPTION: description,
92
91
  IS_TEMPLATE: isTemplate,
93
92
  IS_PICKLIST: isPicklist,
94
93
  IS_BOOLEAN: isBool,
@@ -173,17 +172,15 @@ const validateCompile = async (
173
172
  };
174
173
 
175
174
  export default async options => {
176
- showVersion();
177
-
178
- if (options.params[9]) {
179
-
180
- const type = options.params[3];
181
- const subtype = options.params[4];
182
- const componentName = options.params[5];
183
- const componentLabel = options.params[6];
184
- const library = options.params[7];
185
- const version = options.params[9];
186
- const description = options.params[9];
175
+ if (options.params[10]) {
176
+ const componentName = options.params[3];
177
+ const componentLabel = options.params[4];
178
+ const library = options.params[5];
179
+ const version = options.params[6];
180
+ const framework = options.params[7];
181
+ const type = options.params[8];
182
+ const subtype = options.params[9];
183
+ const description = options.params[10];
187
184
 
188
185
  await validateCompile(
189
186
  {
@@ -201,50 +198,6 @@ export default async options => {
201
198
  } else {
202
199
  const componentDefaults = await getComponentDefaults();
203
200
  const questions = [
204
- {
205
- name: 'type',
206
- type: 'rawlist',
207
- message: 'Enter type of component',
208
- default: componentDefaults.type,
209
- choices: COMPONENT_SCHEMA.type
210
- },
211
- {
212
- name: 'subtype',
213
- type: 'rawlist',
214
- message: 'Enter subtype of component',
215
- default: componentDefaults.subtype,
216
- choices: COMPONENT_SCHEMA.subtype.field,
217
- when(answers) {
218
- return answers.type === 'Field';
219
- }
220
- },
221
- {
222
- name: 'subtype',
223
- type: 'rawlist',
224
- message: 'Enter subtype of component',
225
- default: componentDefaults.subtype,
226
- choices: COMPONENT_SCHEMA.subtype.template,
227
- when(answers) {
228
- return answers.type === 'Template';
229
- }
230
- },
231
- {
232
- name: 'subtype',
233
- type: 'rawlist',
234
- message: 'Enter subtype of component',
235
- default: [componentDefaults.subtype || COMPONENT_SCHEMA.subtype.widget[0]],
236
- choices: COMPONENT_SCHEMA.subtype.widget,
237
- when(answers) {
238
- return answers.type === 'Widget';
239
- },
240
- validate: value => {
241
- /* value should not be empty */
242
- if (Array.isArray(value) && value.length) {
243
- return true;
244
- }
245
- return 'Please select subtype';
246
- }
247
- },
248
201
  {
249
202
  name: 'componentName',
250
203
  message: 'Enter component name (required)',
@@ -273,7 +226,6 @@ export default async options => {
273
226
  {
274
227
  name: 'version',
275
228
  message: 'Enter component version',
276
- default: componentDefaults.version,
277
229
  validate: value => {
278
230
  if (validateSemver(value)) {
279
231
  return true;
@@ -302,6 +254,57 @@ export default async options => {
302
254
  message: 'Please enter the application names to be supported (comma-separated). ',
303
255
  suffix: 'Keep empty for all applications'
304
256
  },
257
+ // {
258
+ // name: 'framework',
259
+ // type: 'rawlist',
260
+ // message: 'Enter framework a',
261
+ // default: 'COSMOS_React',
262
+ // choices: COMPONENT_SCHEMA.framework
263
+ // },
264
+ {
265
+ name: 'type',
266
+ type: 'rawlist',
267
+ message: 'Enter type of component',
268
+ default: componentDefaults.type,
269
+ choices: COMPONENT_SCHEMA.type
270
+ },
271
+ {
272
+ name: 'subtype',
273
+ type: 'rawlist',
274
+ message: 'Enter subtype of component',
275
+ default: componentDefaults.subtype,
276
+ choices: COMPONENT_SCHEMA.subtype.field,
277
+ when(answers) {
278
+ return answers.type === 'Field';
279
+ }
280
+ },
281
+ {
282
+ name: 'subtype',
283
+ type: 'rawlist',
284
+ message: 'Enter subtype of component',
285
+ default: componentDefaults.subtype,
286
+ choices: COMPONENT_SCHEMA.subtype.template,
287
+ when(answers) {
288
+ return answers.type === 'Template';
289
+ }
290
+ },
291
+ {
292
+ name: 'subtype',
293
+ type: 'rawlist',
294
+ message: 'Enter subtype of component',
295
+ default: [componentDefaults.subtype || COMPONENT_SCHEMA.subtype.widget[0]],
296
+ choices: COMPONENT_SCHEMA.subtype.widget,
297
+ when(answers) {
298
+ return answers.type === 'Widget';
299
+ },
300
+ validate: value => {
301
+ /* value should not be empty */
302
+ if (Array.isArray(value) && value.length) {
303
+ return true;
304
+ }
305
+ return 'Please select subtype';
306
+ }
307
+ },
305
308
  {
306
309
  name: 'description',
307
310
  message: 'Enter description for the component',
@@ -309,6 +312,7 @@ export default async options => {
309
312
  }
310
313
  ];
311
314
 
315
+ console.log(chalk.green("DX Component Builder v2.0.16"));
312
316
  await inquirer.prompt(questions).then(async answers => {
313
317
  const {
314
318
  componentName,
@@ -7,7 +7,7 @@ export default {
7
7
 
8
8
 
9
9
 
10
- export function format(value, type) {
10
+ export function format(value, type, options) {
11
11
  let formattedValue;
12
12
 
13
13
  switch (type?.toLowerCase()) {