@codemoreira/esad 2.0.1-2 ā 2.0.1-3
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
package/src/cli/commands/init.js
CHANGED
|
@@ -63,13 +63,23 @@ export default {
|
|
|
63
63
|
await renameProject(hostDir, hostName);
|
|
64
64
|
|
|
65
65
|
// Inject local context mock immediately to avoid crashes on fresh boot
|
|
66
|
-
|
|
66
|
+
const context = { projectName, devMode: {} };
|
|
67
|
+
fs.writeJsonSync(path.join(hostDir, '.esad.context.json'), context, { spaces: 2 });
|
|
67
68
|
|
|
68
|
-
|
|
69
|
+
// Stabilize filesystem before heavy operations
|
|
70
|
+
await new Promise(res => setTimeout(res, 500));
|
|
71
|
+
|
|
72
|
+
console.log(`\nš¦ Installing dependencies into host (this may take a minute)...`);
|
|
69
73
|
await runProcess('npm', ['install'], { cwd: hostDir });
|
|
70
|
-
|
|
71
|
-
console.log(
|
|
74
|
+
|
|
75
|
+
console.log(chalk.green(`\nš ESAD Workspace Initialized successfully!`));
|
|
76
|
+
console.log(chalk.cyan(`\nš Next steps:`));
|
|
77
|
+
console.log(` 1. cd ${projectName}/${hostName}`);
|
|
78
|
+
console.log(` 2. esad host dev (to start Host)`);
|
|
79
|
+
console.log(` 3. esad dev (in a module folder to federate)\n`);
|
|
72
80
|
} catch (err) {
|
|
73
|
-
console.error(
|
|
81
|
+
console.error(chalk.red(`\nā Failed to initialize workspace:`));
|
|
82
|
+
console.error(chalk.yellow(` ${err.message}`));
|
|
83
|
+
console.log(chalk.dim(`\n Check npm logs if it was an installation error.`));
|
|
74
84
|
}
|
|
75
85
|
};
|
package/src/cli/utils/process.js
CHANGED
|
@@ -3,7 +3,8 @@ const nativeSpawn = require('child_process').spawn;
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const fs = require('fs-extra');
|
|
5
5
|
|
|
6
|
-
const runProcess = (cmd, args,
|
|
6
|
+
const runProcess = (cmd, args, options = process.cwd()) => {
|
|
7
|
+
const cwd = typeof options === 'string' ? options : (options.cwd || process.cwd());
|
|
7
8
|
let childRef;
|
|
8
9
|
const promise = new Promise((resolve, reject) => {
|
|
9
10
|
let finished = false;
|
|
@@ -10,20 +10,19 @@ const updateDevMode = (configPath, moduleId, url) => {
|
|
|
10
10
|
|
|
11
11
|
// 1. Ensure devMode object exists
|
|
12
12
|
if (!content.includes('devMode:')) {
|
|
13
|
-
// Inject devMode
|
|
14
|
-
content = content.replace(/
|
|
13
|
+
// Inject devMode after the opening brace of export default
|
|
14
|
+
content = content.replace(/(export default\s*\{)/, `$1\n devMode: {},\n`);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
// 2. Add or update the module entry
|
|
18
18
|
const entryRegex = new RegExp(`(['"]${moduleId}['"]|${moduleId}):\\s*['"]([^'"]*)['"]`, 'g');
|
|
19
19
|
|
|
20
20
|
if (entryRegex.test(content)) {
|
|
21
|
-
// Update existing
|
|
22
|
-
content = content.replace(entryRegex,
|
|
21
|
+
// Update existing entry
|
|
22
|
+
content = content.replace(entryRegex, `'${moduleId}': '${url}'`);
|
|
23
23
|
} else {
|
|
24
|
-
// Insert new entry
|
|
25
|
-
|
|
26
|
-
content = content.replace(devModeRegex, `$1\n '${moduleId}': '${url}',`);
|
|
24
|
+
// Insert new entry right after devMode: {
|
|
25
|
+
content = content.replace(/(devMode:\s*\{)/, `$1\n '${moduleId}': '${url}',`);
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
fs.writeFileSync(configPath, content);
|
|
@@ -44,9 +43,9 @@ const clearAllDevMode = (configPath) => {
|
|
|
44
43
|
if (!fs.existsSync(configPath)) return;
|
|
45
44
|
let content = fs.readFileSync(configPath, 'utf8');
|
|
46
45
|
|
|
47
|
-
//
|
|
48
|
-
const devModeBlockRegex =
|
|
49
|
-
content = content.replace(devModeBlockRegex, '');
|
|
46
|
+
// Simply reset devMode to empty object
|
|
47
|
+
const devModeBlockRegex = /devMode:\s*{[\s\S]*?}/;
|
|
48
|
+
content = content.replace(devModeBlockRegex, 'devMode: {}');
|
|
50
49
|
|
|
51
50
|
fs.writeFileSync(configPath, content);
|
|
52
51
|
};
|