@jayfong/x-server 2.85.0 → 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.
- package/lib/_cjs/cli/cli.js +0 -0
- package/lib/_cjs/cli/dev_util.js +8 -1
- package/lib/_cjs/cli/env_util.js +18 -2
- package/lib/cli/dev_util.js +8 -1
- package/lib/cli/env_util.js +18 -2
- package/package.json +3 -1
package/lib/_cjs/cli/cli.js
CHANGED
|
File without changes
|
package/lib/_cjs/cli/dev_util.js
CHANGED
|
@@ -3,10 +3,17 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.DevUtil = void 0;
|
|
6
|
+
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
6
7
|
var _execa = _interopRequireDefault(require("execa"));
|
|
8
|
+
var _vtils = require("vtils");
|
|
7
9
|
class DevUtil {
|
|
8
10
|
static runFile(options) {
|
|
9
|
-
return options.runner === 'tsx' ? (0, _execa.default)('node', ['-r', require.resolve("./css_register"),
|
|
11
|
+
return options.runner === 'tsx' ? (0, _execa.default)('node', ['-r', require.resolve("./css_register"), (0, _vtils.ii)(() => {
|
|
12
|
+
const tsxPkgFile = require.resolve('tsx/package.json');
|
|
13
|
+
const tsxJsFile = tsxPkgFile.replace('/package.json', '/dist/cli.js');
|
|
14
|
+
const tsxCjsFile = tsxPkgFile.replace('/package.json', '/dist/cli.cjs');
|
|
15
|
+
return _nodeFs.default.existsSync(tsxCjsFile) ? tsxCjsFile : tsxJsFile;
|
|
16
|
+
}), options.file], {
|
|
10
17
|
cwd: options.cwd,
|
|
11
18
|
stdio: 'inherit'
|
|
12
19
|
}) : (0, _execa.default)('node', ['-r', require.resolve("./esbuild_register"), '-r', require.resolve("./css_register"), options.file], {
|
package/lib/_cjs/cli/env_util.js
CHANGED
|
@@ -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: '
|
|
47
|
+
type: 'search-list',
|
|
35
48
|
message: '请选择渠道',
|
|
36
|
-
choices:
|
|
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
|
}
|
package/lib/cli/dev_util.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
1
2
|
import execa from 'execa';
|
|
3
|
+
import { ii } from 'vtils';
|
|
2
4
|
export class DevUtil {
|
|
3
5
|
static runFile(options) {
|
|
4
|
-
return options.runner === 'tsx' ? execa('node', ['-r', require.resolve("./css_register"),
|
|
6
|
+
return options.runner === 'tsx' ? execa('node', ['-r', require.resolve("./css_register"), ii(() => {
|
|
7
|
+
const tsxPkgFile = require.resolve('tsx/package.json');
|
|
8
|
+
const tsxJsFile = tsxPkgFile.replace('/package.json', '/dist/cli.js');
|
|
9
|
+
const tsxCjsFile = tsxPkgFile.replace('/package.json', '/dist/cli.cjs');
|
|
10
|
+
return fs.existsSync(tsxCjsFile) ? tsxCjsFile : tsxJsFile;
|
|
11
|
+
}), options.file], {
|
|
5
12
|
cwd: options.cwd,
|
|
6
13
|
stdio: 'inherit'
|
|
7
14
|
}) : execa('node', ['-r', require.resolve("./esbuild_register"), '-r', require.resolve("./css_register"), options.file], {
|
package/lib/cli/env_util.js
CHANGED
|
@@ -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: '
|
|
42
|
+
type: 'search-list',
|
|
30
43
|
message: '请选择渠道',
|
|
31
|
-
choices:
|
|
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.
|
|
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",
|