Skip to content

Commit

Permalink
chore(deps): upgrade dependencies (#1103)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
JamesIves and dependabot[bot] authored Nov 9, 2024
1 parent 9aaa027 commit e70bf04
Show file tree
Hide file tree
Showing 15 changed files with 988 additions and 1,507 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
node-version-file: '.node-version'
registry-url: 'https://registry.npmjs.org'

- name: Install Yarn
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
workflow_dispatch:
schedule:
- cron: 30 15 * * 0-6

push:
tags-ignore:
- '*.*'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
node-version-file: '.node-version'
registry-url: 'https://registry.npmjs.org'

- name: Install Yarn
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
node-version-file: '.node-version'
registry-url: 'https://registry.npmjs.org'
scope: '@jamesives'

Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
# Setup .npmrc file to publish to GitHub Packages
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
node-version-file: '.node-version'
registry-url: 'https://npm.pkg.github.com'
scope: '@jamesives'

Expand Down
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v22.11.0
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

51 changes: 26 additions & 25 deletions __tests__/fetch.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import {retrieveData, generateExport} from '../src/fetch'
import nock from 'nock'

jest.setTimeout(1000000)
nock.enableNetConnect()

describe('fetch', () => {
describe('retrieveData', () => {
afterEach(nock.cleanAll)
afterAll(nock.restore)
afterEach(() => {
jest.clearAllMocks()
})

it('should return some data', async () => {
nock('https://jamesiv.es').get('/').reply(200, {
data: '12345'
global.fetch = jest.fn().mockResolvedValue({
ok: true,
json: jest.fn().mockResolvedValue({data: '12345'}),
text: jest.fn().mockResolvedValue('{"data":"12345"}')
})

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

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

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

it('should error if improperly formatted json is passed in', async () => {
try {
nock('https://jamesiv.es').get('/').reply(200)

await retrieveData({
debug: true,
endpoint: 'https://example.com',
Expand All @@ -61,8 +60,10 @@ describe('fetch', () => {
})

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

try {
Expand All @@ -83,18 +84,18 @@ describe('fetch', () => {
}
})

it('should error if the response is not ok after several retrys', async () => {
it('should error if the response is not ok after several retries', async () => {
jest.setTimeout(1000000)

try {
nock('https://jives.dev').get('/').once().replyWithError({
message: 'This is catastrophic'
})

nock('https://jives.dev').get('/').reply(200, {
data: '12345'
global.fetch = jest
.fn()
.mockRejectedValueOnce(new Error('This is catastrophic'))
.mockResolvedValueOnce({
ok: true,
json: jest.fn().mockResolvedValue({data: '12345'}),
text: jest.fn().mockResolvedValue('{"data":"12345"}')
})

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

it('should save non standard file types', async () => {
it('should save non-standard file types', async () => {
await generateExport({
data: 'hello',
format: 'txt',
Expand Down
30 changes: 21 additions & 9 deletions __tests__/lib.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {exportVariable, setFailed} from '@actions/core'
import nock from 'nock'
import {action} from '../src/constants'
import run from '../src/lib'
import '../src/main'
Expand All @@ -15,38 +14,49 @@ jest.mock('@actions/core', () => ({

describe('lib', () => {
beforeEach(() => {
nock('https://jamesiv.es').get('/').reply(200, {
data: '12345'
jest.clearAllMocks()

global.fetch = jest.fn().mockResolvedValue({
json: jest.fn().mockResolvedValue({data: '12345'}),
text: jest.fn().mockResolvedValue('{"data":"12345"}'),
ok: true
})
})

afterEach(() => {
nock.restore()
Object.assign(action, JSON.parse(originalAction))
})

afterEach(nock.cleanAll)

it('should run through the commands', async () => {
Object.assign(action, {
debug: true,
endpoint: 'https://jamesiv.es',
endpoint: 'https://jives.dev',
setOutput: true
})

await run(action)

expect(exportVariable).toHaveBeenCalled()
expect(exportVariable).toHaveBeenCalledTimes(1)
expect(global.fetch).toHaveBeenCalledWith(
'https://jives.dev',
expect.any(Object)
)
})

it('should run through the commands but not save output', async () => {
Object.assign(action, {
debug: true,
endpoint: 'https://jamesiv.es',
endpoint: 'https://jives.dev',
setOutput: false
})

await run(action)

expect(exportVariable).toHaveBeenCalledTimes(0)
expect(global.fetch).toHaveBeenCalledWith(
'https://jives.dev',
expect.any(Object)
)
})

it('should throw an error if no endpoint is provided', async () => {
Expand All @@ -58,6 +68,7 @@ describe('lib', () => {
try {
await run(action)
} catch (error) {
console.error(error)
expect(setFailed).toHaveBeenCalled()
}
})
Expand All @@ -73,6 +84,7 @@ describe('lib', () => {
try {
await run(action)
} catch (error) {
console.error(error)
expect(setFailed).toHaveBeenCalled()
}
})
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default tseslint.config(
},
rules: {
'jest/no-conditional-expect': 'off',
'@typescript-eslint/ban-types': [
'@typescript-eslint/no-restricted-types': [
'error',
{
types: {
Expand Down
32 changes: 15 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,28 @@
"github-action"
],
"dependencies": {
"@actions/core": "1.10.1",
"@actions/core": "1.11.1",
"@actions/io": "1.1.3",
"async-retry": "1.3.3",
"cross-fetch": "4.0.0",
"mustache": "4.2.0"
},
"devDependencies": {
"@types/async-retry": "1.3.0",
"@types/jest": "29.5.12",
"@types/async-retry": "1.4.9",
"@types/jest": "29.5.14",
"@types/mustache": "4.2.5",
"@types/node": "20.12.7",
"@types/node": "22.9.0",
"@types/retry": "0.12.5",
"@typescript-eslint/eslint-plugin": "7.9.0",
"@typescript-eslint/parser": "7.9.0",
"eslint": "9.0.0",
"@typescript-eslint/eslint-plugin": "8.13.0",
"@typescript-eslint/parser": "8.13.0",
"eslint": "9.14.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-jest": "28.5.0",
"eslint-plugin-prettier": "5.1.3",
"jest": "27.5.1",
"jest-circus": "27.5.1",
"nock": "13.5.4",
"prettier": "3.2.5",
"ts-jest": "29.1.2",
"typescript": "5.4.5",
"typescript-eslint": "7.7.0"
"eslint-plugin-jest": "28.9.0",
"eslint-plugin-prettier": "5.2.1",
"jest": "29.7.0",
"jest-circus": "29.7.0",
"prettier": "3.3.3",
"ts-jest": "29.2.5",
"typescript": "5.6.3",
"typescript-eslint": "8.13.0"
}
}
13 changes: 12 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {getInput} from '@actions/core'
import {isNullOrUndefined} from './util'

/**
* Required action data that gets initialized when running within the GitHub Actions environment.
*/
export interface ActionInterface {
/** Allows you to log the retrieved data to the terminal. */
debug?: boolean
Expand Down Expand Up @@ -28,6 +31,9 @@ export interface ActionInterface {
variableName?: string
}

/**
* Required data to fetch the data.
*/
export interface DataInterface {
/** Allows you to log the retrieved data to the terminal. */
debug?: boolean
Expand All @@ -43,6 +49,9 @@ export interface DataInterface {
retry?: boolean | null
}

/**
* Required data to export the data.
*/
export interface ExportInterface {
/** The data to save. */
data: string
Expand All @@ -60,7 +69,9 @@ export interface ExportInterface {
variableName?: string
}

// Required action data that gets initialized when running within the GitHub Actions environment.
/**
* Required action data that gets initialized when running within the GitHub Actions environment.
*/
export const action = {
debug: !isNullOrUndefined(getInput('debug'))
? getInput('debug').toLowerCase() === 'true'
Expand Down
9 changes: 6 additions & 3 deletions src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import {
debug
} from '@actions/core'
import {mkdirP} from '@actions/io'
import 'cross-fetch/polyfill'
import {promises as fs} from 'fs'
import {render} from 'mustache'
import retryRequest from 'async-retry'
import {DataInterface, ExportInterface, Status} from './constants'
import {parseData} from './util'

/* Fetches or Posts data to an API. If auth is provided it will replace the mustache variables with the data from it. */
/**
* Retrieves data from an API endpoint.
*/
export async function retrieveData({
debug: requestDebug,
endpoint,
Expand Down Expand Up @@ -67,7 +68,9 @@ export async function retrieveData({
}
}

/* Saves the data to the local file system and exports an environment variable containing the retrieved data. */
/**
* Generates an export file from the data provided.
*/
export async function generateExport({
data,
encoding,
Expand Down
1 change: 1 addition & 0 deletions src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default async function run(
hasRequiredParameters(settings)

let auth = ''

if (settings.tokenEndpoint) {
auth = await retrieveData({
debug: settings.debug,
Expand Down
15 changes: 12 additions & 3 deletions src/util.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import {ActionInterface} from './constants'

/* Utility function that checks to see if a value is undefined or not. */
/**
* Checks to see if a value is null or undefined.
*/
export const isNullOrUndefined = (value: string | undefined | null): boolean =>
typeof value === 'undefined' || value === null || value === ''

/* Checks for the required inputs. Throws an error if any case is matched. */
/**
* Checks to see if the action has the required parameters to run.
*/
export const hasRequiredParameters = (action: ActionInterface): void => {
if (isNullOrUndefined(action.endpoint)) {
throw new Error(
Expand All @@ -13,14 +17,19 @@ export const hasRequiredParameters = (action: ActionInterface): void => {
}
}

/**
* Extracts the error message from an error object or string.
*/
export const extractErrorMessage = (error: unknown): string =>
error instanceof Error
? error.message
: typeof error == 'string'
? error
: JSON.stringify(error)

/* Attempt to parse data as JSON and catch any errors. */
/**
* Parses a string into a JSON object.
*/
export const parseData = (data: string): Record<string, unknown> | null => {
try {
return JSON.parse(data)
Expand Down
Loading

0 comments on commit e70bf04

Please sign in to comment.