From a4509d507c62dd7f49fba7df7d2db3997222393a Mon Sep 17 00:00:00 2001 From: Cina Saffary Date: Tue, 10 Oct 2023 18:00:32 -0500 Subject: [PATCH 1/2] Don't set `packageManager` default via action.yml We need to distinguish between when the value is and isn't set in order to perform inference based on lockfile and only fallback to the default of npm if inference fails. --- .changeset/dirty-poets-swim.md | 5 +++++ action.yml | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 .changeset/dirty-poets-swim.md diff --git a/.changeset/dirty-poets-swim.md b/.changeset/dirty-poets-swim.md new file mode 100644 index 0000000..38a42fe --- /dev/null +++ b/.changeset/dirty-poets-swim.md @@ -0,0 +1,5 @@ +--- +"wrangler-action": patch +--- + +Fixed the package manager not being inferred based on lockfile when the `packageManager` input isn't set. diff --git a/action.yml b/action.yml index 657d76a..b5fda3e 100644 --- a/action.yml +++ b/action.yml @@ -42,6 +42,5 @@ inputs: description: "A string of environment variable names, separated by newlines. These will be bound to your Worker using the values of matching environment variables declared in `env` of this workflow." required: false packageManager: - description: "The package manager you'd like to use to install and run wrangler. If not specified, a value will be inferred based on the presence of a lockfile. Valid values: [npm, pnpm, yarn, bun]" + description: "The package manager you'd like to use to install and run wrangler. If not specified, the preferred package manager will be inferred based on the presence of a lockfile or fallback to using npm if no lockfile is found. Valid values are `npm` | `pnpm` | `yarn` | `bun`." required: false - default: npm From bd06b290b1c46b908025f9db3fc27131b794df91 Mon Sep 17 00:00:00 2001 From: Cina Saffary Date: Tue, 10 Oct 2023 18:00:40 -0500 Subject: [PATCH 2/2] Fix code formatting errors --- src/packageManagers.test.ts | 2 +- src/packageManagers.ts | 2 +- test/bun/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/packageManagers.test.ts b/src/packageManagers.test.ts index 4536c67..1653cb5 100644 --- a/src/packageManagers.test.ts +++ b/src/packageManagers.test.ts @@ -27,7 +27,7 @@ describe("getPackageManager", () => { } `); - expect(getPackageManager('bun', { workingDirectory: "test/bun" })) + expect(getPackageManager("bun", { workingDirectory: "test/bun" })) .toMatchInlineSnapshot(` { "exec": "bunx", diff --git a/src/packageManagers.ts b/src/packageManagers.ts index e87f9ee..6eaaf12 100644 --- a/src/packageManagers.ts +++ b/src/packageManagers.ts @@ -21,7 +21,7 @@ const PACKAGE_MANAGERS = { }, bun: { install: "bun i", - exec: "bunx" + exec: "bunx", }, } as const satisfies Readonly>; diff --git a/test/bun/package.json b/test/bun/package.json index 75d5eeb..44c8c5a 100644 --- a/test/bun/package.json +++ b/test/bun/package.json @@ -1,3 +1,3 @@ { - "name": "wrangler-action-bun-test", + "name": "wrangler-action-bun-test" }