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