@pega/dx-component-builder-sdk 0.1.15 → 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
|
@@ -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: ['
|
|
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('
|
|
348
|
+
console.log(`${chalk.bold.yellow('Config file not availabe for: ' + componentToValidate)}`);
|
|
349
349
|
return;
|
|
350
350
|
}
|
|
351
351
|
}
|