@eventcatalog/core 2.0.26 → 2.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @eventcatalog/core
2
2
 
3
+ ## 2.0.28
4
+
5
+ ### Patch Changes
6
+
7
+ - 0bad036: feat(core): added beta version of generators
8
+
9
+ ## 2.0.27
10
+
11
+ ### Patch Changes
12
+
13
+ - c6da224: feat(core): added ability to configure landing page
14
+
3
15
  ## 2.0.26
4
16
 
5
17
  ### Patch Changes
package/astro.config.mjs CHANGED
@@ -43,6 +43,6 @@ export default defineConfig({
43
43
  pagefind(),
44
44
  ],
45
45
  redirects: {
46
- "/": "/docs"
46
+ "/": config.landingPage || '/docs',
47
47
  }
48
48
  });
@@ -3155,4 +3155,14 @@ program2.command("start").description("Serves the contents of your eventcatalog
3155
3155
  console.log("Starting preview of your build...");
3156
3156
  previewCatalog();
3157
3157
  });
3158
+ program2.command("generate [siteDir]").description("Start the generator scripts.").action(() => {
3159
+ copyCore();
3160
+ copyFolder((0, import_node_path.join)(dir, "public"), (0, import_node_path.join)(core, "public"));
3161
+ copyFile((0, import_node_path.join)(dir, "eventcatalog.config.js"), (0, import_node_path.join)(core, "eventcatalog.config.js"));
3162
+ copyFile((0, import_node_path.join)(dir, "eventcatalog.styles.css"), (0, import_node_path.join)(core, "eventcatalog.styles.css"));
3163
+ (0, import_node_child_process.execSync)(`PROJECT_DIR='${dir}' npm run generate`, {
3164
+ cwd: core,
3165
+ stdio: "inherit"
3166
+ });
3167
+ });
3158
3168
  program2.parse();
@@ -7,6 +7,7 @@ interface Config {
7
7
  organizationName: string;
8
8
  homepageLink: string;
9
9
  editUrl: string;
10
+ landingPage?: string;
10
11
  base?: string;
11
12
  port?: string;
12
13
  trailingSlash?: boolean;
@@ -7,6 +7,7 @@ interface Config {
7
7
  organizationName: string;
8
8
  homepageLink: string;
9
9
  editUrl: string;
10
+ landingPage?: string;
10
11
  base?: string;
11
12
  port?: string;
12
13
  trailingSlash?: boolean;
@@ -3122,4 +3122,14 @@ program2.command("start").description("Serves the contents of your eventcatalog
3122
3122
  console.log("Starting preview of your build...");
3123
3123
  previewCatalog();
3124
3124
  });
3125
+ program2.command("generate [siteDir]").description("Start the generator scripts.").action(() => {
3126
+ copyCore();
3127
+ copyFolder(join(dir, "public"), join(core, "public"));
3128
+ copyFile(join(dir, "eventcatalog.config.js"), join(core, "eventcatalog.config.js"));
3129
+ copyFile(join(dir, "eventcatalog.styles.css"), join(core, "eventcatalog.styles.css"));
3130
+ execSync(`PROJECT_DIR='${dir}' npm run generate`, {
3131
+ cwd: core,
3132
+ stdio: "inherit"
3133
+ });
3134
+ });
3125
3135
  program2.parse();
@@ -8,6 +8,7 @@ export interface Config {
8
8
  organizationName: string;
9
9
  homepageLink: string;
10
10
  editUrl: string;
11
+ landingPage?: string;
11
12
  base?: string;
12
13
  port?: string;
13
14
  trailingSlash?: boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@eventcatalog/core",
3
3
  "type": "module",
4
- "version": "2.0.26",
4
+ "version": "2.0.28",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -23,6 +23,7 @@
23
23
  "start:catalog": "node scripts/start-catalog-locally.js",
24
24
  "verify-build:catalog": "rimraf dist && npm run build:cd",
25
25
  "changeset": "changeset",
26
+ "generate": "node scripts/generate.js",
26
27
  "release": "changeset publish",
27
28
  "format": "prettier --config .prettierrc --write \"**/*.{js,jsx,ts,tsx,json}\"",
28
29
  "format:diff": "prettier --config .prettierrc --list-different \"**/*.{js,jsx,ts,tsx,json}\""
@@ -0,0 +1,53 @@
1
+ import { readFile, writeFile } from 'node:fs/promises';
2
+ import { createRequire } from 'module';
3
+ import path from 'node:path';
4
+
5
+ const generate = async () => {
6
+ // Fix for the file
7
+ const rawFile = await readFile(path.join(process.env.PROJECT_DIR, 'eventcatalog.config.js'), 'utf8');
8
+
9
+ const require = createRequire(process.env.PROJECT_DIR);
10
+
11
+ // Convert export default to module.exports (Needed for dynamic require)
12
+ if (rawFile.includes('export default')) {
13
+ const fixedFile = rawFile.replace('export default', 'module.exports =');
14
+ await writeFile(path.join(process.env.PROJECT_DIR, 'eventcatalog.config.js'), fixedFile);
15
+ }
16
+
17
+ const config = require(path.join(process.env.PROJECT_DIR, 'eventcatalog.config.js'));
18
+
19
+ const { generators = [] } = config;
20
+
21
+ if (!generators.length) {
22
+ console.log('No configured generators found, skipping generation');
23
+ return;
24
+ }
25
+
26
+ console.log('Running generators...');
27
+
28
+ // Tidy up
29
+ await writeFile(path.join(process.env.PROJECT_DIR, 'eventcatalog.config.js'), rawFile);
30
+
31
+ const plugins = generators.map((generator) => {
32
+ let plugin = generator[0];
33
+ const pluginConfig = generator[1];
34
+
35
+ if (plugin.startsWith('./')) {
36
+ plugin = path.join(process.env.PROJECT_DIR, plugin);
37
+ }
38
+
39
+ if (plugin.includes('<rootDir>')) {
40
+ plugin = plugin.replace('<rootDir>', process.env.PROJECT_DIR);
41
+ }
42
+
43
+ const importedGenerator = require(plugin);
44
+
45
+ console.log(`Generating EventCatalog docs using: ${plugin}`);
46
+
47
+ return importedGenerator({ eventCatalogConfig: config }, pluginConfig);
48
+ });
49
+
50
+ await Promise.all(plugins);
51
+ };
52
+
53
+ generate();
@@ -1,6 +1,5 @@
1
1
  ---
2
2
  import catalog from '@eventcatalog';
3
- // import Search from 'astro-pagefind/components/Search';
4
3
  import Search from '@components/Search.astro';
5
4
  import { buildUrl } from '@utils/url-builder';
6
5
 
@@ -31,7 +30,7 @@ const logo = {
31
30
  <nav class="md:fixed top-0 w-full z-20 bg-white border-b border-gray-200 py-4 font-bold text-xl max-w-[70em]">
32
31
  <div class="flex justify-between items-center">
33
32
  <div class="w-1/3 flex space-x-2 items-center">
34
- <a href={buildUrl('/docs')} class="flex space-x-2 items-center">
33
+ <a href={buildUrl(catalog.landingPage || '/docs')} class="flex space-x-2 items-center">
35
34
  {logo.src && <img alt={logo.alt} src={buildUrl(logo.src, true)} class="w-8" />}
36
35
  {logo.text && <span class="hidden sm:inline-block text-[1em]">{logo.text}</span>}
37
36
  </a>