@baeta/plugin-prisma 0.0.17 → 0.0.18
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 +10 -0
- package/dist/index.cjs +11 -6
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -0
- package/package.json +14 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @baeta/plugin-prisma
|
|
2
2
|
|
|
3
|
+
## 0.0.18
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#66](https://github.com/andreisergiu98/baeta/pull/66) [`9a4a021`](https://github.com/andreisergiu98/baeta/commit/9a4a0214351b70295ce4f7eecaa8c49ab0e1325b) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - replace chokidar with @parcel/watcher
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`9a4a021`](https://github.com/andreisergiu98/baeta/commit/9a4a0214351b70295ce4f7eecaa8c49ab0e1325b)]:
|
|
10
|
+
- @baeta/generator-sdk@0.0.8
|
|
11
|
+
- @baeta/plugin-exec@0.0.6
|
|
12
|
+
|
|
3
13
|
## 0.0.17
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// lib/client-generator.ts
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// lib/client-generator.ts
|
|
2
2
|
var _pluginexec = require('@baeta/plugin-exec');
|
|
3
3
|
var _promises = require('fs/promises');
|
|
4
4
|
var _path = require('path');
|
|
@@ -13,7 +13,7 @@ function createPrismaClientPlugin(options) {
|
|
|
13
13
|
const { prismaSchema, generateCommand, generatedSchemaPath } = options;
|
|
14
14
|
const skip = async (ctx) => {
|
|
15
15
|
const schema = _path.resolve.call(void 0, ctx.generatorOptions.cwd, prismaSchema);
|
|
16
|
-
if (ctx.watching && ctx.changedFile !== schema) {
|
|
16
|
+
if (ctx.watching && _optionalChain([ctx, 'access', _ => _.changedFile, 'optionalAccess', _2 => _2.path]) !== schema) {
|
|
17
17
|
return true;
|
|
18
18
|
}
|
|
19
19
|
if (!ctx.watching && generatedSchemaPath) {
|
|
@@ -25,11 +25,15 @@ function createPrismaClientPlugin(options) {
|
|
|
25
25
|
name: "prisma-client",
|
|
26
26
|
actionName: "Prisma client",
|
|
27
27
|
exec: _nullishCoalesce(generateCommand, () => ( "prisma generate")),
|
|
28
|
-
watch: (generatorOptions) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
watch: (generatorOptions, watcher, reload) => {
|
|
29
|
+
const prismaPath = _path.resolve.call(void 0, generatorOptions.cwd, prismaSchema);
|
|
30
|
+
const handleChange = (file) => {
|
|
31
|
+
if (file.path === prismaPath) {
|
|
32
|
+
reload(file);
|
|
33
|
+
}
|
|
32
34
|
};
|
|
35
|
+
watcher.on("update", handleChange);
|
|
36
|
+
watcher.on("delete", handleChange);
|
|
33
37
|
},
|
|
34
38
|
skip
|
|
35
39
|
});
|
|
@@ -47,3 +51,4 @@ function prismaPlugin(options) {
|
|
|
47
51
|
|
|
48
52
|
|
|
49
53
|
exports.default = plugin_prisma_default; exports.prismaPlugin = prismaPlug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SAA8B;AACzD,MAAI,QAAQ,mBAAmB,OAAO;AACpC,WAAO,CAAC;AAAA,EACV;AACA,SAAO,CAAC,yBAAyB,OAAO,CAAC;AAC3C","sourcesContent":["import { Ctx, WatcherFile } from '@baeta/generator-sdk';\nimport { createExecPlugin } from '@baeta/plugin-exec';\nimport { readFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { PrismaPluginOptions } from './options';\n\nasync function compareSchemas(cwd: string, current: string, generated: string) {\n const [currentSchema, generatedSchema] = await Promise.all([\n readFile(resolve(cwd, current), 'utf-8'),\n readFile(resolve(cwd, generated), 'utf-8').catch(() => null),\n ]);\n return currentSchema === generatedSchema;\n}\n\nexport function createPrismaClientPlugin(options: PrismaPluginOptions) {\n const { prismaSchema, generateCommand, generatedSchemaPath } = options;\n\n const skip = async (ctx: Ctx) => {\n const schema = resolve(ctx.generatorOptions.cwd, prismaSchema);\n\n if (ctx.watching && ctx.changedFile?.path !== schema) {\n return true;\n }\n\n if (!ctx.watching && generatedSchemaPath) {\n return compareSchemas(ctx.generatorOptions.cwd, prismaSchema, generatedSchemaPath);\n }\n\n return false;\n };\n\n return createExecPlugin({\n name: 'prisma-client',\n actionName: 'Prisma client',\n exec: generateCommand ?? 'prisma generate',\n watch: (generatorOptions, watcher, reload) => {\n const prismaPath = resolve(generatorOptions.cwd, prismaSchema);\n\n const handleChange = (file: WatcherFile) => {\n if (file.path === prismaPath) {\n reload(file);\n }\n };\n\n watcher.on('update', handleChange);\n watcher.on('delete', handleChange);\n },\n skip,\n });\n}\n","import { createPrismaClientPlugin } from './lib/client-generator';\nimport { PrismaPluginOptions } from './lib/options';\n\nexport type { PrismaPluginOptions };\nexport default prismaPlugin;\n\nexport function prismaPlugin(options: PrismaPluginOptions) {\n if (options.generateClient === false) {\n return [];\n }\n return [createPrismaClientPlugin(options)];\n}\n"]}
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ function createPrismaClientPlugin(options) {
|
|
|
13
13
|
const { prismaSchema, generateCommand, generatedSchemaPath } = options;
|
|
14
14
|
const skip = async (ctx) => {
|
|
15
15
|
const schema = resolve(ctx.generatorOptions.cwd, prismaSchema);
|
|
16
|
-
if (ctx.watching && ctx.changedFile !== schema) {
|
|
16
|
+
if (ctx.watching && ctx.changedFile?.path !== schema) {
|
|
17
17
|
return true;
|
|
18
18
|
}
|
|
19
19
|
if (!ctx.watching && generatedSchemaPath) {
|
|
@@ -25,11 +25,15 @@ function createPrismaClientPlugin(options) {
|
|
|
25
25
|
name: "prisma-client",
|
|
26
26
|
actionName: "Prisma client",
|
|
27
27
|
exec: generateCommand ?? "prisma generate",
|
|
28
|
-
watch: (generatorOptions) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
watch: (generatorOptions, watcher, reload) => {
|
|
29
|
+
const prismaPath = resolve(generatorOptions.cwd, prismaSchema);
|
|
30
|
+
const handleChange = (file) => {
|
|
31
|
+
if (file.path === prismaPath) {
|
|
32
|
+
reload(file);
|
|
33
|
+
}
|
|
32
34
|
};
|
|
35
|
+
watcher.on("update", handleChange);
|
|
36
|
+
watcher.on("delete", handleChange);
|
|
33
37
|
},
|
|
34
38
|
skip
|
|
35
39
|
});
|
|
@@ -47,3 +51,4 @@ export {
|
|
|
47
51
|
plugin_prisma_default as default,
|
|
48
52
|
prismaPlugin
|
|
49
53
|
};
|
|
54
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../lib/client-generator.ts","../index.ts"],"sourcesContent":["import { Ctx, WatcherFile } from '@baeta/generator-sdk';\nimport { createExecPlugin } from '@baeta/plugin-exec';\nimport { readFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { PrismaPluginOptions } from './options';\n\nasync function compareSchemas(cwd: string, current: string, generated: string) {\n const [currentSchema, generatedSchema] = await Promise.all([\n readFile(resolve(cwd, current), 'utf-8'),\n readFile(resolve(cwd, generated), 'utf-8').catch(() => null),\n ]);\n return currentSchema === generatedSchema;\n}\n\nexport function createPrismaClientPlugin(options: PrismaPluginOptions) {\n const { prismaSchema, generateCommand, generatedSchemaPath } = options;\n\n const skip = async (ctx: Ctx) => {\n const schema = resolve(ctx.generatorOptions.cwd, prismaSchema);\n\n if (ctx.watching && ctx.changedFile?.path !== schema) {\n return true;\n }\n\n if (!ctx.watching && generatedSchemaPath) {\n return compareSchemas(ctx.generatorOptions.cwd, prismaSchema, generatedSchemaPath);\n }\n\n return false;\n };\n\n return createExecPlugin({\n name: 'prisma-client',\n actionName: 'Prisma client',\n exec: generateCommand ?? 'prisma generate',\n watch: (generatorOptions, watcher, reload) => {\n const prismaPath = resolve(generatorOptions.cwd, prismaSchema);\n\n const handleChange = (file: WatcherFile) => {\n if (file.path === prismaPath) {\n reload(file);\n }\n };\n\n watcher.on('update', handleChange);\n watcher.on('delete', handleChange);\n },\n skip,\n });\n}\n","import { createPrismaClientPlugin } from './lib/client-generator';\nimport { PrismaPluginOptions } from './lib/options';\n\nexport type { PrismaPluginOptions };\nexport default prismaPlugin;\n\nexport function prismaPlugin(options: PrismaPluginOptions) {\n if (options.generateClient === false) {\n return [];\n }\n return [createPrismaClientPlugin(options)];\n}\n"],"mappings":";AACA,SAAS,wBAAwB;AACjC,SAAS,gBAAgB;AACzB,SAAS,eAAe;AAGxB,eAAe,eAAe,KAAa,SAAiB,WAAmB;AAC7E,QAAM,CAAC,eAAe,eAAe,IAAI,MAAM,QAAQ,IAAI;AAAA,IACzD,SAAS,QAAQ,KAAK,OAAO,GAAG,OAAO;AAAA,IACvC,SAAS,QAAQ,KAAK,SAAS,GAAG,OAAO,EAAE,MAAM,MAAM,IAAI;AAAA,EAC7D,CAAC;AACD,SAAO,kBAAkB;AAC3B;AAEO,SAAS,yBAAyB,SAA8B;AACrE,QAAM,EAAE,cAAc,iBAAiB,oBAAoB,IAAI;AAE/D,QAAM,OAAO,OAAO,QAAa;AAC/B,UAAM,SAAS,QAAQ,IAAI,iBAAiB,KAAK,YAAY;AAE7D,QAAI,IAAI,YAAY,IAAI,aAAa,SAAS,QAAQ;AACpD,aAAO;AAAA,IACT;AAEA,QAAI,CAAC,IAAI,YAAY,qBAAqB;AACxC,aAAO,eAAe,IAAI,iBAAiB,KAAK,cAAc,mBAAmB;AAAA,IACnF;AAEA,WAAO;AAAA,EACT;AAEA,SAAO,iBAAiB;AAAA,IACtB,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,MAAM,mBAAmB;AAAA,IACzB,OAAO,CAAC,kBAAkB,SAAS,WAAW;AAC5C,YAAM,aAAa,QAAQ,iBAAiB,KAAK,YAAY;AAE7D,YAAM,eAAe,CAAC,SAAsB;AAC1C,YAAI,KAAK,SAAS,YAAY;AAC5B,iBAAO,IAAI;AAAA,QACb;AAAA,MACF;AAEA,cAAQ,GAAG,UAAU,YAAY;AACjC,cAAQ,GAAG,UAAU,YAAY;AAAA,IACnC;AAAA,IACA;AAAA,EACF,CAAC;AACH;;;AC7CA,IAAO,wBAAQ;AAER,SAAS,aAAa,SAA8B;AACzD,MAAI,QAAQ,mBAAmB,OAAO;AACpC,WAAO,CAAC;AAAA,EACV;AACA,SAAO,CAAC,yBAAyB,OAAO,CAAC;AAC3C;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@baeta/plugin-prisma",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"homepage": "https://github.com/andreisergiu98/baeta#readme",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/andreisergiu98/baeta/issues"
|
|
@@ -13,19 +13,28 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"author": "Andrei Pampu <pampu.andrei@pm.me>",
|
|
15
15
|
"type": "module",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"require": "./dist/index.cjs",
|
|
20
|
+
"types": "./dist/index.d.ts"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"types": "dist/index.d.ts",
|
|
16
24
|
"files": [
|
|
17
25
|
"dist",
|
|
18
26
|
"package.json"
|
|
19
27
|
],
|
|
20
28
|
"scripts": {
|
|
21
29
|
"build": "tsup",
|
|
30
|
+
"dev": "tsup --watch",
|
|
22
31
|
"prepack": "prep",
|
|
23
32
|
"postpack": "prep --clean",
|
|
24
33
|
"types": "tsc --noEmit"
|
|
25
34
|
},
|
|
26
35
|
"dependencies": {
|
|
27
|
-
"@baeta/generator-sdk": "^0.0.
|
|
28
|
-
"@baeta/plugin-exec": "^0.0.
|
|
36
|
+
"@baeta/generator-sdk": "^0.0.8",
|
|
37
|
+
"@baeta/plugin-exec": "^0.0.6",
|
|
29
38
|
"execa": "^6.1.0"
|
|
30
39
|
},
|
|
31
40
|
"devDependencies": {
|
|
@@ -38,22 +47,6 @@
|
|
|
38
47
|
"node": ">=18.0.0"
|
|
39
48
|
},
|
|
40
49
|
"publishConfig": {
|
|
41
|
-
"access": "public"
|
|
42
|
-
|
|
43
|
-
".": {
|
|
44
|
-
"import": "./dist/index.js",
|
|
45
|
-
"require": "./dist/index.cjs",
|
|
46
|
-
"types": "./dist/index.d.ts"
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
"types": "dist/index.d.ts"
|
|
50
|
-
},
|
|
51
|
-
"exports": {
|
|
52
|
-
".": {
|
|
53
|
-
"import": "./dist/index.js",
|
|
54
|
-
"require": "./dist/index.cjs",
|
|
55
|
-
"types": "./dist/index.d.ts"
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
"types": "dist/index.d.ts"
|
|
50
|
+
"access": "public"
|
|
51
|
+
}
|
|
59
52
|
}
|