@jerryc05/hi-tools 0.2.5 → 0.2.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 +1 -1
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ ${await s.text()}`),process.exit(1));let i=await a();i.pipelineRuns[0]?.runStatu
|
|
|
11
11
|
${await s.text()}`),process.exit(1));let i=await a();i.pipelineRuns.length<=0&&(b.error(`No pipeline runs found in the most recent 10 runs
|
|
12
12
|
${JSON.stringify(i,null,1)}`),process.exit(1)),X("The latest pipeline run may be ongoing/failed. Try a previous run to inspect.","Select a previous run");let o=i.pipelineRuns.map(c=>{let l=Z(c.runStatus),u=Ce(c),f=c.triggerInfo?.triggeredBy||c.createdBy||"?";return{value:c.runId,label:`#${c.runSeq} runId=${c.runId} ${l}`,hint:`${u} by ${f}`}}),p=await W({message:"Select the run ID to inspect",options:o});return q(p)&&(M("Run selection cancelled"),process.exit(0)),p}async function ve(e,t,n){let{response:r,getJson:s}=await H(e,t,n);r.ok||(b.error(`[getRunDetailByRunID] failed: ${r.status} ${r.statusText}
|
|
13
13
|
${await r.text()}`),process.exit(1));let a=await s();return V([a.pipelineRun])}function Q(e){let t=/\bpipelineId=(\d+)\b/,r=e.match(t)?.[1]?.trim();if(r){if(!/^\d+$/.test(r))throw new Error("Invalid pipelineId query from URL. Expecting a pipelineId query value with all numbers");return r}throw new Error(`Invalid URL. Expecting a url containing ${m.bold(m.yellow("pipelineId"))} query param. E.g. `+m.underline(m.gray(`https://b??.net/devops/??/develop/detail/??/flow?devops_space_type=server_fe&${m.bold(m.magenta("pipelineId=1139212901634"))}&stage=dev_gatekeeper_stage`)))}function Z(e){switch(e){case y.RUNNING:return m.blue("RUNNING");case y.CANCELLED:return m.gray("CANCELLED");case y.SUCCESS:return m.green("SUCCESS");case y.FAIL:return m.red("FAIL")}return`status=${e}`}function Ce(e){return e.startedAt?`started @ ${h(e.startedAt)}`:e.createdAt?`created @ ${h(e.createdAt)}`:"time=?"}import{access as xe,constants as ke}from"node:fs/promises";async function Y(e){let t=[".js",".cjs",".mjs"].map(n=>`${e}${n}`);for(let n of t)try{return await xe(n,ke.R_OK),n}catch{}console.error(`tt i18n: Failed to read one of ${t.join(", ")}`),process.exit(1)}var ee=[{command:"i18n",describe:"I18n scan and sort",handler:async()=>{let[e,t]=await Promise.all([Y("starling.config"),Y("combine-lang")]),{execa:n,execaNode:r}=await import("execa");await n({stdio:"inherit"})`pnpm dlx @ies/starling-cli scan -c ${e} --fallback --disable-browser`,await r({stdio:"inherit"})`${t}`,await n({stdio:"inherit"})`pnpm --package=json-sort-cli dlx sortjson ./src/lang`.catch(s=>console.error("tt i18n sortjson error:",s))}}];import{log as w,note as Ee}from"@clack/prompts";import{lstat as Se,readFile as _e}from"node:fs/promises";import{join as Pe}from"node:path";async function x(){let e=Pe(process.cwd(),"./package.json");return(await Se(e)).isFile()?JSON.parse(await _e(e,"utf8")):null}async function Ae({repoId:e,hash:t,branch:n}){let r=await x();r||(w.error(`Failed to get package.json at ${process.cwd()}`),process.exit(1));let s="SCM_USERNAME",a="SCM_PASSWORD",i=process.env[s],o=process.env[a];(!i||!o)&&(w.error(`Missing ${i?a:s} in env var.
|
|
14
|
-
Go to https://luban.bytedance.net/npm/publish and get your personal SCM username+password.`),process.exit(1));let{execa:p}=await import("execa");try{let c=p`git log -1 --pretty=%s`,l,u;n==null?t?l=t:l=(await p`git rev-parse HEAD`).stdout.trim():n?u=n:u=(await p`git branch --show-current`).stdout.trim();let f={repos:e,create_user:i,desc:`
|
|
14
|
+
Go to https://luban.bytedance.net/npm/publish and get your personal SCM username+password.`),process.exit(1));let{execa:p}=await import("execa");try{let c=p`git log -1 --pretty=%s`,l,u;n==null?t?l=t:l=(await p`git rev-parse HEAD`).stdout.trim():n?u=n:u=(await p`git branch --show-current`).stdout.trim();let f={repos:e,create_user:i,desc:`v${r?.version}: ${(await c).stdout.trim()}`,has_version_stage:!1,version:r?.version,...l?{pub_base:"commit_base",base_commit_hash:l}:{pub_base:"branch_base",branch_name:u}};Ee(`${f.create_user} is publishing ${r?.name}@${r?.version} to repoId=${f.repos}
|
|
15
15
|
${l?`hash: ${l}`:`brch: ${u}`}`);let d=await fetch("https://scm.byted.org/api/v2/npm_versions/",{method:"POST",headers:{Authorization:`Basic ${Buffer.from(`${i}:${o}`).toString("base64")}`,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(f)});if(!d.ok){let P=await d.text();w.error(`HTTP ${d.status} Error: ${P}`),process.exit(1)}let _=await d.text();w.success(`\u{1F389} Successfully published: ${_}`)}catch(c){w.error("Execution Failed:"),console.error(c),process.exit(1)}}var De={"by-hash":{alias:"h",desc:"Publish pkg by hash (default)",string:!0,conflicts:["by-branch"]},"by-branch":{alias:"b",desc:"Publish pkg by branch",string:!0,conflicts:["by-hash"]}},te=[{command:"luban <repoId>",describe:"Publish current repo pkg to Luban",builder:De,handler(e){let{byHash:t,byBranch:n}=e,r=Number(e.repoId);Ae({repoId:r,hash:t,branch:n})}}];import{unlink as Ne}from"node:fs/promises";import{join as Oe}from"node:path";import{log as ne,note as je}from"@clack/prompts";import re from"picocolors";import I from"base62";var g;(o=>{let e=0;o.RAX_WEBPAGE="/",o.RAX_CONNECT=`/${I.encode(e++)}`,o.RAX_DEVICE_INFO=`/${I.encode(e++)}`,o.RAX_CHANGE_ACCOUNT=`/${I.encode(e++)}`,o.RAX_SCRSHOT=`/${I.encode(e++)}`,o.RAX_OPEN_SCHEMA=`/${I.encode(e++)}`})(g||={});var $=["pnpm","dlx","--silent","--allow-build=better-sqlite3","--allow-build=sharp","@tiktok-fe/rax-cli@>=0.3.28"];async function Te(e){let{execa:t}=await import("execa"),{default:n}=await import("express"),r=n();r.use(n.json()),r.get(g.RAX_WEBPAGE,(a,i)=>{i.sendFile(Oe(import.meta.dirname,"index.html"))}),r.post(g.RAX_CONNECT,async(a,i)=>{throw new Error("unimplemented")}),r.get(g.RAX_DEVICE_INFO,async(a,i)=>{let{stdout:o}=await t`${$} device info`;if(o.trim().startsWith("Error:")){i.status(400).send(o);return}let p=JSON.parse(o);delete p.appInfo.appInfo.appIconBase64,delete p.appInfo.appSettings.language;let{account:c}=p.appInfo.appSettings;c.current={customID:c.current.customID,nickname:c.current.nickname,userID:c.current.userID};for(let l=0;l<(c.loginAccountList?.length??0);l++){if(!c.loginAccountList)continue;let u=c.loginAccountList[l];u&&(c.loginAccountList[l]={customID:u.customID,nickname:u.nickname,userID:u.userID})}i.json(p)}),r.post(g.RAX_CHANGE_ACCOUNT,async(a,i)=>{let{userID:o}=a.body;if(!o){i.sendStatus(400);return}let{stdout:p}=await t`${$} app account change ${o} --json`,c=JSON.parse(p).content?.[0]?.text;i.type("json").send(c)}),r.get(g.RAX_SCRSHOT,async(a,i)=>{let{execa:o}=await import("execa"),{default:p}=await import("sharp"),{temporaryFile:c}=await import("tempy"),l=c({extension:"png"}),{stdout:u,stderr:f}=await o`${$} device screenshot --output ${l}`;if(u.trim().includes("Cannot screenshot")||u.trim().includes("no available device")){i.status(404).send(u);return}let d=c({extension:"webp"});await p(l).webp({quality:70,effort:5,smartSubsample:!0}).toFile(d),Ne(l).catch(),i.sendFile(d)}),r.post(g.RAX_OPEN_SCHEMA,async(a,i)=>{let{execa:o}=await import("execa"),{schema:p}=a.body,{stdout:c}=await o`${$} device open-schema ${p}`;i.send(c)});let s=r.listen(e.port??0,()=>{let a=s.address(),i=typeof a!="string"?a?.port:void 0;i||(ne.error(`Failed to get port from addr [${a}]`),process.exit(1));let o=Object.values(E()??{"":["localhost"]}).flat().sort((p,c)=>p.internal&&!c.internal?-1:!p.internal&&c.internal?1:p.family==="IPv4"&&c.family==="IPv6"?-1:p.family==="IPv6"&&c.family==="IPv4"?1:p.address.localeCompare(c.address)).map(p=>` ${p.internal?re.green("[LOCAL]"):re.yellow("[ LAN ]")} http://${p.family==="IPv6"?`[${p.address}]`:p.address}:${i}
|
|
16
16
|
`);je(`Server running at
|
|
17
17
|
${o.join("")}`),ne.info(`\u{1F680} Try ${o[0]}`)})}var Le={port:{alias:"p",desc:"Port for helper",number:!0}},oe=[{command:"rax",describe:"Start rax helper (web)",builder:Le,handler:Te}];var ie=[{command:"tt",describe:"TT/BD internal toolset",builder:e=>e.command([...U,...K,...ee,...te,...oe]).demandCommand(1),handler(){}}];import{lstatSync as Je}from"node:fs";import{log as R,note as Ue,spinner as k}from"@clack/prompts";import S from"node:process";var Ge=e=>new Promise(t=>setTimeout(t,e));async function He(e){let t=await x();t||(R.error(`Failed to get package.json at ${S.cwd()}`),S.exit(1));let n=t.version,r=`${t.name}@${n}`,s=1e4,a=[...e.installCmdPrefix.split(" "),r];Ue(`\u{1F680} Monitoring ${r}...
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jerryc05/hi-tools",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "A collection of my everyday SDE tools.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"pub": "npm run build && npm version patch && export NPM_CONFIG_REGISTRY=https://registry.npmjs.org &&{ npm whoami || npm login ;} && npm publish --access public && git push",
|