@infosupport/huddle-cli 0.0.0-experiment-66.37.1 → 0.0.0-experiment-66.39.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/dist/config.js CHANGED
@@ -3,6 +3,7 @@ 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;
6
7
  exports.configPath = configPath;
7
8
  exports.readConfig = readConfig;
8
9
  exports.writeConfig = writeConfig;
@@ -12,8 +13,8 @@ exports.imageTag = imageTag;
12
13
  const fs_1 = __importDefault(require("fs"));
13
14
  const os_1 = __importDefault(require("os"));
14
15
  const path_1 = __importDefault(require("path"));
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');
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');
17
18
  function configPath() {
18
19
  return CONFIG_PATH;
19
20
  }
@@ -26,7 +27,7 @@ function readConfig() {
26
27
  }
27
28
  }
28
29
  function writeConfig(config) {
29
- fs_1.default.mkdirSync(CONFIG_DIR, { recursive: true });
30
+ fs_1.default.mkdirSync(exports.CONFIG_DIR, { recursive: true });
30
31
  fs_1.default.writeFileSync(CONFIG_PATH, `${JSON.stringify(config, null, 2)}\n`);
31
32
  }
32
33
  /** Operator-token voor API-auth: env wint, anders uit de config. */
@@ -33,9 +33,14 @@ function parseIssueNumber(raw) {
33
33
  * itself (install + restart) is done by self-update.ts. On a switch this
34
34
  * function does not return (process.exit with the exit code of the new process).
35
35
  */
36
- function ensureCliForChannel(relaunchArgs) {
36
+ function ensureCliForChannel(relaunchArgs, opts = {}) {
37
37
  const wanted = (0, config_1.activeExperiment)();
38
- if (wanted === cliExperiment())
38
+ // Normally we only switch when the experiment NUMBER differs — otherwise every
39
+ // command would reinstall. But `huddle experiment use <n>` must pick up a newer
40
+ // build of the SAME experiment (the CLI version is baked in, so the number
41
+ // alone can't tell 66.34 from 66.35): force a reinstall of the channel tag,
42
+ // which npm resolves to the latest build for that experiment.
43
+ if (!opts.force && wanted === cliExperiment())
39
44
  return;
40
45
  const spec = wanted !== undefined ? `${self_update_1.CLI_PACKAGE}@experiment-${wanted}` : `${self_update_1.CLI_PACKAGE}@latest`;
41
46
  try {
@@ -56,7 +61,9 @@ async function runExperimentUse(issue, initOpts = {}) {
56
61
  console.log((0, utils_1.green)(`Experiment ${issue} activated`) + (0, utils_1.dim)(` (${(0, config_1.configPath)()})`));
57
62
  const relaunchArgs = ['init', ...(initOpts.runtime ? ['--runtime', initOpts.runtime] : [])];
58
63
  try {
59
- ensureCliForChannel(relaunchArgs);
64
+ // Force: `use` always (re)installs the latest build of the target experiment,
65
+ // even when already on that experiment number, so a republished build lands.
66
+ ensureCliForChannel(relaunchArgs, { force: true });
60
67
  }
61
68
  catch (err) {
62
69
  // Activation failed → roll back the config so a subsequent `huddle init`
package/dist/firewall.js CHANGED
@@ -254,29 +254,29 @@ async function runFirewallGroup(opts) {
254
254
  async function runFirewallFolder(opts) {
255
255
  const action = opts.action ?? 'show';
256
256
  if (action === 'show') {
257
- const s = await (0, api_1.get)('/api/settings');
258
- console.log(s.firewallRulesFolder ? s.firewallRulesFolder : (0, utils_1.dim)('(no firewall rules folder configured)'));
257
+ // The CLI config is the source of truth for the path.
258
+ const folder = (0, config_1.readConfig)().firewallRulesFolder;
259
+ console.log(folder ? folder : (0, utils_1.dim)('(no firewall rules folder configured)'));
259
260
  return;
260
261
  }
261
262
  if (action === 'set') {
262
263
  const path = (opts.path ?? '').trim();
263
264
  if (!path)
264
265
  throw new Error('Usage: huddle firewall folder set <path>');
265
- await (0, api_1.post)('/api/settings', { firewallRulesFolder: path });
266
- // Persist on the host too, so `huddle init`/`restart` mounts the folder into
267
- // the gateway container (which otherwise cannot see host paths).
266
+ // Config-only: the gateway reads the folder at the fixed mount point the CLI
267
+ // binds it to; there is no DB setting. Persist here and mount on restart.
268
268
  (0, config_1.writeConfig)({ ...(0, config_1.readConfig)(), firewallRulesFolder: path });
269
269
  console.log((0, utils_1.green)(`[OK] Firewall rules folder set to ${(0, utils_1.cyan)(path)}`));
270
- console.log((0, utils_1.dim)(' Run `huddle restart` to mount it into the gateway, then it is re-read on start & reload.'));
270
+ console.log((0, utils_1.dim)(' Run `huddle restart` to mount it into the gateway; it is then read on start & reload.'));
271
271
  return;
272
272
  }
273
273
  if (action === 'reload') {
274
274
  const res = await (0, api_1.post)('/api/firewall-rules-folder/reload', {});
275
- if (!res.folder) {
276
- console.log((0, utils_1.dim)('No firewall rules folder configured. Use `huddle firewall folder set <path>`.'));
275
+ if (!res.mounted) {
276
+ console.log((0, utils_1.dim)('No firewall rules folder mounted. Set one with `huddle firewall folder set <path>` and run `huddle restart`.'));
277
277
  return;
278
278
  }
279
- console.log((0, utils_1.green)(`[OK] Reloaded ${res.folder}: ${res.groups} group(s), ${res.imported} rule(s), ${res.errors.length} error(s)`));
279
+ console.log((0, utils_1.green)(`[OK] Reloaded: ${res.groups} group(s), ${res.imported} rule(s), ${res.errors.length} error(s)`));
280
280
  for (const e of res.errors)
281
281
  console.error((0, utils_1.red)(` [!] ${e.file}: ${e.message}`));
282
282
  return;
package/dist/index.js CHANGED
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const api_1 = require("./api");
10
- const config_1 = require("./config");
11
10
  const start_1 = require("./start");
12
11
  const firewall_1 = require("./firewall");
13
12
  const init_1 = require("./init");
@@ -221,21 +220,10 @@ async function main() {
221
220
  return;
222
221
  }
223
222
  if (cmd === 'restart') {
224
- // Stop + recreate the gateway (runInit does `rm -f` first) so a changed
225
- // team firewall-rules folder gets mounted. Refresh the folder from the
226
- // running gateway's DB setting so a value set in the portal takes effect.
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.
227
226
  const initOpts = { runtime: flagString(flags, 'runtime') };
228
- try {
229
- const s = await (0, api_1.get)('/api/settings');
230
- const folder = (s.firewallRulesFolder ?? '').trim();
231
- const cfg = (0, config_1.readConfig)();
232
- if (folder !== (cfg.firewallRulesFolder ?? '')) {
233
- (0, config_1.writeConfig)({ ...cfg, firewallRulesFolder: folder || undefined });
234
- }
235
- }
236
- catch {
237
- // Gateway not reachable — fall back to the cached folder in the CLI config.
238
- }
239
227
  (0, experiment_1.ensureCliForChannel)(process.argv.slice(2));
240
228
  await (0, init_1.runInit)(initOpts, (0, images_1.resolveImages)());
241
229
  return;
package/dist/init.js CHANGED
@@ -145,15 +145,19 @@ async function runInit(opts, images) {
145
145
  // network (moby/moby#36174). Which source IP the gateway sees for forwarded
146
146
  // traffic no longer matters — the control plane authenticates with the
147
147
  // operator token instead of source-IP filtering.
148
- // Team-managed firewall-rules folder (#69): the gateway can only read folders
149
- // the CLI binds into its container, so mount the configured host folder at the
150
- // same path (so the path stored in the DB setting resolves identically inside
151
- // the gateway). Read-only — Huddle never writes back to the team's Git folder.
148
+ // Team-managed folders (#69). Bind the CLI config dir (~/.huddle) read-write so
149
+ // the gateway/portal read and write the folder paths there (config.json is the
150
+ // single source of truth), then bind each configured team folder to a FIXED
151
+ // path so the gateway reads it without knowing the host path. Read-only.
152
152
  const fwFolder = cfg.firewallRulesFolder?.trim();
153
- const fwMountFlag = fwFolder ? ` -v "${fwFolder}:${fwFolder}:ro"` : '';
154
- if (fwFolder) {
155
- console.log((0, utils_1.dim)(` Mounting firewall-rules folder: ${fwFolder}`));
156
- }
153
+ const extFolder = cfg.extensionsFolder?.trim();
154
+ const homeMountFlag = ` -v "${config_1.CONFIG_DIR}:/huddle-home:rw" -e HUDDLE_HOME_DIR=/huddle-home`;
155
+ const fwMountFlag = fwFolder ? ` -v "${fwFolder}:/firewall-rules:ro"` : '';
156
+ const extMountFlag = extFolder ? ` -v "${extFolder}:/extensions:ro"` : '';
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`));
157
161
  run(`${rt} run -d` +
158
162
  ` --name ${CONTAINER}` +
159
163
  ` --network ${runtime.defaultNetwork}` +
@@ -164,7 +168,9 @@ async function runInit(opts, images) {
164
168
  ` -v ${VOLUME}:/data` +
165
169
  ` -v ${runtime.socketPath}:/var/run/docker.sock` +
166
170
  ` -v "${hostTmpSockets}:/tmp/dc-sockets"` +
171
+ homeMountFlag +
167
172
  fwMountFlag +
173
+ extMountFlag +
168
174
  (0, images_1.gatewayEnvFlags)(images) +
169
175
  ` ${IMAGE}`);
170
176
  // Attaching devcontainer-net after the container has started pollutes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infosupport/huddle-cli",
3
- "version": "0.0.0-experiment-66.37.1",
3
+ "version": "0.0.0-experiment-66.39.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.",