@eventcatalog/core 2.13.3 → 2.14.0

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.
Files changed (25) hide show
  1. package/.github/workflows/test-e2e.yml +19 -21
  2. package/CHANGELOG.md +12 -0
  3. package/bin/dist/eventcatalog.cjs +478 -26
  4. package/bin/dist/eventcatalog.js +478 -26
  5. package/package.json +4 -6
  6. package/scripts/analytics/analytics.js +2 -16
  7. package/scripts/analytics/log-build.js +8 -4
  8. package/scripts/build-ci.js +14 -7
  9. package/scripts/catalog-to-astro-content-directory.js +13 -10
  10. package/scripts/constants.ts +3 -0
  11. package/scripts/generate.js +1 -4
  12. package/scripts/start-catalog-locally.js +19 -11
  13. package/scripts/watcher.js +0 -17
  14. package/src/utils/node-graphs/services-node-graph.ts +8 -4
  15. /package/{scripts/default-files-for-collections → default-files-for-collections}/changelogs.md +0 -0
  16. /package/{scripts/default-files-for-collections → default-files-for-collections}/channels.md +0 -0
  17. /package/{scripts/default-files-for-collections → default-files-for-collections}/commands.md +0 -0
  18. /package/{scripts/default-files-for-collections → default-files-for-collections}/domains.md +0 -0
  19. /package/{scripts/default-files-for-collections → default-files-for-collections}/events.md +0 -0
  20. /package/{scripts/default-files-for-collections → default-files-for-collections}/flows.md +0 -0
  21. /package/{scripts/default-files-for-collections → default-files-for-collections}/pages.md +0 -0
  22. /package/{scripts/default-files-for-collections → default-files-for-collections}/queries.md +0 -0
  23. /package/{scripts/default-files-for-collections → default-files-for-collections}/services.md +0 -0
  24. /package/{scripts/default-files-for-collections → default-files-for-collections}/teams.md +0 -0
  25. /package/{scripts/default-files-for-collections → default-files-for-collections}/users.md +0 -0
@@ -1,29 +1,27 @@
1
1
  name: Tests e2e
2
2
  on:
3
3
  pull_request:
4
- branches: [ main, master ]
4
+ branches: [main, master]
5
5
  jobs:
6
6
  test:
7
7
  timeout-minutes: 60
8
8
  runs-on: ubuntu-latest
9
9
  steps:
