@solcreek/adapter-creek 0.1.3 → 0.1.4

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/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as path from "node:path";
2
2
  import { fileURLToPath } from "node:url";
3
- import { existsSync } from "node:fs";
3
+ import { copyFileSync, existsSync } from "node:fs";
4
4
  import { applyBaseModifyConfig } from "@solcreek/adapter-core";
5
5
  import { handleBuild } from "./build.js";
6
6
  // Dev-fallback path to the cache handler shipped by @solcreek/adapter-core.
@@ -12,6 +12,21 @@ const coreEntryUrl = new URL("../node_modules/@solcreek/adapter-core/dist/cache-
12
12
  const fallbackCacheHandlerPath = existsSync(fileURLToPath(coreEntryUrl))
13
13
  ? fileURLToPath(coreEntryUrl)
14
14
  : path.join(process.cwd(), "node_modules", "@solcreek", "adapter-core", "dist", "cache-handler.js");
15
+ function mirrorCacheHandlerIntoProject(cacheHandlerPath) {
16
+ if (!existsSync(cacheHandlerPath))
17
+ return cacheHandlerPath;
18
+ const localPath = path.join(process.cwd(), ".solcreek-cache-handler.mjs");
19
+ if (path.resolve(cacheHandlerPath) === path.resolve(localPath))
20
+ return localPath;
21
+ try {
22
+ copyFileSync(cacheHandlerPath, localPath);
23
+ return localPath;
24
+ }
25
+ catch (err) {
26
+ console.warn(` [Creek Adapter] Failed to mirror cache-handler into project (${err instanceof Error ? err.message : String(err)}); falling back to ${cacheHandlerPath}`);
27
+ return cacheHandlerPath;
28
+ }
29
+ }
15
30
  const adapter = {
16
31
  name: "adapter-creek",
17
32
  modifyConfig(config, ctx) {
@@ -26,8 +41,16 @@ const adapter = {
26
41
  // for other phases, so guarding here matches its behaviour.
27
42
  if (ctx.phase !== "phase-production-build")
28
43
  return baseConfig;
44
+ const cacheHandlerPath = typeof baseConfig.cacheHandler === "string"
45
+ ? mirrorCacheHandlerIntoProject(baseConfig.cacheHandler)
46
+ : mirrorCacheHandlerIntoProject(fallbackCacheHandlerPath);
29
47
  return {
30
48
  ...baseConfig,
49
+ // Next may dynamically import this cache handler on error/404 render
50
+ // paths. Keep it as a project-local sentinel path instead of a pnpm
51
+ // node_modules realpath; the Workers bundler redirects that sentinel
52
+ // to the inline CreekCacheHandler.
53
+ cacheHandler: cacheHandlerPath,
31
54
  // Disable memory cache — CF Workers doesn't have persistent fs.
32
55
  // The runtime cache handler is inlined in the worker entry (CreekCacheHandler).
33
56
  cacheMaxMemorySize: 0,
@@ -4,15 +4,8 @@
4
4
  * Written to .creek/adapter-output/manifest.json after build.
5
5
  * Creek CLI reads this to know how to upload and deploy.
6
6
  */
7
- export interface DeployManifest {
8
- /** Manifest schema version */
9
- version: 1;
10
- /** Next.js build ID */
11
- buildId: string;
12
- /** Next.js version used */
13
- nextVersion: string;
14
- /** Framework identifier */
15
- framework: "nextjs";
7
+ import type { DeployManifestBase } from "@solcreek/adapter-core";
8
+ export interface DeployManifest extends DeployManifestBase {
16
9
  /** Main worker entry file name (relative to server/) */
17
10
  entrypoint: string;
18
11
  /** All files in server/ directory */
package/dist/manifest.js CHANGED
@@ -6,12 +6,19 @@
6
6
  */
7
7
  import * as fs from "node:fs/promises";
8
8
  import * as path from "node:path";
9
+ import { createRequire } from "node:module";
10
+ const require = createRequire(import.meta.url);
11
+ const adapterPackage = require("../package.json");
9
12
  export async function writeManifest(outputDir, opts) {
10
13
  const manifest = {
11
14
  version: 1,
12
15
  buildId: opts.buildId,
13
16
  nextVersion: opts.nextVersion,
14
17
  framework: "nextjs",
18
+ adapter: {
19
+ name: adapterPackage.name ?? "@solcreek/adapter-creek",
20
+ version: adapterPackage.version ?? "0.0.0",
21
+ },
15
22
  entrypoint: opts.entrypoint,
16
23
  serverFiles: opts.serverFiles,
17
24
  assetDir: "assets",