@codemoreira/esad 1.3.9 → 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/README.md CHANGED
@@ -30,7 +30,14 @@ npx esad host dev # Run the Host App
30
30
  npx esad dev --id module-name --port 9000 # Run a Module
31
31
  ```
32
32
 
33
- ### 5. Deployment
33
+ ### 5. Build for Production
34
+ Prepares the bundle and chunks for deployment, generating a standardized `./build` directory.
35
+ ```bash
36
+ npx esad build --id module-name --platform android
37
+ ```
38
+
39
+ ### 6. Deployment
40
+ Packages the `./build` folder and uploads it to your configured Registry/CDN via multipart POST.
34
41
  ```bash
35
42
  npx esad deploy --id module-name --version 1.0.0
36
43
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemoreira/esad",
3
- "version": "1.3.9",
3
+ "version": "1.3.12",
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",
@@ -36,15 +36,20 @@ module.exports = async (options) => {
36
36
  console.log(`\nšŸ—ļø Building production bundle for ${path.basename(cwd)} (${platform})...\n`);
37
37
 
38
38
  try {
39
+ const bundleOutput = path.join(cwd, 'build', platform, 'index.bundle');
40
+ fs.ensureDirSync(path.dirname(bundleOutput));
41
+
39
42
  // Run Re.Pack production build
40
43
  await runProcess('npx', [
41
44
  'react-native',
42
45
  'webpack-bundle',
43
46
  '--platform', platform,
44
- '--dev', 'false'
47
+ '--dev', 'false',
48
+ '--bundle-output', bundleOutput,
49
+ '--assets-dest', path.dirname(bundleOutput)
45
50
  ], cwd);
46
51
 
47
- console.log(chalk.green(`\nāœ… Build complete! Assets generated in dist/ directory.`));
52
+ console.log(chalk.green(`\nāœ… Build complete! Assets generated in build/ directory.`));
48
53
  console.log(`šŸ‘‰ You can now run: esad deploy ${options.id ? `--id ${options.id}` : ''}\n`);
49
54
  } catch (err) {
50
55
  console.error(chalk.red(`\nāŒ Build failed: ${err.message}`));
@@ -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 { resolveProjectDir, listAvailableModules } = require('../utils/resolution');
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
- if (options.id) {
23
- const targetDir = resolveProjectDir(options.id, configObj);
24
- if (!targetDir) {
25
- console.error(chalk.red(`\nāŒ Error: Module not found: ${options.id}`));
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 = targetDir;
31
+ cwd = meta.path;
32
+ moduleId = meta.id; // Correct fully qualified ID
30
33
  pkgPath = path.join(cwd, 'package.json');
31
- console.log(chalk.green(`šŸ“‚ Module detected for Deploy: ${path.relative(workspaceRoot, cwd)}`));
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.relative(workspaceRoot, cwd)}`));
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
- const moduleId = options.id || pkg.name;
51
+ moduleId = moduleId || pkg.name;
49
52
  const version = options.version || pkg.version;
50
53
  const entry = options.entry || 'index.bundle';
51
54
 
@@ -60,9 +63,9 @@ module.exports = async (options) => {
60
63
  const deployUrl = config.deployEndpoint.replace('{{moduleId}}', moduleId);
61
64
  console.log(`šŸ“” Deployment Endpoint Resolved: ${deployUrl}`);
62
65
 
63
- const distPath = path.join(cwd, 'dist');
66
+ const distPath = path.join(cwd, 'build');
64
67
  if (!fs.existsSync(distPath)) {
65
- console.error(`āŒ Error: dist/ directory not found in ${cwd}. Did you run the build command?`);
68
+ console.error(`āŒ Error: build/ directory not found in ${cwd}. Did you run the build command?`);
66
69
  process.exit(1);
67
70
  }
68
71
 
@@ -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
  };
@@ -32,7 +32,7 @@ function withESAD(env, options) {
32
32
  context: dirname,
33
33
  entry: options.entry || './index.js',
34
34
  output: {
35
- path: path.resolve(dirname, 'dist', platform),
35
+ path: path.resolve(dirname, 'build', platform),
36
36
  filename: 'index.bundle',
37
37
  clean: true,
38
38
  },