rwsdk 0.1.16 → 0.1.17
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/$.d.mts +8 -0
- package/dist/lib/$.mjs +5 -0
- package/dist/lib/compileTsModule.d.mts +1 -0
- package/dist/lib/compileTsModule.mjs +27 -0
- package/dist/lib/constants.d.mts +4 -0
- package/dist/lib/constants.mjs +6 -0
- package/dist/lib/findWranglerConfig.d.mts +1 -0
- package/dist/lib/findWranglerConfig.mjs +12 -0
- package/dist/lib/getShortName.d.mts +1 -0
- package/dist/lib/getShortName.mjs +2 -0
- package/dist/lib/getSrcPaths.d.ts +15 -0
- package/dist/lib/getSrcPaths.js +80 -0
- package/dist/lib/hasPkgScript.d.mts +1 -0
- package/dist/lib/hasPkgScript.mjs +9 -0
- package/dist/lib/jsonUtils.d.mts +28 -0
- package/dist/lib/jsonUtils.mjs +167 -0
- package/dist/lib/setupEnvFiles.d.mts +4 -0
- package/dist/lib/setupEnvFiles.mjs +31 -0
- package/dist/lib/smokeTests/artifacts.d.mts +10 -0
- package/dist/lib/smokeTests/artifacts.mjs +164 -0
- package/dist/lib/smokeTests/browser.d.mts +48 -0
- package/dist/lib/smokeTests/browser.mjs +1041 -0
- package/dist/lib/smokeTests/cleanup.d.mts +5 -0
- package/dist/lib/smokeTests/cleanup.mjs +214 -0
- package/dist/lib/smokeTests/codeUpdates.d.mts +8 -0
- package/dist/lib/smokeTests/codeUpdates.mjs +229 -0
- package/dist/lib/smokeTests/constants.d.mts +5 -0
- package/dist/lib/smokeTests/constants.mjs +10 -0
- package/dist/lib/smokeTests/development.d.mts +11 -0
- package/dist/lib/smokeTests/development.mjs +209 -0
- package/dist/lib/smokeTests/environment.d.mts +14 -0
- package/dist/lib/smokeTests/environment.mjs +163 -0
- package/dist/lib/smokeTests/release.d.mts +61 -0
- package/dist/lib/smokeTests/release.mjs +526 -0
- package/dist/lib/smokeTests/reporting.d.mts +13 -0
- package/dist/lib/smokeTests/reporting.mjs +355 -0
- package/dist/lib/smokeTests/runSmokeTests.d.mts +5 -0
- package/dist/lib/smokeTests/runSmokeTests.mjs +144 -0
- package/dist/lib/smokeTests/state.d.mts +48 -0
- package/dist/lib/smokeTests/state.mjs +57 -0
- package/dist/lib/smokeTests/templates/SmokeTest.template.d.ts +1 -0
- package/dist/lib/smokeTests/templates/SmokeTest.template.js +81 -0
- package/dist/lib/smokeTests/templates/SmokeTestClient.template.d.ts +1 -0
- package/dist/lib/smokeTests/templates/SmokeTestClient.template.js +159 -0
- package/dist/lib/smokeTests/templates/smokeTestFunctions.template.d.ts +1 -0
- package/dist/lib/smokeTests/templates/smokeTestFunctions.template.js +19 -0
- package/dist/lib/smokeTests/types.d.mts +75 -0
- package/dist/lib/smokeTests/types.mjs +1 -0
- package/dist/lib/smokeTests/utils.d.mts +15 -0
- package/dist/lib/smokeTests/utils.mjs +147 -0
- package/dist/llms/index.d.ts +3 -0
- package/dist/llms/index.js +35 -0
- package/dist/llms/rules/interruptors.d.ts +1 -0
- package/dist/llms/rules/interruptors.js +243 -0
- package/dist/llms/rules/middleware.d.ts +1 -0
- package/dist/llms/rules/middleware.js +71 -0
- package/dist/llms/rules/react.d.ts +1 -0
- package/dist/llms/rules/react.js +106 -0
- package/dist/llms/rules/request-response.d.ts +1 -0
- package/dist/llms/rules/request-response.js +209 -0
- package/dist/runtime/client.d.ts +17 -0
- package/dist/runtime/client.js +74 -0
- package/dist/runtime/clientNavigation.d.ts +4 -0
- package/dist/runtime/clientNavigation.js +53 -0
- package/dist/runtime/clientNavigation.test.d.ts +1 -0
- package/dist/runtime/clientNavigation.test.js +55 -0
- package/dist/runtime/constants.d.ts +1 -0
- package/dist/runtime/constants.js +1 -0
- package/dist/runtime/entries/auth.d.ts +1 -0
- package/dist/runtime/entries/auth.js +1 -0
- package/dist/runtime/entries/client.d.ts +4 -0
- package/dist/runtime/entries/client.js +4 -0
- package/dist/runtime/entries/clientSSR.d.ts +1 -0
- package/dist/runtime/entries/clientSSR.js +1 -0
- package/dist/runtime/entries/navigation.d.ts +1 -0
- package/dist/runtime/entries/navigation.js +1 -0
- package/dist/runtime/entries/no-react-server.d.ts +0 -0
- package/dist/runtime/entries/no-react-server.js +2 -0
- package/dist/runtime/entries/react-server-only.d.ts +0 -0
- package/dist/runtime/entries/react-server-only.js +2 -0
- package/dist/runtime/entries/router.d.ts +2 -0
- package/dist/runtime/entries/router.js +2 -0
- package/dist/runtime/entries/ssr.d.ts +1 -0
- package/dist/runtime/entries/ssr.js +1 -0
- package/dist/runtime/entries/worker.d.ts +9 -0
- package/dist/runtime/entries/worker.js +9 -0
- package/dist/runtime/error.d.ts +6 -0
- package/dist/runtime/error.js +8 -0
- package/dist/runtime/imports/ClientOnly.d.ts +3 -0
- package/dist/runtime/imports/ClientOnly.js +8 -0
- package/dist/runtime/imports/client.d.ts +4 -0
- package/dist/runtime/imports/client.js +33 -0
- package/dist/runtime/imports/ssr.d.ts +5 -0
- package/dist/runtime/imports/ssr.js +20 -0
- package/dist/runtime/imports/worker.d.ts +5 -0
- package/dist/runtime/imports/worker.js +22 -0
- package/dist/runtime/lib/auth/index.d.ts +1 -0
- package/dist/runtime/lib/auth/index.js +1 -0
- package/dist/runtime/lib/auth/session.d.ts +50 -0
- package/dist/runtime/lib/auth/session.js +148 -0
- package/dist/runtime/lib/db/DOWorkerDialect.d.ts +29 -0
- package/dist/runtime/lib/db/DOWorkerDialect.js +66 -0
- package/dist/runtime/lib/db/SqliteDurableObject.d.ts +14 -0
- package/dist/runtime/lib/db/SqliteDurableObject.js +42 -0
- package/dist/runtime/lib/db/createDb.d.ts +2 -0
- package/dist/runtime/lib/db/createDb.js +33 -0
- package/dist/runtime/lib/db/index.d.ts +4 -0
- package/dist/runtime/lib/db/index.js +3 -0
- package/dist/runtime/lib/db/migrations.d.ts +23 -0
- package/dist/runtime/lib/db/migrations.js +34 -0
- package/dist/runtime/lib/db/typeInference/assert.d.ts +2 -0
- package/dist/runtime/lib/db/typeInference/assert.js +1 -0
- package/dist/runtime/lib/db/typeInference/builders/alterColumn.d.ts +27 -0
- package/dist/runtime/lib/db/typeInference/builders/alterColumn.js +1 -0
- package/dist/runtime/lib/db/typeInference/builders/alterTable.d.ts +53 -0
- package/dist/runtime/lib/db/typeInference/builders/alterTable.js +1 -0
- package/dist/runtime/lib/db/typeInference/builders/columnDefinition.d.ts +26 -0
- package/dist/runtime/lib/db/typeInference/builders/columnDefinition.js +1 -0
- package/dist/runtime/lib/db/typeInference/builders/createTable.d.ts +49 -0
- package/dist/runtime/lib/db/typeInference/builders/createTable.js +1 -0
- package/dist/runtime/lib/db/typeInference/builders/createView.d.ts +17 -0
- package/dist/runtime/lib/db/typeInference/builders/createView.js +1 -0
- package/dist/runtime/lib/db/typeInference/builders/dropTable.d.ts +11 -0
- package/dist/runtime/lib/db/typeInference/builders/dropTable.js +1 -0
- package/dist/runtime/lib/db/typeInference/builders/dropView.d.ts +12 -0
- package/dist/runtime/lib/db/typeInference/builders/dropView.js +1 -0
- package/dist/runtime/lib/db/typeInference/builders/schema.d.ts +24 -0
- package/dist/runtime/lib/db/typeInference/builders/schema.js +1 -0
- package/dist/runtime/lib/db/typeInference/database.d.ts +27 -0
- package/dist/runtime/lib/db/typeInference/database.js +1 -0
- package/dist/runtime/lib/db/typeInference/typetests/alterTable.typetest.d.ts +1 -0
- package/dist/runtime/lib/db/typeInference/typetests/alterTable.typetest.js +360 -0
- package/dist/runtime/lib/db/typeInference/typetests/createTable.typetest.d.ts +1 -0
- package/dist/runtime/lib/db/typeInference/typetests/createTable.typetest.js +33 -0
- package/dist/runtime/lib/db/typeInference/typetests/dropTable.typetest.d.ts +1 -0
- package/dist/runtime/lib/db/typeInference/typetests/dropTable.typetest.js +143 -0
- package/dist/runtime/lib/db/typeInference/typetests/print.d.ts +3 -0
- package/dist/runtime/lib/db/typeInference/typetests/print.js +1 -0
- package/dist/runtime/lib/db/typeInference/typetests/testUtils.d.ts +2 -0
- package/dist/runtime/lib/db/typeInference/typetests/testUtils.js +1 -0
- package/dist/runtime/lib/db/typeInference/typetests/typeInference.typetest.d.ts +1 -0
- package/dist/runtime/lib/db/typeInference/typetests/typeInference.typetest.js +17 -0
- package/dist/runtime/lib/db/typeInference/utils.d.ts +82 -0
- package/dist/runtime/lib/db/typeInference/utils.js +2 -0
- package/dist/runtime/lib/debug.d.ts +2 -0
- package/dist/runtime/lib/debug.js +36 -0
- package/dist/runtime/lib/links.d.ts +14 -0
- package/dist/runtime/lib/links.js +38 -0
- package/dist/runtime/lib/realtime/client.d.ts +7 -0
- package/dist/runtime/lib/realtime/client.js +166 -0
- package/dist/runtime/lib/realtime/constants.d.ts +1 -0
- package/dist/runtime/lib/realtime/constants.js +1 -0
- package/dist/runtime/lib/realtime/durableObject.d.ts +29 -0
- package/dist/runtime/lib/realtime/durableObject.js +187 -0
- package/dist/runtime/lib/realtime/renderRealtimeClients.d.ts +7 -0
- package/dist/runtime/lib/realtime/renderRealtimeClients.js +6 -0
- package/dist/runtime/lib/realtime/shared.d.ts +10 -0
- package/dist/runtime/lib/realtime/shared.js +10 -0
- package/dist/runtime/lib/realtime/validateUpgradeRequest.d.ts +6 -0
- package/dist/runtime/lib/realtime/validateUpgradeRequest.js +29 -0
- package/dist/runtime/lib/realtime/worker.d.ts +3 -0
- package/dist/runtime/lib/realtime/worker.js +16 -0
- package/dist/runtime/lib/router.d.ts +56 -0
- package/dist/runtime/lib/router.js +210 -0
- package/dist/runtime/lib/router.test.d.ts +1 -0
- package/dist/runtime/lib/router.test.js +58 -0
- package/dist/runtime/lib/streams/consumeEventStream.d.ts +4 -0
- package/dist/runtime/lib/streams/consumeEventStream.js +13 -0
- package/dist/runtime/lib/turnstile/TurnstileScript.d.ts +1 -0
- package/dist/runtime/lib/turnstile/TurnstileScript.js +2 -0
- package/dist/runtime/lib/turnstile/turnstile.d.ts +3 -0
- package/dist/runtime/lib/turnstile/turnstile.js +3 -0
- package/dist/runtime/lib/turnstile/useTurnstile.d.ts +4 -0
- package/dist/runtime/lib/turnstile/useTurnstile.js +23 -0
- package/dist/runtime/lib/turnstile/verifyTurnstileToken.d.ts +4 -0
- package/dist/runtime/lib/turnstile/verifyTurnstileToken.js +15 -0
- package/dist/runtime/lib/utils.d.ts +1 -0
- package/dist/runtime/lib/utils.js +1 -0
- package/dist/runtime/register/client.d.ts +1 -0
- package/dist/runtime/register/client.js +5 -0
- package/dist/runtime/register/ssr.d.ts +3 -0
- package/dist/runtime/register/ssr.js +26 -0
- package/dist/runtime/register/worker.d.ts +4 -0
- package/dist/runtime/register/worker.js +42 -0
- package/dist/runtime/render/createClientManifest.d.ts +1 -0
- package/dist/runtime/render/createClientManifest.js +7 -0
- package/dist/runtime/render/createModuleMap.d.ts +1 -0
- package/dist/runtime/render/createModuleMap.js +13 -0
- package/dist/runtime/render/injectRSCPayload.d.ts +3 -0
- package/dist/runtime/render/injectRSCPayload.js +79 -0
- package/dist/runtime/render/renderRscThenableToHtmlStream.d.ts +9 -0
- package/dist/runtime/render/renderRscThenableToHtmlStream.js +49 -0
- package/dist/runtime/render/renderToRscStream.d.ts +5 -0
- package/dist/runtime/render/renderToRscStream.js +46 -0
- package/dist/runtime/render/renderToStream.d.ts +9 -0
- package/dist/runtime/render/renderToStream.js +27 -0
- package/dist/runtime/render/renderToString.d.ts +7 -0
- package/dist/runtime/render/renderToString.js +26 -0
- package/dist/runtime/render/transformRscToHtmlStream.d.ts +8 -0
- package/dist/runtime/render/transformRscToHtmlStream.js +19 -0
- package/dist/runtime/requestInfo/types.d.ts +11 -0
- package/dist/runtime/requestInfo/types.js +1 -0
- package/dist/runtime/requestInfo/worker.d.ts +5 -0
- package/dist/runtime/requestInfo/worker.js +33 -0
- package/dist/runtime/script.d.ts +5 -0
- package/dist/runtime/script.js +8 -0
- package/dist/runtime/ssrBridge.d.ts +2 -0
- package/dist/runtime/ssrBridge.js +11 -0
- package/dist/runtime/worker.d.ts +18 -0
- package/dist/runtime/worker.js +173 -0
- package/dist/scripts/__sdk.d.mts +1 -0
- package/dist/scripts/__sdk.mjs +14 -0
- package/dist/scripts/build-vendor-bundles.d.mts +1 -0
- package/dist/scripts/build-vendor-bundles.mjs +92 -0
- package/dist/scripts/debug-sync.d.mts +6 -0
- package/dist/scripts/debug-sync.mjs +224 -0
- package/dist/scripts/dev-init.d.mts +1 -0
- package/dist/scripts/dev-init.mjs +25 -0
- package/dist/scripts/ensure-deploy-env.d.mts +1 -0
- package/dist/scripts/ensure-deploy-env.mjs +271 -0
- package/dist/scripts/ensure-env.d.mts +1 -0
- package/dist/scripts/ensure-env.mjs +9 -0
- package/dist/scripts/migrate-new.d.mts +1 -0
- package/dist/scripts/migrate-new.mjs +51 -0
- package/dist/scripts/smoke-test.d.mts +1 -0
- package/dist/scripts/smoke-test.mjs +166 -0
- package/dist/scripts/worker-run.d.mts +1 -0
- package/dist/scripts/worker-run.mjs +82 -0
- package/dist/vite/aliasByEnvPlugin.d.mts +2 -0
- package/dist/vite/aliasByEnvPlugin.mjs +11 -0
- package/dist/vite/asyncSetupPlugin.d.mts +6 -0
- package/dist/vite/asyncSetupPlugin.mjs +23 -0
- package/dist/vite/checkIsUsingPrisma.d.mts +6 -0
- package/dist/vite/checkIsUsingPrisma.mjs +18 -0
- package/dist/vite/configPlugin.d.mts +9 -0
- package/dist/vite/configPlugin.mjs +169 -0
- package/dist/vite/copyPrismaWasmPlugin.d.mts +4 -0
- package/dist/vite/copyPrismaWasmPlugin.mjs +32 -0
- package/dist/vite/createDirectiveLookupPlugin.d.mts +21 -0
- package/dist/vite/createDirectiveLookupPlugin.mjs +231 -0
- package/dist/vite/customReactBuildPlugin.d.mts +4 -0
- package/dist/vite/customReactBuildPlugin.mjs +61 -0
- package/dist/vite/devServerTimingPlugin.d.mts +2 -0
- package/dist/vite/devServerTimingPlugin.mjs +24 -0
- package/dist/vite/directivesPlugin.d.mts +6 -0
- package/dist/vite/directivesPlugin.mjs +200 -0
- package/dist/vite/ensureAliasArray.d.mts +2 -0
- package/dist/vite/ensureAliasArray.mjs +17 -0
- package/dist/vite/findSpecifiers.d.mts +31 -0
- package/dist/vite/findSpecifiers.mjs +230 -0
- package/dist/vite/findSsrSpecifiers.d.mts +11 -0
- package/dist/vite/findSsrSpecifiers.mjs +67 -0
- package/dist/vite/hasDirective.d.mts +7 -0
- package/dist/vite/hasDirective.mjs +54 -0
- package/dist/vite/hasOwnCloudflareVitePlugin.d.mts +3 -0
- package/dist/vite/hasOwnCloudflareVitePlugin.mjs +14 -0
- package/dist/vite/index.d.mts +1 -0
- package/dist/vite/index.mjs +1 -0
- package/dist/vite/injectHmrPreambleJsxPlugin.d.mts +2 -0
- package/dist/vite/injectHmrPreambleJsxPlugin.mjs +22 -0
- package/dist/vite/injectVitePreamblePlugin.d.mts +4 -0
- package/dist/vite/injectVitePreamblePlugin.mjs +23 -0
- package/dist/vite/invalidateCacheIfPrismaClientChanged.d.mts +3 -0
- package/dist/vite/invalidateCacheIfPrismaClientChanged.mjs +27 -0
- package/dist/vite/invalidateModule.d.mts +6 -0
- package/dist/vite/invalidateModule.mjs +30 -0
- package/dist/vite/miniflareHMRPlugin.d.mts +10 -0
- package/dist/vite/miniflareHMRPlugin.mjs +209 -0
- package/dist/vite/miniflarePlugin.d.mts +9 -0
- package/dist/vite/miniflarePlugin.mjs +135 -0
- package/dist/vite/moveStaticAssetsPlugin.d.mts +4 -0
- package/dist/vite/moveStaticAssetsPlugin.mjs +12 -0
- package/dist/vite/normalizeModulePath.d.mts +1 -0
- package/dist/vite/normalizeModulePath.mjs +13 -0
- package/dist/vite/prismaPlugin.d.mts +4 -0
- package/dist/vite/prismaPlugin.mjs +43 -0
- package/dist/vite/reactConditionsResolverPlugin.d.mts +16 -0
- package/dist/vite/reactConditionsResolverPlugin.mjs +179 -0
- package/dist/vite/redwoodPlugin.d.mts +12 -0
- package/dist/vite/redwoodPlugin.mjs +105 -0
- package/dist/vite/requestUtils.d.mts +6 -0
- package/dist/vite/requestUtils.mjs +35 -0
- package/dist/vite/setupEnvFiles.d.mts +4 -0
- package/dist/vite/setupEnvFiles.mjs +31 -0
- package/dist/vite/ssrBridgePlugin.d.mts +7 -0
- package/dist/vite/ssrBridgePlugin.mjs +137 -0
- package/dist/vite/transformClientComponents.d.mts +12 -0
- package/dist/vite/transformClientComponents.mjs +116 -0
- package/dist/vite/transformClientComponents.test.d.mts +1 -0
- package/dist/vite/transformClientComponents.test.mjs +264 -0
- package/dist/vite/transformJsxScriptTagsPlugin.d.mts +8 -0
- package/dist/vite/transformJsxScriptTagsPlugin.mjs +315 -0
- package/dist/vite/transformJsxScriptTagsPlugin.test.d.mts +1 -0
- package/dist/vite/transformJsxScriptTagsPlugin.test.mjs +334 -0
- package/dist/vite/transformServerFunctions.d.mts +16 -0
- package/dist/vite/transformServerFunctions.mjs +296 -0
- package/dist/vite/transformServerFunctions.test.d.mts +1 -0
- package/dist/vite/transformServerFunctions.test.mjs +124 -0
- package/dist/vite/useClientLookupPlugin.d.mts +5 -0
- package/dist/vite/useClientLookupPlugin.mjs +15 -0
- package/dist/vite/useClientPlugin.d.mts +8 -0
- package/dist/vite/useClientPlugin.mjs +295 -0
- package/dist/vite/useClientPlugin.test.d.mts +1 -0
- package/dist/vite/useClientPlugin.test.mjs +1204 -0
- package/dist/vite/useServerLookupPlugin.d.mts +5 -0
- package/dist/vite/useServerLookupPlugin.mjs +15 -0
- package/dist/vite/useServerPlugin.d.mts +1 -0
- package/dist/vite/useServerPlugin.mjs +1 -0
- package/dist/vite/virtualPlugin.d.mts +2 -0
- package/dist/vite/virtualPlugin.mjs +18 -0
- package/dist/vite/vitePreamblePlugin.d.mts +1 -0
- package/dist/vite/vitePreamblePlugin.mjs +11 -0
- package/dist/worker/__ssr_bridge.js +8947 -0
- package/dist/worker/__ssr_bridge.js.map +1 -0
- package/package.json +1 -1
- package/dist/vite/invalidateClientModule.d.mts +0 -2
- package/dist/vite/invalidateClientModule.mjs +0 -8
- package/dist/vite/invalidateModule copy.d.mts +0 -2
- package/dist/vite/invalidateModule copy.mjs +0 -14
- package/dist/vite/invalidateSSRModule.d.mts +0 -2
- package/dist/vite/invalidateSSRModule.mjs +0 -7
- package/dist/vite/mode.d.mts +0 -5
- package/dist/vite/mode.mjs +0 -25
- package/dist/vite/modePlugin.d.mts +0 -2
- package/dist/vite/modePlugin.mjs +0 -10
- /package/dist/vite/{isJsFile.d.ts → isJsFile.d.mts} +0 -0
- /package/dist/vite/{isJsFile.js → isJsFile.mjs} +0 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { setTimeout } from "node:timers/promises";
|
|
2
|
+
import { log, RETRIES } from "./constants.mjs";
|
|
3
|
+
import { $ } from "../$.mjs";
|
|
4
|
+
import { checkUrl, checkServerUp } from "./browser.mjs";
|
|
5
|
+
import { fail } from "./utils.mjs";
|
|
6
|
+
import { state } from "./state.mjs";
|
|
7
|
+
/**
|
|
8
|
+
* Run the local development server and return the URL
|
|
9
|
+
*/
|
|
10
|
+
export async function runDevServer(cwd) {
|
|
11
|
+
console.log("🚀 Starting development server...");
|
|
12
|
+
// Function to stop the dev server - defined early so we can use it in error handling
|
|
13
|
+
let devProcess = null;
|
|
14
|
+
let isErrorExpected = false;
|
|
15
|
+
const stopDev = async () => {
|
|
16
|
+
isErrorExpected = true;
|
|
17
|
+
if (!devProcess) {
|
|
18
|
+
log("No dev process to stop");
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
console.log("Stopping development server...");
|
|
22
|
+
try {
|
|
23
|
+
// Send a regular termination signal first
|
|
24
|
+
devProcess.kill();
|
|
25
|
+
// Wait for the process to terminate with a timeout
|
|
26
|
+
const terminationTimeout = 5000; // 5 seconds timeout
|
|
27
|
+
const terminationPromise = Promise.race([
|
|
28
|
+
// Wait for natural process termination
|
|
29
|
+
(async () => {
|
|
30
|
+
try {
|
|
31
|
+
await devProcess;
|
|
32
|
+
log("Dev server process was terminated normally");
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
// Expected error when the process is killed
|
|
37
|
+
log("Dev server process was terminated");
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
})(),
|
|
41
|
+
// Or timeout
|
|
42
|
+
(async () => {
|
|
43
|
+
await setTimeout(terminationTimeout);
|
|
44
|
+
return false;
|
|
45
|
+
})(),
|
|
46
|
+
]);
|
|
47
|
+
// Check if process terminated within timeout
|
|
48
|
+
const terminated = await terminationPromise;
|
|
49
|
+
// If not terminated within timeout, force kill
|
|
50
|
+
if (!terminated) {
|
|
51
|
+
log("Dev server process did not terminate within timeout, force killing with SIGKILL");
|
|
52
|
+
console.log("⚠️ Development server not responding after 5 seconds timeout, force killing...");
|
|
53
|
+
// Try to kill with SIGKILL if the process still has a pid
|
|
54
|
+
if (devProcess.pid) {
|
|
55
|
+
try {
|
|
56
|
+
// Use process.kill with SIGKILL for a stronger termination
|
|
57
|
+
process.kill(devProcess.pid, "SIGKILL");
|
|
58
|
+
log("Sent SIGKILL to process %d", devProcess.pid);
|
|
59
|
+
}
|
|
60
|
+
catch (killError) {
|
|
61
|
+
log("Error sending SIGKILL to process: %O", killError);
|
|
62
|
+
// Non-fatal, as the process might already be gone
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
// Process might already have exited
|
|
69
|
+
log("Could not kill dev server process: %O", e);
|
|
70
|
+
}
|
|
71
|
+
console.log("Development server stopped");
|
|
72
|
+
};
|
|
73
|
+
try {
|
|
74
|
+
// Check if we're in CI mode
|
|
75
|
+
const inCIMode = process.env.CI === "true" || process.env.CI === "1";
|
|
76
|
+
// Start dev server with stdout pipe to capture URL
|
|
77
|
+
// Create environment variables object
|
|
78
|
+
const env = { ...process.env };
|
|
79
|
+
// Disable colors when running in CI mode to make URL parsing more reliable
|
|
80
|
+
if (inCIMode) {
|
|
81
|
+
log("Running in CI mode, disabling colors for dev server output");
|
|
82
|
+
env.NO_COLOR = "1";
|
|
83
|
+
env.FORCE_COLOR = "0";
|
|
84
|
+
}
|
|
85
|
+
// Use the provided cwd if available
|
|
86
|
+
devProcess = $({
|
|
87
|
+
stdio: ["inherit", "pipe", "pipe"], // Pipe stderr again to check both streams
|
|
88
|
+
detached: true,
|
|
89
|
+
cleanup: false, // Don't auto-kill on exit
|
|
90
|
+
cwd: cwd || process.cwd(), // Use provided directory or current directory
|
|
91
|
+
env, // Pass the updated environment variables
|
|
92
|
+
}) `npm run dev`;
|
|
93
|
+
devProcess.catch((error) => {
|
|
94
|
+
if (!isErrorExpected) {
|
|
95
|
+
// Use fail() directly here to properly handle errors from the dev process
|
|
96
|
+
fail(error, 1, "Development Server Process");
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
log("Development server process spawned in directory: %s", cwd || process.cwd());
|
|
100
|
+
// Store chunks to parse the URL
|
|
101
|
+
let url = "";
|
|
102
|
+
// Listen for stdout to get the URL
|
|
103
|
+
devProcess.stdout?.on("data", (data) => {
|
|
104
|
+
const output = data.toString();
|
|
105
|
+
console.log(output);
|
|
106
|
+
// Try to extract the URL from the server output with a more flexible regex
|
|
107
|
+
// Allow for variable amounts of whitespace between "Local:" and the URL
|
|
108
|
+
// And handle ANSI color codes by using a more robust pattern
|
|
109
|
+
const localMatch = output.match(/Local:.*?(http:\/\/localhost:\d+)/);
|
|
110
|
+
if (localMatch && localMatch[1] && !url) {
|
|
111
|
+
url = localMatch[1];
|
|
112
|
+
log("Found development server URL: %s", url);
|
|
113
|
+
}
|
|
114
|
+
else if (output.includes("Local:") &&
|
|
115
|
+
output.includes("http://localhost:")) {
|
|
116
|
+
// Log near-match for debugging
|
|
117
|
+
log("Found potential URL pattern but regex didn't match. Content: %s", output);
|
|
118
|
+
// Try an alternative, more general pattern that's more resilient to ANSI codes
|
|
119
|
+
const altMatch = output.match(/localhost:(\d+)/i);
|
|
120
|
+
if (altMatch && altMatch[1] && !url) {
|
|
121
|
+
url = `http://localhost:${altMatch[1]}`;
|
|
122
|
+
log("Found development server URL with alternative pattern: %s", url);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
// Also listen for stderr to check for URL patterns there as well
|
|
127
|
+
devProcess.stderr?.on("data", (data) => {
|
|
128
|
+
const output = data.toString();
|
|
129
|
+
console.error(output); // Output error messages to console
|
|
130
|
+
// Check if we already found a URL
|
|
131
|
+
if (url)
|
|
132
|
+
return;
|
|
133
|
+
// Check for localhost URLs in stderr using the same resilient patterns as stdout
|
|
134
|
+
const urlMatch = output.match(/localhost:(\d+)/i);
|
|
135
|
+
if (urlMatch && urlMatch[1]) {
|
|
136
|
+
url = `http://localhost:${urlMatch[1]}`;
|
|
137
|
+
log("Found development server URL in stderr: %s", url);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
// Wait for URL with timeout
|
|
141
|
+
const waitForUrl = async () => {
|
|
142
|
+
const start = Date.now();
|
|
143
|
+
const timeout = 60000; // 60 seconds
|
|
144
|
+
while (Date.now() - start < timeout) {
|
|
145
|
+
if (url) {
|
|
146
|
+
return url;
|
|
147
|
+
}
|
|
148
|
+
// Check if the process is still running
|
|
149
|
+
if (devProcess.exitCode !== null) {
|
|
150
|
+
log("ERROR: Development server process exited with code %d", devProcess.exitCode);
|
|
151
|
+
throw new Error(`Development server process exited with code ${devProcess.exitCode}`);
|
|
152
|
+
}
|
|
153
|
+
await setTimeout(500); // Check every 500ms
|
|
154
|
+
}
|
|
155
|
+
log("ERROR: Timed out waiting for dev server URL");
|
|
156
|
+
throw new Error("Timed out waiting for dev server URL");
|
|
157
|
+
};
|
|
158
|
+
// Wait for the URL
|
|
159
|
+
const serverUrl = await waitForUrl();
|
|
160
|
+
console.log(`✅ Development server started at ${serverUrl}`);
|
|
161
|
+
return { url: serverUrl, stopDev };
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
// Make sure to try to stop the server on error
|
|
165
|
+
log("Error during dev server startup: %O", error);
|
|
166
|
+
await stopDev().catch((e) => {
|
|
167
|
+
log("Failed to stop dev server during error handling: %O", e);
|
|
168
|
+
});
|
|
169
|
+
throw error;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Runs tests against the development server
|
|
174
|
+
*/
|
|
175
|
+
export async function runDevTest(url, artifactDir, customPath = "/", browserPath, headless = true, bail = false, skipClient = false, realtime = false, skipHmr = false) {
|
|
176
|
+
log("Starting dev server test with path: %s", customPath || "/");
|
|
177
|
+
console.log("🚀 Testing local development server");
|
|
178
|
+
try {
|
|
179
|
+
// DRY: check both root and custom path
|
|
180
|
+
await checkServerUp(url, customPath, RETRIES, bail);
|
|
181
|
+
// Now run the tests with the custom path
|
|
182
|
+
const testUrl = url +
|
|
183
|
+
(customPath === "/"
|
|
184
|
+
? ""
|
|
185
|
+
: customPath.startsWith("/")
|
|
186
|
+
? customPath
|
|
187
|
+
: "/" + customPath);
|
|
188
|
+
// Pass the target directory to checkUrl for HMR testing
|
|
189
|
+
const targetDir = state.resources.targetDir;
|
|
190
|
+
await checkUrl(testUrl, artifactDir, browserPath, headless, bail, skipClient, "Development", // Add environment context parameter
|
|
191
|
+
realtime, // Add realtime parameter
|
|
192
|
+
targetDir, // Add target directory for HMR testing
|
|
193
|
+
skipHmr);
|
|
194
|
+
log("Development server test completed successfully");
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
// Add more context about the specific part that failed
|
|
198
|
+
if (error instanceof Error && error.message.includes("Server at")) {
|
|
199
|
+
state.failures.push({
|
|
200
|
+
step: "Development - Server Availability",
|
|
201
|
+
error: error.message,
|
|
202
|
+
details: error.stack,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
log("Error during development server testing: %O", error);
|
|
206
|
+
// Make sure we throw the error so it's properly handled upstream
|
|
207
|
+
throw error;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import tmp from "tmp-promise";
|
|
2
|
+
import { SmokeTestOptions, TestResources } from "./types.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Sets up the test environment, preparing any resources needed for testing
|
|
5
|
+
*/
|
|
6
|
+
export declare function setupTestEnvironment(options?: SmokeTestOptions): Promise<TestResources>;
|
|
7
|
+
/**
|
|
8
|
+
* Copy project to a temporary directory with a unique name
|
|
9
|
+
*/
|
|
10
|
+
export declare function copyProjectToTempDir(projectDir: string, sync: boolean | undefined, resourceUniqueKey: string): Promise<{
|
|
11
|
+
tempDir: tmp.DirectoryResult;
|
|
12
|
+
targetDir: string;
|
|
13
|
+
workerName: string;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { join } from "path";
|
|
2
|
+
import { pathExists, copy } from "fs-extra";
|
|
3
|
+
import * as fs from "fs/promises";
|
|
4
|
+
import tmp from "tmp-promise";
|
|
5
|
+
import ignore from "ignore";
|
|
6
|
+
import { relative, basename, resolve } from "path";
|
|
7
|
+
import { uniqueNamesGenerator, adjectives, animals, } from "unique-names-generator";
|
|
8
|
+
import { $ } from "../../lib/$.mjs";
|
|
9
|
+
import { log } from "./constants.mjs";
|
|
10
|
+
import { debugSync } from "../../scripts/debug-sync.mjs";
|
|
11
|
+
import { createSmokeTestComponents } from "./codeUpdates.mjs";
|
|
12
|
+
import { createHash } from "crypto";
|
|
13
|
+
/**
|
|
14
|
+
* Sets up the test environment, preparing any resources needed for testing
|
|
15
|
+
*/
|
|
16
|
+
export async function setupTestEnvironment(options = {}) {
|
|
17
|
+
log("Setting up test environment with options: %O", options);
|
|
18
|
+
// Generate a resource unique key for this test run right at the start
|
|
19
|
+
const uniqueNameSuffix = uniqueNamesGenerator({
|
|
20
|
+
dictionaries: [adjectives, animals],
|
|
21
|
+
separator: "-",
|
|
22
|
+
length: 2,
|
|
23
|
+
style: "lowerCase",
|
|
24
|
+
});
|
|
25
|
+
// Create a short unique hash based on the timestamp
|
|
26
|
+
const hash = createHash("md5")
|
|
27
|
+
.update(Date.now().toString())
|
|
28
|
+
.digest("hex")
|
|
29
|
+
.substring(0, 8);
|
|
30
|
+
// Create a resource unique key even if we're not copying a project
|
|
31
|
+
const resourceUniqueKey = `${uniqueNameSuffix}-${hash}`;
|
|
32
|
+
const resources = {
|
|
33
|
+
tempDirCleanup: undefined,
|
|
34
|
+
workerName: undefined,
|
|
35
|
+
originalCwd: process.cwd(),
|
|
36
|
+
targetDir: undefined,
|
|
37
|
+
workerCreatedDuringTest: false,
|
|
38
|
+
stopDev: undefined,
|
|
39
|
+
resourceUniqueKey, // Set at initialization
|
|
40
|
+
};
|
|
41
|
+
log("Current working directory: %s", resources.originalCwd);
|
|
42
|
+
try {
|
|
43
|
+
// If a project dir is specified, copy it to a temp dir with a unique name
|
|
44
|
+
if (options.projectDir) {
|
|
45
|
+
log("Project directory specified: %s", options.projectDir);
|
|
46
|
+
const { tempDir, targetDir, workerName } = await copyProjectToTempDir(options.projectDir, options.sync !== false, // default to true if undefined
|
|
47
|
+
resourceUniqueKey);
|
|
48
|
+
// Store cleanup function
|
|
49
|
+
resources.tempDirCleanup = tempDir.cleanup;
|
|
50
|
+
resources.workerName = workerName;
|
|
51
|
+
resources.targetDir = targetDir;
|
|
52
|
+
log("Target directory: %s", targetDir);
|
|
53
|
+
// Create the smoke test components in the user's project
|
|
54
|
+
log("Creating smoke test components");
|
|
55
|
+
await createSmokeTestComponents(targetDir, options.skipClient);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
log("No project directory specified, using current directory");
|
|
59
|
+
// When no project dir is specified, we'll use the current directory
|
|
60
|
+
resources.targetDir = resources.originalCwd;
|
|
61
|
+
}
|
|
62
|
+
return resources;
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
log("Error during test environment setup: %O", error);
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Copy project to a temporary directory with a unique name
|
|
71
|
+
*/
|
|
72
|
+
export async function copyProjectToTempDir(projectDir, sync = true, resourceUniqueKey) {
|
|
73
|
+
log("Creating temporary directory for project");
|
|
74
|
+
// Create a temporary directory
|
|
75
|
+
const tempDir = await tmp.dir({ unsafeCleanup: true });
|
|
76
|
+
// Create unique project directory name
|
|
77
|
+
const originalDirName = basename(projectDir);
|
|
78
|
+
const workerName = `${originalDirName}-smoke-test-${resourceUniqueKey}`;
|
|
79
|
+
const targetDir = resolve(tempDir.path, workerName);
|
|
80
|
+
console.log(`Copying project from ${projectDir} to ${targetDir}`);
|
|
81
|
+
// Read project's .gitignore if it exists
|
|
82
|
+
let ig = ignore();
|
|
83
|
+
const gitignorePath = join(projectDir, ".gitignore");
|
|
84
|
+
if (await pathExists(gitignorePath)) {
|
|
85
|
+
log("Found .gitignore file at %s", gitignorePath);
|
|
86
|
+
const gitignoreContent = await fs.readFile(gitignorePath, "utf-8");
|
|
87
|
+
ig = ig.add(gitignoreContent);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
log("No .gitignore found, using default ignore patterns");
|
|
91
|
+
// Add default ignores if no .gitignore exists
|
|
92
|
+
ig = ig.add([
|
|
93
|
+
"node_modules",
|
|
94
|
+
".git",
|
|
95
|
+
"dist",
|
|
96
|
+
"build",
|
|
97
|
+
".DS_Store",
|
|
98
|
+
"coverage",
|
|
99
|
+
".cache",
|
|
100
|
+
".wrangler",
|
|
101
|
+
".env",
|
|
102
|
+
].join("\n"));
|
|
103
|
+
}
|
|
104
|
+
// Copy the project directory, respecting .gitignore
|
|
105
|
+
log("Starting copy process with ignored patterns");
|
|
106
|
+
await copy(projectDir, targetDir, {
|
|
107
|
+
filter: (src) => {
|
|
108
|
+
// Get path relative to project directory
|
|
109
|
+
const relativePath = relative(projectDir, src);
|
|
110
|
+
if (!relativePath)
|
|
111
|
+
return true; // Include the root directory
|
|
112
|
+
// Check against ignore patterns
|
|
113
|
+
const result = !ig.ignores(relativePath);
|
|
114
|
+
return result;
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
log("Project copy completed successfully");
|
|
118
|
+
// Install dependencies in the target directory
|
|
119
|
+
await installDependencies(targetDir);
|
|
120
|
+
// Sync SDK to the temp dir if requested
|
|
121
|
+
if (sync) {
|
|
122
|
+
console.log(`🔄 Syncing SDK to ${targetDir} after installing dependencies...`);
|
|
123
|
+
await debugSync({ targetDir });
|
|
124
|
+
}
|
|
125
|
+
return { tempDir, targetDir, workerName };
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Install project dependencies using pnpm
|
|
129
|
+
*/
|
|
130
|
+
async function installDependencies(targetDir) {
|
|
131
|
+
console.log(`📦 Installing project dependencies in ${targetDir}...`);
|
|
132
|
+
try {
|
|
133
|
+
// Run pnpm install in the target directory
|
|
134
|
+
log("Running pnpm install");
|
|
135
|
+
const result = await $({
|
|
136
|
+
cwd: targetDir,
|
|
137
|
+
stdio: "pipe", // Capture output
|
|
138
|
+
}) `pnpm install`;
|
|
139
|
+
console.log("✅ Dependencies installed successfully");
|
|
140
|
+
// Log installation details at debug level
|
|
141
|
+
if (result.stdout) {
|
|
142
|
+
log("pnpm install output: %s", result.stdout);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
log("ERROR: Failed to install dependencies: %O", error);
|
|
147
|
+
console.error(`❌ Failed to install dependencies: ${error instanceof Error ? error.message : String(error)}`);
|
|
148
|
+
// Try npm as fallback if pnpm fails
|
|
149
|
+
try {
|
|
150
|
+
console.log("⚠️ pnpm install failed, trying npm install as fallback...");
|
|
151
|
+
await $({
|
|
152
|
+
cwd: targetDir,
|
|
153
|
+
stdio: "pipe",
|
|
154
|
+
}) `npm install`;
|
|
155
|
+
console.log("✅ Dependencies installed successfully with npm");
|
|
156
|
+
}
|
|
157
|
+
catch (npmError) {
|
|
158
|
+
log("ERROR: Both pnpm and npm install failed: %O", npmError);
|
|
159
|
+
console.error(`❌ Failed to install dependencies with npm: ${npmError instanceof Error ? npmError.message : String(npmError)}`);
|
|
160
|
+
throw new Error(`Failed to install project dependencies. Please ensure the project can be installed with pnpm or npm.`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { TestResources } from "./types.mjs";
|
|
2
|
+
interface ExpectOptions {
|
|
3
|
+
expect: string | RegExp;
|
|
4
|
+
send?: string;
|
|
5
|
+
}
|
|
6
|
+
interface ExpectResult {
|
|
7
|
+
stdout: string;
|
|
8
|
+
stderr: string;
|
|
9
|
+
code: number | null;
|
|
10
|
+
}
|
|
11
|
+
interface D1Database {
|
|
12
|
+
name: string;
|
|
13
|
+
uuid: string;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A mini expect-like utility for handling interactive CLI prompts and verifying output
|
|
18
|
+
* @param command The command to execute
|
|
19
|
+
* @param expectations Array of {expect, send} objects for interactive responses and verification
|
|
20
|
+
* @param options Additional options for command execution including working directory and environment
|
|
21
|
+
* @returns Promise that resolves when the command completes
|
|
22
|
+
*/
|
|
23
|
+
export declare function $expect(command: string, expectations: Array<ExpectOptions>, options?: {
|
|
24
|
+
reject?: boolean;
|
|
25
|
+
env?: NodeJS.ProcessEnv;
|
|
26
|
+
cwd?: string;
|
|
27
|
+
}): Promise<ExpectResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Ensures Cloudflare account ID is set in environment
|
|
30
|
+
* First checks wrangler cache, then environment variables, and finally guides the user
|
|
31
|
+
*/
|
|
32
|
+
export declare function ensureCloudflareAccountId(cwd?: string, projectDir?: string): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Run the release command to deploy to Cloudflare
|
|
35
|
+
*/
|
|
36
|
+
export declare function runRelease(cwd: string, projectDir: string, resourceUniqueKey: string): Promise<{
|
|
37
|
+
url: string;
|
|
38
|
+
workerName: string;
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* Runs tests against the production deployment
|
|
42
|
+
*/
|
|
43
|
+
export declare function runReleaseTest(customPath: string | undefined, artifactDir: string, resources: TestResources, browserPath?: string, headless?: boolean, bail?: boolean, skipClient?: boolean, projectDir?: string, realtime?: boolean, skipHmr?: boolean): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Check if a resource name includes a specific resource unique key
|
|
46
|
+
* This is used to identify resources created during our tests
|
|
47
|
+
*/
|
|
48
|
+
export declare function isRelatedToTest(resourceName: string, resourceUniqueKey: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Delete the worker using wrangler
|
|
51
|
+
*/
|
|
52
|
+
export declare function deleteWorker(name: string, cwd: string, resourceUniqueKey: string): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* List D1 databases using wrangler
|
|
55
|
+
*/
|
|
56
|
+
export declare function listD1Databases(cwd?: string): Promise<Array<D1Database>>;
|
|
57
|
+
/**
|
|
58
|
+
* Delete a D1 database using wrangler
|
|
59
|
+
*/
|
|
60
|
+
export declare function deleteD1Database(name: string, cwd: string, resourceUniqueKey: string): Promise<void>;
|
|
61
|
+
export {};
|