@r5n/sisyphus 0.3.1 → 0.3.2
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 +2 -2
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
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
|
|
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"dependency":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
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
5
|
<details><summary>${o.length} ${e?"Commits in this release":"Commits since last stone"}:</summary>
|
|
6
6
|
${o.join("\n")}
|
|
@@ -14,7 +14,7 @@ ${r.packages.map((l)=>` - ${G[l.bump]} ${l.name}@${P({tag:r.tag,bump:l.bump,ver
|
|
|
14
14
|
${q("Packages:")}
|
|
15
15
|
${t.map((r)=>` - ${r}@${e[r]?.version}`).join("\n")}
|
|
16
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.
|
|
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.2";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
18
|
Usage: bunx @r5n/sisyphus ${ve(k(e&&!["check","help"].includes(e)?`${e} ${A("[...flags]")}`:"<command>"))}
|
|
19
19
|
${t.join("\n ")}
|
|
20
20
|
${S("Any issues & ideas can be reported at https://github.com/r5n-labs/ts-packages/issues/new/choose")}
|
package/package.json
CHANGED
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"lint": "biome check --write",
|
|
29
29
|
"package:publish": "npm publish",
|
|
30
30
|
"package:dryRun": "npm publish --dry-run",
|
|
31
|
-
"type-check": "bun tsc --noEmit"
|
|
31
|
+
"type-check": "bun --bun tsc --noEmit"
|
|
32
32
|
},
|
|
33
33
|
"type": "module",
|
|
34
34
|
"types": "./cli.ts",
|
|
35
|
-
"version": "0.3.
|
|
35
|
+
"version": "0.3.2"
|
|
36
36
|
}
|