10
- - uses: actions/checkout@v4
11
- - uses: actions/setup-node@v4
12
- with:
13
- node-version: lts/*
14
- - name: Install dependencies
15
- run: npm ci
16
- - name: Install Playwright Browsers
17
- run: npx playwright install --with-deps
18
- - name: Build catalog
19
- shell: bash
20
- run: |
21
- cp $PROJECT_DIR/eventcatalog.config.js $CATALOG_DIR/eventcatalog.config.js
22
- cp $PROJECT_DIR/eventcatalog.styles.css $CATALOG_DIR/eventcatalog.styles.css
23
- npm run build
24
- env:
25
- PROJECT_DIR: ./examples/default/
26
- CATALOG_DIR: ./
27
- NODE_ENV: CI # Skip analytics
28
- - name: Run tests
29
- run: npm run test:e2e
10
+ - uses: actions/checkout@v4
11
+ - uses: actions/setup-node@v4
12
+ with:
13
+ node-version: lts/*
14
+ - name: Install dependencies
15
+ run: npm ci
16
+ - name: Install Playwright Browsers
17
+ run: npx playwright install --with-deps
18
+ - name: Build cli
19
+ run: npm run build:bin
20
+ - name: Build catalog
21
+ run: npx . build
22
+ env:
23
+ PROJECT_DIR: ./examples/default/
24
+ CATALOG_DIR: ./
25
+ NODE_ENV: CI # Skip analytics
26
+ - name: Run tests
27
+ run: npm run test:e2e
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @eventcatalog/core
2
2
 
3
+ ## 2.14.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 536511e: chore(core): refactor core logic to simplify the code
8
+
9
+ ## 2.13.4
10
+
11
+ ### Patch Changes
12
+
13
+ - 2ad9561: fix(core): fixed issues with node graphs for services and metadata in the nodes
14
+
3
15
  ## 2.13.3
4
16
 
5
17
  ### Patch Changes
@@ -30,24 +30,462 @@ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
30
30
  // bin/eventcatalog.ts
31
31
  var import_commander = require("commander");
32
32
  var import_node_child_process = require("child_process");
33
- var import_node_path = require("path");
34
- var import_fs = __toESM(require("fs"), 1);
35
- var import_node_path2 = __toESM(require("path"), 1);
33
+ var import_node_path4 = require("path");
34
+ var import_fs2 = __toESM(require("fs"), 1);
35
+ var import_node_path5 = __toESM(require("path"), 1);
36
36
  var import_node_url = require("url");
37
- var currentDir = import_node_path2.default.dirname((0, import_node_url.fileURLToPath)(importMetaUrl));
38
- var program = new import_commander.Command();
39
- var dir = process.cwd();
40
- var core = (0, import_node_path.join)(dir, ".eventcatalog-core");
41
- var eventCatalogDir = (0, import_node_path.join)(currentDir, "../../");
37
+ var import_concurrently = __toESM(require("concurrently"), 1);
38
+
39
+ // scripts/generate.js
40
+ var import_node_path2 = __toESM(require("path"), 1);
41
+
42
+ // scripts/eventcatalog-config-file-utils.js
43
+ var import_promises = require("fs/promises");
44
+ var import_node_fs = require("fs");
45
+ var import_promises2 = require("fs/promises");
46
+ var import_node_path = __toESM(require("path"), 1);
47
+ var import_uuid = require("uuid");
48
+ var import_url = require("url");
49
+ var import_gray_matter = __toESM(require("gray-matter"), 1);
50
+ async function cleanup(projectDirectory) {
51
+ const filePath = import_node_path.default.join(projectDirectory, "eventcatalog.config.mjs");
52
+ if ((0, import_node_fs.existsSync)(filePath)) {
53
+ await (0, import_promises.rm)(filePath);
54
+ }
55
+ }
56
+ var getEventCatalogConfigFile = async (projectDirectory) => {
57
+ try {
58
+ let configFilePath = import_node_path.default.join(projectDirectory, "eventcatalog.config.js");
59
+ const filePath = import_node_path.default.join(projectDirectory, "package.json");
60
+ const packageJson = JSON.parse(await (0, import_promises.readFile)(filePath, "utf-8"));
61
+ if (packageJson?.type !== "module") {
62
+ await (0, import_promises2.copyFile)(configFilePath, import_node_path.default.join(projectDirectory, "eventcatalog.config.mjs"));
63
+ configFilePath = import_node_path.default.join(projectDirectory, "eventcatalog.config.mjs");
64
+ }
65
+ const configFileURL = (0, import_url.pathToFileURL)(configFilePath).href;
66
+ const config = await import(
67
+ /* @vite-ignore */
68
+ configFileURL
69
+ );
70
+ return config.default;
71
+ } finally {
72
+ await cleanup(projectDirectory);
73
+ }
74
+ };
75
+ var writeEventCatalogConfigFile = async (projectDirectory, newConfig) => {
76
+ try {
77
+ const configFilePath = import_node_path.default.join(projectDirectory, "eventcatalog.config.js");
78
+ let content = await (0, import_promises.readFile)(configFilePath, "utf8");
79
+ const startIndex = content.indexOf("export default {");
80
+ if (startIndex === -1) {
81
+ return;
82
+ }
83
+ Object.entries(newConfig).forEach(([key, value]) => {
84
+ const valueString = JSON.stringify(value, null, 2).replace(/"/g, "'").replace(/\n/g, "\n ");
85
+ const keyRegex = new RegExp(`(${key}\\s*:)([^,}]+)`, "g");
86
+ if (content.match(keyRegex)) {
87
+ content = content.replace(keyRegex, `$1 ${valueString}`);
88
+ } else {
89
+ const insertPosition = content.indexOf("{", startIndex) + 1;
90
+ content = content.slice(0, insertPosition) + `
91
+ ${key}: ${valueString},` + content.slice(insertPosition);
92
+ }
93
+ });
94
+ await (0, import_promises.writeFile)(configFilePath, content);
95
+ } finally {
96
+ await cleanup(projectDirectory);
97
+ }
98
+ };
99
+ var verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
100
+ try {
101
+ const config = await getEventCatalogConfigFile(projectDirectory);
102
+ if (!config.cId) {
103
+ await writeEventCatalogConfigFile(projectDirectory, { cId: (0, import_uuid.v4)() });
104
+ }
105
+ } catch (error) {
106
+ }
107
+ };
108
+ function addPropertyToFrontMatter(input, newProperty, newValue) {
109
+ const file = (0, import_gray_matter.default)(input);
110
+ return import_gray_matter.default.stringify(file.content, { ...file.data, [newProperty]: newValue });
111
+ }
112
+
113
+ // scripts/generate.js
114
+ function getDefaultExport(importedModule) {
115
+ if (importedModule === null || typeof importedModule !== "object") {
116
+ throw new Error("Invalid module");
117
+ }
118
+ if (typeof importedModule.default === "object" && importedModule.default !== null) {
119
+ return importedModule.default.default || importedModule.default;
120
+ }
121
+ if (typeof importedModule.default !== "undefined") {
122
+ return importedModule.default;
123
+ }
124
+ return importedModule;
125
+ }
126
+ var generate = async (PROJECT_DIRECTORY) => {
127
+ try {
128
+ const config = await getEventCatalogConfigFile(PROJECT_DIRECTORY);
129
+ const { generators = [] } = config;
130
+ if (!generators.length) {
131
+ console.log("No configured generators found, skipping generation");
132
+ return;
133
+ }
134
+ for (const generator of generators) {
135
+ let plugin = generator[0];
136
+ const pluginConfig = generator[1];
137
+ if (plugin.startsWith("./")) {
138
+ plugin = import_node_path2.default.join(PROJECT_DIRECTORY, plugin);
139
+ }
140
+ if (plugin.includes("<rootDir>")) {
141
+ plugin = plugin.replace("<rootDir>", PROJECT_DIRECTORY);
142
+ }
143
+ try {
144
+ const importedGenerator = await import(plugin);
145
+ const generator2 = getDefaultExport(importedGenerator);
146
+ await generator2({ eventCatalogConfig: {} }, pluginConfig);
147
+ } catch (error) {
148
+ console.error("Error loading plugin:", error);
149
+ await cleanup(PROJECT_DIRECTORY);
150
+ return;
151
+ }
152
+ }
153
+ await cleanup(PROJECT_DIRECTORY);
154
+ } catch (error) {
155
+ console.error(error);
156
+ await cleanup(PROJECT_DIRECTORY);
157
+ }
158
+ };
159
+
160
+ // scripts/analytics/analytics.js
161
+ var import_axios = __toESM(require("axios"), 1);
162
+ var import_os = __toESM(require("os"), 1);
163
+
164
+ // package.json
165
+ var version = "2.14.0";
166
+
167
+ // scripts/constants.ts
168
+ var VERSION = version;
169
+
170
+ // scripts/analytics/analytics.js
171
+ async function raiseEvent(eventData) {
172
+ const url = "https://queue.simpleanalyticscdn.com/events";
173
+ const userAgent = `@eventcatalog/eventcatalog@${VERSION} (${import_os.default.platform()}; ${import_os.default.arch()}; Node/${process.version})`;
174
+ const headers = {
175
+ "Content-Type": "application/json"
176
+ };
177
+ const payload = {
178
+ type: "event",
179
+ hostname: "eventcatalog.dev",
180
+ event: "@eventcatalog/eventcatalog",
181
+ metadata: {
182
+ ...eventData,
183
+ t: `t;${(/* @__PURE__ */ new Date()).toISOString()}`,
184
+ ua: userAgent
185
+ },
186
+ ua: userAgent
187
+ };
188
+ try {
189
+ await import_axios.default.post(url, payload, { headers });
190
+ } catch (error) {
191
+ }
192
+ }
193
+
194
+ // scripts/analytics/log-build.js
195
+ var main = async (projectDir) => {
196
+ if (process.env.NODE_ENV === "CI") return;
197
+ try {
198
+ await verifyRequiredFieldsAreInCatalogConfigFile(projectDir);
199
+ const configFile = await getEventCatalogConfigFile(projectDir);
200
+ const { cId, organizationName, generators = [] } = configFile;
201
+ const generatorNames = generators.length > 0 ? generators.map((generator) => generator[0]) : ["none"];
202
+ await raiseEvent({
203
+ command: "build",
204
+ org: organizationName,
205
+ cId,
206
+ generators: generatorNames.toString()
207
+ });
208
+ } catch (error) {
209
+ }
210
+ };
211
+ var log_build_default = main;
212
+
213
+ // scripts/watcher.js
214
+ var import_watcher = __toESM(require("@parcel/watcher"), 1);
215
+ var import_node_fs2 = __toESM(require("fs"), 1);
216
+
217
+ // scripts/map-catalog-to-astro.js
218
+ var import_node_path3 = __toESM(require("path"), 1);
219
+ var COLLECTION_KEYS = [
220
+ "events",
221
+ "commands",
222
+ "services",
223
+ "users",
224
+ "teams",
225
+ "domains",
226
+ "flows",
227
+ "pages",
228
+ "changelogs",
229
+ "queries",
230
+ "channels"
231
+ ];
232
+ function mapCatalogToAstro({ filePath, astroDir, projectDir }) {
233
+ const relativeFilePath = removeBasePath(filePath, projectDir);
234
+ if (!isCatalogRelated(relativeFilePath)) {
235
+ return [];
236
+ }
237
+ const baseTargetPaths = getBaseTargetPaths(relativeFilePath);
238
+ const relativeTargetPath = getRelativeTargetPath(relativeFilePath);
239
+ return baseTargetPaths.map(
240
+ (base) => import_node_path3.default.join(astroDir, base, relativeTargetPath.replace("index.md", "index.mdx").replace("changelog.md", "changelog.mdx"))
241
+ );
242
+ }
243
+ function removeBasePath(fullPath, basePath) {
244
+ const relativePath = import_node_path3.default.relative(basePath, fullPath);
245
+ return relativePath.startsWith("..") ? fullPath : relativePath;
246
+ }
247
+ function isCollectionKey(key) {
248
+ return COLLECTION_KEYS.includes(key);
249
+ }
250
+ function isCatalogRelated(filePath) {
251
+ const filePathArr = filePath.split(import_node_path3.default.sep).filter(Boolean);
252
+ if ([
253
+ "eventcatalog.config.js",
254
+ // config file at root
255
+ "eventcatalog.styles.css",
256
+ // custom styles file at root
257
+ "components",
258
+ // custom components
259
+ "public",
260
+ // public assets
261
+ ...COLLECTION_KEYS
262
+ ].includes(filePathArr[0])) {
263
+ return true;
264
+ }
265
+ return false;
266
+ }
267
+ function getBaseTargetPaths(filePath) {
268
+ const filePathArr = filePath.split(import_node_path3.default.sep).filter(Boolean);
269
+ if (isCollectionKey(filePathArr[0])) {
270
+ if (filePathArr[filePathArr.length - 1] == "changelog.md") {
271
+ return [import_node_path3.default.join("src", "content", "changelogs")];
272
+ }
273
+ if (filePathArr[filePathArr.length - 1].match(/\.md$/)) {
274
+ return [import_node_path3.default.join("src", "content")];
275
+ }
276
+ const hasExtension = (str) => /\.[a-zA-Z0-9]{2,}$/.test(str);
277
+ if (hasExtension(filePath)) {
278
+ return [import_node_path3.default.join("public", "generated"), import_node_path3.default.join("src", "catalog-files")];
279
+ }
280
+ return [import_node_path3.default.join("public", "generated"), import_node_path3.default.join("src", "catalog-files"), import_node_path3.default.join("src", "content")];
281
+ }
282
+ if (filePathArr[0] == "components") {
283
+ return [import_node_path3.default.join("src", "custom-defined-components")];
284
+ }
285
+ if (filePathArr[0] == "public") {
286
+ return [import_node_path3.default.join("public")];
287
+ }
288
+ return [import_node_path3.default.join("/")];
289
+ }
290
+ function getRelativeTargetPath(filePath) {
291
+ const filePathArr = filePath.split(import_node_path3.default.sep).filter(Boolean);
292
+ if (filePathArr[0] == "public" || filePathArr[0] == "components") {
293
+ filePathArr.shift();
294
+ }
295
+ const relativePath = [];
296
+ for (let i = filePathArr.length - 1; i >= 0; i--) {
297
+ relativePath.unshift(filePathArr[i]);
298
+ if (isCollectionKey(filePathArr[i])) break;
299
+ }
300
+ return import_node_path3.default.join(...relativePath);
301
+ }
302
+
303
+ // scripts/watcher.js
304
+ var import_rimraf = require("rimraf");
305
+ async function watch(projectDirectory, catalogDirectory, callback = void 0) {
306
+ const subscription = await import_watcher.default.subscribe(
307
+ projectDirectory,
308
+ compose(
309
+ /**
310
+ * @param {Error|null} err
311
+ * @param {Event[]} events
312
+ * @returns {unknown}
313
+ */
314
+ (err, events) => {
315
+ if (err) {
316
+ return;
317
+ }
318
+ for (let event of events) {
319
+ const { path: filePath, type } = event;
320
+ const astroPaths = mapCatalogToAstro({
321
+ filePath,
322
+ astroDir: catalogDirectory,
323
+ projectDir: projectDirectory
324
+ });
325
+ for (const astroPath of astroPaths) {
326
+ switch (type) {
327
+ case "create":
328
+ case "update":
329
+ try {
330
+ if (astroPath.endsWith(".mdx")) {
331
+ const content = import_node_fs2.default.readFileSync(astroPath, "utf-8");
332
+ const frontmatter = addPropertyToFrontMatter(content, "pathToFile", filePath);
333
+ import_node_fs2.default.writeFileSync(astroPath, frontmatter);
334
+ }
335
+ } catch (error) {
336
+ }
337
+ if (import_node_fs2.default.statSync(filePath).isDirectory()) import_node_fs2.default.mkdirSync(astroPath, { recursive: true });
338
+ else retryEPERM(import_node_fs2.default.cpSync)(filePath, astroPath);
339
+ break;
340
+ case "delete":
341
+ retryEPERM(import_rimraf.rimrafSync)(astroPath);
342
+ break;
343
+ }
344
+ }
345
+ }
346
+ },
347
+ callback
348
+ ),
349
+ {
350
+ ignore: [`**/${catalogDirectory}/!(${projectDirectory})**`]
351
+ }
352
+ );
353
+ return () => subscription.unsubscribe();
354
+ }
355
+ function compose(...fns) {
356
+ return function(err, events) {
357
+ fns.filter(Boolean).forEach((fn, i) => {
358
+ try {
359
+ fn(err, events);
360
+ } catch (error) {
361
+ console.error({ error });
362
+ throw error;
363
+ }
364
+ });
365
+ };
366
+ }
367
+ var MAX_RETRIES = 5;
368
+ var DELAY_MS = 100;
369
+ function retryEPERM(fn) {
370
+ return (...args) => {
371
+ let retries = 0;
372
+ while (retries < MAX_RETRIES) {
373
+ try {
374
+ return fn(...args);
375
+ } catch (err) {
376
+ if (err.code !== "EPERM") throw err;
377
+ setTimeout(() => {
378
+ }, DELAY_MS);
379
+ retries += 1;
380
+ }
381
+ }
382
+ };
383
+ }
384
+
385
+ // scripts/catalog-to-astro-content-directory.js
386
+ var import_glob = require("glob");
387
+ var path4 = __toESM(require("path"), 1);
388
+ var import_fs = __toESM(require("fs"), 1);
389
+ var import_url2 = require("url");
390
+ var import_node_os = __toESM(require("os"), 1);
391
+ var __filename2 = (0, import_url2.fileURLToPath)(importMetaUrl);
392
+ var rootPkg = path4.resolve(
393
+ path4.dirname(__filename2),
394
+ /**
395
+ * TODO: fix me =0
396
+ *
397
+ * The following is a workaround until organize the structure to have the correct path
398
+ * for any value of NODE_ENV
399
+ *
400
+ * @author carlosallexandre
401
+ */
402
+ process.env.NODE_ENV === "test" ? "../" : "../../"
403
+ );
404
+ var copyFiles = async (source, target) => {
405
+ const files = await (0, import_glob.glob)(path4.join(source, "**"), {
406
+ nodir: true,
407
+ windowsPathsNoEscape: import_node_os.default.platform() == "win32"
408
+ });
409
+ for (const file of files) {
410
+ mapCatalogToAstro({
411
+ filePath: file,
412
+ astroDir: target,
413
+ projectDir: source
414
+ }).map((astroPath) => {
415
+ import_fs.default.cpSync(file, astroPath);
416
+ return { oldPath: file, newPath: astroPath };
417
+ }).map(({ oldPath, newPath }) => {
418
+ if (!oldPath.endsWith(".md") && !oldPath.endsWith(".mdx")) return;
419
+ try {
420
+ const content = import_fs.default.readFileSync(newPath, "utf-8");
421
+ const frontmatter = addPropertyToFrontMatter(content, "pathToFile", oldPath);
422
+ import_fs.default.writeFileSync(newPath, frontmatter);
423
+ } catch (error) {
424
+ }
425
+ });
426
+ }
427
+ };
428
+ var ensureAstroCollectionNotEmpty = async (astroDir) => {
429
+ const COLLECTIONS = [
430
+ "events",
431
+ "commands",
432
+ "services",
433
+ "users",
434
+ "teams",
435
+ "domains",
436
+ "flows",
437
+ "pages",
438
+ "changelogs",
439
+ "queries",
440
+ "channels"
441
+ ];
442
+ const emptyCollections = [];
443
+ for (const collection of COLLECTIONS) {
444
+ const markdownFiles = await (0, import_glob.glob)(path4.join(astroDir, "src/content/", collection, "**"), {
445
+ nodir: true,
446
+ windowsPathsNoEscape: import_node_os.default.platform() == "win32"
447
+ });
448
+ if (markdownFiles.length === 0) emptyCollections.push(collection);
449
+ }
450
+ const defaultCollectionFilesDir = path4.join(rootPkg, "default-files-for-collections");
451
+ for (const collection of emptyCollections) {
452
+ const defaultFile = path4.join(defaultCollectionFilesDir, `${collection}.md`);
453
+ const targetDir = path4.join(astroDir, "src/content/", collection);
454
+ if (!import_fs.default.existsSync(targetDir)) {
455
+ import_fs.default.mkdirSync(targetDir, { recursive: true });
456
+ }
457
+ import_fs.default.cpSync(defaultFile, path4.join(targetDir, `${collection}.md`));
458
+ }
459
+ };
460
+ var catalogToAstro = async (source, astroDir) => {
461
+ const astroContentDir = path4.join(astroDir, "src/content/");
462
+ const astroConfigFile = import_fs.default.readFileSync(path4.join(astroContentDir, "config.ts"));
463
+ import_fs.default.rmSync(astroContentDir, { recursive: true });
464
+ import_fs.default.mkdirSync(astroContentDir);
465
+ import_fs.default.writeFileSync(path4.join(astroContentDir, "config.ts"), astroConfigFile);
466
+ await verifyRequiredFieldsAreInCatalogConfigFile(source);
467
+ await copyFiles(source, astroDir);
468
+ await ensureAstroCollectionNotEmpty(astroDir);
469
+ };
470
+
471
+ // bin/eventcatalog.ts
472
+ var currentDir = import_node_path5.default.dirname((0, import_node_url.fileURLToPath)(importMetaUrl));
473
+ var program = new import_commander.Command().version(VERSION);
474
+ var dir = import_node_path5.default.resolve(process.env.PROJECT_DIR || process.cwd());
475
+ var core = import_node_path5.default.resolve(process.env.CATALOG_DIR || (0, import_node_path4.join)(dir, ".eventcatalog-core"));
476
+ var eventCatalogDir = import_node_path5.default.resolve((0, import_node_path4.join)(currentDir, "../../"));
42
477
  program.name("eventcatalog").description("Documentation tool for event-driven architectures");
