@jerryc05/hi-tools 0.1.10 → 0.1.11
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/README.md +4 -5
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -5,10 +5,10 @@ pnpm add -g @jerryc05/hi-tools
|
|
|
5
5
|
|
|
6
6
|
# Help
|
|
7
7
|
```
|
|
8
|
-
hi/0.
|
|
8
|
+
hi/0.1.10
|
|
9
9
|
|
|
10
10
|
Usage:
|
|
11
|
-
$ hi
|
|
11
|
+
$ hi
|
|
12
12
|
|
|
13
13
|
Commands:
|
|
14
14
|
upgrade Upgrade to latest version (default using pnpm)
|
|
@@ -41,7 +41,6 @@ For more info, run any command with the `--help` flag:
|
|
|
41
41
|
$ hi --help
|
|
42
42
|
|
|
43
43
|
Options:
|
|
44
|
-
--
|
|
45
|
-
-
|
|
46
|
-
-h, --help Display this message
|
|
44
|
+
-v, --version Display version number
|
|
45
|
+
-h, --help Display this message
|
|
47
46
|
```
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ ${p}`),console.dir(a),c<s.length-1&&console.log(`
|
|
|
13
13
|
${await o.text()}`),process.exit(1));let s=await r();s.pipelineRuns[0]?.runStatus!==y.SUCCESS&&b.warn(`Latest run (runId=${s.pipelineRuns[0]?.runId}) status=${q(s.pipelineRuns[0]?.runStatus)}. Gecko info may be unavailable.`);let m=B(s.pipelineRuns).filter(p=>p.region?.includes(i??""));if(m.length)return m;let c=await se(e,s.pipelineRuns);if(c)return O(c,n,t,i);let a=await ae(e,n,t);return await ce(a,n,t)}function M(e){let n=/\bpipelineId=(\d+)\b/,t=e.match(n);if(t?.[1])return t[1];throw new Error(`Invalid URL. Expecting a url containing ${d.bold(d.yellow("pipelineId"))} query param. E.g. `+d.underline(d.gray(`https://b??.net/devops/??/develop/detail/??/flow?devops_space_type=server_fe&${d.bold(d.magenta("pipelineId=1139212901634"))}&stage=dev_gatekeeper_stage`)))}function B(e){return e.flatMap(n=>n.jobs.map(t=>{try{let i=t.jobAtom.output;if(!i)return null;let o=i.GECKO_packageInfo;if(!o)return null;let r=JSON.parse(o),{qrCodeScheme:s,candidatePackage:m,channel:c,updatedAt:a,creator:p,distributeRule:g}=r.package,{scmVersion:f}=m,I=h(Number.parseInt(a,10)*1e3),R=g.envLaneList.flatMap(Q=>Q.values);return{qrCodeScheme:s,region:i.GECKO_region,scmVersion:f,channel:c,updatedDate:I,creator:p,envs:R,runId:n.runId,runSeq:n.runSeq}}catch(i){return console.error(i),null}}).filter(t=>t!=null)).filter(n=>!!n)}async function se(e,n){let t=n.flatMap(r=>r.jobs.map(s=>s.jobAtom.inputs?.trigger_params).filter(s=>!!s).filter(s=>s.detail_url.length));if(!t.length)return;L(`Found ${t.length} possible alternative pipeline(s) you may want to try instead.`,"Mistyped the pipeline ID?");let i=[{value:"",label:`(Keep current pipeline id=${e})`}].concat(t.map(r=>({value:M(r.detail_url),label:`${d.underline(r.development_task_name)} by ${r.developer.join(",")}`,hint:r.detail_url}))),o=await G({message:"Select a pipeline to change, or cancel [ESC] to use the current pipeline.",options:i});if(j(o)||!o){H("Keep using current pipeline");return}return b.success(`Using new pipeline id=${o}`),o}async function ae(e,n,t){let{response:o,getJson:r}=await x({pipelineId:e,pageSize:10,withoutJob:!0},n,t);o.ok||(b.error(`[getRunInfoByPipelineID] failed: ${o.status} ${o.statusText}
|
|
14
14
|
${await o.text()}`),process.exit(1));let s=await r();s.pipelineRuns.length<=0&&(b.error(`No pipeline runs found in the most recent 10 runs
|
|
15
15
|
${JSON.stringify(s,null,1)}`),process.exit(1)),L("The latest pipeline run may be ongoing/failed. Try a previous run to inspect.","Select a previous run");let m=s.pipelineRuns.map(a=>{let p=q(a.runStatus),g=me(a),f=a.triggerInfo?.triggeredBy||a.createdBy||"?";return{value:a.runId,label:`#${a.runSeq} runId=${a.runId} ${p}`,hint:`${g} by ${f}`}}),c=await G({message:"Select the run ID to inspect",options:m});return j(c)&&(H("Run selection cancelled"),process.exit(0)),c}async function ce(e,n,t){let{response:i,getJson:o}=await U(e,n,t);i.ok||(b.error(`[getRunDetailByRunID] failed: ${i.status} ${i.statusText}
|
|
16
|
-
${await i.text()}`),process.exit(1));let r=await o();return B([r.pipelineRun])}function q(e){switch(e){case y.RUNNING:return d.blue("RUNNING");case y.CANCELLED:return d.gray("CANCELLED");case y.SUCCESS:return d.green("SUCCESS");case y.FAILURE:return d.red("FAILURE")}return`status=${e}`}function me(e){return e.completedAt?`completed @ ${h(e.completedAt)}`:e.startedAt?`started @ ${h(e.startedAt)}`:e.createdAt?`created @ ${h(e.createdAt)}`:"time=?"}var F=[{cmd:{name:"tt-gecko",desc:"Show gecko info by bits URL"},options:[{name:"-p,--pipelineId <pipelineId>",desc:"Pipeline ID (Overrides URL)"},{name:"-u,--url <url>",desc:"Bits URL"},{name:"-r,--region <region>",desc:"Region
|
|
16
|
+
${await i.text()}`),process.exit(1));let r=await o();return B([r.pipelineRun])}function q(e){switch(e){case y.RUNNING:return d.blue("RUNNING");case y.CANCELLED:return d.gray("CANCELLED");case y.SUCCESS:return d.green("SUCCESS");case y.FAILURE:return d.red("FAILURE")}return`status=${e}`}function me(e){return e.completedAt?`completed @ ${h(e.completedAt)}`:e.startedAt?`started @ ${h(e.startedAt)}`:e.createdAt?`created @ ${h(e.createdAt)}`:"time=?"}var F=[{cmd:{name:"tt-gecko",desc:"Show gecko info by bits URL"},options:[{name:"-p,--pipelineId <pipelineId>",desc:"Pipeline ID (Overrides URL)"},{name:"-u,--url <url>",desc:"Bits URL"},{name:"-r,--region <region>",desc:"Region filter (match-based)"}],examples:[`${u.name} tt-gecko -r us -u 'https://b??.net/devops/??/develop/detail/??/flow?devops_space_type=server_fe&pipelineId=1139212901634&stage=dev_gatekeeper_stage'`],action:ie}];import{access as pe,constants as le}from"node:fs/promises";var K=[{cmd:{name:"tt-i18n",desc:"I18n scan and sort"},action:async()=>{let e="starling.config.js",n="combine-lang.js";for(let o of[e,n])try{await pe(o,le.R_OK)}catch(r){console.error(`tt i18n: Failed to read ${o}
|
|
17
17
|
`,r),process.exit(1)}let{execa:t,execaNode:i}=await import("execa");await t({stdio:"inherit"})`pnpm dlx @ies/starling-cli scan -c ${e} --fallback --disable-browser`,await i({stdio:"inherit"})`${e}`,await t({stdio:"inherit"})`pnpm --package=json-sort-cli dlx sortjson ./src/lang`.catch(o=>console.error("tt i18n sortjson error:",o))}}];var W=[...E,...F,...K];async function ue({npm:e,global:n}){let{execa:t}=await import("execa");await t({stdio:"inherit"})`${e?"npm":"pnpm"} add ${n?"-g":""} https://github.com/jerryc05/hi-tools.git`}var z=[{cmd:{name:"upgrade",desc:"Upgrade to latest version (default using pnpm)"},options:[{name:"--npm",desc:"Use npm instead of default"},{name:"-g,--global",desc:"Pass -g flag to pkg mgr"}],action:ue}];var de=e=>new Promise(n=>setTimeout(n,e)),V=[{cmd:{name:"wup",desc:"[W]ait for pkg publish, [U]pdate target repo, and [P]ush"},options:[{name:"-t, --target <path>",desc:"Target repository path"},{name:"-c, --cmdPrefix <prefix>",desc:"Pkg install command prefix",config:{default:"pnpm add"}},{name:"--timeout <limit>",desc:"Timeout limit in seconds",config:{default:300}}],examples:[`${u.name} wup -t "/tmp/otherRepoPath" -c "emo add"`,`${u.name} wup -t "/tmp/otherRepoPath" -c "rush add --make-consistent -p"`],action:async({target:e,cmdPrefix:n,timeout:t})=>{l||(console.log("\u274C Unable to parse package.json!"),process.exit(1)),e||(console.log("\u274C Missing target repo path"),process.exit(1));let i=l.version,o=`${l.name}@${i}`,r=1e4,s=[...n.split(" "),o];console.log(`\u{1F680} Monitoring ${o}...`),console.log(`\u{1F4C2} Target: ${e}`),console.log(`\u{1F6E0} Install cmd: ${s.join(" ")}`);let{execa:m}=await import("execa");try{console.log("\u{1F4E5} Pulling latest changes in target repo..."),await m({cwd:e,stdio:"inherit",env:{GIT_TRACE:"1"}})`git pull`;let c=Date.now();for(;;){let{exitCode:a}=await m({reject:!1,stdio:"inherit"})`npm view ${o} version`;if(a===0){console.log(`
|
|
18
18
|
\u2705 v${i} is live! Installing...`);try{await m({cwd:e,stdio:"inherit"})`${s}`,console.log(`
|
|
19
19
|
\u{1F389} [SUCCESS] ${o} installed!`);break}catch{console.log(`
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jerryc05/hi-tools",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "A collection of my everyday SDE tools.",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"pub": "npm run build && npm version patch && npm login --registry https://registry.npmjs.org && npm publish --access public && git push",
|
|
6
|
+
"pub": "npm run build && npm version patch && { npm whoami || npm login --registry https://registry.npmjs.org; } && npm publish --access public && git push",
|
|
7
7
|
"build": "node build.js",
|
|
8
8
|
"prepare": "husky"
|
|
9
9
|
},
|