diff --git a/RELEASE_MANAGEMENT.md b/RELEASE_MANAGEMENT.md index 0b2844e477..4621ec528f 100644 --- a/RELEASE_MANAGEMENT.md +++ b/RELEASE_MANAGEMENT.md @@ -30,9 +30,10 @@ git rebase upstream/main git push --force-with-lease git checkout -b release-v1.1.3 yarn run configure -yarn lerna version 1.1.3 --ignore-scripts --conventional-commits --exact --git-remote upstream --message="chore(release): publish %s" --no-push --no-git-tag-version --no-ignore-changes --force-publish -yarn tools:bump-openapi-spec-dep-versions +yarn lerna version 1.1.3 --ignore-scripts --conventional-commits --exact --git-remote upstream --message="chore(release): publish %s" --no-push --no-git-tag-version --no-ignore-changes +yarn tools:bump-openapi-spec-dep-versions --target-version=1.1.3 yarn codegen +yarn build:dev ./tools/weaver-update-version.sh 1.1.3 . ./tools/go-gen-checksum.sh 1.1.3 . ``` diff --git a/package.json b/package.json index 021096ed70..e771c47e7c 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "lint": "yarn run format && yarn run spellcheck", "format": "eslint '**/*.{js,ts}' --quiet --fix", "spellcheck": "cspell lint --no-progress \"*/*/src/**/*.{js,ts}\"", - "tsc": "tsc --build --verbose", + "tsc": "NODE_OPTIONS=\"--max_old_space_size=3072\" tsc --build --verbose", "codegen": "run-s 'codegen:warmup-*' codegen:lerna codegen:cleanup", "codegen:cleanup": "rm --force --verbose ./openapitools.json", "codegen:lerna": "lerna run codegen", diff --git a/tools/bump-openapi-spec-dep-versions.ts b/tools/bump-openapi-spec-dep-versions.ts index 6baf9b1055..5cdf59cb41 100644 --- a/tools/bump-openapi-spec-dep-versions.ts +++ b/tools/bump-openapi-spec-dep-versions.ts @@ -1,4 +1,3 @@ -import { URL } from "url"; import { fileURLToPath } from "url"; import path from "path"; import yargs from "yargs"; @@ -8,10 +7,7 @@ import { globby, Options as GlobbyOptions } from "globby"; import { RuntimeError } from "run-time-error"; import prettier from "prettier"; import { OpenAPIV3_1 } from "openapi-types"; -import { isValidSemVer } from "semver-parser"; -import fastSafeStringify from "fast-safe-stringify"; -import { hasKey } from "./has-key"; import { getLatestSemVerGitTagV1 } from "./get-latest-sem-ver-git-tag"; const TAG = "[tools/bump-openapi-spec-dep-versions.ts]"; @@ -99,67 +95,6 @@ async function createRequest( return req; } -function traversePojoRefs( - file: string, - newVersion: string, - pojo: unknown, - replacements: ISpecRefReplacementV1[], - propPartPaths: string[], -): ISpecRefReplacementV1[] { - if (!pojo || typeof pojo !== "object") { - throw new RuntimeError(`Expected "pojo" as a Plain Old Javascript Object`); - } - Object.entries(pojo).forEach(([key, oldVal]: [string, unknown]) => { - if (!oldVal) { - return; - } else if (typeof oldVal === "object") { - propPartPaths.push(key); - traversePojoRefs(file, newVersion, oldVal, replacements, propPartPaths); - propPartPaths.pop(); - } else if (key === "$ref") { - if (typeof oldVal !== "string") { - throw new RuntimeError(`Expected string value for $ref in ${file}`); - } - if (oldVal.startsWith("#")) { - // skip references that are local, e.g. pointint go a schema component - // within the same openapi.json specification file because these are - // not going to have a git tag in their URLs (because they aren't URLs) - return; - } - if (!hasKey(pojo, "$ref")) { - throw new RuntimeError(`Expected pojo to have a "$pref" property.`); - } - - const aUrl = tryParseUrl(oldVal); - const urlPathParts = aUrl.pathname.split("/"); - - let dirty = false; - - urlPathParts.forEach((x, idx) => { - if (isValidSemVer(x) && x !== newVersion) { - dirty = true; - urlPathParts[idx] = newVersion; - console.log(`${TAG} ${file} Swapping "${x}" to "${newVersion}"`); - } - }); - - if (dirty) { - aUrl.pathname = urlPathParts.join("/"); - const newValue = aUrl.toString(); - console.log(`${TAG} ${file} Swapping "${oldVal}" to "${newValue}"`); - pojo[key] = newValue; - const propertyPath = ".".concat(propPartPaths.join(".")); - replacements.push({ - newValue, - oldValue: oldVal, - propertyPath, - }); - } - } - }); - return replacements; -} - async function bumpOpenApiSpecDepVersionsOneFile( filePathAbs: string, filePathRel: string, @@ -176,13 +111,7 @@ async function bumpOpenApiSpecDepVersionsOneFile( openApiJson.info = { title: filePathRel, version: "0.0.0" }; } - const replacements = traversePojoRefs( - filePathRel, - newVersion, - openApiJson, - [], - [], - ); + const replacements = []; if (openApiJson.info.version !== newVersion) { const oldVersion = openApiJson.info.version; @@ -217,24 +146,6 @@ async function bumpOpenApiSpecDepVersionsOneFile( return replacements; } -function tryParseUrl(x: unknown): URL { - if (typeof x !== "string") { - throw new RuntimeError(`${TAG} tryParseUrl() expected string input.`); - } - try { - return new URL(x); - } catch (ex) { - console.error(`${TAG} parsing failed for ${x}`, ex); - let innerEx; - if (ex instanceof Error || typeof ex === "string") { - innerEx = ex; - } else { - innerEx = fastSafeStringify(ex); - } - throw new RuntimeError(`${TAG} parsing failed for ${x}`, innerEx); - } -} - export async function bumpOpenApiSpecDepVersions( req: IBumpOpenAPISpecDepVersionsV1Request, ): Promise { @@ -260,7 +171,7 @@ export async function bumpOpenApiSpecDepVersions( ignore: ["**/node_modules"], }; - const DEFAULT_GLOB = "**/src/main/json/openapi.json"; + const DEFAULT_GLOB = "**/src/main/json/openapi.tpl.json"; const oasPaths = await globby(DEFAULT_GLOB, globbyOpts);