Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: octokit/request-error.js
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.0.0
Choose a base ref
...
head repository: octokit/request-error.js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.0.1
Choose a head ref
  • 1 commit
  • 6 files changed
  • 1 contributor

Commits on Jun 2, 2023

  1. Verified

    This commit was signed with the committer’s verified signature.
    Copy the full SHA
    5ff96da View commit details
Showing with 4,252 additions and 7,843 deletions.
  1. +4,151 −7,813 package-lock.json
  2. +4 −23 package.json
  3. +89 −0 scripts/build.mjs
  4. +2 −2 src/index.ts
  5. +1 −1 src/types.ts
  6. +5 −4 tsconfig.json
11,964 changes: 4,151 additions & 7,813 deletions package-lock.json

Large diffs are not rendered by default.

27 changes: 4 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
},
"description": "Error class for Octokit request errors",
"scripts": {
"build": "pika-pack build",
"build": "node scripts/build.mjs && tsc -p tsconfig.json",
"lint": "prettier --check '{src,test}/**/*' README.md package.json",
"lint:fix": "prettier --write '{src,test}/**/*' README.md package.json",
"pretest": "npm run -s lint",
@@ -27,16 +27,13 @@
"once": "^1.4.0"
},
"devDependencies": {
"@pika/pack": "^0.3.7",
"@pika/plugin-build-node": "^0.9.0",
"@pika/plugin-build-web": "^0.9.0",
"@pika/plugin-bundle-web": "^0.9.0",
"@pika/plugin-ts-standard-pkg": "^0.9.0",
"@octokit/tsconfig": "^1.0.2",
"@types/jest": "^29.0.0",
"@types/node": "^18.0.0",
"@types/once": "^1.4.0",
"esbuild": "^0.17.19",
"glob": "^10.2.6",
"jest": "^29.0.0",
"pika-plugin-unpkg-field": "^1.1.0",
"prettier": "2.8.8",
"ts-jest": "^29.0.0",
"typescript": "^5.0.0"
@@ -52,22 +49,6 @@
}
}
},
"@pika/pack": {
"pipeline": [
[
"@pika/plugin-ts-standard-pkg"
],
[
"@pika/plugin-build-node",
{
"minNodeVersion": 18
}
],
[
"@pika/plugin-build-web"
]
]
},
"release": {
"branches": [
"+([0-9]).x",
89 changes: 89 additions & 0 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import esbuild from "esbuild";
import { copyFile, readFile, writeFile, rm } from "node:fs/promises";
import { glob } from "glob";

const sharedOptions = {
sourcemap: "external",
sourcesContent: true,
minify: false,
allowOverwrite: true,
packages: "external",
};

async function main() {
// Start with a clean slate
await rm("pkg", { recursive: true, force: true });
// Build the source code for a neutral platform as ESM
await esbuild.build({
entryPoints: await glob(["./src/*.ts", "./src/**/*.ts"]),
outdir: "pkg/dist-src",
bundle: false,
platform: "neutral",
format: "esm",
...sharedOptions,
sourcemap: false,
});

// Remove the types file from the dist-src folder
const typeFiles = await glob([
"./pkg/dist-src/**/types.js.map",
"./pkg/dist-src/**/types.js",
]);
for (const typeFile of typeFiles) {
await rm(typeFile);
}

const entryPoints = ["./pkg/dist-src/index.js"];

await Promise.all([
// Build the a CJS Node.js bundle
esbuild.build({
entryPoints,
outdir: "pkg/dist-node",
bundle: true,
platform: "node",
target: "node18",
format: "cjs",
...sharedOptions,
}),
// Build an ESM browser bundle
esbuild.build({
entryPoints,
outdir: "pkg/dist-web",
bundle: true,
platform: "browser",
format: "esm",
...sharedOptions,
}),
]);

// Copy the README, LICENSE to the pkg folder
await copyFile("LICENSE", "pkg/LICENSE");
await copyFile("README.md", "pkg/README.md");

// Handle the package.json
let pkg = JSON.parse((await readFile("package.json", "utf8")).toString());
// Remove unnecessary fields from the package.json
delete pkg.scripts;
delete pkg.prettier;
delete pkg.release;
delete pkg.jest;
await writeFile(
"pkg/package.json",
JSON.stringify(
{
...pkg,
files: ["dist-*/**", "bin/**"],
main: "dist-node/index.js",
browser: "dist-web/index.js",
types: "dist-types/index.d.ts",
module: "dist-src/index.js",
sideEffects: false,
unpkg: "dist-web/index.js",
},
null,
2
)
);
}
main();
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -3,12 +3,12 @@ import once from "once";
const logOnceCode = once((deprecation: any) => console.warn(deprecation));
const logOnceHeaders = once((deprecation: any) => console.warn(deprecation));

import {
import type {
RequestOptions,
ResponseHeaders,
OctokitResponse,
} from "@octokit/types";
import { RequestErrorOptions } from "./types";
import type { RequestErrorOptions } from "./types";

/**
* Error with extra properties to help with debugging
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
RequestOptions,
ResponseHeaders,
OctokitResponse,
9 changes: 5 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"extends": "@octokit/tsconfig",
"compilerOptions": {
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"target": "es2018"
"declaration": true,
"outDir": "pkg/dist-types",
"emitDeclarationOnly": true,
"sourceMap": true
},
"include": ["src/**/*"]
}