Repository navigation
feat(sdk): read schema path from package.json - #3566
Conversation
| getSchemaPathFromPackageJson, | ||
| getSchemaPathFromPackageJsonSync, |
There was a problem hiding this comment.
Didn't know whether we want to expose these helpers on the SDK. Let me know
| export function getSchemaPathSyncInternal( | ||
| schemaPathFromArgs?: string, | ||
| opts: { cwd: string } = { | ||
| cwd: process.cwd(), | ||
| }, | ||
| ): string | null { |
There was a problem hiding this comment.
Not sure whether we actually want to make this signature the exported one on the SDK. While it was made to ease testing, it could be useful for SDK tinkerers as well. The goal here was to minimize changes of the surface API (although it wouldn't be a breaking change anyway), but I'm happy to expose that one instead. Same goes for the getSchemaPathInternal.
There was a problem hiding this comment.
(not clear on the highlighted code, but the exported getSchemaPathSync function now just calls that "internal" one)
| { | ||
| "name": "yarn-workspaces", | ||
| "workspaces": ["packages/*"], | ||
| "private": true | ||
| } No newline at end of file |
There was a problem hiding this comment.
I created a bunch of fixtures to match the current style of testing. I can as well come up with some utilities to dynamically write these fixtures in tmp and clean them up for each tests. That's what we used to do in Nexus.
| } | ||
|
|
||
| // in case the normal schema path doesn't exist, try the npm base dir | ||
| // 4. In case no schema can't be found there, try the npm-based INIT_CWD |
There was a problem hiding this comment.
| // 4. In case no schema can't be found there, try the npm-based INIT_CWD | |
| // 4. In case no schema can be found there, try the npm-based INIT_CWD |
| if (process.env.INIT_CWD) { | ||
| return ( | ||
| (await getRelativeSchemaPath(process.env.INIT_CWD)) || | ||
| (await resolveYarnSchema()) |
There was a problem hiding this comment.
I removed the INIT_CWD logic. As seen with Tim, it looks like INIT_CWD is always process.cwd() anyway.
If you want your script to use different behavior based on what subdirectory you’re in, you can use the INIT_CWD environment variable, which holds the full path you were in when you ran npm run
See the documentation full doc here: https://docs.npmjs.com/cli/run-script
Closes #3144
package.jsonfile in aprisma.schemapropertygetSchemaPathandgetSchemaPathSync