@mostajs/setup 1.4.13 → 1.4.15
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/api/wire-module.route.js +31 -22
- package/package.json +1 -1
|
@@ -24,18 +24,23 @@ export function createWireModuleHandler() {
|
|
|
24
24
|
return Response.json({ error: { code: 'VALIDATION_ERROR', message: "action doit etre 'install' ou 'uninstall'" } }, { status: 400 });
|
|
25
25
|
}
|
|
26
26
|
try {
|
|
27
|
-
// Dynamic import to avoid
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
const socle = await import(/* webpackIgnore: true */ pkg);
|
|
27
|
+
// Dynamic import from specific paths to avoid barrel missing exports
|
|
28
|
+
const installPkg = '@mostajs' + '/socle/lib/install-module';
|
|
29
|
+
const uninstallPkg = '@mostajs' + '/socle/lib/uninstall-module';
|
|
31
30
|
const logs = [];
|
|
32
31
|
const opts = {
|
|
33
32
|
projectRoot: process.cwd(),
|
|
34
33
|
log: (msg) => logs.push(msg),
|
|
35
34
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
let result;
|
|
36
|
+
if (action === 'install') {
|
|
37
|
+
const mod = await import(/* webpackIgnore: true */ installPkg);
|
|
38
|
+
result = mod.installModule(moduleName, opts);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const mod = await import(/* webpackIgnore: true */ uninstallPkg);
|
|
42
|
+
result = mod.uninstallModule(moduleName, opts);
|
|
43
|
+
}
|
|
39
44
|
return Response.json({
|
|
40
45
|
data: {
|
|
41
46
|
ok: result.success,
|
|
@@ -86,22 +91,26 @@ export function createWireModuleHandler() {
|
|
|
86
91
|
const wireFile = path.join(mostaDir, dir, `${dir}.wire.json`);
|
|
87
92
|
if (fs.existsSync(wireFile)) {
|
|
88
93
|
const manifest = JSON.parse(fs.readFileSync(wireFile, 'utf8'));
|
|
89
|
-
// Check if already wired
|
|
90
|
-
const
|
|
91
|
-
let installed =
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (fs.existsSync(regFile)) {
|
|
98
|
-
installed = fs.readFileSync(regFile, 'utf8').includes(manifest.schemas.exports[0]);
|
|
94
|
+
// Check if already wired — primary: package in dependencies
|
|
95
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
|
|
96
|
+
let installed = !!pkg.dependencies?.[manifest.package];
|
|
97
|
+
// Fallback: check host source files for legacy codegen markers
|
|
98
|
+
if (!installed) {
|
|
99
|
+
const permFile = path.join(root, 'src/lib/permissions.ts');
|
|
100
|
+
if (manifest.permissions?.permissionsConst && fs.existsSync(permFile)) {
|
|
101
|
+
installed = fs.readFileSync(permFile, 'utf8').includes(manifest.permissions.permissionsConst);
|
|
99
102
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
else if (manifest.schemas?.exports?.[0]) {
|
|
104
|
+
const regFile = path.join(root, 'src/dal/registry.ts');
|
|
105
|
+
if (fs.existsSync(regFile)) {
|
|
106
|
+
installed = fs.readFileSync(regFile, 'utf8').includes(manifest.schemas.exports[0]);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else if (manifest.menu?.name) {
|
|
110
|
+
const sidebarFile = path.join(root, 'src/components/layout/Sidebar.tsx');
|
|
111
|
+
if (fs.existsSync(sidebarFile)) {
|
|
112
|
+
installed = fs.readFileSync(sidebarFile, 'utf8').includes(manifest.menu.name);
|
|
113
|
+
}
|
|
105
114
|
}
|
|
106
115
|
}
|
|
107
116
|
found.push({
|
package/package.json
CHANGED