@eventcatalog/core 4.11.2 → 4.12.0-beta.1
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/dist/analytics/analytics.cjs +1 -1
- package/dist/analytics/analytics.js +2 -2
- package/dist/analytics/log-build.cjs +17 -11
- package/dist/analytics/log-build.js +4 -4
- package/dist/astro-config-path.cjs +51 -0
- package/dist/astro-config-path.d.cts +6 -0
- package/dist/astro-config-path.d.ts +6 -0
- package/dist/astro-config-path.js +6 -0
- package/dist/catalog-runtime.cjs +136 -0
- package/dist/catalog-runtime.d.cts +12 -0
- package/dist/catalog-runtime.d.ts +12 -0
- package/dist/catalog-runtime.js +8 -0
- package/dist/{chunk-B7HCX5HM.js → chunk-3SJDIENM.js} +1 -1
- package/dist/{chunk-AFPH6ERZ.js → chunk-5QRWGO2E.js} +1 -1
- package/dist/{chunk-6U72KINX.js → chunk-DJCOJ77J.js} +1 -0
- package/dist/{chunk-LHR4G2UO.js → chunk-EEZXGNF6.js} +1 -1
- package/dist/{chunk-XMRPNDXB.js → chunk-ISBBAOCD.js} +1 -1
- package/dist/{chunk-Z6OKCHWL.js → chunk-IUPFEQMU.js} +2 -2
- package/dist/{chunk-6QENHZZP.js → chunk-JE6RX7SJ.js} +11 -5
- package/dist/{chunk-LAWEGSJH.js → chunk-LU4GFIHH.js} +1 -1
- package/dist/{chunk-2YJRF4ZX.js → chunk-RYPZGCRN.js} +1 -1
- package/dist/chunk-SAN4U2WU.js +96 -0
- package/dist/{chunk-EGH3ALRY.js → chunk-TVLJNFDW.js} +4 -4
- package/dist/chunk-U63GDPPY.js +14 -0
- package/dist/chunk-VIJJ7JKH.js +17 -0
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/eventcatalog-config-file-utils.cjs +13 -7
- package/dist/eventcatalog-config-file-utils.d.cts +86 -2
- package/dist/eventcatalog-config-file-utils.d.ts +86 -2
- package/dist/eventcatalog-config-file-utils.js +1 -1
- package/dist/eventcatalog.cjs +227 -561
- package/dist/eventcatalog.js +62 -71
- package/dist/features.cjs +10 -6
- package/dist/features.js +2 -2
- package/dist/federation/federate.cjs +110 -106
- package/dist/federation/federate.js +4 -4
- package/dist/generate.cjs +11 -7
- package/dist/generate.js +4 -4
- package/dist/resolve-catalog-dependencies.cjs +12 -8
- package/dist/resolve-catalog-dependencies.js +2 -2
- package/dist/runtime-dependencies/@ai-sdk__react.mjs +3 -0
- package/dist/runtime-dependencies/@astrojs__markdown-remark.mjs +3 -0
- package/dist/runtime-dependencies/@astrojs__mdx.mjs +3 -0
- package/dist/runtime-dependencies/@astrojs__node.mjs +3 -0
- package/dist/runtime-dependencies/@astrojs__react.mjs +3 -0
- package/dist/runtime-dependencies/@astrojs__rss.mjs +3 -0
- package/dist/runtime-dependencies/@asyncapi__avro-schema-parser.mjs +3 -0
- package/dist/runtime-dependencies/@asyncapi__parser.mjs +3 -0
- package/dist/runtime-dependencies/@asyncapi__react-component.mjs +3 -0
- package/dist/runtime-dependencies/@asyncapi__react-component__styles__default.min.css.mjs +3 -0
- package/dist/runtime-dependencies/@auth__core.mjs +3 -0
- package/dist/runtime-dependencies/@auth__core__providers__auth0.mjs +3 -0
- package/dist/runtime-dependencies/@auth__core__providers__github.mjs +3 -0
- package/dist/runtime-dependencies/@auth__core__providers__google.mjs +3 -0
- package/dist/runtime-dependencies/@auth__core__providers__microsoft-entra-id.mjs +3 -0
- package/dist/runtime-dependencies/@auth__core__providers__okta.mjs +3 -0
- package/dist/runtime-dependencies/@auth__core__types.mjs +3 -0
- package/dist/runtime-dependencies/@eventcatalog__license.mjs +3 -0
- package/dist/runtime-dependencies/@eventcatalog__linter.mjs +3 -0
- package/dist/runtime-dependencies/@eventcatalog__sdk.mjs +3 -0
- package/dist/runtime-dependencies/@eventcatalog__visualiser.mjs +3 -0
- package/dist/runtime-dependencies/@eventcatalog__visualiser__styles-core.css.mjs +3 -0
- package/dist/runtime-dependencies/@fontsource__inter.mjs +3 -0
- package/dist/runtime-dependencies/@fontsource__inter__400.css.mjs +3 -0
- package/dist/runtime-dependencies/@fontsource__inter__700.css.mjs +3 -0
- package/dist/runtime-dependencies/@headlessui__react.mjs +3 -0
- package/dist/runtime-dependencies/@heroicons__react.mjs +3 -0
- package/dist/runtime-dependencies/@heroicons__react__16__solid__EnvelopeIcon.mjs +3 -0
- package/dist/runtime-dependencies/@heroicons__react__20__solid.mjs +3 -0
- package/dist/runtime-dependencies/@heroicons__react__24__outline.mjs +3 -0
- package/dist/runtime-dependencies/@heroicons__react__24__outline__MagnifyingGlassIcon.mjs +3 -0
- package/dist/runtime-dependencies/@heroicons__react__24__outline__RectangleGroupIcon.mjs +3 -0
- package/dist/runtime-dependencies/@heroicons__react__24__outline__ServerIcon.mjs +3 -0
- package/dist/runtime-dependencies/@heroicons__react__24__solid.mjs +3 -0
- package/dist/runtime-dependencies/@iconify-json__logos.mjs +3 -0
- package/dist/runtime-dependencies/@mermaid-js__layout-elk.mjs +3 -0
- package/dist/runtime-dependencies/@mermaid-js__layout-elk__dist__mermaid-layout-elk.core.mjs.mjs +3 -0
- package/dist/runtime-dependencies/@modelcontextprotocol__sdk.mjs +3 -0
- package/dist/runtime-dependencies/@modelcontextprotocol__sdk__server__mcp.js.mjs +3 -0
- package/dist/runtime-dependencies/@modelcontextprotocol__sdk__server__webStandardStreamableHttp.js.mjs +3 -0
- package/dist/runtime-dependencies/@nanostores__react.mjs +3 -0
- package/dist/runtime-dependencies/@parcel__watcher.mjs +3 -0
- package/dist/runtime-dependencies/@radix-ui__react-context-menu.mjs +3 -0
- package/dist/runtime-dependencies/@radix-ui__react-dialog.mjs +3 -0
- package/dist/runtime-dependencies/@radix-ui__react-dropdown-menu.mjs +3 -0
- package/dist/runtime-dependencies/@radix-ui__react-popover.mjs +3 -0
- package/dist/runtime-dependencies/@radix-ui__react-tooltip.mjs +3 -0
- package/dist/runtime-dependencies/@scalar__api-reference-react.mjs +3 -0
- package/dist/runtime-dependencies/@scalar__api-reference-react__style.css.mjs +3 -0
- package/dist/runtime-dependencies/@tailwindcss__typography.mjs +3 -0
- package/dist/runtime-dependencies/@tailwindcss__vite.mjs +3 -0
- package/dist/runtime-dependencies/@tanstack__react-table.mjs +3 -0
- package/dist/runtime-dependencies/@xyflow__react.mjs +3 -0
- package/dist/runtime-dependencies/@xyflow__react__dist__style.css.mjs +3 -0
- package/dist/runtime-dependencies/ai.mjs +3 -0
- package/dist/runtime-dependencies/astro-expressive-code.mjs +3 -0
- package/dist/runtime-dependencies/astro-expressive-code__components.mjs +3 -0
- package/dist/runtime-dependencies/astro-seo.mjs +3 -0
- package/dist/runtime-dependencies/astro.mjs +3 -0
- package/dist/runtime-dependencies/astro__assets__services__sharp.mjs +3 -0
- package/dist/runtime-dependencies/astro__config.mjs +3 -0
- package/dist/runtime-dependencies/astro__jsx-runtime.mjs +3 -0
- package/dist/runtime-dependencies/astro__loaders.mjs +3 -0
- package/dist/runtime-dependencies/astro__logger__node.mjs +3 -0
- package/dist/runtime-dependencies/astro__types.mjs +3 -0
- package/dist/runtime-dependencies/astro__zod.mjs +3 -0
- package/dist/runtime-dependencies/auth-astro.mjs +3 -0
- package/dist/runtime-dependencies/auth-astro__client.mjs +3 -0
- package/dist/runtime-dependencies/auth-astro__server.mjs +3 -0
- package/dist/runtime-dependencies/boxen.mjs +3 -0
- package/dist/runtime-dependencies/commander.mjs +3 -0
- package/dist/runtime-dependencies/cross-env.mjs +3 -0
- package/dist/runtime-dependencies/d3-drag.mjs +3 -0
- package/dist/runtime-dependencies/d3-force.mjs +3 -0
- package/dist/runtime-dependencies/d3-selection.mjs +3 -0
- package/dist/runtime-dependencies/d3-zoom.mjs +3 -0
- package/dist/runtime-dependencies/dagre.mjs +3 -0
- package/dist/runtime-dependencies/diff.mjs +3 -0
- package/dist/runtime-dependencies/diff2html.mjs +3 -0
- package/dist/runtime-dependencies/diff2html__bundles__css__diff2html.min.css.mjs +3 -0
- package/dist/runtime-dependencies/dotenv.mjs +3 -0
- package/dist/runtime-dependencies/elkjs.mjs +3 -0
- package/dist/runtime-dependencies/elkjs__lib__elk.bundled.js.mjs +3 -0
- package/dist/runtime-dependencies/glob.mjs +3 -0
- package/dist/runtime-dependencies/gray-matter.mjs +3 -0
- package/dist/runtime-dependencies/hono.mjs +3 -0
- package/dist/runtime-dependencies/html-to-image.mjs +3 -0
- package/dist/runtime-dependencies/js-yaml.mjs +3 -0
- package/dist/runtime-dependencies/jsonpath-plus.mjs +3 -0
- package/dist/runtime-dependencies/jsonwebtoken.mjs +3 -0
- package/dist/runtime-dependencies/lodash.debounce.mjs +3 -0
- package/dist/runtime-dependencies/lodash.merge.mjs +3 -0
- package/dist/runtime-dependencies/lucide-react.mjs +3 -0
- package/dist/runtime-dependencies/manifest.json +136 -0
- package/dist/runtime-dependencies/marked.mjs +3 -0
- package/dist/runtime-dependencies/mdast-util-find-and-replace.mjs +3 -0
- package/dist/runtime-dependencies/mermaid.mjs +3 -0
- package/dist/runtime-dependencies/minisearch.mjs +3 -0
- package/dist/runtime-dependencies/nanostores.mjs +3 -0
- package/dist/runtime-dependencies/pagefind.mjs +3 -0
- package/dist/runtime-dependencies/pako.mjs +3 -0
- package/dist/runtime-dependencies/parse5.mjs +3 -0
- package/dist/runtime-dependencies/picocolors.mjs +3 -0
- package/dist/runtime-dependencies/picomatch.mjs +3 -0
- package/dist/runtime-dependencies/react-dom.mjs +3 -0
- package/dist/runtime-dependencies/react-dom__client.mjs +3 -0
- package/dist/runtime-dependencies/react-dom__server.mjs +3 -0
- package/dist/runtime-dependencies/react-markdown.mjs +3 -0
- package/dist/runtime-dependencies/react-syntax-highlighter.mjs +3 -0
- package/dist/runtime-dependencies/react-syntax-highlighter__dist__cjs__styles__prism.mjs +3 -0
- package/dist/runtime-dependencies/react-syntax-highlighter__dist__cjs__styles__prism__index.js.mjs +3 -0
- package/dist/runtime-dependencies/react.mjs +3 -0
- package/dist/runtime-dependencies/react__jsx-dev-runtime.mjs +3 -0
- package/dist/runtime-dependencies/react__jsx-runtime.mjs +3 -0
- package/dist/runtime-dependencies/recast.mjs +3 -0
- package/dist/runtime-dependencies/recast__parsers__babel.js.mjs +3 -0
- package/dist/runtime-dependencies/rehype-autolink-headings.mjs +3 -0
- package/dist/runtime-dependencies/rehype-expressive-code.mjs +3 -0
- package/dist/runtime-dependencies/rehype-expressive-code__hast.mjs +3 -0
- package/dist/runtime-dependencies/rehype-slug.mjs +3 -0
- package/dist/runtime-dependencies/remark-comment.mjs +3 -0
- package/dist/runtime-dependencies/remark-directive.mjs +3 -0
- package/dist/runtime-dependencies/remark-gfm.mjs +3 -0
- package/dist/runtime-dependencies/rimraf.mjs +3 -0
- package/dist/runtime-dependencies/semver.mjs +3 -0
- package/dist/runtime-dependencies/shelljs.mjs +3 -0
- package/dist/runtime-dependencies/sonner.mjs +3 -0
- package/dist/runtime-dependencies/sql.js.mjs +3 -0
- package/dist/runtime-dependencies/tailwindcss.mjs +3 -0
- package/dist/runtime-dependencies/typescript.mjs +3 -0
- package/dist/runtime-dependencies/unist-util-visit.mjs +3 -0
- package/dist/runtime-dependencies/update-notifier.mjs +3 -0
- package/dist/runtime-dependencies/uuid.mjs +3 -0
- package/dist/runtime-dependencies/zod.mjs +3 -0
- package/dist/runtime-dependencies/zod__v4.mjs +3 -0
- package/dist/search-indexer.cjs +1 -0
- package/dist/search-indexer.js +1 -1
- package/dist/utils/cli-logger.cjs +1 -1
- package/dist/utils/cli-logger.js +2 -2
- package/dist/watcher.cjs +5 -204
- package/dist/watcher.js +1 -2
- package/eventcatalog/astro.config.mjs +57 -31
- package/eventcatalog/integrations/catalog-assets.mjs +204 -0
- package/eventcatalog/integrations/config-loader.mjs +85 -0
- package/eventcatalog/integrations/ecstudio-watcher.mjs +11 -9
- package/eventcatalog/integrations/eventcatalog-runtime.mjs +252 -0
- package/eventcatalog/integrations/expressive-code-config.mjs +6 -0
- package/eventcatalog/integrations/runtime-dependencies.mjs +49 -0
- package/eventcatalog/integrations/runtime-dependency-manifest.mjs +15 -0
- package/eventcatalog/integrations/runtime-paths.mjs +16 -0
- package/eventcatalog/src/content.config.ts +33 -46
- package/eventcatalog/src/enterprise/custom-pages/routes.ts +3 -2
- package/eventcatalog/src/enterprise/feature.ts +2 -1
- package/eventcatalog/src/enterprise/fields/field-indexer.ts +5 -2
- package/eventcatalog/src/enterprise/fields/pages/api/fields.ts +4 -3
- package/eventcatalog/src/enterprise/integrations/eventcatalog-features.ts +32 -32
- package/eventcatalog/src/enterprise/mcp/mcp-auth.ts +1 -1
- package/eventcatalog/src/env.d.ts +7 -1
- package/eventcatalog/src/layouts/VerticalSideBarLayout.astro +15 -3
- package/eventcatalog/src/pages/architecture/[type]/[id]/[version]/index.astro +1 -1
- package/eventcatalog/src/pages/diagrams/[id]/[version]/index.astro +2 -2
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/[docType]/[docId]/[docVersion]/index.astro +2 -2
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/[docType]/[docId]/index.astro +2 -2
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/graphql/[filename].astro +1 -1
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/index.astro +2 -2
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/resources/index.astro +1 -1
- package/eventcatalog/src/pages/docs/[type]/[id]/language/[dictionaryId]/index.astro +1 -1
- package/eventcatalog/src/pages/docs/[type]/[id]/language/index.astro +1 -1
- package/eventcatalog/src/pages/docs/teams/[id]/index.astro +2 -2
- package/eventcatalog/src/pages/docs/users/[id]/index.astro +2 -2
- package/eventcatalog/src/pages/index.astro +2 -3
- package/eventcatalog/src/styles/tailwind.css +3 -0
- package/eventcatalog/src/utils/eventcatalog-config/source.ts +9 -0
- package/eventcatalog/src/utils/feature.ts +2 -1
- package/eventcatalog/tsconfig.json +1 -4
- package/package.json +17 -4
- package/dist/catalog-to-astro-content-directory.cjs +0 -382
- package/dist/catalog-to-astro-content-directory.d.cts +0 -3
- package/dist/catalog-to-astro-content-directory.d.ts +0 -3
- package/dist/catalog-to-astro-content-directory.js +0 -9
- package/dist/chunk-BWN544LB.js +0 -73
- package/dist/chunk-DHH5U5PF.js +0 -53
- package/dist/chunk-KLOHNCNF.js +0 -101
- package/dist/chunk-T4RVWPIQ.js +0 -85
- package/dist/chunk-T5IUG523.js +0 -54
- package/dist/chunk-W5JQON7Z.js +0 -117
- package/dist/copy-core.cjs +0 -88
- package/dist/copy-core.d.cts +0 -4
- package/dist/copy-core.d.ts +0 -4
- package/dist/copy-core.js +0 -8
- package/dist/core-node-modules.cjs +0 -108
- package/dist/core-node-modules.d.cts +0 -7
- package/dist/core-node-modules.d.ts +0 -7
- package/dist/core-node-modules.js +0 -8
- package/dist/custom-components.cjs +0 -89
- package/dist/custom-components.d.cts +0 -4
- package/dist/custom-components.d.ts +0 -4
- package/dist/custom-components.js +0 -8
- package/dist/map-catalog-to-astro.cjs +0 -151
- package/dist/map-catalog-to-astro.d.cts +0 -28
- package/dist/map-catalog-to-astro.d.ts +0 -28
- package/dist/map-catalog-to-astro.js +0 -6
|
@@ -37,13 +37,17 @@ __export(eventcatalog_config_file_utils_exports, {
|
|
|
37
37
|
writeEventCatalogConfigFile: () => writeEventCatalogConfigFile
|
|
38
38
|
});
|
|
39
39
|
module.exports = __toCommonJS(eventcatalog_config_file_utils_exports);
|
|
40
|
+
var import_promises2 = require("fs/promises");
|
|
41
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
42
|
+
var import_uuid = require("uuid");
|
|
43
|
+
var import_gray_matter = __toESM(require("gray-matter"), 1);
|
|
44
|
+
|
|
45
|
+
// eventcatalog/integrations/config-loader.mjs
|
|
40
46
|
var import_promises = require("fs/promises");
|
|
41
47
|
var import_node_fs = require("fs");
|
|
42
48
|
var import_node_path = __toESM(require("path"), 1);
|
|
43
|
-
var
|
|
44
|
-
var import_url = require("url");
|
|
49
|
+
var import_node_url = require("url");
|
|
45
50
|
var import_node_os = require("os");
|
|
46
|
-
var import_gray_matter = __toESM(require("gray-matter"), 1);
|
|
47
51
|
async function cleanup(projectDirectory) {
|
|
48
52
|
const filePath = import_node_path.default.join(projectDirectory, "eventcatalog.config.mjs");
|
|
49
53
|
if ((0, import_node_fs.existsSync)(filePath)) {
|
|
@@ -91,7 +95,7 @@ var getEventCatalogConfigFile = async (projectDirectory) => {
|
|
|
91
95
|
configFilePath = import_node_path.default.join(tempDir, "eventcatalog.config.mjs");
|
|
92
96
|
await (0, import_promises.copyFile)(import_node_path.default.join(projectDirectory, "eventcatalog.config.js"), configFilePath);
|
|
93
97
|
}
|
|
94
|
-
const configFileURL = `${(0,
|
|
98
|
+
const configFileURL = `${(0, import_node_url.pathToFileURL)(configFilePath).href}?t=${Date.now()}`;
|
|
95
99
|
const config = await import(
|
|
96
100
|
/* @vite-ignore */
|
|
97
101
|
configFileURL
|
|
@@ -104,10 +108,12 @@ var getEventCatalogConfigFile = async (projectDirectory) => {
|
|
|
104
108
|
}
|
|
105
109
|
}
|
|
106
110
|
};
|
|
111
|
+
|
|
112
|
+
// src/eventcatalog-config-file-utils.js
|
|
107
113
|
var writeEventCatalogConfigFile = async (projectDirectory, newConfig) => {
|
|
108
114
|
try {
|
|
109
|
-
const configFilePath =
|
|
110
|
-
let content = await (0,
|
|
115
|
+
const configFilePath = import_node_path2.default.join(projectDirectory, "eventcatalog.config.js");
|
|
116
|
+
let content = await (0, import_promises2.readFile)(configFilePath, "utf8");
|
|
111
117
|
const startIndex = content.indexOf("export default {");
|
|
112
118
|
if (startIndex === -1) {
|
|
113
119
|
return;
|
|
@@ -123,7 +129,7 @@ var writeEventCatalogConfigFile = async (projectDirectory, newConfig) => {
|
|
|
123
129
|
${key}: ${valueString},` + content.slice(insertPosition);
|
|
124
130
|
}
|
|
125
131
|
});
|
|
126
|
-
await (0,
|
|
132
|
+
await (0, import_promises2.writeFile)(configFilePath, content);
|
|
127
133
|
} finally {
|
|
128
134
|
await cleanup(projectDirectory);
|
|
129
135
|
}
|
|
@@ -1,6 +1,90 @@
|
|
|
1
|
-
|
|
1
|
+
import { rm, readFile, copyFile, mkdtemp, symlink } from 'node:fs/promises';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
|
|
7
|
+
async function cleanup(projectDirectory) {
|
|
8
|
+
const filePath = path.join(projectDirectory, 'eventcatalog.config.mjs');
|
|
9
|
+
if (existsSync(filePath)) {
|
|
10
|
+
await rm(filePath);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const findNodeModulesDirectory = (directory) => {
|
|
15
|
+
let currentDirectory = directory;
|
|
16
|
+
|
|
17
|
+
while (true) {
|
|
18
|
+
const nodeModulesDirectory = path.join(currentDirectory, 'node_modules');
|
|
19
|
+
|
|
20
|
+
if (existsSync(nodeModulesDirectory)) {
|
|
21
|
+
return nodeModulesDirectory;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const parentDirectory = path.dirname(currentDirectory);
|
|
25
|
+
|
|
26
|
+
if (parentDirectory === currentDirectory) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
currentDirectory = parentDirectory;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const linkNodeModulesIntoTempDirectory = async ({ projectDirectory, tempDir }) => {
|
|
35
|
+
const nodeModulesDirectory = findNodeModulesDirectory(projectDirectory);
|
|
36
|
+
|
|
37
|
+
if (!nodeModulesDirectory) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
await symlink(nodeModulesDirectory, path.join(tempDir, 'node_modules'), 'dir');
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const createTemporaryConfigDirectory = async (projectDirectory) => {
|
|
45
|
+
const nodeModulesDirectory = findNodeModulesDirectory(projectDirectory);
|
|
46
|
+
|
|
47
|
+
if (nodeModulesDirectory) {
|
|
48
|
+
return mkdtemp(path.join(nodeModulesDirectory, '.eventcatalog-config-'));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const tempDir = await mkdtemp(path.join(tmpdir(), 'eventcatalog-config-'));
|
|
52
|
+
await linkNodeModulesIntoTempDirectory({ projectDirectory, tempDir });
|
|
53
|
+
return tempDir;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const getEventCatalogConfigFile = async (projectDirectory) => {
|
|
57
|
+
let tempDir;
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
let configFilePath = path.join(projectDirectory, 'eventcatalog.config.js');
|
|
61
|
+
|
|
62
|
+
const filePath = path.join(projectDirectory, 'package.json');
|
|
63
|
+
const packageJson = JSON.parse(await readFile(filePath, 'utf-8'));
|
|
64
|
+
|
|
65
|
+
if (packageJson?.type !== 'module') {
|
|
66
|
+
// Importing CommonJS config via ESM import requires an .mjs file.
|
|
67
|
+
// Keep this temp copy outside the project directory so Astro/Vite
|
|
68
|
+
// file watchers do not trigger a dev-server restart during startup.
|
|
69
|
+
tempDir = await createTemporaryConfigDirectory(projectDirectory);
|
|
70
|
+
configFilePath = path.join(tempDir, 'eventcatalog.config.mjs');
|
|
71
|
+
await copyFile(path.join(projectDirectory, 'eventcatalog.config.js'), configFilePath);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const configFileURL = `${pathToFileURL(configFilePath).href}?t=${Date.now()}`;
|
|
75
|
+
const config = await import(/* @vite-ignore */ configFileURL);
|
|
76
|
+
|
|
77
|
+
return config.default;
|
|
78
|
+
} finally {
|
|
79
|
+
await cleanup(projectDirectory);
|
|
80
|
+
|
|
81
|
+
if (tempDir) {
|
|
82
|
+
await rm(tempDir, { recursive: true, force: true });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
2
87
|
declare function addPropertyToFrontMatter(input: any, newProperty: any, newValue: any): string;
|
|
3
|
-
declare function getEventCatalogConfigFile(projectDirectory: any): Promise<any>;
|
|
4
88
|
declare function writeEventCatalogConfigFile(projectDirectory: any, newConfig: any): Promise<void>;
|
|
5
89
|
declare function verifyRequiredFieldsAreInCatalogConfigFile(projectDirectory: any): Promise<void>;
|
|
6
90
|
|
|
@@ -1,6 +1,90 @@
|
|
|
1
|
-
|
|
1
|
+
import { rm, readFile, copyFile, mkdtemp, symlink } from 'node:fs/promises';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
|
|
7
|
+
async function cleanup(projectDirectory) {
|
|
8
|
+
const filePath = path.join(projectDirectory, 'eventcatalog.config.mjs');
|
|
9
|
+
if (existsSync(filePath)) {
|
|
10
|
+
await rm(filePath);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const findNodeModulesDirectory = (directory) => {
|
|
15
|
+
let currentDirectory = directory;
|
|
16
|
+
|
|
17
|
+
while (true) {
|
|
18
|
+
const nodeModulesDirectory = path.join(currentDirectory, 'node_modules');
|
|
19
|
+
|
|
20
|
+
if (existsSync(nodeModulesDirectory)) {
|
|
21
|
+
return nodeModulesDirectory;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const parentDirectory = path.dirname(currentDirectory);
|
|
25
|
+
|
|
26
|
+
if (parentDirectory === currentDirectory) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
currentDirectory = parentDirectory;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const linkNodeModulesIntoTempDirectory = async ({ projectDirectory, tempDir }) => {
|
|
35
|
+
const nodeModulesDirectory = findNodeModulesDirectory(projectDirectory);
|
|
36
|
+
|
|
37
|
+
if (!nodeModulesDirectory) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
await symlink(nodeModulesDirectory, path.join(tempDir, 'node_modules'), 'dir');
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const createTemporaryConfigDirectory = async (projectDirectory) => {
|
|
45
|
+
const nodeModulesDirectory = findNodeModulesDirectory(projectDirectory);
|
|
46
|
+
|
|
47
|
+
if (nodeModulesDirectory) {
|
|
48
|
+
return mkdtemp(path.join(nodeModulesDirectory, '.eventcatalog-config-'));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const tempDir = await mkdtemp(path.join(tmpdir(), 'eventcatalog-config-'));
|
|
52
|
+
await linkNodeModulesIntoTempDirectory({ projectDirectory, tempDir });
|
|
53
|
+
return tempDir;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const getEventCatalogConfigFile = async (projectDirectory) => {
|
|
57
|
+
let tempDir;
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
let configFilePath = path.join(projectDirectory, 'eventcatalog.config.js');
|
|
61
|
+
|
|
62
|
+
const filePath = path.join(projectDirectory, 'package.json');
|
|
63
|
+
const packageJson = JSON.parse(await readFile(filePath, 'utf-8'));
|
|
64
|
+
|
|
65
|
+
if (packageJson?.type !== 'module') {
|
|
66
|
+
// Importing CommonJS config via ESM import requires an .mjs file.
|
|
67
|
+
// Keep this temp copy outside the project directory so Astro/Vite
|
|
68
|
+
// file watchers do not trigger a dev-server restart during startup.
|
|
69
|
+
tempDir = await createTemporaryConfigDirectory(projectDirectory);
|
|
70
|
+
configFilePath = path.join(tempDir, 'eventcatalog.config.mjs');
|
|
71
|
+
await copyFile(path.join(projectDirectory, 'eventcatalog.config.js'), configFilePath);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const configFileURL = `${pathToFileURL(configFilePath).href}?t=${Date.now()}`;
|
|
75
|
+
const config = await import(/* @vite-ignore */ configFileURL);
|
|
76
|
+
|
|
77
|
+
return config.default;
|
|
78
|
+
} finally {
|
|
79
|
+
await cleanup(projectDirectory);
|
|
80
|
+
|
|
81
|
+
if (tempDir) {
|
|
82
|
+
await rm(tempDir, { recursive: true, force: true });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
2
87
|
declare function addPropertyToFrontMatter(input: any, newProperty: any, newValue: any): string;
|
|
3
|
-
declare function getEventCatalogConfigFile(projectDirectory: any): Promise<any>;
|
|
4
88
|
declare function writeEventCatalogConfigFile(projectDirectory: any, newConfig: any): Promise<void>;
|
|
5
89
|
declare function verifyRequiredFieldsAreInCatalogConfigFile(projectDirectory: any): Promise<void>;
|
|
6
90
|
|