@codemoreira/esad 2.0.0-rc.2 โ†’ 2.0.1-0

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemoreira/esad",
3
- "version": "2.0.0-rc.2",
3
+ "version": "2.0.1-0",
4
4
  "description": "Easy Super App Development - Zero-Config CLI and DevTools for React Native Module Federation",
5
5
  "main": "src/plugin/index.js",
6
6
  "types": "./src/plugin/index.d.ts",
@@ -58,4 +58,4 @@
58
58
  "@types/react": "^19.2.14",
59
59
  "@types/react-native": "^0.72.8"
60
60
  }
61
- }
61
+ }
@@ -4,7 +4,7 @@ const fs = require('fs-extra');
4
4
  const chalk = require('chalk');
5
5
  const { getWorkspaceConfig } = require('../utils/config');
6
6
  const { resolveProjectDir } = require('../utils/resolution');
7
- const { clearAllDevMode } = require('../utils/transformer');
7
+ const { clearAllDevMode, syncContextDownwards } = require('../utils/transformer');
8
8
 
9
9
  module.exports = async (options) => {
10
10
  const configObj = getWorkspaceConfig();
@@ -35,6 +35,7 @@ module.exports = async (options) => {
35
35
  // 1. CLEANUP CONFIG (Avoid shipping local dev URLs)
36
36
  console.log(chalk.gray(`๐Ÿงน Cleaning up devMode mappings in esad.config.js...`));
37
37
  clearAllDevMode(configObj.path);
38
+ syncContextDownwards(configObj);
38
39
 
39
40
  try {
40
41
  const bundleOutput = path.join(cwd, 'build', 'index.bundle'); // Simplified path as per V2
@@ -55,6 +55,10 @@ export default {
55
55
  try {
56
56
  await cloneTemplate(templatesConfig.host, hostDir);
57
57
  await renameProject(hostDir, hostName);
58
+
59
+ // Inject local context mock immediately to avoid crashes on fresh boot
60
+ fs.writeJsonSync(path.join(hostDir, '.esad.context.json'), { projectName, devMode: {} }, { spaces: 2 });
61
+
58
62
  console.log(`\n๐Ÿ“ฆ Installing dependencies into host...`);
59
63
  await runProcess('npm', ['install'], { cwd: hostDir });
60
64
  console.log(`\n๐ŸŽ‰ ESAD Workspace Initialized!`);
@@ -85,6 +89,10 @@ const createModule = async (moduleName) => {
85
89
  try {
86
90
  await cloneTemplate(templatesConfig.module, targetDir);
87
91
  await renameProject(targetDir, finalModuleName);
92
+
93
+ // Inject local context mock immediately
94
+ fs.writeJsonSync(path.join(targetDir, '.esad.context.json'), { projectName, devMode: {} }, { spaces: 2 });
95
+
88
96
  console.log(`\n๐Ÿ“ฆ Installing dependencies...`);
89
97
  await runProcess('npm', ['install'], { cwd: targetDir });
90
98
  console.log(`\n๐ŸŽ‰ Module ${finalModuleName} is ready!`);
@@ -45,13 +45,14 @@ module.exports = async (options) => {
45
45
  return;
46
46
  }
47
47
 
48
- const { updateDevMode, removeDevMode } = require('../utils/transformer');
48
+ const { updateDevMode, removeDevMode, syncContextDownwards } = require('../utils/transformer');
49
49
 
50
50
  console.log(`\nโšก Starting ESAD Dev Server for ${chalk.cyan(moduleId)} on port ${port}...\n`);
51
51
 
52
52
  // Automate devMode update in esad.config.js
53
53
  const localBundleUrl = `http://localhost:${port}/index.bundle`;
54
54
  updateDevMode(configObj.path, moduleId, localBundleUrl);
55
+ syncContextDownwards(configObj);
55
56
  console.log(chalk.gray(`๐Ÿ“ก Mode: Module Dev. Host configured to load ${moduleId} from ${localBundleUrl}`));
56
57
 
57
58
  const proc = runProcess('npx', ['react-native', 'webpack-start', '--port', port], { cwd });
@@ -59,6 +60,7 @@ module.exports = async (options) => {
59
60
  const shutdown = async () => {
60
61
  console.log(`\n๐Ÿ›‘ Stopping ESAD Dev Server and reverting config...`);
61
62
  removeDevMode(configObj.path, moduleId);
63
+ syncContextDownwards(configObj);
62
64
  if (proc.kill) proc.kill();
63
65
  process.exit(0);
64
66
  };
@@ -32,10 +32,10 @@ module.exports = async () => {
32
32
  const envPath = path.join(process.cwd(), '.env');
33
33
  if (fs.existsSync(envPath)) {
34
34
  const envContent = fs.readFileSync(envPath, 'utf8');
35
- if (envContent.includes('registryUrl')) {
36
- console.log(`${chalk.green('โœ”')} registryUrl found in .env`);
35
+ if (envContent.includes('EXPO_PUBLIC_REGISTRY_URL')) {
36
+ console.log(`${chalk.green('โœ”')} EXPO_PUBLIC_REGISTRY_URL found in .env`);
37
37
  } else {
38
- console.warn(`${chalk.yellow('โš ')} Warning: registryUrl not found in .env (Host might fail to resolve modules).`);
38
+ console.warn(`${chalk.yellow('โš ')} Warning: EXPO_PUBLIC_REGISTRY_URL not found in .env (Host might fail to resolve modules).`);
39
39
  warnings++;
40
40
  }
41
41
  } else {
@@ -51,4 +51,32 @@ const clearAllDevMode = (configPath) => {
51
51
  fs.writeFileSync(configPath, content);
52
52
  };
53
53
 
54
- module.exports = { updateDevMode, removeDevMode, clearAllDevMode };
54
+ const syncContextDownwards = (configObj) => {
55
+ if (!fs.existsSync(configObj.path)) return;
56
+ const configDir = path.dirname(configObj.path);
57
+
58
+ // Clear cache to read fresh state
59
+ delete require.cache[require.resolve(configObj.path)];
60
+ let configContent = require(configObj.path);
61
+ if (configContent.default) configContent = configContent.default;
62
+
63
+ const exportData = {
64
+ projectName: configContent.projectName || 'esad-workspace',
65
+ devMode: configContent.devMode || {}
66
+ };
67
+
68
+ try {
69
+ const children = fs.readdirSync(configDir, { withFileTypes: true })
70
+ .filter(dirent => dirent.isDirectory())
71
+ .map(dirent => path.join(configDir, dirent.name))
72
+ .filter(dir => fs.existsSync(path.join(dir, 'package.json')));
73
+
74
+ for (const childDir of children) {
75
+ fs.writeJsonSync(path.join(childDir, '.esad.context.json'), exportData, { spaces: 2 });
76
+ }
77
+ } catch (err) {
78
+ console.error('Failed to sync context downwards:', err.message);
79
+ }
80
+ };
81
+
82
+ module.exports = { updateDevMode, removeDevMode, clearAllDevMode, syncContextDownwards };