Skip to content
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

Migrate to ESM #617

Merged
merged 1 commit into from
Apr 21, 2024
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
File renamed without changes.
12 changes: 7 additions & 5 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
module.exports = {
preset: 'ts-jest',
/** @type {import('ts-jest').JestConfigWithTsJest} */
export default {
preset: 'ts-jest/presets/default-esm',
clearMocks: true,
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
verbose: true
// https://kulshekhar.github.io/ts-jest/docs/guides/esm-support/
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"build": "ncc build --source-map --license licenses.txt src/main.ts",
"test": "jest"
},
"type": "module",
"dependencies": {
"@actions/core": "1.10.1",
"@actions/exec": "1.1.1",
Expand Down
8 changes: 4 additions & 4 deletions src/command.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as core from '@actions/core'
import * as exec from '@actions/exec'
import { GitHub } from '@actions/github/lib/utils'
import { postComment, UpdateIfExistsType } from './comment'
import { replaceTemplate } from './template'
import * as github from '@actions/github'
import { postComment, UpdateIfExistsType } from './comment.js'
import { replaceTemplate } from './template.js'

type Octokit = InstanceType<typeof GitHub>
type Octokit = ReturnType<typeof github.getOctokit>

type Inputs = {
run: string
Expand Down
3 changes: 1 addition & 2 deletions src/comment.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
import { GitHub } from '@actions/github/lib/utils'

type Octokit = InstanceType<typeof GitHub>
type Octokit = ReturnType<typeof github.getOctokit>

type Inputs = {
body: string
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as core from '@actions/core'
import { UpdateIfExistsType } from './comment'
import { run } from './run'
import { UpdateIfExistsType } from './comment.js'
import { run } from './run.js'

const main = async (): Promise<void> => {
await run({
Expand Down
4 changes: 2 additions & 2 deletions src/run.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as github from '@actions/github'
import { runCommand } from './command'
import { postComment, UpdateIfExistsType } from './comment'
import { runCommand } from './command.js'
import { postComment, UpdateIfExistsType } from './comment.js'

type Inputs = {
post: string
Expand Down
2 changes: 1 addition & 1 deletion tests/template.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { replaceTemplate } from '../src/template'
import { replaceTemplate } from '../src/template.js'

test('plain text', () => {
expect(replaceTemplate('foo', {})).toBe('foo')
Expand Down
6 changes: 2 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"extends": "@tsconfig/node20/tsconfig.json",
"compilerOptions": {
"outDir": "./lib"
}
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@tsconfig/node20/tsconfig.json"
}
Loading