-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jason Kuhrt
authored
Mar 3, 2021
1 parent
c51973a
commit 3a0a75a
Showing
37 changed files
with
3,619 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.yalc | ||
.vscode | ||
.github | ||
node_modules | ||
dist | ||
dist-esm | ||
tests | ||
jest.config.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"root": true, | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"project": ["tsconfig.json", "tests/tsconfig.json"] | ||
}, | ||
"plugins": ["@typescript-eslint", "only-warn"], | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:@typescript-eslint/recommended-requiring-type-checking", | ||
"prettier" | ||
], | ||
"overrides": [], | ||
"rules": { | ||
// TypeScript makes these safe & effective | ||
"no-case-declarations": "off", | ||
// Same approach used by TypeScript noUnusedLocals | ||
"@typescript-eslint/no-unused-vars": ["warn", { "varsIgnorePattern": "^_", "argsIgnorePattern": "^_" }] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
...require('@prisma-labs/prettier-config'), | ||
jsdocParser: true, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "dev:link", | ||
"dependsOn": ["dev:yalc", "dev:ts"] | ||
}, | ||
{ | ||
"label": "tdd", | ||
"type": "shell", | ||
"command": "yarn -s tdd", | ||
"presentation": { | ||
"group": "test", | ||
"focus": true, | ||
"panel": "shared", | ||
"clear": true | ||
} | ||
}, | ||
|
||
// Lower level task building blocks | ||
|
||
{ | ||
"label": "dev:yalc", | ||
"type": "shell", | ||
"command": "yarn -s dev:yalc", | ||
"presentation": { | ||
"group": "dev", | ||
"focus": false, | ||
"panel": "shared", | ||
"clear": true | ||
} | ||
}, | ||
{ | ||
"label": "dev:ts", | ||
"type": "shell", | ||
"command": "yarn -s dev:ts", | ||
"presentation": { | ||
"group": "dev", | ||
"focus": false, | ||
"panel": "shared", | ||
"clear": true | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,49 @@ | ||
## Tests | ||
|
||
- We disable `kleur` colors so snapshots do not have them. It would be nice to put the DX of colors into tests but needs some work. Node 12/14 results in different codes, [thus different snapshots](https://github.com/prisma/nexus-prisma/pull/3#issuecomment-782432471). See test-mode feature request here: https://github.com/lukeed/kleur/issues/47#issue-812419257. | ||
|
||
## Link-Like Development | ||
|
||
Sometimes it is useful to use a [link workflow](https://docs.npmjs.com/cli/v6/commands/npm-link). This means working on a local checkout of the Nexus Prisma source code, while trying it out in a project as local on your machine. This can be great for feeling out ideas. | ||
|
||
Linking with Nexus Prisma is problematic because some modules in the Nexus Prisma source do file path lookups relative to where they are on disk. These lookups expect to be in the project that is using Nexus Prisma. Regular link workflows violate this assumptions. | ||
|
||
The solution is to use [Yalc](https://github.com/wclr/yalc). | ||
|
||
#### Instructions | ||
|
||
Definitions: | ||
|
||
- `Nexus Prisma`: Your local checkout of the source code. | ||
- `Project`: Some project that you are trying out your local version of Nexus Prisma on. | ||
|
||
One-time: | ||
|
||
1. Install yalc on your machine `npm -g add yalc`. | ||
1. Install nodemon on your machine `npm -g add nodemon`. | ||
|
||
Usually-one-time: | ||
|
||
1. In `Project` run `yalc add nexus-prisma`. | ||
|
||
Every-time: | ||
|
||
1. In `Nexus Prisma` run the VSCode task `dev:link`. | ||
1. In `Project` run `nodemon --watch '.yalc/**/*' --exec 'yarn -s prisma generate'` | ||
|
||
With all this in place, the chain reaction goes like this: | ||
|
||
1. You change `Nexus Prisma` | ||
1. `Nexus Prisma` TS in watch mode emits into `dist` | ||
1. `Nexus Prisma` `nodemon` reacts to this, runs `yalc push`, Yalc emits into `Project`'s `.yalc` dir | ||
1. `Project` `nodemon` reacts to this, runs `prisma generate` | ||
1. You try things out with newly generated Nexus Prisma in `Project`! | ||
|
||
One issues are being worked out related to `bin` and `chmod`: https://github.com/wclr/yalc/issues/156 | ||
|
||
If you change a dependency in `Nexus Prisma` while working (especially adding a new one) you will need to remove the `node_modules` in `Project` and re-install e.g. `yarn install`. | ||
|
||
## Debugging | ||
|
||
- We use `debug`. Enable by setting envar `DEBUG=nexus-prisma*` | ||
- If you set envar `NP_DEBUG=true` then Nexus Prisma will write `dmmf.json` to CWD at generation time. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.