@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qodalis/cli-scp",
3
- "version": "2.0.0-beta.11",
3
+ "version": "2.0.0-beta.13",
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.11"
21
+ "@qodalis/cli-core": "2.0.0-beta.13"
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.11";
21
+ declare const LIBRARY_VERSION = "2.0.0-beta.13";
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.11";
21
+ declare const LIBRARY_VERSION = "2.0.0-beta.13";
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.11";
8
+ var LIBRARY_VERSION = "2.0.0-beta.13";
9
9
  var API_VERSION = 2;
10
10
 
11
11
  // src/lib/interfaces/index.ts
@@ -96,7 +96,7 @@ var CliScpLsProcessor = class {
96
96
  const [serverName, path] = parsed;
97
97
  const server = resolveServer(serverName, context);
98
98
  if (!server) return;
99
- const transferService = context.services.get(
99
+ const transferService = context.services.getRequired(
100
100
  IScpTransferService_TOKEN
101
101
  );
102
102
  if (!transferService) {
@@ -165,7 +165,7 @@ var CliScpCatProcessor = class {
165
165
  const [serverName, path] = parsed;
166
166
  const server = resolveServer(serverName, context);
167
167
  if (!server) return;
168
- const transferService = context.services.get(
168
+ const transferService = context.services.getRequired(
169
169
  IScpTransferService_TOKEN
170
170
  );
171
171
  if (!transferService) {
@@ -256,7 +256,7 @@ var CliScpDownloadProcessor = class {
256
256
  localPath = localPath || remotePath.split("/").pop() || "download";
257
257
  const server = resolveServer(serverName, context);
258
258
  if (!server) return;
259
- const transferService = context.services.get(
259
+ const transferService = context.services.getRequired(
260
260
  IScpTransferService_TOKEN
261
261
  );
262
262
  if (!transferService) {
@@ -265,6 +265,7 @@ var CliScpDownloadProcessor = class {
265
265
  }
266
266
  const useBrowserDownload = command.args?.["save"] === true;
267
267
  context.spinner?.show(`Downloading ${remotePath} from ${server.name}...`);
268
+ context.notifier.info(`scp: downloading from ${server.name}`);
268
269
  const abortController = new AbortController();
269
270
  const abortSub = context.onAbort.subscribe(() => abortController.abort());
270
271
  try {
@@ -282,17 +283,19 @@ var CliScpDownloadProcessor = class {
282
283
  context.spinner?.show(
283
284
  `Downloading ${remotePath}... ${pct}% (${formatBytes(received)}/${formatBytes(total)})`
284
285
  );
286
+ context.notifier.info(`scp: download ${pct}%`);
285
287
  } else {
286
288
  context.spinner?.show(
287
289
  `Downloading ${remotePath}... ${formatBytes(received)}`
288
290
  );
291
+ context.notifier.info(`scp: download ${formatBytes(received)}`);
289
292
  }
290
293
  },
291
294
  abortController.signal
292
295
  );
293
296
  context.spinner?.hide();
294
297
  if (useBrowserDownload) {
295
- const fileService = context.services.get(
298
+ const fileService = context.services.getRequired(
296
299
  cliCore.ICliFileTransferService_TOKEN
297
300
  );
298
301
  if (fileService) {
@@ -304,7 +307,7 @@ var CliScpDownloadProcessor = class {
304
307
  context.writer.writeError("File transfer service not available for browser download.");
305
308
  }
306
309
  } else {
307
- const fileService = context.services.get(
310
+ const fileService = context.services.getRequired(
308
311
  cliCore.ICliFileTransferService_TOKEN
309
312
  );
310
313
  if (fileService) {
@@ -407,14 +410,14 @@ var CliScpUploadProcessor = class {
407
410
  }
408
411
  const server = resolveServer(serverName, context);
409
412
  if (!server) return;
410
- const fileService = context.services.get(
413
+ const fileService = context.services.getRequired(
411
414
  cliCore.ICliFileTransferService_TOKEN
412
415
  );
413
416
  if (!fileService) {
414
417
  context.writer.writeError("File transfer service not available.");
415
418
  return;
416
419
  }
417
- const transferService = context.services.get(
420
+ const transferService = context.services.getRequired(
418
421
  IScpTransferService_TOKEN
419
422
  );
420
423
  if (!transferService) {
@@ -444,6 +447,7 @@ var CliScpUploadProcessor = class {
444
447
  context.spinner?.show(
445
448
  `Uploading "${filename}" (${formatBytes(content.length)}) to ${server.name}:${remotePath}...`
446
449
  );
450
+ context.notifier.info(`scp: uploading to ${server.name}`);
447
451
  try {
448
452
  await transferService.upload(
449
453
  serverUrl(server),
@@ -501,7 +505,7 @@ var CliScpRmProcessor = class {
501
505
  const [serverName, path] = parsed;
502
506
  const server = resolveServer(serverName, context);
503
507
  if (!server) return;
504
- const transferService = context.services.get(
508
+ const transferService = context.services.getRequired(
505
509
  IScpTransferService_TOKEN
506
510
  );
507
511
  if (!transferService) {
@@ -558,7 +562,7 @@ var CliScpMkdirProcessor = class {
558
562
  const [serverName, path] = parsed;
559
563
  const server = resolveServer(serverName, context);
560
564
  if (!server) return;
561
- const transferService = context.services.get(
565
+ const transferService = context.services.getRequired(
562
566
  IScpTransferService_TOKEN
563
567
  );
564
568
  if (!transferService) {
@@ -615,7 +619,7 @@ var CliScpStatProcessor = class {
615
619
  const [serverName, path] = parsed;
616
620
  const server = resolveServer(serverName, context);
617
621
  if (!server) return;
618
- const transferService = context.services.get(
622
+ const transferService = context.services.getRequired(
619
623
  IScpTransferService_TOKEN
620
624
  );
621
625
  if (!transferService) {
@@ -709,7 +713,7 @@ var CliScpCommandCommandProcessor = class {
709
713
  async doDownload(serverName, remotePath, localPath, command, context) {
710
714
  const server = resolveServer(serverName, context);
711
715
  if (!server) return;
712
- const transferService = context.services.get(
716
+ const transferService = context.services.getRequired(
713
717
  IScpTransferService_TOKEN
714
718
  );
715
719
  if (!transferService) {
@@ -718,6 +722,7 @@ var CliScpCommandCommandProcessor = class {
718
722
  }
719
723
  const useBrowserDownload = command.args?.["save"] === true;
720
724
  context.spinner?.show(`Downloading ${remotePath} from ${server.name}...`);
725
+ context.notifier.info(`scp: downloading from ${server.name}`);
721
726
  try {
722
727
  let lastProgressUpdate = 0;
723
728
  const { content, size } = await transferService.download(
@@ -733,15 +738,17 @@ var CliScpCommandCommandProcessor = class {
733
738
  context.spinner?.show(
734
739
  `Downloading ${remotePath}... ${pct}% (${formatBytes(received)}/${formatBytes(total)})`
735
740
  );
741
+ context.notifier.info(`scp: download ${pct}%`);
736
742
  } else {
737
743
  context.spinner?.show(
738
744
  `Downloading ${remotePath}... ${formatBytes(received)}`
739
745
  );
746
+ context.notifier.info(`scp: download ${formatBytes(received)}`);
740
747
  }
741
748
  }
742
749
  );
743
750
  context.spinner?.hide();
744
- const fileService = context.services.get(
751
+ const fileService = context.services.getRequired(
745
752
  cliCore.ICliFileTransferService_TOKEN
746
753
  );
747
754
  if (!fileService) {
@@ -767,14 +774,14 @@ var CliScpCommandCommandProcessor = class {
767
774
  async doUpload(serverName, localPath, remotePath, context) {
768
775
  const server = resolveServer(serverName, context);
769
776
  if (!server) return;
770
- const fileService = context.services.get(
777
+ const fileService = context.services.getRequired(
771
778
  cliCore.ICliFileTransferService_TOKEN
772
779
  );
773
780
  if (!fileService) {
774
781
  context.writer.writeError("File transfer service not available.");
775
782
  return;
776
783
  }
777
- const transferService = context.services.get(
784
+ const transferService = context.services.getRequired(
778
785
  IScpTransferService_TOKEN
779
786
  );
780
787
  if (!transferService) {
@@ -782,6 +789,7 @@ var CliScpCommandCommandProcessor = class {
782
789
  return;
783
790
  }
784
791
  context.spinner?.show(`Reading local file "${localPath}"...`);
792
+ context.notifier.info(`scp: reading ${localPath}`);
785
793
  try {
786
794
  const content = await fileService.readFile(localPath);
787
795
  if (content === null) {
@@ -793,6 +801,7 @@ var CliScpCommandCommandProcessor = class {
793
801
  context.spinner?.show(
794
802
  `Uploading "${filename}" (${formatBytes(content.length)}) to ${server.name}:${remotePath}...`
795
803
  );
804
+ context.notifier.info(`scp: uploading to ${server.name}`);
796
805
  await transferService.upload(
797
806
  serverUrl(server),
798
807
  remotePath,
@@ -810,32 +819,30 @@ var CliScpCommandCommandProcessor = class {
810
819
  }
811
820
  }
812
821
  };
813
-
814
- // src/lib/services/scp-transfer.service.ts
815
822
  var ScpTransferService = class {
816
823
  async ls(serverUrl2, path, headers) {
817
824
  const res = await this._fetch(`${serverUrl2}/api/qcli/fs/ls?path=${encodeURIComponent(path)}`, {
818
- headers
825
+ headers: cliCore.resolveHeaders(headers)
819
826
  });
820
827
  const data = await res.json();
821
828
  return data.entries;
822
829
  }
823
830
  async cat(serverUrl2, path, headers) {
824
831
  const res = await this._fetch(`${serverUrl2}/api/qcli/fs/cat?path=${encodeURIComponent(path)}`, {
825
- headers
832
+ headers: cliCore.resolveHeaders(headers)
826
833
  });
827
834
  const data = await res.json();
828
835
  return data.content;
829
836
  }
830
837
  async stat(serverUrl2, path, headers) {
831
838
  const res = await this._fetch(`${serverUrl2}/api/qcli/fs/stat?path=${encodeURIComponent(path)}`, {
832
- headers
839
+ headers: cliCore.resolveHeaders(headers)
833
840
  });
834
841
  return await res.json();
835
842
  }
836
843
  async download(serverUrl2, path, headers, onProgress, signal) {
837
844
  const res = await this._fetch(`${serverUrl2}/api/qcli/fs/download?path=${encodeURIComponent(path)}`, {
838
- headers,
845
+ headers: cliCore.resolveHeaders(headers),
839
846
  signal
840
847
  });
841
848
  const contentLength = parseInt(res.headers.get("content-length") || "0", 10);
@@ -871,20 +878,20 @@ var ScpTransferService = class {
871
878
  await this._fetch(`${serverUrl2}/api/qcli/fs/upload`, {
872
879
  method: "POST",
873
880
  body: formData,
874
- headers
881
+ headers: cliCore.resolveHeaders(headers)
875
882
  });
876
883
  }
877
884
  async mkdir(serverUrl2, path, headers) {
878
885
  await this._fetch(`${serverUrl2}/api/qcli/fs/mkdir`, {
879
886
  method: "POST",
880
- headers: { "Content-Type": "application/json", ...headers },
887
+ headers: { "Content-Type": "application/json", ...cliCore.resolveHeaders(headers) },
881
888
  body: JSON.stringify({ path })
882
889
  });
883
890
  }
884
891
  async rm(serverUrl2, path, headers) {
885
892
  await this._fetch(`${serverUrl2}/api/qcli/fs/rm?path=${encodeURIComponent(path)}`, {
886
893
  method: "DELETE",
887
- headers
894
+ headers: cliCore.resolveHeaders(headers)
888
895
  });
889
896
  }
890
897
  async _fetch(url, init) {