Skip to content

Commit

Permalink
docs(nx-prisma): 📝 basic docs
Browse files Browse the repository at this point in the history
  • Loading branch information
linbudu599 committed Sep 27, 2021
1 parent 3fc2ee8 commit 96100b5
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 2 deletions.
70 changes: 70 additions & 0 deletions docs/nx/prisma.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,74 @@ Nx plugin integration with [Prisma](https://www.prisma.io/)

## Generators

### init

```bash
nx g nx-plugin-prisma:init --app prisma-app --latestPackage
```

> `--latestPackage` means fetching latest version of Prisma package
Create a node application with prisma relateds initializations:

- Required dependencies([prisma](https://npmjs.com/package/prisma) & [@prisma/client](https://www.npmjs.com/package/@prisma/client))
- Workspace configuration corresponding to Prisma cli commands, `generate` / `db` / `studio` ...
- Initial Prisma schema

You can then run `nx prisma-db-push prisma-app` command to push schema to database and generate PrismaClient.

The generated application use self-contained scripts to handler dev/build/start, for example, `nx dev prisma-app` will execute this file:

```typescript
// scripts/dev.ts
import execa from 'execa';

export default async function dev() {
await execa('ts-node-dev --respawn src/main.ts', {
cwd: process.cwd(),
stdio: 'inherit',
shell: true,
});
}

(async () => {
await dev();
})();
```

You can find more supported schema options in [Prisma.Generator.Init](/packages/nx-plugin-prisma/src/generators/init/schema.json).

### setup

```bash
nx g nx-plugin-prisma:setup --app prisma-app
```

Similar to `init`, but `setup` generator should and can only be applied in exist application, which will also install deps, generate Prisma file, and add related workspace targsts for application.

Another difference is that `setup` generator doesnot add `dev`/`build`/`start` targets.

You can find more supported schema options in [Prisma.Generator.Setup](/packages/nx-plugin-prisma/src/generators/setup/schema.json).

## Executors

### info

```bash
nx info prisma-app
```

Add target configuration below (included in `init` / `setup` generator):

```json
{
"prisma-app": {
"targets": {
"info": {
"executor": "nx-plugin-prisma:info",
"options": {}
}
}
}
}
```
1 change: 1 addition & 0 deletions packages/nx-plugin-prisma/src/executors/info/info.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default async function infoExecutor(
const envInfos = await envInfo([
'prisma',
'@prisma/client',
'nx-plugin-devkit',
'nx-plugin-workspace',
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ export function prismaTargetsConfig(schema: NormalizedPrismaGeneratorSchema) {
basicPrismaTargetConfiguration,
sharedPrismaOptions
),
info: merge({
executor: 'nx-plugin-prisma:info',
options: {},
}),
};

return {
Expand Down
6 changes: 4 additions & 2 deletions scripts/release/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ export default function useReleaseProject(cli: CAC) {
}
);

console.log('');

await execa(
'git',
['push', '--verbose', '--progress'].concat(
Expand Down Expand Up @@ -270,7 +272,7 @@ export default function useReleaseProject(cli: CAC) {
}
);

dryRunSuccessLogger('Package published', dryRun);
dryRunSuccessLogger('Package published.', dryRun);
} catch (error) {
consola.error(error);
}
Expand All @@ -288,4 +290,4 @@ export const dryRunInfoLogger = (msg: string, dryRun: boolean) =>
export const dryRunSuccessLogger = (msg: string, dryRun: boolean) =>
dryRun
? consola.success(`${chalk.white('DRY RUN MODE')}: ${msg}`)
: consola.info(msg);
: consola.success(msg);

0 comments on commit 96100b5

Please sign in to comment.