@infosupport/huddle-cli 0.0.0-experiment-98.50.1 → 0.0.0-experiment-98.51.1
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 +38 -0
- package/dist/index.js +29 -3
- package/dist/indexfolder.js +143 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,6 +44,44 @@ huddle --ide vscode \
|
|
|
44
44
|
|
|
45
45
|
Default API URL: `http://localhost:3000`. Override it with `--url` or `HUDDLE_URL`.
|
|
46
46
|
|
|
47
|
+
## Making host folders selectable in the portal
|
|
48
|
+
|
|
49
|
+
Huddle's portal runs inside a container, so it cannot open a folder dialog on your
|
|
50
|
+
host: every host path had to be typed from memory. `huddle indexfolder` scans your
|
|
51
|
+
host once and stores what it finds, and every host-path field in the portal grows a
|
|
52
|
+
**Browse** button that opens those folders as a tree — starting a devcontainer, the
|
|
53
|
+
folder mappings, and the team-managed folders. Starting a devcontainer, Ctrl-click picks
|
|
54
|
+
several folders at once and each becomes its own worktree. Typing a path by hand keeps working:
|
|
55
|
+
the index is a snapshot, so a folder created after the last scan must not be
|
|
56
|
+
unreachable.
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
cd T:/projects
|
|
60
|
+
huddle indexfolder # this folder + 2 levels below it
|
|
61
|
+
huddle indexfolder T:/projects --depth 3
|
|
62
|
+
huddle indexfolder --all # also index node_modules, dist, target, ...
|
|
63
|
+
huddle indexfolder --replace # re-scan: drop the earlier entries under this folder first
|
|
64
|
+
huddle indexfolder --list # show what is indexed
|
|
65
|
+
huddle indexfolder --clear # empty the index (with a folder: only that subtree)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Hidden (dot) folders and the usual build folders (`node_modules`, `dist`, `target`,
|
|
69
|
+
`obj`, …) are skipped, which is what keeps a scan of a projects folder in the
|
|
70
|
+
hundreds instead of the tens of thousands; `--all` turns that off. The scan stops
|
|
71
|
+
at 1500 folders and the index holds at most 2000 — index a more specific folder if
|
|
72
|
+
you hit that.
|
|
73
|
+
|
|
74
|
+
The index is a **snapshot**, not a live view: the gateway cannot read your host, so
|
|
75
|
+
re-run the command after adding projects. Every input keeps accepting a typed path,
|
|
76
|
+
so a folder you created a minute ago works without re-indexing first. Windows paths
|
|
77
|
+
may be typed either way (`T:\projects\app` or `T:/projects/app`) — they are stored
|
|
78
|
+
in one canonical form, and the two spellings are the same entry.
|
|
79
|
+
|
|
80
|
+
Individual folders can also be added or removed under **Settings > Indexed
|
|
81
|
+
folders** in the portal. The index lives in Huddle's database, not in
|
|
82
|
+
`~/.huddle/config.json`: it describes this machine, so unlike the team-managed
|
|
83
|
+
settings it is not something to share in version control.
|
|
84
|
+
|
|
47
85
|
## Experiments
|
|
48
86
|
|
|
49
87
|
An experiment is a complete Huddle version (CLI + all Docker images) tied to a single GitHub issue. Push a branch `experiment/<issue-number>-<description>` and the pipeline publishes everything under the tag `experiment-<issue-number>`, fully separated from the normal releases.
|
package/dist/index.js
CHANGED
|
@@ -11,13 +11,14 @@ const start_1 = require("./start");
|
|
|
11
11
|
const firewall_1 = require("./firewall");
|
|
12
12
|
const init_1 = require("./init");
|
|
13
13
|
const migrate_1 = require("./migrate");
|
|
14
|
+
const indexfolder_1 = require("./indexfolder");
|
|
14
15
|
const images_1 = require("./images");
|
|
15
16
|
const self_update_1 = require("./self-update");
|
|
16
17
|
const utils_1 = require("./utils");
|
|
17
18
|
const experiment_1 = require("./experiment");
|
|
18
|
-
const VALUE_FLAGS = new Set(['url', 'ide', 'name', 'image', 'workspace', 'container', 'status', 'runtime', 'experiment', 'path', 'ca-path', 'output', 'out', 'workspace-root']);
|
|
19
|
-
const BOOLEAN_FLAGS = new Set(['help', 'h', 'empty', 'i', 'interactive', 'version', 'v', 'deny', 'docker-socket', 'force', 'replace']);
|
|
20
|
-
const COMMANDS = new Set(['start', 'firewall', 'fw', 'init', 'restart', 'experiment', 'migrate', 'help', 'version']);
|
|
19
|
+
const VALUE_FLAGS = new Set(['url', 'ide', 'name', 'image', 'workspace', 'container', 'status', 'runtime', 'experiment', 'path', 'ca-path', 'output', 'out', 'workspace-root', 'depth']);
|
|
20
|
+
const BOOLEAN_FLAGS = new Set(['help', 'h', 'empty', 'i', 'interactive', 'version', 'v', 'deny', 'docker-socket', 'force', 'replace', 'all', 'list', 'clear']);
|
|
21
|
+
const COMMANDS = new Set(['start', 'firewall', 'fw', 'init', 'restart', 'experiment', 'migrate', 'indexfolder', 'indexfolders', 'help', 'version']);
|
|
21
22
|
function parseArgs(argv) {
|
|
22
23
|
const positional = [];
|
|
23
24
|
const flags = {};
|
|
@@ -122,6 +123,10 @@ Usage:
|
|
|
122
123
|
team firewall-rules folder)
|
|
123
124
|
huddle migrate [folder] Wire an existing docker-compose devcontainer
|
|
124
125
|
behind Huddle by generating an override file
|
|
126
|
+
huddle indexfolder [folder] Index the folders under this one so the portal
|
|
127
|
+
can offer them where a host path is needed
|
|
128
|
+
(the portal runs in a container and cannot
|
|
129
|
+
browse your host)
|
|
125
130
|
huddle firewall list [options] Show firewall requests
|
|
126
131
|
huddle fw list [options] Alias for firewall list
|
|
127
132
|
huddle firewall add <domain> Add a custom firewall rule (wildcards
|
|
@@ -169,6 +174,16 @@ Migrate options:
|
|
|
169
174
|
(default: docker-compose.huddle.yml next to the source)
|
|
170
175
|
--force Overwrite an existing override file
|
|
171
176
|
|
|
177
|
+
Indexfolder options:
|
|
178
|
+
--depth <n> How deep to walk (default: 2, max 8)
|
|
179
|
+
--all Also index build folders (node_modules, dist,
|
|
180
|
+
target, ...); hidden folders stay skipped
|
|
181
|
+
--replace Drop the earlier entries under this folder
|
|
182
|
+
first, instead of merging
|
|
183
|
+
--list Show the current index and exit
|
|
184
|
+
--clear Empty the index (or, with a folder, only the
|
|
185
|
+
entries under it)
|
|
186
|
+
|
|
172
187
|
Firewall options:
|
|
173
188
|
-i, --interactive Interactively approve/deny (list)
|
|
174
189
|
--container <name> Filter by (list) / scope to (add) a container
|
|
@@ -337,6 +352,17 @@ async function main() {
|
|
|
337
352
|
}
|
|
338
353
|
return;
|
|
339
354
|
}
|
|
355
|
+
if (cmd === 'indexfolder' || cmd === 'indexfolders') {
|
|
356
|
+
await (0, indexfolder_1.runIndexFolder)({
|
|
357
|
+
path: positional[1],
|
|
358
|
+
depth: flagString(flags, 'depth'),
|
|
359
|
+
all: flagBool(flags, 'all'),
|
|
360
|
+
replace: flagBool(flags, 'replace'),
|
|
361
|
+
clear: flagBool(flags, 'clear'),
|
|
362
|
+
list: flagBool(flags, 'list'),
|
|
363
|
+
});
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
340
366
|
if (cmd === 'migrate') {
|
|
341
367
|
await (0, migrate_1.runMigrate)({
|
|
342
368
|
path: positional[1],
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.runIndexFolder = runIndexFolder;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const api_1 = require("./api");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
// `huddle indexfolder` — make host folders selectable in the portal.
|
|
12
|
+
//
|
|
13
|
+
// The portal runs inside a container: it cannot open a file dialog on the host,
|
|
14
|
+
// so every host path had to be typed from memory. This command walks the host
|
|
15
|
+
// filesystem where the operator already is (their projects folder) and posts the
|
|
16
|
+
// folders it finds to the gateway, which stores them as an index. The portal then
|
|
17
|
+
// offers that index wherever a host path is needed.
|
|
18
|
+
//
|
|
19
|
+
// Deliberately a snapshot, not a live view: the gateway has no way to read the
|
|
20
|
+
// host filesystem, and re-running the command is cheap.
|
|
21
|
+
// Folders that are never a workspace choice but do contain thousands of
|
|
22
|
+
// subfolders. Skipping them is what keeps a scan of a projects folder in the
|
|
23
|
+
// hundreds rather than the tens of thousands. `--all` turns this off; hidden
|
|
24
|
+
// (dot) folders stay skipped either way.
|
|
25
|
+
const NOISE = new Set([
|
|
26
|
+
'node_modules', 'dist', 'build', 'out', 'bin', 'obj', 'target', 'vendor',
|
|
27
|
+
'venv', '__pycache__', 'coverage', 'packages', 'AppData', 'Library',
|
|
28
|
+
'$RECYCLE.BIN', 'System Volume Information', 'Windows', 'Program Files',
|
|
29
|
+
'Program Files (x86)', 'ProgramData',
|
|
30
|
+
]);
|
|
31
|
+
// Hard stop on discovery, well under the gateway's own cap. Pointing the command
|
|
32
|
+
// at a drive root should end in a clear warning, not a ten-minute walk.
|
|
33
|
+
const MAX_FOLDERS = 1500;
|
|
34
|
+
// Host paths travel to the gateway with forward slashes: `path.resolve` hands
|
|
35
|
+
// back `T:\projects\app` on Windows, and the whole stack (the portal, the index,
|
|
36
|
+
// the Docker mount translation) speaks the forward-slash form. The gateway
|
|
37
|
+
// normalizes again on ingest — this is only so what we PRINT matches what gets
|
|
38
|
+
// stored.
|
|
39
|
+
function toPosix(p) {
|
|
40
|
+
return p.replace(/\\/g, '/').replace(/^([a-z]):/, (_m, d) => `${d.toUpperCase()}:`);
|
|
41
|
+
}
|
|
42
|
+
function parseDepth(raw) {
|
|
43
|
+
if (raw === undefined)
|
|
44
|
+
return 2;
|
|
45
|
+
const n = Number(raw);
|
|
46
|
+
if (!Number.isInteger(n) || n < 0 || n > 8) {
|
|
47
|
+
throw new Error(`Invalid --depth "${raw}": use a whole number between 0 and 8.`);
|
|
48
|
+
}
|
|
49
|
+
return n;
|
|
50
|
+
}
|
|
51
|
+
// Breadth-first so a depth cut-off keeps the folders nearest the root — those are
|
|
52
|
+
// the ones an operator actually mounts. Symlinks are not followed: `isDirectory()`
|
|
53
|
+
// is false for a symlink entry, which also rules out a link loop.
|
|
54
|
+
function scan(root, depth, all) {
|
|
55
|
+
const folders = [root];
|
|
56
|
+
let level = [root];
|
|
57
|
+
for (let d = 0; d < depth; d++) {
|
|
58
|
+
const next = [];
|
|
59
|
+
for (const dir of level) {
|
|
60
|
+
let entries;
|
|
61
|
+
try {
|
|
62
|
+
entries = fs_1.default.readdirSync(dir, { withFileTypes: true });
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
continue; // unreadable folder (permissions, a vanished dir) — skip it
|
|
66
|
+
}
|
|
67
|
+
for (const e of entries) {
|
|
68
|
+
if (!e.isDirectory())
|
|
69
|
+
continue;
|
|
70
|
+
if (e.name.startsWith('.'))
|
|
71
|
+
continue;
|
|
72
|
+
if (!all && NOISE.has(e.name))
|
|
73
|
+
continue;
|
|
74
|
+
const full = path_1.default.join(dir, e.name);
|
|
75
|
+
folders.push(full);
|
|
76
|
+
next.push(full);
|
|
77
|
+
if (folders.length >= MAX_FOLDERS)
|
|
78
|
+
return { folders, truncated: true };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
level = next;
|
|
82
|
+
if (level.length === 0)
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
return { folders, truncated: false };
|
|
86
|
+
}
|
|
87
|
+
async function runIndexFolder(opts) {
|
|
88
|
+
if (opts.list) {
|
|
89
|
+
const res = await (0, api_1.get)('/api/indexed-folders');
|
|
90
|
+
if (res.folders.length === 0) {
|
|
91
|
+
console.log((0, utils_1.dim)('No folders indexed yet. Run `huddle indexfolder` in your projects folder.'));
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
(0, utils_1.printTable)(['ID', 'PATH', 'SOURCE'], res.folders.map((f) => [String(f.id), f.path, f.source]));
|
|
95
|
+
console.log((0, utils_1.dim)(`\n${res.folders.length} folder(s) indexed (max ${res.max}).`));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (opts.clear) {
|
|
99
|
+
// Scoped when a folder is given, so clearing one project's entries does not
|
|
100
|
+
// throw away everything else that was indexed.
|
|
101
|
+
const root = opts.path ? toPosix(path_1.default.resolve(opts.path)) : undefined;
|
|
102
|
+
const query = root ? `?root=${encodeURIComponent(root)}` : '';
|
|
103
|
+
const res = await (0, api_1.del)(`/api/indexed-folders${query}`);
|
|
104
|
+
console.log((0, utils_1.green)(`[OK] Removed ${res.removed} folder(s) from the index${root ? ` under ${(0, utils_1.cyan)(root)}` : ''}.`));
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const depth = parseDepth(opts.depth);
|
|
108
|
+
const root = path_1.default.resolve(opts.path ?? process.cwd());
|
|
109
|
+
let stat;
|
|
110
|
+
try {
|
|
111
|
+
stat = fs_1.default.statSync(root);
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
throw new Error(`Folder does not exist: ${root}`);
|
|
115
|
+
}
|
|
116
|
+
if (!stat.isDirectory())
|
|
117
|
+
throw new Error(`Not a folder: ${root}`);
|
|
118
|
+
const posixRoot = toPosix(root);
|
|
119
|
+
console.log(`Indexing ${(0, utils_1.bold)(posixRoot)} ${(0, utils_1.dim)(`(depth ${depth}${opts.all ? ', including build folders' : ''})`)}`);
|
|
120
|
+
const { folders, truncated } = scan(root, depth, opts.all === true);
|
|
121
|
+
if (truncated) {
|
|
122
|
+
console.log((0, utils_1.yellow)(`[!] Stopped at ${MAX_FOLDERS} folders. Index a more specific folder, or lower --depth.`));
|
|
123
|
+
}
|
|
124
|
+
const res = await (0, api_1.post)('/api/indexed-folders', {
|
|
125
|
+
paths: folders.map(toPosix),
|
|
126
|
+
root: posixRoot,
|
|
127
|
+
replace: opts.replace === true,
|
|
128
|
+
});
|
|
129
|
+
if (res.removed)
|
|
130
|
+
console.log((0, utils_1.dim)(` Replaced: removed ${res.removed} earlier entr(y|ies) under this folder.`));
|
|
131
|
+
console.log((0, utils_1.green)(`[OK] ${res.added} added, ${res.updated} already known — ${res.total} folder(s) in the index.`));
|
|
132
|
+
if (res.skipped) {
|
|
133
|
+
console.log((0, utils_1.yellow)(`[!] ${res.skipped} folder(s) skipped (index limit ${res.max} reached, or a duplicate spelling).`));
|
|
134
|
+
}
|
|
135
|
+
for (const bad of res.invalid.slice(0, 5)) {
|
|
136
|
+
console.log((0, utils_1.yellow)(`[!] Refused ${bad.path}: ${bad.error}`));
|
|
137
|
+
}
|
|
138
|
+
if (res.invalid.length > 5)
|
|
139
|
+
console.log((0, utils_1.yellow)(`[!] ...and ${res.invalid.length - 5} more refused.`));
|
|
140
|
+
console.log();
|
|
141
|
+
console.log('Pick these folders in the portal when starting a devcontainer,');
|
|
142
|
+
console.log(`or manage the index under ${(0, utils_1.cyan)('Settings > Indexed folders')}.`);
|
|
143
|
+
}
|
package/package.json
CHANGED