@r5n/sisyphus 0.3.0 → 0.3.1
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 +1 -1
package/dist/cli.js
CHANGED
|
@@ -5,7 +5,7 @@ If you want to run Sisyphus in single-mode/root package, use --single flag or se
|
|
|
5
5
|
<details><summary>${o.length} ${e?"Commits in this release":"Commits since last stone"}:</summary>
|
|
6
6
|
${o.join("\n")}
|
|
7
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:
|
|
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
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
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
11
|
${o.map((r)=>`${W("- Name:")} ${r.name}
|
|
@@ -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.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
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