@eventcatalog/core 2.14.3 → 2.16.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 (232) hide show
  1. package/README.md +2 -1
  2. package/bin/eventcatalog.js +2 -0
  3. package/default-files-for-collections/ubiquitousLanguages.md +7 -0
  4. package/dist/analytics/analytics.cjs +71 -0
  5. package/dist/analytics/analytics.d.cts +3 -0
  6. package/dist/analytics/analytics.d.ts +3 -0
  7. package/dist/analytics/analytics.js +7 -0
  8. package/dist/analytics/log-build.cjs +155 -0
  9. package/dist/analytics/log-build.d.cts +7 -0
  10. package/dist/analytics/log-build.d.ts +7 -0
  11. package/dist/analytics/log-build.js +9 -0
  12. package/dist/catalog-to-astro-content-directory.cjs +286 -0
  13. package/dist/catalog-to-astro-content-directory.d.cts +3 -0
  14. package/dist/catalog-to-astro-content-directory.d.ts +3 -0
  15. package/dist/catalog-to-astro-content-directory.js +8 -0
  16. package/dist/chunk-55YPRY5U.js +87 -0
  17. package/dist/chunk-5RNDOKYT.js +97 -0
  18. package/dist/chunk-6VJTKPOS.js +30 -0
  19. package/dist/chunk-BT6ILNB3.js +33 -0
  20. package/dist/chunk-DMGFALQN.js +9 -0
  21. package/dist/chunk-E7TXTI7G.js +78 -0
  22. package/{scripts/watcher.js → dist/chunk-NTCYOR4N.js} +29 -52
  23. package/dist/chunk-YEQVKHST.js +56 -0
  24. package/dist/constants.cjs +35 -0
  25. package/dist/constants.d.cts +3 -0
  26. package/dist/constants.d.ts +3 -0
  27. package/dist/constants.js +6 -0
  28. package/dist/eventcatalog-config-file-utils.cjs +116 -0
  29. package/dist/eventcatalog-config-file-utils.d.cts +7 -0
  30. package/dist/eventcatalog-config-file-utils.d.ts +7 -0
  31. package/dist/eventcatalog-config-file-utils.js +14 -0
  32. package/{bin/dist → dist}/eventcatalog.cjs +35 -36
  33. package/{bin/dist → dist}/eventcatalog.config.cjs +1 -1
  34. package/dist/eventcatalog.config.js +0 -0
  35. package/dist/eventcatalog.d.cts +2 -0
  36. package/dist/eventcatalog.d.ts +2 -0
  37. package/dist/eventcatalog.js +116 -0
  38. package/dist/generate.cjs +121 -0
  39. package/dist/generate.d.cts +3 -0
  40. package/dist/generate.d.ts +3 -0
  41. package/dist/generate.js +7 -0
  42. package/dist/map-catalog-to-astro.cjs +131 -0
  43. package/dist/map-catalog-to-astro.d.cts +28 -0
  44. package/dist/map-catalog-to-astro.d.ts +28 -0
  45. package/dist/map-catalog-to-astro.js +6 -0
  46. package/dist/watcher.cjs +231 -0
  47. package/dist/watcher.d.cts +21 -0
  48. package/dist/watcher.d.ts +21 -0
  49. package/dist/watcher.js +8 -0
  50. package/{src → eventcatalog/src}/components/MDX/NodeGraph/Edges/AnimatedMessageEdge.tsx +1 -1
  51. package/{src → eventcatalog/src}/components/MDX/NodeGraph/NodeGraph.tsx +28 -38
  52. package/{src → eventcatalog/src}/components/MDX/SchemaViewer/SchemaViewer.astro +6 -1
  53. package/{src → eventcatalog/src}/components/SideBars/CatalogResourcesSideBar/index.tsx +19 -1
  54. package/{src → eventcatalog/src}/components/SideBars/DomainSideBar.astro +23 -0
  55. package/eventcatalog/src/components/Tables/columns/ServiceTableColumns.tsx +196 -0
  56. package/{src → eventcatalog/src}/content/config.ts +18 -0
  57. package/eventcatalog/src/hooks/eventcatalog-visualizer.ts +89 -0
  58. package/eventcatalog/src/pages/docs/[type]/[id]/language.astro +301 -0
  59. package/{src → eventcatalog/src}/utils/collections/domains.ts +17 -2
  60. package/{src → eventcatalog/src}/utils/collections/icons.ts +3 -0
  61. package/{src → eventcatalog/src}/utils/node-graphs/message-node-graph.ts +2 -27
  62. package/{src → eventcatalog/src}/utils/node-graphs/utils/utils.ts +60 -3
  63. package/package.json +12 -3
  64. package/.all-contributorsrc +0 -436
  65. package/.changeset/config.json +0 -11
  66. package/.github/CODEOWNERS +0 -3
  67. package/.github/ISSUE_TEMPLATE/bug.yml +0 -84
  68. package/.github/ISSUE_TEMPLATE/config.yml +0 -5
  69. package/.github/ISSUE_TEMPLATE/feature.yml +0 -48
  70. package/.github/PULL_REQUEST_TEMPLATE.md +0 -14
  71. package/.github/funding.yml +0 -1
  72. package/.github/workflows/lint.yml +0 -22
  73. package/.github/workflows/release.yml +0 -34
  74. package/.github/workflows/test-bin.yml +0 -29
  75. package/.github/workflows/test-e2e.yml +0 -27
  76. package/.github/workflows/verify-build.yml +0 -28
  77. package/.prettierignore +0 -7
  78. package/.prettierrc +0 -18
  79. package/CHANGELOG.md +0 -1296
  80. package/bin/dist/eventcatalog.d.cts +0 -1
  81. package/bin/dist/eventcatalog.d.ts +0 -1
  82. package/bin/dist/eventcatalog.js +0 -531
  83. package/bin/eventcatalog.config.ts +0 -34
  84. package/images/example.png +0 -0
  85. package/images/sponsors/gravitee-logo-black.svg +0 -54
  86. package/images/sponsors/hookdeck.svg +0 -11
  87. package/images/sponsors/oso-logo-green.png +0 -0
  88. package/scripts/analytics/analytics.js +0 -31
  89. package/scripts/analytics/log-build.js +0 -26
  90. package/scripts/build-ci.js +0 -27
  91. package/scripts/catalog-to-astro-content-directory.js +0 -115
  92. package/scripts/ci/test.js +0 -24
  93. package/scripts/constants.ts +0 -3
  94. package/scripts/eventcatalog-config-file-utils.js +0 -89
  95. package/scripts/generate.js +0 -65
  96. package/scripts/map-catalog-to-astro.js +0 -174
  97. package/scripts/start-catalog-locally.js +0 -26
  98. package/src/components/Tables/columns/ServiceTableColumns.tsx +0 -164
  99. /package/{bin/dist → dist}/eventcatalog.config.d.cts +0 -0
  100. /package/{bin/dist → dist}/eventcatalog.config.d.ts +0 -0
  101. /package/{astro.config.mjs → eventcatalog/astro.config.mjs} +0 -0
  102. /package/{global.d.ts → eventcatalog/global.d.ts} +0 -0
  103. /package/{public → eventcatalog/public}/favicon.ico +0 -0
  104. /package/{public → eventcatalog/public}/icons/asyncapi.svg +0 -0
  105. /package/{public → eventcatalog/public}/icons/discord.svg +0 -0
  106. /package/{public → eventcatalog/public}/icons/github-purple.svg +0 -0
  107. /package/{public → eventcatalog/public}/icons/github.svg +0 -0
  108. /package/{public → eventcatalog/public}/icons/ms-teams.svg +0 -0
  109. /package/{public → eventcatalog/public}/icons/openapi.svg +0 -0
  110. /package/{public → eventcatalog/public}/icons/protocols/kafka.svg +0 -0
  111. /package/{public → eventcatalog/public}/icons/x-twitter.svg +0 -0
  112. /package/{public → eventcatalog/public}/icons/youtube.svg +0 -0
  113. /package/{public → eventcatalog/public}/logo.png +0 -0
  114. /package/{public → eventcatalog/public}/openapi.yml +0 -0
  115. /package/{public → eventcatalog/public}/opengraph.png +0 -0
  116. /package/{public → eventcatalog/public}/slack-icon.svg +0 -0
  117. /package/{src → eventcatalog/src}/components/DiscoverInsight.astro +0 -0
  118. /package/{src → eventcatalog/src}/components/DocsNavigation.astro +0 -0
  119. /package/{src → eventcatalog/src}/components/Header.astro +0 -0
  120. /package/{src → eventcatalog/src}/components/Lists/OwnersList.tsx +0 -0
  121. /package/{src → eventcatalog/src}/components/Lists/PillList.tsx +0 -0
  122. /package/{src → eventcatalog/src}/components/Lists/PillListFlat.styles.css +0 -0
  123. /package/{src → eventcatalog/src}/components/Lists/PillListFlat.tsx +0 -0
  124. /package/{src → eventcatalog/src}/components/Lists/ProtocolList.tsx +0 -0
  125. /package/{src → eventcatalog/src}/components/Lists/RepositoryList.astro +0 -0
  126. /package/{src → eventcatalog/src}/components/Lists/SpecificationsList.astro +0 -0
  127. /package/{src → eventcatalog/src}/components/Lists/VersionList.astro +0 -0
  128. /package/{src → eventcatalog/src}/components/MDX/Accordion/Accordion.astro +0 -0
  129. /package/{src → eventcatalog/src}/components/MDX/Accordion/Accordion.tsx +0 -0
  130. /package/{src → eventcatalog/src}/components/MDX/Accordion/AccordionGroup.astro +0 -0
  131. /package/{src → eventcatalog/src}/components/MDX/Admonition.tsx +0 -0
  132. /package/{src → eventcatalog/src}/components/MDX/AsyncAPI/AsyncAPI.astro +0 -0
  133. /package/{src → eventcatalog/src}/components/MDX/ChannelInformation/ChannelInformation.tsx +0 -0
  134. /package/{src → eventcatalog/src}/components/MDX/File.tsx +0 -0
  135. /package/{src → eventcatalog/src}/components/MDX/Flow/Flow.astro +0 -0
  136. /package/{src → eventcatalog/src}/components/MDX/NodeGraph/DownloadButton.tsx +0 -0
  137. /package/{src → eventcatalog/src}/components/MDX/NodeGraph/NodeGraph.astro +0 -0
  138. /package/{src → eventcatalog/src}/components/MDX/NodeGraph/NodeGraphPortal.tsx +0 -0
  139. /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Channel.tsx +0 -0
  140. /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Command.tsx +0 -0
  141. /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Event.tsx +0 -0
  142. /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/ExternalSystem.tsx +0 -0
  143. /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Query.tsx +0 -0
  144. /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Service.tsx +0 -0
  145. /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Step.tsx +0 -0
  146. /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/User.tsx +0 -0
  147. /package/{src → eventcatalog/src}/components/MDX/OpenAPI/OpenAPI.astro +0 -0
  148. /package/{src → eventcatalog/src}/components/MDX/Schema.astro +0 -0
  149. /package/{src → eventcatalog/src}/components/MDX/SchemaViewer/SchemaViewer.tsx +0 -0
  150. /package/{src → eventcatalog/src}/components/MDX/SchemaViewer/SchemaViewerPortal.tsx +0 -0
  151. /package/{src → eventcatalog/src}/components/MDX/Steps/Step.astro +0 -0
  152. /package/{src → eventcatalog/src}/components/MDX/Steps/Steps.astro +0 -0
  153. /package/{src → eventcatalog/src}/components/MDX/Tiles/Tile.astro +0 -0
  154. /package/{src → eventcatalog/src}/components/MDX/Tiles/Tiles.astro +0 -0
  155. /package/{src → eventcatalog/src}/components/MDX/components.tsx +0 -0
  156. /package/{src → eventcatalog/src}/components/MDX/page-components.tsx +0 -0
  157. /package/{src → eventcatalog/src}/components/Search.astro +0 -0
  158. /package/{src → eventcatalog/src}/components/Seo.astro +0 -0
  159. /package/{src → eventcatalog/src}/components/SideBars/CatalogResourcesSideBar/styles.css +0 -0
  160. /package/{src → eventcatalog/src}/components/SideBars/ChannelSideBar.astro +0 -0
  161. /package/{src → eventcatalog/src}/components/SideBars/MessageSideBar.astro +0 -0
  162. /package/{src → eventcatalog/src}/components/SideBars/ServiceSideBar.astro +0 -0
  163. /package/{src → eventcatalog/src}/components/Tables/DebouncedInput.tsx +0 -0
  164. /package/{src → eventcatalog/src}/components/Tables/Table.tsx +0 -0
  165. /package/{src → eventcatalog/src}/components/Tables/columns/DomainTableColumns.tsx +0 -0
  166. /package/{src → eventcatalog/src}/components/Tables/columns/FlowTableColumns.tsx +0 -0
  167. /package/{src → eventcatalog/src}/components/Tables/columns/MessageTableColumns.tsx +0 -0
  168. /package/{src → eventcatalog/src}/components/Tables/columns/index.tsx +0 -0
  169. /package/{src → eventcatalog/src}/components/Tables/filters/custom-filters.ts +0 -0
  170. /package/{src → eventcatalog/src}/env.d.ts +0 -0
  171. /package/{src → eventcatalog/src}/icons/protocols/WebSocket.svg +0 -0
  172. /package/{src → eventcatalog/src}/icons/protocols/amqp.svg +0 -0
  173. /package/{src → eventcatalog/src}/icons/protocols/eventbridge.svg +0 -0
  174. /package/{src → eventcatalog/src}/icons/protocols/googlepubsub.svg +0 -0
  175. /package/{src → eventcatalog/src}/icons/protocols/http.svg +0 -0
  176. /package/{src → eventcatalog/src}/icons/protocols/index.ts +0 -0
  177. /package/{src → eventcatalog/src}/icons/protocols/jms.svg +0 -0
  178. /package/{src → eventcatalog/src}/icons/protocols/kafka.svg +0 -0
  179. /package/{src → eventcatalog/src}/icons/protocols/mercure.svg +0 -0
  180. /package/{src → eventcatalog/src}/icons/protocols/mqtt.svg +0 -0
  181. /package/{src → eventcatalog/src}/icons/protocols/nats.svg +0 -0
  182. /package/{src → eventcatalog/src}/icons/protocols/pulsar.svg +0 -0
  183. /package/{src → eventcatalog/src}/icons/protocols/redis.svg +0 -0
  184. /package/{src → eventcatalog/src}/icons/protocols/sns.svg +0 -0
  185. /package/{src → eventcatalog/src}/icons/protocols/solace.svg +0 -0
  186. /package/{src → eventcatalog/src}/icons/protocols/sqs.svg +0 -0
  187. /package/{src → eventcatalog/src}/icons/protocols/ws.svg +0 -0
  188. /package/{src → eventcatalog/src}/layouts/CustomDocsPageLayout.astro +0 -0
  189. /package/{src → eventcatalog/src}/layouts/DiscoverLayout.astro +0 -0
  190. /package/{src → eventcatalog/src}/layouts/Footer.astro +0 -0
  191. /package/{src → eventcatalog/src}/layouts/PlainPage.astro +0 -0
  192. /package/{src → eventcatalog/src}/layouts/VerticalSideBarLayout.astro +0 -0
  193. /package/{src → eventcatalog/src}/layouts/VisualiserLayout.astro +0 -0
  194. /package/{src → eventcatalog/src}/pages/discover/[type]/index.astro +0 -0
  195. /package/{src → eventcatalog/src}/pages/docs/[type]/[id]/[version]/asyncapi/index.astro +0 -0
  196. /package/{src → eventcatalog/src}/pages/docs/[type]/[id]/[version]/changelog/index.astro +0 -0
  197. /package/{src → eventcatalog/src}/pages/docs/[type]/[id]/[version]/index.astro +0 -0
  198. /package/{src → eventcatalog/src}/pages/docs/[type]/[id]/[version]/spec/_styles.css +0 -0
  199. /package/{src → eventcatalog/src}/pages/docs/[type]/[id]/[version]/spec/index.astro +0 -0
  200. /package/{src → eventcatalog/src}/pages/docs/[type]/[id]/index.astro +0 -0
  201. /package/{src → eventcatalog/src}/pages/docs/index.astro +0 -0
  202. /package/{src → eventcatalog/src}/pages/docs/teams/[id]/index.astro +0 -0
  203. /package/{src → eventcatalog/src}/pages/docs/users/[id]/index.astro +0 -0
  204. /package/{src → eventcatalog/src}/pages/index.astro +0 -0
  205. /package/{src → eventcatalog/src}/pages/visualiser/[type]/[id]/[version]/index.astro +0 -0
  206. /package/{src → eventcatalog/src}/pages/visualiser/[type]/[id]/index.astro +0 -0
  207. /package/{src → eventcatalog/src}/remark-plugins/mermaid.ts +0 -0
  208. /package/{src → eventcatalog/src}/types/index.ts +0 -0
  209. /package/{src → eventcatalog/src}/utils/channels.ts +0 -0
  210. /package/{src → eventcatalog/src}/utils/collections/changelogs.ts +0 -0
  211. /package/{src → eventcatalog/src}/utils/collections/file-diffs.ts +0 -0
  212. /package/{src → eventcatalog/src}/utils/collections/flows.ts +0 -0
  213. /package/{src → eventcatalog/src}/utils/collections/services.ts +0 -0
  214. /package/{src → eventcatalog/src}/utils/collections/util.ts +0 -0
  215. /package/{src → eventcatalog/src}/utils/collections/versions.ts +0 -0
  216. /package/{src → eventcatalog/src}/utils/colors.ts +0 -0
  217. /package/{src → eventcatalog/src}/utils/commands.ts +0 -0
  218. /package/{src → eventcatalog/src}/utils/eventcatalog-config/catalog.ts +0 -0
  219. /package/{src → eventcatalog/src}/utils/events.ts +0 -0
  220. /package/{src → eventcatalog/src}/utils/example-remark-plugin.mjs +0 -0
  221. /package/{src → eventcatalog/src}/utils/messages.ts +0 -0
  222. /package/{src → eventcatalog/src}/utils/node-graphs/domains-node-graph.ts +0 -0
  223. /package/{src → eventcatalog/src}/utils/node-graphs/flows-node-graph.ts +0 -0
  224. /package/{src → eventcatalog/src}/utils/node-graphs/services-node-graph.ts +0 -0
  225. /package/{src → eventcatalog/src}/utils/page-loaders/page-data-loader.ts +0 -0
  226. /package/{src → eventcatalog/src}/utils/pages.ts +0 -0
  227. /package/{src → eventcatalog/src}/utils/queries.ts +0 -0
  228. /package/{src → eventcatalog/src}/utils/teams.ts +0 -0
  229. /package/{src → eventcatalog/src}/utils/url-builder.ts +0 -0
  230. /package/{src → eventcatalog/src}/utils/users.ts +0 -0
  231. /package/{tailwind.config.mjs → eventcatalog/tailwind.config.mjs} +0 -0
  232. /package/{tsconfig.json → eventcatalog/tsconfig.json} +0 -0
