dtsgenerator 3.15.0 → 3.15.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/README.md CHANGED
@@ -143,6 +143,11 @@ Output debug message by [debug](https://www.npmjs.com/package/debug) library.
143
143
 
144
144
  ## ChangeLog
145
145
 
146
+ ### [v3.15.1](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.15.1) (2022-03-10)
147
+
148
+ - fixed:
149
+ - Fix handling of stdin option with config file for #534. Thank you @arnestaphorsius :+1:
150
+
146
151
  ### [v3.15.0](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.15.0) (2022-02-06)
147
152
 
148
153
  - features:
package/dist/cli.js CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const fs = (0, tslib_1.__importStar)(require("fs"));
4
+ const fs = tslib_1.__importStar(require("fs"));
5
5
  const path_1 = require("path");
6
- const commandOptions_1 = (0, tslib_1.__importStar)(require("./commandOptions"));
7
- const core_1 = (0, tslib_1.__importStar)(require("./core"));
8
- const config_1 = (0, tslib_1.__importStar)(require("./core/config"));
6
+ const commandOptions_1 = tslib_1.__importStar(require("./commandOptions"));
7
+ const core_1 = tslib_1.__importStar(require("./core"));
8
+ const config_1 = tslib_1.__importStar(require("./core/config"));
9
9
  const utils_1 = require("./utils");
10
10
  async function loadContents() {
11
11
  let contents = [];
@@ -9,7 +9,6 @@ export declare class CommandOptions {
9
9
  target?: string;
10
10
  info?: boolean;
11
11
  outputAST?: boolean;
12
- isReadFromStdin(): boolean;
13
12
  }
14
13
  declare const opts: CommandOptions;
15
14
  export default opts;
@@ -2,16 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.clear = exports.initialize = exports.CommandOptions = exports.defaultConfigFile = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const commander = (0, tslib_1.__importStar)(require("commander"));
5
+ const commander = tslib_1.__importStar(require("commander"));
6
6
  exports.defaultConfigFile = 'dtsgen.json';
7
7
  class CommandOptions {
8
8
  constructor() {
9
9
  this.files = [];
10
10
  this.urls = [];
11
11
  }
12
- isReadFromStdin() {
13
- return (this.stdin || (this.files.length === 0 && this.urls.length === 0));
14
- }
15
12
  }
16
13
  exports.CommandOptions = CommandOptions;
17
14
  const opts = new CommandOptions();
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addOptionalInformation = exports.addComment = exports.buildTypeReferenceNode = exports.buildTupleTypeNode = exports.buildIntersectionTypeNode = exports.buildUnionTypeNode = exports.buildFreeFormObjectTypeLiteralNode = exports.buildTypeLiteralNode = exports.buildIndexSignatureNode = exports.buildPropertySignature = exports.buildTypeAliasNode = exports.buildInterfaceNode = exports.buildNamespaceNode = exports.buildBooleanLiteralTypeNode = exports.buildNumericLiteralTypeNode = exports.buildStringLiteralTypeNode = exports.buildNullKeyword = exports.buildSimpleArrayNode = exports.buildStringKeyword = exports.buildVoidKeyword = exports.buildUnknownKeyword = exports.buildNeverKeyword = exports.buildAnyKeyword = exports.buildKeyword = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const ts = (0, tslib_1.__importStar)(require("typescript"));
6
- const config_1 = (0, tslib_1.__importDefault)(require("./config"));
5
+ const ts = tslib_1.__importStar(require("typescript"));
6
+ const config_1 = tslib_1.__importDefault(require("./config"));
7
7
  const validateIdentifier_1 = require("./validateIdentifier");
8
8
  function buildTypeNameIdentifier(name) {
9
9
  return ts.factory.createIdentifier((0, validateIdentifier_1.toValidIdentifier)(name, config_1.default.target));
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const debug_1 = (0, tslib_1.__importDefault)(require("debug"));
5
- const ts = (0, tslib_1.__importStar)(require("typescript"));
4
+ const debug_1 = tslib_1.__importDefault(require("debug"));
5
+ const ts = tslib_1.__importStar(require("typescript"));
6
6
  const jsonPointer_1 = require("../jsonPointer");
7
- const ast = (0, tslib_1.__importStar)(require("./astBuilder"));
8
- const config_1 = (0, tslib_1.__importDefault)(require("./config"));
7
+ const ast = tslib_1.__importStar(require("./astBuilder"));
8
+ const config_1 = tslib_1.__importDefault(require("./config"));
9
9
  const jsonSchema_1 = require("./jsonSchema");
10
- const referenceResolver_1 = (0, tslib_1.__importDefault)(require("./referenceResolver"));
10
+ const referenceResolver_1 = tslib_1.__importDefault(require("./referenceResolver"));
11
11
  const type_1 = require("./type");
12
12
  const typeTree_1 = require("./typeTree");
13
- const utils = (0, tslib_1.__importStar)(require("./utils"));
13
+ const utils = tslib_1.__importStar(require("./utils"));
14
14
  const debug = (0, debug_1.default)('dtsgen');
15
15
  class DtsGenerator {
16
16
  constructor(contents) {
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SchemaId = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const config_1 = require("./config");
6
- const dtsGenerator_1 = (0, tslib_1.__importDefault)(require("./dtsGenerator"));
6
+ const dtsGenerator_1 = tslib_1.__importDefault(require("./dtsGenerator"));
7
7
  var schemaId_1 = require("./schemaId");
8
- Object.defineProperty(exports, "SchemaId", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(schemaId_1).default; } });
9
- (0, tslib_1.__exportStar)(require("./type"), exports);
8
+ Object.defineProperty(exports, "SchemaId", { enumerable: true, get: function () { return tslib_1.__importDefault(schemaId_1).default; } });
9
+ tslib_1.__exportStar(require("./type"), exports);
10
10
  async function dtsGenerator(options) {
11
11
  if (options.config) {
12
12
  (0, config_1.setConfig)(options.config);
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.selectSchemaType = exports.searchAllSubSchema = exports.setId = exports.getId = exports.getSubSchema = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const JsonPointer = (0, tslib_1.__importStar)(require("../jsonPointer"));
6
- const schemaId_1 = (0, tslib_1.__importDefault)(require("./schemaId"));
5
+ const JsonPointer = tslib_1.__importStar(require("../jsonPointer"));
6
+ const schemaId_1 = tslib_1.__importDefault(require("./schemaId"));
7
7
  const type_1 = require("./type");
8
8
  function getSubSchema(rootSchema, pointer, id) {
9
9
  const content = JsonPointer.get(rootSchema.content, JsonPointer.parse(pointer));
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  require("cross-fetch/polyfill");
5
- const debug_1 = (0, tslib_1.__importDefault)(require("debug"));
5
+ const debug_1 = tslib_1.__importDefault(require("debug"));
6
6
  const jsonSchema_1 = require("./jsonSchema");
7
- const schemaId_1 = (0, tslib_1.__importDefault)(require("./schemaId"));
7
+ const schemaId_1 = tslib_1.__importDefault(require("./schemaId"));
8
8
  const type_1 = require("./type");
9
9
  const debug = (0, debug_1.default)('dtsgen');
10
10
  class ReferenceResolver {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const url = (0, tslib_1.__importStar)(require("url"));
4
+ const url = tslib_1.__importStar(require("url"));
5
5
  const validateIdentifier_1 = require("./validateIdentifier");
6
6
  class SchemaId {
7
7
  constructor(inputId, parentIds) {
package/dist/core/type.js CHANGED
@@ -2,12 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadPlugin = exports.parseFileContent = exports.readSchemaFromUrl = exports.readSchemasFromFile = exports.readSchemaFromStdin = exports.parseSchema = exports.isJsonSchemaDraft04 = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const fs = (0, tslib_1.__importStar)(require("fs"));
5
+ const fs = tslib_1.__importStar(require("fs"));
6
6
  const path_1 = require("path");
7
7
  const js_yaml_1 = require("js-yaml");
8
8
  const utils_1 = require("../utils");
9
9
  const jsonSchema_1 = require("./jsonSchema");
10
- const schemaId_1 = (0, tslib_1.__importDefault)(require("./schemaId"));
10
+ const schemaId_1 = tslib_1.__importDefault(require("./schemaId"));
11
11
  exports.ts = require("typescript");
12
12
  function isJsonSchemaDraft04(_content, type) {
13
13
  return type === 'Draft04';
@@ -81,7 +81,7 @@ async function loadPlugin(name, option) {
81
81
  if (!option) {
82
82
  return undefined;
83
83
  }
84
- const mod = (await Promise.resolve().then(() => (0, tslib_1.__importStar)(require(name))));
84
+ const mod = (await Promise.resolve().then(() => tslib_1.__importStar(require(name))));
85
85
  if (!(mod === null || mod === void 0 ? void 0 : mod.default)) {
86
86
  console.warn(`The plugin (${name}) is invalid module. That is not default export format.`);
87
87
  return undefined;
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mergeSchema = exports.reduceTypes = exports.toTSType = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const debug_1 = (0, tslib_1.__importDefault)(require("debug"));
6
- const ts = (0, tslib_1.__importStar)(require("typescript"));
5
+ const debug_1 = tslib_1.__importDefault(require("debug"));
6
+ const ts = tslib_1.__importStar(require("typescript"));
7
7
  const debug = (0, debug_1.default)('dtsgen');
8
8
  function toTSType(type, debugSource) {
9
9
  switch (type) {
package/dist/utils.js CHANGED
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.readConfig = exports.globFiles = exports.buildProxyOptions = exports.readUrl = exports.readStream = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const fs = (0, tslib_1.__importStar)(require("fs"));
5
+ const fs = tslib_1.__importStar(require("fs"));
6
6
  const url_1 = require("url");
7
- const glob_1 = (0, tslib_1.__importDefault)(require("glob"));
8
- const https_proxy_agent_1 = (0, tslib_1.__importDefault)(require("https-proxy-agent"));
7
+ const glob_1 = tslib_1.__importDefault(require("glob"));
8
+ const https_proxy_agent_1 = tslib_1.__importDefault(require("https-proxy-agent"));
9
9
  const typescript_1 = require("typescript");
10
10
  const commandOptions_1 = require("./commandOptions");
11
11
  function readStream(stream, encoding = 'utf8') {
@@ -107,7 +107,14 @@ function readConfig(options) {
107
107
  else if (pc.input.urls == null) {
108
108
  pc.input.urls = [];
109
109
  }
110
- pc.input.stdin = options.isReadFromStdin();
110
+ if (options.stdin != null) {
111
+ pc.input.stdin = options.stdin;
112
+ }
113
+ else {
114
+ pc.input.stdin =
115
+ pc.input.stdin ||
116
+ (pc.input.files.length === 0 && pc.input.urls.length === 0);
117
+ }
111
118
  if (options.out != null) {
112
119
  pc.outputFile = options.out;
113
120
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtsgenerator",
3
- "version": "3.15.0",
3
+ "version": "3.15.1",
4
4
  "description": "TypeScript d.ts file generator for JSON Schema file",
5
5
  "bin": {
6
6
  "dtsgen": "bin/dtsgen"
@@ -51,7 +51,7 @@
51
51
  "https-proxy-agent": "^5.0.0",
52
52
  "js-yaml": "^4.1.0",
53
53
  "tslib": "^2.3.1",
54
- "typescript": "^4.5.5"
54
+ "typescript": "^4.6.2"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@dtsgenerator/do-nothing": "^2.5.1",
@@ -64,17 +64,17 @@
64
64
  "@types/js-yaml": "^4.0.5",
65
65
  "@types/mkdirp": "^1.0.2",
66
66
  "@types/mocha": "^9.1.0",
67
- "@types/node": "^16.11.22",
67
+ "@types/node": "^16.11.26",
68
68
  "cross-env": "^7.0.3",
69
- "eslint": "^8.8.0",
69
+ "eslint": "^8.10.0",
70
70
  "husky": "^7.0.4",
71
- "lint-staged": "^12.3.3",
72
- "mocha": "^9.2.0",
71
+ "lint-staged": "^12.3.5",
72
+ "mocha": "^9.2.1",
73
73
  "nyc": "^15.1.0",
74
74
  "prettier": "^2.5.1",
75
75
  "rimraf": "^3.0.2",
76
76
  "source-map-support": "^0.5.21",
77
- "ts-node": "^10.4.0"
77
+ "ts-node": "^10.7.0"
78
78
  },
79
79
  "lint-staged": {
80
80
  "**/*.ts": [
@@ -11,12 +11,6 @@ export class CommandOptions {
11
11
  public target?: string;
12
12
  public info?: boolean;
13
13
  public outputAST?: boolean;
14
-
15
- public isReadFromStdin(): boolean {
16
- return (
17
- this.stdin || (this.files.length === 0 && this.urls.length === 0)
18
- );
19
- }
20
14
  }
21
15
 
22
16
  const opts = new CommandOptions();
package/src/utils.ts CHANGED
@@ -109,7 +109,13 @@ export function readConfig(options: CommandOptions): Partial<Config> {
109
109
  } else if (pc.input.urls == null) {
110
110
  pc.input.urls = [];
111
111
  }
112
- pc.input.stdin = options.isReadFromStdin();
112
+ if (options.stdin != null) {
113
+ pc.input.stdin = options.stdin;
114
+ } else {
115
+ pc.input.stdin =
116
+ pc.input.stdin ||
117
+ (pc.input.files.length === 0 && pc.input.urls.length === 0);
118
+ }
113
119
 
114
120
  if (options.out != null) {
115
121
  pc.outputFile = options.out;