Closed nick-keller closed 1 year ago
Hey @adelsz, I took your comments into consideration but I could not make the example work.
Running test
gives me:
Step 2/6 : FROM $NODE_IMAGE
ERROR: Service 'build' failed to build : invalid reference format
And running check
gives me:
error TS6059: File '/Users/nick/projects/pgtyped/packages/example/jest-cjs.config.ts' is not under 'rootDir' '/Users/nick/projects/pgtyped/packages/example/src'. 'rootDir' is expected to contain all source files.
The file is in the program because:
Matched by default include pattern '**/*'
error TS6059: File '/Users/nick/projects/pgtyped/packages/example/jest.config.ts' is not under 'rootDir' '/Users/nick/projects/pgtyped/packages/example/src'. 'rootDir' is expected to contain all source files.
The file is in the program because:
Matched by default include pattern '**/*'
Found 2 errors.
If you can help me make it work so that I can add examples, or add them yourself if you feel like it that;s be great!
Thanks @nick-keller. The changes look good.
To run the example packages you need to specify the node version as follows NODE_VERSION=16 npm run test
.
We run it as part of the CI https://github.com/adelsz/pgtyped/blob/master/.github/workflows/main.yml
Sorry @adelsz but I cannot get it to work.
Running check
still gives me the two errors I listed above. And running test
kinda works until src/index.test.ts
timesout. This is definitly not my cup of tea, and I don't have the skills and the patience to solve those kind of issues.
Furthermore:
expect(typeof dateAsString).toBe('string');
only checks that pg.types.setTypeParser(...)
works, it is not checking that pgtyped actually typed the column as string.^2.0.0
, meaning that my work will not be reflected until you actually publish the package anyway.I'll have to let you take it from here I'm afraid :/
No worries, I can handle that on my side. Thanks for working on this major feature, it will be a great addition to pgTyped.
As for the issues you encountered, packages/example
is one of the confusing parts of the codebase. I will have to write more detailed instructions in a CONTRIBUTING.md
doc.
In case it might be of any future use I will comment on the issues you brought up:
The tests are not really checking that the generated types are correct. For instance expect(typeof dateAsString).toBe('string'); only checks that pg.types.setTypeParser(...) works, it is not checking that pgtyped actually typed the column as string.
The idea of the example
package is to serve both as an e2e test (compile-time and runtime) and example usage of pgTyped.
The npm run test
command does two things:
git diff
will show if there are any unexpected problems with the generated queries and types (e2e compile-time test).In the package.json, dependencies are ^2.0.0, meaning that my work will not be reflected until you actually publish the package anyway.
pgTyped is a monorepo using npm workspaces, so running npm install
actually crosslinks all of the pgTyped
packages together locally (the exact versions in package jsons don't matter). Running npm run build
builds all packages and makes them available to each other as if they were published.
As I said, all of this belongs in CONTRIBUTING.md
doc, which has been long overdue.
Fix #480
Please review it carefully, I did not test it end to end.