From 8e95677be2aaa0497930b62c8419fa56b36e7a31 Mon Sep 17 00:00:00 2001 From: Carlos Rodrigues Date: Tue, 3 Dec 2024 10:23:54 -0300 Subject: [PATCH] refactor/move-scripts-to-src (#985) * chore: move scripts to src directory It moves the modules needed by the cli from scripts to src. It lets only scripts needed by ci and dev under scripts dir. * refactor: move `bin/eventcatalog.ts`to `src/` It moves the `bin` to `scr/` dir to centralize all source files. * chore: update tsup config * refactor: update paths and references for new structure * chore: remove `copyCore` from preview cli command The preview cli command needs the `dist/` dir from the build command, so the `copyCore` is useless. * Create neat-crabs-join.md --------- Co-authored-by: David Boyne --- .changeset/neat-crabs-join.md | 5 +++ bin/eventcatalog.js | 2 ++ package.json | 5 +-- ...catalog-to-astro-content-directory.spec.ts | 0 .../eventcatalog-config-file-utils.spec.ts | 2 +- .../commands/AddInventory/index.md | 0 .../commands/AddInventory/schema.json | 0 .../AddInventory/versioned/0.0.1/index.md | 0 .../AddInventory/versioned/0.0.1/schema.json | 0 .../domains/Payment/asyncapi.yml | 0 .../events/PaymentDomainTestEvent1/index.md | 0 .../PaymentDomainTestEvent1/schema.json | 0 .../versioned/0.0.1/index.md | 0 .../flows/ProcessingOfAnOrder/index.md | 0 .../versioned/0.0.1/index.md | 0 .../example-catalog/domains/Payment/index.md | 0 .../ExternalPaymentService/asyncapi.yml | 0 .../services/ExternalPaymentService/index.md | 0 .../versioned/0.0.1/index.md | 0 .../domains/Payment/versioned/0.0.1/index.md | 0 .../eventcatalog.config.defaults.js | 0 .../example-catalog/eventcatalog.config.js | 0 .../Inventory/InventoryAdjusted/changelog.md | 0 .../Inventory/InventoryAdjusted/index.md | 0 .../Inventory/InventoryAdjusted/schema.avro | 0 .../Inventory/InventoryAdjusted/schema.json | 0 .../versioned/0.0.1/changelog.md | 0 .../versioned/0.0.1/index.md | 0 .../versioned/0.0.1/schema.avro | 0 .../versioned/1.0.0/changelog.md | 0 .../versioned/1.0.0/index.md | 0 .../versioned/1.0.0/schema.avro | 0 .../events/Inventory/OutOfStock/index.md | 0 .../OutOfStock/versioned/0.0.1/index.md | 0 .../events/Order/OrderAmended/index.md | 0 .../events/Order/OrderAmended/schema.avro | 0 .../events/Order/OrderAmended/schema.json | 0 .../events/Order/OrderCancelled/index.md | 0 .../events/Order/OrderCancelled/schema.json | 0 .../events/Order/OrderConfirmed/index.md | 0 .../events/Order/OrderConfirmed/schema.json | 0 .../flows/Payment/PaymentProcessed/index.md | 0 .../PaymentProcessed/versioned/0.0.1/index.md | 0 .../Subscriptions/CancelSubscription/index.md | 0 .../__tests__/example-catalog/package.json | 0 .../services/PaymentService/asyncapi.yml | 0 .../events/PaymentAccepted/index.md | 0 .../events/PaymentAccepted/schema.json | 0 .../PaymentAccepted/versioned/0.0.1/index.md | 0 .../flows/PaymentAccepted/index.md | 0 .../PaymentAccepted/versioned/0.0.1/index.md | 0 .../services/PaymentService/index.md | 0 .../PaymentService/versioned/0.0.1/index.md | 0 .../example-catalog/teams/full-stack.md | 0 .../__tests__/example-catalog/users/dboyne.md | 0 {scripts => src}/analytics/analytics.js | 0 {scripts => src}/analytics/log-build.js | 0 .../catalog-to-astro-content-directory.js | 13 +------ {scripts => src}/constants.ts | 0 .../eventcatalog-config-file-utils.js | 0 {bin => src}/eventcatalog.config.ts | 0 {bin => src}/eventcatalog.ts | 34 +++++++++---------- {scripts => src}/generate.js | 0 {scripts => src}/map-catalog-to-astro.js | 0 {scripts => src}/watcher.js | 0 tsconfig.json | 1 + tsup.config.js | 4 +-- 67 files changed, 32 insertions(+), 34 deletions(-) create mode 100644 .changeset/neat-crabs-join.md create mode 100755 bin/eventcatalog.js rename {scripts => src}/__tests__/catalog-to-astro-content-directory.spec.ts (100%) rename {scripts => src}/__tests__/eventcatalog-config-file-utils.spec.ts (99%) rename {scripts => src}/__tests__/example-catalog/commands/AddInventory/index.md (100%) rename {scripts => src}/__tests__/example-catalog/commands/AddInventory/schema.json (100%) rename {scripts => src}/__tests__/example-catalog/commands/AddInventory/versioned/0.0.1/index.md (100%) rename {scripts => src}/__tests__/example-catalog/commands/AddInventory/versioned/0.0.1/schema.json (100%) rename {scripts => src}/__tests__/example-catalog/domains/Payment/asyncapi.yml (100%) rename {scripts => src}/__tests__/example-catalog/domains/Payment/events/PaymentDomainTestEvent1/index.md (100%) rename {scripts => src}/__tests__/example-catalog/domains/Payment/events/PaymentDomainTestEvent1/schema.json (100%) rename {scripts => src}/__tests__/example-catalog/domains/Payment/events/PaymentDomainTestEvent1/versioned/0.0.1/index.md (100%) rename {scripts => src}/__tests__/example-catalog/domains/Payment/flows/ProcessingOfAnOrder/index.md (100%) rename {scripts => src}/__tests__/example-catalog/domains/Payment/flows/ProcessingOfAnOrder/versioned/0.0.1/index.md (100%) rename {scripts => src}/__tests__/example-catalog/domains/Payment/index.md (100%) rename {scripts => src}/__tests__/example-catalog/domains/Payment/services/ExternalPaymentService/asyncapi.yml (100%) rename {scripts => src}/__tests__/example-catalog/domains/Payment/services/ExternalPaymentService/index.md (100%) rename {scripts => src}/__tests__/example-catalog/domains/Payment/services/ExternalPaymentService/versioned/0.0.1/index.md (100%) rename {scripts => src}/__tests__/example-catalog/domains/Payment/versioned/0.0.1/index.md (100%) rename {scripts => src}/__tests__/example-catalog/eventcatalog.config.defaults.js (100%) rename {scripts => src}/__tests__/example-catalog/eventcatalog.config.js (100%) rename {scripts => src}/__tests__/example-catalog/events/Inventory/InventoryAdjusted/changelog.md (100%) rename {scripts => src}/__tests__/example-catalog/events/Inventory/InventoryAdjusted/index.md (100%) rename {scripts => src}/__tests__/example-catalog/events/Inventory/InventoryAdjusted/schema.avro (100%) rename {scripts => src}/__tests__/example-catalog/events/Inventory/InventoryAdjusted/schema.json (100%) rename {scripts => src}/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/0.0.1/changelog.md (100%) rename {scripts => src}/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/0.0.1/index.md (100%) rename {scripts => src}/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/0.0.1/schema.avro (100%) rename {scripts => src}/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/1.0.0/changelog.md (100%) rename {scripts => src}/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/1.0.0/index.md (100%) rename {scripts => src}/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/1.0.0/schema.avro (100%) rename {scripts => src}/__tests__/example-catalog/events/Inventory/OutOfStock/index.md (100%) rename {scripts => src}/__tests__/example-catalog/events/Inventory/OutOfStock/versioned/0.0.1/index.md (100%) rename {scripts => src}/__tests__/example-catalog/events/Order/OrderAmended/index.md (100%) rename {scripts => src}/__tests__/example-catalog/events/Order/OrderAmended/schema.avro (100%) rename {scripts => src}/__tests__/example-catalog/events/Order/OrderAmended/schema.json (100%) rename {scripts => src}/__tests__/example-catalog/events/Order/OrderCancelled/index.md (100%) rename {scripts => src}/__tests__/example-catalog/events/Order/OrderCancelled/schema.json (100%) rename {scripts => src}/__tests__/example-catalog/events/Order/OrderConfirmed/index.md (100%) rename {scripts => src}/__tests__/example-catalog/events/Order/OrderConfirmed/schema.json (100%) rename {scripts => src}/__tests__/example-catalog/flows/Payment/PaymentProcessed/index.md (100%) rename {scripts => src}/__tests__/example-catalog/flows/Payment/PaymentProcessed/versioned/0.0.1/index.md (100%) rename {scripts => src}/__tests__/example-catalog/flows/Subscriptions/CancelSubscription/index.md (100%) rename {scripts => src}/__tests__/example-catalog/package.json (100%) rename {scripts => src}/__tests__/example-catalog/services/PaymentService/asyncapi.yml (100%) rename {scripts => src}/__tests__/example-catalog/services/PaymentService/events/PaymentAccepted/index.md (100%) rename {scripts => src}/__tests__/example-catalog/services/PaymentService/events/PaymentAccepted/schema.json (100%) rename {scripts => src}/__tests__/example-catalog/services/PaymentService/events/PaymentAccepted/versioned/0.0.1/index.md (100%) rename {scripts => src}/__tests__/example-catalog/services/PaymentService/flows/PaymentAccepted/index.md (100%) rename {scripts => src}/__tests__/example-catalog/services/PaymentService/flows/PaymentAccepted/versioned/0.0.1/index.md (100%) rename {scripts => src}/__tests__/example-catalog/services/PaymentService/index.md (100%) rename {scripts => src}/__tests__/example-catalog/services/PaymentService/versioned/0.0.1/index.md (100%) rename {scripts => src}/__tests__/example-catalog/teams/full-stack.md (100%) rename {scripts => src}/__tests__/example-catalog/users/dboyne.md (100%) rename {scripts => src}/analytics/analytics.js (100%) rename {scripts => src}/analytics/log-build.js (100%) rename {scripts => src}/catalog-to-astro-content-directory.js (91%) rename {scripts => src}/constants.ts (100%) rename {scripts => src}/eventcatalog-config-file-utils.js (100%) rename {bin => src}/eventcatalog.config.ts (100%) rename {bin => src}/eventcatalog.ts (86%) rename {scripts => src}/generate.js (100%) rename {scripts => src}/map-catalog-to-astro.js (100%) rename {scripts => src}/watcher.js (100%) diff --git a/.changeset/neat-crabs-join.md b/.changeset/neat-crabs-join.md new file mode 100644 index 00000000..db692fcd --- /dev/null +++ b/.changeset/neat-crabs-join.md @@ -0,0 +1,5 @@ +--- +"@eventcatalog/core": minor +--- + +chore(core): refactor to code base moving files to new src directory diff --git a/bin/eventcatalog.js b/bin/eventcatalog.js new file mode 100755 index 00000000..5293e420 --- /dev/null +++ b/bin/eventcatalog.js @@ -0,0 +1,2 @@ +#!/usr/bin/env node +import '../dist/eventcatalog.js'; diff --git a/package.json b/package.json index f9a9b08e..fca114db 100644 --- a/package.json +++ b/package.json @@ -11,12 +11,13 @@ "access": "public" }, "bin": { - "eventcatalog": "bin/dist/eventcatalog.cjs" + "eventcatalog": "bin/eventcatalog.js" }, "files": [ "eventcatalog/", "!eventcatalog/**/__tests__/", - "bin/dist/", + "bin/", + "dist/", "default-files-for-collections/" ], "scripts": { diff --git a/scripts/__tests__/catalog-to-astro-content-directory.spec.ts b/src/__tests__/catalog-to-astro-content-directory.spec.ts similarity index 100% rename from scripts/__tests__/catalog-to-astro-content-directory.spec.ts rename to src/__tests__/catalog-to-astro-content-directory.spec.ts diff --git a/scripts/__tests__/eventcatalog-config-file-utils.spec.ts b/src/__tests__/eventcatalog-config-file-utils.spec.ts similarity index 99% rename from scripts/__tests__/eventcatalog-config-file-utils.spec.ts rename to src/__tests__/eventcatalog-config-file-utils.spec.ts index 2c7fd541..28dae452 100644 --- a/scripts/__tests__/eventcatalog-config-file-utils.spec.ts +++ b/src/__tests__/eventcatalog-config-file-utils.spec.ts @@ -10,7 +10,7 @@ import { getEventCatalogConfigFile, verifyRequiredFieldsAreInCatalogConfigFile, writeEventCatalogConfigFile, -} from 'scripts/eventcatalog-config-file-utils'; +} from '../eventcatalog-config-file-utils'; import { tmpdir } from 'os'; describe('catalog-to-astro-content-directory', () => { diff --git a/scripts/__tests__/example-catalog/commands/AddInventory/index.md b/src/__tests__/example-catalog/commands/AddInventory/index.md similarity index 100% rename from scripts/__tests__/example-catalog/commands/AddInventory/index.md rename to src/__tests__/example-catalog/commands/AddInventory/index.md diff --git a/scripts/__tests__/example-catalog/commands/AddInventory/schema.json b/src/__tests__/example-catalog/commands/AddInventory/schema.json similarity index 100% rename from scripts/__tests__/example-catalog/commands/AddInventory/schema.json rename to src/__tests__/example-catalog/commands/AddInventory/schema.json diff --git a/scripts/__tests__/example-catalog/commands/AddInventory/versioned/0.0.1/index.md b/src/__tests__/example-catalog/commands/AddInventory/versioned/0.0.1/index.md similarity index 100% rename from scripts/__tests__/example-catalog/commands/AddInventory/versioned/0.0.1/index.md rename to src/__tests__/example-catalog/commands/AddInventory/versioned/0.0.1/index.md diff --git a/scripts/__tests__/example-catalog/commands/AddInventory/versioned/0.0.1/schema.json b/src/__tests__/example-catalog/commands/AddInventory/versioned/0.0.1/schema.json similarity index 100% rename from scripts/__tests__/example-catalog/commands/AddInventory/versioned/0.0.1/schema.json rename to src/__tests__/example-catalog/commands/AddInventory/versioned/0.0.1/schema.json diff --git a/scripts/__tests__/example-catalog/domains/Payment/asyncapi.yml b/src/__tests__/example-catalog/domains/Payment/asyncapi.yml similarity index 100% rename from scripts/__tests__/example-catalog/domains/Payment/asyncapi.yml rename to src/__tests__/example-catalog/domains/Payment/asyncapi.yml diff --git a/scripts/__tests__/example-catalog/domains/Payment/events/PaymentDomainTestEvent1/index.md b/src/__tests__/example-catalog/domains/Payment/events/PaymentDomainTestEvent1/index.md similarity index 100% rename from scripts/__tests__/example-catalog/domains/Payment/events/PaymentDomainTestEvent1/index.md rename to src/__tests__/example-catalog/domains/Payment/events/PaymentDomainTestEvent1/index.md diff --git a/scripts/__tests__/example-catalog/domains/Payment/events/PaymentDomainTestEvent1/schema.json b/src/__tests__/example-catalog/domains/Payment/events/PaymentDomainTestEvent1/schema.json similarity index 100% rename from scripts/__tests__/example-catalog/domains/Payment/events/PaymentDomainTestEvent1/schema.json rename to src/__tests__/example-catalog/domains/Payment/events/PaymentDomainTestEvent1/schema.json diff --git a/scripts/__tests__/example-catalog/domains/Payment/events/PaymentDomainTestEvent1/versioned/0.0.1/index.md b/src/__tests__/example-catalog/domains/Payment/events/PaymentDomainTestEvent1/versioned/0.0.1/index.md similarity index 100% rename from scripts/__tests__/example-catalog/domains/Payment/events/PaymentDomainTestEvent1/versioned/0.0.1/index.md rename to src/__tests__/example-catalog/domains/Payment/events/PaymentDomainTestEvent1/versioned/0.0.1/index.md diff --git a/scripts/__tests__/example-catalog/domains/Payment/flows/ProcessingOfAnOrder/index.md b/src/__tests__/example-catalog/domains/Payment/flows/ProcessingOfAnOrder/index.md similarity index 100% rename from scripts/__tests__/example-catalog/domains/Payment/flows/ProcessingOfAnOrder/index.md rename to src/__tests__/example-catalog/domains/Payment/flows/ProcessingOfAnOrder/index.md diff --git a/scripts/__tests__/example-catalog/domains/Payment/flows/ProcessingOfAnOrder/versioned/0.0.1/index.md b/src/__tests__/example-catalog/domains/Payment/flows/ProcessingOfAnOrder/versioned/0.0.1/index.md similarity index 100% rename from scripts/__tests__/example-catalog/domains/Payment/flows/ProcessingOfAnOrder/versioned/0.0.1/index.md rename to src/__tests__/example-catalog/domains/Payment/flows/ProcessingOfAnOrder/versioned/0.0.1/index.md diff --git a/scripts/__tests__/example-catalog/domains/Payment/index.md b/src/__tests__/example-catalog/domains/Payment/index.md similarity index 100% rename from scripts/__tests__/example-catalog/domains/Payment/index.md rename to src/__tests__/example-catalog/domains/Payment/index.md diff --git a/scripts/__tests__/example-catalog/domains/Payment/services/ExternalPaymentService/asyncapi.yml b/src/__tests__/example-catalog/domains/Payment/services/ExternalPaymentService/asyncapi.yml similarity index 100% rename from scripts/__tests__/example-catalog/domains/Payment/services/ExternalPaymentService/asyncapi.yml rename to src/__tests__/example-catalog/domains/Payment/services/ExternalPaymentService/asyncapi.yml diff --git a/scripts/__tests__/example-catalog/domains/Payment/services/ExternalPaymentService/index.md b/src/__tests__/example-catalog/domains/Payment/services/ExternalPaymentService/index.md similarity index 100% rename from scripts/__tests__/example-catalog/domains/Payment/services/ExternalPaymentService/index.md rename to src/__tests__/example-catalog/domains/Payment/services/ExternalPaymentService/index.md diff --git a/scripts/__tests__/example-catalog/domains/Payment/services/ExternalPaymentService/versioned/0.0.1/index.md b/src/__tests__/example-catalog/domains/Payment/services/ExternalPaymentService/versioned/0.0.1/index.md similarity index 100% rename from scripts/__tests__/example-catalog/domains/Payment/services/ExternalPaymentService/versioned/0.0.1/index.md rename to src/__tests__/example-catalog/domains/Payment/services/ExternalPaymentService/versioned/0.0.1/index.md diff --git a/scripts/__tests__/example-catalog/domains/Payment/versioned/0.0.1/index.md b/src/__tests__/example-catalog/domains/Payment/versioned/0.0.1/index.md similarity index 100% rename from scripts/__tests__/example-catalog/domains/Payment/versioned/0.0.1/index.md rename to src/__tests__/example-catalog/domains/Payment/versioned/0.0.1/index.md diff --git a/scripts/__tests__/example-catalog/eventcatalog.config.defaults.js b/src/__tests__/example-catalog/eventcatalog.config.defaults.js similarity index 100% rename from scripts/__tests__/example-catalog/eventcatalog.config.defaults.js rename to src/__tests__/example-catalog/eventcatalog.config.defaults.js diff --git a/scripts/__tests__/example-catalog/eventcatalog.config.js b/src/__tests__/example-catalog/eventcatalog.config.js similarity index 100% rename from scripts/__tests__/example-catalog/eventcatalog.config.js rename to src/__tests__/example-catalog/eventcatalog.config.js diff --git a/scripts/__tests__/example-catalog/events/Inventory/InventoryAdjusted/changelog.md b/src/__tests__/example-catalog/events/Inventory/InventoryAdjusted/changelog.md similarity index 100% rename from scripts/__tests__/example-catalog/events/Inventory/InventoryAdjusted/changelog.md rename to src/__tests__/example-catalog/events/Inventory/InventoryAdjusted/changelog.md diff --git a/scripts/__tests__/example-catalog/events/Inventory/InventoryAdjusted/index.md b/src/__tests__/example-catalog/events/Inventory/InventoryAdjusted/index.md similarity index 100% rename from scripts/__tests__/example-catalog/events/Inventory/InventoryAdjusted/index.md rename to src/__tests__/example-catalog/events/Inventory/InventoryAdjusted/index.md diff --git a/scripts/__tests__/example-catalog/events/Inventory/InventoryAdjusted/schema.avro b/src/__tests__/example-catalog/events/Inventory/InventoryAdjusted/schema.avro similarity index 100% rename from scripts/__tests__/example-catalog/events/Inventory/InventoryAdjusted/schema.avro rename to src/__tests__/example-catalog/events/Inventory/InventoryAdjusted/schema.avro diff --git a/scripts/__tests__/example-catalog/events/Inventory/InventoryAdjusted/schema.json b/src/__tests__/example-catalog/events/Inventory/InventoryAdjusted/schema.json similarity index 100% rename from scripts/__tests__/example-catalog/events/Inventory/InventoryAdjusted/schema.json rename to src/__tests__/example-catalog/events/Inventory/InventoryAdjusted/schema.json diff --git a/scripts/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/0.0.1/changelog.md b/src/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/0.0.1/changelog.md similarity index 100% rename from scripts/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/0.0.1/changelog.md rename to src/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/0.0.1/changelog.md diff --git a/scripts/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/0.0.1/index.md b/src/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/0.0.1/index.md similarity index 100% rename from scripts/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/0.0.1/index.md rename to src/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/0.0.1/index.md diff --git a/scripts/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/0.0.1/schema.avro b/src/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/0.0.1/schema.avro similarity index 100% rename from scripts/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/0.0.1/schema.avro rename to src/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/0.0.1/schema.avro diff --git a/scripts/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/1.0.0/changelog.md b/src/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/1.0.0/changelog.md similarity index 100% rename from scripts/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/1.0.0/changelog.md rename to src/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/1.0.0/changelog.md diff --git a/scripts/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/1.0.0/index.md b/src/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/1.0.0/index.md similarity index 100% rename from scripts/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/1.0.0/index.md rename to src/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/1.0.0/index.md diff --git a/scripts/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/1.0.0/schema.avro b/src/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/1.0.0/schema.avro similarity index 100% rename from scripts/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/1.0.0/schema.avro rename to src/__tests__/example-catalog/events/Inventory/InventoryAdjusted/versioned/1.0.0/schema.avro diff --git a/scripts/__tests__/example-catalog/events/Inventory/OutOfStock/index.md b/src/__tests__/example-catalog/events/Inventory/OutOfStock/index.md similarity index 100% rename from scripts/__tests__/example-catalog/events/Inventory/OutOfStock/index.md rename to src/__tests__/example-catalog/events/Inventory/OutOfStock/index.md diff --git a/scripts/__tests__/example-catalog/events/Inventory/OutOfStock/versioned/0.0.1/index.md b/src/__tests__/example-catalog/events/Inventory/OutOfStock/versioned/0.0.1/index.md similarity index 100% rename from scripts/__tests__/example-catalog/events/Inventory/OutOfStock/versioned/0.0.1/index.md rename to src/__tests__/example-catalog/events/Inventory/OutOfStock/versioned/0.0.1/index.md diff --git a/scripts/__tests__/example-catalog/events/Order/OrderAmended/index.md b/src/__tests__/example-catalog/events/Order/OrderAmended/index.md similarity index 100% rename from scripts/__tests__/example-catalog/events/Order/OrderAmended/index.md rename to src/__tests__/example-catalog/events/Order/OrderAmended/index.md diff --git a/scripts/__tests__/example-catalog/events/Order/OrderAmended/schema.avro b/src/__tests__/example-catalog/events/Order/OrderAmended/schema.avro similarity index 100% rename from scripts/__tests__/example-catalog/events/Order/OrderAmended/schema.avro rename to src/__tests__/example-catalog/events/Order/OrderAmended/schema.avro diff --git a/scripts/__tests__/example-catalog/events/Order/OrderAmended/schema.json b/src/__tests__/example-catalog/events/Order/OrderAmended/schema.json similarity index 100% rename from scripts/__tests__/example-catalog/events/Order/OrderAmended/schema.json rename to src/__tests__/example-catalog/events/Order/OrderAmended/schema.json diff --git a/scripts/__tests__/example-catalog/events/Order/OrderCancelled/index.md b/src/__tests__/example-catalog/events/Order/OrderCancelled/index.md similarity index 100% rename from scripts/__tests__/example-catalog/events/Order/OrderCancelled/index.md rename to src/__tests__/example-catalog/events/Order/OrderCancelled/index.md diff --git a/scripts/__tests__/example-catalog/events/Order/OrderCancelled/schema.json b/src/__tests__/example-catalog/events/Order/OrderCancelled/schema.json similarity index 100% rename from scripts/__tests__/example-catalog/events/Order/OrderCancelled/schema.json rename to src/__tests__/example-catalog/events/Order/OrderCancelled/schema.json diff --git a/scripts/__tests__/example-catalog/events/Order/OrderConfirmed/index.md b/src/__tests__/example-catalog/events/Order/OrderConfirmed/index.md similarity index 100% rename from scripts/__tests__/example-catalog/events/Order/OrderConfirmed/index.md rename to src/__tests__/example-catalog/events/Order/OrderConfirmed/index.md diff --git a/scripts/__tests__/example-catalog/events/Order/OrderConfirmed/schema.json b/src/__tests__/example-catalog/events/Order/OrderConfirmed/schema.json similarity index 100% rename from scripts/__tests__/example-catalog/events/Order/OrderConfirmed/schema.json rename to src/__tests__/example-catalog/events/Order/OrderConfirmed/schema.json diff --git a/scripts/__tests__/example-catalog/flows/Payment/PaymentProcessed/index.md b/src/__tests__/example-catalog/flows/Payment/PaymentProcessed/index.md similarity index 100% rename from scripts/__tests__/example-catalog/flows/Payment/PaymentProcessed/index.md rename to src/__tests__/example-catalog/flows/Payment/PaymentProcessed/index.md diff --git a/scripts/__tests__/example-catalog/flows/Payment/PaymentProcessed/versioned/0.0.1/index.md b/src/__tests__/example-catalog/flows/Payment/PaymentProcessed/versioned/0.0.1/index.md similarity index 100% rename from scripts/__tests__/example-catalog/flows/Payment/PaymentProcessed/versioned/0.0.1/index.md rename to src/__tests__/example-catalog/flows/Payment/PaymentProcessed/versioned/0.0.1/index.md diff --git a/scripts/__tests__/example-catalog/flows/Subscriptions/CancelSubscription/index.md b/src/__tests__/example-catalog/flows/Subscriptions/CancelSubscription/index.md similarity index 100% rename from scripts/__tests__/example-catalog/flows/Subscriptions/CancelSubscription/index.md rename to src/__tests__/example-catalog/flows/Subscriptions/CancelSubscription/index.md diff --git a/scripts/__tests__/example-catalog/package.json b/src/__tests__/example-catalog/package.json similarity index 100% rename from scripts/__tests__/example-catalog/package.json rename to src/__tests__/example-catalog/package.json diff --git a/scripts/__tests__/example-catalog/services/PaymentService/asyncapi.yml b/src/__tests__/example-catalog/services/PaymentService/asyncapi.yml similarity index 100% rename from scripts/__tests__/example-catalog/services/PaymentService/asyncapi.yml rename to src/__tests__/example-catalog/services/PaymentService/asyncapi.yml diff --git a/scripts/__tests__/example-catalog/services/PaymentService/events/PaymentAccepted/index.md b/src/__tests__/example-catalog/services/PaymentService/events/PaymentAccepted/index.md similarity index 100% rename from scripts/__tests__/example-catalog/services/PaymentService/events/PaymentAccepted/index.md rename to src/__tests__/example-catalog/services/PaymentService/events/PaymentAccepted/index.md diff --git a/scripts/__tests__/example-catalog/services/PaymentService/events/PaymentAccepted/schema.json b/src/__tests__/example-catalog/services/PaymentService/events/PaymentAccepted/schema.json similarity index 100% rename from scripts/__tests__/example-catalog/services/PaymentService/events/PaymentAccepted/schema.json rename to src/__tests__/example-catalog/services/PaymentService/events/PaymentAccepted/schema.json diff --git a/scripts/__tests__/example-catalog/services/PaymentService/events/PaymentAccepted/versioned/0.0.1/index.md b/src/__tests__/example-catalog/services/PaymentService/events/PaymentAccepted/versioned/0.0.1/index.md similarity index 100% rename from scripts/__tests__/example-catalog/services/PaymentService/events/PaymentAccepted/versioned/0.0.1/index.md rename to src/__tests__/example-catalog/services/PaymentService/events/PaymentAccepted/versioned/0.0.1/index.md diff --git a/scripts/__tests__/example-catalog/services/PaymentService/flows/PaymentAccepted/index.md b/src/__tests__/example-catalog/services/PaymentService/flows/PaymentAccepted/index.md similarity index 100% rename from scripts/__tests__/example-catalog/services/PaymentService/flows/PaymentAccepted/index.md rename to src/__tests__/example-catalog/services/PaymentService/flows/PaymentAccepted/index.md diff --git a/scripts/__tests__/example-catalog/services/PaymentService/flows/PaymentAccepted/versioned/0.0.1/index.md b/src/__tests__/example-catalog/services/PaymentService/flows/PaymentAccepted/versioned/0.0.1/index.md similarity index 100% rename from scripts/__tests__/example-catalog/services/PaymentService/flows/PaymentAccepted/versioned/0.0.1/index.md rename to src/__tests__/example-catalog/services/PaymentService/flows/PaymentAccepted/versioned/0.0.1/index.md diff --git a/scripts/__tests__/example-catalog/services/PaymentService/index.md b/src/__tests__/example-catalog/services/PaymentService/index.md similarity index 100% rename from scripts/__tests__/example-catalog/services/PaymentService/index.md rename to src/__tests__/example-catalog/services/PaymentService/index.md diff --git a/scripts/__tests__/example-catalog/services/PaymentService/versioned/0.0.1/index.md b/src/__tests__/example-catalog/services/PaymentService/versioned/0.0.1/index.md similarity index 100% rename from scripts/__tests__/example-catalog/services/PaymentService/versioned/0.0.1/index.md rename to src/__tests__/example-catalog/services/PaymentService/versioned/0.0.1/index.md diff --git a/scripts/__tests__/example-catalog/teams/full-stack.md b/src/__tests__/example-catalog/teams/full-stack.md similarity index 100% rename from scripts/__tests__/example-catalog/teams/full-stack.md rename to src/__tests__/example-catalog/teams/full-stack.md diff --git a/scripts/__tests__/example-catalog/users/dboyne.md b/src/__tests__/example-catalog/users/dboyne.md similarity index 100% rename from scripts/__tests__/example-catalog/users/dboyne.md rename to src/__tests__/example-catalog/users/dboyne.md diff --git a/scripts/analytics/analytics.js b/src/analytics/analytics.js similarity index 100% rename from scripts/analytics/analytics.js rename to src/analytics/analytics.js diff --git a/scripts/analytics/log-build.js b/src/analytics/log-build.js similarity index 100% rename from scripts/analytics/log-build.js rename to src/analytics/log-build.js diff --git a/scripts/catalog-to-astro-content-directory.js b/src/catalog-to-astro-content-directory.js similarity index 91% rename from scripts/catalog-to-astro-content-directory.js rename to src/catalog-to-astro-content-directory.js index cf32a3a2..4cada736 100644 --- a/scripts/catalog-to-astro-content-directory.js +++ b/src/catalog-to-astro-content-directory.js @@ -7,18 +7,7 @@ import { verifyRequiredFieldsAreInCatalogConfigFile, addPropertyToFrontMatter } import { mapCatalogToAstro } from './map-catalog-to-astro.js'; const __filename = fileURLToPath(import.meta.url); -const rootPkg = path.resolve( - path.dirname(__filename), - /** - * TODO: fix me =0 - * - * The following is a workaround until organize the structure to have the correct path - * for any value of NODE_ENV - * - * @author carlosallexandre - */ - process.env.NODE_ENV === 'test' ? '../' : '../../' -); +const rootPkg = path.resolve(path.dirname(__filename), '../'); const copyFiles = async (source, target) => { const files = await glob(path.join(source, '**'), { diff --git a/scripts/constants.ts b/src/constants.ts similarity index 100% rename from scripts/constants.ts rename to src/constants.ts diff --git a/scripts/eventcatalog-config-file-utils.js b/src/eventcatalog-config-file-utils.js similarity index 100% rename from scripts/eventcatalog-config-file-utils.js rename to src/eventcatalog-config-file-utils.js diff --git a/bin/eventcatalog.config.ts b/src/eventcatalog.config.ts similarity index 100% rename from bin/eventcatalog.config.ts rename to src/eventcatalog.config.ts diff --git a/bin/eventcatalog.ts b/src/eventcatalog.ts similarity index 86% rename from bin/eventcatalog.ts rename to src/eventcatalog.ts index 928cd859..628c782a 100755 --- a/bin/eventcatalog.ts +++ b/src/eventcatalog.ts @@ -1,16 +1,15 @@ -#!/usr/bin/env node import { Command } from 'commander'; -import { exec, execSync } from 'node:child_process'; +import { execSync } from 'node:child_process'; import { join } from 'node:path'; import fs from 'fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; import concurrently from 'concurrently'; -import { generate } from 'scripts/generate'; -import logBuild from 'scripts/analytics/log-build'; -import { VERSION } from 'scripts/constants'; -import { watch } from 'scripts/watcher'; -import { catalogToAstro } from 'scripts/catalog-to-astro-content-directory'; +import { generate } from './generate'; +import logBuild from './analytics/log-build'; +import { VERSION } from './constants'; +import { watch } from './watcher'; +import { catalogToAstro } from './catalog-to-astro-content-directory'; const currentDir = path.dirname(fileURLToPath(import.meta.url)); @@ -23,16 +22,10 @@ const dir = path.resolve(process.env.PROJECT_DIR || process.cwd()); const core = path.resolve(process.env.CATALOG_DIR || join(dir, '.eventcatalog-core')); // The project itself -const eventCatalogDir = path.resolve(join(currentDir, '../../eventcatalog/')); +const eventCatalogDir = path.resolve(join(currentDir, '../eventcatalog/')); program.name('eventcatalog').description('Documentation tool for event-driven architectures'); -const copyFolder = (from: string, to: string) => { - if (fs.existsSync(from)) { - fs.cpSync(from, to, { recursive: true }); - } -}; - const ensureDir = (dir: string) => { if (!fs.existsSync(dir)) { fs.mkdirSync(dir); @@ -130,8 +123,9 @@ program }); const previewCatalog = () => { - copyCore(); - + /** + * TODO: get the port and outDir from the eventcatalog.config.js. + */ execSync(`cross-env PROJECT_DIR='${dir}' CATALOG_DIR='${core}' npx astro preview --root ${dir} --port 3000`, { cwd: core, stdio: 'inherit', @@ -161,4 +155,10 @@ program await generate(dir); }); -program.parseAsync(); +program + .parseAsync() + .then(() => process.exit(0)) + .catch((err) => { + console.error(err); + process.exit(1); + }); diff --git a/scripts/generate.js b/src/generate.js similarity index 100% rename from scripts/generate.js rename to src/generate.js diff --git a/scripts/map-catalog-to-astro.js b/src/map-catalog-to-astro.js similarity index 100% rename from scripts/map-catalog-to-astro.js rename to src/map-catalog-to-astro.js diff --git a/scripts/watcher.js b/src/watcher.js similarity index 100% rename from scripts/watcher.js rename to src/watcher.js diff --git a/tsconfig.json b/tsconfig.json index f2b617d8..1e6b7015 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,7 @@ "compilerOptions": { "strict": true, "baseUrl": ".", + "outDir": "dist/", "types": ["vitest/globals"] } } diff --git a/tsup.config.js b/tsup.config.js index acfcf6a3..d1ba570c 100644 --- a/tsup.config.js +++ b/tsup.config.js @@ -1,9 +1,9 @@ import { defineConfig } from 'tsup'; export default defineConfig({ - entry: ['bin/eventcatalog.ts', 'bin/eventcatalog.config.ts'], + entry: ['src/**', '!src/**/__tests__/**'], dts: true, - outDir: 'bin/dist', + outDir: 'dist/', format: ['esm', 'cjs'], shims: true, clean: true,