@jayfong/x-server 2.85.1 → 2.86.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.
File without changes
@@ -6,7 +6,7 @@ exports.EnvUtil = void 0;
6
6
  var _nodePath = _interopRequireDefault(require("node:path"));
7
7
  var _fsExtra = _interopRequireDefault(require("fs-extra"));
8
8
  var _globby = _interopRequireDefault(require("globby"));
9
- var _inquirer = _interopRequireDefault(require("inquirer"));
9
+ var _pinyinPro = require("pinyin-pro");
10
10
  var _vtils = require("vtils");
11
11
  var _yaml = require("yaml");
12
12
  class EnvUtil {
@@ -29,13 +29,32 @@ class EnvUtil {
29
29
  const channels = await EnvUtil.getAllChannel(cwd, excludeChannels);
30
30
  if (channels.length === 0) return undefined;
31
31
  if (channels.length === 1) return channels[0];
32
- const res = await _inquirer.default.prompt([{
33
- name: 'channel',
34
- type: 'select',
32
+ const channelOptions = channels.sort((a, b) => a.localeCompare(b, 'zh-CN')).map(channel => {
33
+ const channelPinyin = (0, _pinyinPro.pinyin)(channel, {
34
+ type: 'string',
35
+ pattern: 'initial',
36
+ separator: ''
37
+ });
38
+ return {
39
+ name: channel,
40
+ value: channel,
41
+ pinyin: channelPinyin,
42
+ description: `${channel}<${channelPinyin}>`
43
+ };
44
+ });
45
+ // @ts-ignore
46
+ const {
47
+ default: autocomplete
48
+ } = await import('inquirer-autocomplete-standalone');
49
+ const selectedChannel = await autocomplete({
35
50
  message: '请选择渠道',
36
- choices: channels
37
- }]);
38
- return res.channel || undefined;
51
+ source: async input => {
52
+ return !input ? channelOptions : channelOptions.filter(channelOption => {
53
+ return channelOption.pinyin.includes(input) || channelOption.name.includes(input);
54
+ });
55
+ }
56
+ });
57
+ return selectedChannel || undefined;
39
58
  }
40
59
  static async withChannel(options) {
41
60
  const successChannels = [];
@@ -1,7 +1,7 @@
1
1
  import path from 'node:path';
2
2
  import fs from 'fs-extra';
3
3
  import globby from 'globby';
4
- import inquirer from 'inquirer';
4
+ import { pinyin } from 'pinyin-pro';
5
5
  import { asyncLimit, dedent, difference, escapeRegExp, isPlainObject, uniq } from 'vtils';
6
6
  import { parse as yamlParse } from 'yaml';
7
7
  export class EnvUtil {
@@ -24,13 +24,32 @@ export class EnvUtil {
24
24
  const channels = await EnvUtil.getAllChannel(cwd, excludeChannels);
25
25
  if (channels.length === 0) return undefined;
26
26
  if (channels.length === 1) return channels[0];
27
- const res = await inquirer.prompt([{
28
- name: 'channel',
29
- type: 'select',
27
+ const channelOptions = channels.sort((a, b) => a.localeCompare(b, 'zh-CN')).map(channel => {
28
+ const channelPinyin = pinyin(channel, {
29
+ type: 'string',
30
+ pattern: 'initial',
31
+ separator: ''
32
+ });
33
+ return {
34
+ name: channel,
35
+ value: channel,
36
+ pinyin: channelPinyin,
37
+ description: `${channel}<${channelPinyin}>`
38
+ };
39
+ });
40
+ // @ts-ignore
41
+ const {
42
+ default: autocomplete
43
+ } = await import('inquirer-autocomplete-standalone');
44
+ const selectedChannel = await autocomplete({
30
45
  message: '请选择渠道',
31
- choices: channels
32
- }]);
33
- return res.channel || undefined;
46
+ source: async input => {
47
+ return !input ? channelOptions : channelOptions.filter(channelOption => {
48
+ return channelOption.pinyin.includes(input) || channelOption.name.includes(input);
49
+ });
50
+ }
51
+ });
52
+ return selectedChannel || undefined;
34
53
  }
35
54
  static async withChannel(options) {
36
55
  const successChannels = [];
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.1",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "lib/_cjs/index.js",
@@ -9,9 +9,7 @@
9
9
  "bin": {
10
10
  "xs": "lib/_cjs/cli/cli.js"
11
11
  },
12
- "files": [
13
- "lib"
14
- ],
12
+ "files": ["lib"],
15
13
  "scripts": {
16
14
  "build": "haoma compile",
17
15
  "build_test_pkg": "tyn build && rm -rf ./lib_test && mkdir -p ./lib_test && cp -r ./lib ./lib_test/lib && cp ./package.json ./lib_test/package.json && cd ./tests/app && tyn add file:../../lib_test",
@@ -53,6 +51,7 @@
53
51
  "got": "^11.8.2",
54
52
  "http-errors": "^2.0.0",
55
53
  "inquirer": "^12.5.0",
54
+ "inquirer-autocomplete-standalone": "^0.8.1",
56
55
  "ioredis": "^5.3.2",
57
56
  "jsonwebtoken": "^8.5.1",
58
57
  "lru-cache": "^10.0.0",
@@ -61,6 +60,7 @@
61
60
  "node-ssh": "^13.1.0",
62
61
  "nodemailer": "^6.7.3",
63
62
  "pino-pretty": "^10.0.1",
63
+ "pinyin-pro": "^3.26.0",
64
64
  "pirates": "^4.0.6",
65
65
  "prisma": "^6.3.1",
66
66
  "select-run": "^1.1.2",