@r5n/sisyphus 0.4.7 → 0.4.8

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.
Files changed (2) hide show
  1. package/dist/cli.js +2 -2
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -87,7 +87,7 @@ ${e}`);return}await Bun.write(t,e),B(`${y.green("Sisyphus config updated!")}`)}f
87
87
  `).filter(Boolean).map((m)=>m.replace(".md",""))}catch(a){if(!n)await vo`mkdir -p ${e}`.quiet();return[]}}async function U({filter:n,single:o,includePrivate:r}={}){let i=process.cwd(),s=await Bun.file("package.json").json();if(o)return Oe(s);let t=s?.workspaces,e=Array.isArray(t)?t:t?.packages||[];if(e.length===0)throw Error(`Seems like package.json doesn't have \`workspaces\` field or it's empty. Are you sure you are in the root of the workspace? (cwd: ${i})
88
88
 
89
89
  If you want to run Sisyphus in single-mode/root package, use --single flag or set \`"single": true\` in .sisyphus/config.json.`);let{packages:a,privatePackageCount:c}=await Pe({cwd:i,includePrivate:r,workspaces:e}),u=Object.keys(a);return{packageNames:n?u.filter((m)=>m.includes(n)):u,packages:a,privatePackageCount:c}}async function Pe({workspaces:n,cwd:o,includePrivate:r}){let i={},s={},t=0;for(let e of n){let a=new Bun.Glob(`${e}/package.json`).scanSync({cwd:o});for(let c of a){let{name:u,version:m,private:g,dependencies:d={},devDependencies:w={}}=await Bun.file(c).json();if(g&&!r){jo.debug(`Skipping private package: ${u}`),t++;continue}let f=Object.entries({...d,...w}).map(([h,x])=>x.startsWith("workspace")?h:"").filter(Boolean);for(let h of f)if(s[h]||=[],!s[h].includes(u))s[h].push(u);i[u]={bump:"dependency",dependencyOf:[],file:c,name:u,version:m||"0.0.0"}}}for(let[e,a]of Object.entries(s))if(i[e])i[e].dependencyOf=a;return{packages:i,privatePackageCount:t}}function Oe({name:n,version:o}){return{packageNames:[n],packages:{[n]:{bump:"dependency",dependencyOf:[],file:"package.json",name:n,version:o||"0.0.0"}},privatePackageCount:0}}var jo,xr="***",qi=".",zi,ki=14,Ji="nightly",Rn,En;var G=A(()=>{N();_();Di();Mn();Ui();jo=C({prefix:"sisyphus"}).child("helpers"),zi=/[.ZT:-]/g,Rn=["dependency","patch","minor","major","snapshot"],En={dependency:"\uD83D\uDCE6",patch:"\uD83D\uDC1B",minor:"\u2728",major:"\uD83D\uDEA8",snapshot:"\uD83D\uDCF8"}});var ns={};Gn(ns,{validateGitWorkingDirectory:()=>Ve,validateGitRepository:()=>na,getCurrentGitCommit:()=>oa});var{$:Eo}=globalThis.Bun;async function Ve(){try{let{exitCode:n}=await Eo`git diff --quiet`.nothrow(),{exitCode:o}=await Eo`git diff --cached --quiet`.nothrow();if(n!==0||o!==0)throw new K("Git working directory has uncommitted changes. Please commit or stash your changes before running this command.","GIT_DIRTY_WORKING_DIR")}catch(n){if(n instanceof K)throw n;throw new K("Failed to validate git working directory. Are you in a git repository?","GIT_VALIDATION_FAILED")}}async function na(){try{await Eo`git rev-parse --git-dir`.quiet()}catch{throw new K("Not a git repository. Please initialize git repository first with 'git init'.","NOT_GIT_REPO")}}async function oa(){try{let o=(await Eo`git rev-parse HEAD`.quiet()).stdout.toString().trim();if(!o)throw new K("Could not get current git commit","GIT_NO_COMMIT");return o}catch(n){if(n instanceof K)throw n;throw new K("Failed to get current git commit","GIT_COMMIT_FAILED")}}var os=A(()=>{L()});var is={};Gn(is,{updateLockfile:()=>ia,detectPackageManager:()=>rs});import{existsSync as Co}from"fs";var{$:ra}=globalThis.Bun;async function rs(n=process.cwd()){if(Co(`${n}/bun.lock`))return"bun";if(Co(`${n}/pnpm-lock.yaml`))return"pnpm";if(Co(`${n}/yarn.lock`))return"yarn";if(Co(`${n}/package-lock.json`))return"npm";return null}async function ia(n={}){let{cwd:o=process.cwd(),dryRun:r=!1}=n,i=await rs(o);if(!i){Fn.warn("No lockfile detected, skipping lockfile update");return}if(r){Fn.info(`[dry-run] Would run: ${i} install`);return}Fn.info(`Updating lockfile with ${i}...`);try{await ra`${i} install`.cwd(o).quiet(),Fn.info("Lockfile updated successfully")}catch(s){throw Fn.error(`Failed to update lockfile: ${s instanceof Error?s.message:String(s)}`),s}}var Fn;var ss=A(()=>{_();Fn=C({prefix:"lockfile-updater"})});var es={};Gn(es,{createStoneParser:()=>pa,StoneParseError:()=>Z});function ta(n,o){let r=o[0];if(!r)throw new Z("Stone file is empty",n);let i=r.replace(/^#+\s*/,"").trim();if(!i)throw new Z("Stone message cannot be empty",n);return i}function ea(n){let o=n.find((r)=>r.trim().startsWith("_")&&r.trim().endsWith("_"));return o?o.replace(/_/g,"").trim():void 0}function ts(n){return n.split("|").map((o)=>o.trim()).filter(Boolean)}function aa(n,o){let r=n.toLowerCase().trim(),i={dependency:"dependency",major:"major",minor:"minor",patch:"patch",snapshot:"snapshot"},s=i[r];if(!s)throw new Z(`Invalid bump type "${n}". Must be one of: ${Object.keys(i).join(", ")}`,o);return s}function ca(n,o,r){let i=o.findIndex((u)=>{let m=u.trim();return m.includes("|")&&/:\s*-+\s*:/.test(m)});if(i===-1)throw new Z("Missing table separator (e.g., | :---: |)",n);let s=o[i-1],t=o[i+1];if(!s)throw new Z("Missing table header line",n);if(!t)throw new Z("Missing table data line",n);let e=ts(s),a=ts(t);if(e.length===0)throw new Z("Table header is empty",n);if(e.length!==a.length)throw new Z(`Table column mismatch: ${e.length} headers, ${a.length} data cells`,n);let c=[];for(let u=0;u<e.length;u++){let m=aa(e[u]||"",n),g=a[u]||"";if(!g)continue;let d=g.split(",").map((w)=>w.trim()).filter(Boolean);for(let w of d){let p=r[w];if(!p){sa.warn(`Package "${w}" in stone "${n}" not found in workspace, skipping`);continue}c.push({...p,bump:m})}}if(c.length===0)throw new Z("No valid packages found in stone",n);return c}function ua(n,o,r){let i=o.split(`
90
- `),s=ta(n,i),t=ea(i),e=ca(n,i,r);return{message:s,name:n,packages:e,tag:t}}function pa(n){return async(o,r)=>{let i=`${n}/${o}.md`;try{let s=await Bun.file(i).text();return ua(o,s,r)}catch(s){if(s instanceof Z)throw s;throw new Z("Could not read stone file",o,s)}}}var sa,Z;var as=A(()=>{_();sa=C({prefix:"stone-parser"});Z=class Z extends Error{stoneName;cause;constructor(n,o,r){super(`Failed to parse stone "${o}": ${n}`);this.stoneName=o;this.cause=r;this.name="StoneParseError"}}});var cs={};Gn(cs,{createFileTransaction:()=>la});function la(){let n={changes:new Map,committed:!1};return{clear:()=>{if(n.committed)throw Error("Cannot clear committed transaction");n.changes.clear()},commit:async()=>{if(n.committed)throw Error("Transaction already committed");if(n.changes.size===0){dn.info("No changes to commit"),n.committed=!0;return}dn.info(`Committing ${n.changes.size} file changes`);let e=new Map;try{for(let[a]of n.changes)try{let c=await Bun.file(a).text();e.set(a,c)}catch{dn.debug(`File ${a} does not exist, creating new file`)}for(let a of n.changes.values())await Bun.write(a.path,a.content),dn.debug(`Wrote ${a.path}`);n.committed=!0,dn.info("Transaction committed successfully")}catch(a){dn.error("Transaction failed, attempting rollback");for(let[c,u]of e)try{await Bun.write(c,u),dn.debug(`Restored ${c} from backup`)}catch(m){dn.error(`Failed to restore ${c}: ${m}`)}throw Error(`Transaction failed: ${a instanceof Error?a.message:String(a)}`)}},getQueuedChanges:()=>{return Array.from(n.changes.entries()).map(([e,a])=>({content:a.content,path:e}))},hasChanges:()=>{return n.changes.size>0},queue:(e,a)=>{if(n.committed)throw Error("Cannot queue changes after transaction is committed");n.changes.set(e,{content:a,path:e})}}}var dn;var us=A(()=>{_();dn=C({prefix:"file-transaction"})});L();_();var vn="0.4.7";L();L();var Li=hi({errorPrefix:"\u2717"});N();L();_();G();import{parseArgs as _e}from"util";var Wi=C({prefix:"changeset"}),Yi=".changesets";async function Fi(){let n=await Ge();un("\uD83D\uDE80 Create a new changeset");try{let{packages:o,packageNames:r}=await U({includePrivate:!1});if(r.length===0)throw new K("No public packages found","NO_PUBLIC_PACKAGES");let i=r.map((t)=>({name:t,version:o[t]?.version||"0.0.0"})),s=await Te(i,n.all);if(s.changes.length===0){q("\u274C No packages selected");return}if(n.dryRun){Me(s),q("\u2728 Dry run complete - no files created");return}await Le(s),q("\u2728 Changeset created successfully!")}catch(o){throw Wi.error("Failed to create changeset:",o),o}}async function Te(n,o){let r=await Be(n,o);if(r.length===0)return{changes:[],summary:""};let i=[];for(let a of r){let c=await Ae(a);if(c)i.push({packageName:a.name,versionType:c})}let s=await J({message:"Write a summary for this change",placeholder:"Fixed critical bug in authentication flow",validate:(a)=>{if(!a||a.trim().length===0)return"Summary is required";if(a.length>100)return"Summary should be less than 100 characters";return}});if(typeof s==="symbol")throw new K("Changeset creation cancelled","CANCELLED");let t=await D({initialValue:!1,message:"Do you want to add a longer description?"}),e;if(t){let a=await J({message:"Write a detailed description (optional)",placeholder:"This change fixes the issue where users could not..."});if(typeof a!=="symbol"&&a.trim().length>0)e=a}return{changes:i,description:e,summary:s}}async function Be(n,o){if(o)return n;let r=n.map((s)=>({hint:s.version,label:s.name,value:s})),i=await $n({message:"Which packages have changed?",options:r,required:!1});if(typeof i==="symbol")throw new K("Package selection cancelled","CANCELLED");return i}async function Ae(n){let o=await nn({message:`How should ${n.name} be updated?`,options:[{hint:"Bug fixes and small changes",label:"Patch",value:"patch"},{hint:"New features, backwards compatible",label:"Minor",value:"minor"},{hint:"Breaking changes",label:"Major",value:"major"},{hint:"Don't update this package",label:"Skip",value:"skip"}]});if(typeof o==="symbol")throw new K("Version selection cancelled","CANCELLED");return o==="skip"?null:o}function Me(n){if(console.log(`
90
+ `),s=ta(n,i),t=ea(i),e=ca(n,i,r);return{message:s,name:n,packages:e,tag:t}}function pa(n){return async(o,r)=>{let i=`${n}/${o}.md`;try{let s=await Bun.file(i).text();return ua(o,s,r)}catch(s){if(s instanceof Z)throw s;throw new Z("Could not read stone file",o,s)}}}var sa,Z;var as=A(()=>{_();sa=C({prefix:"stone-parser"});Z=class Z extends Error{stoneName;cause;constructor(n,o,r){super(`Failed to parse stone "${o}": ${n}`);this.stoneName=o;this.cause=r;this.name="StoneParseError"}}});var cs={};Gn(cs,{createFileTransaction:()=>la});function la(){let n={changes:new Map,committed:!1};return{clear:()=>{if(n.committed)throw Error("Cannot clear committed transaction");n.changes.clear()},commit:async()=>{if(n.committed)throw Error("Transaction already committed");if(n.changes.size===0){dn.info("No changes to commit"),n.committed=!0;return}dn.info(`Committing ${n.changes.size} file changes`);let e=new Map;try{for(let[a]of n.changes)try{let c=await Bun.file(a).text();e.set(a,c)}catch{dn.debug(`File ${a} does not exist, creating new file`)}for(let a of n.changes.values())await Bun.write(a.path,a.content),dn.debug(`Wrote ${a.path}`);n.committed=!0,dn.info("Transaction committed successfully")}catch(a){dn.error("Transaction failed, attempting rollback");for(let[c,u]of e)try{await Bun.write(c,u),dn.debug(`Restored ${c} from backup`)}catch(m){dn.error(`Failed to restore ${c}: ${m}`)}throw Error(`Transaction failed: ${a instanceof Error?a.message:String(a)}`)}},getQueuedChanges:()=>{return Array.from(n.changes.entries()).map(([e,a])=>({content:a.content,path:e}))},hasChanges:()=>{return n.changes.size>0},queue:(e,a)=>{if(n.committed)throw Error("Cannot queue changes after transaction is committed");n.changes.set(e,{content:a,path:e})}}}var dn;var us=A(()=>{_();dn=C({prefix:"file-transaction"})});L();_();var vn="0.4.8";L();L();var Li=hi({errorPrefix:"\u2717"});N();L();_();G();import{parseArgs as _e}from"util";var Wi=C({prefix:"changeset"}),Yi=".changesets";async function Fi(){let n=await Ge();un("\uD83D\uDE80 Create a new changeset");try{let{packages:o,packageNames:r}=await U({includePrivate:!1});if(r.length===0)throw new K("No public packages found","NO_PUBLIC_PACKAGES");let i=r.map((t)=>({name:t,version:o[t]?.version||"0.0.0"})),s=await Te(i,n.all);if(s.changes.length===0){q("\u274C No packages selected");return}if(n.dryRun){Me(s),q("\u2728 Dry run complete - no files created");return}await Le(s),q("\u2728 Changeset created successfully!")}catch(o){throw Wi.error("Failed to create changeset:",o),o}}async function Te(n,o){let r=await Be(n,o);if(r.length===0)return{changes:[],summary:""};let i=[];for(let a of r){let c=await Ae(a);if(c)i.push({packageName:a.name,versionType:c})}let s=await J({message:"Write a summary for this change",placeholder:"Fixed critical bug in authentication flow",validate:(a)=>{if(!a||a.trim().length===0)return"Summary is required";if(a.length>100)return"Summary should be less than 100 characters";return}});if(typeof s==="symbol")throw new K("Changeset creation cancelled","CANCELLED");let t=await D({initialValue:!1,message:"Do you want to add a longer description?"}),e;if(t){let a=await J({message:"Write a detailed description (optional)",placeholder:"This change fixes the issue where users could not..."});if(typeof a!=="symbol"&&a.trim().length>0)e=a}return{changes:i,description:e,summary:s}}async function Be(n,o){if(o)return n;let r=n.map((s)=>({hint:s.version,label:s.name,value:s})),i=await $n({message:"Which packages have changed?",options:r,required:!1});if(typeof i==="symbol")throw new K("Package selection cancelled","CANCELLED");return i}async function Ae(n){let o=await nn({message:`How should ${n.name} be updated?`,options:[{hint:"Bug fixes and small changes",label:"Patch",value:"patch"},{hint:"New features, backwards compatible",label:"Minor",value:"minor"},{hint:"Breaking changes",label:"Major",value:"major"},{hint:"Don't update this package",label:"Skip",value:"skip"}]});if(typeof o==="symbol")throw new K("Version selection cancelled","CANCELLED");return o==="skip"?null:o}function Me(n){if(console.log(`
91
91
  \uD83D\uDCC4 Changeset Preview:`),console.log("\u2500".repeat(50)),console.log(`Summary: ${n.summary}`),n.description)console.log(`
92
92
  Description:
93
93
  ${n.description}`);console.log(`
@@ -116,7 +116,7 @@ ${t instanceof Error?t.message:t}`),B(y.reset(y.bold(y.redBright("Failed to crea
116
116
  ${i}`,name:`Release ${o}`,tag:o,token:n}),B(y.green(`\u2713 Created GitHub root release ${o}`))}N();L();_();G();var{$:Fe}=globalThis.Bun;async function Vi({packages:n,dryRun:o,npmToken:r}){let i=r||process.env.NPM_CONFIG_TOKEN||process.env.NPM_TOKEN;if(!(i||o))return B(y.reset(y.bold(`${y.redBright("No NPM token found.")}
117
117
  Please provide one by using ${y.cyanBright("--npmToken")} flag or by setting one of ${y.green("NPM_CONFIG_TOKEN")} or ${y.green("NPM_TOKEN")} environment variables.`)));await Ke({dryRun:o,packages:n,token:i})}async function Ke({packages:n,dryRun:o,token:r}){let i=await Xe();for(let{name:s,version:t,tag:e,file:a}of Object.values(n)){let c=Sn();c.start(`${o?y.yellow("[dry-run]: Test "):""}Publishing ${y.magenta(s)}@${y.cyanBright(t)}...`),await Ze({cwd:a.replace("package.json","")});let u=await(async()=>{try{let m=Qe({dryRun:o,otp:i,tag:e});return await Ri(async()=>{let{stdout:g,exitCode:d}=Bun.spawnSync(m,{cwd:a.replace("package.json",""),env:{...process.env,NPM_CONFIG_TOKEN:r,NPM_TOKEN:r},stderr:"inherit"});if(d!==0)throw Error(`npm publish failed with exit code ${d}`);return g},{onRetry:(g,d)=>{c.stop(),c.start(`${o?y.yellow("[dry-run]: Test "):""}Retrying publish ${y.magenta(s)}@${y.cyanBright(t)} (attempt ${g})...`)}}),`${y.green("Successfully published")} ${y.magenta(s)}@${y.cyanBright(t)}`}catch(m){return $.error(m instanceof Error?m.message:String(m)),`${y.bold(`${y.redBright("Failed")} ${y.magenta(s)}@${y.cyanBright(t)}`)}`}})();c.stop(`${o?y.yellow("[dry-run]: Test "):""}${u}`)}}async function Xe(){if(!$r())return"";let n=await J({message:"Provide your NPM one-time password"});return sn(n)?"":n}async function Ze({cwd:n}){try{let o=await Fe`cd ${n} && bun run build`.quiet();if(o.exitCode!==0)throw Error(`Build failed with exit code ${o.exitCode}`)}catch(o){try{if(!(await Bun.file(`${n}/package.json`).json()).scripts?.build)return}catch{}$.warn(`${o instanceof Error?o.message:String(o)}:
118
118
  Error during build step. If you don't have a build step, you can ignore this message.`)}}function Qe({dryRun:n,tag:o,otp:r}){return["npm","publish","--access","public"].concat(o?["--tag",o]:[]).concat(n?["--dry-run"]:[]).concat(r?["--otp",r]:[])}var cn=C({prefix:"sisyphus"}).child("roll");function ma(){let{values:n}=fa({allowPositionals:!0,args:Bun.argv,options:{changelog:{short:"c",type:"boolean"},changelogRoot:{short:"r",type:"boolean"},"dry-run":{default:!1,short:"d",type:"boolean"},github:{short:"g",type:"boolean"},githubToken:{type:"string"},npm:{short:"n",type:"boolean"},npmToken:{type:"string"},rootTag:{type:"string"},withTags:{short:"t",type:"boolean"}},strict:!0});return{changelog:n.changelog,changelogRoot:n.changelogRoot,dryRun:n["dry-run"],github:n.github,githubToken:n.githubToken,npm:n.npm,npmToken:n.npmToken,rootTag:n.rootTag,withTags:n.withTags}}async function ps(){let{validateGitWorkingDirectory:n}=await Promise.resolve().then(() => (os(),ns));await n();let o=ma(),{dryRun:r,changelog:i,changelogRoot:s,github:t,githubToken:e,npm:a,npmToken:c,rootTag:u,withTags:m}=o,g=await O(),d=Bun.spawnSync(["git","rev-parse","HEAD"]).stdout.toString().trim(),w=await(async()=>{try{return await Kn()}catch{return[]}})();if(w.length===0)return B(y.reset(y.bold(`${y.redBright("No stones found.")}
119
- ${y.reset(`Run ${y.green("bunx @r5n/sisyphus")}${y.yellow(" version")} and create some first.`)}`)));if(typeof i==="boolean"?i:g.changelog?.generate)await Xi({changelogRoot:typeof s==="boolean"?s:g.changelog?.root,commit:d,dryRun:r,stones:w});let p=await ga({dryRun:r,stones:w});if(!r){let{updateLockfile:S}=await Promise.resolve().then(() => (ss(),is));await S({dryRun:r})}if(typeof a==="boolean"?a:g.release?.npm)await Vi({dryRun:r,npmToken:c,packages:p});let f=new Date().toISOString().split(".")[0]||"";await Qi({dryRun:r,github:typeof t==="boolean"?t:g.release?.github,githubToken:e,packages:p,rootTag:u,withTags:typeof m==="boolean"?m:g.release?.tags});let h={commit:d,date:f},x=await O();if(x.lastStone.commit===d&&x.stones.length===0){cn.warn("This commit has already been released. Skipping duplicate release.");return}if(await vr({dryRun:r,lastStone:h,stones:[]}),!r)await Y`rm -rf .sisyphus/stones`.quiet();if(g.release?.commitAndPush){let S=Object.values(p).map((z)=>`${z.name}@${z.version}`).join(", "),I=g.commit?.message?g.commit.message.replace("{message}",S):`release(\uD83C\uDF89): ${S}`,{exitCode:j,stdout:R}=await Y`git config --local user.name`.nothrow().quiet(),{exitCode:P,stdout:v}=await Y`git config --local user.email`.nothrow().quiet(),E=j===0?R.toString().trim():"",H=P===0?v.toString().trim():"";try{await Y`bun lint`.quiet()}catch(z){cn.warn("Linting failed, continuing with commit")}try{await Y`git config --local user.name "Sisyphus"`,await Y`git config --local user.email "1390689+r5n-sisyphus@users.noreply.github.com"`;let{exitCode:z}=await Y`git diff --quiet`.nothrow(),{exitCode:W}=await Y`git diff --cached --quiet`.nothrow(),{stdout:On}=await Y`git ls-files --others --exclude-standard`.nothrow();if(z!==0||W!==0||On.toString().trim()){await Y`git add -A`,await Y`git commit -m "${I}"`;let{exitCode:k}=await Y`git push`.nothrow();if(k!==0)cn.warn("Failed to push changes. This might be due to branch protection or lack of push permissions."),cn.info("The release was successful, but changes were not pushed to the repository.")}else cn.info("No changes to commit after release")}catch(z){cn.error(`Failed during git operations: ${z}`)}finally{try{if(E)await Y`git config --local user.name "${E}"`;else await Y`git config --local --unset user.name`.nothrow();if(H)await Y`git config --local user.email "${H}"`;else await Y`git config --local --unset user.email`.nothrow()}catch{}}}}async function Kn({dryRun:n,silent:o,configPath:r,testModeEnabled:i}={}){let s=i,t=await on({configPath:r,dryRun:n,silent:o}),{packages:e}=await U({single:s}),a=r||".sisyphus";if(s&&t.length===0&&r)try{let g=`${r}/stones`,w=(await Y`ls ${g} 2>/dev/null || true`.quiet()).stdout.toString().trim(),p=w?w.split(`
119
+ ${y.reset(`Run ${y.green("bunx @r5n/sisyphus")}${y.yellow(" version")} and create some first.`)}`)));if(typeof i==="boolean"?i:g.changelog?.generate)await Xi({changelogRoot:typeof s==="boolean"?s:g.changelog?.root,commit:d,dryRun:r,stones:w});let p=await ga({dryRun:r,stones:w});if(!r){let{updateLockfile:S}=await Promise.resolve().then(() => (ss(),is));await S({dryRun:r})}if(typeof a==="boolean"?a:g.release?.npm)await Vi({dryRun:r,npmToken:c,packages:p});let f=new Date().toISOString().split(".")[0]||"";await Qi({dryRun:r,github:typeof t==="boolean"?t:g.release?.github,githubToken:e,packages:p,rootTag:u,withTags:typeof m==="boolean"?m:g.release?.tags});let h={commit:d,date:f},x=await O();if(x.lastStone.commit===d&&x.stones.length===0){cn.warn("This commit has already been released. Skipping duplicate release.");return}if(await vr({dryRun:r,lastStone:h,stones:[]}),!r)await Y`rm -rf .sisyphus/stones`.quiet();if(g.release?.commitAndPush){let S=Object.values(p).map((z)=>`${z.name}@${z.version}`).join(", "),I=g.commit?.message?g.commit.message.replace("{message}",S):`release(\uD83C\uDF89): ${S}`,{exitCode:j,stdout:R}=await Y`git config --local user.name`.nothrow().quiet(),{exitCode:P,stdout:v}=await Y`git config --local user.email`.nothrow().quiet(),E=j===0?R.toString().trim():"",H=P===0?v.toString().trim():"";try{await Y`bun lint`.quiet()}catch(z){cn.warn("Linting failed, continuing with commit")}try{await Y`git config --local user.name "r5n[bot]"`,await Y`git config --local user.email "237849083+r5n-bot@users.noreply.github.com"`;let{exitCode:z}=await Y`git diff --quiet`.nothrow(),{exitCode:W}=await Y`git diff --cached --quiet`.nothrow(),{stdout:On}=await Y`git ls-files --others --exclude-standard`.nothrow();if(z!==0||W!==0||On.toString().trim()){await Y`git add -A`,await Y`git commit -m "${I}"`;let{exitCode:k}=await Y`git push`.nothrow();if(k!==0)cn.warn("Failed to push changes. This might be due to branch protection or lack of push permissions."),cn.info("The release was successful, but changes were not pushed to the repository.")}else cn.info("No changes to commit after release")}catch(z){cn.error(`Failed during git operations: ${z}`)}finally{try{if(E)await Y`git config --local user.name "${E}"`;else await Y`git config --local --unset user.name`.nothrow();if(H)await Y`git config --local user.email "${H}"`;else await Y`git config --local --unset user.email`.nothrow()}catch{}}}}async function Kn({dryRun:n,silent:o,configPath:r,testModeEnabled:i}={}){let s=i,t=await on({configPath:r,dryRun:n,silent:o}),{packages:e}=await U({single:s}),a=r||".sisyphus";if(s&&t.length===0&&r)try{let g=`${r}/stones`,w=(await Y`ls ${g} 2>/dev/null || true`.quiet()).stdout.toString().trim(),p=w?w.split(`
120
120
  `).filter(Boolean).map((f)=>f.replace(".md","")):[];if(p.length>0)return cn.info(`Found ${p.length} stones in test environment`),[{message:"Test stone config",name:p[0],packages:[{bump:"major",file:`${r}/workspace/packages/test-pkg/package.json`,name:"@test/pkg",version:"1.0.0"}],tag:"latest"}]}catch(g){cn.error(`Test directory read error: ${g}`)}let{createStoneParser:c}=await Promise.resolve().then(() => (as(),es)),u=c(`${a}/stones`),m=[];for(let g of t)try{let d=await u(g,e);m.push({message:d.message,name:d.name,packages:d.packages,tag:d.tag})}catch(d){cn.error(`Error processing stone ${g}
121
121
  ${d instanceof Error?d.message:String(d)}`)}return m}async function ga({stones:n,dryRun:o=!1}){let r=[],i={};for(let{tag:t,packages:e,message:a}of n){r.push(a);for(let c of e){i[c.name]||=c;let u=i[c.name]||c;if(t)u.tag=t;u.bump=Rn.indexOf(c.bump)>Rn.indexOf(u.bump)?c.bump:u.bump,i[c.name]=u}}let s=Object.values(i).reduce((t,e)=>{return t[e.name]={...e,version:e.tag?X({tag:e.tag,version:X({bump:e.bump,version:e.version})}):X({bump:e.bump,version:e.version})},t},{});if(o)cn.info(`${y.bold(y.yellow("[dry-run]"))}
122
122
  Config for next release:
package/package.json CHANGED
@@ -37,5 +37,5 @@
37
37
  },
38
38
  "type": "module",
39
39
  "types": "src/cli.ts",
40
- "version": "0.4.7"
40
+ "version": "0.4.8"
41
41
  }