@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 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.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.12"
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.12";
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.12";
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.12";
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,7 +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.setStatusText(`scp: downloading from ${server.name}`);
268
+ context.notifier.info(`scp: downloading from ${server.name}`);
269
269
  const abortController = new AbortController();
270
270
  const abortSub = context.onAbort.subscribe(() => abortController.abort());
271
271
  try {
@@ -283,19 +283,19 @@ var CliScpDownloadProcessor = class {
283
283
  context.spinner?.show(
284
284
  `Downloading ${remotePath}... ${pct}% (${formatBytes(received)}/${formatBytes(total)})`
285
285
  );
286
- context.setStatusText(`scp: download ${pct}%`);
286
+ context.notifier.info(`scp: download ${pct}%`);
287
287
  } else {
288
288
  context.spinner?.show(
289
289
  `Downloading ${remotePath}... ${formatBytes(received)}`
290
290
  );
291
- context.setStatusText(`scp: download ${formatBytes(received)}`);
291
+ context.notifier.info(`scp: download ${formatBytes(received)}`);
292
292
  }
293
293
  },
294
294
  abortController.signal
295
295
  );
296
296
  context.spinner?.hide();
297
297
  if (useBrowserDownload) {
298
- const fileService = context.services.get(
298
+ const fileService = context.services.getRequired(
299
299
  cliCore.ICliFileTransferService_TOKEN
300
300
  );
301
301
  if (fileService) {
@@ -307,7 +307,7 @@ var CliScpDownloadProcessor = class {
307
307
  context.writer.writeError("File transfer service not available for browser download.");
308
308
  }
309
309
  } else {
310
- const fileService = context.services.get(
310
+ const fileService = context.services.getRequired(
311
311
  cliCore.ICliFileTransferService_TOKEN
312
312
  );
313
313
  if (fileService) {
@@ -410,14 +410,14 @@ var CliScpUploadProcessor = class {
410
410
  }
411
411
  const server = resolveServer(serverName, context);
412
412
  if (!server) return;
413
- const fileService = context.services.get(
413
+ const fileService = context.services.getRequired(
414
414
  cliCore.ICliFileTransferService_TOKEN
415
415
  );
416
416
  if (!fileService) {
417
417
  context.writer.writeError("File transfer service not available.");
418
418
  return;
419
419
  }
420
- const transferService = context.services.get(
420
+ const transferService = context.services.getRequired(
421
421
  IScpTransferService_TOKEN
422
422
  );
423
423
  if (!transferService) {
@@ -447,7 +447,7 @@ var CliScpUploadProcessor = class {
447
447
  context.spinner?.show(
448
448
  `Uploading "${filename}" (${formatBytes(content.length)}) to ${server.name}:${remotePath}...`
449
449
  );
450
- context.setStatusText(`scp: uploading to ${server.name}`);
450
+ context.notifier.info(`scp: uploading to ${server.name}`);
451
451
  try {
452
452
  await transferService.upload(
453
453
  serverUrl(server),
@@ -505,7 +505,7 @@ var CliScpRmProcessor = class {
505
505
  const [serverName, path] = parsed;
506
506
  const server = resolveServer(serverName, context);
507
507
  if (!server) return;
508
- const transferService = context.services.get(
508
+ const transferService = context.services.getRequired(
509
509
  IScpTransferService_TOKEN
510
510
  );
511
511
  if (!transferService) {
@@ -562,7 +562,7 @@ var CliScpMkdirProcessor = class {
562
562
  const [serverName, path] = parsed;
563
563
  const server = resolveServer(serverName, context);
564
564
  if (!server) return;
565
- const transferService = context.services.get(
565
+ const transferService = context.services.getRequired(
566
566
  IScpTransferService_TOKEN
567
567
  );
568
568
  if (!transferService) {
@@ -619,7 +619,7 @@ var CliScpStatProcessor = class {
619
619
  const [serverName, path] = parsed;
620
620
  const server = resolveServer(serverName, context);
621
621
  if (!server) return;
622
- const transferService = context.services.get(
622
+ const transferService = context.services.getRequired(
623
623
  IScpTransferService_TOKEN
624
624
  );
625
625
  if (!transferService) {
@@ -713,7 +713,7 @@ var CliScpCommandCommandProcessor = class {
713
713
  async doDownload(serverName, remotePath, localPath, command, context) {
714
714
  const server = resolveServer(serverName, context);
715
715
  if (!server) return;
716
- const transferService = context.services.get(
716
+ const transferService = context.services.getRequired(
717
717
  IScpTransferService_TOKEN
718
718
  );
719
719
  if (!transferService) {
@@ -722,7 +722,7 @@ var CliScpCommandCommandProcessor = class {
722
722
  }
723
723
  const useBrowserDownload = command.args?.["save"] === true;
724
724
  context.spinner?.show(`Downloading ${remotePath} from ${server.name}...`);
725
- context.setStatusText(`scp: downloading from ${server.name}`);
725
+ context.notifier.info(`scp: downloading from ${server.name}`);
726
726
  try {
727
727
  let lastProgressUpdate = 0;
728
728
  const { content, size } = await transferService.download(
@@ -738,17 +738,17 @@ var CliScpCommandCommandProcessor = class {
738
738
  context.spinner?.show(
739
739
  `Downloading ${remotePath}... ${pct}% (${formatBytes(received)}/${formatBytes(total)})`
740
740
  );
741
- context.setStatusText(`scp: download ${pct}%`);
741
+ context.notifier.info(`scp: download ${pct}%`);
742
742
  } else {
743
743
  context.spinner?.show(
744
744
  `Downloading ${remotePath}... ${formatBytes(received)}`
745
745
  );
746
- context.setStatusText(`scp: download ${formatBytes(received)}`);
746
+ context.notifier.info(`scp: download ${formatBytes(received)}`);
747
747
  }
748
748
  }
749
749
  );
750
750
  context.spinner?.hide();
751
- const fileService = context.services.get(
751
+ const fileService = context.services.getRequired(
752
752
  cliCore.ICliFileTransferService_TOKEN
753
753
  );
754
754
  if (!fileService) {
@@ -774,14 +774,14 @@ var CliScpCommandCommandProcessor = class {
774
774
  async doUpload(serverName, localPath, remotePath, context) {
775
775
  const server = resolveServer(serverName, context);
776
776
  if (!server) return;
777
- const fileService = context.services.get(
777
+ const fileService = context.services.getRequired(
778
778
  cliCore.ICliFileTransferService_TOKEN
779
779
  );
780
780
  if (!fileService) {
781
781
  context.writer.writeError("File transfer service not available.");
782
782
  return;
783
783
  }
784
- const transferService = context.services.get(
784
+ const transferService = context.services.getRequired(
785
785
  IScpTransferService_TOKEN
786
786
  );
787
787
  if (!transferService) {
@@ -789,7 +789,7 @@ var CliScpCommandCommandProcessor = class {
789
789
  return;
790
790
  }
791
791
  context.spinner?.show(`Reading local file "${localPath}"...`);
792
- context.setStatusText(`scp: reading ${localPath}`);
792
+ context.notifier.info(`scp: reading ${localPath}`);
793
793
  try {
794
794
  const content = await fileService.readFile(localPath);
795
795
  if (content === null) {
@@ -801,7 +801,7 @@ var CliScpCommandCommandProcessor = class {
801
801
  context.spinner?.show(
802
802
  `Uploading "${filename}" (${formatBytes(content.length)}) to ${server.name}:${remotePath}...`
803
803
  );
804
- context.setStatusText(`scp: uploading to ${server.name}`);
804
+ context.notifier.info(`scp: uploading to ${server.name}`);
805
805
  await transferService.upload(
806
806
  serverUrl(server),
807
807
  remotePath,
@@ -819,32 +819,30 @@ var CliScpCommandCommandProcessor = class {
819
819
  }
820
820
  }
821
821
  };
822
-
823
- // src/lib/services/scp-transfer.service.ts
824
822
  var ScpTransferService = class {
825
823
  async ls(serverUrl2, path, headers) {
826
824
  const res = await this._fetch(`${serverUrl2}/api/qcli/fs/ls?path=${encodeURIComponent(path)}`, {
827
- headers
825
+ headers: cliCore.resolveHeaders(headers)
828
826
  });
829
827
  const data = await res.json();
830
828
  return data.entries;
831
829
  }
832
830
  async cat(serverUrl2, path, headers) {
833
831
  const res = await this._fetch(`${serverUrl2}/api/qcli/fs/cat?path=${encodeURIComponent(path)}`, {
834
- headers
832
+ headers: cliCore.resolveHeaders(headers)
835
833
  });
836
834
  const data = await res.json();
837
835
  return data.content;
838
836
  }
839
837
  async stat(serverUrl2, path, headers) {
840
838
  const res = await this._fetch(`${serverUrl2}/api/qcli/fs/stat?path=${encodeURIComponent(path)}`, {
841
- headers
839
+ headers: cliCore.resolveHeaders(headers)
842
840
  });
843
841
  return await res.json();
844
842
  }
845
843
  async download(serverUrl2, path, headers, onProgress, signal) {
846
844
  const res = await this._fetch(`${serverUrl2}/api/qcli/fs/download?path=${encodeURIComponent(path)}`, {
847
- headers,
845
+ headers: cliCore.resolveHeaders(headers),
848
846
  signal
849
847
  });
850
848
  const contentLength = parseInt(res.headers.get("content-length") || "0", 10);
@@ -880,20 +878,20 @@ var ScpTransferService = class {
880
878
  await this._fetch(`${serverUrl2}/api/qcli/fs/upload`, {
881
879
  method: "POST",
882
880
  body: formData,
883
- headers
881
+ headers: cliCore.resolveHeaders(headers)
884
882
  });
885
883
  }
886
884
  async mkdir(serverUrl2, path, headers) {
887
885
  await this._fetch(`${serverUrl2}/api/qcli/fs/mkdir`, {
888
886
  method: "POST",
889
- headers: { "Content-Type": "application/json", ...headers },
887
+ headers: { "Content-Type": "application/json", ...cliCore.resolveHeaders(headers) },
890
888
  body: JSON.stringify({ path })
891
889
  });
892
890
  }
893
891
  async rm(serverUrl2, path, headers) {
894
892
  await this._fetch(`${serverUrl2}/api/qcli/fs/rm?path=${encodeURIComponent(path)}`, {
895
893
  method: "DELETE",
896
- headers
894
+ headers: cliCore.resolveHeaders(headers)
897
895
  });
898
896
  }
899
897
  async _fetch(url, init) {