@fnndsc/chell 4.4.0 → 5.0.0
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/dist/builtins/sys/prompt.js +2 -2
- package/dist/builtins/sys/prompt.js.map +1 -1
- package/dist/chell.d.ts +2 -2
- package/dist/chell.js +2 -2
- package/dist/chell.js.map +1 -1
- package/dist/config/settings.d.ts +4 -2
- package/dist/config/settings.js +7 -2
- package/dist/config/settings.js.map +1 -1
- package/dist/core/boot.js +49 -60
- package/dist/core/boot.js.map +1 -1
- package/dist/core/cliSurface.d.ts +1 -1
- package/dist/core/cliSurface.js +1 -1
- package/dist/core/cliSurface.js.map +1 -1
- package/dist/core/progressRenderer.d.ts +2 -2
- package/dist/core/prompt/session.d.ts +26 -1
- package/dist/core/prompt/session.js +25 -20
- package/dist/core/prompt/session.js.map +1 -1
- package/dist/core/repl.d.ts +2 -2
- package/dist/core/repl.js +6 -4
- package/dist/core/repl.js.map +1 -1
- package/dist/core/surfaceDispatch.d.ts +21 -0
- package/dist/core/surfaceDispatch.js +33 -0
- package/dist/core/surfaceDispatch.js.map +1 -0
- package/dist/remote/client.js +2 -2
- package/dist/remote/client.js.map +1 -1
- package/dist/remote/remoteEngine.d.ts +3 -3
- package/dist/remote/remoteEngine.js +7 -4
- package/dist/remote/remoteEngine.js.map +1 -1
- package/package.json +5 -5
- package/dist/builtins/debug.d.ts +0 -8
- package/dist/builtins/debug.js +0 -39
- package/dist/builtins/debug.js.map +0 -1
- package/dist/builtins/executable.d.ts +0 -22
- package/dist/builtins/executable.js +0 -115
- package/dist/builtins/executable.js.map +0 -1
- package/dist/builtins/fs/cat.d.ts +0 -16
- package/dist/builtins/fs/cat.js +0 -266
- package/dist/builtins/fs/cat.js.map +0 -1
- package/dist/builtins/fs/cd.d.ts +0 -42
- package/dist/builtins/fs/cd.js +0 -193
- package/dist/builtins/fs/cd.js.map +0 -1
- package/dist/builtins/fs/cp.d.ts +0 -10
- package/dist/builtins/fs/cp.js +0 -86
- package/dist/builtins/fs/cp.js.map +0 -1
- package/dist/builtins/fs/download.d.ts +0 -6
- package/dist/builtins/fs/download.js +0 -45
- package/dist/builtins/fs/download.js.map +0 -1
- package/dist/builtins/fs/du.d.ts +0 -58
- package/dist/builtins/fs/du.js +0 -210
- package/dist/builtins/fs/du.js.map +0 -1
- package/dist/builtins/fs/edit.d.ts +0 -7
- package/dist/builtins/fs/edit.js +0 -104
- package/dist/builtins/fs/edit.js.map +0 -1
- package/dist/builtins/fs/ls.d.ts +0 -8
- package/dist/builtins/fs/ls.js +0 -68
- package/dist/builtins/fs/ls.js.map +0 -1
- package/dist/builtins/fs/mkdir.d.ts +0 -9
- package/dist/builtins/fs/mkdir.js +0 -52
- package/dist/builtins/fs/mkdir.js.map +0 -1
- package/dist/builtins/fs/mv.d.ts +0 -10
- package/dist/builtins/fs/mv.js +0 -88
- package/dist/builtins/fs/mv.js.map +0 -1
- package/dist/builtins/fs/pull.args.d.ts +0 -22
- package/dist/builtins/fs/pull.args.js +0 -30
- package/dist/builtins/fs/pull.args.js.map +0 -1
- package/dist/builtins/fs/pull.d.ts +0 -26
- package/dist/builtins/fs/pull.js +0 -445
- package/dist/builtins/fs/pull.js.map +0 -1
- package/dist/builtins/fs/pwd.d.ts +0 -10
- package/dist/builtins/fs/pwd.js +0 -73
- package/dist/builtins/fs/pwd.js.map +0 -1
- package/dist/builtins/fs/rm.d.ts +0 -37
- package/dist/builtins/fs/rm.js +0 -197
- package/dist/builtins/fs/rm.js.map +0 -1
- package/dist/builtins/fs/touch.d.ts +0 -9
- package/dist/builtins/fs/touch.js +0 -76
- package/dist/builtins/fs/touch.js.map +0 -1
- package/dist/builtins/fs/tree.d.ts +0 -15
- package/dist/builtins/fs/tree.js +0 -84
- package/dist/builtins/fs/tree.js.map +0 -1
- package/dist/builtins/fs/upload.d.ts +0 -6
- package/dist/builtins/fs/upload.js +0 -48
- package/dist/builtins/fs/upload.js.map +0 -1
- package/dist/builtins/help.d.ts +0 -74
- package/dist/builtins/help.js +0 -1217
- package/dist/builtins/help.js.map +0 -1
- package/dist/builtins/index.d.ts +0 -46
- package/dist/builtins/index.js +0 -46
- package/dist/builtins/index.js.map +0 -1
- package/dist/builtins/net/connect.d.ts +0 -7
- package/dist/builtins/net/connect.js +0 -42
- package/dist/builtins/net/connect.js.map +0 -1
- package/dist/builtins/net/cubepath.d.ts +0 -18
- package/dist/builtins/net/cubepath.js +0 -102
- package/dist/builtins/net/cubepath.js.map +0 -1
- package/dist/builtins/net/logout.d.ts +0 -6
- package/dist/builtins/net/logout.js +0 -24
- package/dist/builtins/net/logout.js.map +0 -1
- package/dist/builtins/net/pacs.d.ts +0 -24
- package/dist/builtins/net/pacs.js +0 -121
- package/dist/builtins/net/pacs.js.map +0 -1
- package/dist/builtins/net/pacsUtils.d.ts +0 -85
- package/dist/builtins/net/pacsUtils.js +0 -184
- package/dist/builtins/net/pacsUtils.js.map +0 -1
- package/dist/builtins/net/query.d.ts +0 -60
- package/dist/builtins/net/query.js +0 -324
- package/dist/builtins/net/query.js.map +0 -1
- package/dist/builtins/parametersofplugin.d.ts +0 -13
- package/dist/builtins/parametersofplugin.js +0 -43
- package/dist/builtins/parametersofplugin.js.map +0 -1
- package/dist/builtins/pluginExecute.d.ts +0 -27
- package/dist/builtins/pluginExecute.js +0 -165
- package/dist/builtins/pluginExecute.js.map +0 -1
- package/dist/builtins/proc.d.ts +0 -6
- package/dist/builtins/proc.helpers.d.ts +0 -68
- package/dist/builtins/proc.helpers.js +0 -102
- package/dist/builtins/proc.helpers.js.map +0 -1
- package/dist/builtins/proc.js +0 -289
- package/dist/builtins/proc.js.map +0 -1
- package/dist/builtins/res/compute.d.ts +0 -6
- package/dist/builtins/res/compute.js +0 -55
- package/dist/builtins/res/compute.js.map +0 -1
- package/dist/builtins/res/feed.d.ts +0 -6
- package/dist/builtins/res/feed.js +0 -244
- package/dist/builtins/res/feed.js.map +0 -1
- package/dist/builtins/res/feed.notes.d.ts +0 -28
- package/dist/builtins/res/feed.notes.js +0 -24
- package/dist/builtins/res/feed.notes.js.map +0 -1
- package/dist/builtins/res/files.d.ts +0 -18
- package/dist/builtins/res/files.js +0 -85
- package/dist/builtins/res/files.js.map +0 -1
- package/dist/builtins/res/group.d.ts +0 -6
- package/dist/builtins/res/group.js +0 -54
- package/dist/builtins/res/group.js.map +0 -1
- package/dist/builtins/res/pipeline.args.d.ts +0 -22
- package/dist/builtins/res/pipeline.args.js +0 -28
- package/dist/builtins/res/pipeline.args.js.map +0 -1
- package/dist/builtins/res/pipeline.d.ts +0 -20
- package/dist/builtins/res/pipeline.js +0 -252
- package/dist/builtins/res/pipeline.js.map +0 -1
- package/dist/builtins/res/plugin.d.ts +0 -13
- package/dist/builtins/res/plugin.js +0 -140
- package/dist/builtins/res/plugin.js.map +0 -1
- package/dist/builtins/res/plugininstance.d.ts +0 -6
- package/dist/builtins/res/plugininstance.js +0 -53
- package/dist/builtins/res/plugininstance.js.map +0 -1
- package/dist/builtins/res/pluginmeta.d.ts +0 -6
- package/dist/builtins/res/pluginmeta.js +0 -53
- package/dist/builtins/res/pluginmeta.js.map +0 -1
- package/dist/builtins/res/tag.d.ts +0 -6
- package/dist/builtins/res/tag.js +0 -53
- package/dist/builtins/res/tag.js.map +0 -1
- package/dist/builtins/res/workflow.d.ts +0 -6
- package/dist/builtins/res/workflow.js +0 -53
- package/dist/builtins/res/workflow.js.map +0 -1
- package/dist/builtins/store.d.ts +0 -6
- package/dist/builtins/store.js +0 -108
- package/dist/builtins/store.js.map +0 -1
- package/dist/builtins/sys/context.d.ts +0 -6
- package/dist/builtins/sys/context.js +0 -50
- package/dist/builtins/sys/context.js.map +0 -1
- package/dist/builtins/sys/physicalmode.d.ts +0 -8
- package/dist/builtins/sys/physicalmode.js +0 -34
- package/dist/builtins/sys/physicalmode.js.map +0 -1
- package/dist/builtins/sys/timing.d.ts +0 -8
- package/dist/builtins/sys/timing.js +0 -34
- package/dist/builtins/sys/timing.js.map +0 -1
- package/dist/builtins/sys/version.d.ts +0 -15
- package/dist/builtins/sys/version.js +0 -23
- package/dist/builtins/sys/version.js.map +0 -1
- package/dist/builtins/sys/whoami.d.ts +0 -17
- package/dist/builtins/sys/whoami.js +0 -44
- package/dist/builtins/sys/whoami.js.map +0 -1
- package/dist/builtins/utils.d.ts +0 -55
- package/dist/builtins/utils.js +0 -145
- package/dist/builtins/utils.js.map +0 -1
- package/dist/builtins/wildcard.d.ts +0 -26
- package/dist/builtins/wildcard.js +0 -120
- package/dist/builtins/wildcard.js.map +0 -1
- package/dist/calypso.d.ts +0 -13
- package/dist/calypso.js +0 -44
- package/dist/calypso.js.map +0 -1
- package/dist/command-keys.d.ts +0 -8
- package/dist/command-keys.js +0 -32
- package/dist/command-keys.js.map +0 -1
- package/dist/core/dispatch.d.ts +0 -101
- package/dist/core/dispatch.js +0 -636
- package/dist/core/dispatch.js.map +0 -1
- package/dist/core/engine.d.ts +0 -91
- package/dist/core/engine.js +0 -222
- package/dist/core/engine.js.map +0 -1
- package/dist/core/preprocess.d.ts +0 -46
- package/dist/core/preprocess.js +0 -146
- package/dist/core/preprocess.js.map +0 -1
- package/dist/core/progress.d.ts +0 -25
- package/dist/core/progress.js +0 -10
- package/dist/core/progress.js.map +0 -1
- package/dist/core/question.d.ts +0 -27
- package/dist/core/question.js +0 -33
- package/dist/core/question.js.map +0 -1
- package/dist/core/sink.d.ts +0 -201
- package/dist/core/sink.js +0 -300
- package/dist/core/sink.js.map +0 -1
- package/dist/core/surface.d.ts +0 -172
- package/dist/core/surface.js +0 -105
- package/dist/core/surface.js.map +0 -1
- package/dist/core/version.d.ts +0 -20
- package/dist/core/version.js +0 -82
- package/dist/core/version.js.map +0 -1
- package/dist/daemon/launch.d.ts +0 -9
- package/dist/daemon/launch.js +0 -82
- package/dist/daemon/launch.js.map +0 -1
- package/dist/lib/completer/index.d.ts +0 -15
- package/dist/lib/completer/index.js +0 -212
- package/dist/lib/completer/index.js.map +0 -1
- package/dist/lib/completer/pathComplete.helpers.d.ts +0 -22
- package/dist/lib/completer/pathComplete.helpers.js +0 -49
- package/dist/lib/completer/pathComplete.helpers.js.map +0 -1
- package/dist/lib/parser.d.ts +0 -13
- package/dist/lib/parser.js +0 -52
- package/dist/lib/parser.js.map +0 -1
- package/dist/lib/pipe.d.ts +0 -11
- package/dist/lib/pipe.js +0 -90
- package/dist/lib/pipe.js.map +0 -1
- package/dist/lib/prefetch.d.ts +0 -25
- package/dist/lib/prefetch.js +0 -64
- package/dist/lib/prefetch.js.map +0 -1
- package/dist/lib/semicolonParser.d.ts +0 -22
- package/dist/lib/semicolonParser.js +0 -53
- package/dist/lib/semicolonParser.js.map +0 -1
- package/dist/lib/spinner.d.ts +0 -23
- package/dist/lib/spinner.js +0 -71
- package/dist/lib/spinner.js.map +0 -1
- package/dist/lib/vfs/providers/static.d.ts +0 -65
- package/dist/lib/vfs/providers/static.js +0 -164
- package/dist/lib/vfs/providers/static.js.map +0 -1
- package/dist/lib/vfs/providers/static_content.d.ts +0 -27
- package/dist/lib/vfs/providers/static_content.js +0 -180
- package/dist/lib/vfs/providers/static_content.js.map +0 -1
- package/dist/lib/vfs/vfs.d.ts +0 -59
- package/dist/lib/vfs/vfs.js +0 -202
- package/dist/lib/vfs/vfs.js.map +0 -1
- package/dist/remote/discovery.d.ts +0 -23
- package/dist/remote/discovery.js +0 -55
- package/dist/remote/discovery.js.map +0 -1
- package/dist/session/index.d.ts +0 -76
- package/dist/session/index.js +0 -120
- package/dist/session/index.js.map +0 -1
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Builtin download command.
|
|
3
|
-
* Downloads files from ChRIS to the local filesystem with progress.
|
|
4
|
-
*/
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import { path_resolve } from '../utils.js';
|
|
8
|
-
import { files_downloadWithProgress as chefs_download_cmd, bytes_format } from '@fnndsc/chili/commands/fs/download.js';
|
|
9
|
-
import { sink_get } from '../../core/sink.js';
|
|
10
|
-
/**
|
|
11
|
-
* Downloads a remote ChRIS file or directory to the local filesystem.
|
|
12
|
-
*
|
|
13
|
-
* @param args - [remotePath, localPath] plus optional -f/--force to overwrite.
|
|
14
|
-
*/
|
|
15
|
-
export async function builtin_download(args) {
|
|
16
|
-
const force = args.includes('-f') || args.includes('--force');
|
|
17
|
-
const cleanArgs = args.filter(arg => arg !== '-f' && arg !== '--force');
|
|
18
|
-
if (cleanArgs.length < 2) {
|
|
19
|
-
console.log(chalk.red('Usage: download <remote_path> <local_path> [-f|--force]'));
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const remotePathArg = cleanArgs[0];
|
|
23
|
-
const localPathArg = cleanArgs[1];
|
|
24
|
-
const targetRemote = await path_resolve(remotePathArg);
|
|
25
|
-
const targetLocal = path.resolve(localPathArg);
|
|
26
|
-
try {
|
|
27
|
-
const summary = await chefs_download_cmd(targetRemote, targetLocal, {
|
|
28
|
-
force,
|
|
29
|
-
onProgress: event => sink_get().progress_write(event),
|
|
30
|
-
});
|
|
31
|
-
console.log('');
|
|
32
|
-
if (summary.failedCount === 0) {
|
|
33
|
-
console.log(chalk.green(`✓ Successfully downloaded ${summary.transferredCount} file(s)`));
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
console.log(chalk.yellow(`⚠ Downloaded ${summary.transferredCount} file(s), ${summary.failedCount} failed`));
|
|
37
|
-
}
|
|
38
|
-
console.log(chalk.gray(` Total: ${bytes_format(summary.transferSize)} in ${summary.duration.toFixed(1)}s (${bytes_format(summary.speed)}/s)`));
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
const msg = e instanceof Error ? e.message : String(e);
|
|
42
|
-
console.error(chalk.red(`Download error: ${msg}`));
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=download.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"download.js","sourceRoot":"","sources":["../../../src/built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AC,CAAC;QAChB,IAAI,OAAO,CAAC,WAAW,KAAK,CAAC,EAAE,CAAC;YAC9B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,6BAA6B,OAAO,CAAC,gBAAgB,UAAU,CAAC,CAAC,CAAC;QAC5F,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,gBAAgB,OAAO,CAAC,gBAAgB,aAAa,OAAO,CAAC,WAAW,SAAS,CAAC,CAAC,CAAC;QAC/G,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAClJ,CAAC;IAAC,OAAO,CAAU,EAAE,CAAC;QACpB,MAAM,GAAG,GAAW,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC/D,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,mBAAmB,GAAG,EAAE,CAAC,CAAC,CAAC;IACrD,CAAC;AACH,CAAC"}
|
package/dist/builtins/fs/du.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { ParsedArgs } from '../utils.js';
|
|
2
|
-
import { type ScanRecord } from '@fnndsc/chili/path/pathCommand.js';
|
|
3
|
-
/**
|
|
4
|
-
* Parsed flags controlling `du` output.
|
|
5
|
-
*/
|
|
6
|
-
export interface DuOptions {
|
|
7
|
-
humanReadable: boolean;
|
|
8
|
-
summarize: boolean;
|
|
9
|
-
showAll: boolean;
|
|
10
|
-
showTotal: boolean;
|
|
11
|
-
separateDirs: boolean;
|
|
12
|
-
maxDepth: number | undefined;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Formats a byte count for `du` output: human-readable string or KB integer,
|
|
16
|
-
* right-padded to 12 characters for column alignment.
|
|
17
|
-
*
|
|
18
|
-
* @param bytes - Raw byte count.
|
|
19
|
-
* @param humanReadable - If true, format as human-readable (e.g. `1.2M`).
|
|
20
|
-
* @returns Right-aligned size string.
|
|
21
|
-
*/
|
|
22
|
-
export declare function duSize_format(bytes: number, humanReadable: boolean): string;
|
|
23
|
-
/**
|
|
24
|
-
* Extracts `du` flags from parsed command arguments.
|
|
25
|
-
*
|
|
26
|
-
* @param parsed - The parsed command arguments.
|
|
27
|
-
* @returns The resolved du options.
|
|
28
|
-
*/
|
|
29
|
-
export declare function duOptions_parse(parsed: ParsedArgs): DuOptions;
|
|
30
|
-
/**
|
|
31
|
-
* Accumulates per-directory sizes from a scan result, attributing each file's
|
|
32
|
-
* size to its ancestor directories up to (and including) the target path.
|
|
33
|
-
*
|
|
34
|
-
* @param scanResult - The recursive scan result.
|
|
35
|
-
* @param targetPath - The directory being measured.
|
|
36
|
-
* @param opts - The du options (separateDirs / showAll affect attribution).
|
|
37
|
-
* @returns A map of directory path to accumulated size.
|
|
38
|
-
*/
|
|
39
|
-
export declare function dirSizes_compute(scanResult: ScanRecord, targetPath: string, opts: DuOptions): Map<string, number>;
|
|
40
|
-
/**
|
|
41
|
-
* Displays disk usage statistics for ChRIS filesystem directories.
|
|
42
|
-
* Mimics standard Linux du command behavior and flags.
|
|
43
|
-
* Uses chili's scan_do machinery for recursive filesystem traversal.
|
|
44
|
-
*
|
|
45
|
-
* @param args - Command line arguments (optional path and flags).
|
|
46
|
-
* @returns A Promise that resolves when disk usage is displayed.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```
|
|
50
|
-
* du # Disk usage of current directory
|
|
51
|
-
* du -h # Human-readable sizes
|
|
52
|
-
* du -s /home/user/data # Summary only
|
|
53
|
-
* du -a # Show all files, not just directories
|
|
54
|
-
* du -c # Show grand total
|
|
55
|
-
* du -d 2 # Max depth of 2 levels
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
export declare function builtin_du(args: string[]): Promise<void>;
|
package/dist/builtins/fs/du.js
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Builtin du command.
|
|
3
|
-
* Displays disk usage.
|
|
4
|
-
*/
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import { commandArgs_process, path_resolve } from '../utils.js';
|
|
8
|
-
import { session } from '../../session/index.js';
|
|
9
|
-
import { vfs } from '../../lib/vfs/vfs.js';
|
|
10
|
-
import { spinner } from '../../lib/spinner.js';
|
|
11
|
-
import { scan_do } from '@fnndsc/chili/path/pathCommand.js';
|
|
12
|
-
import { bytes_format } from '@fnndsc/chili/commands/fs/upload.js';
|
|
13
|
-
/**
|
|
14
|
-
* Formats a byte count for `du` output: human-readable string or KB integer,
|
|
15
|
-
* right-padded to 12 characters for column alignment.
|
|
16
|
-
*
|
|
17
|
-
* @param bytes - Raw byte count.
|
|
18
|
-
* @param humanReadable - If true, format as human-readable (e.g. `1.2M`).
|
|
19
|
-
* @returns Right-aligned size string.
|
|
20
|
-
*/
|
|
21
|
-
export function duSize_format(bytes, humanReadable) {
|
|
22
|
-
const formatted = humanReadable
|
|
23
|
-
? bytes_format(bytes)
|
|
24
|
-
: Math.ceil(bytes / 1024).toString();
|
|
25
|
-
return formatted.padStart(12, ' ');
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Extracts `du` flags from parsed command arguments.
|
|
29
|
-
*
|
|
30
|
-
* @param parsed - The parsed command arguments.
|
|
31
|
-
* @returns The resolved du options.
|
|
32
|
-
*/
|
|
33
|
-
export function duOptions_parse(parsed) {
|
|
34
|
-
const maxDepth = parsed['d']
|
|
35
|
-
? parseInt(String(parsed['d']), 10)
|
|
36
|
-
: parsed['max-depth']
|
|
37
|
-
? parseInt(String(parsed['max-depth']), 10)
|
|
38
|
-
: undefined;
|
|
39
|
-
return {
|
|
40
|
-
humanReadable: !!parsed['h'] || !!parsed['human-readable'],
|
|
41
|
-
summarize: !!parsed['s'] || !!parsed['summarize'],
|
|
42
|
-
showAll: !!parsed['a'] || !!parsed['all'],
|
|
43
|
-
showTotal: !!parsed['c'] || !!parsed['total'],
|
|
44
|
-
separateDirs: !!parsed['S'] || !!parsed['separate-dirs'],
|
|
45
|
-
maxDepth,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Resolves whether a target path is a directory or a file (with size).
|
|
50
|
-
*
|
|
51
|
-
* @param targetPath - The resolved ChRIS path to stat.
|
|
52
|
-
* @returns A TargetStat on success, or an error message string on failure.
|
|
53
|
-
*/
|
|
54
|
-
async function targetStat_resolve(targetPath) {
|
|
55
|
-
try {
|
|
56
|
-
const result = await vfs.data_get(targetPath, { directory: true });
|
|
57
|
-
if (result.ok && result.value.length > 0) {
|
|
58
|
-
const item = result.value[0];
|
|
59
|
-
if (item.type === 'dir' || item.type === 'vfs') {
|
|
60
|
-
return { isDirectory: true, fileSize: 0 };
|
|
61
|
-
}
|
|
62
|
-
return { isDirectory: false, fileSize: item.size || 0 };
|
|
63
|
-
}
|
|
64
|
-
return `du: cannot access '${targetPath}': No such file or directory`;
|
|
65
|
-
}
|
|
66
|
-
catch (e) {
|
|
67
|
-
return `du: cannot access '${targetPath}': ${e}`;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Accumulates per-directory sizes from a scan result, attributing each file's
|
|
72
|
-
* size to its ancestor directories up to (and including) the target path.
|
|
73
|
-
*
|
|
74
|
-
* @param scanResult - The recursive scan result.
|
|
75
|
-
* @param targetPath - The directory being measured.
|
|
76
|
-
* @param opts - The du options (separateDirs / showAll affect attribution).
|
|
77
|
-
* @returns A map of directory path to accumulated size.
|
|
78
|
-
*/
|
|
79
|
-
export function dirSizes_compute(scanResult, targetPath, opts) {
|
|
80
|
-
const dirSizes = new Map();
|
|
81
|
-
scanResult.fileInfo.forEach((fileInfo) => {
|
|
82
|
-
const filePath = fileInfo.chrisPath;
|
|
83
|
-
const fSize = fileInfo.size;
|
|
84
|
-
if (fileInfo.isDirectory) {
|
|
85
|
-
if (!dirSizes.has(filePath)) {
|
|
86
|
-
dirSizes.set(filePath, 0);
|
|
87
|
-
}
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
// File: add to its parent directory and all ancestor directories,
|
|
91
|
-
// but only up to the targetPath currently being scanned.
|
|
92
|
-
let currentPath = path.posix.dirname(filePath);
|
|
93
|
-
while (currentPath && currentPath.startsWith(targetPath)) {
|
|
94
|
-
const currentSize = dirSizes.get(currentPath) || 0;
|
|
95
|
-
dirSizes.set(currentPath, currentSize + fSize);
|
|
96
|
-
if (currentPath === targetPath)
|
|
97
|
-
break;
|
|
98
|
-
if (opts.separateDirs)
|
|
99
|
-
break;
|
|
100
|
-
currentPath = path.posix.dirname(currentPath);
|
|
101
|
-
}
|
|
102
|
-
if (opts.showAll) {
|
|
103
|
-
dirSizes.set(filePath, fSize);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
// Ensure the target directory itself exists in the map with total size.
|
|
107
|
-
if (!dirSizes.has(targetPath)) {
|
|
108
|
-
dirSizes.set(targetPath, scanResult.totalSize);
|
|
109
|
-
}
|
|
110
|
-
return dirSizes;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Renders accumulated directory sizes to stdout, honouring summary and
|
|
114
|
-
* max-depth options.
|
|
115
|
-
*
|
|
116
|
-
* @param dirSizes - Map of directory path to size.
|
|
117
|
-
* @param targetPath - The directory being measured.
|
|
118
|
-
* @param opts - The du options.
|
|
119
|
-
*/
|
|
120
|
-
function dirUsage_render(dirSizes, targetPath, opts) {
|
|
121
|
-
if (opts.summarize) {
|
|
122
|
-
const size = dirSizes.get(targetPath) || 0;
|
|
123
|
-
console.log(`${duSize_format(size, opts.humanReadable)}\t${targetPath}`);
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
const entries = Array.from(dirSizes.entries());
|
|
127
|
-
entries.sort((a, b) => a[0].localeCompare(b[0]));
|
|
128
|
-
for (const [dirPath, dirSize] of entries) {
|
|
129
|
-
if (opts.maxDepth !== undefined) {
|
|
130
|
-
const rel = path.posix.relative(targetPath, dirPath);
|
|
131
|
-
const depth = rel === '' ? 0 : rel.split('/').length;
|
|
132
|
-
if (depth > opts.maxDepth)
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
console.log(`${duSize_format(dirSize, opts.humanReadable)}\t${dirPath}`);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Displays disk usage statistics for ChRIS filesystem directories.
|
|
140
|
-
* Mimics standard Linux du command behavior and flags.
|
|
141
|
-
* Uses chili's scan_do machinery for recursive filesystem traversal.
|
|
142
|
-
*
|
|
143
|
-
* @param args - Command line arguments (optional path and flags).
|
|
144
|
-
* @returns A Promise that resolves when disk usage is displayed.
|
|
145
|
-
*
|
|
146
|
-
* @example
|
|
147
|
-
* ```
|
|
148
|
-
* du # Disk usage of current directory
|
|
149
|
-
* du -h # Human-readable sizes
|
|
150
|
-
* du -s /home/user/data # Summary only
|
|
151
|
-
* du -a # Show all files, not just directories
|
|
152
|
-
* du -c # Show grand total
|
|
153
|
-
* du -d 2 # Max depth of 2 levels
|
|
154
|
-
* ```
|
|
155
|
-
*/
|
|
156
|
-
export async function builtin_du(args) {
|
|
157
|
-
const parsed = commandArgs_process(args);
|
|
158
|
-
const opts = duOptions_parse(parsed);
|
|
159
|
-
const pathArgs = parsed._;
|
|
160
|
-
const originalFolder = await session.getCWD();
|
|
161
|
-
const rawTargets = pathArgs.length > 0 ? pathArgs : ['.'];
|
|
162
|
-
const resolvedTargets = [];
|
|
163
|
-
for (const raw of rawTargets) {
|
|
164
|
-
resolvedTargets.push(await path_resolve(raw));
|
|
165
|
-
}
|
|
166
|
-
let grandTotal = 0;
|
|
167
|
-
try {
|
|
168
|
-
for (const targetPath of resolvedTargets) {
|
|
169
|
-
const argLabel = path.basename(targetPath);
|
|
170
|
-
spinner.start(`Scanning ${argLabel}...`);
|
|
171
|
-
const stat = await targetStat_resolve(targetPath);
|
|
172
|
-
if (typeof stat === 'string') {
|
|
173
|
-
spinner.stop();
|
|
174
|
-
console.error(chalk.red(stat));
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
if (!stat.isDirectory) {
|
|
178
|
-
grandTotal += stat.fileSize;
|
|
179
|
-
spinner.stop();
|
|
180
|
-
console.log(`${duSize_format(stat.fileSize, opts.humanReadable)}\t${targetPath}`);
|
|
181
|
-
continue;
|
|
182
|
-
}
|
|
183
|
-
await session.setCWD(targetPath);
|
|
184
|
-
const scanOptions = {
|
|
185
|
-
silent: true,
|
|
186
|
-
tree: false,
|
|
187
|
-
follow: false,
|
|
188
|
-
dirsOnly: false,
|
|
189
|
-
};
|
|
190
|
-
const scanResult = await scan_do(scanOptions);
|
|
191
|
-
await session.setCWD(originalFolder);
|
|
192
|
-
if (!scanResult) {
|
|
193
|
-
spinner.stop();
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
const dirSizes = dirSizes_compute(scanResult, targetPath, opts);
|
|
197
|
-
grandTotal += scanResult.totalSize;
|
|
198
|
-
spinner.stop();
|
|
199
|
-
dirUsage_render(dirSizes, targetPath, opts);
|
|
200
|
-
}
|
|
201
|
-
if (opts.showTotal && rawTargets.length > 0) {
|
|
202
|
-
console.log(`${duSize_format(grandTotal, opts.humanReadable)}\ttotal`);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
finally {
|
|
206
|
-
spinner.stop();
|
|
207
|
-
await session.setCWD(originalFolder);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
//# sourceMappingURL=du.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"du.js","sourceRoot":"","sources":["../../../src/builtins/fs/du.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
|
|
4
|
-
* re-uploads on save. The editor mechanics live in the surface, so this
|
|
5
|
-
* builtin knows nothing of processes or terminals — it fetches, hands the
|
|
6
|
-
* content to the surface, and uploads the result.
|
|
7
|
-
*/
|
|
8
|
-
import { writeFileSync, unlinkSync, existsSync } from 'fs';
|
|
9
|
-
import { tmpdir } from 'os';
|
|
10
|
-
import { join, extname, posix } from 'path';
|
|
11
|
-
import chalk from 'chalk';
|
|
12
|
-
import { path_resolve, error_stripDebugPrefix } from '../utils.js';
|
|
13
|
-
import { surface_get, capability_require, CapabilityError } from '../../core/surface.js';
|
|
14
|
-
import { files_cat } from '@fnndsc/chili/commands/fs/cat.js';
|
|
15
|
-
import { file_replaceContent } from '@fnndsc/chili/commands/fs/edit.js';
|
|
16
|
-
import { errorStack, listCache_get } from '@fnndsc/cumin';
|
|
17
|
-
const BINARY_EXTENSIONS = new Set([
|
|
18
|
-
'.dcm', '.png', '.jpg', '.jpeg', '.gif', '.bmp', '.webp', '.ico',
|
|
19
|
-
'.pdf', '.zip', '.tar', '.gz', '.bz2', '.xz', '.7z',
|
|
20
|
-
'.exe', '.dll', '.so', '.bin', '.mp3', '.mp4', '.avi', '.wav',
|
|
21
|
-
]);
|
|
22
|
-
/**
|
|
23
|
-
* Opens a ChRIS file in the surface's local editor. On save, replaces the
|
|
24
|
-
* original via delete + re-upload. No-ops if content is unchanged.
|
|
25
|
-
*
|
|
26
|
-
* @param args - [filePath, ...]
|
|
27
|
-
*/
|
|
28
|
-
export async function builtin_edit(args) {
|
|
29
|
-
if (args.length === 0) {
|
|
30
|
-
console.error(chalk.red('Usage: edit <file>'));
|
|
31
|
-
process.exitCode = 1;
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
// Editing needs a surface that can open a local editor. A surface without
|
|
35
|
-
// the capability (a headless or browser host) fails here with a clear
|
|
36
|
-
// message instead of assuming a terminal exists.
|
|
37
|
-
try {
|
|
38
|
-
capability_require('localEdit', 'edit: this surface cannot open a local editor.');
|
|
39
|
-
}
|
|
40
|
-
catch (err) {
|
|
41
|
-
const message = err instanceof CapabilityError ? err.message : String(err);
|
|
42
|
-
console.error(chalk.red(message));
|
|
43
|
-
process.exitCode = 1;
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const target = await path_resolve(args[0]);
|
|
47
|
-
const ext = extname(target).toLowerCase();
|
|
48
|
-
if (BINARY_EXTENSIONS.has(ext)) {
|
|
49
|
-
console.error(chalk.red(`edit: ${args[0]}: binary file (${ext}), cannot edit as text`));
|
|
50
|
-
process.exitCode = 1;
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const catResult = await files_cat(target);
|
|
54
|
-
if (!catResult.ok) {
|
|
55
|
-
const err = errorStack.stack_pop();
|
|
56
|
-
console.error(chalk.red(`edit: ${err ? error_stripDebugPrefix(err.message) : 'Failed to read file'}`));
|
|
57
|
-
process.exitCode = 1;
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
// Hand the content to the surface's editor.
|
|
61
|
-
let edit;
|
|
62
|
-
try {
|
|
63
|
-
edit = await surface_get().localEdit({ content: catResult.value, extension: ext || '.txt' });
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
console.error(chalk.red(`edit: ${err instanceof Error ? err.message : String(err)}`));
|
|
67
|
-
process.exitCode = 1;
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (!edit.changed) {
|
|
71
|
-
console.log(chalk.gray('(no changes)'));
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
// Upload the edited content: write it to a temp file the replace command
|
|
75
|
-
// reads, and preserve that file (reporting its path) if the save fails.
|
|
76
|
-
const tmpPath = join(tmpdir(), `chell-edit-${Date.now()}${ext || '.txt'}`);
|
|
77
|
-
let keepTmp = false;
|
|
78
|
-
try {
|
|
79
|
-
writeFileSync(tmpPath, edit.content, 'utf8');
|
|
80
|
-
const result = await file_replaceContent(target, tmpPath);
|
|
81
|
-
listCache_get().cache_invalidate(posix.dirname(target));
|
|
82
|
-
if (result.success) {
|
|
83
|
-
console.log(chalk.green(`Saved: ${args[0]}`));
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
const apiErr = errorStack.stack_pop();
|
|
87
|
-
console.error(chalk.red(`edit: Save failed — ${result.error}`));
|
|
88
|
-
if (apiErr)
|
|
89
|
-
console.error(chalk.red(` API error: ${error_stripDebugPrefix(apiErr.message)}`));
|
|
90
|
-
console.error(chalk.yellow(`Your edits are preserved at: ${tmpPath}`));
|
|
91
|
-
keepTmp = true;
|
|
92
|
-
process.exitCode = 1;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
finally {
|
|
96
|
-
if (!keepTmp && existsSync(tmpPath)) {
|
|
97
|
-
try {
|
|
98
|
-
unlinkSync(tmpPath);
|
|
99
|
-
}
|
|
100
|
-
catch { /* ignore */ }
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
//# sourceMappingURL=edit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/builtins/fs/edit.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,eAAe,EAAwB,MAAM,uBAAuB,CAAC;AAC/G,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAc,MAAM,mCAAmC,CAAC;AACpF,OAAO,EA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OAAO,CAAC,EAAE,CAAC;YACpC,IAAI,CAAC;gBAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YAAC,CAAC;YAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/builtins/fs/ls.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lists the contents of the current or specified directory/files in the ChRIS filesystem context.
|
|
3
|
-
* Supports a virtual `/bin` directory for plugins and multiple paths (e.g., from wildcard expansion).
|
|
4
|
-
*
|
|
5
|
-
* @param args - An array containing target paths (optional).
|
|
6
|
-
* @returns A Promise that resolves when the directory contents are listed.
|
|
7
|
-
*/
|
|
8
|
-
export declare function builtin_ls(args: string[]): Promise<void>;
|
package/dist/builtins/fs/ls.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Builtin ls command.
|
|
3
|
-
* Lists directory contents.
|
|
4
|
-
*/
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
import { commandArgs_process, path_resolve } from '../utils.js';
|
|
7
|
-
import { listCache_get } from '@fnndsc/cumin';
|
|
8
|
-
import { session } from '../../session/index.js';
|
|
9
|
-
import { vfs } from '../../lib/vfs/vfs.js';
|
|
10
|
-
/**
|
|
11
|
-
* Lists the contents of the current or specified directory/files in the ChRIS filesystem context.
|
|
12
|
-
* Supports a virtual `/bin` directory for plugins and multiple paths (e.g., from wildcard expansion).
|
|
13
|
-
*
|
|
14
|
-
* @param args - An array containing target paths (optional).
|
|
15
|
-
* @returns A Promise that resolves when the directory contents are listed.
|
|
16
|
-
*/
|
|
17
|
-
export async function builtin_ls(args) {
|
|
18
|
-
const parsed = commandArgs_process(args);
|
|
19
|
-
const pathArgsRaw = parsed._;
|
|
20
|
-
let sortBy = 'name';
|
|
21
|
-
if (parsed['sort']) {
|
|
22
|
-
const sortValue = String(parsed['sort']);
|
|
23
|
-
if (['name', 'size', 'date', 'owner'].includes(sortValue)) {
|
|
24
|
-
sortBy = sortValue;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
let pathArgs = pathArgsRaw;
|
|
28
|
-
const shouldRefresh = !!parsed['refresh'] || !!parsed['f'];
|
|
29
|
-
const options = {
|
|
30
|
-
long: !!parsed['l'],
|
|
31
|
-
human: !!parsed['h'],
|
|
32
|
-
oneColumn: !!parsed['1'],
|
|
33
|
-
sort: sortBy,
|
|
34
|
-
reverse: !!parsed['reverse'] || !!parsed['r'],
|
|
35
|
-
directory: !!parsed['d']
|
|
36
|
-
};
|
|
37
|
-
if (shouldRefresh) {
|
|
38
|
-
const listCache = listCache_get();
|
|
39
|
-
if (pathArgs.length === 0) {
|
|
40
|
-
const cwd = await session.getCWD();
|
|
41
|
-
console.log(chalk.gray(`[Cache] Invalidating: ${cwd}`));
|
|
42
|
-
listCache.cache_invalidate(cwd);
|
|
43
|
-
listCache.cache_invalidate();
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
for (const pathArg of pathArgs) {
|
|
47
|
-
const resolvedPath = await path_resolve(pathArg);
|
|
48
|
-
console.log(chalk.gray(`[Cache] Invalidating: ${resolvedPath}`));
|
|
49
|
-
listCache.cache_invalidate(resolvedPath);
|
|
50
|
-
}
|
|
51
|
-
listCache.cache_invalidate();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
if (pathArgs.length === 0) {
|
|
55
|
-
await vfs.list(undefined, options);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (pathArgs.length === 1) {
|
|
59
|
-
const target = await path_resolve(pathArgs[0]);
|
|
60
|
-
await vfs.list(target, options);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
for (const pathArg of pathArgs) {
|
|
64
|
-
const target = await path_resolve(pathArg);
|
|
65
|
-
await vfs.list(target, options);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=ls.js.map
|
|
@@ -1 +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AC;IAED,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,MAAM,GAAW,MAAM,YAAY,CAAC,OAAO,CAAC,CAAC;QACnD,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,CAAC;AACH,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { CommandEnvelope } from '@fnndsc/cumin';
|
|
2
|
-
/**
|
|
3
|
-
* Creates directories.
|
|
4
|
-
*
|
|
5
|
-
* @param args - Command line arguments (directory paths).
|
|
6
|
-
* @returns An envelope whose rendered text reports each directory and whose
|
|
7
|
-
* model lists per-target outcomes.
|
|
8
|
-
*/
|
|
9
|
-
export declare function builtin_mkdir(args: string[]): Promise<CommandEnvelope>;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Builtin mkdir command.
|
|
3
|
-
* Creates directories, reported as a command envelope.
|
|
4
|
-
*/
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
import { listCache_get, envelope_ok, envelope_error } from '@fnndsc/cumin';
|
|
7
|
-
import { path_resolve } from '../utils.js';
|
|
8
|
-
import { files_mkdir as chefs_mkdir_cmd } from '@fnndsc/chili/commands/fs/mkdir.js';
|
|
9
|
-
import { mkdir_render } from '@fnndsc/chili/views/fs.js';
|
|
10
|
-
/**
|
|
11
|
-
* Creates directories.
|
|
12
|
-
*
|
|
13
|
-
* @param args - Command line arguments (directory paths).
|
|
14
|
-
* @returns An envelope whose rendered text reports each directory and whose
|
|
15
|
-
* model lists per-target outcomes.
|
|
16
|
-
*/
|
|
17
|
-
export async function builtin_mkdir(args) {
|
|
18
|
-
if (args.length === 0) {
|
|
19
|
-
return envelope_error('', undefined, `${chalk.red('Usage: mkdir <directory> [directory...]')}\n`);
|
|
20
|
-
}
|
|
21
|
-
let rendered = '';
|
|
22
|
-
let renderedErr = '';
|
|
23
|
-
const outcomes = [];
|
|
24
|
-
for (const pathArg of args) {
|
|
25
|
-
try {
|
|
26
|
-
const targetPath = await path_resolve(pathArg);
|
|
27
|
-
const success = await chefs_mkdir_cmd(targetPath);
|
|
28
|
-
rendered += `${mkdir_render(targetPath, success)}\n`;
|
|
29
|
-
outcomes.push({ path: targetPath, created: success });
|
|
30
|
-
// Invalidate cache for parent directory
|
|
31
|
-
if (success) {
|
|
32
|
-
const parentDir = targetPath.substring(0, targetPath.lastIndexOf('/')) || '/';
|
|
33
|
-
const listCache = listCache_get();
|
|
34
|
-
listCache.cache_invalidate(parentDir);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
catch (e) {
|
|
38
|
-
const msg = e instanceof Error ? e.message : String(e);
|
|
39
|
-
renderedErr += `${chalk.red(`mkdir: ${pathArg}: ${msg}`)}\n`;
|
|
40
|
-
outcomes.push({ path: pathArg, created: false });
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
const anyFailed = outcomes.some((outcome) => !outcome.created);
|
|
44
|
-
const model = { kind: 'fs.mkdir', data: outcomes };
|
|
45
|
-
if (anyFailed) {
|
|
46
|
-
const envelope = envelope_error(rendered, undefined, renderedErr || undefined);
|
|
47
|
-
envelope.model = model;
|
|
48
|
-
return envelope;
|
|
49
|
-
}
|
|
50
|
-
return envelope_ok(rendered, model);
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=mkdir.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mkdir.js","sourceRoot":"","sources":["../../../src/builtins/fs/mkdir.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAmB,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE5F,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE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AU,OAAO,KAAK,GAAG,EAAE,CAAC,IAAI,CAAC;YAC7D,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAED,MAAM,SAAS,GAAY,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAqB,EAAW,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/F,MAAM,KAAK,GAA2C,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAC3F,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,QAAQ,GAAoB,cAAc,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,IAAI,SAAS,CAAC,CAAC;QAChG,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;QACvB,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AACtC,CAAC"}
|
package/dist/builtins/fs/mv.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { CommandEnvelope } from '@fnndsc/cumin';
|
|
2
|
-
/**
|
|
3
|
-
* Moves or renames a file or directory.
|
|
4
|
-
* Supports multiple sources when destination is a directory.
|
|
5
|
-
*
|
|
6
|
-
* @param args - [src1, src2, ..., dest] or [src, dest]
|
|
7
|
-
* @returns An envelope whose rendered text reports progress and results and
|
|
8
|
-
* whose model carries per-source outcomes.
|
|
9
|
-
*/
|
|
10
|
-
export declare function builtin_mv(args: string[]): Promise<CommandEnvelope>;
|