@baeta/plugin-prisma 0.1.5 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js.map +1 -1
- package/package.json +12 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @baeta/plugin-prisma
|
|
2
2
|
|
|
3
|
+
## 1.0.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#189](https://github.com/andreisergiu98/baeta/pull/189) [`d500378`](https://github.com/andreisergiu98/baeta/commit/d500378198e0a9c48298c4242913bca8ad348228) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - add jsdocs
|
|
8
|
+
|
|
9
|
+
- [#165](https://github.com/andreisergiu98/baeta/pull/165) [`1334c2a`](https://github.com/andreisergiu98/baeta/commit/1334c2a866676c88f0f3d380b22133d81c4e98bc) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - mark as stable
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`d500378`](https://github.com/andreisergiu98/baeta/commit/d500378198e0a9c48298c4242913bca8ad348228), [`1334c2a`](https://github.com/andreisergiu98/baeta/commit/1334c2a866676c88f0f3d380b22133d81c4e98bc)]:
|
|
12
|
+
- @baeta/generator-sdk@1.0.0
|
|
13
|
+
- @baeta/plugin-exec@1.0.8
|
|
14
|
+
- @baeta/util-path@1.0.0
|
|
15
|
+
|
|
3
16
|
## 0.1.5
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,39 @@
|
|
|
1
1
|
import * as _baeta_generator_sdk from '@baeta/generator-sdk';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for the Prisma plugin
|
|
5
|
+
*/
|
|
3
6
|
interface PrismaPluginOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Whether to generate the Prisma client
|
|
9
|
+
* @defaultValue true
|
|
10
|
+
*/
|
|
4
11
|
generateClient?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Custom command to generate Prisma client
|
|
14
|
+
* @defaultValue 'prisma generate'
|
|
15
|
+
*/
|
|
5
16
|
generateCommand?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Path to the Prisma schema file
|
|
19
|
+
* @example 'prisma/schema.prisma'
|
|
20
|
+
*/
|
|
6
21
|
prismaSchema: string;
|
|
22
|
+
/**
|
|
23
|
+
* Path to the generated schema file for comparison
|
|
24
|
+
* Used to avoid unnecessary regeneration
|
|
25
|
+
* @example 'node_modules/@prisma/client/schema.prisma'
|
|
26
|
+
*/
|
|
7
27
|
generatedSchemaPath: string;
|
|
8
28
|
}
|
|
9
29
|
|
|
30
|
+
/**
|
|
31
|
+
* A plugin that manages Prisma client generation in your Baeta project.
|
|
32
|
+
* See https://baeta.io/docs/plugins/prisma
|
|
33
|
+
*
|
|
34
|
+
* @param options - Configuration options for the pagination plugin
|
|
35
|
+
* @returns A Baeta generator plugin
|
|
36
|
+
*/
|
|
10
37
|
declare function prismaPlugin(options: PrismaPluginOptions): _baeta_generator_sdk.GeneratorPluginV1<unknown>[];
|
|
11
38
|
|
|
12
39
|
export { type PrismaPluginOptions, prismaPlugin as default, prismaPlugin };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../lib/client-generator.ts","../index.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport type { Ctx, WatcherFile } from '@baeta/generator-sdk';\nimport { createExecPlugin } from '@baeta/plugin-exec';\nimport { resolve } from '@baeta/util-path';\nimport type { PrismaPluginOptions } from './options.ts';\n\nasync function compareSchemas(cwd: string, current: string, generated: string) {\n\tconst [currentSchema, generatedSchema] = await Promise.all([\n\t\treadFile(resolve(cwd, current), 'utf-8'),\n\t\treadFile(resolve(cwd, generated), 'utf-8').catch(() => null),\n\t]);\n\treturn currentSchema.replaceAll(' ', '') === generatedSchema?.replaceAll(' ', '');\n}\n\nexport function createPrismaClientPlugin(options: PrismaPluginOptions) {\n\tconst { prismaSchema, generateCommand, generatedSchemaPath } = options;\n\n\treturn createExecPlugin({\n\t\tname: 'prisma-client',\n\t\tactionName: 'Prisma client',\n\t\texec: generateCommand ?? 'prisma generate',\n\t\twatch: (generatorOptions, watcher, reload) => {\n\t\t\tconst prismaPath = resolve(generatorOptions.cwd, prismaSchema);\n\n\t\t\tconst handleChange = (file: WatcherFile) => {\n\t\t\t\tif (file.path === prismaPath) {\n\t\t\t\t\treload(file);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\twatcher.on('update', handleChange);\n\t\t\twatcher.on('delete', handleChange);\n\t\t},\n\t\tskip: async (ctx: Ctx) => {\n\t\t\tconst schema = resolve(ctx.generatorOptions.cwd, prismaSchema);\n\n\t\t\tif (ctx.watching && ctx.changedFile?.path !== schema) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif (!ctx.watching && generatedSchemaPath) {\n\t\t\t\treturn compareSchemas(ctx.generatorOptions.cwd, prismaSchema, generatedSchemaPath);\n\t\t\t}\n\n\t\t\treturn false;\n\t\t},\n\t});\n}\n","import { createPrismaClientPlugin } from './lib/client-generator.ts';\nimport type { PrismaPluginOptions } from './lib/options.ts';\n\nexport type { PrismaPluginOptions };\nexport default prismaPlugin;\n\nexport function prismaPlugin(options: PrismaPluginOptions) {\n\tif (options.generateClient === false) {\n\t\treturn [];\n\t}\n\treturn [createPrismaClientPlugin(options)];\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAEzB,SAAS,wBAAwB;AACjC,SAAS,eAAe;AAGxB,eAAe,eAAe,KAAa,SAAiB,WAAmB;AAC9E,QAAM,CAAC,eAAe,eAAe,IAAI,MAAM,QAAQ,IAAI;AAAA,IAC1D,SAAS,QAAQ,KAAK,OAAO,GAAG,OAAO;AAAA,IACvC,SAAS,QAAQ,KAAK,SAAS,GAAG,OAAO,EAAE,MAAM,MAAM,IAAI;AAAA,EAC5D,CAAC;AACD,SAAO,cAAc,WAAW,KAAK,EAAE,MAAM,iBAAiB,WAAW,KAAK,EAAE;AACjF;AAEO,SAAS,yBAAyB,SAA8B;AACtE,QAAM,EAAE,cAAc,iBAAiB,oBAAoB,IAAI;AAE/D,SAAO,iBAAiB;AAAA,IACvB,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,MAAM,mBAAmB;AAAA,IACzB,OAAO,CAAC,kBAAkB,SAAS,WAAW;AAC7C,YAAM,aAAa,QAAQ,iBAAiB,KAAK,YAAY;AAE7D,YAAM,eAAe,CAAC,SAAsB;AAC3C,YAAI,KAAK,SAAS,YAAY;AAC7B,iBAAO,IAAI;AAAA,QACZ;AAAA,MACD;AAEA,cAAQ,GAAG,UAAU,YAAY;AACjC,cAAQ,GAAG,UAAU,YAAY;AAAA,IAClC;AAAA,IACA,MAAM,OAAO,QAAa;AACzB,YAAM,SAAS,QAAQ,IAAI,iBAAiB,KAAK,YAAY;AAE7D,UAAI,IAAI,YAAY,IAAI,aAAa,SAAS,QAAQ;AACrD,eAAO;AAAA,MACR;AAEA,UAAI,CAAC,IAAI,YAAY,qBAAqB;AACzC,eAAO,eAAe,IAAI,iBAAiB,KAAK,cAAc,mBAAmB;AAAA,MAClF;AAEA,aAAO;AAAA,IACR;AAAA,EACD,CAAC;AACF;;;AC3CA,IAAO,wBAAQ;
|
|
1
|
+
{"version":3,"sources":["../lib/client-generator.ts","../index.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport type { Ctx, WatcherFile } from '@baeta/generator-sdk';\nimport { createExecPlugin } from '@baeta/plugin-exec';\nimport { resolve } from '@baeta/util-path';\nimport type { PrismaPluginOptions } from './options.ts';\n\nasync function compareSchemas(cwd: string, current: string, generated: string) {\n\tconst [currentSchema, generatedSchema] = await Promise.all([\n\t\treadFile(resolve(cwd, current), 'utf-8'),\n\t\treadFile(resolve(cwd, generated), 'utf-8').catch(() => null),\n\t]);\n\treturn currentSchema.replaceAll(' ', '') === generatedSchema?.replaceAll(' ', '');\n}\n\nexport function createPrismaClientPlugin(options: PrismaPluginOptions) {\n\tconst { prismaSchema, generateCommand, generatedSchemaPath } = options;\n\n\treturn createExecPlugin({\n\t\tname: 'prisma-client',\n\t\tactionName: 'Prisma client',\n\t\texec: generateCommand ?? 'prisma generate',\n\t\twatch: (generatorOptions, watcher, reload) => {\n\t\t\tconst prismaPath = resolve(generatorOptions.cwd, prismaSchema);\n\n\t\t\tconst handleChange = (file: WatcherFile) => {\n\t\t\t\tif (file.path === prismaPath) {\n\t\t\t\t\treload(file);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\twatcher.on('update', handleChange);\n\t\t\twatcher.on('delete', handleChange);\n\t\t},\n\t\tskip: async (ctx: Ctx) => {\n\t\t\tconst schema = resolve(ctx.generatorOptions.cwd, prismaSchema);\n\n\t\t\tif (ctx.watching && ctx.changedFile?.path !== schema) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif (!ctx.watching && generatedSchemaPath) {\n\t\t\t\treturn compareSchemas(ctx.generatorOptions.cwd, prismaSchema, generatedSchemaPath);\n\t\t\t}\n\n\t\t\treturn false;\n\t\t},\n\t});\n}\n","import { createPrismaClientPlugin } from './lib/client-generator.ts';\nimport type { PrismaPluginOptions } from './lib/options.ts';\n\nexport type { PrismaPluginOptions };\nexport default prismaPlugin;\n\n/**\n * A plugin that manages Prisma client generation in your Baeta project.\n * See https://baeta.io/docs/plugins/prisma\n *\n * @param options - Configuration options for the pagination plugin\n * @returns A Baeta generator plugin\n */\nexport function prismaPlugin(options: PrismaPluginOptions) {\n\tif (options.generateClient === false) {\n\t\treturn [];\n\t}\n\treturn [createPrismaClientPlugin(options)];\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAEzB,SAAS,wBAAwB;AACjC,SAAS,eAAe;AAGxB,eAAe,eAAe,KAAa,SAAiB,WAAmB;AAC9E,QAAM,CAAC,eAAe,eAAe,IAAI,MAA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version": "0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"baeta",
|
|
6
6
|
"graphql",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"types": "tsc --noEmit"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@baeta/generator-sdk": "^0.
|
|
47
|
-
"@baeta/plugin-exec": "^0.
|
|
48
|
-
"@baeta/util-path": "^0.
|
|
49
|
-
"execa": "^9.5.
|
|
46
|
+
"@baeta/generator-sdk": "^1.0.0",
|
|
47
|
+
"@baeta/plugin-exec": "^1.0.8",
|
|
48
|
+
"@baeta/util-path": "^1.0.0",
|
|
49
|
+
"execa": "^9.5.2"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@baeta/builder": "^0.0.0",
|
|
@@ -80,6 +80,12 @@
|
|
|
80
80
|
"./index.ts"
|
|
81
81
|
],
|
|
82
82
|
"readme": "none",
|
|
83
|
-
"tsconfig": "./tsconfig.json"
|
|
83
|
+
"tsconfig": "./tsconfig.json",
|
|
84
|
+
"sort": [
|
|
85
|
+
"kind",
|
|
86
|
+
"instance-first",
|
|
87
|
+
"required-first",
|
|
88
|
+
"alphabetical-ignoring-documents"
|
|
89
|
+
]
|
|
84
90
|
}
|
|
85
91
|
}
|