dts-gen 0.7.3 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,51 +1,43 @@
1
1
  {
2
2
  "name": "dts-gen",
3
- "version": "0.7.3",
3
+ "version": "0.8.1",
4
4
  "description": "TypeScript Definition File Generator",
5
- "main": "bin/lib/index.js",
5
+ "author": "Ryan Cavanaugh <ryanca@microsoft.com> (https://www.github.com/RyanCavanaugh)",
6
+ "homepage": "https://github.com/microsoft/DefinitelyTyped-tools/tree/main/packages/typescript-packages#readme",
7
+ "license": "MIT",
8
+ "main": "dist/index.js",
6
9
  "bin": {
7
- "dts-gen": "bin/lib/run.js"
10
+ "dts-gen": "dist/run.js"
11
+ },
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/microsoft/DefinitelyTyped-tools.git",
18
+ "directory": "packages/dts-gen"
19
+ },
20
+ "bugs": {
21
+ "url": "https://github.com/microsoft/DefinitelyTyped-tools/issues"
22
+ },
23
+ "engines": {
24
+ "node": ">=16.17.0"
8
25
  },
9
26
  "dependencies": {
10
- "dts-dom": "latest",
27
+ "dts-dom": "^3.7.0",
11
28
  "parse-git-config": "^1.1.1",
12
- "typescript": "^3.5.1",
29
+ "typescript": "^5.3.3",
13
30
  "yargs": "^4.8.1"
14
31
  },
15
32
  "devDependencies": {
16
- "@types/mocha": "latest",
17
- "@types/node": "latest",
33
+ "@types/node": "^16.18.61",
18
34
  "@types/parse-git-config": "^1.1.0",
19
35
  "@types/yargs": "latest",
20
36
  "ecurve": "1.0.5",
21
- "jquery": "latest",
22
- "lodash": "latest",
23
- "mocha": "^3.0.2",
24
- "react": "latest",
25
- "tslint": "^5.1.0",
26
- "webpack": "^1.13.1"
37
+ "jquery": "3.7.1",
38
+ "lodash": "4.17.21"
27
39
  },
28
40
  "keywords": [
29
41
  "typescript"
30
- ],
31
- "preferGlobal": true,
32
- "scripts": {
33
- "test": "mocha bin/tests/test.js",
34
- "build": "tsc",
35
- "build-browser": "tsc -p browser && webpack",
36
- "lint": "tslint --project tsconfig.json --format stylish"
37
- },
38
- "repository": {
39
- "type": "git",
40
- "url": "git+https://github.com/Microsoft/dts-gen.git"
41
- },
42
- "author": "Ryan Cavanaugh <ryanca@microsoft.com> (https://www.github.com/RyanCavanaugh)",
43
- "license": "Apache-2.0",
44
- "bugs": {
45
- "url": "https://github.com/Microsoft/dts-gen/issues"
46
- },
47
- "homepage": "https://github.com/Microsoft/dts-gen#readme",
48
- "engines": {
49
- "node": ">=6.0.0"
50
- }
51
- }
42
+ ]
43
+ }
@@ -3,21 +3,21 @@
3
3
  *~ template files
4
4
  */
5
5
  declare global {
6
- /*~ Here, declare things that go in the global namespace, or augment
7
- *~ existing declarations in the global namespace
8
- */
9
- interface String {
10
- fancyFormat(opts: StringFormatOptions): string;
11
- }
6
+ /*~ Here, declare things that go in the global namespace, or augment
7
+ *~ existing declarations in the global namespace
8
+ */
9
+ interface String {
10
+ fancyFormat(opts: StringFormatOptions): string;
11
+ }
12
12
  }
13
13
 
14
14
  /*~ If your module exports types or values, write them as usual */
15
15
  export interface StringFormatOptions {
16
- fancinessLevel: number;
16
+ fancinessLevel: number;
17
17
  }
18
18
 
19
19
  /*~ For example, declaring a method on the module (in addition to its global side effects) */
20
20
  export function doSomething(): void;
21
21
 
22
22
  /*~ If your module exports nothing, you'll need this line. Otherwise, delete it */
23
- export { };
23
+ export {};
@@ -3,17 +3,17 @@
3
3
  *~ the built-in number type.
