@infosupport/huddle-cli 0.0.0-experiment-66.37.1 → 0.0.0-experiment-66.38.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. */
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
@@ -149,11 +149,20 @@ async function runInit(opts, images) {
149
149
  // the CLI binds into its container, so mount the configured host folder at the
150
150
  // same path (so the path stored in the DB setting resolves identically inside
151
151
  // the gateway). Read-only — Huddle never writes back to the team's Git folder.
152
+ // Bind the CLI config dir (~/.huddle) read-write so the gateway/portal can
153
+ // read and write the team-folder paths there (config.json is the single
154
+ // source of truth). Then bind each configured team folder to a FIXED path so
155
+ // the gateway reads it without ever knowing the host path. Read-only — Huddle
156
+ // never writes back to the team's Git folders.
152
157
  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
- }
158
+ const extFolder = cfg.extensionsFolder?.trim();
159
+ const homeMountFlag = ` -v "${config_1.CONFIG_DIR}:/huddle-home:rw" -e HUDDLE_HOME_DIR=/huddle-home`;
160
+ const fwMountFlag = fwFolder ? ` -v "${fwFolder}:/firewall-rules:ro"` : '';
161
+ const extMountFlag = extFolder ? ` -v "${extFolder}:/extensions:ro"` : '';
162
+ if (fwFolder)
163
+ console.log((0, utils_1.dim)(` Mounting firewall-rules folder: ${fwFolder} -> /firewall-rules`));
164
+ if (extFolder)
165
+ console.log((0, utils_1.dim)(` Mounting extensions folder: ${extFolder} -> /extensions`));
157
166
  run(`${rt} run -d` +
158
167
  ` --name ${CONTAINER}` +
159
168
  ` --network ${runtime.defaultNetwork}` +
@@ -164,7 +173,9 @@ async function runInit(opts, images) {
164
173
  ` -v ${VOLUME}:/data` +
165
174
  ` -v ${runtime.socketPath}:/var/run/docker.sock` +
166
175
  ` -v "${hostTmpSockets}:/tmp/dc-sockets"` +
176
+ homeMountFlag +
167
177
  fwMountFlag +
178
+ extMountFlag +
168
179
  (0, images_1.gatewayEnvFlags)(images) +
169
180
  ` ${IMAGE}`);
170
181
  // 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.38.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.",