aws / aws-pdk

The AWS PDK provides building blocks for common patterns together with development tools to manage and build your projects.
https://aws.github.io/aws-pdk/
Apache License 2.0
351 stars 73 forks source link

[BUG] npx projen build doesn't remove corresponding files in `packages/api/handlers/typescript/test` (and other files, see detailed issue) #779

Closed teddyaryono closed 1 week ago

teddyaryono commented 2 months ago

Describe the bug

I followed the getting started guide to build a shopping list application.

Ran npx projen build to build. Build failed because of failed test.

Expected Behavior

pdk to version and remove corresponding unused test and other files (see current behaviour).

Current Behavior

pdk left some un-used files in packages/api/handlers/typescript/test and packages/api/handlers/typescript/lib. Users need to handpick and remove leftover files manually.

Reproduction Steps

  1. Follow a getting started guide here to build a shopping list application.
  2. Add 5 files: types/shopping-list.smithy, types/pagination.smithy, operations/put-shopping-list.smithy, operations/delete-shopping-list.smithy, operations/get-shopping-list.smithy.
  3. Update main.smithy to include GetShoppingLists, PutShoppingList, DeleteShoppingList.
  4. Remove packages/api/model/src/main/smithy/operations/say-hello.smithy and packages/api/handlers/typescript/src/say-hello.ts
  5. Run npx projen build
  6. Build failed with the following error:
myapi-typescript-handlers: ๐Ÿ‘พ build ยป compile | tsc --build
myapi-typescript-handlers: ๐Ÿ‘พ build ยป test | jest --passWithNoTests --updateSnapshot
myapi-typescript-handlers:  FAIL  test/say-hello.test.ts
myapi-typescript-handlers:   โ— Test suite failed to run
myapi-typescript-handlers:     test/say-hello.test.ts:3:3 - error TS2724: '"myapi-typescript-runtime"' has no exported member named 'SayHelloChainedRequestInput'. Did you mean 'ChainedRequestInput'?
myapi-typescript-handlers:     3   SayHelloChainedRequestInput,
myapi-typescript-handlers:         ~~~~~~~~~~~~~~~~~~~~~~~~~~~
myapi-typescript-handlers:     test/say-hello.test.ts:5:26 - error TS2307: Cannot find module '../src/say-hello' or its corresponding type declarations.
myapi-typescript-handlers:     5 import { sayHello } from "../src/say-hello";
myapi-typescript-handlers:                                ~~~~~~~~~~~~~~~~~~
myapi-typescript-handlers:  PASS  test/delete-shopping-list.test.ts
myapi-typescript-handlers:  PASS  test/get-shopping-lists.test.ts
myapi-typescript-handlers:  PASS  test/put-shopping-list.test.ts
myapi-typescript-handlers: -------------------------|---------|----------|---------|---------|-------------------
myapi-typescript-handlers: File                     | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
myapi-typescript-handlers: -------------------------|---------|----------|---------|---------|-------------------
myapi-typescript-handlers: All files                |     100 |      100 |     100 |     100 |                   
myapi-typescript-handlers:  delete-shopping-list.ts |     100 |      100 |     100 |     100 |                   
myapi-typescript-handlers:  get-shopping-lists.ts   |     100 |      100 |     100 |     100 |                   
myapi-typescript-handlers:  put-shopping-list.ts    |     100 |      100 |     100 |     100 |                   
myapi-typescript-handlers: -------------------------|---------|----------|---------|---------|-------------------
myapi-typescript-handlers: Test Suites: 1 failed, 3 passed, 4 total
myapi-typescript-handlers: Tests:       3 passed, 3 total
myapi-typescript-handlers: Snapshots:   0 total
myapi-typescript-handlers: Time:        1.729 s, estimated 2 s
myapi-typescript-handlers: Ran all test suites.
myapi-typescript-handlers: ๐Ÿ‘พ Task "build ยป test" failed when executing "jest --passWithNoTests --updateSnapshot" (cwd: /Users/taryono/Code/projects/prototyping-sandbox/transurban-v2/packages/api/handlers/typescript)
myapi-typescript-handlers: Warning: run-commands command "pnpm exec projen build" exited with non-zero status code

 โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”

 >  NX   Running target build for 9 projects failed

   Tasks not run because their dependencies failed or --nx-bail=true:

   - infra:build

   Failed tasks:

   - myapi-typescript-handlers:build

๐Ÿ‘พ Task "build" failed when executing "pnpm exec nx run-many --target=build --output-style=stream --nx-bail" (cwd: /Users/taryono/Code/projects/prototyping-sandbox/transurban-v2)

Possible Solution

No response

Additional Information/Context

No response

PDK version used

0.23.37

What languages are you seeing this issue on?

Typescript

Environment details (OS name and version, etc.)

Apple M1 Pro, MacOS Sonoma 14.4.1

github-actions[bot] commented 2 weeks ago

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[bot] commented 1 week ago

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.