4
4
  */
5
5
  interface Number {
6
- toBinaryString(opts?: MyLibrary.BinaryFormatOptions): string;
7
- toBinaryString(callback: MyLibrary.BinaryFormatCallback, opts?: MyLibrary.BinaryFormatOptions): string;
6
+ toBinaryString(opts?: MyLibrary.BinaryFormatOptions): string;
7
+ toBinaryString(callback: MyLibrary.BinaryFormatCallback, opts?: MyLibrary.BinaryFormatOptions): string;
8
8
  }
9
9
 
10
10
  /*~ If you need to declare several types, place them inside a namespace
11
11
  *~ to avoid adding too many things to the global namespace.
12
12
  */
13
13
  declare namespace MyLibrary {
14
- type BinaryFormatCallback = (n: number) => string;
15
- interface BinaryFormatOptions {
16
- prefix?: string;
17
- padding: number;
18
- }
14
+ type BinaryFormatCallback = (n: number) => string;
15
+ interface BinaryFormatOptions {
16
+ prefix?: string;
17
+ padding: number;
18
+ }
19
19
  }
@@ -13,9 +13,9 @@ declare function myLib(a: number): number;
13
13
  *~ delete this declaration and add types inside the namespace below.
14
14
  */
15
15
  interface myLib {
16
- name: string;
17
- length: number;
18
- extras?: string[];
16
+ name: string;
17
+ length: number;
18
+ extras?: string[];
19
19
  }
20
20
 
21
21
  /*~ If your library has properties exposed on a global variable,
@@ -23,36 +23,36 @@ interface myLib {
23
23
  *~ You should also place types (interfaces and type alias) here.
24
24
  */
25
25
  declare namespace myLib {
26
- //~ We can write 'myLib.timeout = 50;'
27
- let timeout: number;
28
-
29
- //~ We can access 'myLib.version', but not change it
30
- const version: string;
31
-
32
- //~ There's some class we can create via 'let c = new myLib.Cat(42)'
33
- //~ Or reference e.g. 'function f(c: myLib.Cat) { ... }
34
- class Cat {
35
- constructor(n: number);
36
-
37
- //~ We can read 'c.age' from a 'Cat' instance
38
- readonly age: number;
39
-
40
- //~ We can invoke 'c.purr()' from a 'Cat' instance
41
- purr(): void;
42
- }
43
-
44
- //~ We can declare a variable as
45
- //~ 'var s: myLib.CatSettings = { weight: 5, name: "Maru" };'
46
- interface CatSettings {
47
- weight: number;
48
- name: string;
49
- tailLength?: number;
50
- }
51
-
52
- //~ We can write 'const v: myLib.VetID = 42;'
53
- //~ or 'const v: myLib.VetID = "bob";'
54
- type VetID = string | number;
55
-
56
- //~ We can invoke 'myLib.checkCat(c)' or 'myLib.checkCat(c, v);'
57
- function checkCat(c: Cat, s?: VetID);
26
+ //~ We can write 'myLib.timeout = 50;'
27
+ let timeout: number;
28
+
29
+ //~ We can access 'myLib.version', but not change it
30
+ const version: string;
31
+
32
+ //~ There's some class we can create via 'let c = new myLib.Cat(42)'
33
+ //~ Or reference e.g. 'function f(c: myLib.Cat) { ... }
34
+ class Cat {
35
+ constructor(n: number);
36
+
37
+ //~ We can read 'c.age' from a 'Cat' instance
38
+ readonly age: number;
39
+
40
+ //~ We can invoke 'c.purr()' from a 'Cat' instance
41
+ purr(): void;
42
+ }
43
+
44
+ //~ We can declare a variable as
45
+ //~ 'var s: myLib.CatSettings = { weight: 5, name: "Maru" };'
46
+ interface CatSettings {
47
+ weight: number;
48
+ name: string;
49
+ tailLength?: number;
50
+ }
51
+
52
+ //~ We can write 'const v: myLib.VetID = 42;'
53
+ //~ or 'const v: myLib.VetID = "bob";'
54
+ type VetID = string | number;
55
+
56
+ //~ We can invoke 'myLib.checkCat(c)' or 'myLib.checkCat(c, v);'
57
+ function checkCat(c: Cat, s?: VetID);
58
58
  }