43
478
  var ensureDir = (dir2) => {
44
- if (!import_fs.default.existsSync(dir2)) {
45
- import_fs.default.mkdirSync(dir2);
479
+ if (!import_fs2.default.existsSync(dir2)) {
480
+ import_fs2.default.mkdirSync(dir2);
46
481
  }
47
482
  };
48
483
  var copyCore = () => {
49
484
  ensureDir(core);
50
- import_fs.default.cpSync(eventCatalogDir, core, {
485
+ if (eventCatalogDir === core) {
486
+ return;
487
+ }
488
+ import_fs2.default.cpSync(eventCatalogDir, core, {
51
489
  recursive: true,
52
490
  filter: (src) => {
53
491
  return true;
@@ -55,9 +493,9 @@ var copyCore = () => {
55
493
  });
56
494
  };
57
495
  var clearCore = () => {
58
- if (import_fs.default.existsSync(core)) import_fs.default.rmSync(core, { recursive: true });
496
+ if (import_fs2.default.existsSync(core)) import_fs2.default.rmSync(core, { recursive: true });
59
497
  };
60
- program.command("dev").description("Run development server of EventCatalog").option("-d, --debug", "Output EventCatalog application information into your terminal").option("--force-recreate", "Recreate the eventcatalog-core directory", false).action((options) => {
498
+ program.command("dev").description("Run development server of EventCatalog").option("-d, --debug", "Output EventCatalog application information into your terminal").option("--force-recreate", "Recreate the eventcatalog-core directory", false).action(async (options) => {
61
499
  console.log("Setting up EventCatalog....");
62
500
  if (options.debug) {
63
501
  console.log("Debug mode enabled");
@@ -67,15 +505,33 @@ program.command("dev").description("Run development server of EventCatalog").opt
67
505
  if (options.forceRecreate) clearCore();
68
506
  copyCore();
69
507
  console.log("EventCatalog is starting at http://localhost:3000/docs");
70
- (0, import_node_child_process.execSync)(`cross-env PROJECT_DIR='${dir}' CATALOG_DIR='${core}' npm run dev`, {
71
- cwd: core,
72
- // @ts-ignore
73
- stdio: "inherit"
74
- });
508
+ await catalogToAstro(dir, core);
509
+ let watchUnsub;
510
+ try {
511
+ watchUnsub = await watch(dir, core);
512
+ const { result } = (0, import_concurrently.default)([
513
+ {
514
+ name: "astro",
515
+ command: "npm run dev",
516
+ cwd: core,
517
+ env: {
518
+ PROJECT_DIR: dir,
519
+ CATALOG_DIR: core
520
+ }
521
+ }
522
+ ]);
523
+ await result;
524
+ } catch (err) {
525
+ console.error(err);
526
+ } finally {
527
+ await watchUnsub?.();
528
+ }
75
529
  });
76
- program.command("build").description("Run build of EventCatalog").action((options) => {
530
+ program.command("build").description("Run build of EventCatalog").action(async (options) => {
77
531
  console.log("Building EventCatalog...");
78
532
  copyCore();
533
+ await log_build_default(dir);
534
+ await catalogToAstro(dir, core);
79
535
  (0, import_node_child_process.execSync)(`cross-env PROJECT_DIR='${dir}' CATALOG_DIR='${core}' npm run build`, {
80
536
  cwd: core,
81
537
  stdio: "inherit"
@@ -96,11 +552,7 @@ program.command("start").description("Serves the contents of your eventcatalog b
96
552
  console.log("Starting preview of your build...");
97
553
  previewCatalog();
98
554
  });
99
- program.command("generate [siteDir]").description("Start the generator scripts.").action(() => {
100
- copyCore();
101
- (0, import_node_child_process.execSync)(`cross-env PROJECT_DIR='${dir}' npm run generate`, {
102
- cwd: core,
103
- stdio: "inherit"
104
- });
555
+ program.command("generate [siteDir]").description("Start the generator scripts.").action(async () => {
556
+ await generate(dir);
105
557
  });
106
- program.parse();
558
+ program.parseAsync();