@jayfong/x-server 2.101.0 → 2.103.0

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.
@@ -367,12 +367,18 @@ _yargs.default.command('dev', '开始开发', _ => _.positional('index', {
367
367
  alias: 'h',
368
368
  describe: '渠道',
369
369
  type: 'string'
370
- }), deploy).command('get-channel', '获取渠道', async () => {
370
+ }), deploy).command('get-channel [file]', '获取渠道', _ => _.positional('file', {
371
+ describe: '写入文件',
372
+ type: 'string'
373
+ }), async argv => {
371
374
  await _env_util.EnvUtil.withChannel({
372
375
  cwd: process.cwd(),
373
376
  channel: '_',
374
377
  cb: async channel => {
375
- console.log(channel);
378
+ if (channel && argv.file) {
379
+ await _fsExtra.default.writeFile(_path.default.join(process.cwd(), argv.file), channel);
380
+ }
381
+ console.log(channel || '');
376
382
  }
377
383
  });
378
384
  }).parse();
@@ -64,7 +64,7 @@ class EnvUtil {
64
64
  const failedChannels = [];
65
65
  if (options.channel?.startsWith('_')) {
66
66
  const excludeChannels = options.channel.split('!')[1]?.split(',').filter(Boolean);
67
- const channel = await EnvUtil.chooseChannel(options.cwd, excludeChannels);
67
+ const channel = process.env.APP_CHANNEL || (await EnvUtil.chooseChannel(options.cwd, excludeChannels));
68
68
  console.log(`========= ${channel} =========`);
69
69
  try {
70
70
  await options.cb(channel);
package/lib/cli/cli.js CHANGED
@@ -364,12 +364,18 @@ yargs.command('dev', '开始开发', _ => _.positional('index', {
364
364
  alias: 'h',
365
365
  describe: '渠道',
366
366
  type: 'string'
367
- }), deploy).command('get-channel', '获取渠道', async () => {
367
+ }), deploy).command('get-channel [file]', '获取渠道', _ => _.positional('file', {
368
+ describe: '写入文件',
369
+ type: 'string'
370
+ }), async argv => {
368
371
  await EnvUtil.withChannel({
369
372
  cwd: process.cwd(),
370
373
  channel: '_',
371
374
  cb: async channel => {
372
- console.log(channel);
375
+ if (channel && argv.file) {
376
+ await fs.writeFile(path.join(process.cwd(), argv.file), channel);
377
+ }
378
+ console.log(channel || '');
373
379
  }
374
380
  });
375
381
  }).parse();
@@ -59,7 +59,7 @@ export class EnvUtil {
59
59
  const failedChannels = [];
60
60
  if (options.channel?.startsWith('_')) {
61
61
  const excludeChannels = options.channel.split('!')[1]?.split(',').filter(Boolean);
62
- const channel = await EnvUtil.chooseChannel(options.cwd, excludeChannels);
62
+ const channel = process.env.APP_CHANNEL || (await EnvUtil.chooseChannel(options.cwd, excludeChannels));
63
63
  console.log(`========= ${channel} =========`);
64
64
  try {
65
65
  await options.cb(channel);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayfong/x-server",
3
- "version": "2.101.0",
3
+ "version": "2.103.0",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "lib/_cjs/index.js",