ylyx-cli 1.0.3 → 1.0.4
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/deploy.js +12 -1
- package/package.json +1 -1
package/lib/deploy.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const crypto = require('crypto');
|
|
4
|
-
const Client = require('ssh2-sftp-client');
|
|
5
4
|
const ora = require('ora');
|
|
6
5
|
const prompts = require('prompts');
|
|
7
6
|
const archiver = require('archiver');
|
|
@@ -171,6 +170,18 @@ async function deploy(overrides = {}) {
|
|
|
171
170
|
if (!cfg.password) throw new Error('缺少 deploy.password(测试服上传需要,在 .ylyxrc.json 的 deploy 字段配置)');
|
|
172
171
|
if (!remoteFolderPath) throw new Error('缺少 deploy.remoteDir(测试服上传需要,在 .ylyxrc.json 的 deploy 字段配置)');
|
|
173
172
|
|
|
173
|
+
let Client;
|
|
174
|
+
try {
|
|
175
|
+
// 仅在需要“上传”时才加载,避免“正式服只压缩”也因为缺依赖而崩
|
|
176
|
+
Client = require('ssh2-sftp-client');
|
|
177
|
+
} catch (e) {
|
|
178
|
+
throw new Error(
|
|
179
|
+
"缺少依赖:ssh2-sftp-client。\n" +
|
|
180
|
+
"如果你在 ylyx-cli 仓库本地跑:请先在 ylyx-cli 目录执行 `npm i`。\n" +
|
|
181
|
+
"如果你用 npx:请确认你运行的是已发布且包含依赖的版本,或清理 npx 缓存后重试。"
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
174
185
|
const sftp = new Client();
|
|
175
186
|
try {
|
|
176
187
|
spinner = ora('连接服务器...').start();
|