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