@nocobase/utils 1.0.0-alpha.13 → 1.0.0-alpha.14
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/requireModule.d.ts +1 -0
- package/lib/requireModule.js +19 -2
- package/package.json +2 -2
- package/plugin-symlink.js +5 -1
package/lib/requireModule.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
+
export declare function requireResolve(m: any): Promise<string>;
|
|
9
10
|
export declare function requireModule(m: any): any;
|
|
10
11
|
export default requireModule;
|
|
11
12
|
export declare function importModule(m: string): Promise<any>;
|
package/lib/requireModule.js
CHANGED
|
@@ -39,11 +39,27 @@ var requireModule_exports = {};
|
|
|
39
39
|
__export(requireModule_exports, {
|
|
40
40
|
default: () => requireModule_default,
|
|
41
41
|
importModule: () => importModule,
|
|
42
|
-
requireModule: () => requireModule
|
|
42
|
+
requireModule: () => requireModule,
|
|
43
|
+
requireResolve: () => requireResolve
|
|
43
44
|
});
|
|
44
45
|
module.exports = __toCommonJS(requireModule_exports);
|
|
46
|
+
var import_fs = __toESM(require("fs"));
|
|
45
47
|
var import_path = __toESM(require("path"));
|
|
46
48
|
var import_url = require("url");
|
|
49
|
+
async function requireResolve(m) {
|
|
50
|
+
if (!process.env.VITEST) {
|
|
51
|
+
return require.resolve(m);
|
|
52
|
+
}
|
|
53
|
+
const json = JSON.parse(
|
|
54
|
+
await import_fs.default.promises.readFile(import_path.default.resolve(process.cwd(), "./tsconfig.paths.json"), { encoding: "utf8" })
|
|
55
|
+
);
|
|
56
|
+
const paths = json.compilerOptions.paths;
|
|
57
|
+
if (paths[m]) {
|
|
58
|
+
return require.resolve(import_path.default.resolve(process.cwd(), paths[m][0], "index.ts"));
|
|
59
|
+
}
|
|
60
|
+
return require.resolve(m);
|
|
61
|
+
}
|
|
62
|
+
__name(requireResolve, "requireResolve");
|
|
47
63
|
function requireModule(m) {
|
|
48
64
|
if (typeof m === "string") {
|
|
49
65
|
m = require(m);
|
|
@@ -69,5 +85,6 @@ __name(importModule, "importModule");
|
|
|
69
85
|
// Annotate the CommonJS export names for ESM import in node:
|
|
70
86
|
0 && (module.exports = {
|
|
71
87
|
importModule,
|
|
72
|
-
requireModule
|
|
88
|
+
requireModule,
|
|
89
|
+
requireResolve
|
|
73
90
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/utils",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.14",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
"multer": "^1.4.5-lts.1",
|
|
16
16
|
"object-path": "^0.11.8"
|
|
17
17
|
},
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "829078819e5b9720a4c2501c340a301315c0d029"
|
|
19
19
|
}
|
package/plugin-symlink.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { dirname, resolve } = require('path');
|
|
2
|
-
const { readFile, writeFile, readdir, symlink, unlink, mkdir, stat } = require('fs').promises;
|
|
2
|
+
const { realpath, readFile, writeFile, readdir, symlink, unlink, mkdir, stat } = require('fs').promises;
|
|
3
3
|
|
|
4
4
|
async function getStoragePluginNames(target) {
|
|
5
5
|
const plugins = [];
|
|
@@ -76,6 +76,10 @@ async function createDevPluginSymLink(pluginName) {
|
|
|
76
76
|
}
|
|
77
77
|
const link = resolve(nodeModulesPath, pluginName);
|
|
78
78
|
if (await fsExists(link)) {
|
|
79
|
+
const real = await realpath(link);
|
|
80
|
+
if (real === resolve(packagePluginsPath, pluginName)) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
79
83
|
await unlink(link);
|
|
80
84
|
}
|
|
81
85
|
await symlink(resolve(packagePluginsPath, pluginName), link, 'dir');
|