@initx-plugin/core 0.0.35 → 0.0.37
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 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -114,9 +114,10 @@ declare abstract class InitxPlugin<TStore extends object = object> {
|
|
|
114
114
|
private executeHandle;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
declare function detectManager(): boolean;
|
|
117
118
|
declare function installManager(): Promise<void>;
|
|
118
119
|
|
|
119
120
|
declare function createStore(name: string, defaultStore?: Record<string, any>): Record<string, any>;
|
|
120
121
|
declare function writeStore(name: string): void;
|
|
121
122
|
|
|
122
|
-
export { type HandlerInfo, INITX_DIR, type InitxBaseContext, type InitxContext, type InitxMatcherRules, InitxPlugin, type InitxPluginInfo, type LoadPluginResult, type MatchedPlugin, NODE_MODULES_DIR, PLUGIN_DIR, type PackageInfo, STORE_DIR, STORE_FILE_NAME, createStore, fetchPlugins, installManager, loadPlugins, matchPlugins, withPluginPrefix, writeStore };
|
|
123
|
+
export { type HandlerInfo, INITX_DIR, type InitxBaseContext, type InitxContext, type InitxMatcherRules, InitxPlugin, type InitxPluginInfo, type LoadPluginResult, type MatchedPlugin, NODE_MODULES_DIR, PLUGIN_DIR, type PackageInfo, STORE_DIR, STORE_FILE_NAME, createStore, detectManager, fetchPlugins, installManager, loadPlugins, matchPlugins, withPluginPrefix, writeStore };
|
package/dist/index.d.ts
CHANGED
|
@@ -114,9 +114,10 @@ declare abstract class InitxPlugin<TStore extends object = object> {
|
|
|
114
114
|
private executeHandle;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
declare function detectManager(): boolean;
|
|
117
118
|
declare function installManager(): Promise<void>;
|
|
118
119
|
|
|
119
120
|
declare function createStore(name: string, defaultStore?: Record<string, any>): Record<string, any>;
|
|
120
121
|
declare function writeStore(name: string): void;
|
|
121
122
|
|
|
122
|
-
export { type HandlerInfo, INITX_DIR, type InitxBaseContext, type InitxContext, type InitxMatcherRules, InitxPlugin, type InitxPluginInfo, type LoadPluginResult, type MatchedPlugin, NODE_MODULES_DIR, PLUGIN_DIR, type PackageInfo, STORE_DIR, STORE_FILE_NAME, createStore, fetchPlugins, installManager, loadPlugins, matchPlugins, withPluginPrefix, writeStore };
|
|
123
|
+
export { type HandlerInfo, INITX_DIR, type InitxBaseContext, type InitxContext, type InitxMatcherRules, InitxPlugin, type InitxPluginInfo, type LoadPluginResult, type MatchedPlugin, NODE_MODULES_DIR, PLUGIN_DIR, type PackageInfo, STORE_DIR, STORE_FILE_NAME, createStore, detectManager, fetchPlugins, installManager, loadPlugins, matchPlugins, withPluginPrefix, writeStore };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{homedir as D}from"node:os";import a from"fs-extra";import p,{resolve as f}from"pathe";import{useInitxMatcher as R}from"matchinitx";import{defu as E}from"defu";import M from"node:process";import{c as J}from"@initx-plugin/utils";const m=f(D(),".initx"),y=f(m,"stores"),h="store.json",c=f(m,"plugins"),x=a.existsSync(f(c,"lib"))?"lib/node_modules":"node_modules";let d=!1,g={};const S=o=>p.resolve(y,o,h);function I(o,n={}){a.ensureDirSync(p.resolve(y,o));const t=S(o),i=r=>(k(t,r),L(r));if(!a.existsSync(t))return i(n);let e;try{const r=a.readJsonSync(t);e=E(r,n)}catch{e=n}return i(e)}function w(o){d&&k(S(o),g)}function k(o,n){a.writeJsonSync(o,n,{spaces:2})}function L(o={}){const n=i=>typeof i=="object"&&i!==null&&new Set(["[object Object]","[object Array]"]).has(Object.prototype.toString.call(i)),t=i=>new Proxy(i,{get(e,r){const s=Reflect.get(e,r);return n(s)?t(s):s},set(e,r,s){const l=Reflect.set(e,r,s);return d=!0,l},deleteProperty(e,r){const s=Reflect.deleteProperty(e,r);return d=!0,s}});return g=t(o),g}const P={plugin:/^(?:@initx-plugin\/|initx-plugin-)/,exclude:/@initx-plugin\/(?:core|utils)$/};async function v(o){const n=p.resolve(o,"package.json");if(!a.existsSync(n))return[];const t=a.readJsonSync(n),{dependencies:i={},devDependencies:e={}}=t;return Object.keys({...i,...e}).filter(r=>P.plugin.test(r)&&!P.exclude.test(r)).map(r=>({name:r,root:p.resolve(o,"node_modules",r)}))}async function N(){return v(M.cwd())}async function O(){return a.existsSync(c)?v(c):(a.ensureDirSync(c),[])}async function $(){const o=await N(),n=o.map(({name:e})=>e),t=[...(await O()).filter(({name:e})=>!n.includes(e)),...o],i=await import("importx");return Promise.all(t.map(async({root:e})=>{const r=await i.import(e,import.meta.url).then(l=>l.default),s=a.readJsonSync(p.resolve(e,"package.json"));return{packageInfo:{root:e,name:s.name,version:s.version,description:s.description,author:s.author,homepage:s.homepage},instance:new r}}))}async function T(o,{key:n,cliOptions:t},...i){const e=[];for(const r of o){const{instance:s,packageInfo:l}=r,b=await s.run({key:n,cliOptions:t,packageInfo:l,optionsList:Object.keys(t).filter(u=>t[u]===!0).map(u=>`--${u}`)},...i);e.push(...b.map(u=>({handler:u.handler,description:u.description,packageInfo:l})))}return e}function A(o,n){return o.some(t=>typeof t=="string"||typeof t>"u"?t===n:t.test(n))}function j(o){return o.push("--prefix",c),o}class H{defaultStore;async run(n,...t){const i=R((e,...r)=>({handler:()=>this.executeHandle(n,e,...r),...e}));return(await Promise.all(i.match(this.rules,n.key,...t).map(async e=>e.verify&&!e.verify(n,...t)||e.optional&&!A(e.optional,t[0])?!1:e))).filter(Boolean)}async executeHandle(n,t,...i){const e=I(n.packageInfo.name,this.defaultStore);await this.handle({...n,rule:t,store:e},...i),w(n.packageInfo.name)}}const _="@initx-plugin/manager";function U(){return a.existsSync(f(c,x,_))}async function B(){await J("npm",j(["install",_]))}export{m as INITX_DIR,H as InitxPlugin,x as NODE_MODULES_DIR,c as PLUGIN_DIR,y as STORE_DIR,h as STORE_FILE_NAME,I as createStore,U as detectManager,O as fetchPlugins,B as installManager,$ as loadPlugins,T as matchPlugins,j as withPluginPrefix,w as writeStore};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@initx-plugin/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.37",
|
|
5
5
|
"description": "core module for initx plugins",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/initx-collective/initx#readme",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"importx": "^0.5.2",
|
|
28
28
|
"matchinitx": "^0.0.4",
|
|
29
29
|
"pathe": "^2.0.3",
|
|
30
|
-
"@initx-plugin/utils": "0.0.
|
|
30
|
+
"@initx-plugin/utils": "0.0.37"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/fs-extra": "^11.0.4"
|