@codemoreira/esad 1.4.6-3 โ 1.4.6-31
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 +82 -96
- package/bin/esad.js +88 -88
- package/package.json +13 -8
- package/src/cli/commands/build.js +1 -7
- package/src/cli/commands/createCdn.js +44 -45
- package/src/cli/commands/deploy.js +112 -118
- package/src/cli/commands/dev.js +42 -82
- package/src/cli/commands/host.js +6 -5
- package/src/cli/utils/config.js +11 -37
- package/src/cli/utils/process.js +28 -20
- package/src/cli/utils/scaffold.js +96 -96
- package/src/client/index.js +69 -82
- package/src/plugin/index.js +39 -22
package/README.md
CHANGED
|
@@ -1,96 +1,82 @@
|
|
|
1
|
-
# ESAD (Easy Super App Development) ๐
|
|
2
|
-
|
|
3
|
-
Zero-Config CLI and DevTools for React Native Module Federation + Expo.
|
|
4
|
-
|
|
5
|
-
ESAD is a unified toolkit designed to abstract all the complexity from Super App development using **Re.Pack (Rspack)** and **Expo**.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## ๐๏ธ CLI Commands
|
|
10
|
-
|
|
11
|
-
### 1. Initialize a Workspace
|
|
12
|
-
```bash
|
|
13
|
-
npx @codemoreira/esad init my-project
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
### 2. Create a Federated Module
|
|
17
|
-
```bash
|
|
18
|
-
npx esad create-module module-name
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
### 3. Create a Local CDN / Registry
|
|
22
|
-
```bash
|
|
23
|
-
npx esad create-cdn
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
### 4. Development &
|
|
27
|
-
Starts the Rspack server
|
|
28
|
-
```bash
|
|
29
|
-
npx esad dev
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
## ๐ Template Features (Host & Module)
|
|
85
|
-
|
|
86
|
-
ESAD provides high-quality, boilerplate-free templates:
|
|
87
|
-
- **๐ Rspack + Re.Pack**: Blazing fast builds powered by Rspack.
|
|
88
|
-
- **๐ฑ Clean UI**: Modern, responsive designs built with **Vanilla StyleSheet** (No external CSS libraries required).
|
|
89
|
-
- **๐ค๏ธ Dynamic Navigation**: Pre-configured Dashboard and Module Viewer with **Suspense** support.
|
|
90
|
-
- **๐ State-Driven Auth**: Built-in login and session management via the ESAD SDK.
|
|
91
|
-
- **๐ง Automated Patching**: CLI-driven injection of Re.Pack extensions into Android and iOS native projects.
|
|
92
|
-
|
|
93
|
-
---
|
|
94
|
-
|
|
95
|
-
## ๐จ Architecture & Workflow
|
|
96
|
-
For technical diagrams and the modular deployment lifecycle, see [ESAD_ARCHITECTURE.md](./ESAD_ARCHITECTURE.md).
|
|
1
|
+
# ESAD (Easy Super App Development) ๐
|
|
2
|
+
|
|
3
|
+
Zero-Config CLI and DevTools for React Native Module Federation + Expo.
|
|
4
|
+
|
|
5
|
+
ESAD is a unified toolkit designed to abstract all the complexity from Super App development using **Re.Pack (Rspack)** and **Expo**.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## ๐๏ธ CLI Commands
|
|
10
|
+
|
|
11
|
+
### 1. Initialize a Workspace
|
|
12
|
+
```bash
|
|
13
|
+
npx @codemoreira/esad init my-project
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### 2. Create a Federated Module
|
|
17
|
+
```bash
|
|
18
|
+
npx esad create-module module-name
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### 3. Create a Local CDN / Registry
|
|
22
|
+
```bash
|
|
23
|
+
npx esad create-cdn
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### 4. Development & Native Automation
|
|
27
|
+
Starts the Rspack server and **automatically patches** native files (Gradle, Entry Points) if necessary.
|
|
28
|
+
```bash
|
|
29
|
+
npx esad host dev # Run the Host App
|
|
30
|
+
npx esad dev --id module-name --port 9000 # Run a Module
|
|
31
|
+
```
|
|
32
|
+
|
|
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.
|
|
41
|
+
```bash
|
|
42
|
+
npx esad deploy --id module-name --version 1.0.0
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## ๐ ๏ธ Library Usage
|
|
48
|
+
|
|
49
|
+
### ๐จ Bundler Plugin (`@codemoreira/esad/plugin`)
|
|
50
|
+
Wrap your configuration to enable ESAD's smart resolution and redirection logic:
|
|
51
|
+
```javascript
|
|
52
|
+
import { withESAD } from '@codemoreira/esad/plugin';
|
|
53
|
+
|
|
54
|
+
export default withESAD({
|
|
55
|
+
type: 'module', // or 'host'
|
|
56
|
+
id: 'my-mini-app'
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### โก Global State SDK (`@codemoreira/esad/client`)
|
|
61
|
+
Share state across the Host and all Remote Modules reactively:
|
|
62
|
+
```javascript
|
|
63
|
+
import { useESADState } from '@codemoreira/esad/client';
|
|
64
|
+
|
|
65
|
+
const [user, setUser] = useESADState('user');
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## ๐ Template Features (Host & Module)
|
|
71
|
+
|
|
72
|
+
ESAD provides high-quality, boilerplate-free templates:
|
|
73
|
+
- **๐ Rspack + Re.Pack**: Blazing fast builds powered by Rspack.
|
|
74
|
+
- **๐ฑ Clean UI**: Modern, responsive designs built with **Vanilla StyleSheet** (No external CSS libraries required).
|
|
75
|
+
- **๐ค๏ธ Dynamic Navigation**: Pre-configured Dashboard and Module Viewer with **Suspense** support.
|
|
76
|
+
- **๐ State-Driven Auth**: Built-in login and session management via the ESAD SDK.
|
|
77
|
+
- **๐ง Automated Patching**: CLI-driven injection of Re.Pack extensions into Android and iOS native projects.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## ๐จ Architecture & Workflow
|
|
82
|
+
For technical diagrams and the modular deployment lifecycle, see [ESAD_ARCHITECTURE.md](./ESAD_ARCHITECTURE.md).
|
package/bin/esad.js
CHANGED
|
@@ -1,89 +1,89 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { program } = require('commander');
|
|
4
|
-
const pkg = require('../package.json');
|
|
5
|
-
|
|
6
|
-
// Import Commands
|
|
7
|
-
const initCommand = require('../src/cli/commands/init');
|
|
8
|
-
const createModuleCommand = require('../src/cli/commands/createModule');
|
|
9
|
-
const createCdnCommand = require('../src/cli/commands/createCdn');
|
|
10
|
-
const deployCommand = require('../src/cli/commands/deploy');
|
|
11
|
-
const devCommand = require('../src/cli/commands/dev');
|
|
12
|
-
const hostCommand = require('../src/cli/commands/host');
|
|
13
|
-
const buildCommand = require('../src/cli/commands/build');
|
|
14
|
-
|
|
15
|
-
program
|
|
16
|
-
.version(pkg.version)
|
|
17
|
-
.description('esad - Easy Super App Development Toolkit');
|
|
18
|
-
|
|
19
|
-
// --- COMMMAND: esad init ---
|
|
20
|
-
program
|
|
21
|
-
.command('init <project-name>')
|
|
22
|
-
.description('Scaffold a new ESAD workspace containing the Host App')
|
|
23
|
-
.action(async (name) => {
|
|
24
|
-
await initCommand(name);
|
|
25
|
-
process.exit(0);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
// --- COMMAND: esad create-cdn ---
|
|
29
|
-
program
|
|
30
|
-
.command('create-cdn')
|
|
31
|
-
.description('Scaffold the CDN
|
|
32
|
-
.action(async (name) => {
|
|
33
|
-
await createCdnCommand(name);
|
|
34
|
-
process.exit(0);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// --- COMMAND: esad host ---
|
|
38
|
-
program
|
|
39
|
-
.command('host <subcommand>')
|
|
40
|
-
.description('Manage the Host App (
|
|
41
|
-
.action(async (sub) => {
|
|
42
|
-
await hostCommand(sub);
|
|
43
|
-
process.exit(0);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// --- COMMAND: esad create-module ---
|
|
47
|
-
program
|
|
48
|
-
.command('create-module <module-name>')
|
|
49
|
-
.description('Scaffold a React Native mini-app automatically configured for Module Federation via ESAD')
|
|
50
|
-
.action(async (name) => {
|
|
51
|
-
await createModuleCommand(name);
|
|
52
|
-
process.exit(0);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// --- COMMAND: esad build ---
|
|
56
|
-
program
|
|
57
|
-
.command('build')
|
|
58
|
-
.option('-i, --id <moduleId>', 'The Module ID to build')
|
|
59
|
-
.option('-p, --platform <platform>', 'Platform to build for (android, ios)', 'android')
|
|
60
|
-
.description('Builds a production bundle for the host or a specific module')
|
|
61
|
-
.action(async (options) => {
|
|
62
|
-
await buildCommand(options);
|
|
63
|
-
process.exit(0);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
// --- COMMAND: esad deploy ---
|
|
67
|
-
program
|
|
68
|
-
.command('deploy')
|
|
69
|
-
.option('-v, --version <semver>', 'Version number (e.g., 1.0.0)')
|
|
70
|
-
.option('-i, --id <moduleId>', 'The Module ID to deploy')
|
|
71
|
-
.option('-e, --entry <entryFileName>', 'The name of the main entry bundle (e.g., index.bundle)', 'index.bundle')
|
|
72
|
-
.description('Zips the local dist directory and uploads it to the configured deployment endpoint')
|
|
73
|
-
.action(async (options) => {
|
|
74
|
-
await deployCommand(options);
|
|
75
|
-
process.exit(0);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// --- COMMAND: esad dev ---
|
|
79
|
-
program
|
|
80
|
-
.command('dev')
|
|
81
|
-
.option('-i, --id <moduleId>', 'The Module ID to
|
|
82
|
-
.option('-p, --
|
|
83
|
-
.description('
|
|
84
|
-
.action(async (options) => {
|
|
85
|
-
await devCommand(options);
|
|
86
|
-
// Note: dev command has its own shutdown logic with SIGINT/SIGTERM
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
program.parse(process.argv);
|
|
2
|
+
|
|
3
|
+
const { program } = require('commander');
|
|
4
|
+
const pkg = require('../package.json');
|
|
5
|
+
|
|
6
|
+
// Import Commands
|
|
7
|
+
const initCommand = require('../src/cli/commands/init');
|
|
8
|
+
const createModuleCommand = require('../src/cli/commands/createModule');
|
|
9
|
+
const createCdnCommand = require('../src/cli/commands/createCdn');
|
|
10
|
+
const deployCommand = require('../src/cli/commands/deploy');
|
|
11
|
+
const devCommand = require('../src/cli/commands/dev');
|
|
12
|
+
const hostCommand = require('../src/cli/commands/host');
|
|
13
|
+
const buildCommand = require('../src/cli/commands/build');
|
|
14
|
+
|
|
15
|
+
program
|
|
16
|
+
.version(pkg.version)
|
|
17
|
+
.description('esad - Easy Super App Development Toolkit');
|
|
18
|
+
|
|
19
|
+
// --- COMMMAND: esad init ---
|
|
20
|
+
program
|
|
21
|
+
.command('init <project-name>')
|
|
22
|
+
.description('Scaffold a new ESAD workspace containing the Host App')
|
|
23
|
+
.action(async (name) => {
|
|
24
|
+
await initCommand(name);
|
|
25
|
+
process.exit(0);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// --- COMMAND: esad create-cdn ---
|
|
29
|
+
program
|
|
30
|
+
.command('create-cdn [cdn-name]')
|
|
31
|
+
.description('Scaffold the CDN / Registry backend')
|
|
32
|
+
.action(async (name) => {
|
|
33
|
+
await createCdnCommand(name);
|
|
34
|
+
process.exit(0);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// --- COMMAND: esad host ---
|
|
38
|
+
program
|
|
39
|
+
.command('host <subcommand>')
|
|
40
|
+
.description('Manage the Host App (dev, android, ios)')
|
|
41
|
+
.action(async (sub) => {
|
|
42
|
+
await hostCommand(sub);
|
|
43
|
+
process.exit(0);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// --- COMMAND: esad create-module ---
|
|
47
|
+
program
|
|
48
|
+
.command('create-module <module-name>')
|
|
49
|
+
.description('Scaffold a React Native mini-app automatically configured for Module Federation via ESAD')
|
|
50
|
+
.action(async (name) => {
|
|
51
|
+
await createModuleCommand(name);
|
|
52
|
+
process.exit(0);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// --- COMMAND: esad build ---
|
|
56
|
+
program
|
|
57
|
+
.command('build')
|
|
58
|
+
.option('-i, --id <moduleId>', 'The Module ID to build')
|
|
59
|
+
.option('-p, --platform <platform>', 'Platform to build for (android, ios)', 'android')
|
|
60
|
+
.description('Builds a production bundle for the host or a specific module')
|
|
61
|
+
.action(async (options) => {
|
|
62
|
+
await buildCommand(options);
|
|
63
|
+
process.exit(0);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// --- COMMAND: esad deploy ---
|
|
67
|
+
program
|
|
68
|
+
.command('deploy')
|
|
69
|
+
.option('-v, --version <semver>', 'Version number (e.g., 1.0.0)')
|
|
70
|
+
.option('-i, --id <moduleId>', 'The Module ID to deploy')
|
|
71
|
+
.option('-e, --entry <entryFileName>', 'The name of the main entry bundle (e.g., index.bundle)', 'index.bundle')
|
|
72
|
+
.description('Zips the local dist directory and uploads it to the configured deployment endpoint')
|
|
73
|
+
.action(async (options) => {
|
|
74
|
+
await deployCommand(options);
|
|
75
|
+
process.exit(0);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// --- COMMAND: esad dev ---
|
|
79
|
+
program
|
|
80
|
+
.command('dev')
|
|
81
|
+
.option('-i, --id <moduleId>', 'The Module ID to run in dev mode')
|
|
82
|
+
.option('-p, --port <port>', 'The port to run the dev server on', '8081')
|
|
83
|
+
.description('Starts the dev server and updates the external registry to bypass CDN')
|
|
84
|
+
.action(async (options) => {
|
|
85
|
+
await devCommand(options);
|
|
86
|
+
// Note: dev command has its own shutdown logic with SIGINT/SIGTERM
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
program.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codemoreira/esad",
|
|
3
|
-
"version": "1.4.6-
|
|
3
|
+
"version": "1.4.6-31",
|
|
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",
|
|
@@ -29,24 +29,29 @@
|
|
|
29
29
|
"scripts": {
|
|
30
30
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
31
31
|
},
|
|
32
|
+
"overrides": {
|
|
33
|
+
"axios": "1.15.0",
|
|
34
|
+
"@xmldom/xmldom": "0.9.9"
|
|
35
|
+
},
|
|
32
36
|
"dependencies": {
|
|
37
|
+
"@babel/core": "^7.20.0",
|
|
33
38
|
"@callstack/repack": "^5.2.5",
|
|
34
39
|
"@callstack/repack-plugin-expo-modules": "^5.2.5",
|
|
35
40
|
"@callstack/repack-plugin-reanimated": "^5.2.5",
|
|
36
|
-
"@module-federation/enhanced": "^2.
|
|
41
|
+
"@module-federation/enhanced": "^2.3.1",
|
|
37
42
|
"@rspack/core": "^1.7.8",
|
|
43
|
+
"@swc/core": "^1.7.0",
|
|
44
|
+
"@swc/helpers": "^0.5.11",
|
|
38
45
|
"adm-zip": "^0.5.10",
|
|
46
|
+
"babel-loader": "^9.1.3",
|
|
47
|
+
"babel-preset-expo": "~12.0.0",
|
|
39
48
|
"chalk": "^4.1.2",
|
|
40
49
|
"commander": "^11.1.0",
|
|
41
50
|
"cross-spawn": "^7.0.3",
|
|
42
|
-
"@babel/core": "^7.20.0",
|
|
43
|
-
"babel-loader": "^9.1.3",
|
|
44
|
-
"babel-preset-expo": "~12.0.0",
|
|
45
|
-
"expo": "~52.0.0",
|
|
46
|
-
"react-native-reanimated": "~3.16.1",
|
|
47
51
|
"form-data": "^4.0.0",
|
|
48
52
|
"fs-extra": "^11.2.0",
|
|
49
|
-
"node-fetch": "^2.7.0"
|
|
53
|
+
"node-fetch": "^2.7.0",
|
|
54
|
+
"process": "^0.11.10"
|
|
50
55
|
},
|
|
51
56
|
"devDependencies": {
|
|
52
57
|
"@rspack/core": "^1.7.9",
|
|
@@ -2,9 +2,8 @@ const { runProcess } = require('../utils/process');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const fs = require('fs-extra');
|
|
4
4
|
const chalk = require('chalk');
|
|
5
|
-
const { getWorkspaceConfig
|
|
5
|
+
const { getWorkspaceConfig } = require('../utils/config');
|
|
6
6
|
const { resolveProjectDir, listAvailableModules } = require('../utils/resolution');
|
|
7
|
-
const { prepareNative } = require('../utils/scaffold');
|
|
8
7
|
|
|
9
8
|
module.exports = async (options) => {
|
|
10
9
|
let cwd = process.cwd();
|
|
@@ -16,8 +15,6 @@ module.exports = async (options) => {
|
|
|
16
15
|
process.exit(1);
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
syncHostConfig(configObj);
|
|
20
|
-
|
|
21
18
|
const { projectName } = configObj.data;
|
|
22
19
|
|
|
23
20
|
if (options.id) {
|
|
@@ -36,9 +33,6 @@ module.exports = async (options) => {
|
|
|
36
33
|
|
|
37
34
|
const platform = options.platform || 'android';
|
|
38
35
|
|
|
39
|
-
// Prepare Native Folders
|
|
40
|
-
await prepareNative(cwd, platform);
|
|
41
|
-
|
|
42
36
|
console.log(`\n๐๏ธ Building production bundle for ${path.basename(cwd)} (${platform})...\n`);
|
|
43
37
|
|
|
44
38
|
try {
|
|
@@ -1,45 +1,44 @@
|
|
|
1
|
-
const { runProcess } = require('../utils/process');
|
|
2
|
-
const { getWorkspaceConfig } = require('../utils/config');
|
|
3
|
-
const fs = require('fs-extra');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
|
|
6
|
-
module.exports = async (cdnName) => {
|
|
7
|
-
const configObj = getWorkspaceConfig();
|
|
8
|
-
if (!configObj) {
|
|
9
|
-
console.error(`โ Error: Call this command from inside an ESAD workspace (esad.config.json not found).`);
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
console.log(
|
|
38
|
-
console.log(`
|
|
39
|
-
console.log(`
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
};
|
|
1
|
+
const { runProcess } = require('../utils/process');
|
|
2
|
+
const { getWorkspaceConfig } = require('../utils/config');
|
|
3
|
+
const fs = require('fs-extra');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
module.exports = async (cdnName) => {
|
|
7
|
+
const configObj = getWorkspaceConfig();
|
|
8
|
+
if (!configObj) {
|
|
9
|
+
console.error(`โ Error: Call this command from inside an ESAD workspace (esad.config.json not found).`);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const finalCdnName = cdnName || `${configObj.data.projectName}-cdn`;
|
|
14
|
+
const cdnPath = path.join(process.cwd(), finalCdnName);
|
|
15
|
+
|
|
16
|
+
if (fs.existsSync(cdnPath)) {
|
|
17
|
+
console.error(`โ Error: Directory ./${finalCdnName} already exists.`);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
console.log(`\n๐ฆ Initializing Flux Registry & CDN: ${finalCdnName}...\n`);
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
// 1. Clone the template
|
|
25
|
+
console.log(`๐ก Cloning template from GitHub...`);
|
|
26
|
+
await runProcess('git', ['clone', 'https://github.com/CodeMoreira/simple-cdn.git', finalCdnName]);
|
|
27
|
+
|
|
28
|
+
// 2. Remove .git from template
|
|
29
|
+
console.log(`๐งน Cleaning up template metadata...`);
|
|
30
|
+
await fs.remove(path.join(cdnPath, '.git'));
|
|
31
|
+
|
|
32
|
+
// 3. Install dependencies
|
|
33
|
+
console.log(`\n๐ฅ Installing dependencies (this may take a minute)...`);
|
|
34
|
+
await runProcess('npm', ['install'], cdnPath);
|
|
35
|
+
|
|
36
|
+
console.log(`\nโ
CDN Registry created successfully in ./${finalCdnName}\n`);
|
|
37
|
+
console.log(`To start your CDN:`);
|
|
38
|
+
console.log(` cd ${finalCdnName}`);
|
|
39
|
+
console.log(` npm start\n`);
|
|
40
|
+
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error(`\nโ Failed to create CDN: ${error.message}`);
|
|
43
|
+
}
|
|
44
|
+
};
|