@r5n/sisyphus 0.3.1 → 0.3.3

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 (3) hide show
  1. package/README.md +15 -0
  2. package/package.json +5 -5
  3. package/dist/cli.js +0 -30
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # Sisyphus
2
+
3
+ Sisyphus is a CLI tool for versioning and publishing of packages with a focus on automation and ease of use.
4
+
5
+ ## Initialization
6
+
7
+ ```bash
8
+ bunx @r5n/sisyphus init
9
+ ```
10
+
11
+ This will create a `.sisyphus/config.json` file in the root of your project which stores configuration for every command run and data required for next release.
12
+
13
+ ### Commands
14
+
15
+
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "bin": "dist/cli.js",
4
4
  "dependencies": {
5
5
  "@clack/prompts": "0.7.0",
6
- "picocolors": "1.1.0"
6
+ "picocolors": "1.1.1"
7
7
  },
8
8
  "description": "Sisyphus CLI",
9
9
  "files": [
@@ -26,11 +26,11 @@
26
26
  "clean": "rm -rf ./dist ./node_modules",
27
27
  "dev": "bun run --bun ./cli.ts",
28
28
  "lint": "biome check --write",
29
- "package:publish": "npm publish",
30
- "package:dryRun": "npm publish --dry-run",
31
- "type-check": "bun tsc --noEmit"
29
+ "package:publish": "NODE_ENV=production bun build; bun publish --access public",
30
+ "package:dryRun": "bun publish --dry-run",
31
+ "type-check": "bun --bun tsc --noEmit"
32
32
  },
33
33
  "type": "module",
34
34
  "types": "./cli.ts",
35
- "version": "0.3.1"
35
+ "version": "0.3.3"
36
36
  }
