aws-pdk
aws-pdk copied to clipboard
[BUG] typesafe-api code generation script doesn't handle spaces in the directory path
Describe the bug
Running pnpm build
in a directory that contains spaces in the path will cause the typesafe-api generate task to fail.
Expected Behavior
@redacted/api-model: 👾 build » compile » generate | npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api.parse-openapi-spec --spec-path build/smithyprojections/@redacted-api-model/openapi/openapi/api.openapi.json --output-path .api.json --smithy-json-path build/smithyprojections/@redacted-api-model/openapi/model/model.json
@redacted/api-model: package manager :: pnpm
@redacted/api-model: parse-openapi-spec :: tmp_dir :: /var/folders/xk/wd42j4dj3w58p0n9bzsf3th00000gs/T/parse-openapi-spec.ej1C8Q8uZ
@redacted/api-model: installing packages :: [email protected] @types/[email protected] [email protected] [email protected] @redocly/[email protected] [email protected] @faker-js/[email protected] @openapitools/[email protected] [email protected] @types/[email protected] @apidevtools/[email protected] [email protected] [email protected]
@redacted/api-model: running command pnpm exec ts-node parse-openapi-spec.ts --specPath=/Users/myusername/Repos/prototyping/aws-anz-redacted/packages/api/model/build/smithyprojections/@redacted-api-model/openapi/openapi/api.openapi.json --outputPath=/Users/myusername/Repos/prototyping/aws-anz-redacted/packages/api/model/.api.json --smithyJsonPath=/Users/myusername/Repos/prototyping/aws-anz-redacted/packages/api/model/build/smithyprojections/@redacted-api-model/openapi/model/model.json
@redacted/api-model: openapi-spec parsed
The previous output is from a project without a space in the directory, the openapi file is parsed correctly and the build continues.
Current Behavior
The following terminal output occurs when there is a space in the directory name. Then the build fails
@redacted/api-model: 👾 build » compile » generate | npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api.parse-openapi-spec --spec-path build/smithyprojections/@redacted-api-model/openapi/openapi/api.openapi.json --output-path .api.json --smithy-json-path build/smithyprojections/@redacted-api-model/openapi/model/model.json
@redacted/api-model: /Users/myusername/Downloads/PROTOTYPE CODE/redactedcode/node_modules/.bin/../@aws/pdk/scripts/type-safe-api/parser/parse-openapi-spec: line 19: /Users/myusername/Downloads/PROTOTYPE CODE/redactedcode/packages/api/model/../common/common.sh: No such file or directory
@redacted/api-model: 👾 Task "build » compile » generate" failed when executing "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api.parse-openapi-spec --spec-path build/smithyprojections/@redacted-api-model/openapi/openapi/api.openapi.json --output-path .api.json --smithy-json-path build/smithyprojections/@redacted-api-model/openapi/model/model.json" (cwd: /Users/myusername/Downloads/PROTOTYPE CODE/redactedcode/packages/api/model)
@redacted/api-model: Warning: run-commands command "pnpm dlx projen build" exited with non-zero status code
Reproduction Steps
- Create a new project in a directory that contains a space in the directory name
- Run
pnpm build
Possible Solution
The generate task parsing script may have an error at the following line or above
https://github.com/aws/aws-pdk/blob/6fc5ca16bb87fb00d61f25844ce2463c1c90980f/packages/type-safe-api/scripts/type-safe-api/parser/parse-openapi-spec#L16
Additional Information/Context
No response
PDK version used
0.23.16
What languages are you seeing this issue on?
No response
Environment details (OS name and version, etc.)
MacOS 14.5, OpenJDK Runtime Environment Corretto-17.0.11.9.1, pnpm 8.15.8, (build 17.0.11+9-LTS), npm 10.7.0, node 18.20.3