@eventcatalog/create-eventcatalog 2.0.13 → 2.0.15

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
@@ -1203,7 +1203,7 @@ var require_has_flag = __commonJS({
1203
1203
  var require_supports_color = __commonJS({
1204
1204
  "node_modules/supports-color/index.js"(exports2, module2) {
1205
1205
  "use strict";
1206
- var os2 = require("os");
1206
+ var os3 = require("os");
1207
1207
  var hasFlag = require_has_flag();
1208
1208
  var env = process.env;
1209
1209
  var forceColor;
@@ -1241,7 +1241,7 @@ var require_supports_color = __commonJS({
1241
1241
  }
1242
1242
  const min = forceColor ? 1 : 0;
1243
1243
  if (process.platform === "win32") {
1244
- const osRelease = os2.release().split(".");
1244
+ const osRelease = os3.release().split(".");
1245
1245
  if (Number(process.versions.node.split(".")[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
1246
1246
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
1247
1247
  }
@@ -7884,9 +7884,9 @@ var require_path = __commonJS({
7884
7884
  "use strict";
7885
7885
  Object.defineProperty(exports2, "__esModule", { value: true });
7886
7886
  exports2.convertPosixPathToPattern = exports2.convertWindowsPathToPattern = exports2.convertPathToPattern = exports2.escapePosixPath = exports2.escapeWindowsPath = exports2.escape = exports2.removeLeadingDotSegment = exports2.makeAbsolute = exports2.unixify = void 0;
7887
- var os2 = require("os");
7887
+ var os3 = require("os");
7888
7888
  var path8 = require("path");
7889
- var IS_WINDOWS_PLATFORM = os2.platform() === "win32";
7889
+ var IS_WINDOWS_PLATFORM = os3.platform() === "win32";
7890
7890
  var LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2;
7891
7891
  var POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g;
7892
7892
  var WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()[\]{}]|^!|[!+@](?=\())/g;
@@ -13106,8 +13106,8 @@ var require_settings4 = __commonJS({
13106
13106
  Object.defineProperty(exports2, "__esModule", { value: true });
13107
13107
  exports2.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
13108
13108
  var fs7 = require("fs");
13109
- var os2 = require("os");
13110
- var CPU_COUNT = Math.max(os2.cpus().length, 1);
13109
+ var os3 = require("os");
13110
+ var CPU_COUNT = Math.max(os3.cpus().length, 1);
13111
13111
  exports2.DEFAULT_FILE_SYSTEM_ADAPTER = {
13112
13112
  lstat: fs7.lstat,
13113
13113
  lstatSync: fs7.lstatSync,
@@ -22452,10 +22452,97 @@ function install(root, dependencies, { packageManager: packageManager2, isOnline
22452
22452
  }
22453
22453
 
22454
22454
  // templates/index.ts
22455
- var import_os2 = __toESM(require("os"));
22455
+ var import_os3 = __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
+ var import_os2 = __toESM(require("os"));
22464
+
22465
+ // package.json
22466
+ var package_default = {
22467
+ name: "@eventcatalog/create-eventcatalog",
22468
+ description: "Create EventCatalog with one command",
22469
+ version: "2.0.15",
22470
+ bin: {
22471
+ "create-catalog": "./dist/index.js"
22472
+ },
22473
+ files: [
22474
+ "dist",
22475
+ "templates"
22476
+ ],
22477
+ publishConfig: {
22478
+ access: "public"
22479
+ },
22480
+ scripts: {
22481
+ prepublishOnly: "npm run build",
22482
+ build: "tsup index.ts --format cjs --dts",
22483
+ run: "node dist/index.js",
22484
+ dev: "npm run build --watch",
22485
+ changeset: "changeset",
22486
+ release: "changeset publish"
22487
+ },
22488
+ devDependencies: {
22489
+ "@types/async-retry": "1.4.2",
22490
+ "@types/ci-info": "2.0.0",
22491
+ "@types/cross-spawn": "6.0.0",
22492
+ "@types/node": "^12.6.8",
22493
+ "@types/prompts": "2.0.1",
22494
+ "@types/rimraf": "3.0.0",
22495
+ "@types/tar": "4.0.3",
22496
+ "@types/uuid": "^10.0.0",
22497
+ "@types/validate-npm-package-name": "3.0.0",
22498
+ "@vercel/ncc": "0.34.0",
22499
+ "async-retry": "1.3.1",
22500
+ chalk: "2.4.2",
22501
+ "ci-info": "watson/ci-info#f43f6a1cefff47fb361c88cf4b943fdbcaafe540",
22502
+ commander: "2.20.0",
22503
+ cpy: "^11.0.0",
22504
+ "cross-spawn": "6.0.5",
22505
+ "fast-glob": "^3.3.2",
22506
+ got: "^14.0.0",
22507
+ prompts: "2.1.0",
22508
+ rimraf: "^5.0.7",
22509
+ tar: "^4.4.19",
22510
+ tsup: "^8.1.0",
22511
+ typescript: "^5.4.5",
22512
+ "update-check": "1.5.4",
22513
+ "validate-npm-package-name": "3.0.0"
22514
+ },
22515
+ dependencies: {
22516
+ "@changesets/cli": "^2.27.6",
22517
+ axios: "^1.7.7",
22518
+ uuid: "^10.0.0"
22519
+ }
22520
+ };
22521
+
22522
+ // templates/analytics.ts
22523
+ async function raiseEvent(eventData) {
22524
+ const url2 = "https://queue.simpleanalyticscdn.com/events";
22525
+ const userAgent = `@eventcatalog/create-eventcatalog/${package_default.version} (${import_os2.default.platform()}; ${import_os2.default.arch()}; Node/${process.version})`;
22526
+ const headers = {
22527
+ "Content-Type": "application/json"
22528
+ };
22529
+ const payload = {
22530
+ type: "event",
22531
+ hostname: "eventcatalog.dev",
22532
+ event: "@eventcatalog/create-eventcatalog",
22533
+ metadata: {
22534
+ ...eventData,
22535
+ ua: userAgent
22536
+ },
22537
+ ua: userAgent
22538
+ };
22539
+ try {
22540
+ await import_axios.default.post(url2, payload, { headers });
22541
+ } catch (error) {
22542
+ }
22543
+ }
22544
+
22545
+ // templates/index.ts
22459
22546
  var installTemplate = async ({
22460
22547
  appName,
22461
22548
  root,
@@ -22463,7 +22550,8 @@ var installTemplate = async ({
22463
22550
  isOnline,
22464
22551
  template,
22465
22552
  mode,
22466
- eslint
22553
+ eslint,
22554
+ organizationName: organizationName2
22467
22555
  }) => {
22468
22556
  console.log(import_chalk3.default.bold(`Using ${packageManager2}.`));
22469
22557
  const packageJson = {
@@ -22484,7 +22572,7 @@ var installTemplate = async ({
22484
22572
  };
22485
22573
  import_fs16.default.writeFileSync(
22486
22574
  import_path9.default.join(root, "package.json"),
22487
- JSON.stringify(packageJson, null, 2) + import_os2.default.EOL
22575
+ JSON.stringify(packageJson, null, 2) + import_os3.default.EOL
22488
22576
  );
22489
22577
  const installFlags = { packageManager: packageManager2, isOnline };
22490
22578
  const dependencies = [];
@@ -22533,6 +22621,13 @@ var installTemplate = async ({
22533
22621
  }
22534
22622
  }
22535
22623
  });
22624
+ const cId = (0, import_uuid.v4)();
22625
+ const eventCatalogConfigPath = import_path9.default.join(root, "eventcatalog.config.js");
22626
+ let eventCatalogConfig = import_fs16.default.readFileSync(eventCatalogConfigPath, "utf8");
22627
+ eventCatalogConfig = eventCatalogConfig.replace(/<organizationName>/g, organizationName2);
22628
+ eventCatalogConfig = eventCatalogConfig.replace(/<cId>/g, cId);
22629
+ import_fs16.default.writeFileSync(eventCatalogConfigPath, eventCatalogConfig);
22630
+ await raiseEvent({ command: "create", org: organizationName2, cId });
22536
22631
  if (!eslint) {
22537
22632
  await import_fs16.default.promises.unlink(import_path9.default.join(root, ".eslintrc.json"));
22538
22633
  }
@@ -22548,7 +22643,8 @@ async function createApp({
22548
22643
  examplePath,
22549
22644
  typescript,
22550
22645
  eslint,
22551
- experimentalApp
22646
+ experimentalApp,
22647
+ organizationName: organizationName2
22552
22648
  }) {
22553
22649
  let repoInfo;
22554
22650
  const mode = typescript ? "ts" : "js";
@@ -22582,7 +22678,8 @@ async function createApp({
22582
22678
  mode,
22583
22679
  packageManager: packageManager2,
22584
22680
  isOnline,
22585
- eslint
22681
+ eslint,
22682
+ organizationName: organizationName2
22586
22683
  });
22587
22684
  if (tryGitInit(root)) {
22588
22685
  console.log("Initialized a git repository.");
@@ -22651,62 +22748,9 @@ function validateNpmName(name) {
22651
22748
  };
22652
22749
  }
22653
22750
 
22654
- // package.json
22655
- var package_default = {
22656
- name: "@eventcatalog/create-eventcatalog",
22657
- description: "Create EventCatalog with one command",
22658
- version: "2.0.13",
22659
- bin: {
22660
- "create-catalog": "./dist/index.js"
22661
- },
22662
- files: [
22663
- "dist",
22664
- "templates"
22665
- ],
22666
- publishConfig: {
22667
- access: "public"
22668
- },
22669
- scripts: {
22670
- prepublishOnly: "npm run build",
22671
- build: "tsup index.ts --format cjs --dts",
22672
- run: "node dist/index.js",
22673
- dev: "npm run build --watch",
22674
- changeset: "changeset",
22675
- release: "changeset publish"
22676
- },
22677
- devDependencies: {
22678
- "@types/async-retry": "1.4.2",
22679
- "@types/ci-info": "2.0.0",
22680
- "@types/cross-spawn": "6.0.0",
22681
- "@types/node": "^12.6.8",
22682
- "@types/prompts": "2.0.1",
22683
- "@types/rimraf": "3.0.0",
22684
- "@types/tar": "4.0.3",
22685
- "@types/validate-npm-package-name": "3.0.0",
22686
- "@vercel/ncc": "0.34.0",
22687
- "async-retry": "1.3.1",
22688
- chalk: "2.4.2",
22689
- "ci-info": "watson/ci-info#f43f6a1cefff47fb361c88cf4b943fdbcaafe540",
22690
- commander: "2.20.0",
22691
- cpy: "^11.0.0",
22692
- "cross-spawn": "6.0.5",
22693
- "fast-glob": "^3.3.2",
22694
- got: "^14.0.0",
22695
- prompts: "2.1.0",
22696
- rimraf: "^5.0.7",
22697
- tar: "^4.4.19",
22698
- tsup: "^8.1.0",
22699
- typescript: "^5.4.5",
22700
- "update-check": "1.5.4",
22701
- "validate-npm-package-name": "3.0.0"
22702
- },
22703
- dependencies: {
22704
- "@changesets/cli": "^2.27.6"
22705
- }
22706
- };
22707
-
22708
22751
  // index.ts
22709
22752
  var projectPath = "";
22753
+ var organizationName = "";
22710
22754
  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
22755
  projectPath = name;
22712
22756
  }).option(
@@ -22802,6 +22846,17 @@ Run ${import_chalk5.default.cyan(`${program.name()} --help`)} to see all options
22802
22846
  );
22803
22847
  process.exit(1);
22804
22848
  }
22849
+ if (!organizationName) {
22850
+ const res = await (0, import_prompts.default)({
22851
+ type: "text",
22852
+ name: "organizationName",
22853
+ message: "What is your organization name?",
22854
+ initial: "EventCatalog Ltd"
22855
+ });
22856
+ if (typeof res.organizationName === "string") {
22857
+ organizationName = res.organizationName.trim();
22858
+ }
22859
+ }
22805
22860
  const resolvedProjectPath = import_path11.default.resolve(projectPath);
22806
22861
  const projectName = import_path11.default.basename(resolvedProjectPath);
22807
22862
  const { valid, problems } = validateNpmName(projectName);
@@ -22829,7 +22884,8 @@ Run ${import_chalk5.default.cyan(`${program.name()} --help`)} to see all options
22829
22884
  examplePath: program.examplePath,
22830
22885
  typescript: true,
22831
22886
  eslint: true,
22832
- experimentalApp: false
22887
+ experimentalApp: false,
22888
+ organizationName
22833
22889
  });
22834
22890
  } catch (reason) {
22835
22891
  if (!(reason instanceof DownloadError)) {
@@ -22850,6 +22906,7 @@ Do you want to use the default template instead?`,
22850
22906
  packageManager,
22851
22907
  typescript: program.typescript,
22852
22908
  eslint: program.eslint,
22909
+ organizationName,
22853
22910
  experimentalApp: program.experimentalApp
22854
22911
  });
22855
22912
  }
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.15",
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,37 @@
1
+ import axios from 'axios';
2
+ import os from 'os';
3
+ import pkg from '../package.json';
4
+
5
+ interface EventMetadata {
6
+ command: string;
7
+ org: string;
8
+ cId: string;
9
+ }
10
+
11
+ async function raiseEvent(eventData: EventMetadata): Promise<void> {
12
+ const url = "https://queue.simpleanalyticscdn.com/events";
13
+ const userAgent = `@eventcatalog/create-eventcatalog/${pkg.version} (${os.platform()}; ${os.arch()}; Node/${process.version})`;
14
+ const headers = {
15
+ "Content-Type": "application/json",
16
+ };
17
+
18
+ const payload = {
19
+ type: "event",
20
+ hostname: "eventcatalog.dev",
21
+ event: "@eventcatalog/create-eventcatalog",
22
+ metadata: {
23
+ ...eventData,
24
+ ua: userAgent
25
+ },
26
+ ua: userAgent
27
+ };
28
+
29
+ try {
30
+ await axios.post(url, payload, { headers });
31
+ } catch (error) {
32
+ // swallow the error
33
+ }
34
+ }
35
+
36
+ // Export the function so it can be used in other parts of the application
37
+ 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,17 @@ export const installTemplate = async ({
131
134
  },
132
135
  });
133
136
 
137
+ const cId = v4();
138
+
139
+ // update the properties in the eventcatalog.config.js
140
+ const eventCatalogConfigPath = path.join(root, "eventcatalog.config.js");
141
+ let eventCatalogConfig = fs.readFileSync(eventCatalogConfigPath, "utf8");
142
+ eventCatalogConfig = eventCatalogConfig.replace( /<organizationName>/g, organizationName );
143
+ eventCatalogConfig = eventCatalogConfig.replace( /<cId>/g, cId );
144
+ fs.writeFileSync(eventCatalogConfigPath, eventCatalogConfig);
145
+
146
+ await raiseEvent({ command: 'create', org: organizationName, cId });
147
+
134
148
  if (!eslint) {
135
149
  // remove un-necessary template file if eslint is not desired
136
150
  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;