@mercurjs/dashboard-sdk 2.0.0-canary.68 → 2.0.0-canary.69
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.cjs +24 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -523,25 +523,42 @@ var UI_MODULE_KEYS = [
|
|
|
523
523
|
"admin_ui",
|
|
524
524
|
"vendor_ui"
|
|
525
525
|
];
|
|
526
|
-
function
|
|
526
|
+
function findNodeModulesRoot(configDir) {
|
|
527
|
+
let dir = configDir;
|
|
528
|
+
while (dir !== import_path5.default.dirname(dir)) {
|
|
529
|
+
const candidate = import_path5.default.join(dir, "node_modules");
|
|
530
|
+
if (import_fs4.default.existsSync(candidate) && import_fs4.default.statSync(candidate).isDirectory()) {
|
|
531
|
+
return candidate;
|
|
532
|
+
}
|
|
533
|
+
dir = import_path5.default.dirname(dir);
|
|
534
|
+
}
|
|
535
|
+
return import_path5.default.join(configDir, "node_modules");
|
|
536
|
+
}
|
|
537
|
+
function resolvePluginRoot(resolve, configDir, nodeModulesRoot) {
|
|
527
538
|
try {
|
|
528
539
|
if (resolve.startsWith(".")) {
|
|
529
|
-
|
|
540
|
+
const resolved = import_path5.default.resolve(configDir, resolve);
|
|
541
|
+
if (import_fs4.default.existsSync(resolved)) {
|
|
542
|
+
return import_fs4.default.realpathSync(resolved);
|
|
543
|
+
}
|
|
544
|
+
return null;
|
|
530
545
|
}
|
|
531
|
-
const
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
546
|
+
const packagePath = import_path5.default.join(nodeModulesRoot, resolve);
|
|
547
|
+
if (!import_fs4.default.existsSync(packagePath)) {
|
|
548
|
+
return null;
|
|
549
|
+
}
|
|
550
|
+
return import_fs4.default.realpathSync(packagePath);
|
|
535
551
|
} catch {
|
|
536
552
|
return null;
|
|
537
553
|
}
|
|
538
554
|
}
|
|
539
555
|
function resolvePluginDirs(plugins, configDir, appType) {
|
|
556
|
+
const nodeModulesRoot = findNodeModulesRoot(configDir);
|
|
540
557
|
const dirs = [];
|
|
541
558
|
for (const plugin of plugins) {
|
|
542
559
|
const resolve = typeof plugin === "string" ? plugin : plugin?.resolve;
|
|
543
560
|
if (!resolve || typeof resolve !== "string") continue;
|
|
544
|
-
const pluginRoot = resolvePluginRoot(resolve, configDir);
|
|
561
|
+
const pluginRoot = resolvePluginRoot(resolve, configDir, nodeModulesRoot);
|
|
545
562
|
if (!pluginRoot) continue;
|
|
546
563
|
const extDir = import_path5.default.join(pluginRoot, appType);
|
|
547
564
|
if (import_fs4.default.existsSync(extDir) && import_fs4.default.statSync(extDir).isDirectory()) {
|