@pega/dx-component-builder-sdk 0.1.14 → 0.1.16

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.14",
3
+ "version": "0.1.16",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
package/src/constants.js CHANGED
@@ -323,10 +323,6 @@ export const COMPONENT_SCHEMA = {
323
323
  name: 'Stages',
324
324
  value: 'Stages'
325
325
  },
326
- {
327
- name: 'To Do',
328
- value: 'ToDo'
329
- },
330
326
  {
331
327
  name: 'Vertical Tabs',
332
328
  value: 'VerticalTabs/VerticalTabs'
@@ -518,6 +514,10 @@ export const COMPONENT_SCHEMA = {
518
514
  {
519
515
  name: 'Summary List',
520
516
  value: 'SummaryList'
517
+ },
518
+ {
519
+ name: 'To Do',
520
+ value: 'ToDo'
521
521
  }
522
522
  ],
523
523
  }
@@ -39,6 +39,33 @@ const copyComponentTemplate = async options => {
39
39
  };
40
40
 
41
41
 
42
+ const checkAndCreateConfigComponentKey = async (targetDirectory) => {
43
+
44
+ const configFile = path.join(targetDirectory, "config-ext.json");
45
+ try {
46
+ const configData = fs.readFileSync(path.resolve(configFile), 'utf8');
47
+ const configObj = JSON.parse(configData);
48
+
49
+ if (!configObj.componentKey) {
50
+ const name = configObj.name;
51
+ const componentKey = name;
52
+ const newConfigObj = { componentKey, ...configObj };
53
+
54
+ // stringify "4", makes the json string look like JSON in the file
55
+ const configContent = JSON.stringify(newConfigObj, null, 4);
56
+
57
+ // update file
58
+ fs.writeFileSync(configFile, configContent, { encoding: 'utf8' });
59
+ }
60
+
61
+ }
62
+ catch (err) {
63
+ // no config-ext.json file, so no update, which is ok
64
+ console.log(chalk.yellow("Component has no config file for extension."));
65
+ }
66
+ }
67
+
68
+
42
69
  const getListAvailableComponents = async (type) => {
43
70
  const components = await getComponents(false, CATEGORY_OVERRIDE);
44
71
  const fullList = COMPONENT_SCHEMA.overrideComponent[type];
@@ -102,6 +129,8 @@ const validateCompile = async (
102
129
  overrideDirectory
103
130
  });
104
131
 
132
+ await checkAndCreateConfigComponentKey(targetDirectory);
133
+
105
134
 
106
135
  console.log(chalk.green(`> Created ${componentKey} component in ${targetDirectory}`));
107
136
 
@@ -300,7 +300,7 @@ const overrideSchema = {
300
300
  },
301
301
  defaultConfig: { type: 'object' }
302
302
  },
303
- required: ['componentKey', 'name', 'description', 'type', 'subtype', 'properties'],
303
+ required: ['name', 'type', 'subtype', 'properties', 'componentKey'],
304
304
  additionalProperties: true
305
305
  };
306
306
 
@@ -345,7 +345,7 @@ export default async (option, category = CATEGORY_CUSTOM) => {
345
345
  }
346
346
  else if (category === CATEGORY_OVERRIDE) {
347
347
  // for now, if now file just end
348
- console.log(`${chalk.bold.yellow('config file not availabe for: ' + componentToValidate)}`);
348
+ console.log(`${chalk.bold.yellow('Config file not availabe for: ' + componentToValidate)}`);
349
349
  return;
350
350
  }
351
351
  }