rwsdk 1.0.0-beta.4 → 1.0.0-beta.40
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/dist/lib/constants.d.mts +1 -0
- package/dist/lib/constants.mjs +7 -4
- package/dist/lib/e2e/browser.mjs +6 -2
- package/dist/lib/e2e/constants.d.mts +4 -0
- package/dist/lib/e2e/constants.mjs +49 -12
- package/dist/lib/e2e/dev.mjs +37 -49
- package/dist/lib/e2e/environment.d.mts +2 -0
- package/dist/lib/e2e/environment.mjs +201 -64
- package/dist/lib/e2e/index.d.mts +1 -0
- package/dist/lib/e2e/index.mjs +1 -0
- package/dist/lib/e2e/poll.d.mts +1 -1
- package/dist/lib/e2e/release.d.mts +1 -0
- package/dist/lib/e2e/release.mjs +16 -32
- package/dist/lib/e2e/tarball.mjs +2 -34
- package/dist/lib/e2e/testHarness.d.mts +34 -3
- package/dist/lib/e2e/testHarness.mjs +219 -90
- package/dist/lib/e2e/utils.d.mts +1 -0
- package/dist/lib/e2e/utils.mjs +15 -0
- package/dist/runtime/client/client.d.ts +35 -0
- package/dist/runtime/client/client.js +35 -0
- package/dist/runtime/client/navigation.d.ts +49 -0
- package/dist/runtime/client/navigation.js +80 -31
- package/dist/runtime/entries/clientSSR.d.ts +1 -0
- package/dist/runtime/entries/clientSSR.js +3 -0
- package/dist/runtime/entries/no-react-server-ssr-bridge.d.ts +0 -0
- package/dist/runtime/entries/no-react-server-ssr-bridge.js +2 -0
- package/dist/runtime/entries/router.d.ts +1 -0
- package/dist/runtime/entries/routerClient.d.ts +1 -0
- package/dist/runtime/entries/routerClient.js +1 -0
- package/dist/runtime/entries/worker.d.ts +2 -0
- package/dist/runtime/entries/worker.js +2 -0
- package/dist/runtime/imports/__mocks__/use-client-lookup.d.ts +6 -0
- package/dist/runtime/imports/__mocks__/use-client-lookup.js +6 -0
- package/dist/runtime/lib/db/SqliteDurableObject.d.ts +2 -2
- package/dist/runtime/lib/db/SqliteDurableObject.js +2 -2
- package/dist/runtime/lib/db/createDb.d.ts +1 -2
- package/dist/runtime/lib/db/createDb.js +4 -0
- package/dist/runtime/lib/db/typeInference/builders/alterTable.d.ts +13 -3
- package/dist/runtime/lib/db/typeInference/builders/columnDefinition.d.ts +35 -21
- package/dist/runtime/lib/db/typeInference/builders/createTable.d.ts +9 -2
- package/dist/runtime/lib/db/typeInference/database.d.ts +16 -2
- package/dist/runtime/lib/db/typeInference/typetests/alterTable.typetest.js +80 -5
- package/dist/runtime/lib/db/typeInference/typetests/createTable.typetest.js +104 -2
- package/dist/runtime/lib/db/typeInference/typetests/testUtils.d.ts +1 -0
- package/dist/runtime/lib/db/typeInference/utils.d.ts +59 -9
- package/dist/runtime/lib/links.d.ts +21 -7
- package/dist/runtime/lib/links.js +82 -24
- package/dist/runtime/lib/links.test.js +20 -0
- package/dist/runtime/lib/manifest.d.ts +1 -1
- package/dist/runtime/lib/manifest.js +7 -4
- package/dist/runtime/lib/realtime/client.js +8 -2
- package/dist/runtime/lib/realtime/worker.d.ts +1 -1
- package/dist/runtime/lib/router.d.ts +153 -36
- package/dist/runtime/lib/router.js +169 -20
- package/dist/runtime/lib/router.test.js +241 -0
- package/dist/runtime/lib/stitchDocumentAndAppStreams.d.ts +66 -0
- package/dist/runtime/lib/stitchDocumentAndAppStreams.js +302 -35
- package/dist/runtime/lib/stitchDocumentAndAppStreams.test.d.ts +1 -0
- package/dist/runtime/lib/stitchDocumentAndAppStreams.test.js +418 -0
- package/dist/runtime/lib/{rwContext.d.ts → types.d.ts} +1 -0
- package/dist/runtime/lib/types.js +1 -0
- package/dist/runtime/render/renderDocumentHtmlStream.d.ts +1 -1
- package/dist/runtime/render/renderToStream.d.ts +4 -2
- package/dist/runtime/render/renderToStream.js +53 -24
- package/dist/runtime/render/renderToString.d.ts +3 -6
- package/dist/runtime/requestInfo/types.d.ts +4 -1
- package/dist/runtime/requestInfo/utils.d.ts +9 -0
- package/dist/runtime/requestInfo/utils.js +44 -0
- package/dist/runtime/requestInfo/worker.d.ts +0 -1
- package/dist/runtime/requestInfo/worker.js +3 -10
- package/dist/runtime/script.d.ts +1 -3
- package/dist/runtime/script.js +1 -10
- package/dist/runtime/state.d.ts +3 -0
- package/dist/runtime/state.js +13 -0
- package/dist/runtime/worker.d.ts +3 -1
- package/dist/runtime/worker.js +32 -0
- package/dist/scripts/debug-sync.mjs +18 -20
- package/dist/scripts/worker-run.d.mts +1 -1
- package/dist/scripts/worker-run.mjs +59 -113
- package/dist/use-synced-state/SyncedStateServer.d.mts +21 -0
- package/dist/use-synced-state/SyncedStateServer.mjs +128 -0
- package/dist/use-synced-state/__tests__/SyncStateServer.test.d.mts +1 -0
- package/dist/use-synced-state/__tests__/SyncStateServer.test.mjs +109 -0
- package/dist/use-synced-state/__tests__/useSyncState.test.d.ts +1 -0
- package/dist/use-synced-state/__tests__/useSyncState.test.js +115 -0
- package/dist/use-synced-state/__tests__/useSyncedState.test.d.ts +1 -0
- package/dist/use-synced-state/__tests__/useSyncedState.test.js +115 -0
- package/dist/use-synced-state/__tests__/worker.test.d.mts +1 -0
- package/dist/use-synced-state/__tests__/worker.test.mjs +69 -0
- package/dist/use-synced-state/client-core.d.ts +26 -0
- package/dist/use-synced-state/client-core.js +39 -0
- package/dist/use-synced-state/client.d.ts +3 -0
- package/dist/use-synced-state/client.js +4 -0
- package/dist/use-synced-state/constants.d.mts +1 -0
- package/dist/use-synced-state/constants.mjs +1 -0
- package/dist/use-synced-state/useSyncedState.d.ts +20 -0
- package/dist/use-synced-state/useSyncedState.js +58 -0
- package/dist/use-synced-state/worker.d.mts +13 -0
- package/dist/use-synced-state/worker.mjs +69 -0
- package/dist/vite/buildApp.mjs +34 -2
- package/dist/vite/cloudflarePreInitPlugin.d.mts +11 -0
- package/dist/vite/cloudflarePreInitPlugin.mjs +40 -0
- package/dist/vite/configPlugin.mjs +9 -14
- package/dist/vite/constants.d.mts +1 -0
- package/dist/vite/constants.mjs +1 -0
- package/dist/vite/createDirectiveLookupPlugin.mjs +10 -7
- package/dist/vite/devServerTimingPlugin.mjs +4 -0
- package/dist/vite/diagnosticAssetGraphPlugin.d.mts +4 -0
- package/dist/vite/diagnosticAssetGraphPlugin.mjs +41 -0
- package/dist/vite/directiveModulesDevPlugin.mjs +9 -1
- package/dist/vite/directivesPlugin.mjs +4 -4
- package/dist/vite/envResolvers.d.mts +11 -0
- package/dist/vite/envResolvers.mjs +20 -0
- package/dist/vite/getViteEsbuild.mjs +2 -1
- package/dist/vite/hmrStabilityPlugin.d.mts +2 -0
- package/dist/vite/hmrStabilityPlugin.mjs +73 -0
- package/dist/vite/injectVitePreamblePlugin.mjs +0 -4
- package/dist/vite/knownDepsResolverPlugin.d.mts +0 -6
- package/dist/vite/knownDepsResolverPlugin.mjs +25 -17
- package/dist/vite/linkerPlugin.d.mts +2 -1
- package/dist/vite/linkerPlugin.mjs +11 -3
- package/dist/vite/linkerPlugin.test.mjs +15 -0
- package/dist/vite/miniflareHMRPlugin.mjs +6 -38
- package/dist/vite/moveStaticAssetsPlugin.mjs +35 -4
- package/dist/vite/redwoodPlugin.mjs +8 -10
- package/dist/vite/runDirectivesScan.mjs +72 -18
- package/dist/vite/ssrBridgePlugin.mjs +132 -40
- package/dist/vite/ssrBridgeWrapPlugin.d.mts +2 -0
- package/dist/vite/ssrBridgeWrapPlugin.mjs +85 -0
- package/dist/vite/staleDepRetryPlugin.d.mts +2 -0
- package/dist/vite/staleDepRetryPlugin.mjs +74 -0
- package/dist/vite/statePlugin.d.mts +4 -0
- package/dist/vite/statePlugin.mjs +62 -0
- package/dist/vite/transformJsxScriptTagsPlugin.mjs +0 -5
- package/dist/vite/virtualPlugin.mjs +6 -7
- package/package.json +27 -10
- package/dist/vite/manifestPlugin.d.mts +0 -4
- package/dist/vite/manifestPlugin.mjs +0 -63
- /package/dist/runtime/lib/{rwContext.js → links.test.d.ts} +0 -0
package/dist/lib/constants.d.mts
CHANGED
|
@@ -7,5 +7,6 @@ export declare const VENDOR_CLIENT_BARREL_PATH: string;
|
|
|
7
7
|
export declare const VENDOR_SERVER_BARREL_PATH: string;
|
|
8
8
|
export declare const VENDOR_CLIENT_BARREL_EXPORT_PATH = "rwsdk/__vendor_client_barrel";
|
|
9
9
|
export declare const VENDOR_SERVER_BARREL_EXPORT_PATH = "rwsdk/__vendor_server_barrel";
|
|
10
|
+
export declare const RW_STATE_EXPORT_PATH = "rwsdk/__state";
|
|
10
11
|
export declare const INTERMEDIATE_SSR_BRIDGE_PATH: string;
|
|
11
12
|
export declare const CLIENT_MANIFEST_RELATIVE_PATH: string;
|
package/dist/lib/constants.mjs
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { fileURLToPath } from "url";
|
|
2
|
+
import { dirname, resolve } from "path";
|
|
3
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
4
|
+
const __dirname = dirname(__filename);
|
|
3
5
|
export const ROOT_DIR = resolve(__dirname, "..", "..");
|
|
4
6
|
export const SRC_DIR = resolve(ROOT_DIR, "src");
|
|
5
7
|
export const DIST_DIR = resolve(ROOT_DIR, "dist");
|
|
6
8
|
export const VITE_DIR = resolve(ROOT_DIR, "src", "vite");
|
|
7
9
|
export const INTERMEDIATES_OUTPUT_DIR = resolve(DIST_DIR, "__intermediate_builds");
|
|
8
|
-
export const VENDOR_CLIENT_BARREL_PATH =
|
|
9
|
-
export const VENDOR_SERVER_BARREL_PATH =
|
|
10
|
+
export const VENDOR_CLIENT_BARREL_PATH = resolve(INTERMEDIATES_OUTPUT_DIR, "rwsdk-vendor-client-barrel.js");
|
|
11
|
+
export const VENDOR_SERVER_BARREL_PATH = resolve(INTERMEDIATES_OUTPUT_DIR, "rwsdk-vendor-server-barrel.js");
|
|
10
12
|
export const VENDOR_CLIENT_BARREL_EXPORT_PATH = "rwsdk/__vendor_client_barrel";
|
|
11
13
|
export const VENDOR_SERVER_BARREL_EXPORT_PATH = "rwsdk/__vendor_server_barrel";
|
|
14
|
+
export const RW_STATE_EXPORT_PATH = "rwsdk/__state";
|
|
12
15
|
export const INTERMEDIATE_SSR_BRIDGE_PATH = resolve(INTERMEDIATES_OUTPUT_DIR, "ssr", "ssr_bridge.js");
|
|
13
16
|
export const CLIENT_MANIFEST_RELATIVE_PATH = resolve("dist", "client", ".vite", "manifest.json");
|
package/dist/lib/e2e/browser.mjs
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { computeExecutablePath, detectBrowserPlatform, install, Browser as PuppeteerBrowser, resolveBuildId, } from "@puppeteer/browsers";
|
|
2
2
|
import debug from "debug";
|
|
3
3
|
import { mkdirp, pathExists } from "fs-extra";
|
|
4
|
-
import * as os from "os";
|
|
5
4
|
import { join } from "path";
|
|
6
5
|
import puppeteer from "puppeteer-core";
|
|
6
|
+
import { ensureTmpDir } from "./utils.mjs";
|
|
7
7
|
const log = debug("rwsdk:e2e:browser");
|
|
8
8
|
/**
|
|
9
9
|
* Launch a browser instance
|
|
10
10
|
*/
|
|
11
11
|
export async function launchBrowser(browserPath, headless = true) {
|
|
12
|
+
// Define a consistent cache directory path in system temp folder
|
|
13
|
+
const rwCacheDir = join(await ensureTmpDir(), "redwoodjs-smoke-test-cache");
|
|
14
|
+
await mkdirp(rwCacheDir);
|
|
15
|
+
log("Using cache directory: %s", rwCacheDir);
|
|
12
16
|
// Get browser path if not provided
|
|
13
17
|
if (!browserPath) {
|
|
14
18
|
log("Getting browser executable path");
|
|
@@ -41,7 +45,7 @@ export async function getBrowserPath(testOptions) {
|
|
|
41
45
|
}
|
|
42
46
|
log("Detected platform: %s", platform);
|
|
43
47
|
// Define a consistent cache directory path in system temp folder
|
|
44
|
-
const rwCacheDir = join(
|
|
48
|
+
const rwCacheDir = join(await ensureTmpDir(), "redwoodjs-smoke-test-cache");
|
|
45
49
|
await mkdirp(rwCacheDir);
|
|
46
50
|
log("Using cache directory: %s", rwCacheDir);
|
|
47
51
|
// Determine browser type based on headless option
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export declare const IS_CI: boolean;
|
|
2
|
+
export declare const RWSDK_SKIP_DEV: boolean;
|
|
3
|
+
export declare const RWSDK_SKIP_DEPLOY: boolean;
|
|
4
|
+
export declare const IS_DEBUG_MODE: boolean;
|
|
1
5
|
export declare const SETUP_PLAYGROUND_ENV_TIMEOUT: number;
|
|
2
6
|
export declare const DEPLOYMENT_TIMEOUT: number;
|
|
3
7
|
export declare const DEPLOYMENT_MIN_TRIES: number;
|
|
@@ -1,40 +1,77 @@
|
|
|
1
|
+
export const IS_CI = !!((process.env.CI && !process.env.NOT_CI) ||
|
|
2
|
+
process.env.GITHUB_ACTIONS ||
|
|
3
|
+
process.env.GITLAB_CI ||
|
|
4
|
+
process.env.CIRCLECI ||
|
|
5
|
+
process.env.TRAVIS ||
|
|
6
|
+
process.env.JENKINS_URL ||
|
|
7
|
+
process.env.NETLIFY);
|
|
8
|
+
export const RWSDK_SKIP_DEV = Boolean(process.env.RWSDK_SKIP_DEV);
|
|
9
|
+
export const RWSDK_SKIP_DEPLOY = process.env.RWSDK_SKIP_DEPLOY === "true" ||
|
|
10
|
+
process.env.RWSDK_SKIP_DEPLOY === "1";
|
|
11
|
+
export const IS_DEBUG_MODE = process.env.RWSDK_E2E_DEBUG
|
|
12
|
+
? process.env.RWSDK_E2E_DEBUG === "true"
|
|
13
|
+
: !IS_CI;
|
|
1
14
|
export const SETUP_PLAYGROUND_ENV_TIMEOUT = process.env
|
|
2
15
|
.RWSDK_SETUP_PLAYGROUND_ENV_TIMEOUT
|
|
3
16
|
? parseInt(process.env.RWSDK_SETUP_PLAYGROUND_ENV_TIMEOUT, 10)
|
|
4
|
-
:
|
|
17
|
+
: IS_DEBUG_MODE
|
|
18
|
+
? 10 * 60 * 1000
|
|
19
|
+
: 15 * 60 * 1000;
|
|
5
20
|
export const DEPLOYMENT_TIMEOUT = process.env.RWSDK_DEPLOYMENT_TIMEOUT
|
|
6
21
|
? parseInt(process.env.RWSDK_DEPLOYMENT_TIMEOUT, 10)
|
|
7
|
-
:
|
|
22
|
+
: IS_DEBUG_MODE
|
|
23
|
+
? 5 * 30 * 1000
|
|
24
|
+
: 5 * 60 * 1000;
|
|
8
25
|
export const DEPLOYMENT_MIN_TRIES = process.env.RWSDK_DEPLOYMENT_MIN_TRIES
|
|
9
26
|
? parseInt(process.env.RWSDK_DEPLOYMENT_MIN_TRIES, 10)
|
|
10
|
-
:
|
|
27
|
+
: IS_DEBUG_MODE
|
|
28
|
+
? 1
|
|
29
|
+
: 5;
|
|
11
30
|
export const DEPLOYMENT_CHECK_TIMEOUT = process.env
|
|
12
31
|
.RWSDK_DEPLOYMENT_CHECK_TIMEOUT
|
|
13
32
|
? parseInt(process.env.RWSDK_DEPLOYMENT_CHECK_TIMEOUT, 10)
|
|
14
|
-
:
|
|
33
|
+
: IS_DEBUG_MODE
|
|
34
|
+
? 30 * 1000
|
|
35
|
+
: 5 * 60 * 1000;
|
|
15
36
|
export const PUPPETEER_TIMEOUT = process.env.RWSDK_PUPPETEER_TIMEOUT
|
|
16
37
|
? parseInt(process.env.RWSDK_PUPPETEER_TIMEOUT, 10)
|
|
17
|
-
:
|
|
38
|
+
: IS_DEBUG_MODE
|
|
39
|
+
? 30 * 1000
|
|
40
|
+
: 60 * 1000 * 2;
|
|
18
41
|
export const HYDRATION_TIMEOUT = process.env.RWSDK_HYDRATION_TIMEOUT
|
|
19
42
|
? parseInt(process.env.RWSDK_HYDRATION_TIMEOUT, 10)
|
|
20
|
-
:
|
|
43
|
+
: IS_DEBUG_MODE
|
|
44
|
+
? 2000
|
|
45
|
+
: 5000;
|
|
21
46
|
export const DEV_SERVER_TIMEOUT = process.env.RWSDK_DEV_SERVER_TIMEOUT
|
|
22
47
|
? parseInt(process.env.RWSDK_DEV_SERVER_TIMEOUT, 10)
|
|
23
|
-
:
|
|
48
|
+
: IS_DEBUG_MODE
|
|
49
|
+
? 60 * 1000
|
|
50
|
+
: 5 * 60 * 1000;
|
|
24
51
|
export const DEV_SERVER_MIN_TRIES = process.env.RWSDK_DEV_SERVER_MIN_TRIES
|
|
25
52
|
? parseInt(process.env.RWSDK_DEV_SERVER_MIN_TRIES, 10)
|
|
26
|
-
:
|
|
53
|
+
: IS_DEBUG_MODE
|
|
54
|
+
? 1
|
|
55
|
+
: 5;
|
|
27
56
|
export const SETUP_WAIT_TIMEOUT = process.env.RWSDK_SETUP_WAIT_TIMEOUT
|
|
28
57
|
? parseInt(process.env.RWSDK_SETUP_WAIT_TIMEOUT, 10)
|
|
29
|
-
:
|
|
58
|
+
: IS_DEBUG_MODE
|
|
59
|
+
? 60 * 1000
|
|
60
|
+
: 10 * 60 * 1000;
|
|
30
61
|
export const TEST_MAX_RETRIES = process.env.RWSDK_TEST_MAX_RETRIES
|
|
31
62
|
? parseInt(process.env.RWSDK_TEST_MAX_RETRIES, 10)
|
|
32
|
-
:
|
|
63
|
+
: IS_DEBUG_MODE
|
|
64
|
+
? 1
|
|
65
|
+
: 10;
|
|
33
66
|
export const TEST_MAX_RETRIES_PER_CODE = process.env
|
|
34
67
|
.RWSDK_TEST_MAX_RETRIES_PER_CODE
|
|
35
68
|
? parseInt(process.env.RWSDK_TEST_MAX_RETRIES_PER_CODE, 10)
|
|
36
|
-
:
|
|
69
|
+
: IS_DEBUG_MODE
|
|
70
|
+
? 0
|
|
71
|
+
: 6;
|
|
37
72
|
export const INSTALL_DEPENDENCIES_RETRIES = process.env
|
|
38
73
|
.RWSDK_INSTALL_DEPENDENCIES_RETRIES
|
|
39
74
|
? parseInt(process.env.RWSDK_INSTALL_DEPENDENCIES_RETRIES, 10)
|
|
40
|
-
:
|
|
75
|
+
: IS_DEBUG_MODE
|
|
76
|
+
? 1
|
|
77
|
+
: 10;
|
package/dist/lib/e2e/dev.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import debug from "debug";
|
|
2
2
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
3
|
-
import { $ } from "../../lib/$.mjs";
|
|
3
|
+
import { $, $sh } from "../../lib/$.mjs";
|
|
4
4
|
import { poll } from "./poll.mjs";
|
|
5
5
|
const DEV_SERVER_CHECK_TIMEOUT = process.env.RWSDK_DEV_SERVER_CHECK_TIMEOUT
|
|
6
6
|
? parseInt(process.env.RWSDK_DEV_SERVER_CHECK_TIMEOUT, 10)
|
|
@@ -21,43 +21,30 @@ export async function runDevServer(packageManager = "pnpm", cwd) {
|
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
console.log("Stopping development server...");
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
// Wait for the process to terminate with a timeout
|
|
32
|
-
const terminationTimeout = 5000; // 5 seconds
|
|
33
|
-
const processExitPromise = devProcess.catch(() => {
|
|
34
|
-
// We expect this promise to reject when the process is killed,
|
|
35
|
-
// so we catch and ignore the error.
|
|
36
|
-
});
|
|
37
|
-
const timeoutPromise = new Promise((resolve) => setTimeout(() => resolve(undefined), terminationTimeout));
|
|
38
|
-
await Promise.race([processExitPromise, timeoutPromise]);
|
|
39
|
-
// Check if the process is still alive. We can't reliably check exitCode
|
|
40
|
-
// on a detached process, so we try sending a signal 0, which errors
|
|
41
|
-
// if the process doesn't exist.
|
|
42
|
-
let isAlive = true;
|
|
43
|
-
try {
|
|
44
|
-
// Sending signal 0 doesn't kill the process, but checks if it exists
|
|
45
|
-
process.kill(-devProcess.pid, 0);
|
|
46
|
-
}
|
|
47
|
-
catch (e) {
|
|
48
|
-
isAlive = false;
|
|
24
|
+
if (process.platform === "win32") {
|
|
25
|
+
try {
|
|
26
|
+
await $sh(`taskkill /pid ${devProcess.pid} /f /t`);
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
log("Failed to kill process tree with taskkill:", err);
|
|
30
|
+
}
|
|
49
31
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
32
|
+
else {
|
|
33
|
+
// On Unix-like systems, we kill the entire process group by sending a signal
|
|
34
|
+
// to the negative PID. This is the equivalent of the `/t` flag for `taskkill` on Windows.
|
|
35
|
+
// This relies on `detached: true` being set in the execa options, which makes
|
|
36
|
+
// the child process the leader of a new process group.
|
|
54
37
|
try {
|
|
55
38
|
process.kill(-devProcess.pid, "SIGKILL");
|
|
56
39
|
}
|
|
57
40
|
catch (e) {
|
|
58
|
-
log("
|
|
41
|
+
log("Failed to kill process group. This may happen if the process already exited. %O", e);
|
|
59
42
|
}
|
|
60
43
|
}
|
|
44
|
+
await devProcess.catch(() => {
|
|
45
|
+
// We expect this promise to reject when the process is killed,
|
|
46
|
+
// so we catch and ignore the error.
|
|
47
|
+
});
|
|
61
48
|
console.log("Development server stopped");
|
|
62
49
|
};
|
|
63
50
|
try {
|
|
@@ -86,20 +73,23 @@ export async function runDevServer(packageManager = "pnpm", cwd) {
|
|
|
86
73
|
};
|
|
87
74
|
const pm = getPackageManagerCommand(packageManager);
|
|
88
75
|
// Use the provided cwd if available
|
|
89
|
-
devProcess = $({
|
|
76
|
+
devProcess = $(pm, ["run", "dev"], {
|
|
90
77
|
all: true,
|
|
91
|
-
|
|
92
|
-
|
|
78
|
+
// On Windows, detached: true prevents stdio from being captured.
|
|
79
|
+
// On Unix, it's required for reliable cleanup by killing the process group.
|
|
80
|
+
detached: process.platform !== "win32",
|
|
81
|
+
cleanup: true, // Let execa handle cleanup
|
|
82
|
+
forceKillAfterTimeout: 2000, // Force kill if graceful shutdown fails
|
|
93
83
|
cwd: cwd || process.cwd(), // Use provided directory or current directory
|
|
94
84
|
env, // Pass the updated environment variables
|
|
95
85
|
stdio: "pipe", // Ensure streams are piped
|
|
96
|
-
})
|
|
86
|
+
});
|
|
97
87
|
devProcess.catch((error) => {
|
|
98
88
|
if (!isErrorExpected) {
|
|
99
89
|
// Don't re-throw. The error will be handled gracefully by the polling
|
|
100
90
|
// logic in `waitForUrl`, which will detect that the process has exited.
|
|
101
91
|
// Re-throwing here would cause an unhandled promise rejection.
|
|
102
|
-
log("Dev server process exited unexpectedly:", error
|
|
92
|
+
log("Dev server process exited unexpectedly: %O", error);
|
|
103
93
|
}
|
|
104
94
|
});
|
|
105
95
|
log("Development server process spawned in directory: %s", cwd || process.cwd());
|
|
@@ -109,9 +99,9 @@ export async function runDevServer(packageManager = "pnpm", cwd) {
|
|
|
109
99
|
// Listen for all output to get the URL
|
|
110
100
|
const handleOutput = (data, source) => {
|
|
111
101
|
const output = data.toString();
|
|
112
|
-
|
|
102
|
+
// Raw output for debugging
|
|
103
|
+
process.stdout.write(`[dev:${source}] ` + output);
|
|
113
104
|
allOutput += output; // Accumulate all output
|
|
114
|
-
log("Received output from %s: %s", source, output.replace(/\n/g, "\\n"));
|
|
115
105
|
if (!url) {
|
|
116
106
|
// Multiple patterns to catch different package manager outputs
|
|
117
107
|
const patterns = [
|
|
@@ -131,28 +121,17 @@ export async function runDevServer(packageManager = "pnpm", cwd) {
|
|
|
131
121
|
];
|
|
132
122
|
for (const pattern of patterns) {
|
|
133
123
|
const match = output.match(pattern);
|
|
134
|
-
log("Testing pattern %s against output: %s", pattern.source, output.replace(/\n/g, "\\n"));
|
|
135
124
|
if (match) {
|
|
136
|
-
log("Pattern matched: %s, groups: %o", pattern.source, match);
|
|
137
125
|
if (match[1] && match[1].startsWith("http")) {
|
|
138
126
|
url = match[1];
|
|
139
|
-
log("Found development server URL with pattern %s: %s", pattern.source, url);
|
|
140
127
|
break;
|
|
141
128
|
}
|
|
142
129
|
else if (match[1] && /^\d+$/.test(match[1])) {
|
|
143
130
|
url = `http://localhost:${match[1]}`;
|
|
144
|
-
log("Found development server URL with port pattern %s: %s", pattern.source, url);
|
|
145
131
|
break;
|
|
146
132
|
}
|
|
147
133
|
}
|
|
148
134
|
}
|
|
149
|
-
// Log potential matches for debugging
|
|
150
|
-
if (!url &&
|
|
151
|
-
(output.includes("localhost") ||
|
|
152
|
-
output.includes("Local") ||
|
|
153
|
-
output.includes("server"))) {
|
|
154
|
-
log("Potential URL pattern found but not matched: %s", output.trim());
|
|
155
|
-
}
|
|
156
135
|
}
|
|
157
136
|
};
|
|
158
137
|
// Listen to all possible output streams
|
|
@@ -163,6 +142,15 @@ export async function runDevServer(packageManager = "pnpm", cwd) {
|
|
|
163
142
|
// Also try listening to the raw process output
|
|
164
143
|
if (devProcess.child) {
|
|
165
144
|
log("Setting up child process stream listeners");
|
|
145
|
+
devProcess.child.on("spawn", () => {
|
|
146
|
+
log("Child process spawned successfully.");
|
|
147
|
+
});
|
|
148
|
+
devProcess.child.on("error", (err) => {
|
|
149
|
+
log("Child process error: %O", err);
|
|
150
|
+
});
|
|
151
|
+
devProcess.child.on("exit", (code, signal) => {
|
|
152
|
+
log("Child process exited with code %s and signal %s", code, signal);
|
|
153
|
+
});
|
|
166
154
|
devProcess.child.stdout?.on("data", (data) => handleOutput(data, "child.stdout"));
|
|
167
155
|
devProcess.child.stderr?.on("data", (data) => handleOutput(data, "child.stderr"));
|
|
168
156
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import tmp from "tmp-promise";
|
|
2
2
|
import { PackageManager } from "./types.mjs";
|
|
3
|
+
export declare function getFilesRecursively(directory: string): Promise<string[]>;
|
|
4
|
+
export declare function getDirectoryHash(directory: string): Promise<string>;
|
|
3
5
|
/**
|
|
4
6
|
* Copy project to a temporary directory with a unique name
|
|
5
7
|
*/
|