@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
@@ -7,7 +7,18 @@ import { verifyRequiredFieldsAreInCatalogConfigFile, addPropertyToFrontMatter }
7
7
  import { mapCatalogToAstro } from './map-catalog-to-astro.js';
8
8
 
9
9
  const __filename = fileURLToPath(import.meta.url);
10
- const scriptsDir = path.dirname(__filename);
10
+ const rootPkg = path.resolve(
11
+ path.dirname(__filename),
12
+ /**
13
+ * TODO: fix me =0
14
+ *
15
+ * The following is a workaround until organize the structure to have the correct path
16
+ * for any value of NODE_ENV
17
+ *
18
+ * @author carlosallexandre
19
+ */
20
+ process.env.NODE_ENV === 'test' ? '../' : '../../'
21
+ );
11
22
 
12
23
  const copyFiles = async (source, target) => {
13
24
  const files = await glob(path.join(source, '**'), {
@@ -67,7 +78,7 @@ const ensureAstroCollectionNotEmpty = async (astroDir) => {
67
78
  }
68
79
 
69
80
  // Hydrate empty collections
70
- const defaultCollectionFilesDir = path.join(scriptsDir, 'default-files-for-collections');
81
+ const defaultCollectionFilesDir = path.join(rootPkg, 'default-files-for-collections');
71
82
  for (const collection of emptyCollections) {
72
83
  const defaultFile = path.join(defaultCollectionFilesDir, `${collection}.md`);
73
84
  const targetDir = path.join(astroDir, 'src/content/', collection);
@@ -102,11 +113,3 @@ export const catalogToAstro = async (source, astroDir) => {
102
113
  // insert empty one that is filtered out
103
114
  await ensureAstroCollectionNotEmpty(astroDir);
104
115
  };
105
-
106
- if (process.env.NODE_ENV !== 'test') {
107
- // // Get the project directory of the source
108
- const source = process.env.PROJECT_DIR;
109
- const astroDir = process.env.CATALOG_DIR;
110
-
111
- catalogToAstro(source, astroDir);
112
- }
@@ -0,0 +1,3 @@
1
+ import { version } from '../package.json';
2
+
3
+ export const VERSION = version;
@@ -17,8 +17,7 @@ function getDefaultExport(importedModule) {
17
17
  return importedModule;
18
18
  }
19
19
 
20
- const generate = async () => {
21
- const PROJECT_DIRECTORY = process.env.PROJECT_DIR;
20
+ export const generate = async (PROJECT_DIRECTORY) => {
22
21
  try {
23
22
  const config = await getEventCatalogConfigFile(PROJECT_DIRECTORY);
24
23
 
@@ -64,5 +63,3 @@ const generate = async () => {
64
63
  await cleanup(PROJECT_DIRECTORY);
65
64
  }
66
65
  };
67
-
68
- generate();
@@ -1,18 +1,26 @@
1
1
  #!/usr/bin/env node
2
2
  import { join } from 'node:path';
3
3
  import { execSync } from 'node:child_process';
4
- const __dirname = import.meta.dirname;
5
4
 
6
- const args = process.argv.slice(2);
7
- const catalog = args[0] || 'default';
5
+ async function main() {
6
+ const __dirname = import.meta.dirname;
8
7
 
9
- const catalogDir = join(__dirname, '../');
10
- const projectDIR = join(__dirname, `../examples/${catalog}`);
8
+ const args = process.argv.slice(2);
9
+ const catalog = args[0] || 'default';
11
10
 
12
- execSync(
13
- `cross-env NODE_ENV=development PROJECT_DIR=${projectDIR} CATALOG_DIR=${catalogDir} npm run scripts:hydrate-content && cross-env PROJECT_DIR=${projectDIR} CATALOG_DIR=${catalogDir} npm run dev:local`,
14
- {
15
- cwd: catalogDir,
11
+ const catalogDir = join(__dirname, '../');
12
+ const projectDIR = join(__dirname, `../examples/${catalog}`);
13
+
14
+ execSync('npm run build:bin', { stdio: 'inherit' });
15
+
16
+ execSync(`cross-env NODE_ENV=development PROJECT_DIR=${projectDIR} CATALOG_DIR=${catalogDir} npx . dev`, {
16
17
  stdio: 'inherit',
17
- }
18
- );
18
+ });
19
+ }
20
+
21
+ main()
22
+ .then(() => process.exit(0))
23
+ .catch((err) => {
24
+ console.error(err);
25
+ process.exit(1);
26
+ });
@@ -1,6 +1,5 @@
1
1
  import watcher from '@parcel/watcher';
2
2
  import fs from 'node:fs';
3
- import path from 'node:path';
4
3
  import { mapCatalogToAstro } from './map-catalog-to-astro.js';
5
4
  import { rimrafSync } from 'rimraf';
6
5
  import { addPropertyToFrontMatter } from './eventcatalog-config-file-utils.js';
@@ -116,19 +115,3 @@ function retryEPERM(fn) {
116
115
  }
117
116
  };
118
117
  }
119
-
120
- /**
121
- * TODO: call `watch` from the dev command.
122
- * Calling `watch` there will avoid these if statement.
123
- * The same could be done to `catalog-to-astro-content-directory`
124
- */
125
- if (process.env.NODE_ENV !== 'test') {
126
- // Where the users project is located
127
- const projectDirectory = process.env.PROJECT_DIR || process.cwd();
128
- // Where the catalog code is located.
129
- const catalogDirectory = process.env.CATALOG_DIR || path.join(projectDirectory, '.eventcatalog-core');
130
-
131
- const unsub = await watch(projectDirectory, catalogDirectory);
132
-
133
- process.on('exit', () => unsub());
134
- }
@@ -11,6 +11,10 @@ import {
11
11
  import { findMatchingNodes, getItemsFromCollectionByIdAndSemverOrLatest } from '@utils/collections/util';
12
12
  import { MarkerType } from 'reactflow';
13
13
  import type { CollectionMessageTypes } from '@types';
14
+ import { getCommands } from '@utils/commands';
15
+ import { getEvents } from '@utils/events';
16
+ import { getQueries } from '@utils/queries';
17
+ import { getChannels } from '@utils/channels';
14
18
 
15
19
  type DagreGraph = any;
16
20
 
@@ -67,10 +71,10 @@ export const getNodesAndEdges = async ({ id, defaultFlow, version, mode = 'simpl
67
71
  const receivesRaw = service?.data.receives || [];
68
72
  const sendsRaw = service?.data.sends || [];
69
73
 
70
- const events = await getCollection('events');
71
- const commands = await getCollection('commands');
72
- const queries = await getCollection('queries');
73
- const channels = await getCollection('channels');
74
+ const events = await getEvents();
75
+ const commands = await getCommands();
76
+ const queries = await getQueries();
77
+ const channels = await getChannels();
74
78
 
75
79
  const messages = [...events, ...commands, ...queries];
76
80