@ts-type/package-dts 2.0.8 → 3.0.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/CHANGELOG.md +27 -0
- package/README.md +39 -14
- package/eslintrc-json.js +1 -1
- package/eslintrc-json.js.map +1 -1
- package/index.d.ts +17 -1
- package/index.js +18 -3
- package/index.js.map +1 -1
- package/lerna-json.js +2 -15
- package/lerna-json.js.map +1 -1
- package/lib/package-json/exports.js.map +1 -1
- package/lib/package-json/publishConfig.js +1 -1
- package/lib/package-json/publishConfig.js.map +1 -1
- package/lib/package-json/types.d.ts +28 -0
- package/lib/package-json/types.js +14 -2
- package/lib/package-json/types.js.map +1 -1
- package/package-json.d.ts +1 -1
- package/package-json.js +2 -15
- package/package-json.js.map +1 -1
- package/package.json +10 -4
- package/schema/eslintrc.json +29 -17
- package/schema/lerna.json +1 -1
- package/schema/package.json +530 -28
- package/schema/travis.json +17 -10
- package/script/index.js +2 -4
- package/script/index.js.map +1 -1
- package/script/util.js +7 -10
- package/script/util.js.map +1 -1
- package/types/eslintrc.json.d.ts +7496 -9
- package/types/lerna.json.d.ts +1 -1
- package/types/package.json.d.ts +27813 -7682
- package/types/travis.json.d.ts +15 -10
- package/types/tsconfig.json.d.ts +1298 -326
package/schema/travis.json
CHANGED
|
@@ -204,7 +204,7 @@
|
|
|
204
204
|
},
|
|
205
205
|
"fast_finish": {
|
|
206
206
|
"type": "boolean",
|
|
207
|
-
"description": "If some rows in the build matrix are allowed to fail, the build won
|
|
207
|
+
"description": "If some rows in the build matrix are allowed to fail, the build won't be marked as finished until they have completed. To mark the build as finished as soon as possible, add fast_finish: true"
|
|
208
208
|
}
|
|
209
209
|
},
|
|
210
210
|
"additionalProperties": false
|
|
@@ -261,7 +261,7 @@
|
|
|
261
261
|
},
|
|
262
262
|
"fast_finish": {
|
|
263
263
|
"type": "boolean",
|
|
264
|
-
"description": "If some rows in the build matrix are allowed to fail, the build won
|
|
264
|
+
"description": "If some rows in the build matrix are allowed to fail, the build won't be marked as finished until they have completed. To mark the build as finished as soon as possible, add fast_finish: true"
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
267
|
},
|
|
@@ -545,7 +545,10 @@
|
|
|
545
545
|
"xcode13.1",
|
|
546
546
|
"xcode13.2",
|
|
547
547
|
"xcode13.3",
|
|
548
|
-
"xcode13.4"
|
|
548
|
+
"xcode13.4",
|
|
549
|
+
"xcode14",
|
|
550
|
+
"xcode14.1",
|
|
551
|
+
"xcode14.2"
|
|
549
552
|
]
|
|
550
553
|
},
|
|
551
554
|
"envVars": {
|
|
@@ -1020,6 +1023,7 @@
|
|
|
1020
1023
|
"enum": [
|
|
1021
1024
|
"osx",
|
|
1022
1025
|
"linux",
|
|
1026
|
+
"linux-ppc64le",
|
|
1023
1027
|
"windows"
|
|
1024
1028
|
]
|
|
1025
1029
|
},
|
|
@@ -1031,6 +1035,7 @@
|
|
|
1031
1035
|
"enum": [
|
|
1032
1036
|
"osx",
|
|
1033
1037
|
"linux",
|
|
1038
|
+
"linux-ppc64le",
|
|
1034
1039
|
"windows"
|
|
1035
1040
|
]
|
|
1036
1041
|
}
|
|
@@ -1061,7 +1066,8 @@
|
|
|
1061
1066
|
"xenial",
|
|
1062
1067
|
"bionic",
|
|
1063
1068
|
"focal",
|
|
1064
|
-
"jammy"
|
|
1069
|
+
"jammy",
|
|
1070
|
+
"noble"
|
|
1065
1071
|
]
|
|
1066
1072
|
},
|
|
1067
1073
|
"sudo": {
|
|
@@ -1138,8 +1144,8 @@
|
|
|
1138
1144
|
]
|
|
1139
1145
|
},
|
|
1140
1146
|
"ssh_known_hosts": {
|
|
1141
|
-
"
|
|
1142
|
-
"
|
|
1147
|
+
"$ref": "#/definitions/stringOrStringArrayUnique",
|
|
1148
|
+
"description": "Travis CI can add entries to ~/.ssh/known_hosts prior to cloning your git repository, which is necessary if there are git submodules from domains other than github.com, gist.github.com, or ssh.github.com."
|
|
1143
1149
|
},
|
|
1144
1150
|
"artifacts": {
|
|
1145
1151
|
"oneOf": [
|
|
@@ -1162,11 +1168,11 @@
|
|
|
1162
1168
|
},
|
|
1163
1169
|
"working_dir": {
|
|
1164
1170
|
"type": "string",
|
|
1165
|
-
"description": "If you
|
|
1171
|
+
"description": "If you'd like to upload file from a specific directory, you can change your working directory "
|
|
1166
1172
|
},
|
|
1167
1173
|
"debug": {
|
|
1168
1174
|
"type": "boolean",
|
|
1169
|
-
"description": "If you
|
|
1175
|
+
"description": "If you'd like to see more detail about what the artifacts addon is doing"
|
|
1170
1176
|
}
|
|
1171
1177
|
}
|
|
1172
1178
|
}
|
|
@@ -1523,7 +1529,7 @@
|
|
|
1523
1529
|
},
|
|
1524
1530
|
"quiet": {
|
|
1525
1531
|
"type": "boolean",
|
|
1526
|
-
"description": "Travis CI clones repositories without the quiet flag (-q) by default. Enabling the quiet flag can be useful if you
|
|
1532
|
+
"description": "Travis CI clones repositories without the quiet flag (-q) by default. Enabling the quiet flag can be useful if you're trying to avoid log file size limits or even if you just don't need to include it."
|
|
1527
1533
|
},
|
|
1528
1534
|
"submodules": {
|
|
1529
1535
|
"type": "boolean",
|
|
@@ -1539,7 +1545,7 @@
|
|
|
1539
1545
|
},
|
|
1540
1546
|
"sparse_checkout": {
|
|
1541
1547
|
"$ref": "#/definitions/nonEmptyString",
|
|
1542
|
-
"description": "Is a path to the existing file in the current repository with data you
|
|
1548
|
+
"description": "Is a path to the existing file in the current repository with data you'd like to put into $GIT_DIR/info/sparse-checkout file of format described in Git documentation."
|
|
1543
1549
|
},
|
|
1544
1550
|
"autocrlf": {
|
|
1545
1551
|
"oneOf": [
|
|
@@ -2352,5 +2358,6 @@
|
|
|
2352
2358
|
]
|
|
2353
2359
|
}
|
|
2354
2360
|
},
|
|
2361
|
+
"id": "https://json.schemastore.org/travis.json",
|
|
2355
2362
|
"title": "JSON schema for Travis CI configuration files"
|
|
2356
2363
|
}
|
package/script/index.js
CHANGED
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Created by user on 2019/5/18.
|
|
4
4
|
*/
|
|
5
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
-
};
|
|
8
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
9
7
|
const util_1 = require("./util");
|
|
10
|
-
const bluebird_1 = __importDefault(require("bluebird"));
|
|
8
|
+
const bluebird_1 = tslib_1.__importDefault(require("bluebird"));
|
|
11
9
|
const path_1 = require("path");
|
|
12
10
|
let skipExists;
|
|
13
11
|
skipExists = false;
|
package/script/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;GAEG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,iCAA2E;AAC3E,gEAAgC;AAChC,+BAAgC;AAGhC,IAAI,UAAmB,CAAC;AACxB,UAAU,GAAG,KAAK,CAAC;AAEnB,kBAAQ;KACN,IAAI,CAAC;IACL,qFAAqF;IACrF,sFAAsF;IACtF,oFAAoF;IACpF,sFAAsF;IACtF,mFAAmF;CACnF,EAAE,CAAC,IAAI,EAAE,EAAE;IAEX,IAAI,yBAAmF,CAAC;IAGxF,QAAQ,IAAA,eAAQ,EAAC,IAAI,CAAC,EACtB,CAAC;QACA,KAAK,cAAc;YAElB,aAAa;YACb,yBAAyB,GAAG,CAAC,MAA+C,EAAE,EAAE;gBAE/E,IACA,CAAC;oBACA,aAAa;oBACb,OAAO,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,iBAAiB,CAAC;oBAE3D,aAAa;oBACb,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,oBAAoB,GAAG,KAAK,CAAC;oBAC/D,aAAa;oBACb,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,eAAe,GAAG,KAAK,CAAC;oBAE1D,aAAa;oBACb,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;gBAChD,CAAC;gBACD,OAAO,CAAC,EACR,CAAC;gBAED,CAAC;gBAED,OAAO,MAAM,CAAA;YACd,CAAC,CAAA;YAED,MAAM;QACP,KAAK,YAAY;YAEhB,aAAa;YACb,yBAAyB,GAAG,CAAC,MAA6C,EAAE,EAAE;gBAE7E,aAAa;gBACb,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,oBAAoB,GAAG,KAAK,CAAC;gBACvD,aAAa;gBACb,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC;gBAElD,OAAO,MAAM,CAAA;YACd,CAAC,CAAA;YAED,MAAM;IACR,CAAC;IAED,OAAO,IAAA,2BAAoB,EAAC;QAC3B,IAAI;QACJ,UAAU;QACV,yBAAyB;KACzB,CAAC,CAAC;AACJ,CAAC,CAAC;KACD,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAChC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2CE","sourcesContent":["/**\n * Created by user on 2019/5/18.\n */\n\nimport { downloadJsonAndBuild, IDownloadJsonAndBuildParams } from './util';\nimport Bluebird from 'bluebird';\nimport { basename } from 'path';\nimport { unsetValue } from 'dot-values2';\n\nlet skipExists: boolean;\nskipExists = false;\n\nBluebird\n\t.each([\n\t\t'https://github.com/SchemaStore/schemastore/raw/master/src/schemas/json/package.json',\n\t\t'https://github.com/SchemaStore/schemastore/raw/master/src/schemas/json/eslintrc.json',\n\t\t'https://github.com/SchemaStore/schemastore/raw/master/src/schemas/json/travis.json',\n\t\t'https://github.com/SchemaStore/schemastore/raw/master/src/schemas/json/tsconfig.json',\n\t\t'https://github.com/SchemaStore/schemastore/raw/master/src/schemas/json/lerna.json',\n\t], (href) =>\n\t{\n\t\tlet handleSchemaBeforeCompile: IDownloadJsonAndBuildParams[\"handleSchemaBeforeCompile\"];\n\n\n\t\tswitch (basename(href))\n\t\t{\n\t\t\tcase 'package.json':\n\n\t\t\t\t// @ts-ignore\n\t\t\t\thandleSchemaBeforeCompile = (schema: typeof import('../schema/package.json')) => {\n\n\t\t\t\t\ttry\n\t\t\t\t\t{\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\tdelete schema.definitions.coreProperties.patternProperties;\n\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\tschema.definitions.coreProperties.additionalProperties = false;\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\tschema.definitions.coreProperties.additionalItems = false;\n\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\tconsole.dir(schema.definitions.coreProperties);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (e)\n\t\t\t\t\t{\n\n\t\t\t\t\t}\n\n\t\t\t\t\treturn schema\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\tcase 'lerna.json':\n\n\t\t\t\t// @ts-ignore\n\t\t\t\thandleSchemaBeforeCompile = (schema: typeof import('../schema/lerna.json')) => {\n\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tschema.properties.command.additionalProperties = false;\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tschema.properties.command.additionalItems = false;\n\n\t\t\t\t\treturn schema\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn downloadJsonAndBuild({\n\t\t\thref,\n\t\t\tskipExists,\n\t\t\thandleSchemaBeforeCompile,\n\t\t});\n\t})\n\t.tap(r => console.log(r.length))\n;\n\n/*\ndownloadJsonAndBuild({\n\thref: 'https://github.com/SchemaStore/schemastore/raw/master/src/schemas/json/package.json',\n\tskipExists,\n});\n\ndownloadJsonAndBuild({\n\thref: 'https://github.com/SchemaStore/schemastore/raw/master/src/schemas/json/eslintrc.json',\n\tskipExists,\n});\n\ndownloadJsonAndBuild({\n\thref: 'https://github.com/SchemaStore/schemastore/raw/master/src/schemas/json/travis.json',\n\tskipExists,\n});\n\ndownloadJsonAndBuild({\n\thref: 'https://github.com/SchemaStore/schemastore/raw/master/src/schemas/json/tsconfig.json',\n\tskipExists,\n});\n\ndownloadJsonAndBuild({\n\thref: 'https://github.com/SchemaStore/schemastore/raw/master/src/schemas/json/lerna.json',\n\tskipExists,\n});\n */\n\n/*\nBluebird.resolve(axios.get('https://github.com/SchemaStore/schemastore/raw/master/src/schemas/json/package.json'))\n\t.then(function (res)\n\t{\n\t\tconsole.log(`downloaded`);\n\n\t\tif (typeof res.data === 'string')\n\t\t{\n\t\t\treturn JSON.parse(res.data)\n\t\t}\n\n\t\treturn res.data\n\t})\n\t.tap(function (data)\n\t{\n\t\treturn fs.writeJSON(path.join(__dirname, '../schema/package.json'), data, {\n\t\t\tspaces: \"\\t\",\n\t\t})\n\t})\n\t.tap(function (data)\n\t{\n\t\tconsole.log(`json saved`);\n\t})\n\t.then(function (data)\n\t{\n\t\tconsole.log(`start compile .d.ts`);\n\n\t\treturn compile(data, 'IPackageJson', {\n\t\t\tenableConstEnums: true,\n\t\t\tunreachableDefinitions: true,\n\t\t})\n\t})\n\t.then(function (ts)\n\t{\n\t\tconsole.log(`compiled`);\n\n\t\treturn fs.writeFile(path.join(__dirname, '../types', 'package.json.d.ts'), ts)\n\t})\n\t.tap(function (data)\n\t{\n\t\tconsole.log(`.d.ts saved`);\n\t})\n;\n*/\n\n"]}
|
package/script/util.js
CHANGED
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Created by user on 2019/5/19.
|
|
4
4
|
*/
|
|
5
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
-
};
|
|
8
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
6
|
+
exports.downloadJsonAndBuild = downloadJsonAndBuild;
|
|
7
|
+
exports.handleFileName = handleFileName;
|
|
8
|
+
const tslib_1 = require("tslib");
|
|
9
|
+
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
10
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
12
|
+
const bluebird_1 = tslib_1.__importDefault(require("bluebird"));
|
|
14
13
|
const json_schema_to_typescript_1 = require("json-schema-to-typescript");
|
|
15
14
|
function downloadJsonAndBuild(options) {
|
|
16
15
|
if (!options.saveName) {
|
|
@@ -64,9 +63,7 @@ function downloadJsonAndBuild(options) {
|
|
|
64
63
|
})
|
|
65
64
|
.thenReturn(true);
|
|
66
65
|
}
|
|
67
|
-
exports.downloadJsonAndBuild = downloadJsonAndBuild;
|
|
68
66
|
function handleFileName(name) {
|
|
69
67
|
return name + '.d.ts';
|
|
70
68
|
}
|
|
71
|
-
exports.handleFileName = handleFileName;
|
|
72
69
|
//# sourceMappingURL=util.js.map
|
package/script/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["util.ts"],"names":[],"mappings":";AAAA;;GAEG
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["util.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * Created by user on 2019/5/19.\n */\n\nimport fs from \"fs-extra\"\nimport http from \"http\"\nimport path from \"path\"\nimport axios from \"axios\"\nimport Bluebird from \"bluebird\"\nimport { compile, compileFromFile } from 'json-schema-to-typescript'\nimport { JSONSchema4 } from 'json-schema';\n\nexport interface IDownloadJsonAndBuildParams\n{\n\thref: string;\n\tsaveName?: string;\n\tsavePath?: string;\n\tcompileName?: string;\n\n\tsavePathCompile?: string;\n\tsaveNameCompile?: string;\n\n\tskipExists?: boolean;\n\n\thandleSchemaBeforeCompile?<T extends JSONSchema4>(schema: T): T;\n\n}\n\nexport function downloadJsonAndBuild(options: IDownloadJsonAndBuildParams)\n{\n\tif (!options.saveName)\n\t{\n\t\toptions.saveName = path.basename(options.href)\n\t}\n\n\tif (!options.saveNameCompile)\n\t{\n\t\toptions.saveNameCompile = handleFileName(options.saveName)\n\t}\n\n\tlet filePath = path.join(__dirname, '../', options.savePath || 'schema', options.saveName);\n\n\tlet filePathCompile = path.join(__dirname, '..', options.savePathCompile || 'types', options.saveNameCompile);\n\n\tlet label = `[${path.basename(options.saveName)}]`;\n\n\tconsole.log(`${options.saveName}\\n${options.saveNameCompile}`);\n\n\tlet { skipExists = true } = options;\n\n\tif (skipExists && fs.existsSync(filePathCompile))\n\t{\n\t\tconsole.warn(label, `skip`);\n\n\t\treturn Bluebird.resolve(null)\n\t}\n\n\treturn Bluebird.resolve()\n\t\t.then(() => axios.get(options.href, {\n\t\t\ttimeout: 10 * 1000,\n\t\t}))\n\t\t.then(function (res)\n\t\t{\n\t\t\tconsole.log(label, `downloaded`);\n\n\t\t\tif (typeof res.data === 'string')\n\t\t\t{\n\t\t\t\treturn JSON.parse(res.data)\n\t\t\t}\n\n\t\t\treturn res.data\n\t\t})\n\t\t.tap(function (data)\n\t\t{\n\t\t\treturn fs.writeJSON(filePath, data, {\n\t\t\t\tspaces: \"\\t\",\n\t\t\t})\n\t\t})\n\t\t.tap(function ()\n\t\t{\n\t\t\tconsole.log(label, `json saved`);\n\t\t})\n\t\t.then(function (data)\n\t\t{\n\t\t\tconsole.log(label, `start compile .d.ts`);\n\n\t\t\treturn compile(options.handleSchemaBeforeCompile?.(data) ?? data, 'IMySchema', {\n\t\t\t\tenableConstEnums: true,\n\t\t\t\tunreachableDefinitions: true,\n\t\t\t})\n\t\t})\n\t\t.tap(function (ts)\n\t\t{\n\t\t\tconsole.log(label, `compiled`);\n\n\t\t\treturn fs.writeFile(filePathCompile, ts)\n\t\t})\n\t\t.tap(function ()\n\t\t{\n\t\t\tconsole.log(label, `.d.ts saved`);\n\t\t})\n\t\t.thenReturn(true)\n\t\t;\n}\n\nexport function handleFileName(name: string)\n{\n\treturn name + '.d.ts';\n}\n"]}
|