Skip to content

Commit

Permalink
feat(nx-prisma): better executors schemas descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
gperdomor committed Aug 18, 2023
1 parent 5b25b2f commit d5dc51a
Show file tree
Hide file tree
Showing 34 changed files with 201 additions and 94 deletions.
14 changes: 7 additions & 7 deletions packages/nx-prisma/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["./package.json", "./generators.json", "./executors.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/nx-plugin-checks": "error"
}
},
{
"files": ["*.json"],
"parser": "jsonc-eslint-parser",
Expand All @@ -32,6 +25,13 @@
}
]
}
},
{
"files": ["./package.json", "./executors.json", "./generators.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/nx-plugin-checks": "error"
}
}
]
}
31 changes: 15 additions & 16 deletions packages/nx-prisma/executors.json
Original file line number Diff line number Diff line change
@@ -1,60 +1,59 @@
{
"$schema": "http://json-schema.org/schema",
"executors": {
"deploy": {
"implementation": "./src/executors/deploy/executor",
"schema": "./src/executors/deploy/schema.json",
"description": "Applies all pending migrations, and creates the database if it does not exist"
},
"validate": {
"implementation": "./src/executors/validate/executor",
"schema": "./src/executors/validate/schema.json",
"description": "Validates your prisma schema"
"description": "The migrate deploy command applies all pending migrations, and creates the database if it does not exist. Primarily used in non-development environments."
},
"generate": {
"implementation": "./src/executors/generate/executor",
"schema": "./src/executors/generate/schema.json",
"description": "Generates assets like Prisma Client based on the generator and data model blocks defined in your schema.prisma file"
"description": "The generate command generates assets like Prisma Client based on the generator and data model blocks defined in your schema.prisma file."
},
"migrate": {
"implementation": "./src/executors/migrate/executor",
"schema": "./src/executors/migrate/schema.json",
"description": "Syncs Prisma Migrations"
"description": "The migrate dev command updates your database using migrations during development and creates the database if it does not exist."
},
"pull": {
"implementation": "./src/executors/pull/executor",
"schema": "./src/executors/pull/schema.json",
"description": "Connects to your database and adds Prisma models to your Prisma schema that reflect the current database schema"
"description": "The db pull command connects to your database and adds Prisma models to your Prisma schema that reflect the current database schema."
},
"push": {
"implementation": "./src/executors/push/executor",
"schema": "./src/executors/push/schema.json",
"description": "Pushes the state of your Prisma schema file to the database without using migrations. It creates the database if the database does not exist."
"description": "The db push command pushes the state of your Prisma schema file to the database without using migrations. It creates the database if the database does not exist."
},
"reset": {
"implementation": "./src/executors/reset/executor",
"schema": "./src/executors/reset/schema.json",
"description": "Deletes and recreates the database, or performs a 'soft reset' by removing all data, tables, indexes, and other artifacts"
"description": "This command deletes and recreates the database, or performs a 'soft reset' by removing all data, tables, indexes, and other artifacts."
},
"resolve": {
"implementation": "./src/executors/resolve/executor",
"schema": "./src/executors/resolve/schema.json",
"description": "Allows you to solve migration history issues in production by marking a failed migration as already applied (supports baselining) or rolled back"
"description": "The migrate resolve command allows you to solve migration history issues in production by marking a failed migration as already applied (supports baselining) or rolled back."
},
"seed": {
"implementation": "./src/executors/seed/executor",
"schema": "./src/executors/seed/schema.json",
"description": "Seed your database using Prisma Client"
"description": "Seed your database."
},
"status": {
"implementation": "./src/executors/status/executor",
"schema": "./src/executors/status/schema.json",
"description": "Looks up the migrations and shows the DB status"
"description": "The prisma migrate status command looks up the migrations in migrations folder and the entries in the _prisma_migrations table and compiles information about the state of the migrations in your database."
},
"studio": {
"implementation": "./src/executors/studio/executor",
"schema": "./src/executors/studio/schema.json",
"description": "The studio command allows you to interact with and manage your data interactively"
"description": "The studio command allows you to interact with and manage your data interactively. It does this by starting a local web server with a web app configured with your project's data schema and records."
},
"validate": {
"implementation": "./src/executors/validate/executor",
"schema": "./src/executors/validate/schema.json",
"description": "Validates the Prisma Schema Language of the Prisma schema file."
}
}
}
8 changes: 1 addition & 7 deletions packages/nx-prisma/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@
export default {
displayName: 'nx-prisma',
preset: '../../jest.preset.js',
globals: {},
transform: {
'^.+\\.[tj]s$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
},
],
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/packages/nx-prisma',
Expand Down
16 changes: 8 additions & 8 deletions packages/nx-prisma/package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{
"name": "@nx-tools/nx-prisma",
"version": "5.0.3",
"version": "6.0.0-alpha.1",
"type": "commonjs",
"author": "gperdomor <gperdomor@gmail.com>",
"contributors": [
"wSedlacek"
],
"repository": "https://github.com/gperdomor/nx-tools",
"bugs": "https://github.com/gperdomor/nx-tools/issues",
"license": "MIT",
"main": "src/index.js",
"generators": "./generators.json",
"main": "./src/index.js",
"typings": "./src/index.d.ts",
"executors": "./executors.json",
"generators": "./generators.json",
"dependencies": {
"@nx-tools/core": "5.0.3",
"semver": "7.5.4"
"@nx-tools/core": "6.0.0-alpha.1"
},
"peerDependencies": {
"@nx/devkit": "^16.0.0",
"@nx/workspace": "^16.0.0",
"prisma": "^4.5.0 || ^5.0.0",
"ts-node": "*",
"prisma": "^5.0.0",
"ts-node": "^10.0.0",
"tslib": "^2.5.3"
}
}
8 changes: 6 additions & 2 deletions packages/nx-prisma/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,19 @@
]
}
},
"publish": {
"command": "node tools/scripts/publish.mjs nx-prisma {args.ver} {args.tag}",
"dependsOn": ["build"]
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": [
"packages/nx-prisma/**/*.ts",
"packages/nx-prisma/generators.json",
"packages/nx-prisma/package.json",
"packages/nx-prisma/executors.json",
"packages/nx-prisma/package.json"
"packages/nx-prisma/generators.json"
]
}
},
Expand Down
12 changes: 10 additions & 2 deletions packages/nx-prisma/src/executors/deploy/schema.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/

