@jayfong/x-server 2.86.0 → 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.
- package/lib/_cjs/cli/env_util.js +23 -20
- package/lib/cli/env_util.js +23 -20
- package/package.json +3 -5
package/lib/_cjs/cli/env_util.js
CHANGED
|
@@ -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,32 @@ 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
|
-
|
|
36
|
-
|
|
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 {
|
|
37
39
|
name: channel,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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({
|
|
48
50
|
message: '请选择渠道',
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
source: async input => {
|
|
52
|
+
return !input ? channelOptions : channelOptions.filter(channelOption => {
|
|
53
|
+
return channelOption.pinyin.includes(input) || channelOption.name.includes(input);
|
|
54
|
+
});
|
|
52
55
|
}
|
|
53
|
-
}
|
|
54
|
-
return
|
|
56
|
+
});
|
|
57
|
+
return selectedChannel || undefined;
|
|
55
58
|
}
|
|
56
59
|
static async withChannel(options) {
|
|
57
60
|
const successChannels = [];
|
package/lib/cli/env_util.js
CHANGED
|
@@ -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,32 @@ 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
|
-
|
|
31
|
-
|
|
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 {
|
|
32
34
|
name: channel,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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({
|
|
43
45
|
message: '请选择渠道',
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
source: async input => {
|
|
47
|
+
return !input ? channelOptions : channelOptions.filter(channelOption => {
|
|
48
|
+
return channelOption.pinyin.includes(input) || channelOption.name.includes(input);
|
|
49
|
+
});
|
|
47
50
|
}
|
|
48
|
-
}
|
|
49
|
-
return
|
|
51
|
+
});
|
|
52
|
+
return selectedChannel || undefined;
|
|
50
53
|
}
|
|
51
54
|
static async withChannel(options) {
|
|
52
55
|
const successChannels = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jayfong/x-server",
|
|
3
|
-
"version": "2.86.
|
|
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,7 +51,7 @@
|
|
|
53
51
|
"got": "^11.8.2",
|
|
54
52
|
"http-errors": "^2.0.0",
|
|
55
53
|
"inquirer": "^12.5.0",
|
|
56
|
-
"inquirer-
|
|
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",
|