@infosupport/huddle-cli 0.0.0-experiment-108.77.1 → 0.0.0-experiment-108.79.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.
Files changed (2) hide show
  1. package/dist/firewall.js +20 -0
  2. package/package.json +1 -1
package/dist/firewall.js CHANGED
@@ -177,9 +177,29 @@ function readJsonFile(file) {
177
177
  throw new Error(`${file} is not valid JSON`);
178
178
  }
179
179
  }
180
+ // The name of the group a document describes, or null when it is a plain rules
181
+ // export. A group envelope carries it under `group`, or at the top level in the
182
+ // documented bare form.
183
+ function groupNameOf(doc) {
184
+ const meta = (doc['group'] && typeof doc['group'] === 'object' && !Array.isArray(doc['group']) ? doc['group'] : doc);
185
+ const name = typeof meta['name'] === 'string' ? meta['name'].trim() : '';
186
+ return name || null;
187
+ }
180
188
  async function runFirewallImport(opts) {
181
189
  const doc = readJsonFile(opts.file);
182
190
  const mode = opts.replace ? 'replace' : 'merge';
191
+ // A group envelope handed to the flat importer used to import its rules and
192
+ // silently drop the group (#98). Send it where it belongs instead — unless
193
+ // --container asks for a scope remap, which only the flat importer does.
194
+ const groupName = groupNameOf(doc);
195
+ if (groupName && !opts.container) {
196
+ console.error((0, utils_1.dim)(`[i] ${opts.file} is the group "${groupName}" — importing it as a group.`));
197
+ await runFirewallGroup({ action: 'import', arg: opts.file, replace: opts.replace });
198
+ return;
199
+ }
200
+ if (groupName) {
201
+ console.error((0, utils_1.dim)(`[i] ${opts.file} is the group "${groupName}"; --container imports its rules into that scope without the group.`));
202
+ }
183
203
  const qs = new URLSearchParams();
184
204
  if (opts.container)
185
205
  qs.set('container', opts.container);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infosupport/huddle-cli",
3
- "version": "0.0.0-experiment-108.77.1",
3
+ "version": "0.0.0-experiment-108.79.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.",