@eventcatalog/core 4.7.1 → 4.7.3
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 +1 -1
- package/dist/analytics/log-build.js +3 -3
- package/dist/catalog-to-astro-content-directory.cjs +65 -13
- package/dist/catalog-to-astro-content-directory.js +2 -1
- package/dist/{chunk-B2DV3HIK.js → chunk-GINIJSFI.js} +3 -3
- package/dist/{chunk-NK3O75ST.js → chunk-IALEXWSE.js} +1 -1
- package/dist/{chunk-DRXKILAB.js → chunk-SMDTRRED.js} +1 -1
- package/dist/{chunk-W3SAPOZU.js → chunk-T4RVWPIQ.js} +6 -0
- package/dist/chunk-T5IUG523.js +54 -0
- package/dist/{chunk-U7HRSTMK.js → chunk-V4FAVGI7.js} +1 -1
- package/dist/{chunk-QC6KK6U7.js → chunk-XXJX3WWF.js} +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/custom-components.cjs +89 -0
- package/dist/custom-components.d.cts +4 -0
- package/dist/custom-components.d.ts +4 -0
- package/dist/custom-components.js +8 -0
- package/dist/eventcatalog.cjs +206 -152
- package/dist/eventcatalog.js +12 -11
- package/dist/generate.cjs +1 -1
- package/dist/generate.js +3 -3
- package/dist/utils/cli-logger.cjs +1 -1
- package/dist/utils/cli-logger.js +2 -2
- package/package.json +2 -2
package/dist/eventcatalog.cjs
CHANGED
|
@@ -29,10 +29,10 @@ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
|
29
29
|
// src/eventcatalog.ts
|
|
30
30
|
var import_commander = require("commander");
|
|
31
31
|
var import_node_child_process2 = require("child_process");
|
|
32
|
-
var
|
|
32
|
+
var import_node_path15 = require("path");
|
|
33
33
|
var import_node_http = __toESM(require("http"), 1);
|
|
34
34
|
var import_fs3 = __toESM(require("fs"), 1);
|
|
35
|
-
var
|
|
35
|
+
var import_node_path16 = __toESM(require("path"), 1);
|
|
36
36
|
var import_node_url = require("url");
|
|
37
37
|
|
|
38
38
|
// src/generate.js
|
|
@@ -144,7 +144,7 @@ var verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
|
|
|
144
144
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
145
145
|
|
|
146
146
|
// package.json
|
|
147
|
-
var version = "4.7.
|
|
147
|
+
var version = "4.7.3";
|
|
148
148
|
|
|
149
149
|
// src/constants.ts
|
|
150
150
|
var VERSION = version;
|
|
@@ -632,29 +632,82 @@ function retryEPERM(fn) {
|
|
|
632
632
|
|
|
633
633
|
// src/catalog-to-astro-content-directory.js
|
|
634
634
|
var import_glob2 = require("glob");
|
|
635
|
-
var
|
|
635
|
+
var path5 = __toESM(require("path"), 1);
|
|
636
636
|
var import_fs = __toESM(require("fs"), 1);
|
|
637
637
|
var import_url2 = require("url");
|
|
638
638
|
var import_node_os2 = __toESM(require("os"), 1);
|
|
639
|
+
|
|
640
|
+
// src/custom-components.js
|
|
641
|
+
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
642
|
+
var import_node_path4 = __toESM(require("path"), 1);
|
|
643
|
+
var isCustomComponentPath = (projectDirectory, filePath) => {
|
|
644
|
+
const [rootDirectory, childDirectory] = import_node_path4.default.relative(projectDirectory, filePath).split(import_node_path4.default.sep);
|
|
645
|
+
return rootDirectory === "components" || rootDirectory === "federated" && childDirectory === "components";
|
|
646
|
+
};
|
|
647
|
+
var readDirectory = async (directory) => {
|
|
648
|
+
try {
|
|
649
|
+
return await import_promises2.default.readdir(directory, { withFileTypes: true });
|
|
650
|
+
} catch (error) {
|
|
651
|
+
if (error.code === "ENOENT") return [];
|
|
652
|
+
throw error;
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
var mergeDirectory = async (sourceDirectory, destinationDirectory) => {
|
|
656
|
+
for (const entry of await readDirectory(sourceDirectory)) {
|
|
657
|
+
const sourcePath = import_node_path4.default.join(sourceDirectory, entry.name);
|
|
658
|
+
const destinationPath = import_node_path4.default.join(destinationDirectory, entry.name);
|
|
659
|
+
if (entry.isDirectory()) {
|
|
660
|
+
const destinationEntry = await import_promises2.default.stat(destinationPath).catch((error) => {
|
|
661
|
+
if (error.code === "ENOENT") return void 0;
|
|
662
|
+
throw error;
|
|
663
|
+
});
|
|
664
|
+
if (destinationEntry && !destinationEntry.isDirectory()) {
|
|
665
|
+
await import_promises2.default.rm(destinationPath, { recursive: true, force: true });
|
|
666
|
+
}
|
|
667
|
+
await import_promises2.default.mkdir(destinationPath, { recursive: true });
|
|
668
|
+
await mergeDirectory(sourcePath, destinationPath);
|
|
669
|
+
continue;
|
|
670
|
+
}
|
|
671
|
+
await import_promises2.default.rm(destinationPath, { recursive: true, force: true });
|
|
672
|
+
await import_promises2.default.copyFile(sourcePath, destinationPath);
|
|
673
|
+
}
|
|
674
|
+
};
|
|
675
|
+
var syncCustomComponents = async (projectDirectory, catalogDirectory) => {
|
|
676
|
+
const destinationDirectory = import_node_path4.default.join(catalogDirectory, "src", "custom-defined-components");
|
|
677
|
+
const destinationParent = import_node_path4.default.dirname(destinationDirectory);
|
|
678
|
+
await import_promises2.default.mkdir(destinationParent, { recursive: true });
|
|
679
|
+
const stagingDirectory = await import_promises2.default.mkdtemp(import_node_path4.default.join(destinationParent, ".custom-defined-components.staging-"));
|
|
680
|
+
try {
|
|
681
|
+
await mergeDirectory(import_node_path4.default.join(projectDirectory, "federated", "components"), stagingDirectory);
|
|
682
|
+
await mergeDirectory(import_node_path4.default.join(projectDirectory, "components"), stagingDirectory);
|
|
683
|
+
await import_promises2.default.rm(destinationDirectory, { recursive: true, force: true });
|
|
684
|
+
await import_promises2.default.rename(stagingDirectory, destinationDirectory);
|
|
685
|
+
} finally {
|
|
686
|
+
await import_promises2.default.rm(stagingDirectory, { recursive: true, force: true });
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
|
|
690
|
+
// src/catalog-to-astro-content-directory.js
|
|
639
691
|
var __filename2 = (0, import_url2.fileURLToPath)(importMetaUrl);
|
|
640
|
-
var rootPkg =
|
|
692
|
+
var rootPkg = path5.resolve(path5.dirname(__filename2), "../");
|
|
641
693
|
var copyFiles = async (source, target) => {
|
|
642
|
-
const files = await (0, import_glob2.glob)(
|
|
694
|
+
const files = await (0, import_glob2.glob)(path5.join(source, "**"), {
|
|
643
695
|
nodir: true,
|
|
644
696
|
windowsPathsNoEscape: import_node_os2.default.platform() == "win32",
|
|
645
697
|
ignore: ["node_modules/**", "**/dist/**", "**/teams", "**/users", "**/*.mdx", "**/*.md", "**/package.json", "**/Dockerfile"]
|
|
646
698
|
});
|
|
647
|
-
const snippets = await (0, import_glob2.glob)(
|
|
699
|
+
const snippets = await (0, import_glob2.glob)(path5.join(source, "snippets/**/*.mdx"), {
|
|
648
700
|
nodir: true,
|
|
649
701
|
windowsPathsNoEscape: import_node_os2.default.platform() == "win32"
|
|
650
702
|
});
|
|
651
703
|
if (snippets.length > 0) {
|
|
652
704
|
files.push(...snippets);
|
|
653
705
|
}
|
|
654
|
-
if (import_fs.default.existsSync(
|
|
655
|
-
files.push(
|
|
706
|
+
if (import_fs.default.existsSync(path5.join(source, ".env"))) {
|
|
707
|
+
files.push(path5.join(source, ".env"));
|
|
656
708
|
}
|
|
657
709
|
for (const file of files) {
|
|
710
|
+
if (isCustomComponentPath(source, file)) continue;
|
|
658
711
|
mapCatalogToAstro({
|
|
659
712
|
filePath: file,
|
|
660
713
|
astroDir: target,
|
|
@@ -666,9 +719,9 @@ var copyFiles = async (source, target) => {
|
|
|
666
719
|
}
|
|
667
720
|
};
|
|
668
721
|
var clearCustomPages = async (target) => {
|
|
669
|
-
const customPagesDir =
|
|
722
|
+
const customPagesDir = path5.join(target, "src", "custom-pages");
|
|
670
723
|
if (import_fs.default.existsSync(customPagesDir)) import_fs.default.rmSync(customPagesDir, { recursive: true });
|
|
671
|
-
const staleCodeFiles = await (0, import_glob2.glob)(
|
|
724
|
+
const staleCodeFiles = await (0, import_glob2.glob)(path5.join(target, "public", "generated", "pages", "**/*.{astro,ts,js,mjs}"), {
|
|
672
725
|
nodir: true,
|
|
673
726
|
windowsPathsNoEscape: import_node_os2.default.platform() == "win32"
|
|
674
727
|
});
|
|
@@ -677,8 +730,8 @@ var clearCustomPages = async (target) => {
|
|
|
677
730
|
}
|
|
678
731
|
};
|
|
679
732
|
var removeGeneratedLikeC4Sources = async (target) => {
|
|
680
|
-
const generatedDir =
|
|
681
|
-
const files = await (0, import_glob2.glob)(
|
|
733
|
+
const generatedDir = path5.join(target, "public", "generated");
|
|
734
|
+
const files = await (0, import_glob2.glob)(path5.join(generatedDir, "**/*.{c4,likec4}"), {
|
|
682
735
|
nodir: true,
|
|
683
736
|
windowsPathsNoEscape: import_node_os2.default.platform() == "win32"
|
|
684
737
|
});
|
|
@@ -687,20 +740,21 @@ var removeGeneratedLikeC4Sources = async (target) => {
|
|
|
687
740
|
}
|
|
688
741
|
};
|
|
689
742
|
var catalogToAstro = async (source, astroDir) => {
|
|
690
|
-
const astroContentDir =
|
|
743
|
+
const astroContentDir = path5.join(astroDir, "src/content/");
|
|
691
744
|
if (import_fs.default.existsSync(astroContentDir)) import_fs.default.rmSync(astroContentDir, { recursive: true });
|
|
692
745
|
import_fs.default.mkdirSync(astroContentDir);
|
|
693
746
|
await verifyRequiredFieldsAreInCatalogConfigFile(source);
|
|
694
|
-
if (!import_fs.default.existsSync(
|
|
695
|
-
import_fs.default.writeFileSync(
|
|
747
|
+
if (!import_fs.default.existsSync(path5.join(source, "eventcatalog.styles.css"))) {
|
|
748
|
+
import_fs.default.writeFileSync(path5.join(source, "eventcatalog.styles.css"), "");
|
|
696
749
|
}
|
|
697
750
|
await clearCustomPages(astroDir);
|
|
698
751
|
await removeGeneratedLikeC4Sources(astroDir);
|
|
752
|
+
await syncCustomComponents(source, astroDir);
|
|
699
753
|
await copyFiles(source, astroDir);
|
|
700
754
|
};
|
|
701
755
|
|
|
702
756
|
// src/resolve-catalog-dependencies.js
|
|
703
|
-
var
|
|
757
|
+
var import_node_path5 = __toESM(require("path"), 1);
|
|
704
758
|
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
705
759
|
var import_gray_matter2 = __toESM(require("gray-matter"), 1);
|
|
706
760
|
var resolve_catalog_dependencies_default = async (catalogDir, core2) => {
|
|
@@ -709,7 +763,7 @@ var resolve_catalog_dependencies_default = async (catalogDir, core2) => {
|
|
|
709
763
|
if (!dependencies) {
|
|
710
764
|
return;
|
|
711
765
|
}
|
|
712
|
-
const dependenciesDir =
|
|
766
|
+
const dependenciesDir = import_node_path5.default.join(catalogDir, "dependencies");
|
|
713
767
|
if (import_node_fs3.default.existsSync(dependenciesDir)) {
|
|
714
768
|
import_node_fs3.default.rmSync(dependenciesDir, { recursive: true, force: true });
|
|
715
769
|
}
|
|
@@ -733,8 +787,8 @@ var resolve_catalog_dependencies_default = async (catalogDir, core2) => {
|
|
|
733
787
|
},
|
|
734
788
|
frontmatter
|
|
735
789
|
);
|
|
736
|
-
const resourceFile =
|
|
737
|
-
import_node_fs3.default.mkdirSync(
|
|
790
|
+
const resourceFile = import_node_path5.default.join(dependenciesDir, resourceType, dependency.id, `index.md`);
|
|
791
|
+
import_node_fs3.default.mkdirSync(import_node_path5.default.dirname(resourceFile), { recursive: true });
|
|
738
792
|
import_node_fs3.default.writeFileSync(resourceFile, markdown);
|
|
739
793
|
}
|
|
740
794
|
}
|
|
@@ -745,7 +799,7 @@ var resolve_catalog_dependencies_default = async (catalogDir, core2) => {
|
|
|
745
799
|
var import_boxen = __toESM(require("boxen"), 1);
|
|
746
800
|
|
|
747
801
|
// src/features.ts
|
|
748
|
-
var
|
|
802
|
+
var import_node_path6 = require("path");
|
|
749
803
|
var import_node_fs4 = __toESM(require("fs"), 1);
|
|
750
804
|
var getProjectOutDir = async () => {
|
|
751
805
|
const config = await getEventCatalogConfigFile(process.env.PROJECT_DIR || "");
|
|
@@ -761,7 +815,7 @@ var isIndexedSearchEnabled = async () => {
|
|
|
761
815
|
};
|
|
762
816
|
var isAuthEnabled = async () => {
|
|
763
817
|
const directory = process.env.PROJECT_DIR || process.cwd();
|
|
764
|
-
const hasAuthConfig = import_node_fs4.default.existsSync((0,
|
|
818
|
+
const hasAuthConfig = import_node_fs4.default.existsSync((0, import_node_path6.join)(directory, "eventcatalog.auth.js"));
|
|
765
819
|
return hasAuthConfig;
|
|
766
820
|
};
|
|
767
821
|
|
|
@@ -774,7 +828,7 @@ var import_node_fs5 = __toESM(require("fs"), 1);
|
|
|
774
828
|
var import_glob3 = require("glob");
|
|
775
829
|
var import_node_os3 = __toESM(require("os"), 1);
|
|
776
830
|
var import_gray_matter3 = __toESM(require("gray-matter"), 1);
|
|
777
|
-
var
|
|
831
|
+
var import_node_path7 = __toESM(require("path"), 1);
|
|
778
832
|
var DISABLE_CHANNEL_MIGRATION_ENV = "EVENTCATALOG_DISABLE_CHANNEL_MIGRATION";
|
|
779
833
|
var isChannelMigrationDisabled = () => {
|
|
780
834
|
return ["true", "1", "yes"].includes((process.env[DISABLE_CHANNEL_MIGRATION_ENV] ?? "").toLowerCase());
|
|
@@ -783,7 +837,7 @@ var message_channels_to_service_channels_default = async (dir2) => {
|
|
|
783
837
|
if (isChannelMigrationDisabled()) {
|
|
784
838
|
return { status: "skipped", message: `Channel migration disabled by ${DISABLE_CHANNEL_MIGRATION_ENV}` };
|
|
785
839
|
}
|
|
786
|
-
const PROJECT_DIR =
|
|
840
|
+
const PROJECT_DIR = import_node_path7.default.join(dir2 || process.env.PROJECT_DIR);
|
|
787
841
|
const messages = await (0, import_glob3.glob)(
|
|
788
842
|
[
|
|
789
843
|
"**/events/*/index.mdx",
|
|
@@ -890,7 +944,7 @@ var runMigrations = async (dir2) => {
|
|
|
890
944
|
};
|
|
891
945
|
|
|
892
946
|
// eventcatalog/src/enterprise/fields/field-indexer.ts
|
|
893
|
-
var
|
|
947
|
+
var import_node_path8 = __toESM(require("path"), 1);
|
|
894
948
|
var import_node_fs7 = __toESM(require("fs"), 1);
|
|
895
949
|
|
|
896
950
|
// eventcatalog/src/enterprise/fields/fields-db.ts
|
|
@@ -1256,22 +1310,22 @@ function getAvroTypeName(type) {
|
|
|
1256
1310
|
function walkAvroRecord(schema, prefix, fields) {
|
|
1257
1311
|
if (!schema.fields || !Array.isArray(schema.fields)) return;
|
|
1258
1312
|
for (const field of schema.fields) {
|
|
1259
|
-
const
|
|
1313
|
+
const path16 = prefix ? `${prefix}.${field.name}` : field.name;
|
|
1260
1314
|
const isOptional = Array.isArray(field.type) && field.type.includes("null");
|
|
1261
1315
|
const typeName = getAvroTypeName(field.type);
|
|
1262
1316
|
fields.push({
|
|
1263
|
-
path:
|
|
1317
|
+
path: path16,
|
|
1264
1318
|
type: typeName,
|
|
1265
1319
|
description: field.doc || "",
|
|
1266
1320
|
required: !isOptional
|
|
1267
1321
|
});
|
|
1268
1322
|
const innerType = Array.isArray(field.type) ? field.type.find((t) => typeof t === "object" && t.type === "record") : typeof field.type === "object" && field.type.type === "record" ? field.type : null;
|
|
1269
1323
|
if (innerType) {
|
|
1270
|
-
walkAvroRecord(innerType,
|
|
1324
|
+
walkAvroRecord(innerType, path16, fields);
|
|
1271
1325
|
}
|
|
1272
1326
|
const arrayType = Array.isArray(field.type) ? field.type.find((t) => typeof t === "object" && t.type === "array") : typeof field.type === "object" && field.type.type === "array" ? field.type : null;
|
|
1273
1327
|
if (arrayType && typeof arrayType.items === "object" && arrayType.items.type === "record") {
|
|
1274
|
-
walkAvroRecord(arrayType.items, `${
|
|
1328
|
+
walkAvroRecord(arrayType.items, `${path16}[]`, fields);
|
|
1275
1329
|
}
|
|
1276
1330
|
}
|
|
1277
1331
|
}
|
|
@@ -1302,32 +1356,32 @@ function walkJsonSchema(node, prefix, requiredList, rootSchema, fields) {
|
|
|
1302
1356
|
}
|
|
1303
1357
|
if (!node.properties) return;
|
|
1304
1358
|
for (const [name, prop] of Object.entries(node.properties)) {
|
|
1305
|
-
const
|
|
1359
|
+
const path16 = prefix ? `${prefix}.${name}` : name;
|
|
1306
1360
|
const isRequired = requiredList.includes(name);
|
|
1307
1361
|
if (prop.$ref) {
|
|
1308
1362
|
const resolved = resolveLocalRef(prop.$ref, rootSchema);
|
|
1309
1363
|
if (resolved) {
|
|
1310
1364
|
const rawRefType = resolved.type || "object";
|
|
1311
1365
|
const type2 = Array.isArray(rawRefType) ? [...rawRefType].sort().join(" | ") : rawRefType;
|
|
1312
|
-
fields.push({ path:
|
|
1366
|
+
fields.push({ path: path16, type: type2, description: resolved.description || "", required: isRequired });
|
|
1313
1367
|
if (resolved.properties) {
|
|
1314
|
-
walkJsonSchema(resolved,
|
|
1368
|
+
walkJsonSchema(resolved, path16, resolved.required || [], rootSchema, fields);
|
|
1315
1369
|
}
|
|
1316
1370
|
} else {
|
|
1317
|
-
fields.push({ path:
|
|
1371
|
+
fields.push({ path: path16, type: "$ref", description: "", required: isRequired });
|
|
1318
1372
|
}
|
|
1319
1373
|
continue;
|
|
1320
1374
|
}
|
|
1321
1375
|
const rawType = prop.type || (prop.enum ? "enum" : prop.$ref ? "$ref" : "object");
|
|
1322
1376
|
const typeList = Array.isArray(rawType) ? rawType : [rawType];
|
|
1323
1377
|
const type = Array.isArray(rawType) ? [...rawType].sort().join(" | ") : rawType;
|
|
1324
|
-
fields.push({ path:
|
|
1378
|
+
fields.push({ path: path16, type, description: prop.description || "", required: isRequired });
|
|
1325
1379
|
if (typeList.includes("object") && prop.properties) {
|
|
1326
|
-
walkJsonSchema(prop,
|
|
1380
|
+
walkJsonSchema(prop, path16, prop.required || [], rootSchema, fields);
|
|
1327
1381
|
}
|
|
1328
1382
|
if (typeList.includes("array") && prop.items) {
|
|
1329
1383
|
if (prop.items.type === "object" && prop.items.properties) {
|
|
1330
|
-
walkJsonSchema(prop.items, `${
|
|
1384
|
+
walkJsonSchema(prop.items, `${path16}[]`, prop.items.required || [], rootSchema, fields);
|
|
1331
1385
|
}
|
|
1332
1386
|
}
|
|
1333
1387
|
}
|
|
@@ -1345,7 +1399,7 @@ function resolveLocalRef(ref, rootSchema) {
|
|
|
1345
1399
|
|
|
1346
1400
|
// eventcatalog/src/enterprise/fields/field-indexer.ts
|
|
1347
1401
|
function detectFormat(fileName) {
|
|
1348
|
-
const ext =
|
|
1402
|
+
const ext = import_node_path8.default.extname(fileName).toLowerCase();
|
|
1349
1403
|
if (ext === ".proto") return "proto";
|
|
1350
1404
|
if (ext === ".avro" || ext === ".avsc") return "avro";
|
|
1351
1405
|
return "json-schema";
|
|
@@ -1353,8 +1407,8 @@ function detectFormat(fileName) {
|
|
|
1353
1407
|
async function buildFieldsIndex(catalogDir, outputDir) {
|
|
1354
1408
|
const sdkModule = await import("@eventcatalog/sdk");
|
|
1355
1409
|
const sdk = sdkModule.default(catalogDir);
|
|
1356
|
-
const dbDir =
|
|
1357
|
-
const dbPath =
|
|
1410
|
+
const dbDir = import_node_path8.default.join(outputDir || catalogDir, ".eventcatalog");
|
|
1411
|
+
const dbPath = import_node_path8.default.join(dbDir, "fields.db");
|
|
1358
1412
|
if (!import_node_fs7.default.existsSync(dbDir)) {
|
|
1359
1413
|
import_node_fs7.default.mkdirSync(dbDir, { recursive: true });
|
|
1360
1414
|
}
|
|
@@ -1439,8 +1493,8 @@ async function buildFieldsIndex(catalogDir, outputDir) {
|
|
|
1439
1493
|
}
|
|
1440
1494
|
|
|
1441
1495
|
// src/search-indexer.ts
|
|
1442
|
-
var
|
|
1443
|
-
var
|
|
1496
|
+
var import_promises3 = __toESM(require("fs/promises"), 1);
|
|
1497
|
+
var import_node_path9 = __toESM(require("path"), 1);
|
|
1444
1498
|
var import_glob4 = require("glob");
|
|
1445
1499
|
var import_gray_matter4 = __toESM(require("gray-matter"), 1);
|
|
1446
1500
|
var RESOURCE_COLLECTIONS = {
|
|
@@ -1499,9 +1553,9 @@ var markdownToSearchText = (content) => {
|
|
|
1499
1553
|
};
|
|
1500
1554
|
var inferDocIdFromFile = (relativePath, frontmatterId) => {
|
|
1501
1555
|
if (frontmatterId) return frontmatterId;
|
|
1502
|
-
const fileName =
|
|
1556
|
+
const fileName = import_node_path9.default.posix.basename(removeExtension(relativePath));
|
|
1503
1557
|
if (fileName.toLowerCase() === "index") {
|
|
1504
|
-
return
|
|
1558
|
+
return import_node_path9.default.posix.basename(import_node_path9.default.posix.dirname(relativePath));
|
|
1505
1559
|
}
|
|
1506
1560
|
return stripNumericPrefix(fileName);
|
|
1507
1561
|
};
|
|
@@ -1519,10 +1573,10 @@ var findResourceSegment = (segments) => {
|
|
|
1519
1573
|
return match;
|
|
1520
1574
|
};
|
|
1521
1575
|
var readResourceFrontmatter = async (projectDir, resourcePath) => {
|
|
1522
|
-
const candidates = [
|
|
1576
|
+
const candidates = [import_node_path9.default.join(projectDir, resourcePath, "index.mdx"), import_node_path9.default.join(projectDir, resourcePath, "index.md")];
|
|
1523
1577
|
for (const candidate of candidates) {
|
|
1524
1578
|
try {
|
|
1525
|
-
const file = await
|
|
1579
|
+
const file = await import_promises3.default.readFile(candidate, "utf8");
|
|
1526
1580
|
return (0, import_gray_matter4.default)(file).data;
|
|
1527
1581
|
} catch {
|
|
1528
1582
|
}
|
|
@@ -1544,7 +1598,7 @@ var deriveRecordFromPath = async ({
|
|
|
1544
1598
|
}
|
|
1545
1599
|
if (segments[0] === "docs") {
|
|
1546
1600
|
const customPath = normalizeUrlPath(removeExtension(segments.slice(1).join("/")));
|
|
1547
|
-
const title = data.title || data.label ||
|
|
1601
|
+
const title = data.title || data.label || import_node_path9.default.posix.basename(customPath) || "Custom docs";
|
|
1548
1602
|
return {
|
|
1549
1603
|
url: buildUrl(`/docs/custom/${customPath}`, config),
|
|
1550
1604
|
title,
|
|
@@ -1660,9 +1714,9 @@ var collectSearchRecords = async ({
|
|
|
1660
1714
|
});
|
|
1661
1715
|
const records = await Promise.all(
|
|
1662
1716
|
files.map(async (file) => {
|
|
1663
|
-
const raw = await
|
|
1717
|
+
const raw = await import_promises3.default.readFile(file, "utf8");
|
|
1664
1718
|
const parsed = (0, import_gray_matter4.default)(raw);
|
|
1665
|
-
const relativePath = normalizePath(
|
|
1719
|
+
const relativePath = normalizePath(import_node_path9.default.relative(projectDir, file));
|
|
1666
1720
|
const baseRecord = await deriveRecordFromPath({
|
|
1667
1721
|
projectDir,
|
|
1668
1722
|
relativePath,
|
|
@@ -1709,7 +1763,7 @@ var getSearchOutputPath = ({
|
|
|
1709
1763
|
if (searchOutputPath) {
|
|
1710
1764
|
return searchOutputPath;
|
|
1711
1765
|
}
|
|
1712
|
-
return
|
|
1766
|
+
return import_node_path9.default.join(outDir, isServer ? "client" : "", "pagefind");
|
|
1713
1767
|
};
|
|
1714
1768
|
var buildSearchIndex = async ({ projectDir, outDir, config, isServer, searchOutputPath }) => {
|
|
1715
1769
|
const records = await collectSearchRecords({ projectDir, config });
|
|
@@ -1745,7 +1799,7 @@ var buildSearchIndex = async ({ projectDir, outDir, config, isServer, searchOutp
|
|
|
1745
1799
|
}
|
|
1746
1800
|
}
|
|
1747
1801
|
const outputPath = getSearchOutputPath({ outDir, isServer, searchOutputPath });
|
|
1748
|
-
await
|
|
1802
|
+
await import_promises3.default.rm(outputPath, { recursive: true, force: true });
|
|
1749
1803
|
const writeResult = await index.writeFiles({ outputPath });
|
|
1750
1804
|
if (writeResult.errors?.length) {
|
|
1751
1805
|
errors.push(...writeResult.errors.map((error) => error.message || String(error)));
|
|
@@ -1764,7 +1818,7 @@ ${errors.join("\n")}`);
|
|
|
1764
1818
|
|
|
1765
1819
|
// src/core-node-modules.ts
|
|
1766
1820
|
var import_fs2 = __toESM(require("fs"), 1);
|
|
1767
|
-
var
|
|
1821
|
+
var import_node_path10 = __toESM(require("path"), 1);
|
|
1768
1822
|
var isDirectory = (directory) => {
|
|
1769
1823
|
try {
|
|
1770
1824
|
return import_fs2.default.statSync(directory).isDirectory();
|
|
@@ -1774,7 +1828,7 @@ var isDirectory = (directory) => {
|
|
|
1774
1828
|
};
|
|
1775
1829
|
var hasAstroDependency = (nodeModulesDirectory) => {
|
|
1776
1830
|
const astroBin = process.platform === "win32" ? "astro.cmd" : "astro";
|
|
1777
|
-
return import_fs2.default.existsSync(
|
|
1831
|
+
return import_fs2.default.existsSync(import_node_path10.default.join(nodeModulesDirectory, "astro", "package.json")) || import_fs2.default.existsSync(import_node_path10.default.join(nodeModulesDirectory, ".bin", astroBin));
|
|
1778
1832
|
};
|
|
1779
1833
|
var isSymbolicLink = (targetPath) => {
|
|
1780
1834
|
try {
|
|
@@ -1794,20 +1848,20 @@ var resolveInstalledCoreNodeModules = (currentDir2) => {
|
|
|
1794
1848
|
const candidates = [];
|
|
1795
1849
|
const seen = /* @__PURE__ */ new Set();
|
|
1796
1850
|
const addCandidate = (candidate) => {
|
|
1797
|
-
const resolvedCandidate =
|
|
1851
|
+
const resolvedCandidate = import_node_path10.default.resolve(candidate);
|
|
1798
1852
|
if (!seen.has(resolvedCandidate)) {
|
|
1799
1853
|
candidates.push(resolvedCandidate);
|
|
1800
1854
|
seen.add(resolvedCandidate);
|
|
1801
1855
|
}
|
|
1802
1856
|
};
|
|
1803
|
-
addCandidate(
|
|
1804
|
-
let directory =
|
|
1857
|
+
addCandidate(import_node_path10.default.resolve(currentDir2, "..", "node_modules"));
|
|
1858
|
+
let directory = import_node_path10.default.resolve(currentDir2);
|
|
1805
1859
|
while (true) {
|
|
1806
|
-
if (
|
|
1860
|
+
if (import_node_path10.default.basename(directory) === "node_modules") {
|
|
1807
1861
|
addCandidate(directory);
|
|
1808
1862
|
}
|
|
1809
|
-
addCandidate(
|
|
1810
|
-
const parentDirectory =
|
|
1863
|
+
addCandidate(import_node_path10.default.join(directory, "node_modules"));
|
|
1864
|
+
const parentDirectory = import_node_path10.default.dirname(directory);
|
|
1811
1865
|
if (parentDirectory === directory) {
|
|
1812
1866
|
break;
|
|
1813
1867
|
}
|
|
@@ -1847,27 +1901,27 @@ var createAstroDevLineFilter = () => {
|
|
|
1847
1901
|
|
|
1848
1902
|
// src/federation/federate.ts
|
|
1849
1903
|
var import_node_crypto3 = require("crypto");
|
|
1850
|
-
var
|
|
1851
|
-
var
|
|
1904
|
+
var import_promises7 = __toESM(require("fs/promises"), 1);
|
|
1905
|
+
var import_node_path14 = __toESM(require("path"), 1);
|
|
1852
1906
|
var import_sdk2 = __toESM(require("@eventcatalog/sdk"), 1);
|
|
1853
1907
|
|
|
1854
1908
|
// src/federation/content-cache.ts
|
|
1855
1909
|
var import_node_crypto = require("crypto");
|
|
1856
|
-
var
|
|
1857
|
-
var
|
|
1910
|
+
var import_promises4 = __toESM(require("fs/promises"), 1);
|
|
1911
|
+
var import_node_path11 = __toESM(require("path"), 1);
|
|
1858
1912
|
var getContentHash = (content) => `sha256:${(0, import_node_crypto.createHash)("sha256").update(content).digest("hex")}`;
|
|
1859
1913
|
var isContentHash = (key) => /^sha256:[a-f0-9]{64}$/i.test(key);
|
|
1860
1914
|
var createFederationContentCache = (projectDirectory, options = {}) => {
|
|
1861
|
-
const cacheDirectory =
|
|
1862
|
-
const getCachePath = (key) =>
|
|
1915
|
+
const cacheDirectory = import_node_path11.default.join(projectDirectory, ".eventcatalog-cache", "federation", "content");
|
|
1916
|
+
const getCachePath = (key) => import_node_path11.default.join(cacheDirectory, encodeURIComponent(key));
|
|
1863
1917
|
return {
|
|
1864
1918
|
async get(key) {
|
|
1865
1919
|
if (options.read === false || !isContentHash(key)) return void 0;
|
|
1866
1920
|
const cachePath = getCachePath(key);
|
|
1867
1921
|
try {
|
|
1868
|
-
const content = await
|
|
1922
|
+
const content = await import_promises4.default.readFile(cachePath);
|
|
1869
1923
|
if (getContentHash(content) !== key) {
|
|
1870
|
-
await
|
|
1924
|
+
await import_promises4.default.rm(cachePath, { force: true });
|
|
1871
1925
|
return void 0;
|
|
1872
1926
|
}
|
|
1873
1927
|
options.onHit?.(key);
|
|
@@ -1879,14 +1933,14 @@ var createFederationContentCache = (projectDirectory, options = {}) => {
|
|
|
1879
1933
|
},
|
|
1880
1934
|
async set(key, content) {
|
|
1881
1935
|
if (!isContentHash(key) || getContentHash(content) !== key) return;
|
|
1882
|
-
await
|
|
1936
|
+
await import_promises4.default.mkdir(cacheDirectory, { recursive: true });
|
|
1883
1937
|
const cachePath = getCachePath(key);
|
|
1884
1938
|
const temporaryPath = `${cachePath}.tmp-${process.pid}-${(0, import_node_crypto.randomUUID)()}`;
|
|
1885
1939
|
try {
|
|
1886
|
-
await
|
|
1887
|
-
await
|
|
1940
|
+
await import_promises4.default.writeFile(temporaryPath, content);
|
|
1941
|
+
await import_promises4.default.rename(temporaryPath, cachePath);
|
|
1888
1942
|
} finally {
|
|
1889
|
-
await
|
|
1943
|
+
await import_promises4.default.rm(temporaryPath, { force: true });
|
|
1890
1944
|
}
|
|
1891
1945
|
}
|
|
1892
1946
|
};
|
|
@@ -1894,9 +1948,9 @@ var createFederationContentCache = (projectDirectory, options = {}) => {
|
|
|
1894
1948
|
|
|
1895
1949
|
// src/federation/github-source-provider.ts
|
|
1896
1950
|
var import_node_child_process = require("child_process");
|
|
1897
|
-
var
|
|
1951
|
+
var import_promises5 = __toESM(require("fs/promises"), 1);
|
|
1898
1952
|
var import_node_os4 = __toESM(require("os"), 1);
|
|
1899
|
-
var
|
|
1953
|
+
var import_node_path12 = __toESM(require("path"), 1);
|
|
1900
1954
|
var import_node_util = require("util");
|
|
1901
1955
|
var import_sdk = __toESM(require("@eventcatalog/sdk"), 1);
|
|
1902
1956
|
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
|
|
@@ -1907,8 +1961,8 @@ var parseGitHubSource = (source) => {
|
|
|
1907
1961
|
};
|
|
1908
1962
|
var assertSafeCatalogPath = (source) => {
|
|
1909
1963
|
const catalogPath = source.path ?? ".";
|
|
1910
|
-
const normalized =
|
|
1911
|
-
if (catalogPath.includes("\\") ||
|
|
1964
|
+
const normalized = import_node_path12.default.posix.normalize(catalogPath.replaceAll("\\", "/"));
|
|
1965
|
+
if (catalogPath.includes("\\") || import_node_path12.default.posix.isAbsolute(normalized) || normalized === ".." || normalized.startsWith("../")) {
|
|
1912
1966
|
throw new Error(`Catalog path "${catalogPath}" escapes source "${source.id}"`);
|
|
1913
1967
|
}
|
|
1914
1968
|
};
|
|
@@ -1951,8 +2005,8 @@ var getGitEnvironment = (token) => {
|
|
|
1951
2005
|
};
|
|
1952
2006
|
var createCheckout = (executeFile, token) => async (source, ref, callback) => {
|
|
1953
2007
|
const { owner, repository } = parseGitHubSource(source);
|
|
1954
|
-
const catalogPath =
|
|
1955
|
-
const directory = await
|
|
2008
|
+
const catalogPath = import_node_path12.default.posix.normalize(source.path ?? ".");
|
|
2009
|
+
const directory = await import_promises5.default.mkdtemp(import_node_path12.default.join(import_node_os4.default.tmpdir(), "eventcatalog-federation-"));
|
|
1956
2010
|
const env = getGitEnvironment(token);
|
|
1957
2011
|
try {
|
|
1958
2012
|
const git = (args) => executeFile("git", args, { cwd: directory, env, encoding: "utf8" });
|
|
@@ -1966,22 +2020,22 @@ var createCheckout = (executeFile, token) => async (source, ref, callback) => {
|
|
|
1966
2020
|
await git(["checkout", "--quiet", "--detach", "FETCH_HEAD"]);
|
|
1967
2021
|
return await callback(directory);
|
|
1968
2022
|
} finally {
|
|
1969
|
-
await
|
|
2023
|
+
await import_promises5.default.rm(directory, { recursive: true, force: true });
|
|
1970
2024
|
}
|
|
1971
2025
|
};
|
|
1972
2026
|
var generateIndex = async (source, ref, checkout, executeFile) => checkout(source, ref, async (directory) => {
|
|
1973
2027
|
const { stdout } = await executeFile("git", ["rev-parse", "HEAD"], { cwd: directory, encoding: "utf8" });
|
|
1974
2028
|
const commit = stdout.trim();
|
|
1975
|
-
const catalogDirectory =
|
|
1976
|
-
const relativeCatalogDirectory =
|
|
1977
|
-
if (relativeCatalogDirectory.startsWith("..") ||
|
|
2029
|
+
const catalogDirectory = import_node_path12.default.resolve(directory, source.path ?? ".");
|
|
2030
|
+
const relativeCatalogDirectory = import_node_path12.default.relative(directory, catalogDirectory);
|
|
2031
|
+
if (relativeCatalogDirectory.startsWith("..") || import_node_path12.default.isAbsolute(relativeCatalogDirectory)) {
|
|
1978
2032
|
throw new Error(`Catalog path "${source.path}" escapes source "${source.id}"`);
|
|
1979
2033
|
}
|
|
1980
2034
|
const index = await (0, import_sdk.default)(catalogDirectory).buildIndex({ source: source.id, commit });
|
|
1981
2035
|
return { bytes: Buffer.from(JSON.stringify(index)), index, commit, generated: true };
|
|
1982
2036
|
});
|
|
1983
2037
|
var fetchPublishedIndex = async (source, ref, fetcher, token) => {
|
|
1984
|
-
const indexPath =
|
|
2038
|
+
const indexPath = import_node_path12.default.posix.join(source.path ?? ".", "catalog.index.json");
|
|
1985
2039
|
const bytes = await fetchBytes(source, ref, indexPath, fetcher, token);
|
|
1986
2040
|
if (!bytes) return void 0;
|
|
1987
2041
|
const index = (0, import_sdk.parseIndex)(JSON.parse(bytes.toString("utf8")));
|
|
@@ -2004,7 +2058,7 @@ var createGitHubSourceProvider = (options = {}) => {
|
|
|
2004
2058
|
},
|
|
2005
2059
|
async fetchContent({ source, commit, path: artifactPath }) {
|
|
2006
2060
|
assertSafeCatalogPath(source);
|
|
2007
|
-
const catalogPath =
|
|
2061
|
+
const catalogPath = import_node_path12.default.posix.join(source.path ?? ".", artifactPath);
|
|
2008
2062
|
const content = await fetchBytes(source, commit, catalogPath, fetcher, token);
|
|
2009
2063
|
if (!content) throw new Error(`Federated artifact not found for "${source.id}": ${artifactPath}`);
|
|
2010
2064
|
return content;
|
|
@@ -2014,26 +2068,26 @@ var createGitHubSourceProvider = (options = {}) => {
|
|
|
2014
2068
|
|
|
2015
2069
|
// src/federation/public-assets.ts
|
|
2016
2070
|
var import_node_crypto2 = require("crypto");
|
|
2017
|
-
var
|
|
2018
|
-
var
|
|
2071
|
+
var import_promises6 = __toESM(require("fs/promises"), 1);
|
|
2072
|
+
var import_node_path13 = __toESM(require("path"), 1);
|
|
2019
2073
|
var getContentHash2 = (content) => `sha256:${(0, import_node_crypto2.createHash)("sha256").update(content).digest("hex")}`;
|
|
2020
2074
|
var getFileHash = async (filePath) => {
|
|
2021
2075
|
try {
|
|
2022
|
-
const stat = await
|
|
2023
|
-
return stat.isFile() ? getContentHash2(await
|
|
2076
|
+
const stat = await import_promises6.default.lstat(filePath);
|
|
2077
|
+
return stat.isFile() ? getContentHash2(await import_promises6.default.readFile(filePath)) : void 0;
|
|
2024
2078
|
} catch (error) {
|
|
2025
2079
|
if (error.code === "ENOENT") return void 0;
|
|
2026
2080
|
throw error;
|
|
2027
2081
|
}
|
|
2028
2082
|
};
|
|
2029
2083
|
var getSafePath = (directory, relativePath) => {
|
|
2030
|
-
const normalizedPath =
|
|
2031
|
-
const unsafe = relativePath.length === 0 || relativePath.includes("\0") || relativePath.includes("\\") ||
|
|
2084
|
+
const normalizedPath = import_node_path13.default.posix.normalize(relativePath);
|
|
2085
|
+
const unsafe = relativePath.length === 0 || relativePath.includes("\0") || relativePath.includes("\\") || import_node_path13.default.posix.isAbsolute(relativePath) || /^[a-zA-Z]:\//.test(relativePath) || normalizedPath !== relativePath || normalizedPath === ".." || normalizedPath.startsWith("../");
|
|
2032
2086
|
if (unsafe) return void 0;
|
|
2033
|
-
const resolvedDirectory =
|
|
2034
|
-
const resolvedPath =
|
|
2035
|
-
const relativeResolvedPath =
|
|
2036
|
-
if (relativeResolvedPath === "" || relativeResolvedPath === ".." || relativeResolvedPath.startsWith(`..${
|
|
2087
|
+
const resolvedDirectory = import_node_path13.default.resolve(directory);
|
|
2088
|
+
const resolvedPath = import_node_path13.default.resolve(resolvedDirectory, relativePath);
|
|
2089
|
+
const relativeResolvedPath = import_node_path13.default.relative(resolvedDirectory, resolvedPath);
|
|
2090
|
+
if (relativeResolvedPath === "" || relativeResolvedPath === ".." || relativeResolvedPath.startsWith(`..${import_node_path13.default.sep}`) || import_node_path13.default.isAbsolute(relativeResolvedPath)) {
|
|
2037
2091
|
return void 0;
|
|
2038
2092
|
}
|
|
2039
2093
|
return resolvedPath;
|
|
@@ -2041,23 +2095,23 @@ var getSafePath = (directory, relativePath) => {
|
|
|
2041
2095
|
var listFiles = async (directory, relativeDirectory = "") => {
|
|
2042
2096
|
let entries;
|
|
2043
2097
|
try {
|
|
2044
|
-
entries = await
|
|
2098
|
+
entries = await import_promises6.default.readdir(import_node_path13.default.join(directory, relativeDirectory), { withFileTypes: true });
|
|
2045
2099
|
} catch (error) {
|
|
2046
2100
|
if (error.code === "ENOENT") return [];
|
|
2047
2101
|
throw error;
|
|
2048
2102
|
}
|
|
2049
2103
|
const files = await Promise.all(
|
|
2050
2104
|
entries.map(async (entry) => {
|
|
2051
|
-
const relativePath =
|
|
2105
|
+
const relativePath = import_node_path13.default.join(relativeDirectory, entry.name);
|
|
2052
2106
|
if (entry.isDirectory()) return listFiles(directory, relativePath);
|
|
2053
|
-
return entry.isFile() ? [relativePath.split(
|
|
2107
|
+
return entry.isFile() ? [relativePath.split(import_node_path13.default.sep).join("/")] : [];
|
|
2054
2108
|
})
|
|
2055
2109
|
);
|
|
2056
2110
|
return files.flat().sort();
|
|
2057
2111
|
};
|
|
2058
2112
|
var pathExists = async (filePath) => {
|
|
2059
2113
|
try {
|
|
2060
|
-
await
|
|
2114
|
+
await import_promises6.default.lstat(filePath);
|
|
2061
2115
|
return true;
|
|
2062
2116
|
} catch (error) {
|
|
2063
2117
|
if (error.code === "ENOENT") return false;
|
|
@@ -2065,27 +2119,27 @@ var pathExists = async (filePath) => {
|
|
|
2065
2119
|
}
|
|
2066
2120
|
};
|
|
2067
2121
|
var hasBlockingParent = async (publicDirectory, destinationPath) => {
|
|
2068
|
-
let currentPath =
|
|
2122
|
+
let currentPath = import_node_path13.default.dirname(destinationPath);
|
|
2069
2123
|
while (currentPath !== publicDirectory) {
|
|
2070
2124
|
try {
|
|
2071
|
-
if (!(await
|
|
2125
|
+
if (!(await import_promises6.default.lstat(currentPath)).isDirectory()) return true;
|
|
2072
2126
|
} catch (error) {
|
|
2073
2127
|
if (error.code !== "ENOENT") throw error;
|
|
2074
2128
|
}
|
|
2075
|
-
currentPath =
|
|
2129
|
+
currentPath = import_node_path13.default.dirname(currentPath);
|
|
2076
2130
|
}
|
|
2077
2131
|
return false;
|
|
2078
2132
|
};
|
|
2079
2133
|
var pruneEmptyDirectories = async (publicDirectory, filePath) => {
|
|
2080
|
-
let currentPath =
|
|
2134
|
+
let currentPath = import_node_path13.default.dirname(filePath);
|
|
2081
2135
|
while (currentPath !== publicDirectory) {
|
|
2082
2136
|
try {
|
|
2083
|
-
await
|
|
2137
|
+
await import_promises6.default.rmdir(currentPath);
|
|
2084
2138
|
} catch (error) {
|
|
2085
2139
|
if (!["ENOENT", "ENOTEMPTY"].includes(error.code ?? "")) throw error;
|
|
2086
2140
|
if (error.code === "ENOTEMPTY") return;
|
|
2087
2141
|
}
|
|
2088
|
-
currentPath =
|
|
2142
|
+
currentPath = import_node_path13.default.dirname(currentPath);
|
|
2089
2143
|
}
|
|
2090
2144
|
};
|
|
2091
2145
|
var composePublicAssets = async ({
|
|
@@ -2095,8 +2149,8 @@ var composePublicAssets = async ({
|
|
|
2095
2149
|
previousFiles = {},
|
|
2096
2150
|
collisionPaths = /* @__PURE__ */ new Set()
|
|
2097
2151
|
}) => {
|
|
2098
|
-
const publicDirectory =
|
|
2099
|
-
const federatedPublicDirectory =
|
|
2152
|
+
const publicDirectory = import_node_path13.default.resolve(projectDirectory, "public");
|
|
2153
|
+
const federatedPublicDirectory = import_node_path13.default.resolve(federatedDirectory, "public");
|
|
2100
2154
|
const sourceFiles = await listFiles(federatedPublicDirectory);
|
|
2101
2155
|
const sourceFileSet = new Set(sourceFiles);
|
|
2102
2156
|
const managedFiles = /* @__PURE__ */ new Set();
|
|
@@ -2109,7 +2163,7 @@ var composePublicAssets = async ({
|
|
|
2109
2163
|
if (sourceFileSet.has(relativePath)) continue;
|
|
2110
2164
|
const destinationPath = getSafePath(publicDirectory, relativePath);
|
|
2111
2165
|
if (!destinationPath) continue;
|
|
2112
|
-
await
|
|
2166
|
+
await import_promises6.default.rm(destinationPath, { force: true });
|
|
2113
2167
|
await pruneEmptyDirectories(publicDirectory, destinationPath);
|
|
2114
2168
|
removed += 1;
|
|
2115
2169
|
}
|
|
@@ -2131,14 +2185,14 @@ var composePublicAssets = async ({
|
|
|
2131
2185
|
}
|
|
2132
2186
|
const asset = publicAssetsByPath.get(relativePath);
|
|
2133
2187
|
if (!asset) throw new Error(`Cannot identify the source of federated public asset "${relativePath}"`);
|
|
2134
|
-
const content = await
|
|
2135
|
-
await
|
|
2136
|
-
await
|
|
2188
|
+
const content = await import_promises6.default.readFile(sourcePath);
|
|
2189
|
+
await import_promises6.default.mkdir(import_node_path13.default.dirname(destinationPath), { recursive: true });
|
|
2190
|
+
await import_promises6.default.writeFile(destinationPath, content);
|
|
2137
2191
|
files[relativePath] = { source: asset.resolvedFrom.source, hash: getContentHash2(content) };
|
|
2138
2192
|
copied += 1;
|
|
2139
2193
|
if (collisionPaths.has(`public/${relativePath}`)) overwritten += 1;
|
|
2140
2194
|
}
|
|
2141
|
-
await
|
|
2195
|
+
await import_promises6.default.rm(federatedPublicDirectory, { recursive: true, force: true });
|
|
2142
2196
|
return { files, copied, skipped, overwritten, removed };
|
|
2143
2197
|
};
|
|
2144
2198
|
|
|
@@ -2164,16 +2218,16 @@ var validateSources = (sources) => {
|
|
|
2164
2218
|
var writeLock = async (lockPath, lock) => {
|
|
2165
2219
|
const temporaryPath = `${lockPath}.tmp-${process.pid}`;
|
|
2166
2220
|
try {
|
|
2167
|
-
await
|
|
2221
|
+
await import_promises7.default.writeFile(temporaryPath, `${JSON.stringify(lock, null, 2)}
|
|
2168
2222
|
`, "utf8");
|
|
2169
|
-
await
|
|
2223
|
+
await import_promises7.default.rename(temporaryPath, lockPath);
|
|
2170
2224
|
} finally {
|
|
2171
|
-
await
|
|
2225
|
+
await import_promises7.default.rm(temporaryPath, { force: true });
|
|
2172
2226
|
}
|
|
2173
2227
|
};
|
|
2174
2228
|
var readLock = async (lockPath) => {
|
|
2175
2229
|
try {
|
|
2176
|
-
return JSON.parse(await
|
|
2230
|
+
return JSON.parse(await import_promises7.default.readFile(lockPath, "utf8"));
|
|
2177
2231
|
} catch (error) {
|
|
2178
2232
|
if (error.code === "ENOENT") return void 0;
|
|
2179
2233
|
throw new Error(`Cannot read federation lock at "${lockPath}"`, { cause: error });
|
|
@@ -2181,7 +2235,7 @@ var readLock = async (lockPath) => {
|
|
|
2181
2235
|
};
|
|
2182
2236
|
var pathExists2 = async (filePath) => {
|
|
2183
2237
|
try {
|
|
2184
|
-
await
|
|
2238
|
+
await import_promises7.default.access(filePath);
|
|
2185
2239
|
return true;
|
|
2186
2240
|
} catch (error) {
|
|
2187
2241
|
if (error.code === "ENOENT") return false;
|
|
@@ -2189,20 +2243,20 @@ var pathExists2 = async (filePath) => {
|
|
|
2189
2243
|
}
|
|
2190
2244
|
};
|
|
2191
2245
|
var cleanupPreviousFederation = async (projectDirectory, onProgress) => {
|
|
2192
|
-
const outDir =
|
|
2193
|
-
const lockPath =
|
|
2246
|
+
const outDir = import_node_path14.default.join(projectDirectory, "federated");
|
|
2247
|
+
const lockPath = import_node_path14.default.join(projectDirectory, "eventcatalog.lock");
|
|
2194
2248
|
const previousLock = await readLock(lockPath);
|
|
2195
2249
|
const hadFederatedOutput = await pathExists2(outDir);
|
|
2196
2250
|
const hadLock = previousLock !== void 0;
|
|
2197
2251
|
if (!hadFederatedOutput && !hadLock) return;
|
|
2198
|
-
await
|
|
2252
|
+
await import_promises7.default.rm(outDir, { recursive: true, force: true });
|
|
2199
2253
|
const publicResult = await composePublicAssets({
|
|
2200
2254
|
projectDirectory,
|
|
2201
2255
|
federatedDirectory: outDir,
|
|
2202
2256
|
assets: [],
|
|
2203
2257
|
previousFiles: previousLock?.publicFiles
|
|
2204
2258
|
});
|
|
2205
|
-
await
|
|
2259
|
+
await import_promises7.default.rm(lockPath, { force: true });
|
|
2206
2260
|
onProgress?.({
|
|
2207
2261
|
type: "cleanup:complete",
|
|
2208
2262
|
federated: hadFederatedOutput,
|
|
@@ -2247,8 +2301,8 @@ var federateCatalog = async (projectDirectory, options = {}) => {
|
|
|
2247
2301
|
throw new Error(`Failed to federate source "${source.id}": ${message}`, { cause: error });
|
|
2248
2302
|
}
|
|
2249
2303
|
}
|
|
2250
|
-
const outDir =
|
|
2251
|
-
const lockPath =
|
|
2304
|
+
const outDir = import_node_path14.default.join(projectDirectory, "federated");
|
|
2305
|
+
const lockPath = import_node_path14.default.join(projectDirectory, "eventcatalog.lock");
|
|
2252
2306
|
const previousLock = await readLock(lockPath);
|
|
2253
2307
|
const resources = resolvedSources.reduce((total, source) => total + source.resolved.index.resources.length, 0);
|
|
2254
2308
|
const remoteIndexes = resolvedSources.map(({ resolved }) => resolved.index);
|
|
@@ -2327,14 +2381,14 @@ var federateCatalog = async (projectDirectory, options = {}) => {
|
|
|
2327
2381
|
|
|
2328
2382
|
// src/eventcatalog.ts
|
|
2329
2383
|
var import_license = require("@eventcatalog/license");
|
|
2330
|
-
var currentDir =
|
|
2384
|
+
var currentDir = import_node_path16.default.dirname((0, import_node_url.fileURLToPath)(importMetaUrl));
|
|
2331
2385
|
var program = new import_commander.Command().version(VERSION);
|
|
2332
|
-
var dir =
|
|
2333
|
-
var core =
|
|
2334
|
-
var eventCatalogDir =
|
|
2386
|
+
var dir = import_node_path16.default.resolve(process.env.PROJECT_DIR || process.cwd());
|
|
2387
|
+
var core = import_node_path16.default.resolve(process.env.CATALOG_DIR || (0, import_node_path15.join)(dir, ".eventcatalog-core"));
|
|
2388
|
+
var eventCatalogDir = import_node_path16.default.resolve((0, import_node_path15.join)(currentDir, "../eventcatalog/"));
|
|
2335
2389
|
var getInstalledEventCatalogVersion = () => {
|
|
2336
2390
|
try {
|
|
2337
|
-
const pkg = import_fs3.default.readFileSync((0,
|
|
2391
|
+
const pkg = import_fs3.default.readFileSync((0, import_node_path15.join)(dir, "package.json"), "utf8");
|
|
2338
2392
|
const json = JSON.parse(pkg);
|
|
2339
2393
|
return json.dependencies["@eventcatalog/core"];
|
|
2340
2394
|
} catch (error) {
|
|
@@ -2400,12 +2454,12 @@ var startDevPrewarm = ({
|
|
|
2400
2454
|
var buildDevSearchIndex = async ({ config }) => {
|
|
2401
2455
|
const result = await buildSearchIndex({
|
|
2402
2456
|
projectDir: dir,
|
|
2403
|
-
outDir:
|
|
2404
|
-
searchOutputPath:
|
|
2457
|
+
outDir: import_node_path16.default.join(core, "public"),
|
|
2458
|
+
searchOutputPath: import_node_path16.default.join(core, "public", "pagefind"),
|
|
2405
2459
|
config,
|
|
2406
2460
|
isServer: false
|
|
2407
2461
|
});
|
|
2408
|
-
logger.info(`Indexed ${result.records} page(s) into ${
|
|
2462
|
+
logger.info(`Indexed ${result.records} page(s) into ${import_node_path16.default.relative(core, result.outputPath)}`, "search");
|
|
2409
2463
|
};
|
|
2410
2464
|
var warnIfIndexedSearchUsesAuth = async () => {
|
|
2411
2465
|
if (!await isAuthEnabled()) {
|
|
@@ -2520,12 +2574,12 @@ var copyCore = () => {
|
|
|
2520
2574
|
import_fs3.default.cpSync(eventCatalogDir, core, {
|
|
2521
2575
|
recursive: true,
|
|
2522
2576
|
filter: (src) => {
|
|
2523
|
-
const relativePath =
|
|
2524
|
-
const pathParts = relativePath.split(
|
|
2577
|
+
const relativePath = import_node_path16.default.relative(eventCatalogDir, src);
|
|
2578
|
+
const pathParts = relativePath.split(import_node_path16.default.sep);
|
|
2525
2579
|
return !pathParts.some((part) => [".astro", "dist", "node_modules"].includes(part));
|
|
2526
2580
|
}
|
|
2527
2581
|
});
|
|
2528
|
-
const coreNodeModules =
|
|
2582
|
+
const coreNodeModules = import_node_path16.default.join(core, "node_modules");
|
|
2529
2583
|
const installedCoreNodeModules = resolveInstalledCoreNodeModules(currentDir);
|
|
2530
2584
|
linkCoreNodeModules({ coreNodeModules, installedCoreNodeModules });
|
|
2531
2585
|
};
|
|
@@ -2584,8 +2638,8 @@ program.command("dev").description("Run development server of EventCatalog").opt
|
|
|
2584
2638
|
logger.info("Setting up EventCatalog...", "eventcatalog");
|
|
2585
2639
|
const isServer = await isOutputServer();
|
|
2586
2640
|
logger.info(isServer ? "EventCatalog is running in Server Mode" : "EventCatalog is running in Static Mode", "config");
|
|
2587
|
-
if (import_fs3.default.existsSync(
|
|
2588
|
-
import_dotenv.default.config({ path:
|
|
2641
|
+
if (import_fs3.default.existsSync(import_node_path16.default.join(dir, ".env"))) {
|
|
2642
|
+
import_dotenv.default.config({ path: import_node_path16.default.join(dir, ".env") });
|
|
2589
2643
|
}
|
|
2590
2644
|
if (options.debug) {
|
|
2591
2645
|
logger.info("Debug mode enabled", "debug");
|
|
@@ -2665,8 +2719,8 @@ program.command("build").description("Run build of EventCatalog").action(async (
|
|
|
2665
2719
|
logger.info("Building EventCatalog...", "build");
|
|
2666
2720
|
const isServer = await isOutputServer();
|
|
2667
2721
|
logger.info(isServer ? "EventCatalog is running in Server Mode" : "EventCatalog is running in Static Mode", "config");
|
|
2668
|
-
if (import_fs3.default.existsSync(
|
|
2669
|
-
import_dotenv.default.config({ path:
|
|
2722
|
+
if (import_fs3.default.existsSync(import_node_path16.default.join(dir, ".env"))) {
|
|
2723
|
+
import_dotenv.default.config({ path: import_node_path16.default.join(dir, ".env") });
|
|
2670
2724
|
}
|
|
2671
2725
|
await verifyRequiredFieldsAreInCatalogConfigFile(dir);
|
|
2672
2726
|
copyCore();
|
|
@@ -2716,7 +2770,7 @@ program.command("build").description("Run build of EventCatalog").action(async (
|
|
|
2716
2770
|
if (await isIndexedSearchEnabled()) {
|
|
2717
2771
|
await warnIfIndexedSearchUsesAuth();
|
|
2718
2772
|
const config = await getEventCatalogConfigFile(dir);
|
|
2719
|
-
const outDir =
|
|
2773
|
+
const outDir = import_node_path16.default.resolve(dir, await getProjectOutDir());
|
|
2720
2774
|
logger.info("Building indexed search...", "search");
|
|
2721
2775
|
const result = await buildSearchIndex({
|
|
2722
2776
|
projectDir: dir,
|
|
@@ -2724,7 +2778,7 @@ program.command("build").description("Run build of EventCatalog").action(async (
|
|
|
2724
2778
|
config,
|
|
2725
2779
|
isServer
|
|
2726
2780
|
});
|
|
2727
|
-
logger.info(`Indexed ${result.records} page(s) into ${
|
|
2781
|
+
logger.info(`Indexed ${result.records} page(s) into ${import_node_path16.default.relative(dir, result.outputPath)}`, "search");
|
|
2728
2782
|
}
|
|
2729
2783
|
});
|
|
2730
2784
|
var previewCatalog = async ({
|
|
@@ -2751,7 +2805,7 @@ var startServerCatalog = async ({
|
|
|
2751
2805
|
isEventCatalogStarter = false,
|
|
2752
2806
|
isEventCatalogScale = false
|
|
2753
2807
|
}) => {
|
|
2754
|
-
const serverEntryPath =
|
|
2808
|
+
const serverEntryPath = import_node_path16.default.join(dir, "dist", "server", "entry.mjs");
|
|
2755
2809
|
await runCommandWithFilteredOutput({
|
|
2756
2810
|
command: `node "${serverEntryPath}"`,
|
|
2757
2811
|
cwd: core,
|
|
@@ -2768,8 +2822,8 @@ var startServerCatalog = async ({
|
|
|
2768
2822
|
program.command("preview").description("Serves the contents of your eventcatalog build directory").action(async (options, command) => {
|
|
2769
2823
|
logger.welcome();
|
|
2770
2824
|
logger.info("Starting preview of your build...", "preview");
|
|
2771
|
-
if (import_fs3.default.existsSync(
|
|
2772
|
-
import_dotenv.default.config({ path:
|
|
2825
|
+
if (import_fs3.default.existsSync(import_node_path16.default.join(dir, ".env"))) {
|
|
2826
|
+
import_dotenv.default.config({ path: import_node_path16.default.join(dir, ".env") });
|
|
2773
2827
|
}
|
|
2774
2828
|
const canEmbedPages = await (0, import_license.isFeatureEnabled)(
|
|
2775
2829
|
"@eventcatalog/backstage-plugin-eventcatalog",
|
|
@@ -2787,8 +2841,8 @@ program.command("preview").description("Serves the contents of your eventcatalog
|
|
|
2787
2841
|
program.command("start").description("Serves the contents of your eventcatalog build directory").action(async (options, command) => {
|
|
2788
2842
|
logger.welcome();
|
|
2789
2843
|
logger.info("Starting preview of your build...", "preview");
|
|
2790
|
-
if (import_fs3.default.existsSync(
|
|
2791
|
-
import_dotenv.default.config({ path:
|
|
2844
|
+
if (import_fs3.default.existsSync(import_node_path16.default.join(dir, ".env"))) {
|
|
2845
|
+
import_dotenv.default.config({ path: import_node_path16.default.join(dir, ".env") });
|
|
2792
2846
|
}
|
|
2793
2847
|
const canEmbedPages = await (0, import_license.isFeatureEnabled)(
|
|
2794
2848
|
"@eventcatalog/backstage-plugin-eventcatalog",
|
|
@@ -2815,22 +2869,22 @@ program.command("start").description("Serves the contents of your eventcatalog b
|
|
|
2815
2869
|
program.command("export").description("Export your EventCatalog using the SDK dumpCatalog function").option("--include-markdown", "Include markdown content in the export", false).action(async (options) => {
|
|
2816
2870
|
logger.welcome();
|
|
2817
2871
|
logger.info("Exporting EventCatalog...", "export");
|
|
2818
|
-
if (import_fs3.default.existsSync(
|
|
2819
|
-
import_dotenv.default.config({ path:
|
|
2872
|
+
if (import_fs3.default.existsSync(import_node_path16.default.join(dir, ".env"))) {
|
|
2873
|
+
import_dotenv.default.config({ path: import_node_path16.default.join(dir, ".env") });
|
|
2820
2874
|
}
|
|
2821
2875
|
const { default: initSDK } = await import("@eventcatalog/sdk");
|
|
2822
2876
|
const sdk = initSDK(dir);
|
|
2823
2877
|
const catalog = await sdk.dumpCatalog({ includeMarkdown: options.includeMarkdown });
|
|
2824
|
-
const exportsDir =
|
|
2878
|
+
const exportsDir = import_node_path16.default.join(dir, "exports");
|
|
2825
2879
|
ensureDir(exportsDir);
|
|
2826
2880
|
const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
2827
|
-
const exportFile =
|
|
2881
|
+
const exportFile = import_node_path16.default.join(exportsDir, `catalog-${date}.json`);
|
|
2828
2882
|
import_fs3.default.writeFileSync(exportFile, JSON.stringify(catalog, null, 2), "utf-8");
|
|
2829
2883
|
logger.info(`Catalog exported to ${exportFile}`, "export");
|
|
2830
2884
|
});
|
|
2831
2885
|
program.command("generate [siteDir]").description("Start the generator scripts.").action(async () => {
|
|
2832
|
-
if (import_fs3.default.existsSync(
|
|
2833
|
-
import_dotenv.default.config({ path:
|
|
2886
|
+
if (import_fs3.default.existsSync(import_node_path16.default.join(dir, ".env"))) {
|
|
2887
|
+
import_dotenv.default.config({ path: import_node_path16.default.join(dir, ".env") });
|
|
2834
2888
|
}
|
|
2835
2889
|
await generate(dir);
|
|
2836
2890
|
});
|
|
@@ -2905,7 +2959,7 @@ var reportFederationProgress = (event) => {
|
|
|
2905
2959
|
}
|
|
2906
2960
|
return;
|
|
2907
2961
|
case "hydrating":
|
|
2908
|
-
logger.info(`Hydrating federated content into ${
|
|
2962
|
+
logger.info(`Hydrating federated content into ${import_node_path16.default.relative(dir, event.outDir)}/...`, "federation");
|
|
2909
2963
|
return;
|
|
2910
2964
|
case "hydrate:cache":
|
|
2911
2965
|
if (event.files === 1 || event.files % 25 === 0) {
|
|
@@ -2934,13 +2988,13 @@ var reportFederationProgress = (event) => {
|
|
|
2934
2988
|
`Federation complete: ${event.result.sources} sources, ${event.result.resources} remote resources, ${event.result.hydrate.written} files written (${event.result.hydrate.fetched} downloaded, ${event.result.hydrate.written - event.result.hydrate.fetched} cached)`,
|
|
2935
2989
|
"federation"
|
|
2936
2990
|
);
|
|
2937
|
-
logger.info(`Pinned source commits in ${
|
|
2991
|
+
logger.info(`Pinned source commits in ${import_node_path16.default.relative(dir, event.result.lockPath)}`, "federation");
|
|
2938
2992
|
}
|
|
2939
2993
|
};
|
|
2940
2994
|
program.command("federate").description("Fetch, resolve, and hydrate the catalogs configured in federation.sources.").option("--no-cache", "Download all federation content and refresh the cache.").action(async (commandOptions) => {
|
|
2941
2995
|
logger.welcome();
|
|
2942
|
-
if (import_fs3.default.existsSync(
|
|
2943
|
-
import_dotenv.default.config({ path:
|
|
2996
|
+
if (import_fs3.default.existsSync(import_node_path16.default.join(dir, ".env"))) {
|
|
2997
|
+
import_dotenv.default.config({ path: import_node_path16.default.join(dir, ".env") });
|
|
2944
2998
|
}
|
|
2945
2999
|
logger.info("Starting federation...", "federation");
|
|
2946
3000
|
let cleanedPreviousOutput = false;
|