@qodalis/cli-scp 2.0.0-beta.12 → 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 -33
- package/public-api.js.map +1 -1
- package/public-api.mjs +32 -34
- package/public-api.mjs.map +1 -1
- package/umd/index.global.js +41 -34
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,7 +2951,7 @@ var scp = (() => {
|
|
|
2944
2951
|
}
|
|
2945
2952
|
const useBrowserDownload = command.args?.["save"] === true;
|
|
2946
2953
|
context.spinner?.show(`Downloading ${remotePath} from ${server.name}...`);
|
|
2947
|
-
context.
|
|
2954
|
+
context.notifier.info(`scp: downloading from ${server.name}`);
|
|
2948
2955
|
const abortController = new AbortController();
|
|
2949
2956
|
const abortSub = context.onAbort.subscribe(() => abortController.abort());
|
|
2950
2957
|
try {
|
|
@@ -2962,19 +2969,19 @@ var scp = (() => {
|
|
|
2962
2969
|
context.spinner?.show(
|
|
2963
2970
|
`Downloading ${remotePath}... ${pct}% (${formatBytes(received)}/${formatBytes(total)})`
|
|
2964
2971
|
);
|
|
2965
|
-
context.
|
|
2972
|
+
context.notifier.info(`scp: download ${pct}%`);
|
|
2966
2973
|
} else {
|
|
2967
2974
|
context.spinner?.show(
|
|
2968
2975
|
`Downloading ${remotePath}... ${formatBytes(received)}`
|
|
2969
2976
|
);
|
|
2970
|
-
context.
|
|
2977
|
+
context.notifier.info(`scp: download ${formatBytes(received)}`);
|
|
2971
2978
|
}
|
|
2972
2979
|
},
|
|
2973
2980
|
abortController.signal
|
|
2974
2981
|
);
|
|
2975
2982
|
context.spinner?.hide();
|
|
2976
2983
|
if (useBrowserDownload) {
|
|
2977
|
-
const fileService = context.services.
|
|
2984
|
+
const fileService = context.services.getRequired(
|
|
2978
2985
|
ICliFileTransferService_TOKEN
|
|
2979
2986
|
);
|
|
2980
2987
|
if (fileService) {
|
|
@@ -2986,7 +2993,7 @@ var scp = (() => {
|
|
|
2986
2993
|
context.writer.writeError("File transfer service not available for browser download.");
|
|
2987
2994
|
}
|
|
2988
2995
|
} else {
|
|
2989
|
-
const fileService = context.services.
|
|
2996
|
+
const fileService = context.services.getRequired(
|
|
2990
2997
|
ICliFileTransferService_TOKEN
|
|
2991
2998
|
);
|
|
2992
2999
|
if (fileService) {
|
|
@@ -3091,14 +3098,14 @@ var scp = (() => {
|
|
|
3091
3098
|
}
|
|
3092
3099
|
const server = resolveServer(serverName, context);
|
|
3093
3100
|
if (!server) return;
|
|
3094
|
-
const fileService = context.services.
|
|
3101
|
+
const fileService = context.services.getRequired(
|
|
3095
3102
|
ICliFileTransferService_TOKEN
|
|
3096
3103
|
);
|
|
3097
3104
|
if (!fileService) {
|
|
3098
3105
|
context.writer.writeError("File transfer service not available.");
|
|
3099
3106
|
return;
|
|
3100
3107
|
}
|
|
3101
|
-
const transferService = context.services.
|
|
3108
|
+
const transferService = context.services.getRequired(
|
|
3102
3109
|
IScpTransferService_TOKEN
|
|
3103
3110
|
);
|
|
3104
3111
|
if (!transferService) {
|
|
@@ -3128,7 +3135,7 @@ var scp = (() => {
|
|
|
3128
3135
|
context.spinner?.show(
|
|
3129
3136
|
`Uploading "${filename}" (${formatBytes(content.length)}) to ${server.name}:${remotePath}...`
|
|
3130
3137
|
);
|
|
3131
|
-
context.
|
|
3138
|
+
context.notifier.info(`scp: uploading to ${server.name}`);
|
|
3132
3139
|
try {
|
|
3133
3140
|
await transferService.upload(
|
|
3134
3141
|
serverUrl(server),
|
|
@@ -3186,7 +3193,7 @@ var scp = (() => {
|
|
|
3186
3193
|
const [serverName, path] = parsed;
|
|
3187
3194
|
const server = resolveServer(serverName, context);
|
|
3188
3195
|
if (!server) return;
|
|
3189
|
-
const transferService = context.services.
|
|
3196
|
+
const transferService = context.services.getRequired(
|
|
3190
3197
|
IScpTransferService_TOKEN
|
|
3191
3198
|
);
|
|
3192
3199
|
if (!transferService) {
|
|
@@ -3243,7 +3250,7 @@ var scp = (() => {
|
|
|
3243
3250
|
const [serverName, path] = parsed;
|
|
3244
3251
|
const server = resolveServer(serverName, context);
|
|
3245
3252
|
if (!server) return;
|
|
3246
|
-
const transferService = context.services.
|
|
3253
|
+
const transferService = context.services.getRequired(
|
|
3247
3254
|
IScpTransferService_TOKEN
|
|
3248
3255
|
);
|
|
3249
3256
|
if (!transferService) {
|
|
@@ -3300,7 +3307,7 @@ var scp = (() => {
|
|
|
3300
3307
|
const [serverName, path] = parsed;
|
|
3301
3308
|
const server = resolveServer(serverName, context);
|
|
3302
3309
|
if (!server) return;
|
|
3303
|
-
const transferService = context.services.
|
|
3310
|
+
const transferService = context.services.getRequired(
|
|
3304
3311
|
IScpTransferService_TOKEN
|
|
3305
3312
|
);
|
|
3306
3313
|
if (!transferService) {
|
|
@@ -3394,7 +3401,7 @@ var scp = (() => {
|
|
|
3394
3401
|
async doDownload(serverName, remotePath, localPath, command, context) {
|
|
3395
3402
|
const server = resolveServer(serverName, context);
|
|
3396
3403
|
if (!server) return;
|
|
3397
|
-
const transferService = context.services.
|
|
3404
|
+
const transferService = context.services.getRequired(
|
|
3398
3405
|
IScpTransferService_TOKEN
|
|
3399
3406
|
);
|
|
3400
3407
|
if (!transferService) {
|
|
@@ -3403,7 +3410,7 @@ var scp = (() => {
|
|
|
3403
3410
|
}
|
|
3404
3411
|
const useBrowserDownload = command.args?.["save"] === true;
|
|
3405
3412
|
context.spinner?.show(`Downloading ${remotePath} from ${server.name}...`);
|
|
3406
|
-
context.
|
|
3413
|
+
context.notifier.info(`scp: downloading from ${server.name}`);
|
|
3407
3414
|
try {
|
|
3408
3415
|
let lastProgressUpdate = 0;
|
|
3409
3416
|
const { content, size } = await transferService.download(
|
|
@@ -3419,17 +3426,17 @@ var scp = (() => {
|
|
|
3419
3426
|
context.spinner?.show(
|
|
3420
3427
|
`Downloading ${remotePath}... ${pct}% (${formatBytes(received)}/${formatBytes(total)})`
|
|
3421
3428
|
);
|
|
3422
|
-
context.
|
|
3429
|
+
context.notifier.info(`scp: download ${pct}%`);
|
|
3423
3430
|
} else {
|
|
3424
3431
|
context.spinner?.show(
|
|
3425
3432
|
`Downloading ${remotePath}... ${formatBytes(received)}`
|
|
3426
3433
|
);
|
|
3427
|
-
context.
|
|
3434
|
+
context.notifier.info(`scp: download ${formatBytes(received)}`);
|
|
3428
3435
|
}
|
|
3429
3436
|
}
|
|
3430
3437
|
);
|
|
3431
3438
|
context.spinner?.hide();
|
|
3432
|
-
const fileService = context.services.
|
|
3439
|
+
const fileService = context.services.getRequired(
|
|
3433
3440
|
ICliFileTransferService_TOKEN
|
|
3434
3441
|
);
|
|
3435
3442
|
if (!fileService) {
|
|
@@ -3455,14 +3462,14 @@ var scp = (() => {
|
|
|
3455
3462
|
async doUpload(serverName, localPath, remotePath, context) {
|
|
3456
3463
|
const server = resolveServer(serverName, context);
|
|
3457
3464
|
if (!server) return;
|
|
3458
|
-
const fileService = context.services.
|
|
3465
|
+
const fileService = context.services.getRequired(
|
|
3459
3466
|
ICliFileTransferService_TOKEN
|
|
3460
3467
|
);
|
|
3461
3468
|
if (!fileService) {
|
|
3462
3469
|
context.writer.writeError("File transfer service not available.");
|
|
3463
3470
|
return;
|
|
3464
3471
|
}
|
|
3465
|
-
const transferService = context.services.
|
|
3472
|
+
const transferService = context.services.getRequired(
|
|
3466
3473
|
IScpTransferService_TOKEN
|
|
3467
3474
|
);
|
|
3468
3475
|
if (!transferService) {
|
|
@@ -3470,7 +3477,7 @@ var scp = (() => {
|
|
|
3470
3477
|
return;
|
|
3471
3478
|
}
|
|
3472
3479
|
context.spinner?.show(`Reading local file "${localPath}"...`);
|
|
3473
|
-
context.
|
|
3480
|
+
context.notifier.info(`scp: reading ${localPath}`);
|
|
3474
3481
|
try {
|
|
3475
3482
|
const content = await fileService.readFile(localPath);
|
|
3476
3483
|
if (content === null) {
|
|
@@ -3482,7 +3489,7 @@ var scp = (() => {
|
|
|
3482
3489
|
context.spinner?.show(
|
|
3483
3490
|
`Uploading "${filename}" (${formatBytes(content.length)}) to ${server.name}:${remotePath}...`
|
|
3484
3491
|
);
|
|
3485
|
-
context.
|
|
3492
|
+
context.notifier.info(`scp: uploading to ${server.name}`);
|
|
3486
3493
|
await transferService.upload(
|
|
3487
3494
|
serverUrl(server),
|
|
3488
3495
|
remotePath,
|
|
@@ -3505,27 +3512,27 @@ var scp = (() => {
|
|
|
3505
3512
|
var ScpTransferService = class {
|
|
3506
3513
|
async ls(serverUrl2, path, headers) {
|
|
3507
3514
|
const res = await this._fetch(`${serverUrl2}/api/qcli/fs/ls?path=${encodeURIComponent(path)}`, {
|
|
3508
|
-
headers
|
|
3515
|
+
headers: resolveHeaders(headers)
|
|
3509
3516
|
});
|
|
3510
3517
|
const data = await res.json();
|
|
3511
3518
|
return data.entries;
|
|
3512
3519
|
}
|
|
3513
3520
|
async cat(serverUrl2, path, headers) {
|
|
3514
3521
|
const res = await this._fetch(`${serverUrl2}/api/qcli/fs/cat?path=${encodeURIComponent(path)}`, {
|
|
3515
|
-
headers
|
|
3522
|
+
headers: resolveHeaders(headers)
|
|
3516
3523
|
});
|
|
3517
3524
|
const data = await res.json();
|
|
3518
3525
|
return data.content;
|
|
3519
3526
|
}
|
|
3520
3527
|
async stat(serverUrl2, path, headers) {
|
|
3521
3528
|
const res = await this._fetch(`${serverUrl2}/api/qcli/fs/stat?path=${encodeURIComponent(path)}`, {
|
|
3522
|
-
headers
|
|
3529
|
+
headers: resolveHeaders(headers)
|
|
3523
3530
|
});
|
|
3524
3531
|
return await res.json();
|
|
3525
3532
|
}
|
|
3526
3533
|
async download(serverUrl2, path, headers, onProgress, signal) {
|
|
3527
3534
|
const res = await this._fetch(`${serverUrl2}/api/qcli/fs/download?path=${encodeURIComponent(path)}`, {
|
|
3528
|
-
headers,
|
|
3535
|
+
headers: resolveHeaders(headers),
|
|
3529
3536
|
signal
|
|
3530
3537
|
});
|
|
3531
3538
|
const contentLength = parseInt(res.headers.get("content-length") || "0", 10);
|
|
@@ -3561,20 +3568,20 @@ var scp = (() => {
|
|
|
3561
3568
|
await this._fetch(`${serverUrl2}/api/qcli/fs/upload`, {
|
|
3562
3569
|
method: "POST",
|
|
3563
3570
|
body: formData,
|
|
3564
|
-
headers
|
|
3571
|
+
headers: resolveHeaders(headers)
|
|
3565
3572
|
});
|
|
3566
3573
|
}
|
|
3567
3574
|
async mkdir(serverUrl2, path, headers) {
|
|
3568
3575
|
await this._fetch(`${serverUrl2}/api/qcli/fs/mkdir`, {
|
|
3569
3576
|
method: "POST",
|
|
3570
|
-
headers: { "Content-Type": "application/json", ...headers },
|
|
3577
|
+
headers: { "Content-Type": "application/json", ...resolveHeaders(headers) },
|
|
3571
3578
|
body: JSON.stringify({ path })
|
|
3572
3579
|
});
|
|
3573
3580
|
}
|
|
3574
3581
|
async rm(serverUrl2, path, headers) {
|
|
3575
3582
|
await this._fetch(`${serverUrl2}/api/qcli/fs/rm?path=${encodeURIComponent(path)}`, {
|
|
3576
3583
|
method: "DELETE",
|
|
3577
|
-
headers
|
|
3584
|
+
headers: resolveHeaders(headers)
|
|
3578
3585
|
});
|
|
3579
3586
|
}
|
|
3580
3587
|
async _fetch(url, init) {
|
|
@@ -3601,7 +3608,7 @@ var scp = (() => {
|
|
|
3601
3608
|
services: [
|
|
3602
3609
|
{
|
|
3603
3610
|
provide: IScpTransferService_TOKEN,
|
|
3604
|
-
|
|
3611
|
+
useClass: ScpTransferService
|
|
3605
3612
|
}
|
|
3606
3613
|
]
|
|
3607
3614
|
};
|