[BUG] Error when working with npm workspaces
@kay-schecker is already working on this.
Since Jan 30, 2022.
Assessment
This issue has not been assessed yet.
Description
🐛 Bug Report:
Describe the bug
The generator crashes with the [error] Required option '-i' is missing error when running with different cwd.
Steps to Reproduce
Steps to reproduce the behavior:
- Create a npm project with two workspaces:
packages/clientandpackages/server(server probably isn't even necessary) - Save a spec in
packages/openapi.yaml - Reference it in
packages/client/openapitools.jsonvia"inputSpec": "../openapi.yaml" - Add a script in client:
"openapi": "openapi-generator-cli generate"and run it- It works ✔️
- Add a script in root
"openapi": "npm run openapi --workspaces --if-present"and run it- See error ❌
- Generates a
openapitools.jsonin the root directory
Failing workaround
I created a packages/client/openapi.js script and let it run in client via "openapi": "node openapi.js" , but this also fails in the same way.
// try forcing the cwd to the client directory (works when checking with pwd command)
const child = require('child_process').exec('openapi-generator-cli generate', { cwd: __dirname });
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
child.on('exit', code => process.exit(code));
Expected behavior
I expect the generator to always find the file.
Operation System:
- OS: Windows
- Version 10
Package System:
- npm v8.3.0
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 208
- Avg merge
- 7h 12m
- Merged PRs (30d)
- 6
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from OpenAPITools/openapi-generator-cli
-
[FEATURE] consider using caret ranges instead of pinned exact versions for runtime dependenciesOpen
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
[BUG] JAVA_OPTS is incorrectly evaluatedMay be free again @kay-schecker claimed this 115 days ago, and no pull request is open. Openbug
OpenAPITools/openapi-generator-cli#1213 · 1 assignee ·
-
[BUG] Proxy configuration of NPM not used when downloading .jar via version managerMay be free again @kay-schecker claimed this 170 days ago, and no pull request is open. Openbug
OpenAPITools/openapi-generator-cli#1190 · 1 assignee ·
-
[BUG] openapiGeneratorIgnoreList is missing from schemaMay be free again @kay-schecker claimed this 220 days ago, and no pull request is open. Openbug
OpenAPITools/openapi-generator-cli#1138 · 1 comment · 1 assignee ·
-
[BUG] Environment variable not found (missing .env loading)May be free again @kay-schecker claimed this 259 days ago, and no pull request is open. Openbug
OpenAPITools/openapi-generator-cli#1094 · 1 comment · 1 assignee ·
All issues in OpenAPITools/openapi-generator-cli
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
diegosouzapw/OmniRoute#14869 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
Maintainers usually reply within 1 day
-
status: waiting triage
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
freeCodeCamp/freeCodeCamp#70412 ·
Maintainers usually reply within 1 day
-
Mend: dependency security vulnerability untriaged
Difficulty 1/5 Under an hour Newbie friendliness 88/100
opensearch-project/OpenSearch-Dashboards#12816 ·
Maintainers usually reply within 1 day