@qodalis/cli-files 2.0.0-beta.1 → 2.0.0-beta.11
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 +4 -4
- package/public-api.d.mts +6 -4
- package/public-api.d.ts +6 -4
- package/public-api.js +72 -4
- package/public-api.js.map +1 -1
- package/public-api.mjs +72 -4
- package/public-api.mjs.map +1 -1
- package/umd/{cli-entrypoint.global.js → index.global.js} +9 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qodalis/cli-files",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.11",
|
|
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",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"cd",
|
|
21
21
|
"mkdir"
|
|
22
22
|
],
|
|
23
|
-
"umd": "./umd/index.js",
|
|
24
|
-
"unpkg": "./umd/index.js",
|
|
23
|
+
"umd": "./umd/index.global.js",
|
|
24
|
+
"unpkg": "./umd/index.global.js",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@qodalis/cli-core": "2.0.0-beta.
|
|
26
|
+
"@qodalis/cli-core": "2.0.0-beta.11"
|
|
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,
|
|
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).
|
|
@@ -886,7 +887,7 @@ interface ServerFileSystemOptions {
|
|
|
886
887
|
}
|
|
887
888
|
/**
|
|
888
889
|
* IFileSystemService implementation that delegates operations to a CLI server's
|
|
889
|
-
* `/api/
|
|
890
|
+
* `/api/qcli/fs/*` REST endpoints.
|
|
890
891
|
*
|
|
891
892
|
* Because the IFileSystemService interface is synchronous, this service maintains
|
|
892
893
|
* an in-memory file tree that is returned immediately by read operations. Write
|
|
@@ -987,8 +988,9 @@ interface CliFilesModuleConfig {
|
|
|
987
988
|
*/
|
|
988
989
|
showPathInPrompt?: boolean;
|
|
989
990
|
}
|
|
990
|
-
interface ICliFilesModule extends
|
|
991
|
-
|
|
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,
|
|
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).
|
|
@@ -886,7 +887,7 @@ interface ServerFileSystemOptions {
|
|
|
886
887
|
}
|
|
887
888
|
/**
|
|
888
889
|
* IFileSystemService implementation that delegates operations to a CLI server's
|
|
889
|
-
* `/api/
|
|
890
|
+
* `/api/qcli/fs/*` REST endpoints.
|
|
890
891
|
*
|
|
891
892
|
* Because the IFileSystemService interface is synchronous, this service maintains
|
|
892
893
|
* an in-memory file tree that is returned immediately by read operations. Write
|
|
@@ -987,8 +988,9 @@ interface CliFilesModuleConfig {
|
|
|
987
988
|
*/
|
|
988
989
|
showPathInPrompt?: boolean;
|
|
989
990
|
}
|
|
990
|
-
interface ICliFilesModule extends
|
|
991
|
-
|
|
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.
|
|
9
|
+
var LIBRARY_VERSION = "2.0.0-beta.11";
|
|
10
10
|
var API_VERSION = 2;
|
|
11
11
|
|
|
12
12
|
// src/lib/processors/cli-ls-command-processor.ts
|
|
@@ -3839,7 +3839,7 @@ var STORE_NAME = "filesystem";
|
|
|
3839
3839
|
var ROOT_KEY = "root";
|
|
3840
3840
|
var CWD_KEY = "cwd";
|
|
3841
3841
|
var HOME_KEY = "home";
|
|
3842
|
-
var DEFAULT_HOME = "/
|
|
3842
|
+
var DEFAULT_HOME = "/";
|
|
3843
3843
|
function createSeedFileSystem() {
|
|
3844
3844
|
const now = Date.now();
|
|
3845
3845
|
return {
|
|
@@ -4789,7 +4789,7 @@ var ServerFileSystemService = class {
|
|
|
4789
4789
|
}
|
|
4790
4790
|
// --- Private: server communication ---
|
|
4791
4791
|
async serverFetch(endpoint, options) {
|
|
4792
|
-
const url = `${this.baseUrl}/api/
|
|
4792
|
+
const url = `${this.baseUrl}/api/qcli/fs${endpoint}`;
|
|
4793
4793
|
const response = await fetch(url, options);
|
|
4794
4794
|
if (!response.ok) {
|
|
4795
4795
|
const body = await response.text();
|
|
@@ -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
|
{
|