diff --git a/.gitignore b/.gitignore index 94299767d9..a78522ea9b 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ _infrastructure/tests/build *.iml *.js.map !*.js/ +!scripts/new-package.js node_modules diff --git a/scripts/new-package.js b/scripts/new-package.js new file mode 100644 index 0000000000..5a9690b43c --- /dev/null +++ b/scripts/new-package.js @@ -0,0 +1,41 @@ +/// +"use strict"; +const fs_1 = require("fs"); +const path = require("path"); +const newPackageName = process.argv[2]; +if (!newPackageName) { + throw new Error("Usage: node scripts/new-package.js new-package-name"); +} +fs_1.mkdirSync(newPackageName); +write("index.d.ts", `// Type definitions for ${newPackageName} 1.2 +// Project: https://github.com/baz/foo (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.) +// Definitions by: My Self +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +Fill the header in! +`); +const testsFile = `${newPackageName}-tests.ts`; +write(testsFile, ""); +const tsconfig = { + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + `${newPackageName}-tests.ts` + ] +}; +write("tsconfig.json", JSON.stringify(tsconfig, undefined, 4)); +function write(name, content) { + fs_1.writeFileSync(path.join(newPackageName, name), content); +}