@eventcatalog/core 2.14.3 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/bin/eventcatalog.js +2 -0
- package/default-files-for-collections/ubiquitousLanguages.md +7 -0
- package/dist/analytics/analytics.cjs +71 -0
- package/dist/analytics/analytics.d.cts +3 -0
- package/dist/analytics/analytics.d.ts +3 -0
- package/dist/analytics/analytics.js +7 -0
- package/dist/analytics/log-build.cjs +155 -0
- package/dist/analytics/log-build.d.cts +7 -0
- package/dist/analytics/log-build.d.ts +7 -0
- package/dist/analytics/log-build.js +9 -0
- package/dist/catalog-to-astro-content-directory.cjs +286 -0
- package/dist/catalog-to-astro-content-directory.d.cts +3 -0
- package/dist/catalog-to-astro-content-directory.d.ts +3 -0
- package/dist/catalog-to-astro-content-directory.js +8 -0
- package/dist/chunk-55YPRY5U.js +87 -0
- package/dist/chunk-5RNDOKYT.js +97 -0
- package/dist/chunk-6VJTKPOS.js +30 -0
- package/dist/chunk-BT6ILNB3.js +33 -0
- package/dist/chunk-DMGFALQN.js +9 -0
- package/dist/chunk-E7TXTI7G.js +78 -0
- package/{scripts/watcher.js → dist/chunk-NTCYOR4N.js} +29 -52
- package/dist/chunk-YEQVKHST.js +56 -0
- package/dist/constants.cjs +35 -0
- package/dist/constants.d.cts +3 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.js +6 -0
- package/dist/eventcatalog-config-file-utils.cjs +116 -0
- package/dist/eventcatalog-config-file-utils.d.cts +7 -0
- package/dist/eventcatalog-config-file-utils.d.ts +7 -0
- package/dist/eventcatalog-config-file-utils.js +14 -0
- package/{bin/dist → dist}/eventcatalog.cjs +35 -36
- package/{bin/dist → dist}/eventcatalog.config.cjs +1 -1
- package/dist/eventcatalog.config.js +0 -0
- package/dist/eventcatalog.d.cts +2 -0
- package/dist/eventcatalog.d.ts +2 -0
- package/dist/eventcatalog.js +116 -0
- package/dist/generate.cjs +121 -0
- package/dist/generate.d.cts +3 -0
- package/dist/generate.d.ts +3 -0
- package/dist/generate.js +7 -0
- package/dist/map-catalog-to-astro.cjs +131 -0
- package/dist/map-catalog-to-astro.d.cts +28 -0
- package/dist/map-catalog-to-astro.d.ts +28 -0
- package/dist/map-catalog-to-astro.js +6 -0
- package/dist/watcher.cjs +231 -0
- package/dist/watcher.d.cts +21 -0
- package/dist/watcher.d.ts +21 -0
- package/dist/watcher.js +8 -0
- package/{src → eventcatalog/src}/components/MDX/NodeGraph/Edges/AnimatedMessageEdge.tsx +1 -1
- package/{src → eventcatalog/src}/components/MDX/NodeGraph/NodeGraph.tsx +28 -38
- package/{src → eventcatalog/src}/components/MDX/SchemaViewer/SchemaViewer.astro +6 -1
- package/{src → eventcatalog/src}/components/SideBars/CatalogResourcesSideBar/index.tsx +19 -1
- package/{src → eventcatalog/src}/components/SideBars/DomainSideBar.astro +23 -0
- package/eventcatalog/src/components/Tables/columns/ServiceTableColumns.tsx +196 -0
- package/{src → eventcatalog/src}/content/config.ts +18 -0
- package/eventcatalog/src/hooks/eventcatalog-visualizer.ts +89 -0
- package/eventcatalog/src/pages/docs/[type]/[id]/language.astro +301 -0
- package/{src → eventcatalog/src}/utils/collections/domains.ts +17 -2
- package/{src → eventcatalog/src}/utils/collections/icons.ts +3 -0
- package/{src → eventcatalog/src}/utils/node-graphs/message-node-graph.ts +2 -27
- package/{src → eventcatalog/src}/utils/node-graphs/utils/utils.ts +60 -3
- package/package.json +12 -3
- package/.all-contributorsrc +0 -436
- package/.changeset/config.json +0 -11
- package/.github/CODEOWNERS +0 -3
- package/.github/ISSUE_TEMPLATE/bug.yml +0 -84
- package/.github/ISSUE_TEMPLATE/config.yml +0 -5
- package/.github/ISSUE_TEMPLATE/feature.yml +0 -48
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -14
- package/.github/funding.yml +0 -1
- package/.github/workflows/lint.yml +0 -22
- package/.github/workflows/release.yml +0 -34
- package/.github/workflows/test-bin.yml +0 -29
- package/.github/workflows/test-e2e.yml +0 -27
- package/.github/workflows/verify-build.yml +0 -28
- package/.prettierignore +0 -7
- package/.prettierrc +0 -18
- package/CHANGELOG.md +0 -1296
- package/bin/dist/eventcatalog.d.cts +0 -1
- package/bin/dist/eventcatalog.d.ts +0 -1
- package/bin/dist/eventcatalog.js +0 -531
- package/bin/eventcatalog.config.ts +0 -34
- package/images/example.png +0 -0
- package/images/sponsors/gravitee-logo-black.svg +0 -54
- package/images/sponsors/hookdeck.svg +0 -11
- package/images/sponsors/oso-logo-green.png +0 -0
- package/scripts/analytics/analytics.js +0 -31
- package/scripts/analytics/log-build.js +0 -26
- package/scripts/build-ci.js +0 -27
- package/scripts/catalog-to-astro-content-directory.js +0 -115
- package/scripts/ci/test.js +0 -24
- package/scripts/constants.ts +0 -3
- package/scripts/eventcatalog-config-file-utils.js +0 -89
- package/scripts/generate.js +0 -65
- package/scripts/map-catalog-to-astro.js +0 -174
- package/scripts/start-catalog-locally.js +0 -26
- package/src/components/Tables/columns/ServiceTableColumns.tsx +0 -164
- /package/{bin/dist → dist}/eventcatalog.config.d.cts +0 -0
- /package/{bin/dist → dist}/eventcatalog.config.d.ts +0 -0
- /package/{astro.config.mjs → eventcatalog/astro.config.mjs} +0 -0
- /package/{global.d.ts → eventcatalog/global.d.ts} +0 -0
- /package/{public → eventcatalog/public}/favicon.ico +0 -0
- /package/{public → eventcatalog/public}/icons/asyncapi.svg +0 -0
- /package/{public → eventcatalog/public}/icons/discord.svg +0 -0
- /package/{public → eventcatalog/public}/icons/github-purple.svg +0 -0
- /package/{public → eventcatalog/public}/icons/github.svg +0 -0
- /package/{public → eventcatalog/public}/icons/ms-teams.svg +0 -0
- /package/{public → eventcatalog/public}/icons/openapi.svg +0 -0
- /package/{public → eventcatalog/public}/icons/protocols/kafka.svg +0 -0
- /package/{public → eventcatalog/public}/icons/x-twitter.svg +0 -0
- /package/{public → eventcatalog/public}/icons/youtube.svg +0 -0
- /package/{public → eventcatalog/public}/logo.png +0 -0
- /package/{public → eventcatalog/public}/openapi.yml +0 -0
- /package/{public → eventcatalog/public}/opengraph.png +0 -0
- /package/{public → eventcatalog/public}/slack-icon.svg +0 -0
- /package/{src → eventcatalog/src}/components/DiscoverInsight.astro +0 -0
- /package/{src → eventcatalog/src}/components/DocsNavigation.astro +0 -0
- /package/{src → eventcatalog/src}/components/Header.astro +0 -0
- /package/{src → eventcatalog/src}/components/Lists/OwnersList.tsx +0 -0
- /package/{src → eventcatalog/src}/components/Lists/PillList.tsx +0 -0
- /package/{src → eventcatalog/src}/components/Lists/PillListFlat.styles.css +0 -0
- /package/{src → eventcatalog/src}/components/Lists/PillListFlat.tsx +0 -0
- /package/{src → eventcatalog/src}/components/Lists/ProtocolList.tsx +0 -0
- /package/{src → eventcatalog/src}/components/Lists/RepositoryList.astro +0 -0
- /package/{src → eventcatalog/src}/components/Lists/SpecificationsList.astro +0 -0
- /package/{src → eventcatalog/src}/components/Lists/VersionList.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/Accordion/Accordion.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/Accordion/Accordion.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/Accordion/AccordionGroup.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/Admonition.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/AsyncAPI/AsyncAPI.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/ChannelInformation/ChannelInformation.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/File.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/Flow/Flow.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/NodeGraph/DownloadButton.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/NodeGraph/NodeGraph.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/NodeGraph/NodeGraphPortal.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Channel.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Command.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Event.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/ExternalSystem.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Query.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Service.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Step.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/User.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/OpenAPI/OpenAPI.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/Schema.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/SchemaViewer/SchemaViewer.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/SchemaViewer/SchemaViewerPortal.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/Steps/Step.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/Steps/Steps.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/Tiles/Tile.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/Tiles/Tiles.astro +0 -0
- /package/{src → eventcatalog/src}/components/MDX/components.tsx +0 -0
- /package/{src → eventcatalog/src}/components/MDX/page-components.tsx +0 -0
- /package/{src → eventcatalog/src}/components/Search.astro +0 -0
- /package/{src → eventcatalog/src}/components/Seo.astro +0 -0
- /package/{src → eventcatalog/src}/components/SideBars/CatalogResourcesSideBar/styles.css +0 -0
- /package/{src → eventcatalog/src}/components/SideBars/ChannelSideBar.astro +0 -0
- /package/{src → eventcatalog/src}/components/SideBars/MessageSideBar.astro +0 -0
- /package/{src → eventcatalog/src}/components/SideBars/ServiceSideBar.astro +0 -0
- /package/{src → eventcatalog/src}/components/Tables/DebouncedInput.tsx +0 -0
- /package/{src → eventcatalog/src}/components/Tables/Table.tsx +0 -0
- /package/{src → eventcatalog/src}/components/Tables/columns/DomainTableColumns.tsx +0 -0
- /package/{src → eventcatalog/src}/components/Tables/columns/FlowTableColumns.tsx +0 -0
- /package/{src → eventcatalog/src}/components/Tables/columns/MessageTableColumns.tsx +0 -0
- /package/{src → eventcatalog/src}/components/Tables/columns/index.tsx +0 -0
- /package/{src → eventcatalog/src}/components/Tables/filters/custom-filters.ts +0 -0
- /package/{src → eventcatalog/src}/env.d.ts +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/WebSocket.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/amqp.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/eventbridge.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/googlepubsub.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/http.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/index.ts +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/jms.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/kafka.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/mercure.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/mqtt.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/nats.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/pulsar.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/redis.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/sns.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/solace.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/sqs.svg +0 -0
- /package/{src → eventcatalog/src}/icons/protocols/ws.svg +0 -0
- /package/{src → eventcatalog/src}/layouts/CustomDocsPageLayout.astro +0 -0
- /package/{src → eventcatalog/src}/layouts/DiscoverLayout.astro +0 -0
- /package/{src → eventcatalog/src}/layouts/Footer.astro +0 -0
- /package/{src → eventcatalog/src}/layouts/PlainPage.astro +0 -0
- /package/{src → eventcatalog/src}/layouts/VerticalSideBarLayout.astro +0 -0
- /package/{src → eventcatalog/src}/layouts/VisualiserLayout.astro +0 -0
- /package/{src → eventcatalog/src}/pages/discover/[type]/index.astro +0 -0
- /package/{src → eventcatalog/src}/pages/docs/[type]/[id]/[version]/asyncapi/index.astro +0 -0
- /package/{src → eventcatalog/src}/pages/docs/[type]/[id]/[version]/changelog/index.astro +0 -0
- /package/{src → eventcatalog/src}/pages/docs/[type]/[id]/[version]/index.astro +0 -0
- /package/{src → eventcatalog/src}/pages/docs/[type]/[id]/[version]/spec/_styles.css +0 -0
- /package/{src → eventcatalog/src}/pages/docs/[type]/[id]/[version]/spec/index.astro +0 -0
- /package/{src → eventcatalog/src}/pages/docs/[type]/[id]/index.astro +0 -0
- /package/{src → eventcatalog/src}/pages/docs/index.astro +0 -0
- /package/{src → eventcatalog/src}/pages/docs/teams/[id]/index.astro +0 -0
- /package/{src → eventcatalog/src}/pages/docs/users/[id]/index.astro +0 -0
- /package/{src → eventcatalog/src}/pages/index.astro +0 -0
- /package/{src → eventcatalog/src}/pages/visualiser/[type]/[id]/[version]/index.astro +0 -0
- /package/{src → eventcatalog/src}/pages/visualiser/[type]/[id]/index.astro +0 -0
- /package/{src → eventcatalog/src}/remark-plugins/mermaid.ts +0 -0
- /package/{src → eventcatalog/src}/types/index.ts +0 -0
- /package/{src → eventcatalog/src}/utils/channels.ts +0 -0
- /package/{src → eventcatalog/src}/utils/collections/changelogs.ts +0 -0
- /package/{src → eventcatalog/src}/utils/collections/file-diffs.ts +0 -0
- /package/{src → eventcatalog/src}/utils/collections/flows.ts +0 -0
- /package/{src → eventcatalog/src}/utils/collections/services.ts +0 -0
- /package/{src → eventcatalog/src}/utils/collections/util.ts +0 -0
- /package/{src → eventcatalog/src}/utils/collections/versions.ts +0 -0
- /package/{src → eventcatalog/src}/utils/colors.ts +0 -0
- /package/{src → eventcatalog/src}/utils/commands.ts +0 -0
- /package/{src → eventcatalog/src}/utils/eventcatalog-config/catalog.ts +0 -0
- /package/{src → eventcatalog/src}/utils/events.ts +0 -0
- /package/{src → eventcatalog/src}/utils/example-remark-plugin.mjs +0 -0
- /package/{src → eventcatalog/src}/utils/messages.ts +0 -0
- /package/{src → eventcatalog/src}/utils/node-graphs/domains-node-graph.ts +0 -0
- /package/{src → eventcatalog/src}/utils/node-graphs/flows-node-graph.ts +0 -0
- /package/{src → eventcatalog/src}/utils/node-graphs/services-node-graph.ts +0 -0
- /package/{src → eventcatalog/src}/utils/page-loaders/page-data-loader.ts +0 -0
- /package/{src → eventcatalog/src}/utils/pages.ts +0 -0
- /package/{src → eventcatalog/src}/utils/queries.ts +0 -0
- /package/{src → eventcatalog/src}/utils/teams.ts +0 -0
- /package/{src → eventcatalog/src}/utils/url-builder.ts +0 -0
- /package/{src → eventcatalog/src}/utils/users.ts +0 -0
- /package/{tailwind.config.mjs → eventcatalog/tailwind.config.mjs} +0 -0
- /package/{tsconfig.json → eventcatalog/tsconfig.json} +0 -0
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { getEventCatalogConfigFile, verifyRequiredFieldsAreInCatalogConfigFile } from '../eventcatalog-config-file-utils.js';
|
|
2
|
-
import { raiseEvent } from './analytics.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* @param {string} projectDir
|
|
7
|
-
*/
|
|
8
|
-
const main = async (projectDir) => {
|
|
9
|
-
if (process.env.NODE_ENV === 'CI') return;
|
|
10
|
-
try {
|
|
11
|
-
await verifyRequiredFieldsAreInCatalogConfigFile(projectDir);
|
|
12
|
-
const configFile = await getEventCatalogConfigFile(projectDir);
|
|
13
|
-
const { cId, organizationName, generators = [] } = configFile;
|
|
14
|
-
const generatorNames = generators.length > 0 ? generators.map((generator) => generator[0]) : ['none'];
|
|
15
|
-
await raiseEvent({
|
|
16
|
-
command: 'build',
|
|
17
|
-
org: organizationName,
|
|
18
|
-
cId,
|
|
19
|
-
generators: generatorNames.toString(),
|
|
20
|
-
});
|
|
21
|
-
} catch (error) {
|
|
22
|
-
// Just swallow the error
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export default main;
|
package/scripts/build-ci.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// This is used for CI on vercel. Must copy files before building.
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import { execSync } from 'node:child_process';
|
|
6
|
-
const __dirname = import.meta.dirname;
|
|
7
|
-
|
|
8
|
-
const args = process.argv.slice(2);
|
|
9
|
-
const catalog = args[0] || 'default';
|
|
10
|
-
|
|
11
|
-
const catalogDir = join(__dirname, '../');
|
|
12
|
-
const projectDIR = join(__dirname, `../examples/${catalog}`);
|
|
13
|
-
|
|
14
|
-
// Build cli
|
|
15
|
-
execSync('npm run build:bin', { stdio: 'inherit' });
|
|
16
|
-
|
|
17
|
-
// Build catalog
|
|
18
|
-
execSync(`cross-env NODE_ENV=CI PROJECT_DIR=${projectDIR} CATALOG_DIR=${catalogDir} npx . build`, {
|
|
19
|
-
cwd: catalogDir,
|
|
20
|
-
stdio: 'inherit',
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
// Type check
|
|
24
|
-
execSync('npx astro check --minimumSeverity error', {
|
|
25
|
-
cwd: catalogDir,
|
|
26
|
-
stdio: 'inherit',
|
|
27
|
-
});
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { glob } from 'glob';
|
|
2
|
-
import * as path from 'node:path';
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import { fileURLToPath } from 'url';
|
|
5
|
-
import os from 'node:os';
|
|
6
|
-
import { verifyRequiredFieldsAreInCatalogConfigFile, addPropertyToFrontMatter } from './eventcatalog-config-file-utils.js';
|
|
7
|
-
import { mapCatalogToAstro } from './map-catalog-to-astro.js';
|
|
8
|
-
|
|
9
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
-
const rootPkg = path.resolve(
|
|
11
|
-
path.dirname(__filename),
|
|
12
|
-
/**
|
|
13
|
-
* TODO: fix me =0
|
|
14
|
-
*
|
|
15
|
-
* The following is a workaround until organize the structure to have the correct path
|
|
16
|
-
* for any value of NODE_ENV
|
|
17
|
-
*
|
|
18
|
-
* @author carlosallexandre
|
|
19
|
-
*/
|
|
20
|
-
process.env.NODE_ENV === 'test' ? '../' : '../../'
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
const copyFiles = async (source, target) => {
|
|
24
|
-
const files = await glob(path.join(source, '**'), {
|
|
25
|
-
nodir: true,
|
|
26
|
-
windowsPathsNoEscape: os.platform() == 'win32',
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
for (const file of files) {
|
|
30
|
-
mapCatalogToAstro({
|
|
31
|
-
filePath: file,
|
|
32
|
-
astroDir: target,
|
|
33
|
-
projectDir: source,
|
|
34
|
-
})
|
|
35
|
-
.map((astroPath) => {
|
|
36
|
-
fs.cpSync(file, astroPath);
|
|
37
|
-
return { oldPath: file, newPath: astroPath };
|
|
38
|
-
})
|
|
39
|
-
.map(({ oldPath, newPath }) => {
|
|
40
|
-
if (!oldPath.endsWith('.md') && !oldPath.endsWith('.mdx')) return;
|
|
41
|
-
try {
|
|
42
|
-
// EventCatalog requires the original path to be in the frontmatter for Schemas and Changelogs
|
|
43
|
-
const content = fs.readFileSync(newPath, 'utf-8');
|
|
44
|
-
const frontmatter = addPropertyToFrontMatter(content, 'pathToFile', oldPath);
|
|
45
|
-
fs.writeFileSync(newPath, frontmatter);
|
|
46
|
-
} catch (error) {
|
|
47
|
-
// silent fail
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const ensureAstroCollectionNotEmpty = async (astroDir) => {
|
|
54
|
-
// TODO: maybe import collections from `src/content/config.ts`...
|
|
55
|
-
const COLLECTIONS = [
|
|
56
|
-
'events',
|
|
57
|
-
'commands',
|
|
58
|
-
'services',
|
|
59
|
-
'users',
|
|
60
|
-
'teams',
|
|
61
|
-
'domains',
|
|
62
|
-
'flows',
|
|
63
|
-
'pages',
|
|
64
|
-
'changelogs',
|
|
65
|
-
'queries',
|
|
66
|
-
'channels',
|
|
67
|
-
];
|
|
68
|
-
|
|
69
|
-
// Check empty collections
|
|
70
|
-
const emptyCollections = [];
|
|
71
|
-
for (const collection of COLLECTIONS) {
|
|
72
|
-
const markdownFiles = await glob(path.join(astroDir, 'src/content/', collection, '**'), {
|
|
73
|
-
nodir: true,
|
|
74
|
-
windowsPathsNoEscape: os.platform() == 'win32',
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
if (markdownFiles.length === 0) emptyCollections.push(collection);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Hydrate empty collections
|
|
81
|
-
const defaultCollectionFilesDir = path.join(rootPkg, 'default-files-for-collections');
|
|
82
|
-
for (const collection of emptyCollections) {
|
|
83
|
-
const defaultFile = path.join(defaultCollectionFilesDir, `${collection}.md`);
|
|
84
|
-
const targetDir = path.join(astroDir, 'src/content/', collection);
|
|
85
|
-
if (!fs.existsSync(targetDir)) {
|
|
86
|
-
fs.mkdirSync(targetDir, { recursive: true });
|
|
87
|
-
}
|
|
88
|
-
fs.cpSync(defaultFile, path.join(targetDir, `${collection}.md`));
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export const catalogToAstro = async (source, astroDir) => {
|
|
93
|
-
const astroContentDir = path.join(astroDir, 'src/content/');
|
|
94
|
-
|
|
95
|
-
// Config file
|
|
96
|
-
const astroConfigFile = fs.readFileSync(path.join(astroContentDir, 'config.ts'));
|
|
97
|
-
|
|
98
|
-
// Clear the astro directory before we copy files over
|
|
99
|
-
fs.rmSync(astroContentDir, { recursive: true });
|
|
100
|
-
|
|
101
|
-
// Create the folder again
|
|
102
|
-
fs.mkdirSync(astroContentDir);
|
|
103
|
-
|
|
104
|
-
// Write config file back
|
|
105
|
-
fs.writeFileSync(path.join(astroContentDir, 'config.ts'), astroConfigFile);
|
|
106
|
-
|
|
107
|
-
// Verify required fields are in the catalog config file
|
|
108
|
-
await verifyRequiredFieldsAreInCatalogConfigFile(source);
|
|
109
|
-
|
|
110
|
-
await copyFiles(source, astroDir);
|
|
111
|
-
|
|
112
|
-
// Check if the directory is empty. EC (astro collections) requires at least 1 item in the collection
|
|
113
|
-
// insert empty one that is filtered out
|
|
114
|
-
await ensureAstroCollectionNotEmpty(astroDir);
|
|
115
|
-
};
|
package/scripts/ci/test.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Script for GitHub Actions
|
|
5
|
-
* Sets up the project with required files
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { join } from 'node:path';
|
|
9
|
-
import fs from 'fs';
|
|
10
|
-
import { execSync } from 'node:child_process';
|
|
11
|
-
|
|
12
|
-
const args = process.argv.slice(2);
|
|
13
|
-
const catalog = args[0] || 'default';
|
|
14
|
-
|
|
15
|
-
const catalogDir = join(process.cwd());
|
|
16
|
-
const projectDIR = join(process.cwd(), `/examples/${catalog}`);
|
|
17
|
-
|
|
18
|
-
fs.copyFileSync(join(projectDIR, 'eventcatalog.config.js'), join(catalogDir, 'eventcatalog.config.js'));
|
|
19
|
-
fs.copyFileSync(join(projectDIR, 'eventcatalog.styles.css'), join(catalogDir, 'eventcatalog.styles.css'));
|
|
20
|
-
|
|
21
|
-
execSync(`cross-env NODE_ENV=test PROJECT_DIR=${projectDIR} CATALOG_DIR=${catalogDir} npm run test`, {
|
|
22
|
-
cwd: catalogDir,
|
|
23
|
-
stdio: 'inherit',
|
|
24
|
-
});
|
package/scripts/constants.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { readFile, writeFile, rm } from 'node:fs/promises';
|
|
2
|
-
import { existsSync } from 'node:fs';
|
|
3
|
-
import { copyFile } from 'node:fs/promises';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import { v4 as uuidV4 } from 'uuid';
|
|
6
|
-
import { pathToFileURL } from 'url';
|
|
7
|
-
import matter from 'gray-matter';
|
|
8
|
-
|
|
9
|
-
export async function cleanup(projectDirectory) {
|
|
10
|
-
const filePath = path.join(projectDirectory, 'eventcatalog.config.mjs');
|
|
11
|
-
if (existsSync(filePath)) {
|
|
12
|
-
await rm(filePath);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const getEventCatalogConfigFile = async (projectDirectory) => {
|
|
17
|
-
try {
|
|
18
|
-
let configFilePath = path.join(projectDirectory, 'eventcatalog.config.js');
|
|
19
|
-
|
|
20
|
-
const filePath = path.join(projectDirectory, 'package.json');
|
|
21
|
-
const packageJson = JSON.parse(await readFile(filePath, 'utf-8'));
|
|
22
|
-
|
|
23
|
-
if (packageJson?.type !== 'module') {
|
|
24
|
-
await copyFile(configFilePath, path.join(projectDirectory, 'eventcatalog.config.mjs'));
|
|
25
|
-
configFilePath = path.join(projectDirectory, 'eventcatalog.config.mjs');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const configFileURL = pathToFileURL(configFilePath).href;
|
|
29
|
-
const config = await import(/* @vite-ignore */ configFileURL);
|
|
30
|
-
|
|
31
|
-
return config.default;
|
|
32
|
-
} finally {
|
|
33
|
-
await cleanup(projectDirectory);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const writeEventCatalogConfigFile = async (projectDirectory, newConfig) => {
|
|
38
|
-
try {
|
|
39
|
-
const configFilePath = path.join(projectDirectory, 'eventcatalog.config.js');
|
|
40
|
-
let content = await readFile(configFilePath, 'utf8');
|
|
41
|
-
|
|
42
|
-
// Find the start of the config object
|
|
43
|
-
const startIndex = content.indexOf('export default {');
|
|
44
|
-
if (startIndex === -1) {
|
|
45
|
-
// Just fail silently if the config object is not found
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Update or add each new config item
|
|
50
|
-
Object.entries(newConfig).forEach(([key, value]) => {
|
|
51
|
-
const valueString = JSON.stringify(value, null, 2).replace(/"/g, "'").replace(/\n/g, '\n ');
|
|
52
|
-
|
|
53
|
-
// Check if the key already exists
|
|
54
|
-
const keyRegex = new RegExp(`(${key}\\s*:)([^,}]+)`, 'g');
|
|
55
|
-
if (content.match(keyRegex)) {
|
|
56
|
-
// Update existing key
|
|
57
|
-
content = content.replace(keyRegex, `$1 ${valueString}`);
|
|
58
|
-
} else {
|
|
59
|
-
// Add new key-value pair
|
|
60
|
-
const insertPosition = content.indexOf('{', startIndex) + 1;
|
|
61
|
-
content = content.slice(0, insertPosition) + `\n ${key}: ${valueString},` + content.slice(insertPosition);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// Write the updated content back to the file
|
|
66
|
-
await writeFile(configFilePath, content);
|
|
67
|
-
} finally {
|
|
68
|
-
await cleanup(projectDirectory);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
// Check the eventcatalog.config.js and add any missing required fields on it
|
|
73
|
-
export const verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
|
|
74
|
-
try {
|
|
75
|
-
const config = await getEventCatalogConfigFile(projectDirectory);
|
|
76
|
-
|
|
77
|
-
if (!config.cId) {
|
|
78
|
-
await writeEventCatalogConfigFile(projectDirectory, { cId: uuidV4() });
|
|
79
|
-
}
|
|
80
|
-
} catch (error) {
|
|
81
|
-
// fail silently, it's overly important
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export function addPropertyToFrontMatter(input, newProperty, newValue) {
|
|
86
|
-
const file = matter(input);
|
|
87
|
-
|
|
88
|
-
return matter.stringify(file.content, { ...file.data, [newProperty]: newValue });
|
|
89
|
-
}
|
package/scripts/generate.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { getEventCatalogConfigFile, cleanup } from './eventcatalog-config-file-utils.js';
|
|
3
|
-
|
|
4
|
-
function getDefaultExport(importedModule) {
|
|
5
|
-
if (importedModule === null || typeof importedModule !== 'object') {
|
|
6
|
-
throw new Error('Invalid module');
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
if (typeof importedModule.default === 'object' && importedModule.default !== null) {
|
|
10
|
-
return importedModule.default.default || importedModule.default;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (typeof importedModule.default !== 'undefined') {
|
|
14
|
-
return importedModule.default;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return importedModule;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const generate = async (PROJECT_DIRECTORY) => {
|
|
21
|
-
try {
|
|
22
|
-
const config = await getEventCatalogConfigFile(PROJECT_DIRECTORY);
|
|
23
|
-
|
|
24
|
-
const { generators = [] } = config;
|
|
25
|
-
|
|
26
|
-
if (!generators.length) {
|
|
27
|
-
console.log('No configured generators found, skipping generation');
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
for (const generator of generators) {
|
|
32
|
-
let plugin = generator[0];
|
|
33
|
-
const pluginConfig = generator[1];
|
|
34
|
-
|
|
35
|
-
if (plugin.startsWith('./')) {
|
|
36
|
-
plugin = path.join(PROJECT_DIRECTORY, plugin);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (plugin.includes('<rootDir>')) {
|
|
40
|
-
plugin = plugin.replace('<rootDir>', PROJECT_DIRECTORY);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
const importedGenerator = await import(plugin);
|
|
45
|
-
|
|
46
|
-
// TODO: Fix this...
|
|
47
|
-
const generator = getDefaultExport(importedGenerator);
|
|
48
|
-
|
|
49
|
-
await generator({ eventCatalogConfig: {} }, pluginConfig);
|
|
50
|
-
|
|
51
|
-
// Use importedGenerator here
|
|
52
|
-
} catch (error) {
|
|
53
|
-
console.error('Error loading plugin:', error);
|
|
54
|
-
await cleanup(PROJECT_DIRECTORY);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
await cleanup(PROJECT_DIRECTORY);
|
|
60
|
-
} catch (error) {
|
|
61
|
-
// Failed to generate clean up...
|
|
62
|
-
console.error(error);
|
|
63
|
-
await cleanup(PROJECT_DIRECTORY);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
|
|
3
|
-
const COLLECTION_KEYS = [
|
|
4
|
-
'events',
|
|
5
|
-
'commands',
|
|
6
|
-
'services',
|
|
7
|
-
'users',
|
|
8
|
-
'teams',
|
|
9
|
-
'domains',
|
|
10
|
-
'flows',
|
|
11
|
-
'pages',
|
|
12
|
-
'changelogs',
|
|
13
|
-
'queries',
|
|
14
|
-
'channels',
|
|
15
|
-
];
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @typedef {Object} MapCatalogToAstroParams
|
|
19
|
-
* @prop {string} filePath The catalog file path
|
|
20
|
-
* @prop {string} astroDir The astro directory
|
|
21
|
-
* @prop {string} projectDir The user's project directory
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
*
|
|
26
|
-
* @param {MapCatalogToAstroParams} params
|
|
27
|
-
* @returns {string[]} The astro file paths
|
|
28
|
-
*/
|
|
29
|
-
export function mapCatalogToAstro({ filePath, astroDir, projectDir }) {
|
|
30
|
-
const relativeFilePath = removeBasePath(filePath, projectDir);
|
|
31
|
-
|
|
32
|
-
if (!isCatalogRelated(relativeFilePath)) {
|
|
33
|
-
return [];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const baseTargetPaths = getBaseTargetPaths(relativeFilePath);
|
|
37
|
-
const relativeTargetPath = getRelativeTargetPath(relativeFilePath);
|
|
38
|
-
|
|
39
|
-
return baseTargetPaths.map((base) =>
|
|
40
|
-
path.join(astroDir, base, relativeTargetPath.replace('index.md', 'index.mdx').replace('changelog.md', 'changelog.mdx'))
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
*
|
|
46
|
-
* @param {string} fullPath
|
|
47
|
-
* @param {string} basePath
|
|
48
|
-
* @returns {string} The fullPath without the basePath
|
|
49
|
-
*/
|
|
50
|
-
function removeBasePath(fullPath, basePath) {
|
|
51
|
-
const relativePath = path.relative(basePath, fullPath);
|
|
52
|
-
return relativePath.startsWith('..') ? fullPath : relativePath;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Check if the key is an ASTRO COLLECTION KEY
|
|
57
|
-
* @param {string} key
|
|
58
|
-
* @returns {boolean}
|
|
59
|
-
*/
|
|
60
|
-
function isCollectionKey(key) {
|
|
61
|
-
return COLLECTION_KEYS.includes(key);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Checks whether the given path is a configuration file, styles file, public asset file or collection file.
|
|
66
|
-
* @param {string} filePath - The file path without the projectDir prefix.
|
|
67
|
-
* @returns {boolean}
|
|
68
|
-
*/
|
|
69
|
-
function isCatalogRelated(filePath) {
|
|
70
|
-
const filePathArr = filePath.split(path.sep).filter(Boolean);
|
|
71
|
-
|
|
72
|
-
if (
|
|
73
|
-
[
|
|
74
|
-
'eventcatalog.config.js', // config file at root
|
|
75
|
-
'eventcatalog.styles.css', // custom styles file at root
|
|
76
|
-
'components', // custom components
|
|
77
|
-
'public', // public assets
|
|
78
|
-
...COLLECTION_KEYS,
|
|
79
|
-
].includes(filePathArr[0])
|
|
80
|
-
) {
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Generates the base target path accordingly to the file path.
|
|
89
|
-
* @param {string} filePath The path to the file without PROJECT_DIR prefix.
|
|
90
|
-
* @returns {Array.<'src/content'|'public/generated'|'src/catalog-files'|'/'>} The base target path.
|
|
91
|
-
*/
|
|
92
|
-
function getBaseTargetPaths(filePath) {
|
|
93
|
-
const filePathArr = filePath.split(path.sep).filter(Boolean);
|
|
94
|
-
|
|
95
|
-
// Collection
|
|
96
|
-
if (isCollectionKey(filePathArr[0])) {
|
|
97
|
-
// Changelogs files
|
|
98
|
-
if (filePathArr[filePathArr.length - 1] == 'changelog.md') {
|
|
99
|
-
return [path.join('src', 'content', 'changelogs')];
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Markdown files
|
|
103
|
-
if (filePathArr[filePathArr.length - 1].match(/\.md$/)) {
|
|
104
|
-
return [path.join('src', 'content')];
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// This is a workaround to differentiate between a file and a directory.
|
|
108
|
-
// Of course this is not the best solution. But how differentiate? `fs.stats`
|
|
109
|
-
// could be used, but sometimes the filePath references a deleted file/directory
|
|
110
|
-
// which causes an error when using `fs.stats`.
|
|
111
|
-
const hasExtension = (str) => /\.[a-zA-Z0-9]{2,}$/.test(str);
|
|
112
|
-
|
|
113
|
-
// Assets files
|
|
114
|
-
if (hasExtension(filePath)) {
|
|
115
|
-
return [path.join('public', 'generated'), path.join('src', 'catalog-files')];
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* @parcel/watcher throttle and coalesce events for performance reasons.
|
|
120
|
-
*
|
|
121
|
-
* Consider the following:
|
|
122
|
-
* The user deletes a large `services/` dir from eventcatalog.
|
|
123
|
-
* The @parcel/watcher could emit only one delete event of the
|
|
124
|
-
* `services/` directory.
|
|
125
|
-
*
|
|
126
|
-
* In this situation we need delete all files from
|
|
127
|
-
* - `public/generated/services/`
|
|
128
|
-
* - `src/catalog-files/services/`
|
|
129
|
-
* - `src/content/services/`
|
|
130
|
-
*
|
|
131
|
-
* TODO: What happens if services contains commands/events inside of it??? How handle this?
|
|
132
|
-
*/
|
|
133
|
-
// Directories
|
|
134
|
-
return [path.join('public', 'generated'), path.join('src', 'catalog-files'), path.join('src', 'content')];
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Custom components
|
|
138
|
-
if (filePathArr[0] == 'components') {
|
|
139
|
-
return [path.join('src', 'custom-defined-components')];
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Public assets (public/*)
|
|
143
|
-
if (filePathArr[0] == 'public') {
|
|
144
|
-
return [path.join('public')];
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Config files:
|
|
149
|
-
* - eventcatalog.config.js
|
|
150
|
-
* - eventcatalog.styles.css
|
|
151
|
-
*/
|
|
152
|
-
return [path.join('/')];
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Generates the path until the ASTRO_COLLECTION_KEY or the PROJECT_DIR root.
|
|
157
|
-
* @param {string} filePath The path to the file.
|
|
158
|
-
* @returns {string} The path until the COLLECTION_KEY or PROJECT_DIR root.
|
|
159
|
-
*/
|
|
160
|
-
function getRelativeTargetPath(filePath) {
|
|
161
|
-
const filePathArr = filePath.split(path.sep).filter(Boolean);
|
|
162
|
-
|
|
163
|
-
if (filePathArr[0] == 'public' || filePathArr[0] == 'components') {
|
|
164
|
-
filePathArr.shift();
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const relativePath = [];
|
|
168
|
-
for (let i = filePathArr.length - 1; i >= 0; i--) {
|
|
169
|
-
relativePath.unshift(filePathArr[i]);
|
|
170
|
-
if (isCollectionKey(filePathArr[i])) break;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return path.join(...relativePath);
|
|
174
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { execSync } from 'node:child_process';
|
|
4
|
-
|
|
5
|
-
async function main() {
|
|
6
|
-
const __dirname = import.meta.dirname;
|
|
7
|
-
|
|
8
|
-
const args = process.argv.slice(2);
|
|
9
|
-
const catalog = args[0] || 'default';
|
|
10
|
-
|
|
11
|
-
const catalogDir = join(__dirname, '../');
|
|
12
|
-
const projectDIR = join(__dirname, `../examples/${catalog}`);
|
|
13
|
-
|
|
14
|
-
execSync('npm run build:bin', { stdio: 'inherit' });
|
|
15
|
-
|
|
16
|
-
execSync(`cross-env NODE_ENV=development PROJECT_DIR=${projectDIR} CATALOG_DIR=${catalogDir} npx . dev`, {
|
|
17
|
-
stdio: 'inherit',
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
main()
|
|
22
|
-
.then(() => process.exit(0))
|
|
23
|
-
.catch((err) => {
|
|
24
|
-
console.error(err);
|
|
25
|
-
process.exit(1);
|
|
26
|
-
});
|