@infosupport/huddle-cli 0.0.0-experiment-147.88.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/config.js +5 -2
- package/dist/extension.js +33 -1
- package/dist/index.js +8 -3
- package/package.json +1 -1
package/dist/config.js
CHANGED
|
@@ -139,7 +139,10 @@ let tmpSeq = 0;
|
|
|
139
139
|
* config.
|
|
140
140
|
*/
|
|
141
141
|
function updateConfig(patch) {
|
|
142
|
-
|
|
142
|
+
// The config holds the operator token: owner-only. chmod as well, because
|
|
143
|
+
// mkdir's mode does not tighten a directory created by an older version.
|
|
144
|
+
fs_1.default.mkdirSync(exports.CONFIG_DIR, { recursive: true, mode: 0o700 });
|
|
145
|
+
fs_1.default.chmodSync(exports.CONFIG_DIR, 0o700);
|
|
143
146
|
const token = acquireLock();
|
|
144
147
|
if (token === null) {
|
|
145
148
|
throw new Error(`Could not lock ${CONFIG_PATH} within ${LOCK_WAIT_MS}ms — another Huddle process ` +
|
|
@@ -153,7 +156,7 @@ function updateConfig(patch) {
|
|
|
153
156
|
if (v === undefined)
|
|
154
157
|
delete next[k];
|
|
155
158
|
}
|
|
156
|
-
fs_1.default.writeFileSync(tmp, `${JSON.stringify(next, null, 2)}\n
|
|
159
|
+
fs_1.default.writeFileSync(tmp, `${JSON.stringify(next, null, 2)}\n`, { mode: 0o600 });
|
|
157
160
|
fs_1.default.renameSync(tmp, CONFIG_PATH);
|
|
158
161
|
return next;
|
|
159
162
|
}
|
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 = (
|
|
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, {
|
|
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