Skip to content

Commit

Permalink
update: using @types/gecko from gecko-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
windingwind committed May 6, 2024
1 parent e063415 commit 35c5a06
Show file tree
Hide file tree
Showing 9 changed files with 66,265 additions and 557 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@
"devDependencies": {
"husky": "^9.0.6",
"lint-staged": "^15.2.0",
"octokit": "^3.2.1",
"prettier": "3.2.4",
"release-it": "^17.0.3"
},
"dependencies": {
"@types/bluebird": "^3.5.42",
"@types/react": "17.0.2",
"pdfjs-dist": "~3.8.0",
"epubjs": "^0.3.93"
"epubjs": "^0.3.93",
"pdfjs-dist": "~3.8.0"
},
"publishConfig": {
"access": "public",
Expand Down
46 changes: 46 additions & 0 deletions scripts/updateGecko.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Octokit } from "octokit";
import fs from "fs";
import path from "path";

// Download all files in https://github.com/mozilla/gecko-dev/tree/master/tools/@types to types/gecko

const GITHUB_TOKEN = process.env.GITHUB_TOKEN;

const octokit = new Octokit({ auth: GITHUB_TOKEN });

const owner = "mozilla";
const repo = "gecko-dev";
const dir = "tools/@types";

async function main() {
const { data: files } = await octokit.rest.repos.getContent({
owner,
repo,
path: dir,
});

for (const file of files) {
let { data: fileContent } = await octokit.rest.repos.getContent({
owner,
repo,
path: file.path,
mediaType: {
format: "raw",
},
});

await new Promise((resolve) => setTimeout(resolve, 500));

const filePath = path.join("types/gecko", file.name);
if (file.name === "lib.gecko.dom.d.ts") {
// Remove no-default-lib to avoid conflict with lib.d.ts
fileContent = fileContent.replace(
'/// <reference no-default-lib="true" />',
"",
);
}
fs.writeFileSync(filePath, fileContent, { encoding: "utf-8" });
}
}

main().catch(console.error);
9 changes: 9 additions & 0 deletions types/gecko/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* NOTE: Do not modify this file by hand.
* Run `mach ts update` to reference typelibs generated in <objdir>.
*/

/// <reference types="./lib.gecko.dom.d.ts" />
/// <reference types="./lib.gecko.nsresult.d.ts" />
/// <reference types="./lib.gecko.services.d.ts" />
/// <reference types="./lib.gecko.xpcom.d.ts" />
Loading

0 comments on commit 35c5a06

Please sign in to comment.