ccommand 1.0.11 → 1.0.12
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 +3 -5
- package/dist/index.js +4 -1
- package/dist/index.mjs +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
<span><div align="center"></div></span>
|
|
2
2
|
|
|
3
|
-
高效的执行命令行工具 | Efficient execution of command-line tools
|
|
3
|
+
- 高效的执行命令行工具 | Efficient execution of command-line tools
|
|
4
|
+
- 基于 [gum](https://github.com/charmbracelet/gum#installation) | Powered by [gum](https://github.com/charmbracelet/gum#installation)
|
|
4
5
|
|
|
5
6
|
## 介绍 | Introduction
|
|
6
7
|
支持yarn、pnpm、npm、bun
|
|
7
8
|
|
|
8
|
-
## 依赖 | Dependencies
|
|
9
|
-
- 需要安装[gum](https://github.com/charmbracelet/gum#installation)
|
|
10
|
-
|
|
11
9
|
## 安装 | Install
|
|
12
10
|
```bash
|
|
13
|
-
brew install gum # 安装gum
|
|
14
11
|
npm install -g ccommand # 安装ccommand
|
|
15
12
|
```
|
|
16
13
|
|
|
@@ -28,6 +25,7 @@ ccommand # 执行当前script
|
|
|
28
25
|
|
|
29
26
|
https://user-images.githubusercontent.com/57086651/198815869-ae9cb88c-3ebd-4193-94ff-bed0c974269c.mov
|
|
30
27
|
|
|
28
|
+
|
|
31
29
|
<a href="https://github.com/Simon-He95/sponsor" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" style="height: 51px !important;width: 217px !important;" ></a>
|
|
32
30
|
|
|
33
31
|
## License
|
package/dist/index.js
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var N=require("module"),P=require("child_process"),x=require("fs"),D=require("path"),l=require("simon-js-tool"),O=require("fast-glob");function f(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var u=f(P),y=f(x),w=f(D),L=f(O),R=require;const F=R("yamljs");let d=[],c=null;async function k(){const{status:t}=u.default.spawnSync("gum -v",{shell:!0,encoding:"utf-8"});if(t!==0){console.log("install gum...");const{status:s}=u.default.spawnSync("brew install gum",{shell:!0});if(s!==0){const{status:o}=u.default.spawnSync(`sudo mkdir -p /etc/apt/keyrings
|
|
2
|
+
curl -fsSL https://repo.charm.sh/apt/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/charm.gpg
|
|
3
|
+
echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | sudo tee /etc/apt/sources.list.d/charm.list
|
|
4
|
+
sudo apt update && sudo apt install gum`,{shell:!0});if(o!==0)return console.log("gum install error")}console.log("gum install successfully")}const a=process.argv.slice(2);if(a[0]==="-v"){const{version:s}=await l.getPkg();console.log(`ccommand Version: ${s}`);return}const[i,n]=I(a);let e=i;const r=l.getPkgTool();if(a[0]==="find")if(r==="yarn")await v(),e=u.default.spawnSync(`echo ${d.join(",")} | sed "s/,/\\n/g" | gum filter`,{shell:!0,stdio:["inherit","pipe","inherit"],encoding:"utf8"}).output[1].trim();else if(r==="pnpm")await $(),e=u.default.spawnSync(`echo ${d.join(",")} | sed "s/,/\\n/g" | gum filter`,{shell:!0,stdio:["inherit","pipe","inherit"],encoding:"utf8"}).output[1].trim();else return console.log("find command only support yarn or pnpm");const p=await q();if(!p)return console.log("No scripts found");const m=[],_=Object.keys(p).reduce((s,o)=>{const g=p[o];return m.push(o),s+=`"${o}: ${g}",`,s},""),h=u.default.spawnSync(`echo ${_} | sed "s/,/\\n/g" | gum filter | cut -d' ' -f1`,{shell:!0,stdio:["inherit","pipe","inherit"],encoding:"utf8"}).output[1];if(!h)return console.log("\u5DF2\u53D6\u6D88"),process.exit();u.default.spawnSync(b(),{shell:!0,stdio:"inherit"});function S(s){return m.find(o=>s.startsWith(o))}function b(){let s="",o="";const g=r!=="yarn";return r==="npm"?(o=n?` -- ${n}`:"",s=e?` --prefix ${e} `:" "):r==="pnpm"?(o=n?` ${n}`:"",s=e?` --filter ${e.slice(e.lastIndexOf("/")+1)} `:" "):r==="yarn"?(o=n?` ${n}`:"",s=e?` workspace ${e.slice(e.lastIndexOf("/")+1)} `:" "):r==="bun"&&(o=n?` ${n}`:"",s=""),`${r}${g?" run":" "}${s}${S(h)}${o}`}async function q(){try{if(!e||r==="bun"||r==="npm")return(await l.getPkg("./package.json"))?.scripts;if(r==="pnpm")return(await $())[e]||(await l.getPkg(`${e}/package.json`))?.scripts;if(r==="yarn")return(await v())[e]||(await l.getPkg(`${e}/package.json`))?.scripts}catch{console.log("The package.json is not found in workspace or current directory, please check"),process.exit()}}}async function $(){if(c)return c;const t=await y.default.readFileSync(w.default.resolve(process.cwd(),"pnpm-workspace.yaml"),"utf-8"),a=F.parse(t)?.packages||[];return c=await j(a)||{},d=Object.keys(c),c}async function v(){if(c)return c;const t=await y.default.readFileSync(w.default.resolve(process.cwd(),"package.json"),"utf-8"),a=JSON.parse(t)?.workspaces||[];return c=await j(a)||{},d=Object.keys(c),c}function I(t){const a=t[0];return a?a.startsWith("--")?[".",t.join(" ")]:[a,t.slice(1).join(" ")]:["",""]}async function j(t){if(!t.length)return;const a=await L.default(t.map(i=>`${i}/package.json`),{dot:!0,ignore:["**/node_modules/**"]});return Promise.all(a.map(async i=>{const n=await l.getPkg(i);if(!n)return;const{name:e,scripts:r}=n;return{name:e,scripts:r}})).then(i=>i.reduce((n,e)=>{const{name:r,scripts:p}=e;return n[r]=p,n},{}))}k(),exports.ccommand=k;
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as
|
|
2
|
+
import{createRequire as D}from"module";import p from"child_process";import h from"fs";import w from"path";import{getPkg as l,getPkgTool as O}from"simon-js-tool";import P from"fast-glob";var q=D(import.meta.url);const F=q("yamljs");let f=[],a=null;async function y(){const{status:i}=p.spawnSync("gum -v",{shell:!0,encoding:"utf-8"});if(i!==0){console.log("install gum...");const{status:e}=p.spawnSync("brew install gum",{shell:!0});if(e!==0){const{status:o}=p.spawnSync(`sudo mkdir -p /etc/apt/keyrings
|
|
3
|
+
curl -fsSL https://repo.charm.sh/apt/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/charm.gpg
|
|
4
|
+
echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | sudo tee /etc/apt/sources.list.d/charm.list
|
|
5
|
+
sudo apt update && sudo apt install gum`,{shell:!0});if(o!==0)return console.log("gum install error")}console.log("gum install successfully")}const r=process.argv.slice(2);if(r[0]==="-v"){const{version:e}=await l();console.log(`ccommand Version: ${e}`);return}const[c,n]=N(r);let t=c;const s=O();if(r[0]==="find")if(s==="yarn")await $(),t=p.spawnSync(`echo ${f.join(",")} | sed "s/,/\\n/g" | gum filter`,{shell:!0,stdio:["inherit","pipe","inherit"],encoding:"utf8"}).output[1].trim();else if(s==="pnpm")await k(),t=p.spawnSync(`echo ${f.join(",")} | sed "s/,/\\n/g" | gum filter`,{shell:!0,stdio:["inherit","pipe","inherit"],encoding:"utf8"}).output[1].trim();else return console.log("find command only support yarn or pnpm");const u=await x();if(!u)return console.log("No scripts found");const g=[],S=Object.keys(u).reduce((e,o)=>{const m=u[o];return g.push(o),e+=`"${o}: ${m}",`,e},""),d=p.spawnSync(`echo ${S} | sed "s/,/\\n/g" | gum filter | cut -d' ' -f1`,{shell:!0,stdio:["inherit","pipe","inherit"],encoding:"utf8"}).output[1];if(!d)return console.log("\u5DF2\u53D6\u6D88"),process.exit();p.spawnSync(b(),{shell:!0,stdio:"inherit"});function v(e){return g.find(o=>e.startsWith(o))}function b(){let e="",o="";const m=s!=="yarn";return s==="npm"?(o=n?` -- ${n}`:"",e=t?` --prefix ${t} `:" "):s==="pnpm"?(o=n?` ${n}`:"",e=t?` --filter ${t.slice(t.lastIndexOf("/")+1)} `:" "):s==="yarn"?(o=n?` ${n}`:"",e=t?` workspace ${t.slice(t.lastIndexOf("/")+1)} `:" "):s==="bun"&&(o=n?` ${n}`:"",e=""),`${s}${m?" run":" "}${e}${v(d)}${o}`}async function x(){try{if(!t||s==="bun"||s==="npm")return(await l("./package.json"))?.scripts;if(s==="pnpm")return(await k())[t]||(await l(`${t}/package.json`))?.scripts;if(s==="yarn")return(await $())[t]||(await l(`${t}/package.json`))?.scripts}catch{console.log("The package.json is not found in workspace or current directory, please check"),process.exit()}}}async function k(){if(a)return a;const i=await h.readFileSync(w.resolve(process.cwd(),"pnpm-workspace.yaml"),"utf-8"),r=F.parse(i)?.packages||[];return a=await j(r)||{},f=Object.keys(a),a}async function $(){if(a)return a;const i=await h.readFileSync(w.resolve(process.cwd(),"package.json"),"utf-8"),r=JSON.parse(i)?.workspaces||[];return a=await j(r)||{},f=Object.keys(a),a}function N(i){const r=i[0];return r?r.startsWith("--")?[".",i.join(" ")]:[r,i.slice(1).join(" ")]:["",""]}async function j(i){if(!i.length)return;const r=await P(i.map(c=>`${c}/package.json`),{dot:!0,ignore:["**/node_modules/**"]});return Promise.all(r.map(async c=>{const n=await l(c);if(!n)return;const{name:t,scripts:s}=n;return{name:t,scripts:s}})).then(c=>c.reduce((n,t)=>{const{name:s,scripts:u}=t;return n[s]=u,n},{}))}y();export{y as ccommand};
|