Skip to content

Commit 5cc518b

Browse files
committed
feat: use an exact version of wrangler as the default
1 parent 6b74fa8 commit 5cc518b

16 files changed

Lines changed: 34 additions & 25 deletions

File tree

.changeset/cold-cats-carry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'github-actions-cloudflare-pages': minor
3+
---
4+
5+
Use an exact version of wrangler as the default version. This avoids using a version published that may have a potential security issue.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ working-directory:
6565
description: 'Directory to run wrangler cli from'
6666
required: false
6767
wrangler-version:
68-
description: 'Wrangler version to use. Otherwise a default version of ^4.6.0 will be used.'
68+
description: 'Wrangler version to use. Otherwise a default version from the action will be used.'
6969
required: false
7070
```
7171

__tests__/common/batch-delete.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
setMockApi
2121
} from '../helpers/api.js'
2222

23-
vi.mock('@actions/core')
23+
vi.mock(import('@actions/core'))
2424

2525
describe('batch-delete', () => {
2626
let mockApi: MockApi

__tests__/common/cloudflare/api/fetch-error.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {throwFetchError} from '@/common/cloudflare/api/fetch-error.js'
77

88
const RESOURCE_URL = `https://api.cloudflare.com/path`
99

10-
vi.mock('@actions/core')
10+
vi.mock(import('@actions/core'))
1111

1212
describe(throwFetchError, () => {
1313
test('throws parsed error with notes', () => {

__tests__/common/cloudflare/api/fetch-result.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const RESOURCE_URL_DOMAIN = `https://api.cloudflare.com`
1414
const RESOURCE_URL_PATH = `/client/v4/accounts`
1515
const RESOURCE_URL = `${RESOURCE_URL_DOMAIN}${RESOURCE_URL_PATH}`
1616

17-
vi.mock('@actions/core')
17+
vi.mock(import('@actions/core'))
1818

1919
describe('api', () => {
2020
describe(fetchResult, () => {

__tests__/common/cloudflare/deployment/create.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ import {
1717
import {execAsync} from '@/common/utils.js'
1818
import {INPUT_KEY_WORKING_DIRECTORY} from '@/input-keys'
1919

20-
vi.mock('@/common/utils.js')
21-
vi.mock('@actions/core')
20+
import packageJson from '../../../../package.json' with {type: 'json'}
21+
22+
vi.mock(import('@/common/utils.js'))
23+
vi.mock(import('@actions/core'))
2224

2325
describe(createCloudflareDeployment, () => {
2426
describe('api calls', () => {
@@ -57,7 +59,7 @@ describe(createCloudflareDeployment, () => {
5759
).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: Oh no!]`)
5860

5961
expect(execAsync).toHaveBeenCalledWith(
60-
`npx wrangler@^4.34.0 pages deploy mock-directory --project-name=mock-cloudflare-project-name --branch=mock-github-head-ref --commit-dirty=true --commit-hash=mock-github-sha`,
62+
`npx wrangler@${packageJson.devDependencies.wrangler} pages deploy mock-directory --project-name=mock-cloudflare-project-name --branch=mock-github-head-ref --commit-dirty=true --commit-hash=mock-github-sha`,
6163
{
6264
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
6365
env: expect.objectContaining({
@@ -143,7 +145,7 @@ describe(createCloudflareDeployment, () => {
143145
// vi.advanceTimersByTime(2000)
144146

145147
expect(execAsync).toHaveBeenCalledWith(
146-
`npx wrangler@^4.34.0 pages deploy mock-directory --project-name=mock-cloudflare-project-name --branch=mock-github-head-ref --commit-dirty=true --commit-hash=mock-github-sha`,
148+
`npx wrangler@${packageJson.devDependencies.wrangler} pages deploy mock-directory --project-name=mock-cloudflare-project-name --branch=mock-github-head-ref --commit-dirty=true --commit-hash=mock-github-sha`,
147149
{
148150
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
149151
env: expect.objectContaining({

__tests__/common/github/comment.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type {WorkflowEventExtract} from '@/common/github/workflow-event/types.js
1212
import {addComment, MutationAddComment} from '@/common/github/comment.js'
1313
import * as Context from '@/common/github/context.js'
1414

15-
vi.mock('@actions/core')
15+
vi.mock(import('@actions/core'))
1616

1717
describe(addComment, () => {
1818
const mockData = RESPONSE_DEPLOYMENTS.result[0] as unknown as PagesDeployment

__tests__/common/github/environment.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
QueryGetEnvironment
1717
} from '@/common/github/environment.js'
1818

19-
vi.mock('@actions/core')
19+
vi.mock(import('@actions/core'))
2020

2121
describe('environment', () => {
2222
let mockApi: MockApi

__tests__/common/inputs.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
INPUT_KEY_WRANGLER_VERSION
1010
} from '@/input-keys'
1111

12+
import packageJson from '../../package.json' with {type: 'json'}
13+
1214
const setup = async () => {
1315
return await import('@/common/inputs.js')
1416
}
@@ -70,7 +72,7 @@ describe('common', () => {
7072
cloudflareApiToken: 'mock-cloudflare-api-token',
7173
gitHubApiToken: 'mock-github-token',
7274
gitHubEnvironment: undefined,
73-
wranglerVersion: '^4.34.0'
75+
wranglerVersion: packageJson.devDependencies.wrangler
7476
})
7577
})
7678

@@ -84,7 +86,7 @@ describe('common', () => {
8486

8587
expect(useCommonInputs()).toStrictEqual(
8688
expect.objectContaining({
87-
wranglerVersion: '^4.34.0'
89+
wranglerVersion: packageJson.devDependencies.wrangler
8890
})
8991
)
9092
})

__tests__/deploy/main.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import {execAsync} from '@/common/utils.js'
1616
// import RESPONSE_PROJECT from '@/responses/api.cloudflare.com/pages/projects/project.response.json'
1717
import {run} from '@/deploy/main.js'
1818

19-
vi.mock('@actions/core')
20-
vi.mock('@/common/utils.js')
21-
vi.mock('@/common/github/environment.js')
22-
vi.mock('@/common/github/deployment/create.js')
23-
vi.mock('@/common/github/comment.js')
19+
vi.mock(import('@actions/core'))
20+
vi.mock(import('@/common/utils.js'))
21+
vi.mock(import('@/common/github/environment.js'))
22+
vi.mock(import('@/common/github/deployment/create.js'))
23+
vi.mock(import('@/common/github/comment.js'))
2424

2525
describe('deploy', () => {
2626
describe('main', () => {

0 commit comments

Comments
 (0)