Skip to content

Commit 70f9f52

Browse files
CopilotJamesIves
andauthored
chore: merge all open Dependabot dependency updates (#1967)
* chore: merge all Dependabot dependency updates with fixes - Update @actions/core/exec/github/io to v3/v9 (ESM-only) - Update @eslint/js to v10, @typescript-eslint/* to 8.58, eslint-plugin-jest/prettier - Update jest 29→30, typescript 5.8→6.0, @types/jest/node, prettier, rimraf, ts-jest - Update lodash 4.17→4.18 (yarn.lock only) - Add CJS test stubs for ESM-only @actions/* packages - Update tsconfig.json: target es2022, add types for node+jest - Update jest.config.js: moduleNameMapper for stubs, remove jest-circus runner - Fix new lint rules: preserve-caught-error and no-useless-assignment Agent-Logs-Url: https://github.com/JamesIves/github-pages-deploy-action/sessions/2a6d68c0-eab5-4c98-a927-2525b124ca87 Co-authored-by: JamesIves <10888441+JamesIves@users.noreply.github.com> * refactor: convert project to proper ESM - package.json: add "type": "module" for ESM runtime + nodenext compilation - tsconfig.json: module/moduleResolution → nodenext (ESM output with .js extensions) - src/*.ts: add .js extensions to all relative imports - __tests__/*.test.ts: add .js to relative imports, remove jest.mock() factories for @actions/* - jest.config.js → jest.config.cjs: CJS jest config, moduleNameMapper strips .js for ts-jest - __mocks__/@actions/*.js + package.json: proper Jest manual mocks (CJS, with functional implementations for integration tests) replacing __tests__/stubs/ workaround - eslint.config.mjs: ignore __mocks__/** instead of __tests__/stubs/** Agent-Logs-Url: https://github.com/JamesIves/github-pages-deploy-action/sessions/c73b8f61-87f7-4eab-8e99-d363a69f6e66 Co-authored-by: JamesIves <10888441+JamesIves@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: JamesIves <10888441+JamesIves@users.noreply.github.com>
1 parent 58bf4c7 commit 70f9f52

24 files changed

Lines changed: 732 additions & 1771 deletions

__mocks__/@actions/core.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
exportVariable: jest.fn(),
3+
getInput: jest.fn(),
4+
info: jest.fn(),
5+
isDebug: jest.fn(() => process.env['RUNNER_DEBUG'] === '1'),
6+
notice: jest.fn(),
7+
setFailed: jest.fn(),
8+
setOutput: jest.fn(),
9+
warning: jest.fn()
10+
}

__mocks__/@actions/exec.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const cp = require('child_process')
2+
3+
module.exports = {
4+
exec: jest.fn(async (command, args = [], options = {}) => {
5+
const {cwd, listeners = {}, ignoreReturnCode = false} = options
6+
const fullCommand =
7+
args && args.length ? `${command} ${args.join(' ')}` : command
8+
return new Promise((resolve, reject) => {
9+
const child = cp.spawn(fullCommand, {
10+
cwd: cwd || process.cwd(),
11+
shell: true,
12+
stdio: ['inherit', 'pipe', 'pipe']
13+
})
14+
child.stdout.on('data', data => {
15+
if (listeners.stdout) listeners.stdout(data)
16+
})
17+
child.stderr.on('data', data => {
18+
if (listeners.stderr) listeners.stderr(data)
19+
})
20+
child.on('close', code => {
21+
if (code !== 0 && !ignoreReturnCode) {
22+
reject(new Error(`Command failed: ${command} (exit ${code})`))
23+
} else {
24+
resolve(code || 0)
25+
}
26+
})
27+
child.on('error', reject)
28+
})
29+
})
30+
}

__mocks__/@actions/github.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
context: {
3+
payload: {}
4+
}
5+
}

__mocks__/@actions/io.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
mkdirP: jest.fn(dir =>
3+
require('fs/promises')
4+
.mkdir(dir, {recursive: true})
5+
.catch(() => {})
6+
),
7+
rmRF: jest.fn(p =>
8+
require('fs/promises').rm(p, {recursive: true, force: true})
9+
)
10+
}

__mocks__/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}

__tests__/execute.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import {execute, stdout} from '../src/execute'
1+
import {execute, stdout} from '../src/execute.js'
22
import {exec} from '@actions/exec'
33

4-
jest.mock('@actions/exec', () => ({
5-
exec: jest.fn()
6-
}))
4+
jest.mock('@actions/exec')
75

86
describe('execute', () => {
97
it('should be called with the correct arguments when silent mode is enabled', async () => {

__tests__/git.test.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ process.env['INPUT_FOLDER'] = 'build'
33
process.env['GITHUB_SHA'] = '123'
44

55
import {mkdirP, rmRF} from '@actions/io'
6-
import {action, Status, TestFlag} from '../src/constants'
7-
import {execute} from '../src/execute'
8-
import {deploy, init} from '../src/git'
6+
import {action, Status, TestFlag} from '../src/constants.js'
7+
import {execute} from '../src/execute.js'
8+
import {deploy, init} from '../src/git.js'
99
import fs from 'fs'
1010

1111
const originalAction = JSON.stringify(action)
@@ -14,18 +14,9 @@ jest.mock('fs', () => ({
1414
existsSync: jest.fn()
1515
}))
1616

17-
jest.mock('@actions/core', () => ({
18-
setFailed: jest.fn(),
19-
getInput: jest.fn(),
20-
setOutput: jest.fn(),
21-
isDebug: jest.fn(),
22-
info: jest.fn()
23-
}))
17+
jest.mock('@actions/core')
2418

25-
jest.mock('@actions/io', () => ({
26-
rmRF: jest.fn(),
27-
mkdirP: jest.fn()
28-
}))
19+
jest.mock('@actions/io')
2920

3021
jest.mock('../src/execute', () => ({
3122
__esModule: true,

__tests__/main.test.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ process.env['GITHUB_REF_NAME'] = 'test'
66
process.env['RUNNER_OS'] = 'Linux'
77
process.env['CI'] = 'true'
88

9-
import '../src/main'
10-
import {action, TestFlag} from '../src/constants'
11-
import run from '../src/lib'
12-
import {execute} from '../src/execute'
9+
import '../src/main.js'
10+
import {action, TestFlag} from '../src/constants.js'
11+
import run from '../src/lib.js'
12+
import {execute} from '../src/execute.js'
1313
import {rmRF} from '@actions/io'
1414
import {setFailed, exportVariable} from '@actions/core'
1515

@@ -19,19 +19,9 @@ jest.mock('../src/execute', () => ({
1919
execute: jest.fn(() => ({stdout: '', stderr: ''}))
2020
}))
2121

22-
jest.mock('@actions/io', () => ({
23-
rmRF: jest.fn()
24-
}))
22+
jest.mock('@actions/io')
2523

26-
jest.mock('@actions/core', () => ({
27-
setFailed: jest.fn(),
28-
getInput: jest.fn(),
29-
setOutput: jest.fn(),
30-
exportVariable: jest.fn(),
31-
isDebug: jest.fn(),
32-
info: jest.fn(),
33-
notice: jest.fn()
34-
}))
24+
jest.mock('@actions/core')
3525

3626
describe('main', () => {
3727
afterEach(() => {

__tests__/ssh.test.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import {exportVariable} from '@actions/core'
22
import {mkdirP} from '@actions/io'
33
import child_process, {execFileSync, execSync} from 'child_process'
44
import {appendFileSync} from 'fs'
5-
import {action, TestFlag} from '../src/constants'
6-
import {execute} from '../src/execute'
7-
import {configureSSH} from '../src/ssh'
5+
import {action, TestFlag} from '../src/constants.js'
6+
import {execute} from '../src/execute.js'
7+
import {configureSSH} from '../src/ssh.js'
88

99
const originalAction = JSON.stringify(action)
1010

@@ -18,19 +18,9 @@ jest.mock('child_process', () => ({
1818
execSync: jest.fn()
1919
}))
2020

21-
jest.mock('@actions/io', () => ({
22-
rmRF: jest.fn(),
23-
mkdirP: jest.fn()
24-
}))
21+
jest.mock('@actions/io')
2522

26-
jest.mock('@actions/core', () => ({
27-
setFailed: jest.fn(),
28-
getInput: jest.fn(),
29-
setOutput: jest.fn(),
30-
isDebug: jest.fn(),
31-
info: jest.fn(),
32-
exportVariable: jest.fn()
33-
}))
23+
jest.mock('@actions/core')
3424

3525
jest.mock('../src/execute', () => ({
3626
execute: jest.fn(() => ({stdout: '', stderr: ''}))

__tests__/util.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ActionInterface, TestFlag} from '../src/constants'
1+
import {ActionInterface, TestFlag} from '../src/constants.js'
22
import {
33
isNullOrUndefined,
44
generateTokenType,
@@ -8,7 +8,7 @@ import {
88
checkParameters,
99
stripProtocolFromUrl,
1010
extractErrorMessage
11-
} from '../src/util'
11+
} from '../src/util.js'
1212

1313
describe('util', () => {
1414
describe('isNullOrUndefined', () => {

0 commit comments

Comments
 (0)