@qodalis/cli-scp 2.0.0-beta.11 → 2.0.0-beta.13
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/package.json +2 -2
- package/public-api.d.mts +1 -1
- package/public-api.d.ts +1 -1
- package/public-api.js +31 -24
- package/public-api.js.map +1 -1
- package/public-api.mjs +32 -25
- package/public-api.mjs.map +1 -1
- package/umd/index.global.js +41 -25
package/umd/index.global.js
CHANGED
|
@@ -1822,6 +1822,10 @@ var scp = (() => {
|
|
|
1822
1822
|
}
|
|
1823
1823
|
});
|
|
1824
1824
|
var ICliFileTransferService_TOKEN = "cli-file-transfer-service";
|
|
1825
|
+
function resolveHeaders(provider) {
|
|
1826
|
+
if (!provider) return {};
|
|
1827
|
+
return typeof provider === "function" ? provider() : provider;
|
|
1828
|
+
}
|
|
1825
1829
|
var DefaultLibraryAuthor = {
|
|
1826
1830
|
name: "Nicolae Lupei",
|
|
1827
1831
|
email: "nicolae.lupei@qodalis.com"
|
|
@@ -1848,9 +1852,12 @@ var scp = (() => {
|
|
|
1848
1852
|
* Returns the negotiated API version and the base path for all subsequent calls,
|
|
1849
1853
|
* or null if the server is unreachable or incompatible.
|
|
1850
1854
|
*/
|
|
1851
|
-
static async discover(baseUrl) {
|
|
1855
|
+
static async discover(baseUrl, headers) {
|
|
1852
1856
|
try {
|
|
1853
|
-
const
|
|
1857
|
+
const resolved = resolveHeaders(headers);
|
|
1858
|
+
const response = await fetch(`${baseUrl}${VERSIONS_ENDPOINT}`, {
|
|
1859
|
+
headers: Object.keys(resolved).length > 0 ? resolved : void 0
|
|
1860
|
+
});
|
|
1854
1861
|
if (!response.ok) return null;
|
|
1855
1862
|
const info = await response.json();
|
|
1856
1863
|
const version = this.negotiate(info);
|
|
@@ -2682,7 +2689,7 @@ var scp = (() => {
|
|
|
2682
2689
|
};
|
|
2683
2690
|
|
|
2684
2691
|
// src/lib/version.ts
|
|
2685
|
-
var LIBRARY_VERSION = "2.0.0-beta.
|
|
2692
|
+
var LIBRARY_VERSION = "2.0.0-beta.13";
|
|
2686
2693
|
var API_VERSION2 = 2;
|
|
2687
2694
|
|
|
2688
2695
|
// src/lib/interfaces/index.ts
|
|
@@ -2773,7 +2780,7 @@ var scp = (() => {
|
|
|
2773
2780
|
const [serverName, path] = parsed;
|
|
2774
2781
|
const server = resolveServer(serverName, context);
|
|
2775
2782
|
if (!server) return;
|
|
2776
|
-
const transferService = context.services.
|
|
2783
|
+
const transferService = context.services.getRequired(
|
|
2777
2784
|
IScpTransferService_TOKEN
|
|
2778
2785
|
);
|
|
2779
2786
|
if (!transferService) {
|
|
@@ -2842,7 +2849,7 @@ var scp = (() => {
|
|
|
2842
2849
|
const [serverName, path] = parsed;
|
|
2843
2850
|
const server = resolveServer(serverName, context);
|
|
2844
2851
|
if (!server) return;
|
|
2845
|
-
const transferService = context.services.
|
|
2852
|
+
const transferService = context.services.getRequired(
|
|
2846
2853
|
IScpTransferService_TOKEN
|
|
2847
2854
|
);
|
|
2848
2855
|
if (!transferService) {
|
|
@@ -2935,7 +2942,7 @@ var scp = (() => {
|
|
|
2935
2942
|
localPath = localPath || remotePath.split("/").pop() || "download";
|
|
2936
2943
|
const server = resolveServer(serverName, context);
|
|
2937
2944
|
if (!server) return;
|
|
2938
|
-
const transferService = context.services.
|
|
2945
|
+
const transferService = context.services.getRequired(
|
|
2939
2946
|
IScpTransferService_TOKEN
|
|
2940
2947
|
);
|
|
2941
2948
|
if (!transferService) {
|
|
@@ -2944,6 +2951,7 @@ var scp = (() => {
|
|
|
2944
2951
|
}
|
|
2945
2952
|
const useBrowserDownload = command.args?.["save"] === true;
|
|
2946
2953
|
context.spinner?.show(`Downloading ${remotePath} from ${server.name}...`);
|
|
2954
|
+
context.notifier.info(`scp: downloading from ${server.name}`);
|
|
2947
2955
|
const abortController = new AbortController();
|
|
2948
2956
|
const abortSub = context.onAbort.subscribe(() => abortController.abort());
|
|
2949
2957
|
try {
|
|
@@ -2961,17 +2969,19 @@ var scp = (() => {
|
|
|
2961
2969
|
context.spinner?.show(
|
|
2962
2970
|
`Downloading ${remotePath}... ${pct}% (${formatBytes(received)}/${formatBytes(total)})`
|
|
2963
2971
|
);
|
|
2972
|
+
context.notifier.info(`scp: download ${pct}%`);
|
|
2964
2973
|
} else {
|
|
2965
2974
|
context.spinner?.show(
|
|
2966
2975
|
`Downloading ${remotePath}... ${formatBytes(received)}`
|
|
2967
2976
|
);
|
|
2977
|
+
context.notifier.info(`scp: download ${formatBytes(received)}`);
|
|
2968
2978
|
}
|
|
2969
2979
|
},
|
|
2970
2980
|
abortController.signal
|
|
2971
2981
|
);
|
|
2972
2982
|
context.spinner?.hide();
|
|
2973
2983
|
if (useBrowserDownload) {
|
|
2974
|
-
const fileService = context.services.
|
|
2984
|
+
const fileService = context.services.getRequired(
|
|
2975
2985
|
ICliFileTransferService_TOKEN
|
|
2976
2986
|
);
|
|
2977
2987
|
if (fileService) {
|
|
@@ -2983,7 +2993,7 @@ var scp = (() => {
|
|
|
2983
2993
|
context.writer.writeError("File transfer service not available for browser download.");
|
|
2984
2994
|
}
|
|
2985
2995
|
} else {
|
|
2986
|
-
const fileService = context.services.
|
|
2996
|
+
const fileService = context.services.getRequired(
|
|
2987
2997
|
ICliFileTransferService_TOKEN
|
|
2988
2998
|
);
|
|
2989
2999
|
if (fileService) {
|
|
@@ -3088,14 +3098,14 @@ var scp = (() => {
|
|
|
3088
3098
|
}
|
|
3089
3099
|
const server = resolveServer(serverName, context);
|
|
3090
3100
|
if (!server) return;
|
|
3091
|
-
const fileService = context.services.
|
|
3101
|
+
const fileService = context.services.getRequired(
|
|
3092
3102
|
ICliFileTransferService_TOKEN
|
|
3093
3103
|
);
|
|
3094
3104
|
if (!fileService) {
|
|
3095
3105
|
context.writer.writeError("File transfer service not available.");
|
|
3096
3106
|
return;
|
|
3097
3107
|
}
|
|
3098
|
-
const transferService = context.services.
|
|
3108
|
+
const transferService = context.services.getRequired(
|
|
3099
3109
|
IScpTransferService_TOKEN
|
|
3100
3110
|
);
|
|
3101
3111
|
if (!transferService) {
|
|
@@ -3125,6 +3135,7 @@ var scp = (() => {
|
|
|
3125
3135
|
context.spinner?.show(
|
|
3126
3136
|
`Uploading "${filename}" (${formatBytes(content.length)}) to ${server.name}:${remotePath}...`
|
|
3127
3137
|
);
|
|
3138
|
+
context.notifier.info(`scp: uploading to ${server.name}`);
|
|
3128
3139
|
try {
|
|
3129
3140
|
await transferService.upload(
|
|
3130
3141
|
serverUrl(server),
|
|
@@ -3182,7 +3193,7 @@ var scp = (() => {
|
|
|
3182
3193
|
const [serverName, path] = parsed;
|
|
3183
3194
|
const server = resolveServer(serverName, context);
|
|
3184
3195
|
if (!server) return;
|
|
3185
|
-
const transferService = context.services.
|
|
3196
|
+
const transferService = context.services.getRequired(
|
|
3186
3197
|
IScpTransferService_TOKEN
|
|
3187
3198
|
);
|
|
3188
3199
|
if (!transferService) {
|
|
@@ -3239,7 +3250,7 @@ var scp = (() => {
|
|
|
3239
3250
|
const [serverName, path] = parsed;
|
|
3240
3251
|
const server = resolveServer(serverName, context);
|
|
3241
3252
|
if (!server) return;
|
|
3242
|
-
const transferService = context.services.
|
|
3253
|
+
const transferService = context.services.getRequired(
|
|
3243
3254
|
IScpTransferService_TOKEN
|
|
3244
3255
|
);
|
|
3245
3256
|
if (!transferService) {
|
|
@@ -3296,7 +3307,7 @@ var scp = (() => {
|
|
|
3296
3307
|
const [serverName, path] = parsed;
|
|
3297
3308
|
const server = resolveServer(serverName, context);
|
|
3298
3309
|
if (!server) return;
|
|
3299
|
-
const transferService = context.services.
|
|
3310
|
+
const transferService = context.services.getRequired(
|
|
3300
3311
|
IScpTransferService_TOKEN
|
|
3301
3312
|
);
|
|
3302
3313
|
if (!transferService) {
|
|
@@ -3390,7 +3401,7 @@ var scp = (() => {
|
|
|
3390
3401
|
async doDownload(serverName, remotePath, localPath, command, context) {
|
|
3391
3402
|
const server = resolveServer(serverName, context);
|
|
3392
3403
|
if (!server) return;
|
|
3393
|
-
const transferService = context.services.
|
|
3404
|
+
const transferService = context.services.getRequired(
|
|
3394
3405
|
IScpTransferService_TOKEN
|
|
3395
3406
|
);
|
|
3396
3407
|
if (!transferService) {
|
|
@@ -3399,6 +3410,7 @@ var scp = (() => {
|
|
|
3399
3410
|
}
|
|
3400
3411
|
const useBrowserDownload = command.args?.["save"] === true;
|
|
3401
3412
|
context.spinner?.show(`Downloading ${remotePath} from ${server.name}...`);
|
|
3413
|
+
context.notifier.info(`scp: downloading from ${server.name}`);
|
|
3402
3414
|
try {
|
|
3403
3415
|
let lastProgressUpdate = 0;
|
|
3404
3416
|
const { content, size } = await transferService.download(
|
|
@@ -3414,15 +3426,17 @@ var scp = (() => {
|
|
|
3414
3426
|
context.spinner?.show(
|
|
3415
3427
|
`Downloading ${remotePath}... ${pct}% (${formatBytes(received)}/${formatBytes(total)})`
|
|
3416
3428
|
);
|
|
3429
|
+
context.notifier.info(`scp: download ${pct}%`);
|
|
3417
3430
|
} else {
|
|
3418
3431
|
context.spinner?.show(
|
|
3419
3432
|
`Downloading ${remotePath}... ${formatBytes(received)}`
|
|
3420
3433
|
);
|
|
3434
|
+
context.notifier.info(`scp: download ${formatBytes(received)}`);
|
|
3421
3435
|
}
|
|
3422
3436
|
}
|
|
3423
3437
|
);
|
|
3424
3438
|
context.spinner?.hide();
|
|
3425
|
-
const fileService = context.services.
|
|
3439
|
+
const fileService = context.services.getRequired(
|
|
3426
3440
|
ICliFileTransferService_TOKEN
|
|
3427
3441
|
);
|
|
3428
3442
|
if (!fileService) {
|
|
@@ -3448,14 +3462,14 @@ var scp = (() => {
|
|
|
3448
3462
|
async doUpload(serverName, localPath, remotePath, context) {
|
|
3449
3463
|
const server = resolveServer(serverName, context);
|
|
3450
3464
|
if (!server) return;
|
|
3451
|
-
const fileService = context.services.
|
|
3465
|
+
const fileService = context.services.getRequired(
|
|
3452
3466
|
ICliFileTransferService_TOKEN
|
|
3453
3467
|
);
|
|
3454
3468
|
if (!fileService) {
|
|
3455
3469
|
context.writer.writeError("File transfer service not available.");
|
|
3456
3470
|
return;
|
|
3457
3471
|
}
|
|
3458
|
-
const transferService = context.services.
|
|
3472
|
+
const transferService = context.services.getRequired(
|
|
3459
3473
|
IScpTransferService_TOKEN
|
|
3460
3474
|
);
|
|
3461
3475
|
if (!transferService) {
|
|
@@ -3463,6 +3477,7 @@ var scp = (() => {
|
|
|
3463
3477
|
return;
|
|
3464
3478
|
}
|
|
3465
3479
|
context.spinner?.show(`Reading local file "${localPath}"...`);
|
|
3480
|
+
context.notifier.info(`scp: reading ${localPath}`);
|
|
3466
3481
|
try {
|
|
3467
3482
|
const content = await fileService.readFile(localPath);
|
|
3468
3483
|
if (content === null) {
|
|
@@ -3474,6 +3489,7 @@ var scp = (() => {
|
|
|
3474
3489
|
context.spinner?.show(
|
|
3475
3490
|
`Uploading "${filename}" (${formatBytes(content.length)}) to ${server.name}:${remotePath}...`
|
|
3476
3491
|
);
|
|
3492
|
+
context.notifier.info(`scp: uploading to ${server.name}`);
|
|
3477
3493
|
await transferService.upload(
|
|
3478
3494
|
serverUrl(server),
|
|
3479
3495
|
remotePath,
|
|
@@ -3496,27 +3512,27 @@ var scp = (() => {
|
|
|
3496
3512
|
var ScpTransferService = class {
|
|
3497
3513
|
async ls(serverUrl2, path, headers) {
|
|
3498
3514
|
const res = await this._fetch(`${serverUrl2}/api/qcli/fs/ls?path=${encodeURIComponent(path)}`, {
|
|
3499
|
-
headers
|
|
3515
|
+
headers: resolveHeaders(headers)
|
|
3500
3516
|
});
|
|
3501
3517
|
const data = await res.json();
|
|
3502
3518
|
return data.entries;
|
|
3503
3519
|
}
|
|
3504
3520
|
async cat(serverUrl2, path, headers) {
|
|
3505
3521
|
const res = await this._fetch(`${serverUrl2}/api/qcli/fs/cat?path=${encodeURIComponent(path)}`, {
|
|
3506
|
-
headers
|
|
3522
|
+
headers: resolveHeaders(headers)
|
|
3507
3523
|
});
|
|
3508
3524
|
const data = await res.json();
|
|
3509
3525
|
return data.content;
|
|
3510
3526
|
}
|
|
3511
3527
|
async stat(serverUrl2, path, headers) {
|
|
3512
3528
|
const res = await this._fetch(`${serverUrl2}/api/qcli/fs/stat?path=${encodeURIComponent(path)}`, {
|
|
3513
|
-
headers
|
|
3529
|
+
headers: resolveHeaders(headers)
|
|
3514
3530
|
});
|
|
3515
3531
|
return await res.json();
|
|
3516
3532
|
}
|
|
3517
3533
|
async download(serverUrl2, path, headers, onProgress, signal) {
|
|
3518
3534
|
const res = await this._fetch(`${serverUrl2}/api/qcli/fs/download?path=${encodeURIComponent(path)}`, {
|
|
3519
|
-
headers,
|
|
3535
|
+
headers: resolveHeaders(headers),
|
|
3520
3536
|
signal
|
|
3521
3537
|
});
|
|
3522
3538
|
const contentLength = parseInt(res.headers.get("content-length") || "0", 10);
|
|
@@ -3552,20 +3568,20 @@ var scp = (() => {
|
|
|
3552
3568
|
await this._fetch(`${serverUrl2}/api/qcli/fs/upload`, {
|
|
3553
3569
|
method: "POST",
|
|
3554
3570
|
body: formData,
|
|
3555
|
-
headers
|
|
3571
|
+
headers: resolveHeaders(headers)
|
|
3556
3572
|
});
|
|
3557
3573
|
}
|
|
3558
3574
|
async mkdir(serverUrl2, path, headers) {
|
|
3559
3575
|
await this._fetch(`${serverUrl2}/api/qcli/fs/mkdir`, {
|
|
3560
3576
|
method: "POST",
|
|
3561
|
-
headers: { "Content-Type": "application/json", ...headers },
|
|
3577
|
+
headers: { "Content-Type": "application/json", ...resolveHeaders(headers) },
|
|
3562
3578
|
body: JSON.stringify({ path })
|
|
3563
3579
|
});
|
|
3564
3580
|
}
|
|
3565
3581
|
async rm(serverUrl2, path, headers) {
|
|
3566
3582
|
await this._fetch(`${serverUrl2}/api/qcli/fs/rm?path=${encodeURIComponent(path)}`, {
|
|
3567
3583
|
method: "DELETE",
|
|
3568
|
-
headers
|
|
3584
|
+
headers: resolveHeaders(headers)
|
|
3569
3585
|
});
|
|
3570
3586
|
}
|
|
3571
3587
|
async _fetch(url, init) {
|
|
@@ -3592,7 +3608,7 @@ var scp = (() => {
|
|
|
3592
3608
|
services: [
|
|
3593
3609
|
{
|
|
3594
3610
|
provide: IScpTransferService_TOKEN,
|
|
3595
|
-
|
|
3611
|
+
useClass: ScpTransferService
|
|
3596
3612
|
}
|
|
3597
3613
|
]
|
|
3598
3614
|
};
|