uptide 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/chunk-CXWIS6QF.js +337 -0
- package/dist/{chunk-VHIIYAJM.js → chunk-H55HNL33.js} +1 -1
- package/dist/chunk-HW7GXSSE.js +335 -0
- package/dist/{chunk-W74OVIU4.js → chunk-RPK3NKP7.js} +1 -1
- package/dist/engine-worker.js +1 -1
- package/dist/index.js +34 -15
- package/dist/{publish-4HTIOEBW-HI6XQ6IX.js → publish-X56BNLOQ-6J6EBNN4.js} +1 -1
- package/dist/worker.js +1 -1
- package/package.json +2 -1
- package/dist/chunk-2QJIOZA7.js +0 -329
- package/dist/chunk-AGUD7WFB.js +0 -273
|
@@ -3,7 +3,7 @@ import { fileURLToPath as __uptideFileURLToPath } from 'node:url';
|
|
|
3
3
|
const require = __uptideCreateRequire(import.meta.url);
|
|
4
4
|
const __filename = __uptideFileURLToPath(import.meta.url);
|
|
5
5
|
const __dirname = __uptideFileURLToPath(new URL('.', import.meta.url));
|
|
6
|
-
import{UPTIDE_COMMAND,UptideError,command,git,uptideVersionInfo}from"./chunk-
|
|
6
|
+
import{UPTIDE_COMMAND,UptideError,command,git,uptideVersionInfo}from"./chunk-RPK3NKP7.js";import{readFileSync}from"fs";var count=(n,one)=>`${n} ${one}${n===1?"":"s"}`;function publicationBlockers(report,tool=uptideVersionInfo()){let blockers=[],v=report.verification;if(report.verificationPending)blockers.push("verification has not run");else if(!v.passed){let failed=(v.tests??[]).filter(t=>t.status==="failed"||t.status==="timeout"),reasons=[...v.typesUnverified?[`types not verified (type resolution failed: ${v.typesUnverified})`]:[],...v.newErrors?.length?[count(v.newErrors.length,"new type error")]:[],...(v.lint??[]).filter(l=>l.status==="failed").map(l=>`lint (${l.tool}) fails on the edited files`),...failed.map(t=>`tests ${t.status==="timeout"?"timed out":"failed"} in ${t.workspace}`)];blockers.push(`verification failed${reasons.length?`: ${reasons.join(", ")}`:" (files were left uncommitted)"}`)}return report.sourceChanged?.length&&blockers.push(`your checkout changed during the run (${report.sourceChanged.join("; ")})`),(report.uptideDirty||tool.uptideDirty)&&blockers.push("Uptide ran from a checkout with uncommitted changes; rerun from a committed build so the run is reproducible"),blockers}var GITHUB_BODY_LIMIT=65536;function remoteBranchHead(cwd,branch,io){try{let line=io.git(cwd,"ls-remote","--heads","origin",`refs/heads/${branch}`);return/^([0-9a-f]{40})\s/.exec(line)?.[1]}catch{return}}var defaults={git,command,print:console.log};async function publishTarget(cwd,repo,io=defaults){let auth=await io.command(cwd,"gh",["auth","status"]);if(auth.code)throw new UptideError("PUBLICATION_REFUSED",`--pr needs GitHub CLI signed in: ${auth.output.trim().split(`
|
|
7
7
|
`).at(-1)??"gh auth status failed"}; run \`gh auth login\``);let remote=io.git(cwd,"remote","get-url","origin"),owner=/github\.com[:/]([^/]+)\/([^/\s]+?)(?:\.git)?$/.exec(remote)?.[1],scopes=/Token scopes: (.*)$/m.exec(auth.output)?.[1],lacksRepoScope=scopes!==void 0&&!/'repo'/.test(scopes),own;try{own=await viewRepository(cwd,remote,io)}catch(error){let message=error instanceof Error?error.message:String(error);throw new UptideError("PUBLICATION_REFUSED",[`--pr cannot reach ${remote} with the GitHub token: ${firstLine(message.replace(/^cannot resolve target repository: /,""))}`,"Likely causes, and what fixes each:",` the token lacks the \`repo\` scope${lacksRepoScope?` (it does: its scopes are ${scopes})`:""}: gh auth refresh -h github.com -s repo`,...owner?[` ${owner} enforces SSO and the token is not authorized for it: https://github.com/orgs/${owner}/sso`]:[]," the account has no access to the repository: ask for it, or run from a fork you own","Nothing was cloned or changed."].join(`
|
|
8
8
|
`))}if(own.viewerPermission&&!["WRITE","MAINTAIN","ADMIN"].includes(own.viewerPermission))throw new UptideError("PUBLICATION_REFUSED",[`--pr needs push access to ${own.nameWithOwner??remote}; this account has ${own.viewerPermission.toLowerCase()} access only.`,"What fixes it:"," ask for write access to the repository, or",` fork it and run from the fork (gh repo fork ${own.nameWithOwner??""} --clone), then \`${UPTIDE_COMMAND} pr --repo ${own.nameWithOwner??"<owner/name>"}\` opens the PR upstream`,...owner?[` if you do have write access through ${owner}, authorize the token for its SSO: https://github.com/orgs/${owner}/sso`]:[],`Nothing was cloned or changed. Without --pr the migration still runs, and \`${UPTIDE_COMMAND} pr\` publishes it later.`].join(`
|
|
9
9
|
`));let target=repo?await viewRepository(cwd,repo,io):own;if(!target.defaultBranchRef?.name||!target.nameWithOwner)throw new UptideError("PUBLICATION_REFUSED","target repository has no default branch");return{nameWithOwner:target.nameWithOwner,base:target.defaultBranchRef.name,...own.isFork&&own.parent?.nameWithOwner?{parent:own.parent.nameWithOwner}:{}}}async function viewRepository(cwd,target,io){let metadata=await io.command(cwd,"gh",["repo","view",target,"--json","defaultBranchRef,nameWithOwner,isFork,parent,viewerPermission"]);if(metadata.code)throw new Error(`cannot resolve target repository: ${metadata.output}`);let parsed=JSON.parse(metadata.output),parent=parsed.parent?parsed.parent.nameWithOwner??(parsed.parent.owner?.login&&parsed.parent.name?`${parsed.parent.owner.login}/${parsed.parent.name}`:void 0):void 0;return{...parsed,parent:parent?{nameWithOwner:parent}:null}}var firstLine=text=>text.trim().split(`
|