Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"@toon-format/toon": "^1.0.0",
"@types/node": "^24.7.2",
"@types/object-hash": "^3.0.6",
"@types/semver": "^7.7.1",
"@types/turndown": "^5.0.5",
"agent-browser": "0.25.4",
"ajv": "^8.18.0",
Expand All @@ -57,12 +56,12 @@
"opencode-ai": "1.18.5",
"package-manager-detector": "^1.6.0",
"picocolors": "^1.1.1",
"semver": "^7.7.3",
"skills": "1.4.9",
"table": "^6.9.0",
"turndown": "^7.2.0",
"typescript": "^5.9.3",
"undici": "^7.22.0",
"verkit": "0.4.0",
"vitest": "^4.0.17",
"yaml": "^2.8.2"
},
Expand Down
66 changes: 30 additions & 36 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions utils/packageManager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { existsSync } from "node:fs";
import { mkdir, readFile } from "node:fs/promises";
import { delimiter, join } from "node:path";
import semver from "semver";
import { isValid, satisfies } from "verkit";
import { log } from "./cli.ts";
import { filterEnvForUntrustedCode } from "./secrets.ts";
import { spawn } from "./subprocess.ts";
Expand Down Expand Up @@ -57,7 +57,7 @@ function parsePackageManagerField(value: string): PackageManagerSpec | null {
return {
name,
version,
concrete: semver.valid(version) !== null,
concrete: isValid(version),
source: "packageManager",
};
}
Expand All @@ -74,7 +74,7 @@ function parseDevEnginesField(
return {
name: field.name,
version,
concrete: semver.valid(version) !== null,
concrete: isValid(version),
source: "devEngines",
};
}
Expand Down Expand Up @@ -127,7 +127,7 @@ export async function resolvePackageManagerSpec(cwd: string): Promise<PackageMan
return devSpec;
}

if (pmSpec.concrete && semver.satisfies(pmSpec.version, devSpec.version)) {
if (pmSpec.concrete && satisfies(pmSpec.version, devSpec.version)) {
return pmSpec;
}

Expand Down
4 changes: 2 additions & 2 deletions utils/version.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import semver from "semver";
import { isValid } from "verkit";
import packageJson from "../package.json" with { type: "json" };

export function getDevDependencyVersion(name: keyof typeof packageJson.devDependencies): string {
const version = packageJson.devDependencies[name];
if (!semver.valid(version)) {
if (!isValid(version)) {
throw new Error(`dev dependency "${name}" must be a pinned version, got "${version}"`);
}
return version;
Expand Down
12 changes: 8 additions & 4 deletions utils/versioning.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import semver from "semver";
import { findMinimumForRange, normalize, satisfies, tryParse } from "verkit";

type CompatibilityPolicy =
/**
Expand All @@ -16,14 +16,18 @@ type CompatibilityPolicy =

const COMPATIBILITY_POLICY: CompatibilityPolicy = "non-breaking";

function minVersion(range: string): string {
return normalize(findMinimumForRange(range)!)!;
}
Comment thread
pullfrog[bot] marked this conversation as resolved.

/**
* @throws Error if the action can't process payload
* The compatibility is determined according to the COMPATIBILITY_POLICY above.
* @param payloadVersion the version of the payload
* @param actionVersion the version of the action (recipient)
*/
export function validateCompatibility(payloadVersion: string, actionVersion: string): void {
const payloadSemVer = semver.parse(payloadVersion);
const payloadSemVer = tryParse(payloadVersion);
if (!payloadSemVer)
throw new Error(`Payload version ${payloadVersion} is not a valid semantic version.`);
const major = payloadSemVer.major;
Expand All @@ -35,10 +39,10 @@ export function validateCompatibility(payloadVersion: string, actionVersion: str
? `^${major}.${minor}.${major === 0 ? patch : 0}`
: `^${major}.${major === 0 ? minor : 0}.${major === 0 ? "x" : 0}`; // non-breaking

if (!semver.satisfies(actionVersion, compatibilityRange)) {
if (!satisfies(actionVersion, compatibilityRange)) {
throw new Error(
`Payload version ${payloadVersion} is incompatible with action version ${actionVersion}. ` +
`Please update your workflow to use at least ${semver.minVersion(compatibilityRange)} version of the action.`
`Please update your workflow to use at least ${minVersion(compatibilityRange)} version of the action.`
);
}
}
Loading