@infosupport/huddle-cli 0.0.0-experiment-147.91.1 → 0.0.0-experiment-147.92.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/extension.js CHANGED
@@ -9,6 +9,7 @@ exports.collectExtensionFiles = collectExtensionFiles;
9
9
  exports.planInstall = planInstall;
10
10
  exports.asExtensionList = asExtensionList;
11
11
  exports.runExtensionList = runExtensionList;
12
+ exports.restartRuntime = restartRuntime;
12
13
  exports.runExtensionInstall = runExtensionInstall;
13
14
  exports.runExtensionRemove = runExtensionRemove;
14
15
  const fs_1 = __importDefault(require("fs"));
@@ -106,6 +107,37 @@ async function runExtensionList() {
106
107
  }
107
108
  (0, utils_1.printTable)(['ID', 'NAME', 'VERSION', 'ENABLED'], installed.map((e) => [e.id, e.name, e.version ?? '-', e.enabled === false ? 'no' : 'yes']));
108
109
  }
110
+ function hasHuddleContainer(rt) {
111
+ try {
112
+ (0, child_process_1.execFileSync)(rt, ['container', 'inspect', init_1.CONTAINER], { stdio: 'ignore' });
113
+ return true;
114
+ }
115
+ catch {
116
+ return false;
117
+ }
118
+ }
119
+ /**
120
+ * The engine whose huddle container gets restarted after an install. An explicit
121
+ * --runtime / HUDDLE_RUNTIME wins; otherwise the engine that actually runs the
122
+ * container. Plain auto-detection prefers Docker, so with Podman owning Huddle
123
+ * it would restart an unrelated `huddle` container (or none) and leave the new
124
+ * extension inactive.
125
+ */
126
+ function restartRuntime(explicit, hasContainer = hasHuddleContainer, detect = () => (0, runtime_1.resolveRuntime)().name) {
127
+ if (explicit ?? process.env.HUDDLE_RUNTIME)
128
+ return (0, runtime_1.resolveRuntime)(explicit).name;
129
+ const owners = ['docker', 'podman'].filter((rt) => hasContainer(rt));
130
+ if (owners.length === 1)
131
+ return owners[0];
132
+ if (owners.length === 0) {
133
+ throw new Error(`No ${init_1.CONTAINER} container found under docker or podman. Run huddle init first.`);
134
+ }
135
+ // Both commands see a huddle container: either `docker` is a Podman shim
136
+ // (one engine, detection reports podman) or two engines each run one.
137
+ if (detect() === 'podman')
138
+ return 'podman';
139
+ throw new Error(`Both docker and podman run a ${init_1.CONTAINER} container; pick one with --runtime <docker|podman>.`);
140
+ }
109
141
  async function runExtensionInstall(dir, opts) {
110
142
  const { manifest, entries } = collectExtensionFiles(dir);
111
143
  const plan = planInstall(manifest, asExtensionList(await (0, api_1.get)('/api/extensions')), opts.force);
@@ -120,7 +152,7 @@ async function runExtensionInstall(dir, opts) {
120
152
  console.log((0, utils_1.yellow)('The gateway keeps running the old code until it restarts. Re-run with --restart, or restart the huddle container.'));
121
153
  return;
122
154
  }
123
- const rt = (0, runtime_1.resolveRuntime)().name;
155
+ const rt = restartRuntime(opts.runtime);
124
156
  console.log((0, utils_1.dim)(`Restarting the gateway process (${rt} restart ${init_1.CONTAINER}); the container itself is kept.`));
125
157
  (0, child_process_1.execFileSync)(rt, ['restart', init_1.CONTAINER], { stdio: 'ignore' });
126
158
  console.log((0, utils_1.green)('[OK] Gateway restarted with the new extension code.'));
package/dist/index.js CHANGED
@@ -147,7 +147,8 @@ Usage:
147
147
  huddle ext list Alias for extension list
148
148
  huddle extension install <dir> Install or update the extension in a folder
149
149
  (--force replaces another extension with the
150
- same id, --restart reloads the gateway process)
150
+ same id, --restart reloads the gateway process
151
+ on the engine that runs Huddle, or --runtime)
151
152
  huddle extension remove <id> Remove an installed extension
152
153
  huddle experiment use <nr> Activate the experimental build of issue/PR <nr>
153
154
  and run init
@@ -367,10 +368,14 @@ async function main() {
367
368
  else if (subCmd === 'install') {
368
369
  const dir = positional[2];
369
370
  if (!dir) {
370
- console.error('Usage: huddle extension install <dir> [--force] [--restart]');
371
+ console.error('Usage: huddle extension install <dir> [--force] [--restart] [--runtime <docker|podman>]');
371
372
  process.exit(1);
372
373
  }
373
- await (0, extension_1.runExtensionInstall)(dir, { force: flagBool(flags, 'force'), restart: flagBool(flags, 'restart') });
374
+ await (0, extension_1.runExtensionInstall)(dir, {
375
+ force: flagBool(flags, 'force'),
376
+ restart: flagBool(flags, 'restart'),
377
+ runtime: flagString(flags, 'runtime'),
378
+ });
374
379
  }
375
380
  else if (subCmd === 'remove' || subCmd === 'rm') {
376
381
  const id = positional[2];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infosupport/huddle-cli",
3
- "version": "0.0.0-experiment-147.91.1",
3
+ "version": "0.0.0-experiment-147.92.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.",