@qodalis/cli-files 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qodalis/cli-files",
3
- "version": "2.0.0-beta.7",
3
+ "version": "2.0.0-beta.9",
4
4
  "description": "@qodalis/cli extension for Linux file management commands with in-memory filesystem.",
5
5
  "author": "Nicolae Lupei, Qodalis Solutions",
6
6
  "license": "MIT",
@@ -23,7 +23,7 @@
23
23
  "umd": "./umd/index.global.js",
24
24
  "unpkg": "./umd/index.global.js",
25
25
  "dependencies": {
26
- "@qodalis/cli-core": "2.0.0-beta.7"
26
+ "@qodalis/cli-core": "2.0.0-beta.9"
27
27
  },
28
28
  "sideEffects": false,
29
29
  "main": "./public-api.js",
package/public-api.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as _qodalis_cli_core from '@qodalis/cli-core';
2
- import { ICliOwnership, ICliCommandProcessor, CliProcessCommand, ICliExecutionContext, ICliFileTransferService, ICliFileEntry, ICliCompletionProvider, ICliCompletionContext, ICliModule } from '@qodalis/cli-core';
2
+ import { ICliOwnership, ICliCommandProcessor, CliProcessCommand, ICliExecutionContext, ICliFileTransferService, ICliFileEntry, ICliCompletionProvider, ICliCompletionContext, ICliConfigurableModule } from '@qodalis/cli-core';
3
+ import { Subscription } from 'rxjs';
3
4
 
4
5
  /**
5
6
  * Represents a node in the virtual filesystem (file or directory).
@@ -987,8 +988,9 @@ interface CliFilesModuleConfig {
987
988
  */
988
989
  showPathInPrompt?: boolean;
989
990
  }
990
- interface ICliFilesModule extends ICliModule {
991
- configure(config: CliFilesModuleConfig): ICliModule;
991
+ interface ICliFilesModule extends ICliConfigurableModule<CliFilesModuleConfig> {
992
+ /** Subscription for drag-and-drop file uploads, cleaned up in onDestroy */
993
+ _dragDropSubscription?: Subscription;
992
994
  }
993
995
  declare const filesModule: ICliFilesModule;
994
996
 
package/public-api.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as _qodalis_cli_core from '@qodalis/cli-core';
2
- import { ICliOwnership, ICliCommandProcessor, CliProcessCommand, ICliExecutionContext, ICliFileTransferService, ICliFileEntry, ICliCompletionProvider, ICliCompletionContext, ICliModule } from '@qodalis/cli-core';
2
+ import { ICliOwnership, ICliCommandProcessor, CliProcessCommand, ICliExecutionContext, ICliFileTransferService, ICliFileEntry, ICliCompletionProvider, ICliCompletionContext, ICliConfigurableModule } from '@qodalis/cli-core';
3
+ import { Subscription } from 'rxjs';
3
4
 
4
5
  /**
5
6
  * Represents a node in the virtual filesystem (file or directory).
@@ -987,8 +988,9 @@ interface CliFilesModuleConfig {
987
988
  */
988
989
  showPathInPrompt?: boolean;
989
990
  }
990
- interface ICliFilesModule extends ICliModule {
991
- configure(config: CliFilesModuleConfig): ICliModule;
991
+ interface ICliFilesModule extends ICliConfigurableModule<CliFilesModuleConfig> {
992
+ /** Subscription for drag-and-drop file uploads, cleaned up in onDestroy */
993
+ _dragDropSubscription?: Subscription;
992
994
  }
993
995
  declare const filesModule: ICliFilesModule;
994
996
 
package/public-api.js CHANGED
@@ -6,7 +6,7 @@ var cliCore = require('@qodalis/cli-core');
6
6
  var IFileSystemService_TOKEN = "cli-file-system-service";
7
7
 
8
8
  // src/lib/version.ts
9
- var LIBRARY_VERSION = "2.0.0-beta.7";
9
+ var LIBRARY_VERSION = "2.0.0-beta.9";
10
10
  var API_VERSION = 2;
11
11
 
12
12
  // src/lib/processors/cli-ls-command-processor.ts
@@ -5041,6 +5041,73 @@ var FilePathCompletionProvider = class {
5041
5041
  return results.sort();
5042
5042
  }
5043
5043
  };
