@jerryc05/hi-tools 0.2.9 → 0.2.10

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 (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ ${m?`hash: ${m}`:`brch: ${l}`}`);let d=await fetch("https://scm.byted.org/api/v2
16
16
  `);je(`Server running at
17
17
  ${a.join("")}`),re.info(`\u{1F680} Try ${a[0]}`)})}var Le={port:{alias:"p",desc:"Port for helper",number:!0}},ie=[{command:"rax",describe:"Start rax helper (web)",builder:Le,handler:Te}];var se=[{command:"tt",describe:"TT/BD internal toolset",builder:e=>e.command([...G,...z,...te,...ne,...ie]).demandCommand(1),handler(){}}];import{lstatSync as Je}from"node:fs";import{log as f,note as Ue,spinner as S}from"@clack/prompts";import Ge from"string-argv";import y from"node:process";var He=e=>new Promise(t=>setTimeout(t,e)),Fe=1e4;async function Be(e){let t=await C();t||(f.error(`Failed to get package.json at ${y.cwd()}`),y.exit(1));let n=t.version,r=`${t.name}@${n}`,i=[...Ge(e.installCmdPrefix),r];Ue(`\u{1F680} Monitoring ${r}...
18
18
  \u{1F4C2} Target: ${e.target}
19
- \u{1F6E0} Install cmd: ${i.join(" ")}`);let{execa:s}=await import("execa");try{let o=S();o.start("Pulling latest changes in target repo..."),await s({cwd:e.target,stdio:"ignore"})`git pull`,o.stop("Latest commit pulled"),o=S();let a=Date.now();for(let c=1;;c++){o.start(`Waiting for ${r}, attempt ${c}`);let{exitCode:p}=await s({reject:!1,stdio:"ignore"})`npm view ${r} version`;if(p===0){o.stop(`${r} is live! Found it \u2705`);try{f.info(`Installing ${r} via ${i}`),await s({cwd:e.target,stdio:"inherit"})`${i}`,f.success(`${r} installed! \u2705`);break}catch(l){f.error(`${r} was found in registry, but install command failed. Err: ${l}`),y.exit(1)}}(Date.now()-a)/1e3>=e.timeout&&(o.stop(`Didn't find ${r} in ${e.timeout} sec(s)`),y.exit(1)),await He(Fe)}if(e.skipCommit)f.info("Git-commit skipped");else{let{stdout:c}=await s({cwd:e.target})`git ls-files --others --exclude-standard`;c.trim()&&(f.error(`Target repo has untracked files. Please commit or remove them manually before running wup:
19
+ \u{1F6E0} Install cmd: ${i.join(" ")}`);let{execa:s}=await import("execa");try{let o=S();o.start("Pulling latest changes in target repo..."),await s({cwd:e.target,stdio:"ignore"})`git pull`,o.stop("Latest commit pulled"),o=S(),o.start();let a=Date.now();for(let c=1;;c++){o.message(`Waiting for ${r}, attempt ${c}`);let{exitCode:p}=await s({reject:!1,stdio:"ignore"})`npm view ${r} version`;if(p===0){o.stop(`#${c}: ${r} is live! Found it \u2705`);try{f.info(`Installing ${r} via ${i}`),await s({cwd:e.target,stdio:"inherit"})`${i}`,f.success(`${r} installed! \u2705`);break}catch(l){f.error(`${r} was found in registry, but install command failed. Err: ${l}`),y.exit(1)}}(Date.now()-a)/1e3>=e.timeout&&(o.stop(`Didn't find ${r} in ${e.timeout} sec(s)`),y.exit(1)),await He(Fe)}if(e.skipCommit)f.info("Git-commit skipped");else{let{stdout:c}=await s({cwd:e.target})`git ls-files --others --exclude-standard`;c.trim()&&(f.error(`Target repo has untracked files. Please commit or remove them manually before running wup:
20
20
  ${c}`),y.exit(1)),o=S(),o.start("Committing changes..."),await s({cwd:e.target,stdio:"inherit"})`git commit -am ${`chore: upd ${r}`}`,o.stop("Committed \u2705"),o=S(),o.start("Pushing to remote..."),await s({cwd:e.target,stdio:"inherit"})`git push`,o.stop("Pushed \u2705")}f.success("\u{1F389} DONE!")}catch(o){console.error(`
21
21
  \u274C Task failed:`,o),y.exit(1)}}var A={target:{alias:"t",desc:"Target repository path",demandOption:!0,normalize:!0},"install-cmd-prefix":{alias:"cmd",desc:"Pkg install command prefix. Default: pnpm add",default:"pnpm add"},timeout:{desc:"Timeout checking new pkg version in sec",default:300,type:"number"},"skip-commit":{desc:"Do not commit changes",default:!1,type:"boolean"}},ae=[{command:"wup",describe:"[W]ait for pkg publish, [U]pdate target repo, and [P]ush",builder:e=>e.options(A).example('$0 wup -t "/tmp/..." --cmd "emo add"',"Install w/ eden-mono").example('$0 wup -t "/tmp/..." --cmd "rush add --make-consistent -p" --skip-commit',"Install w/ @microsoft/rush"),async handler(e){let{target:t,installCmdPrefix:n=A["install-cmd-prefix"].default,"skip-commit":r=A["skip-commit"].default,verbose:i}=e,s=Number(e.timeout);(!Number.isFinite(s)||s<=0)&&(f.error(`Timeout must be a positive number, received: ${e.timeout}`),y.exit(1));let o=`Path ${t} is not a directory.`;try{if(!t||!Je(t).isDirectory())throw new Error(o)}catch(a){f.error(`${o}. Err: ${a}`),y.exit(1)}await Be({target:t,installCmdPrefix:n,timeout:s,skipCommit:!!r,verbose:i})}}];var N=JSON.parse(await Me(qe(import.meta.dirname,"../package.json"),"utf8"));Xe(`\u{1F44B} ${N.name} v${N.version}`);var ze=[...J,...U,...ae,...O,...j,...se];We().scriptName("hi").version(N.version).option("verbose",{type:"boolean",description:"Run with verbose logging",global:!0}).strict().recommendCommands().command(ze).help().parse(Ke(process.argv));export{N as PKG};
22
22
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jerryc05/hi-tools",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "A collection of my everyday SDE tools.",
5
5
  "scripts": {
6
6
  "pub": "npm run build && export NPM_CONFIG_REGISTRY=https://registry.npmjs.org &&{ npm whoami || npm login ;} && npm publish --access public && git push",