initx 0.3.5 → 0.3.6

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.
@@ -1 +1 @@
1
- import x from"node:process";import{detectManager as k,installManager as C,loadPlugins as F,matchPlugins as I}from"@initx-plugin/core";import{inquirer as L,loadingFunction as O,logger as D}from"@initx-plugin/utils";import N from"cac";const R={version:"0.3.5"};function f(){const e=N("initx");return e.help().command("<something>","see https://github.com/initx-collective/initx").usage("").option("-v, --version","Display version number").option("-d, --debug","Debug mode"),e}function m(e){const t=f(),{args:s,options:o}=t.parse(e);if(o.h||o.help)return{type:"help"};if(o.v||o.version)return{type:"version"};const[u,...r]=s;return{type:"run",input:{key:u,others:r,cliOptions:o}}}const j=/^@?initx-plugin[-/]/;function q(e){return Object.keys(e).filter(t=>e[t]===!0).map(t=>`--${t}`)}async function b(e,t){const{detectManager:s,installManager:o,loadPlugins:u,loadingFunction:r,logger:n,matchPlugins:y,select:v}=t,{key:a,others:w,cliOptions:l}=e;if((l.d||l.debug)&&(n.setLevel("debug"),n.debug("Debug mode enabled")),!a||typeof a!="string"){n.error("Please enter something");return}n.debug(`Input: ${a}`);let g=!1;await r("initx",async()=>{g=await s()}),n.debug(`Manager: ${g?"installed":"not found"}`),g||await r("Installing manager plugin",o);const c=await r("Loading plugins",u);if(c.length===0){n.error("No plugin installed");return}n.debug(`Loaded ${c.length} plugins`);const $={key:a,cliOptions:l,optionsList:q(l)},i=await y(c,$,...w);if(n.debug(`Matched ${i.length} handlers`),i.length===0){n.warn("No handler found");return}if(i.length===1){const[{handler:p,description:h}]=i;n.debug(`Running: ${h}`),await p();return}const d=await v("Which handler do you want to run?",i.map(({description:p,packageInfo:h})=>`[${h.name.replace(j,"")}] ${p}`));if(!i[d]||typeof i[d].handler!="function"){n.error("Handler not found");return}const{handler:M,description:P}=i[d];n.debug(`Running: ${P}`),await M()}const H={detectManager:k,installManager:C,loadPlugins:F,matchPlugins:I,select:L.select,loadingFunction:O,logger:D};async function W(e=x.argv){const t=m(e);return t.type==="help"?0:t.type==="version"?(console.log(R.version),0):(await b(t.input,H),0)}export{f as createCli,m as parseCliInput,b as runCli,W as runCliFromProcess};
1
+ import x from"node:process";import{detectManager as k,installManager as C,loadPlugins as F,matchPlugins as I}from"@initx-plugin/core";import{inquirer as L,loadingFunction as O,logger as D}from"@initx-plugin/utils";import N from"cac";const R={version:"0.3.6"};function f(){const e=N("initx");return e.help().command("<something>","see https://github.com/initx-collective/initx").usage("").option("-v, --version","Display version number").option("-d, --debug","Debug mode"),e}function m(e){const t=f(),{args:s,options:o}=t.parse(e);if(o.h||o.help)return{type:"help"};if(o.v||o.version)return{type:"version"};const[u,...r]=s;return{type:"run",input:{key:u,others:r,cliOptions:o}}}const j=/^@?initx-plugin[-/]/;function q(e){return Object.keys(e).filter(t=>e[t]===!0).map(t=>`--${t}`)}async function b(e,t){const{detectManager:s,installManager:o,loadPlugins:u,loadingFunction:r,logger:n,matchPlugins:y,select:v}=t,{key:a,others:w,cliOptions:l}=e;if((l.d||l.debug)&&(n.setLevel("debug"),n.debug("Debug mode enabled")),!a||typeof a!="string"){n.error("Please enter something");return}n.debug(`Input: ${a}`);let g=!1;await r("initx",async()=>{g=await s()}),n.debug(`Manager: ${g?"installed":"not found"}`),g||await r("Installing manager plugin",o);const c=await r("Loading plugins",u);if(c.length===0){n.error("No plugin installed");return}n.debug(`Loaded ${c.length} plugins`);const $={key:a,cliOptions:l,optionsList:q(l)},i=await y(c,$,...w);if(n.debug(`Matched ${i.length} handlers`),i.length===0){n.warn("No handler found");return}if(i.length===1){const[{handler:p,description:h}]=i;n.debug(`Running: ${h}`),await p();return}const d=await v("Which handler do you want to run?",i.map(({description:p,packageInfo:h})=>`[${h.name.replace(j,"")}] ${p}`));if(!i[d]||typeof i[d].handler!="function"){n.error("Handler not found");return}const{handler:M,description:P}=i[d];n.debug(`Running: ${P}`),await M()}const H={detectManager:k,installManager:C,loadPlugins:F,matchPlugins:I,select:L.select,loadingFunction:O,logger:D};async function W(e=x.argv){const t=m(e);return t.type==="help"?0:t.type==="version"?(console.log(R.version),0):(await b(t.input,H),0)}export{f as createCli,m as parseCliInput,b as runCli,W as runCliFromProcess};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "initx",
3
3
  "type": "module",
4
- "version": "0.3.5",
4
+ "version": "0.3.6",
5
5
  "description": "A more convenient scripting engine",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/initx-collective/initx#readme",
@@ -28,8 +28,8 @@
28
28
  ],
29
29
  "dependencies": {
30
30
  "cac": "^7.0.0",
31
- "@initx-plugin/utils": "0.3.5",
32
- "@initx-plugin/core": "0.3.5"
31
+ "@initx-plugin/utils": "0.3.6",
32
+ "@initx-plugin/core": "0.3.6"
33
33
  },
34
34
  "scripts": {
35
35
  "stub": "unbuild --stub",