@infosupport/huddle-cli 0.0.0-experiment-98.44.1 → 0.0.0-experiment-57.47.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 CHANGED
@@ -16,7 +16,7 @@ npm install -g @infosupport/huddle-cli
16
16
  huddle init
17
17
  ```
18
18
 
19
- Pulls `ghcr.io/infosupport/huddle:latest` and starts the container. Works with Docker and Podman: the runtime is detected automatically (Docker first, then Podman), or pick one explicitly with `huddle init --runtime <docker|podman>` or the `HUDDLE_RUNTIME` env var. If you run `huddle` while Huddle isn't running, you automatically get a hint to run this command.
19
+ Pulls `ghcr.io/infosupport/huddle:latest` and starts the container. Works with Docker, Podman and WSLc: the runtime is detected automatically (Docker first, then Podman, then WSLc), or pick one explicitly with `huddle init --runtime <docker|podman|wslc>` or the `HUDDLE_RUNTIME` env var. If you run `huddle` while Huddle isn't running, you automatically get a hint to run this command.
20
20
 
21
21
  ## Starting devcontainers
22
22
 
package/dist/config.js CHANGED
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.CONFIG_DIR = void 0;
7
6
  exports.configPath = configPath;
8
7
  exports.readConfig = readConfig;
9
8
  exports.writeConfig = writeConfig;
@@ -13,8 +12,8 @@ exports.imageTag = imageTag;
13
12
  const fs_1 = __importDefault(require("fs"));
14
13
  const os_1 = __importDefault(require("os"));
15
14
  const path_1 = __importDefault(require("path"));
16
- exports.CONFIG_DIR = path_1.default.join(os_1.default.homedir(), '.huddle');
17
- const CONFIG_PATH = path_1.default.join(exports.CONFIG_DIR, 'config.json');
15
+ const CONFIG_DIR = path_1.default.join(os_1.default.homedir(), '.huddle');
16
+ const CONFIG_PATH = path_1.default.join(CONFIG_DIR, 'config.json');
18
17
  function configPath() {
19
18
  return CONFIG_PATH;
20
19
  }
@@ -27,7 +26,7 @@ function readConfig() {
27
26
  }
28
27
  }
29
28
  function writeConfig(config) {
30
- fs_1.default.mkdirSync(exports.CONFIG_DIR, { recursive: true });
29
+ fs_1.default.mkdirSync(CONFIG_DIR, { recursive: true });
31
30
  fs_1.default.writeFileSync(CONFIG_PATH, `${JSON.stringify(config, null, 2)}\n`);
32
31
  }
33
32
  /** Operator-token voor API-auth: env wint, anders uit de config. */
package/dist/firewall.js CHANGED
@@ -1,18 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.runFirewallList = runFirewallList;
7
4
  exports.runFirewallAdd = runFirewallAdd;
8
5
  exports.runFirewallDelete = runFirewallDelete;
9
- exports.runFirewallExport = runFirewallExport;
10
- exports.runFirewallImport = runFirewallImport;
11
- exports.runFirewallGroup = runFirewallGroup;
12
- exports.runFirewallFolder = runFirewallFolder;
13
- const fs_1 = __importDefault(require("fs"));
14
6
  const api_1 = require("./api");
15
- const config_1 = require("./config");
16
7
  const utils_1 = require("./utils");
17
8
  async function runFirewallList(opts) {
18
9
  const qs = new URLSearchParams({ status: opts.status ?? 'requested' });
@@ -65,9 +56,9 @@ async function resolveRule(rule, status, scope) {
65
56
  }
66
57
  // Creates a custom firewall rule. Supports wildcards: `*.` in the domain
67
58
  // (e.g. `*.pkgs.dev.azure.com`) and `*` in the path pattern (e.g.
68
- // `/_packaging/*/nuget/v3/*` for an Azure DevOps feed with a changing
69
- // GUID). Defaults to 'allow'; --deny creates a block rule. Without --container
70
- // the rule is global.
59
+ // `/_packaging/*/nuget/v3/*` for an Azure DevOps feed with a rotating
60
+ // GUID). Defaults to 'allow'; with --deny a block rule. Without --container the
61
+ // rule is global.
71
62
  async function runFirewallAdd(opts) {
72
63
  const domain = (opts.domain ?? '').trim();
73
64
  if (!domain) {
@@ -144,137 +135,3 @@ function printRulesTable(rules) {
144
135
  function formatTarget(rule) {
145
136
  return rule.path_pattern ? `${rule.domain}${rule.path_pattern}` : rule.domain;
146
137
  }
147
- async function runFirewallExport(opts) {
148
- const qs = new URLSearchParams();
149
- if (opts.container)
150
- qs.set('container', opts.container);
151
- const suffix = qs.toString() ? `?${qs}` : '';
152
- const doc = await (0, api_1.get)(`/api/rules/export${suffix}`);
153
- const json = JSON.stringify(doc, null, 2);
154
- if (opts.out) {
155
- fs_1.default.writeFileSync(opts.out, `${json}\n`);
156
- // Progress to stderr so a pure `--out` run leaks nothing to stdout.
157
- console.error((0, utils_1.green)(`[OK] Exported ${doc.rules.length} rule(s) to ${opts.out}`));
158
- }
159
- else {
160
- console.log(json);
161
- }
162
- }
163
- // Read + JSON-parse a file with uniform, actionable errors. Shared by both
164
- // import paths (flat rules and groups).
165
- function readJsonFile(file) {
166
- let raw;
167
- try {
168
- raw = fs_1.default.readFileSync(file, 'utf8');
169
- }
170
- catch {
171
- throw new Error(`Cannot read ${file}`);
172
- }
173
- try {
174
- return JSON.parse(raw);
175
- }
176
- catch {
177
- throw new Error(`${file} is not valid JSON`);
178
- }
179
- }
180
- async function runFirewallImport(opts) {
181
- const doc = readJsonFile(opts.file);
182
- const mode = opts.replace ? 'replace' : 'merge';
183
- const qs = new URLSearchParams();
184
- if (opts.container)
185
- qs.set('container', opts.container);
186
- const suffix = qs.toString() ? `?${qs}` : '';
187
- const res = await (0, api_1.post)(`/api/rules/import${suffix}`, { mode, rules: doc.rules });
188
- console.error((0, utils_1.green)(`[OK] Imported (${mode}): ${res.imported} added, ${res.updated} updated, ${res.skipped} skipped`));
189
- }
190
- async function resolveGroupByName(name) {
191
- const groups = await (0, api_1.get)('/api/groups');
192
- const match = groups.filter((g) => g.name.toLowerCase() === name.toLowerCase());
193
- if (match.length === 0)
194
- throw new Error(`No group named "${name}". Run \`huddle firewall group list\`.`);
195
- return match[0];
196
- }
197
- async function runFirewallGroup(opts) {
198
- const action = opts.action ?? 'list';
199
- if (action === 'list') {
200
- const groups = await (0, api_1.get)('/api/groups');
201
- if (groups.length === 0) {
202
- console.log((0, utils_1.dim)('No firewall groups yet.'));
203
- return;
204
- }
205
- const headers = ['ID', 'Name', 'Rules', 'Shared', 'Source'];
206
- const rows = groups.map((g) => [String(g.id), g.name, String(g.rule_count), g.shared ? 'yes' : 'no', g.source]);
207
- (0, utils_1.printTable)(headers, rows);
208
- return;
209
- }
210
- if (action === 'export') {
211
- const name = (opts.arg ?? '').trim();
212
- if (!name)
213
- throw new Error('Usage: huddle firewall group export <name> [--out <file>]');
214
- const g = await resolveGroupByName(name);
215
- const env = await (0, api_1.get)(`/api/groups/${g.id}/export`);
216
- const json = JSON.stringify(env, null, 2);
217
- if (opts.out) {
218
- fs_1.default.writeFileSync(opts.out, `${json}\n`);
219
- console.error((0, utils_1.green)(`[OK] Exported group "${g.name}" to ${opts.out}`));
220
- }
221
- else {
222
- console.log(json);
223
- }
224
- return;
225
- }
226
- if (action === 'import') {
227
- const file = (opts.arg ?? '').trim();
228
- if (!file)
229
- throw new Error('Usage: huddle firewall group import <file> [--replace]');
230
- const envelope = readJsonFile(file);
231
- const mode = opts.replace ? 'replace' : 'merge';
232
- const res = await (0, api_1.post)('/api/groups/import', { mode, envelope });
233
- console.error((0, utils_1.green)(`[OK] Imported group "${res.group.name}" (${mode}): ${res.imported} added, ${res.updated} updated, ${res.skipped} skipped`));
234
- return;
235
- }
236
- if (action === 'apply') {
237
- const name = (opts.arg ?? '').trim();
238
- if (!name)
239
- throw new Error('Usage: huddle firewall group apply <name> [--container <id>]');
240
- const g = await resolveGroupByName(name);
241
- const container = opts.container ?? null;
242
- const res = await (0, api_1.post)(`/api/groups/${g.id}/apply`, { container });
243
- const scope = container ? `container ${container}` : 'global';
244
- console.log((0, utils_1.green)(`[OK] Applied "${g.name}" to ${scope}: ${res.applied} added, ${res.updated} updated`));
245
- return;
246
- }
247
- throw new Error(`Unknown group action: ${action}. Use list | export | import | apply.`);
248
- }
249
- async function runFirewallFolder(opts) {
250
- const action = opts.action ?? 'show';
251
- if (action === 'show') {
252
- // The CLI config is the source of truth for the path.
253
- const folder = (0, config_1.readConfig)().firewallRulesFolder;
254
- console.log(folder ? folder : (0, utils_1.dim)('(no firewall rules folder configured)'));
255
- return;
256
- }
257
- if (action === 'set') {
258
- const path = (opts.path ?? '').trim();
259
- if (!path)
260
- throw new Error('Usage: huddle firewall folder set <path>');
261
- // Config-only: the gateway reads the folder at the fixed mount point the CLI
262
- // binds it to; there is no DB setting. Persist here and mount on restart.
263
- (0, config_1.writeConfig)({ ...(0, config_1.readConfig)(), firewallRulesFolder: path });
264
- console.log((0, utils_1.green)(`[OK] Firewall rules folder set to ${(0, utils_1.cyan)(path)}`));
265
- console.log((0, utils_1.dim)(' Run `huddle restart` to mount it into the gateway; it is then read on start & reload.'));
266
- return;
267
- }
268
- if (action === 'reload') {
269
- const res = await (0, api_1.post)('/api/firewall-rules-folder/reload', {});
270
- if (!res.mounted) {
271
- console.log((0, utils_1.dim)('No firewall rules folder mounted. Set one with `huddle firewall folder set <path>` and run `huddle restart`.'));
272
- return;
273
- }
274
- console.log((0, utils_1.green)(`[OK] Reloaded: ${res.groups} group(s), ${res.imported} rule(s), ${res.errors.length} error(s)`));
275
- for (const e of res.errors)
276
- console.error((0, utils_1.red)(` [!] ${e.file}: ${e.message}`));
277
- return;
278
- }
279
- throw new Error(`Unknown folder action: ${action}. Use show | set | reload.`);
280
- }
package/dist/images.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveImages = resolveImages;
4
- exports.gatewayEnvArgs = gatewayEnvArgs;
4
+ exports.gatewayEnvFlags = gatewayEnvFlags;
5
5
  const config_1 = require("./config");
6
6
  function resolveImages() {
7
7
  const experiment = (0, config_1.activeExperiment)();
@@ -19,17 +19,13 @@ function resolveImages() {
19
19
  };
20
20
  }
21
21
  /**
22
- * `-e KEY=val` argv pairs for the gateway container. During an experiment (or
23
- * with an explicit override) the gateway must start devcontainers from the same
24
- * base images the CLI just pulled. Returned as an argv array (not a shell
25
- * string) so init can spawn `docker run` without a shell.
22
+ * `-e` flags for the gateway container. During an experiment (or with an
23
+ * explicit override) the gateway must start devcontainers from the same
24
+ * base images the CLI just pulled.
26
25
  */
