@eventcatalog/create-eventcatalog 2.0.13 → 2.0.14

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/index.js CHANGED
@@ -22456,6 +22456,31 @@ var import_os2 = __toESM(require("os"));
22456
22456
  var import_fs16 = __toESM(require("fs"));
22457
22457
  var import_path9 = __toESM(require("path"));
22458
22458
  var import_chalk3 = __toESM(require_chalk());
22459
+ var import_uuid = require("uuid");
22460
+
22461
+ // templates/analytics.ts
22462
+ var import_axios = __toESM(require("axios"));
22463
+ async function raiseEvent(eventData) {
22464
+ const url2 = "https://queue.simpleanalyticscdn.com/events";
22465
+ const headers = {
22466
+ "Content-Type": "application/json"
22467
+ };
22468
+ const payload = {
22469
+ type: "event",
22470
+ hostname: "eventcatalog.dev",
22471
+ event: "@eventcatalog/create-eventcatalog",
22472
+ metadata: eventData,
22473
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
22474
+ };
22475
+ try {
22476
+ await import_axios.default.post(url2, payload, { headers });
22477
+ console.log("Event successfully sent");
22478
+ } catch (error) {
22479
+ console.log("Error sending event:", error);
22480
+ }
22481
+ }
22482
+
22483
+ // templates/index.ts
22459
22484
  var installTemplate = async ({
22460
22485
  appName,
22461
22486
  root,
@@ -22463,7 +22488,8 @@ var installTemplate = async ({
22463
22488
  isOnline,
22464
22489
  template,
22465
22490
  mode,
22466
- eslint
22491
+ eslint,
22492
+ organizationName: organizationName2
22467
22493
  }) => {
22468
22494
  console.log(import_chalk3.default.bold(`Using ${packageManager2}.`));
22469
22495
  const packageJson = {
@@ -22533,6 +22559,12 @@ var installTemplate = async ({
22533
22559
  }
22534
22560
  }
22535
22561
  });
22562
+ const eventCatalogConfigPath = import_path9.default.join(root, "eventcatalog.config.js");
22563
+ let eventCatalogConfig = import_fs16.default.readFileSync(eventCatalogConfigPath, "utf8");
22564
+ eventCatalogConfig = eventCatalogConfig.replace(/<organizationName>/g, organizationName2);
22565
+ eventCatalogConfig = eventCatalogConfig.replace(/<cId>/g, (0, import_uuid.v4)());
22566
+ import_fs16.default.writeFileSync(eventCatalogConfigPath, eventCatalogConfig);
22567
+ await raiseEvent({ command: "create", org: organizationName2, id: (0, import_uuid.v4)() });
22536
22568
  if (!eslint) {
22537
22569
  await import_fs16.default.promises.unlink(import_path9.default.join(root, ".eslintrc.json"));
22538
22570
  }
@@ -22548,7 +22580,8 @@ async function createApp({
22548
22580
  examplePath,
22549
22581
  typescript,
22550
22582
  eslint,
22551
- experimentalApp
22583
+ experimentalApp,
22584
+ organizationName: organizationName2
22552
22585
  }) {
22553
22586
  let repoInfo;
22554
22587
  const mode = typescript ? "ts" : "js";
@@ -22582,7 +22615,8 @@ async function createApp({
22582
22615
  mode,
22583
22616
  packageManager: packageManager2,
22584
22617
  isOnline,
22585
- eslint
22618
+ eslint,
22619
+ organizationName: organizationName2
22586
22620
  });
22587
22621
  if (tryGitInit(root)) {
22588
22622
  console.log("Initialized a git repository.");
@@ -22655,7 +22689,7 @@ function validateNpmName(name) {
22655
22689
  var package_default = {
22656
22690
  name: "@eventcatalog/create-eventcatalog",
22657
22691
  description: "Create EventCatalog with one command",
22658
- version: "2.0.13",
22692
+ version: "2.0.14",
22659
22693
  bin: {
22660
22694
  "create-catalog": "./dist/index.js"
22661
22695
  },
@@ -22682,6 +22716,7 @@ var package_default = {
22682
22716
  "@types/prompts": "2.0.1",
22683
22717
  "@types/rimraf": "3.0.0",
22684
22718
  "@types/tar": "4.0.3",
22719
+ "@types/uuid": "^10.0.0",
22685
22720
  "@types/validate-npm-package-name": "3.0.0",
22686
22721
  "@vercel/ncc": "0.34.0",
22687
22722
  "async-retry": "1.3.1",
@@ -22701,12 +22736,15 @@ var package_default = {
22701
22736
  "validate-npm-package-name": "3.0.0"
22702
22737
  },
22703
22738
  dependencies: {
22704
- "@changesets/cli": "^2.27.6"
22739
+ "@changesets/cli": "^2.27.6",
22740
+ axios: "^1.7.7",
22741
+ uuid: "^10.0.0"
22705
22742
  }
22706
22743
  };
22707
22744
 
22708
22745
  // index.ts
22709
22746
  var projectPath = "";
22747
+ var organizationName = "";
22710
22748
  var program = new import_commander.default.Command(package_default.name).version(package_default.version).arguments("<project-directory>").usage(`${import_chalk5.default.green("<project-directory>")} [options]`).action((name) => {
22711
22749
  projectPath = name;
22712
22750
  }).option(
@@ -22802,6 +22840,17 @@ Run ${import_chalk5.default.cyan(`${program.name()} --help`)} to see all options
22802
22840
  );
22803
22841
  process.exit(1);
22804
22842
  }
22843
+ if (!organizationName) {
22844
+ const res = await (0, import_prompts.default)({
22845
+ type: "text",
22846
+ name: "organizationName",
22847
+ message: "What is your organization name?",
22848
+ initial: "EventCatalog Ltd"
22849
+ });
22850
+ if (typeof res.organizationName === "string") {
22851
+ organizationName = res.organizationName.trim();
22852
+ }
22853
+ }
22805
22854
  const resolvedProjectPath = import_path11.default.resolve(projectPath);
22806
22855
  const projectName = import_path11.default.basename(resolvedProjectPath);
22807
22856
  const { valid, problems } = validateNpmName(projectName);
@@ -22829,7 +22878,8 @@ Run ${import_chalk5.default.cyan(`${program.name()} --help`)} to see all options
22829
22878
  examplePath: program.examplePath,
22830
22879
  typescript: true,
22831
22880
  eslint: true,
22832
- experimentalApp: false
22881
+ experimentalApp: false,
22882
+ organizationName
22833
22883
  });
22834
22884
  } catch (reason) {
22835
22885
  if (!(reason instanceof DownloadError)) {
@@ -22850,6 +22900,7 @@ Do you want to use the default template instead?`,
22850
22900
  packageManager,
22851
22901
  typescript: program.typescript,
22852
22902
  eslint: program.eslint,
22903
+ organizationName,
22853
22904
  experimentalApp: program.experimentalApp
22854
22905
  });
22855
22906
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@eventcatalog/create-eventcatalog",
3
3
  "description": "Create EventCatalog with one command",
4
- "version": "2.0.13",
4
+ "version": "2.0.14",
5
5
  "bin": {
6
6
  "create-catalog": "./dist/index.js"
7
7
  },
@@ -28,6 +28,7 @@
28
28
  "@types/prompts": "2.0.1",
29
29
  "@types/rimraf": "3.0.0",
30
30
  "@types/tar": "4.0.3",
31
+ "@types/uuid": "^10.0.0",
31
32
  "@types/validate-npm-package-name": "3.0.0",
32
33
  "@vercel/ncc": "0.34.0",
33
34
  "async-retry": "1.3.1",
@@ -47,6 +48,8 @@
47
48
  "validate-npm-package-name": "3.0.0"
48
49
  },
49
50
  "dependencies": {
50
- "@changesets/cli": "^2.27.6"
51
+ "@changesets/cli": "^2.27.6",
52
+ "axios": "^1.7.7",
53
+ "uuid": "^10.0.0"
51
54
  }
52
55
  }
@@ -0,0 +1,32 @@
1
+ import axios from 'axios';
2
+
3
+ interface EventMetadata {
4
+ command: string;
5
+ org: string;
6
+ id: string;
7
+ }
8
+
9
+ async function raiseEvent(eventData: EventMetadata): Promise<void> {
10
+ const url = "https://queue.simpleanalyticscdn.com/events";
11
+ const headers = {
12
+ "Content-Type": "application/json",
13
+ };
14
+
15
+ const payload = {
16
+ type: "event",
17
+ hostname: "eventcatalog.dev",
18
+ event: "@eventcatalog/create-eventcatalog",
19
+ metadata: eventData,
20
+ timestamp: new Date().toISOString(),
21
+ };
22
+
23
+ try {
24
+ await axios.post(url, payload, { headers });
25
+ console.log("Event successfully sent");
26
+ } catch (error) {
27
+ console.log("Error sending event:", error);
28
+ }
29
+ }
30
+
31
+ // Export the function so it can be used in other parts of the application
32
+ export { raiseEvent };
@@ -2,7 +2,7 @@
2
2
  export default {
3
3
  title: 'EventCatalog',
4
4
  tagline: 'Discover, Explore and Document your Event Driven Architectures',
5
- organizationName: 'Your Company',
5
+ organizationName: '<organizationName>',
6
6
  homepageLink: 'https://eventcatalog.dev/',
7
7
  editUrl: 'https://github.com/boyney123/eventcatalog-demo/edit/master',
8
8
  // By default set to false, add true to get urls ending in /
@@ -21,5 +21,7 @@ export default {
21
21
  // Should the sub heading be rendered in the docs sidebar?
22
22
  showPageHeadings: true
23
23
  }
24
- }
24
+ },
25
+ // required random generated id used by eventcatalog
26
+ cId: '<cId>'
25
27
  }
@@ -5,8 +5,10 @@ import os from "os";
5
5
  import fs from "fs";
6
6
  import path from "path";
7
7
  import chalk from "chalk";
8
+ import { v4 } from 'uuid'
8
9
 
9
10
  import { GetTemplateFileArgs, InstallTemplateArgs } from "./types";
11
+ import { raiseEvent } from "./analytics";
10
12
 
11
13
  /**
12
14
  * Get the file path for a given file in a template, e.g. "next.config.js".
@@ -30,6 +32,7 @@ export const installTemplate = async ({
30
32
  template,
31
33
  mode,
32
34
  eslint,
35
+ organizationName
33
36
  }: InstallTemplateArgs) => {
34
37
  console.log(chalk.bold(`Using ${packageManager}.`));
35
38
 
@@ -131,6 +134,15 @@ export const installTemplate = async ({
131
134
  },
132
135
  });
133
136
 
137
+ // update the properties in the eventcatalog.config.js
138
+ const eventCatalogConfigPath = path.join(root, "eventcatalog.config.js");
139
+ let eventCatalogConfig = fs.readFileSync(eventCatalogConfigPath, "utf8");
140
+ eventCatalogConfig = eventCatalogConfig.replace( /<organizationName>/g, organizationName );
141
+ eventCatalogConfig = eventCatalogConfig.replace( /<cId>/g, v4() );
142
+ fs.writeFileSync(eventCatalogConfigPath, eventCatalogConfig);
143
+
144
+ await raiseEvent({ command: 'create', org: organizationName, id: v4() });
145
+
134
146
  if (!eslint) {
135
147
  // remove un-necessary template file if eslint is not desired
136
148
  await fs.promises.unlink(path.join(root, ".eslintrc.json"));
@@ -14,7 +14,7 @@ export interface InstallTemplateArgs {
14
14
  root: string;
15
15
  packageManager: PackageManager;
16
16
  isOnline: boolean;
17
-
17
+ organizationName: string;
18
18
  template: TemplateType;
19
19
  mode: TemplateMode;
20
20
  eslint: boolean;