Skip to content

Commit e70bf04

Browse files
chore(deps): upgrade dependencies (#1103)
* chore(deps): bump the misc group across 1 directory with 16 updates Bumps the misc group with 16 updates in the / directory: | Package | From | To | | --- | --- | --- | | [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) | `1.10.1` | `1.11.1` | | [@types/async-retry](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/async-retry) | `1.3.0` | `1.4.9` | | [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) | `20.12.7` | `22.9.0` | | [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) | `7.9.0` | `8.13.0` | | [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) | `7.9.0` | `8.13.0` | | [eslint](https://github.com/eslint/eslint) | `9.0.0` | `9.14.0` | | [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) | `28.5.0` | `28.9.0` | | [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier) | `5.1.3` | `5.2.1` | | [jest](https://github.com/jestjs/jest/tree/HEAD/packages/jest) | `27.5.1` | `29.7.0` | | [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) | `29.5.12` | `29.5.14` | | [jest-circus](https://github.com/jestjs/jest/tree/HEAD/packages/jest-circus) | `27.5.1` | `29.7.0` | | [nock](https://github.com/nock/nock) | `13.5.4` | `13.5.5` | | [prettier](https://github.com/prettier/prettier) | `3.2.5` | `3.3.3` | | [ts-jest](https://github.com/kulshekhar/ts-jest) | `29.1.2` | `29.2.5` | | [typescript](https://github.com/microsoft/TypeScript) | `5.4.5` | `5.6.3` | | [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint) | `7.7.0` | `8.13.0` | Updates `@actions/core` from 1.10.1 to 1.11.1 - [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md) - [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core) Updates `@types/async-retry` from 1.3.0 to 1.4.9 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/async-retry) Updates `@types/node` from 20.12.7 to 22.9.0 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Updates `@typescript-eslint/eslint-plugin` from 7.9.0 to 8.13.0 - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.13.0/packages/eslint-plugin) Updates `@typescript-eslint/parser` from 7.9.0 to 8.13.0 - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.13.0/packages/parser) Updates `eslint` from 9.0.0 to 9.14.0 - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](eslint/eslint@v9.0.0...v9.14.0) Updates `eslint-plugin-jest` from 28.5.0 to 28.9.0 - [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases) - [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md) - [Commits](jest-community/eslint-plugin-jest@v28.5.0...v28.9.0) Updates `eslint-plugin-prettier` from 5.1.3 to 5.2.1 - [Release notes](https://github.com/prettier/eslint-plugin-prettier/releases) - [Changelog](https://github.com/prettier/eslint-plugin-prettier/blob/master/CHANGELOG.md) - [Commits](prettier/eslint-plugin-prettier@v5.1.3...v5.2.1) Updates `jest` from 27.5.1 to 29.7.0 - [Release notes](https://github.com/jestjs/jest/releases) - [Changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md) - [Commits](https://github.com/jestjs/jest/commits/v29.7.0/packages/jest) Updates `@types/jest` from 29.5.12 to 29.5.14 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest) Updates `jest-circus` from 27.5.1 to 29.7.0 - [Release notes](https://github.com/jestjs/jest/releases) - [Changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md) - [Commits](https://github.com/jestjs/jest/commits/v29.7.0/packages/jest-circus) Updates `nock` from 13.5.4 to 13.5.5 - [Release notes](https://github.com/nock/nock/releases) - [Changelog](https://github.com/nock/nock/blob/main/CHANGELOG.md) - [Commits](nock/nock@v13.5.4...v13.5.5) Updates `prettier` from 3.2.5 to 3.3.3 - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md) - [Commits](prettier/prettier@3.2.5...3.3.3) Updates `ts-jest` from 29.1.2 to 29.2.5 - [Release notes](https://github.com/kulshekhar/ts-jest/releases) - [Changelog](https://github.com/kulshekhar/ts-jest/blob/main/CHANGELOG.md) - [Commits](kulshekhar/ts-jest@v29.1.2...v29.2.5) Updates `typescript` from 5.4.5 to 5.6.3 - [Release notes](https://github.com/microsoft/TypeScript/releases) - [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml) - [Commits](microsoft/TypeScript@v5.4.5...v5.6.3) Updates `typescript-eslint` from 7.7.0 to 8.13.0 - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.13.0/packages/typescript-eslint) --- updated-dependencies: - dependency-name: "@actions/core" dependency-type: direct:production update-type: version-update:semver-minor dependency-group: misc - dependency-name: "@types/async-retry" dependency-type: direct:development update-type: version-update:semver-minor dependency-group: misc - dependency-name: "@types/node" dependency-type: direct:development update-type: version-update:semver-major dependency-group: misc - dependency-name: "@typescript-eslint/eslint-plugin" dependency-type: direct:development update-type: version-update:semver-major dependency-group: misc - dependency-name: "@typescript-eslint/parser" dependency-type: direct:development update-type: version-update:semver-major dependency-group: misc - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor dependency-group: misc - dependency-name: eslint-plugin-jest dependency-type: direct:development update-type: version-update:semver-minor dependency-group: misc - dependency-name: eslint-plugin-prettier dependency-type: direct:development update-type: version-update:semver-minor dependency-group: misc - dependency-name: jest dependency-type: direct:development update-type: version-update:semver-major dependency-group: misc - dependency-name: "@types/jest" dependency-type: direct:development update-type: version-update:semver-patch dependency-group: misc - dependency-name: jest-circus dependency-type: direct:development update-type: version-update:semver-major dependency-group: misc - dependency-name: nock dependency-type: direct:development update-type: version-update:semver-patch dependency-group: misc - dependency-name: prettier dependency-type: direct:development update-type: version-update:semver-minor dependency-group: misc - dependency-name: ts-jest dependency-type: direct:development update-type: version-update:semver-minor dependency-group: misc - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-minor dependency-group: misc - dependency-name: typescript-eslint dependency-type: direct:development update-type: version-update:semver-major dependency-group: misc ... Signed-off-by: dependabot[bot] <[email protected]> * chore(deps): bump dependencies and Node version --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 9aaa027 commit e70bf04

15 files changed

+988
-1507
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
- uses: actions/setup-node@v4
2121
with:
22-
node-version-file: '.nvmrc'
22+
node-version-file: '.node-version'
2323
registry-url: 'https://registry.npmjs.org'
2424

2525
- name: Install Yarn

.github/workflows/integration.yml

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
workflow_dispatch:
55
schedule:
66
- cron: 30 15 * * 0-6
7-
87
push:
98
tags-ignore:
109
- '*.*'

.github/workflows/production.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
- uses: actions/setup-node@v4
2121
with:
22-
node-version-file: '.nvmrc'
22+
node-version-file: '.node-version'
2323
registry-url: 'https://registry.npmjs.org'
2424

2525
- name: Install Yarn

.github/workflows/version.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
# Setup .npmrc file to publish to npm
3030
- uses: actions/setup-node@v4
3131
with:
32-
node-version-file: '.nvmrc'
32+
node-version-file: '.node-version'
3333
registry-url: 'https://registry.npmjs.org'
3434
scope: '@jamesives'
3535

@@ -60,7 +60,7 @@ jobs:
6060
# Setup .npmrc file to publish to GitHub Packages
6161
- uses: actions/setup-node@v4
6262
with:
63-
node-version-file: '.nvmrc'
63+
node-version-file: '.node-version'
6464
registry-url: 'https://npm.pkg.github.com'
6565
scope: '@jamesives'
6666

.node-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v22.11.0

.nvmrc

-1
This file was deleted.

__tests__/fetch.test.ts

+26-25
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import {retrieveData, generateExport} from '../src/fetch'
2-
import nock from 'nock'
32

43
jest.setTimeout(1000000)
5-
nock.enableNetConnect()
64

75
describe('fetch', () => {
86
describe('retrieveData', () => {
9-
afterEach(nock.cleanAll)
10-
afterAll(nock.restore)
7+
afterEach(() => {
8+
jest.clearAllMocks()
9+
})
1110

1211
it('should return some data', async () => {
13-
nock('https://jamesiv.es').get('/').reply(200, {
14-
data: '12345'
12+
global.fetch = jest.fn().mockResolvedValue({
13+
ok: true,
14+
json: jest.fn().mockResolvedValue({data: '12345'}),
15+
text: jest.fn().mockResolvedValue('{"data":"12345"}')
1516
})
1617

1718
const data = await retrieveData({
@@ -22,11 +23,11 @@ describe('fetch', () => {
2223
})
2324

2425
it('should handle the triple bracket replacements', async () => {
25-
nock('https://jives.dev/')
26-
.post('/', '{"bestCat":"montezuma"}')
27-
.reply(200, {
28-
data: '12345'
29-
})
26+
global.fetch = jest.fn().mockResolvedValue({
27+
ok: true,
28+
json: jest.fn().mockResolvedValue({data: '12345'}),
29+
text: jest.fn().mockResolvedValue('{"data":"12345"}')
30+
})
3031

3132
const data = await retrieveData({
3233
debug: true,
@@ -45,8 +46,6 @@ describe('fetch', () => {
4546

4647
it('should error if improperly formatted json is passed in', async () => {
4748
try {
48-
nock('https://jamesiv.es').get('/').reply(200)
49-
5049
await retrieveData({
5150
debug: true,
5251
endpoint: 'https://example.com',
@@ -61,8 +60,10 @@ describe('fetch', () => {
6160
})
6261

6362
it('should error if the response is not ok', async () => {
64-
nock('https://jamesiv.es').post('/').reply(404, {
65-
a: 1
63+
global.fetch = jest.fn().mockResolvedValue({
64+
ok: false,
65+
json: jest.fn().mockResolvedValue({a: 1}),
66+
text: jest.fn().mockResolvedValue('{"a":1}')
6667
})
6768

6869
try {
@@ -83,18 +84,18 @@ describe('fetch', () => {
8384
}
8485
})
8586

86-
it('should error if the response is not ok after several retrys', async () => {
87+
it('should error if the response is not ok after several retries', async () => {
8788
jest.setTimeout(1000000)
88-
89-
try {
90-
nock('https://jives.dev').get('/').once().replyWithError({
91-
message: 'This is catastrophic'
92-
})
93-
94-
nock('https://jives.dev').get('/').reply(200, {
95-
data: '12345'
89+
global.fetch = jest
90+
.fn()
91+
.mockRejectedValueOnce(new Error('This is catastrophic'))
92+
.mockResolvedValueOnce({
93+
ok: true,
94+
json: jest.fn().mockResolvedValue({data: '12345'}),
95+
text: jest.fn().mockResolvedValue('{"data":"12345"}')
9696
})
9797

98+
try {
9899
await retrieveData({
99100
debug: true,
100101
endpoint: 'https://jives.dev',
@@ -117,7 +118,7 @@ describe('fetch', () => {
117118
expect(process.env['fetchApiData']).toBe('{"bestCat":"montezuma"}')
118119
})
119120

120-
it('should save non standard file types', async () => {
121+
it('should save non-standard file types', async () => {
121122
await generateExport({
122123
data: 'hello',
123124
format: 'txt',

__tests__/lib.test.ts

+21-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {exportVariable, setFailed} from '@actions/core'
2-
import nock from 'nock'
32
import {action} from '../src/constants'
43
import run from '../src/lib'
54
import '../src/main'
@@ -15,38 +14,49 @@ jest.mock('@actions/core', () => ({
1514

1615
describe('lib', () => {
1716
beforeEach(() => {
18-
nock('https://jamesiv.es').get('/').reply(200, {
19-
data: '12345'
17+
jest.clearAllMocks()
18+
19+
global.fetch = jest.fn().mockResolvedValue({
20+
json: jest.fn().mockResolvedValue({data: '12345'}),
21+
text: jest.fn().mockResolvedValue('{"data":"12345"}'),
22+
ok: true
2023
})
2124
})
2225

2326
afterEach(() => {
24-
nock.restore()
2527
Object.assign(action, JSON.parse(originalAction))
2628
})
2729

28-
afterEach(nock.cleanAll)
29-
3030
it('should run through the commands', async () => {
3131
Object.assign(action, {
3232
debug: true,
33-
endpoint: 'https://jamesiv.es',
33+
endpoint: 'https://jives.dev',
3434
setOutput: true
3535
})
36+
3637
await run(action)
3738

38-
expect(exportVariable).toHaveBeenCalled()
39+
expect(exportVariable).toHaveBeenCalledTimes(1)
40+
expect(global.fetch).toHaveBeenCalledWith(
41+
'https://jives.dev',
42+
expect.any(Object)
43+
)
3944
})
4045

4146
it('should run through the commands but not save output', async () => {
4247
Object.assign(action, {
4348
debug: true,
44-
endpoint: 'https://jamesiv.es',
49+
endpoint: 'https://jives.dev',
4550
setOutput: false
4651
})
52+
4753
await run(action)
4854

4955
expect(exportVariable).toHaveBeenCalledTimes(0)
56+
expect(global.fetch).toHaveBeenCalledWith(
57+
'https://jives.dev',
58+
expect.any(Object)
59+
)
5060
})
5161

5262
it('should throw an error if no endpoint is provided', async () => {
@@ -58,6 +68,7 @@ describe('lib', () => {
5868
try {
5969
await run(action)
6070
} catch (error) {
71+
console.error(error)
6172
expect(setFailed).toHaveBeenCalled()
6273
}
6374
})
@@ -73,6 +84,7 @@ describe('lib', () => {
7384
try {
7485
await run(action)
7586
} catch (error) {
87+
console.error(error)
7688
expect(setFailed).toHaveBeenCalled()
7789
}
7890
})

eslint.config.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default tseslint.config(
1717
},
1818
rules: {
1919
'jest/no-conditional-expect': 'off',
20-
'@typescript-eslint/ban-types': [
20+
'@typescript-eslint/no-restricted-types': [
2121
'error',
2222
{
2323
types: {

package.json

+15-17
Original file line numberDiff line numberDiff line change
@@ -35,30 +35,28 @@
3535
"github-action"
3636
],
3737
"dependencies": {
38-
"@actions/core": "1.10.1",
38+
"@actions/core": "1.11.1",
3939
"@actions/io": "1.1.3",
4040
"async-retry": "1.3.3",
41-
"cross-fetch": "4.0.0",
4241
"mustache": "4.2.0"
4342
},
4443
"devDependencies": {
45-
"@types/async-retry": "1.3.0",
46-
"@types/jest": "29.5.12",
44+
"@types/async-retry": "1.4.9",
45+
"@types/jest": "29.5.14",
4746
"@types/mustache": "4.2.5",
48-
"@types/node": "20.12.7",
47+
"@types/node": "22.9.0",
4948
"@types/retry": "0.12.5",
50-
"@typescript-eslint/eslint-plugin": "7.9.0",
51-
"@typescript-eslint/parser": "7.9.0",
52-
"eslint": "9.0.0",
49+
"@typescript-eslint/eslint-plugin": "8.13.0",
50+
"@typescript-eslint/parser": "8.13.0",
51+
"eslint": "9.14.0",
5352
"eslint-config-prettier": "9.1.0",
54-
"eslint-plugin-jest": "28.5.0",
55-
"eslint-plugin-prettier": "5.1.3",
56-
"jest": "27.5.1",
57-
"jest-circus": "27.5.1",
58-
"nock": "13.5.4",
59-
"prettier": "3.2.5",
60-
"ts-jest": "29.1.2",
61-
"typescript": "5.4.5",
62-
"typescript-eslint": "7.7.0"
53+
"eslint-plugin-jest": "28.9.0",
54+
"eslint-plugin-prettier": "5.2.1",
55+
"jest": "29.7.0",
56+
"jest-circus": "29.7.0",
57+
"prettier": "3.3.3",
58+
"ts-jest": "29.2.5",
59+
"typescript": "5.6.3",
60+
"typescript-eslint": "8.13.0"
6361
}
6462
}

src/constants.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import {getInput} from '@actions/core'
22
import {isNullOrUndefined} from './util'
33

4+
/**
5+
* Required action data that gets initialized when running within the GitHub Actions environment.
6+
*/
47
export interface ActionInterface {
58
/** Allows you to log the retrieved data to the terminal. */
69
debug?: boolean
@@ -28,6 +31,9 @@ export interface ActionInterface {
2831
variableName?: string
2932
}
3033

34+
/**
35+
* Required data to fetch the data.
36+
*/
3137
export interface DataInterface {
3238
/** Allows you to log the retrieved data to the terminal. */
3339
debug?: boolean
@@ -43,6 +49,9 @@ export interface DataInterface {
4349
retry?: boolean | null
4450
}
4551

52+
/**
53+
* Required data to export the data.
54+
*/
4655
export interface ExportInterface {
4756
/** The data to save. */
4857
data: string
@@ -60,7 +69,9 @@ export interface ExportInterface {
6069
variableName?: string
6170
}
6271

63-
// Required action data that gets initialized when running within the GitHub Actions environment.
72+
/**
73+
* Required action data that gets initialized when running within the GitHub Actions environment.
74+
*/
6475
export const action = {
6576
debug: !isNullOrUndefined(getInput('debug'))
6677
? getInput('debug').toLowerCase() === 'true'

src/fetch.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ import {
55
debug
66
} from '@actions/core'
77
import {mkdirP} from '@actions/io'
8-
import 'cross-fetch/polyfill'
98
import {promises as fs} from 'fs'
109
import {render} from 'mustache'
1110
import retryRequest from 'async-retry'
1211
import {DataInterface, ExportInterface, Status} from './constants'
1312
import {parseData} from './util'
1413

15-
/* Fetches or Posts data to an API. If auth is provided it will replace the mustache variables with the data from it. */
14+
/**
15+
* Retrieves data from an API endpoint.
16+
*/
1617
export async function retrieveData({
1718
debug: requestDebug,
1819
endpoint,
@@ -67,7 +68,9 @@ export async function retrieveData({
6768
}
6869
}
6970

70-
/* Saves the data to the local file system and exports an environment variable containing the retrieved data. */
71+
/**
72+
* Generates an export file from the data provided.
73+
*/
7174
export async function generateExport({
7275
data,
7376
encoding,

src/lib.ts

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export default async function run(
3131
hasRequiredParameters(settings)
3232

3333
let auth = ''
34+
3435
if (settings.tokenEndpoint) {
3536
auth = await retrieveData({
3637
debug: settings.debug,

src/util.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import {ActionInterface} from './constants'
22

3-
/* Utility function that checks to see if a value is undefined or not. */
3+
/**
4+
* Checks to see if a value is null or undefined.
5+
*/
46
export const isNullOrUndefined = (value: string | undefined | null): boolean =>
57
typeof value === 'undefined' || value === null || value === ''
68

7-
/* Checks for the required inputs. Throws an error if any case is matched. */
9+
/**
10+
* Checks to see if the action has the required parameters to run.
11+
*/
812
export const hasRequiredParameters = (action: ActionInterface): void => {
913
if (isNullOrUndefined(action.endpoint)) {
1014
throw new Error(
@@ -13,14 +17,19 @@ export const hasRequiredParameters = (action: ActionInterface): void => {
1317
}
1418
}
1519

20+
/**
21+
* Extracts the error message from an error object or string.
22+
*/
1623
export const extractErrorMessage = (error: unknown): string =>
1724
error instanceof Error
1825
? error.message
1926
: typeof error == 'string'
2027
? error
2128
: JSON.stringify(error)
2229

23-
/* Attempt to parse data as JSON and catch any errors. */
30+
/**
31+
* Parses a string into a JSON object.
32+
*/
2433
export const parseData = (data: string): Record<string, unknown> | null => {
2534
try {
2635
return JSON.parse(data)

0 commit comments

Comments
 (0)