@eventcatalog/generator-openapi 6.0.1 → 7.0.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/dist/index.mjs CHANGED
@@ -279,7 +279,7 @@ var require_ansi_align = __commonJS({
279
279
 
280
280
  // src/index.ts
281
281
  import utils2 from "@eventcatalog/sdk";
282
- import { readFile } from "node:fs/promises";
282
+ import { readFile } from "fs/promises";
283
283
  import chalk3 from "chalk";
284
284
  import SwaggerParser2 from "@apidevtools/swagger-parser";
285
285
 
@@ -629,7 +629,7 @@ import chalk from "chalk";
629
629
  // package.json
630
630
  var package_default = {
631
631
  name: "@eventcatalog/generator-openapi",
632
- version: "6.0.1",
632
+ version: "7.0.0",
633
633
  description: "OpenAPI generator for EventCatalog",
634
634
  scripts: {
635
635
  build: "tsup",
@@ -650,6 +650,7 @@ var package_default = {
650
650
  "@types/js-yaml": "^4.0.9",
651
651
  "@types/lodash": "^4.17.7",
652
652
  "@types/node": "^20.16.1",
653
+ "@types/semver": "^7.7.0",
653
654
  prettier: "^3.3.3",
654
655
  tsup: "^8.1.0",
655
656
  typescript: "^5.5.3",
@@ -669,6 +670,7 @@ var package_default = {
669
670
  chalk: "^4",
670
671
  "js-yaml": "^4.1.0",
671
672
  "openapi-types": "^12.1.3",
673
+ semver: "^7.7.2",
672
674
  slugify: "^1.6.6",
673
675
  "update-notifier": "^7.3.1"
674
676
  }
@@ -715,10 +717,10 @@ You are using a trial license for this plugin`));
715
717
 
716
718
  // src/index.ts
717
719
  import yaml from "js-yaml";
718
- import { join } from "node:path";
720
+ import { join } from "path";
719
721
 
720
722
  // ../../node_modules/.pnpm/boxen@8.0.1/node_modules/boxen/index.js
721
- import process2 from "node:process";
723
+ import process2 from "process";
722
724
 
723
725
  // ../../node_modules/.pnpm/ansi-regex@6.1.0/node_modules/ansi-regex/index.js
724
726
  function ansiRegex({ onlyFirst = false } = {}) {
@@ -1574,6 +1576,15 @@ Run npm i ${packageName} to update`;
1574
1576
  }
1575
1577
  }
1576
1578
 
1579
+ // src/utils/versions.ts
1580
+ import { satisfies } from "semver";
1581
+ var isVersionGreaterThan = (version, givenVersion) => {
1582
+ return satisfies(version, `>${givenVersion}`);
1583
+ };
1584
+ var isVersionLessThan = (version, givenVersion) => {
1585
+ return satisfies(version, `<${givenVersion}`);
1586
+ };
1587
+
1577
1588
  // src/index.ts
1578
1589
  var index_default = async (_, options) => {
1579
1590
  if (!process.env.PROJECT_DIR) {
@@ -1657,8 +1668,11 @@ Processing domain: ${domainName} (v${domainVersion})`));
1657
1668
  await addServiceToDomain(domainId, { id: service.id, version: service.version }, domainVersion);
1658
1669
  }
1659
1670
  const latestServiceInCatalog = await getService(service.id, "latest");
1660
- const versionTheService = latestServiceInCatalog && latestServiceInCatalog.version !== version;
1671
+ const versionTheService = latestServiceInCatalog && isVersionGreaterThan(version, latestServiceInCatalog.version);
1661
1672
  console.log(chalk3.blue(`Processing service: ${document.info.title} (v${version})`));
1673
+ if (latestServiceInCatalog && isVersionLessThan(version, latestServiceInCatalog.version)) {
1674
+ servicePath = join(servicePath, "versioned", version);
1675
+ }
1662
1676
  if (versionTheService) {
1663
1677
  await versionService(service.id);
1664
1678
  console.log(chalk3.cyan(` - Versioned previous service (v${latestServiceInCatalog.version})`));