import { PrismaBase } from '../../interfaces';

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface DeployExecutorSchema extends PrismaBase {}
/**
* Applies all pending migrations, and creates the database if it does not exist.
*/
export type DeployExecutorSchema = PrismaBase;
6 changes: 3 additions & 3 deletions packages/nx-prisma/src/executors/deploy/schema.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"$schema": "http://json-schema.org/schema",
"version": 2,
"title": "Prisma Deploy executor",
"description": "Apply pending migrations to update the database schema in production/staging.",
"title": "Prisma migrate deploy executor",
"description": "The migrate deploy command applies all pending migrations, and creates the database if it does not exist. Primarily used in non-development environments.",
"type": "object",
"properties": {
"schema": {
"type": "string",
"description": "The path to the prisma schema eg. 'prisma/schema.prisma'"
"description": "Specifies the path to the desired schema.prisma file to be processed instead of the default path. Both absolute and relative paths are supported."
}
},
"required": []
Expand Down
6 changes: 5 additions & 1 deletion packages/nx-prisma/src/executors/generate/executor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ExecutorContext } from '@nx/devkit';
import { getExecOutput } from '@nx-tools/core';
import { ExecutorContext } from '@nx/devkit';
import executor from './executor';
import { GenerateExecutorSchema } from './schema';

Expand All @@ -23,6 +23,10 @@ export const expectCommandToHaveBeenCalled = (cmd: string, args: string[]) => {
};

