@eventcatalog/core 2.14.2 → 2.15.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.
- package/README.md +4 -3
- package/bin/eventcatalog.js +2 -0
- package/dist/analytics/analytics.cjs +71 -0
- package/dist/analytics/analytics.d.cts +3 -0
- package/dist/analytics/analytics.d.ts +3 -0
- package/dist/analytics/analytics.js +7 -0
- package/dist/analytics/log-build.cjs +155 -0
- package/dist/analytics/log-build.d.cts +7 -0
- package/dist/analytics/log-build.d.ts +7 -0
- package/dist/analytics/log-build.js +9 -0
- package/dist/catalog-to-astro-content-directory.cjs +277 -0
- package/dist/catalog-to-astro-content-directory.d.cts +3 -0
- package/dist/catalog-to-astro-content-directory.d.ts +3 -0
- package/dist/catalog-to-astro-content-directory.js +8 -0
- package/dist/chunk-65VQIGAP.js +33 -0
- package/{scripts/watcher.js → dist/chunk-7HYM3M5I.js} +29 -52
- package/dist/chunk-E7TXTI7G.js +78 -0
- package/dist/chunk-KI4KAUWW.js +30 -0
- package/dist/chunk-O6BGVVOW.js +86 -0
- package/dist/chunk-PK2EQVPD.js +89 -0
- package/dist/chunk-TGOUSS6C.js +9 -0
- package/dist/chunk-YEQVKHST.js +56 -0
- package/dist/constants.cjs +35 -0
- package/dist/constants.d.cts +3 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.js +6 -0
- package/dist/eventcatalog-config-file-utils.cjs +116 -0
- package/dist/eventcatalog-config-file-utils.d.cts +7 -0
- package/dist/eventcatalog-config-file-utils.d.ts +7 -0
- package/dist/eventcatalog-config-file-utils.js +14 -0
- package/{bin/dist → dist}/eventcatalog.cjs +23 -33
- package/{bin/dist → dist}/eventcatalog.config.cjs +1 -1
- package/dist/eventcatalog.config.js +0 -0
- package/dist/eventcatalog.d.cts +2 -0
- package/dist/eventcatalog.d.ts +2 -0
- package/dist/eventcatalog.js +116 -0
- package/dist/generate.cjs +121 -0
- package/dist/generate.d.cts +3 -0
- package/dist/generate.d.ts +3 -0
- package/dist/generate.js +7 -0
- package/dist/map-catalog-to-astro.cjs +123 -0
- package/dist/map-catalog-to-astro.d.cts +28 -0
- package/dist/map-catalog-to-astro.d.ts +28 -0
- package/dist/map-catalog-to-astro.js +6 -0
- package/dist/watcher.cjs +223 -0
- package/dist/watcher.d.cts +21 -0
- package/dist/watcher.d.ts +21 -0
- package/dist/watcher.js +8 -0
- package/eventcatalog/public/icons/ms-teams.svg +2 -0
- package/{src → eventcatalog/src}/components/MDX/NodeGraph/NodeGraph.tsx +27 -38
- package/{src → eventcatalog/src}/content/config.ts +2 -0
- package/eventcatalog/src/hooks/eventcatalog-visualizer.ts +89 -0
- package/{src → eventcatalog/src}/pages/docs/[type]/[id]/[version]/asyncapi/index.astro +2 -1
- package/{src → eventcatalog/src}/pages/docs/teams/[id]/index.astro +10 -0
- package/{src → eventcatalog/src}/pages/docs/users/[id]/index.astro +10 -0
- package/{src → eventcatalog/src}/utils/node-graphs/message-node-graph.ts +2 -27
- package/{src → eventcatalog/src}/utils/node-graphs/utils/utils.ts +60 -3
- package/package.json +11 -3
- package/.all-contributorsrc +0 -436
- package/.changeset/config.json +0 -11
- package/.github/CODEOWNERS +0 -3
- package/.github/ISSUE_TEMPLATE/bug.yml +0 -84
- package/.github/ISSUE_TEMPLATE/config.yml +0 -5
- package/.github/ISSUE_TEMPLATE/feature.yml +0 -48
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -14
- package/.github/funding.yml +0 -1
- package/.github/workflows/lint.yml +0 -22
- package/.github/workflows/release.yml +0 -34
- package/.github/workflows/test-bin.yml +0 -29
- package/.github/workflows/test-e2e.yml +0 -27
- package/.github/workflows/verify-build.yml +0 -28
- package/.prettierignore +0 -7
- package/.prettierrc +0 -18
- package/CHANGELOG.md +0 -1289
- package/bin/dist/eventcatalog.d.cts +0 -1
- package/bin/dist/eventcatalog.d.ts +0 -1
- package/bin/dist/eventcatalog.js +0 -531
- package/bin/eventcatalog.config.ts +0 -34
- package/images/example.png +0 -0
- package/images/sponsors/gravitee-logo-black.svg +0 -54
- package/images/sponsors/hookdeck.svg +0 -11
- package/images/sponsors/oso-logo-green.png +0 -0
- package/scripts/analytics/analytics.js +0 -31
- package/scripts/analytics/log-build.js +0 -26
- package/scripts/build-ci.js +0 -27
- package/scripts/catalog-to-astro-content-directory.js +0 -115
- package/scripts/ci/test.js +0 -24
- package/scripts/constants.ts +0 -3
- package/scripts/eventcatalog-config-file-utils.js +0 -89
- package/scripts/generate.js +0 -65
- package/scripts/map-catalog-to-astro.js +0 -174
- package/scripts/start-catalog-locally.js +0 -26
- /package/{bin/dist → dist}/eventcatalog.config.d.cts +0 -0
- /package/{bin/dist → dist}/eventcatalog.config.d.ts +0 -0
- /package/{astro.config.mjs → eventcatalog/astro.config.mjs} +0 -0
- /package/{global.d.ts → eventcatalog/global.d.ts} +0 -0
- /package/{public → eventcatalog/public}/favicon.ico +0 -0
- /package/{public → eventcatalog/public}/icons/asyncapi.svg +0 -0
- /package/{public → eventcatalog/public}/icons/discord.svg +0 -0
- /package/{public → eventcatalog/public}/icons/github-purple.svg +0 -0
- /package/{public → eventcatalog/public}/icons/github.svg +0 -0
- /package/{public → eventcatalog/public}/icons/openapi.svg +0 -0
- /package/{public → eventcatalog/public}/icons/protocols/kafka.svg +0 -0
- /package/{public → eventcatalog/public}/icons/x-twitter.svg +0 -0
- /package/{public → eventcatalog/public}/icons/youtube.svg +0 -0
- /package/{public → eventcatalog/public}/logo.png +0 -0
- /package/{public → eventcatalog/public}/openapi.yml +0 -0
- /package/{public → eventcatalog/public}/opengraph.png +0 -0
- /package/{public → eventcatalog/public}/slack-icon.svg +0 -0
- /package/{src → eventcatalog/src}/components/DiscoverInsight.astro +0 -0
- /package/{src → eventcatalog/src}/components/DocsNavigation.astro +0 -0
- /package/{src → eventcatalog/src}/components/Header.astro +0 -0
- /package/{src → eventcatalog/src}/components/Lists/OwnersList.tsx +0 -0
- /package/{src → eventcatalog/src}/components/Lists/PillList.tsx +0 -0
- /package/{src → eventcatalog/src}/components/Lists/PillListFlat.styles.css +0 -0
- /package/{src → eventcatalog/src}/components/Lists/PillListFlat.tsx +0 -0
- /package/{src → eventcatalog/src}/components/Lists/ProtocolList.tsx +0 -0
- /package/{src → eventcatalog/src}/components/Lists/RepositoryList.astro +0 -0
- /package/{src → eventcatalog/src}/components/Lists/SpecificationsList.astro +0 -0
- /package/{src → eventcatalog/src}/components/Lists/VersionList.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/Accordion/Accordion.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/Accordion/Accordion.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/Accordion/AccordionGroup.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/Admonition.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/AsyncAPI/AsyncAPI.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/ChannelInformation/ChannelInformation.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/File.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/Flow/Flow.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/NodeGraph/DownloadButton.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Edges/AnimatedMessageEdge.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/NodeGraph/NodeGraph.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/NodeGraph/NodeGraphPortal.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Channel.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Command.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Event.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/ExternalSystem.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Query.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Service.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Step.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/User.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/OpenAPI/OpenAPI.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/Schema.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/SchemaViewer/SchemaViewer.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/SchemaViewer/SchemaViewer.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/SchemaViewer/SchemaViewerPortal.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/Steps/Step.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/Steps/Steps.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/Tiles/Tile.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/Tiles/Tiles.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/components.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/page-components.tsx +0 -0
- /package/{src → eventcatalog/src}/components/Search.astro +0 -0
- /package/{src → eventcatalog/src}/components/Seo.astro +0 -0
- /package/{src → eventcatalog/src}/components/SideBars/CatalogResourcesSideBar/index.tsx +0 -0
- /package/{src → eventcatalog/src}/components/SideBars/CatalogResourcesSideBar/styles.css +0 -0
- /package/{src → eventcatalog/src}/components/SideBars/ChannelSideBar.astro +0 -0
- /package/{src → eventcatalog/src}/components/SideBars/DomainSideBar.astro +0 -0
- /package/{src → eventcatalog/src}/components/SideBars/MessageSideBar.astro +0 -0
- /package/{src → eventcatalog/src}/components/SideBars/ServiceSideBar.astro +0 -0
- /package/{src → eventcatalog/src}/components/Tables/DebouncedInput.tsx +0 -0
- /package/{src → eventcatalog/src}/components/Tables/Table.tsx +0 -0
- /package/{src → eventcatalog/src}/components/Tables/columns/DomainTableColumns.tsx +0 -0
- /package/{src → eventcatalog/src}/components/Tables/columns/FlowTableColumns.tsx +0 -0
- /package/{src → eventcatalog/src}/components/Tables/columns/MessageTableColumns.tsx +0 -0
- /package/{src → eventcatalog/src}/components/Tables/columns/ServiceTableColumns.tsx +0 -0
- /package/{src → eventcatalog/src}/components/Tables/columns/index.tsx +0 -0
- /package/{src → eventcatalog/src}/components/Tables/filters/custom-filters.ts +0 -0
- /package/{src → eventcatalog/src}/env.d.ts +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/WebSocket.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/amqp.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/eventbridge.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/googlepubsub.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/http.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/index.ts +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/jms.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/kafka.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/mercure.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/mqtt.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/nats.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/pulsar.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/redis.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/sns.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/solace.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/sqs.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/ws.svg +0 -0
- /package/{src → eventcatalog/src}/layouts/CustomDocsPageLayout.astro +0 -0
- /package/{src → eventcatalog/src}/layouts/DiscoverLayout.astro +0 -0
- /package/{src → eventcatalog/src}/layouts/Footer.astro +0 -0
- /package/{src → eventcatalog/src}/layouts/PlainPage.astro +0 -0
- /package/{src → eventcatalog/src}/layouts/VerticalSideBarLayout.astro +0 -0
- /package/{src → eventcatalog/src}/layouts/VisualiserLayout.astro +0 -0
- /package/{src → eventcatalog/src}/pages/discover/[type]/index.astro +0 -0
- /package/{src → eventcatalog/src}/pages/docs/[type]/[id]/[version]/changelog/index.astro +0 -0
- /package/{src → eventcatalog/src}/pages/docs/[type]/[id]/[version]/index.astro +0 -0
- /package/{src → eventcatalog/src}/pages/docs/[type]/[id]/[version]/spec/_styles.css +0 -0
- /package/{src → eventcatalog/src}/pages/docs/[type]/[id]/[version]/spec/index.astro +0 -0
- /package/{src → eventcatalog/src}/pages/docs/[type]/[id]/index.astro +0 -0
- /package/{src → eventcatalog/src}/pages/docs/index.astro +0 -0
- /package/{src → eventcatalog/src}/pages/index.astro +0 -0
- /package/{src → eventcatalog/src}/pages/visualiser/[type]/[id]/[version]/index.astro +0 -0
- /package/{src → eventcatalog/src}/pages/visualiser/[type]/[id]/index.astro +0 -0
- /package/{src → eventcatalog/src}/remark-plugins/mermaid.ts +0 -0
- /package/{src → eventcatalog/src}/types/index.ts +0 -0
- /package/{src → eventcatalog/src}/utils/channels.ts +0 -0
- /package/{src → eventcatalog/src}/utils/collections/changelogs.ts +0 -0
- /package/{src → eventcatalog/src}/utils/collections/domains.ts +0 -0
- /package/{src → eventcatalog/src}/utils/collections/file-diffs.ts +0 -0
- /package/{src → eventcatalog/src}/utils/collections/flows.ts +0 -0
- /package/{src → eventcatalog/src}/utils/collections/icons.ts +0 -0
- /package/{src → eventcatalog/src}/utils/collections/services.ts +0 -0
- /package/{src → eventcatalog/src}/utils/collections/util.ts +0 -0
- /package/{src → eventcatalog/src}/utils/collections/versions.ts +0 -0
- /package/{src → eventcatalog/src}/utils/colors.ts +0 -0
- /package/{src → eventcatalog/src}/utils/commands.ts +0 -0
- /package/{src → eventcatalog/src}/utils/eventcatalog-config/catalog.ts +0 -0
- /package/{src → eventcatalog/src}/utils/events.ts +0 -0
- /package/{src → eventcatalog/src}/utils/example-remark-plugin.mjs +0 -0
- /package/{src → eventcatalog/src}/utils/messages.ts +0 -0
- /package/{src → eventcatalog/src}/utils/node-graphs/domains-node-graph.ts +0 -0
- /package/{src → eventcatalog/src}/utils/node-graphs/flows-node-graph.ts +0 -0
- /package/{src → eventcatalog/src}/utils/node-graphs/services-node-graph.ts +0 -0
- /package/{src → eventcatalog/src}/utils/page-loaders/page-data-loader.ts +0 -0
- /package/{src → eventcatalog/src}/utils/pages.ts +0 -0
- /package/{src → eventcatalog/src}/utils/queries.ts +0 -0
- /package/{src → eventcatalog/src}/utils/teams.ts +0 -0
- /package/{src → eventcatalog/src}/utils/url-builder.ts +0 -0
- /package/{src → eventcatalog/src}/utils/users.ts +0 -0
- /package/{tailwind.config.mjs → eventcatalog/tailwind.config.mjs} +0 -0
- /package/{tsconfig.json → eventcatalog/tsconfig.json} +0 -0
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import {
|
|
2
|
+
addPropertyToFrontMatter
|
|
3
|
+
} from "./chunk-E7TXTI7G.js";
|
|
4
|
+
import {
|
|
5
|
+
mapCatalogToAstro
|
|
6
|
+
} from "./chunk-PK2EQVPD.js";
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* @typedef {(err: Error | null, events: Event[]) => unknown} SubscribeCallback
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
*
|
|
17
|
-
* @param {string} projectDirectory
|
|
18
|
-
* @param {string} catalogDirectory
|
|
19
|
-
* @param {SubscribeCallback|undefined} callback
|
|
20
|
-
*/
|
|
21
|
-
export async function watch(projectDirectory, catalogDirectory, callback = undefined) {
|
|
8
|
+
// src/watcher.js
|
|
9
|
+
import watcher from "@parcel/watcher";
|
|
10
|
+
import fs from "node:fs";
|
|
11
|
+
import { rimrafSync } from "rimraf";
|
|
12
|
+
async function watch(projectDirectory, catalogDirectory, callback = void 0) {
|
|
22
13
|
const subscription = await watcher.subscribe(
|
|
23
14
|
projectDirectory,
|
|
24
15
|
compose(
|
|
@@ -31,36 +22,29 @@ export async function watch(projectDirectory, catalogDirectory, callback = undef
|
|
|
31
22
|
if (err) {
|
|
32
23
|
return;
|
|
33
24
|
}
|
|
34
|
-
|
|
35
25
|
for (let event of events) {
|
|
36
26
|
const { path: filePath, type } = event;
|
|
37
|
-
|
|
38
27
|
const astroPaths = mapCatalogToAstro({
|
|
39
28
|
filePath,
|
|
40
29
|
astroDir: catalogDirectory,
|
|
41
|
-
projectDir: projectDirectory
|
|
30
|
+
projectDir: projectDirectory
|
|
42
31
|
});
|
|
43
|
-
|
|
44
32
|
for (const astroPath of astroPaths) {
|
|
45
33
|
switch (type) {
|
|
46
|
-
case
|
|
47
|
-
case
|
|
34
|
+
case "create":
|
|
35
|
+
case "update":
|
|
48
36
|
try {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
const frontmatter = addPropertyToFrontMatter(content, 'pathToFile', filePath);
|
|
37
|
+
if (astroPath.endsWith(".mdx")) {
|
|
38
|
+
const content = fs.readFileSync(astroPath, "utf-8");
|
|
39
|
+
const frontmatter = addPropertyToFrontMatter(content, "pathToFile", filePath);
|
|
53
40
|
fs.writeFileSync(astroPath, frontmatter);
|
|
54
41
|
}
|
|
55
42
|
} catch (error) {
|
|
56
|
-
// silent fail
|
|
57
43
|
}
|
|
58
|
-
|
|
59
44
|
if (fs.statSync(filePath).isDirectory()) fs.mkdirSync(astroPath, { recursive: true });
|
|
60
45
|
else retryEPERM(fs.cpSync)(filePath, astroPath);
|
|
61
|
-
|
|
62
46
|
break;
|
|
63
|
-
case
|
|
47
|
+
case "delete":
|
|
64
48
|
retryEPERM(rimrafSync)(astroPath);
|
|
65
49
|
break;
|
|
66
50
|
}
|
|
@@ -70,20 +54,13 @@ export async function watch(projectDirectory, catalogDirectory, callback = undef
|
|
|
70
54
|
callback
|
|
71
55
|
),
|
|
72
56
|
{
|
|
73
|
-
ignore: [`**/${catalogDirectory}/!(${projectDirectory})**`]
|
|
57
|
+
ignore: [`**/${catalogDirectory}/!(${projectDirectory})**`]
|
|
74
58
|
}
|
|
75
59
|
);
|
|
76
|
-
|
|
77
60
|
return () => subscription.unsubscribe();
|
|
78
61
|
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
*
|
|
82
|
-
* @param {...Function} fns
|
|
83
|
-
* @returns {SubscribeCallback}
|
|
84
|
-
*/
|
|
85
62
|
function compose(...fns) {
|
|
86
|
-
return function
|
|
63
|
+
return function(err, events) {
|
|
87
64
|
fns.filter(Boolean).forEach((fn, i) => {
|
|
88
65
|
try {
|
|
89
66
|
fn(err, events);
|
|
@@ -94,24 +71,24 @@ function compose(...fns) {
|
|
|
94
71
|
});
|
|
95
72
|
};
|
|
96
73
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const DELAY_MS = 100;
|
|
100
|
-
|
|
101
|
-
// In win32 some tests failed when attempting copy the file at the same time
|
|
102
|
-
// that another process is editing it.
|
|
74
|
+
var MAX_RETRIES = 5;
|
|
75
|
+
var DELAY_MS = 100;
|
|
103
76
|
function retryEPERM(fn) {
|
|
104
77
|
return (...args) => {
|
|
105
78
|
let retries = 0;
|
|
106
|
-
|
|
107
79
|
while (retries < MAX_RETRIES) {
|
|
108
80
|
try {
|
|
109
81
|
return fn(...args);
|
|
110
82
|
} catch (err) {
|
|
111
|
-
if (err.code !==
|
|
112
|
-
setTimeout(() => {
|
|
83
|
+
if (err.code !== "EPERM") throw err;
|
|
84
|
+
setTimeout(() => {
|
|
85
|
+
}, DELAY_MS);
|
|
113
86
|
retries += 1;
|
|
114
87
|
}
|
|
115
88
|
}
|
|
116
89
|
};
|
|
117
90
|
}
|
|
91
|
+
|
|
92
|
+
export {
|
|
93
|
+
watch
|
|
94
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// src/eventcatalog-config-file-utils.js
|
|
2
|
+
import { readFile, writeFile, rm } from "node:fs/promises";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { copyFile } from "node:fs/promises";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { v4 as uuidV4 } from "uuid";
|
|
7
|
+
import { pathToFileURL } from "url";
|
|
8
|
+
import matter from "gray-matter";
|
|
9
|
+
async function cleanup(projectDirectory) {
|
|
10
|
+
const filePath = path.join(projectDirectory, "eventcatalog.config.mjs");
|
|
11
|
+
if (existsSync(filePath)) {
|
|
12
|
+
await rm(filePath);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
var getEventCatalogConfigFile = async (projectDirectory) => {
|
|
16
|
+
try {
|
|
17
|
+
let configFilePath = path.join(projectDirectory, "eventcatalog.config.js");
|
|
18
|
+
const filePath = path.join(projectDirectory, "package.json");
|
|
19
|
+
const packageJson = JSON.parse(await readFile(filePath, "utf-8"));
|
|
20
|
+
if (packageJson?.type !== "module") {
|
|
21
|
+
await copyFile(configFilePath, path.join(projectDirectory, "eventcatalog.config.mjs"));
|
|
22
|
+
configFilePath = path.join(projectDirectory, "eventcatalog.config.mjs");
|
|
23
|
+
}
|
|
24
|
+
const configFileURL = pathToFileURL(configFilePath).href;
|
|
25
|
+
const config = await import(
|
|
26
|
+
/* @vite-ignore */
|
|
27
|
+
configFileURL
|
|
28
|
+
);
|
|
29
|
+
return config.default;
|
|
30
|
+
} finally {
|
|
31
|
+
await cleanup(projectDirectory);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var writeEventCatalogConfigFile = async (projectDirectory, newConfig) => {
|
|
35
|
+
try {
|
|
36
|
+
const configFilePath = path.join(projectDirectory, "eventcatalog.config.js");
|
|
37
|
+
let content = await readFile(configFilePath, "utf8");
|
|
38
|
+
const startIndex = content.indexOf("export default {");
|
|
39
|
+
if (startIndex === -1) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
Object.entries(newConfig).forEach(([key, value]) => {
|
|
43
|
+
const valueString = JSON.stringify(value, null, 2).replace(/"/g, "'").replace(/\n/g, "\n ");
|
|
44
|
+
const keyRegex = new RegExp(`(${key}\\s*:)([^,}]+)`, "g");
|
|
45
|
+
if (content.match(keyRegex)) {
|
|
46
|
+
content = content.replace(keyRegex, `$1 ${valueString}`);
|
|
47
|
+
} else {
|
|
48
|
+
const insertPosition = content.indexOf("{", startIndex) + 1;
|
|
49
|
+
content = content.slice(0, insertPosition) + `
|
|
50
|
+
${key}: ${valueString},` + content.slice(insertPosition);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
await writeFile(configFilePath, content);
|
|
54
|
+
} finally {
|
|
55
|
+
await cleanup(projectDirectory);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
|
|
59
|
+
try {
|
|
60
|
+
const config = await getEventCatalogConfigFile(projectDirectory);
|
|
61
|
+
if (!config.cId) {
|
|
62
|
+
await writeEventCatalogConfigFile(projectDirectory, { cId: uuidV4() });
|
|
63
|
+
}
|
|
64
|
+
} catch (error) {
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
function addPropertyToFrontMatter(input, newProperty, newValue) {
|
|
68
|
+
const file = matter(input);
|
|
69
|
+
return matter.stringify(file.content, { ...file.data, [newProperty]: newValue });
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export {
|
|
73
|
+
cleanup,
|
|
74
|
+
getEventCatalogConfigFile,
|
|
75
|
+
writeEventCatalogConfigFile,
|
|
76
|
+
verifyRequiredFieldsAreInCatalogConfigFile,
|
|
77
|
+
addPropertyToFrontMatter
|
|
78
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
raiseEvent
|
|
3
|
+
} from "./chunk-65VQIGAP.js";
|
|
4
|
+
import {
|
|
5
|
+
getEventCatalogConfigFile,
|
|
6
|
+
verifyRequiredFieldsAreInCatalogConfigFile
|
|
7
|
+
} from "./chunk-E7TXTI7G.js";
|
|
8
|
+
|
|
9
|
+
// src/analytics/log-build.js
|
|
10
|
+
var main = async (projectDir) => {
|
|
11
|
+
if (process.env.NODE_ENV === "CI") return;
|
|
12
|
+
try {
|
|
13
|
+
await verifyRequiredFieldsAreInCatalogConfigFile(projectDir);
|
|
14
|
+
const configFile = await getEventCatalogConfigFile(projectDir);
|
|
15
|
+
const { cId, organizationName, generators = [] } = configFile;
|
|
16
|
+
const generatorNames = generators.length > 0 ? generators.map((generator) => generator[0]) : ["none"];
|
|
17
|
+
await raiseEvent({
|
|
18
|
+
command: "build",
|
|
19
|
+
org: organizationName,
|
|
20
|
+
cId,
|
|
21
|
+
generators: generatorNames.toString()
|
|
22
|
+
});
|
|
23
|
+
} catch (error) {
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var log_build_default = main;
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
log_build_default
|
|
30
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addPropertyToFrontMatter,
|
|
3
|
+
verifyRequiredFieldsAreInCatalogConfigFile
|
|
4
|
+
} from "./chunk-E7TXTI7G.js";
|
|
5
|
+
import {
|
|
6
|
+
mapCatalogToAstro
|
|
7
|
+
} from "./chunk-PK2EQVPD.js";
|
|
8
|
+
|
|
9
|
+
// src/catalog-to-astro-content-directory.js
|
|
10
|
+
import { glob } from "glob";
|
|
11
|
+
import * as path from "node:path";
|
|
12
|
+
import fs from "fs";
|
|
13
|
+
import { fileURLToPath } from "url";
|
|
14
|
+
import os from "node:os";
|
|
15
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
16
|
+
var rootPkg = path.resolve(path.dirname(__filename), "../");
|
|
17
|
+
var copyFiles = async (source, target) => {
|
|
18
|
+
const files = await glob(path.join(source, "**"), {
|
|
19
|
+
nodir: true,
|
|
20
|
+
windowsPathsNoEscape: os.platform() == "win32"
|
|
21
|
+
});
|
|
22
|
+
for (const file of files) {
|
|
23
|
+
mapCatalogToAstro({
|
|
24
|
+
filePath: file,
|
|
25
|
+
astroDir: target,
|
|
26
|
+
projectDir: source
|
|
27
|
+
}).map((astroPath) => {
|
|
28
|
+
fs.cpSync(file, astroPath);
|
|
29
|
+
return { oldPath: file, newPath: astroPath };
|
|
30
|
+
}).map(({ oldPath, newPath }) => {
|
|
31
|
+
if (!oldPath.endsWith(".md") && !oldPath.endsWith(".mdx")) return;
|
|
32
|
+
try {
|
|
33
|
+
const content = fs.readFileSync(newPath, "utf-8");
|
|
34
|
+
const frontmatter = addPropertyToFrontMatter(content, "pathToFile", oldPath);
|
|
35
|
+
fs.writeFileSync(newPath, frontmatter);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var ensureAstroCollectionNotEmpty = async (astroDir) => {
|
|
42
|
+
const COLLECTIONS = [
|
|
43
|
+
"events",
|
|
44
|
+
"commands",
|
|
45
|
+
"services",
|
|
46
|
+
"users",
|
|
47
|
+
"teams",
|
|
48
|
+
"domains",
|
|
49
|
+
"flows",
|
|
50
|
+
"pages",
|
|
51
|
+
"changelogs",
|
|
52
|
+
"queries",
|
|
53
|
+
"channels"
|
|
54
|
+
];
|
|
55
|
+
const emptyCollections = [];
|
|
56
|
+
for (const collection of COLLECTIONS) {
|
|
57
|
+
const markdownFiles = await glob(path.join(astroDir, "src/content/", collection, "**"), {
|
|
58
|
+
nodir: true,
|
|
59
|
+
windowsPathsNoEscape: os.platform() == "win32"
|
|
60
|
+
});
|
|
61
|
+
if (markdownFiles.length === 0) emptyCollections.push(collection);
|
|
62
|
+
}
|
|
63
|
+
const defaultCollectionFilesDir = path.join(rootPkg, "default-files-for-collections");
|
|
64
|
+
for (const collection of emptyCollections) {
|
|
65
|
+
const defaultFile = path.join(defaultCollectionFilesDir, `${collection}.md`);
|
|
66
|
+
const targetDir = path.join(astroDir, "src/content/", collection);
|
|
67
|
+
if (!fs.existsSync(targetDir)) {
|
|
68
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
69
|
+
}
|
|
70
|
+
fs.cpSync(defaultFile, path.join(targetDir, `${collection}.md`));
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
var catalogToAstro = async (source, astroDir) => {
|
|
74
|
+
const astroContentDir = path.join(astroDir, "src/content/");
|
|
75
|
+
const astroConfigFile = fs.readFileSync(path.join(astroContentDir, "config.ts"));
|
|
76
|
+
fs.rmSync(astroContentDir, { recursive: true });
|
|
77
|
+
fs.mkdirSync(astroContentDir);
|
|
78
|
+
fs.writeFileSync(path.join(astroContentDir, "config.ts"), astroConfigFile);
|
|
79
|
+
await verifyRequiredFieldsAreInCatalogConfigFile(source);
|
|
80
|
+
await copyFiles(source, astroDir);
|
|
81
|
+
await ensureAstroCollectionNotEmpty(astroDir);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export {
|
|
85
|
+
catalogToAstro
|
|
86
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// src/map-catalog-to-astro.js
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
var 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
|
+
function mapCatalogToAstro({ filePath, astroDir, projectDir }) {
|
|
17
|
+
const relativeFilePath = removeBasePath(filePath, projectDir);
|
|
18
|
+
if (!isCatalogRelated(relativeFilePath)) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
const baseTargetPaths = getBaseTargetPaths(relativeFilePath);
|
|
22
|
+
const relativeTargetPath = getRelativeTargetPath(relativeFilePath);
|
|
23
|
+
return baseTargetPaths.map(
|
|
24
|
+
(base) => path.join(astroDir, base, relativeTargetPath.replace("index.md", "index.mdx").replace("changelog.md", "changelog.mdx"))
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
function removeBasePath(fullPath, basePath) {
|
|
28
|
+
const relativePath = path.relative(basePath, fullPath);
|
|
29
|
+
return relativePath.startsWith("..") ? fullPath : relativePath;
|
|
30
|
+
}
|
|
31
|
+
function isCollectionKey(key) {
|
|
32
|
+
return COLLECTION_KEYS.includes(key);
|
|
33
|
+
}
|
|
34
|
+
function isCatalogRelated(filePath) {
|
|
35
|
+
const filePathArr = filePath.split(path.sep).filter(Boolean);
|
|
36
|
+
if ([
|
|
37
|
+
"eventcatalog.config.js",
|
|
38
|
+
// config file at root
|
|
39
|
+
"eventcatalog.styles.css",
|
|
40
|
+
// custom styles file at root
|
|
41
|
+
"components",
|
|
42
|
+
// custom components
|
|
43
|
+
"public",
|
|
44
|
+
// public assets
|
|
45
|
+
...COLLECTION_KEYS
|
|
46
|
+
].includes(filePathArr[0])) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
function getBaseTargetPaths(filePath) {
|
|
52
|
+
const filePathArr = filePath.split(path.sep).filter(Boolean);
|
|
53
|
+
if (isCollectionKey(filePathArr[0])) {
|
|
54
|
+
if (filePathArr[filePathArr.length - 1] == "changelog.md") {
|
|
55
|
+
return [path.join("src", "content", "changelogs")];
|
|
56
|
+
}
|
|
57
|
+
if (filePathArr[filePathArr.length - 1].match(/\.md$/)) {
|
|
58
|
+
return [path.join("src", "content")];
|
|
59
|
+
}
|
|
60
|
+
const hasExtension = (str) => /\.[a-zA-Z0-9]{2,}$/.test(str);
|
|
61
|
+
if (hasExtension(filePath)) {
|
|
62
|
+
return [path.join("public", "generated"), path.join("src", "catalog-files")];
|
|
63
|
+
}
|
|
64
|
+
return [path.join("public", "generated"), path.join("src", "catalog-files"), path.join("src", "content")];
|
|
65
|
+
}
|
|
66
|
+
if (filePathArr[0] == "components") {
|
|
67
|
+
return [path.join("src", "custom-defined-components")];
|
|
68
|
+
}
|
|
69
|
+
if (filePathArr[0] == "public") {
|
|
70
|
+
return [path.join("public")];
|
|
71
|
+
}
|
|
72
|
+
return [path.join("/")];
|
|
73
|
+
}
|
|
74
|
+
function getRelativeTargetPath(filePath) {
|
|
75
|
+
const filePathArr = filePath.split(path.sep).filter(Boolean);
|
|
76
|
+
if (filePathArr[0] == "public" || filePathArr[0] == "components") {
|
|
77
|
+
filePathArr.shift();
|
|
78
|
+
}
|
|
79
|
+
const relativePath = [];
|
|
80
|
+
for (let i = filePathArr.length - 1; i >= 0; i--) {
|
|
81
|
+
relativePath.unshift(filePathArr[i]);
|
|
82
|
+
if (isCollectionKey(filePathArr[i])) break;
|
|
83
|
+
}
|
|
84
|
+
return path.join(...relativePath);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export {
|
|
88
|
+
mapCatalogToAstro
|
|
89
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cleanup,
|
|
3
|
+
getEventCatalogConfigFile
|
|
4
|
+
} from "./chunk-E7TXTI7G.js";
|
|
5
|
+
|
|
6
|
+
// src/generate.js
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
function getDefaultExport(importedModule) {
|
|
9
|
+
if (importedModule === null || typeof importedModule !== "object") {
|
|
10
|
+
throw new Error("Invalid module");
|
|
11
|
+
}
|
|
12
|
+
if (typeof importedModule.default === "object" && importedModule.default !== null) {
|
|
13
|
+
return importedModule.default.default || importedModule.default;
|
|
14
|
+
}
|
|
15
|
+
if (typeof importedModule.default !== "undefined") {
|
|
16
|
+
return importedModule.default;
|
|
17
|
+
}
|
|
18
|
+
return importedModule;
|
|
19
|
+
}
|
|
20
|
+
var generate = async (PROJECT_DIRECTORY) => {
|
|
21
|
+
try {
|
|
22
|
+
const config = await getEventCatalogConfigFile(PROJECT_DIRECTORY);
|
|
23
|
+
const { generators = [] } = config;
|
|
24
|
+
if (!generators.length) {
|
|
25
|
+
console.log("No configured generators found, skipping generation");
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
for (const generator of generators) {
|
|
29
|
+
let plugin = generator[0];
|
|
30
|
+
const pluginConfig = generator[1];
|
|
31
|
+
if (plugin.startsWith("./")) {
|
|
32
|
+
plugin = path.join(PROJECT_DIRECTORY, plugin);
|
|
33
|
+
}
|
|
34
|
+
if (plugin.includes("<rootDir>")) {
|
|
35
|
+
plugin = plugin.replace("<rootDir>", PROJECT_DIRECTORY);
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
const importedGenerator = await import(plugin);
|
|
39
|
+
const generator2 = getDefaultExport(importedGenerator);
|
|
40
|
+
await generator2({ eventCatalogConfig: {} }, pluginConfig);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error("Error loading plugin:", error);
|
|
43
|
+
await cleanup(PROJECT_DIRECTORY);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
await cleanup(PROJECT_DIRECTORY);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.error(error);
|
|
50
|
+
await cleanup(PROJECT_DIRECTORY);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export {
|
|
55
|
+
generate
|
|
56
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/constants.ts
|
|
21
|
+
var constants_exports = {};
|
|
22
|
+
__export(constants_exports, {
|
|
23
|
+
VERSION: () => VERSION
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(constants_exports);
|
|
26
|
+
|
|
27
|
+
// package.json
|
|
28
|
+
var version = "2.15.0";
|
|
29
|
+
|
|
30
|
+
// src/constants.ts
|
|
31
|
+
var VERSION = version;
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
VERSION
|
|
35
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/eventcatalog-config-file-utils.js
|
|
31
|
+
var eventcatalog_config_file_utils_exports = {};
|
|
32
|
+
__export(eventcatalog_config_file_utils_exports, {
|
|
33
|
+
addPropertyToFrontMatter: () => addPropertyToFrontMatter,
|
|
34
|
+
cleanup: () => cleanup,
|
|
35
|
+
getEventCatalogConfigFile: () => getEventCatalogConfigFile,
|
|
36
|
+
verifyRequiredFieldsAreInCatalogConfigFile: () => verifyRequiredFieldsAreInCatalogConfigFile,
|
|
37
|
+
writeEventCatalogConfigFile: () => writeEventCatalogConfigFile
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(eventcatalog_config_file_utils_exports);
|
|
40
|
+
var import_promises = require("fs/promises");
|
|
41
|
+
var import_node_fs = require("fs");
|
|
42
|
+
var import_promises2 = require("fs/promises");
|
|
43
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
44
|
+
var import_uuid = require("uuid");
|
|
45
|
+
var import_url = require("url");
|
|
46
|
+
var import_gray_matter = __toESM(require("gray-matter"), 1);
|
|
47
|
+
async function cleanup(projectDirectory) {
|
|
48
|
+
const filePath = import_node_path.default.join(projectDirectory, "eventcatalog.config.mjs");
|
|
49
|
+
if ((0, import_node_fs.existsSync)(filePath)) {
|
|
50
|
+
await (0, import_promises.rm)(filePath);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
var getEventCatalogConfigFile = async (projectDirectory) => {
|
|
54
|
+
try {
|
|
55
|
+
let configFilePath = import_node_path.default.join(projectDirectory, "eventcatalog.config.js");
|
|
56
|
+
const filePath = import_node_path.default.join(projectDirectory, "package.json");
|
|
57
|
+
const packageJson = JSON.parse(await (0, import_promises.readFile)(filePath, "utf-8"));
|
|
58
|
+
if (packageJson?.type !== "module") {
|
|
59
|
+
await (0, import_promises2.copyFile)(configFilePath, import_node_path.default.join(projectDirectory, "eventcatalog.config.mjs"));
|
|
60
|
+
configFilePath = import_node_path.default.join(projectDirectory, "eventcatalog.config.mjs");
|
|
61
|
+
}
|
|
62
|
+
const configFileURL = (0, import_url.pathToFileURL)(configFilePath).href;
|
|
63
|
+
const config = await import(
|
|
64
|
+
/* @vite-ignore */
|
|
65
|
+
configFileURL
|
|
66
|
+
);
|
|
67
|
+
return config.default;
|
|
68
|
+
} finally {
|
|
69
|
+
await cleanup(projectDirectory);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var writeEventCatalogConfigFile = async (projectDirectory, newConfig) => {
|
|
73
|
+
try {
|
|
74
|
+
const configFilePath = import_node_path.default.join(projectDirectory, "eventcatalog.config.js");
|
|
75
|
+
let content = await (0, import_promises.readFile)(configFilePath, "utf8");
|
|
76
|
+
const startIndex = content.indexOf("export default {");
|
|
77
|
+
if (startIndex === -1) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
Object.entries(newConfig).forEach(([key, value]) => {
|
|
81
|
+
const valueString = JSON.stringify(value, null, 2).replace(/"/g, "'").replace(/\n/g, "\n ");
|
|
82
|
+
const keyRegex = new RegExp(`(${key}\\s*:)([^,}]+)`, "g");
|
|
83
|
+
if (content.match(keyRegex)) {
|
|
84
|
+
content = content.replace(keyRegex, `$1 ${valueString}`);
|
|
85
|
+
} else {
|
|
86
|
+
const insertPosition = content.indexOf("{", startIndex) + 1;
|
|
87
|
+
content = content.slice(0, insertPosition) + `
|
|
88
|
+
${key}: ${valueString},` + content.slice(insertPosition);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
await (0, import_promises.writeFile)(configFilePath, content);
|
|
92
|
+
} finally {
|
|
93
|
+
await cleanup(projectDirectory);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
var verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
|
|
97
|
+
try {
|
|
98
|
+
const config = await getEventCatalogConfigFile(projectDirectory);
|
|
99
|
+
if (!config.cId) {
|
|
100
|
+
await writeEventCatalogConfigFile(projectDirectory, { cId: (0, import_uuid.v4)() });
|
|
101
|
+
}
|
|
102
|
+
} catch (error) {
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
function addPropertyToFrontMatter(input, newProperty, newValue) {
|
|
106
|
+
const file = (0, import_gray_matter.default)(input);
|
|
107
|
+
return import_gray_matter.default.stringify(file.content, { ...file.data, [newProperty]: newValue });
|
|
108
|
+
}
|
|
109
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
110
|
+
0 && (module.exports = {
|
|
111
|
+
addPropertyToFrontMatter,
|
|
112
|
+
cleanup,
|
|
113
|
+
getEventCatalogConfigFile,
|
|
114
|
+
verifyRequiredFieldsAreInCatalogConfigFile,
|
|
115
|
+
writeEventCatalogConfigFile
|
|
116
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare function cleanup(projectDirectory: any): Promise<void>;
|
|
2
|
+
declare function addPropertyToFrontMatter(input: any, newProperty: any, newValue: any): string;
|
|
3
|
+
declare function getEventCatalogConfigFile(projectDirectory: any): Promise<any>;
|
|
4
|
+
declare function writeEventCatalogConfigFile(projectDirectory: any, newConfig: any): Promise<void>;
|
|
5
|
+
declare function verifyRequiredFieldsAreInCatalogConfigFile(projectDirectory: any): Promise<void>;
|
|
6
|
+
|
|
7
|
+
export { addPropertyToFrontMatter, cleanup, getEventCatalogConfigFile, verifyRequiredFieldsAreInCatalogConfigFile, writeEventCatalogConfigFile };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare function cleanup(projectDirectory: any): Promise<void>;
|
|
2
|
+
declare function addPropertyToFrontMatter(input: any, newProperty: any, newValue: any): string;
|
|
3
|
+
declare function getEventCatalogConfigFile(projectDirectory: any): Promise<any>;
|
|
4
|
+
declare function writeEventCatalogConfigFile(projectDirectory: any, newConfig: any): Promise<void>;
|
|
5
|
+
declare function verifyRequiredFieldsAreInCatalogConfigFile(projectDirectory: any): Promise<void>;
|
|
6
|
+
|
|
7
|
+
export { addPropertyToFrontMatter, cleanup, getEventCatalogConfigFile, verifyRequiredFieldsAreInCatalogConfigFile, writeEventCatalogConfigFile };
|