Skip to content

Update Node.js, TypeScript, drop ts-node dependency #82

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ module.exports = {
files: ["*.ts", "*.tsx"],
excludedFiles: ["*.d.ts"],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint/eslint-plugin"],
parserOptions: {
project: "./tsconfig.json",
project: ["./tsconfig.json", "./scripts/tsconfig.json"],
},
plugins: ["@typescript-eslint/eslint-plugin"],
rules: {
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-tslint-comment": "error",
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "22"

- name: Enable Corepack
run: corepack enable
Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "22"

- name: Enable Corepack
run: corepack enable
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "22"

- name: Enable Corepack
run: corepack enable
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "22"

- name: Enable Corepack
run: corepack enable
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-history.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "22"

- name: Enable Corepack
run: corepack enable
Expand Down
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"postinstall": "husky install",
"prettier": "prettier --check .",
"prettier:fix": "prettier --write .",
"fetch-wayback-machine-history": "node --loader=ts-node/esm ./scripts/fetchWaybackMachineHistory.js",
"generate-assets": "node --loader=ts-node/esm ./scripts/generateAssets.js",
"update-history": "node --loader=ts-node/esm ./scripts/updateHistory.js",
"tsc": "tsc --noEmit",
"fetch-wayback-machine-history": "node --experimental-strip-types ./scripts/fetchWaybackMachineHistory.ts",
"generate-assets": "node --experimental-strip-types ./scripts/generateAssets.ts",
"update-history": "node --experimental-strip-types ./scripts/updateHistory.ts",
"tsc": "tsc --noEmit && cd ./scripts && tsc --noEmit",
"test": "yarn lint && yarn prettier && yarn tsc"
},
"dependencies": {
Expand Down Expand Up @@ -59,8 +59,7 @@
"lint-staged": "^14.0.0",
"prettier": "^2.0.0",
"sass": "^1.45.2",
"ts-node": "^10.9.0",
"typescript": "^4.1.2",
"typescript": "^5.8.3",
"vite": "^4.4.0"
},
"packageManager": "[email protected]"
Expand Down
4 changes: 2 additions & 2 deletions scripts/fetchWaybackMachineHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import path from "path";

import { promises as fs } from "fs";

import createAxiosInstance from "./helper/createAxiosInstance.js";
import { PackageIdentifier, packages } from "../src/PackageDescription.js";
import createAxiosInstance from "./helper/createAxiosInstance.ts";
import { packages, type PackageIdentifier } from "../src/PackageDescription.ts";

type WaybackMachineStats = {
archived_snapshots?: {
Expand Down
4 changes: 2 additions & 2 deletions scripts/generateAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import { promises as fs } from "fs";

import createAxiosInstance from "./helper/createAxiosInstance.js";
import { PackageIdentifier, packages } from "../src/PackageDescription.js";
import createAxiosInstance from "./helper/createAxiosInstance.ts";
import { packages, type PackageIdentifier } from "../src/PackageDescription.ts";

type VersionIndex = string;

Expand Down Expand Up @@ -111,7 +111,7 @@
versionCounts: {},
};

if (keyedPoints[keyedPoints.length - 1]?.date == newPoint.date) {

Check warning on line 114 in scripts/generateAssets.ts

View workflow job for this annotation

GitHub Actions / Static code analysis

Expected '===' and instead saw '=='
keyedPoints.pop();
}

Expand Down
18 changes: 12 additions & 6 deletions scripts/helper/createAxiosInstance.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import axios from "axios";
import axios, { type AxiosStatic } from "axios";
import rateLimit, {
RateLimitedAxiosInstance,
rateLimitOptions as RateLimitOptions,
type RateLimitedAxiosInstance,
type rateLimitOptions as RateLimitOptions,
} from "axios-rate-limit";
import axiosRetry, {
isNetworkOrIdempotentRequestError,
IAxiosRetryConfig,
type IAxiosRetryConfig,
} from "axios-retry";

/**
Expand Down Expand Up @@ -36,11 +36,17 @@ export default function createAxiosInstance(): RateLimitedAxiosInstance {
maxRPS: 2,
};

const axiosClient = axios.create();
// @FIXME: Legacy version of axios does not play well with verbatim types
const axiosClient = (axios as unknown as AxiosStatic).create();

axiosClient.defaults.headers.common["User-Agent"] =
"React Native Version Tracker";

axiosRetry(axiosClient, axiosRetryConfig);
return rateLimit(axiosClient, axiosRateLimitOptions);

// @FIXME: Legacy version of axios-rate-limit does not play well with verbatim types
return (rateLimit as unknown as typeof import("axios-rate-limit").default)(
axiosClient,
axiosRateLimitOptions
);
}
7 changes: 5 additions & 2 deletions scripts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"allowImportingTsExtensions": true,
"lib": ["esnext"],
"module": "nodenext",
"moduleResolution": "nodenext",
"target": "esnext"
}
"target": "esnext",
"verbatimModuleSyntax": true
},
"exclude": []
}
6 changes: 3 additions & 3 deletions scripts/updateHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import semver from "semver";

import { promises as fs } from "fs";

import createAxiosInstance from "./helper/createAxiosInstance.js";
import { PackageIdentifier, packages } from "../src/PackageDescription.js";
import createAxiosInstance from "./helper/createAxiosInstance.ts";
import { packages, type PackageIdentifier } from "../src/PackageDescription.ts";

type NpmApiStats = {
package: string;
Expand Down Expand Up @@ -55,7 +55,7 @@ const axiosInstance = createAxiosInstance();
}
}

await import("./generateAssets.js");
await import("./generateAssets.ts");
})();

/**
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"strictNullChecks": true,
"target": "esnext"
},
"exclude": ["build"]
"exclude": ["build", "scripts"]
}
Loading