@jerryc05/hi-tools 0.1.5 → 0.1.7
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/index.js +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ ${p}`),console.dir(c),a<s.length-1&&console.log(`
|
|
|
11
11
|
-----------------
|
|
12
12
|
|
|
13
13
|
`)}catch(p){console.error("Failed to generate QR:",p)}}}async function W(e,t,n){let{response:i,getJson:o}=await v({pipelineId:e,pageSize:1,withoutJob:!1},t,n);i.ok||(w.error(`[getRunInfoByPipelineID] failed: ${i.status} ${i.statusText}
|
|
14
|
-
${await i.text()}`),process.exit(1));let r=await o();r.pipelineRuns[0]?.runStatus!==I.SUCCESS&&w.warn(`Latest run (runId=${r.pipelineRuns[0]?.runId}) status=${Q(r.pipelineRuns[0]?.runStatus)}. Gecko info may be unavailable.`);let s=V(r.pipelineRuns);if(s.length)return s;let l=await ce(e,r.pipelineRuns);if(l)return W(l,t,n);let a=await le(e,t,n);return await me(a,t,n)}function z(e){let t=/\bpipelineId=(\d+)\b/,n=e.match(t);if(n?.[1])return n[1];throw new Error(`Invalid URL. Expecting a url containing ${g.bold(g.yellow("pipelineId"))} query param. E.g. `+g.underline(g.gray(`https://b??.net/devops/??/develop/detail/??/flow?devops_space_type=server_fe&${g.bold(g.magenta("pipelineId=1139212901634"))}&stage=dev_gatekeeper_stage`)))}function V(e){return e.flatMap(t=>t.jobs.map(n=>{try{let i=n.jobAtom.output;if(!i)return null;let o=i.GECKO_packageInfo;if(!o)return null;let r=JSON.parse(o),{qrCodeScheme:s,candidatePackage:l,channel:a,updatedAt:c,creator:p,distributeRule:f}=r.package,{scmVersion:b}=l,$=y(Number.parseInt(c,10)*1e3),C=f.envLaneList.flatMap(ne=>ne.values);return{qrCodeScheme:s,region:i.GECKO_region,scmVersion:b,channel:a,updatedDate:$,creator:p,envs:C,runId:t.runId,runSeq:t.runSeq}}catch(i){return console.error(i),null}}).filter(n=>n!=null)).filter(t=>!!t)}async function ce(e,t){let n=t.flatMap(r=>r.jobs.map(s=>s.jobAtom.inputs?.trigger_params).filter(s=>!!s).filter(s=>s.detail_url.length));if(!n.length)return;F(`Found ${n.length} possible alternative pipeline you
|
|
14
|
+
${await i.text()}`),process.exit(1));let r=await o();r.pipelineRuns[0]?.runStatus!==I.SUCCESS&&w.warn(`Latest run (runId=${r.pipelineRuns[0]?.runId}) status=${Q(r.pipelineRuns[0]?.runStatus)}. Gecko info may be unavailable.`);let s=V(r.pipelineRuns);if(s.length)return s;let l=await ce(e,r.pipelineRuns);if(l)return W(l,t,n);let a=await le(e,t,n);return await me(a,t,n)}function z(e){let t=/\bpipelineId=(\d+)\b/,n=e.match(t);if(n?.[1])return n[1];throw new Error(`Invalid URL. Expecting a url containing ${g.bold(g.yellow("pipelineId"))} query param. E.g. `+g.underline(g.gray(`https://b??.net/devops/??/develop/detail/??/flow?devops_space_type=server_fe&${g.bold(g.magenta("pipelineId=1139212901634"))}&stage=dev_gatekeeper_stage`)))}function V(e){return e.flatMap(t=>t.jobs.map(n=>{try{let i=n.jobAtom.output;if(!i)return null;let o=i.GECKO_packageInfo;if(!o)return null;let r=JSON.parse(o),{qrCodeScheme:s,candidatePackage:l,channel:a,updatedAt:c,creator:p,distributeRule:f}=r.package,{scmVersion:b}=l,$=y(Number.parseInt(c,10)*1e3),C=f.envLaneList.flatMap(ne=>ne.values);return{qrCodeScheme:s,region:i.GECKO_region,scmVersion:b,channel:a,updatedDate:$,creator:p,envs:C,runId:t.runId,runSeq:t.runSeq}}catch(i){return console.error(i),null}}).filter(n=>n!=null)).filter(t=>!!t)}async function ce(e,t){let n=t.flatMap(r=>r.jobs.map(s=>s.jobAtom.inputs?.trigger_params).filter(s=>!!s).filter(s=>s.detail_url.length));if(!n.length)return;F(`Found ${n.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(n.map(r=>({value:z(r.detail_url),label:`${g.underline(r.development_task_name)} by ${r.developer.join(",")}`,hint:r.detail_url}))),o=await K({message:"Select a pipeline to change, or cancel [ESC] to use the current pipeline.",options:i});if(q(o)||!o){B("Keep using current pipeline");return}return w.success(`Using new pipeline id=${o}`),o}async function le(e,t,n){let{response:o,getJson:r}=await v({pipelineId:e,pageSize:10,withoutJob:!0},t,n);o.ok||(w.error(`[getRunInfoByPipelineID] failed: ${o.status} ${o.statusText}
|
|
15
15
|
${await o.text()}`),process.exit(1));let s=await r();s.pipelineRuns.length<=0&&(w.error(`No pipeline runs found in the most recent 10 runs
|
|
16
16
|
${JSON.stringify(s,null,1)}`),process.exit(1)),F("The latest pipeline run may be ongoing/failed. Try a previous run to inspect.","Select a previous run");let l=s.pipelineRuns.map(c=>{let p=Q(c.runStatus),f=pe(c),b=c.triggerInfo?.triggeredBy||c.createdBy||"?";return{value:c.runId,label:`#${c.runSeq} runId=${c.runId} ${p}`,hint:`${f} by ${b}`}}),a=await K({message:"Select the run ID to inspect",options:l});return q(a)&&(B("Run selection cancelled"),process.exit(0)),a}async function me(e,t,n){let{response:i,getJson:o}=await G(e,t,n);i.ok||(w.error(`[getRunDetailByRunID] failed: ${i.status} ${i.statusText}
|
|
17
17
|
${await i.text()}`),process.exit(1));let r=await o();return V([r.pipelineRun])}function Q(e){switch(e){case I.RUNNING:return g.blue("RUNNING");case I.CANCELLED:return g.gray("CANCELLED");case I.SUCCESS:return g.green("SUCCESS");case I.FAILURE:return g.red("FAILURE")}return`status=${e}`}function pe(e){return e.completedAt?`completed @ ${y(e.completedAt)}`:e.startedAt?`started @ ${y(e.startedAt)}`:e.createdAt?`created @ ${y(e.createdAt)}`:"time=?"}var X=[{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 kw filter"}],examples:[`${d.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:ae}];import{access as ue,constants as de}from"node:fs/promises";var Z=[{cmd:{name:"tt-i18n",desc:"I18n scan and sort"},action:async()=>{let e="starling.config.js",t="combine-lang.js";for(let o of[e,t])try{await ue(o,de.R_OK)}catch(r){console.error(`tt i18n: Failed to read ${o}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jerryc05/hi-tools",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
|
+
"description": "A collection of my everyday SDE tools.",
|
|
4
5
|
"scripts": {
|
|
5
6
|
"pub": "npm run build && npm version patch && npm publish --access public && git push",
|
|
6
7
|
"build": "node build.js",
|