@qodalis/cli-scp 2.0.0-beta.1 → 2.0.0-beta.11
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 +4 -4
- package/public-api.d.mts +5 -1
- package/public-api.d.ts +5 -1
- package/public-api.js +67 -31
- package/public-api.js.map +1 -1
- package/public-api.mjs +67 -31
- package/public-api.mjs.map +1 -1
- package/umd/{cli-entrypoint.global.js → index.global.js} +74 -36
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qodalis/cli-scp",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.11",
|
|
4
4
|
"description": "SCP-like file transfer between browser and remote servers",
|
|
5
5
|
"author": "Qodalis Solutions",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"terminal",
|
|
16
16
|
"scp"
|
|
17
17
|
],
|
|
18
|
-
"umd": "./umd/index.js",
|
|
19
|
-
"unpkg": "./umd/index.js",
|
|
18
|
+
"umd": "./umd/index.global.js",
|
|
19
|
+
"unpkg": "./umd/index.global.js",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@qodalis/cli-core": "2.0.0-beta.
|
|
21
|
+
"@qodalis/cli-core": "2.0.0-beta.11"
|
|
22
22
|
},
|
|
23
23
|
"sideEffects": false,
|
|
24
24
|
"main": "./public-api.js",
|
package/public-api.d.mts
CHANGED
|
@@ -6,6 +6,10 @@ declare class CliScpCommandCommandProcessor implements ICliCommandProcessor {
|
|
|
6
6
|
description: string;
|
|
7
7
|
author: _qodalis_cli_core.ICliCommandAuthor;
|
|
8
8
|
version: string;
|
|
9
|
+
metadata: {
|
|
10
|
+
icon: string;
|
|
11
|
+
module: string;
|
|
12
|
+
};
|
|
9
13
|
acceptsRawInput: boolean;
|
|
10
14
|
processors: ICliCommandChildProcessor[];
|
|
11
15
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
@@ -14,7 +18,7 @@ declare class CliScpCommandCommandProcessor implements ICliCommandProcessor {
|
|
|
14
18
|
private doUpload;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
|
-
declare const LIBRARY_VERSION = "2.0.0-beta.
|
|
21
|
+
declare const LIBRARY_VERSION = "2.0.0-beta.11";
|
|
18
22
|
declare const API_VERSION = 2;
|
|
19
23
|
|
|
20
24
|
declare const scpModule: ICliModule;
|
package/public-api.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ declare class CliScpCommandCommandProcessor implements ICliCommandProcessor {
|
|
|
6
6
|
description: string;
|
|
7
7
|
author: _qodalis_cli_core.ICliCommandAuthor;
|
|
8
8
|
version: string;
|
|
9
|
+
metadata: {
|
|
10
|
+
icon: string;
|
|
11
|
+
module: string;
|
|
12
|
+
};
|
|
9
13
|
acceptsRawInput: boolean;
|
|
10
14
|
processors: ICliCommandChildProcessor[];
|
|
11
15
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
@@ -14,7 +18,7 @@ declare class CliScpCommandCommandProcessor implements ICliCommandProcessor {
|
|
|
14
18
|
private doUpload;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
|
-
declare const LIBRARY_VERSION = "2.0.0-beta.
|
|
21
|
+
declare const LIBRARY_VERSION = "2.0.0-beta.11";
|
|
18
22
|
declare const API_VERSION = 2;
|
|
19
23
|
|
|
20
24
|
declare const scpModule: ICliModule;
|
package/public-api.js
CHANGED
|
@@ -5,7 +5,7 @@ var cliCore = require('@qodalis/cli-core');
|
|
|
5
5
|
// src/lib/processors/cli-scp-command-processor.ts
|
|
6
6
|
|
|
7
7
|
// src/lib/version.ts
|
|
8
|
-
var LIBRARY_VERSION = "2.0.0-beta.
|
|
8
|
+
var LIBRARY_VERSION = "2.0.0-beta.11";
|
|
9
9
|
var API_VERSION = 2;
|
|
10
10
|
|
|
11
11
|
// src/lib/interfaces/index.ts
|
|
@@ -333,7 +333,7 @@ var CliScpUploadProcessor = class {
|
|
|
333
333
|
constructor() {
|
|
334
334
|
this.command = "upload";
|
|
335
335
|
this.aliases = ["put"];
|
|
336
|
-
this.description = "Upload a
|
|
336
|
+
this.description = "Upload a file to a remote server (use --local to pick from your machine)";
|
|
337
337
|
this.acceptsRawInput = true;
|
|
338
338
|
this.valueRequired = true;
|
|
339
339
|
this.parameters = [
|
|
@@ -345,8 +345,8 @@ var CliScpUploadProcessor = class {
|
|
|
345
345
|
},
|
|
346
346
|
{
|
|
347
347
|
name: "local-path",
|
|
348
|
-
description: "Local file path",
|
|
349
|
-
required:
|
|
348
|
+
description: "Local file path (from virtual filesystem)",
|
|
349
|
+
required: false,
|
|
350
350
|
type: "string"
|
|
351
351
|
},
|
|
352
352
|
{
|
|
@@ -354,35 +354,55 @@ var CliScpUploadProcessor = class {
|
|
|
354
354
|
description: "Remote destination path",
|
|
355
355
|
required: true,
|
|
356
356
|
type: "string"
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
name: "local",
|
|
360
|
+
description: "Pick a file from your local machine via browser file picker",
|
|
361
|
+
required: false,
|
|
362
|
+
type: "boolean"
|
|
357
363
|
}
|
|
358
364
|
];
|
|
359
365
|
}
|
|
360
366
|
async processCommand(command, context) {
|
|
361
367
|
const args = command.args || {};
|
|
368
|
+
const useLocalPicker = !!args["local"];
|
|
362
369
|
let serverName;
|
|
363
370
|
let localPath;
|
|
364
371
|
let remotePath;
|
|
365
|
-
if (args["server"] && args["
|
|
372
|
+
if (args["server"] && args["remote-path"]) {
|
|
366
373
|
serverName = String(args["server"]);
|
|
367
|
-
localPath = String(args["local-path"]);
|
|
374
|
+
localPath = args["local-path"] ? String(args["local-path"]) : void 0;
|
|
368
375
|
remotePath = String(args["remote-path"]);
|
|
369
376
|
} else {
|
|
370
377
|
const value = command.value?.trim();
|
|
371
378
|
if (!value) {
|
|
372
|
-
context.writer.writeError(
|
|
379
|
+
context.writer.writeError(
|
|
380
|
+
useLocalPicker ? "Usage: scp upload --local <server> <remote-path>" : "Usage: scp upload <server> <local-path> <remote-path>"
|
|
381
|
+
);
|
|
373
382
|
return;
|
|
374
383
|
}
|
|
375
384
|
const parts = value.split(/\s+/);
|
|
376
|
-
if (
|
|
377
|
-
|
|
378
|
-
|
|
385
|
+
if (useLocalPicker) {
|
|
386
|
+
if (parts.length < 2) {
|
|
387
|
+
context.writer.writeError("Usage: scp upload --local <server> <remote-path>");
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
serverName = parts[0];
|
|
391
|
+
remotePath = parts[1];
|
|
392
|
+
} else {
|
|
393
|
+
if (parts.length < 3) {
|
|
394
|
+
context.writer.writeError("Usage: scp upload <server> <local-path> <remote-path>");
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
serverName = parts[0];
|
|
398
|
+
localPath = parts[1];
|
|
399
|
+
remotePath = parts[2];
|
|
379
400
|
}
|
|
380
|
-
serverName = parts[0];
|
|
381
|
-
localPath = parts[1];
|
|
382
|
-
remotePath = parts[2];
|
|
383
401
|
}
|
|
384
|
-
if (!serverName || !localPath || !remotePath) {
|
|
385
|
-
context.writer.writeError(
|
|
402
|
+
if (!serverName || !useLocalPicker && !localPath || !remotePath) {
|
|
403
|
+
context.writer.writeError(
|
|
404
|
+
useLocalPicker ? "Usage: scp upload --local <server> <remote-path>" : "Usage: scp upload <server> <local-path> <remote-path>"
|
|
405
|
+
);
|
|
386
406
|
return;
|
|
387
407
|
}
|
|
388
408
|
const server = resolveServer(serverName, context);
|
|
@@ -401,18 +421,30 @@ var CliScpUploadProcessor = class {
|
|
|
401
421
|
context.writer.writeError("SCP transfer service not available.");
|
|
402
422
|
return;
|
|
403
423
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
424
|
+
let content;
|
|
425
|
+
let filename;
|
|
426
|
+
if (useLocalPicker) {
|
|
427
|
+
const picked = await fileService.uploadFromBrowser();
|
|
428
|
+
if (!picked) {
|
|
429
|
+
context.writer.writeln("Upload cancelled.");
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
content = picked.content;
|
|
433
|
+
filename = picked.name;
|
|
434
|
+
} else {
|
|
435
|
+
context.spinner?.show(`Reading local file "${localPath}"...`);
|
|
436
|
+
content = await fileService.readFile(localPath);
|
|
407
437
|
if (content === null) {
|
|
408
438
|
context.spinner?.hide();
|
|
409
439
|
context.writer.writeError(`Local file not found: ${localPath}`);
|
|
410
440
|
return;
|
|
411
441
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
)
|
|
442
|
+
filename = localPath.split("/").pop() || "file";
|
|
443
|
+
}
|
|
444
|
+
context.spinner?.show(
|
|
445
|
+
`Uploading "${filename}" (${formatBytes(content.length)}) to ${server.name}:${remotePath}...`
|
|
446
|
+
);
|
|
447
|
+
try {
|
|
416
448
|
await transferService.upload(
|
|
417
449
|
serverUrl(server),
|
|
418
450
|
remotePath,
|
|
@@ -430,8 +462,11 @@ var CliScpUploadProcessor = class {
|
|
|
430
462
|
}
|
|
431
463
|
}
|
|
432
464
|
writeDescription(context) {
|
|
433
|
-
context.writer.writeln("Upload a
|
|
434
|
-
context.writer.writeln("
|
|
465
|
+
context.writer.writeln("Upload a file to a remote server.");
|
|
466
|
+
context.writer.writeln("");
|
|
467
|
+
context.writer.writeln("Usage:");
|
|
468
|
+
context.writer.writeln(" scp upload <server> <local-path> <remote-path> Upload from virtual filesystem");
|
|
469
|
+
context.writer.writeln(" scp upload --local <server> <remote-path> Pick from your machine via browser");
|
|
435
470
|
}
|
|
436
471
|
};
|
|
437
472
|
|
|
@@ -623,6 +658,7 @@ var CliScpCommandCommandProcessor = class {
|
|
|
623
658
|
this.description = "SCP-like file transfer between browser and remote servers";
|
|
624
659
|
this.author = cliCore.DefaultLibraryAuthor;
|
|
625
660
|
this.version = LIBRARY_VERSION;
|
|
661
|
+
this.metadata = { icon: "\u{1F4C1}", module: "file management" };
|
|
626
662
|
this.acceptsRawInput = true;
|
|
627
663
|
this.processors = [
|
|
628
664
|
new CliScpLsProcessor(),
|
|
@@ -778,27 +814,27 @@ var CliScpCommandCommandProcessor = class {
|
|
|
778
814
|
// src/lib/services/scp-transfer.service.ts
|
|
779
815
|
var ScpTransferService = class {
|
|
780
816
|
async ls(serverUrl2, path, headers) {
|
|
781
|
-
const res = await this._fetch(`${serverUrl2}/api/
|
|
817
|
+
const res = await this._fetch(`${serverUrl2}/api/qcli/fs/ls?path=${encodeURIComponent(path)}`, {
|
|
782
818
|
headers
|
|
783
819
|
});
|
|
784
820
|
const data = await res.json();
|
|
785
821
|
return data.entries;
|
|
786
822
|
}
|
|
787
823
|
async cat(serverUrl2, path, headers) {
|
|
788
|
-
const res = await this._fetch(`${serverUrl2}/api/
|
|
824
|
+
const res = await this._fetch(`${serverUrl2}/api/qcli/fs/cat?path=${encodeURIComponent(path)}`, {
|
|
789
825
|
headers
|
|
790
826
|
});
|
|
791
827
|
const data = await res.json();
|
|
792
828
|
return data.content;
|
|
793
829
|
}
|
|
794
830
|
async stat(serverUrl2, path, headers) {
|
|
795
|
-
const res = await this._fetch(`${serverUrl2}/api/
|
|
831
|
+
const res = await this._fetch(`${serverUrl2}/api/qcli/fs/stat?path=${encodeURIComponent(path)}`, {
|
|
796
832
|
headers
|
|
797
833
|
});
|
|
798
834
|
return await res.json();
|
|
799
835
|
}
|
|
800
836
|
async download(serverUrl2, path, headers, onProgress, signal) {
|
|
801
|
-
const res = await this._fetch(`${serverUrl2}/api/
|
|
837
|
+
const res = await this._fetch(`${serverUrl2}/api/qcli/fs/download?path=${encodeURIComponent(path)}`, {
|
|
802
838
|
headers,
|
|
803
839
|
signal
|
|
804
840
|
});
|
|
@@ -832,21 +868,21 @@ var ScpTransferService = class {
|
|
|
832
868
|
const formData = new FormData();
|
|
833
869
|
formData.append("path", remotePath);
|
|
834
870
|
formData.append("file", new Blob([content]), filename);
|
|
835
|
-
await this._fetch(`${serverUrl2}/api/
|
|
871
|
+
await this._fetch(`${serverUrl2}/api/qcli/fs/upload`, {
|
|
836
872
|
method: "POST",
|
|
837
873
|
body: formData,
|
|
838
874
|
headers
|
|
839
875
|
});
|
|
840
876
|
}
|
|
841
877
|
async mkdir(serverUrl2, path, headers) {
|
|
842
|
-
await this._fetch(`${serverUrl2}/api/
|
|
878
|
+
await this._fetch(`${serverUrl2}/api/qcli/fs/mkdir`, {
|
|
843
879
|
method: "POST",
|
|
844
880
|
headers: { "Content-Type": "application/json", ...headers },
|
|
845
881
|
body: JSON.stringify({ path })
|
|
846
882
|
});
|
|
847
883
|
}
|
|
848
884
|
async rm(serverUrl2, path, headers) {
|
|
849
|
-
await this._fetch(`${serverUrl2}/api/
|
|
885
|
+
await this._fetch(`${serverUrl2}/api/qcli/fs/rm?path=${encodeURIComponent(path)}`, {
|
|
850
886
|
method: "DELETE",
|
|
851
887
|
headers
|
|
852
888
|
});
|