package/dist/cli.js DELETED
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env bun
2
- // @bun
3
- import{note as at}from"@clack/prompts";import{bold as W,green as q,italic as it,reset as rt}from"picocolors";import{mkdirSync as ee,readdirSync as Be,rmdirSync as Ie}from"fs";import{cancel as Re,note as Ue}from"@clack/prompts";import{bold as te,green as se,italic as oe,yellow as ne}from"picocolors";function j(e){if(typeof e==="function")e();else Re(e||"Operation cancelled by user");process.exit(0)}async function v({overwrite:e,tag:t,dryRun:a,...s}={}){const i=await Bun.file("./.sisyphus/config.json").exists(),r=i&&e,l=Bun.spawnSync(["git","rev-parse","HEAD"]).stdout.toString().trim();if(l.length===0)throw new Error("Couldn't find git repository. Have you initialized git repository?");const n={$schema:"https://raw.githubusercontent.com/r5n-labs/ts-packages/refs/heads/develop/packages/cli/sisyphus/schema.json",tag:t||"latest",lastStone:{commit:l,date:new Date().toISOString().split(".")[0]||""},ignore:[],stones:[],...s},c=`${JSON.stringify(n,null,2)}\n`;if(a)return console.info(`${te(ne("[dry-run]"))}\n${oe(".sisyphus/config.json")}:\n${c}`),n;if(r)try{Ie(".sisyphus",{recursive:!0})}catch{}if(!i)ee(".sisyphus"),await Bun.write(".sisyphus/config.json",c);return Bun.file(".sisyphus/config.json").json()}async function ae({dryRun:e,...t}){const a=await v(),s=`${JSON.stringify({...a,...t},null,2)}\n`;if(e)console.info(`${te(ne("[dry-run]"))}\n${oe(".sisyphus/config.json")} would be updated to\n${s}`);else await Bun.write(".sisyphus/config.json",s),Ue(`${se("Sisyphus config updated!")}`)}function O({name:e,version:t,bump:a,tag:s}){return`${e}@${t} => ${se(P({version:t,bump:a,tag:s}))} ${G[a]}`}function P({version:e="",bump:t,tag:a}){const[s="0.0.0",o=""]=e.split("-"),[i="0",r="0",l="0"]=s.split("."),[n="",c="0"]=o.split(".");if(t==="snapshot"){const u=new Date().toISOString().replaceAll(/[.ZT:-]/g,"").slice(0,14);return`0.0.0-${a||"nightly"}-${u}`}if(a||t==="dependency"&&n){const u=a===n||!n?Number.parseInt(c)+1:0;return`${s}-${a||n}.${u}`}const m=t==="major"?`${i}.0.0`:t==="minor"?`${i}.${r}.0`:`${i}.${r}.${l}`;if(n&&s===m)return m;switch(t){case"major":return`${Number.parseInt(i)+1}.0.0`;case"minor":return`${i}.${Number.parseInt(r)+1}.0`;case"patch":return`${i}.${r}.${Number.parseInt(l)+1}`;default:return e}}function B({dryRun:e}={}){try{return Be(".sisyphus/stones").map((t)=>t.replace(".md",""))}catch{if(!e)ee(".sisyphus/stones");return[]}}async function C({filter:e,single:t}={}){const a=process.cwd(),s={};let o=[];const i=await Bun.file("package.json").json();if(t)return Ye(i);try{o=i?.workspaces||[]}catch(n){throw new Error("Couldn't find package.json for this project.",{cause:n})}if(o.length===0)throw new 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: ${a})\n
4
- If you want to run Sisyphus in single-mode/root package, use --single flag or set \`"single": true\` in .sisyphus/config.json.`);const r={};for(let n of o){const c=new Bun.Glob(`${n}/package.json`).scanSync({cwd:a});for(let m of c){const{name:u,version:p,dependencies:$,devDependencies:h}=await Bun.file(m).json(),b=Object.entries({...$??{},...h??{}}).map(([w,He])=>He.startsWith("workspace")?w:"").filter(Boolean);for(let w of b)if(r[w]||=[],!r[w].includes(u))r[w].push(u);s[u]={bump:"dependency",name:u,version:p,file:m,dependencyOf:[]}}}for(let[n,c]of Object.entries(r))if(s[n])s[n].dependencyOf=c;const l=Object.keys(s);return{packages:s,packageNames:e?l.filter((n)=>n.includes(e)):l}}function Ye({name:e,version:t}){const a={bump:"dependency",dependencyOf:[],file:"package.json",name:e,version:t||"0.0.0"};return{packageNames:[e],packages:{[e]:a}}}var N="***",E=["dependency","patch","minor","major","snapshot"],G={dependency:"\uD83D\uDCE6",patch:"\uD83D\uDC1B",minor:"\u2728",major:"\uD83D\uDEA8",snapshot:"\uD83D\uDCF8"};import{rmSync as Ze}from"fs";import{parseArgs as Te}from"util";import{note as et}from"@clack/prompts";import{bold as be,green as tt,redBright as st,reset as $e,yellow as de}from"picocolors";import{bold as ie,yellow as re}from"picocolors";async function ce({changelogRoot:e,commit:t,dryRun:a=!1,stones:s}){const o=[""],{lastStone:{commit:i=""}}=await v(),r=Fe({stones:s});for(let[l,{bump:n,path:c,changelog:m}]of r.entries()){const u=[...m,le({lastCommit:i,commit:t})],p=await Bun.file(c).exists(),[$,...h]=p?(await Bun.file(c).text()).split("\n"):[`# ${l}`],g=[$,...u,...h];if(a)console.info(`${ie(re("[dry-run]"))}\n${g.join("\n")}`);else await Bun.write(c,`${g.join("\n").trimEnd()}\n`);const[b="",,,w=""]=m;if(!o.includes(w))o.unshift(w);o.push(`### ${G[n]} ${l}@${b.slice(7)}`)}if(e){const l=Bun.file("CHANGELOG.md"),n=await l.exists(),[c,...m]=n?(await l.text()).split("\n"):["# Changelog"],u=[c,"",...o,...m,le({root:!0,lastCommit:i,commit:t}),N];if(a)console.info(`${ie(re("[dry-run]"))}\nRoot changelog:\n${u.join("\n")}`);else await Bun.write(l,u.join("\n"))}}function Fe({stones:e}){const t=new Map;for(let{tag:a,packages:s,message:o}of e)for(let{file:i,name:r,version:l,bump:n}of s){const c=P({version:l,tag:a,bump:n}),{bump:m,path:u,changelog:p}=t.get(r)??{path:i.replace("package.json","CHANGELOG.md"),changelog:[],bump:n},[$="",,,h=""]=p,g=[$.replace("### ","")||"0.0.0",c].sort(Bun.semver.order)[1];t.set(r,{bump:m,path:u,changelog:[`### ${G[n]} ${g}`,"",p.length>0?"__Stones:__":"__Stone:__",`_${o}${h?`, ${h.replaceAll("_","")}_`:"_"}`]})}return t}function le({root:e,lastCommit:t,commit:a}){const s=Bun.spawnSync(["git","remote","get-url","origin"]).stdout.toString().trim().split(":")[1]?.replaceAll(".git","")||"",o=Bun.spawnSync(["git","log",`--pretty=format:%H${K}%s${K}%cn`,`${t}..${a}`]).stdout.toString().split("\n").map((i)=>{if(i.length===0)return;const[r="",l="",n=""]=i.split(K);return`- ${s?`[${r.slice(0,7)} ${l}](https://github.com/${s}/commit/${r})`:l} (by [@${n}](https://github.com/${n}))`}).filter(Boolean);return o.length>0?`
5
- <details><summary>${o.length} ${e?"Commits in this release":"Commits since last stone"}:</summary>
6
- ${o.join("\n")}
7
- </details>`:""}var K="#@!";import{note as De}from"@clack/prompts";import{bold as Ke,cyanBright as Le,green as Ve,redBright as We,reset as qe}from"picocolors";function ge({dryRun:e,github:t,githubToken:a,packages:s,rootTag:o,withTags:i}){if(e)return;if(i)for(let{name:r,version:l}of Object.values(s)){const n=`${r}@${l}`;Bun.spawnSync(["git","tag",n,"-m",`Release ${n}`,"-f"])}if(o)Bun.spawnSync(["git","tag",o,"-m","Release","-f"]);if(t){if(!(a||process.env.GITHUB_TOKEN))return De(qe(Ke(`${We("No Github token found.")}
8
- Please provide one by using ${Le("--githubToken")} flag or by setting ${Ve("GITHUB_TOKEN")} environment variable.`)));console.info("TODO: This will be implemented in the future as Github release",{withTags:i,githubToken:a})}}import{note as Je,spinner as Qe}from"@clack/prompts";import{bold as ue,cyanBright as I,green as me,magenta as L,redBright as he,reset as ze,yellow as fe}from"picocolors";function pe({packages:e,dryRun:t,npmToken:a}){if(!(a||process.env.NPM_TOKEN||t))return Je(ze(ue(`${he("No NPM token found.")}
9
- Please provide one by using ${I("--npmToken")} flag or by setting ${me("NPM_TOKEN")} environment variable.`)));for(let{name:o,version:i,file:r}of Object.values(e)){const l=Qe();l.start(`${t?fe("[dry-run]: Test "):""}Publishing ${L(o)}@${I(i)}...`);let n="";try{Bun.spawnSync(Xe({dryRun:t}),{cwd:r.replace("package.json","")}),n=`${me("Successfully published")} ${L(o)}@${I(i)}`}catch(c){n=`${ue(`${he("Failed to publish")} ${L(o)}@${I(i)}`)}`,console.error(c)}l.stop(`${t?fe("[dry-run]: Test "):""}${n}`)}}function Xe({dryRun:e}){return["npm","publish","--access","public"].concat(e?["--dry-run"]:[])}function ot(){const{values:e}=Te({allowPositionals:!0,args:Bun.argv,strict:!0,options:{changelog:{type:"boolean",short:"c"},changelogRoot:{default:!1,type:"boolean",short:"r"},dryRun:{default:!1,type:"boolean",short:"d"},github:{type:"boolean",short:"g"},githubToken:{type:"string"},npm:{type:"boolean",short:"n"},npmToken:{type:"string"},rootTag:{type:"string"},withTags:{default:!1,type:"boolean",short:"t"}}});return e}async function we(){const{dryRun:e,npmToken:t,changelogRoot:a,changelog:s,npm:o,github:i,withTags:r,rootTag:l,githubToken:n}=ot(),c=await v(),m=typeof s==="boolean"?s:c.changelog?.generate,u=typeof o==="boolean"?o:c.release?.npm,p=typeof i==="boolean"?i:c.release?.github,$=typeof a==="boolean"?a:c.changelog?.root,h=Bun.spawnSync(["git","rev-parse","HEAD"]).stdout.toString().trim();let g=[];try{g=await V()}catch{}if(g.length===0)return et($e(be(`${st("No stones found.")}
10
- ${$e(`Run ${tt("bunx @r5n/sisyphus")}${de(" version")} and create some first.`)}`)));if(m)await ce({dryRun:e,changelogRoot:$,commit:h,stones:g});const b=await nt({dryRun:e,stones:g});if(u)pe({dryRun:e,packages:b,npmToken:t});const w=new Date().toISOString().split(".")[0]||"";if(ge({dryRun:e,packages:b,withTags:r,rootTag:l,githubToken:n,github:p}),await ae({dryRun:e,stones:[],lastStone:{commit:h,date:w}}),!e)Ze(".sisyphus/stones",{recursive:!0,force:!0})}async function V({dryRun:e}={}){const t=B({dryRun:e}),{packages:a}=await C({}),s=[];for(let o of t)try{const i=await Bun.file(`.sisyphus/stones/${o}.md`).text(),[r="",l=""]=i.split(N),[n="",,c=""]=l.trim().split("|\n|"),[m="",u=""]=r.split("\n"),p=n.slice(2).split("|").map((g)=>g.trim()),h=c.trim().slice(0,-2).split("|").map((g)=>g.split(",").map((b)=>b.trim())).flatMap((g,b)=>g.map((w)=>a[w]?{...a[w],bump:p[b]}:void 0)).filter(Boolean);s.push({message:m.replace("###","").trim(),name:o,packages:h,tag:u.replaceAll("_","").trim()})}catch(i){console.error(`Error processing stone ${o}`),console.error(i)}return s}async function nt({stones:e,dryRun:t=!1}){const a=[],s={};for(let{tag:i,packages:r,message:l}of e){a.push(l);for(let n of r){s[n.name]||=n;const c=s[n.name]||n;c.tag=i,c.bump=E.indexOf(n.bump)>E.indexOf(c.bump)?n.bump:c.bump,s[n.name]=c}}const o=Object.values(s).reduce((i,r)=>{return i[r.name]||=r,i[r.name].version=P(i[r.name]||r),i},{});if(t)console.info(`${be(de("[dry-run]"))}\nConfig for next release:\nStones: ${a.join(", ")}\n${JSON.stringify(o,null,2)}`);else for(let{version:i,file:r}of Object.values(o)){const l=await Bun.file(r).json();l.version=i,await Bun.write(r,`${JSON.stringify(l,null,2)}\n`)}return o}async function ye(){await v({dryRun:!0});const{packages:e,packageNames:t}=await C(),{packages:a,packageNames:[s=""]}=await C({single:!0}),o=await V({dryRun:!0}),i=o.length>0?`${W(it("Stones:"))}
11
- ${o.map((r)=>`${W("- Name:")} ${r.name}
12
- ${W("- Packages:")}
13
- ${r.packages.map((l)=>` - ${G[l.bump]} ${l.name}@${P({tag:r.tag,bump:l.bump,version:l.version})} (${l.bump})`).join("\n")}`).join("\n")}`:"";console.info(`${q("Root package:")} ${s}@${a[s]?.version}
14
- ${q("Packages:")}
15
- ${t.map((r)=>` - ${r}@${e[r]?.version}`).join("\n")}
16
-
17
- ${i}`),at(rt(q("Sisyphus check complete.")))}import{blue as ct,bold as y,cyanBright as A,dim as S,green as gt,italic as k,magenta as ut,underline as U,whiteBright as mt,yellow as ve}from"picocolors";var R="0.3.1";function J(e){let t=[];switch(e){case"init":t=[mt(`Initialises Sisyphus with config, by creating ${k(".sisyphus/config.json")} file in the root of the workspace.`),"",y("Flags:"),f("--single",`Initialises config in a single package mode. Sisyphus will work for root ${S(k("package.json"))} file only`),f("--overwrite",["Overrides existing config.","It will remove existing one and creates new one with default values or given options"]),f("--tag","Initialises config with a specific tag"),f("--ignore",`Array of packages to ignore. Can be used as array: ${U(k("bunx @r5n/sisyphus init -i pkg1 -i pkg2"))}`),f("--nonInteractive","Sisyphus will not ask for config options, it will use defaults"),"",y("Examples:"),d("Usual monorepo setup with multiple packages","init",""),d("Single package setup","init","--single"),d("Setup with defaults using non-interactive mode","init","-n"),d("Setup with a specific tag","init","--tag v1.0.0"),d("Setup with ignored packages","init","-i pkg1 -i pkg2")];break;case"version":{t=["Generates a stone from interactive mode. It will ask you about version bump, release message, changelog generation etc.","",y("Flags:"),f("--bump",["Predefined semantic version of bump for selected packages.",`Available types: ${U(k("major, minor, patch"))}. ${y(k(`Can't be used with ${A("--snapshot")} option`))}`]),f("--tag","Version tag for release. Given string will be used as a tagged version for selected packages"),f("--filter","Sisyphus will only update packages that match the given filter"),f("--snapshot",[`Create a snapshot release with version of given tag and timestamp. ${y(k(`Can't be used with ${A("--bump")} option`))}`,"Useful for creating a release from a specific point in time for analysis, debugging or nightly builds"]),f("--yes","Sisyphus will not ask for confirmation before creating a stone"),"",y("Examples:"),d("Base usage","version",""),d("Generate stone with predefined version bump","version","--bump major"),d("Generate stone with snapshot release","version","--snapshot"),d("Confirm stone creation automatically","version","--yes")];break}case"roll":{t=["Creates a release from a specific point in time. It's based on stones created by Sisyphus.","With proper flags it will publish to NPM, create a release on GitHub, generate a changelog and more.","",y("Flags:"),f("--changelog","Creates a changelog from a specific point in time"),f(["-r","--changelogRoot"],"Creates a combined changelog for the monorepo. Useful for release notes."),f("--npm","Publishes packages to NPM"),f("--github","Creates a release on GitHub. Can be configured via `github` in config."),f(["-t","--withTags"],"Creates git tags for release"),f(["","--rootTag"],"Creates a tag of given string. Useful for creating a release from a specific point in time."),f(["","--npmToken"],["NPM token to use for publishing.",`By default it's read from ${y(k("NPM_TOKEN"))} environment variable`]),f(["","--githubToken"],["GitHub token to use for creating a release & tags.",`By default it's read from ${y(k("GITHUB_TOKEN"))} environment variable`]),f("--dryRun","Roll will not make any changes, it will only show what it would do"),"",y("Examples:"),d("Base usage of roll command to generate tags, changelog and npm release","roll","-n -c -t"),d("Generate changelog on release","roll","--changelog"),d("Creates release and publish packages to NPM","roll","--npm"),d("Enables GitHub release creation","roll","--github"),d("Creates release with git tags per package","roll","--withTags"),d("Creates release with a specific tag","roll","--rootTag v1.0.0"),d("Roll with dry run to check for changes","roll","--dryRun")];break}case"check":{t=["",k(S("Checks current state of Sisyphus config and packages. It's useful to run it before roll command to see what will be affected by release.")),""];break}default:t=["",k(S(`Run ${U(k("bunx @r5n/sisyphus <command> --help"))} for more info on command usage`)),"",y("Commands:"),x("help","Show this help information"),x("init","Initialise Sisyphus config"),x("roll","Release packages, tags, changelogs etc. based on generated stones"),x("version","Create stone from interactive mode"),x("check","Check current state of Sisyphus config and packages"),""]}console.info(`${ut(`${y("Sisyphus ")}${U(k(`v${R}`))}`)}
18
- Usage: bunx @r5n/sisyphus ${ve(k(e&&!["check","help"].includes(e)?`${e} ${A("[...flags]")}`:"<command>"))}
19
- ${t.join("\n ")}
20
- ${S("Any issues & ideas can be reported at https://github.com/r5n-labs/ts-packages/issues/new/choose")}
21
- `)}function d(e,t,a){return` ${S(e)}
22
- ${gt("bunx @r5n/sisyphus")}${ve(` ${t} `)}${A(a)}
23
- `}function f(e,t,a=40){const[s,o]=Array.isArray(e)?e:[e.slice(1,3),e],i=A(y(`${s?`${s}, `:""}${o}`)),r=Array.isArray(t)?t.map((l,n)=>`${A(y("")).padEnd(n===0?0:a+4," ")}${S(l)}`).join("\n"):S(t);return` ${i.padEnd(a," ")}${r}`}function x(e,t,a=32){return` ${ct(y(e)).padEnd(a," ")}${S(t)}`}import{parseArgs as ft}from"util";import{note as pt}from"@clack/prompts";import{blue as Ne,bold as $t,green as z,italic as bt,magenta as dt,reset as Ge,underline as wt}from"picocolors";import{confirm as _,group as Pe,multiselect as ht,text as H}from"@clack/prompts";import{bold as M,dim as ke,italic as Se,magenta as Q,underline as Y,whiteBright as F}from"picocolors";async function Ce({single:e,tag:t,ignore:a}){const s=await Pe({single:()=>_({initialValue:e,message:"Setup Sisyphus for only root package?",active:"Yes, setup for root package",inactive:"No, setup for monorepo workspace packages"}),tag:()=>H({initialValue:t,placeholder:"latest",message:"Tag used when versioning packages. Leave `latest` if you are not sure or want to release packages with latest tag."}),generateChangelog:()=>_({initialValue:!0,message:"Generate changelog for release?",active:"Yes, Generate changelog",inactive:"Skip changelog"}),rootChangelog:({results:{generateChangelog:o}})=>o?_({initialValue:!0,message:"Generate combined changelog for monorepo?",active:"Yes, generate combined changelog",inactive:"Skip root changelog"}):void 0,releaseOnGitHub:()=>_({initialValue:!1,message:"Create a release on GitHub when releasing packages?",active:"Yes, create a GitHub release",inactive:"Skip GitHub release"}),releaseOnNPM:()=>_({initialValue:!1,message:"Publish packages to NPM when releasing packages?",active:"Yes, publish packages to NPM",inactive:"Skip NPM release"}),commitConfig:()=>_({initialValue:!1,message:"Configure commit for release? Default commit message is `release(:tada:): <last-stone-message>`",active:"Yes, configure commit",inactive:"Skip commit config"}),commitMessage:({results:{commitConfig:o}})=>o?H({placeholder:"release(\uD83C\uDF89): <last-stone-message>",message:"Commit message"}):void 0,commitAuthor:({results:{commitConfig:o}})=>o?H({placeholder:"r5n-bot",message:"Commit author"}):void 0,commitEmail:({results:{commitConfig:o}})=>o?H({placeholder:"r5n-bot@users.noreply.github.com",message:"Commit author email"}):void 0},{onCancel:()=>j()});return{single:s.single,tag:s.tag,generateChangelog:s.generateChangelog,rootChangelog:!!s.rootChangelog,releaseOnGitHub:!!s.releaseOnGitHub,releaseOnNPM:!!s.releaseOnNPM,commitConfig:!!s.commitConfig,commitMessage:s.commitMessage||"",commitAuthor:s.commitAuthor||"",commitEmail:s.commitEmail||""}}async function Me({packages:e,packageNames:t,tag:a}){function s({message:c,bump:m,packageNames:u,filterPackages:p}){const $=u.filter((h)=>!p?.includes(h)).map((h)=>({value:h,label:O({tag:a,name:h,version:e[h]?.version||"",bump:m})}));return $.length>0?ht({required:!1,initialValues:void 0,message:c,options:$}):void 0}const o=`\n - ${ke(Se(`Press ${Y(M(F("a")))} to select/unselect all, ${Y(M(F("SPACE")))} to select/unselect, ${Y(M(F("ARROWS")))} to move, ${Y(M(F("ENTER")))} to confirm`))}\n`,{message:i,majorPackages:r,minorPackages:l,patchPackages:n}=await Pe({message:()=>H({placeholder:"New feature",message:`Name of the stone. ${ke(Se("Default prefix or message can be configured in config."))}`}),majorPackages:()=>s({message:`Select packages for ${M(Q("major"))} bump.${o}`,bump:"major",packageNames:t,filterPackages:[]}),minorPackages:({results:{majorPackages:c}})=>s({message:`Select packages for ${M(Q("minor"))} bump.`,bump:"minor",packageNames:t,filterPackages:c||[]}),patchPackages:({results:{majorPackages:c,minorPackages:m}})=>s({message:`Select packages for ${M(Q("patch"))} bump.`,bump:"patch",packageNames:t,filterPackages:(c||[]).concat(m||[])})},{onCancel:()=>j()});return{message:i,majorPackages:r||[],minorPackages:l||[],patchPackages:n||[]}}async function je(){const{values:{nonInteractive:e,overwrite:t,tag:a,single:s,ignore:o}}=ft({allowPositionals:!0,args:Bun.argv,strict:!0,options:{ignore:{default:[],type:"string",short:"i",multiple:!0},nonInteractive:{default:!1,type:"boolean",short:"n"},overwrite:{default:!1,type:"boolean",short:"o"},single:{default:!1,type:"boolean",short:"s"},tag:{default:"latest",type:"string",short:"t"}}});if(e)await v({single:s,ignore:o,overwrite:t,tag:a});else{const{commitConfig:i,releaseOnGitHub:r,releaseOnNPM:l,commitMessage:n,commitAuthor:c,commitEmail:m,generateChangelog:u,rootChangelog:p,single:$,tag:h}=await Ce({tag:a,single:s,ignore:o}),g={ignore:o,single:$,tag:h};if(i)g.commit={message:n,author:c,email:m};if(r||l)g.release={github:r,npm:l};if(u)g.changelog={generate:u,root:p};await v({overwrite:t,...g})}pt(`${dt(`${$t("Sisyphus ")}${wt(bt(`v${R}`))}`)}${z(" is setup to roll stones.")}
24
-
25
- You can now start by creating a new stone by running ${Ge(z("bunx @r5n/sisyphus"))}${Ne(" version")}
26
- and following the prompts.
27
-
28
- After you finished, you can release it by running ${Ge(z("bunx @r5n/sisyphus"))}${Ne(" roll")}
29
- `)}import{parseArgs as vt}from"util";import{confirm as kt,isCancel as St,note as Pt}from"@clack/prompts";import{bold as D,cyanBright as _e,green as Z,italic as T,yellow as Ee}from"picocolors";import{randomUUID as yt}from"crypto";async function Ae({majorPackages:e,message:t,minorPackages:a,packages:s,patchPackages:o,tag:i}){const l=`${`${B().length+1}`.padStart(4,"0")}-${yt().slice(0,8)}`,n=[...e,...a,...o],c=n.flatMap((g)=>s[g]?.dependencyOf||[]),m=[e,a,o,c.filter((g)=>!n.includes(g))],u=m.flatMap((g,b)=>g.length>0&&X[b]).filter(Boolean),p=[`### ${t}`,i?`_${i}_`:"",N,"",`| ${u.join(" | ")} |`,`| ${u.map(()=>":---:").join(" | ")} |`,`| ${u.map((g)=>m[X.indexOf(g)]?.join(", ")).join(" | ")} |`,""];return(await v()).stones.push(l),{packages:m.flatMap((g,b)=>g.map((w)=>({...s[w],tag:i,bump:X[b]}))).filter(Boolean),stoneContent:p,stoneName:l}}var X=E.slice(0,4).reverse();async function xe(){const{values:{bump:e,dryRun:t,filter:a,tag:s,snapshot:o,yes:i}}=vt({allowPositionals:!0,args:Bun.argv,strict:!0,options:{bump:{default:"",type:"string",short:"b"},dryRun:{default:!1,type:"boolean",short:"d"},filter:{default:"",type:"string",short:"f"},snapshot:{default:!1,type:"boolean",short:"s"},tag:{default:"",type:"string",short:"t"},yes:{default:!1,type:"boolean",short:"y"}}});if(o&&e)return j(`Cannot use both ${_e("--snapshot")} and ${_e("--bump")} options, pick one.`);const{packages:r,packageNames:l}=await C({filter:a}),{message:n,majorPackages:c,minorPackages:m,patchPackages:u}=await Me({packages:r,packageNames:l,tag:s}),{packages:p,stoneContent:$,stoneName:h}=await Ae({message:n,packages:r,tag:s,majorPackages:c,minorPackages:m,patchPackages:u});if(console.info([`${t?D(Ee("[dry-run]\n")):""}${T("Changes preview:")}\n`,`${T("Stone: ")}${D(n)}`,...p.map(O)].join("\n")),t)return console.info(`${D(Ee("[dry-run]"))}\nStone file preview:\n${$.join("\n")}`);if(!i){const g=await kt({message:"Are you sure you want to create a new stone?",active:"Yes, continue",inactive:"No, cancel"});if(!g||St(g))return j("Operation cancelled by user");const b=await v();b.stones.push(h),await Bun.write(`.sisyphus/stones/${h}.md`,$.join("\n")),await Bun.write(".sisyphus/config.json",`${JSON.stringify(b,null,2)}\n`)}Pt(`Now you can run ${Z("bunx @r5n/sisyphus roll")} to release packages
30
- or create another stone with ${Z("bunx @r5n/sisyphus version")}`,`${D("Stone ")}${T(`${h}.md`)} ${Z("created!")}`)}function Mt({method:e}){if(Bun.argv.includes("--help"))return J(e);switch(e){case"check":return ye();case"init":return je();case"roll":return we();case"version":return xe();default:return J()}}var[Ct]=process.argv.slice(2);Mt({method:Ct});