diff --git a/package.json b/package.json index d65ac84..515e141 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ ], "license": "MIT", "private": true, + "type": "module", "exports": { ".": "./dist/index.js" }, @@ -17,7 +18,7 @@ "node": ">=20" }, "scripts": { - "start": "ts-node src/index.ts", + "start": "tsx src/index.ts", "build": "ncc build src/index.ts --license LICENSE.txt --minify", "lint": "eslint --max-warnings 0 .", "pretty": "prettier --check .", @@ -42,7 +43,7 @@ "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", "prettier": "^3.2.5", - "ts-node": "^10.9.2", + "tsx": "^4.7.1", "typescript": "^5.3.3", "vitest": "^1.3.1", "vitest-mock-extended": "^1.3.1" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0cb3356..b6840e5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -52,9 +52,9 @@ devDependencies: prettier: specifier: ^3.2.5 version: 3.2.5 - ts-node: - specifier: ^10.9.2 - version: 10.9.2(@types/node@20.11.20)(typescript@5.3.3) + tsx: + specifier: ^4.7.1 + version: 4.7.1 typescript: specifier: ^5.3.3 version: 5.3.3 @@ -220,13 +220,6 @@ packages: to-fast-properties: 2.0.0 dev: true - /@cspotcode/source-map-support@0.8.1: - resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} - engines: {node: '>=12'} - dependencies: - '@jridgewell/trace-mapping': 0.3.9 - dev: true - /@esbuild/aix-ppc64@0.19.12: resolution: {integrity: sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA==} engines: {node: '>=12'} @@ -533,13 +526,6 @@ packages: '@jridgewell/sourcemap-codec': 1.4.15 dev: true - /@jridgewell/trace-mapping@0.3.9: - resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} - dependencies: - '@jridgewell/resolve-uri': 3.1.2 - '@jridgewell/sourcemap-codec': 1.4.15 - dev: true - /@nodelib/fs.scandir@2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -782,22 +768,6 @@ packages: - supports-color dev: true - /@tsconfig/node10@1.0.9: - resolution: {integrity: sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==} - dev: true - - /@tsconfig/node12@1.0.11: - resolution: {integrity: sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==} - dev: true - - /@tsconfig/node14@1.0.3: - resolution: {integrity: sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==} - dev: true - - /@tsconfig/node16@1.0.4: - resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==} - dev: true - /@types/estree@1.0.5: resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} dev: true @@ -1048,10 +1018,6 @@ packages: engines: {node: '>=10'} dev: true - /arg@4.1.3: - resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==} - dev: true - /argparse@2.0.1: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} dev: true @@ -1168,10 +1134,6 @@ packages: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} dev: true - /create-require@1.1.1: - resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} - dev: true - /cross-spawn@7.0.3: resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} engines: {node: '>= 8'} @@ -1213,11 +1175,6 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dev: true - /diff@4.0.2: - resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} - engines: {node: '>=0.3.1'} - dev: true - /dir-glob@3.0.1: resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} engines: {node: '>=8'} @@ -1481,6 +1438,12 @@ packages: engines: {node: '>=16'} dev: true + /get-tsconfig@4.7.2: + resolution: {integrity: sha512-wuMsz4leaj5hbGgg4IvDU0bqJagpftG5l5cXIAvo8uZrqn0NJqwtfupTN00VnkQJPcIRrxYrm1Ue24btpCha2A==} + dependencies: + resolve-pkg-maps: 1.0.0 + dev: true + /glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} @@ -1706,10 +1669,6 @@ packages: '@jridgewell/sourcemap-codec': 1.4.15 dev: true - /make-error@1.3.6: - resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==} - dev: true - /merge-stream@2.0.0: resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} dev: true @@ -1924,6 +1883,10 @@ packages: engines: {node: '>=4'} dev: true + /resolve-pkg-maps@1.0.0: + resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} + dev: true + /reusify@1.0.4: resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} engines: {iojs: '>=1.0.0', node: '>=0.10.0'} @@ -2103,35 +2066,15 @@ packages: typescript: 5.3.3 dev: true - /ts-node@10.9.2(@types/node@20.11.20)(typescript@5.3.3): - resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==} + /tsx@4.7.1: + resolution: {integrity: sha512-8d6VuibXHtlN5E3zFkgY8u4DX7Y3Z27zvvPKVmLon/D4AjuKzarkUBTLDBgj9iTQ0hg5xM7c/mYiRVM+HETf0g==} + engines: {node: '>=18.0.0'} hasBin: true - peerDependencies: - '@swc/core': '>=1.2.50' - '@swc/wasm': '>=1.2.50' - '@types/node': '*' - typescript: '>=2.7' - peerDependenciesMeta: - '@swc/core': - optional: true - '@swc/wasm': - optional: true dependencies: - '@cspotcode/source-map-support': 0.8.1 - '@tsconfig/node10': 1.0.9 - '@tsconfig/node12': 1.0.11 - '@tsconfig/node14': 1.0.3 - '@tsconfig/node16': 1.0.4 - '@types/node': 20.11.20 - acorn: 8.11.3 - acorn-walk: 8.3.2 - arg: 4.1.3 - create-require: 1.1.1 - diff: 4.0.2 - make-error: 1.3.6 - typescript: 5.3.3 - v8-compile-cache-lib: 3.0.1 - yn: 3.1.1 + esbuild: 0.19.12 + get-tsconfig: 4.7.2 + optionalDependencies: + fsevents: 2.3.3 dev: true /tunnel@0.0.6: @@ -2192,10 +2135,6 @@ packages: hasBin: true dev: false - /v8-compile-cache-lib@3.0.1: - resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} - dev: true - /vite-node@1.3.1(@types/node@20.11.20): resolution: {integrity: sha512-azbRrqRxlWTJEVbzInZCTchx0X69M/XPTCz4H+TLvlTcR/xH/3hkRqhOakT41fMJCMzXTu4UvegkZiEoJAWvng==} engines: {node: ^18.0.0 || >=20.0.0} @@ -2343,11 +2282,6 @@ packages: /yallist@4.0.0: resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} - /yn@3.1.1: - resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==} - engines: {node: '>=6'} - dev: true - /yocto-queue@0.1.0: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} diff --git a/src/action.ts b/src/action.ts index 9ef608b..35e1319 100644 --- a/src/action.ts +++ b/src/action.ts @@ -1,6 +1,6 @@ import { group, info, warning } from "@actions/core" -import { processPackages } from "./process/process" -import { DeleteStrategy, Input, QueryStrategy } from "./types" +import { processPackages } from "./process/process.js" +import { DeleteStrategy, Input, QueryStrategy } from "./types.js" export async function executeAction(input: Input, queryStrategy: QueryStrategy, deleteStrategy: DeleteStrategy) { if (input.dryRun) { diff --git a/src/clients/packages.client.ts b/src/clients/packages.client.ts index c465ee1..478e380 100644 --- a/src/clients/packages.client.ts +++ b/src/clients/packages.client.ts @@ -1,12 +1,11 @@ import { info, warning } from "@actions/core" import { getOctokit } from "@actions/github" -import { GitHub } from "@actions/github/lib/utils" import { Octokit } from "@octokit/core" import { throttling } from "@octokit/plugin-throttling" import { RequestOptions } from "@octokit/types" -import { Input } from "../types" +import { Input } from "../types.js" -export function createPackagesClient(input: Input): InstanceType { +export function createPackagesClient(input: Input): ReturnType { const customClient = Octokit.plugin(throttling) const customOctokit = new customClient({ diff --git a/src/delete/delete.strategy.factory.ts b/src/delete/delete.strategy.factory.ts index 270b0ab..8fb8116 100644 --- a/src/delete/delete.strategy.factory.ts +++ b/src/delete/delete.strategy.factory.ts @@ -1,7 +1,7 @@ -import { createPackagesClient } from "../clients/packages.client" -import { DeleteStrategy, Input } from "../types" -import OrganizationDeleteStrategy from "./strategies/organization.delete.strategy" -import UserDeleteStrategy from "./strategies/user.delete.strategy" +import { createPackagesClient } from "../clients/packages.client.js" +import { DeleteStrategy, Input } from "../types.js" +import OrganizationDeleteStrategy from "./strategies/organization.delete.strategy.js" +import UserDeleteStrategy from "./strategies/user.delete.strategy.js" export function decideDeleteStrategy(input: Input): DeleteStrategy { const packagesClient = createPackagesClient(input) diff --git a/src/delete/strategies/organization.delete.strategy.ts b/src/delete/strategies/organization.delete.strategy.ts index 611d280..a05e7bb 100644 --- a/src/delete/strategies/organization.delete.strategy.ts +++ b/src/delete/strategies/organization.delete.strategy.ts @@ -1,8 +1,8 @@ -import { GitHub } from "@actions/github/lib/utils" -import { DeleteStrategy, Input } from "../../types" +import { getOctokit } from "@actions/github" +import { DeleteStrategy, Input } from "../../types.js" export default class OrganizationDeleteStrategy implements DeleteStrategy { - constructor(private readonly octokit: InstanceType) {} + constructor(private readonly octokit: ReturnType) {} async deletePackageVersion(input: Input, name: string, id: string): Promise { await this.octokit.rest.packages.deletePackageVersionForOrg({ diff --git a/src/delete/strategies/user.delete.strategy.ts b/src/delete/strategies/user.delete.strategy.ts index 0cb17c3..4c84f9a 100644 --- a/src/delete/strategies/user.delete.strategy.ts +++ b/src/delete/strategies/user.delete.strategy.ts @@ -1,8 +1,8 @@ -import { GitHub } from "@actions/github/lib/utils" -import { DeleteStrategy, Input } from "../../types" +import { getOctokit } from "@actions/github" +import { DeleteStrategy, Input } from "../../types.js" export default class UserDeleteStrategy implements DeleteStrategy { - constructor(private readonly octokit: InstanceType) {} + constructor(private readonly octokit: ReturnType) {} async deletePackageVersion(input: Input, name: string, id: string): Promise { await this.octokit.rest.packages.deletePackageVersionForUser({ diff --git a/src/index.ts b/src/index.ts index 0ac4143..357bad0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,8 @@ import { setFailed } from "@actions/core" -import { executeAction } from "./action" -import { decideDeleteStrategy } from "./delete/delete.strategy.factory" -import { getActionInput, validateInput } from "./input" -import { decideQueryStrategy } from "./query/query.strategy.factory" +import { executeAction } from "./action.js" +import { decideDeleteStrategy } from "./delete/delete.strategy.factory.js" +import { getActionInput, validateInput } from "./input.js" +import { decideQueryStrategy } from "./query/query.strategy.factory.js" async function run() { const input = validateInput(getActionInput()) diff --git a/src/input.ts b/src/input.ts index 49ac32d..c56b9fb 100644 --- a/src/input.ts +++ b/src/input.ts @@ -1,6 +1,6 @@ import { getBooleanInput, getInput, getMultilineInput } from "@actions/core" import { Range } from "semver" -import { Input, PackageType } from "./types" +import { Input, PackageType } from "./types.js" const DEFAULT_KEEP = 2 diff --git a/src/process/process.ts b/src/process/process.ts index 1ceb170..2cfdfa1 100644 --- a/src/process/process.ts +++ b/src/process/process.ts @@ -1,7 +1,6 @@ import { Endpoints } from "@octokit/types" -import semverCoerce from "semver/functions/coerce" -import semverSatisfies from "semver/functions/satisfies" -import { Input, Package, PackageType, PackageVersion } from "../types" +import { coerce as semverCoerce, satisfies as semverSatisfies } from "semver" +import { Input, Package, PackageType, PackageVersion } from "../types.js" type OctokitPackageResponse = Endpoints["GET /users/{username}/packages/{package_type}/{package_name}/versions"]["response"] diff --git a/src/query/query.strategy.factory.ts b/src/query/query.strategy.factory.ts index 6ff5fd3..d63ff4e 100644 --- a/src/query/query.strategy.factory.ts +++ b/src/query/query.strategy.factory.ts @@ -1,7 +1,7 @@ -import { createPackagesClient } from "../clients/packages.client" -import { Input, QueryStrategy } from "../types" -import OrganizationQueryStrategy from "./strategies/organization.query.strategy" -import UserQueryStrategy from "./strategies/user.query.strategy" +import { createPackagesClient } from "../clients/packages.client.js" +import { Input, QueryStrategy } from "../types.js" +import OrganizationQueryStrategy from "./strategies/organization.query.strategy.js" +import UserQueryStrategy from "./strategies/user.query.strategy.js" export function decideQueryStrategy(input: Input): QueryStrategy { const packagesClient = createPackagesClient(input) diff --git a/src/query/strategies/organization.query.strategy.ts b/src/query/strategies/organization.query.strategy.ts index 4edc760..3bed868 100644 --- a/src/query/strategies/organization.query.strategy.ts +++ b/src/query/strategies/organization.query.strategy.ts @@ -1,9 +1,9 @@ -import { GitHub } from "@actions/github/lib/utils" -import { processResponse } from "../../process/process" -import { Input, Package, QueryStrategy } from "../../types" +import { getOctokit } from "@actions/github" +import { processResponse } from "../../process/process.js" +import { Input, Package, QueryStrategy } from "../../types.js" export default class OrganizationQueryStrategy implements QueryStrategy { - constructor(private readonly octokit: InstanceType) {} + constructor(private readonly octokit: ReturnType) {} async queryPackages(input: Input): Promise { return await Promise.all( diff --git a/src/query/strategies/user.query.strategy.ts b/src/query/strategies/user.query.strategy.ts index ea8c228..c84f2c1 100644 --- a/src/query/strategies/user.query.strategy.ts +++ b/src/query/strategies/user.query.strategy.ts @@ -1,9 +1,9 @@ -import { GitHub } from "@actions/github/lib/utils" -import { processResponse } from "../../process/process" -import { Input, Package, QueryStrategy } from "../../types" +import { getOctokit } from "@actions/github" +import { processResponse } from "../../process/process.js" +import { Input, Package, QueryStrategy } from "../../types.js" export default class UserQueryStrategy implements QueryStrategy { - constructor(private readonly octokit: InstanceType) {} + constructor(private readonly octokit: ReturnType) {} async queryPackages(input: Input): Promise { return await Promise.all( diff --git a/test/action.spec.ts b/test/action.spec.ts index 14e9c5b..84dc092 100644 --- a/test/action.spec.ts +++ b/test/action.spec.ts @@ -1,8 +1,8 @@ import { Range } from "semver" import { expect, test } from "vitest" import { mock } from "vitest-mock-extended" -import { executeAction } from "../src/action" -import { DeleteStrategy, Input, PackageType, QueryStrategy } from "../src/types" +import { executeAction } from "../src/action.js" +import { DeleteStrategy, Input, PackageType, QueryStrategy } from "../src/types.js" const packages = [ { diff --git a/test/delete/delete.strategy.factory.spec.ts b/test/delete/delete.strategy.factory.spec.ts index 4a97f99..f45df43 100644 --- a/test/delete/delete.strategy.factory.spec.ts +++ b/test/delete/delete.strategy.factory.spec.ts @@ -1,8 +1,8 @@ import { expect, test } from "vitest" -import { decideDeleteStrategy } from "../../src/delete/delete.strategy.factory" -import OrganizationDeleteStrategy from "../../src/delete/strategies/organization.delete.strategy" -import UserDeleteStrategy from "../../src/delete/strategies/user.delete.strategy" -import { Input, PackageType } from "../../src/types" +import { decideDeleteStrategy } from "../../src/delete/delete.strategy.factory.js" +import OrganizationDeleteStrategy from "../../src/delete/strategies/organization.delete.strategy.js" +import UserDeleteStrategy from "../../src/delete/strategies/user.delete.strategy.js" +import { Input, PackageType } from "../../src/types.js" test("decide default delete strategy", () => { const input: Input = { diff --git a/test/input.spec.ts b/test/input.spec.ts index ba7d128..8c18786 100644 --- a/test/input.spec.ts +++ b/test/input.spec.ts @@ -1,7 +1,7 @@ import { Range } from "semver" import { afterEach, beforeEach, describe, expect, test, vi } from "vitest" -import { getActionInput, validateInput } from "../src/input" -import { Input, PackageType } from "../src/types" +import { getActionInput, validateInput } from "../src/input.js" +import { Input, PackageType } from "../src/types.js" describe("getActionInput", () => { const env = process.env diff --git a/test/process/process.spec.ts b/test/process/process.spec.ts index 7343cd3..30a89ed 100644 --- a/test/process/process.spec.ts +++ b/test/process/process.spec.ts @@ -1,8 +1,8 @@ import { Endpoints } from "@octokit/types" import { Range } from "semver" import { expect, test } from "vitest" -import { processPackages, processResponse } from "../../src/process/process" -import { PackageType } from "../../src/types" +import { processPackages, processResponse } from "../../src/process/process.js" +import { PackageType } from "../../src/types.js" test("filters correctly", () => { const result = processPackages( diff --git a/test/query/query.strategy.factory.spec.ts b/test/query/query.strategy.factory.spec.ts index 30cc47f..a1bbe22 100644 --- a/test/query/query.strategy.factory.spec.ts +++ b/test/query/query.strategy.factory.spec.ts @@ -1,8 +1,8 @@ import { expect, test } from "vitest" -import { decideQueryStrategy } from "../../src/query/query.strategy.factory" -import OrganizationQueryStrategy from "../../src/query/strategies/organization.query.strategy" -import UserQueryStrategy from "../../src/query/strategies/user.query.strategy" -import { Input, PackageType } from "../../src/types" +import { decideQueryStrategy } from "../../src/query/query.strategy.factory.js" +import OrganizationQueryStrategy from "../../src/query/strategies/organization.query.strategy.js" +import UserQueryStrategy from "../../src/query/strategies/user.query.strategy.js" +import { Input, PackageType } from "../../src/types.js" test("decide user query strategy", () => { const input: Input = { diff --git a/tsconfig.json b/tsconfig.json index d297dde..310fa31 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,8 @@ { "compilerOptions": { "target": "ES2022", - "module": "CommonJS", - "moduleResolution": "Node", + "module": "NodeNext", + "moduleResolution": "NodeNext", "esModuleInterop": true, "noEmit": true, "noImplicitAny": true,