Repository navigation
chore: sync public mirror from internal #489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,8 +2,6 @@ | |
| // @ts-check | ||
|
|
||
| import { execFileSync } from "node:child_process"; | ||
| import { readFileSync } from "node:fs"; | ||
| import { join } from "node:path"; | ||
|
|
||
| export function getNpmCommand() { | ||
| return process.platform === "win32" ? "npm.cmd" : "npm"; | ||
|
|
@@ -11,115 +9,8 @@ | |
|
|
||
| export function getNpxCommand() { | ||
| return process.platform === "win32" ? "npx.cmd" : "npx"; | ||
| } | ||
|
Check failure on line 12 in scripts/install-smoke-utils.js
|
||
|
|
||
| export function getBunCommand() { | ||
| return process.platform === "win32" ? "bun.exe" : "bun"; | ||
| } | ||
|
|
||
| export function installedPackageJsonPath(packageName, installRoot) { | ||
| return join( | ||
| installRoot, | ||
| "node_modules", | ||
| ...packageName.split("/"), | ||
| "package.json", | ||
| ); | ||
| } | ||
|
|
||
| export function installedBinPath(installRoot, cliCommand) { | ||
| return process.platform === "win32" | ||
| ? join(installRoot, "node_modules", ".bin", `${cliCommand}.cmd`) | ||
| : join(installRoot, "node_modules", ".bin", cliCommand); | ||
| } | ||
|
|
||
| export function readInstalledPackageJson(packageName, installRoot) { | ||
| const packageJsonPath = installedPackageJsonPath(packageName, installRoot); | ||
| try { | ||
| const parsed = JSON.parse(readFileSync(packageJsonPath, "utf8")); | ||
| if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) { | ||
| throw new Error("installed package.json did not contain an object"); | ||
| } | ||
| return parsed; | ||
| } catch (error) { | ||
| const reason = | ||
| error instanceof Error ? error.message : "unknown package read error"; | ||
| throw new Error( | ||
| `Could not read installed package metadata at ${packageJsonPath}: ${reason}`, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| function arrayValues(value) { | ||
| return Array.isArray(value) | ||
| ? value.filter((entry) => typeof entry === "string" && entry.length > 0) | ||
| : []; | ||
| } | ||
|
|
||
| function objectEntries(value) { | ||
| return value && typeof value === "object" && !Array.isArray(value) | ||
| ? Object.entries(value) | ||
| : []; | ||
| } | ||
|
|
||
| export function assertInstallablePackageMetadata( | ||
| installedPackage, | ||
| { label, forbiddenWorkspaceNames = [] }, | ||
| ) { | ||
| const forbiddenNames = new Set(forbiddenWorkspaceNames); | ||
| const offenders = []; | ||
| for (const section of [ | ||
| "dependencies", | ||
| "optionalDependencies", | ||
| "peerDependencies", | ||
| ]) { | ||
| for (const [name, spec] of objectEntries(installedPackage[section])) { | ||
| if (forbiddenNames.has(name)) { | ||
| offenders.push(`${section}.${name}`); | ||
| } | ||
| if (typeof spec === "string" && spec.startsWith("workspace:")) { | ||
| offenders.push(`${section}.${name}=workspace:`); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| for (const section of ["bundleDependencies", "bundledDependencies"]) { | ||
| for (const name of arrayValues(installedPackage[section])) { | ||
| if (forbiddenNames.has(name)) { | ||
| offenders.push(`${section}.${name}`); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (offenders.length > 0) { | ||
| throw new Error( | ||
| `${label} exposes non-registry workspace metadata: ${offenders | ||
| .sort() | ||
| .join(", ")}`, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| export function runInstalledCliSmoke( | ||
| cwd, | ||
| { cliCommand, expectedVersion, label }, | ||
| ) { | ||
| const binPath = installedBinPath(cwd, cliCommand); | ||
| const versionOutput = execFileSync(binPath, ["--version"], { | ||
| cwd, | ||
| encoding: "utf8", | ||
| }); | ||
| if (!versionOutput.includes(expectedVersion)) { | ||
| throw new Error( | ||
| `Expected ${label} ${cliCommand} --version output to include ${expectedVersion}, received: ${versionOutput.trim()}`, | ||
| ); | ||
| } | ||
|
|
||
| execFileSync(binPath, ["--help"], { | ||
| cwd, | ||
| stdio: "ignore", | ||
| }); | ||
| } | ||
|
|
||
| function parseAuditJson(output) { | ||
| try { | ||
| return JSON.parse(output); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,9 +8,9 @@ | |
| const mode = process.argv[2] ?? "release"; | ||
| const rootPackage = loadRootPackage(); | ||
|
|
||
| function run(command, env = {}) { | ||
| function run(command) { | ||
| console.log(`$ ${command}`); | ||
| execSync(command, { stdio: "inherit", env: { ...process.env, ...env } }); | ||
| execSync(command, { stdio: "inherit" }); | ||
| } | ||
|
|
||
| function hasScript(name) { | ||
|
|
@@ -32,6 +32,12 @@ | |
| console.log("Skipping packed CLI smoke test (script missing)"); | ||
| return; | ||
| } | ||
| if (!shouldManagePackageLock(rootPackage)) { | ||
| console.log( | ||
| "Skipping packed CLI smoke test (package is not npm-installable from a tarball in this repo)", | ||
| ); | ||
| return; | ||
|
Check failure on line 39 in scripts/release-readiness.js
|
||
|
haasonsaas marked this conversation as resolved.
Resolved
|
||
| } | ||
|
|
||
| const tarball = execSync("npm pack --silent", { encoding: "utf8" }) | ||
| .trim() | ||
|
|
@@ -43,10 +49,7 @@ | |
| } | ||
|
|
||
| try { | ||
| run(`node scripts/smoke-packed-cli.js "${tarball}"`, { | ||
| MAESTRO_INSTALL_AUDIT_LEVEL: | ||
| process.env.MAESTRO_INSTALL_AUDIT_LEVEL ?? "critical", | ||
| }); | ||
| run(`node scripts/smoke-packed-cli.js "${tarball}"`); | ||
| } finally { | ||
| rmSync(resolve(process.cwd(), tarball), { force: true }); | ||
| } | ||
|
|
@@ -58,8 +61,6 @@ | |
| run("bun run bun:lint"); | ||
| run("npm run build"); | ||
| run("npm run verify:runtime-deps"); | ||
| runPackSmoke(); | ||
| maybeRunScript("smoke:exec-replay-e2e"); | ||
| maybeRunScript("openapi:check"); | ||
| } | ||
|
|
||
|
|
@@ -77,7 +78,6 @@ | |
| console.log("Skipping npm audit (package-lock not managed in this repo)"); | ||
| } | ||
| runPackSmoke(); | ||
| maybeRunScript("smoke:exec-replay-e2e"); | ||
| } | ||
|
|
||
| switch (mode) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.