@infosupport/huddle-cli 0.0.0-experiment-98.46.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 +1 -1
- package/dist/config.js +3 -4
- package/dist/firewall.js +3 -164
- package/dist/images.js +9 -13
- package/dist/index.js +4 -61
- package/dist/init.js +25 -48
- package/dist/runtime.js +16 -12
- package/package.json +1 -1
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
|
|
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
|
-
|
|
17
|
-
const CONFIG_PATH = path_1.default.join(
|
|
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(
|
|
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
|
|
69
|
-
// GUID). Defaults to 'allow'; --deny
|
|
70
|
-
//
|
|
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,155 +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
|
-
if (action === 'sync') {
|
|
280
|
-
// Write the portal's groups back out to the folder (app → files).
|
|
281
|
-
const res = await (0, api_1.post)('/api/firewall-rules-folder/sync', {});
|
|
282
|
-
if (!res.mounted) {
|
|
283
|
-
console.log((0, utils_1.dim)('No firewall rules folder mounted. Set one with `huddle firewall folder set <path>` and run `huddle restart`.'));
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
if (res.written === 0 && res.errors.length > 0) {
|
|
287
|
-
console.error((0, utils_1.red)('[!] Could not write to the folder — it may still be mounted read-only. Run `huddle restart` to remount it writable.'));
|
|
288
|
-
for (const e of res.errors)
|
|
289
|
-
console.error((0, utils_1.red)(` [!] ${e.file}: ${e.message}`));
|
|
290
|
-
return;
|
|
291
|
-
}
|
|
292
|
-
console.log((0, utils_1.green)(`[OK] Synced: ${res.written} group(s) written, ${res.pruned} stale file(s) removed, ${res.errors.length} error(s)`));
|
|
293
|
-
for (const e of res.errors)
|
|
294
|
-
console.error((0, utils_1.red)(` [!] ${e.file}: ${e.message}`));
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
throw new Error(`Unknown folder action: ${action}. Use show | set | reload | sync.`);
|
|
298
|
-
}
|
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.
|
|
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
|
|
23
|
-
*
|
|
24
|
-
* base images the CLI just pulled.
|
|
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
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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'
|
|
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', '
|
|
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,22 +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
|
-
huddle firewall folder sync Write the portal's groups back to the folder
|
|
116
105
|
huddle experiment use <nr> Activate the experimental build of issue/PR <nr>
|
|
117
106
|
and run init
|
|
118
107
|
huddle experiment reset Back to the stable release
|
|
119
108
|
huddle experiment status Show the active channel and CLI version
|
|
120
109
|
|
|
121
110
|
Init options:
|
|
122
|
-
--runtime <docker|podman>
|
|
111
|
+
--runtime <docker|podman|wslc> Container runtime (default: auto-detected;
|
|
123
112
|
also via the HUDDLE_RUNTIME env var)
|
|
124
113
|
--experiment <nr> Use the experimental build of issue/PR <nr>
|
|
125
114
|
(same as "huddle experiment use <nr>")
|
|
@@ -143,8 +132,6 @@ Migrate options:
|
|
|
143
132
|
Firewall options:
|
|
144
133
|
-i, --interactive Interactively approve/deny (list)
|
|
145
134
|
--container <name> Filter by (list) / scope to (add) a container
|
|
146
|
-
(or __global__). On import: remap all rules
|
|
147
|
-
to this scope
|
|
148
135
|
--status <requested|allow|deny> Filter by status (default: requested)
|
|
149
136
|
|
|
150
137
|
Firewall add options:
|
|
@@ -153,11 +140,6 @@ Firewall add options:
|
|
|
153
140
|
(e.g. /_packaging/*/nuget/v3/*)
|
|
154
141
|
--deny Create a block rule (default: allow)
|
|
155
142
|
|
|
156
|
-
Firewall export/import options:
|
|
157
|
-
--out <file> Write export to a file (default: stdout)
|
|
158
|
-
--replace Import in replace mode: wipe the target
|
|
159
|
-
scope first (default: merge/upsert)
|
|
160
|
-
|
|
161
143
|
Global options:
|
|
162
144
|
--url <url> Huddle URL (default: http://localhost:3000)
|
|
163
145
|
Or via the HUDDLE_URL env var
|
|
@@ -220,15 +202,6 @@ async function main() {
|
|
|
220
202
|
await (0, init_1.runInit)(initOpts, (0, images_1.resolveImages)());
|
|
221
203
|
return;
|
|
222
204
|
}
|
|
223
|
-
if (cmd === 'restart') {
|
|
224
|
-
// Stop + recreate the gateway (runInit does `rm -f` first) so changed team
|
|
225
|
-
// folders get mounted. The portal writes the paths straight into the mounted
|
|
226
|
-
// ~/.huddle/config.json, so runInit already reads the latest values here.
|
|
227
|
-
const initOpts = { runtime: flagString(flags, 'runtime') };
|
|
228
|
-
(0, experiment_1.ensureCliForChannel)(process.argv.slice(2));
|
|
229
|
-
await (0, init_1.runInit)(initOpts, (0, images_1.resolveImages)());
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
205
|
if (cmd === 'experiment') {
|
|
233
206
|
const subCmd = sub ?? 'status';
|
|
234
207
|
if (subCmd === 'use') {
|
|
@@ -270,36 +243,6 @@ async function main() {
|
|
|
270
243
|
container: flagString(flags, 'container'),
|
|
271
244
|
});
|
|
272
245
|
}
|
|
273
|
-
else if (subCmd === 'export') {
|
|
274
|
-
await (0, firewall_1.runFirewallExport)({
|
|
275
|
-
container: flagString(flags, 'container'),
|
|
276
|
-
out: flagString(flags, 'out'),
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
else if (subCmd === 'import') {
|
|
280
|
-
const file = positional[2];
|
|
281
|
-
if (!file) {
|
|
282
|
-
console.error('Usage: huddle firewall import <file> [--replace] [--container <id>]');
|
|
283
|
-
process.exit(1);
|
|
284
|
-
}
|
|
285
|
-
await (0, firewall_1.runFirewallImport)({
|
|
286
|
-
file,
|
|
287
|
-
replace: flagBool(flags, 'replace'),
|
|
288
|
-
container: flagString(flags, 'container'),
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
else if (subCmd === 'group' || subCmd === 'groups') {
|
|
292
|
-
await (0, firewall_1.runFirewallGroup)({
|
|
293
|
-
action: positional[2],
|
|
294
|
-
arg: positional[3],
|
|
295
|
-
out: flagString(flags, 'out'),
|
|
296
|
-
replace: flagBool(flags, 'replace'),
|
|
297
|
-
container: flagString(flags, 'container'),
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
else if (subCmd === 'folder') {
|
|
301
|
-
await (0, firewall_1.runFirewallFolder)({ action: positional[2], path: positional[3] });
|
|
302
|
-
}
|
|
303
246
|
else {
|
|
304
247
|
console.error(`Unknown firewall subcommand: ${subCmd}`);
|
|
305
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
|
-
|
|
33
|
-
|
|
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
|
|
35
|
+
function runSilent(cmd) {
|
|
40
36
|
try {
|
|
41
|
-
(0, child_process_1.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
89
|
+
runSilent(`${rt} volume inspect ${VOLUME}`) || run(`${rt} volume create ${VOLUME}`);
|
|
94
90
|
console.log((0, utils_1.dim)(`Network: ${exports.INTERNAL_NET}`));
|
|
95
|
-
|
|
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
|
-
|
|
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 (!
|
|
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.
|
|
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,43 +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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
// Build the container command as an argv array (runArgs → execFileSync, no
|
|
164
|
-
// shell). The folder paths below come from config and are operator-writable via
|
|
165
|
-
// the settings API, so they must never reach a shell as a string.
|
|
166
|
-
const dockerArgs = ['run', '-d', '--name', CONTAINER, '--network', runtime.defaultNetwork];
|
|
167
|
-
for (const opt of runtime.securityOpts)
|
|
168
|
-
dockerArgs.push('--security-opt', opt);
|
|
169
|
-
dockerArgs.push('-e', `HUDDLE_RUNTIME=${runtime.name}`);
|
|
170
|
-
dockerArgs.push('-e', `HUDDLE_OPERATOR_TOKEN=${operatorToken}`);
|
|
171
|
-
dockerArgs.push('-p', `${HOST_PORT}:3000`);
|
|
172
|
-
dockerArgs.push('-v', `${VOLUME}:/data`);
|
|
173
|
-
dockerArgs.push('-v', `${runtime.socketPath}:/var/run/docker.sock`);
|
|
174
|
-
dockerArgs.push('-v', `${hostTmpSockets}:/tmp/dc-sockets`);
|
|
175
|
-
dockerArgs.push('-v', `${config_1.CONFIG_DIR}:/huddle-home:rw`, '-e', 'HUDDLE_HOME_DIR=/huddle-home');
|
|
176
|
-
if (fwFolder)
|
|
177
|
-
dockerArgs.push('-v', `${fwFolder}:/firewall-rules:rw`);
|
|
178
|
-
if (extFolder)
|
|
179
|
-
dockerArgs.push('-v', `${extFolder}:/extensions:ro`);
|
|
180
|
-
dockerArgs.push(...(0, images_1.gatewayEnvArgs)(images));
|
|
181
|
-
dockerArgs.push(IMAGE);
|
|
182
|
-
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}`);
|
|
183
160
|
// Attaching devcontainer-net after the container has started pollutes
|
|
184
161
|
// resolv.conf on Podman with that network's internal aardvark-DNS; the
|
|
185
162
|
// gateway cleans that up itself (see dns-egress.ts / the startup sanitize in
|
|
186
163
|
// index.ts).
|
|
187
|
-
|
|
164
|
+
runSilent(`${rt} network connect ${exports.INTERNAL_NET} ${CONTAINER}`);
|
|
188
165
|
console.log();
|
|
189
166
|
console.log((0, utils_1.green)(`[OK] Huddle is running at http://localhost:${HOST_PORT}`));
|
|
190
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
|
-
|
|
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
|
|
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
|
|
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
|
|
152
|
-
// Podman shim), then at
|
|
153
|
-
// is one,
|
|
154
|
-
|
|
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
|
|
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