@qodalis/cli-scp 2.0.0-beta.7 → 2.0.0-beta.9

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.
@@ -1827,9 +1827,11 @@ var scp = (() => {
1827
1827
  email: "nicolae.lupei@qodalis.com"
1828
1828
  };
1829
1829
  var semver = __toESM(require_semver2());
1830
+ var API_VERSION = 2;
1831
+ var VERSIONS_ENDPOINT = "/api/qcli/versions";
1830
1832
  var ServerVersionNegotiator = class {
1831
1833
  static {
1832
- this.CLIENT_SUPPORTED_VERSIONS = [2];
1834
+ this.CLIENT_SUPPORTED_VERSIONS = [API_VERSION];
1833
1835
  }
1834
1836
  /**
1835
1837
  * Given a server's version info, pick the highest mutually compatible version.
@@ -1848,7 +1850,7 @@ var scp = (() => {
1848
1850
  */
1849
1851
  static async discover(baseUrl) {
1850
1852
  try {
1851
- const response = await fetch(`${baseUrl}/api/qcli/versions`);
1853
+ const response = await fetch(`${baseUrl}${VERSIONS_ENDPOINT}`);
1852
1854
  if (!response.ok) return null;
1853
1855
  const info = await response.json();
1854
1856
  const version = this.negotiate(info);
@@ -2680,8 +2682,8 @@ var scp = (() => {
2680
2682
  };
2681
2683
 
2682
2684
  // src/lib/version.ts
2683
- var LIBRARY_VERSION = "2.0.0-beta.7";
2684
- var API_VERSION = 2;
2685
+ var LIBRARY_VERSION = "2.0.0-beta.9";
2686
+ var API_VERSION2 = 2;
2685
2687
 
2686
2688
  // src/lib/interfaces/index.ts
2687
2689
  var IScpTransferService_TOKEN = "scp-transfer-service";
@@ -3012,7 +3014,7 @@ var scp = (() => {
3012
3014
  constructor() {
3013
3015
  this.command = "upload";
3014
3016
  this.aliases = ["put"];
3015
- this.description = "Upload a local file to a remote server";
3017
+ this.description = "Upload a file to a remote server (use --local to pick from your machine)";
3016
3018
  this.acceptsRawInput = true;
3017
3019
  this.valueRequired = true;
3018
3020
  this.parameters = [
@@ -3024,8 +3026,8 @@ var scp = (() => {
3024
3026
  },
3025
3027
  {
3026
3028
  name: "local-path",
3027
- description: "Local file path",
3028
- required: true,
3029
+ description: "Local file path (from virtual filesystem)",
3030
+ required: false,
3029
3031
  type: "string"
3030
3032
  },
3031
3033
  {
@@ -3033,35 +3035,55 @@ var scp = (() => {
3033
3035
  description: "Remote destination path",
3034
3036
  required: true,
3035
3037
  type: "string"
3038
+ },
3039
+ {
3040
+ name: "local",
3041
+ description: "Pick a file from your local machine via browser file picker",
3042
+ required: false,
3043
+ type: "boolean"
3036
3044
  }
3037
3045
  ];
3038
3046
  }
3039
3047
  async processCommand(command, context) {
3040
3048
  const args = command.args || {};
3049
+ const useLocalPicker = !!args["local"];
3041
3050
  let serverName;
3042
3051
  let localPath;
3043
3052
  let remotePath;
3044
- if (args["server"] && args["local-path"] && args["remote-path"]) {
3053
+ if (args["server"] && args["remote-path"]) {
3045
3054
  serverName = String(args["server"]);
3046
- localPath = String(args["local-path"]);
3055
+ localPath = args["local-path"] ? String(args["local-path"]) : void 0;
3047
3056
  remotePath = String(args["remote-path"]);
3048
3057
  } else {
3049
3058
  const value = command.value?.trim();
3050
3059
  if (!value) {
3051
- context.writer.writeError("Usage: scp upload <server> <local-path> <remote-path>");
3060
+ context.writer.writeError(
3061
+ useLocalPicker ? "Usage: scp upload --local <server> <remote-path>" : "Usage: scp upload <server> <local-path> <remote-path>"
3062
+ );
3052
3063
  return;
3053
3064
  }
3054
3065
  const parts = value.split(/\s+/);
3055
- if (parts.length < 3) {
3056
- context.writer.writeError("Usage: scp upload <server> <local-path> <remote-path>");
3057
- return;
3066
+ if (useLocalPicker) {
3067
+ if (parts.length < 2) {
3068
+ context.writer.writeError("Usage: scp upload --local <server> <remote-path>");
3069
+ return;
3070
+ }
3071
+ serverName = parts[0];
3072
+ remotePath = parts[1];
3073
+ } else {
3074
+ if (parts.length < 3) {
3075
+ context.writer.writeError("Usage: scp upload <server> <local-path> <remote-path>");
3076
+ return;
3077
+ }
3078
+ serverName = parts[0];
3079
+ localPath = parts[1];
3080
+ remotePath = parts[2];
3058
3081
  }
3059
- serverName = parts[0];
3060
- localPath = parts[1];
3061
- remotePath = parts[2];
3062
3082
  }
3063
- if (!serverName || !localPath || !remotePath) {
3064
- context.writer.writeError("Usage: scp upload <server> <local-path> <remote-path>");
3083
+ if (!serverName || !useLocalPicker && !localPath || !remotePath) {
3084
+ context.writer.writeError(
3085
+ useLocalPicker ? "Usage: scp upload --local <server> <remote-path>" : "Usage: scp upload <server> <local-path> <remote-path>"
3086
+ );
3065
3087
  return;
3066
3088
  }
3067
3089
  const server = resolveServer(serverName, context);
@@ -3080,18 +3102,30 @@ var scp = (() => {
3080
3102
  context.writer.writeError("SCP transfer service not available.");
3081
3103
  return;
3082
3104
  }
3083
- context.spinner?.show(`Reading local file "${localPath}"...`);
3084
- try {
3085
- const content = await fileService.readFile(localPath);
3105
+ let content;
3106
+ let filename;
3107
+ if (useLocalPicker) {
3108
+ const picked = await fileService.uploadFromBrowser();
3109
+ if (!picked) {
3110
+ context.writer.writeln("Upload cancelled.");
3111
+ return;
3112
+ }
3113
+ content = picked.content;
3114
+ filename = picked.name;
3115
+ } else {
3116
+ context.spinner?.show(`Reading local file "${localPath}"...`);
3117
+ content = await fileService.readFile(localPath);
3086
3118
  if (content === null) {
3087
3119
  context.spinner?.hide();
3088
3120
  context.writer.writeError(`Local file not found: ${localPath}`);
3089
3121
  return;
3090
3122
  }
3091
- const filename = localPath.split("/").pop() || "file";
3092
- context.spinner?.show(
3093
- `Uploading "${filename}" (${formatBytes(content.length)}) to ${server.name}:${remotePath}...`
3094
- );
3123
+ filename = localPath.split("/").pop() || "file";
3124
+ }
3125
+ context.spinner?.show(
3126
+ `Uploading "${filename}" (${formatBytes(content.length)}) to ${server.name}:${remotePath}...`
3127
+ );
3128
+ try {
3095
3129
  await transferService.upload(
3096
3130
  serverUrl(server),
3097
3131
  remotePath,
@@ -3109,8 +3143,11 @@ var scp = (() => {
3109
3143
  }
3110
3144
  }
3111
3145
  writeDescription(context) {
3112
- context.writer.writeln("Upload a local file to a remote server.");
3113
- context.writer.writeln("Usage: scp upload <server> <local-path> <remote-path>");
3146
+ context.writer.writeln("Upload a file to a remote server.");
3147
+ context.writer.writeln("");
3148
+ context.writer.writeln("Usage:");
3149
+ context.writer.writeln(" scp upload <server> <local-path> <remote-path> Upload from virtual filesystem");
3150
+ context.writer.writeln(" scp upload --local <server> <remote-path> Pick from your machine via browser");
3114
3151
  }
3115
3152
  };
3116
3153
 
@@ -3302,6 +3339,7 @@ var scp = (() => {
3302
3339
  this.description = "SCP-like file transfer between browser and remote servers";
3303
3340
  this.author = DefaultLibraryAuthor;
3304
3341
  this.version = LIBRARY_VERSION;
3342
+ this.metadata = { icon: "\u{1F4C1}", module: "file management" };
3305
3343
  this.acceptsRawInput = true;
3306
3344
  this.processors = [
3307
3345
  new CliScpLsProcessor(),
@@ -3548,7 +3586,7 @@ var scp = (() => {
3548
3586
 
3549
3587
  // src/cli-entrypoint.ts
3550
3588
  var module = {
3551
- apiVersion: API_VERSION,
3589
+ apiVersion: API_VERSION2,
3552
3590
  name: "@qodalis/cli-scp",
3553
3591
  processors: [new CliScpCommandCommandProcessor()],
3554
3592
  services: [