@initx-plugin/manager 0.0.5 → 0.0.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.
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 U}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 C,reset as b,dim as y,gray as w}from"picocolors";import N from"node:path";import I from"columnify";import D from"fs-extra";const h={once:!1,names:[]},P=n=>`@initx-plugin/${n}`,x=n=>`initx-plugin-${n}`;function J(n){return/^@initx-plugin\/|^initx-plugin-/.test(n)}function O(n,e){return P(n)===e||x(n)===e}function u(n){return/^@initx-plugin\//.test(n)?j(n):C(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 M(n){return(await A()).includes(n)}async function E(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 R(n){const e=await g("Searching plugin",()=>W(n));if(e.length===0){m.error(`Plugin ${u(P(n))} or ${u(x(n))} not found`);return}let t=0,i=!0;if(e.length===2){const o=[];for(const r of e)o.push(await F(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 F(a)} ?`)){m.warn("Installation canceled");return}const s=await g("Installing plugin",()=>q(a.name));if(!s.success){m.error(`Failed to install plugin ${u(a.name)}`),console.log(s.content);return}m.success(`Plugin ${u(a.name)} installed`)}async function W(n){const e=[P(n),x(n)];return(await E(e))?.filter(t=>J(t.name)&&O(n,t.name))}async function q(n){return d("npm",["install","-g",n])}async function F({name:n,version:e,description:t},i=!1){const a=await M(n),s=i?" ":" ",o={name:u(n),version:b(y(w(`@${e}`))),description:`${s}${b(t)}`,installed:a?y(j(" [already]")):s};return`${o.name}${o.version}${o.installed}${o.description}`}async function L(){const n=await g("Fetching plugins",v),e=[];n.forEach(({root:t})=>{const i=D.readJsonSync(N.join(t,"package.json"));e.push({name:u(i.name),version:w(i.version),description:w(i.description)})}),console.log(I(e))}async function z(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(u).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})=>u(r))),s=!1);const o=i[a];s&&!await f.confirm(`Are you sure you want to remove ${u(o.name)}?`)||(await g(`Removing ${u(o.name)}...`,()=>d("npm",["uninstall","-g",o.name])),m.success(`Removed ${u(o.name)}`))}async function B(n){const e=n.dev||!1,[t,i]=await g("Fetching plugins",()=>Promise.all([G(),v()])),a=[],s=i.reduce((c,{name:l,root:p})=>(!e&&t.includes(l)||(a.push(l),c[l]=p),c),{}),o=await g("Checking plugins",()=>E(a)),r=[];if(Object.keys(s).forEach(c=>{const l=D.readJsonSync(N.join(s[c],"package.json")),p=o.find(S=>S.name===c);if(!p)return;const $=t.includes(c);($?!e:l.version===p.version)||r.push({name:c,version:l.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(I(r.map(({name:c,version:l,target:p,isDev:$})=>({name:u(c),version:y(w(`${$?"[dev] ":""}${l}`)),target:p})))),!await f.confirm("Do you want to update these plugins?")){m.warn("Update canceled");return}const k=r.map(({name:c,target:l})=>`${u(c)}${y(w(`@${l}`))}`).join(" ");await g(`Updating ${k}`,()=>d("npm",["install","-g",...r.map(({name:c,target:l})=>`${c}@${l}`)])),m.success(`Plugins updated: ${k}`)}async function G(){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 U{rules=[{matching:"plugin",description:"Plugin Manager"}];async handle(e,t,...i){const[a]=i;switch(t){case"list":{await L();break}case"add":{await R(a);break}case"update":{await B(e.cliOptions);break}case"remove":{await z(a);break}default:m.warn(`Unknown command: ${t}`)}}}export{H as default};
1
+ import{fetchPlugins as v,InitxPlugin as U}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 C,dim as y,reset as b,gray as w}from"picocolors";import N from"node:path";import I from"columnify";import D from"fs-extra";const h={once:!1,names:[]},P=n=>`@initx-plugin/${n}`,x=n=>`initx-plugin-${n}`;function J(n){return/^@initx-plugin\/|^initx-plugin-/.test(n)}function O(n,e){return P(n)===e||x(n)===e}function l(n){return/^@initx-plugin\//.test(n)?j(n):C(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 M(n){return(await A()).includes(n)}async function E(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 R(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 F(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 F(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 E(e))?.filter(t=>J(t.name)&&O(n,t.name))}async function q(n){return d("npm",["install","-g",n])}async function F({name:n,version:e,description:t},i=!1){const a=await M(n),s=i?" ":" ",o={name:l(n),version:b(y(w(`@${e}`))),description:`${s}${b(t)}`,installed:a?y(j(" [already]")):s};return`${o.name}${o.version}${o.installed}${o.description}`}async function L(){const n=await g("Fetching plugins",v),e=[];n.forEach(({root:t})=>{const i=D.readJsonSync(N.join(t,"package.json"));e.push({name:l(i.name),version:w(i.version),description:w(i.description)})}),console.log(I(e))}async function z(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 B(n){const e=n.dev||!1,[t,i]=await g("Fetching plugins",()=>Promise.all([G(),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",()=>E(a)),r=[];if(Object.keys(s).forEach(c=>{const u=D.readJsonSync(N.join(s[c],"package.json")),p=o.find(S=>S.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(I(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 G(){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 U{rules=[{matching:"plugin",description:"Plugin Manager",optional:["list","add","update","remove"]}];async handle(e,t,...i){const[a]=i;switch(t){case"list":{await L();break}case"add":{await R(a);break}case"update":{await B(e.cliOptions);break}case"remove":{await z(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.5",
4
+ "version": "0.0.6",
5
5
  "description": "initx plugin manager",
6
6
  "author": "imba97",
7
7
  "license": "MIT",
@@ -24,34 +24,34 @@
24
24
  "dist"
25
25
  ],
26
26
  "dependencies": {
27
- "@initx-plugin/core": "^0.0.28",
28
- "@initx-plugin/utils": "^0.0.28",
27
+ "@initx-plugin/core": "^0.0.30",
28
+ "@initx-plugin/utils": "^0.0.30",
29
29
  "columnify": "^1.6.0",
30
- "fs-extra": "^11.2.0",
30
+ "fs-extra": "^11.3.0",
31
31
  "picocolors": "^1.1.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@imba97/eslint-config": "^0.0.5",
35
35
  "@types/columnify": "^1.5.4",
36
36
  "@types/fs-extra": "^11.0.4",
37
- "@types/node": "^22.10.2",
38
- "bumpp": "^9.9.2",
39
- "eslint": "^9.17.0",
40
- "lint-staged": "^15.3.0",
37
+ "@types/node": "^22.13.9",
38
+ "bumpp": "^10.0.3",
39
+ "eslint": "^9.21.0",
40
+ "lint-staged": "^15.4.3",
41
41
  "simple-git-hooks": "^2.11.1",
42
- "typescript": "^5.7.2",
43
- "unbuild": "^3.1.0"
42
+ "typescript": "^5.8.2",
43
+ "unbuild": "^3.5.0"
44
44
  },
45
45
  "simple-git-hooks": {
46
46
  "pre-commit": "pnpm lint-staged"
47
47
  },
48
48
  "lint-staged": {
49
- "*": "eslint --cache --flag unstable_ts_config --fix"
49
+ "*": "eslint --cache --fix"
50
50
  },
51
51
  "scripts": {
52
52
  "stub": "unbuild --stub",
53
53
  "build": "unbuild",
54
54
  "release": "bumpp",
55
- "lint": "eslint --cache --flag unstable_ts_config"
55
+ "lint": "eslint --cache"
56
56
  }
57
57
  }