GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — t3code/scripts/update-release-package-versions.ts at main · TimoKruth/t3code Expand file tree/ Copy pathupdate-release-package-versions.tsMore file actions 99 lines (81 loc) · 2.78 KB / Copy pathupdate-release-package-versions.tsFile metadata and controls99 lines (81 loc) · 2.78 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 import { appendFileSync, readFileSync, writeFileSync } from "node:fs"; import { resolve } from "node:path"; import { fileURLToPath } from "node:url"; import { parseCliArgs } from "@t3tools/shared/cliArgs"; export const releasePackageFiles = [ "apps/server/package.json", "apps/desktop/package.json", "apps/web/package.json", "packages/contracts/package.json", ] as const; interface UpdateReleasePackageVersionsOptions { readonly rootDir?: string; } interface MutablePackageJson { version?: string; [key: string]: unknown; } export function updateReleasePackageVersions( version: string, options: UpdateReleasePackageVersionsOptions = {}, ): { changed: boolean } { const rootDir = resolve(options.rootDir ?? process.cwd()); let changed = false; for (const relativePath of releasePackageFiles) { const filePath = resolve(rootDir, relativePath); const packageJson = JSON.parse(readFileSync(filePath, "utf8")) as MutablePackageJson; if (packageJson.version === version) { continue; } packageJson.version = version; writeFileSync(filePath, `${JSON.stringify(packageJson, null, 2)}\n`); changed = true; } return { changed }; } export function parseArgs(argv: ReadonlyArray<string>): { version: string; rootDir: string | undefined; writeGithubOutput: boolean; } { const { flags, positionals } = parseCliArgs(argv, { booleanFlags: ["github-output"] }); const unknownFlags = Object.keys(flags).filter((k) => k !== "github-output" && k !== "root"); if (unknownFlags.length > 0) { throw new Error(`Unknown argument: --${unknownFlags[0]}`); } if ("root" in flags && flags.root === null) { throw new Error("Missing value for --root."); } if (positionals.length > 1) { throw new Error("Only one release version can be provided."); } if (positionals.length !== 1 || !positionals[0]) { throw new Error( "Usage: node scripts/update-release-package-versions.ts <version> [--root <path>] [--github-output]", ); } return { version: positionals[0], rootDir: flags.root ?? undefined, writeGithubOutput: "github-output" in flags, }; } const isMain = process.argv[1] !== undefined && resolve(process.argv[1]) === fileURLToPath(import.meta.url); if (isMain) { const { version, rootDir, writeGithubOutput } = parseArgs(process.argv.slice(2)); const { changed } = updateReleasePackageVersions( version, rootDir === undefined ? {} : { rootDir }, ); if (!changed) { console.log("All package.json versions already match release version."); } if (writeGithubOutput) { const githubOutputPath = process.env.GITHUB_OUTPUT; if (!githubOutputPath) { throw new Error("GITHUB_OUTPUT is required when --github-output is set."); } appendFileSync(githubOutputPath, `changed=${changed}\n`); } } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |