Skip to content

Pre-release updates #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .c8rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"all": true,
"include": "index.js",
"reporter": [
"html",
"lcov",
"text"
]
}
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@ on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
paths-ignore:
- '*.md'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
nodejs:
name: Node.js
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node-version: [^18.18, ^20.8, ^21, ^22, ^24]
node-version: [^20.8, ^22, ^24]
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4
Expand All @@ -26,3 +31,4 @@ jobs:
with:
files: coverage/lcov.info
name: ${{ matrix.os }}/${{ matrix.node-version }}
token: ${{ secrets.CODECOV_TOKEN }}
89 changes: 89 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Release tag (e.g., v1.2.3)'
required: true
type: string
skip_ci_check:
description: 'Skip CI status check'
required: false
type: boolean
default: false

permissions:
contents: write
id-token: write

jobs:
release:
name: Release
runs-on: ubuntu-latest
environment: npm
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }}
fetch-depth: 0

- name: Verify tag matches package.json version
run: |
jq --raw-output --exit-status --arg tag "$RELEASE_TAG" '
if (.version == ($tag | ltrimstr("v"))) then
"Package version (\(.version)) matches tag version (\($tag | ltrimstr("v")))"
else
"Package version (\(.version)) does not match tag version (\($tag | ltrimstr("v")))" | halt_error(1)
end' package.json
env:
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}

- name: Verify commit is in main branch
run: |
# Check if the tagged commit is included in the main branch
if git merge-base --is-ancestor ${{ github.sha }} origin/main; then
echo "Tagged commit is properly included in main branch"
else
echo "Tagged commit is not included in the main branch"
echo "Please push the commit to main before releasing"
exit 1
fi

- name: Check CI status
if: ${{ !inputs.skip_ci_check }}
run: |
# Check if CI has completed successfully for this commit
gh run list --commit ${{ github.sha }} --status success --json workflowName | jq --raw-output --exit-status '
if any(.[]; .workflowName == "Install and test @ava/typescript") then
"All CI checks have passed!"
else
"CI has not completed successfully for this commit" | halt_error(1)
end'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: npm
registry-url: https://registry.npmjs.org

- name: Publish to npm with provenance
run: npm publish --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Create GitHub Release
run: |
gh release create "$RELEASE_TAG" \
--title "$RELEASE_TAG" \
--draft \
--generate-notes
env:
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 14 additions & 0 deletions ava.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const avaConfig = {
files: [
'!test/broken-fixtures/**',
],
watchMode: {
ignoreChanges: [
'test/fixtures/**',
'test/broken-fixtures/**',
],
},
timeout: '60s',
};

export default avaConfig;
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function validate(target, properties) {
}

async function compileTypeScript(projectDirectory) {
return execa('tsc', ['--incremental'], {preferLocal: true, cwd: projectDirectory});
return execa({preferLocal: true, cwd: projectDirectory})`tsc --incremental`;
}

const configProperties = {
Expand Down
41 changes: 10 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "5.0.0",
"description": "TypeScript provider for AVA",
"engines": {
"node": "^18.18 || ^20.8 || ^21 || ^22 || >=24"
"node": "^20.8 || ^22 || >=24"
},
"files": [
"index.js"
Expand All @@ -24,38 +24,17 @@
},
"dependencies": {
"escape-string-regexp": "^5.0.0",
"execa": "^8.0.1"
"execa": "^9.6.0"
},
"devDependencies": {
"ava": "^6.1.2",
"c8": "^9.1.0",
"del": "^7.1.0",
"typescript": "^5.4.5",
"xo": "^0.58.0"
"ava": "^6.4.0",
"c8": "^10.1.3",
"del": "^8.0.0",
"typescript": "^5.8.3",
"xo": "^1.1.0"
},
"c8": {
"reporter": [
"html",
"lcov",
"text"
]
},
"ava": {
"files": [
"!test/broken-fixtures/**"
],
"watcher": {
"ignoreChanges": [
"test/fixtures/**",
"test/broken-fixtures/**"
]
},
"timeout": "60s"
},
"xo": {
"ignores": [
"test/broken-fixtures",
"test/fixtures/**/compiled/**"
]
"volta": {
"node": "22.16.0",
"npm": "11.4.2"
}
}
5 changes: 4 additions & 1 deletion test/broken-fixtures/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"compilerOptions": {
"outDir": "typescript/compiled"
"outDir": "typescript/compiled",
"lib": [
"es2022"
]
},
"include": [
"typescript"
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/load/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"strictNullChecks": true,
"module": "Node16",
"module": "node18",
"outDir": "compiled"
},
"include": [
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"compilerOptions": {
"strictNullChecks": true,
"lib": [
"es2022",
"dom"
],
"outDir": "typescript/compiled"
},
"include": [
Expand Down
16 changes: 13 additions & 3 deletions test/protocol-ava-6.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,27 @@ test('main() resolvePossibleOutOfBandCompilationSources() .js but .ts not config

test('main() resolvePossibleOutOfBandCompilationSources() .cjs and .cjs and .cts configured', withProvider, (t, provider) => {
const main = provider.main({config: {extensions: ['cjs', 'cts'], rewritePaths: {'src/': 'build/'}, compile: false}});
t.deepEqual(main.resolvePossibleOutOfBandCompilationSources(path.join(projectDirectory, 'build/foo.cjs')), [path.join(projectDirectory, 'src/foo.cjs'), path.join(projectDirectory, 'src/foo.cts')]);
t.deepEqual(main.resolvePossibleOutOfBandCompilationSources(path.join(projectDirectory, 'build/foo.cjs')), [
path.join(projectDirectory, 'src/foo.cjs'),
path.join(projectDirectory, 'src/foo.cts'),
]);
});

test('main() resolvePossibleOutOfBandCompilationSources() .mjs and .mjs and .mts configured', withProvider, (t, provider) => {
const main = provider.main({config: {extensions: ['mjs', 'mts'], rewritePaths: {'src/': 'build/'}, compile: false}});
t.deepEqual(main.resolvePossibleOutOfBandCompilationSources(path.join(projectDirectory, 'build/foo.mjs')), [path.join(projectDirectory, 'src/foo.mjs'), path.join(projectDirectory, 'src/foo.mts')]);
t.deepEqual(main.resolvePossibleOutOfBandCompilationSources(path.join(projectDirectory, 'build/foo.mjs')), [
path.join(projectDirectory, 'src/foo.mjs'),
path.join(projectDirectory, 'src/foo.mts'),
]);
});

test('main() resolvePossibleOutOfBandCompilationSources() .js and .js, .ts and .tsx configured', withProvider, (t, provider) => {
const main = provider.main({config: {extensions: ['js', 'ts', 'tsx'], rewritePaths: {'src/': 'build/'}, compile: false}});
t.deepEqual(main.resolvePossibleOutOfBandCompilationSources(path.join(projectDirectory, 'build/foo.js')), [path.join(projectDirectory, 'src/foo.js'), path.join(projectDirectory, 'src/foo.ts'), path.join(projectDirectory, 'src/foo.tsx')]);
t.deepEqual(main.resolvePossibleOutOfBandCompilationSources(path.join(projectDirectory, 'build/foo.js')), [
path.join(projectDirectory, 'src/foo.js'),
path.join(projectDirectory, 'src/foo.ts'),
path.join(projectDirectory, 'src/foo.tsx'),
]);
});

test('main() resolvePossibleOutOfBandCompilationSources() returns the first possible path that exists', withProvider, (t, provider) => {
Expand Down
1 change: 1 addition & 0 deletions test/snapshots/compilation.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`Command failed with exit code 2: tsc --incremental␊
typescript/typescript.ts(1,1): error TS2304: Cannot find name 'a'.`
Binary file modified test/snapshots/compilation.js.snap
Binary file not shown.
Binary file modified test/snapshots/protocol-ava-6.js.snap
Binary file not shown.
11 changes: 11 additions & 0 deletions xo.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @type {import('xo').FlatXoConfig} */
const xoConfig = [
{
ignores: [
'test/broken-fixtures',
'test/fixtures/**/compiled/**',
],
},
];

export default xoConfig;