diff --git a/package.json b/package.json index b78dbe535..65a34cc55 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,9 @@ "functions": 100, "lines": 100 } + }, + "moduleNameMapper": { + "^(.+)\\.jsx?$": "$1" } }, "release": { diff --git a/scripts/update-endpoints/code.mjs b/scripts/update-endpoints/code.mjs index 7f5bd1123..de129e0d9 100644 --- a/scripts/update-endpoints/code.mjs +++ b/scripts/update-endpoints/code.mjs @@ -1,6 +1,6 @@ -import { readFileSync, writeFileSync } from "fs"; -import { join } from "path"; -import { fileURLToPath } from "url"; +import { readFileSync, writeFileSync } from "node:fs"; +import { join } from "node:path"; +import { fileURLToPath } from "node:url"; import { format } from "prettier"; import sortKeys from "sort-keys"; @@ -123,7 +123,7 @@ async function generateRoutes() { writeFileSync( ROUTES_PATH, await format( - `import type { EndpointsDefaultsAndDecorations } from "../types"; + `import type { EndpointsDefaultsAndDecorations } from "../types.js"; const Endpoints: EndpointsDefaultsAndDecorations = ${JSON.stringify( sortKeys(newRoutes, { deep: true }), )} diff --git a/scripts/update-endpoints/docs.mjs b/scripts/update-endpoints/docs.mjs index 618de6ddc..b5c1b877d 100644 --- a/scripts/update-endpoints/docs.mjs +++ b/scripts/update-endpoints/docs.mjs @@ -1,7 +1,7 @@ import { format } from "prettier"; import { isDeprecated } from "./util.mjs"; -import { readFileSync, mkdirSync, writeFileSync } from "fs"; +import { readFileSync, mkdirSync, writeFileSync } from "node:fs"; const ENDPOINTS = JSON.parse( readFileSync( diff --git a/scripts/update-endpoints/fetch-json.mjs b/scripts/update-endpoints/fetch-json.mjs index 62c851f2b..6906ac765 100644 --- a/scripts/update-endpoints/fetch-json.mjs +++ b/scripts/update-endpoints/fetch-json.mjs @@ -1,6 +1,6 @@ -import { writeFileSync } from "fs"; -import { resolve } from "path"; -import { fileURLToPath } from "url"; +import { writeFileSync } from "node:fs"; +import { resolve } from "node:path"; +import { fileURLToPath } from "node:url"; import graphql from "github-openapi-graphql-query"; import { format } from "prettier"; diff --git a/scripts/update-endpoints/types.mjs b/scripts/update-endpoints/types.mjs index 3a0786f0e..919f58e2e 100644 --- a/scripts/update-endpoints/types.mjs +++ b/scripts/update-endpoints/types.mjs @@ -1,5 +1,5 @@ -import { writeFileSync, readFileSync } from "fs"; -import { join as pathJoin } from "path"; +import { writeFileSync, readFileSync } from "node:fs"; +import { join as pathJoin } from "node:path"; import camelCase from "lodash.camelcase"; import { format } from "prettier"; diff --git a/src/endpoints-to-methods.ts b/src/endpoints-to-methods.ts index 67105fba4..e52e1216f 100644 --- a/src/endpoints-to-methods.ts +++ b/src/endpoints-to-methods.ts @@ -1,8 +1,8 @@ import type { Octokit } from "@octokit/core"; import type { EndpointOptions, RequestParameters, Route } from "@octokit/types"; -import ENDPOINTS from "./generated/endpoints"; -import type { RestEndpointMethods } from "./generated/method-types"; -import type { EndpointDecorations } from "./types"; +import ENDPOINTS from "./generated/endpoints.js"; +import type { RestEndpointMethods } from "./generated/method-types.js"; +import type { EndpointDecorations } from "./types.js"; // The following code was refactored in: https://github.com/octokit/plugin-rest-endpoint-methods.js/pull/622 // to optimise the runtime performance of Octokit initialization. diff --git a/src/generated/endpoints.ts b/src/generated/endpoints.ts index 856bd0d2a..b5d98896b 100644 --- a/src/generated/endpoints.ts +++ b/src/generated/endpoints.ts @@ -1,4 +1,4 @@ -import type { EndpointsDefaultsAndDecorations } from "../types"; +import type { EndpointsDefaultsAndDecorations } from "../types.js"; const Endpoints: EndpointsDefaultsAndDecorations = { actions: { addCustomLabelsToSelfHostedRunnerForOrg: [ diff --git a/src/generated/method-types.ts b/src/generated/method-types.ts index 363f575c1..6adad23c2 100644 --- a/src/generated/method-types.ts +++ b/src/generated/method-types.ts @@ -1,5 +1,5 @@ import type { EndpointInterface, RequestInterface } from "@octokit/types"; -import type { RestEndpointMethodTypes } from "./parameters-and-response-types"; +import type { RestEndpointMethodTypes } from "./parameters-and-response-types.js"; export type RestEndpointMethods = { actions: { diff --git a/src/index.ts b/src/index.ts index 406e72a9d..ef9cb65c7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,9 @@ import type { Octokit } from "@octokit/core"; -export type { RestEndpointMethodTypes } from "./generated/parameters-and-response-types"; -import { VERSION } from "./version"; -import type { Api } from "./types"; -import { endpointsToMethods } from "./endpoints-to-methods"; +export type { RestEndpointMethodTypes } from "./generated/parameters-and-response-types.js"; +import { VERSION } from "./version.js"; +import type { Api } from "./types.js"; +import { endpointsToMethods } from "./endpoints-to-methods.js"; export function restEndpointMethods(octokit: Octokit): Api { const api = endpointsToMethods(octokit); diff --git a/src/types.ts b/src/types.ts index 26c628271..ebf5c4384 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,6 +1,6 @@ import type { Route, RequestParameters } from "@octokit/types"; -import type { RestEndpointMethods } from "./generated/method-types"; +import type { RestEndpointMethods } from "./generated/method-types.js"; export type Api = { rest: RestEndpointMethods }; diff --git a/test/issues.test.ts b/test/issues.test.ts index f0fc6803f..6bb9d2766 100644 --- a/test/issues.test.ts +++ b/test/issues.test.ts @@ -1,7 +1,7 @@ import fetchMock from "fetch-mock"; import { Octokit } from "@octokit/core"; -import { restEndpointMethods } from "../src"; +import { restEndpointMethods } from "../src/index.ts"; describe("https://github.com/octokit/plugin-rest-endpoint-methods.js/issues/83", () => { it("git.gists.update({ gist_id, files })", async () => { diff --git a/test/rest-endpoint-methods.test.ts b/test/rest-endpoint-methods.test.ts index ae9901c27..1d8179b81 100644 --- a/test/rest-endpoint-methods.test.ts +++ b/test/rest-endpoint-methods.test.ts @@ -2,8 +2,11 @@ import { Octokit } from "@octokit/core"; import fetchMock from "fetch-mock"; import sinon from "sinon"; -import { legacyRestEndpointMethods, restEndpointMethods } from "../src"; -import { Api } from "../src/types"; +import { + legacyRestEndpointMethods, + restEndpointMethods, +} from "../src/index.ts"; +import { Api } from "../src/types.ts"; describe("REST API endpoint methods", () => { it("README example", async () => { diff --git a/test/smoke.test.ts b/test/smoke.test.ts index 93aa4ed29..f0516975a 100644 --- a/test/smoke.test.ts +++ b/test/smoke.test.ts @@ -1,4 +1,4 @@ -import { restEndpointMethods } from "../src"; +import { restEndpointMethods } from "../src/index.ts"; describe("Smoke test", () => { it("is a function", () => { diff --git a/test/tsconfig.test.json b/test/tsconfig.test.json index b0961e18c..5e8dc2487 100644 --- a/test/tsconfig.test.json +++ b/test/tsconfig.test.json @@ -3,7 +3,8 @@ "compilerOptions": { "emitDeclarationOnly": false, "noEmit": true, - "verbatimModuleSyntax": false + "verbatimModuleSyntax": false, + "allowImportingTsExtensions": true }, "include": ["src/**/*"] } diff --git a/test/typescript.test.ts b/test/typescript.test.ts index 38b91064e..8430e421f 100644 --- a/test/typescript.test.ts +++ b/test/typescript.test.ts @@ -1,5 +1,5 @@ import { Octokit } from "@octokit/core"; -import { RestEndpointMethodTypes, restEndpointMethods } from "../src"; +import { RestEndpointMethodTypes, restEndpointMethods } from "../src/index.ts"; describe("Smoke test", () => { it("Get parameters type for octokit.rest.issues.updateLabel()", async () => {