@jayfong/x-server 2.85.1 → 2.86.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.
File without changes
@@ -7,8 +7,10 @@ var _nodePath = _interopRequireDefault(require("node:path"));
7
7
  var _fsExtra = _interopRequireDefault(require("fs-extra"));
8
8
  var _globby = _interopRequireDefault(require("globby"));
9
9
  var _inquirer = _interopRequireDefault(require("inquirer"));
10
+ var _pinyinPro = require("pinyin-pro");
10
11
  var _vtils = require("vtils");
11
12
  var _yaml = require("yaml");
13
+ _inquirer.default.registerPrompt('search-list', require('inquirer-search-list'));
12
14
  class EnvUtil {
13
15
  static async getAllChannel(cwd, excludeChannels) {
14
16
  const channelFiles = await (0, _globby.default)(['.env@*'], {
@@ -29,11 +31,25 @@ class EnvUtil {
29
31
  const channels = await EnvUtil.getAllChannel(cwd, excludeChannels);
30
32
  if (channels.length === 0) return undefined;
31
33
  if (channels.length === 1) return channels[0];
34
+ const channelOptions = channels.sort((a, b) => a.localeCompare(b, 'zh-CN')).map(channel => ({
35
+ name: channel,
36
+ value: {
37
+ name: channel,
38
+ pinyin: (0, _pinyinPro.pinyin)(channel, {
39
+ type: 'string',
40
+ pattern: 'initial',
41
+ separator: ''
42
+ })
43
+ }
44
+ }));
32
45
  const res = await _inquirer.default.prompt([{
33
46
  name: 'channel',
34
- type: 'select',
47
+ type: 'search-list',
35
48
  message: '请选择渠道',
36
- choices: channels
49
+ choices: channelOptions,
50
+ filterRow: (choice, query) => {
51
+ return !query ? true : choice.value.pinyin.includes(query) || choice.value.name.includes(query);
52
+ }
37
53
  }]);
38
54
  return res.channel || undefined;
39
55
  }
@@ -2,8 +2,10 @@ 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 { pinyin } from 'pinyin-pro';
5
6
  import { asyncLimit, dedent, difference, escapeRegExp, isPlainObject, uniq } from 'vtils';
6
7
  import { parse as yamlParse } from 'yaml';
8
+ inquirer.registerPrompt('search-list', require('inquirer-search-list'));
7
9
  export class EnvUtil {
8
10
  static async getAllChannel(cwd, excludeChannels) {
9
11
  const channelFiles = await globby(['.env@*'], {
@@ -24,11 +26,25 @@ export class EnvUtil {
24
26
  const channels = await EnvUtil.getAllChannel(cwd, excludeChannels);
25
27
  if (channels.length === 0) return undefined;
26
28
  if (channels.length === 1) return channels[0];
29
+ const channelOptions = channels.sort((a, b) => a.localeCompare(b, 'zh-CN')).map(channel => ({
30
+ name: channel,
31
+ value: {
32
+ name: channel,
33
+ pinyin: pinyin(channel, {
34
+ type: 'string',
35
+ pattern: 'initial',
36
+ separator: ''
37
+ })
38
+ }
39
+ }));
27
40
  const res = await inquirer.prompt([{
28
41
  name: 'channel',
29
- type: 'select',
42
+ type: 'search-list',
30
43
  message: '请选择渠道',
31
- choices: channels
44
+ choices: channelOptions,
45
+ filterRow: (choice, query) => {
46
+ return !query ? true : choice.value.pinyin.includes(query) || choice.value.name.includes(query);
47
+ }
32
48
  }]);
33
49
  return res.channel || undefined;
34
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayfong/x-server",
3
- "version": "2.85.1",
3
+ "version": "2.86.0",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "lib/_cjs/index.js",
@@ -53,6 +53,7 @@
53
53
  "got": "^11.8.2",
54
54
  "http-errors": "^2.0.0",
55
55
  "inquirer": "^12.5.0",
56
+ "inquirer-search-list": "^1.2.6",
56
57
  "ioredis": "^5.3.2",
57
58
  "jsonwebtoken": "^8.5.1",
58
59
  "lru-cache": "^10.0.0",
@@ -61,6 +62,7 @@
61
62
  "node-ssh": "^13.1.0",
62
63
  "nodemailer": "^6.7.3",
63
64
  "pino-pretty": "^10.0.1",
65
+ "pinyin-pro": "^3.26.0",
64
66
  "pirates": "^4.0.6",
65
67
  "prisma": "^6.3.1",
66
68
  "select-run": "^1.1.2",