@jayfong/x-server 2.86.0 → 2.86.2

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,11 +6,9 @@ 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"));
10
9
  var _pinyinPro = require("pinyin-pro");
11
10
  var _vtils = require("vtils");
12
11
  var _yaml = require("yaml");
13
- _inquirer.default.registerPrompt('search-list', require('inquirer-search-list'));
14
12
  class EnvUtil {
15
13
  static async getAllChannel(cwd, excludeChannels) {
16
14
  const channelFiles = await (0, _globby.default)(['.env@*'], {
@@ -31,27 +29,34 @@ class EnvUtil {
31
29
  const channels = await EnvUtil.getAllChannel(cwd, excludeChannels);
32
30
  if (channels.length === 0) return undefined;
33
31
  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: {
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: 'first',
36
+ separator: '',
37
+ removeNonZh: false,
38
+ nonZh: 'consecutive'
39
+ });
40
+ return {
37
41
  name: channel,
38
- pinyin: (0, _pinyinPro.pinyin)(channel, {
39
- type: 'string',
40
- pattern: 'initial',
41
- separator: ''
42
- })
43
- }
44
- }));
45
- const res = await _inquirer.default.prompt([{
46
- name: 'channel',
47
- type: 'search-list',
42
+ value: channel,
43
+ pinyin: channelPinyin,
44
+ description: `${channel}<${channelPinyin}>`
45
+ };
46
+ });
47
+ // @ts-ignore
48
+ const {
49
+ default: autocomplete
50
+ } = await import('inquirer-autocomplete-standalone');
51
+ const selectedChannel = await autocomplete({
48
52
  message: '请选择渠道',
49
- choices: channelOptions,
50
- filterRow: (choice, query) => {
51
- return !query ? true : choice.value.pinyin.includes(query) || choice.value.name.includes(query);
53
+ source: async input => {
54
+ return !input ? channelOptions : channelOptions.filter(channelOption => {
55
+ return channelOption.pinyin.includes(input) || channelOption.name.includes(input);
56
+ });
52
57
  }
53
- }]);
54
- return res.channel || undefined;
58
+ });
59
+ return selectedChannel || undefined;
55
60
  }
56
61
  static async withChannel(options) {
57
62
  const successChannels = [];
@@ -1,11 +1,9 @@
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';
5
4
  import { pinyin } from 'pinyin-pro';
6
5
  import { asyncLimit, dedent, difference, escapeRegExp, isPlainObject, uniq } from 'vtils';
7
6
  import { parse as yamlParse } from 'yaml';
8
- inquirer.registerPrompt('search-list', require('inquirer-search-list'));
9
7
  export class EnvUtil {
10
8
  static async getAllChannel(cwd, excludeChannels) {
11
9
  const channelFiles = await globby(['.env@*'], {
@@ -26,27 +24,34 @@ export class EnvUtil {
26
24
  const channels = await EnvUtil.getAllChannel(cwd, excludeChannels);
27
25
  if (channels.length === 0) return undefined;
28
26
  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: {
27
+ const channelOptions = channels.sort((a, b) => a.localeCompare(b, 'zh-CN')).map(channel => {
28
+ const channelPinyin = pinyin(channel, {
29
+ type: 'string',
30
+ pattern: 'first',
31
+ separator: '',
32
+ removeNonZh: false,
33
+ nonZh: 'consecutive'
34
+ });
35
+ return {
32
36
  name: channel,
33
- pinyin: pinyin(channel, {
34
- type: 'string',
35
- pattern: 'initial',
36
- separator: ''
37
- })
38
- }
39
- }));
40
- const res = await inquirer.prompt([{
41
- name: 'channel',
42
- type: 'search-list',
37
+ value: channel,
38
+ pinyin: channelPinyin,
39
+ description: `${channel}<${channelPinyin}>`
40
+ };
41
+ });
42
+ // @ts-ignore
43
+ const {
44
+ default: autocomplete
45
+ } = await import('inquirer-autocomplete-standalone');
46
+ const selectedChannel = await autocomplete({
43
47
  message: '请选择渠道',
44
- choices: channelOptions,
45
- filterRow: (choice, query) => {
46
- return !query ? true : choice.value.pinyin.includes(query) || choice.value.name.includes(query);
48
+ source: async input => {
49
+ return !input ? channelOptions : channelOptions.filter(channelOption => {
50
+ return channelOption.pinyin.includes(input) || channelOption.name.includes(input);
51
+ });
47
52
  }
48
- }]);
49
- return res.channel || undefined;
53
+ });
54
+ return selectedChannel || undefined;
50
55
  }
51
56
  static async withChannel(options) {
52
57
  const successChannels = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayfong/x-server",
3
- "version": "2.86.0",
3
+ "version": "2.86.2",
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,7 +51,7 @@
53
51
  "got": "^11.8.2",
54
52
  "http-errors": "^2.0.0",
55
53
  "inquirer": "^12.5.0",
56
- "inquirer-search-list": "^1.2.6",
54
+ "inquirer-autocomplete-standalone": "^0.8.1",
57
55
  "ioredis": "^5.3.2",
58
56
  "jsonwebtoken": "^8.5.1",
59
57
  "lru-cache": "^10.0.0",