@codemoreira/esad 1.3.11 → 1.3.12
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/package.json
CHANGED
|
@@ -3,7 +3,7 @@ const path = require('path');
|
|
|
3
3
|
const AdmZip = require('adm-zip');
|
|
4
4
|
const chalk = require('chalk');
|
|
5
5
|
const { getWorkspaceConfig } = require('../utils/config');
|
|
6
|
-
const {
|
|
6
|
+
const { resolveModuleMetadata, listAvailableModules } = require('../utils/resolution');
|
|
7
7
|
|
|
8
8
|
module.exports = async (options) => {
|
|
9
9
|
let cwd = process.cwd();
|
|
@@ -19,23 +19,26 @@ module.exports = async (options) => {
|
|
|
19
19
|
const workspaceRoot = path.dirname(configObj.path);
|
|
20
20
|
const { projectName } = configObj.data;
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
let moduleId = options.id;
|
|
23
|
+
|
|
24
|
+
if (moduleId) {
|
|
25
|
+
const meta = resolveModuleMetadata(moduleId, configObj);
|
|
26
|
+
if (!meta) {
|
|
27
|
+
console.error(chalk.red(`\n❌ Error: Module not found: ${moduleId}`));
|
|
26
28
|
listAvailableModules(configObj);
|
|
27
29
|
process.exit(1);
|
|
28
30
|
}
|
|
29
|
-
cwd =
|
|
31
|
+
cwd = meta.path;
|
|
32
|
+
moduleId = meta.id; // Correct fully qualified ID
|
|
30
33
|
pkgPath = path.join(cwd, 'package.json');
|
|
31
|
-
console.log(
|
|
34
|
+
console.log(`📂 Module detected for Deploy: ${path.basename(cwd)}`);
|
|
32
35
|
} else {
|
|
33
36
|
// Target host by default if in root
|
|
34
37
|
const hostDir = path.join(workspaceRoot, `${projectName}-host`);
|
|
35
38
|
if (fs.existsSync(hostDir)) {
|
|
36
39
|
cwd = hostDir;
|
|
37
40
|
pkgPath = path.join(cwd, 'package.json');
|
|
38
|
-
console.log(chalk.green(`📂 Host detected for Deploy: ${path.
|
|
41
|
+
console.log(chalk.green(`📂 Host detected for Deploy: ${path.basename(cwd)}`));
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
|
|
@@ -45,7 +48,7 @@ module.exports = async (options) => {
|
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
const pkg = fs.readJsonSync(pkgPath);
|
|
48
|
-
|
|
51
|
+
moduleId = moduleId || pkg.name;
|
|
49
52
|
const version = options.version || pkg.version;
|
|
50
53
|
const entry = options.entry || 'index.bundle';
|
|
51
54
|
|
|
@@ -49,7 +49,35 @@ function listAvailableModules(configObj) {
|
|
|
49
49
|
modules.forEach(m => console.log(chalk.blue(`- ${m}`)));
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Resolves a module's metadata (path and full ID) from a given shorthand or full ID.
|
|
54
|
+
* @param {string} id
|
|
55
|
+
* @param {Object} configObj
|
|
56
|
+
*/
|
|
57
|
+
function resolveModuleMetadata(id, configObj) {
|
|
58
|
+
if (!configObj) return null;
|
|
59
|
+
|
|
60
|
+
const workspaceRoot = path.dirname(configObj.path);
|
|
61
|
+
const { projectName } = configObj.data;
|
|
62
|
+
|
|
63
|
+
// 1. Try exact match
|
|
64
|
+
let targetDir = path.join(workspaceRoot, id);
|
|
65
|
+
if (fs.existsSync(targetDir) && fs.statSync(targetDir).isDirectory()) {
|
|
66
|
+
return { path: targetDir, id: id };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// 2. Try prefixed match
|
|
70
|
+
const fullId = `${projectName}-${id}`;
|
|
71
|
+
targetDir = path.join(workspaceRoot, fullId);
|
|
72
|
+
if (fs.existsSync(targetDir) && fs.statSync(targetDir).isDirectory()) {
|
|
73
|
+
return { path: targetDir, id: fullId };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
52
79
|
module.exports = {
|
|
53
80
|
resolveProjectDir,
|
|
54
|
-
listAvailableModules
|
|
81
|
+
listAvailableModules,
|
|
82
|
+
resolveModuleMetadata
|
|
55
83
|
};
|