@rayburst/cli 0.1.17 ā 0.1.18
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/bin/rayburst.js +2 -18
- package/package.json +4 -12
- package/server.js +3 -44
- package/src/main.tsx +105 -6
- package/vite.config.ts +3 -4
- package/dist/assets/_commonjsHelpers-B85MJLTf.js +0 -5
- package/dist/assets/hostInit-BWYxHpMp.js +0 -9
- package/dist/assets/index-9R1akZrm.js +0 -578
- package/dist/assets/index-BW-RulSg.js +0 -258
- package/dist/assets/index-VnAMn3JB.js +0 -16587
- package/dist/assets/preload-helper-Dea3Szod.js +0 -54
- package/dist/assets/rayburstCli__loadRemote__rayburstApp_mf_1_App__loadRemote__-CHUYMhiU.js +0 -35
- package/dist/assets/rayburstCli__loadShare__react__loadShare__-CE7VtFm0.js +0 -19
- package/dist/assets/rayburstCli__mf_v__runtimeInit__mf_v__-C_SVfzik.js +0 -4173
- package/dist/assets/remoteEntry-B8biLITo.js +0 -122
- package/dist/assets/virtualExposes-DwA08f_D.js +0 -5
- package/dist/index.html +0 -56
package/bin/rayburst.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
|
-
import { spawn
|
|
5
|
+
import { spawn } from 'child_process';
|
|
6
6
|
import { fileURLToPath } from 'url';
|
|
7
7
|
import { dirname, join, resolve } from 'path';
|
|
8
8
|
import {
|
|
@@ -29,7 +29,7 @@ program
|
|
|
29
29
|
.command('start')
|
|
30
30
|
.description('Start the Rayburst application')
|
|
31
31
|
.option('-p, --port <port>', 'Port to run the server on', '3105')
|
|
32
|
-
.option('-e, --env <environment>', 'Environment (
|
|
32
|
+
.option('-e, --env <environment>', 'Environment (development|staging|production)', 'development')
|
|
33
33
|
.action((options) => {
|
|
34
34
|
console.log(chalk.blue('š Starting Rayburst CLI...'));
|
|
35
35
|
console.log(chalk.gray(` Port: ${options.port}`));
|
|
@@ -48,22 +48,6 @@ program
|
|
|
48
48
|
stdio: 'inherit',
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
// Open browser after server starts
|
|
52
|
-
let browserOpened = false;
|
|
53
|
-
setTimeout(() => {
|
|
54
|
-
if (!browserOpened) {
|
|
55
|
-
browserOpened = true;
|
|
56
|
-
const url = `http://localhost:${options.port}`;
|
|
57
|
-
const openCommand = process.platform === 'darwin' ? 'open' :
|
|
58
|
-
process.platform === 'win32' ? 'start' : 'xdg-open';
|
|
59
|
-
exec(`${openCommand} ${url}`, (err) => {
|
|
60
|
-
if (err) {
|
|
61
|
-
console.log(chalk.dim(`\nš” Open your browser to: ${url}`));
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}, 2000);
|
|
66
|
-
|
|
67
51
|
server.on('error', (err) => {
|
|
68
52
|
console.error(chalk.red('Failed to start server:'), err);
|
|
69
53
|
process.exit(1);
|
package/package.json
CHANGED
|
@@ -1,22 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rayburst/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "Rayburst CLI - A module federation host for Rayburst app",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"rayburst": "./bin/rayburst.js"
|
|
8
8
|
},
|
|
9
9
|
"main": "./server.js",
|
|
10
|
-
"files": [
|
|
11
|
-
"bin",
|
|
12
|
-
"src",
|
|
13
|
-
"scripts",
|
|
14
|
-
"dist",
|
|
15
|
-
"server.js",
|
|
16
|
-
"vite.config.ts",
|
|
17
|
-
"vite-plugin-api.js",
|
|
18
|
-
"index.html"
|
|
19
|
-
],
|
|
20
10
|
"scripts": {
|
|
21
11
|
"dev": "vite",
|
|
22
12
|
"build": "vite build",
|
|
@@ -34,15 +24,17 @@
|
|
|
34
24
|
"chokidar": "^4.0.3",
|
|
35
25
|
"commander": "^11.1.0",
|
|
36
26
|
"express": "^4.18.2",
|
|
37
|
-
"http-proxy-middleware": "^3.0.5",
|
|
38
27
|
"ts-morph": "^21.0.1",
|
|
39
28
|
"ws": "^8.18.3"
|
|
40
29
|
},
|
|
41
30
|
"devDependencies": {
|
|
42
31
|
"@module-federation/vite": "^1.9.0",
|
|
32
|
+
"@tailwindcss/vite": "^4.1.17",
|
|
43
33
|
"@vitejs/plugin-react": "^4.2.1",
|
|
44
34
|
"react": "^19.0.0",
|
|
45
35
|
"react-dom": "^19.0.0",
|
|
36
|
+
"tailwindcss": "^4.1.17",
|
|
37
|
+
"tw-animate-css": "^1.4.0",
|
|
46
38
|
"vite": "^7.1.7"
|
|
47
39
|
},
|
|
48
40
|
"peerDependencies": {
|
package/server.js
CHANGED
|
@@ -2,7 +2,6 @@ import express from 'express';
|
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
3
|
import { dirname, join } from 'path';
|
|
4
4
|
import { existsSync } from 'fs';
|
|
5
|
-
import { createProxyMiddleware } from 'http-proxy-middleware';
|
|
6
5
|
import {
|
|
7
6
|
listProjects,
|
|
8
7
|
getProject,
|
|
@@ -26,14 +25,13 @@ const hasBuilt = existsSync(distPath);
|
|
|
26
25
|
// Environment-specific remote URLs
|
|
27
26
|
function getRemoteUrl(env) {
|
|
28
27
|
switch (env) {
|
|
29
|
-
case '
|
|
30
|
-
return '
|
|
28
|
+
case 'production':
|
|
29
|
+
return 'https://www.rayburst.app';
|
|
31
30
|
case 'staging':
|
|
32
31
|
return 'https://dev.rayburst.app';
|
|
33
32
|
case 'development':
|
|
34
|
-
case 'production':
|
|
35
33
|
default:
|
|
36
|
-
return '
|
|
34
|
+
return 'http://localhost:3000';
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
37
|
|
|
@@ -53,45 +51,6 @@ console.log('');
|
|
|
53
51
|
// Enable JSON body parsing for API routes
|
|
54
52
|
app.use(express.json());
|
|
55
53
|
|
|
56
|
-
// Proxy auth API requests to production API in production/staging mode
|
|
57
|
-
if (NODE_ENV === 'production' || NODE_ENV === 'staging') {
|
|
58
|
-
const apiUrl = NODE_ENV === 'staging' ? 'https://api-dev.rayburst.app' : 'https://api.rayburst.app';
|
|
59
|
-
|
|
60
|
-
app.use('/api/v1/auth', createProxyMiddleware({
|
|
61
|
-
target: apiUrl,
|
|
62
|
-
changeOrigin: true,
|
|
63
|
-
cookieDomainRewrite: 'localhost',
|
|
64
|
-
onProxyReq: (proxyReq, req, res) => {
|
|
65
|
-
// Forward cookies
|
|
66
|
-
if (req.headers.cookie) {
|
|
67
|
-
proxyReq.setHeader('cookie', req.headers.cookie);
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
onProxyRes: (proxyRes, req, res) => {
|
|
71
|
-
// Rewrite set-cookie headers to work with localhost
|
|
72
|
-
const setCookie = proxyRes.headers['set-cookie'];
|
|
73
|
-
if (setCookie) {
|
|
74
|
-
proxyRes.headers['set-cookie'] = setCookie.map(cookie =>
|
|
75
|
-
cookie.replace(/Domain=[^;]+/gi, 'Domain=localhost')
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}));
|
|
80
|
-
|
|
81
|
-
app.use('/api/v1/newsletter', createProxyMiddleware({
|
|
82
|
-
target: apiUrl,
|
|
83
|
-
changeOrigin: true,
|
|
84
|
-
cookieDomainRewrite: 'localhost',
|
|
85
|
-
onProxyReq: (proxyReq, req, res) => {
|
|
86
|
-
if (req.headers.cookie) {
|
|
87
|
-
proxyReq.setHeader('cookie', req.headers.cookie);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}));
|
|
91
|
-
|
|
92
|
-
console.log(`š Proxying auth/newsletter API requests to: ${apiUrl}`);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
54
|
// API Routes - These run regardless of build status
|
|
96
55
|
// GET /api/projects - List all registered projects
|
|
97
56
|
app.get('/api/projects', (req, res) => {
|
package/src/main.tsx
CHANGED
|
@@ -86,14 +86,113 @@ class ErrorBoundary extends React.Component<
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
// Function to load remote CSS
|
|
90
|
+
const loadRemoteCSS = async () => {
|
|
91
|
+
try {
|
|
92
|
+
// Determine the remote URL based on environment
|
|
93
|
+
const isDevelopment = import.meta.env.DEV;
|
|
94
|
+
const remoteUrl = isDevelopment
|
|
95
|
+
? 'http://localhost:3000'
|
|
96
|
+
: import.meta.env.PROD
|
|
97
|
+
? 'https://www.rayburst.app'
|
|
98
|
+
: 'https://dev.rayburst.app';
|
|
99
|
+
|
|
100
|
+
console.log('[CLI] Attempting to load CSS from:', remoteUrl, '(dev mode:', isDevelopment, ')');
|
|
101
|
+
|
|
102
|
+
if (isDevelopment) {
|
|
103
|
+
// In development mode, Vite serves CSS as a JavaScript module
|
|
104
|
+
// We need to dynamically import it to trigger Vite's CSS injection
|
|
105
|
+
console.log('[CLI] Development mode: Importing CSS module from Vite dev server');
|
|
106
|
+
|
|
107
|
+
const cssModuleUrl = `${remoteUrl}/src/styles.css`;
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
// Check if we've already loaded this CSS module
|
|
111
|
+
if (!(window as any).__rayburstCssLoaded) {
|
|
112
|
+
console.log('[CLI] Dynamically importing CSS module:', cssModuleUrl);
|
|
113
|
+
|
|
114
|
+
// Create a script tag to load the CSS module
|
|
115
|
+
const script = document.createElement('script');
|
|
116
|
+
script.type = 'module';
|
|
117
|
+
script.textContent = `import '${cssModuleUrl}';`;
|
|
118
|
+
document.head.appendChild(script);
|
|
119
|
+
|
|
120
|
+
// Mark as loaded
|
|
121
|
+
(window as any).__rayburstCssLoaded = true;
|
|
122
|
+
console.log('[CLI] CSS module import initiated');
|
|
123
|
+
|
|
124
|
+
// Give it a moment to process
|
|
125
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
126
|
+
} else {
|
|
127
|
+
console.log('[CLI] CSS module already loaded');
|
|
128
|
+
}
|
|
129
|
+
} catch (cssErr) {
|
|
130
|
+
console.warn('[CLI] Could not load CSS module, styles may be missing:', cssErr);
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
// In production/staging, fetch the index.html to find the CSS file
|
|
134
|
+
const response = await fetch(remoteUrl);
|
|
135
|
+
const html = await response.text();
|
|
136
|
+
|
|
137
|
+
// Extract CSS filename from the HTML
|
|
138
|
+
const cssMatch = html.match(/href="\/assets\/(style-[^"]+\.css)"/);
|
|
139
|
+
|
|
140
|
+
if (cssMatch && cssMatch[1]) {
|
|
141
|
+
const cssFile = cssMatch[1];
|
|
142
|
+
const cssUrl = `${remoteUrl}/assets/${cssFile}`;
|
|
143
|
+
|
|
144
|
+
console.log('[CLI] Loading remote CSS:', cssUrl);
|
|
145
|
+
|
|
146
|
+
// Check if CSS is already loaded
|
|
147
|
+
const existingLink = document.querySelector(`link[href="${cssUrl}"]`);
|
|
148
|
+
if (!existingLink) {
|
|
149
|
+
const link = document.createElement('link');
|
|
150
|
+
link.rel = 'stylesheet';
|
|
151
|
+
link.href = cssUrl;
|
|
152
|
+
document.head.appendChild(link);
|
|
153
|
+
console.log('[CLI] Remote CSS loaded successfully');
|
|
154
|
+
|
|
155
|
+
// Wait for CSS to load
|
|
156
|
+
await new Promise((resolve) => {
|
|
157
|
+
link.onload = resolve;
|
|
158
|
+
link.onerror = resolve;
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
} else {
|
|
162
|
+
console.warn('[CLI] No CSS file found in remote HTML');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
} catch (err) {
|
|
166
|
+
console.error('[CLI] Failed to load remote CSS:', err);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
89
170
|
// Dynamically import the remote app
|
|
90
|
-
const RemoteApp = lazy(() => {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
171
|
+
const RemoteApp = lazy(async () => {
|
|
172
|
+
console.log('[CLI] Attempting to load remote app from rayburstApp/App');
|
|
173
|
+
console.log('[CLI] Expected remote URL:', 'http://localhost:3000/remoteEntry.js');
|
|
174
|
+
|
|
175
|
+
// Load the remote CSS first (in parallel with module loading)
|
|
176
|
+
const cssPromise = loadRemoteCSS();
|
|
177
|
+
|
|
178
|
+
try {
|
|
179
|
+
// @ts-ignore - Module federation import
|
|
180
|
+
const module = await import('rayburstApp/App');
|
|
181
|
+
console.log('[CLI] Successfully loaded remote app module:', module);
|
|
182
|
+
|
|
183
|
+
// Wait for CSS to finish loading
|
|
184
|
+
await cssPromise;
|
|
185
|
+
|
|
186
|
+
return module;
|
|
187
|
+
} catch (err: any) {
|
|
188
|
+
console.error('[CLI] Failed to load remote app:', err);
|
|
189
|
+
console.error('[CLI] Error details:', {
|
|
190
|
+
name: err.name,
|
|
191
|
+
message: err.message,
|
|
192
|
+
stack: err.stack
|
|
96
193
|
});
|
|
194
|
+
throw new Error('Could not load Rayburst application. Make sure it is running on port 3000.');
|
|
195
|
+
}
|
|
97
196
|
});
|
|
98
197
|
|
|
99
198
|
function App() {
|
package/vite.config.ts
CHANGED
|
@@ -6,14 +6,13 @@ import { apiPlugin } from './vite-plugin-api.js';
|
|
|
6
6
|
// Determine remote URL based on environment
|
|
7
7
|
function getRemoteUrl(env: string): string {
|
|
8
8
|
switch (env) {
|
|
9
|
-
case '
|
|
10
|
-
return '
|
|
9
|
+
case 'production':
|
|
10
|
+
return 'https://www.rayburst.app';
|
|
11
11
|
case 'staging':
|
|
12
12
|
return 'https://dev.rayburst.app';
|
|
13
13
|
case 'development':
|
|
14
|
-
case 'production':
|
|
15
14
|
default:
|
|
16
|
-
return '
|
|
15
|
+
return 'http://localhost:3000';
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
18
|
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { _ as __vitePreload } from './preload-helper-Dea3Szod.js';
|
|
2
|
-
|
|
3
|
-
const remoteEntryPromise = __vitePreload(() => import('./remoteEntry-B8biLITo.js'),true ?[]:void 0);
|
|
4
|
-
// __tla only serves as a hack for vite-plugin-top-level-await.
|
|
5
|
-
Promise.resolve(remoteEntryPromise)
|
|
6
|
-
.then(remoteEntry => {
|
|
7
|
-
return Promise.resolve(remoteEntry.__tla)
|
|
8
|
-
.then(remoteEntry.init).catch(remoteEntry.init)
|
|
9
|
-
});
|