@space-lens/cli 0.2.0 → 0.2.2

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/README.md CHANGED
@@ -1,83 +1,25 @@
1
- # spacelens
1
+ # Space Lens TUI
2
2
 
3
- OpenTUI-powered terminal viewer for Space Lens cleanup plans.
4
-
5
- The command-line surface is defined with Effect CLI, and the startup workflow is
6
- run as an Effect program before handing control to OpenTUI.
7
-
8
- It has two modes:
9
-
10
- - `scan`: inspect disk usage as a tree.
11
- - `clean`: inspect cleanup candidates, select paths, and execute deletion after
12
- confirmation.
13
-
14
- ## Runtime
15
-
16
- OpenTUI `0.4.x` currently needs Bun for its native FFI runtime. Use the root
17
- `yarn tui` script or run the app with `bun`.
18
-
19
- Running the built CLI with `node` prints a runtime error instead of opening the
20
- TUI.
21
-
22
- ## Run From The Repo Root
23
-
24
- Use this for normal local scanning:
3
+ The published `@space-lens/cli` package uses Solid and the public `@uniview/tui-solid` binding.
25
4
 
26
5
  ```bash
27
- yarn tui ~/Dev --preset rust
28
- yarn tui ~/Dev --preset node,gitignored --sort path
29
- yarn tui . --preset rust
30
- npx @space-lens/cli ~/Dev --preset rust
6
+ yarn tui . --preset node
7
+ # or, from this package directory
8
+ vite-node src/cli.ts . --preset node
31
9
  ```
32
10
 
33
- `yarn tui` intentionally runs `bun apps/tui/src/cli.ts` from the current working
34
- directory, so relative paths like `.` mean the directory where you invoked the
35
- command.
11
+ ## Publish
36
12
 
37
- ## Controls
38
-
39
- ```text
40
- tab Switch scan/clean mode
41
- j / down Move down
42
- k / up Move up
43
- space Toggle the active cleanup candidate in clean mode
44
- a Select or unselect all visible cleanup candidates
45
- x Ask to delete selected cleanup candidates
46
- enter Confirm deletion after pressing x
47
- esc Cancel deletion confirmation
48
- q / ctrl+c Quit
49
- ```
50
-
51
- Deletion is only available from clean mode, only for selected rows, and only
52
- after the `x` then `enter` confirmation flow. After deletion, the TUI refreshes
53
- both the scan tree and cleanup plan.
54
-
55
- ## Run From The App Workspace
56
-
57
- Useful while developing the TUI package itself:
13
+ Build and publish the public CLI from this directory:
58
14
 
59
15
  ```bash
60
- yarn workspace @space-lens/cli dev -- --preset rust .
61
- ```
62
-
63
- This runs with `apps/tui` as the working directory, so `.` means `apps/tui`, not
64
- the repository root.
65
-
66
- ## Options
67
-
68
- ```text
69
- -p, --preset <name> Cleanup preset: node, rust, gitignored. Repeat or comma-separate.
70
- --ignore-hidden Skip hidden paths while searching.
71
- --sort <mode> Sort rows by size or path. Defaults to size.
72
- -h, --help Show help.
16
+ yarn build
17
+ npm publish --access public
73
18
  ```
74
19
 
75
- Press `Ctrl+C` to exit the TUI.
20
+ The package uses `@uniview/tui-solid` and requires Node.js 20 or newer.
76
21
 
77
- ## Build And Verify
22
+ ## Controls
78
23
 
79
- ```bash
80
- yarn workspace @space-lens/cli build
81
- yarn workspace @space-lens/cli test
82
- yarn workspace @space-lens/cli typecheck
83
- ```
24
+ `tab`, `j/k` or arrows, `space`, `a`, `x`, `enter`,
25
+ `esc`, `q`, and Ctrl-C.
@@ -1,3 +1,43 @@
1
+ //#region src/cli-config.ts
2
+ var PRESETS = [
3
+ "node",
4
+ "rust",
5
+ "gitignored"
6
+ ];
7
+ var SORT_MODES = ["size", "path"];
8
+ function normalizeCliConfig(raw) {
9
+ return {
10
+ paths: raw.paths.length > 0 ? [...raw.paths] : ["."],
11
+ presets: parsePresetList(raw.presets),
12
+ ignoreHidden: raw.ignoreHidden,
13
+ sort: parseSortMode(raw.sort)
14
+ };
15
+ }
16
+ function parsePresetList(raw) {
17
+ const seen = /* @__PURE__ */ new Set();
18
+ const presets = [];
19
+ for (const value of raw) for (const token of value.split(",")) {
20
+ const preset = token.trim();
21
+ if (preset.length === 0) continue;
22
+ if (!isPreset(preset)) throw new Error(`Unknown preset "${preset}". Use node, rust, or gitignored.`);
23
+ if (!seen.has(preset)) {
24
+ seen.add(preset);
25
+ presets.push(preset);
26
+ }
27
+ }
28
+ return presets;
29
+ }
30
+ function parseSortMode(raw) {
31
+ if (!isSortMode(raw)) throw new Error(`Unknown sort mode "${raw}". Use size or path.`);
32
+ return raw;
33
+ }
34
+ function isPreset(value) {
35
+ return PRESETS.includes(value);
36
+ }
37
+ function isSortMode(value) {
38
+ return SORT_MODES.includes(value);
39
+ }
40
+ //#endregion
1
41
  //#region src/model.ts
2
42
  function createInitialTuiState() {
3
43
  return {
@@ -129,4 +169,4 @@ function clampCursor(cursor, rowCount) {
129
169
  return Math.max(0, Math.min(cursor, rowCount - 1));
130
170
  }
131
171
  //#endregion
132
- export { formatBytes as a, createScanViewModel as i, createCleanViewModel as n, getSelectedEntries as o, createInitialTuiState as r, applyTuiAction as t };
172
+ export { formatBytes as a, SORT_MODES as c, parseSortMode as d, createScanViewModel as i, normalizeCliConfig as l, createCleanViewModel as n, getSelectedEntries as o, createInitialTuiState as r, PRESETS as s, applyTuiAction as t, parsePresetList as u };
@@ -17,9 +17,10 @@ function loadSpaceLensData(options) {
17
17
  };
18
18
  }
19
19
  function executeCleanupEntries(entries) {
20
+ const totalSize = entries.reduce((total, entry) => total + entry.size, 0);
20
21
  return executeCleanup({
21
22
  entries,
22
- totalSize: entries.reduce((total, entry) => total + entry.size, 0),
23
+ totalSize,
23
24
  errors: []
24
25
  });
25
26
  }