@@ -1,26 +0,0 @@
1
- import { getEventCatalogConfigFile, verifyRequiredFieldsAreInCatalogConfigFile } from '../eventcatalog-config-file-utils.js';
2
- import { raiseEvent } from './analytics.js';
3
-
4
- /**
5
- *
6
- * @param {string} projectDir
7
- */
8
- const main = async (projectDir) => {
9
- if (process.env.NODE_ENV === 'CI') return;
10
- try {
11
- await verifyRequiredFieldsAreInCatalogConfigFile(projectDir);
12
- const configFile = await getEventCatalogConfigFile(projectDir);
13
- const { cId, organizationName, generators = [] } = configFile;
14
- const generatorNames = generators.length > 0 ? generators.map((generator) => generator[0]) : ['none'];
15
- await raiseEvent({
16
- command: 'build',
17
- org: organizationName,
18
- cId,
19
- generators: generatorNames.toString(),
20
- });
21
- } catch (error) {
22
- // Just swallow the error
23
- }
24
- };
25
-
26
- export default main;
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // This is used for CI on vercel. Must copy files before building.
4
- import { join } from 'node:path';
5
- import { execSync } from 'node:child_process';
6
- const __dirname = import.meta.dirname;
7
-
8
- const args = process.argv.slice(2);
9
- const catalog = args[0] || 'default';
10
-
11
- const catalogDir = join(__dirname, '../');
12
- const projectDIR = join(__dirname, `../examples/${catalog}`);
13
-
14
- // Build cli
15
- execSync('npm run build:bin', { stdio: 'inherit' });
16
-
17
- // Build catalog
18
- execSync(`cross-env NODE_ENV=CI PROJECT_DIR=${projectDIR} CATALOG_DIR=${catalogDir} npx . build`, {
19
- cwd: catalogDir,
20
- stdio: 'inherit',
21
- });
22
-
23
- // Type check
24
- execSync('npx astro check --minimumSeverity error', {
25
- cwd: catalogDir,
26
- stdio: 'inherit',
27
- });
@@ -1,115 +0,0 @@
1
- import { glob } from 'glob';
2
- import * as path from 'node:path';
3
- import fs from 'fs';
4
- import { fileURLToPath } from 'url';
5
- import os from 'node:os';
6
- import { verifyRequiredFieldsAreInCatalogConfigFile, addPropertyToFrontMatter } from './eventcatalog-config-file-utils.js';
7
- import { mapCatalogToAstro } from './map-catalog-to-astro.js';
8
-
9
- const __filename = fileURLToPath(import.meta.url);
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
- );
22
-
23
- const copyFiles = async (source, target) => {
24
- const files = await glob(path.join(source, '**'), {
25
- nodir: true,
26
- windowsPathsNoEscape: os.platform() == 'win32',
27
- });
28
-
29
- for (const file of files) {
30
- mapCatalogToAstro({
31
- filePath: file,
32
- astroDir: target,
33
- projectDir: source,
34
- })
35
- .map((astroPath) => {
36
- fs.cpSync(file, astroPath);
37
- return { oldPath: file, newPath: astroPath };
38
- })
39
- .map(({ oldPath, newPath }) => {
40
- if (!oldPath.endsWith('.md') && !oldPath.endsWith('.mdx')) return;
41
- try {
42
- // EventCatalog requires the original path to be in the frontmatter for Schemas and Changelogs
43
- const content = fs.readFileSync(newPath, 'utf-8');
44
- const frontmatter = addPropertyToFrontMatter(content, 'pathToFile', oldPath);
45
- fs.writeFileSync(newPath, frontmatter);
46
- } catch (error) {
47
- // silent fail
48
- }
49
- });
50
- }
51
- };
52
-
53
- const ensureAstroCollectionNotEmpty = async (astroDir) => {
54
- // TODO: maybe import collections from `src/content/config.ts`...
55
- const COLLECTIONS = [
56
- 'events',
57
- 'commands',
58
- 'services',
59
- 'users',
60
- 'teams',
61
- 'domains',
62
- 'flows',
63
- 'pages',
64
- 'changelogs',
65
- 'queries',
66
- 'channels',
67
- ];
68
-
69
- // Check empty collections
70
- const emptyCollections = [];
71
- for (const collection of COLLECTIONS) {
72
- const markdownFiles = await glob(path.join(astroDir, 'src/content/', collection, '**'), {
73
- nodir: true,
74
- windowsPathsNoEscape: os.platform() == 'win32',
75
- });
76
-
77
- if (markdownFiles.length === 0) emptyCollections.push(collection);
78
- }
79
-
80
- // Hydrate empty collections
81
- const defaultCollectionFilesDir = path.join(rootPkg, 'default-files-for-collections');
82
- for (const collection of emptyCollections) {
83
- const defaultFile = path.join(defaultCollectionFilesDir, `${collection}.md`);
84
- const targetDir = path.join(astroDir, 'src/content/', collection);
85
- if (!fs.existsSync(targetDir)) {
86
- fs.mkdirSync(targetDir, { recursive: true });
87
- }
88
- fs.cpSync(defaultFile, path.join(targetDir, `${collection}.md`));
89
- }
90
- };
91
-
92
- export const catalogToAstro = async (source, astroDir) => {
93
- const astroContentDir = path.join(astroDir, 'src/content/');
94
-
95
- // Config file
96
- const astroConfigFile = fs.readFileSync(path.join(astroContentDir, 'config.ts'));
97
-
98
- // Clear the astro directory before we copy files over
99
- fs.rmSync(astroContentDir, { recursive: true });
100
-
101
- // Create the folder again
102
- fs.mkdirSync(astroContentDir);
103
-
104
- // Write config file back
105
- fs.writeFileSync(path.join(astroContentDir, 'config.ts'), astroConfigFile);
106
-
107
- // Verify required fields are in the catalog config file
108
- await verifyRequiredFieldsAreInCatalogConfigFile(source);
109
-
110
- await copyFiles(source, astroDir);
111
-
112
- // Check if the directory is empty. EC (astro collections) requires at least 1 item in the collection
113
- // insert empty one that is filtered out
114
- await ensureAstroCollectionNotEmpty(astroDir);
115
- };
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Script for GitHub Actions
5
- * Sets up the project with required files
6
- */
7
-
8
- import { join } from 'node:path';
9
- import fs from 'fs';
10
- import { execSync } from 'node:child_process';
11
-
12
- const args = process.argv.slice(2);
13
- const catalog = args[0] || 'default';
14
-
15
- const catalogDir = join(process.cwd());
16
- const projectDIR = join(process.cwd(), `/examples/${catalog}`);
17
-
18
- fs.copyFileSync(join(projectDIR, 'eventcatalog.config.js'), join(catalogDir, 'eventcatalog.config.js'));
19
- fs.copyFileSync(join(projectDIR, 'eventcatalog.styles.css'), join(catalogDir, 'eventcatalog.styles.css'));
20
-
21
- execSync(`cross-env NODE_ENV=test PROJECT_DIR=${projectDIR} CATALOG_DIR=${catalogDir} npm run test`, {
22
- cwd: catalogDir,
23
- stdio: 'inherit',
24
- });
@@ -1,3 +0,0 @@
1
- import { version } from '../package.json';
2
-
3
- export const VERSION = version;
@@ -1,89 +0,0 @@
1
- import { readFile, writeFile, rm } from 'node:fs/promises';
2
- import { existsSync } from 'node:fs';
3
- import { copyFile } from 'node:fs/promises';
4
- import path from 'node:path';
5
- import { v4 as uuidV4 } from 'uuid';
6
- import { pathToFileURL } from 'url';
7
- import matter from 'gray-matter';
8
-
9
- export async function cleanup(projectDirectory) {
10
- const filePath = path.join(projectDirectory, 'eventcatalog.config.mjs');
11
- if (existsSync(filePath)) {
12
- await rm(filePath);
13
- }
14
- }
15
-
16
- export const getEventCatalogConfigFile = async (projectDirectory) => {
17
- try {
18
- let configFilePath = path.join(projectDirectory, 'eventcatalog.config.js');
19
-
20
- const filePath = path.join(projectDirectory, 'package.json');
21
- const packageJson = JSON.parse(await readFile(filePath, 'utf-8'));
22
-
23
- if (packageJson?.type !== 'module') {
24
- await copyFile(configFilePath, path.join(projectDirectory, 'eventcatalog.config.mjs'));
25
- configFilePath = path.join(projectDirectory, 'eventcatalog.config.mjs');
26
- }
27
-
28
- const configFileURL = pathToFileURL(configFilePath).href;
29
- const config = await import(/* @vite-ignore */ configFileURL);
30
-
31
- return config.default;
32
- } finally {
33
- await cleanup(projectDirectory);
34
- }
35
- };
36
-
37
- export const writeEventCatalogConfigFile = async (projectDirectory, newConfig) => {
38
- try {
39
- const configFilePath = path.join(projectDirectory, 'eventcatalog.config.js');
40
- let content = await readFile(configFilePath, 'utf8');
41
-
42
- // Find the start of the config object
43
- const startIndex = content.indexOf('export default {');
44
- if (startIndex === -1) {
45
- // Just fail silently if the config object is not found
46
- return;
47
- }
48
-
49
- // Update or add each new config item
50
- Object.entries(newConfig).forEach(([key, value]) => {
51
- const valueString = JSON.stringify(value, null, 2).replace(/"/g, "'").replace(/\n/g, '\n ');
52
-
53
- // Check if the key already exists
54
- const keyRegex = new RegExp(`(${key}\\s*:)([^,}]+)`, 'g');
55
- if (content.match(keyRegex)) {
56
- // Update existing key
57
- content = content.replace(keyRegex, `$1 ${valueString}`);
58
- } else {
59
- // Add new key-value pair
60
- const insertPosition = content.indexOf('{', startIndex) + 1;
61
- content = content.slice(0, insertPosition) + `\n ${key}: ${valueString},` + content.slice(insertPosition);
62
- }
63
- });
64
-
65
- // Write the updated content back to the file
66
- await writeFile(configFilePath, content);
67
- } finally {
68
- await cleanup(projectDirectory);
69
- }
70
- };
71
-
72
- // Check the eventcatalog.config.js and add any missing required fields on it
73
- export const verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
74
- try {
75
- const config = await getEventCatalogConfigFile(projectDirectory);
76
-
77
- if (!config.cId) {
78
- await writeEventCatalogConfigFile(projectDirectory, { cId: uuidV4() });
79
- }
80
- } catch (error) {
81
- // fail silently, it's overly important
82
- }
83
- };
84
-
85
- export function addPropertyToFrontMatter(input, newProperty, newValue) {
86
- const file = matter(input);
87
-
88
- return matter.stringify(file.content, { ...file.data, [newProperty]: newValue });
89
- }
@@ -1,65 +0,0 @@
1
- import path from 'node:path';
2
- import { getEventCatalogConfigFile, cleanup } from './eventcatalog-config-file-utils.js';
3
-
4
- function getDefaultExport(importedModule) {
5
- if (importedModule === null || typeof importedModule !== 'object') {
6
- throw new Error('Invalid module');
7
- }
8
-
9
- if (typeof importedModule.default === 'object' && importedModule.default !== null) {
10
- return importedModule.default.default || importedModule.default;
11
- }
12
-
13
- if (typeof importedModule.default !== 'undefined') {
14
- return importedModule.default;
15
- }
16
-
17
- return importedModule;
18
- }
19
-
20
- export const generate = async (PROJECT_DIRECTORY) => {
21
- try {
22
- const config = await getEventCatalogConfigFile(PROJECT_DIRECTORY);
23
-
24
- const { generators = [] } = config;
25
-
26
- if (!generators.length) {
27
- console.log('No configured generators found, skipping generation');
28
- return;
29
- }
30
-
31
- for (const generator of generators) {
32
- let plugin = generator[0];
33
- const pluginConfig = generator[1];
34
-
35
- if (plugin.startsWith('./')) {
36
- plugin = path.join(PROJECT_DIRECTORY, plugin);
37
- }
38
-
39
- if (plugin.includes('<rootDir>')) {
40
- plugin = plugin.replace('<rootDir>', PROJECT_DIRECTORY);
41
- }
42
-
43
- try {
44
- const importedGenerator = await import(plugin);
45
-
46
- // TODO: Fix this...
47
- const generator = getDefaultExport(importedGenerator);
48
-
49
- await generator({ eventCatalogConfig: {} }, pluginConfig);
50
-
51
- // Use importedGenerator here
52
- } catch (error) {
53
- console.error('Error loading plugin:', error);
54
- await cleanup(PROJECT_DIRECTORY);
55
- return;
56
- }
57
- }
58
-
59
- await cleanup(PROJECT_DIRECTORY);
60
- } catch (error) {
61
- // Failed to generate clean up...
62
- console.error(error);
63
- await cleanup(PROJECT_DIRECTORY);
64
- }
65
- };
@@ -1,174 +0,0 @@
1
- import path from 'node:path';
2
-
3
- const COLLECTION_KEYS = [
4
- 'events',
5
- 'commands',
6
- 'services',
7
- 'users',
8
- 'teams',
9
- 'domains',
10
- 'flows',
11
- 'pages',
12
- 'changelogs',
13
- 'queries',
14
- 'channels',
15
- ];
16
-
17
- /**
18
- * @typedef {Object} MapCatalogToAstroParams
19
- * @prop {string} filePath The catalog file path
20
- * @prop {string} astroDir The astro directory
21
- * @prop {string} projectDir The user's project directory
22
- */
23
-
24
- /**
25
- *
26
- * @param {MapCatalogToAstroParams} params
27
- * @returns {string[]} The astro file paths
28
- */
29
- export function mapCatalogToAstro({ filePath, astroDir, projectDir }) {
30
- const relativeFilePath = removeBasePath(filePath, projectDir);
31
-
32
- if (!isCatalogRelated(relativeFilePath)) {
33
- return [];
34
- }
35
-
36
- const baseTargetPaths = getBaseTargetPaths(relativeFilePath);
37
- const relativeTargetPath = getRelativeTargetPath(relativeFilePath);
38
-
39
- return baseTargetPaths.map((base) =>
40
- path.join(astroDir, base, relativeTargetPath.replace('index.md', 'index.mdx').replace('changelog.md', 'changelog.mdx'))
41
- );
42
- }
43
-
44
- /**
45
- *
46
- * @param {string} fullPath
47
- * @param {string} basePath
48
- * @returns {string} The fullPath without the basePath
49
- */
50
- function removeBasePath(fullPath, basePath) {
51
- const relativePath = path.relative(basePath, fullPath);
52
- return relativePath.startsWith('..') ? fullPath : relativePath;
53
- }
54
-
55
- /**
56
- * Check if the key is an ASTRO COLLECTION KEY
57
- * @param {string} key
58
- * @returns {boolean}
59
- */
60
- function isCollectionKey(key) {
61
- return COLLECTION_KEYS.includes(key);
62
- }
63
-
64
- /**
65
- * Checks whether the given path is a configuration file, styles file, public asset file or collection file.
66
- * @param {string} filePath - The file path without the projectDir prefix.
67
- * @returns {boolean}
68
- */
69
- function isCatalogRelated(filePath) {
70
- const filePathArr = filePath.split(path.sep).filter(Boolean);
71
-
72
- if (
73
- [
74
- 'eventcatalog.config.js', // config file at root
75
- 'eventcatalog.styles.css', // custom styles file at root
76
- 'components', // custom components
77
- 'public', // public assets
78
- ...COLLECTION_KEYS,
79
- ].includes(filePathArr[0])
80
- ) {
81
- return true;
82
- }
83
-
84
- return false;
85
- }
86
-
87
- /**
88
- * Generates the base target path accordingly to the file path.
89
- * @param {string} filePath The path to the file without PROJECT_DIR prefix.
90
- * @returns {Array.<'src/content'|'public/generated'|'src/catalog-files'|'/'>} The base target path.
91
- */
92
- function getBaseTargetPaths(filePath) {
93
- const filePathArr = filePath.split(path.sep).filter(Boolean);
94
-
95
- // Collection
96
- if (isCollectionKey(filePathArr[0])) {
97
- // Changelogs files
98
- if (filePathArr[filePathArr.length - 1] == 'changelog.md') {
99
- return [path.join('src', 'content', 'changelogs')];
100
- }
101
-
102
- // Markdown files
103
- if (filePathArr[filePathArr.length - 1].match(/\.md$/)) {
104
- return [path.join('src', 'content')];
105
- }
106
-
107
- // This is a workaround to differentiate between a file and a directory.
108
- // Of course this is not the best solution. But how differentiate? `fs.stats`
109
- // could be used, but sometimes the filePath references a deleted file/directory
110
- // which causes an error when using `fs.stats`.
111
- const hasExtension = (str) => /\.[a-zA-Z0-9]{2,}$/.test(str);
112
-
113
- // Assets files
114
- if (hasExtension(filePath)) {
115
- return [path.join('public', 'generated'), path.join('src', 'catalog-files')];
116
- }
117
-
118
- /**
119
- * @parcel/watcher throttle and coalesce events for performance reasons.
120
- *
121
- * Consider the following:
122
- * The user deletes a large `services/` dir from eventcatalog.
123
- * The @parcel/watcher could emit only one delete event of the
124
- * `services/` directory.
125
- *
126
- * In this situation we need delete all files from
127
- * - `public/generated/services/`
128
- * - `src/catalog-files/services/`
129
- * - `src/content/services/`
130
- *
131
- * TODO: What happens if services contains commands/events inside of it??? How handle this?
132
- */
133
- // Directories
134
- return [path.join('public', 'generated'), path.join('src', 'catalog-files'), path.join('src', 'content')];
135
- }
136
-
137
- // Custom components
138
- if (filePathArr[0] == 'components') {
139
- return [path.join('src', 'custom-defined-components')];
140
- }
141
-
142
- // Public assets (public/*)
143
- if (filePathArr[0] == 'public') {
144
- return [path.join('public')];
145
- }
146
-
147
- /**
148
- * Config files:
149
- * - eventcatalog.config.js
150
- * - eventcatalog.styles.css
151
- */
152
- return [path.join('/')];
153
- }
154
-
155
- /**
156
- * Generates the path until the ASTRO_COLLECTION_KEY or the PROJECT_DIR root.
157
- * @param {string} filePath The path to the file.
158
- * @returns {string} The path until the COLLECTION_KEY or PROJECT_DIR root.
159
- */
160
- function getRelativeTargetPath(filePath) {
161
- const filePathArr = filePath.split(path.sep).filter(Boolean);
162
-
163
- if (filePathArr[0] == 'public' || filePathArr[0] == 'components') {
164
- filePathArr.shift();
165
- }
166
-
167
- const relativePath = [];
168
- for (let i = filePathArr.length - 1; i >= 0; i--) {
169
- relativePath.unshift(filePathArr[i]);
170
- if (isCollectionKey(filePathArr[i])) break;
171
- }
172
-
173
- return path.join(...relativePath);
174
- }
@@ -1,26 +0,0 @@
1
- #!/usr/bin/env node
2
- import { join } from 'node:path';
3
- import { execSync } from 'node:child_process';
4
-
5
- async function main() {
6
- const __dirname = import.meta.dirname;
7
-
8
- const args = process.argv.slice(2);
9
- const catalog = args[0] || 'default';
10
-
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`, {
17
- stdio: 'inherit',
18
- });
19
- }
20
-
21
- main()
22
- .then(() => process.exit(0))
23
- .catch((err) => {
24
- console.error(err);
25
- process.exit(1);
26
- });