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

Rewrite in JavaScript #95

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a5294a5
Blindly convert `.ts` files to `.mjs`
brettcannon Jan 8, 2024
a0b1331
Move from Jest to Vitest
brettcannon Jan 9, 2024
9a02679
Fix formatting
brettcannon Jan 9, 2024
48426d1
Set up eslint to use modules
brettcannon Jan 9, 2024
87639ce
Drop `tsconfig.json`
brettcannon Jan 9, 2024
a2cac0a
Tweak command used to run vitest
brettcannon Jan 9, 2024
17a6ba1
Update config for ECMAScript version appropriate to Node 20
brettcannon Jan 9, 2024
ac619d5
Update `package-lock.json`
brettcannon Mar 22, 2024
2b266ea
Drop the `build` step of CI
brettcannon Mar 23, 2024
5ae9fc8
Bump to @vercel/ncc to 0.38.1
brettcannon Mar 23, 2024
9025ec7
Rename `index.mjs` to `index.js` to try and deal with an ncc problem …
brettcannon Mar 23, 2024
3bd8c66
Try not specifying the module type
brettcannon Mar 23, 2024
8914dcc
Move back to `index.mjs`
brettcannon Mar 23, 2024
ccd0c63
Minify ncc output
brettcannon Mar 23, 2024
a2cbc57
Use file extensions in imports
brettcannon Mar 23, 2024
7c9c2dd
Try moving to esbuild for bundling
brettcannon Mar 23, 2024
57497d7
Rename output file
brettcannon Mar 23, 2024
b62365e
Explicitly move to `dist/index.js`
brettcannon Mar 23, 2024
8b34e12
Don't explicitly say everything is a module
brettcannon Mar 23, 2024
fdacb92
Upgrade http-client
brettcannon Mar 23, 2024
190dee6
Specify the default glob pattern at the action level instead of the J…
brettcannon Apr 28, 2024
b14d28b
Remove some dead code due to moving default glob to `action.yml`
brettcannon Apr 28, 2024
2858137
Check for `.mjs` changes in PRs
brettcannon Apr 28, 2024
190d74b
Drop some lingering TS settings
brettcannon Apr 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 12 additions & 8 deletions .eslintrc.json
@@ -1,11 +1,15 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["jest", "@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"env": { "node": true, "jest/globals": true }
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2023, // https://node.green/#ES2023
"ecmaFeatures": {
"impliedStrict": true
}
},
"extends": ["eslint:recommended", "prettier"],
"env": {
"node": true,
"es2023": true // https://node.green/#ES2023
}
}
1 change: 0 additions & 1 deletion .github/workflows/pull-request.yml
Expand Up @@ -20,7 +20,6 @@ jobs:
with:
node-version: "20"
- run: npm ci
- run: npm run build
- run: npm run lint
- run: npm run format-check

Expand Down
23 changes: 14 additions & 9 deletions __tests__/gh.test.ts → __tests__/gh.test.mjs
@@ -1,5 +1,13 @@
import { ImportMock } from "ts-mock-imports";
import * as github from "@actions/github";
import {
afterAll,
afterEach,
beforeEach,
describe,
expect,
test,
vi,
} from "vitest";
import * as gh from "../src/gh";

test("gh.pullRequestEvent() return undefined by default", () => {
Expand All @@ -15,12 +23,10 @@ describe("Stub github.context w/ a pull_request payload", () => {
},
};

beforeEach(() => {
ImportMock.mockOther(github, "context", context);
});
afterEach(() => ImportMock.restore());
afterEach(() => vi.restoreAllMocks());

test("pull_request context is returned by gh.pullRequestEvent()", () => {
vi.spyOn(github, "context", "get").mockReturnValue(context);
expect(gh.pullRequestPayload()).toEqual(context.payload);
});
});
Expand All @@ -33,12 +39,11 @@ describe("Stub github.context w/ a 'push' payload", () => {
repository: { name: "test", owner: { login: "anonymous" } },
},
};
beforeEach(() => {
ImportMock.mockOther(github, "context", context);
});
afterEach(() => ImportMock.restore());

afterEach(() => vi.restoreAllMocks());

test("'undefined' is returned by gh.pullRequestEvent()", () => {
vi.spyOn(github, "context", "get").mockReturnValue(context);
expect(gh.pullRequestPayload()).toBeUndefined();
});
});
1 change: 1 addition & 0 deletions __tests__/main.test.ts → __tests__/main.test.mjs
@@ -1,3 +1,4 @@
import { describe, expect, test } from "vitest";
import * as main from "../src/main";

describe("repr()", () => {
Expand Down
1 change: 1 addition & 0 deletions __tests__/matching.test.ts → __tests__/matching.test.mjs
@@ -1,3 +1,4 @@
import { describe, expect, test } from "vitest";
import * as matching from "../src/matching";

describe("anyFileMatches()", () => {
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Expand Up @@ -25,4 +25,4 @@ inputs:
required: False
runs:
using: "node20"
main: "dist/index.js"
main: "dist/index.mjs"