ccommand 1.0.8 → 1.0.9
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 +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ npm install -g ccommand # 安装ccommand
|
|
|
18
18
|
- ccommand playground 选取当前目录下的playground文件夹下的package.json文件中的scripts中的命令
|
|
19
19
|
- ccommand playground -silent 支持额外的参数传参
|
|
20
20
|
|
|
21
|
-
https://user-images.githubusercontent.com/57086651/
|
|
21
|
+
https://user-images.githubusercontent.com/57086651/198815869-ae9cb88c-3ebd-4193-94ff-bed0c974269c.mov
|
|
22
22
|
|
|
23
23
|
<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>
|
|
24
24
|
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var O=require("module"),y=require("child_process"),_=require("fs"),j=require("path"),i=require("simon-js-tool"),q=require("fast-glob");function l(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var d=l(y),g=l(_),m=l(j),S=l(q),P=require;const b=P("yamljs");async function w(){const n=process.argv.slice(2);if(n[0]==="-v"){const{version:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var O=require("module"),y=require("child_process"),_=require("fs"),j=require("path"),i=require("simon-js-tool"),q=require("fast-glob");function l(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var d=l(y),g=l(_),m=l(j),S=l(q),P=require;const b=P("yamljs");async function w(){const n=process.argv.slice(2);if(n[0]==="-v"){const{version:t}=await i.getPkg();console.log(`ccommand Version: ${t}`);return}const[e,a]=x(n),r=i.getPkgTool(),o=await v();if(!o)return console.log("No scripts found");const c=[],f=Object.keys(o).reduce((t,s)=>{const u=o[s];return c.push(s),t+=`"${s}: ${u}",`,t},""),p=d.default.spawnSync(`echo ${f} | sed "s/,/\\n/g" | gum filter | cut -d' ' -f1`,{shell:!0,stdio:["inherit","pipe","inherit"],encoding:"utf8"}).output[1];if(!p)return console.log("\u5DF2\u53D6\u6D88"),process.exit();d.default.spawnSync($(),{shell:!0,stdio:"inherit"});function k(t){return c.find(s=>t.startsWith(s))}function $(){let t="",s="";const u=r!=="yarn";return r==="npm"?(s=a?` -- ${a}`:"",t=e?` --prefix ${e} `:" "):r==="pnpm"?(s=a?` ${a}`:"",t=e?` --filter ${e.slice(e.lastIndexOf("/")+1)} `:" "):r==="yarn"?(s=a?` ${a}`:"",t=e?` workspace ${e.slice(e.lastIndexOf("/")+1)} `:" "):r==="bun"&&(s=a?` ${a}`:"",t=""),`${r}${u?" run":" "}${t}${k(p)}${s}`}async function v(){try{if(!e||r==="bun"||r==="npm")return(await i.getPkg("./package.json"))?.scripts;if(r==="pnpm"){const t=await g.default.readFileSync(m.default.resolve(process.cwd(),"pnpm-workspace.yaml"),"utf-8"),s=b.parse(t)?.packages||[];return(await h(s))?.[e]||(await i.getPkg(`${e}/package.json`))?.scripts}else if(r==="yarn"){const t=await g.default.readFileSync(m.default.resolve(process.cwd(),"package.json"),"utf-8"),s=JSON.parse(t)?.workspaces||[];return(await h(s))?.[e]||(await i.getPkg(`${e}/package.json`))?.scripts}}catch{console.log("The package.json is not found in workspace or current directory, please check"),process.exit()}}}function x(n){const e=n[0];return e?e.startsWith("--")?[".",n.join(" ")]:[e,n.slice(1).join(" ")]:["",""]}async function h(n){if(!n.length)return;const e=await S.default(n.map(a=>`${a}/package.json`),{dot:!0,ignore:["**/node_modules/**"]});return Promise.all(e.map(async a=>{const r=await i.getPkg(a);if(!r)return;const{name:o,scripts:c}=r;return{name:o,scripts:c}})).then(a=>a.reduce((r,o)=>{const{name:c,scripts:f}=o;return r[c]=f,r},{}))}w(),exports.ccommand=w;
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as y}from"module";import l from"child_process";import m from"fs";import d from"path";import{getPkg as p,getPkgTool as j}from"simon-js-tool";import v from"fast-glob";var S=y(import.meta.url);const x=S("yamljs");async function g(){const o=process.argv.slice(2);if(o[0]==="-v"){const{version:
|
|
2
|
+
import{createRequire as y}from"module";import l from"child_process";import m from"fs";import d from"path";import{getPkg as p,getPkgTool as j}from"simon-js-tool";import v from"fast-glob";var S=y(import.meta.url);const x=S("yamljs");async function g(){const o=process.argv.slice(2);if(o[0]==="-v"){const{version:e}=await p();console.log(`ccommand Version: ${e}`);return}const[t,s]=b(o),r=j(),a=await h();if(!a)return console.log("No scripts found");const c=[],u=Object.keys(a).reduce((e,n)=>{const i=a[n];return c.push(n),e+=`"${n}: ${i}",`,e},""),f=l.spawnSync(`echo ${u} | sed "s/,/\\n/g" | gum filter | cut -d' ' -f1`,{shell:!0,stdio:["inherit","pipe","inherit"],encoding:"utf8"}).output[1];if(!f)return console.log("\u5DF2\u53D6\u6D88"),process.exit();l.spawnSync(k(),{shell:!0,stdio:"inherit"});function $(e){return c.find(n=>e.startsWith(n))}function k(){let e="",n="";const i=r!=="yarn";return r==="npm"?(n=s?` -- ${s}`:"",e=t?` --prefix ${t} `:" "):r==="pnpm"?(n=s?` ${s}`:"",e=t?` --filter ${t.slice(t.lastIndexOf("/")+1)} `:" "):r==="yarn"?(n=s?` ${s}`:"",e=t?` workspace ${t.slice(t.lastIndexOf("/")+1)} `:" "):r==="bun"&&(n=s?` ${s}`:"",e=""),`${r}${i?" run":" "}${e}${$(f)}${n}`}async function h(){try{if(!t||r==="bun"||r==="npm")return(await p("./package.json"))?.scripts;if(r==="pnpm"){const e=await m.readFileSync(d.resolve(process.cwd(),"pnpm-workspace.yaml"),"utf-8"),n=x.parse(e)?.packages||[];return(await w(n))?.[t]||(await p(`${t}/package.json`))?.scripts}else if(r==="yarn"){const e=await m.readFileSync(d.resolve(process.cwd(),"package.json"),"utf-8"),n=JSON.parse(e)?.workspaces||[];return(await w(n))?.[t]||(await p(`${t}/package.json`))?.scripts}}catch{console.log("The package.json is not found in workspace or current directory, please check"),process.exit()}}}function b(o){const t=o[0];return t?t.startsWith("--")?[".",o.join(" ")]:[t,o.slice(1).join(" ")]:["",""]}async function w(o){if(!o.length)return;const t=await v(o.map(s=>`${s}/package.json`),{dot:!0,ignore:["**/node_modules/**"]});return Promise.all(t.map(async s=>{const r=await p(s);if(!r)return;const{name:a,scripts:c}=r;return{name:a,scripts:c}})).then(s=>s.reduce((r,a)=>{const{name:c,scripts:u}=a;return r[c]=u,r},{}))}g();export{g as ccommand};
|