describe('Generate Executor', () => {
beforeEach(() => {
jest.spyOn(console, 'info').mockImplementation(() => true);
});

it('empty options', async () => {
const options: GenerateExecutorSchema = {};
const output = await executor(options, mockContext as ExecutorContext);
Expand Down
9 changes: 9 additions & 0 deletions packages/nx-prisma/src/executors/generate/schema.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/

import { PrismaBase } from '../../interfaces';

/**
* Generate artifacts (e.g. Prisma Client).
*/
export interface GenerateExecutorSchema extends PrismaBase {
/**
* The generate command will generate Prisma Client for use with the Data Proxy.
Expand Down
6 changes: 3 additions & 3 deletions packages/nx-prisma/src/executors/generate/schema.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"$schema": "http://json-schema.org/schema",
"version": 2,
"title": "Prisma Generate executor",
"description": "Generate artifacts (e.g. Prisma Client).",
"title": "Prisma generate executor",
"description": "The generate command generates assets like Prisma Client based on the generator and data model blocks defined in your schema.prisma file.",
"type": "object",
"properties": {
"schema": {
"type": "string",
"description": "The path to the prisma schema eg. 'prisma/schema.prisma'"
"description": "Specifies the path to the desired schema.prisma file to be processed instead of the default path. Both absolute and relative paths are supported."
},
"data-proxy": {
"type": "boolean",
Expand Down
4 changes: 4 additions & 0 deletions packages/nx-prisma/src/executors/migrate/executor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ const mockContext: Partial<ExecutorContext> = {
};

describe('Migrate Executor', () => {
beforeEach(() => {
jest.spyOn(console, 'info').mockImplementation(() => true);
});

it('empty options', async () => {
const options: MigrateExecutorSchema = { name: 'mig-name' };
const output = await executor(options, mockContext as ExecutorContext);
Expand Down
11 changes: 10 additions & 1 deletion packages/nx-prisma/src/executors/migrate/schema.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/

import { PrismaBase } from '../../interfaces';

/**
* Updates your database using migrations during development and creates the database if it does not exist.
*/
export interface MigrateExecutorSchema extends PrismaBase {
/**
* The name of the migration. If no name is provided, the CLI will prompt you.
* The name of the migration.
*/
name: string;
/**
Expand Down
8 changes: 4 additions & 4 deletions packages/nx-prisma/src/executors/migrate/schema.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"$schema": "http://json-schema.org/schema",
"version": 2,
"title": "Prisma Migrate executor",
"description": "Create a migration from changes in Prisma schema, apply it to the database, trigger generators (e.g. Prisma Client).",
"title": "Prisma migrate dev executor",
"description": "The migrate dev command updates your database using migrations during development and creates the database if it does not exist.",
"type": "object",
"properties": {
"schema": {
"type": "string",
"description": "The path to the prisma schema eg. 'prisma/schema.prisma'"
"description": "Specifies the path to the desired schema.prisma file to be processed instead of the default path. Both absolute and relative paths are supported."
},
"name": {
"type": "string",
"description": "The name of the migration. If no name is provided, the CLI will prompt you."
"description": "The name of the migration."
},
"create-only": {
"type": "boolean",
Expand Down
11 changes: 10 additions & 1 deletion packages/nx-prisma/src/executors/pull/schema.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/

import { PrismaBase } from '../../interfaces';

/**
* The db pull command connects to your database and adds Prisma models to your Prisma schema that reflect the current database schema.
*/
export interface PullExecutorSchema extends PrismaBase {
/**
* Force overwrite of manual changes made to schema.
* Force overwrite of manual changes made to schema. The generated schema will be based on the introspected schema only.
*/
force?: boolean;
/**
Expand Down
8 changes: 4 additions & 4 deletions packages/nx-prisma/src/executors/pull/schema.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"$schema": "http://json-schema.org/schema",
"version": 2,
"title": "Prisma Pull executor",
"description": "Pull the schema from an existing database, updating the Prisma schema.",
"title": "Prisma db pull executor",
"description": "The db pull command connects to your database and adds Prisma models to your Prisma schema that reflect the current database schema.",
"type": "object",
"properties": {
"schema": {
"type": "string",
"description": "The path to the prisma schema eg. 'prisma/schema.prisma'"
"description": "Specifies the path to the desired schema.prisma file to be processed instead of the default path. Both absolute and relative paths are supported."
},
"force": {
"type": "boolean",
"description": "Force overwrite of manual changes made to schema."
"description": "Force overwrite of manual changes made to schema. The generated schema will be based on the introspected schema only."
},
"print": {
"type": "boolean",
Expand Down
9 changes: 9 additions & 0 deletions packages/nx-prisma/src/executors/push/schema.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/

import { PrismaBase } from '../../interfaces';

/**
* The db push command pushes the state of your Prisma schema file to the database without using migrations. It creates the database if the database does not exist
*/
export interface PushExecutorSchema extends PrismaBase {
/**
* Skip generation of artifacts such as Prisma Client.
Expand Down
6 changes: 3 additions & 3 deletions packages/nx-prisma/src/executors/push/schema.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"$schema": "http://json-schema.org/schema",
"version": 2,
"title": "Push executor",
"description": "Push the Prisma schema state to the database.",
"title": "Prisma db push executor",
"description": "The db push command pushes the state of your Prisma schema file to the database without using migrations. It creates the database if the database does not exist.",
"type": "object",
"properties": {
"schema": {
"type": "string",
"description": "The path to the prisma schema eg. 'prisma/schema.prisma'"
"description": "Specifies the path to the desired schema.prisma file to be processed instead of the default path. Both absolute and relative paths are supported."
},
"skip-generate": {
"type": "boolean",
Expand Down
4 changes: 4 additions & 0 deletions packages/nx-prisma/src/executors/reset/executor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ const mockContext: Partial<ExecutorContext> = {
};

describe('Reset Executor', () => {
beforeEach(() => {
jest.spyOn(console, 'info').mockImplementation(() => true);
});

it('empty options', async () => {
const options: ResetExecutorSchema = { force: true };
const output = await executor(options, mockContext as ExecutorContext);
Expand Down
Loading

0 comments on commit d5dc51a

Please sign in to comment.