Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wildcard not working - not output #505

Open
magick93 opened this issue Jan 28, 2023 · 2 comments
Open

Wildcard not working - not output #505

magick93 opened this issue Jan 28, 2023 · 2 comments
Assignees

Comments

@magick93
Copy link

I'm trying to generate ts for several files, using the example in the readme:

json2ts -i 'schemas/**/*.json'
# or
json2ts -i schemas/ -o types/

However I'm only able to get output for a single specified .json file. For example at RateType.json | json2ts > RateType.d.ts does generate.

What I've tried

The following did not generate any output.

 json2ts -i *.json --output./types
 json2ts -i ./*.json --output./types
 json2ts -i base/ -o base/
 json2ts -i base/*.json -o base/
 json2ts -i base/*.json -o base/ --help
 json2ts -i base/*.json -o base/ --help --cwd ./base
 json2ts -i base/*.json -o base/ --help --cwd=./base
 json2ts -i base/*.json -o base/ --cwd=./base
 json2ts -i base/*.json -o base/base.d.ts --cwd=./base
 json2ts -i ./base/*.json -o base/base.d.ts --cwd=./base
 json2ts -i ./base/*.json -o ./base/base.d.ts --cwd=./base
 json2ts -i ./base/*.json
 json2ts -i ./base/*.json --cwd=./base
 json2ts -i ./base/*.json --cwd=./base > > output.d.ts
 json2ts -i ./base/*.json --cwd=./base > output.d.ts
 json2ts -i *.json
 json2ts -i */*.json
 json2ts -i */*.json --cwd=base
 json2ts -i */*.json --cwd=base -out common.d.ts
 json2ts -i */*.json --cwd=base -o common.d.ts
 json2ts -i */**.json --cwd=base -o common.d.ts
 json2ts -i **/**.json --cwd=base -o common.d.ts
 json2ts -i **/**.json --cwd=base -o ./common.d.ts
 json2ts -i **/**.json --cwd=./base -o ./common.d.ts
 json2ts -i **/**.json -o ./common.d.ts
 json2ts -i **/**.json -o ./common.d.ts --cwd=base
@bcherny
Copy link
Owner

bcherny commented Feb 19, 2023

It's hard to know what the issue is from your description. This case is well-covered by tests, so is expected to work.

Can you comment with your directory structure (using bullets) and the contents of your schemas? A whittled down repro case would be best (ie. a single property per schema, with 2 files, should be enough to repro from the info you've shared so far).

@keul
Copy link

keul commented Sep 1, 2023

@bcherny I've the same problem with wildcardas (tried both globbing in single quote or directly a folder name).

The error I get: CLI script seems to find files properly, but then resolve them in the wrong path:

I'm in /Users/keul/projects/MYPROJECT/stac-spec, the I run…

json2ts -i '*-spec/json-schema/*.json' -o types/

[
  {
    stack: 'ResolverError: Error opening file "/Users/keul/projects/item-spec/json-schema/item.json" \n' +
      "ENOENT: no such file or directory, open '/Users/keul/projects/item-spec/json-schema/item.json'\n" +
      '    at ReadFileContext.callback (/Users/keul/projects/hedp/jsonschema-to-ts/node_modules/@bcherny/json-schema-ref-parser/cjs/resolvers/file.js:96:32)\n' +
      '    at FSReqCallback.readFileAfterOpen [as oncomplete] (node:fs:325:13)',
    code: 'ERESOLVER',
    message: 'Error opening file "/Users/keul/projects/item-spec/json-schema/item.json" \n' +
      "ENOENT: no such file or directory, open '/Users/keul/projects/item-spec/json-schema/item.json'",
    source: '/Users/keul/projects/item-spec/json-schema/item.json',
    path: null,
    toJSON: [Function: toJSON],
    ioErrorCode: 'ENOENT',
    name: 'ResolverError',
    footprint: 'null+/Users/keul/projects/item-spec/json-schema/item.json+ERESOLVER+Error opening file "/Users/keul/projects/item-spec/json-schema/item.json" \n' +
      "ENOENT: no such file or directory, open '/Users/keul/projects/item-spec/json-schema/item.json'",
    toString: [Function: toString]
  }
]

One of the resolved file is /Users/keul/projects/item-spec/json-schema/item.json. The file name is OK, but is missing some intermediate subfolders.

This should be easy to reproduce as I'm trying to generate TS interfaces for the STAC spec repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants