@eventcatalog/core 2.7.9 → 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,11 @@
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
+
3
9
  ## 2.7.9
4
10
 
5
11
  ### 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.9",
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
+ };