@opennextjs/cloudflare 0.6.3 → 0.6.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.
@@ -1,17 +1,33 @@
1
1
  import { spawnSync } from "node:child_process";
2
+ import { readFileSync } from "node:fs";
3
+ import path from "node:path";
4
+ import { compareSemver } from "@opennextjs/aws/build/helper.js";
2
5
  import logger from "@opennextjs/aws/logger.js";
6
+ /**
7
+ * Checks the package.json `packageManager` field to determine whether yarn modern is used.
8
+ *
9
+ * @param options Build options.
10
+ * @returns Whether yarn modern is used.
11
+ */
12
+ function isYarnModern(options) {
13
+ const packageJson = JSON.parse(readFileSync(path.join(options.monorepoRoot, "package.json"), "utf-8"));
14
+ if (!packageJson.packageManager?.startsWith("yarn"))
15
+ return false;
16
+ const [, version] = packageJson.packageManager.split("@");
17
+ return version ? compareSemver(version, ">=", "4.0.0") : false;
18
+ }
3
19
  /**
4
20
  * Prepends CLI flags with `--` so that certain package managers can pass args through to wrangler
5
21
  * properly.
6
22
  *
7
- * npm and yarn require `--` to be used, while pnpm and bun require that it is not used.
23
+ * npm and yarn classic require `--` to be used, while pnpm and bun require that it is not used.
8
24
  *
9
25
  * @param options Build options.
10
26
  * @param args CLI args.
11
27
  * @returns Arguments with a passthrough flag injected when needed.
12
28
  */
13
29
  function injectPassthroughFlagForArgs(options, args) {
14
- if (options.packager !== "npm" && options.packager !== "yarn") {
30
+ if (options.packager !== "npm" && (options.packager !== "yarn" || isYarnModern(options))) {
15
31
  return args;
16
32
  }
17
33
  const flagInArgsIndex = args.findIndex((v) => v.startsWith("--"));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@opennextjs/cloudflare",
3
3
  "description": "Cloudflare builder for next apps",
4
- "version": "0.6.3",
4
+ "version": "0.6.4",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "opennextjs-cloudflare": "dist/cli/index.js"