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

[BUG] typesafe-api code generation script doesn't handle spaces in the directory path #793

Closed
julianpitt opened this issue Jun 4, 2024 · 3 comments · Fixed by #870
Closed
Labels
backlog bug Something isn't working needs-triage

Comments

@julianpitt
Copy link

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 :: typescript@5.0.4 @types/node@20.1.5 ts-node@10.9.1 ts-command-line-args@2.4.2 @redocly/cli@1.0.0-beta.126 reregexp@1.6.1 @faker-js/faker@8.1.0 @openapitools/openapi-generator-cli@2.6.0 lodash@4.17.21 @types/lodash@4.14.197 @apidevtools/swagger-parser@10.1.0 openapi-types@12.1.0 projen@0.73.8
@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

  1. Create a new project in a directory that contains a space in the directory name
  2. Run pnpm build

Possible Solution

The generate task parsing script may have an error at the following line or above

script_dir="$( cd -- "$(dirname $([ -L "${BASH_SOURCE[0]:-$0}" ] && readlink -f "${BASH_SOURCE[0]:-$0}" || echo "${BASH_SOURCE[0]:-$0}"))" >/dev/null 2>&1 ; pwd -P )";

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

@julianpitt julianpitt added bug Something isn't working needs-triage labels Jun 4, 2024
Copy link

github-actions bot commented Aug 5, 2024

This issue is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon. If you wish to exclude this issue from being marked as stale, add the "backlog" label.

@github-actions github-actions bot added the stale label Aug 5, 2024
Copy link

Closing this issue as it hasn't seen activity for a while. Please add a comment @mentioning a maintainer to reopen. If you wish to exclude this issue from being marked as stale, add the "backlog" label.

@cogwirrel
Copy link
Member

Hey @julianpitt! This will be fully fixed by #870 since all scripts are now in nodejs and we no longer do any juggling with temporary directories or absolute paths in bash!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog bug Something isn't working needs-triage
Projects
None yet
2 participants