@widget-js/cli 1.0.11 → 1.0.12
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/index.cjs +7 -10
- package/lib/index.js +7 -10
- package/package.json +3 -2
- package/src/ftp/ftp.ts +7 -10
package/lib/index.cjs
CHANGED
|
@@ -345,7 +345,7 @@ var import_os = __toESM(require("os"), 1);
|
|
|
345
345
|
var import_ssh2_sftp_client = __toESM(require("ssh2-sftp-client"), 1);
|
|
346
346
|
var import_consola2 = __toESM(require("consola"), 1);
|
|
347
347
|
var import_inquirer3 = __toESM(require("inquirer"), 1);
|
|
348
|
-
var
|
|
348
|
+
var import_ora = __toESM(require("ora"), 1);
|
|
349
349
|
var process2 = __toESM(require("process"), 1);
|
|
350
350
|
var console2 = __toESM(require("console"), 1);
|
|
351
351
|
function ftpUpload() {
|
|
@@ -364,7 +364,7 @@ function ftpUpload() {
|
|
|
364
364
|
let ftpClient = new import_ssh2_sftp_client.default();
|
|
365
365
|
const port = sshConfig["Port"];
|
|
366
366
|
const key = import_fs5.default.readFileSync(import_path3.default.resolve(import_os.default.homedir(), ".ssh/id_rsa"));
|
|
367
|
-
const spinner = (0,
|
|
367
|
+
const spinner = (0, import_ora.default)("Connecting");
|
|
368
368
|
try {
|
|
369
369
|
spinner.start();
|
|
370
370
|
await ftpClient.connect({
|
|
@@ -374,31 +374,28 @@ function ftpUpload() {
|
|
|
374
374
|
passphrase: answer.password,
|
|
375
375
|
privateKey: key
|
|
376
376
|
});
|
|
377
|
-
ftpClient.on("upload", (info) => {
|
|
378
|
-
spinner.update({ text: `Uploading: ${info.source}` });
|
|
379
|
-
});
|
|
380
377
|
for (let item of releaseConfig.fileMap) {
|
|
381
378
|
if (typeof item.src == "string") {
|
|
382
379
|
const localFile = import_path3.default.resolve(process2.cwd(), item.src);
|
|
383
380
|
if (!import_fs5.default.existsSync(localFile)) {
|
|
384
|
-
spinner.warn(
|
|
381
|
+
spinner.warn(`Skip not exists file:${localFile}`);
|
|
385
382
|
continue;
|
|
386
383
|
}
|
|
387
384
|
if (import_fs5.default.lstatSync(localFile).isDirectory()) {
|
|
388
|
-
spinner.
|
|
385
|
+
spinner.info(`Uploading Dir: ${localFile} -> ${item.dest}`);
|
|
389
386
|
await ftpClient.uploadDir(localFile, item.dest);
|
|
390
387
|
} else {
|
|
391
|
-
spinner.
|
|
388
|
+
spinner.info(`Uploading File: ${localFile} -> ${item.dest}`);
|
|
392
389
|
await ftpClient.put(localFile, item.dest);
|
|
393
390
|
}
|
|
394
391
|
} else {
|
|
395
392
|
await ftpClient.put(Buffer.from(JSON.stringify(item.src), "utf-8"), item.dest);
|
|
396
393
|
}
|
|
397
394
|
}
|
|
398
|
-
spinner.
|
|
395
|
+
spinner.succeed("Files uploaded!");
|
|
399
396
|
await ftpClient.end();
|
|
400
397
|
} catch (e) {
|
|
401
|
-
spinner.
|
|
398
|
+
spinner.fail(`Connection error:${e}`);
|
|
402
399
|
await ftpClient.end();
|
|
403
400
|
}
|
|
404
401
|
});
|
package/lib/index.js
CHANGED
|
@@ -324,7 +324,7 @@ import os from "os";
|
|
|
324
324
|
import Client from "ssh2-sftp-client";
|
|
325
325
|
import consola2 from "consola";
|
|
326
326
|
import inquirer3 from "inquirer";
|
|
327
|
-
import
|
|
327
|
+
import ora from "ora";
|
|
328
328
|
import * as process2 from "process";
|
|
329
329
|
import * as console2 from "console";
|
|
330
330
|
function ftpUpload() {
|
|
@@ -343,7 +343,7 @@ function ftpUpload() {
|
|
|
343
343
|
let ftpClient = new Client();
|
|
344
344
|
const port = sshConfig["Port"];
|
|
345
345
|
const key = fs5.readFileSync(path3.resolve(os.homedir(), ".ssh/id_rsa"));
|
|
346
|
-
const spinner =
|
|
346
|
+
const spinner = ora("Connecting");
|
|
347
347
|
try {
|
|
348
348
|
spinner.start();
|
|
349
349
|
await ftpClient.connect({
|
|
@@ -353,31 +353,28 @@ function ftpUpload() {
|
|
|
353
353
|
passphrase: answer.password,
|
|
354
354
|
privateKey: key
|
|
355
355
|
});
|
|
356
|
-
ftpClient.on("upload", (info) => {
|
|
357
|
-
spinner.update({ text: `Uploading: ${info.source}` });
|
|
358
|
-
});
|
|
359
356
|
for (let item of releaseConfig.fileMap) {
|
|
360
357
|
if (typeof item.src == "string") {
|
|
361
358
|
const localFile = path3.resolve(process2.cwd(), item.src);
|
|
362
359
|
if (!fs5.existsSync(localFile)) {
|
|
363
|
-
spinner.warn(
|
|
360
|
+
spinner.warn(`Skip not exists file:${localFile}`);
|
|
364
361
|
continue;
|
|
365
362
|
}
|
|
366
363
|
if (fs5.lstatSync(localFile).isDirectory()) {
|
|
367
|
-
spinner.
|
|
364
|
+
spinner.info(`Uploading Dir: ${localFile} -> ${item.dest}`);
|
|
368
365
|
await ftpClient.uploadDir(localFile, item.dest);
|
|
369
366
|
} else {
|
|
370
|
-
spinner.
|
|
367
|
+
spinner.info(`Uploading File: ${localFile} -> ${item.dest}`);
|
|
371
368
|
await ftpClient.put(localFile, item.dest);
|
|
372
369
|
}
|
|
373
370
|
} else {
|
|
374
371
|
await ftpClient.put(Buffer.from(JSON.stringify(item.src), "utf-8"), item.dest);
|
|
375
372
|
}
|
|
376
373
|
}
|
|
377
|
-
spinner.
|
|
374
|
+
spinner.succeed("Files uploaded!");
|
|
378
375
|
await ftpClient.end();
|
|
379
376
|
} catch (e) {
|
|
380
|
-
spinner.
|
|
377
|
+
spinner.fail(`Connection error:${e}`);
|
|
381
378
|
await ftpClient.end();
|
|
382
379
|
}
|
|
383
380
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@widget-js/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"author": "Neo Fu",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"figlet": "^1.5.2",
|
|
37
37
|
"gradient-string": "^2.0.2",
|
|
38
38
|
"inquirer": "^9.1.4",
|
|
39
|
-
"
|
|
39
|
+
"ora": "^6.2.0",
|
|
40
40
|
"shelljs": "^0.8.5",
|
|
41
41
|
"ssh-config": "file://D:\\workspace\\ssh-config",
|
|
42
42
|
"ssh2-sftp-client": "^9.0.4",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"@types/node": "^18.11.13",
|
|
56
56
|
"@types/shelljs": "latest",
|
|
57
57
|
"@types/ssh2-sftp-client": "^9.0.0",
|
|
58
|
+
"jest": "^29.5.0",
|
|
58
59
|
"pinst": "^3.0.0",
|
|
59
60
|
"prettier": "^2.8.4",
|
|
60
61
|
"ts-jest": "^29.0.3",
|
package/src/ftp/ftp.ts
CHANGED
|
@@ -5,7 +5,7 @@ import os from 'os'
|
|
|
5
5
|
import Client from 'ssh2-sftp-client'
|
|
6
6
|
import consola from 'consola'
|
|
7
7
|
import inquirer from 'inquirer'
|
|
8
|
-
import
|
|
8
|
+
import ora from 'ora'
|
|
9
9
|
import * as process from 'process'
|
|
10
10
|
import * as console from 'console'
|
|
11
11
|
|
|
@@ -31,7 +31,7 @@ export function ftpUpload() {
|
|
|
31
31
|
let ftpClient = new Client()
|
|
32
32
|
const port = sshConfig['Port']
|
|
33
33
|
const key = fs.readFileSync(path.resolve(os.homedir(), '.ssh/id_rsa'))
|
|
34
|
-
const spinner =
|
|
34
|
+
const spinner = ora('Connecting')
|
|
35
35
|
try {
|
|
36
36
|
spinner.start()
|
|
37
37
|
await ftpClient.connect({
|
|
@@ -41,32 +41,29 @@ export function ftpUpload() {
|
|
|
41
41
|
passphrase: answer.password,
|
|
42
42
|
privateKey: key,
|
|
43
43
|
})
|
|
44
|
-
ftpClient.on('upload', info => {
|
|
45
|
-
spinner.update({text: `Uploading: ${info.source}`})
|
|
46
|
-
})
|
|
47
44
|
// upload files
|
|
48
45
|
for (let item of releaseConfig.fileMap) {
|
|
49
46
|
if (typeof item.src == 'string') {
|
|
50
47
|
const localFile = path.resolve(process.cwd(), item.src as string)
|
|
51
48
|
if (!fs.existsSync(localFile)) {
|
|
52
|
-
spinner.warn(
|
|
49
|
+
spinner.warn(`Skip not exists file:${localFile}`)
|
|
53
50
|
continue
|
|
54
51
|
}
|
|
55
52
|
if (fs.lstatSync(localFile).isDirectory()) {
|
|
56
|
-
spinner.
|
|
53
|
+
spinner.info(`Uploading Dir: ${localFile} -> ${item.dest}`)
|
|
57
54
|
await ftpClient.uploadDir(localFile, item.dest)
|
|
58
55
|
} else {
|
|
59
|
-
spinner.
|
|
56
|
+
spinner.info(`Uploading File: ${localFile} -> ${item.dest}`)
|
|
60
57
|
await ftpClient.put(localFile, item.dest)
|
|
61
58
|
}
|
|
62
59
|
} else {
|
|
63
60
|
await ftpClient.put(Buffer.from(JSON.stringify(item.src), 'utf-8'), item.dest)
|
|
64
61
|
}
|
|
65
62
|
}
|
|
66
|
-
spinner.
|
|
63
|
+
spinner.succeed('Files uploaded!')
|
|
67
64
|
await ftpClient.end()
|
|
68
65
|
} catch (e) {
|
|
69
|
-
spinner.
|
|
66
|
+
spinner.fail(`Connection error:${e}`)
|
|
70
67
|
await ftpClient.end()
|
|
71
68
|
}
|
|
72
69
|
})
|