@qodalis/cli-scp 2.0.0-beta.12 → 2.0.0-beta.14

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qodalis/cli-scp",
3
- "version": "2.0.0-beta.12",
3
+ "version": "2.0.0-beta.14",
4
4
  "description": "SCP-like file transfer between browser and remote servers",
5
5
  "author": "Qodalis Solutions",
6
6
  "license": "MIT",
@@ -18,7 +18,7 @@
18
18
  "umd": "./umd/index.global.js",
19
19
  "unpkg": "./umd/index.global.js",
20
20
  "dependencies": {
21
- "@qodalis/cli-core": "2.0.0-beta.12"
21
+ "@qodalis/cli-core": "2.0.0-beta.14"
22
22
  },
23
23
  "sideEffects": false,
24
24
  "main": "./public-api.js",
package/public-api.d.mts CHANGED
@@ -18,7 +18,7 @@ declare class CliScpCommandCommandProcessor implements ICliCommandProcessor {
18
18
  private doUpload;
19
19
  }
20
20
 
21
- declare const LIBRARY_VERSION = "2.0.0-beta.12";
21
+ declare const LIBRARY_VERSION = "2.0.0-beta.14";
22
22
  declare const API_VERSION = 2;
23
23
 
24
24
  declare const scpModule: ICliModule;
package/public-api.d.ts CHANGED
@@ -18,7 +18,7 @@ declare class CliScpCommandCommandProcessor implements ICliCommandProcessor {
18
18
  private doUpload;
19
19
  }
20
20
 
21
- declare const LIBRARY_VERSION = "2.0.0-beta.12";
21
+ declare const LIBRARY_VERSION = "2.0.0-beta.14";
22
22
  declare const API_VERSION = 2;
23
23
 
24
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.12";
8
+ var LIBRARY_VERSION = "2.0.0-beta.14";
9
9
  var API_VERSION = 2;
10
10
 
11
11
  // src/lib/interfaces/index.ts
@@ -64,8 +64,6 @@ function parseServerAndPath(value, context, args) {
64
64
  }
65
65
  return [parts[0], parts.slice(1).join(" ")];
66
66
  }
