@initx-plugin/core 0.0.31 → 0.0.32
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 +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { MatcherRules } from 'matchinitx';
|
|
2
2
|
|
|
3
|
+
declare const INITX_DIR: string;
|
|
4
|
+
declare const STORE_DIR: string;
|
|
5
|
+
declare const STORE_FILE_NAME = "store.json";
|
|
6
|
+
declare const PLUGIN_DIR: string;
|
|
7
|
+
|
|
3
8
|
type MaybePromise<T> = T | Promise<T>;
|
|
4
9
|
type OptionalValue = string | RegExp | undefined;
|
|
5
10
|
|
|
@@ -110,4 +115,4 @@ declare abstract class InitxPlugin<TStore extends object = object> {
|
|
|
110
115
|
declare function createStore(name: string, defaultStore?: Record<string, any>): Record<string, any>;
|
|
111
116
|
declare function writeStore(name: string): void;
|
|
112
117
|
|
|
113
|
-
export { type HandlerInfo, type InitxBaseContext, type InitxContext, type InitxMatcherRules, InitxPlugin, type InitxPluginInfo, type LoadPluginResult, type MatchedPlugin, type PackageInfo, createStore, fetchPlugins, loadPlugins, matchPlugins, writeStore };
|
|
118
|
+
export { type HandlerInfo, INITX_DIR, type InitxBaseContext, type InitxContext, type InitxMatcherRules, InitxPlugin, type InitxPluginInfo, type LoadPluginResult, type MatchedPlugin, PLUGIN_DIR, type PackageInfo, STORE_DIR, STORE_FILE_NAME, createStore, fetchPlugins, loadPlugins, matchPlugins, writeStore };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { MatcherRules } from 'matchinitx';
|
|
2
2
|
|
|
3
|
+
declare const INITX_DIR: string;
|
|
4
|
+
declare const STORE_DIR: string;
|
|
5
|
+
declare const STORE_FILE_NAME = "store.json";
|
|
6
|
+
declare const PLUGIN_DIR: string;
|
|
7
|
+
|
|
3
8
|
type MaybePromise<T> = T | Promise<T>;
|
|
4
9
|
type OptionalValue = string | RegExp | undefined;
|
|
5
10
|
|
|
@@ -110,4 +115,4 @@ declare abstract class InitxPlugin<TStore extends object = object> {
|
|
|
110
115
|
declare function createStore(name: string, defaultStore?: Record<string, any>): Record<string, any>;
|
|
111
116
|
declare function writeStore(name: string): void;
|
|
112
117
|
|
|
113
|
-
export { type HandlerInfo, type InitxBaseContext, type InitxContext, type InitxMatcherRules, InitxPlugin, type InitxPluginInfo, type LoadPluginResult, type MatchedPlugin, type PackageInfo, createStore, fetchPlugins, loadPlugins, matchPlugins, writeStore };
|
|
118
|
+
export { type HandlerInfo, INITX_DIR, type InitxBaseContext, type InitxContext, type InitxMatcherRules, InitxPlugin, type InitxPluginInfo, type LoadPluginResult, type MatchedPlugin, PLUGIN_DIR, type PackageInfo, STORE_DIR, STORE_FILE_NAME, createStore, fetchPlugins, loadPlugins, matchPlugins, writeStore };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{homedir as O}from"node:os";import a,{resolve as m}from"pathe";import{useInitxMatcher as R}from"matchinitx";import{defu as b}from"defu";import c from"fs-extra";import S from"node:process";const d=m(O(),".initx"),y=m(d,"stores"),x="store.json",p=m(d,"plugins");let g=!1,h={};const I=o=>a.resolve(y,o,x);function w(o,n={}){c.ensureDirSync(a.resolve(y,o));const t=I(o),r=i=>(v(t,i),D(i));if(!c.existsSync(t))return r(n);let e;try{const i=c.readJsonSync(t);e=b(i,n)}catch{e=n}return r(e)}function k(o){g&&v(I(o),h)}function v(o,n){c.writeJsonSync(o,n,{spaces:2})}function D(o={}){const n=r=>typeof r=="object"&&r!==null&&new Set(["[object Object]","[object Array]"]).has(Object.prototype.toString.call(r)),t=r=>new Proxy(r,{get(e,i){const s=Reflect.get(e,i);return n(s)?t(s):s},set(e,i,s){const l=Reflect.set(e,i,s);return g=!0,l},deleteProperty(e,i){const s=Reflect.deleteProperty(e,i);return g=!0,s}});return h=t(o),h}const f={plugin:/^(?:@initx-plugin\/|initx-plugin-)/,exclude:/@initx-plugin\/(?:core|utils)$/};async function _(){const o=a.resolve(S.cwd(),"package.json");if(!c.existsSync(o))return[];const n=c.readJsonSync(o),{dependencies:t={},devDependencies:r={}}=n;return Object.keys({...t,...r}).filter(e=>f.plugin.test(e)&&!f.exclude.test(e)).map(e=>({name:e,root:a.resolve(S.cwd(),"node_modules",e)}))}async function j(){c.ensureDirSync(p);const o=c.readdirSync(p),n=a.resolve(p,"@initx-plugin");return[...c.existsSync(n)?c.readdirSync(n).map(t=>`@initx-plugin/${t}`):[],...o].filter(t=>f.plugin.test(t)&&!f.exclude.test(t)).map(t=>({name:t,root:a.resolve(p,t)}))}async function $(){const o=await _(),n=o.map(({name:e})=>e),t=[...(await j()).filter(({name:e})=>!n.includes(e)),...o],r=await import("importx");return Promise.all(t.map(async({root:e})=>{const i=await r.import(e,import.meta.url).then(l=>l.default),s=c.readJsonSync(a.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 i}}))}async function E(o,{key:n,cliOptions:t},...r){const e=[];for(const i of o){const{instance:s,packageInfo:l}=i,P=await s.run({key:n,cliOptions:t,packageInfo:l,optionsList:Object.keys(t).filter(u=>t[u]===!0).map(u=>`--${u}`)},...r);e.push(...P.map(u=>({handler:u.handler,description:u.description,packageInfo:l})))}return e}function J(o,n){return o.some(t=>typeof t=="string"||typeof t>"u"?t===n:t.test(n))}class L{defaultStore;async run(n,...t){const r=R((e,...i)=>({handler:()=>this.executeHandle(n,e,...i),...e}));return(await Promise.all(r.match(this.rules,n.key,...t).map(async e=>e.verify&&!e.verify(n,...t)||e.optional&&!J(e.optional,t[0])?!1:e))).filter(Boolean)}async executeHandle(n,t,...r){const e=w(n.packageInfo.name,this.defaultStore);await this.handle({...n,rule:t,store:e},...r),k(n.packageInfo.name)}}export{d as INITX_DIR,L as InitxPlugin,p as PLUGIN_DIR,y as STORE_DIR,x as STORE_FILE_NAME,w as createStore,j as fetchPlugins,$ as loadPlugins,E as matchPlugins,k 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.32",
|
|
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.32"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/fs-extra": "^11.0.4"
|