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