@initx-plugin/core 0.0.28 → 0.0.29
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -96,4 +96,4 @@ declare abstract class InitxPlugin<TStore extends object = object> {
|
|
|
96
96
|
declare function createStore(name: string, defaultStore?: Record<string, any>): any;
|
|
97
97
|
declare function writeStore(name: string): void;
|
|
98
98
|
|
|
99
|
-
export { type HandlerInfo, type InitxBaseContext, type InitxContext, type InitxMatcherRules
|
|
99
|
+
export { type HandlerInfo, type InitxBaseContext, type InitxContext, type InitxMatcherRules, InitxPlugin, type InitxPluginInfo, type LoadPluginResult, type MatchedPlugin, type PackageInfo, createStore, fetchPlugins, loadPlugins, matchPlugins, writeStore };
|
package/dist/index.d.ts
CHANGED
|
@@ -96,4 +96,4 @@ declare abstract class InitxPlugin<TStore extends object = object> {
|
|
|
96
96
|
declare function createStore(name: string, defaultStore?: Record<string, any>): any;
|
|
97
97
|
declare function writeStore(name: string): void;
|
|
98
98
|
|
|
99
|
-
export { type HandlerInfo, type InitxBaseContext, type InitxContext, type InitxMatcherRules
|
|
99
|
+
export { type HandlerInfo, type InitxBaseContext, type InitxContext, type InitxMatcherRules, InitxPlugin, type InitxPluginInfo, type LoadPluginResult, type MatchedPlugin, type PackageInfo, createStore, fetchPlugins, loadPlugins, matchPlugins, writeStore };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useInitxMatcher as
|
|
1
|
+
import{useInitxMatcher as k}from"matchinitx";import{homedir as w}from"node:os";import a from"node:path";import{defu as I}from"defu";import s from"fs-extra";import d from"node:process";import{c as $}from"@initx-plugin/utils";let m=null;const f=a.resolve(w(),".initx"),v="store.json",g=n=>a.resolve(f,n,v);function y(n,o={}){s.ensureDirSync(a.resolve(f,n));const i=g(n),e=c=>(x(i,c),O(c));if(!s.existsSync(i))return e(o);let t;try{const c=s.readJsonSync(i);t=I(c,o)}catch{t=o}return e(t)}function h(n){m&&x(g(n),m)}function x(n,o){s.writeJsonSync(n,o,{spaces:2})}function O(n={}){const o=e=>Object.prototype.toString.call(e)==="[object Object]",i=e=>new Proxy(e,{get(t,c){const r=Reflect.get(t,c);return o(r)?i(r):r},set(t,c,r){const u=Reflect.set(t,c,r);return m=t,u}});return i(n)}class P{defaultStore;run(o,...i){return k((e,...t)=>({handler:()=>this.executeHandle(o,e,...t),description:e.description})).match(this.rules,o.key,...i)}async executeHandle(o,i,...e){const t=y(o.packageInfo.name,this.defaultStore);await this.handle({...o,rule:i,store:t},...e),h(o.packageInfo.name)}}const l={plugin:/^(?:@initx-plugin\/|initx-plugin-)/,exclude:/@initx-plugin\/(?:core|utils)$/};async function b(){const n=a.join(d.cwd(),"package.json");if(!s.existsSync(n))return[];const o=s.readJsonSync(n),{dependencies:i={},devDependencies:e={}}=o;return Object.keys({...i,...e}).filter(t=>l.plugin.test(t)&&!l.exclude.test(t)).map(t=>({name:t,root:a.join(d.cwd(),"node_modules",t)}))}async function S(){const{content:n}=await $("npm",["root","-g"]),o=s.readdirSync(n),i=a.join(n,"@initx-plugin");return[...s.existsSync(i)?s.readdirSync(i).map(e=>`@initx-plugin/${e}`):[],...o].filter(e=>l.plugin.test(e)&&!l.exclude.test(e)).map(e=>({name:e,root:a.join(n,e)}))}async function J(){const n=await b(),o=n.map(({name:t})=>t),i=[...(await S()).filter(({name:t})=>!o.includes(t)),...n],e=await import("importx");return Promise.all(i.map(async({root:t})=>{const c=await e.import(t,import.meta.url).then(u=>u.default),r=s.readJsonSync(a.join(t,"package.json"));return{packageInfo:{root:t,name:r.name,version:r.version,description:r.description,author:r.author,homepage:r.homepage},instance:new c}}))}function D(n,{key:o,cliOptions:i},...e){const t=[];for(const c of n){const{instance:r,packageInfo:u}=c,j=r.run({key:o,cliOptions:i,packageInfo:u,optionsList:Object.keys(i).filter(p=>i[p]===!0).map(p=>`--${p}`)},...e);t.push(...j.map(p=>({handler:p.handler,description:p.description,packageInfo:u})))}return t}export{P as InitxPlugin,y as createStore,S as fetchPlugins,J as loadPlugins,D as matchPlugins,h 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.29",
|
|
5
5
|
"description": "core module for initx plugins",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/initx-collective/initx#readme",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"fs-extra": "^11.2.0",
|
|
27
27
|
"importx": "^0.5.1",
|
|
28
28
|
"matchinitx": "^0.0.2",
|
|
29
|
-
"@initx-plugin/utils": "0.0.
|
|
29
|
+
"@initx-plugin/utils": "0.0.29"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/fs-extra": "^11.0.4"
|