@ebowwa/seedinstallation 0.4.0 → 0.4.2

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/bootstrap.js CHANGED
@@ -68,7 +68,8 @@ function buildSshPrefix(ctx) {
68
68
  return parts;
69
69
  }
70
70
  async function exec(args, opts) {
71
- const finalArgs = opts.context.type === "ssh" ? [...buildSshPrefix(opts.context), args.map(shellEscape).join(" ")] : args;
71
+ const ctx = opts.context ?? { type: "local" };
72
+ const finalArgs = ctx.type === "ssh" ? [...buildSshPrefix(ctx), args.map(shellEscape).join(" ")] : args;
72
73
  const proc = Bun.spawn(finalArgs, {
73
74
  stdout: "pipe",
74
75
  stderr: "pipe",
@@ -80,8 +81,9 @@ async function exec(args, opts) {
80
81
  return { stdout, stderr, exitCode, ok: exitCode === 0 };
81
82
  }
82
83
  async function execPipe(input, args, opts) {
83
- if (opts.context.type === "ssh") {
84
- const sshPrefix = buildSshPrefix(opts.context);
84
+ const ctx = opts.context ?? { type: "local" };
85
+ if (ctx.type === "ssh") {
86
+ const sshPrefix = buildSshPrefix(ctx);
85
87
  const remoteCmd = args.join(" ");
86
88
  const fullArgs = [...sshPrefix, remoteCmd];
87
89
  const proc2 = Bun.spawn(fullArgs, {
@@ -68,7 +68,8 @@ function buildSshPrefix(ctx) {
68
68
  return parts;
69
69
  }
70
70
  async function exec(args, opts) {
71
- const finalArgs = opts.context.type === "ssh" ? [...buildSshPrefix(opts.context), args.map(shellEscape).join(" ")] : args;
71
+ const ctx = opts.context ?? { type: "local" };
72
+ const finalArgs = ctx.type === "ssh" ? [...buildSshPrefix(ctx), args.map(shellEscape).join(" ")] : args;
72
73
  const proc = Bun.spawn(finalArgs, {
73
74
  stdout: "pipe",
74
75
  stderr: "pipe",
@@ -80,8 +81,9 @@ async function exec(args, opts) {
80
81
  return { stdout, stderr, exitCode, ok: exitCode === 0 };
81
82
  }
82
83
  async function execPipe(input, args, opts) {
83
- if (opts.context.type === "ssh") {
84
- const sshPrefix = buildSshPrefix(opts.context);
84
+ const ctx = opts.context ?? { type: "local" };
85
+ if (ctx.type === "ssh") {
86
+ const sshPrefix = buildSshPrefix(ctx);
85
87
  const remoteCmd = args.join(" ");
86
88
  const fullArgs = [...sshPrefix, remoteCmd];
87
89
  const proc2 = Bun.spawn(fullArgs, {
package/dist/index.js CHANGED
@@ -68,7 +68,8 @@ function buildSshPrefix(ctx) {
68
68
  return parts;
69
69
  }
70
70
  async function exec(args, opts) {
71
- const finalArgs = opts.context.type === "ssh" ? [...buildSshPrefix(opts.context), args.map(shellEscape).join(" ")] : args;
71
+ const ctx = opts.context ?? { type: "local" };
72
+ const finalArgs = ctx.type === "ssh" ? [...buildSshPrefix(ctx), args.map(shellEscape).join(" ")] : args;
72
73
  const proc = Bun.spawn(finalArgs, {
73
74
  stdout: "pipe",
74
75
  stderr: "pipe",
@@ -80,8 +81,9 @@ async function exec(args, opts) {
80
81
  return { stdout, stderr, exitCode, ok: exitCode === 0 };
81
82
  }
82
83
  async function execPipe(input, args, opts) {
83
- if (opts.context.type === "ssh") {
84
- const sshPrefix = buildSshPrefix(opts.context);
84
+ const ctx = opts.context ?? { type: "local" };
85
+ if (ctx.type === "ssh") {
86
+ const sshPrefix = buildSshPrefix(ctx);
85
87
  const remoteCmd = args.join(" ");
86
88
  const fullArgs = [...sshPrefix, remoteCmd];
87
89
  const proc2 = Bun.spawn(fullArgs, {
@@ -272,7 +274,6 @@ async function hasSystemd(opts) {
272
274
  const sudoOpts = opts ?? { context: { type: "local" } };
273
275
  const whichResult = await exec3(["which", "systemctl"], {
274
276
  ...sudoOpts,
275
- quiet: true,
276
277
  env: sudoOpts.env
277
278
  });
278
279
  if (!whichResult.ok || !whichResult.stdout.trim()) {
@@ -286,7 +287,6 @@ async function hasSystemd(opts) {
286
287
  }
287
288
  const runningResult = await exec3(["systemctl", "is-system-running"], {
288
289
  ...sudoOpts,
289
- quiet: true,
290
290
  env: sudoOpts.env
291
291
  });
292
292
  if (runningResult.ok && runningResult.stdout.trim() !== "") {
@@ -299,7 +299,6 @@ async function hasSystemd(opts) {
299
299
  }
300
300
  const dirResult = await exec3(["test", "-d", "/run/systemd/system"], {
301
301
  ...sudoOpts,
302
- quiet: true,
303
302
  env: sudoOpts.env
304
303
  });
305
304
  if (dirResult.ok) {
@@ -402,7 +401,7 @@ function generateServiceUnit(name, opts) {
402
401
  lines.push(`SystemCallFilter=${opts.systemCallFilter.join(" ")}`);
403
402
  if (opts.restrictNamespaces === true)
404
403
  lines.push("RestrictNamespaces=true");
405
- else if (opts.restrictNamespaces?.length)
404
+ else if (Array.isArray(opts.restrictNamespaces) && opts.restrictNamespaces.length > 0)
406
405
  lines.push(`RestrictNamespaces=${opts.restrictNamespaces.join(" ")}`);
407
406
  if (opts.personality)
408
407
  lines.push(`Personality=${opts.personality}`);
@@ -467,7 +466,7 @@ async function getServiceStatus(name, opts) {
467
466
  quiet: true
468
467
  });
469
468
  if (!result.ok) {
470
- return { loaded: false, active: false, subState: "unknown", mainPid: 0 };
469
+ return { loaded: false, active: false, subState: "unknown", mainPid: 0, description: "" };
471
470
  }
472
471
  const parse = (key) => {
473
472
  const match = result.stdout.match(new RegExp(`^${key}=(.+)$`, "m"));
package/dist/runtime.js CHANGED
@@ -68,7 +68,8 @@ function buildSshPrefix(ctx) {
68
68
  return parts;
69
69
  }
70
70
  async function exec(args, opts) {
71
- const finalArgs = opts.context.type === "ssh" ? [...buildSshPrefix(opts.context), args.map(shellEscape).join(" ")] : args;
71
+ const ctx = opts.context ?? { type: "local" };
72
+ const finalArgs = ctx.type === "ssh" ? [...buildSshPrefix(ctx), args.map(shellEscape).join(" ")] : args;
72
73
  const proc = Bun.spawn(finalArgs, {
73
74
  stdout: "pipe",
74
75
  stderr: "pipe",
@@ -80,8 +81,9 @@ async function exec(args, opts) {
80
81
  return { stdout, stderr, exitCode, ok: exitCode === 0 };
81
82
  }
82
83
  async function execPipe(input, args, opts) {
83
- if (opts.context.type === "ssh") {
84
- const sshPrefix = buildSshPrefix(opts.context);
84
+ const ctx = opts.context ?? { type: "local" };
85
+ if (ctx.type === "ssh") {
86
+ const sshPrefix = buildSshPrefix(ctx);
85
87
  const remoteCmd = args.join(" ");
86
88
  const fullArgs = [...sshPrefix, remoteCmd];
87
89
  const proc2 = Bun.spawn(fullArgs, {
package/dist/sudo.js CHANGED
@@ -68,7 +68,8 @@ function buildSshPrefix(ctx) {
68
68
  return parts;
69
69
  }
70
70
  async function exec(args, opts) {
71
- const finalArgs = opts.context.type === "ssh" ? [...buildSshPrefix(opts.context), args.map(shellEscape).join(" ")] : args;
71
+ const ctx = opts.context ?? { type: "local" };
72
+ const finalArgs = ctx.type === "ssh" ? [...buildSshPrefix(ctx), args.map(shellEscape).join(" ")] : args;
72
73
  const proc = Bun.spawn(finalArgs, {
73
74
  stdout: "pipe",
74
75
  stderr: "pipe",
@@ -80,8 +81,9 @@ async function exec(args, opts) {
80
81
  return { stdout, stderr, exitCode, ok: exitCode === 0 };
81
82
  }
82
83
  async function execPipe(input, args, opts) {
83
- if (opts.context.type === "ssh") {
84
- const sshPrefix = buildSshPrefix(opts.context);
84
+ const ctx = opts.context ?? { type: "local" };
85
+ if (ctx.type === "ssh") {
86
+ const sshPrefix = buildSshPrefix(ctx);
85
87
  const remoteCmd = args.join(" ");
86
88
  const fullArgs = [...sshPrefix, remoteCmd];
87
89
  const proc2 = Bun.spawn(fullArgs, {
package/dist/systemd.js CHANGED
@@ -68,7 +68,8 @@ function buildSshPrefix(ctx) {
68
68
  return parts;
69
69
  }
70
70
  async function exec(args, opts) {
71
- const finalArgs = opts.context.type === "ssh" ? [...buildSshPrefix(opts.context), args.map(shellEscape).join(" ")] : args;
71
+ const ctx = opts.context ?? { type: "local" };
72
+ const finalArgs = ctx.type === "ssh" ? [...buildSshPrefix(ctx), args.map(shellEscape).join(" ")] : args;
72
73
  const proc = Bun.spawn(finalArgs, {
73
74
  stdout: "pipe",
74
75
  stderr: "pipe",
@@ -80,8 +81,9 @@ async function exec(args, opts) {
80
81
  return { stdout, stderr, exitCode, ok: exitCode === 0 };
81
82
  }
82
83
  async function execPipe(input, args, opts) {
83
- if (opts.context.type === "ssh") {
84
- const sshPrefix = buildSshPrefix(opts.context);
84
+ const ctx = opts.context ?? { type: "local" };
85
+ if (ctx.type === "ssh") {
86
+ const sshPrefix = buildSshPrefix(ctx);
85
87
  const remoteCmd = args.join(" ");
86
88
  const fullArgs = [...sshPrefix, remoteCmd];
87
89
  const proc2 = Bun.spawn(fullArgs, {
@@ -142,7 +144,6 @@ async function hasSystemd(opts) {
142
144
  const sudoOpts = opts ?? { context: { type: "local" } };
143
145
  const whichResult = await exec2(["which", "systemctl"], {
144
146
  ...sudoOpts,
145
- quiet: true,
146
147
  env: sudoOpts.env
147
148
  });
148
149
  if (!whichResult.ok || !whichResult.stdout.trim()) {
@@ -156,7 +157,6 @@ async function hasSystemd(opts) {
156
157
  }
157
158
  const runningResult = await exec2(["systemctl", "is-system-running"], {
158
159
  ...sudoOpts,
159
- quiet: true,
160
160
  env: sudoOpts.env
161
161
  });
162
162
  if (runningResult.ok && runningResult.stdout.trim() !== "") {
@@ -169,7 +169,6 @@ async function hasSystemd(opts) {
169
169
  }
170
170
  const dirResult = await exec2(["test", "-d", "/run/systemd/system"], {
171
171
  ...sudoOpts,
172
- quiet: true,
173
172
  env: sudoOpts.env
174
173
  });
175
174
  if (dirResult.ok) {
@@ -272,7 +271,7 @@ function generateServiceUnit(name, opts) {
272
271
  lines.push(`SystemCallFilter=${opts.systemCallFilter.join(" ")}`);
273
272
  if (opts.restrictNamespaces === true)
274
273
  lines.push("RestrictNamespaces=true");
275
- else if (opts.restrictNamespaces?.length)
274
+ else if (Array.isArray(opts.restrictNamespaces) && opts.restrictNamespaces.length > 0)
276
275
  lines.push(`RestrictNamespaces=${opts.restrictNamespaces.join(" ")}`);
277
276
  if (opts.personality)
278
277
  lines.push(`Personality=${opts.personality}`);
@@ -337,7 +336,7 @@ async function getServiceStatus(name, opts) {
337
336
  quiet: true
338
337
  });
339
338
  if (!result.ok) {
340
- return { loaded: false, active: false, subState: "unknown", mainPid: 0 };
339
+ return { loaded: false, active: false, subState: "unknown", mainPid: 0, description: "" };
341
340
  }
342
341
  const parse = (key) => {
343
342
  const match = result.stdout.match(new RegExp(`^${key}=(.+)$`, "m"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ebowwa/seedinstallation",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Composable server installation utilities for edge deployment automation",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -65,7 +65,7 @@
65
65
  },
66
66
  "homepage": "https://github.com/ebowwa/codespaces/tree/main/packages/src/installations",
67
67
  "devDependencies": {
68
- "@types/bun": "latest",
68
+ "@types/bun": "^1.3.8",
69
69
  "@types/node": "^22.10.2",
70
70
  "typescript": "^5.7.2"
71
71
  },