rwsdk 1.0.0-beta.5 → 1.0.0-beta.50
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/rw-scripts.mjs +13 -13
- 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 +49 -57
- package/dist/lib/e2e/environment.d.mts +2 -0
- package/dist/lib/e2e/environment.mjs +201 -64
- package/dist/lib/e2e/index.d.mts +2 -0
- package/dist/lib/e2e/index.mjs +2 -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 +57 -52
- package/dist/lib/e2e/tarball.mjs +2 -34
- package/dist/lib/e2e/testHarness.d.mts +39 -3
- package/dist/lib/e2e/testHarness.mjs +239 -92
- package/dist/lib/e2e/utils.d.mts +1 -0
- package/dist/lib/e2e/utils.mjs +15 -0
- package/dist/lib/normalizeModulePath.mjs +1 -1
- package/dist/runtime/client/client.d.ts +64 -2
- package/dist/runtime/client/client.js +156 -15
- package/dist/runtime/client/navigation.d.ts +45 -0
- package/dist/runtime/client/navigation.js +68 -14
- package/dist/runtime/client/navigationCache.d.ts +68 -0
- package/dist/runtime/client/navigationCache.js +294 -0
- package/dist/runtime/client/navigationCache.test.js +469 -0
- package/dist/runtime/client/types.d.ts +26 -5
- package/dist/runtime/client/types.js +8 -1
- 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/no-react-server.js +3 -1
- package/dist/runtime/entries/react-server-only.js +1 -1
- 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 +4 -0
- package/dist/runtime/entries/worker.js +4 -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 +84 -26
- package/dist/runtime/lib/links.test.d.ts +1 -0
- 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 +28 -6
- package/dist/runtime/lib/realtime/worker.d.ts +1 -1
- package/dist/runtime/lib/router.d.ts +154 -35
- package/dist/runtime/lib/router.js +491 -105
- package/dist/runtime/lib/router.test.js +611 -1
- 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/register/client.d.ts +1 -1
- package/dist/runtime/register/client.js +10 -3
- package/dist/runtime/register/worker.js +13 -4
- package/dist/runtime/render/normalizeActionResult.js +8 -1
- 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 +5 -1
- package/dist/runtime/requestInfo/utils.d.ts +9 -0
- package/dist/runtime/requestInfo/utils.js +45 -0
- package/dist/runtime/requestInfo/worker.d.ts +0 -1
- package/dist/runtime/requestInfo/worker.js +5 -11
- package/dist/runtime/script.d.ts +1 -3
- package/dist/runtime/script.js +1 -10
- package/dist/runtime/server.d.ts +52 -0
- package/dist/runtime/server.js +88 -0
- 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 +45 -2
- 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 +36 -0
- package/dist/use-synced-state/SyncedStateServer.mjs +196 -0
- package/dist/use-synced-state/__tests__/SyncStateServer.test.d.mts +1 -0
- package/dist/use-synced-state/__tests__/SyncStateServer.test.mjs +116 -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 +70 -0
- package/dist/use-synced-state/client-core.d.ts +29 -0
- package/dist/use-synced-state/client-core.js +103 -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 +21 -0
- package/dist/use-synced-state/useSyncedState.js +64 -0
- package/dist/use-synced-state/worker.d.mts +14 -0
- package/dist/use-synced-state/worker.mjs +135 -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 +9 -11
- package/dist/vite/redwoodPlugin.test.mjs +4 -4
- package/dist/vite/runDirectivesScan.mjs +75 -19
- 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/transformClientComponents.test.mjs +32 -0
- package/dist/vite/transformJsxScriptTagsPlugin.mjs +0 -5
- package/dist/vite/transformServerFunctions.mjs +66 -4
- package/dist/vite/transformServerFunctions.test.mjs +35 -0
- package/dist/vite/virtualPlugin.mjs +6 -7
- package/package.json +41 -19
- package/dist/vite/manifestPlugin.d.mts +0 -4
- package/dist/vite/manifestPlugin.mjs +0 -63
- /package/dist/runtime/{lib/rwContext.js → client/navigationCache.test.d.ts} +0 -0
package/bin/rw-scripts.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import { execa } from "execa";
|
|
3
4
|
import path from "node:path";
|
|
4
5
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
import { $ as $base } from "execa";
|
|
6
6
|
|
|
7
7
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
8
|
|
|
@@ -12,19 +12,19 @@ const BIN_DIR = path.resolve(ROOT_DIR, "node_modules", ".bin");
|
|
|
12
12
|
const ARGS = process.argv.slice(2);
|
|
13
13
|
const SCRIPT_NAME = ARGS[0];
|
|
14
14
|
|
|
15
|
-
const $ = $base({
|
|
16
|
-
shell: true,
|
|
17
|
-
stdio: "inherit",
|
|
18
|
-
reject: false,
|
|
19
|
-
env: {
|
|
20
|
-
PATH: `${process.env.PATH}:${BIN_DIR}`,
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
|
|
24
15
|
const main = async () => {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
const scriptPath =
|
|
17
|
+
path.resolve(ROOT_DIR, "dist", "scripts", SCRIPT_NAME) + ".mjs";
|
|
18
|
+
const args = ARGS.slice(1);
|
|
19
|
+
|
|
20
|
+
const result = await execa("node", [scriptPath, ...args], {
|
|
21
|
+
stdio: "inherit",
|
|
22
|
+
reject: false,
|
|
23
|
+
env: {
|
|
24
|
+
...process.env,
|
|
25
|
+
PATH: `${process.env.PATH}:${BIN_DIR}`,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
28
|
process.exitCode = result.exitCode;
|
|
29
29
|
};
|
|
30
30
|
|
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,7 +1,8 @@
|
|
|
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
|
+
import { IS_DEBUG_MODE } from "./constants.mjs";
|
|
5
6
|
const DEV_SERVER_CHECK_TIMEOUT = process.env.RWSDK_DEV_SERVER_CHECK_TIMEOUT
|
|
6
7
|
? parseInt(process.env.RWSDK_DEV_SERVER_CHECK_TIMEOUT, 10)
|
|
7
8
|
: 5 * 60 * 1000;
|
|
@@ -21,43 +22,30 @@ export async function runDevServer(packageManager = "pnpm", cwd) {
|
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
23
24
|
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;
|
|
25
|
+
if (process.platform === "win32") {
|
|
26
|
+
try {
|
|
27
|
+
await $sh(`taskkill /pid ${devProcess.pid} /f /t`);
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
log("Failed to kill process tree with taskkill:", err);
|
|
31
|
+
}
|
|
49
32
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
33
|
+
else {
|
|
34
|
+
// On Unix-like systems, we kill the entire process group by sending a signal
|
|
35
|
+
// to the negative PID. This is the equivalent of the `/t` flag for `taskkill` on Windows.
|
|
36
|
+
// This relies on `detached: true` being set in the execa options, which makes
|
|
37
|
+
// the child process the leader of a new process group.
|
|
54
38
|
try {
|
|
55
39
|
process.kill(-devProcess.pid, "SIGKILL");
|
|
56
40
|
}
|
|
57
41
|
catch (e) {
|
|
58
|
-
log("
|
|
42
|
+
log("Failed to kill process group. This may happen if the process already exited. %O", e);
|
|
59
43
|
}
|
|
60
44
|
}
|
|
45
|
+
await devProcess.catch(() => {
|
|
46
|
+
// We expect this promise to reject when the process is killed,
|
|
47
|
+
// so we catch and ignore the error.
|
|
48
|
+
});
|
|
61
49
|
console.log("Development server stopped");
|
|
62
50
|
};
|
|
63
51
|
try {
|
|
@@ -86,20 +74,23 @@ export async function runDevServer(packageManager = "pnpm", cwd) {
|
|
|
86
74
|
};
|
|
87
75
|
const pm = getPackageManagerCommand(packageManager);
|
|
88
76
|
// Use the provided cwd if available
|
|
89
|
-
devProcess = $({
|
|
77
|
+
devProcess = $(pm, ["run", "dev"], {
|
|
90
78
|
all: true,
|
|
91
|
-
|
|
92
|
-
|
|
79
|
+
// On Windows, detached: true prevents stdio from being captured.
|
|
80
|
+
// On Unix, it's required for reliable cleanup by killing the process group.
|
|
81
|
+
detached: process.platform !== "win32",
|
|
82
|
+
cleanup: true, // Let execa handle cleanup
|
|
83
|
+
forceKillAfterTimeout: 2000, // Force kill if graceful shutdown fails
|
|
93
84
|
cwd: cwd || process.cwd(), // Use provided directory or current directory
|
|
94
85
|
env, // Pass the updated environment variables
|
|
95
86
|
stdio: "pipe", // Ensure streams are piped
|
|
96
|
-
})
|
|
87
|
+
});
|
|
97
88
|
devProcess.catch((error) => {
|
|
98
89
|
if (!isErrorExpected) {
|
|
99
90
|
// Don't re-throw. The error will be handled gracefully by the polling
|
|
100
91
|
// logic in `waitForUrl`, which will detect that the process has exited.
|
|
101
92
|
// Re-throwing here would cause an unhandled promise rejection.
|
|
102
|
-
log("Dev server process exited unexpectedly:", error
|
|
93
|
+
log("Dev server process exited unexpectedly: %O", error);
|
|
103
94
|
}
|
|
104
95
|
});
|
|
105
96
|
log("Development server process spawned in directory: %s", cwd || process.cwd());
|
|
@@ -109,9 +100,11 @@ export async function runDevServer(packageManager = "pnpm", cwd) {
|
|
|
109
100
|
// Listen for all output to get the URL
|
|
110
101
|
const handleOutput = (data, source) => {
|
|
111
102
|
const output = data.toString();
|
|
112
|
-
|
|
103
|
+
// Raw output for debugging - only in debug mode
|
|
104
|
+
if (IS_DEBUG_MODE) {
|
|
105
|
+
process.stdout.write(`[dev:${source}] ` + output);
|
|
106
|
+
}
|
|
113
107
|
allOutput += output; // Accumulate all output
|
|
114
|
-
log("Received output from %s: %s", source, output.replace(/\n/g, "\\n"));
|
|
115
108
|
if (!url) {
|
|
116
109
|
// Multiple patterns to catch different package manager outputs
|
|
117
110
|
const patterns = [
|
|
@@ -131,40 +124,40 @@ export async function runDevServer(packageManager = "pnpm", cwd) {
|
|
|
131
124
|
];
|
|
132
125
|
for (const pattern of patterns) {
|
|
133
126
|
const match = output.match(pattern);
|
|
134
|
-
log("Testing pattern %s against output: %s", pattern.source, output.replace(/\n/g, "\\n"));
|
|
135
127
|
if (match) {
|
|
136
|
-
log("Pattern matched: %s, groups: %o", pattern.source, match);
|
|
137
128
|
if (match[1] && match[1].startsWith("http")) {
|
|
138
129
|
url = match[1];
|
|
139
|
-
log("Found development server URL with pattern %s: %s", pattern.source, url);
|
|
140
130
|
break;
|
|
141
131
|
}
|
|
142
132
|
else if (match[1] && /^\d+$/.test(match[1])) {
|
|
143
133
|
url = `http://localhost:${match[1]}`;
|
|
144
|
-
log("Found development server URL with port pattern %s: %s", pattern.source, url);
|
|
145
134
|
break;
|
|
146
135
|
}
|
|
147
136
|
}
|
|
148
137
|
}
|
|
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
138
|
}
|
|
157
139
|
};
|
|
158
140
|
// Listen to all possible output streams
|
|
159
141
|
log("Setting up stream listeners. Available streams: all=%s, stdout=%s, stderr=%s", !!devProcess.all, !!devProcess.stdout, !!devProcess.stderr);
|
|
160
|
-
devProcess.all
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
142
|
+
if (devProcess.all) {
|
|
143
|
+
devProcess.all.on("data", (data) => handleOutput(data, "all"));
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
devProcess.stdout?.on("data", (data) => handleOutput(data, "stdout"));
|
|
147
|
+
devProcess.stderr?.on("data", (data) => handleOutput(data, "stderr"));
|
|
148
|
+
}
|
|
149
|
+
// Also try listening to the raw process events
|
|
164
150
|
if (devProcess.child) {
|
|
165
|
-
log("Setting up child process
|
|
166
|
-
devProcess.child.
|
|
167
|
-
|
|
151
|
+
log("Setting up child process events listeners");
|
|
152
|
+
devProcess.child.on("spawn", () => {
|
|
153
|
+
log("Child process spawned successfully.");
|
|
154
|
+
});
|
|
155
|
+
devProcess.child.on("error", (err) => {
|
|
156
|
+
log("Child process error: %O", err);
|
|
157
|
+
});
|
|
158
|
+
devProcess.child.on("exit", (code, signal) => {
|
|
159
|
+
log("Child process exited with code %s and signal %s", code, signal);
|
|
160
|
+
});
|
|
168
161
|
}
|
|
169
162
|
// Wait for URL with timeout
|
|
170
163
|
const waitForUrl = async () => {
|
|
@@ -176,7 +169,6 @@ export async function runDevServer(packageManager = "pnpm", cwd) {
|
|
|
176
169
|
}
|
|
177
170
|
// Fallback: check accumulated output if stream listeners aren't working
|
|
178
171
|
if (!url && allOutput) {
|
|
179
|
-
log("Checking accumulated output for URL patterns: %s", allOutput.replace(/\n/g, "\\n"));
|
|
180
172
|
const patterns = [
|
|
181
173
|
/Local:\s*(?:\u001b\[\d+m)?(https?:\/\/localhost:\d+)/i,
|
|
182
174
|
/[➜→]\s*Local:\s*(?:\u001b\[\d+m)?(https?:\/\/localhost:\d+)/i,
|
|
@@ -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
|
*/
|