@pega/dx-component-builder-sdk 0.1.39 → 0.1.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/dx-component-builder-sdk",
3
- "version": "0.1.39",
3
+ "version": "0.1.41",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
package/src/cli.js CHANGED
@@ -5,6 +5,7 @@ import {
5
5
  authenticate,
6
6
  buildComponent,
7
7
  buildAllComponents,
8
+ clearMap,
8
9
  createComponent,
9
10
  createAllComponents,
10
11
  deleteComponent,
@@ -23,6 +24,7 @@ import {
23
24
  } from './tasks/index.js';
24
25
 
25
26
  const TASKS = {
27
+ CLEAR_MAP: 'clearMap',
26
28
  CREATE: 'create',
27
29
  CREATE_ALL: 'createAll',
28
30
  OVERRIDE: 'override',
@@ -66,6 +68,10 @@ export default async (args = []) => {
66
68
  const options = parseArgumentsIntoOptions(args);
67
69
  const { task } = options;
68
70
  switch (task) {
71
+ case TASKS.CLEAR_MAP: {
72
+ clearMap(options);
73
+ break;
74
+ }
69
75
  case TASKS.CREATE: {
70
76
  createComponent(options);
71
77
  break;
package/src/constants.js CHANGED
@@ -22,7 +22,9 @@ export const COMPONENT_PREFIX_INFRA_PATH = "infra/";
22
22
  export const CUSTOM_TEMPLATES = "componentTemplates";
23
23
  export const CUSTOM_TEMPLATE_PATH = 'customTemplatesPath';
24
24
  export const OVERRIDE_TEMPLATE_PATH = 'overrideTemplatesPath';
25
- export const OVERRIDE_LIB_PATH = 'node_modules/@pega/react-sdk-overrides/lib';
25
+
26
+ export const COMPONENT_REACT_LIB_PATH = 'node_modules/@pega/react-sdk-components/lib';
27
+ export const OVERRIDE_REACT_LIB_PATH = 'node_modules/@pega/react-sdk-overrides/lib';
26
28
 
27
29
  export const COMPONENT_DIRECTORY_PREFIX_CUSTOM = "/custom-";
28
30
  export const COMPONENT_DIRECTORY_SUFFIX_SDK = "-sdk";
@@ -360,6 +362,10 @@ export const COMPONENT_SCHEMA = {
360
362
  {
361
363
  name: 'Pulse',
362
364
  value: 'Pulse'
365
+ },
366
+ {
367
+ name: 'Wss Quick Create',
368
+ value: 'WssQuickCreate'
363
369
  }
364
370
  ],
365
371
  infra: [
@@ -591,6 +597,10 @@ export const COMPONENT_SCHEMA = {
591
597
  name: 'Followers',
592
598
  value: 'Followers'
593
599
  },
600
+ {
601
+ name: 'Quick Create',
602
+ value: 'QuickCreate'
603
+ },
594
604
  {
595
605
  name: 'Summary Item',
596
606
  value: 'SummaryItem'
@@ -0,0 +1,18 @@
1
+
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import { join } from 'path';
5
+ import chalk from 'chalk';
6
+
7
+ import { clearComponentMap } from '../map/map.js';
8
+ import { showVersion } from '../../util.js';
9
+
10
+
11
+ export default async options => {
12
+ showVersion();
13
+
14
+ await clearComponentMap();
15
+
16
+ console.log(chalk.bold.green("Clear component map"));
17
+
18
+ };
@@ -8,7 +8,7 @@ import inquirer from 'inquirer';
8
8
  import ncp from 'ncp';
9
9
  import chalk from 'chalk';
10
10
 
11
- import { checkPathAccess, showVersion } from '../../util.js';
11
+ import { checkPathAccess, showVersion, getFramework } from '../../util.js';
12
12
  import { CATEGORY_CONSTELLATION,
13
13
  SDK_CONFIG_JSON_FILENAME,
14
14
  DXCB_CONFIG,
@@ -166,10 +166,7 @@ export const validateCompile = async (
166
166
 
167
167
  await checkPathAccess(pegaConfigInternalJsonPath);
168
168
 
169
- let internalData = fs.readFileSync(pegaConfigInternalJsonPath, { encoding: 'utf8' });
170
- internalData = internalData && JSON.parse(internalData);
171
-
172
- framework = internalData.sdkType;
169
+ framework = await getFramework();
173
170
 
174
171
  let pegaConfig = await getPegaConfig();
175
172
  let templateParentDir = `./templates/${framework}`;
@@ -8,7 +8,7 @@ import inquirer from 'inquirer';
8
8
  import ncp from 'ncp';
9
9
  import chalk from 'chalk';
10
10
 
11
- import { checkPathAccess, showVersion } from '../../util.js';
11
+ import { checkPathAccess, showVersion, getFramework } from '../../util.js';
12
12
  import { CATEGORY_CONSTELLATION,
13
13
  SDK_CONFIG_JSON_FILENAME,
14
14
  DXCB_CONFIG,
@@ -269,10 +269,7 @@ export const validateCompile = async (
269
269
 
270
270
  await checkPathAccess(pegaConfigInternalJsonPath);
271
271
 
272
- let internalData = fs.readFileSync(pegaConfigInternalJsonPath, { encoding: 'utf8' });
273
- internalData = internalData && JSON.parse(internalData);
274
-
275
- framework = internalData.sdkType;
272
+ framework = await getFramework();
276
273
 
277
274
  let pegaConfig = await getPegaConfig();
278
275
  let templateParentDir = `./templates/${framework}`;
@@ -1,3 +1,4 @@
1
+ export { default as clearMap } from './clear-map/index.js';
1
2
  export { default as createComponent } from './create/index.js';
2
3
  export { default as createAllComponents } from './create-all/index.js';
3
4
  export { default as overrideComponent } from './override/index.js';
@@ -5,7 +5,8 @@ import { join } from 'path';
5
5
 
6
6
  import {
7
7
  convertIntoPascalCase,
8
- removeComponentPrefix
8
+ removeComponentPrefix,
9
+ getFramework
9
10
  } from '../../util.js';
10
11
 
11
12
  import {
@@ -15,110 +16,177 @@ import {
15
16
  CATEGORY_CONSTELLATION,
16
17
  COMPONENT_DIRECTORY_PREFIX_CUSTOM,
17
18
  COMPONENT_DIRECTORY_SUFFIX_SDK,
18
- DXCB_CONFIG
19
+ COMPONENT_REACT_LIB_PATH
19
20
  } from '../../constants.js';
20
21
 
21
22
  export const SDK_LOCAL_COMPONENT_MAP_FILENAME = "sdk-local-component-map.js";
22
23
  export const IMPORT_END_TAG = "/*import end";
23
24
  export const MAP_END_TAG = "/*map end";
24
25
 
25
- export const updateComponentMap = async (componentKey, category = CATEGORY_CUSTOM) => {
26
-
27
- const pegaConfigJsonPath = path.join(path.resolve(), SDK_CONFIG_JSON_FILENAME);
28
- const pegaLocalComponentMapPath = path.join(path.resolve(), SDK_LOCAL_COMPONENT_MAP_FILENAME);
29
- const categoryDirectory = (category === CATEGORY_CONSTELLATION) ? join("/", COMPONENT_DIRECTORY_PREFIX_CUSTOM + category.toLowerCase()) : join("/", category.toLowerCase() + COMPONENT_DIRECTORY_SUFFIX_SDK);
30
-
31
- const componentNameNoPrefix = removeComponentPrefix(componentKey);
32
- const componentName = convertIntoPascalCase(componentNameNoPrefix);
33
-
34
- let mapData = fs.readFileSync(pegaLocalComponentMapPath, { encoding: 'utf8' });
35
-
36
- let importComponent = join(COMPONENTS_DIRECTORY_PATH, categoryDirectory, componentKey);
37
- importComponent = "./".concat(importComponent);
38
-
39
- let importFull = "import ".concat(componentName).concat(" from '").concat(importComponent).concat("/';");
40
- let mapFull = "\"".concat(componentNameNoPrefix).concat("\" : " ).concat(componentName).concat(",");
41
-
42
- if (mapData.indexOf(importComponent.concat("/")) < 0) {
43
- // not present so we can add
26
+ export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
27
+ const pegaConfigInternalJsonPath = path.join(path.resolve(), DXCB_CONFIG_INTERNAL_JSON_FILENAME);
28
+ const pegaLocalComponentMapPath = path.join(path.resolve(), SDK_LOCAL_COMPONENT_MAP_FILENAME);
44
29
 
45
- // add import
46
- let endImportIndex = mapData.indexOf(IMPORT_END_TAG);
47
- let mapDataStart = mapData.substring(0, endImportIndex);
48
- let mapDataEnd = mapData.substring(endImportIndex);
49
-
50
- mapData = mapDataStart.concat(importFull).concat("\n").concat(mapDataEnd);
51
-
52
- // add map
53
- let endMapIndex = mapData.indexOf(MAP_END_TAG);
54
- mapDataStart = mapData.substring(0, endMapIndex);
55
- mapDataEnd = mapData.substring(endMapIndex);
56
-
57
- mapData = mapDataStart.concat(" ").concat(mapFull).concat("\n").concat(mapDataEnd);
30
+ export const updateComponentMap = async (componentKey, category = CATEGORY_CUSTOM) => {
58
31
 
59
- fs.writeFileSync(pegaLocalComponentMapPath, mapData, { encoding: 'utf8' });
32
+ const framework = await getFramework();
33
+
34
+ switch (framework) {
35
+ case 'SDK-React' :
36
+
37
+ const categoryDirectory = (category === CATEGORY_CONSTELLATION) ? join("/", COMPONENT_DIRECTORY_PREFIX_CUSTOM + category.toLowerCase()) : join("/", category.toLowerCase() + COMPONENT_DIRECTORY_SUFFIX_SDK);
38
+
39
+ const componentNameNoPrefix = removeComponentPrefix(componentKey);
40
+ const componentName = convertIntoPascalCase(componentNameNoPrefix);
41
+
42
+ let mapData = fs.readFileSync(pegaLocalComponentMapPath, { encoding: 'utf8' });
43
+
44
+ let importComponent = join(COMPONENTS_DIRECTORY_PATH, categoryDirectory, componentKey);
45
+ importComponent = "./".concat(importComponent);
46
+
47
+ let importFull = "import ".concat(componentName).concat(" from '").concat(importComponent).concat("/';");
48
+ let mapFull = "\"".concat(componentNameNoPrefix).concat("\" : " ).concat(componentName).concat(",");
49
+
50
+ if (mapData.indexOf(importComponent.concat("/")) < 0) {
51
+ // not present so we can add
52
+
53
+ // add import
54
+ let endImportIndex = mapData.indexOf(IMPORT_END_TAG);
55
+ let mapDataStart = mapData.substring(0, endImportIndex);
56
+ let mapDataEnd = mapData.substring(endImportIndex);
57
+
58
+ mapData = mapDataStart.concat(importFull).concat("\n").concat(mapDataEnd);
59
+
60
+ // add map
61
+ let endMapIndex = mapData.indexOf(MAP_END_TAG);
62
+ mapDataStart = mapData.substring(0, endMapIndex);
63
+ mapDataEnd = mapData.substring(endMapIndex);
64
+
65
+ mapData = mapDataStart.concat(" ").concat(mapFull).concat("\n").concat(mapDataEnd);
66
+
67
+ fs.writeFileSync(pegaLocalComponentMapPath, mapData, { encoding: 'utf8' });
68
+
69
+
70
+ }
71
+ break;
72
+ case 'SDK-Angular' :
73
+ break;
74
+ case 'WebComponents' :
75
+ break;
76
+
77
+ }
60
78
 
61
79
 
62
- }
63
80
 
64
81
 
65
82
  };
66
83
 
67
84
  export const deleteFromComponentMap = async (componentKey, category = CATEGORY_CUSTOM) => {
68
- const pegaLocalComponentMapPath = path.join(path.resolve(), SDK_LOCAL_COMPONENT_MAP_FILENAME);
69
- const categoryDirectory = (category === CATEGORY_CONSTELLATION) ? join("/", COMPONENT_DIRECTORY_PREFIX_CUSTOM + category.toLowerCase()) : join("/", category.toLowerCase() + COMPONENT_DIRECTORY_SUFFIX_SDK);
70
- const pegaConfigJsonPath = path.join(path.resolve(), SDK_CONFIG_JSON_FILENAME);
71
-
72
- const componentNameNoPrefix = removeComponentPrefix(componentKey);
73
- const componentName = convertIntoPascalCase(componentNameNoPrefix);
74
-
75
- let mapData = fs.readFileSync(pegaLocalComponentMapPath, { encoding: 'utf8' });
76
-
77
- let importComponent = join(COMPONENTS_DIRECTORY_PATH, categoryDirectory, componentKey);
78
- importComponent = "./".concat(importComponent);
79
-
80
- let importFull = "import ".concat(componentName).concat(" from '").concat(importComponent).concat("/';");
81
- let mapFull = "\"".concat(componentNameNoPrefix).concat("\" : " ).concat(componentName).concat(",");
82
-
83
-
84
- if (mapData.indexOf(importFull) >= 0) {
85
-
86
- let removeImport = importFull.concat("\n");
87
- let removeMap = " ".concat(mapFull).concat("\n");
88
-
89
- mapData = mapData.replace(removeImport, "");
90
- mapData = mapData.replace(removeMap, "");
91
-
92
- fs.writeFileSync(pegaLocalComponentMapPath, mapData, { encoding: 'utf8' });
93
85
 
86
+ const framework = await getFramework();
87
+
88
+ switch (framework) {
89
+ case 'SDK-React' :
90
+ const categoryDirectory = (category === CATEGORY_CONSTELLATION) ? join("/", COMPONENT_DIRECTORY_PREFIX_CUSTOM + category.toLowerCase()) : join("/", category.toLowerCase() + COMPONENT_DIRECTORY_SUFFIX_SDK);
91
+
92
+ const componentNameNoPrefix = removeComponentPrefix(componentKey);
93
+ const componentName = convertIntoPascalCase(componentNameNoPrefix);
94
+
95
+ let mapData = fs.readFileSync(pegaLocalComponentMapPath, { encoding: 'utf8' });
96
+
97
+ let importComponent = join(COMPONENTS_DIRECTORY_PATH, categoryDirectory, componentKey);
98
+ importComponent = "./".concat(importComponent);
99
+
100
+ let importFull = "import ".concat(componentName).concat(" from '").concat(importComponent).concat("/';");
101
+ let mapFull = "\"".concat(componentNameNoPrefix).concat("\" : " ).concat(componentName).concat(",");
102
+
103
+
104
+ if (mapData.indexOf(importFull) >= 0) {
105
+
106
+ let removeImport = importFull.concat("\n");
107
+ let removeMap = " ".concat(mapFull).concat("\n");
108
+
109
+ mapData = mapData.replace(removeImport, "");
110
+ mapData = mapData.replace(removeMap, "");
111
+
112
+ fs.writeFileSync(pegaLocalComponentMapPath, mapData, { encoding: 'utf8' });
113
+
114
+ }
115
+ break;
116
+ case 'SDK-Angular' :
117
+ break;
118
+ case 'WebComponents' :
119
+ break;
120
+
94
121
  }
95
122
 
123
+
124
+
96
125
 
97
126
  };
98
127
 
99
128
  export const renameComponentInMap = async (oldComponentKey, newComponentKey) => {
100
- const pegaLocalComponentMapPath = path.join(path.resolve(), SDK_LOCAL_COMPONENT_MAP_FILENAME);
101
129
 
102
- const oldComponentNameNoPrefix = removeComponentPrefix(oldComponentKey);
103
- const oldComponentName = convertIntoPascalCase(oldComponentNameNoPrefix);
130
+ const framework = await getFramework();
131
+
132
+ switch (framework) {
133
+ case 'SDK-React' :
134
+
135
+ const oldComponentNameNoPrefix = removeComponentPrefix(oldComponentKey);
136
+ const oldComponentName = convertIntoPascalCase(oldComponentNameNoPrefix);
137
+
138
+ const newComponentNameNoPrefix = removeComponentPrefix(newComponentKey);
139
+ const newComponentName = convertIntoPascalCase(newComponentNameNoPrefix);
140
+
141
+ let mapData = fs.readFileSync(pegaLocalComponentMapPath, { encoding: 'utf8' });
142
+
143
+ if (mapData.indexOf(oldComponentName) >= 0) {
144
+
145
+
146
+
147
+ mapData = mapData.replaceAll(oldComponentName + " ", newComponentName + " ");
148
+ mapData = mapData.replaceAll(oldComponentName + ",", newComponentName + ",");
149
+
150
+ mapData = mapData.replaceAll(oldComponentNameNoPrefix + "/", newComponentNameNoPrefix + "/");
151
+ mapData = mapData.replaceAll( '"' + oldComponentNameNoPrefix + '"' , '"' + newComponentNameNoPrefix + '"');
152
+
153
+ fs.writeFileSync(pegaLocalComponentMapPath, mapData, { encoding: 'utf8' });
154
+
155
+ }
156
+ break;
157
+ case 'SDK-Angular' :
158
+ break;
159
+ case 'WebComponents' :
160
+ break;
161
+
162
+ }
104
163
 
105
- const newComponentNameNoPrefix = removeComponentPrefix(newComponentKey);
106
- const newComponentName = convertIntoPascalCase(newComponentNameNoPrefix);
107
164
 
108
- let mapData = fs.readFileSync(pegaLocalComponentMapPath, { encoding: 'utf8' });
109
165
 
110
- if (mapData.indexOf(oldComponentName) >= 0) {
166
+ };
111
167
 
112
168
 
169
+ export const clearComponentMap = async () => {
113
170
 
114
- mapData = mapData.replaceAll(oldComponentName + " ", newComponentName + " ");
115
- mapData = mapData.replaceAll(oldComponentName + ",", newComponentName + ",");
171
+ const framework = await getFramework();
116
172
 
117
- mapData = mapData.replaceAll(oldComponentNameNoPrefix + "/", newComponentNameNoPrefix + "/");
118
- mapData = mapData.replaceAll( '"' + oldComponentNameNoPrefix + '"' , '"' + newComponentNameNoPrefix + '"');
173
+ switch (framework) {
174
+ case 'SDK-React' :
175
+ // get blank version
176
+ let blankMap = path.join(path.resolve(), COMPONENT_REACT_LIB_PATH, SDK_LOCAL_COMPONENT_MAP_FILENAME);
119
177
 
120
- fs.writeFileSync(pegaLocalComponentMapPath, mapData, { encoding: 'utf8' });
178
+ let blankMapData = fs.readFileSync(blankMap, { encoding: 'utf8' });
121
179
 
180
+ // store blank version in sdk-local-component-map.js
181
+ fs.writeFileSync(pegaLocalComponentMapPath, blankMapData, { encoding: 'utf8' });
182
+
183
+ break;
184
+ case 'SDK-Angular' :
185
+ break;
186
+ case 'WebComponents' :
187
+ break;
188
+
122
189
  }
123
- }
190
+
191
+ };
124
192
 
@@ -22,7 +22,7 @@ import { COMPONENT_SCHEMA,
22
22
  DXCB_COMPONENT_DEFAULTS,
23
23
  CUSTOM_TEMPLATES,
24
24
  OVERRIDE_TEMPLATE_PATH,
25
- OVERRIDE_LIB_PATH } from '../../constants.js';
25
+ OVERRIDE_REACT_LIB_PATH } from '../../constants.js';
26
26
 
27
27
  const pegaConfigJsonPath = path.join(path.resolve(), SDK_CONFIG_JSON_FILENAME);
28
28
 
@@ -110,7 +110,9 @@ const validateCompile = async (
110
110
 
111
111
  let pegaConfig =
112
112
  await getPegaConfig();
113
- let templateParentDir = OVERRIDE_LIB_PATH;
113
+
114
+ // will need to put a case statement here checking framework
115
+ let templateParentDir = OVERRIDE_REACT_LIB_PATH;
114
116
 
115
117
  if (pegaConfig[DXCB_CONFIG] &&
116
118
  pegaConfig[DXCB_CONFIG][CUSTOM_TEMPLATES] &&
@@ -22,7 +22,7 @@ import { COMPONENT_SCHEMA,
22
22
  DXCB_COMPONENT_DEFAULTS,
23
23
  CUSTOM_TEMPLATES,
24
24
  OVERRIDE_TEMPLATE_PATH,
25
- OVERRIDE_LIB_PATH } from '../../constants.js';
25
+ OVERRIDE_REACT_LIB_PATH } from '../../constants.js';
26
26
  import { compileMustacheTemplates } from '@pega/dx-component-builder-sdk/src/tasks/create/index.js';
27
27
 
28
28
  const pegaConfigJsonPath = path.join(path.resolve(), SDK_CONFIG_JSON_FILENAME);
@@ -111,7 +111,9 @@ const validateCompile = async (
111
111
 
112
112
  let pegaConfig =
113
113
  await getPegaConfig();
114
- let templateParentDir = OVERRIDE_LIB_PATH;
114
+
115
+ // will need to put a case statement here checking framework
116
+ let templateParentDir = OVERRIDE_REACT_LIB_PATH;
115
117
 
116
118
  if (pegaConfig[DXCB_CONFIG] &&
117
119
  pegaConfig[DXCB_CONFIG][CUSTOM_TEMPLATES] &&
@@ -6,7 +6,8 @@ import { validateCompile } from '../create/index.js';
6
6
  import {
7
7
  showVersion,
8
8
  getComponentDirectoryPath,
9
- getComponentsAndSubDirectory
9
+ getComponentsAndSubDirectory,
10
+ getFramework
10
11
  } from '../../util.js';
11
12
  import {CATEGORY_CONSTELLATION, CATEGORY_CUSTOM } from '../..//constants.js';
12
13
  import { or } from 'ajv/dist/compile/codegen/index.js';
@@ -44,10 +45,8 @@ const generateMissingCompanion = async (componentKey) => {
44
45
  const componentName = componentKey.split("_")[2];
45
46
 
46
47
  // look up the framework
47
- let internalData = fs.readFileSync(pegaConfigInternalJsonPath, { encoding: 'utf8' });
48
- internalData = internalData && JSON.parse(internalData);
48
+ const framework = await getFramework();
49
49
 
50
- const framework = internalData.sdkType;
51
50
  allowedApplications = allowedApplications.toString();
52
51
 
53
52
 
package/src/util.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import fs from 'fs';
2
+ import path from 'path';
2
3
  import { join } from 'path';
3
4
  import { promisify } from 'util';
4
5
  import https from 'https';
@@ -39,7 +40,7 @@ import {
39
40
  SERVER_REST_URL
40
41
  } from './constants.js';
41
42
 
42
-
43
+ export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
43
44
 
44
45
  const access = promisify(fs.access);
45
46
 
@@ -69,6 +70,15 @@ export const visualLCCategory = (category) => {
69
70
  return category.toLowerCase();
70
71
  }
71
72
 
73
+ export const getFramework = async () => {
74
+ const pegaConfigInternalJsonPath = path.join(path.resolve(), DXCB_CONFIG_INTERNAL_JSON_FILENAME);
75
+
76
+ let internalData = fs.readFileSync(pegaConfigInternalJsonPath, { encoding: 'utf8' });
77
+ internalData = internalData && JSON.parse(internalData);
78
+
79
+ return (internalData.sdkType);
80
+ }
81
+
72
82
  export const deleteLocalComponent = async (componentKey, category = CATEGORY_CUSTOM) => {
73
83
  const currentDirectory = process.cwd();
74
84
  const pegaConfigJsonPath = join(currentDirectory, SDK_CONFIG_JSON_FILENAME);