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
package/dist/lib/$.d.mts
ADDED
package/dist/lib/$.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const compileTsModule: (tsCode: string) => string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import path from "path";
|
|
3
|
+
export const compileTsModule = (tsCode) => {
|
|
4
|
+
const tsConfigPath = "./tsconfig.json";
|
|
5
|
+
// Find the nearest tsconfig.json
|
|
6
|
+
const configPath = ts.findConfigFile(path.dirname(tsConfigPath), ts.sys.fileExists, path.basename(tsConfigPath));
|
|
7
|
+
if (!configPath) {
|
|
8
|
+
throw new Error(`Could not find a valid tsconfig.json at path: ${tsConfigPath}`);
|
|
9
|
+
}
|
|
10
|
+
// Read and parse tsconfig.json
|
|
11
|
+
const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
12
|
+
if (configFile.error) {
|
|
13
|
+
throw new Error(`Error reading tsconfig.json: ${ts.formatDiagnostic(configFile.error, ts.createCompilerHost({}))}`);
|
|
14
|
+
}
|
|
15
|
+
const parsedConfig = ts.parseJsonConfigFileContent(configFile.config, ts.sys, path.dirname(configPath));
|
|
16
|
+
const compilerOptions = parsedConfig.options;
|
|
17
|
+
// Transpile the TypeScript code using the compiler options
|
|
18
|
+
const output = ts.transpileModule(tsCode, {
|
|
19
|
+
compilerOptions,
|
|
20
|
+
reportDiagnostics: true,
|
|
21
|
+
});
|
|
22
|
+
if (output.diagnostics && output.diagnostics.length) {
|
|
23
|
+
const diagnosticMessages = output.diagnostics.map((diagnostic) => ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
|
|
24
|
+
throw new Error(`TypeScript Compilation Errors:\n${diagnosticMessages.join("\n")}`);
|
|
25
|
+
}
|
|
26
|
+
return output.outputText; // Compiled JavaScript code
|
|
27
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
const __dirname = new URL(".", import.meta.url).pathname;
|
|
3
|
+
export const ROOT_DIR = resolve(__dirname, "..", "..");
|
|
4
|
+
export const SRC_DIR = resolve(ROOT_DIR, "src");
|
|
5
|
+
export const DIST_DIR = resolve(ROOT_DIR, "dist");
|
|
6
|
+
export const SSR_BRIDGE_PATH = resolve(DIST_DIR, "worker", "__ssr_bridge.js");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const findWranglerConfig: (projectRootDir: string) => Promise<string>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { pathExists } from "fs-extra";
|
|
2
|
+
import { resolve } from "path";
|
|
3
|
+
export const findWranglerConfig = async (projectRootDir) => {
|
|
4
|
+
const configFiles = ["wrangler.jsonc", "wrangler.json", "wrangler.toml"];
|
|
5
|
+
for (const file of configFiles) {
|
|
6
|
+
const fullPath = resolve(projectRootDir, file);
|
|
7
|
+
if (await pathExists(fullPath)) {
|
|
8
|
+
return fullPath;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
throw new Error("No wrangler configuration file found.");
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getShortName: (file: string, root: string) => string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets all source file paths by parsing tsconfig.json using TypeScript's compiler API.
|
|
3
|
+
* Falls back to a glob pattern if tsconfig parsing fails.
|
|
4
|
+
*
|
|
5
|
+
* @param rootDir - The root directory to search from (defaults to current working directory)
|
|
6
|
+
* @returns Promise<string[]> - Array of source file paths
|
|
7
|
+
*/
|
|
8
|
+
export declare function getSrcPaths(rootDir?: string): Promise<string[]>;
|
|
9
|
+
/**
|
|
10
|
+
* Synchronous version of getSrcPaths
|
|
11
|
+
*
|
|
12
|
+
* @param rootDir - The root directory to search from (defaults to current working directory)
|
|
13
|
+
* @returns string[] - Array of source file paths
|
|
14
|
+
*/
|
|
15
|
+
export declare function getSrcPathsSync(rootDir?: string): string[];
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { glob } from "glob";
|
|
4
|
+
/**
|
|
5
|
+
* Gets all source file paths by parsing tsconfig.json using TypeScript's compiler API.
|
|
6
|
+
* Falls back to a glob pattern if tsconfig parsing fails.
|
|
7
|
+
*
|
|
8
|
+
* @param rootDir - The root directory to search from (defaults to current working directory)
|
|
9
|
+
* @returns Promise<string[]> - Array of source file paths
|
|
10
|
+
*/
|
|
11
|
+
export async function getSrcPaths(rootDir = process.cwd()) {
|
|
12
|
+
try {
|
|
13
|
+
const configPath = ts.findConfigFile(rootDir, ts.sys.fileExists, "tsconfig.json");
|
|
14
|
+
if (configPath) {
|
|
15
|
+
const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
16
|
+
if (!configFile.error) {
|
|
17
|
+
// Parse tsconfig
|
|
18
|
+
const parsed = ts.parseJsonConfigFileContent(configFile.config, ts.sys, path.dirname(configPath));
|
|
19
|
+
if (parsed.fileNames && parsed.fileNames.length > 0) {
|
|
20
|
+
return parsed.fileNames;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
console.warn("Failed to parse tsconfig.json, falling back to glob pattern:", error);
|
|
27
|
+
}
|
|
28
|
+
// Fallback to glob pattern
|
|
29
|
+
try {
|
|
30
|
+
const globPattern = path.join(rootDir, "src/**/*.{ts,mts,tsx,jsx,mjs,js}");
|
|
31
|
+
const files = await glob(globPattern, {
|
|
32
|
+
ignore: ["**/node_modules/**", "**/dist/**", "**/*.d.ts"],
|
|
33
|
+
absolute: true,
|
|
34
|
+
nodir: true,
|
|
35
|
+
});
|
|
36
|
+
return files;
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
console.error("Failed to get source paths with glob pattern:", error);
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Synchronous version of getSrcPaths
|
|
45
|
+
*
|
|
46
|
+
* @param rootDir - The root directory to search from (defaults to current working directory)
|
|
47
|
+
* @returns string[] - Array of source file paths
|
|
48
|
+
*/
|
|
49
|
+
export function getSrcPathsSync(rootDir = process.cwd()) {
|
|
50
|
+
try {
|
|
51
|
+
// Try TypeScript compiler API approach first
|
|
52
|
+
const configPath = ts.findConfigFile(rootDir, ts.sys.fileExists, "tsconfig.json");
|
|
53
|
+
if (configPath) {
|
|
54
|
+
const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
55
|
+
if (!configFile.error) {
|
|
56
|
+
// Parse tsconfig
|
|
57
|
+
const parsed = ts.parseJsonConfigFileContent(configFile.config, ts.sys, path.dirname(configPath));
|
|
58
|
+
if (parsed.fileNames && parsed.fileNames.length > 0) {
|
|
59
|
+
return parsed.fileNames;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
console.warn("Failed to parse tsconfig.json, falling back to glob pattern:", error);
|
|
66
|
+
}
|
|
67
|
+
// Fallback to glob pattern
|
|
68
|
+
try {
|
|
69
|
+
const globPattern = path.join(rootDir, "src/**/*.{ts,mts,tsx,jsx,mjs,js}");
|
|
70
|
+
const files = glob.sync(globPattern, {
|
|
71
|
+
ignore: ["**/node_modules/**", "**/dist/**", "**/*.d.ts"],
|
|
72
|
+
absolute: true,
|
|
73
|
+
});
|
|
74
|
+
return files;
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
console.error("Failed to get source paths with glob pattern:", error);
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const hasPkgScript: (projectRootDir: string, script: string) => Promise<any>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { readFile } from "fs/promises";
|
|
2
|
+
import { resolve } from "path";
|
|
3
|
+
let pkg;
|
|
4
|
+
export const hasPkgScript = async (projectRootDir, script) => {
|
|
5
|
+
if (!pkg) {
|
|
6
|
+
pkg = JSON.parse(await readFile(resolve(projectRootDir, "package.json"), "utf-8"));
|
|
7
|
+
}
|
|
8
|
+
return pkg.scripts?.[script];
|
|
9
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for working with JSON in CLI output
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Attempt to extract the last JSON object or array from a string by
|
|
6
|
+
* first finding closing braces/brackets and then matching them to their
|
|
7
|
+
* opening counterparts.
|
|
8
|
+
*
|
|
9
|
+
* @param output - The string to parse
|
|
10
|
+
* @returns JSON object or null if invalid
|
|
11
|
+
*/
|
|
12
|
+
export declare function extractLastJson(output: string | undefined): any;
|
|
13
|
+
/**
|
|
14
|
+
* Extract all valid JSON objects or arrays from a string
|
|
15
|
+
*
|
|
16
|
+
* @param input - The string that might contain multiple JSON objects
|
|
17
|
+
* @returns Array of parsed JSON objects
|
|
18
|
+
*/
|
|
19
|
+
export declare function extractAllJson(input: string | undefined): any[];
|
|
20
|
+
/**
|
|
21
|
+
* Safely parses JSON from a string that might include other content
|
|
22
|
+
*
|
|
23
|
+
* @param input - The string that might contain JSON
|
|
24
|
+
* @param defaultValue - Default value to return if no JSON is found
|
|
25
|
+
* @param findUuid - If true, look for an object with a uuid property
|
|
26
|
+
* @returns The parsed JSON or the default value
|
|
27
|
+
*/
|
|
28
|
+
export declare function parseJson<T>(input: string | undefined, defaultValue: T, findUuid?: boolean): T;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for working with JSON in CLI output
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Attempt to extract the last JSON object or array from a string by
|
|
6
|
+
* first finding closing braces/brackets and then matching them to their
|
|
7
|
+
* opening counterparts.
|
|
8
|
+
*
|
|
9
|
+
* @param output - The string to parse
|
|
10
|
+
* @returns JSON object or null if invalid
|
|
11
|
+
*/
|
|
12
|
+
export function extractLastJson(output) {
|
|
13
|
+
if (!output)
|
|
14
|
+
return null;
|
|
15
|
+
try {
|
|
16
|
+
// First try a direct parse of the entire output
|
|
17
|
+
// (in case it's already valid JSON with no surrounding text)
|
|
18
|
+
try {
|
|
19
|
+
return JSON.parse(output);
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
// If that fails, try more complex extraction
|
|
23
|
+
}
|
|
24
|
+
// Start from the end of the string to find closing braces/brackets
|
|
25
|
+
for (let i = output.length - 1; i >= 0; i--) {
|
|
26
|
+
// Look for closing braces/brackets
|
|
27
|
+
if (output[i] === "}" || output[i] === "]") {
|
|
28
|
+
const closingChar = output[i];
|
|
29
|
+
const openingChar = closingChar === "}" ? "{" : "[";
|
|
30
|
+
// Find the matching opening brace/bracket
|
|
31
|
+
let balance = 1; // Start with 1 since we've already found a closing char
|
|
32
|
+
let j = i - 1;
|
|
33
|
+
while (j >= 0 && balance > 0) {
|
|
34
|
+
if (output[j] === closingChar) {
|
|
35
|
+
balance++;
|
|
36
|
+
}
|
|
37
|
+
else if (output[j] === openingChar) {
|
|
38
|
+
balance--;
|
|
39
|
+
// If balance is 0, we found the matching opening char
|
|
40
|
+
if (balance === 0) {
|
|
41
|
+
// Extract the potential JSON and try to parse it
|
|
42
|
+
const extracted = output.substring(j, i + 1);
|
|
43
|
+
try {
|
|
44
|
+
const parsed = JSON.parse(extracted);
|
|
45
|
+
return parsed;
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
// Not valid JSON, continue
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
j--;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// If we reach here, no valid JSON was found
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
console.error("Error extracting last JSON:", error);
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Extract all valid JSON objects or arrays from a string
|
|
67
|
+
*
|
|
68
|
+
* @param input - The string that might contain multiple JSON objects
|
|
69
|
+
* @returns Array of parsed JSON objects
|
|
70
|
+
*/
|
|
71
|
+
export function extractAllJson(input) {
|
|
72
|
+
if (!input)
|
|
73
|
+
return [];
|
|
74
|
+
const results = [];
|
|
75
|
+
let remainingText = input;
|
|
76
|
+
// Try to extract JSON objects until no more are found
|
|
77
|
+
while (remainingText.length > 0) {
|
|
78
|
+
// Find opening braces/brackets
|
|
79
|
+
const openBracePos = remainingText.indexOf("{");
|
|
80
|
+
const openBracketPos = remainingText.indexOf("[");
|
|
81
|
+
// Determine which comes first (if any)
|
|
82
|
+
let startPos = -1;
|
|
83
|
+
let openChar = "";
|
|
84
|
+
let closeChar = "";
|
|
85
|
+
if (openBracePos >= 0 &&
|
|
86
|
+
(openBracketPos < 0 || openBracePos < openBracketPos)) {
|
|
87
|
+
startPos = openBracePos;
|
|
88
|
+
openChar = "{";
|
|
89
|
+
closeChar = "}";
|
|
90
|
+
}
|
|
91
|
+
else if (openBracketPos >= 0) {
|
|
92
|
+
startPos = openBracketPos;
|
|
93
|
+
openChar = "[";
|
|
94
|
+
closeChar = "]";
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
// No more opening braces/brackets
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
// Cut off the text before the opening character
|
|
101
|
+
remainingText = remainingText.substring(startPos);
|
|
102
|
+
// Find the matching closing character
|
|
103
|
+
let balance = 1;
|
|
104
|
+
let endPos = 1; // Start after the opening character
|
|
105
|
+
while (endPos < remainingText.length && balance > 0) {
|
|
106
|
+
if (remainingText[endPos] === openChar) {
|
|
107
|
+
balance++;
|
|
108
|
+
}
|
|
109
|
+
else if (remainingText[endPos] === closeChar) {
|
|
110
|
+
balance--;
|
|
111
|
+
}
|
|
112
|
+
endPos++;
|
|
113
|
+
}
|
|
114
|
+
// Check if we found a complete JSON object
|
|
115
|
+
if (balance === 0) {
|
|
116
|
+
const potentialJson = remainingText.substring(0, endPos);
|
|
117
|
+
try {
|
|
118
|
+
const parsed = JSON.parse(potentialJson);
|
|
119
|
+
results.push(parsed);
|
|
120
|
+
}
|
|
121
|
+
catch (e) {
|
|
122
|
+
// Not valid JSON, just ignore
|
|
123
|
+
}
|
|
124
|
+
// Continue with text after this JSON object
|
|
125
|
+
remainingText = remainingText.substring(endPos);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
// Unbalanced braces/brackets, skip this one
|
|
129
|
+
remainingText = remainingText.substring(1);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return results;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Safely parses JSON from a string that might include other content
|
|
136
|
+
*
|
|
137
|
+
* @param input - The string that might contain JSON
|
|
138
|
+
* @param defaultValue - Default value to return if no JSON is found
|
|
139
|
+
* @param findUuid - If true, look for an object with a uuid property
|
|
140
|
+
* @returns The parsed JSON or the default value
|
|
141
|
+
*/
|
|
142
|
+
export function parseJson(input, defaultValue, findUuid = false) {
|
|
143
|
+
try {
|
|
144
|
+
// Try to find the last complete JSON object
|
|
145
|
+
const lastJson = extractLastJson(input);
|
|
146
|
+
if (lastJson !== null) {
|
|
147
|
+
if (!findUuid || lastJson.uuid) {
|
|
148
|
+
return lastJson;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// If we need to find an object with a uuid property, try extracting all JSON objects
|
|
152
|
+
if (findUuid) {
|
|
153
|
+
const allJson = extractAllJson(input);
|
|
154
|
+
// Look for an object that has a uuid property
|
|
155
|
+
for (const json of allJson) {
|
|
156
|
+
if (json && json.uuid) {
|
|
157
|
+
return json;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return defaultValue;
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
console.error("Error in parseJson:", error);
|
|
165
|
+
return defaultValue;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { symlink, copyFile } from "node:fs/promises";
|
|
3
|
+
import { pathExists } from "fs-extra";
|
|
4
|
+
export async function setupEnvFiles({ rootDir, }) {
|
|
5
|
+
const envPath = resolve(rootDir, ".env");
|
|
6
|
+
const devVarsPath = resolve(rootDir, ".dev.vars");
|
|
7
|
+
const envExamplePath = resolve(rootDir, ".env.example");
|
|
8
|
+
const envExists = await pathExists(envPath);
|
|
9
|
+
const devVarsExists = await pathExists(devVarsPath);
|
|
10
|
+
const envExampleExists = await pathExists(envExamplePath);
|
|
11
|
+
// If .env.example exists but .env doesn't, copy from example to .env
|
|
12
|
+
if (!envExists && !devVarsExists && envExampleExists) {
|
|
13
|
+
try {
|
|
14
|
+
await copyFile(envExamplePath, envPath);
|
|
15
|
+
console.log("Created .env file from .env.example");
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
console.warn("Failed to copy .env.example to .env:", error);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
// Create symlink from .env to .dev.vars if needed
|
|
22
|
+
if ((await pathExists(envPath)) && !devVarsExists) {
|
|
23
|
+
try {
|
|
24
|
+
await symlink(envPath, devVarsPath);
|
|
25
|
+
console.log("Created symlink from .env to .dev.vars");
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
console.warn("Failed to create symlink from .env to .dev.vars:", error);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SmokeTestOptions, StreamCapturer } from "./types.mjs";
|
|
2
|
+
export declare const capturer: StreamCapturer;
|
|
3
|
+
/**
|
|
4
|
+
* Sets up the artifacts directory with a clean structure
|
|
5
|
+
*/
|
|
6
|
+
export declare function setupArtifactsDirectory(artifactDir: string, options?: SmokeTestOptions): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Helper function to take and save a screenshot with a descriptive name
|
|
9
|
+
*/
|
|
10
|
+
export declare function takeScreenshot(page: any, url: string, artifactDir: string, status: string): Promise<void>;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import * as fs from "fs/promises";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import { mkdirp, pathExists } from "fs-extra";
|
|
4
|
+
import { createWriteStream, existsSync, mkdirSync } from "fs";
|
|
5
|
+
import { log } from "./constants.mjs";
|
|
6
|
+
// Stream capturer for logging
|
|
7
|
+
export const capturer = {
|
|
8
|
+
stdoutLogFile: null,
|
|
9
|
+
stderrLogFile: null,
|
|
10
|
+
combinedLogFile: null,
|
|
11
|
+
// @ts-ignore - TS doesn't like this binding but it works as expected
|
|
12
|
+
originalStdoutWrite: process.stdout.write.bind(process.stdout),
|
|
13
|
+
// @ts-ignore - TS doesn't like this binding but it works as expected
|
|
14
|
+
originalStderrWrite: process.stderr.write.bind(process.stderr),
|
|
15
|
+
start(artifactDir) {
|
|
16
|
+
// Create logs directory in the artifacts directory
|
|
17
|
+
const logsDir = join(artifactDir, "logs");
|
|
18
|
+
try {
|
|
19
|
+
// Synchronously create directory to ensure it exists before writing
|
|
20
|
+
if (!existsSync(logsDir)) {
|
|
21
|
+
mkdirSync(logsDir, { recursive: true });
|
|
22
|
+
}
|
|
23
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
24
|
+
try {
|
|
25
|
+
this.stdoutLogFile = createWriteStream(join(logsDir, `stdout-${timestamp}.log`), { flags: "a" });
|
|
26
|
+
this.stderrLogFile = createWriteStream(join(logsDir, `stderr-${timestamp}.log`), { flags: "a" });
|
|
27
|
+
this.combinedLogFile = createWriteStream(join(logsDir, `combined-${timestamp}.log`), { flags: "a" });
|
|
28
|
+
// Verify the streams are working
|
|
29
|
+
this.stdoutLogFile.write("Log capture started\n");
|
|
30
|
+
this.stderrLogFile.write("Log capture started\n");
|
|
31
|
+
this.combinedLogFile.write("Log capture started\n");
|
|
32
|
+
// Capture stdout
|
|
33
|
+
// @ts-ignore - TS doesn't like dynamically modifying process streams
|
|
34
|
+
process.stdout.write = (chunk, encoding, callback) => {
|
|
35
|
+
if (this.stdoutLogFile && this.stdoutLogFile.writable)
|
|
36
|
+
this.stdoutLogFile.write(chunk, encoding ?? "utf-8");
|
|
37
|
+
if (this.combinedLogFile && this.combinedLogFile.writable)
|
|
38
|
+
this.combinedLogFile.write(chunk, encoding ?? "utf-8");
|
|
39
|
+
return this.originalStdoutWrite(chunk, encoding ?? "utf-8", callback);
|
|
40
|
+
};
|
|
41
|
+
// Capture stderr
|
|
42
|
+
// @ts-ignore - TS doesn't like dynamically modifying process streams
|
|
43
|
+
process.stderr.write = (chunk, encoding, callback) => {
|
|
44
|
+
if (this.stderrLogFile && this.stderrLogFile.writable)
|
|
45
|
+
this.stderrLogFile.write(chunk, encoding ?? "utf-8");
|
|
46
|
+
if (this.combinedLogFile && this.combinedLogFile.writable)
|
|
47
|
+
this.combinedLogFile.write(chunk, encoding ?? "utf-8");
|
|
48
|
+
return this.originalStderrWrite(chunk, encoding ?? "utf-8", callback);
|
|
49
|
+
};
|
|
50
|
+
console.log(`๐ Log files created in ${logsDir}`);
|
|
51
|
+
}
|
|
52
|
+
catch (streamError) {
|
|
53
|
+
console.error(`Failed to create log streams: ${streamError}`);
|
|
54
|
+
// Clean up any partially created log files
|
|
55
|
+
this.stop();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
console.error(`Failed to set up log capturing: ${error}`);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
stop() {
|
|
63
|
+
// Restore original write functions
|
|
64
|
+
// @ts-ignore - TS doesn't like dynamically modifying process streams
|
|
65
|
+
process.stdout.write = this.originalStdoutWrite;
|
|
66
|
+
// @ts-ignore - TS doesn't like dynamically modifying process streams
|
|
67
|
+
process.stderr.write = this.originalStderrWrite;
|
|
68
|
+
// Close log files
|
|
69
|
+
if (this.stdoutLogFile) {
|
|
70
|
+
try {
|
|
71
|
+
this.stdoutLogFile.end();
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
console.error(`Error closing stdout log file: ${e}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (this.stderrLogFile) {
|
|
78
|
+
try {
|
|
79
|
+
this.stderrLogFile.end();
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
console.error(`Error closing stderr log file: ${e}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (this.combinedLogFile) {
|
|
86
|
+
try {
|
|
87
|
+
this.combinedLogFile.end();
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
console.error(`Error closing combined log file: ${e}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
this.stdoutLogFile = null;
|
|
94
|
+
this.stderrLogFile = null;
|
|
95
|
+
this.combinedLogFile = null;
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Sets up the artifacts directory with a clean structure
|
|
100
|
+
*/
|
|
101
|
+
export async function setupArtifactsDirectory(artifactDir, options) {
|
|
102
|
+
log("Setting up artifacts directory: %s", artifactDir);
|
|
103
|
+
console.log(`๐ Setting up artifacts directory: ${artifactDir}`);
|
|
104
|
+
// Check if directory exists
|
|
105
|
+
const exists = await pathExists(artifactDir);
|
|
106
|
+
if (exists) {
|
|
107
|
+
log("Artifacts directory already exists, removing it");
|
|
108
|
+
console.log(`๐งน Cleaning existing artifacts directory`);
|
|
109
|
+
try {
|
|
110
|
+
await fs.rm(artifactDir, { recursive: true, force: true });
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
log("Error removing existing artifacts directory: %O", error);
|
|
114
|
+
console.error(`โ ๏ธ Could not remove existing artifacts directory: ${error instanceof Error ? error.message : String(error)}`);
|
|
115
|
+
// Non-fatal error, continue
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// Create main artifacts directory
|
|
119
|
+
await mkdirp(artifactDir);
|
|
120
|
+
log("Created artifacts directory: %s", artifactDir);
|
|
121
|
+
// Create standard subdirectories
|
|
122
|
+
const subdirs = ["screenshots", "reports", "logs"];
|
|
123
|
+
// Only create project directory if copyProject is enabled
|
|
124
|
+
if (options?.copyProject) {
|
|
125
|
+
subdirs.push("project");
|
|
126
|
+
}
|
|
127
|
+
for (const subdir of subdirs) {
|
|
128
|
+
const dirPath = join(artifactDir, subdir);
|
|
129
|
+
await mkdirp(dirPath);
|
|
130
|
+
log("Created artifacts subdirectory: %s", dirPath);
|
|
131
|
+
}
|
|
132
|
+
console.log(`โ
Artifacts directory structure created`);
|
|
133
|
+
// Ensure logs directory exists and has correct permissions before capturing logs
|
|
134
|
+
try {
|
|
135
|
+
const logsDir = join(artifactDir, "logs");
|
|
136
|
+
// Double-check permissions by writing a test file
|
|
137
|
+
const testLogPath = join(logsDir, "test-log-permissions.txt");
|
|
138
|
+
await fs.writeFile(testLogPath, "Testing log directory permissions\n");
|
|
139
|
+
await fs.unlink(testLogPath);
|
|
140
|
+
log("Log directory permissions verified");
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
log("Error verifying log directory permissions: %O", error);
|
|
144
|
+
console.error(`โ ๏ธ Warning: Log directory permissions issue: ${error instanceof Error ? error.message : String(error)}`);
|
|
145
|
+
// Not fatal, try to proceed anyway
|
|
146
|
+
}
|
|
147
|
+
// Start capturing logs
|
|
148
|
+
capturer.start(artifactDir);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Helper function to take and save a screenshot with a descriptive name
|
|
152
|
+
*/
|
|
153
|
+
export async function takeScreenshot(page, url, artifactDir, status) {
|
|
154
|
+
// Use the standardized screenshots directory
|
|
155
|
+
const screenshotsDir = join(artifactDir, "screenshots");
|
|
156
|
+
log("Saving screenshot to: %s", screenshotsDir);
|
|
157
|
+
// Create a more descriptive filename with timestamp and test result
|
|
158
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
159
|
+
const urlIdentifier = new URL(url).hostname.replace(/\./g, "-");
|
|
160
|
+
const screenshotPath = join(screenshotsDir, `smoke-test-${urlIdentifier}-${status}-${timestamp}.png`);
|
|
161
|
+
log("Taking screenshot: %s", screenshotPath);
|
|
162
|
+
await page.screenshot({ path: screenshotPath, fullPage: true });
|
|
163
|
+
console.log(`๐ธ Screenshot saved to ${screenshotPath}`);
|
|
164
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SmokeTestOptions, SmokeTestResult } from "./types.mjs";
|
|
2
|
+
import type { Page, Browser } from "puppeteer-core";
|
|
3
|
+
/**
|
|
4
|
+
* Launch a browser instance
|
|
5
|
+
*/
|
|
6
|
+
export declare function launchBrowser(browserPath?: string, headless?: boolean): Promise<Browser>;
|
|
7
|
+
/**
|
|
8
|
+
* Get the browser executable path
|
|
9
|
+
*/
|
|
10
|
+
export declare function getBrowserPath(testOptions?: SmokeTestOptions): Promise<string>;
|
|
11
|
+
/**
|
|
12
|
+
* Check a URL by performing smoke tests and realtime upgrade
|
|
13
|
+
*/
|
|
14
|
+
export declare function checkUrl(url: string, artifactDir: string, browserPath?: string, headless?: boolean, bail?: boolean, skipClient?: boolean, environment?: string, realtime?: boolean, targetDir?: string, skipHmr?: boolean): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Check smoke test status for a specific URL
|
|
17
|
+
*/
|
|
18
|
+
export declare function checkUrlSmoke(page: Page, url: string, isRealtime: boolean, bail: boolean | undefined, skipClient: boolean | undefined, environment: string | undefined, timestampState: {
|
|
19
|
+
initialServerValue: number;
|
|
20
|
+
clientUpdatedValue: number | null;
|
|
21
|
+
}, targetDir?: string, skipHmr?: boolean): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Check server-side smoke test status
|
|
24
|
+
*/
|
|
25
|
+
export declare function checkServerSmoke(page: Page, phase?: string, environment?: string, bail?: boolean, expectedTimestamp?: number, isServerRenderCheck?: boolean): Promise<SmokeTestResult>;
|
|
26
|
+
/**
|
|
27
|
+
* Check client-side smoke test if refresh button is available
|
|
28
|
+
*/
|
|
29
|
+
export declare function checkClientSmoke(page: Page, phase?: string, environment?: string, bail?: boolean): Promise<SmokeTestResult | null>;
|
|
30
|
+
/**
|
|
31
|
+
* Upgrade to realtime mode
|
|
32
|
+
*/
|
|
33
|
+
export declare function upgradeToRealtime(page: Page, environment?: string, // Add environment parameter with default
|
|
34
|
+
bail?: boolean): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* DRY: checkServerUp now checks both root and custom path if needed
|
|
37
|
+
*/
|
|
38
|
+
export declare function checkServerUp(baseUrl: string, customPath?: string, retries?: number, bail?: boolean): Promise<boolean>;
|
|
39
|
+
/**
|
|
40
|
+
* HMR test for server component
|
|
41
|
+
* Updates the server component and verifies that HMR applies the changes
|
|
42
|
+
*/
|
|
43
|
+
export declare function testServerComponentHmr(page: Page, targetDir: string, phase?: string, environment?: string, bail?: boolean): Promise<boolean>;
|
|
44
|
+
/**
|
|
45
|
+
* HMR test for client component
|
|
46
|
+
* Updates the client component and verifies that HMR applies the changes
|
|
47
|
+
*/
|
|
48
|
+
export declare function testClientComponentHmr(page: Page, targetDir: string, phase?: string, environment?: string, bail?: boolean): Promise<boolean>;
|