zhixuan-plugin-cli 1.0.4 → 1.0.5
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/bin/index.js +3 -2
- package/commands/pull.js +16 -9
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -23,7 +23,8 @@ program
|
|
|
23
23
|
program
|
|
24
24
|
.command('pull')
|
|
25
25
|
.description('从智轩平台拉取插件')
|
|
26
|
-
.option('--
|
|
26
|
+
.option('--pluginId <pluginId>', '插件ID')
|
|
27
|
+
.option('-vNo, --versionNum <version>', '版本号')
|
|
27
28
|
.option('-t, --token <token>', '访问令牌')
|
|
28
29
|
.option('--server <server>', '服务器地址')
|
|
29
30
|
.option('-d, --dir <directory>', '下载到指定目录')
|
|
@@ -35,7 +36,7 @@ program
|
|
|
35
36
|
// 注册 createPage 命令 - 支持name和page参数
|
|
36
37
|
program
|
|
37
38
|
.command('createPage')
|
|
38
|
-
.description('
|
|
39
|
+
.description('添加一个新页面')
|
|
39
40
|
.option('--name <pageName>', '页面名称')
|
|
40
41
|
.option('--path <pagePath>', '页面路径')
|
|
41
42
|
.action((options) => {
|
package/commands/pull.js
CHANGED
|
@@ -21,11 +21,18 @@ module.exports = async function pull(options) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
// 获取版本ID
|
|
24
|
-
const
|
|
24
|
+
const pluginId = options.pluginId;
|
|
25
|
+
const versionNum = options.versionNum;
|
|
25
26
|
|
|
26
|
-
if (!
|
|
27
|
-
console.log(chalk.red('❌
|
|
28
|
-
console.log(chalk.cyan('请使用 --
|
|
27
|
+
if (!pluginId) {
|
|
28
|
+
console.log(chalk.red('❌ 未提供插件ID'));
|
|
29
|
+
console.log(chalk.cyan('请使用 --pluginId 插件ID'));
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (!versionNum) {
|
|
34
|
+
console.log(chalk.red('❌ 未提供版本号'));
|
|
35
|
+
console.log(chalk.cyan('请使用 --versionNum 插件版本号'));
|
|
29
36
|
return;
|
|
30
37
|
}
|
|
31
38
|
|
|
@@ -35,7 +42,7 @@ module.exports = async function pull(options) {
|
|
|
35
42
|
targetDir = path.resolve(options.dir);
|
|
36
43
|
} else {
|
|
37
44
|
// 默认使用版本ID作为目录名的一部分
|
|
38
|
-
targetDir = path.join(process.cwd(), `
|
|
45
|
+
targetDir = path.join(process.cwd(), `plugin_${pluginId}_${versionNum}`);
|
|
39
46
|
}
|
|
40
47
|
|
|
41
48
|
// 检查目录是否已存在
|
|
@@ -80,17 +87,17 @@ module.exports = async function pull(options) {
|
|
|
80
87
|
|
|
81
88
|
try {
|
|
82
89
|
// 构建下载API端点 - 使用版本ID
|
|
83
|
-
const downloadUrl = `${serverUrl.replace(/\/$/, '')}/api/ViewPlugin/version/download/${
|
|
90
|
+
const downloadUrl = `${serverUrl.replace(/\/$/, '')}/api/ViewPlugin/version/download/${pluginId}/${versionNum}`;
|
|
84
91
|
|
|
85
92
|
// 下载插件
|
|
86
|
-
await downloadPlugin(downloadUrl, token, targetDir,
|
|
93
|
+
await downloadPlugin(downloadUrl, token, targetDir, `${pluginId}_${versionNum}`);
|
|
87
94
|
|
|
88
95
|
spinner.succeed(chalk.green('插件下载成功!'));
|
|
89
96
|
|
|
90
97
|
console.log();
|
|
91
98
|
console.log(chalk.green('✅ 插件拉取成功!'));
|
|
92
99
|
console.log();
|
|
93
|
-
console.log(chalk.cyan(`版本ID: ${
|
|
100
|
+
console.log(chalk.cyan(`版本ID: ${versionNum}`));
|
|
94
101
|
console.log(chalk.cyan('插件已下载到: ' + targetDir));
|
|
95
102
|
console.log();
|
|
96
103
|
} catch (error) {
|
|
@@ -113,7 +120,7 @@ async function downloadPlugin(downloadUrl, token, targetDir, versionId) {
|
|
|
113
120
|
const AdmZip = require('adm-zip'); // 需要安装 adm-zip: npm install adm-zip
|
|
114
121
|
|
|
115
122
|
try {
|
|
116
|
-
console.log(chalk.yellow(`正在从 ${downloadUrl}
|
|
123
|
+
console.log(chalk.yellow(`正在从 ${downloadUrl} 下载 ${versionId}...`));
|
|
117
124
|
|
|
118
125
|
// 发起下载请求
|
|
119
126
|
const response = await axios({
|