mirror of
https://github.com/Azure/k8s-deploy.git
synced 2026-06-27 07:09:26 +08:00
Migrate to esbuild/Vitest and upgrade @actions/* to ESM-only versions (#492)
* Migrate build toolchain from ncc/Jest to esbuild/Vitest Replace the legacy ncc/Jest/Babel build stack with a modern ESM toolchain: Build: - Replace @vercel/ncc with esbuild (--platform=node --target=node20 --format=esm) - Add createRequire banner for CJS interop in ESM bundle - Add "type": "module" to package.json - Add tsc --noEmit typecheck script (esbuild strips types without checking) - Add typecheck to husky pre-commit hook Dependencies: - Bump @actions/core@3, exec@3, io@3, tool-cache@4 (ESM-only) - Replace jest/ts-jest/@babel/* with vitest@4 Tests: - Convert 29 test files: jest.fn()→vi.fn(), jest.mock()→vi.mock(), jest.spyOn()→vi.spyOn() - Fix vitest 4 compat: mockImplementation requires args, mock call tracking, await .rejects CI: - Update build step from ncc build → npm run build - Update composite action to use npm run build * Switch tsconfig to NodeNext module resolution Change module/moduleResolution from ES2022/bundler to NodeNext/NodeNext and target from ES2022 to ES2020. - Add .js extensions to all relative imports across 59 source/test files (required by NodeNext module resolution) - Add vitest/globals to tsconfig types array for global test API declarations
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import * as fileUtils from './fileUtils'
|
||||
import {vi} from 'vitest'
|
||||
import * as fileUtils from './fileUtils.js'
|
||||
|
||||
import * as yaml from 'js-yaml'
|
||||
import fs from 'node:fs'
|
||||
import * as path from 'path'
|
||||
import {K8sObject} from '../types/k8sObject'
|
||||
import {K8sObject} from '../types/k8sObject.js'
|
||||
|
||||
const sampleYamlUrl =
|
||||
'https://raw.githubusercontent.com/kubernetes/website/main/content/en/examples/controllers/nginx-deployment.yaml'
|
||||
@@ -69,7 +70,7 @@ describe('File utils', () => {
|
||||
'manifest_test_dir'
|
||||
)
|
||||
|
||||
expect(
|
||||
await expect(
|
||||
fileUtils.getFilesFromDirectoriesAndURLs([badPath, goodPath])
|
||||
).rejects.toThrow()
|
||||
})
|
||||
@@ -108,8 +109,8 @@ describe('File utils', () => {
|
||||
|
||||
describe('moving files to temp', () => {
|
||||
it('correctly moves the contents of a file to the temporary directory', () => {
|
||||
jest.spyOn(fs, 'writeFileSync').mockImplementation(() => {})
|
||||
jest.spyOn(fs, 'readFileSync').mockImplementation((filename) => {
|
||||
vi.spyOn(fs, 'writeFileSync').mockImplementation(() => {})
|
||||
vi.spyOn(fs, 'readFileSync').mockImplementation((filename) => {
|
||||
return 'test contents'
|
||||
})
|
||||
const originalFilePath = path.join('path', 'in', 'repo')
|
||||
|
||||
Reference in New Issue
Block a user