27
- function gatewayEnvArgs(resolved) {
28
- const args = [];
29
- for (const b of resolved.baseImages) {
30
- if (b.gatewayEnv && (resolved.experiment !== undefined || process.env[b.gatewayEnv])) {
31
- args.push('-e', `${b.gatewayEnv}=${b.image}`);
32
- }
33
- }
34
- return args;
26
+ function gatewayEnvFlags(resolved) {
27
+ return resolved.baseImages
28
+ .filter((b) => b.gatewayEnv && (resolved.experiment !== undefined || process.env[b.gatewayEnv]))
29
+ .map((b) => ` -e ${b.gatewayEnv}=${b.image}`)
30
+ .join('');
35
31
  }
package/dist/index.js CHANGED
@@ -15,9 +15,9 @@ const images_1 = require("./images");
15
15
  const self_update_1 = require("./self-update");
16
16
  const utils_1 = require("./utils");
17
17
  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']);
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']);
18
+ const VALUE_FLAGS = new Set(['url', 'ide', 'name', 'image', 'workspace', 'container', 'status', 'runtime', 'experiment', 'path', 'ca-path', 'output']);
19
+ const BOOLEAN_FLAGS = new Set(['help', 'h', 'empty', 'i', 'interactive', 'version', 'v', 'deny', 'docker-socket', 'force']);
20
+ const COMMANDS = new Set(['start', 'firewall', 'fw', 'init', 'experiment', 'migrate', 'help', 'version']);
21
21
  function parseArgs(argv) {
22
22
  const positional = [];
23
23
  const flags = {};
@@ -94,8 +94,6 @@ Usage:
94
94
  huddle start [options] [folder] Explicitly start a devcontainer
95
95
  huddle init [options] Pull the Huddle + devcontainer base images and
96
96
  start them via Docker or Podman
97
- huddle restart Recreate the gateway (e.g. to mount a changed
98
- team firewall-rules folder)
99
97
  huddle migrate [folder] Wire an existing docker-compose devcontainer
100
98
  behind Huddle by generating an override file
101
99
  huddle firewall list [options] Show firewall requests
@@ -104,21 +102,13 @@ Usage:
104
102
  supported: *.example.com and /path/*)
105
103
  huddle firewall delete <id> Delete a firewall rule by id (or domain;
106
104
  narrow with --container)
107
- huddle firewall export [options] Export firewall rules as JSON
108
- huddle firewall import <file> Import firewall rules from a JSON file
109
- huddle firewall group list List firewall groups (#69)
110
- huddle firewall group export <name> Export a group as JSON (--out <file>)
111
- huddle firewall group import <file> Import a group (--replace to mirror)
112
- huddle firewall group apply <name> Apply a group (--container <id> or global)
113
- huddle firewall folder set <path> Set the team-managed rules folder
114
- huddle firewall folder reload Re-read the team-managed rules folder
115
105
  huddle experiment use <nr> Activate the experimental build of issue/PR <nr>
116
106
  and run init
117
107
  huddle experiment reset Back to the stable release
118
108
  huddle experiment status Show the active channel and CLI version
119
109
 
120
110
  Init options:
121
- --runtime <docker|podman> Container runtime (default: auto-detected;
111
+ --runtime <docker|podman|wslc> Container runtime (default: auto-detected;
122
112
  also via the HUDDLE_RUNTIME env var)
123
113
  --experiment <nr> Use the experimental build of issue/PR <nr>
124
114
  (same as "huddle experiment use <nr>")
@@ -142,8 +132,6 @@ Migrate options:
142
132
  Firewall options:
143
133
  -i, --interactive Interactively approve/deny (list)
144
134
  --container <name> Filter by (list) / scope to (add) a container
145
- (or __global__). On import: remap all rules
146
- to this scope
147
135
  --status <requested|allow|deny> Filter by status (default: requested)
148
136
 
149
137
  Firewall add options:
@@ -152,11 +140,6 @@ Firewall add options:
152
140
  (e.g. /_packaging/*/nuget/v3/*)
153
141
  --deny Create a block rule (default: allow)
154
142
 
155
- Firewall export/import options:
156
- --out <file> Write export to a file (default: stdout)
157
- --replace Import in replace mode: wipe the target
158
- scope first (default: merge/upsert)
159
-
160
143
  Global options:
161
144
  --url <url> Huddle URL (default: http://localhost:3000)
162
145
  Or via the HUDDLE_URL env var
@@ -219,15 +202,6 @@ async function main() {
219
202
  await (0, init_1.runInit)(initOpts, (0, images_1.resolveImages)());
220
203
  return;
221
204
  }
222
- if (cmd === 'restart') {
223
- // Stop + recreate the gateway (runInit does `rm -f` first) so changed team
224
- // folders get mounted. The portal writes the paths straight into the mounted
225
- // ~/.huddle/config.json, so runInit already reads the latest values here.
226
- const initOpts = { runtime: flagString(flags, 'runtime') };
227
- (0, experiment_1.ensureCliForChannel)(process.argv.slice(2));
228
- await (0, init_1.runInit)(initOpts, (0, images_1.resolveImages)());
229
- return;
230
- }
231
205
  if (cmd === 'experiment') {
232
206
  const subCmd = sub ?? 'status';
233
207
  if (subCmd === 'use') {
@@ -269,36 +243,6 @@ async function main() {
269
243
  container: flagString(flags, 'container'),
270
244
  });
271
245
  }
272
- else if (subCmd === 'export') {
273
- await (0, firewall_1.runFirewallExport)({
274
- container: flagString(flags, 'container'),
275
- out: flagString(flags, 'out'),
276
- });
277
- }
278
- else if (subCmd === 'import') {
279
- const file = positional[2];
280
- if (!file) {
281
- console.error('Usage: huddle firewall import <file> [--replace] [--container <id>]');
282
- process.exit(1);
283
- }
284
- await (0, firewall_1.runFirewallImport)({
285
- file,
286
- replace: flagBool(flags, 'replace'),
287
- container: flagString(flags, 'container'),
288
- });
289
- }
290
- else if (subCmd === 'group' || subCmd === 'groups') {
291
- await (0, firewall_1.runFirewallGroup)({
292
- action: positional[2],
293
- arg: positional[3],
294
- out: flagString(flags, 'out'),
295
- replace: flagBool(flags, 'replace'),
296
- container: flagString(flags, 'container'),
297
- });
298
- }
299
- else if (subCmd === 'folder') {
300
- await (0, firewall_1.runFirewallFolder)({ action: positional[2], path: positional[3] });
301
- }
302
246
  else {
303
247
  console.error(`Unknown firewall subcommand: ${subCmd}`);
304
248
  process.exit(1);
package/dist/init.js CHANGED
@@ -29,16 +29,12 @@ exports.INTERNAL_NET = 'devcontainer-net';
29
29
  */
30
30
  exports.HOST_SOCKET_DIR = '/tmp/dc-sockets';
31
31
  const HOST_PORT = process.env.HUDDLE_PORT ?? '3000';
32
- // Run a binary with an argv array — NO shell. Values that originate from config
33
- // (team-folder paths, which are writable via `huddle firewall folder set` and the
34
- // authenticated settings API) must never be interpolated into a shell string, or
35
- // a path containing `$()`/quotes would execute on the host. Used for `docker run`.
36
- function runArgs(file, args) {
37
- (0, child_process_1.execFileSync)(file, args, { stdio: 'inherit' });
32
+ function run(cmd) {
33
+ (0, child_process_1.execSync)(cmd, { stdio: 'inherit' });
38
34
  }
39
- function runArgsSilent(file, args) {
35
+ function runSilent(cmd) {
40
36
  try {
41
- (0, child_process_1.execFileSync)(file, args, { stdio: 'ignore' });
37
+ (0, child_process_1.execSync)(cmd, { stdio: 'ignore' });
42
38
  return true;
43
39
  }
44
40
  catch {
@@ -56,7 +52,7 @@ function pullBaseImages(rt, images) {
56
52
  for (const image of images) {
57
53
  console.log((0, utils_1.dim)(` Pulling ${image}`));
58
54
  try {
59
- runArgs(rt, ['pull', image]);
55
+ run(`${rt} pull ${image}`);
60
56
  }
61
57
  catch {
62
58
  failed.push(image);
@@ -86,15 +82,15 @@ async function runInit(opts, images) {
86
82
  }
87
83
  else {
88
84
  console.log((0, utils_1.dim)(`Pulling ${IMAGE}`));
89
- runArgs(rt, ['pull', IMAGE]);
85
+ run(`${rt} pull ${IMAGE}`);
90
86
  pullBaseImages(rt, images.baseImages.map((b) => b.image));
91
87
  }
92
88
  console.log((0, utils_1.dim)(`Volume: ${VOLUME}`));
93
- runArgsSilent(rt, ['volume', 'inspect', VOLUME]) || runArgs(rt, ['volume', 'create', VOLUME]);
89
+ runSilent(`${rt} volume inspect ${VOLUME}`) || run(`${rt} volume create ${VOLUME}`);
94
90
  console.log((0, utils_1.dim)(`Network: ${exports.INTERNAL_NET}`));
95
- runArgsSilent(rt, ['network', 'inspect', exports.INTERNAL_NET]) || runArgs(rt, ['network', 'create', '--internal', exports.INTERNAL_NET]);
91
+ runSilent(`${rt} network inspect ${exports.INTERNAL_NET}`) || run(`${rt} network create --internal ${exports.INTERNAL_NET}`);
96
92
  console.log((0, utils_1.dim)(`Removing old container if it exists`));
97
- runArgsSilent(rt, ['rm', '-f', CONTAINER]);
93
+ runSilent(`${rt} rm -f ${CONTAINER}`);
98
94
  console.log((0, utils_1.dim)(`Socket directory: /tmp/dc-sockets`));
99
95
  // The mount SOURCE must be the path on the Docker ENGINE host (on Windows:
100
96
  // the WSL2/Linux VM), even when the CLI itself runs on Windows. The gateway
@@ -109,7 +105,7 @@ async function runInit(opts, images) {
109
105
  // Desktop) and fails with "statfs: no such file or directory". So create
110
106
  // the directory explicitly in the machine VM; the socket lives there too.
111
107
  console.log((0, utils_1.dim)(` (Podman: creating ${hostTmpSockets} in the machine VM)`));
112
- if (!runArgsSilent('podman', ['machine', 'ssh', `mkdir -p ${hostTmpSockets}`])) {
108
+ if (!runSilent(`podman machine ssh "mkdir -p ${hostTmpSockets}"`)) {
113
109
  console.log((0, utils_1.yellow)(`[!] Could not create ${hostTmpSockets} in the Podman VM.`));
114
110
  }
115
111
  }
@@ -130,7 +126,8 @@ async function runInit(opts, images) {
130
126
  // The gateway is engine-agnostic (talks the Docker-compatible API on the
131
127
  // mounted socket), but does need to know it's Podman: it then sets
132
128
  // `--security-opt label=disable` on every devcontainer so it can reach the
133
- // SELinux-labeled proxy socket. (Applied as argv below via runtime.securityOpts.)
129
+ // SELinux-labeled proxy socket.
130
+ const securityOptFlags = runtime.securityOpts.map((opt) => ` --security-opt ${opt}`).join('');
134
131
  // Operator token for control-plane auth. Reuse the token from the config (so an
135
132
  // existing browser session/CLI keeps working across re-inits), otherwise
136
133
  // generate one. We pass it to the gateway via env AND store it locally so that
@@ -148,41 +145,23 @@ async function runInit(opts, images) {
148
145
  // network (moby/moby#36174). Which source IP the gateway sees for forwarded
149
146
  // traffic no longer matters — the control plane authenticates with the
150
147
  // operator token instead of source-IP filtering.
151
- // Team-managed folders (#69). Bind the CLI config dir (~/.huddle) read-write so
152
- // the gateway/portal read and write the folder paths there (config.json is the
153
- // single source of truth), then bind each configured team folder to a FIXED
154
- // path so the gateway reads it without knowing the host path. Read-only.
155
- const fwFolder = cfg.firewallRulesFolder?.trim();
156
- const extFolder = cfg.extensionsFolder?.trim();
157
- if (fwFolder)
158
- console.log((0, utils_1.dim)(` Mounting firewall-rules folder: ${fwFolder} -> /firewall-rules`));
159
- if (extFolder)
160
- console.log((0, utils_1.dim)(` Mounting extensions folder: ${extFolder} -> /extensions`));
161
- // Build the container command as an argv array (runArgs → execFileSync, no
162
- // shell). The folder paths below come from config and are operator-writable via
163
- // the settings API, so they must never reach a shell as a string.
164
- const dockerArgs = ['run', '-d', '--name', CONTAINER, '--network', runtime.defaultNetwork];
165
- for (const opt of runtime.securityOpts)
166
- dockerArgs.push('--security-opt', opt);
167
- dockerArgs.push('-e', `HUDDLE_RUNTIME=${runtime.name}`);
168
- dockerArgs.push('-e', `HUDDLE_OPERATOR_TOKEN=${operatorToken}`);
169
- dockerArgs.push('-p', `${HOST_PORT}:3000`);
170
- dockerArgs.push('-v', `${VOLUME}:/data`);
171
- dockerArgs.push('-v', `${runtime.socketPath}:/var/run/docker.sock`);
172
- dockerArgs.push('-v', `${hostTmpSockets}:/tmp/dc-sockets`);
173
- dockerArgs.push('-v', `${config_1.CONFIG_DIR}:/huddle-home:rw`, '-e', 'HUDDLE_HOME_DIR=/huddle-home');
174
- if (fwFolder)
175
- dockerArgs.push('-v', `${fwFolder}:/firewall-rules:ro`);
176
- if (extFolder)
177
- dockerArgs.push('-v', `${extFolder}:/extensions:ro`);
178
- dockerArgs.push(...(0, images_1.gatewayEnvArgs)(images));
179
- dockerArgs.push(IMAGE);
180
- runArgs(rt, dockerArgs);
148
+ run(`${rt} run -d` +
149
+ ` --name ${CONTAINER}` +
150
+ ` --network ${runtime.defaultNetwork}` +
151
+ securityOptFlags +
152
+ ` -e HUDDLE_RUNTIME=${runtime.name}` +
153
+ ` -e HUDDLE_OPERATOR_TOKEN=${operatorToken}` +
154
+ ` -p ${HOST_PORT}:3000` +
155
+ ` -v ${VOLUME}:/data` +
156
+ ` -v "${runtime.socketPath}:/var/run/docker.sock"` +
157
+ ` -v "${hostTmpSockets}:/tmp/dc-sockets"` +
158
+ (0, images_1.gatewayEnvFlags)(images) +
159
+ ` ${IMAGE}`);
181
160
  // Attaching devcontainer-net after the container has started pollutes
182
161
  // resolv.conf on Podman with that network's internal aardvark-DNS; the
183
162
  // gateway cleans that up itself (see dns-egress.ts / the startup sanitize in
184
163
  // index.ts).
185
- runArgsSilent(rt, ['network', 'connect', exports.INTERNAL_NET, CONTAINER]);
164
+ runSilent(`${rt} network connect ${exports.INTERNAL_NET} ${CONTAINER}`);
186
165
  console.log();
187
166
  console.log((0, utils_1.green)(`[OK] Huddle is running at http://localhost:${HOST_PORT}`));
188
167
  console.log();
package/dist/runtime.js CHANGED
@@ -14,8 +14,11 @@ function commandOutput(cmd) {
14
14
  }
15
15
  }
16
16
  function isAvailable(runtime) {
17
- // 'info' only succeeds if the daemon/machine is actually reachable.
18
- return commandOutput(`${runtime} info`) !== undefined;
17
+ // 'info' only succeeds if the daemon/machine is actually reachable. wslc has
18
+ // no 'info' subcommand at all (it exits with "Unrecognized command"), so use
19
+ // 'list' there instead — it equally requires a reachable daemon to succeed.
20
+ const probe = runtime === 'wslc' ? 'list' : 'info';
21
+ return commandOutput(`${runtime} ${probe}`) !== undefined;
19
22
  }
20
23
  /**
21
24
  * Determines the REAL engine behind a command, or undefined if the engine is
@@ -30,7 +33,7 @@ function detectEngine(command) {
30
33
  return 'podman';
31
34
  }
32
35
  if (isAvailable(command))
33
- return 'docker';
36
+ return command;
34
37
  return undefined;
35
38
  }
36
39
  function podmanSocketPath() {
@@ -130,14 +133,14 @@ function buildRuntime(name) {
130
133
  }
131
134
  function parseRuntimeName(value) {
132
135
  const normalized = value.toLowerCase().trim();
133
- if (normalized === 'docker' || normalized === 'podman')
136
+ if (normalized === 'docker' || normalized === 'podman' || normalized === 'wslc')
134
137
  return normalized;
135
- throw new Error(`Unknown container runtime: ${value}. Choose docker or podman.`);
138
+ throw new Error(`Unknown container runtime: ${value}. Choose docker, podman or wslc.`);
136
139
  }
137
140
  /**
138
141
  * Determines which container runtime to use.
139
142
  * An explicit choice (via --runtime or HUDDLE_RUNTIME) wins; otherwise it is
140
- * auto-detected: Docker first, then Podman.
143
+ * auto-detected: Docker first, then Podman, then wslc.
141
144
  */
142
145
  function resolveRuntime(explicit) {
143
146
  const requested = explicit ?? process.env.HUDDLE_RUNTIME;
@@ -148,12 +151,13 @@ function resolveRuntime(explicit) {
148
151
  }
149
152
  return buildRuntime(name);
150
153
  }
151
- // Auto-detection: first look behind the `docker` command (which may be a
152
- // Podman shim), then at `podman`. This way a real Docker engine wins if there
153
- // is one, but we also recognize Podman when it poses as `docker`.
154
- const detected = detectEngine('docker') ?? detectEngine('podman');
154
+ // Auto-detection: first look behind the docker command (which may be a
155
+ // Podman shim or Docker), then at podman, and finally at wslc. This way a
156
+ // real Docker engine wins if there is one, while we also recognize Podman when
157
+ // it poses as docker and fall back to wslc when neither is available.
158
+ const detected = detectEngine('docker') ?? detectEngine('podman') ?? detectEngine('wslc');
155
159
  if (detected)
156
160
  return buildRuntime(detected);
157
- throw new Error('No working container runtime found. Install and start Docker or Podman,\n' +
158
- 'or pick one explicitly with --runtime <docker|podman> or the HUDDLE_RUNTIME env var.');
161
+ throw new Error('No working container runtime found. Install and start Docker, Podman or wslc,\n' +
162
+ 'or pick one explicitly with --runtime <docker|podman|wslc> or the HUDDLE_RUNTIME env var.');
159
163
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infosupport/huddle-cli",
3
- "version": "0.0.0-experiment-98.44.1",
3
+ "version": "0.0.0-experiment-57.47.1",
4
4
  "description": "Huddle CLI — start devcontainers and manage firewall rules",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "author": "Info Support B.V.",