@jayfong/x-server 2.80.4 → 2.81.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.
@@ -186,8 +186,13 @@ class BuildUtil {
186
186
  onlyFiles: true,
187
187
  absolute: true
188
188
  });
189
+ const prismaCliBinaryTargets = options.prismaCliBinaryTargets?.split(',') || [];
189
190
  for (const libqueryEngineFile of libqueryEngineFiles) {
190
- await _fsExtra.default.copyFile(libqueryEngineFile, _nodePath.default.join(distDir, _nodePath.default.basename(libqueryEngineFile)));
191
+ const libqueryEngineFileBaseName = _nodePath.default.basename(libqueryEngineFile);
192
+ if (prismaCliBinaryTargets.length && prismaCliBinaryTargets.every(prismaCliBinaryTarget => !libqueryEngineFile.includes(prismaCliBinaryTarget))) {
193
+ break;
194
+ }
195
+ await _fsExtra.default.copyFile(libqueryEngineFile, _nodePath.default.join(distDir, libqueryEngineFileBaseName));
191
196
  }
192
197
  }
193
198
 
@@ -154,6 +154,11 @@ _yargs.default.command('dev', '开始开发', _ => _.positional('index', {
154
154
  describe: '构建完是否部署',
155
155
  type: 'boolean',
156
156
  default: false
157
+ }).positional('concurrency', {
158
+ alias: 'c',
159
+ describe: '同时构建的数量',
160
+ type: 'number',
161
+ default: 1
157
162
  }).positional('exclude', {
158
163
  alias: 'x',
159
164
  describe: '构建时排除的文件',
@@ -163,6 +168,7 @@ _yargs.default.command('dev', '开始开发', _ => _.positional('index', {
163
168
  await _env_util.EnvUtil.withChannel({
164
169
  cwd: process.cwd(),
165
170
  channel: argv.channel,
171
+ concurrency: argv.concurrency,
166
172
  cb: async channel => {
167
173
  process.env.NODE_ENV = 'production';
168
174
  const externals = (0, _vtils.castArray)(argv.external || []).flatMap(item => item.split(',')).filter(Boolean);
@@ -195,7 +201,8 @@ _yargs.default.command('dev', '开始开发', _ => _.positional('index', {
195
201
  onlyCode: true,
196
202
  beforeReplace: v => (0, _vtils.escapeRegExp)(v)
197
203
  });
198
- })
204
+ }),
205
+ prismaCliBinaryTargets: envMap.PRISMA_CLI_BINARY_TARGETS
199
206
  });
200
207
  console.log('构建成功');
201
208
  if (argv.deploy) {
@@ -38,23 +38,51 @@ class EnvUtil {
38
38
  return res.channel || undefined;
39
39
  }
40
40
  static async withChannel(options) {
41
+ const successChannels = [];
42
+ const failedChannels = [];
41
43
  if (options.channel?.startsWith('_')) {
42
44
  const excludeChannels = options.channel.split('!')[1]?.split(',').filter(Boolean);
43
45
  const channel = await EnvUtil.chooseChannel(options.cwd, excludeChannels);
44
46
  console.log(`========= ${channel} =========`);
45
- await options.cb(channel);
47
+ try {
48
+ await options.cb(channel);
49
+ successChannels.push(channel);
50
+ } catch (err) {
51
+ console.error(err);
52
+ failedChannels.push(channel);
53
+ }
46
54
  } else if (options.channel?.startsWith('@')) {
47
55
  const excludeChannels = options.channel.split('!')[1]?.split(',').filter(Boolean);
48
56
  const channels = await EnvUtil.getAllChannel(options.cwd, excludeChannels);
49
- for (const channel of channels) {
57
+ await Promise.all(channels.map((0, _vtils.asyncLimit)(async channel => {
50
58
  console.log(`========= ${channel} =========`);
51
- await options.cb(channel);
52
- }
59
+ try {
60
+ await options.cb(channel);
61
+ successChannels.push(channel);
62
+ } catch (err) {
63
+ console.error(err);
64
+ failedChannels.push(channel);
65
+ }
66
+ }, {
67
+ concurrency: options.concurrency || 1
68
+ })));
53
69
  } else {
54
70
  if (options.channel) {
55
71
  console.log(`========= ${options.channel} =========`);
56
72
  }
57
- await options.cb(options.channel);
73
+ try {
74
+ await options.cb(options.channel);
75
+ options.channel && successChannels.push(options.channel);
76
+ } catch (err) {
77
+ console.error(err);
78
+ options.channel && failedChannels.push(options.channel);
79
+ }
80
+ }
81
+ if (successChannels.length) {
82
+ console.log(`✅(${successChannels.length}):${JSON.stringify(successChannels)}`);
83
+ }
84
+ if (failedChannels.length) {
85
+ console.log(`❌(${failedChannels.length}):${JSON.stringify(failedChannels)}`);
58
86
  }
59
87
  }
60
88
  static getFile(env, channel, noBase) {
@@ -7,6 +7,7 @@ export interface BuildOptions {
7
7
  noInstall?: boolean;
8
8
  channel?: string;
9
9
  excludeFiles?: string[];
10
+ prismaCliBinaryTargets?: string;
10
11
  }
11
12
  export declare class BuildUtil {
12
13
  static build(options: BuildOptions): Promise<void>;
@@ -180,8 +180,13 @@ export class BuildUtil {
180
180
  onlyFiles: true,
181
181
  absolute: true
182
182
  });
183
+ const prismaCliBinaryTargets = options.prismaCliBinaryTargets?.split(',') || [];
183
184
  for (const libqueryEngineFile of libqueryEngineFiles) {
184
- await fs.copyFile(libqueryEngineFile, path.join(distDir, path.basename(libqueryEngineFile)));
185
+ const libqueryEngineFileBaseName = path.basename(libqueryEngineFile);
186
+ if (prismaCliBinaryTargets.length && prismaCliBinaryTargets.every(prismaCliBinaryTarget => !libqueryEngineFile.includes(prismaCliBinaryTarget))) {
187
+ break;
188
+ }
189
+ await fs.copyFile(libqueryEngineFile, path.join(distDir, libqueryEngineFileBaseName));
185
190
  }
186
191
  }
187
192
 
package/lib/cli/cli.js CHANGED
@@ -152,6 +152,11 @@ yargs.command('dev', '开始开发', _ => _.positional('index', {
152
152
  describe: '构建完是否部署',
153
153
  type: 'boolean',
154
154
  default: false
155
+ }).positional('concurrency', {
156
+ alias: 'c',
157
+ describe: '同时构建的数量',
158
+ type: 'number',
159
+ default: 1
155
160
  }).positional('exclude', {
156
161
  alias: 'x',
157
162
  describe: '构建时排除的文件',
@@ -161,6 +166,7 @@ yargs.command('dev', '开始开发', _ => _.positional('index', {
161
166
  await EnvUtil.withChannel({
162
167
  cwd: process.cwd(),
163
168
  channel: argv.channel,
169
+ concurrency: argv.concurrency,
164
170
  cb: async channel => {
165
171
  process.env.NODE_ENV = 'production';
166
172
  const externals = castArray(argv.external || []).flatMap(item => item.split(',')).filter(Boolean);
@@ -193,7 +199,8 @@ yargs.command('dev', '开始开发', _ => _.positional('index', {
193
199
  onlyCode: true,
194
200
  beforeReplace: v => escapeRegExp(v)
195
201
  });
196
- })
202
+ }),
203
+ prismaCliBinaryTargets: envMap.PRISMA_CLI_BINARY_TARGETS
197
204
  });
198
205
  console.log('构建成功');
199
206
  if (argv.deploy) {
@@ -14,6 +14,7 @@ export declare class EnvUtil {
14
14
  static withChannel(options: {
15
15
  cwd: string;
16
16
  channel?: string;
17
+ concurrency?: number;
17
18
  cb: (channel: string | undefined) => any;
18
19
  }): Promise<void>;
19
20
  static getFile(env?: string, channel?: string, noBase?: boolean): string[];
@@ -2,7 +2,7 @@ import path from 'node:path';
2
2
  import fs from 'fs-extra';
3
3
  import globby from 'globby';
4
4
  import inquirer from 'inquirer';
5
- import { dedent, difference, escapeRegExp, isPlainObject, uniq } from 'vtils';
5
+ import { asyncLimit, dedent, difference, escapeRegExp, isPlainObject, uniq } from 'vtils';
6
6
  import { parse as yamlParse } from 'yaml';
7
7
  export class EnvUtil {
8
8
  static async getAllChannel(cwd, excludeChannels) {
@@ -33,23 +33,51 @@ export class EnvUtil {
33
33
  return res.channel || undefined;
34
34
  }
35
35
  static async withChannel(options) {
36
+ const successChannels = [];
37
+ const failedChannels = [];
36
38
  if (options.channel?.startsWith('_')) {
37
39
  const excludeChannels = options.channel.split('!')[1]?.split(',').filter(Boolean);
38
40
  const channel = await EnvUtil.chooseChannel(options.cwd, excludeChannels);
39
41
  console.log(`========= ${channel} =========`);
40
- await options.cb(channel);
42
+ try {
43
+ await options.cb(channel);
44
+ successChannels.push(channel);
45
+ } catch (err) {
46
+ console.error(err);
47
+ failedChannels.push(channel);
48
+ }
41
49
  } else if (options.channel?.startsWith('@')) {
42
50
  const excludeChannels = options.channel.split('!')[1]?.split(',').filter(Boolean);
43
51
  const channels = await EnvUtil.getAllChannel(options.cwd, excludeChannels);
44
- for (const channel of channels) {
52
+ await Promise.all(channels.map(asyncLimit(async channel => {
45
53
  console.log(`========= ${channel} =========`);
46
- await options.cb(channel);
47
- }
54
+ try {
55
+ await options.cb(channel);
56
+ successChannels.push(channel);
57
+ } catch (err) {
58
+ console.error(err);
59
+ failedChannels.push(channel);
60
+ }
61
+ }, {
62
+ concurrency: options.concurrency || 1
63
+ })));
48
64
  } else {
49
65
  if (options.channel) {
50
66
  console.log(`========= ${options.channel} =========`);
51
67
  }
52
- await options.cb(options.channel);
68
+ try {
69
+ await options.cb(options.channel);
70
+ options.channel && successChannels.push(options.channel);
71
+ } catch (err) {
72
+ console.error(err);
73
+ options.channel && failedChannels.push(options.channel);
74
+ }
75
+ }
76
+ if (successChannels.length) {
77
+ console.log(`✅(${successChannels.length}):${JSON.stringify(successChannels)}`);
78
+ }
79
+ if (failedChannels.length) {
80
+ console.log(`❌(${failedChannels.length}):${JSON.stringify(failedChannels)}`);
53
81
  }
54
82
  }
55
83
  static getFile(env, channel, noBase) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayfong/x-server",
3
- "version": "2.80.4",
3
+ "version": "2.81.1",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "lib/_cjs/index.js",