@@ -19,19 +19,19 @@ export = MyClass;
19
19
 
20
20
  /*~ Write your module's methods and properties in this class */
21
21
  declare class MyClass {
22
- constructor(someParam?: string);
22
+ constructor(someParam?: string);
23
23
 
24
- someProperty: string[];
24
+ someProperty: string[];
25
25
 
26
- myMethod(opts: MyClass.MyClassMethodOptions): number;
26
+ myMethod(opts: MyClass.MyClassMethodOptions): number;
27
27
  }
28
28
 
29
29
  /*~ If you want to expose types from your module as well, you can
30
30
  *~ place them in this block.
31
31
  */
32
32
  declare namespace MyClass {
33
- export interface MyClassMethodOptions {
34
- width?: number;
35
- height?: number;
36
- }
33
+ export interface MyClassMethodOptions {
34
+ width?: number;
35
+ height?: number;
36
+ }
37
37
  }
@@ -27,20 +27,20 @@ declare function MyFunction(length: number): MyFunction.LengthReturnType;
27
27
  *~ be declared in here, as this example shows.
28
28
  */
29
29
  declare namespace MyFunction {
30
- export interface LengthReturnType {
31
- width: number;
32
- height: number;
33
- }
34
- export interface NamedReturnType {
35
- firstName: string;
36
- lastName: string;
37
- }
30
+ export interface LengthReturnType {
31
+ width: number;
32
+ height: number;
33
+ }
34
+ export interface NamedReturnType {
35
+ firstName: string;
36
+ lastName: string;
37
+ }
38
38
 
39
- /*~ If the module also has properties, declare them here. For example,
40
- *~ this declaration says that this code is legal:
41
- *~ import f = require('myFuncLibrary');
42
- *~ console.log(f.defaultName);
43
- */
44
- export const defaultName: string;
45
- export let defaultLength: number;
39
+ /*~ If the module also has properties, declare them here. For example,
40
+ *~ this declaration says that this code is legal:
41
+ *~ import f = require('myFuncLibrary');
42
+ *~ console.log(f.defaultName);
43
+ */
44
+ export const defaultName: string;
45
+ export let defaultLength: number;
46
46
  }
@@ -1,24 +1,24 @@
1
1
  /*~ On this line, import the module which this module adds to */
2
- import * as m from 'someModule';
2
+ import * as m from "someModule";
3
3
 
4
4
  /*~ You can also import other modules if needed */
5
- import * as other from 'anotherModule';
5
+ import * as other from "anotherModule";
6
6
 
7
7
  /*~ Here, declare the same module as the one you imported above */
8
- declare module 'someModule' {
9
- /*~ Inside, add new function, classes, or variables. You can use
10
- *~ unexported types from the original module if needed. */
11
- export function theNewMethod(x: m.foo): other.bar;
8
+ declare module "someModule" {
9
+ /*~ Inside, add new function, classes, or variables. You can use
10
+ *~ unexported types from the original module if needed. */
11
+ export function theNewMethod(x: m.foo): other.bar;
12
12
 
13
- /*~ You can also add new properties to existing interfaces from
14
- *~ the original module by writing interface augmentations */
15
- export interface SomeModuleOptions {
16
- someModuleSetting?: string;
17
- }
13
+ /*~ You can also add new properties to existing interfaces from
14
+ *~ the original module by writing interface augmentations */
15
+ export interface SomeModuleOptions {
16
+ someModuleSetting?: string;
17
+ }
18
18
 
19
- /*~ New types can also be declared and will appear as if they
20
- *~ are in the original module */
21
- export interface MyModulePluginOptions {
22
- size: number;
23
- }
24
- }
19
+ /*~ New types can also be declared and will appear as if they
20
+ *~ are in the original module */
21
+ export interface MyModulePluginOptions {
22
+ size: number;
23
+ }
24
+ }
@@ -11,9 +11,9 @@ export function myOtherMethod(a: number): number;
11
11
 
12
12
  /*~ You can declare types that are available via importing the module */