67
-
68
- // src/lib/processors/cli-scp-ls-processor.ts
69
67
  var CliScpLsProcessor = class {
70
68
  constructor() {
71
69
  this.command = "ls";
@@ -96,7 +94,7 @@ var CliScpLsProcessor = class {
96
94
  const [serverName, path] = parsed;
97
95
  const server = resolveServer(serverName, context);
98
96
  if (!server) return;
99
- const transferService = context.services.get(
97
+ const transferService = context.services.getRequired(
100
98
  IScpTransferService_TOKEN
101
99
  );
102
100
  if (!transferService) {
@@ -108,7 +106,7 @@ var CliScpLsProcessor = class {
108
106
  const entries = await transferService.ls(
109
107
  serverUrl(server),
110
108
  path,
111
- server.headers
109
+ cliCore.resolveServerHeaders(context.services, server.name, server.headers)
112
110
  );
113
111
  context.spinner?.hide();
114
112
  if (entries.length === 0) {
@@ -133,8 +131,6 @@ var CliScpLsProcessor = class {
133
131
  context.writer.writeln("List files and directories on a remote server.");
134
132
  }
135
133
  };
136
-
137
- // src/lib/processors/cli-scp-cat-processor.ts
138
134
  var CliScpCatProcessor = class {
139
135
  constructor() {
140
136
  this.command = "cat";
@@ -165,7 +161,7 @@ var CliScpCatProcessor = class {
165
161
  const [serverName, path] = parsed;
166
162
  const server = resolveServer(serverName, context);
167
163
  if (!server) return;
168
- const transferService = context.services.get(
164
+ const transferService = context.services.getRequired(
169
165
  IScpTransferService_TOKEN
170
166
  );
171
167
  if (!transferService) {
@@ -177,7 +173,7 @@ var CliScpCatProcessor = class {
177
173
  const content = await transferService.cat(
178
174
  serverUrl(server),
179
175
  path,
180
- server.headers
176
+ cliCore.resolveServerHeaders(context.services, server.name, server.headers)
181
177
  );
182
178
  context.spinner?.hide();
183
179
  context.writer.writeln(content);
@@ -256,7 +252,7 @@ var CliScpDownloadProcessor = class {
256
252
  localPath = localPath || remotePath.split("/").pop() || "download";
257
253
  const server = resolveServer(serverName, context);
258
254
  if (!server) return;
259
- const transferService = context.services.get(
255
+ const transferService = context.services.getRequired(
260
256
  IScpTransferService_TOKEN
261
257
  );
262
258
  if (!transferService) {
@@ -265,7 +261,7 @@ var CliScpDownloadProcessor = class {
265
261
  }
266
262
  const useBrowserDownload = command.args?.["save"] === true;
267
263
  context.spinner?.show(`Downloading ${remotePath} from ${server.name}...`);
268
- context.setStatusText(`scp: downloading from ${server.name}`);
264
+ context.notifier.info(`scp: downloading from ${server.name}`);
269
265
  const abortController = new AbortController();
270
266
  const abortSub = context.onAbort.subscribe(() => abortController.abort());
271
267
  try {
@@ -273,7 +269,7 @@ var CliScpDownloadProcessor = class {
273
269
  const { content, size } = await transferService.download(
274
270
  serverUrl(server),
275
271
  remotePath,
276
- server.headers,
272
+ cliCore.resolveServerHeaders(context.services, server.name, server.headers),
277
273
  (received, total) => {
278
274
  const now = Date.now();
279
275
  if (now - lastProgressUpdate < 200) return;
@@ -283,19 +279,19 @@ var CliScpDownloadProcessor = class {
283
279
  context.spinner?.show(
284
280
  `Downloading ${remotePath}... ${pct}% (${formatBytes(received)}/${formatBytes(total)})`
285
281
  );
286
- context.setStatusText(`scp: download ${pct}%`);
282
+ context.notifier.info(`scp: download ${pct}%`);
287
283
  } else {
288
284
  context.spinner?.show(
289
285
  `Downloading ${remotePath}... ${formatBytes(received)}`
290
286
  );
291
- context.setStatusText(`scp: download ${formatBytes(received)}`);
287
+ context.notifier.info(`scp: download ${formatBytes(received)}`);
292
288
  }
293
289
  },
294
290
  abortController.signal
295
291
  );
296
292
  context.spinner?.hide();
297
293
  if (useBrowserDownload) {
298
- const fileService = context.services.get(
294
+ const fileService = context.services.getRequired(
299
295
  cliCore.ICliFileTransferService_TOKEN
300
296
  );
301
297
  if (fileService) {
@@ -307,7 +303,7 @@ var CliScpDownloadProcessor = class {
307
303
  context.writer.writeError("File transfer service not available for browser download.");
308
304
  }
309
305
  } else {
310
- const fileService = context.services.get(
306
+ const fileService = context.services.getRequired(
311
307
  cliCore.ICliFileTransferService_TOKEN
312
308
  );
313
309
  if (fileService) {
@@ -410,14 +406,14 @@ var CliScpUploadProcessor = class {
410
406
  }
411
407
  const server = resolveServer(serverName, context);
412
408
  if (!server) return;
413
- const fileService = context.services.get(
409
+ const fileService = context.services.getRequired(
414
410
  cliCore.ICliFileTransferService_TOKEN
415
411
  );
416
412
  if (!fileService) {
417
413
  context.writer.writeError("File transfer service not available.");
418
414
  return;
419
415
  }
420
- const transferService = context.services.get(
416
+ const transferService = context.services.getRequired(
421
417
  IScpTransferService_TOKEN
422
418
  );
423
419
  if (!transferService) {
@@ -447,14 +443,14 @@ var CliScpUploadProcessor = class {
447
443
  context.spinner?.show(
448
444
  `Uploading "${filename}" (${formatBytes(content.length)}) to ${server.name}:${remotePath}...`
449
445
  );
450
- context.setStatusText(`scp: uploading to ${server.name}`);
446
+ context.notifier.info(`scp: uploading to ${server.name}`);
451
447
  try {
452
448
  await transferService.upload(
453
449
  serverUrl(server),
454
450
  remotePath,
455
451
  content,
456
452
  filename,
457
- server.headers
453
+ cliCore.resolveServerHeaders(context.services, server.name, server.headers)
458
454
  );
459
455
  context.spinner?.hide();
460
456
  context.writer.writeSuccess(
@@ -473,8 +469,6 @@ var CliScpUploadProcessor = class {
473
469
  context.writer.writeln(" scp upload --local <server> <remote-path> Pick from your machine via browser");
474
470
  }
475
471
  };
476
-
477
- // src/lib/processors/cli-scp-rm-processor.ts
478
472
  var CliScpRmProcessor = class {
479
473
  constructor() {
480
474
  this.command = "rm";
@@ -505,7 +499,7 @@ var CliScpRmProcessor = class {
505
499
  const [serverName, path] = parsed;
506
500
  const server = resolveServer(serverName, context);
507
501
  if (!server) return;
508
- const transferService = context.services.get(
502
+ const transferService = context.services.getRequired(
509
503
  IScpTransferService_TOKEN
510
504
  );
511
505
  if (!transferService) {
@@ -517,7 +511,7 @@ var CliScpRmProcessor = class {
517
511
  await transferService.rm(
518
512
  serverUrl(server),
519
513
  path,
520
- server.headers
514
+ cliCore.resolveServerHeaders(context.services, server.name, server.headers)
521
515
  );
522
516
  context.spinner?.hide();
523
517
  context.writer.writeSuccess(`Deleted: ${server.name}:${path}`);
@@ -530,8 +524,6 @@ var CliScpRmProcessor = class {
530
524
  context.writer.writeln("Delete a file on a remote server.");
531
525
  }
532
526
  };
533
-
534
- // src/lib/processors/cli-scp-mkdir-processor.ts
535
527
  var CliScpMkdirProcessor = class {
536
528
  constructor() {
537
529
  this.command = "mkdir";
@@ -562,7 +554,7 @@ var CliScpMkdirProcessor = class {
562
554
  const [serverName, path] = parsed;
563
555
  const server = resolveServer(serverName, context);
564
556
  if (!server) return;
565
- const transferService = context.services.get(
557
+ const transferService = context.services.getRequired(
566
558
  IScpTransferService_TOKEN
567
559
  );
568
560
  if (!transferService) {
@@ -574,7 +566,7 @@ var CliScpMkdirProcessor = class {
574
566
  await transferService.mkdir(
575
567
  serverUrl(server),
576
568
  path,
577
- server.headers
569
+ cliCore.resolveServerHeaders(context.services, server.name, server.headers)
578
570
  );
579
571
  context.spinner?.hide();
580
572
  context.writer.writeSuccess(`Created directory: ${server.name}:${path}`);
@@ -587,8 +579,6 @@ var CliScpMkdirProcessor = class {
587
579
  context.writer.writeln("Create a directory on a remote server.");
588
580
  }
589
581
  };
590
-
591
- // src/lib/processors/cli-scp-stat-processor.ts
592
582
  var CliScpStatProcessor = class {
593
583
  constructor() {
594
584
  this.command = "stat";
@@ -619,7 +609,7 @@ var CliScpStatProcessor = class {
619
609
  const [serverName, path] = parsed;
620
610
  const server = resolveServer(serverName, context);
621
611
  if (!server) return;
622
- const transferService = context.services.get(
612
+ const transferService = context.services.getRequired(
623
613
  IScpTransferService_TOKEN
624
614
  );
625
615
  if (!transferService) {
@@ -631,7 +621,7 @@ var CliScpStatProcessor = class {
631
621
  const stat = await transferService.stat(
632
622
  serverUrl(server),
633
623
  path,
634
- server.headers
624
+ cliCore.resolveServerHeaders(context.services, server.name, server.headers)
635
625
  );
636
626
  context.spinner?.hide();
637
627
  const entries = {
@@ -713,7 +703,7 @@ var CliScpCommandCommandProcessor = class {
713
703
  async doDownload(serverName, remotePath, localPath, command, context) {
714
704
  const server = resolveServer(serverName, context);
715
705
  if (!server) return;
716
- const transferService = context.services.get(
706
+ const transferService = context.services.getRequired(
717
707
  IScpTransferService_TOKEN
718
708
  );
719
709
  if (!transferService) {
@@ -722,13 +712,13 @@ var CliScpCommandCommandProcessor = class {
722
712
  }
723
713
  const useBrowserDownload = command.args?.["save"] === true;
724
714
  context.spinner?.show(`Downloading ${remotePath} from ${server.name}...`);
725
- context.setStatusText(`scp: downloading from ${server.name}`);
715
+ context.notifier.info(`scp: downloading from ${server.name}`);
726
716
  try {
727
717
  let lastProgressUpdate = 0;
728
718
  const { content, size } = await transferService.download(
729
719
  serverUrl(server),
730
720
  remotePath,
731
- server.headers,
721
+ cliCore.resolveServerHeaders(context.services, server.name, server.headers),
732
722
  (received, total) => {
733
723
  const now = Date.now();
734
724
  if (now - lastProgressUpdate < 200) return;
@@ -738,17 +728,17 @@ var CliScpCommandCommandProcessor = class {
738
728
  context.spinner?.show(
739
729
  `Downloading ${remotePath}... ${pct}% (${formatBytes(received)}/${formatBytes(total)})`
740
730
  );
741
- context.setStatusText(`scp: download ${pct}%`);
731
+ context.notifier.info(`scp: download ${pct}%`);
742
732
  } else {
743
733
  context.spinner?.show(
744
734
  `Downloading ${remotePath}... ${formatBytes(received)}`
745
735
  );
746
- context.setStatusText(`scp: download ${formatBytes(received)}`);
736
+ context.notifier.info(`scp: download ${formatBytes(received)}`);
747
737
  }
748
738
  }
749
739
  );
750
740
  context.spinner?.hide();
751
- const fileService = context.services.get(
741
+ const fileService = context.services.getRequired(
752
742
  cliCore.ICliFileTransferService_TOKEN
753
743
  );
754
744
  if (!fileService) {
@@ -774,14 +764,14 @@ var CliScpCommandCommandProcessor = class {
774
764
  async doUpload(serverName, localPath, remotePath, context) {
775
765
  const server = resolveServer(serverName, context);
776
766
  if (!server) return;
777
- const fileService = context.services.get(
767
+ const fileService = context.services.getRequired(
778
768
  cliCore.ICliFileTransferService_TOKEN
779
769
  );
780
770
  if (!fileService) {
781
771
  context.writer.writeError("File transfer service not available.");
782
772
  return;
783
773
  }
784
- const transferService = context.services.get(
774
+ const transferService = context.services.getRequired(
785
775
  IScpTransferService_TOKEN
786
776
  );
787
777
  if (!transferService) {
@@ -789,7 +779,7 @@ var CliScpCommandCommandProcessor = class {
789
779
  return;
790
780
  }
791
781
  context.spinner?.show(`Reading local file "${localPath}"...`);
792
- context.setStatusText(`scp: reading ${localPath}`);
782
+ context.notifier.info(`scp: reading ${localPath}`);
793
783
  try {
794
784
  const content = await fileService.readFile(localPath);
795
785
  if (content === null) {
@@ -801,13 +791,13 @@ var CliScpCommandCommandProcessor = class {
801
791
  context.spinner?.show(
802
792
  `Uploading "${filename}" (${formatBytes(content.length)}) to ${server.name}:${remotePath}...`
803
793
  );
804
- context.setStatusText(`scp: uploading to ${server.name}`);
794
+ context.notifier.info(`scp: uploading to ${server.name}`);
805
795
  await transferService.upload(
806
796
  serverUrl(server),
807
797
  remotePath,
808
798
  content,
809
799
  filename,
810
- server.headers
800
+ cliCore.resolveServerHeaders(context.services, server.name, server.headers)
811
801
  );
812
802
  context.spinner?.hide();
813
803
  context.writer.writeSuccess(
@@ -819,32 +809,30 @@ var CliScpCommandCommandProcessor = class {
819
809
  }
820
810
  }
821
811
  };
822
-
823
- // src/lib/services/scp-transfer.service.ts
824
812
  var ScpTransferService = class {
825
813
  async ls(serverUrl2, path, headers) {
826
814
  const res = await this._fetch(`${serverUrl2}/api/qcli/fs/ls?path=${encodeURIComponent(path)}`, {
827
- headers
815
+ headers: cliCore.resolveHeaders(headers)
828
816
  });
829
817
  const data = await res.json();
830
818
  return data.entries;
831
819
  }
832
820
  async cat(serverUrl2, path, headers) {
833
821
  const res = await this._fetch(`${serverUrl2}/api/qcli/fs/cat?path=${encodeURIComponent(path)}`, {
834
- headers
822
+ headers: cliCore.resolveHeaders(headers)
835
823
  });
836
824
  const data = await res.json();
837
825
  return data.content;
838
826
  }
839
827
  async stat(serverUrl2, path, headers) {
840
828
  const res = await this._fetch(`${serverUrl2}/api/qcli/fs/stat?path=${encodeURIComponent(path)}`, {
841
- headers
829
+ headers: cliCore.resolveHeaders(headers)
842
830
  });
843
831
  return await res.json();
844
832
  }
845
833
  async download(serverUrl2, path, headers, onProgress, signal) {
846
834
  const res = await this._fetch(`${serverUrl2}/api/qcli/fs/download?path=${encodeURIComponent(path)}`, {
847
- headers,
835
+ headers: cliCore.resolveHeaders(headers),
848
836
  signal
849
837
  });
850
838
  const contentLength = parseInt(res.headers.get("content-length") || "0", 10);
@@ -880,20 +868,20 @@ var ScpTransferService = class {
880
868
  await this._fetch(`${serverUrl2}/api/qcli/fs/upload`, {
881
869
  method: "POST",
882
870
  body: formData,
883
- headers
871
+ headers: cliCore.resolveHeaders(headers)
884
872
  });
885
873
  }
886
874
  async mkdir(serverUrl2, path, headers) {
887
875
  await this._fetch(`${serverUrl2}/api/qcli/fs/mkdir`, {
888
876
  method: "POST",
889
- headers: { "Content-Type": "application/json", ...headers },
877
+ headers: { "Content-Type": "application/json", ...cliCore.resolveHeaders(headers) },
890
878
  body: JSON.stringify({ path })
891
879
  });
892
880
  }
893
881
  async rm(serverUrl2, path, headers) {
894
882
  await this._fetch(`${serverUrl2}/api/qcli/fs/rm?path=${encodeURIComponent(path)}`, {
895
883
  method: "DELETE",
896
- headers
884
+ headers: cliCore.resolveHeaders(headers)
897
885
  });
898
886
  }
899
887
  async _fetch(url, init) {