Skip to content

Commit 2443bd0

Browse files
committed
Auto bump version
1 parent 7ed164e commit 2443bd0

5 files changed

Lines changed: 72 additions & 6 deletions

File tree

AGENTS.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ Tests use Jest with project separation for unit and wire suites. Test files foll
1818
## Commit and Pull Request Guidelines
1919
Recent history shows short, descriptive subjects without strict prefixes, so keep commit messages concise and clear about the change. For pull requests, include a summary, the test commands you ran, and any API surface changes. If you add or change a public method, update `README.md` usage examples.
2020

21-
## SDK Documentation Sync
22-
Whenever you change the SDK, update the website API documentation in `app/components/docs/` to match the new behavior. Before finishing any SDK update, use a sub agent to review and apply the documentation updates in `app/components/docs/`, and do not exit until that review is complete.
23-
Before finishing any SDK update, use a sub agent to review `README.md`, apply any updates needed to match the code, and do not exit until that review is complete.
21+
## Hosted Docs (Required)
22+
The public, hosted docs live under `app/pages/docs` (routes/pages) and `app/components/docs` (docs content/components). Any SDK behavior change MUST be reflected in these hosted docs before finishing. Use a subagent to perform the hosted docs updates and review; do not finish the task until the subagent reports back. If you only update SDK code without updating `app/pages/docs` + `app/components/docs`, the task is incomplete.
2423

2524
## Configuration Tips
2625
Set `DIFFIO_API_KEY` for authentication and `DIFFIO_API_BASE_URL` to target emulators or alternate environments. Use Node 18 or later so the built in `fetch` API is available.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Set the API key with `DIFFIO_API_KEY`. If you need to set the base URL explicitl
2121

2222
```bash
2323
export DIFFIO_API_KEY="diffio_live_..."
24-
export DIFFIO_API_BASE_URL="https://us-central1-diffioai.cloudfunctions.net/v1"
24+
export DIFFIO_API_BASE_URL="https://api.diffio.ai/v1"
2525
```
2626

2727
## Request options

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
],
1717
"scripts": {
1818
"build": "tsc -p tsconfig.json",
19-
"prepublishOnly": "npm run build",
19+
"prepublishOnly": "node scripts/bump-version.mjs && npm run build",
20+
"version:registry": "node scripts/bump-version.mjs",
2021
"test": "jest --config jest.config.mjs",
2122
"test:unit": "jest --selectProjects unit",
2223
"test:wire": "jest --selectProjects wire"

scripts/bump-version.mjs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env node
2+
import { execFileSync } from "node:child_process";
3+
import fs from "node:fs";
4+
import path from "node:path";
5+
import { fileURLToPath } from "node:url";
6+
7+
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
8+
const rootDir = path.resolve(scriptDir, "..");
9+
const pkgPath = path.join(rootDir, "package.json");
10+
const versionPath = path.join(rootDir, "src", "version.ts");
11+
12+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
13+
const bump = (process.argv[2] || process.env.BUMP || "patch").toLowerCase();
14+
if (!["major", "minor", "patch"].includes(bump)) {
15+
console.error("Usage: node scripts/bump-version.mjs [major|minor|patch]");
16+
process.exit(1);
17+
}
18+
19+
const run = (cmd, args, options = {}) =>
20+
execFileSync(cmd, args, { encoding: "utf8", ...options }).trim();
21+
22+
let registry = process.env.NPM_REGISTRY;
23+
if (!registry) {
24+
try {
25+
registry = run("npm", ["config", "get", "registry"]);
26+
} catch {
27+
registry = "https://registry.npmjs.org/";
28+
}
29+
}
30+
if (!registry || registry === "undefined" || registry === "null") {
31+
registry = "https://registry.npmjs.org/";
32+
}
33+
34+
let latest = "0.0.0";
35+
try {
36+
const out = run("npm", ["view", pkg.name, "version", "--json", "--registry", registry]);
37+
const parsed = JSON.parse(out);
38+
if (typeof parsed === "string") {
39+
latest = parsed;
40+
}
41+
} catch {
42+
console.warn(`No published version found for ${pkg.name}; starting from ${latest}.`);
43+
}
44+
45+
const parts = latest.split(".");
46+
if (parts.length !== 3 || parts.some((part) => !/^\d+$/.test(part))) {
47+
throw new Error(`Unsupported version format from registry: ${latest}`);
48+
}
49+
50+
let [major, minor, patch] = parts.map((part) => Number(part));
51+
if (bump === "major") {
52+
major += 1;
53+
minor = 0;
54+
patch = 0;
55+
} else if (bump === "minor") {
56+
minor += 1;
57+
patch = 0;
58+
} else {
59+
patch += 1;
60+
}
61+
62+
const next = `${major}.${minor}.${patch}`;
63+
run("npm", ["version", "--no-git-tag-version", next], { cwd: rootDir, stdio: "inherit" });
64+
fs.writeFileSync(versionPath, `export const DIFFIO_SDK_VERSION = "${next}";\n`, "utf8");
65+
66+
console.log(`Bumped ${pkg.name} from ${latest} to ${next} (registry: ${registry}).`);

src/Client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import type {
2929
import { AudioIsolationClient, GenerationsClient, ProjectsClient, WebhooksClient } from "./api/resources";
3030
import { lookup as lookupMimeType } from "mime-types";
3131

32-
const DEFAULT_BASE_URL = "https://us-central1-diffioai.cloudfunctions.net";
32+
const DEFAULT_BASE_URL = "https://api.diffio.ai";
3333
const API_PREFIX = "v1";
3434
const MODEL_ENDPOINTS: Record<string, string> = {
3535
"diffio-2": "diffio-2.0-generation",

0 commit comments

Comments
 (0)