13
13
  export interface someType {
14
- name: string;
15
- length: number;
16
- extras?: string[];
14
+ name: string;
15
+ length: number;
16
+ extras?: string[];
17
17
  }
18
18
 
19
19
  /*~ You can declare properties of the module using const, let, or var */
@@ -23,12 +23,12 @@ export const myField: number;
23
23
  *~ of the module, declare them inside a 'namespace'.
24
24
  */
25
25
  export namespace subProp {
26
- /*~ For example, given this definition, someone could write:
27
- *~ import { subProp } from 'yourModule';
28
- *~ subProp.foo();
29
- *~ or
30
- *~ import * as yourMod from 'yourModule';
31
- *~ yourMod.subProp.foo();
32
- */
33
- function foo(): void;
26
+ /*~ For example, given this definition, someone could write:
27
+ *~ import { subProp } from 'yourModule';
28
+ *~ subProp.foo();
29
+ *~ or
30
+ *~ import * as yourMod from 'yourModule';
31
+ *~ yourMod.subProp.foo();
32
+ */
33
+ function foo(): void;
34
34
  }
package/SECURITY.md DELETED
@@ -1,41 +0,0 @@
1
- <!-- BEGIN MICROSOFT SECURITY.MD V0.0.7 BLOCK -->
2
-
3
- ## Security
4
-
5
- Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
6
-
7
- If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below.
8
-
9
- ## Reporting Security Issues
10
-
11
- **Please do not report security vulnerabilities through public GitHub issues.**
12
-
13
- Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report).
14
-
15
- If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).
16
-
17
- You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc).
18
-
19
- Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
20
-
21
- * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
22
- * Full paths of source file(s) related to the manifestation of the issue
23
- * The location of the affected source code (tag/branch/commit or direct URL)
24
- * Any special configuration required to reproduce the issue
25
- * Step-by-step instructions to reproduce the issue
26
- * Proof-of-concept or exploit code (if possible)
27
- * Impact of the issue, including how an attacker might exploit the issue
28
-
29
- This information will help us triage your report more quickly.
30
-
31
- If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs.
32
-
33
- ## Preferred Languages
34
-
35
- We prefer all communications to be in English.
36
-
37
- ## Policy
38
-
39
- Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd).
40
-
41
- <!-- END MICROSOFT SECURITY.MD BLOCK -->
@@ -1,145 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const fs_1 = require("fs");
13
- const http_1 = require("http");
14
- const https_1 = require("https");
15
- const os_1 = require("os");
16
- const parseGitConfig = require("parse-git-config");
17
- const path_1 = require("path");
18
- const url_1 = require("url");
19
- const names_1 = require("./names");
20
- function writeDefinitelyTypedPackage(indexDtsContent, packageName, overwrite) {
21
- const dtName = (0, names_1.getDTName)(packageName);
22
- const packageDir = (0, path_1.join)("types", dtName);
23
- // Check for overwrite
24
- if (!overwrite) {
25
- if ((0, fs_1.existsSync)(packageDir)) {
26
- console.log(`Directory ${packageDir} already exists and --overwrite was not specified; exiting.`);
27
- process.exit(2);
28
- }
29
- }
30
- if (!(0, fs_1.existsSync)(packageDir)) {
31
- (0, fs_1.mkdirSync)(packageDir);
32
- }
33
- run(indexDtsContent, packageName, dtName, packageDir).catch(e => {
34
- console.error(e);
35
- process.exit(1);
36
- });
37
- }
38
- exports.default = writeDefinitelyTypedPackage;
39
- function run(indexDtsContent, packageName, dtName, packageDir) {
40
- return __awaiter(this, void 0, void 0, function* () {
41
- const files = [
42
- ["index.d.ts", indexDtsContent],
43
- [`${dtName}-tests.ts`, ""],
44
- ["tsconfig.json", `${JSON.stringify(getTSConfig(dtName), undefined, 4)}\n`],
45
- ["package.json", `${JSON.stringify(yield getPackageJson(dtName, packageName), undefined, 4)}\n`],
46
- ["tslint.json", '{ "extends": "@definitelytyped/dtslint/dt.json" }\n'],
47
- [".npmignore", ["*", "!**/*.d.ts", "!**/*.d.cts", "!**/*.d.mts", "!**/*.d.*.ts"].join('\n') + '\n'],
48
- ];
49
- for (const [name, text] of files) {
50
- (0, fs_1.writeFileSync)((0, path_1.join)(packageDir, name), text, "utf-8");
51
- }
52
- });
53
- }
54
- function getTSConfig(dtName) {
55
- return {
56
- compilerOptions: {
57
- module: "commonjs",
58
- lib: ["es6"],
59
- noImplicitAny: true,
60
- noImplicitThis: true,
61
- strictFunctionTypes: true,
62
- strictNullChecks: true,
63
- types: [],
64
- noEmit: true,
65
- forceConsistentCasingInFileNames: true,
66
- },
67
- files: [
68
- "index.d.ts",
69
- `${dtName}-tests.ts`,
70
- ],
71
- };
72
- }
73
- function getPackageJson(dtName, packageName) {
74
- var _a, _b, _c;
75
- return __awaiter(this, void 0, void 0, function* () {
76
- let version = "x.x";
77
- let project = "https://github.com/baz/foo " +
78
- "(Does not have to be to GitHub, " +
79
- "but prefer linking to a source code repository rather than to a project website.)";
80
- try {
81
- const reg = JSON.parse(yield loadString(`https://registry.npmjs.org/${packageName}`));
82
- const { latest } = reg["dist-tags"];
83
- const { homepage } = reg.versions[latest];
84
- version = latest.split(".").slice(0, 2).join("."); // Just major.minor
85
- if (homepage !== undefined)
86
- project = homepage;
87
- }
88
- catch (e) {
89
- console.warn(`Warning: Could not retrieve version/homepage information: ${e.message}`);
90
- }
91
- let authorName = 'My Self';
92
- try {
93
- const globalGitConfig = parseGitConfig.sync({ cwd: (0, os_1.homedir)(), path: '.gitconfig' });
94
- if (globalGitConfig.user && globalGitConfig.user.name) {
95
- authorName = globalGitConfig.user.name;
96
- }
97
- }
98
- catch (e) {
99
- console.warn(`Warning: Could not retrieve author name: ${e.message}`);
100
- }
101
- let authorUserName = 'me';
102
- try {
103
- const repoGitConfig = parseGitConfig.sync({ path: (0, path_1.join)('.git', 'config') });
104
- if (repoGitConfig['remote "origin"'] && repoGitConfig['remote "origin"'].url) {
105
- const url = (0, url_1.parse)(repoGitConfig['remote "origin"'].url);
106
- if (url.hostname === 'github.com' && url.pathname) {
107
- authorUserName = url.pathname.split('/')[1] || authorUserName;
108
- }
109
- else if ((_a = url.pathname) === null || _a === void 0 ? void 0 : _a.startsWith('git@github.com')) {
110
- authorUserName = ((_c = (_b = url.pathname.split(':')) === null || _b === void 0 ? void 0 : _b[1].split('/')) === null || _c === void 0 ? void 0 : _c[0]) || authorUserName;
111
- }
112
- }
113
- }
114
- catch (e) {
115
- console.warn(`Warning: Could not retrieve author's user name: ${e.message}`);
116
- }
117
- return {
118
- private: true,
119
- name: `@types/${dtName}`,
120
- version: `${version}.0.9999`,
121
- projects: [project],
122
- devDependencies: {
123
- [`@types/${dtName}`]: "workspace:."
124
- },
125
- owners: [
126
- {
127
- name: authorName,
128
- githubUsername: authorUserName
129
- }
130
- ]
131
- };
132
- });
133
- }
134
- function loadString(url) {
135
- return new Promise((resolve, reject) => {
136
- (0, https_1.get)(url, res => {
137
- if (res.statusCode !== 200) {
138
- return reject(new Error(`HTTP Error ${res.statusCode}: ${http_1.STATUS_CODES[res.statusCode || 500]} for ${url}`));
139
- }
140
- let rawData = "";
141
- res.on("data", (chunk) => rawData += chunk);
142
- res.on("end", () => resolve(rawData));
143
- }).on("error", (e) => reject(e));
144
- });
145
- }