5044
+ var CliUploadCommandProcessor = class {
5045
+ constructor() {
5046
+ this.command = "upload";
5047
+ this.description = "Upload a file from your local machine into the virtual filesystem";
5048
+ this.author = cliCore.DefaultLibraryAuthor;
5049
+ this.version = LIBRARY_VERSION;
5050
+ this.acceptsRawInput = true;
5051
+ this.metadata = { icon: "\u{1F4E4}", module: "file management" };
5052
+ this.parameters = [
5053
+ {
5054
+ name: "accept",
5055
+ description: 'File type filter (e.g. ".json,.txt" or "image/*")',
5056
+ required: false,
5057
+ type: "string"
5058
+ }
5059
+ ];
5060
+ }
5061
+ async processCommand(command, context) {
5062
+ const fs = context.services.get(
5063
+ IFileSystemService_TOKEN
5064
+ );
5065
+ const fileService = context.services.get(
5066
+ cliCore.ICliFileTransferService_TOKEN
5067
+ );
5068
+ if (!fileService) {
5069
+ context.writer.writeError("File transfer service not available.");
5070
+ return;
5071
+ }
5072
+ const accept = command.args?.["accept"];
5073
+ const destPath = command.value?.trim() || void 0;
5074
+ context.spinner?.show("Waiting for file selection...");
5075
+ const picked = await fileService.uploadFromBrowser(accept);
5076
+ if (!picked) {
5077
+ context.spinner?.hide();
5078
+ context.writer.writeln("Upload cancelled.");
5079
+ return;
5080
+ }
5081
+ const cwd = fs.getCurrentDirectory();
5082
+ const filename = destPath || picked.name;
5083
+ const resolved = fs.resolvePath(
5084
+ filename.startsWith("/") ? filename : cwd + "/" + filename
5085
+ );
5086
+ context.spinner?.show(`Saving "${picked.name}" (${picked.content.length} bytes)...`);
5087
+ try {
5088
+ fs.writeFile(resolved, picked.content);
5089
+ await fs.persist();
5090
+ context.spinner?.hide();
5091
+ context.writer.writeSuccess(
5092
+ `Uploaded ${context.writer.wrapInColor(picked.name, cliCore.CliForegroundColor.Cyan)} (${picked.content.length} bytes) \u2192 ${resolved}`
5093
+ );
5094
+ } catch (e) {
5095
+ context.spinner?.hide();
5096
+ context.writer.writeError(e.message || "Failed to write file");
5097
+ }
5098
+ }
5099
+ writeDescription(context) {
5100
+ context.writer.writeln(this.description);
5101
+ context.writer.writeln("");
5102
+ context.writer.writeln("Usage:");
5103
+ context.writer.writeln(" upload Open file picker, save to current directory");
5104
+ context.writer.writeln(" upload myfile.txt Open file picker, save as myfile.txt");
5105
+ context.writer.writeln(" upload /home/user/data Open file picker, save to absolute path");
5106
+ context.writer.writeln(' upload --accept=".json" Filter file picker to .json files');
5107
+ }
5108
+ };
5109
+
5110
+ // src/public-api.ts
5044
5111
  var fsService = new IndexedDbFileSystemService();
5045
5112
  var filesModule = {
5046
5113
  apiVersion: API_VERSION,
@@ -5081,7 +5148,8 @@ var filesModule = {
5081
5148
  new CliDiffCommandProcessor(),
5082
5149
  new CliTeeCommandProcessor(),
5083
5150
  new CliXargsCommandProcessor(),
5084
- new CliShCommandProcessor()
5151
+ new CliShCommandProcessor(),
5152
+ new CliUploadCommandProcessor()
5085
5153
  ],
5086
5154
  services: [
5087
5155
  {