Skip to content

Commit

Permalink
build: update scripts to ESM, cleanup deps (#681)
Browse files Browse the repository at this point in the history
* build: remove obsolete script

* build: convert scripts to ESM

* build: update scripts to use new file names

* build: lint scripts

* build(deps): remove unused dependency

* build: upgrade `sort-keys` to v5

* build(deps): use `@gr2m/fetch-mock`

* build(deps): remove `fs-extra`

* build: update `package-lock.json`

* style: prettier
  • Loading branch information
wolfy1339 authored Oct 2, 2023
1 parent 15fff46 commit 82a26ac
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 159 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ jobs:
cache: npm
- run: npm ci
- run: npm run build
- name: "Fix pkg.files file pattern"
run: node scripts/fix-package-json.js
- run: npx semantic-release --debug
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
118 changes: 39 additions & 79 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 8 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
"description": "Octokit plugin adding one method for all of api.github.com REST API endpoints",
"scripts": {
"build": "node scripts/build.mjs && tsc -p tsconfig.json",
"lint": "prettier --check '{src,test}/**/*' '!src/generated/**' README.md package.json",
"lint:fix": "prettier --write '{src,test}/**/*' '!src/generated/**' README.md package.json",
"lint": "prettier --check '{src,test,scripts}/**/*' '!scripts/update-endpoints/generated/**' '!src/generated/**' README.md package.json",
"lint:fix": "prettier --write '{src,test,scripts}/**/*' '!scripts/update-endpoints/generated/**' '!src/generated/**' README.md package.json",
"pretest": "npm run -s lint",
"test": "jest --coverage",
"update-endpoints": "npm-run-all update-endpoints:*",
"update-endpoints:fetch-json": "node scripts/update-endpoints/fetch-json",
"update-endpoints:code": "node scripts/update-endpoints/code",
"update-endpoints:docs": "node scripts/update-endpoints/docs",
"update-endpoints:types": "node scripts/update-endpoints/types"
"update-endpoints:fetch-json": "node scripts/update-endpoints/fetch-json.mjs",
"update-endpoints:code": "node scripts/update-endpoints/code.mjs",
"update-endpoints:docs": "node scripts/update-endpoints/docs.mjs",
"update-endpoints:types": "node scripts/update-endpoints/types.mjs"
},
"repository": "github:octokit/plugin-rest-endpoint-methods.js",
"keywords": [
Expand All @@ -27,15 +27,13 @@
"@octokit/types": "^12.0.0"
},
"devDependencies": {
"@gimenete/type-writer": "^0.1.5",
"@octokit/core": "^5.0.0",
"@octokit/tsconfig": "^2.0.0",
"@types/fetch-mock": "^7.3.1",
"@types/jest": "^29.0.0",
"@types/node": "^18.0.0",
"esbuild": "^0.19.0",
"fetch-mock": "^9.0.0",
"fs-extra": "^11.0.0",
"fetch-mock": "npm:@gr2m/fetch-mock@^9.11.0-pull-request-644.1",
"github-openapi-graphql-query": "^4.0.0",
"glob": "^10.2.6",
"jest": "^29.0.0",
Expand All @@ -46,7 +44,7 @@
"npm-run-all": "^4.1.5",
"prettier": "3.0.3",
"semantic-release-plugin-update-version-in-files": "^1.0.0",
"sort-keys": "^4.2.0",
"sort-keys": "^5.0.0",
"string-to-jsdoc-comment": "^1.0.0",
"ts-jest": "^29.0.0",
"typescript": "^5.0.0"
Expand Down
4 changes: 2 additions & 2 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ async function main() {
sideEffects: false,
},
null,
2
)
2,
),
);
}
main();
15 changes: 0 additions & 15 deletions scripts/fix-package-json.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
const { writeFileSync } = require("fs");
const { join } = require("path");
import { readFileSync, writeFileSync } from "fs";
import { join } from "path";
import { fileURLToPath } from "url";

const prettier = require("prettier");
const sortKeys = require("sort-keys");
import { format } from "prettier";
import sortKeys from "sort-keys";

const ENDPOINTS = require("./generated/endpoints.json");
const { isDeprecated } = require("./util");
const parentDir = new URL(".", import.meta.url);
const ENDPOINTS = JSON.parse(
readFileSync(new URL("generated/endpoints.json", parentDir)).toString(),
);
import { isDeprecated } from "./util.mjs";

const ROUTES_PATH = join(
__dirname,
fileURLToPath(parentDir),
"..",
"..",
"src",
"generated",
"endpoints.ts"
"endpoints.ts",
);

const newRoutes = {};
Expand Down Expand Up @@ -84,7 +88,7 @@ async function generateRoutes() {
}

const renamedParameters = endpoint.parameters.filter(
(parameter) => !!parameter.alias
(parameter) => !!parameter.alias,
);

if (renamedParameters.length) {
Expand Down Expand Up @@ -118,15 +122,15 @@ async function generateRoutes() {

writeFileSync(
ROUTES_PATH,
await prettier.format(
await format(
`import type { EndpointsDefaultsAndDecorations } from "../types";
const Endpoints: EndpointsDefaultsAndDecorations = ${JSON.stringify(
sortKeys(newRoutes, { deep: true })
sortKeys(newRoutes, { deep: true }),
)}
export default Endpoints`,
{ parser: "typescript" }
)
{ parser: "typescript" },
),
);
console.log(`${ROUTES_PATH} written.`);
}
Loading

0 comments on commit 82a26ac

Please sign in to comment.