@jayfong/x-server 2.0.0 → 2.1.1

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.
@@ -15,7 +15,7 @@ var _execa = _interopRequireDefault(require("execa"));
15
15
 
16
16
  var _fsExtra = _interopRequireDefault(require("fs-extra"));
17
17
 
18
- var _os = _interopRequireDefault(require("os"));
18
+ var _globby = _interopRequireDefault(require("globby"));
19
19
 
20
20
  var _nodePath = _interopRequireDefault(require("node:path"));
21
21
 
@@ -134,20 +134,21 @@ class BuildUtil {
134
134
  const prismaSchemaFile = _nodePath.default.join(options.cwd, 'src/db/schema.prisma');
135
135
 
136
136
  if (await _fsExtra.default.pathExists(prismaSchemaFile)) {
137
- // 下载 centos (rhel-openssl-1.0.x,rhel-openssl-1.1.x) 的可执行文件
138
- await (0, _execa.default)('tbify', ['node', require.resolve('@prisma/engines/download/index.js')], {
139
- env: {
140
- // https://www.prisma.io/docs/reference/api-reference/environment-variables-reference#prisma_cli_binary_targets
141
- // https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#binarytargets-options
142
- PRISMA_CLI_BINARY_TARGETS: `${_os.default.platform() === 'darwin' ? 'darwin' : 'windows'},rhel-openssl-1.0.x,rhel-openssl-1.1.x`
143
- }
144
- });
137
+ // 复制 schema.prisma
138
+ const distPrismaSchemaFile = _nodePath.default.join(distDir, _nodePath.default.basename(prismaSchemaFile));
145
139
 
146
- const distPrismaSchemaFile = _nodePath.default.join(distDir, 'schema.prisma');
140
+ await _fsExtra.default.copyFile(prismaSchemaFile, distPrismaSchemaFile); // 复制查询引擎
147
141
 
148
- await _fsExtra.default.copyFile(prismaSchemaFile, distPrismaSchemaFile);
149
- await _fsExtra.default.copyFile(require.resolve('@prisma/engines/libquery_engine-rhel-openssl-1.0.x.so.node'), _nodePath.default.join(distDir, 'libquery_engine-rhel-openssl-1.0.x.so.node'));
150
- await _fsExtra.default.copyFile(require.resolve('@prisma/engines/libquery_engine-rhel-openssl-1.1.x.so.node'), _nodePath.default.join(distDir, 'libquery_engine-rhel-openssl-1.1.x.so.node'));
142
+ const libqueryEngineFiles = await (0, _globby.default)('libquery_engine-*', {
143
+ cwd: _nodePath.default.join(options.cwd, 'node_modules/.prisma/client'),
144
+ ignore: ['libquery_engine-{darwin,windows}*'],
145
+ onlyFiles: true,
146
+ absolute: true
147
+ });
148
+
149
+ for (const libqueryEngineFile of libqueryEngineFiles) {
150
+ await _fsExtra.default.copyFile(libqueryEngineFile, _nodePath.default.join(distDir, _nodePath.default.basename(libqueryEngineFile)));
151
+ }
151
152
  } // 写入 pkg
152
153
 
153
154
 
@@ -1,9 +1,8 @@
1
1
  import * as esbuild from 'esbuild';
2
2
  import compressing from 'compressing';
3
3
  import exec from 'execa';
4
- import execa from 'execa';
5
4
  import fs from 'fs-extra';
6
- import os from 'os';
5
+ import globby from 'globby';
7
6
  import path from 'node:path';
8
7
  import { dedent, uniq } from 'vtils';
9
8
  export class BuildUtil {
@@ -108,18 +107,20 @@ export class BuildUtil {
108
107
  const prismaSchemaFile = path.join(options.cwd, 'src/db/schema.prisma');
109
108
 
110
109
  if (await fs.pathExists(prismaSchemaFile)) {
111
- // 下载 centos (rhel-openssl-1.0.x,rhel-openssl-1.1.x) 的可执行文件
112
- await execa('tbify', ['node', require.resolve('@prisma/engines/download/index.js')], {
113
- env: {
114
- // https://www.prisma.io/docs/reference/api-reference/environment-variables-reference#prisma_cli_binary_targets
115
- // https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#binarytargets-options
116
- PRISMA_CLI_BINARY_TARGETS: `${os.platform() === 'darwin' ? 'darwin' : 'windows'},rhel-openssl-1.0.x,rhel-openssl-1.1.x`
117
- }
110
+ // 复制 schema.prisma
111
+ const distPrismaSchemaFile = path.join(distDir, path.basename(prismaSchemaFile));
112
+ await fs.copyFile(prismaSchemaFile, distPrismaSchemaFile); // 复制查询引擎
113
+
114
+ const libqueryEngineFiles = await globby('libquery_engine-*', {
115
+ cwd: path.join(options.cwd, 'node_modules/.prisma/client'),
116
+ ignore: ['libquery_engine-{darwin,windows}*'],
117
+ onlyFiles: true,
118
+ absolute: true
118
119
  });
119
- const distPrismaSchemaFile = path.join(distDir, 'schema.prisma');
120
- await fs.copyFile(prismaSchemaFile, distPrismaSchemaFile);
121
- await fs.copyFile(require.resolve('@prisma/engines/libquery_engine-rhel-openssl-1.0.x.so.node'), path.join(distDir, 'libquery_engine-rhel-openssl-1.0.x.so.node'));
122
- await fs.copyFile(require.resolve('@prisma/engines/libquery_engine-rhel-openssl-1.1.x.so.node'), path.join(distDir, 'libquery_engine-rhel-openssl-1.1.x.so.node'));
120
+
121
+ for (const libqueryEngineFile of libqueryEngineFiles) {
122
+ await fs.copyFile(libqueryEngineFile, path.join(distDir, path.basename(libqueryEngineFile)));
123
+ }
123
124
  } // 写入 pkg
124
125
 
125
126
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayfong/x-server",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "lib/_cjs/index.js",
@@ -54,6 +54,7 @@
54
54
  "fastify-cors": "^6.0.3",
55
55
  "fastify-multipart": "^5.3.1",
56
56
  "fs-extra": "^10.0.1",
57
+ "globby": "^11",
57
58
  "got": "^11.8.2",
58
59
  "http-errors": "^1.8.1",
59
60
  "ioredis": "^4.28.5",