diff --git a/.gitignore b/.gitignore index ce5d4a9d8c..c2773bb5ad 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ _infrastructure/tests/build *.js.map !*.js/ !scripts/new-package.js +!scripts/not-needed.js !scripts/lint.js node_modules diff --git a/README.md b/README.md index bd97c5b22b..eff14514d0 100644 --- a/README.md +++ b/README.md @@ -143,15 +143,14 @@ For a good example package, see [base64-js](https://github.com/DefinitelyTyped/D #### Removing a package When a package [bundles](http://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html) its own types, types should be removed from DefinitelyTyped to avoid confusion. -Make a PR doing the following: -* Delete the directory. -* Add a new entry to `notNeededPackages.json`. - - `libraryName`: Descriptive name of the library, e.g. "Angular 2" instead of "angular2". (May be identical to "typingsPackageName".) - - `typingsPackageName`: This is the name of the directory you just deleted. - - `sourceRepoURL`: This should point to the repository that contains the typings. - - `asOfVersion`: A stub will be published to `@types/foo` with this version. Should be higher than any currently published version. -* Any other packages in DefinitelyTyped that referenced the deleted package should be updated to reference the bundled types. - To do this, add a `package.json` with `"dependencies": { "foo": "x.y.z" }`. + +You can remove it by running `npm run not-needed -- typingsPackageName asOfVersion sourceRepoURL [libraryName]`. +- `typingsPackageName`: This is the name of the directory to delete. +- `asOfVersion`: A stub will be published to `@types/foo` with this version. Should be higher than any currently published version. +- `sourceRepoURL`: This should point to the repository that contains the typings. +- `libraryName`: Descriptive name of the library, e.g. "Angular 2" instead of "angular2". (If ommitted, will be identical to "typingsPackageName".) + +Any other packages in DefinitelyTyped that referenced the deleted package should be updated to reference the bundled types. To do this, add a `package.json` with `"dependencies": { "foo": "x.y.z" }`. If a package was never on DefinitelyTyped, it does not need to be added to `notNeededPackages.json`. diff --git a/package.json b/package.json index f8d482c4b8..a9b9625069 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "scripts": { "compile-scripts": "tsc -p scripts", "new-package": "node scripts/new-package.js", + "not-needed": "node scripts/not-needed.js", "lint": "node scripts/lint.js", "test": "node node_modules/types-publisher/bin/tester/test.js --run-from-definitely-typed --nProcesses 1" }, diff --git a/scripts/not-needed.js b/scripts/not-needed.js new file mode 100644 index 0000000000..f5b5cc8e6a --- /dev/null +++ b/scripts/not-needed.js @@ -0,0 +1,30 @@ +// Script to remove a package from DefinitelyTyped and add it to notNeededPackages.json + +const fs = require("fs"); +const path = require("path"); + +const typingsPackageName = process.argv[2]; +const asOfVersion = process.argv[3]; +const sourceRepoURL = process.argv[4]; +const libraryName = process.argv[5] || typingsPackageName; + +if (process.argv.length !== 5 && process.argv.length !== 6) { + console.log("Usage: npm run not-needed -- typingsPackageName asOfVersion sourceRepoURL [libraryName]"); + process.exit(1); +} + +rmdirRecursive(typingsPackageName); +const notNeededPackages = JSON.parse(fs.readFileSync("notNeededPackages.json", "utf-8")); +notNeededPackages.packages.push({ libraryName, typingsPackageName, sourceRepoURL, asOfVersion }); +fs.writeFileSync("notNeededPackages.json", JSON.stringify(notNeededPackages, undefined, 4), "utf-8"); + +function rmdirRecursive(dir) { + for (let entry of fs.readdirSync(dir)) { + entry = path.join(dir, entry) + if (fs.statSync(entry).isDirectory()) + rmdirRecursive(entry); + else + fs.unlinkSync(entry); + } + fs.rmdirSync(dir); +}