@solcreek/cli 0.4.24 → 0.4.25

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,11 @@ 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.1";
183
+ // Adapter < 0.2.1 resolves its cache handler against paths that don't exist
184
+ // under the .creek lazy install, failing every Next.js build with webpack
185
+ // "Module not found". Installs below this are re-installed, not reused.
186
+ const ADAPTER_MIN_VERSION = "0.2.1";
152
187
  /**
153
188
  * Merge a dependency into .creek/package.json without clobbering deps that
154
189
  * a previous install (adapter or opennext) may have already written.
@@ -199,15 +234,20 @@ function installCreekDep(creekDir, pkg, version) {
199
234
  * CLI dependency that every `npx creek` user would pay for.
200
235
  */
201
236
  function ensureAdapter(cwd) {
202
- const existing = resolveAdapterPath(cwd);
237
+ const existing = resolveAdapterPath(cwd, ADAPTER_MIN_VERSION);
203
238
  if (existing)
204
239
  return existing;
205
- consola.start(` Installing ${ADAPTER_PKG} (one-time setup)...`);
240
+ // Distinguish "not installed" from "only stale copies" for the message;
241
+ // either way the fix is the same install into .creek.
242
+ const stale = resolveAdapterPath(cwd) !== null;
243
+ consola.start(stale
244
+ ? ` Updating ${ADAPTER_PKG} to >= ${ADAPTER_MIN_VERSION} (older versions cannot build)...`
245
+ : ` Installing ${ADAPTER_PKG} (one-time setup)...`);
206
246
  if (!installCreekDep(join(cwd, CREEK_DIR), ADAPTER_PKG, ADAPTER_VERSION)) {
207
247
  consola.warn(` Could not install ${ADAPTER_PKG}`);
208
248
  return null;
209
249
  }
210
- const resolved = resolveAdapterPath(cwd);
250
+ const resolved = resolveAdapterPath(cwd, ADAPTER_MIN_VERSION);
211
251
  if (resolved)
212
252
  consola.success(` ${ADAPTER_PKG} installed`);
213
253
  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.25",
4
4
  "description": "CLI for the Creek deployment platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",