mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-16 20:01:27 +00:00
wip
This commit is contained in:
parent
34d4f3693e
commit
29b159ca20
28 changed files with 2138 additions and 395 deletions
68
scripts/release/update_version.ts
Normal file
68
scripts/release/update_version.ts
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
import * as fs from "node:fs/promises";
|
||||
import { glob } from "glob";
|
||||
import { $ } from "execa";
|
||||
import type { ReleaseOpts } from "./main.js";
|
||||
import { assert } from "./utils.js";
|
||||
|
||||
export async function updateVersion(opts: ReleaseOpts) {
|
||||
const findReplace = [
|
||||
{
|
||||
path: "Cargo.toml",
|
||||
find: /^version = ".*"/m,
|
||||
replace: `version = "${opts.version}"`,
|
||||
},
|
||||
{
|
||||
path: "sdks/typescript/package.json",
|
||||
find: /"version": ".*"/,
|
||||
replace: `"version": "${opts.version}"`,
|
||||
},
|
||||
{
|
||||
path: "sdks/cli/package.json",
|
||||
find: /"version": ".*"/,
|
||||
replace: `"version": "${opts.version}"`,
|
||||
},
|
||||
{
|
||||
path: "sdks/cli/platforms/*/package.json",
|
||||
find: /"version": ".*"/,
|
||||
replace: `"version": "${opts.version}"`,
|
||||
},
|
||||
];
|
||||
|
||||
for (const { path: globPath, find, replace } of findReplace) {
|
||||
const paths = await glob(globPath, { cwd: opts.root });
|
||||
assert(paths.length > 0, `no paths matched: ${globPath}`);
|
||||
|
||||
for (const filePath of paths) {
|
||||
const fullPath = `${opts.root}/${filePath}`;
|
||||
const file = await fs.readFile(fullPath, "utf-8");
|
||||
assert(find.test(file), `file does not match ${find}: ${filePath}`);
|
||||
|
||||
const newFile = file.replace(find, replace);
|
||||
await fs.writeFile(fullPath, newFile);
|
||||
|
||||
await $({ cwd: opts.root })`git add ${filePath}`;
|
||||
}
|
||||
}
|
||||
|
||||
// Update optionalDependencies in CLI package.json
|
||||
const cliPkgPath = `${opts.root}/sdks/cli/package.json`;
|
||||
const cliPkg = JSON.parse(await fs.readFile(cliPkgPath, "utf-8"));
|
||||
if (cliPkg.optionalDependencies) {
|
||||
for (const dep of Object.keys(cliPkg.optionalDependencies)) {
|
||||
cliPkg.optionalDependencies[dep] = opts.version;
|
||||
}
|
||||
await fs.writeFile(cliPkgPath, JSON.stringify(cliPkg, null, 2) + "\n");
|
||||
await $({ cwd: opts.root })`git add sdks/cli/package.json`;
|
||||
}
|
||||
|
||||
// Update optionalDependencies in TypeScript SDK package.json
|
||||
const sdkPkgPath = `${opts.root}/sdks/typescript/package.json`;
|
||||
const sdkPkg = JSON.parse(await fs.readFile(sdkPkgPath, "utf-8"));
|
||||
if (sdkPkg.optionalDependencies) {
|
||||
for (const dep of Object.keys(sdkPkg.optionalDependencies)) {
|
||||
sdkPkg.optionalDependencies[dep] = opts.version;
|
||||
}
|
||||
await fs.writeFile(sdkPkgPath, JSON.stringify(sdkPkg, null, 2) + "\n");
|
||||
await $({ cwd: opts.root })`git add sdks/typescript/package.json`;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue