@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/public-api.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { DefaultLibraryAuthor, ICliFileTransferService_TOKEN } from '@qodalis/cli-core';
1
+ import { DefaultLibraryAuthor, ICliFileTransferService_TOKEN, resolveHeaders } from '@qodalis/cli-core';
2
2
 
3
3
  // src/lib/processors/cli-scp-command-processor.ts
4
4
 
5
5
  // src/lib/version.ts
6
- var LIBRARY_VERSION = "2.0.0-beta.12";
6
+ var LIBRARY_VERSION = "2.0.0-beta.13";
7
7
  var API_VERSION = 2;
8
8
 
9
9
  // src/lib/interfaces/index.ts
@@ -94,7 +94,7 @@ var CliScpLsProcessor = class {
94
94
  const [serverName, path] = parsed;
95
95
  const server = resolveServer(serverName, context);
96
96
  if (!server) return;
97
- const transferService = context.services.get(
97
+ const transferService = context.services.getRequired(
98
98
  IScpTransferService_TOKEN
99
99
  );
100
100
  if (!transferService) {
@@ -163,7 +163,7 @@ var CliScpCatProcessor = class {
163
163
  const [serverName, path] = parsed;
164
164
  const server = resolveServer(serverName, context);
165
165
  if (!server) return;
166
- const transferService = context.services.get(
166
+ const transferService = context.services.getRequired(
167
167
  IScpTransferService_TOKEN
168
168
  );
169
169
  if (!transferService) {
@@ -254,7 +254,7 @@ var CliScpDownloadProcessor = class {
254
254
  localPath = localPath || remotePath.split("/").pop() || "download";
255
255
  const server = resolveServer(serverName, context);
256
256
  if (!server) return;
257
- const transferService = context.services.get(
257
+ const transferService = context.services.getRequired(
258
258
  IScpTransferService_TOKEN
259
259
  );
260
260
  if (!transferService) {
@@ -263,7 +263,7 @@ var CliScpDownloadProcessor = class {
263
263
  }
264
264
  const useBrowserDownload = command.args?.["save"] === true;
265
265
  context.spinner?.show(`Downloading ${remotePath} from ${server.name}...`);
266
- context.setStatusText(`scp: downloading from ${server.name}`);
266
+ context.notifier.info(`scp: downloading from ${server.name}`);
267
267
  const abortController = new AbortController();
268
268
  const abortSub = context.onAbort.subscribe(() => abortController.abort());
269
269
  try {
@@ -281,19 +281,19 @@ var CliScpDownloadProcessor = class {
281
281
  context.spinner?.show(
282
282
  `Downloading ${remotePath}... ${pct}% (${formatBytes(received)}/${formatBytes(total)})`
283
283
  );
284
- context.setStatusText(`scp: download ${pct}%`);
284
+ context.notifier.info(`scp: download ${pct}%`);
285
285
  } else {
286
286
  context.spinner?.show(
287
287
  `Downloading ${remotePath}... ${formatBytes(received)}`
288
288
  );
289
- context.setStatusText(`scp: download ${formatBytes(received)}`);
289
+ context.notifier.info(`scp: download ${formatBytes(received)}`);
290
290
  }
291
291
  },
292
292
  abortController.signal
293
293
  );
294
294
  context.spinner?.hide();
295
295
  if (useBrowserDownload) {
296
- const fileService = context.services.get(
296
+ const fileService = context.services.getRequired(
297
297
  ICliFileTransferService_TOKEN
298
298
  );
299
299
  if (fileService) {
@@ -305,7 +305,7 @@ var CliScpDownloadProcessor = class {
305
305
  context.writer.writeError("File transfer service not available for browser download.");
306
306
  }
307
307
  } else {
308
- const fileService = context.services.get(
308
+ const fileService = context.services.getRequired(
309
309
  ICliFileTransferService_TOKEN
310
310
  );
311
311
  if (fileService) {
@@ -408,14 +408,14 @@ var CliScpUploadProcessor = class {
408
408
  }
409
409
  const server = resolveServer(serverName, context);
410
410
  if (!server) return;
411
- const fileService = context.services.get(
411
+ const fileService = context.services.getRequired(
412
412
  ICliFileTransferService_TOKEN
413
413
  );
414
414
  if (!fileService) {
415
415
  context.writer.writeError("File transfer service not available.");
416
416
  return;
417
417
  }
418
- const transferService = context.services.get(
418
+ const transferService = context.services.getRequired(
419
419
  IScpTransferService_TOKEN
420
420
  );
421
421
  if (!transferService) {
@@ -445,7 +445,7 @@ var CliScpUploadProcessor = class {
445
445
  context.spinner?.show(
446
446
  `Uploading "${filename}" (${formatBytes(content.length)}) to ${server.name}:${remotePath}...`
447
447
  );
448
- context.setStatusText(`scp: uploading to ${server.name}`);
448
+ context.notifier.info(`scp: uploading to ${server.name}`);
449
449
  try {
450
450
  await transferService.upload(
451
451
  serverUrl(server),
@@ -503,7 +503,7 @@ var CliScpRmProcessor = class {
503
503
  const [serverName, path] = parsed;
504
504
  const server = resolveServer(serverName, context);
505
505
  if (!server) return;
506
- const transferService = context.services.get(
506
+ const transferService = context.services.getRequired(
507
507
  IScpTransferService_TOKEN
508
508
  );
509
509
  if (!transferService) {
@@ -560,7 +560,7 @@ var CliScpMkdirProcessor = class {
560
560
  const [serverName, path] = parsed;
561
561
  const server = resolveServer(serverName, context);
562
562
  if (!server) return;
563
- const transferService = context.services.get(
563
+ const transferService = context.services.getRequired(
564
564
  IScpTransferService_TOKEN
565
565
  );
566
566
  if (!transferService) {
@@ -617,7 +617,7 @@ var CliScpStatProcessor = class {
617
617
  const [serverName, path] = parsed;
618
618
  const server = resolveServer(serverName, context);
619
619
  if (!server) return;
620
- const transferService = context.services.get(
620
+ const transferService = context.services.getRequired(
621
621
  IScpTransferService_TOKEN
622
622
  );
623
623
  if (!transferService) {
@@ -711,7 +711,7 @@ var CliScpCommandCommandProcessor = class {
711
711
  async doDownload(serverName, remotePath, localPath, command, context) {
712
712
  const server = resolveServer(serverName, context);
713
713
  if (!server) return;
714
- const transferService = context.services.get(
714
+ const transferService = context.services.getRequired(
715
715
  IScpTransferService_TOKEN
716
716
  );
717
717
  if (!transferService) {
@@ -720,7 +720,7 @@ var CliScpCommandCommandProcessor = class {
720
720
  }
721
721
  const useBrowserDownload = command.args?.["save"] === true;
722
722
  context.spinner?.show(`Downloading ${remotePath} from ${server.name}...`);
723
- context.setStatusText(`scp: downloading from ${server.name}`);
723
+ context.notifier.info(`scp: downloading from ${server.name}`);
724
724
  try {
725
725
  let lastProgressUpdate = 0;
726
726
  const { content, size } = await transferService.download(
@@ -736,17 +736,17 @@ var CliScpCommandCommandProcessor = class {
736
736
  context.spinner?.show(
737
737
  `Downloading ${remotePath}... ${pct}% (${formatBytes(received)}/${formatBytes(total)})`
738
738
  );
739
- context.setStatusText(`scp: download ${pct}%`);
739
+ context.notifier.info(`scp: download ${pct}%`);
740
740
  } else {
741
741
  context.spinner?.show(
742
742
  `Downloading ${remotePath}... ${formatBytes(received)}`
743
743
  );
744
- context.setStatusText(`scp: download ${formatBytes(received)}`);
744
+ context.notifier.info(`scp: download ${formatBytes(received)}`);
745
745
  }
746
746
  }
747
747
  );
748
748
  context.spinner?.hide();
749
- const fileService = context.services.get(
749
+ const fileService = context.services.getRequired(
750
750
  ICliFileTransferService_TOKEN
751
751
  );
752
752
  if (!fileService) {
@@ -772,14 +772,14 @@ var CliScpCommandCommandProcessor = class {
772
772
  async doUpload(serverName, localPath, remotePath, context) {
773
773
  const server = resolveServer(serverName, context);
774
774
  if (!server) return;
775
- const fileService = context.services.get(
775
+ const fileService = context.services.getRequired(
776
776
  ICliFileTransferService_TOKEN
777
777
  );
778
778
  if (!fileService) {
779
779
  context.writer.writeError("File transfer service not available.");
780
780
  return;
781
781
  }
782
- const transferService = context.services.get(
782
+ const transferService = context.services.getRequired(
783
783
  IScpTransferService_TOKEN
784
784
  );
785
785
  if (!transferService) {
@@ -787,7 +787,7 @@ var CliScpCommandCommandProcessor = class {
787
787
  return;
788
788
  }
789
789
  context.spinner?.show(`Reading local file "${localPath}"...`);
790
- context.setStatusText(`scp: reading ${localPath}`);
790
+ context.notifier.info(`scp: reading ${localPath}`);
791
791
  try {
792
792
  const content = await fileService.readFile(localPath);
793
793
  if (content === null) {
@@ -799,7 +799,7 @@ var CliScpCommandCommandProcessor = class {
799
799
  context.spinner?.show(
800
800
  `Uploading "${filename}" (${formatBytes(content.length)}) to ${server.name}:${remotePath}...`
801
801
  );
802
- context.setStatusText(`scp: uploading to ${server.name}`);
802
+ context.notifier.info(`scp: uploading to ${server.name}`);
803
803
  await transferService.upload(
804
804
  serverUrl(server),
805
805
  remotePath,
@@ -817,32 +817,30 @@ var CliScpCommandCommandProcessor = class {
817
817
  }
818
818
  }
819
819
  };
820
-
821
- // src/lib/services/scp-transfer.service.ts
822
820
  var ScpTransferService = class {
823
821
  async ls(serverUrl2, path, headers) {
824
822
  const res = await this._fetch(`${serverUrl2}/api/qcli/fs/ls?path=${encodeURIComponent(path)}`, {
825
- headers
823
+ headers: resolveHeaders(headers)
826
824
  });
827
825
  const data = await res.json();
828
826
  return data.entries;
829
827
  }
830
828
  async cat(serverUrl2, path, headers) {
831
829
  const res = await this._fetch(`${serverUrl2}/api/qcli/fs/cat?path=${encodeURIComponent(path)}`, {
832
- headers
830
+ headers: resolveHeaders(headers)
833
831
  });
834
832
  const data = await res.json();
835
833
  return data.content;
836
834
  }
837
835
  async stat(serverUrl2, path, headers) {
838
836
  const res = await this._fetch(`${serverUrl2}/api/qcli/fs/stat?path=${encodeURIComponent(path)}`, {
839
- headers
837
+ headers: resolveHeaders(headers)
840
838
  });
841
839
  return await res.json();
842
840
  }
843
841
  async download(serverUrl2, path, headers, onProgress, signal) {
844
842
  const res = await this._fetch(`${serverUrl2}/api/qcli/fs/download?path=${encodeURIComponent(path)}`, {
845
- headers,
843
+ headers: resolveHeaders(headers),
846
844
  signal
847
845
  });
848
846
  const contentLength = parseInt(res.headers.get("content-length") || "0", 10);
@@ -878,20 +876,20 @@ var ScpTransferService = class {
878
876
  await this._fetch(`${serverUrl2}/api/qcli/fs/upload`, {
879
877
  method: "POST",
880
878
  body: formData,
881
- headers
879
+ headers: resolveHeaders(headers)
882
880
  });
883
881
  }
884
882
  async mkdir(serverUrl2, path, headers) {
885
883
  await this._fetch(`${serverUrl2}/api/qcli/fs/mkdir`, {
886
884
  method: "POST",
887
- headers: { "Content-Type": "application/json", ...headers },
885
+ headers: { "Content-Type": "application/json", ...resolveHeaders(headers) },
888
886
  body: JSON.stringify({ path })
889
887
  });
890
888
  }
891
889
  async rm(serverUrl2, path, headers) {
892
890
  await this._fetch(`${serverUrl2}/api/qcli/fs/rm?path=${encodeURIComponent(path)}`, {
893
891
  method: "DELETE",
894
- headers
892
+ headers: resolveHeaders(headers)
895
893
  });
896
894
  }
897
895
  async _fetch(url, init) {