@solcreek/cli 0.4.24 → 0.4.26

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.
@@ -39,15 +39,40 @@ function semverGte(version, target) {
39
39
  return aMin > bMin;
40
40
  return aPat >= bPat;
41
41
  }
42
+ /**
43
+ * Read the installed adapter version from the package.json above a resolved
44
+ * adapter entry path (.../adapter-creek/dist/index.js).
45
+ */
46
+ function adapterVersionAt(entryPath) {
47
+ let dir = dirname(entryPath);
48
+ for (let i = 0; i < 3; i++) {
49
+ const pkgPath = join(dir, "package.json");
50
+ if (existsSync(pkgPath)) {
51
+ try {
52
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
53
+ if (pkg.name === ADAPTER_PKG)
54
+ return pkg.version ?? null;
55
+ }
56
+ catch {
57
+ return null;
58
+ }
59
+ }
60
+ dir = dirname(dir);
61
+ }
62
+ return null;
63
+ }
42
64
  /**
43
65
  * Resolve @solcreek/adapter-creek from any reachable location.
44
66
  *
45
67
  * Tries, in order: the CLI's own install (monorepo workspace / global
46
68
  * install alongside the adapter), the project's own node_modules, then the
47
- * lazy-installed copy under .creek/node_modules. Returns the adapter entry
48
- * path (for NEXT_ADAPTER_PATH), or null if not installed anywhere.
69
+ * lazy-installed copy under .creek/node_modules. Copies older than
70
+ * `minVersion` are skipped adapter < 0.2.1 cannot resolve its cache
71
+ * handler from the .creek lazy install, so a stale cached copy must not
72
+ * shadow a fixed one. Returns the adapter entry path (for
73
+ * NEXT_ADAPTER_PATH), or null if no acceptable copy is installed.
49
74
  */
50
- function resolveAdapterPath(cwd) {
75
+ function resolveAdapterPath(cwd, minVersion) {
51
76
  const bases = [import.meta.url];
52
77
  if (cwd) {
53
78
  // createRequire walks node_modules up from the base file's directory;
@@ -57,7 +82,13 @@ function resolveAdapterPath(cwd) {
57
82
  }
58
83
  for (const base of bases) {
59
84
  try {
60
- return createRequire(base).resolve("@solcreek/adapter-creek");
85
+ const entry = createRequire(base).resolve(ADAPTER_PKG);
86
+ if (minVersion) {
87
+ const version = adapterVersionAt(entry);
88
+ if (!version || !semverGte(version, minVersion))
89
+ continue;
90
+ }
91
+ return entry;
61
92
  }
62
93
  catch {
63
94
  // try next base
@@ -148,7 +179,13 @@ const CREEK_DIR = ".creek";
148
179
  const OPENNEXT_PKG = "@opennextjs/cloudflare";
149
180
  const OPENNEXT_VERSION = "^1.18.0";
150
181
  const ADAPTER_PKG = "@solcreek/adapter-creek";
151
- const ADAPTER_VERSION = "^0.2.0";
182
+ const ADAPTER_VERSION = "^0.2.2";
183
+ // Adapter < 0.2.2 resolves its dependencies against paths that don't exist
184
+ // under the .creek lazy install (0.2.0: the cache handler; 0.2.1: the
185
+ // wrangler bin) — npm hoists them to the top of the tree, so the adapter's
186
+ // guessed nested paths fail every Next.js build. Installs below this are
187
+ // re-installed, not reused.
188
+ const ADAPTER_MIN_VERSION = "0.2.2";
152
189
  /**
153
190
  * Merge a dependency into .creek/package.json without clobbering deps that
154
191
  * a previous install (adapter or opennext) may have already written.
@@ -178,7 +215,11 @@ function installCreekDep(creekDir, pkg, version) {
178
215
  mkdirSync(creekDir, { recursive: true });
179
216
  upsertCreekDep(creekDir, pkg, version);
180
217
  try {
181
- execSync("npm install --no-audit --no-fund --ignore-scripts --no-optional", {
218
+ // No --no-optional: the adapter bundles the worker with wrangler, whose
219
+ // workerd dependency ships its platform binary (@cloudflare/workerd-*)
220
+ // as an optionalDependency. Omitting optionals fails the build with
221
+ // "package could not be found, and is needed by workerd".
222
+ execSync("npm install --no-audit --no-fund --ignore-scripts", {
182
223
  cwd: creekDir,
183
224
  stdio: "pipe",
184
225
  });
@@ -199,15 +240,20 @@ function installCreekDep(creekDir, pkg, version) {
199
240
  * CLI dependency that every `npx creek` user would pay for.
200
241
  */
201
242
  function ensureAdapter(cwd) {
202
- const existing = resolveAdapterPath(cwd);
243
+ const existing = resolveAdapterPath(cwd, ADAPTER_MIN_VERSION);
203
244
  if (existing)
204
245
  return existing;
205
- consola.start(` Installing ${ADAPTER_PKG} (one-time setup)...`);
246
+ // Distinguish "not installed" from "only stale copies" for the message;
247
+ // either way the fix is the same install into .creek.
248
+ const stale = resolveAdapterPath(cwd) !== null;
249
+ consola.start(stale
250
+ ? ` Updating ${ADAPTER_PKG} to >= ${ADAPTER_MIN_VERSION} (older versions cannot build)...`
251
+ : ` Installing ${ADAPTER_PKG} (one-time setup)...`);
206
252
  if (!installCreekDep(join(cwd, CREEK_DIR), ADAPTER_PKG, ADAPTER_VERSION)) {
207
253
  consola.warn(` Could not install ${ADAPTER_PKG}`);
208
254
  return null;
209
255
  }
210
- const resolved = resolveAdapterPath(cwd);
256
+ const resolved = resolveAdapterPath(cwd, ADAPTER_MIN_VERSION);
211
257
  if (resolved)
212
258
  consola.success(` ${ADAPTER_PKG} installed`);
213
259
  return resolved;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solcreek/cli",
3
- "version": "0.4.24",
3
+ "version": "0.4.26",
4
4
  "description": "CLI for the Creek deployment platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",