mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add script to remove a package
This commit is contained in:
parent
1cf9dfb2aa
commit
c325f55b5c
1
.gitignore
vendored
1
.gitignore
vendored
@ -31,6 +31,7 @@ _infrastructure/tests/build
|
||||
*.js.map
|
||||
!*.js/
|
||||
!scripts/new-package.js
|
||||
!scripts/not-needed.js
|
||||
!scripts/lint.js
|
||||
|
||||
node_modules
|
||||
|
||||
17
README.md
17
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`.
|
||||
|
||||
|
||||
@ -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"
|
||||
},
|
||||
|
||||
30
scripts/not-needed.js
Normal file
30
scripts/not-needed.js
Normal file
@ -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);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user