@everystack/cli 0.2.10 → 0.2.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/package.json
CHANGED
|
@@ -249,7 +249,7 @@ export async function updateCommand(flags: UpdateFlags & Record<string, string>)
|
|
|
249
249
|
// server rendering code paths and data loaders.
|
|
250
250
|
step('Exporting web bundle (SSR)...');
|
|
251
251
|
process.env.SSR_ENABLED = '1';
|
|
252
|
-
await exportApp();
|
|
252
|
+
await exportApp('web');
|
|
253
253
|
delete process.env.SSR_ENABLED;
|
|
254
254
|
success('Web export complete');
|
|
255
255
|
|
package/src/cli/utils/export.ts
CHANGED
|
@@ -1,11 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
2
|
import fs from 'fs/promises';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export function exportApp(platform?: string): Promise<void> {
|
|
6
|
+
const args = ['expo', 'export', '--output-dir', 'dist'];
|
|
7
|
+
if (platform) args.push('--platform', platform);
|
|
8
|
+
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
const child = spawn('npx', args, {
|
|
11
|
+
stdio: ['inherit', 'pipe', 'inherit'],
|
|
12
|
+
env: { ...process.env, FORCE_COLOR: '1' },
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
let done = false;
|
|
16
|
+
|
|
17
|
+
child.stdout.on('data', (chunk: Buffer) => {
|
|
18
|
+
process.stdout.write(chunk);
|
|
19
|
+
// "Exported: dist" means all files are written. Static pre-rendering
|
|
20
|
+
// can leave open HTTP handles that prevent the process from exiting.
|
|
21
|
+
// Kill cleanly once we know the work is complete.
|
|
22
|
+
if (!done && chunk.toString().includes('Exported:')) {
|
|
23
|
+
done = true;
|
|
24
|
+
setTimeout(() => { if (!child.killed) child.kill(); }, 2000);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
child.on('close', (code, signal) => {
|
|
29
|
+
if (code === 0 || (done && signal === 'SIGTERM')) resolve();
|
|
30
|
+
else reject(new Error(`Export failed with exit code ${code}`));
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
child.on('error', reject);
|
|
9
34
|
});
|
|
10
35
|
}
|
|
11
36
|
|