@eventcatalog/core 5.0.0-beta.27 → 5.0.0-beta.28
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 +55 -3
- package/dist/analytics/log-build.d.cts +2 -2
- package/dist/analytics/log-build.d.ts +2 -2
- package/dist/analytics/log-build.js +4 -3
- package/dist/analytics/studio-usage.cjs +90 -0
- package/dist/analytics/studio-usage.d.cts +5 -0
- package/dist/analytics/studio-usage.d.ts +5 -0
- package/dist/analytics/studio-usage.js +10 -0
- package/dist/chunk-CA6WCQ2T.js +54 -0
- package/dist/{chunk-YGUOLT7F.js → chunk-EUMQAONX.js} +1 -1
- package/dist/{chunk-I6CBMGUM.js → chunk-G46KUC6G.js} +1 -1
- package/dist/{chunk-QJ7KKN2D.js → chunk-OX6TSVHY.js} +1 -1
- package/dist/{chunk-EFBDR7JJ.js → chunk-QWFP2PDM.js} +1 -1
- package/dist/{chunk-ILPH363P.js → chunk-TDUUHSGF.js} +1 -1
- package/dist/{chunk-P5IFIKG6.js → chunk-VAL22T5Y.js} +11 -3
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/eventcatalog.cjs +235 -182
- package/dist/eventcatalog.js +11 -9
- package/dist/federation/federate.js +3 -3
- package/dist/federation/source-provider.js +2 -2
- 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 +1 -1
- package/dist/{chunk-A2RZR3U4.js → chunk-6K7XZAYI.js} +3 -3
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_path21 = require("path");
|
|
33
33
|
var import_node_http = __toESM(require("http"), 1);
|
|
34
34
|
var import_fs = __toESM(require("fs"), 1);
|
|
35
|
-
var
|
|
35
|
+
var import_node_path22 = __toESM(require("path"), 1);
|
|
36
36
|
var import_node_url2 = require("url");
|
|
37
37
|
var import_node_module3 = require("module");
|
|
38
38
|
|
|
@@ -174,7 +174,7 @@ var verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
|
|
|
174
174
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
175
175
|
|
|
176
176
|
// package.json
|
|
177
|
-
var version = "5.0.0-beta.
|
|
177
|
+
var version = "5.0.0-beta.28";
|
|
178
178
|
|
|
179
179
|
// src/constants.ts
|
|
180
180
|
var VERSION = version;
|
|
@@ -636,6 +636,55 @@ var printLicenseStatus = (license, tsd) => {
|
|
|
636
636
|
);
|
|
637
637
|
};
|
|
638
638
|
|
|
639
|
+
// src/analytics/studio-usage.js
|
|
640
|
+
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
641
|
+
var import_node_path6 = __toESM(require("path"), 1);
|
|
642
|
+
var DAY_IN_MS3 = 24 * 60 * 60 * 1e3;
|
|
643
|
+
var DEFAULT_DATABASE_PATH = ".eventcatalog/eventcatalog.db";
|
|
644
|
+
var getStudioMode = (configFile) => {
|
|
645
|
+
const enabled = configFile.studio?.enabled;
|
|
646
|
+
if (enabled === false) return "off";
|
|
647
|
+
return configFile.output === "server" && enabled === true ? "server" : "dev";
|
|
648
|
+
};
|
|
649
|
+
var getStorageType = (configFile) => configFile.storage?.type || "memory";
|
|
650
|
+
var loadSqlite = () => {
|
|
651
|
+
const emitWarning = process.emitWarning;
|
|
652
|
+
process.emitWarning = function(warning, ...args) {
|
|
653
|
+
const type = typeof args[0] === "object" ? args[0]?.type : args[0];
|
|
654
|
+
const message2 = typeof warning === "string" ? warning : warning?.message;
|
|
655
|
+
if (type === "ExperimentalWarning" && message2?.startsWith("SQLite")) return;
|
|
656
|
+
return emitWarning.call(this, warning, ...args);
|
|
657
|
+
};
|
|
658
|
+
try {
|
|
659
|
+
return process.getBuiltinModule?.("node:sqlite");
|
|
660
|
+
} catch {
|
|
661
|
+
return void 0;
|
|
662
|
+
} finally {
|
|
663
|
+
process.emitWarning = emitWarning;
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
var UNKNOWN = "canvases:unknown";
|
|
667
|
+
var serializeStudioUsage = (projectDirectory, configFile, now = Date.now()) => {
|
|
668
|
+
if (getStudioMode(configFile) === "off" || getStorageType(configFile) !== "sqlite") return UNKNOWN;
|
|
669
|
+
const file = import_node_path6.default.resolve(projectDirectory, configFile.storage.path ?? DEFAULT_DATABASE_PATH);
|
|
670
|
+
if (!import_node_fs3.default.existsSync(file)) return "canvases:0,changed7d:0,changed30d:0,deleted:0";
|
|
671
|
+
let database;
|
|
672
|
+
try {
|
|
673
|
+
const sqlite = loadSqlite();
|
|
674
|
+
if (!sqlite?.DatabaseSync) return UNKNOWN;
|
|
675
|
+
database = new sqlite.DatabaseSync(file, { readOnly: true });
|
|
676
|
+
const canvases = database.prepare(
|
|
677
|
+
"SELECT COUNT(*) AS total, SUM(updated_at >= ?) AS changed7d, SUM(updated_at >= ?) AS changed30d FROM studio_canvases"
|
|
678
|
+
).get(now - 7 * DAY_IN_MS3, now - 30 * DAY_IN_MS3);
|
|
679
|
+
const { deleted } = database.prepare("SELECT COUNT(*) AS deleted FROM studio_deleted_canvases").get();
|
|
680
|
+
return `canvases:${canvases.total},changed7d:${canvases.changed7d ?? 0},changed30d:${canvases.changed30d ?? 0},deleted:${deleted}`;
|
|
681
|
+
} catch {
|
|
682
|
+
return UNKNOWN;
|
|
683
|
+
} finally {
|
|
684
|
+
database?.close();
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
|
|
639
688
|
// src/analytics/log-build.js
|
|
640
689
|
var isMCPEnabled = (configFile) => configFile.output === "server" && (configFile.mcp?.enabled ?? true);
|
|
641
690
|
var getFeatures = async (configFile) => {
|
|
@@ -649,7 +698,9 @@ var getFeatures = async (configFile) => {
|
|
|
649
698
|
environments: Array.isArray(configFile.environments) && configFile.environments.length > 0,
|
|
650
699
|
output: configFile.output || "static",
|
|
651
700
|
mcp,
|
|
652
|
-
mcpAuth: mcp && (configFile.mcp?.auth?.enabled ?? false)
|
|
701
|
+
mcpAuth: mcp && (configFile.mcp?.auth?.enabled ?? false),
|
|
702
|
+
studio: getStudioMode(configFile),
|
|
703
|
+
storage: getStorageType(configFile)
|
|
653
704
|
};
|
|
654
705
|
};
|
|
655
706
|
var getDirectoryProvider = (source) => {
|
|
@@ -750,7 +801,8 @@ var main = async (projectDir, { command = "build", license } = {}) => {
|
|
|
750
801
|
generators: generatorNames.toString(),
|
|
751
802
|
features: Object.keys(features).map((feature) => `${feature}:${features[feature]}`).join(","),
|
|
752
803
|
directorySources: serializeDirectorySources(configFile),
|
|
753
|
-
resources: serializeCounts(resourceCounts)
|
|
804
|
+
resources: serializeCounts(resourceCounts),
|
|
805
|
+
studio: serializeStudioUsage(projectDir, configFile)
|
|
754
806
|
},
|
|
755
807
|
configFile
|
|
756
808
|
);
|
|
@@ -771,8 +823,8 @@ async function watch(projectDirectory, catalogDirectory, callback = () => {
|
|
|
771
823
|
}
|
|
772
824
|
|
|
773
825
|
// src/resolve-catalog-dependencies.js
|
|
774
|
-
var
|
|
775
|
-
var
|
|
826
|
+
var import_node_path7 = __toESM(require("path"), 1);
|
|
827
|
+
var import_node_fs4 = __toESM(require("fs"), 1);
|
|
776
828
|
var import_gray_matter2 = __toESM(require("gray-matter"), 1);
|
|
777
829
|
var resolve_catalog_dependencies_default = async (catalogDir, core2) => {
|
|
778
830
|
const catalogConfig = await getEventCatalogConfigFile(catalogDir);
|
|
@@ -780,11 +832,11 @@ var resolve_catalog_dependencies_default = async (catalogDir, core2) => {
|
|
|
780
832
|
if (!dependencies) {
|
|
781
833
|
return;
|
|
782
834
|
}
|
|
783
|
-
const dependenciesDir =
|
|
784
|
-
if (
|
|
785
|
-
|
|
835
|
+
const dependenciesDir = import_node_path7.default.join(catalogDir, "dependencies");
|
|
836
|
+
if (import_node_fs4.default.existsSync(dependenciesDir)) {
|
|
837
|
+
import_node_fs4.default.rmSync(dependenciesDir, { recursive: true, force: true });
|
|
786
838
|
}
|
|
787
|
-
|
|
839
|
+
import_node_fs4.default.mkdirSync(dependenciesDir, { recursive: true });
|
|
788
840
|
const resourceTypes = Object.keys(dependencies);
|
|
789
841
|
for (const resourceType of resourceTypes) {
|
|
790
842
|
for (const dependency of dependencies[resourceType]) {
|
|
@@ -804,9 +856,9 @@ var resolve_catalog_dependencies_default = async (catalogDir, core2) => {
|
|
|
804
856
|
},
|
|
805
857
|
frontmatter
|
|
806
858
|
);
|
|
807
|
-
const resourceFile =
|
|
808
|
-
|
|
809
|
-
|
|
859
|
+
const resourceFile = import_node_path7.default.join(dependenciesDir, resourceType, dependency.id, `index.md`);
|
|
860
|
+
import_node_fs4.default.mkdirSync(import_node_path7.default.dirname(resourceFile), { recursive: true });
|
|
861
|
+
import_node_fs4.default.writeFileSync(resourceFile, markdown);
|
|
810
862
|
}
|
|
811
863
|
}
|
|
812
864
|
return;
|
|
@@ -816,8 +868,8 @@ var resolve_catalog_dependencies_default = async (catalogDir, core2) => {
|
|
|
816
868
|
var import_boxen2 = __toESM(require("boxen"), 1);
|
|
817
869
|
|
|
818
870
|
// src/features.ts
|
|
819
|
-
var
|
|
820
|
-
var
|
|
871
|
+
var import_node_path8 = require("path");
|
|
872
|
+
var import_node_fs5 = __toESM(require("fs"), 1);
|
|
821
873
|
var getProjectOutDir = async () => {
|
|
822
874
|
const config = await getEventCatalogConfigFile(process.env.PROJECT_DIR || "");
|
|
823
875
|
return config?.outDir || "dist";
|
|
@@ -832,7 +884,7 @@ var isIndexedSearchEnabled = async () => {
|
|
|
832
884
|
};
|
|
833
885
|
var isAuthEnabled = async () => {
|
|
834
886
|
const directory = process.env.PROJECT_DIR || process.cwd();
|
|
835
|
-
const hasAuthConfig =
|
|
887
|
+
const hasAuthConfig = import_node_fs5.default.existsSync((0, import_node_path8.join)(directory, "eventcatalog.auth.js"));
|
|
836
888
|
return hasAuthConfig;
|
|
837
889
|
};
|
|
838
890
|
|
|
@@ -841,11 +893,11 @@ var import_update_notifier = __toESM(require("update-notifier"), 1);
|
|
|
841
893
|
var import_dotenv = __toESM(require("dotenv"), 1);
|
|
842
894
|
|
|
843
895
|
// src/migrations/message-channels-to-service-channels.ts
|
|
844
|
-
var
|
|
896
|
+
var import_node_fs6 = __toESM(require("fs"), 1);
|
|
845
897
|
var import_glob2 = require("glob");
|
|
846
898
|
var import_node_os = __toESM(require("os"), 1);
|
|
847
899
|
var import_gray_matter3 = __toESM(require("gray-matter"), 1);
|
|
848
|
-
var
|
|
900
|
+
var import_node_path9 = __toESM(require("path"), 1);
|
|
849
901
|
var DISABLE_CHANNEL_MIGRATION_ENV = "EVENTCATALOG_DISABLE_CHANNEL_MIGRATION";
|
|
850
902
|
var isChannelMigrationDisabled = () => {
|
|
851
903
|
return ["true", "1", "yes"].includes((process.env[DISABLE_CHANNEL_MIGRATION_ENV] ?? "").toLowerCase());
|
|
@@ -854,7 +906,7 @@ var message_channels_to_service_channels_default = async (dir2) => {
|
|
|
854
906
|
if (isChannelMigrationDisabled()) {
|
|
855
907
|
return { status: "skipped", message: `Channel migration disabled by ${DISABLE_CHANNEL_MIGRATION_ENV}` };
|
|
856
908
|
}
|
|
857
|
-
const PROJECT_DIR =
|
|
909
|
+
const PROJECT_DIR = import_node_path9.default.join(dir2 || process.env.PROJECT_DIR);
|
|
858
910
|
const messages = await (0, import_glob2.glob)(
|
|
859
911
|
[
|
|
860
912
|
"**/events/*/index.mdx",
|
|
@@ -894,7 +946,7 @@ var message_channels_to_service_channels_default = async (dir2) => {
|
|
|
894
946
|
}
|
|
895
947
|
);
|
|
896
948
|
const messagesWithChannels = messages.reduce((acc, message2) => {
|
|
897
|
-
const file =
|
|
949
|
+
const file = import_node_fs6.default.readFileSync(message2, "utf8");
|
|
898
950
|
const { data } = (0, import_gray_matter3.default)(file);
|
|
899
951
|
if (data.channels?.length > 0) {
|
|
900
952
|
acc.push({
|
|
@@ -908,7 +960,7 @@ var message_channels_to_service_channels_default = async (dir2) => {
|
|
|
908
960
|
return { status: "success", message: "No messages with channels found in the catalog" };
|
|
909
961
|
}
|
|
910
962
|
const servicesWithChannels = services.reduce((acc, service) => {
|
|
911
|
-
const file =
|
|
963
|
+
const file = import_node_fs6.default.readFileSync(service, "utf8");
|
|
912
964
|
const { data } = (0, import_gray_matter3.default)(file);
|
|
913
965
|
const isSending = data.sends?.some((send) => messagesWithChannels.some((message2) => message2.id === send.id));
|
|
914
966
|
const isReceiving = data.receives?.some(
|
|
@@ -923,7 +975,7 @@ var message_channels_to_service_channels_default = async (dir2) => {
|
|
|
923
975
|
return acc;
|
|
924
976
|
}, []);
|
|
925
977
|
for (const service of servicesWithChannels) {
|
|
926
|
-
const file =
|
|
978
|
+
const file = import_node_fs6.default.readFileSync(service.path, "utf8");
|
|
927
979
|
const { data } = (0, import_gray_matter3.default)(file);
|
|
928
980
|
const messagesTheServiceSendsThatNeedUpdating = data.sends?.filter((send) => messagesWithChannels.some((message2) => message2.id === send.id)) ?? [];
|
|
929
981
|
const messagesTheServiceReceivesThatNeedUpdating = data.receives?.filter((receive) => messagesWithChannels.some((message2) => message2.id === receive.id)) ?? [];
|
|
@@ -943,14 +995,14 @@ var message_channels_to_service_channels_default = async (dir2) => {
|
|
|
943
995
|
...newSends.length > 0 ? { sends: newSends } : {},
|
|
944
996
|
...newReceives.length > 0 ? { receives: newReceives } : {}
|
|
945
997
|
};
|
|
946
|
-
|
|
998
|
+
import_node_fs6.default.writeFileSync(service.path, import_gray_matter3.default.stringify(file, newData));
|
|
947
999
|
}
|
|
948
1000
|
}
|
|
949
1001
|
for (const message2 of messagesWithChannels) {
|
|
950
|
-
const file =
|
|
1002
|
+
const file = import_node_fs6.default.readFileSync(message2.path, "utf8");
|
|
951
1003
|
const parsed = (0, import_gray_matter3.default)(file);
|
|
952
1004
|
const { channels, ...newData } = parsed.data;
|
|
953
|
-
|
|
1005
|
+
import_node_fs6.default.writeFileSync(message2.path, import_gray_matter3.default.stringify(parsed.content, newData));
|
|
954
1006
|
}
|
|
955
1007
|
console.log("\u2714 Channels migrated to new services API");
|
|
956
1008
|
};
|
|
@@ -987,12 +1039,12 @@ var stopChildWithParent = (child, parent = process) => {
|
|
|
987
1039
|
};
|
|
988
1040
|
|
|
989
1041
|
// eventcatalog/src/features/fields/field-indexer.ts
|
|
990
|
-
var
|
|
991
|
-
var
|
|
1042
|
+
var import_node_path11 = __toESM(require("path"), 1);
|
|
1043
|
+
var import_node_fs8 = __toESM(require("fs"), 1);
|
|
992
1044
|
|
|
993
1045
|
// eventcatalog/src/features/fields/fields-db.ts
|
|
994
1046
|
var import_sql = __toESM(require("sql.js"), 1);
|
|
995
|
-
var
|
|
1047
|
+
var import_node_fs7 = __toESM(require("fs"), 1);
|
|
996
1048
|
var SCHEMA_SQL = `
|
|
997
1049
|
CREATE TABLE IF NOT EXISTS fields (
|
|
998
1050
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
@@ -1061,13 +1113,13 @@ var FieldsDatabase = class _FieldsDatabase {
|
|
|
1061
1113
|
this.dbPath = dbPath;
|
|
1062
1114
|
}
|
|
1063
1115
|
static async create(dbPath, options) {
|
|
1064
|
-
if (options?.recreate &&
|
|
1065
|
-
|
|
1116
|
+
if (options?.recreate && import_node_fs7.default.existsSync(dbPath)) {
|
|
1117
|
+
import_node_fs7.default.unlinkSync(dbPath);
|
|
1066
1118
|
}
|
|
1067
1119
|
const SQL = await (0, import_sql.default)();
|
|
1068
1120
|
let db;
|
|
1069
|
-
if (!options?.recreate &&
|
|
1070
|
-
const buffer =
|
|
1121
|
+
if (!options?.recreate && import_node_fs7.default.existsSync(dbPath)) {
|
|
1122
|
+
const buffer = import_node_fs7.default.readFileSync(dbPath);
|
|
1071
1123
|
db = new SQL.Database(buffer);
|
|
1072
1124
|
} else {
|
|
1073
1125
|
db = new SQL.Database();
|
|
@@ -1128,7 +1180,7 @@ var FieldsDatabase = class _FieldsDatabase {
|
|
|
1128
1180
|
save() {
|
|
1129
1181
|
const data = this.db.export();
|
|
1130
1182
|
const buffer = Buffer.from(data);
|
|
1131
|
-
|
|
1183
|
+
import_node_fs7.default.writeFileSync(this.dbPath, buffer);
|
|
1132
1184
|
}
|
|
1133
1185
|
queryFields(params) {
|
|
1134
1186
|
const {
|
|
@@ -1353,22 +1405,22 @@ function getAvroTypeName(type) {
|
|
|
1353
1405
|
function walkAvroRecord(schema, prefix, fields) {
|
|
1354
1406
|
if (!schema.fields || !Array.isArray(schema.fields)) return;
|
|
1355
1407
|
for (const field of schema.fields) {
|
|
1356
|
-
const
|
|
1408
|
+
const path21 = prefix ? `${prefix}.${field.name}` : field.name;
|
|
1357
1409
|
const isOptional = Array.isArray(field.type) && field.type.includes("null");
|
|
1358
1410
|
const typeName = getAvroTypeName(field.type);
|
|
1359
1411
|
fields.push({
|
|
1360
|
-
path:
|
|
1412
|
+
path: path21,
|
|
1361
1413
|
type: typeName,
|
|
1362
1414
|
description: field.doc || "",
|
|
1363
1415
|
required: !isOptional
|
|
1364
1416
|
});
|
|
1365
1417
|
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;
|
|
1366
1418
|
if (innerType) {
|
|
1367
|
-
walkAvroRecord(innerType,
|
|
1419
|
+
walkAvroRecord(innerType, path21, fields);
|
|
1368
1420
|
}
|
|
1369
1421
|
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;
|
|
1370
1422
|
if (arrayType && typeof arrayType.items === "object" && arrayType.items.type === "record") {
|
|
1371
|
-
walkAvroRecord(arrayType.items, `${
|
|
1423
|
+
walkAvroRecord(arrayType.items, `${path21}[]`, fields);
|
|
1372
1424
|
}
|
|
1373
1425
|
}
|
|
1374
1426
|
}
|
|
@@ -1399,32 +1451,32 @@ function walkJsonSchema(node, prefix, requiredList, rootSchema, fields) {
|
|
|
1399
1451
|
}
|
|
1400
1452
|
if (!node.properties) return;
|
|
1401
1453
|
for (const [name, prop] of Object.entries(node.properties)) {
|
|
1402
|
-
const
|
|
1454
|
+
const path21 = prefix ? `${prefix}.${name}` : name;
|
|
1403
1455
|
const isRequired = requiredList.includes(name);
|
|
1404
1456
|
if (prop.$ref) {
|
|
1405
1457
|
const resolved = resolveLocalRef(prop.$ref, rootSchema);
|
|
1406
1458
|
if (resolved) {
|
|
1407
1459
|
const rawRefType = resolved.type || "object";
|
|
1408
1460
|
const type2 = Array.isArray(rawRefType) ? [...rawRefType].sort().join(" | ") : rawRefType;
|
|
1409
|
-
fields.push({ path:
|
|
1461
|
+
fields.push({ path: path21, type: type2, description: resolved.description || "", required: isRequired });
|
|
1410
1462
|
if (resolved.properties) {
|
|
1411
|
-
walkJsonSchema(resolved,
|
|
1463
|
+
walkJsonSchema(resolved, path21, resolved.required || [], rootSchema, fields);
|
|
1412
1464
|
}
|
|
1413
1465
|
} else {
|
|
1414
|
-
fields.push({ path:
|
|
1466
|
+
fields.push({ path: path21, type: "$ref", description: "", required: isRequired });
|
|
1415
1467
|
}
|
|
1416
1468
|
continue;
|
|
1417
1469
|
}
|
|
1418
1470
|
const rawType = prop.type || (prop.enum ? "enum" : prop.$ref ? "$ref" : "object");
|
|
1419
1471
|
const typeList = Array.isArray(rawType) ? rawType : [rawType];
|
|
1420
1472
|
const type = Array.isArray(rawType) ? [...rawType].sort().join(" | ") : rawType;
|
|
1421
|
-
fields.push({ path:
|
|
1473
|
+
fields.push({ path: path21, type, description: prop.description || "", required: isRequired });
|
|
1422
1474
|
if (typeList.includes("object") && prop.properties) {
|
|
1423
|
-
walkJsonSchema(prop,
|
|
1475
|
+
walkJsonSchema(prop, path21, prop.required || [], rootSchema, fields);
|
|
1424
1476
|
}
|
|
1425
1477
|
if (typeList.includes("array") && prop.items) {
|
|
1426
1478
|
if (prop.items.type === "object" && prop.items.properties) {
|
|
1427
|
-
walkJsonSchema(prop.items, `${
|
|
1479
|
+
walkJsonSchema(prop.items, `${path21}[]`, prop.items.required || [], rootSchema, fields);
|
|
1428
1480
|
}
|
|
1429
1481
|
}
|
|
1430
1482
|
}
|
|
@@ -1441,22 +1493,22 @@ function resolveLocalRef(ref, rootSchema) {
|
|
|
1441
1493
|
}
|
|
1442
1494
|
|
|
1443
1495
|
// eventcatalog/integrations/runtime-paths.mjs
|
|
1444
|
-
var
|
|
1496
|
+
var import_node_path10 = __toESM(require("path"), 1);
|
|
1445
1497
|
function getRuntimePaths(projectDirectory, runtimeDirectory) {
|
|
1446
|
-
const project =
|
|
1447
|
-
const cacheDirectory =
|
|
1448
|
-
const runtime = runtimeDirectory ?
|
|
1498
|
+
const project = import_node_path10.default.resolve(projectDirectory);
|
|
1499
|
+
const cacheDirectory = import_node_path10.default.join(project, ".astro");
|
|
1500
|
+
const runtime = runtimeDirectory ? import_node_path10.default.resolve(runtimeDirectory) : import_node_path10.default.join(cacheDirectory, "eventcatalog");
|
|
1449
1501
|
return {
|
|
1450
1502
|
projectDirectory: project,
|
|
1451
1503
|
cacheDirectory,
|
|
1452
1504
|
runtimeDirectory: runtime,
|
|
1453
|
-
fieldsDatabasePath:
|
|
1505
|
+
fieldsDatabasePath: import_node_path10.default.join(runtime, ".eventcatalog", "fields.db")
|
|
1454
1506
|
};
|
|
1455
1507
|
}
|
|
1456
1508
|
|
|
1457
1509
|
// eventcatalog/src/features/fields/field-indexer.ts
|
|
1458
1510
|
function detectFormat(fileName) {
|
|
1459
|
-
const ext =
|
|
1511
|
+
const ext = import_node_path11.default.extname(fileName).toLowerCase();
|
|
1460
1512
|
if (ext === ".proto") return "proto";
|
|
1461
1513
|
if (ext === ".avro" || ext === ".avsc") return "avro";
|
|
1462
1514
|
return "json-schema";
|
|
@@ -1465,9 +1517,9 @@ async function buildFieldsIndex(catalogDir, outputDir) {
|
|
|
1465
1517
|
const sdkModule = await import("@eventcatalog/sdk");
|
|
1466
1518
|
const sdk = sdkModule.default(catalogDir);
|
|
1467
1519
|
const { fieldsDatabasePath: dbPath } = getRuntimePaths(catalogDir, outputDir || catalogDir);
|
|
1468
|
-
const dbDir =
|
|
1469
|
-
if (!
|
|
1470
|
-
|
|
1520
|
+
const dbDir = import_node_path11.default.dirname(dbPath);
|
|
1521
|
+
if (!import_node_fs8.default.existsSync(dbDir)) {
|
|
1522
|
+
import_node_fs8.default.mkdirSync(dbDir, { recursive: true });
|
|
1471
1523
|
}
|
|
1472
1524
|
const db = await FieldsDatabase.create(dbPath, { recreate: true });
|
|
1473
1525
|
const warnings = [];
|
|
@@ -1551,7 +1603,7 @@ async function buildFieldsIndex(catalogDir, outputDir) {
|
|
|
1551
1603
|
|
|
1552
1604
|
// src/search-indexer.ts
|
|
1553
1605
|
var import_promises4 = __toESM(require("fs/promises"), 1);
|
|
1554
|
-
var
|
|
1606
|
+
var import_node_path12 = __toESM(require("path"), 1);
|
|
1555
1607
|
var import_glob3 = require("glob");
|
|
1556
1608
|
var import_gray_matter4 = __toESM(require("gray-matter"), 1);
|
|
1557
1609
|
var RESOURCE_COLLECTIONS = {
|
|
@@ -1615,9 +1667,9 @@ var markdownToSearchText = (content) => {
|
|
|
1615
1667
|
};
|
|
1616
1668
|
var inferDocIdFromFile = (relativePath, frontmatterId) => {
|
|
1617
1669
|
if (frontmatterId) return frontmatterId;
|
|
1618
|
-
const fileName =
|
|
1670
|
+
const fileName = import_node_path12.default.posix.basename(removeExtension(relativePath));
|
|
1619
1671
|
if (fileName.toLowerCase() === "index") {
|
|
1620
|
-
return
|
|
1672
|
+
return import_node_path12.default.posix.basename(import_node_path12.default.posix.dirname(relativePath));
|
|
1621
1673
|
}
|
|
1622
1674
|
return stripNumericPrefix(fileName);
|
|
1623
1675
|
};
|
|
@@ -1635,7 +1687,7 @@ var findResourceSegment = (segments) => {
|
|
|
1635
1687
|
return match;
|
|
1636
1688
|
};
|
|
1637
1689
|
var readResourceFrontmatter = async (projectDir, resourcePath) => {
|
|
1638
|
-
const candidates = [
|
|
1690
|
+
const candidates = [import_node_path12.default.join(projectDir, resourcePath, "index.mdx"), import_node_path12.default.join(projectDir, resourcePath, "index.md")];
|
|
1639
1691
|
for (const candidate of candidates) {
|
|
1640
1692
|
try {
|
|
1641
1693
|
const file = await import_promises4.default.readFile(candidate, "utf8");
|
|
@@ -1660,7 +1712,7 @@ var deriveRecordFromPath = async ({
|
|
|
1660
1712
|
}
|
|
1661
1713
|
if (segments[0] === "docs") {
|
|
1662
1714
|
const customPath = normalizeUrlPath(removeExtension(segments.slice(1).join("/")));
|
|
1663
|
-
const title = data.title || data.label ||
|
|
1715
|
+
const title = data.title || data.label || import_node_path12.default.posix.basename(customPath) || "Custom docs";
|
|
1664
1716
|
return {
|
|
1665
1717
|
url: buildUrl(`/docs/custom/${customPath}`, config),
|
|
1666
1718
|
title,
|
|
@@ -1778,7 +1830,7 @@ var collectSearchRecords = async ({
|
|
|
1778
1830
|
files.map(async (file) => {
|
|
1779
1831
|
const raw = await import_promises4.default.readFile(file, "utf8");
|
|
1780
1832
|
const parsed = (0, import_gray_matter4.default)(raw);
|
|
1781
|
-
const relativePath = normalizePath(
|
|
1833
|
+
const relativePath = normalizePath(import_node_path12.default.relative(projectDir, file));
|
|
1782
1834
|
const baseRecord = await deriveRecordFromPath({
|
|
1783
1835
|
projectDir,
|
|
1784
1836
|
relativePath,
|
|
@@ -1826,7 +1878,7 @@ var getSearchOutputPath = ({
|
|
|
1826
1878
|
if (searchOutputPath) {
|
|
1827
1879
|
return searchOutputPath;
|
|
1828
1880
|
}
|
|
1829
|
-
return
|
|
1881
|
+
return import_node_path12.default.join(outDir, isServer ? "client" : "", "pagefind");
|
|
1830
1882
|
};
|
|
1831
1883
|
var buildSearchIndex = async ({ projectDir, outDir, config, isServer, searchOutputPath }) => {
|
|
1832
1884
|
const records = await collectSearchRecords({ projectDir, config });
|
|
@@ -1880,74 +1932,74 @@ ${errors.join("\n")}`);
|
|
|
1880
1932
|
};
|
|
1881
1933
|
|
|
1882
1934
|
// src/catalog-runtime.ts
|
|
1883
|
-
var
|
|
1884
|
-
var
|
|
1935
|
+
var import_node_fs9 = __toESM(require("fs"), 1);
|
|
1936
|
+
var import_node_path13 = __toESM(require("path"), 1);
|
|
1885
1937
|
var import_node_module2 = require("module");
|
|
1886
1938
|
var require2 = (0, import_node_module2.createRequire)(importMetaUrl);
|
|
1887
1939
|
var writeIfChanged = (file, content) => {
|
|
1888
|
-
if (
|
|
1889
|
-
|
|
1890
|
-
|
|
1940
|
+
if (import_node_fs9.default.existsSync(file) && import_node_fs9.default.readFileSync(file, "utf8") === content) return;
|
|
1941
|
+
import_node_fs9.default.mkdirSync(import_node_path13.default.dirname(file), { recursive: true });
|
|
1942
|
+
import_node_fs9.default.writeFileSync(file, content);
|
|
1891
1943
|
};
|
|
1892
1944
|
var importPath = (file) => file.replace(/\\/g, "/");
|
|
1893
|
-
var hasLegacyCatalogRuntime = (projectDirectory) =>
|
|
1945
|
+
var hasLegacyCatalogRuntime = (projectDirectory) => import_node_fs9.default.existsSync(import_node_path13.default.join(projectDirectory, ".eventcatalog-core"));
|
|
1894
1946
|
var clearCatalogCache = (projectDirectory) => {
|
|
1895
1947
|
const { cacheDirectory } = getRuntimePaths(projectDirectory);
|
|
1896
|
-
|
|
1948
|
+
import_node_fs9.default.rmSync(cacheDirectory, { recursive: true, force: true });
|
|
1897
1949
|
};
|
|
1898
1950
|
var prepareCatalogRuntime = ({ projectDirectory, catalogDirectory, packageDirectory }) => {
|
|
1899
|
-
const runtime =
|
|
1900
|
-
const source =
|
|
1901
|
-
const project =
|
|
1951
|
+
const runtime = import_node_path13.default.resolve(catalogDirectory);
|
|
1952
|
+
const source = import_node_path13.default.resolve(packageDirectory);
|
|
1953
|
+
const project = import_node_path13.default.resolve(projectDirectory);
|
|
1902
1954
|
if (runtime === source || runtime === project) {
|
|
1903
1955
|
throw new Error("The catalog runtime must be separate from the project and installed application directories.");
|
|
1904
1956
|
}
|
|
1905
|
-
|
|
1957
|
+
import_node_fs9.default.mkdirSync(runtime, { recursive: true });
|
|
1906
1958
|
writeIfChanged(
|
|
1907
|
-
|
|
1908
|
-
`export { collections } from ${JSON.stringify(importPath(
|
|
1959
|
+
import_node_path13.default.join(runtime, "content.config.ts"),
|
|
1960
|
+
`export { collections } from ${JSON.stringify(importPath(import_node_path13.default.join(source, "src/content.config.ts")))};
|
|
1909
1961
|
`
|
|
1910
1962
|
);
|
|
1911
|
-
const packageTsconfig = JSON.parse(
|
|
1963
|
+
const packageTsconfig = JSON.parse(import_node_fs9.default.readFileSync(import_node_path13.default.join(source, "tsconfig.json"), "utf8"));
|
|
1912
1964
|
const paths = Object.fromEntries(
|
|
1913
1965
|
Object.entries(packageTsconfig.compilerOptions.paths).map(([alias, targets]) => [
|
|
1914
1966
|
alias,
|
|
1915
|
-
targets.map((target) => importPath(
|
|
1967
|
+
targets.map((target) => importPath(import_node_path13.default.resolve(source, target)))
|
|
1916
1968
|
])
|
|
1917
1969
|
);
|
|
1918
|
-
paths["@config"] = [importPath(
|
|
1919
|
-
paths["@catalog/styles"] = [importPath(
|
|
1970
|
+
paths["@config"] = [importPath(import_node_path13.default.join(project, "eventcatalog.config.js"))];
|
|
1971
|
+
paths["@catalog/styles"] = [importPath(import_node_path13.default.join(project, "eventcatalog.styles.css"))];
|
|
1920
1972
|
paths["@catalog/components/*"] = [
|
|
1921
|
-
importPath(
|
|
1922
|
-
importPath(
|
|
1973
|
+
importPath(import_node_path13.default.join(project, "components/*")),
|
|
1974
|
+
importPath(import_node_path13.default.join(project, "federated/components/*"))
|
|
1923
1975
|
];
|
|
1924
|
-
paths["@catalog/snippets/*"] = [importPath(
|
|
1976
|
+
paths["@catalog/snippets/*"] = [importPath(import_node_path13.default.join(project, "snippets/*"))];
|
|
1925
1977
|
for (const specifier of ["astro", "astro/zod", "astro/loaders", "astro/runtime/server/index.js"]) {
|
|
1926
1978
|
paths[specifier] = [importPath(require2.resolve(specifier).replace(/\.js$/, ".d.ts"))];
|
|
1927
1979
|
}
|
|
1928
1980
|
writeIfChanged(
|
|
1929
|
-
|
|
1981
|
+
import_node_path13.default.join(runtime, "tsconfig.json"),
|
|
1930
1982
|
JSON.stringify(
|
|
1931
1983
|
{
|
|
1932
|
-
extends: importPath(
|
|
1984
|
+
extends: importPath(import_node_path13.default.join(source, "tsconfig.json")),
|
|
1933
1985
|
compilerOptions: {
|
|
1934
1986
|
baseUrl: ".",
|
|
1935
1987
|
paths,
|
|
1936
1988
|
typeRoots: [
|
|
1937
|
-
importPath(
|
|
1938
|
-
importPath(
|
|
1939
|
-
importPath(
|
|
1940
|
-
importPath(
|
|
1989
|
+
importPath(import_node_path13.default.join(project, "node_modules/@types")),
|
|
1990
|
+
importPath(import_node_path13.default.join(source, "../node_modules/@types")),
|
|
1991
|
+
importPath(import_node_path13.default.join(source, "../node_modules")),
|
|
1992
|
+
importPath(import_node_path13.default.join(project, "node_modules"))
|
|
1941
1993
|
]
|
|
1942
1994
|
},
|
|
1943
1995
|
include: [
|
|
1944
|
-
importPath(
|
|
1996
|
+
importPath(import_node_path13.default.join(project, ".astro/types.d.ts")),
|
|
1945
1997
|
"content.config.ts",
|
|
1946
|
-
importPath(
|
|
1947
|
-
importPath(
|
|
1998
|
+
importPath(import_node_path13.default.join(project, "components/**/*")),
|
|
1999
|
+
importPath(import_node_path13.default.join(source, "src/**/*"))
|
|
1948
2000
|
],
|
|
1949
2001
|
// Keep legacy generated files out of checks on an existing checkout.
|
|
1950
|
-
exclude: (packageTsconfig.exclude ?? []).map((entry) => importPath(
|
|
2002
|
+
exclude: (packageTsconfig.exclude ?? []).map((entry) => importPath(import_node_path13.default.resolve(source, entry)))
|
|
1951
2003
|
},
|
|
1952
2004
|
null,
|
|
1953
2005
|
2
|
|
@@ -2027,8 +2079,8 @@ var createAstroDevLineFilter = () => {
|
|
|
2027
2079
|
};
|
|
2028
2080
|
|
|
2029
2081
|
// src/astro-config-path.ts
|
|
2030
|
-
var
|
|
2031
|
-
var getAstroConfigPath = (projectDirectory, configFile, paths =
|
|
2082
|
+
var import_node_path14 = __toESM(require("path"), 1);
|
|
2083
|
+
var getAstroConfigPath = (projectDirectory, configFile, paths = import_node_path14.default) => {
|
|
2032
2084
|
const relative = paths.relative(projectDirectory, configFile);
|
|
2033
2085
|
const projectRoot = paths.parse(paths.resolve(projectDirectory)).root.toLowerCase();
|
|
2034
2086
|
const configRoot = paths.parse(paths.resolve(configFile)).root.toLowerCase();
|
|
@@ -2043,18 +2095,18 @@ var getAstroConfigPath = (projectDirectory, configFile, paths = import_node_path
|
|
|
2043
2095
|
// src/federation/federate.ts
|
|
2044
2096
|
var import_node_crypto5 = require("crypto");
|
|
2045
2097
|
var import_promises10 = __toESM(require("fs/promises"), 1);
|
|
2046
|
-
var
|
|
2098
|
+
var import_node_path20 = __toESM(require("path"), 1);
|
|
2047
2099
|
var import_sdk3 = __toESM(require("@eventcatalog/sdk"), 1);
|
|
2048
2100
|
|
|
2049
2101
|
// src/federation/content-cache.ts
|
|
2050
2102
|
var import_node_crypto2 = require("crypto");
|
|
2051
2103
|
var import_promises5 = __toESM(require("fs/promises"), 1);
|
|
2052
|
-
var
|
|
2104
|
+
var import_node_path15 = __toESM(require("path"), 1);
|
|
2053
2105
|
var getContentHash = (content) => `sha256:${(0, import_node_crypto2.createHash)("sha256").update(content).digest("hex")}`;
|
|
2054
2106
|
var isContentHash = (key) => /^sha256:[a-f0-9]{64}$/i.test(key);
|
|
2055
2107
|
var createFederationContentCache = (projectDirectory, options = {}) => {
|
|
2056
|
-
const cacheDirectory =
|
|
2057
|
-
const getCachePath = (key) =>
|
|
2108
|
+
const cacheDirectory = import_node_path15.default.join(projectDirectory, ".eventcatalog-cache", "federation", "content");
|
|
2109
|
+
const getCachePath = (key) => import_node_path15.default.join(cacheDirectory, encodeURIComponent(key));
|
|
2058
2110
|
return {
|
|
2059
2111
|
async get(key) {
|
|
2060
2112
|
if (options.read === false || !isContentHash(key)) return void 0;
|
|
@@ -2241,20 +2293,20 @@ var getVisibleFederationDiagnostics = (diagnostics, verbose) => diagnostics.filt
|
|
|
2241
2293
|
|
|
2242
2294
|
// src/federation/output-transaction.ts
|
|
2243
2295
|
var import_promises6 = __toESM(require("fs/promises"), 1);
|
|
2244
|
-
var
|
|
2296
|
+
var import_node_path16 = __toESM(require("path"), 1);
|
|
2245
2297
|
var getSafePublicPath = (publicDirectory, relativePath) => {
|
|
2246
|
-
const normalizedPath =
|
|
2247
|
-
const unsafe = relativePath.length === 0 || relativePath.includes("\0") || relativePath.includes("\\") ||
|
|
2298
|
+
const normalizedPath = import_node_path16.default.posix.normalize(relativePath);
|
|
2299
|
+
const unsafe = relativePath.length === 0 || relativePath.includes("\0") || relativePath.includes("\\") || import_node_path16.default.posix.isAbsolute(relativePath) || /^[a-zA-Z]:\//.test(relativePath) || normalizedPath !== relativePath || normalizedPath === ".." || normalizedPath.startsWith("../");
|
|
2248
2300
|
if (unsafe) return void 0;
|
|
2249
|
-
const destinationPath =
|
|
2250
|
-
const relativeDestinationPath =
|
|
2251
|
-
return relativeDestinationPath !== "" && relativeDestinationPath !== ".." && !relativeDestinationPath.startsWith(`..${
|
|
2301
|
+
const destinationPath = import_node_path16.default.resolve(publicDirectory, relativePath);
|
|
2302
|
+
const relativeDestinationPath = import_node_path16.default.relative(publicDirectory, destinationPath);
|
|
2303
|
+
return relativeDestinationPath !== "" && relativeDestinationPath !== ".." && !relativeDestinationPath.startsWith(`..${import_node_path16.default.sep}`) && !import_node_path16.default.isAbsolute(relativeDestinationPath) ? destinationPath : void 0;
|
|
2252
2304
|
};
|
|
2253
2305
|
var beginFederationOutputTransaction = async (projectDirectory, outDir, relativePublicPaths) => {
|
|
2254
|
-
const transactionDirectory = await import_promises6.default.mkdtemp(
|
|
2255
|
-
const previousOutDir =
|
|
2256
|
-
const publicBackupDirectory =
|
|
2257
|
-
const publicDirectory =
|
|
2306
|
+
const transactionDirectory = await import_promises6.default.mkdtemp(import_node_path16.default.join(projectDirectory, ".eventcatalog-federation-transaction-"));
|
|
2307
|
+
const previousOutDir = import_node_path16.default.join(transactionDirectory, "federated");
|
|
2308
|
+
const publicBackupDirectory = import_node_path16.default.join(transactionDirectory, "public");
|
|
2309
|
+
const publicDirectory = import_node_path16.default.resolve(projectDirectory, "public");
|
|
2258
2310
|
const publicSnapshots = [];
|
|
2259
2311
|
const missingPublicDirectories = /* @__PURE__ */ new Set();
|
|
2260
2312
|
let hadPreviousOutDir = false;
|
|
@@ -2265,8 +2317,8 @@ var beginFederationOutputTransaction = async (projectDirectory, outDir, relative
|
|
|
2265
2317
|
try {
|
|
2266
2318
|
const stat = await import_promises6.default.lstat(destinationPath);
|
|
2267
2319
|
if (!stat.isFile()) continue;
|
|
2268
|
-
const backupPath =
|
|
2269
|
-
await import_promises6.default.mkdir(
|
|
2320
|
+
const backupPath = import_node_path16.default.join(publicBackupDirectory, `${publicSnapshots.length}`);
|
|
2321
|
+
await import_promises6.default.mkdir(import_node_path16.default.dirname(backupPath), { recursive: true });
|
|
2270
2322
|
await import_promises6.default.copyFile(destinationPath, backupPath);
|
|
2271
2323
|
publicSnapshots.push({ backupPath, destinationPath, state: "file" });
|
|
2272
2324
|
} catch (error) {
|
|
@@ -2274,7 +2326,7 @@ var beginFederationOutputTransaction = async (projectDirectory, outDir, relative
|
|
|
2274
2326
|
if (code === "ENOTDIR") continue;
|
|
2275
2327
|
if (code !== "ENOENT") throw error;
|
|
2276
2328
|
publicSnapshots.push({ destinationPath, state: "missing" });
|
|
2277
|
-
let directory =
|
|
2329
|
+
let directory = import_node_path16.default.dirname(destinationPath);
|
|
2278
2330
|
while (directory !== publicDirectory) {
|
|
2279
2331
|
try {
|
|
2280
2332
|
await import_promises6.default.lstat(directory);
|
|
@@ -2284,7 +2336,7 @@ var beginFederationOutputTransaction = async (projectDirectory, outDir, relative
|
|
|
2284
2336
|
if (directoryCode === "ENOTDIR") break;
|
|
2285
2337
|
if (directoryCode !== "ENOENT") throw directoryError;
|
|
2286
2338
|
missingPublicDirectories.add(directory);
|
|
2287
|
-
directory =
|
|
2339
|
+
directory = import_node_path16.default.dirname(directory);
|
|
2288
2340
|
}
|
|
2289
2341
|
}
|
|
2290
2342
|
}
|
|
@@ -2320,7 +2372,7 @@ var beginFederationOutputTransaction = async (projectDirectory, outDir, relative
|
|
|
2320
2372
|
continue;
|
|
2321
2373
|
}
|
|
2322
2374
|
await attempt(async () => {
|
|
2323
|
-
await import_promises6.default.mkdir(
|
|
2375
|
+
await import_promises6.default.mkdir(import_node_path16.default.dirname(snapshot.destinationPath), { recursive: true });
|
|
2324
2376
|
await import_promises6.default.copyFile(snapshot.backupPath, snapshot.destinationPath);
|
|
2325
2377
|
});
|
|
2326
2378
|
}
|
|
@@ -2357,7 +2409,7 @@ var withFederationOutputTransaction = async (projectDirectory, outDir, relativeP
|
|
|
2357
2409
|
// src/federation/public-assets.ts
|
|
2358
2410
|
var import_node_crypto3 = require("crypto");
|
|
2359
2411
|
var import_promises7 = __toESM(require("fs/promises"), 1);
|
|
2360
|
-
var
|
|
2412
|
+
var import_node_path17 = __toESM(require("path"), 1);
|
|
2361
2413
|
var getContentHash2 = (content) => `sha256:${(0, import_node_crypto3.createHash)("sha256").update(content).digest("hex")}`;
|
|
2362
2414
|
var getFileHash = async (filePath) => {
|
|
2363
2415
|
try {
|
|
@@ -2369,13 +2421,13 @@ var getFileHash = async (filePath) => {
|
|
|
2369
2421
|
}
|
|
2370
2422
|
};
|
|
2371
2423
|
var getSafePath = (directory, relativePath) => {
|
|
2372
|
-
const normalizedPath =
|
|
2373
|
-
const unsafe = relativePath.length === 0 || relativePath.includes("\0") || relativePath.includes("\\") ||
|
|
2424
|
+
const normalizedPath = import_node_path17.default.posix.normalize(relativePath);
|
|
2425
|
+
const unsafe = relativePath.length === 0 || relativePath.includes("\0") || relativePath.includes("\\") || import_node_path17.default.posix.isAbsolute(relativePath) || /^[a-zA-Z]:\//.test(relativePath) || normalizedPath !== relativePath || normalizedPath === ".." || normalizedPath.startsWith("../");
|
|
2374
2426
|
if (unsafe) return void 0;
|
|
2375
|
-
const resolvedDirectory =
|
|
2376
|
-
const resolvedPath =
|
|
2377
|
-
const relativeResolvedPath =
|
|
2378
|
-
if (relativeResolvedPath === "" || relativeResolvedPath === ".." || relativeResolvedPath.startsWith(`..${
|
|
2427
|
+
const resolvedDirectory = import_node_path17.default.resolve(directory);
|
|
2428
|
+
const resolvedPath = import_node_path17.default.resolve(resolvedDirectory, relativePath);
|
|
2429
|
+
const relativeResolvedPath = import_node_path17.default.relative(resolvedDirectory, resolvedPath);
|
|
2430
|
+
if (relativeResolvedPath === "" || relativeResolvedPath === ".." || relativeResolvedPath.startsWith(`..${import_node_path17.default.sep}`) || import_node_path17.default.isAbsolute(relativeResolvedPath)) {
|
|
2379
2431
|
return void 0;
|
|
2380
2432
|
}
|
|
2381
2433
|
return resolvedPath;
|
|
@@ -2383,16 +2435,16 @@ var getSafePath = (directory, relativePath) => {
|
|
|
2383
2435
|
var listFiles = async (directory, relativeDirectory = "") => {
|
|
2384
2436
|
let entries;
|
|
2385
2437
|
try {
|
|
2386
|
-
entries = await import_promises7.default.readdir(
|
|
2438
|
+
entries = await import_promises7.default.readdir(import_node_path17.default.join(directory, relativeDirectory), { withFileTypes: true });
|
|
2387
2439
|
} catch (error) {
|
|
2388
2440
|
if (error.code === "ENOENT") return [];
|
|
2389
2441
|
throw error;
|
|
2390
2442
|
}
|
|
2391
2443
|
const files = await Promise.all(
|
|
2392
2444
|
entries.map(async (entry) => {
|
|
2393
|
-
const relativePath =
|
|
2445
|
+
const relativePath = import_node_path17.default.join(relativeDirectory, entry.name);
|
|
2394
2446
|
if (entry.isDirectory()) return listFiles(directory, relativePath);
|
|
2395
|
-
return entry.isFile() ? [relativePath.split(
|
|
2447
|
+
return entry.isFile() ? [relativePath.split(import_node_path17.default.sep).join("/")] : [];
|
|
2396
2448
|
})
|
|
2397
2449
|
);
|
|
2398
2450
|
return files.flat().sort();
|
|
@@ -2407,19 +2459,19 @@ var pathExists = async (filePath) => {
|
|
|
2407
2459
|
}
|
|
2408
2460
|
};
|
|
2409
2461
|
var hasBlockingParent = async (publicDirectory, destinationPath) => {
|
|
2410
|
-
let currentPath =
|
|
2462
|
+
let currentPath = import_node_path17.default.dirname(destinationPath);
|
|
2411
2463
|
while (currentPath !== publicDirectory) {
|
|
2412
2464
|
try {
|
|
2413
2465
|
if (!(await import_promises7.default.lstat(currentPath)).isDirectory()) return true;
|
|
2414
2466
|
} catch (error) {
|
|
2415
2467
|
if (error.code !== "ENOENT") throw error;
|
|
2416
2468
|
}
|
|
2417
|
-
currentPath =
|
|
2469
|
+
currentPath = import_node_path17.default.dirname(currentPath);
|
|
2418
2470
|
}
|
|
2419
2471
|
return false;
|
|
2420
2472
|
};
|
|
2421
2473
|
var pruneEmptyDirectories = async (publicDirectory, filePath) => {
|
|
2422
|
-
let currentPath =
|
|
2474
|
+
let currentPath = import_node_path17.default.dirname(filePath);
|
|
2423
2475
|
while (currentPath !== publicDirectory) {
|
|
2424
2476
|
try {
|
|
2425
2477
|
await import_promises7.default.rmdir(currentPath);
|
|
@@ -2427,7 +2479,7 @@ var pruneEmptyDirectories = async (publicDirectory, filePath) => {
|
|
|
2427
2479
|
if (!["ENOENT", "ENOTEMPTY"].includes(error.code ?? "")) throw error;
|
|
2428
2480
|
if (error.code === "ENOTEMPTY") return;
|
|
2429
2481
|
}
|
|
2430
|
-
currentPath =
|
|
2482
|
+
currentPath = import_node_path17.default.dirname(currentPath);
|
|
2431
2483
|
}
|
|
2432
2484
|
};
|
|
2433
2485
|
var composePublicAssets = async ({
|
|
@@ -2437,8 +2489,8 @@ var composePublicAssets = async ({
|
|
|
2437
2489
|
previousFiles = {},
|
|
2438
2490
|
collisionPaths = /* @__PURE__ */ new Set()
|
|
2439
2491
|
}) => {
|
|
2440
|
-
const publicDirectory =
|
|
2441
|
-
const federatedPublicDirectory =
|
|
2492
|
+
const publicDirectory = import_node_path17.default.resolve(projectDirectory, "public");
|
|
2493
|
+
const federatedPublicDirectory = import_node_path17.default.resolve(federatedDirectory, "public");
|
|
2442
2494
|
const sourceFiles = await listFiles(federatedPublicDirectory);
|
|
2443
2495
|
const sourceFileSet = new Set(sourceFiles);
|
|
2444
2496
|
const managedFiles = /* @__PURE__ */ new Set();
|
|
@@ -2474,7 +2526,7 @@ var composePublicAssets = async ({
|
|
|
2474
2526
|
const asset = publicAssetsByPath.get(relativePath);
|
|
2475
2527
|
if (!asset) throw new Error(`Cannot identify the source of federated public asset "${relativePath}"`);
|
|
2476
2528
|
const content = await import_promises7.default.readFile(sourcePath);
|
|
2477
|
-
await import_promises7.default.mkdir(
|
|
2529
|
+
await import_promises7.default.mkdir(import_node_path17.default.dirname(destinationPath), { recursive: true });
|
|
2478
2530
|
await import_promises7.default.writeFile(destinationPath, content);
|
|
2479
2531
|
files[relativePath] = { source: asset.resolvedFrom.source, hash: getContentHash2(content) };
|
|
2480
2532
|
copied += 1;
|
|
@@ -2487,17 +2539,17 @@ var composePublicAssets = async ({
|
|
|
2487
2539
|
// src/federation/filesystem-source-provider.ts
|
|
2488
2540
|
var import_node_crypto4 = require("crypto");
|
|
2489
2541
|
var import_promises8 = __toESM(require("fs/promises"), 1);
|
|
2490
|
-
var
|
|
2542
|
+
var import_node_path18 = __toESM(require("path"), 1);
|
|
2491
2543
|
var import_sdk = __toESM(require("@eventcatalog/sdk"), 1);
|
|
2492
2544
|
var FILESYSTEM_SOURCE_PREFIX = "file:";
|
|
2493
2545
|
var isWithinDirectory = (directory, target) => {
|
|
2494
|
-
const relativePath =
|
|
2495
|
-
return relativePath === "" || !relativePath.startsWith(`..${
|
|
2546
|
+
const relativePath = import_node_path18.default.relative(directory, target);
|
|
2547
|
+
return relativePath === "" || !relativePath.startsWith(`..${import_node_path18.default.sep}`) && relativePath !== ".." && !import_node_path18.default.isAbsolute(relativePath);
|
|
2496
2548
|
};
|
|
2497
2549
|
var assertPortableRelativePath = (filePath, label, allowRoot = true) => {
|
|
2498
2550
|
const portablePath = filePath.replaceAll("\\", "/");
|
|
2499
|
-
const normalizedPath =
|
|
2500
|
-
const isUnsafe = filePath.includes("\\") || filePath.includes("\0") ||
|
|
2551
|
+
const normalizedPath = import_node_path18.default.posix.normalize(portablePath);
|
|
2552
|
+
const isUnsafe = filePath.includes("\\") || filePath.includes("\0") || import_node_path18.default.posix.isAbsolute(normalizedPath) || /^[a-zA-Z]:\//.test(normalizedPath) || normalizedPath === ".." || normalizedPath.startsWith("../") || !allowRoot && (normalizedPath === "." || normalizedPath === "");
|
|
2501
2553
|
if (isUnsafe) throw new Error(`${label} "${filePath}" escapes its filesystem source`);
|
|
2502
2554
|
return normalizedPath;
|
|
2503
2555
|
};
|
|
@@ -2507,13 +2559,13 @@ var getSourceRoot = (projectDirectory, source) => {
|
|
|
2507
2559
|
}
|
|
2508
2560
|
const locator = source.source.slice(FILESYSTEM_SOURCE_PREFIX.length);
|
|
2509
2561
|
if (!locator.trim()) throw new Error(`Filesystem federation source "${source.id}" requires a path after "file:".`);
|
|
2510
|
-
return
|
|
2562
|
+
return import_node_path18.default.resolve(projectDirectory, locator);
|
|
2511
2563
|
};
|
|
2512
2564
|
var getCatalogDirectory = async (projectDirectory, source) => {
|
|
2513
2565
|
if (source.ref) throw new Error(`Filesystem federation source "${source.id}" does not support "ref".`);
|
|
2514
2566
|
const sourceRoot = getSourceRoot(projectDirectory, source);
|
|
2515
2567
|
const catalogPath = assertPortableRelativePath(source.path ?? ".", "Catalog path");
|
|
2516
|
-
const catalogDirectory =
|
|
2568
|
+
const catalogDirectory = import_node_path18.default.resolve(sourceRoot, ...catalogPath.split("/"));
|
|
2517
2569
|
if (!isWithinDirectory(sourceRoot, catalogDirectory)) {
|
|
2518
2570
|
throw new Error(`Catalog path "${source.path}" escapes source "${source.id}"`);
|
|
2519
2571
|
}
|
|
@@ -2535,7 +2587,7 @@ var getCatalogDirectory = async (projectDirectory, source) => {
|
|
|
2535
2587
|
};
|
|
2536
2588
|
var getArtifactPath = async (catalogDirectory, source, artifactPath) => {
|
|
2537
2589
|
const normalizedPath = assertPortableRelativePath(artifactPath, "Federated artifact path", false);
|
|
2538
|
-
const filePath =
|
|
2590
|
+
const filePath = import_node_path18.default.resolve(catalogDirectory, ...normalizedPath.split("/"));
|
|
2539
2591
|
if (!isWithinDirectory(catalogDirectory, filePath)) {
|
|
2540
2592
|
throw new Error(`Federated artifact path "${artifactPath}" escapes source "${source.id}"`);
|
|
2541
2593
|
}
|
|
@@ -2575,7 +2627,7 @@ var createFileSystemSourceProvider = (projectDirectory) => ({
|
|
|
2575
2627
|
var import_node_child_process = require("child_process");
|
|
2576
2628
|
var import_promises9 = __toESM(require("fs/promises"), 1);
|
|
2577
2629
|
var import_node_os3 = __toESM(require("os"), 1);
|
|
2578
|
-
var
|
|
2630
|
+
var import_node_path19 = __toESM(require("path"), 1);
|
|
2579
2631
|
var import_node_util = require("util");
|
|
2580
2632
|
var import_sdk2 = __toESM(require("@eventcatalog/sdk"), 1);
|
|
2581
2633
|
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
|
|
@@ -2586,8 +2638,8 @@ var parseGitHubSource = (source) => {
|
|
|
2586
2638
|
};
|
|
2587
2639
|
var assertSafeCatalogPath = (source) => {
|
|
2588
2640
|
const catalogPath = source.path ?? ".";
|
|
2589
|
-
const normalized =
|
|
2590
|
-
if (catalogPath.includes("\\") ||
|
|
2641
|
+
const normalized = import_node_path19.default.posix.normalize(catalogPath.replaceAll("\\", "/"));
|
|
2642
|
+
if (catalogPath.includes("\\") || import_node_path19.default.posix.isAbsolute(normalized) || normalized === ".." || normalized.startsWith("../")) {
|
|
2591
2643
|
throw new Error(`Catalog path "${catalogPath}" escapes source "${source.id}"`);
|
|
2592
2644
|
}
|
|
2593
2645
|
};
|
|
@@ -2630,8 +2682,8 @@ var getGitEnvironment = (token) => {
|
|
|
2630
2682
|
};
|
|
2631
2683
|
var createCheckout = (executeFile, token) => async (source, ref, callback) => {
|
|
2632
2684
|
const { owner, repository } = parseGitHubSource(source);
|
|
2633
|
-
const catalogPath =
|
|
2634
|
-
const directory = await import_promises9.default.mkdtemp(
|
|
2685
|
+
const catalogPath = import_node_path19.default.posix.normalize(source.path ?? ".");
|
|
2686
|
+
const directory = await import_promises9.default.mkdtemp(import_node_path19.default.join(import_node_os3.default.tmpdir(), "eventcatalog-federation-"));
|
|
2635
2687
|
const env = getGitEnvironment(token);
|
|
2636
2688
|
try {
|
|
2637
2689
|
const git = (args) => executeFile("git", args, { cwd: directory, env, encoding: "utf8" });
|
|
@@ -2651,16 +2703,16 @@ var createCheckout = (executeFile, token) => async (source, ref, callback) => {
|
|
|
2651
2703
|
var generateIndex = async (source, ref, checkout, executeFile) => checkout(source, ref, async (directory) => {
|
|
2652
2704
|
const { stdout } = await executeFile("git", ["rev-parse", "HEAD"], { cwd: directory, encoding: "utf8" });
|
|
2653
2705
|
const commit = stdout.trim();
|
|
2654
|
-
const catalogDirectory =
|
|
2655
|
-
const relativeCatalogDirectory =
|
|
2656
|
-
if (relativeCatalogDirectory.startsWith("..") ||
|
|
2706
|
+
const catalogDirectory = import_node_path19.default.resolve(directory, source.path ?? ".");
|
|
2707
|
+
const relativeCatalogDirectory = import_node_path19.default.relative(directory, catalogDirectory);
|
|
2708
|
+
if (relativeCatalogDirectory.startsWith("..") || import_node_path19.default.isAbsolute(relativeCatalogDirectory)) {
|
|
2657
2709
|
throw new Error(`Catalog path "${source.path}" escapes source "${source.id}"`);
|
|
2658
2710
|
}
|
|
2659
2711
|
const index = await (0, import_sdk2.default)(catalogDirectory).buildIndex({ source: source.id, commit });
|
|
2660
2712
|
return { bytes: Buffer.from(JSON.stringify(index)), index, commit, generated: true };
|
|
2661
2713
|
});
|
|
2662
2714
|
var fetchPublishedIndex = async (source, ref, fetcher, token) => {
|
|
2663
|
-
const indexPath =
|
|
2715
|
+
const indexPath = import_node_path19.default.posix.join(source.path ?? ".", "catalog.index.json");
|
|
2664
2716
|
const bytes = await fetchBytes(source, ref, indexPath, fetcher, token);
|
|
2665
2717
|
if (!bytes) return void 0;
|
|
2666
2718
|
const index = (0, import_sdk2.parseIndex)(JSON.parse(bytes.toString("utf8")));
|
|
@@ -2683,7 +2735,7 @@ var createGitHubSourceProvider = (options = {}) => {
|
|
|
2683
2735
|
},
|
|
2684
2736
|
async fetchContent({ source, commit, path: artifactPath }) {
|
|
2685
2737
|
assertSafeCatalogPath(source);
|
|
2686
|
-
const catalogPath =
|
|
2738
|
+
const catalogPath = import_node_path19.default.posix.join(source.path ?? ".", artifactPath);
|
|
2687
2739
|
const content = await fetchBytes(source, commit, catalogPath, fetcher, token);
|
|
2688
2740
|
if (!content) throw new Error(`Federated artifact not found for "${source.id}": ${artifactPath}`);
|
|
2689
2741
|
return content;
|
|
@@ -2794,8 +2846,8 @@ var pathExists2 = async (filePath) => {
|
|
|
2794
2846
|
}
|
|
2795
2847
|
};
|
|
2796
2848
|
var cleanupPreviousFederation = async (projectDirectory, onProgress) => {
|
|
2797
|
-
const outDir =
|
|
2798
|
-
const lockPath =
|
|
2849
|
+
const outDir = import_node_path20.default.join(projectDirectory, "federated");
|
|
2850
|
+
const lockPath = import_node_path20.default.join(projectDirectory, "eventcatalog.lock");
|
|
2799
2851
|
const previousLock = await readLock(lockPath);
|
|
2800
2852
|
const hadFederatedOutput = await pathExists2(outDir);
|
|
2801
2853
|
const hadLock = previousLock !== void 0;
|
|
@@ -2855,8 +2907,8 @@ var federateCatalog = async (projectDirectory, options = {}) => {
|
|
|
2855
2907
|
throw new Error(`Failed to federate source "${source.id}": ${message2}`, { cause: error });
|
|
2856
2908
|
}
|
|
2857
2909
|
}
|
|
2858
|
-
const outDir =
|
|
2859
|
-
const lockPath =
|
|
2910
|
+
const outDir = import_node_path20.default.join(projectDirectory, "federated");
|
|
2911
|
+
const lockPath = import_node_path20.default.join(projectDirectory, "eventcatalog.lock");
|
|
2860
2912
|
const previousLock = await readLock(lockPath);
|
|
2861
2913
|
const resources = resolvedSources.reduce((total, source) => total + source.resolved.index.resources.length, 0);
|
|
2862
2914
|
const remoteIndexes = resolvedSources.map(({ resolved }) => resolved.index);
|
|
@@ -2968,17 +3020,17 @@ Run npm i @eventcatalog/core to update`;
|
|
|
2968
3020
|
};
|
|
2969
3021
|
|
|
2970
3022
|
// src/eventcatalog.ts
|
|
2971
|
-
var currentDir =
|
|
2972
|
-
var astroCli =
|
|
3023
|
+
var currentDir = import_node_path22.default.dirname((0, import_node_url2.fileURLToPath)(importMetaUrl));
|
|
3024
|
+
var astroCli = import_node_path22.default.join(import_node_path22.default.dirname((0, import_node_module3.createRequire)(importMetaUrl).resolve("astro/package.json")), "bin/astro.mjs");
|
|
2973
3025
|
var ASTRO_IN_FOREGROUND = { ASTRO_DEV_BACKGROUND: "1", ASTRO_PREVIEW_BACKGROUND: "1" };
|
|
2974
3026
|
var program = new import_commander.Command().version(VERSION);
|
|
2975
|
-
var dir =
|
|
2976
|
-
var eventCatalogDir =
|
|
2977
|
-
var astroConfigPath = () => getAstroConfigPath(dir, (0,
|
|
3027
|
+
var dir = import_node_path22.default.resolve(process.env.PROJECT_DIR || process.cwd());
|
|
3028
|
+
var eventCatalogDir = import_node_path22.default.resolve((0, import_node_path21.join)(currentDir, "../eventcatalog/"));
|
|
3029
|
+
var astroConfigPath = () => getAstroConfigPath(dir, (0, import_node_path21.join)(eventCatalogDir, "astro.config.mjs"));
|
|
2978
3030
|
var { runtimeDirectory: core } = getRuntimePaths(dir);
|
|
2979
3031
|
var getInstalledEventCatalogVersion = () => {
|
|
2980
3032
|
try {
|
|
2981
|
-
const pkg = import_fs.default.readFileSync((0,
|
|
3033
|
+
const pkg = import_fs.default.readFileSync((0, import_node_path21.join)(dir, "package.json"), "utf8");
|
|
2982
3034
|
const json = JSON.parse(pkg);
|
|
2983
3035
|
return json.dependencies["@eventcatalog/core"];
|
|
2984
3036
|
} catch (error) {
|
|
@@ -3047,12 +3099,12 @@ var startDevPrewarm = ({
|
|
|
3047
3099
|
var buildDevSearchIndex = async ({ config }) => {
|
|
3048
3100
|
const result = await buildSearchIndex({
|
|
3049
3101
|
projectDir: dir,
|
|
3050
|
-
outDir:
|
|
3051
|
-
searchOutputPath:
|
|
3102
|
+
outDir: import_node_path22.default.join(core, "public"),
|
|
3103
|
+
searchOutputPath: import_node_path22.default.join(core, "public", "pagefind"),
|
|
3052
3104
|
config,
|
|
3053
3105
|
isServer: false
|
|
3054
3106
|
});
|
|
3055
|
-
logger.info(`Indexed ${result.records} page(s) into ${
|
|
3107
|
+
logger.info(`Indexed ${result.records} page(s) into ${import_node_path22.default.relative(core, result.outputPath)}`, "search");
|
|
3056
3108
|
};
|
|
3057
3109
|
var warnIfIndexedSearchUsesAuth = async () => {
|
|
3058
3110
|
if (!await isAuthEnabled()) {
|
|
@@ -3234,8 +3286,8 @@ program.command("dev").description("Run development server of EventCatalog").opt
|
|
|
3234
3286
|
logger.info("Setting up EventCatalog...", "eventcatalog");
|
|
3235
3287
|
const isServer = await isOutputServer();
|
|
3236
3288
|
logger.info(isServer ? "EventCatalog is running in Server Mode" : "EventCatalog is running in Static Mode", "config");
|
|
3237
|
-
if (import_fs.default.existsSync(
|
|
3238
|
-
import_dotenv.default.config({ path:
|
|
3289
|
+
if (import_fs.default.existsSync(import_node_path22.default.join(dir, ".env"))) {
|
|
3290
|
+
import_dotenv.default.config({ path: import_node_path22.default.join(dir, ".env") });
|
|
3239
3291
|
}
|
|
3240
3292
|
if (options.debug) {
|
|
3241
3293
|
logger.info("Debug mode enabled", "debug");
|
|
@@ -3313,8 +3365,8 @@ program.command("build").description("Run build of EventCatalog").action(async (
|
|
|
3313
3365
|
logger.info("Building EventCatalog...", "build");
|
|
3314
3366
|
const isServer = await isOutputServer();
|
|
3315
3367
|
logger.info(isServer ? "EventCatalog is running in Server Mode" : "EventCatalog is running in Static Mode", "config");
|
|
3316
|
-
if (import_fs.default.existsSync(
|
|
3317
|
-
import_dotenv.default.config({ path:
|
|
3368
|
+
if (import_fs.default.existsSync(import_node_path22.default.join(dir, ".env"))) {
|
|
3369
|
+
import_dotenv.default.config({ path: import_node_path22.default.join(dir, ".env") });
|
|
3318
3370
|
}
|
|
3319
3371
|
await verifyRequiredFieldsAreInCatalogConfigFile(dir);
|
|
3320
3372
|
const config = await getEventCatalogConfigFile(dir);
|
|
@@ -3351,7 +3403,7 @@ program.command("build").description("Run build of EventCatalog").action(async (
|
|
|
3351
3403
|
});
|
|
3352
3404
|
if (await isIndexedSearchEnabled()) {
|
|
3353
3405
|
await warnIfIndexedSearchUsesAuth();
|
|
3354
|
-
const outDir =
|
|
3406
|
+
const outDir = import_node_path22.default.resolve(dir, await getProjectOutDir());
|
|
3355
3407
|
logger.info("Building indexed search...", "search");
|
|
3356
3408
|
const result = await buildSearchIndex({
|
|
3357
3409
|
projectDir: dir,
|
|
@@ -3359,7 +3411,7 @@ program.command("build").description("Run build of EventCatalog").action(async (
|
|
|
3359
3411
|
config,
|
|
3360
3412
|
isServer
|
|
3361
3413
|
});
|
|
3362
|
-
logger.info(`Indexed ${result.records} page(s) into ${
|
|
3414
|
+
logger.info(`Indexed ${result.records} page(s) into ${import_node_path22.default.relative(dir, result.outputPath)}`, "search");
|
|
3363
3415
|
}
|
|
3364
3416
|
});
|
|
3365
3417
|
var previewCatalog = async ({ command }) => {
|
|
@@ -3390,7 +3442,7 @@ if (start) {
|
|
|
3390
3442
|
}
|
|
3391
3443
|
`;
|
|
3392
3444
|
var startServerCatalog = async () => {
|
|
3393
|
-
const serverEntryPath =
|
|
3445
|
+
const serverEntryPath = import_node_path22.default.join(dir, "dist", "server", "entry.mjs");
|
|
3394
3446
|
const config = await getEventCatalogConfigFile(dir);
|
|
3395
3447
|
const base = (config?.base || "/").replace(/\/$/, "");
|
|
3396
3448
|
await runCommandWithFilteredOutput({
|
|
@@ -3409,20 +3461,21 @@ var startServerCatalog = async () => {
|
|
|
3409
3461
|
program.command("preview").description("Serves the contents of your eventcatalog build directory").action(async (options, command) => {
|
|
3410
3462
|
logger.welcome();
|
|
3411
3463
|
logger.info("Starting preview of your build...", "preview");
|
|
3412
|
-
if (import_fs.default.existsSync(
|
|
3413
|
-
import_dotenv.default.config({ path:
|
|
3464
|
+
if (import_fs.default.existsSync(import_node_path22.default.join(dir, ".env"))) {
|
|
3465
|
+
import_dotenv.default.config({ path: import_node_path22.default.join(dir, ".env") });
|
|
3414
3466
|
}
|
|
3415
3467
|
await previewCatalog({ command });
|
|
3416
3468
|
});
|
|
3417
3469
|
program.command("start").description("Serves the contents of your eventcatalog build directory").action(async (options, command) => {
|
|
3418
3470
|
logger.welcome();
|
|
3419
3471
|
logger.info("Starting preview of your build...", "preview");
|
|
3420
|
-
if (import_fs.default.existsSync(
|
|
3421
|
-
import_dotenv.default.config({ path:
|
|
3472
|
+
if (import_fs.default.existsSync(import_node_path22.default.join(dir, ".env"))) {
|
|
3473
|
+
import_dotenv.default.config({ path: import_node_path22.default.join(dir, ".env") });
|
|
3422
3474
|
}
|
|
3423
3475
|
const isServerOutput = await isOutputServer();
|
|
3424
3476
|
if (isServerOutput) {
|
|
3425
|
-
await getLicenseStatus2(dir);
|
|
3477
|
+
const license = await getLicenseStatus2(dir);
|
|
3478
|
+
void log_build_default(dir, { command: "start", license });
|
|
3426
3479
|
await startServerCatalog();
|
|
3427
3480
|
} else {
|
|
3428
3481
|
await previewCatalog({ command });
|
|
@@ -3431,22 +3484,22 @@ program.command("start").description("Serves the contents of your eventcatalog b
|
|
|
3431
3484
|
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) => {
|
|
3432
3485
|
logger.welcome();
|
|
3433
3486
|
logger.info("Exporting EventCatalog...", "export");
|
|
3434
|
-
if (import_fs.default.existsSync(
|
|
3435
|
-
import_dotenv.default.config({ path:
|
|
3487
|
+
if (import_fs.default.existsSync(import_node_path22.default.join(dir, ".env"))) {
|
|
3488
|
+
import_dotenv.default.config({ path: import_node_path22.default.join(dir, ".env") });
|
|
3436
3489
|
}
|
|
3437
3490
|
const { default: initSDK } = await import("@eventcatalog/sdk");
|
|
3438
3491
|
const sdk = initSDK(dir);
|
|
3439
3492
|
const catalog = await sdk.dumpCatalog({ includeMarkdown: options.includeMarkdown });
|
|
3440
|
-
const exportsDir =
|
|
3493
|
+
const exportsDir = import_node_path22.default.join(dir, "exports");
|
|
3441
3494
|
ensureDir(exportsDir);
|
|
3442
3495
|
const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
3443
|
-
const exportFile =
|
|
3496
|
+
const exportFile = import_node_path22.default.join(exportsDir, `catalog-${date}.json`);
|
|
3444
3497
|
import_fs.default.writeFileSync(exportFile, JSON.stringify(catalog, null, 2), "utf-8");
|
|
3445
3498
|
logger.info(`Catalog exported to ${exportFile}`, "export");
|
|
3446
3499
|
});
|
|
3447
3500
|
program.command("generate [siteDir]").description("Start the generator scripts.").action(async () => {
|
|
3448
|
-
if (import_fs.default.existsSync(
|
|
3449
|
-
import_dotenv.default.config({ path:
|
|
3501
|
+
if (import_fs.default.existsSync(import_node_path22.default.join(dir, ".env"))) {
|
|
3502
|
+
import_dotenv.default.config({ path: import_node_path22.default.join(dir, ".env") });
|
|
3450
3503
|
}
|
|
3451
3504
|
await generate(dir);
|
|
3452
3505
|
});
|
|
@@ -3519,7 +3572,7 @@ var reportFederationProgress = (event, verbose = false) => {
|
|
|
3519
3572
|
}
|
|
3520
3573
|
return;
|
|
3521
3574
|
case "hydrating":
|
|
3522
|
-
logger.info(`Hydrating federated content into ${
|
|
3575
|
+
logger.info(`Hydrating federated content into ${import_node_path22.default.relative(dir, event.outDir)}/...`, "federation");
|
|
3523
3576
|
return;
|
|
3524
3577
|
case "hydrate:cache":
|
|
3525
3578
|
if (event.files === 1 || event.files % 25 === 0) {
|
|
@@ -3542,13 +3595,13 @@ var reportFederationProgress = (event, verbose = false) => {
|
|
|
3542
3595
|
`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)`,
|
|
3543
3596
|
"federation"
|
|
3544
3597
|
);
|
|
3545
|
-
logger.info(`Recorded resolved source state in ${
|
|
3598
|
+
logger.info(`Recorded resolved source state in ${import_node_path22.default.relative(dir, event.result.lockPath)}`, "federation");
|
|
3546
3599
|
}
|
|
3547
3600
|
};
|
|
3548
3601
|
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.").option("-v, --verbose", "Show detailed federation diagnostics.").action(async (commandOptions) => {
|
|
3549
3602
|
logger.welcome();
|
|
3550
|
-
if (import_fs.default.existsSync(
|
|
3551
|
-
import_dotenv.default.config({ path:
|
|
3603
|
+
if (import_fs.default.existsSync(import_node_path22.default.join(dir, ".env"))) {
|
|
3604
|
+
import_dotenv.default.config({ path: import_node_path22.default.join(dir, ".env") });
|
|
3552
3605
|
}
|
|
3553
3606
|
logger.info("Starting federation...", "federation");
|
|
3554
3607
|
let cleanedPreviousOutput = false;
|