From 3c1b1b2d38580f8740eaf1a51212b924db9acb12 Mon Sep 17 00:00:00 2001 From: Mofeng <363034937@qq.com> Date: Sat, 20 Jul 2024 23:19:57 +0800 Subject: [PATCH] Adapt to new DefinitelyTyped layout * No longer needed to prepend header and descriptions --- build/concat.js | 20 +++++++++-------- build/header.txt | 13 ----------- build/prependDescription.js | 18 --------------- build/prependHeader.js | 12 ---------- dist/.npmignore | 5 +++++ dist/index.d.ts | 15 ------------- dist/package.json | 45 +++++++++++++++++++++++++++++++++++++ dist/tsconfig.json | 4 ---- package.json | 3 +-- 9 files changed, 62 insertions(+), 73 deletions(-) delete mode 100644 build/header.txt delete mode 100644 build/prependDescription.js delete mode 100644 build/prependHeader.js create mode 100644 dist/.npmignore create mode 100644 dist/package.json diff --git a/build/concat.js b/build/concat.js index 14d3c67b..ab51a9c7 100644 --- a/build/concat.js +++ b/build/concat.js @@ -1,16 +1,18 @@ const fs = require("fs"); const path = require("path"); -fs.readdir(path.join(__dirname, "..", "src"), function(err, files) { - files = files.map(function(value) { +fs.readdir(path.join(__dirname, "..", "src"), function (err, files) { + files = files.map(function (value) { return path.join("src", value); }); - Promise.all(files.map((name)=>fs.promises.readFile(name))).then( - (fileContents)=>{ - fs.writeFileSync(path.join(__dirname, "..", "dist", "index.d.ts"), - Buffer.concat(fileContents)); - }, (reason)=>{ - console.log(reason); - }); + Promise.all(files.map((name) => fs.promises.readFile(name))) + .then((fileContents) => { + fs.writeFileSync( + path.join(__dirname, "..", "dist", "index.d.ts"), + Buffer.concat(fileContents) + ); + }, (reason) => { + console.log(reason); + }); }); diff --git a/build/header.txt b/build/header.txt deleted file mode 100644 index cc39ff51..00000000 --- a/build/header.txt +++ /dev/null @@ -1,13 +0,0 @@ -// Project: https://github.com/screeps/screeps -// Definitions by: Nhan Ho -// Bryan -// Resi Respati -// Adam Laycock -// Dominic Marcuse -// Skyler Kehren -// Kieran Carnegie -// Mofeng -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 5.5 - -// Please contribute types to https://github.com/screepers/typed-screeps diff --git a/build/prependDescription.js b/build/prependDescription.js deleted file mode 100644 index 3608ffba..00000000 --- a/build/prependDescription.js +++ /dev/null @@ -1,18 +0,0 @@ -const fs = require("fs"); -const path = require("path"); -const prepend = require("prepend"); -const pkg = require("../package.json"); - -const BUILT_FILE_PATH = path.resolve(__dirname, "../dist/index.d.ts"); - -const [major, minor, patch] = pkg.version.split("."); - -const version = `${major}.${minor}.${patch}`; - -var description = `// Type definitions for Screeps ${version}`; - -if (fs.existsSync(BUILT_FILE_PATH)) { - prepend(BUILT_FILE_PATH, description, function(err) { - if (err) console.error(err); - }); -} diff --git a/build/prependHeader.js b/build/prependHeader.js deleted file mode 100644 index 8f2b6b4d..00000000 --- a/build/prependHeader.js +++ /dev/null @@ -1,12 +0,0 @@ -const fs = require("fs"); -const path = require("path"); -const prepend = require("prepend"); - -const BUILT_FILE_PATH = path.resolve(__dirname, "../dist/index.d.ts"); -const HEADER_TEXT = path.resolve(__dirname, "header.txt"); - -if (fs.existsSync(BUILT_FILE_PATH) && fs.existsSync(HEADER_TEXT)) { - prepend(BUILT_FILE_PATH, fs.readFileSync(HEADER_TEXT), function(err) { - if (err) console.error(err); - }); -} diff --git a/dist/.npmignore b/dist/.npmignore new file mode 100644 index 00000000..93e30740 --- /dev/null +++ b/dist/.npmignore @@ -0,0 +1,5 @@ +* +!**/*.d.ts +!**/*.d.cts +!**/*.d.mts +!**/*.d.*.ts diff --git a/dist/index.d.ts b/dist/index.d.ts index 99a8eb76..b6df6084 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1,18 +1,3 @@ -// Type definitions for Screeps 3.3.3 -// Project: https://github.com/screeps/screeps -// Definitions by: Nhan Ho -// Bryan -// Resi Respati -// Adam Laycock -// Dominic Marcuse -// Skyler Kehren -// Kieran Carnegie -// Mofeng -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 5.5 - -// Please contribute types to https://github.com/screepers/typed-screeps - // Game Constants declare const OK: OK; diff --git a/dist/package.json b/dist/package.json new file mode 100644 index 00000000..213904e2 --- /dev/null +++ b/dist/package.json @@ -0,0 +1,45 @@ +{ + "private": true, + "name": "@types/screeps", + "version": "3.3.9999", + "projects": [ + "https://github.com/screeps/screeps" + ], + "devDependencies": { + "@types/screeps": "workspace:." + }, + "owners": [ + { + "name": "Nhan Ho", + "githubUsername": "NhanHo" + }, + { + "name": "Bryan", + "githubUsername": "bryanbecker" + }, + { + "name": "Resi Respati", + "githubUsername": "resir014" + }, + { + "name": "Adam Laycock", + "githubUsername": "Arcath" + }, + { + "name": "Dominic Marcuse", + "githubUsername": "dmarcuse" + }, + { + "name": "Skyler Kehren", + "githubUsername": "pyrodogg" + }, + { + "name": "Kieran Carnegie", + "githubUsername": "kotarou" + }, + { + "name": "Mofeng", + "githubUsername": "DiamondMofeng" + } + ] +} diff --git a/dist/tsconfig.json b/dist/tsconfig.json index 8dcc302c..88b47cea 100644 --- a/dist/tsconfig.json +++ b/dist/tsconfig.json @@ -8,10 +8,6 @@ "noImplicitThis": true, "strictNullChecks": true, "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/package.json b/package.json index 7d6a3f28..2f9ee493 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "dist/index.d.ts" ], "scripts": { - "compile": "node ./build/concat.js && node ./build/prependHeader.js && node ./build/prependDescription.js", + "compile": "node ./build/concat.js", "format": "npm run format:build && npm run format:src", "format:build": "prettier --write 'build/**/*.js'", "format:src": "prettier --write 'src/**/*.ts'", @@ -31,7 +31,6 @@ "eslint-plugin-expect-type": "^0.4.0", "husky": "^7.0.4", "lint-staged": "^12.3.8", - "prepend": "^1.0.2", "prettier": "^2.6.2", "typescript": "^5.5.0", "typescript-eslint": "^7.16.1"