@nocobase/server 0.17.0-alpha.7 → 0.18.0-alpha.1
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/lib/application.d.ts +2 -2
- package/lib/application.js +6 -6
- package/lib/gateway/ws-server.js +2 -2
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -2
- package/lib/locale/locale.js +4 -1
- package/lib/plugin-manager/plugin-manager.d.ts +5 -5
- package/lib/plugin-manager/plugin-manager.js +20 -17
- package/lib/plugin-manager/utils.d.ts +4 -3
- package/lib/plugin-manager/utils.js +20 -12
- package/package.json +12 -12
- package/lib/read-config.d.ts +0 -8
- package/lib/read-config.js +0 -91
package/lib/application.d.ts
CHANGED
|
@@ -108,8 +108,8 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
108
108
|
protected _cacheManager: CacheManager;
|
|
109
109
|
get cacheManager(): CacheManager;
|
|
110
110
|
protected _cache: Cache;
|
|
111
|
-
set cache(cache: Cache);
|
|
112
111
|
get cache(): Cache;
|
|
112
|
+
set cache(cache: Cache);
|
|
113
113
|
protected _cli: AppCommand;
|
|
114
114
|
get cli(): AppCommand;
|
|
115
115
|
protected _i18n: i18n;
|
|
@@ -131,7 +131,7 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
131
131
|
getMaintaining(): MaintainingCommandStatus;
|
|
132
132
|
setMaintaining(_maintainingCommandStatus: MaintainingCommandStatus): void;
|
|
133
133
|
setMaintainingMessage(message: string): void;
|
|
134
|
-
getVersion():
|
|
134
|
+
getVersion(): string;
|
|
135
135
|
plugin<O = any>(pluginClass: any, options?: O): void;
|
|
136
136
|
use<NewStateT = {}, NewContextT = {}>(middleware: Koa.Middleware<StateT & NewStateT, ContextT & NewContextT>, options?: ToposortOptions): this;
|
|
137
137
|
callback(): (req: IncomingMessage, res: ServerResponse) => any;
|
package/lib/application.js
CHANGED
|
@@ -37,7 +37,6 @@ var import_auth = require("@nocobase/auth");
|
|
|
37
37
|
var import_database = __toESM(require("@nocobase/database"));
|
|
38
38
|
var import_logger = require("@nocobase/logger");
|
|
39
39
|
var import_utils = require("@nocobase/utils");
|
|
40
|
-
var import_chalk = __toESM(require("chalk"));
|
|
41
40
|
var import_koa = __toESM(require("koa"));
|
|
42
41
|
var import_koa_compose = __toESM(require("koa-compose"));
|
|
43
42
|
var import_lodash = __toESM(require("lodash"));
|
|
@@ -52,7 +51,8 @@ var import_helper = require("./helper");
|
|
|
52
51
|
var import_application_version = require("./helpers/application-version");
|
|
53
52
|
var import_locale = require("./locale");
|
|
54
53
|
var import_plugin_manager = require("./plugin-manager");
|
|
55
|
-
|
|
54
|
+
var import_package = __toESM(require("../package.json"));
|
|
55
|
+
var import_chalk = __toESM(require("chalk"));
|
|
56
56
|
const _Application = class _Application extends import_koa.default {
|
|
57
57
|
constructor(options) {
|
|
58
58
|
super();
|
|
@@ -105,12 +105,12 @@ const _Application = class _Application extends import_koa.default {
|
|
|
105
105
|
return this._cacheManager;
|
|
106
106
|
}
|
|
107
107
|
_cache;
|
|
108
|
-
set cache(cache) {
|
|
109
|
-
this._cache = cache;
|
|
110
|
-
}
|
|
111
108
|
get cache() {
|
|
112
109
|
return this._cache;
|
|
113
110
|
}
|
|
111
|
+
set cache(cache) {
|
|
112
|
+
this._cache = cache;
|
|
113
|
+
}
|
|
114
114
|
_cli;
|
|
115
115
|
get cli() {
|
|
116
116
|
return this._cli;
|
|
@@ -171,7 +171,7 @@ const _Application = class _Application extends import_koa.default {
|
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
173
|
getVersion() {
|
|
174
|
-
return
|
|
174
|
+
return import_package.default.version;
|
|
175
175
|
}
|
|
176
176
|
plugin(pluginClass, options) {
|
|
177
177
|
this.log.debug(`add plugin ${pluginClass.name}`);
|
package/lib/gateway/ws-server.js
CHANGED
|
@@ -32,7 +32,7 @@ __export(ws_server_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(ws_server_exports);
|
|
34
34
|
var import_gateway = require("../gateway");
|
|
35
|
-
var import_ws =
|
|
35
|
+
var import_ws = require("ws");
|
|
36
36
|
var import_nanoid = require("nanoid");
|
|
37
37
|
var import_app_supervisor = require("../app-supervisor");
|
|
38
38
|
var import_errors = require("./errors");
|
|
@@ -46,7 +46,7 @@ const _WSServer = class _WSServer {
|
|
|
46
46
|
wss;
|
|
47
47
|
webSocketClients = /* @__PURE__ */ new Map();
|
|
48
48
|
constructor() {
|
|
49
|
-
this.wss = new import_ws.
|
|
49
|
+
this.wss = new import_ws.WebSocketServer({ noServer: true });
|
|
50
50
|
this.wss.on("connection", (ws, request) => {
|
|
51
51
|
const client = this.addNewConnection(ws, request);
|
|
52
52
|
console.log(`new client connected ${ws.id}`);
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -38,7 +38,6 @@ var middlewares = __toESM(require("./middlewares"));
|
|
|
38
38
|
__reExport(src_exports, require("./migration"), module.exports);
|
|
39
39
|
__reExport(src_exports, require("./plugin"), module.exports);
|
|
40
40
|
__reExport(src_exports, require("./plugin-manager"), module.exports);
|
|
41
|
-
__reExport(src_exports, require("./read-config"), module.exports);
|
|
42
41
|
__reExport(src_exports, require("./gateway"), module.exports);
|
|
43
42
|
__reExport(src_exports, require("./app-supervisor"), module.exports);
|
|
44
43
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -48,7 +47,6 @@ __reExport(src_exports, require("./app-supervisor"), module.exports);
|
|
|
48
47
|
...require("./migration"),
|
|
49
48
|
...require("./plugin"),
|
|
50
49
|
...require("./plugin-manager"),
|
|
51
|
-
...require("./read-config"),
|
|
52
50
|
...require("./gateway"),
|
|
53
51
|
...require("./app-supervisor")
|
|
54
52
|
});
|
package/lib/locale/locale.js
CHANGED
|
@@ -96,7 +96,10 @@ const _Locale = class _Locale {
|
|
|
96
96
|
}
|
|
97
97
|
const res = (0, import_resource.getResource)(packageName, lang);
|
|
98
98
|
if (res) {
|
|
99
|
-
resources[
|
|
99
|
+
resources[packageName] = { ...res };
|
|
100
|
+
if (name !== packageName) {
|
|
101
|
+
resources[name] = { ...res };
|
|
102
|
+
}
|
|
100
103
|
}
|
|
101
104
|
} catch (err) {
|
|
102
105
|
}
|
|
@@ -20,18 +20,18 @@ export declare class PluginManager {
|
|
|
20
20
|
options: PluginManagerOptions;
|
|
21
21
|
app: Application;
|
|
22
22
|
collection: Collection;
|
|
23
|
-
_repository: PluginManagerRepository;
|
|
24
23
|
pluginInstances: Map<typeof Plugin, Plugin<any>>;
|
|
25
24
|
pluginAliases: Map<string, Plugin<any>>;
|
|
26
25
|
server: net.Server;
|
|
27
26
|
constructor(options: PluginManagerOptions);
|
|
27
|
+
_repository: PluginManagerRepository;
|
|
28
28
|
get repository(): PluginManagerRepository;
|
|
29
|
-
static getPackageJson(packageName: string): any
|
|
30
|
-
static getPackageName(name: string): string
|
|
29
|
+
static getPackageJson(packageName: string): Promise<any>;
|
|
30
|
+
static getPackageName(name: string): Promise<string>;
|
|
31
31
|
static getPluginPkgPrefix(): string[];
|
|
32
32
|
static findPackage(name: string): Promise<string>;
|
|
33
33
|
static clearCache(packageName: string): void;
|
|
34
|
-
static resolvePlugin(pluginName: string | typeof Plugin, isUpgrade?: boolean, isPkg?: boolean): any
|
|
34
|
+
static resolvePlugin(pluginName: string | typeof Plugin, isUpgrade?: boolean, isPkg?: boolean): Promise<any>;
|
|
35
35
|
addPreset(plugin: string | typeof Plugin, options?: any): void;
|
|
36
36
|
getPlugins(): Map<typeof Plugin, Plugin<any>>;
|
|
37
37
|
getAliases(): IterableIterator<string>;
|
|
@@ -46,7 +46,6 @@ export declare class PluginManager {
|
|
|
46
46
|
enable(name: string | string[]): Promise<void>;
|
|
47
47
|
disable(name: string | string[]): Promise<void>;
|
|
48
48
|
remove(name: string | string[]): Promise<void>;
|
|
49
|
-
protected initPresetPlugins(): Promise<void>;
|
|
50
49
|
loadOne(plugin: Plugin): Promise<void>;
|
|
51
50
|
addViaCLI(urlOrName: string, options?: PluginData): Promise<void>;
|
|
52
51
|
addByNpm(options: {
|
|
@@ -75,5 +74,6 @@ export declare class PluginManager {
|
|
|
75
74
|
getNameByPackageName(packageName: string): string;
|
|
76
75
|
list(options?: any): Promise<any[]>;
|
|
77
76
|
getNpmVersionList(name: string): Promise<string[]>;
|
|
77
|
+
protected initPresetPlugins(): Promise<void>;
|
|
78
78
|
}
|
|
79
79
|
export default PluginManager;
|
|
@@ -36,6 +36,7 @@ module.exports = __toCommonJS(plugin_manager_exports);
|
|
|
36
36
|
var import_utils = require("@nocobase/utils");
|
|
37
37
|
var import_plugin_symlink = require("@nocobase/utils/plugin-symlink");
|
|
38
38
|
var import_execa = __toESM(require("execa"));
|
|
39
|
+
var import_fs = __toESM(require("fs"));
|
|
39
40
|
var import_lodash = __toESM(require("lodash"));
|
|
40
41
|
var import_path = require("path");
|
|
41
42
|
var import_helper = require("../helper");
|
|
@@ -72,21 +73,23 @@ const _PluginManager = class _PluginManager {
|
|
|
72
73
|
}
|
|
73
74
|
app;
|
|
74
75
|
collection;
|
|
75
|
-
_repository;
|
|
76
76
|
pluginInstances = /* @__PURE__ */ new Map();
|
|
77
77
|
pluginAliases = /* @__PURE__ */ new Map();
|
|
78
78
|
server;
|
|
79
|
+
_repository;
|
|
79
80
|
get repository() {
|
|
80
81
|
return this.app.db.getRepository("applicationPlugins");
|
|
81
82
|
}
|
|
82
|
-
static getPackageJson(packageName) {
|
|
83
|
-
|
|
83
|
+
static async getPackageJson(packageName) {
|
|
84
|
+
const file = await import_fs.default.promises.realpath((0, import_path.resolve)(process.env.NODE_MODULES_PATH, packageName, "package.json"));
|
|
85
|
+
const data = await import_fs.default.promises.readFile(file, { encoding: "utf-8" });
|
|
86
|
+
return JSON.parse(data);
|
|
84
87
|
}
|
|
85
|
-
static getPackageName(name) {
|
|
88
|
+
static async getPackageName(name) {
|
|
86
89
|
const prefixes = this.getPluginPkgPrefix();
|
|
87
90
|
for (const prefix of prefixes) {
|
|
88
91
|
try {
|
|
89
|
-
|
|
92
|
+
await import(`${prefix}${name}`);
|
|
90
93
|
return `${prefix}${name}`;
|
|
91
94
|
} catch (error) {
|
|
92
95
|
continue;
|
|
@@ -130,11 +133,11 @@ const _PluginManager = class _PluginManager {
|
|
|
130
133
|
}
|
|
131
134
|
});
|
|
132
135
|
}
|
|
133
|
-
static resolvePlugin(pluginName, isUpgrade = false, isPkg = false) {
|
|
136
|
+
static async resolvePlugin(pluginName, isUpgrade = false, isPkg = false) {
|
|
134
137
|
if (typeof pluginName === "string") {
|
|
135
|
-
const packageName = isPkg ? pluginName : this.getPackageName(pluginName);
|
|
138
|
+
const packageName = isPkg ? pluginName : await this.getPackageName(pluginName);
|
|
136
139
|
this.clearCache(packageName);
|
|
137
|
-
return (0,
|
|
140
|
+
return await (0, import_utils.importModule)(packageName);
|
|
138
141
|
} else {
|
|
139
142
|
return pluginName;
|
|
140
143
|
}
|
|
@@ -207,11 +210,11 @@ const _PluginManager = class _PluginManager {
|
|
|
207
210
|
}
|
|
208
211
|
try {
|
|
209
212
|
if (typeof plugin === "string" && options.name && !options.packageName) {
|
|
210
|
-
const packageName = _PluginManager.getPackageName(options.name);
|
|
213
|
+
const packageName = await _PluginManager.getPackageName(options.name);
|
|
211
214
|
options["packageName"] = packageName;
|
|
212
215
|
}
|
|
213
216
|
if (options.packageName) {
|
|
214
|
-
const packageJson = _PluginManager.getPackageJson(options.packageName);
|
|
217
|
+
const packageJson = await _PluginManager.getPackageJson(options.packageName);
|
|
215
218
|
options["packageJson"] = packageJson;
|
|
216
219
|
options["version"] = packageJson.version;
|
|
217
220
|
}
|
|
@@ -221,7 +224,7 @@ const _PluginManager = class _PluginManager {
|
|
|
221
224
|
this.app.log.debug(`adding plugin [${options.name}]...`);
|
|
222
225
|
let P;
|
|
223
226
|
try {
|
|
224
|
-
P = _PluginManager.resolvePlugin(options.packageName || plugin, isUpgrade, !!options.packageName);
|
|
227
|
+
P = await _PluginManager.resolvePlugin(options.packageName || plugin, isUpgrade, !!options.packageName);
|
|
225
228
|
} catch (error) {
|
|
226
229
|
this.app.log.warn("plugin not found", error);
|
|
227
230
|
return;
|
|
@@ -479,12 +482,6 @@ const _PluginManager = class _PluginManager {
|
|
|
479
482
|
}
|
|
480
483
|
await this.app.emitStartedEvent();
|
|
481
484
|
}
|
|
482
|
-
async initPresetPlugins() {
|
|
483
|
-
for (const plugin of this.options.plugins) {
|
|
484
|
-
const [p, opts = {}] = Array.isArray(plugin) ? plugin : [plugin];
|
|
485
|
-
await this.add(p, { enabled: true, isPreset: true, ...opts });
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
485
|
async loadOne(plugin) {
|
|
489
486
|
this.app.setMaintainingMessage(`loading plugin ${plugin.name}...`);
|
|
490
487
|
if (plugin.state.loaded || !plugin.enabled) {
|
|
@@ -653,6 +650,12 @@ const _PluginManager = class _PluginManager {
|
|
|
653
650
|
const npmInfo = await (0, import_utils2.getNpmInfo)(plugin.options.packageName, plugin.options.registry, plugin.options.authToken);
|
|
654
651
|
return Object.keys(npmInfo.versions);
|
|
655
652
|
}
|
|
653
|
+
async initPresetPlugins() {
|
|
654
|
+
for (const plugin of this.options.plugins) {
|
|
655
|
+
const [p, opts = {}] = Array.isArray(plugin) ? plugin : [plugin];
|
|
656
|
+
await this.add(p, { enabled: true, isPreset: true, ...opts });
|
|
657
|
+
}
|
|
658
|
+
}
|
|
656
659
|
};
|
|
657
660
|
__name(_PluginManager, "PluginManager");
|
|
658
661
|
let PluginManager = _PluginManager;
|
|
@@ -69,8 +69,8 @@ export declare function removePluginPackage(packageName: string): Promise<[void,
|
|
|
69
69
|
* @example
|
|
70
70
|
* getPackageJson('dayjs') => { name: 'dayjs', version: '1.0.0', ... }
|
|
71
71
|
*/
|
|
72
|
-
export declare function getPackageJson(pluginName: string): any
|
|
73
|
-
export declare function getPackageJsonByLocalPath(localPath: string): any
|
|
72
|
+
export declare function getPackageJson(pluginName: string): Promise<any>;
|
|
73
|
+
export declare function getPackageJsonByLocalPath(localPath: string): Promise<any>;
|
|
74
74
|
export declare function updatePluginByCompressedFileUrl(options: Partial<Pick<PluginData, 'compressedFileUrl' | 'packageName' | 'authToken'>>): Promise<{
|
|
75
75
|
packageName: any;
|
|
76
76
|
packageDir: string;
|
|
@@ -78,7 +78,8 @@ export declare function updatePluginByCompressedFileUrl(options: Partial<Pick<Pl
|
|
|
78
78
|
}>;
|
|
79
79
|
export declare function getNewVersion(plugin: PluginData): Promise<string | false>;
|
|
80
80
|
export declare function removeRequireCache(fileOrPackageName: string): void;
|
|
81
|
-
export declare function requireNoCache(fileOrPackageName: string): any
|
|
81
|
+
export declare function requireNoCache(fileOrPackageName: string): Promise<any>;
|
|
82
|
+
export declare function readJSONFileContent(filePath: string): Promise<any>;
|
|
82
83
|
export declare function requireModule(m: any): any;
|
|
83
84
|
export declare function isNotBuiltinModule(packageName: string): boolean;
|
|
84
85
|
export declare const isValidPackageName: (str: string) => boolean;
|
|
@@ -55,6 +55,7 @@ __export(utils_exports, {
|
|
|
55
55
|
getTempDir: () => getTempDir,
|
|
56
56
|
isNotBuiltinModule: () => isNotBuiltinModule,
|
|
57
57
|
isValidPackageName: () => isValidPackageName,
|
|
58
|
+
readJSONFileContent: () => readJSONFileContent,
|
|
58
59
|
removePluginPackage: () => removePluginPackage,
|
|
59
60
|
removeRequireCache: () => removeRequireCache,
|
|
60
61
|
removeTmpDir: () => removeTmpDir,
|
|
@@ -74,9 +75,9 @@ var import_module = require("module");
|
|
|
74
75
|
var import_os = __toESM(require("os"));
|
|
75
76
|
var import_path = __toESM(require("path"));
|
|
76
77
|
var import_semver = __toESM(require("semver"));
|
|
78
|
+
var import_clientStaticUtils = require("./clientStaticUtils");
|
|
77
79
|
var import_constants = require("./constants");
|
|
78
80
|
var import_deps = __toESM(require("./deps"));
|
|
79
|
-
var import_clientStaticUtils = require("./clientStaticUtils");
|
|
80
81
|
async function getTempDir() {
|
|
81
82
|
const temporaryDirectory = await import_fs_extra.default.realpath(import_os.default.tmpdir());
|
|
82
83
|
return import_path.default.join(temporaryDirectory, import_constants.APP_NAME);
|
|
@@ -209,7 +210,7 @@ async function downloadAndUnzipToTempDir(fileUrl, authToken) {
|
|
|
209
210
|
await removeTmpDir(tempFile, tempPackageContentDir);
|
|
210
211
|
throw new Error(`decompress ${fileUrl} failed`);
|
|
211
212
|
}
|
|
212
|
-
const packageJson =
|
|
213
|
+
const packageJson = await readJSONFileContent(packageJsonPath);
|
|
213
214
|
const mainFile = import_path.default.join(tempPackageContentDir, packageJson.main);
|
|
214
215
|
if (!import_fs_extra.default.existsSync(mainFile)) {
|
|
215
216
|
await removeTmpDir(tempFile, tempPackageContentDir);
|
|
@@ -303,16 +304,18 @@ function removePluginPackage(packageName) {
|
|
|
303
304
|
return Promise.all([import_fs_extra.default.remove(packageDir), import_fs_extra.default.remove(nodeModulesPluginDir)]);
|
|
304
305
|
}
|
|
305
306
|
__name(removePluginPackage, "removePluginPackage");
|
|
306
|
-
function getPackageJson(pluginName) {
|
|
307
|
+
async function getPackageJson(pluginName) {
|
|
307
308
|
const packageDir = getStoragePluginDir(pluginName);
|
|
308
|
-
return getPackageJsonByLocalPath(packageDir);
|
|
309
|
+
return await getPackageJsonByLocalPath(packageDir);
|
|
309
310
|
}
|
|
310
311
|
__name(getPackageJson, "getPackageJson");
|
|
311
|
-
function getPackageJsonByLocalPath(localPath) {
|
|
312
|
+
async function getPackageJsonByLocalPath(localPath) {
|
|
312
313
|
if (!import_fs_extra.default.existsSync(localPath)) {
|
|
313
314
|
return null;
|
|
314
315
|
} else {
|
|
315
|
-
|
|
316
|
+
const fullPath = import_path.default.join(localPath, "package.json");
|
|
317
|
+
const data = await import_fs_extra.default.promises.readFile(fullPath, { encoding: "utf-8" });
|
|
318
|
+
return JSON.parse(data);
|
|
316
319
|
}
|
|
317
320
|
}
|
|
318
321
|
__name(getPackageJsonByLocalPath, "getPackageJsonByLocalPath");
|
|
@@ -353,11 +356,15 @@ function removeRequireCache(fileOrPackageName) {
|
|
|
353
356
|
delete require.cache[fileOrPackageName];
|
|
354
357
|
}
|
|
355
358
|
__name(removeRequireCache, "removeRequireCache");
|
|
356
|
-
function requireNoCache(fileOrPackageName) {
|
|
357
|
-
|
|
358
|
-
return require(fileOrPackageName);
|
|
359
|
+
async function requireNoCache(fileOrPackageName) {
|
|
360
|
+
return await (0, import_utils.importModule)(fileOrPackageName);
|
|
359
361
|
}
|
|
360
362
|
__name(requireNoCache, "requireNoCache");
|
|
363
|
+
async function readJSONFileContent(filePath) {
|
|
364
|
+
const data = await import_fs_extra.default.promises.readFile(filePath, { encoding: "utf-8" });
|
|
365
|
+
return JSON.parse(data);
|
|
366
|
+
}
|
|
367
|
+
__name(readJSONFileContent, "readJSONFileContent");
|
|
361
368
|
function requireModule(m) {
|
|
362
369
|
if (typeof m === "string") {
|
|
363
370
|
m = require(m);
|
|
@@ -368,13 +375,13 @@ function requireModule(m) {
|
|
|
368
375
|
return m.__esModule ? m.default : m;
|
|
369
376
|
}
|
|
370
377
|
__name(requireModule, "requireModule");
|
|
371
|
-
function getExternalVersionFromDistFile(packageName) {
|
|
378
|
+
async function getExternalVersionFromDistFile(packageName) {
|
|
372
379
|
const { exists, filePath } = (0, import_clientStaticUtils.getPackageFilePathWithExistCheck)(packageName, "dist/externalVersion.js");
|
|
373
380
|
if (!exists) {
|
|
374
381
|
return false;
|
|
375
382
|
}
|
|
376
383
|
try {
|
|
377
|
-
return requireNoCache(filePath);
|
|
384
|
+
return await requireNoCache(filePath);
|
|
378
385
|
} catch (e) {
|
|
379
386
|
console.error(e);
|
|
380
387
|
return false;
|
|
@@ -439,7 +446,7 @@ __name(getExternalVersionFromSource, "getExternalVersionFromSource");
|
|
|
439
446
|
async function getCompatible(packageName) {
|
|
440
447
|
let externalVersion;
|
|
441
448
|
if (!process.env.IS_DEV_CMD) {
|
|
442
|
-
const res = getExternalVersionFromDistFile(packageName);
|
|
449
|
+
const res = await getExternalVersionFromDistFile(packageName);
|
|
443
450
|
if (!res) {
|
|
444
451
|
return false;
|
|
445
452
|
} else {
|
|
@@ -514,6 +521,7 @@ __name(checkAndGetCompatible, "checkAndGetCompatible");
|
|
|
514
521
|
getTempDir,
|
|
515
522
|
isNotBuiltinModule,
|
|
516
523
|
isValidPackageName,
|
|
524
|
+
readJSONFileContent,
|
|
517
525
|
removePluginPackage,
|
|
518
526
|
removeRequireCache,
|
|
519
527
|
removeTmpDir,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0-alpha.1",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -10,16 +10,16 @@
|
|
|
10
10
|
"@koa/cors": "^3.1.0",
|
|
11
11
|
"@koa/multer": "^3.0.2",
|
|
12
12
|
"@koa/router": "^9.4.0",
|
|
13
|
-
"@nocobase/acl": "0.
|
|
14
|
-
"@nocobase/actions": "0.
|
|
15
|
-
"@nocobase/auth": "0.
|
|
16
|
-
"@nocobase/cache": "0.
|
|
17
|
-
"@nocobase/database": "0.
|
|
18
|
-
"@nocobase/evaluators": "0.
|
|
19
|
-
"@nocobase/logger": "0.
|
|
20
|
-
"@nocobase/resourcer": "0.
|
|
21
|
-
"@nocobase/sdk": "0.
|
|
22
|
-
"@nocobase/utils": "0.
|
|
13
|
+
"@nocobase/acl": "0.18.0-alpha.1",
|
|
14
|
+
"@nocobase/actions": "0.18.0-alpha.1",
|
|
15
|
+
"@nocobase/auth": "0.18.0-alpha.1",
|
|
16
|
+
"@nocobase/cache": "0.18.0-alpha.1",
|
|
17
|
+
"@nocobase/database": "0.18.0-alpha.1",
|
|
18
|
+
"@nocobase/evaluators": "0.18.0-alpha.1",
|
|
19
|
+
"@nocobase/logger": "0.18.0-alpha.1",
|
|
20
|
+
"@nocobase/resourcer": "0.18.0-alpha.1",
|
|
21
|
+
"@nocobase/sdk": "0.18.0-alpha.1",
|
|
22
|
+
"@nocobase/utils": "0.18.0-alpha.1",
|
|
23
23
|
"@types/decompress": "4.2.4",
|
|
24
24
|
"@types/ini": "^1.3.31",
|
|
25
25
|
"@types/koa-send": "^4.1.3",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"@types/serve-handler": "^6.1.1",
|
|
53
53
|
"@types/ws": "^8.5.5"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "0f5f1c0a37dc397a9dc4c8eec0c4ec20fd8107b0"
|
|
56
56
|
}
|
package/lib/read-config.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare function readConfig(dir: string): Promise<{}>;
|
|
2
|
-
export declare class ConfigurationRepository {
|
|
3
|
-
protected items: Map<string, any>;
|
|
4
|
-
get(key: string, defaultValue?: any): any;
|
|
5
|
-
set(key: string, value: any): Map<string, any>;
|
|
6
|
-
toObject(): {};
|
|
7
|
-
}
|
|
8
|
-
export declare function loadConfiguration(configurationDir: string, repository: ConfigurationRepository): Promise<void>;
|
package/lib/read-config.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var read_config_exports = {};
|
|
30
|
-
__export(read_config_exports, {
|
|
31
|
-
ConfigurationRepository: () => ConfigurationRepository,
|
|
32
|
-
loadConfiguration: () => loadConfiguration,
|
|
33
|
-
readConfig: () => readConfig
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(read_config_exports);
|
|
36
|
-
var import_lodash = __toESM(require("lodash"));
|
|
37
|
-
var import_fs = __toESM(require("fs"));
|
|
38
|
-
var import_path = __toESM(require("path"));
|
|
39
|
-
async function readConfig(dir) {
|
|
40
|
-
const repository = new ConfigurationRepository();
|
|
41
|
-
await loadConfiguration(dir, repository);
|
|
42
|
-
return repository.toObject();
|
|
43
|
-
}
|
|
44
|
-
__name(readConfig, "readConfig");
|
|
45
|
-
const _ConfigurationRepository = class _ConfigurationRepository {
|
|
46
|
-
items = /* @__PURE__ */ new Map();
|
|
47
|
-
get(key, defaultValue = void 0) {
|
|
48
|
-
if (this.items.has(key)) {
|
|
49
|
-
return this.items.get(key);
|
|
50
|
-
}
|
|
51
|
-
return defaultValue;
|
|
52
|
-
}
|
|
53
|
-
set(key, value) {
|
|
54
|
-
return this.items.set(key, value);
|
|
55
|
-
}
|
|
56
|
-
toObject() {
|
|
57
|
-
const result = {};
|
|
58
|
-
for (const [key, value] of this.items.entries()) {
|
|
59
|
-
import_lodash.default.set(result, key, value);
|
|
60
|
-
}
|
|
61
|
-
return result;
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
__name(_ConfigurationRepository, "ConfigurationRepository");
|
|
65
|
-
let ConfigurationRepository = _ConfigurationRepository;
|
|
66
|
-
async function loadConfiguration(configurationDir, repository) {
|
|
67
|
-
const getConfigurationFiles = /* @__PURE__ */ __name(async (dir, prefix = []) => {
|
|
68
|
-
const files = await import_fs.default.promises.readdir(dir, { withFileTypes: true });
|
|
69
|
-
for (const file of files) {
|
|
70
|
-
if (file.isDirectory()) {
|
|
71
|
-
await getConfigurationFiles(import_path.default.join(dir, file.name), [...prefix, file.name]);
|
|
72
|
-
} else {
|
|
73
|
-
if (!["ts", "js"].includes(file.name.split(".").slice(1).join("."))) {
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
const filePath = import_path.default.join(dir, file.name);
|
|
77
|
-
const keyName = import_path.default.parse(filePath).name;
|
|
78
|
-
const configuration = require(filePath).default;
|
|
79
|
-
repository.set([...prefix, keyName].join("."), configuration);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}, "getConfigurationFiles");
|
|
83
|
-
await getConfigurationFiles(configurationDir);
|
|
84
|
-
}
|
|
85
|
-
__name(loadConfiguration, "loadConfiguration");
|
|
86
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
87
|
-
0 && (module.exports = {
|
|
88
|
-
ConfigurationRepository,
|
|
89
|
-
loadConfiguration,
|
|
90
|
-
readConfig
|
|
91
|
-
});
|