@initx-plugin/manager 0.0.5 → 0.0.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.d.mts +2 -5
- package/dist/index.d.ts +2 -5
- package/dist/index.mjs +1 -1
- package/package.json +18 -14
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { InitxPlugin, InitxContext } from '@initx-plugin/core';
|
|
1
|
+
import { InitxPlugin, InitxMatcherRules, InitxContext } from '@initx-plugin/core';
|
|
2
2
|
|
|
3
3
|
declare class PluginManagerPlugin extends InitxPlugin {
|
|
4
|
-
rules:
|
|
5
|
-
matching: string;
|
|
6
|
-
description: string;
|
|
7
|
-
}[];
|
|
4
|
+
rules: InitxMatcherRules;
|
|
8
5
|
handle(context: InitxContext, type: string, ...others: string[]): Promise<void>;
|
|
9
6
|
}
|
|
10
7
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { InitxPlugin, InitxContext } from '@initx-plugin/core';
|
|
1
|
+
import { InitxPlugin, InitxMatcherRules, InitxContext } from '@initx-plugin/core';
|
|
2
2
|
|
|
3
3
|
declare class PluginManagerPlugin extends InitxPlugin {
|
|
4
|
-
rules:
|
|
5
|
-
matching: string;
|
|
6
|
-
description: string;
|
|
7
|
-
}[];
|
|
4
|
+
rules: InitxMatcherRules;
|
|
8
5
|
handle(context: InitxContext, type: string, ...others: string[]): Promise<void>;
|
|
9
6
|
}
|
|
10
7
|
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fetchPlugins as v,InitxPlugin as
|
|
1
|
+
import{fetchPlugins as v,PLUGIN_DIR as S,InitxPlugin as C}from"@initx-plugin/core";import{c as d,loadingFunction as g,log as m,inquirer as f}from"@initx-plugin/utils";import{green as j,blue as J,dim as y,reset as I,gray as w}from"picocolors";import b from"node:path";import N from"columnify";import D from"fs-extra";const h={once:!1,names:[]},P=n=>`@initx-plugin/${n}`,x=n=>`initx-plugin-${n}`;function O(n){return/^@initx-plugin\/|^initx-plugin-/.test(n)}function R(n,e){return P(n)===e||x(n)===e}function l(n){return/^@initx-plugin\//.test(n)?j(n):J(n)}async function A(){if(h.once)return h.names;const n=await v();return h.names=n.map(({name:e})=>e),h.once=!0,h.names}async function L(n){return(await A()).includes(n)}async function U(n){const e=[],t=[];for(const i of n){const a=await d("npm",["search","--json",i]);if(a.success)try{JSON.parse(a.content).forEach(s=>{t.includes(s.name)||(t.push(s.name),e.push({name:s.name,version:s.version,description:s.description}))})}catch{return[]}}return e}async function M(n){const e=await g("Searching plugin",()=>W(n));if(e.length===0){m.error(`Plugin ${l(P(n))} or ${l(x(n))} not found`);return}let t=0,i=!0;if(e.length===2){const o=[];for(const r of e)o.push(await E(r,!0));t=await f.select("Which plugin do you want to install?",o),i=!1}const a={name:e[t].name,version:e[t].version,description:e[t].description};if(i&&!await f.confirm(`Do you want to install ${await E(a)} ?`)){m.warn("Installation canceled");return}const s=await g("Installing plugin",()=>q(a.name));if(!s.success){m.error(`Failed to install plugin ${l(a.name)}`),console.log(s.content);return}m.success(`Plugin ${l(a.name)} installed`)}async function W(n){const e=[P(n),x(n)];return(await U(e))?.filter(t=>O(t.name)&&R(n,t.name))}async function q(n){return d("npm",["install","-g",n,"--prefix",S])}async function E({name:n,version:e,description:t},i=!1){const a=await L(n),s=i?" ":" ",o={name:l(n),version:I(y(w(`@${e}`))),description:`${s}${I(t)}`,installed:a?y(j(" [already]")):s};return`${o.name}${o.version}${o.installed}${o.description}`}async function G(){const n=await g("Fetching plugins",v),e=[];n.forEach(({root:t})=>{const i=D.readJsonSync(b.join(t,"package.json"));e.push({name:l(i.name),version:w(i.version),description:w(i.description)})}),console.log(N(e))}async function _(n){const e=await v(),t=[P(n),x(n)],i=e.filter(({name:r})=>t.includes(r));if(i.length===0){const r=t.map(l).join(" or ");m.warn(`Plugin ${r} is not installed`);return}let a=0,s=!0;i.length===2&&(a=await f.select("Which plugin do you want to remove?",i.map(({name:r})=>l(r))),s=!1);const o=i[a];s&&!await f.confirm(`Are you sure you want to remove ${l(o.name)}?`)||(await g(`Removing ${l(o.name)}...`,()=>d("npm",["uninstall","-g",o.name])),m.success(`Removed ${l(o.name)}`))}async function z(n){const e=n.dev||!1,[t,i]=await g("Fetching plugins",()=>Promise.all([B(),v()])),a=[],s=i.reduce((c,{name:u,root:p})=>(!e&&t.includes(u)||(a.push(u),c[u]=p),c),{}),o=await g("Checking plugins",()=>U(a)),r=[];if(Object.keys(s).forEach(c=>{const u=D.readJsonSync(b.join(s[c],"package.json")),p=o.find(F=>F.name===c);if(!p)return;const $=t.includes(c);($?!e:u.version===p.version)||r.push({name:c,version:u.version,target:p.version,isDev:$})}),r.length===0){m.success("All plugins are up to date");return}if(m.info("Need update plugins:"),console.log(N(r.map(({name:c,version:u,target:p,isDev:$})=>({name:l(c),version:y(w(`${$?"[dev] ":""}${u}`)),target:p})))),!await f.confirm("Do you want to update these plugins?")){m.warn("Update canceled");return}const k=r.map(({name:c,target:u})=>`${l(c)}${y(w(`@${u}`))}`).join(" ");await g(`Updating ${k}`,()=>d("npm",["install","-g",...r.map(({name:c,target:u})=>`${c}@${u}`)])),m.success(`Plugins updated: ${k}`)}async function B(){const n=await d("npm",["list","-g","--depth=0"]),e=[];return n.content.split(/\r?\n/).forEach(t=>{const i=/(?:@initx-plugin\/|initx-plugin-)[^@]+/.exec(t);i&&t.includes("->")&&e.push(i[0])}),e}class H extends C{rules=[{matching:"plugin",description:"Plugin Manager",optional:["list","add","update","remove"]}];async handle(e,t,...i){const[a]=i;switch(t){case"list":{await G();break}case"add":{await M(a);break}case"update":{await z(e.cliOptions);break}case"remove":{await _(a);break}default:m.warn(`Unknown command: ${t}`)}}}export{H as default};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@initx-plugin/manager",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.7",
|
|
5
5
|
"description": "initx plugin manager",
|
|
6
6
|
"author": "imba97",
|
|
7
7
|
"license": "MIT",
|
|
@@ -23,35 +23,39 @@
|
|
|
23
23
|
"files": [
|
|
24
24
|
"dist"
|
|
25
25
|
],
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@initx-plugin/core": "^0.0.32",
|
|
28
|
+
"@initx-plugin/utils": "^0.0.32"
|
|
29
|
+
},
|
|
26
30
|
"dependencies": {
|
|
27
|
-
"@initx-plugin/core": "^0.0.28",
|
|
28
|
-
"@initx-plugin/utils": "^0.0.28",
|
|
29
31
|
"columnify": "^1.6.0",
|
|
30
|
-
"fs-extra": "^11.
|
|
32
|
+
"fs-extra": "^11.3.0",
|
|
31
33
|
"picocolors": "^1.1.1"
|
|
32
34
|
},
|
|
33
35
|
"devDependencies": {
|
|
34
|
-
"@imba97/eslint-config": "^0.0.
|
|
36
|
+
"@imba97/eslint-config": "^0.0.6",
|
|
37
|
+
"@initx-plugin/core": "^0.0.32",
|
|
38
|
+
"@initx-plugin/utils": "^0.0.32",
|
|
35
39
|
"@types/columnify": "^1.5.4",
|
|
36
40
|
"@types/fs-extra": "^11.0.4",
|
|
37
|
-
"@types/node": "^22.
|
|
38
|
-
"bumpp": "^
|
|
39
|
-
"eslint": "^9.
|
|
40
|
-
"lint-staged": "^15.
|
|
41
|
-
"simple-git-hooks": "^2.
|
|
42
|
-
"typescript": "^5.
|
|
43
|
-
"unbuild": "^3.
|
|
41
|
+
"@types/node": "^22.13.14",
|
|
42
|
+
"bumpp": "^10.1.0",
|
|
43
|
+
"eslint": "^9.23.0",
|
|
44
|
+
"lint-staged": "^15.5.0",
|
|
45
|
+
"simple-git-hooks": "^2.12.1",
|
|
46
|
+
"typescript": "^5.8.2",
|
|
47
|
+
"unbuild": "^3.5.0"
|
|
44
48
|
},
|
|
45
49
|
"simple-git-hooks": {
|
|
46
50
|
"pre-commit": "pnpm lint-staged"
|
|
47
51
|
},
|
|
48
52
|
"lint-staged": {
|
|
49
|
-
"*": "eslint --cache --
|
|
53
|
+
"*": "eslint --cache --fix"
|
|
50
54
|
},
|
|
51
55
|
"scripts": {
|
|
52
56
|
"stub": "unbuild --stub",
|
|
53
57
|
"build": "unbuild",
|
|
54
58
|
"release": "bumpp",
|
|
55
|
-
"lint": "eslint --cache
|
|
59
|
+
"lint": "eslint --cache"
|
|
56
60
|
}
|
|
57
61
|
}
|