@eventcatalog/core 2.7.8 → 2.7.10
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @eventcatalog/core
|
|
2
2
|
|
|
3
|
+
## 2.7.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d4e2013: chore(core): added ability to check and add properties on users catal…
|
|
8
|
+
|
|
9
|
+
## 2.7.9
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 4cad2eb: fix(core): fixing generate command (again)
|
|
14
|
+
|
|
3
15
|
## 2.7.8
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eventcatalog/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.7.
|
|
4
|
+
"version": "2.7.10",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -65,7 +65,8 @@
|
|
|
65
65
|
"semver": "7.6.3",
|
|
66
66
|
"tailwindcss": "^3.4.3",
|
|
67
67
|
"typescript": "^5.4.5",
|
|
68
|
-
"unist-util-visit": "^5.0.0"
|
|
68
|
+
"unist-util-visit": "^5.0.0",
|
|
69
|
+
"uuid": "^10.0.0"
|
|
69
70
|
},
|
|
70
71
|
"devDependencies": {
|
|
71
72
|
"@parcel/watcher": "^2.4.1",
|
|
@@ -3,6 +3,7 @@ import * as path from 'node:path';
|
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
import os from 'node:os';
|
|
6
|
+
import { verifyRequiredFieldsAreInCatalogConfigFile } from './eventcatalog-config-file-utils.js';
|
|
6
7
|
|
|
7
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
8
9
|
const scriptsDir = path.dirname(__filename);
|
|
@@ -262,6 +263,9 @@ export const catalogToAstro = async (source, astroContentDir, catalogFilesDir) =
|
|
|
262
263
|
|
|
263
264
|
// Copy the components if they are defined
|
|
264
265
|
await copyComponents({ source, target: astroContentDir, catalogFilesDir });
|
|
266
|
+
|
|
267
|
+
// Verify required fields are in the catalog config file
|
|
268
|
+
await verifyRequiredFieldsAreInCatalogConfigFile(source);
|
|
265
269
|
};
|
|
266
270
|
|
|
267
271
|
if (process.env.NODE_ENV !== 'test') {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFile, writeFile, rm } from 'node:fs/promises';
|
|
2
2
|
import { existsSync } from 'fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
import { v4 as uuidV4 } from 'uuid';
|
|
4
5
|
|
|
5
6
|
// * Very strange behaviour when importing ESM files from catalogs into core.
|
|
6
7
|
// * Core (node) does not know how to handle ESM files, so we have to try and convert them.
|
|
@@ -94,3 +95,16 @@ export const writeEventCatalogConfigFile = async (projectDirectory, newConfig) =
|
|
|
94
95
|
await cleanup(projectDirectory);
|
|
95
96
|
}
|
|
96
97
|
};
|
|
98
|
+
|
|
99
|
+
// Check the eventcatalog.config.js and add any missing required fields on it
|
|
100
|
+
export const verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
|
|
101
|
+
try {
|
|
102
|
+
const config = await getEventCatalogConfigFile(projectDirectory);
|
|
103
|
+
|
|
104
|
+
if (!config.cId) {
|
|
105
|
+
await writeEventCatalogConfigFile(projectDirectory, { cId: uuidV4() });
|
|
106
|
+
}
|
|
107
|
+
} catch (error) {
|
|
108
|
+
// fail silently, it's overly important
|
|
109
|
+
}
|
|
110
|
+
};
|
package/scripts/generate.js
CHANGED
|
@@ -18,9 +18,8 @@ function getDefaultExport(importedModule) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
const generate = async () => {
|
|
21
|
+
const PROJECT_DIRECTORY = process.env.PROJECT_DIR;
|
|
21
22
|
try {
|
|
22
|
-
const PROJECT_DIRECTORY = process.env.PROJECT_DIR;
|
|
23
|
-
|
|
24
23
|
const config = await getEventCatalogConfigFile(PROJECT_DIRECTORY);
|
|
25
24
|
|
|
26
25
|
const { generators = [] } = config;
|
|
@@ -53,16 +52,16 @@ const generate = async () => {
|
|
|
53
52
|
// Use importedGenerator here
|
|
54
53
|
} catch (error) {
|
|
55
54
|
console.error('Error loading plugin:', error);
|
|
56
|
-
await cleanup();
|
|
55
|
+
await cleanup(PROJECT_DIRECTORY);
|
|
57
56
|
return;
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
await cleanup();
|
|
60
|
+
await cleanup(PROJECT_DIRECTORY);
|
|
62
61
|
} catch (error) {
|
|
63
62
|
// Failed to generate clean up...
|
|
64
63
|
console.error(error);
|
|
65
|
-
await cleanup();
|
|
64
|
+
await cleanup(PROJECT_DIRECTORY);
|
|
66
65
|
}
|
|
67
66
|
};
|
|
68
67
|
|