flightdeck 0.2.74 → 0.2.76

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.
@@ -193,8 +193,7 @@ var FlightDeck = class {
193
193
  env: import.meta.env
194
194
  });
195
195
  const serviceLogger = this.serviceLoggers[serviceName];
196
- const service = this.services[serviceName] = new ChildSocket(serviceProcess, `${this.options.packageName}::${serviceName}`, serviceLogger);
197
- serviceLogger.processCode = service.process.pid ?? -1;
196
+ serviceLogger.processCode = (this.services[serviceName] = new ChildSocket(serviceProcess, `${this.options.packageName}::${serviceName}`, serviceLogger)).proc.pid ?? -1;
198
197
  this.services[serviceName].onAny((...messages) => {
199
198
  serviceLogger.info(`💬`, ...messages);
200
199
  });
@@ -209,7 +208,7 @@ var FlightDeck = class {
209
208
  if (this.dead.done) this.dead = new Future(() => {});
210
209
  this.dead.use(Promise.all(this.servicesDead));
211
210
  });
212
- this.services[serviceName].process.once(`close`, (exitCode) => {
211
+ this.services[serviceName].proc.once(`close`, (exitCode) => {
213
212
  this.logger.info(`Auto-respawn saw "${serviceName}" exit with code ${exitCode}`);
214
213
  this.services[serviceName] = null;
215
214
  if (!this.autoRespawnDeadServices) {
@@ -218,8 +217,7 @@ var FlightDeck = class {
218
217
  }
219
218
  const updatePhase = this.storage.getItem(`updatePhase`);
220
219
  this.logger.info(`> storage("updatePhase") >`, updatePhase);
221
- const updatesAreReady = updatePhase === `confirmed`;
222
- if (updatesAreReady) {
220
+ if (updatePhase === `confirmed`) {
223
221
  this.serviceLoggers[serviceName].info(`Updating before startup...`);
224
222
  this.restartTimes = [];
225
223
  this.installPackage();
@@ -273,7 +271,7 @@ var FlightDeck = class {
273
271
  this.logger.info(`Stopping service "${serviceName}"...`);
274
272
  this.servicesDead[this.serviceIdx[serviceName]].use(new Promise((pass) => {
275
273
  service.emit(`timeToStop`);
276
- service.process.once(`close`, (exitCode) => {
274
+ service.proc.once(`close`, (exitCode) => {
277
275
  this.logger.info(`Stopped service "${serviceName}"; exited with code ${exitCode}`);
278
276
  this.services[serviceName] = null;
279
277
  pass();
@@ -404,4 +402,4 @@ var FlightDeckLogger = class {
404
402
 
405
403
  //#endregion
406
404
  export { FLIGHTDECK_ERROR, FLIGHTDECK_INFO, FLIGHTDECK_LNAV_FORMAT, FLIGHTDECK_SETUP_PHASES, FLIGHTDECK_UPDATE_PHASES, FLIGHTDECK_WARN, FlightDeck, FlightDeckLogger, flightDeckLogSchema, isVersionNumber };
407
- //# sourceMappingURL=flightdeck.lib-B3x4c_io.js.map
405
+ //# sourceMappingURL=flightdeck.lib-9O00rJ2l.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flightdeck.lib-9O00rJ2l.js","names":["data: Uint8Array[]","log: FlightDeckLog"],"sources":["../src/flightdeck.env.ts","../src/flightdeck.lib.ts"],"sourcesContent":["import { createEnv } from \"@t3-oss/env-core\"\nimport { z } from \"zod/v4\"\n\nexport const env = createEnv({\n\tserver: { FLIGHTDECK_SECRET: z.string().optional() },\n\tclientPrefix: `NEVER`,\n\tclient: {},\n\truntimeEnv: import.meta.env as Record<string, string>,\n\temptyStringAsUndefined: true,\n})\n","/* eslint-disable @typescript-eslint/only-throw-error */\nimport type { ChildProcessWithoutNullStreams } from \"node:child_process\"\nimport { execSync, spawn } from \"node:child_process\"\nimport { createServer } from \"node:http\"\nimport { homedir } from \"node:os\"\nimport { resolve } from \"node:path\"\nimport { inspect } from \"node:util\"\n\nimport { Future } from \"atom.io/internal\"\nimport { discoverType } from \"atom.io/introspection\"\nimport { fromEntries, toEntries } from \"atom.io/json\"\nimport { ChildSocket } from \"atom.io/realtime-server\"\nimport { CronJob } from \"cron\"\nimport { FilesystemStorage } from \"safedeposit\"\nimport { z } from \"zod/v4\"\n\nimport type { LnavFormat } from \"../gen/lnav-format-schema.gen\"\nimport { env } from \"./flightdeck.env\"\n\nexport const FLIGHTDECK_SETUP_PHASES = [`downloaded`, `installed`] as const\n\nexport type FlightDeckSetupPhase = (typeof FLIGHTDECK_SETUP_PHASES)[number]\n\nexport const FLIGHTDECK_UPDATE_PHASES = [`notified`, `confirmed`] as const\n\nexport type FlightDeckUpdatePhase = (typeof FLIGHTDECK_UPDATE_PHASES)[number]\n\nexport function isVersionNumber(version: string): boolean {\n\treturn (\n\t\t/^\\d+\\.\\d+\\.\\d+$/.test(version) || !Number.isNaN(Number.parseFloat(version))\n\t)\n}\n\nexport type FlightDeckOptions<S extends string = string> = {\n\tpackageName: string\n\tservices: { [service in S]: { run: string; waitFor: boolean } }\n\tscripts: {\n\t\tdownload: string\n\t\tinstall: string\n\t\tcheckAvailability?: string\n\t}\n\tport?: number | undefined\n\tflightdeckRootDir?: string | undefined\n\tjsonLogging?: boolean | undefined\n}\n\nexport class FlightDeck<S extends string = string> {\n\tpublic readonly options: FlightDeckOptions<S>\n\tprotected safety = 0\n\n\tprotected storage: FilesystemStorage<{\n\t\tsetupPhase: FlightDeckSetupPhase\n\t\tupdatePhase: FlightDeckUpdatePhase\n\t\tupdateAwaitedVersion: string\n\t}>\n\tprotected services: {\n\t\t[service in S]: ChildSocket<\n\t\t\t{ timeToStop: []; updatesReady: [] },\n\t\t\t{ readyToUpdate: []; alive: [] },\n\t\t\tChildProcessWithoutNullStreams\n\t\t> | null\n\t}\n\tprotected serviceIdx: { readonly [service in S]: number }\n\tpublic defaultServicesReadyToUpdate: { readonly [service in S]: boolean }\n\tpublic servicesReadyToUpdate: { [service in S]: boolean }\n\tpublic autoRespawnDeadServices: boolean\n\n\tprotected logger: Pick<Console, `error` | `info` | `warn`>\n\tprotected serviceLoggers: {\n\t\treadonly [service in S]: FlightDeckLogger\n\t}\n\n\tprotected updateAvailabilityChecker: CronJob | null = null\n\n\tpublic servicesLive: Future<void>[]\n\tpublic servicesDead: Future<void>[]\n\tpublic live = new Future(() => {})\n\tpublic dead = new Future(() => {})\n\n\tprotected restartTimes: number[] = []\n\n\tpublic constructor(options: FlightDeckOptions<S>) {\n\t\tthis.options = options\n\t\tconst { FLIGHTDECK_SECRET } = env\n\t\tconst { flightdeckRootDir = resolve(homedir(), `.flightdeck`) } = options\n\t\tconst port = options.port ?? 8080\n\t\tconst origin = `http://localhost:${port}`\n\n\t\tconst servicesEntries = toEntries(options.services)\n\t\tthis.services = fromEntries(\n\t\t\tservicesEntries.map(([serviceName]) => [serviceName, null]),\n\t\t)\n\t\tthis.serviceIdx = fromEntries(\n\t\t\tservicesEntries.map(([serviceName], idx) => [serviceName, idx]),\n\t\t)\n\t\tthis.defaultServicesReadyToUpdate = fromEntries(\n\t\t\tservicesEntries.map(([serviceName, { waitFor }]) => [\n\t\t\t\tserviceName,\n\t\t\t\t!waitFor,\n\t\t\t]),\n\t\t)\n\t\tthis.servicesReadyToUpdate = { ...this.defaultServicesReadyToUpdate }\n\t\tthis.autoRespawnDeadServices = true\n\n\t\tthis.logger = new FlightDeckLogger(\n\t\t\tthis.options.packageName,\n\t\t\tprocess.pid,\n\t\t\tundefined,\n\t\t\t{ jsonLogging: this.options.jsonLogging ?? false },\n\t\t)\n\t\tthis.serviceLoggers = fromEntries(\n\t\t\tservicesEntries.map(([serviceName]) => [\n\t\t\t\tserviceName,\n\t\t\t\tnew FlightDeckLogger(\n\t\t\t\t\tthis.options.packageName,\n\t\t\t\t\tprocess.pid,\n\t\t\t\t\tserviceName,\n\t\t\t\t\t{ jsonLogging: this.options.jsonLogging ?? false },\n\t\t\t\t),\n\t\t\t]),\n\t\t)\n\n\t\tthis.servicesLive = servicesEntries.map(() => new Future(() => {}))\n\t\tthis.servicesDead = servicesEntries.map(() => new Future(() => {}))\n\t\tthis.live.use(Promise.all(this.servicesLive))\n\t\tthis.dead.use(Promise.all(this.servicesDead))\n\n\t\tthis.storage = new FilesystemStorage({\n\t\t\tpath: resolve(flightdeckRootDir, `storage`, options.packageName),\n\t\t})\n\n\t\tif (FLIGHTDECK_SECRET === undefined) {\n\t\t\tthis.logger.warn(\n\t\t\t\t`No FLIGHTDECK_SECRET environment variable found. FlightDeck will not run an update server.`,\n\t\t\t)\n\t\t} else {\n\t\t\tcreateServer((req, res) => {\n\t\t\t\tlet data: Uint8Array[] = []\n\t\t\t\treq\n\t\t\t\t\t.on(`data`, (chunk) => {\n\t\t\t\t\t\tdata.push(chunk instanceof Buffer ? chunk : Buffer.from(chunk))\n\t\t\t\t\t})\n\t\t\t\t\t.on(`end`, async () => {\n\t\t\t\t\t\tconst authHeader = req.headers.authorization\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tif (typeof req.url === `undefined`) throw 400\n\t\t\t\t\t\t\tconst expectedAuthHeader = `Bearer ${FLIGHTDECK_SECRET}`\n\t\t\t\t\t\t\tif (authHeader !== `Bearer ${FLIGHTDECK_SECRET}`) {\n\t\t\t\t\t\t\t\tthis.logger.info(\n\t\t\t\t\t\t\t\t\t`Unauthorized: needed \\`${expectedAuthHeader}\\`, got \\`${authHeader}\\``,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tthrow 401\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst url = new URL(req.url, origin)\n\t\t\t\t\t\t\tthis.logger.info(req.method, url.pathname)\n\n\t\t\t\t\t\t\tconst versionForeignInput = Buffer.concat(data).toString()\n\t\t\t\t\t\t\tif (!isVersionNumber(versionForeignInput)) {\n\t\t\t\t\t\t\t\tthrow 400\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tres.writeHead(200)\n\t\t\t\t\t\t\tres.end()\n\n\t\t\t\t\t\t\tthis.storage.setItem(`updatePhase`, `notified`)\n\t\t\t\t\t\t\tthis.storage.setItem(`updateAwaitedVersion`, versionForeignInput)\n\t\t\t\t\t\t\tconst { checkAvailability } = options.scripts\n\t\t\t\t\t\t\tif (checkAvailability) {\n\t\t\t\t\t\t\t\tawait this.updateAvailabilityChecker?.stop()\n\t\t\t\t\t\t\t\tawait this.seekUpdate(versionForeignInput)\n\t\t\t\t\t\t\t\tconst updatePhase = this.storage.getItem(`updatePhase`)\n\t\t\t\t\t\t\t\tthis.logger.info(`> storage(\"updatePhase\") >`, updatePhase)\n\t\t\t\t\t\t\t\tif (updatePhase === `notified`) {\n\t\t\t\t\t\t\t\t\tthis.updateAvailabilityChecker = new CronJob(\n\t\t\t\t\t\t\t\t\t\t`*/30 * * * * *`,\n\t\t\t\t\t\t\t\t\t\tasync () => {\n\t\t\t\t\t\t\t\t\t\t\tawait this.seekUpdate(versionForeignInput)\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tthis.updateAvailabilityChecker.start()\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthis.downloadPackage()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (thrown) {\n\t\t\t\t\t\t\tthis.logger.error(thrown, req.url)\n\t\t\t\t\t\t\tif (typeof thrown === `number`) {\n\t\t\t\t\t\t\t\tres.writeHead(thrown)\n\t\t\t\t\t\t\t\tres.end()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} finally {\n\t\t\t\t\t\t\tdata = []\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t}).listen(port, () => {\n\t\t\t\tthis.logger.info(`Server started on port ${port}`)\n\t\t\t})\n\t\t}\n\n\t\tthis.startAllServices()\n\t\t\t.then(() => {\n\t\t\t\tthis.logger.info(`All services started.`)\n\t\t\t})\n\t\t\t.catch((thrown) => {\n\t\t\t\tif (thrown instanceof Error) {\n\t\t\t\t\tthis.logger.error(`Failed to start all services:`, thrown.message)\n\t\t\t\t}\n\t\t\t})\n\t}\n\n\tprotected async seekUpdate(version: string): Promise<void> {\n\t\tthis.logger.info(`Checking for updates...`)\n\t\tconst { checkAvailability } = this.options.scripts\n\t\tif (!checkAvailability) {\n\t\t\tthis.logger.info(`No checkAvailability script found.`)\n\t\t\treturn\n\t\t}\n\t\ttry {\n\t\t\tconst out = execSync(`${checkAvailability} ${version}`)\n\t\t\tthis.logger.info(`Check stdout:`, out.toString())\n\t\t\tawait this.updateAvailabilityChecker?.stop()\n\t\t\tthis.storage.setItem(`updatePhase`, `confirmed`)\n\t\t\tthis.downloadPackage()\n\t\t\tthis.announceUpdate()\n\t\t} catch (thrown) {\n\t\t\tif (thrown instanceof Error) {\n\t\t\t\tthis.logger.error(`Check failed:`, thrown.message)\n\t\t\t} else {\n\t\t\t\tconst thrownType = discoverType(thrown)\n\t\t\t\tthis.logger.error(`Check threw`, thrownType, thrown)\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected announceUpdate(): void {\n\t\tfor (const entry of toEntries(this.services)) {\n\t\t\tconst [serviceName, service] = entry\n\t\t\tif (service) {\n\t\t\t\tif (this.options.services[serviceName].waitFor) {\n\t\t\t\t\tservice.emit(`updatesReady`)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.startService(serviceName)\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected tryUpdate(): void {\n\t\tif (toEntries(this.servicesReadyToUpdate).every(([, isReady]) => isReady)) {\n\t\t\tthis.logger.info(`All services are ready to update.`)\n\t\t\tthis.stopAllServices()\n\t\t\t\t.then(() => {\n\t\t\t\t\tthis.logger.info(`All services stopped; starting up fresh...`)\n\t\t\t\t\tthis.startAllServices()\n\t\t\t\t\t\t.then(() => {\n\t\t\t\t\t\t\tthis.logger.info(`All services started; we're back online.`)\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch((thrown) => {\n\t\t\t\t\t\t\tif (thrown instanceof Error) {\n\t\t\t\t\t\t\t\tthis.logger.error(\n\t\t\t\t\t\t\t\t\t`Failed to start all services:`,\n\t\t\t\t\t\t\t\t\tthrown.message,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t\t.catch((thrown) => {\n\t\t\t\t\tif (thrown instanceof Error) {\n\t\t\t\t\t\tthis.logger.error(`Failed to stop all services:`, thrown.message)\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t}\n\t}\n\n\tprotected startAllServices(): Future<unknown> {\n\t\tthis.logger.info(`Starting all services...`)\n\t\tthis.autoRespawnDeadServices = true\n\t\tconst setupPhase = this.storage.getItem(`setupPhase`)\n\t\tthis.logger.info(`> storage(\"setupPhase\") >`, setupPhase)\n\t\tswitch (setupPhase) {\n\t\t\tcase null:\n\t\t\t\tthis.logger.info(`Starting from scratch.`)\n\t\t\t\tthis.downloadPackage()\n\t\t\t\tthis.installPackage()\n\t\t\t\treturn this.startAllServices()\n\t\t\tcase `downloaded`:\n\t\t\t\tthis.logger.info(`Found package downloaded but not installed.`)\n\t\t\t\tthis.installPackage()\n\t\t\t\treturn this.startAllServices()\n\t\t\tcase `installed`: {\n\t\t\t\tfor (const [serviceName] of toEntries(this.services)) {\n\t\t\t\t\tthis.startService(serviceName)\n\t\t\t\t}\n\t\t\t\treturn this.live\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected startService(serviceName: S): void {\n\t\tthis.logger.info(\n\t\t\t`Starting service ${this.options.packageName}::${serviceName}, try ${this.safety}/2...`,\n\t\t)\n\t\tif (this.safety >= 2) {\n\t\t\tthrow new Error(`Out of tries...`)\n\t\t}\n\t\tthis.safety++\n\n\t\tconst [exe, ...args] = this.options.services[serviceName].run.split(` `)\n\t\tconst serviceProcess = spawn(exe, args, {\n\t\t\tcwd: this.options.flightdeckRootDir,\n\t\t\tenv: import.meta.env as Record<string, string>,\n\t\t})\n\t\tconst serviceLogger = this.serviceLoggers[serviceName]\n\t\tconst service = (this.services[serviceName] = new ChildSocket(\n\t\t\tserviceProcess,\n\t\t\t`${this.options.packageName}::${serviceName}`,\n\t\t\tserviceLogger,\n\t\t))\n\t\tserviceLogger.processCode = service.proc.pid ?? -1\n\t\tthis.services[serviceName].onAny((...messages) => {\n\t\t\tserviceLogger.info(`💬`, ...messages)\n\t\t})\n\t\tthis.services[serviceName].on(`readyToUpdate`, () => {\n\t\t\tthis.logger.info(`Service \"${serviceName}\" is ready to update.`)\n\t\t\tthis.servicesReadyToUpdate[serviceName] = true\n\t\t\tthis.tryUpdate()\n\t\t})\n\t\tthis.services[serviceName].on(`alive`, () => {\n\t\t\tthis.servicesLive[this.serviceIdx[serviceName]].use(Promise.resolve())\n\t\t\tthis.servicesDead[this.serviceIdx[serviceName]] = new Future(() => {})\n\t\t\tif (this.dead.done) {\n\t\t\t\tthis.dead = new Future(() => {})\n\t\t\t}\n\t\t\tthis.dead.use(Promise.all(this.servicesDead))\n\t\t})\n\t\tthis.services[serviceName].proc.once(`close`, (exitCode) => {\n\t\t\tthis.logger.info(\n\t\t\t\t`Auto-respawn saw \"${serviceName}\" exit with code ${exitCode}`,\n\t\t\t)\n\t\t\tthis.services[serviceName] = null\n\t\t\tif (!this.autoRespawnDeadServices) {\n\t\t\t\tthis.logger.info(`Auto-respawn is off; \"${serviceName}\" rests.`)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst updatePhase = this.storage.getItem(`updatePhase`)\n\t\t\tthis.logger.info(`> storage(\"updatePhase\") >`, updatePhase)\n\t\t\tconst updatesAreReady = updatePhase === `confirmed`\n\t\t\tif (updatesAreReady) {\n\t\t\t\tthis.serviceLoggers[serviceName].info(`Updating before startup...`)\n\t\t\t\tthis.restartTimes = []\n\t\t\t\tthis.installPackage()\n\t\t\t\tthis.startService(serviceName)\n\t\t\t} else {\n\t\t\t\tconst now = Date.now()\n\t\t\t\tconst fiveMinutesAgo = now - 5 * 60 * 1000\n\t\t\t\tthis.restartTimes = this.restartTimes.filter(\n\t\t\t\t\t(time) => time > fiveMinutesAgo,\n\t\t\t\t)\n\t\t\t\tthis.restartTimes.push(now)\n\n\t\t\t\tif (this.restartTimes.length < 5) {\n\t\t\t\t\tthis.serviceLoggers[serviceName].info(`Crashed. Restarting...`)\n\t\t\t\t\tthis.startService(serviceName)\n\t\t\t\t} else {\n\t\t\t\t\tthis.serviceLoggers[serviceName].info(\n\t\t\t\t\t\t`Crashed 5 times in 5 minutes. Not restarting.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\tthis.safety = 0\n\t}\n\n\tprotected downloadPackage(): void {\n\t\tthis.logger.info(`Downloading...`)\n\t\ttry {\n\t\t\tconst out = execSync(this.options.scripts.download)\n\t\t\tthis.logger.info(`Download stdout:`, out.toString())\n\t\t\tthis.storage.setItem(`setupPhase`, `downloaded`)\n\t\t\tthis.logger.info(`Downloaded!`)\n\t\t} catch (thrown) {\n\t\t\tif (thrown instanceof Error) {\n\t\t\t\tthis.logger.error(`Failed to get the latest release: ${thrown.message}`)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t}\n\n\tprotected installPackage(): void {\n\t\tthis.logger.info(`Installing...`)\n\n\t\ttry {\n\t\t\tconst out = execSync(this.options.scripts.install)\n\t\t\tthis.logger.info(`Install stdout:`, out.toString())\n\t\t\tthis.storage.setItem(`setupPhase`, `installed`)\n\t\t\tthis.logger.info(`Installed!`)\n\t\t} catch (thrown) {\n\t\t\tif (thrown instanceof Error) {\n\t\t\t\tthis.logger.error(`Failed to get the latest release: ${thrown.message}`)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t}\n\n\tpublic stopAllServices(): Future<unknown> {\n\t\tthis.logger.info(`Stopping all services... auto-respawn disabled.`)\n\t\tthis.autoRespawnDeadServices = false\n\t\tfor (const [serviceName] of toEntries(this.services)) {\n\t\t\tthis.stopService(serviceName)\n\t\t}\n\t\treturn this.dead\n\t}\n\n\tpublic stopService(serviceName: S): void {\n\t\tconst service = this.services[serviceName]\n\t\tif (service) {\n\t\t\tthis.logger.info(`Stopping service \"${serviceName}\"...`)\n\t\t\tthis.servicesDead[this.serviceIdx[serviceName]].use(\n\t\t\t\tnew Promise((pass) => {\n\t\t\t\t\tservice.emit(`timeToStop`)\n\t\t\t\t\tservice.proc.once(`close`, (exitCode) => {\n\t\t\t\t\t\tthis.logger.info(\n\t\t\t\t\t\t\t`Stopped service \"${serviceName}\"; exited with code ${exitCode}`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\tthis.services[serviceName] = null\n\t\t\t\t\t\tpass()\n\t\t\t\t\t})\n\t\t\t\t}),\n\t\t\t)\n\t\t\tthis.dead.use(Promise.all(this.servicesDead))\n\t\t\tthis.servicesLive[this.serviceIdx[serviceName]] = new Future(() => {})\n\t\t\tif (this.live.done) {\n\t\t\t\tthis.live = new Future(() => {})\n\t\t\t}\n\t\t\tthis.live.use(Promise.all(this.servicesLive))\n\t\t} else {\n\t\t\tthis.serviceLoggers[serviceName].error(\n\t\t\t\t`Tried to stop service, but it wasn't running.`,\n\t\t\t)\n\t\t}\n\t}\n}\n\nexport const FLIGHTDECK_INFO = `info`\nexport const FLIGHTDECK_WARN = `warn`\nexport const FLIGHTDECK_ERROR = `ERR!`\n\nexport const flightDeckLogSchema = z.object({\n\tlevel: z.union([\n\t\tz.literal(FLIGHTDECK_INFO),\n\t\tz.literal(FLIGHTDECK_WARN),\n\t\tz.literal(FLIGHTDECK_ERROR),\n\t]),\n\ttimestamp: z.number(),\n\tpackage: z.string(),\n\tservice: z.string().optional(),\n\tprocess: z.number(),\n\tbody: z.string(),\n})\nexport type FlightDeckLog = z.infer<typeof flightDeckLogSchema>\n\nconst LINE_FORMAT = `line-format` satisfies keyof LnavFormat\nconst VALUE = `value` satisfies keyof LnavFormat\n\nexport type LnavFormatVisualComponent = Exclude<\n\tExclude<LnavFormat[`line-format`], undefined>[number],\n\tstring\n>\n\nexport type LnavFormatBreakdown = Exclude<LnavFormat[`value`], undefined>\nexport type MemberOf<T> = T[keyof T]\nexport type LnavFormatValueDefinition = MemberOf<LnavFormatBreakdown>\n\nexport type FlightDeckFormat = {\n\t[LINE_FORMAT]: (\n\t\t| string\n\t\t| (LnavFormatVisualComponent & {\n\t\t\t\tfield: keyof FlightDeckLog | `__level__` | `__timestamp__`\n\t\t })\n\t)[]\n\t[VALUE]: {\n\t\t[K in keyof FlightDeckLog]: LnavFormatValueDefinition & {\n\t\t\tkind: FlightDeckLog[K] extends number | undefined\n\t\t\t\t? `integer`\n\t\t\t\t: FlightDeckLog[K] extends string | undefined\n\t\t\t\t\t? `string`\n\t\t\t\t\t: never\n\t\t}\n\t}\n}\n\nexport const FLIGHTDECK_LNAV_FORMAT = {\n\ttitle: `FlightDeck Log`,\n\tdescription: `Format for events logged by the FlightDeck process manager.`,\n\t\"file-type\": `json`,\n\t\"timestamp-field\": `timestamp`,\n\t\"timestamp-divisor\": 1000,\n\t\"module-field\": `package`,\n\t\"opid-field\": `service`,\n\t\"level-field\": `level`,\n\tlevel: {\n\t\tinfo: FLIGHTDECK_INFO,\n\t\twarning: FLIGHTDECK_WARN,\n\t\terror: FLIGHTDECK_ERROR,\n\t},\n\n\t[LINE_FORMAT]: [\n\t\t{\n\t\t\tfield: `level`,\n\t\t},\n\t\t{\n\t\t\tprefix: ` `,\n\t\t\tfield: `__timestamp__`,\n\t\t\t\"timestamp-format\": `%Y-%m-%dT%H:%M:%S.%L%Z`,\n\t\t},\n\t\t{\n\t\t\tprefix: ` `,\n\t\t\tfield: `process`,\n\t\t\t\"min-width\": 5,\n\t\t},\n\t\t{\n\t\t\tprefix: `:`,\n\t\t\tfield: `package`,\n\t\t},\n\t\t{\n\t\t\tprefix: `:`,\n\t\t\tfield: `service`,\n\t\t\t\"default-value\": ``,\n\t\t},\n\t\t{\n\t\t\tprefix: `: `,\n\t\t\tfield: `body`,\n\t\t},\n\t],\n\n\t[VALUE]: {\n\t\ttimestamp: {\n\t\t\tkind: `integer`,\n\t\t},\n\t\tlevel: {\n\t\t\tkind: `string`,\n\t\t},\n\t\tpackage: {\n\t\t\tkind: `string`,\n\t\t},\n\t\tservice: {\n\t\t\tkind: `string`,\n\t\t},\n\t\tprocess: {\n\t\t\tkind: `integer`,\n\t\t},\n\t\tbody: {\n\t\t\tkind: `string`,\n\t\t},\n\t},\n} as const satisfies FlightDeckFormat & LnavFormat\n\nexport class FlightDeckLogger\n\timplements Pick<Console, `error` | `info` | `warn`>\n{\n\tpublic readonly packageName: string\n\tpublic readonly serviceName?: string\n\tpublic readonly jsonLogging: boolean\n\tpublic processCode: number\n\tpublic constructor(\n\t\tpackageName: string,\n\t\tprocessCode: number,\n\t\tserviceName?: string,\n\t\toptions?: { jsonLogging: boolean },\n\t) {\n\t\tthis.packageName = packageName\n\t\tif (serviceName) {\n\t\t\tthis.serviceName = serviceName\n\t\t}\n\t\tthis.processCode = processCode\n\t\tthis.jsonLogging = options?.jsonLogging ?? false\n\t}\n\tprotected log(\n\t\tlevel:\n\t\t\t| typeof FLIGHTDECK_ERROR\n\t\t\t| typeof FLIGHTDECK_INFO\n\t\t\t| typeof FLIGHTDECK_WARN,\n\t\t...messages: unknown[]\n\t): void {\n\t\tif (this.jsonLogging) {\n\t\t\tlet body = messages\n\t\t\t\t.map((message) =>\n\t\t\t\t\ttypeof message === `string`\n\t\t\t\t\t\t? message\n\t\t\t\t\t\t: inspect(message, false, null, true),\n\t\t\t\t)\n\t\t\t\t.join(` `)\n\t\t\tif (body.includes(`\\n`)) {\n\t\t\t\tbody = `\\n ${body.split(`\\n`).join(`\\n `)}`\n\t\t\t}\n\t\t\tconst log: FlightDeckLog = {\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t\tlevel,\n\t\t\t\tprocess: this.processCode,\n\t\t\t\tpackage: this.packageName,\n\t\t\t\tbody,\n\t\t\t}\n\t\t\tif (this.serviceName) {\n\t\t\t\tlog.service = this.serviceName\n\t\t\t}\n\t\t\tprocess.stdout.write(JSON.stringify(log) + `\\n`)\n\t\t} else {\n\t\t\tconst source = this.serviceName\n\t\t\t\t? `${this.packageName}:${this.serviceName}`\n\t\t\t\t: this.packageName\n\t\t\tswitch (level) {\n\t\t\t\tcase FLIGHTDECK_INFO:\n\t\t\t\t\tconsole.log(`${source}:`, ...messages)\n\t\t\t\t\tbreak\n\t\t\t\tcase FLIGHTDECK_WARN:\n\t\t\t\t\tconsole.warn(`${source}:`, ...messages)\n\t\t\t\t\tbreak\n\t\t\t\tcase FLIGHTDECK_ERROR:\n\t\t\t\t\tconsole.error(`${source}:`, ...messages)\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tpublic info(...messages: unknown[]): void {\n\t\tthis.log(FLIGHTDECK_INFO, ...messages)\n\t}\n\n\tpublic warn(...messages: unknown[]): void {\n\t\tthis.log(FLIGHTDECK_WARN, ...messages)\n\t}\n\n\tpublic error(...messages: unknown[]): void {\n\t\tthis.log(FLIGHTDECK_ERROR, ...messages)\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;AAGA,MAAa,MAAM,UAAU;CAC5B,QAAQ,EAAE,mBAAmB,EAAE,QAAQ,CAAC,UAAU,EAAE;CACpD,cAAc;CACd,QAAQ,EAAE;CACV,YAAY,OAAO,KAAK;CACxB,wBAAwB;CACxB,CAAC;;;;ACUF,MAAa,0BAA0B,CAAC,cAAc,YAAY;AAIlE,MAAa,2BAA2B,CAAC,YAAY,YAAY;AAIjE,SAAgB,gBAAgB,SAA0B;AACzD,QACC,kBAAkB,KAAK,QAAQ,IAAI,CAAC,OAAO,MAAM,OAAO,WAAW,QAAQ,CAAC;;AAiB9E,IAAa,aAAb,MAAmD;CAClD,AAAgB;CAChB,AAAU,SAAS;CAEnB,AAAU;CAKV,AAAU;CAOV,AAAU;CACV,AAAO;CACP,AAAO;CACP,AAAO;CAEP,AAAU;CACV,AAAU;CAIV,AAAU,4BAA4C;CAEtD,AAAO;CACP,AAAO;CACP,AAAO,OAAO,IAAI,aAAa,GAAG;CAClC,AAAO,OAAO,IAAI,aAAa,GAAG;CAElC,AAAU,eAAyB,EAAE;CAErC,AAAO,YAAY,SAA+B;AACjD,OAAK,UAAU;EACf,MAAM,EAAE,sBAAsB;EAC9B,MAAM,EAAE,oBAAoB,QAAQ,SAAS,EAAE,cAAc,KAAK;EAClE,MAAM,OAAO,QAAQ,QAAQ;EAC7B,MAAM,SAAS,oBAAoB;EAEnC,MAAM,kBAAkB,UAAU,QAAQ,SAAS;AACnD,OAAK,WAAW,YACf,gBAAgB,KAAK,CAAC,iBAAiB,CAAC,aAAa,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OAAI,KAAK,SAAS,KAAK,CACtB,QAAO,OAAO,KAAK,MAAM,KAAK,CAAC,KAAK,OAAO;GAE5C,MAAMC,MAAqB;IAC1B,WAAW,KAAK,KAAK;IACrB;IACA,SAAS,KAAK;IACd,SAAS,KAAK;IACd;IACA;AACD,OAAI,KAAK,YACR,KAAI,UAAU,KAAK;AAEpB,WAAQ,OAAO,MAAM,KAAK,UAAU,IAAI,GAAG,KAAK;SAC1C;GACN,MAAM,SAAS,KAAK,cACjB,GAAG,KAAK,YAAY,GAAG,KAAK,gBAC5B,KAAK;AACR,WAAQ,OAAR;IACC,KAAK;AACJ,aAAQ,IAAI,GAAG,OAAO,IAAI,GAAG,SAAS;AACtC;IACD,KAAK;AACJ,aAAQ,KAAK,GAAG,OAAO,IAAI,GAAG,SAAS;AACvC;IACD,KAAK;AACJ,aAAQ,MAAM,GAAG,OAAO,IAAI,GAAG,SAAS;AACxC;;;;CAIJ,AAAO,KAAK,GAAG,UAA2B;AACzC,OAAK,IAAI,iBAAiB,GAAG,SAAS;;CAGvC,AAAO,KAAK,GAAG,UAA2B;AACzC,OAAK,IAAI,iBAAiB,GAAG,SAAS;;CAGvC,AAAO,MAAM,GAAG,UAA2B;AAC1C,OAAK,IAAI,kBAAkB,GAAG,SAAS"}
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { FlightDeck, FlightDeckLogger } from "./flightdeck.lib-B3x4c_io.js";
2
+ import { FlightDeck, FlightDeckLogger } from "./flightdeck.lib-9O00rJ2l.js";
3
3
  import * as path from "node:path";
4
4
  import { cli, optional, parseBooleanOption, parseNumberOption } from "comline";
5
5
  import { z } from "zod/v4";
@@ -80,7 +80,7 @@ const SCHEMA_MANUAL = {
80
80
  example: `--outdir=./dist`
81
81
  } }
82
82
  };
83
- const parse = cli({
83
+ const { inputs, writeJsonSchema } = cli({
84
84
  cliName: `flightdeck`,
85
85
  routes: optional({
86
86
  schema: null,
@@ -94,11 +94,9 @@ const parse = cli({
94
94
  debugOutput: true,
95
95
  discoverConfigPath: (args) => {
96
96
  if (args[0] === `schema`) return;
97
- const configPath = args[0] ?? path.join(process.cwd(), `flightdeck.config.json`);
98
- return configPath;
97
+ return args[0] ?? path.join(process.cwd(), `flightdeck.config.json`);
99
98
  }
100
- }, console);
101
- const { inputs, writeJsonSchema } = parse(process.argv);
99
+ }, console)(process.argv);
102
100
  switch (inputs.case) {
103
101
  case `schema`:
104
102
  {
@@ -1 +1 @@
1
- {"version":3,"file":"flightdeck.x.js","names":[],"sources":["../src/flightdeck.x.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as path from \"node:path\"\n\nimport type { OptionsGroup } from \"comline\"\nimport { cli, optional, parseBooleanOption, parseNumberOption } from \"comline\"\nimport { z } from \"zod/v4\"\n\nimport type { FlightDeckOptions } from \"./flightdeck.lib\"\nimport { FlightDeck, FlightDeckLogger } from \"./flightdeck.lib\"\n\nconst CLI_LOGGER = new FlightDeckLogger(`comline`, process.pid, undefined, {\n\tjsonLogging: true,\n})\nObject.assign(console, {\n\tlog: CLI_LOGGER.info.bind(CLI_LOGGER),\n\tinfo: CLI_LOGGER.info.bind(CLI_LOGGER),\n\twarn: CLI_LOGGER.warn.bind(CLI_LOGGER),\n\terror: CLI_LOGGER.error.bind(CLI_LOGGER),\n})\n\nconst FLIGHTDECK_MANUAL = {\n\toptionsSchema: z.object({\n\t\tport: z.number().optional(),\n\t\tpackageName: z.string(),\n\t\tservices: z.record(\n\t\t\tz.string(),\n\t\t\tz.object({ run: z.string(), waitFor: z.boolean() }),\n\t\t),\n\t\tflightdeckRootDir: z.string(),\n\t\tscripts: z.object({\n\t\t\tdownload: z.string(),\n\t\t\tinstall: z.string(),\n\t\t\tcheckAvailability: z.string(),\n\t\t}),\n\t\tjsonLogging: z.boolean().optional(),\n\t}),\n\toptions: {\n\t\tport: {\n\t\t\tflag: `p`,\n\t\t\trequired: false,\n\t\t\tdescription: `Port to run the flightdeck server on.`,\n\t\t\texample: `--port=8080`,\n\t\t\tparse: parseNumberOption,\n\t\t},\n\t\tpackageName: {\n\t\t\tflag: `n`,\n\t\t\trequired: true,\n\t\t\tdescription: `Name of the package.`,\n\t\t\texample: `--packageName=\\\"my-app\\\"`,\n\t\t},\n\t\tservices: {\n\t\t\tflag: `s`,\n\t\t\trequired: true,\n\t\t\tdescription: `Map of service names to executables.`,\n\t\t\texample: `--services=\"{\\\\\"frontend\\\\\":{\\\\\"run\\\\\":\\\\\"./frontend\\\\\",\\\\\"waitFor\\\\\":false},\\\\\"backend\\\\\":{\\\\\"run\\\\\":\\\\\"./backend\\\\\",\\\\\"waitFor\\\\\":true}}\"`,\n\t\t\tparse: JSON.parse,\n\t\t},\n\t\tflightdeckRootDir: {\n\t\t\tflag: `d`,\n\t\t\trequired: true,\n\t\t\tdescription: `Directory where the service is stored.`,\n\t\t\texample: `--flightdeckRootDir=\\\"./services/sample/repo/my-app/current\\\"`,\n\t\t},\n\t\tscripts: {\n\t\t\tflag: `r`,\n\t\t\trequired: true,\n\t\t\tdescription: `Map of scripts to run.`,\n\t\t\texample: `--scripts=\"{\\\\\"download\\\\\":\\\\\"npm i\",\\\\\"install\\\\\":\\\\\"npm run build\\\\\"}\"`,\n\t\t\tparse: JSON.parse,\n\t\t},\n\t\tjsonLogging: {\n\t\t\tflag: `j`,\n\t\t\trequired: false,\n\t\t\tdescription: `Enable json logging.`,\n\t\t\texample: `--jsonLogging`,\n\t\t\tparse: parseBooleanOption,\n\t\t},\n\t},\n} satisfies OptionsGroup<FlightDeckOptions>\n\nconst SCHEMA_MANUAL = {\n\toptionsSchema: z.object({\n\t\toutdir: z.string().optional(),\n\t}),\n\toptions: {\n\t\toutdir: {\n\t\t\tflag: `o`,\n\t\t\trequired: false,\n\t\t\tdescription: `Directory to write the schema to.`,\n\t\t\texample: `--outdir=./dist`,\n\t\t},\n\t},\n} satisfies OptionsGroup<{ outdir?: string | undefined }>\n\nconst parse = cli(\n\t{\n\t\tcliName: `flightdeck`,\n\t\troutes: optional({ schema: null, $configPath: null }),\n\t\trouteOptions: {\n\t\t\t\"\": FLIGHTDECK_MANUAL,\n\t\t\t$configPath: FLIGHTDECK_MANUAL,\n\t\t\tschema: SCHEMA_MANUAL,\n\t\t},\n\t\tdebugOutput: true,\n\t\tdiscoverConfigPath: (args) => {\n\t\t\tif (args[0] === `schema`) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst configPath =\n\t\t\t\targs[0] ?? path.join(process.cwd(), `flightdeck.config.json`)\n\t\t\treturn configPath\n\t\t},\n\t},\n\tconsole,\n)\n\nconst { inputs, writeJsonSchema } = parse(process.argv)\n\nswitch (inputs.case) {\n\tcase `schema`:\n\t\t{\n\t\t\tconst { outdir } = inputs.opts\n\t\t\twriteJsonSchema(outdir ?? `.`)\n\t\t}\n\t\tbreak\n\tcase ``:\n\tcase `$configPath`: {\n\t\tconst flightDeck = new FlightDeck(inputs.opts)\n\t\tprocess.on(`close`, async () => {\n\t\t\tawait flightDeck.stopAllServices()\n\t\t})\n\t}\n}\n"],"mappings":";;;;;;;AAWA,MAAM,aAAa,IAAI,iBAAiB,WAAW,QAAQ,KAAK,QAAW,EAC1E,aAAa;AAEd,OAAO,OAAO,SAAS;CACtB,KAAK,WAAW,KAAK,KAAK;CAC1B,MAAM,WAAW,KAAK,KAAK;CAC3B,MAAM,WAAW,KAAK,KAAK;CAC3B,OAAO,WAAW,MAAM,KAAK;;AAG9B,MAAM,oBAAoB;CACzB,eAAe,EAAE,OAAO;EACvB,MAAM,EAAE,SAAS;EACjB,aAAa,EAAE;EACf,UAAU,EAAE,OACX,EAAE,UACF,EAAE,OAAO;GAAE,KAAK,EAAE;GAAU,SAAS,EAAE;;EAExC,mBAAmB,EAAE;EACrB,SAAS,EAAE,OAAO;GACjB,UAAU,EAAE;GACZ,SAAS,EAAE;GACX,mBAAmB,EAAE;;EAEtB,aAAa,EAAE,UAAU;;CAE1B,SAAS;EACR,MAAM;GACL,MAAM;GACN,UAAU;GACV,aAAa;GACb,SAAS;GACT,OAAO;;EAER,aAAa;GACZ,MAAM;GACN,UAAU;GACV,aAAa;GACb,SAAS;;EAEV,UAAU;GACT,MAAM;GACN,UAAU;GACV,aAAa;GACb,SAAS;GACT,OAAO,KAAK;;EAEb,mBAAmB;GAClB,MAAM;GACN,UAAU;GACV,aAAa;GACb,SAAS;;EAEV,SAAS;GACR,MAAM;GACN,UAAU;GACV,aAAa;GACb,SAAS;GACT,OAAO,KAAK;;EAEb,aAAa;GACZ,MAAM;GACN,UAAU;GACV,aAAa;GACb,SAAS;GACT,OAAO;;;;AAKV,MAAM,gBAAgB;CACrB,eAAe,EAAE,OAAO,EACvB,QAAQ,EAAE,SAAS;CAEpB,SAAS,EACR,QAAQ;EACP,MAAM;EACN,UAAU;EACV,aAAa;EACb,SAAS;;;AAKZ,MAAM,QAAQ,IACb;CACC,SAAS;CACT,QAAQ,SAAS;EAAE,QAAQ;EAAM,aAAa;;CAC9C,cAAc;EACb,IAAI;EACJ,aAAa;EACb,QAAQ;;CAET,aAAa;CACb,qBAAqB,SAAS;AAC7B,MAAI,KAAK,OAAO,SACf;EAED,MAAM,aACL,KAAK,MAAM,KAAK,KAAK,QAAQ,OAAO;AACrC,SAAO;;GAGT;AAGD,MAAM,EAAE,QAAQ,oBAAoB,MAAM,QAAQ;AAElD,QAAQ,OAAO,MAAf;CACC,KAAK;EACJ;GACC,MAAM,EAAE,WAAW,OAAO;AAC1B,mBAAgB,UAAU;;AAE3B;CACD,KAAK;CACL,KAAK,eAAe;EACnB,MAAM,aAAa,IAAI,WAAW,OAAO;AACzC,UAAQ,GAAG,SAAS,YAAY;AAC/B,SAAM,WAAW"}
1
+ {"version":3,"file":"flightdeck.x.js","names":[],"sources":["../src/flightdeck.x.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as path from \"node:path\"\n\nimport type { OptionsGroup } from \"comline\"\nimport { cli, optional, parseBooleanOption, parseNumberOption } from \"comline\"\nimport { z } from \"zod/v4\"\n\nimport type { FlightDeckOptions } from \"./flightdeck.lib\"\nimport { FlightDeck, FlightDeckLogger } from \"./flightdeck.lib\"\n\nconst CLI_LOGGER = new FlightDeckLogger(`comline`, process.pid, undefined, {\n\tjsonLogging: true,\n})\nObject.assign(console, {\n\tlog: CLI_LOGGER.info.bind(CLI_LOGGER),\n\tinfo: CLI_LOGGER.info.bind(CLI_LOGGER),\n\twarn: CLI_LOGGER.warn.bind(CLI_LOGGER),\n\terror: CLI_LOGGER.error.bind(CLI_LOGGER),\n})\n\nconst FLIGHTDECK_MANUAL = {\n\toptionsSchema: z.object({\n\t\tport: z.number().optional(),\n\t\tpackageName: z.string(),\n\t\tservices: z.record(\n\t\t\tz.string(),\n\t\t\tz.object({ run: z.string(), waitFor: z.boolean() }),\n\t\t),\n\t\tflightdeckRootDir: z.string(),\n\t\tscripts: z.object({\n\t\t\tdownload: z.string(),\n\t\t\tinstall: z.string(),\n\t\t\tcheckAvailability: z.string(),\n\t\t}),\n\t\tjsonLogging: z.boolean().optional(),\n\t}),\n\toptions: {\n\t\tport: {\n\t\t\tflag: `p`,\n\t\t\trequired: false,\n\t\t\tdescription: `Port to run the flightdeck server on.`,\n\t\t\texample: `--port=8080`,\n\t\t\tparse: parseNumberOption,\n\t\t},\n\t\tpackageName: {\n\t\t\tflag: `n`,\n\t\t\trequired: true,\n\t\t\tdescription: `Name of the package.`,\n\t\t\texample: `--packageName=\\\"my-app\\\"`,\n\t\t},\n\t\tservices: {\n\t\t\tflag: `s`,\n\t\t\trequired: true,\n\t\t\tdescription: `Map of service names to executables.`,\n\t\t\texample: `--services=\"{\\\\\"frontend\\\\\":{\\\\\"run\\\\\":\\\\\"./frontend\\\\\",\\\\\"waitFor\\\\\":false},\\\\\"backend\\\\\":{\\\\\"run\\\\\":\\\\\"./backend\\\\\",\\\\\"waitFor\\\\\":true}}\"`,\n\t\t\tparse: JSON.parse,\n\t\t},\n\t\tflightdeckRootDir: {\n\t\t\tflag: `d`,\n\t\t\trequired: true,\n\t\t\tdescription: `Directory where the service is stored.`,\n\t\t\texample: `--flightdeckRootDir=\\\"./services/sample/repo/my-app/current\\\"`,\n\t\t},\n\t\tscripts: {\n\t\t\tflag: `r`,\n\t\t\trequired: true,\n\t\t\tdescription: `Map of scripts to run.`,\n\t\t\texample: `--scripts=\"{\\\\\"download\\\\\":\\\\\"npm i\",\\\\\"install\\\\\":\\\\\"npm run build\\\\\"}\"`,\n\t\t\tparse: JSON.parse,\n\t\t},\n\t\tjsonLogging: {\n\t\t\tflag: `j`,\n\t\t\trequired: false,\n\t\t\tdescription: `Enable json logging.`,\n\t\t\texample: `--jsonLogging`,\n\t\t\tparse: parseBooleanOption,\n\t\t},\n\t},\n} satisfies OptionsGroup<FlightDeckOptions>\n\nconst SCHEMA_MANUAL = {\n\toptionsSchema: z.object({\n\t\toutdir: z.string().optional(),\n\t}),\n\toptions: {\n\t\toutdir: {\n\t\t\tflag: `o`,\n\t\t\trequired: false,\n\t\t\tdescription: `Directory to write the schema to.`,\n\t\t\texample: `--outdir=./dist`,\n\t\t},\n\t},\n} satisfies OptionsGroup<{ outdir?: string | undefined }>\n\nconst parse = cli(\n\t{\n\t\tcliName: `flightdeck`,\n\t\troutes: optional({ schema: null, $configPath: null }),\n\t\trouteOptions: {\n\t\t\t\"\": FLIGHTDECK_MANUAL,\n\t\t\t$configPath: FLIGHTDECK_MANUAL,\n\t\t\tschema: SCHEMA_MANUAL,\n\t\t},\n\t\tdebugOutput: true,\n\t\tdiscoverConfigPath: (args) => {\n\t\t\tif (args[0] === `schema`) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst configPath =\n\t\t\t\targs[0] ?? path.join(process.cwd(), `flightdeck.config.json`)\n\t\t\treturn configPath\n\t\t},\n\t},\n\tconsole,\n)\n\nconst { inputs, writeJsonSchema } = parse(process.argv)\n\nswitch (inputs.case) {\n\tcase `schema`:\n\t\t{\n\t\t\tconst { outdir } = inputs.opts\n\t\t\twriteJsonSchema(outdir ?? `.`)\n\t\t}\n\t\tbreak\n\tcase ``:\n\tcase `$configPath`: {\n\t\tconst flightDeck = new FlightDeck(inputs.opts)\n\t\tprocess.on(`close`, async () => {\n\t\t\tawait flightDeck.stopAllServices()\n\t\t})\n\t}\n}\n"],"mappings":";;;;;;;AAWA,MAAM,aAAa,IAAI,iBAAiB,WAAW,QAAQ,KAAK,QAAW,EAC1E,aAAa,MACb,CAAC;AACF,OAAO,OAAO,SAAS;CACtB,KAAK,WAAW,KAAK,KAAK,WAAW;CACrC,MAAM,WAAW,KAAK,KAAK,WAAW;CACtC,MAAM,WAAW,KAAK,KAAK,WAAW;CACtC,OAAO,WAAW,MAAM,KAAK,WAAW;CACxC,CAAC;AAEF,MAAM,oBAAoB;CACzB,eAAe,EAAE,OAAO;EACvB,MAAM,EAAE,QAAQ,CAAC,UAAU;EAC3B,aAAa,EAAE,QAAQ;EACvB,UAAU,EAAE,OACX,EAAE,QAAQ,EACV,EAAE,OAAO;GAAE,KAAK,EAAE,QAAQ;GAAE,SAAS,EAAE,SAAS;GAAE,CAAC,CACnD;EACD,mBAAmB,EAAE,QAAQ;EAC7B,SAAS,EAAE,OAAO;GACjB,UAAU,EAAE,QAAQ;GACpB,SAAS,EAAE,QAAQ;GACnB,mBAAmB,EAAE,QAAQ;GAC7B,CAAC;EACF,aAAa,EAAE,SAAS,CAAC,UAAU;EACnC,CAAC;CACF,SAAS;EACR,MAAM;GACL,MAAM;GACN,UAAU;GACV,aAAa;GACb,SAAS;GACT,OAAO;GACP;EACD,aAAa;GACZ,MAAM;GACN,UAAU;GACV,aAAa;GACb,SAAS;GACT;EACD,UAAU;GACT,MAAM;GACN,UAAU;GACV,aAAa;GACb,SAAS;GACT,OAAO,KAAK;GACZ;EACD,mBAAmB;GAClB,MAAM;GACN,UAAU;GACV,aAAa;GACb,SAAS;GACT;EACD,SAAS;GACR,MAAM;GACN,UAAU;GACV,aAAa;GACb,SAAS;GACT,OAAO,KAAK;GACZ;EACD,aAAa;GACZ,MAAM;GACN,UAAU;GACV,aAAa;GACb,SAAS;GACT,OAAO;GACP;EACD;CACD;AAED,MAAM,gBAAgB;CACrB,eAAe,EAAE,OAAO,EACvB,QAAQ,EAAE,QAAQ,CAAC,UAAU,EAC7B,CAAC;CACF,SAAS,EACR,QAAQ;EACP,MAAM;EACN,UAAU;EACV,aAAa;EACb,SAAS;EACT,EACD;CACD;AAwBD,MAAM,EAAE,QAAQ,oBAtBF,IACb;CACC,SAAS;CACT,QAAQ,SAAS;EAAE,QAAQ;EAAM,aAAa;EAAM,CAAC;CACrD,cAAc;EACb,IAAI;EACJ,aAAa;EACb,QAAQ;EACR;CACD,aAAa;CACb,qBAAqB,SAAS;AAC7B,MAAI,KAAK,OAAO,SACf;AAID,SADC,KAAK,MAAM,KAAK,KAAK,QAAQ,KAAK,EAAE,yBAAyB;;CAG/D,EACD,QACA,CAEyC,QAAQ,KAAK;AAEvD,QAAQ,OAAO,MAAf;CACC,KAAK;EACJ;GACC,MAAM,EAAE,WAAW,OAAO;AAC1B,mBAAgB,UAAU,IAAI;;AAE/B;CACD,KAAK;CACL,KAAK,eAAe;EACnB,MAAM,aAAa,IAAI,WAAW,OAAO,KAAK;AAC9C,UAAQ,GAAG,SAAS,YAAY;AAC/B,SAAM,WAAW,iBAAiB;IACjC"}
@@ -7,7 +7,7 @@ __export(klaxon_lib_exports, {
7
7
  scramble: () => scramble
8
8
  });
9
9
  async function alert({ secret, endpoint, version }) {
10
- const response = await fetch(endpoint, {
10
+ return await fetch(endpoint, {
11
11
  method: `POST`,
12
12
  headers: {
13
13
  "Content-Type": `text/plain;charset=UTF-8`,
@@ -15,7 +15,6 @@ async function alert({ secret, endpoint, version }) {
15
15
  },
16
16
  body: version
17
17
  });
18
- return response;
19
18
  }
20
19
  async function scramble({ packageConfig, secretsConfig, publishedPackages }) {
21
20
  const alertResults = [];
@@ -32,10 +31,9 @@ async function scramble({ packageConfig, secretsConfig, publishedPackages }) {
32
31
  alertResults.push(alertResultPromise);
33
32
  }
34
33
  const alertResultsResolved = await Promise.all(alertResults);
35
- const scrambleResult = Object.fromEntries(alertResultsResolved);
36
- return scrambleResult;
34
+ return Object.fromEntries(alertResultsResolved);
37
35
  }
38
36
 
39
37
  //#endregion
40
38
  export { klaxon_lib_exports, scramble };
41
- //# sourceMappingURL=klaxon.lib-CNw2A3ce.js.map
39
+ //# sourceMappingURL=klaxon.lib-qvkgjVGs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"klaxon.lib-CNw2A3ce.js","names":["alertResults: Promise<readonly [K, Response]>[]"],"sources":["../src/klaxon.lib.ts"],"sourcesContent":["export type AlertOptions = {\n\tsecret: string\n\tendpoint: string\n\tversion: string\n}\n\nexport async function alert({\n\tsecret,\n\tendpoint,\n\tversion,\n}: AlertOptions): Promise<Response> {\n\tconst response = await fetch(endpoint, {\n\t\tmethod: `POST`,\n\t\theaders: {\n\t\t\t\"Content-Type\": `text/plain;charset=UTF-8`,\n\t\t\tAuthorization: `Bearer ${secret}`,\n\t\t},\n\t\tbody: version,\n\t})\n\n\treturn response\n}\n\n/**\n * @see https://github.com/changesets/action/blob/main/src/run.ts\n */\nexport type ChangesetsPublishedPackage = {\n\tname: string\n\tversion: string\n}\n\n/**\n * @see https://github.com/changesets/action/blob/main/src/run.ts\n */\nexport type ChangesetsPublishResult =\n\t| {\n\t\t\tpublished: true\n\t\t\tpublishedPackages: ChangesetsPublishedPackage[]\n\t }\n\t| { published: false }\n\nexport type PackageConfig<K extends string> = {\n\t[key in K]: { endpoint: string }\n}\nexport type SecretsConfig<K extends string> = {\n\t[key in K]: string\n}\n\nexport type ScrambleOptions<K extends string = string> = {\n\tpackageConfig: PackageConfig<K>\n\tsecretsConfig: SecretsConfig<K>\n\tpublishedPackages: ChangesetsPublishedPackage[]\n}\n\nexport type ScrambleResult<K extends string = string> = {\n\t[key in K]: Response\n}\n\nexport async function scramble<K extends string = string>({\n\tpackageConfig,\n\tsecretsConfig,\n\tpublishedPackages,\n}: ScrambleOptions<K>): Promise<ScrambleResult<K>> {\n\tconst alertResults: Promise<readonly [K, Response]>[] = []\n\tfor (const publishedPackage of publishedPackages) {\n\t\tif (publishedPackage.name in packageConfig) {\n\t\t\tconst name = publishedPackage.name as K\n\t\t\tconst { endpoint } = packageConfig[name]\n\t\t\tconst secret = secretsConfig[name]\n\t\t\tconst version = publishedPackage.version\n\t\t\tconst alertResultPromise = alert({ secret, endpoint, version }).then(\n\t\t\t\t(alertResult) => [name, alertResult] as const,\n\t\t\t)\n\t\t\talertResults.push(alertResultPromise)\n\t\t}\n\t}\n\tconst alertResultsResolved = await Promise.all(alertResults)\n\tconst scrambleResult = Object.fromEntries(\n\t\talertResultsResolved,\n\t) as ScrambleResult<K>\n\treturn scrambleResult\n}\n"],"mappings":";;;;;;;;AAMA,eAAsB,MAAM,EAC3B,QACA,UACA,WACmC;CACnC,MAAM,WAAW,MAAM,MAAM,UAAU;EACtC,QAAQ;EACR,SAAS;GACR,gBAAgB;GAChB,eAAe,UAAU;;EAE1B,MAAM;;AAGP,QAAO;;AAsCR,eAAsB,SAAoC,EACzD,eACA,eACA,qBACkD;CAClD,MAAMA,eAAkD;AACxD,MAAK,MAAM,oBAAoB,kBAC9B,KAAI,iBAAiB,QAAQ,eAAe;EAC3C,MAAM,OAAO,iBAAiB;EAC9B,MAAM,EAAE,aAAa,cAAc;EACnC,MAAM,SAAS,cAAc;EAC7B,MAAM,UAAU,iBAAiB;EACjC,MAAM,qBAAqB,MAAM;GAAE;GAAQ;GAAU;KAAW,MAC9D,gBAAgB,CAAC,MAAM;AAEzB,eAAa,KAAK;;CAGpB,MAAM,uBAAuB,MAAM,QAAQ,IAAI;CAC/C,MAAM,iBAAiB,OAAO,YAC7B;AAED,QAAO"}
1
+ {"version":3,"file":"klaxon.lib-qvkgjVGs.js","names":["alertResults: Promise<readonly [K, Response]>[]"],"sources":["../src/klaxon.lib.ts"],"sourcesContent":["export type AlertOptions = {\n\tsecret: string\n\tendpoint: string\n\tversion: string\n}\n\nexport async function alert({\n\tsecret,\n\tendpoint,\n\tversion,\n}: AlertOptions): Promise<Response> {\n\tconst response = await fetch(endpoint, {\n\t\tmethod: `POST`,\n\t\theaders: {\n\t\t\t\"Content-Type\": `text/plain;charset=UTF-8`,\n\t\t\tAuthorization: `Bearer ${secret}`,\n\t\t},\n\t\tbody: version,\n\t})\n\n\treturn response\n}\n\n/**\n * @see https://github.com/changesets/action/blob/main/src/run.ts\n */\nexport type ChangesetsPublishedPackage = {\n\tname: string\n\tversion: string\n}\n\n/**\n * @see https://github.com/changesets/action/blob/main/src/run.ts\n */\nexport type ChangesetsPublishResult =\n\t| {\n\t\t\tpublished: true\n\t\t\tpublishedPackages: ChangesetsPublishedPackage[]\n\t }\n\t| { published: false }\n\nexport type PackageConfig<K extends string> = {\n\t[key in K]: { endpoint: string }\n}\nexport type SecretsConfig<K extends string> = {\n\t[key in K]: string\n}\n\nexport type ScrambleOptions<K extends string = string> = {\n\tpackageConfig: PackageConfig<K>\n\tsecretsConfig: SecretsConfig<K>\n\tpublishedPackages: ChangesetsPublishedPackage[]\n}\n\nexport type ScrambleResult<K extends string = string> = {\n\t[key in K]: Response\n}\n\nexport async function scramble<K extends string = string>({\n\tpackageConfig,\n\tsecretsConfig,\n\tpublishedPackages,\n}: ScrambleOptions<K>): Promise<ScrambleResult<K>> {\n\tconst alertResults: Promise<readonly [K, Response]>[] = []\n\tfor (const publishedPackage of publishedPackages) {\n\t\tif (publishedPackage.name in packageConfig) {\n\t\t\tconst name = publishedPackage.name as K\n\t\t\tconst { endpoint } = packageConfig[name]\n\t\t\tconst secret = secretsConfig[name]\n\t\t\tconst version = publishedPackage.version\n\t\t\tconst alertResultPromise = alert({ secret, endpoint, version }).then(\n\t\t\t\t(alertResult) => [name, alertResult] as const,\n\t\t\t)\n\t\t\talertResults.push(alertResultPromise)\n\t\t}\n\t}\n\tconst alertResultsResolved = await Promise.all(alertResults)\n\tconst scrambleResult = Object.fromEntries(\n\t\talertResultsResolved,\n\t) as ScrambleResult<K>\n\treturn scrambleResult\n}\n"],"mappings":";;;;;;;;AAMA,eAAsB,MAAM,EAC3B,QACA,UACA,WACmC;AAUnC,QATiB,MAAM,MAAM,UAAU;EACtC,QAAQ;EACR,SAAS;GACR,gBAAgB;GAChB,eAAe,UAAU;GACzB;EACD,MAAM;EACN,CAAC;;AAwCH,eAAsB,SAAoC,EACzD,eACA,eACA,qBACkD;CAClD,MAAMA,eAAkD,EAAE;AAC1D,MAAK,MAAM,oBAAoB,kBAC9B,KAAI,iBAAiB,QAAQ,eAAe;EAC3C,MAAM,OAAO,iBAAiB;EAC9B,MAAM,EAAE,aAAa,cAAc;EACnC,MAAM,SAAS,cAAc;EAC7B,MAAM,UAAU,iBAAiB;EACjC,MAAM,qBAAqB,MAAM;GAAE;GAAQ;GAAU;GAAS,CAAC,CAAC,MAC9D,gBAAgB,CAAC,MAAM,YAAY,CACpC;AACD,eAAa,KAAK,mBAAmB;;CAGvC,MAAM,uBAAuB,MAAM,QAAQ,IAAI,aAAa;AAI5D,QAHuB,OAAO,YAC7B,qBACA"}
package/dist/klaxon.x.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { scramble } from "./klaxon.lib-CNw2A3ce.js";
2
+ import { scramble } from "./klaxon.lib-qvkgjVGs.js";
3
3
  import { cli, required } from "comline";
4
4
  import { z } from "zod/v4";
5
5
 
@@ -12,7 +12,7 @@ const changesetsPublishedPackagesSchema = z.object({
12
12
  version: z.string()
13
13
  }))
14
14
  });
15
- const klaxon = cli({
15
+ const { inputs } = cli({
16
16
  cliName: `klaxon`,
17
17
  routes: required({ scramble: null }),
18
18
  routeOptions: { scramble: {
@@ -41,8 +41,7 @@ const klaxon = cli({
41
41
  },
42
42
  optionsSchema: changesetsPublishedPackagesSchema
43
43
  } }
44
- });
45
- const { inputs } = klaxon(process.argv);
44
+ })(process.argv);
46
45
  await scramble(inputs.opts).then((scrambleResult) => {
47
46
  console.log(scrambleResult);
48
47
  });
@@ -1 +1 @@
1
- {"version":3,"file":"klaxon.x.js","names":["changesetsPublishedPackagesSchema: z.ZodSchema<Klaxon.ScrambleOptions>"],"sources":["../src/klaxon.x.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { cli, required } from \"comline\"\nimport { z } from \"zod/v4\"\n\nimport * as Klaxon from \"./klaxon.lib\"\n\nconst changesetsPublishedPackagesSchema: z.ZodSchema<Klaxon.ScrambleOptions> =\n\tz.object({\n\t\tpackageConfig: z.record(z.string(), z.object({ endpoint: z.string() })),\n\t\tsecretsConfig: z.record(z.string(), z.string()),\n\t\tpublishedPackages: z.array(\n\t\t\tz.object({\n\t\t\t\tname: z.string(),\n\t\t\t\tversion: z.string(),\n\t\t\t}),\n\t\t),\n\t})\n\nconst klaxon = cli({\n\tcliName: `klaxon`,\n\troutes: required({\n\t\tscramble: null,\n\t}),\n\trouteOptions: {\n\t\tscramble: {\n\t\t\toptions: {\n\t\t\t\tpackageConfig: {\n\t\t\t\t\tdescription: `Maps the names of your packages to the endpoints that klaxon will POST to.`,\n\t\t\t\t\texample: `--packageConfig=\"{\\\\\"my-app\\\\\":{\\\\\"endpoint\\\\\":\\\\\"https://my-app.com\\\\\"}}\"`,\n\t\t\t\t\tflag: `c`,\n\t\t\t\t\tparse: JSON.parse,\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t\tsecretsConfig: {\n\t\t\t\t\tdescription: `Maps the names of your packages to the secrets that klaxon will use to authenticate with their respective endpoints.`,\n\t\t\t\t\texample: `--secretsConfig=\"{\\\\\"my-app\\\\\":\\\\\"XXXX-XXXX-XXXX\\\\\"}\"`,\n\t\t\t\t\tflag: `s`,\n\t\t\t\t\tparse: JSON.parse,\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t\tpublishedPackages: {\n\t\t\t\t\tdescription: `The output of the \"Publish\" step in Changesets.`,\n\t\t\t\t\texample: `--publishedPackages=\"[{\\\\\"name\\\\\":\\\\\"my-app\\\\\",\\\\\"version\\\\\":\\\\\"0.0.0\\\\\"}]\"`,\n\t\t\t\t\tflag: `p`,\n\t\t\t\t\tparse: JSON.parse,\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t},\n\t\t\toptionsSchema: changesetsPublishedPackagesSchema,\n\t\t},\n\t},\n})\n\nconst { inputs } = klaxon(process.argv)\nawait Klaxon.scramble(inputs.opts).then((scrambleResult) => {\n\tconsole.log(scrambleResult)\n})\n"],"mappings":";;;;;;AAOA,MAAMA,oCACL,EAAE,OAAO;CACR,eAAe,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE;CAC3D,eAAe,EAAE,OAAO,EAAE,UAAU,EAAE;CACtC,mBAAmB,EAAE,MACpB,EAAE,OAAO;EACR,MAAM,EAAE;EACR,SAAS,EAAE;;;AAKf,MAAM,SAAS,IAAI;CAClB,SAAS;CACT,QAAQ,SAAS,EAChB,UAAU;CAEX,cAAc,EACb,UAAU;EACT,SAAS;GACR,eAAe;IACd,aAAa;IACb,SAAS;IACT,MAAM;IACN,OAAO,KAAK;IACZ,UAAU;;GAEX,eAAe;IACd,aAAa;IACb,SAAS;IACT,MAAM;IACN,OAAO,KAAK;IACZ,UAAU;;GAEX,mBAAmB;IAClB,aAAa;IACb,SAAS;IACT,MAAM;IACN,OAAO,KAAK;IACZ,UAAU;;;EAGZ,eAAe;;;AAKlB,MAAM,EAAE,WAAW,OAAO,QAAQ;AAClC,eAAsB,OAAO,MAAM,MAAM,mBAAmB;AAC3D,SAAQ,IAAI"}
1
+ {"version":3,"file":"klaxon.x.js","names":["changesetsPublishedPackagesSchema: z.ZodSchema<Klaxon.ScrambleOptions>"],"sources":["../src/klaxon.x.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { cli, required } from \"comline\"\nimport { z } from \"zod/v4\"\n\nimport * as Klaxon from \"./klaxon.lib\"\n\nconst changesetsPublishedPackagesSchema: z.ZodSchema<Klaxon.ScrambleOptions> =\n\tz.object({\n\t\tpackageConfig: z.record(z.string(), z.object({ endpoint: z.string() })),\n\t\tsecretsConfig: z.record(z.string(), z.string()),\n\t\tpublishedPackages: z.array(\n\t\t\tz.object({\n\t\t\t\tname: z.string(),\n\t\t\t\tversion: z.string(),\n\t\t\t}),\n\t\t),\n\t})\n\nconst klaxon = cli({\n\tcliName: `klaxon`,\n\troutes: required({\n\t\tscramble: null,\n\t}),\n\trouteOptions: {\n\t\tscramble: {\n\t\t\toptions: {\n\t\t\t\tpackageConfig: {\n\t\t\t\t\tdescription: `Maps the names of your packages to the endpoints that klaxon will POST to.`,\n\t\t\t\t\texample: `--packageConfig=\"{\\\\\"my-app\\\\\":{\\\\\"endpoint\\\\\":\\\\\"https://my-app.com\\\\\"}}\"`,\n\t\t\t\t\tflag: `c`,\n\t\t\t\t\tparse: JSON.parse,\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t\tsecretsConfig: {\n\t\t\t\t\tdescription: `Maps the names of your packages to the secrets that klaxon will use to authenticate with their respective endpoints.`,\n\t\t\t\t\texample: `--secretsConfig=\"{\\\\\"my-app\\\\\":\\\\\"XXXX-XXXX-XXXX\\\\\"}\"`,\n\t\t\t\t\tflag: `s`,\n\t\t\t\t\tparse: JSON.parse,\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t\tpublishedPackages: {\n\t\t\t\t\tdescription: `The output of the \"Publish\" step in Changesets.`,\n\t\t\t\t\texample: `--publishedPackages=\"[{\\\\\"name\\\\\":\\\\\"my-app\\\\\",\\\\\"version\\\\\":\\\\\"0.0.0\\\\\"}]\"`,\n\t\t\t\t\tflag: `p`,\n\t\t\t\t\tparse: JSON.parse,\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t},\n\t\t\toptionsSchema: changesetsPublishedPackagesSchema,\n\t\t},\n\t},\n})\n\nconst { inputs } = klaxon(process.argv)\nawait Klaxon.scramble(inputs.opts).then((scrambleResult) => {\n\tconsole.log(scrambleResult)\n})\n"],"mappings":";;;;;;AAOA,MAAMA,oCACL,EAAE,OAAO;CACR,eAAe,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC;CACvE,eAAe,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,QAAQ,CAAC;CAC/C,mBAAmB,EAAE,MACpB,EAAE,OAAO;EACR,MAAM,EAAE,QAAQ;EAChB,SAAS,EAAE,QAAQ;EACnB,CAAC,CACF;CACD,CAAC;AAqCH,MAAM,EAAE,WAnCO,IAAI;CAClB,SAAS;CACT,QAAQ,SAAS,EAChB,UAAU,MACV,CAAC;CACF,cAAc,EACb,UAAU;EACT,SAAS;GACR,eAAe;IACd,aAAa;IACb,SAAS;IACT,MAAM;IACN,OAAO,KAAK;IACZ,UAAU;IACV;GACD,eAAe;IACd,aAAa;IACb,SAAS;IACT,MAAM;IACN,OAAO,KAAK;IACZ,UAAU;IACV;GACD,mBAAmB;IAClB,aAAa;IACb,SAAS;IACT,MAAM;IACN,OAAO,KAAK;IACZ,UAAU;IACV;GACD;EACD,eAAe;EACf,EACD;CACD,CAAC,CAEwB,QAAQ,KAAK;AACvC,eAAsB,OAAO,KAAK,CAAC,MAAM,mBAAmB;AAC3D,SAAQ,IAAI,eAAe;EAC1B"}
package/dist/lib.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod/v4";
2
+ import { ChildProcessWithoutNullStreams } from "node:child_process";
2
3
  import { Future } from "atom.io/internal";
3
4
  import { ChildSocket } from "atom.io/realtime-server";
4
5
  import { CronJob } from "cron";
@@ -819,7 +820,7 @@ declare class FlightDeck<S extends string = string> {
819
820
  }, {
820
821
  readyToUpdate: [];
821
822
  alive: [];
822
- }> | null };
823
+ }, ChildProcessWithoutNullStreams> | null };
823
824
  protected serviceIdx: { readonly [service in S]: number };
824
825
  defaultServicesReadyToUpdate: { readonly [service in S]: boolean };
825
826
  servicesReadyToUpdate: { [service in S]: boolean };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib.d.ts","names":[],"sources":["../gen/lnav-format-schema.gen.ts","../src/fl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AAK;mDAED,IAAI;uCAGW;gBAEhB;gBACA;QACV;QACA;;uBAIiB,kBAAkB;yCAiID;;;gCAgEf;sCAwBM;;;qBA0GV;2BASM;;cA8BpB,eAAA;cACA,eAAA;cACA,gBAAA;cAEA,qBAAmB,CAAA,CAAA;;;;;;;;KAYpB,aAAA,GAAgB,CAAA,CAAE,aAAa;cAErC,WAAA;cACA,KAAA;KAEM,yBAAA,GAA4B,QACvC,QAAQ;KAIG,mBAAA,GAAsB,QAAQ;KAC9B,cAAc,QAAQ;KACtB,yBAAA,GAA4B,SAAS;KAErC,gBAAA;GACV,WAAA,cAEG;iBACY;;GAGf,KAAA,iBACY,gBAAgB;UACrB,cAAc,4CAEjB,cAAc;;;cAOP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAkEA,gBAAA,YACD,KAAK;;;;;;;;8BAqBL,0BACA,yBACA;;;;;;;;KCrkBA,YAAA;;;;;iBAMU,KAAA;;;;GAInB,eAAe,QAAQ;;;;KAgBd,0BAAA;EFxBC,IAAA,EAAA,MAAA;EAihDqC,OAAA,EAAA,MAAA;;;;;KEj/CtC,uBAAA;;qBAGU;;;;KAIV,4CACH;;;KAEG,4CACH;KAGG;iBACI,cAAc;iBACd,cAAc;qBACV;;KAGR,sDACH,IAAI;iBAGS;;;;GAInB,gBAAgB,KAAK,QAAQ,eAAe"}
package/dist/lib.js CHANGED
@@ -1,4 +1,4 @@
1
- import { FLIGHTDECK_ERROR, FLIGHTDECK_INFO, FLIGHTDECK_LNAV_FORMAT, FLIGHTDECK_SETUP_PHASES, FLIGHTDECK_UPDATE_PHASES, FLIGHTDECK_WARN, FlightDeck, FlightDeckLogger, flightDeckLogSchema, isVersionNumber } from "./flightdeck.lib-B3x4c_io.js";
2
- import { klaxon_lib_exports } from "./klaxon.lib-CNw2A3ce.js";
1
+ import { FLIGHTDECK_ERROR, FLIGHTDECK_INFO, FLIGHTDECK_LNAV_FORMAT, FLIGHTDECK_SETUP_PHASES, FLIGHTDECK_UPDATE_PHASES, FLIGHTDECK_WARN, FlightDeck, FlightDeckLogger, flightDeckLogSchema, isVersionNumber } from "./flightdeck.lib-9O00rJ2l.js";
2
+ import { klaxon_lib_exports } from "./klaxon.lib-qvkgjVGs.js";
3
3
 
4
4
  export { FLIGHTDECK_ERROR, FLIGHTDECK_INFO, FLIGHTDECK_LNAV_FORMAT, FLIGHTDECK_SETUP_PHASES, FLIGHTDECK_UPDATE_PHASES, FLIGHTDECK_WARN, FlightDeck, FlightDeckLogger, klaxon_lib_exports as Klaxon, flightDeckLogSchema, isVersionNumber };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flightdeck",
3
- "version": "0.2.74",
3
+ "version": "0.2.76",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Jeremy Banka",
@@ -30,24 +30,24 @@
30
30
  "@t3-oss/env-core": "0.13.8",
31
31
  "cron": "4.3.3",
32
32
  "zod": "3.25.76",
33
- "atom.io": "0.40.6",
34
- "safedeposit": "0.1.1",
35
- "comline": "0.3.0"
33
+ "atom.io": "0.40.7",
34
+ "comline": "0.3.2",
35
+ "safedeposit": "0.1.2"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/bun": "npm:bun-types@1.2.21",
39
39
  "@biomejs/js-api": "3.0.0",
40
40
  "@biomejs/wasm-nodejs": "2.2.2",
41
- "@types/node": "24.3.0",
41
+ "@types/node": "24.3.1",
42
42
  "@types/tmp": "0.2.6",
43
43
  "concurrently": "9.2.1",
44
- "eslint": "9.34.0",
44
+ "eslint": "9.35.0",
45
45
  "json-schema-to-zod": "2.6.1",
46
46
  "rimraf": "6.0.1",
47
47
  "tmp": "0.2.5",
48
48
  "tsdown": "0.14.2",
49
49
  "vitest": "3.2.4",
50
- "varmint": "0.5.4"
50
+ "varmint": "0.5.6"
51
51
  },
52
52
  "scripts": {
53
53
  "gen": "bun ./__scripts__/gen.bun.ts",
@@ -1,4 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/only-throw-error */
2
+ import type { ChildProcessWithoutNullStreams } from "node:child_process"
2
3
  import { execSync, spawn } from "node:child_process"
3
4
  import { createServer } from "node:http"
4
5
  import { homedir } from "node:os"
@@ -55,7 +56,8 @@ export class FlightDeck<S extends string = string> {
55
56
  protected services: {
56
57
  [service in S]: ChildSocket<
57
58
  { timeToStop: []; updatesReady: [] },
58
- { readyToUpdate: []; alive: [] }
59
+ { readyToUpdate: []; alive: [] },
60
+ ChildProcessWithoutNullStreams
59
61
  > | null
60
62
  }
61
63
  protected serviceIdx: { readonly [service in S]: number }
@@ -314,7 +316,7 @@ export class FlightDeck<S extends string = string> {
314
316
  `${this.options.packageName}::${serviceName}`,
315
317
  serviceLogger,
316
318
  ))
317
- serviceLogger.processCode = service.process.pid ?? -1
319
+ serviceLogger.processCode = service.proc.pid ?? -1
318
320
  this.services[serviceName].onAny((...messages) => {
319
321
  serviceLogger.info(`💬`, ...messages)
320
322
  })
@@ -331,7 +333,7 @@ export class FlightDeck<S extends string = string> {
331
333
  }
332
334
  this.dead.use(Promise.all(this.servicesDead))
333
335
  })
334
- this.services[serviceName].process.once(`close`, (exitCode) => {
336
+ this.services[serviceName].proc.once(`close`, (exitCode) => {
335
337
  this.logger.info(
336
338
  `Auto-respawn saw "${serviceName}" exit with code ${exitCode}`,
337
339
  )
@@ -416,7 +418,7 @@ export class FlightDeck<S extends string = string> {
416
418
  this.servicesDead[this.serviceIdx[serviceName]].use(
417
419
  new Promise((pass) => {
418
420
  service.emit(`timeToStop`)
419
- service.process.once(`close`, (exitCode) => {
421
+ service.proc.once(`close`, (exitCode) => {
420
422
  this.logger.info(
421
423
  `Stopped service "${serviceName}"; exited with code ${exitCode}`,
422
424
  )
@@ -1 +0,0 @@
1
- {"version":3,"file":"flightdeck.lib-B3x4c_io.js","names":["data: Uint8Array[]","log: FlightDeckLog"],"sources":["../src/flightdeck.env.ts","../src/flightdeck.lib.ts"],"sourcesContent":["import { createEnv } from \"@t3-oss/env-core\"\nimport { z } from \"zod/v4\"\n\nexport const env = createEnv({\n\tserver: { FLIGHTDECK_SECRET: z.string().optional() },\n\tclientPrefix: `NEVER`,\n\tclient: {},\n\truntimeEnv: import.meta.env as Record<string, string>,\n\temptyStringAsUndefined: true,\n})\n","/* eslint-disable @typescript-eslint/only-throw-error */\nimport { execSync, spawn } from \"node:child_process\"\nimport { createServer } from \"node:http\"\nimport { homedir } from \"node:os\"\nimport { resolve } from \"node:path\"\nimport { inspect } from \"node:util\"\n\nimport { Future } from \"atom.io/internal\"\nimport { discoverType } from \"atom.io/introspection\"\nimport { fromEntries, toEntries } from \"atom.io/json\"\nimport { ChildSocket } from \"atom.io/realtime-server\"\nimport { CronJob } from \"cron\"\nimport { FilesystemStorage } from \"safedeposit\"\nimport { z } from \"zod/v4\"\n\nimport type { LnavFormat } from \"../gen/lnav-format-schema.gen\"\nimport { env } from \"./flightdeck.env\"\n\nexport const FLIGHTDECK_SETUP_PHASES = [`downloaded`, `installed`] as const\n\nexport type FlightDeckSetupPhase = (typeof FLIGHTDECK_SETUP_PHASES)[number]\n\nexport const FLIGHTDECK_UPDATE_PHASES = [`notified`, `confirmed`] as const\n\nexport type FlightDeckUpdatePhase = (typeof FLIGHTDECK_UPDATE_PHASES)[number]\n\nexport function isVersionNumber(version: string): boolean {\n\treturn (\n\t\t/^\\d+\\.\\d+\\.\\d+$/.test(version) || !Number.isNaN(Number.parseFloat(version))\n\t)\n}\n\nexport type FlightDeckOptions<S extends string = string> = {\n\tpackageName: string\n\tservices: { [service in S]: { run: string; waitFor: boolean } }\n\tscripts: {\n\t\tdownload: string\n\t\tinstall: string\n\t\tcheckAvailability?: string\n\t}\n\tport?: number | undefined\n\tflightdeckRootDir?: string | undefined\n\tjsonLogging?: boolean | undefined\n}\n\nexport class FlightDeck<S extends string = string> {\n\tpublic readonly options: FlightDeckOptions<S>\n\tprotected safety = 0\n\n\tprotected storage: FilesystemStorage<{\n\t\tsetupPhase: FlightDeckSetupPhase\n\t\tupdatePhase: FlightDeckUpdatePhase\n\t\tupdateAwaitedVersion: string\n\t}>\n\tprotected services: {\n\t\t[service in S]: ChildSocket<\n\t\t\t{ timeToStop: []; updatesReady: [] },\n\t\t\t{ readyToUpdate: []; alive: [] }\n\t\t> | null\n\t}\n\tprotected serviceIdx: { readonly [service in S]: number }\n\tpublic defaultServicesReadyToUpdate: { readonly [service in S]: boolean }\n\tpublic servicesReadyToUpdate: { [service in S]: boolean }\n\tpublic autoRespawnDeadServices: boolean\n\n\tprotected logger: Pick<Console, `error` | `info` | `warn`>\n\tprotected serviceLoggers: {\n\t\treadonly [service in S]: FlightDeckLogger\n\t}\n\n\tprotected updateAvailabilityChecker: CronJob | null = null\n\n\tpublic servicesLive: Future<void>[]\n\tpublic servicesDead: Future<void>[]\n\tpublic live = new Future(() => {})\n\tpublic dead = new Future(() => {})\n\n\tprotected restartTimes: number[] = []\n\n\tpublic constructor(options: FlightDeckOptions<S>) {\n\t\tthis.options = options\n\t\tconst { FLIGHTDECK_SECRET } = env\n\t\tconst { flightdeckRootDir = resolve(homedir(), `.flightdeck`) } = options\n\t\tconst port = options.port ?? 8080\n\t\tconst origin = `http://localhost:${port}`\n\n\t\tconst servicesEntries = toEntries(options.services)\n\t\tthis.services = fromEntries(\n\t\t\tservicesEntries.map(([serviceName]) => [serviceName, null]),\n\t\t)\n\t\tthis.serviceIdx = fromEntries(\n\t\t\tservicesEntries.map(([serviceName], idx) => [serviceName, idx]),\n\t\t)\n\t\tthis.defaultServicesReadyToUpdate = fromEntries(\n\t\t\tservicesEntries.map(([serviceName, { waitFor }]) => [\n\t\t\t\tserviceName,\n\t\t\t\t!waitFor,\n\t\t\t]),\n\t\t)\n\t\tthis.servicesReadyToUpdate = { ...this.defaultServicesReadyToUpdate }\n\t\tthis.autoRespawnDeadServices = true\n\n\t\tthis.logger = new FlightDeckLogger(\n\t\t\tthis.options.packageName,\n\t\t\tprocess.pid,\n\t\t\tundefined,\n\t\t\t{ jsonLogging: this.options.jsonLogging ?? false },\n\t\t)\n\t\tthis.serviceLoggers = fromEntries(\n\t\t\tservicesEntries.map(([serviceName]) => [\n\t\t\t\tserviceName,\n\t\t\t\tnew FlightDeckLogger(\n\t\t\t\t\tthis.options.packageName,\n\t\t\t\t\tprocess.pid,\n\t\t\t\t\tserviceName,\n\t\t\t\t\t{ jsonLogging: this.options.jsonLogging ?? false },\n\t\t\t\t),\n\t\t\t]),\n\t\t)\n\n\t\tthis.servicesLive = servicesEntries.map(() => new Future(() => {}))\n\t\tthis.servicesDead = servicesEntries.map(() => new Future(() => {}))\n\t\tthis.live.use(Promise.all(this.servicesLive))\n\t\tthis.dead.use(Promise.all(this.servicesDead))\n\n\t\tthis.storage = new FilesystemStorage({\n\t\t\tpath: resolve(flightdeckRootDir, `storage`, options.packageName),\n\t\t})\n\n\t\tif (FLIGHTDECK_SECRET === undefined) {\n\t\t\tthis.logger.warn(\n\t\t\t\t`No FLIGHTDECK_SECRET environment variable found. FlightDeck will not run an update server.`,\n\t\t\t)\n\t\t} else {\n\t\t\tcreateServer((req, res) => {\n\t\t\t\tlet data: Uint8Array[] = []\n\t\t\t\treq\n\t\t\t\t\t.on(`data`, (chunk) => {\n\t\t\t\t\t\tdata.push(chunk instanceof Buffer ? chunk : Buffer.from(chunk))\n\t\t\t\t\t})\n\t\t\t\t\t.on(`end`, async () => {\n\t\t\t\t\t\tconst authHeader = req.headers.authorization\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tif (typeof req.url === `undefined`) throw 400\n\t\t\t\t\t\t\tconst expectedAuthHeader = `Bearer ${FLIGHTDECK_SECRET}`\n\t\t\t\t\t\t\tif (authHeader !== `Bearer ${FLIGHTDECK_SECRET}`) {\n\t\t\t\t\t\t\t\tthis.logger.info(\n\t\t\t\t\t\t\t\t\t`Unauthorized: needed \\`${expectedAuthHeader}\\`, got \\`${authHeader}\\``,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tthrow 401\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst url = new URL(req.url, origin)\n\t\t\t\t\t\t\tthis.logger.info(req.method, url.pathname)\n\n\t\t\t\t\t\t\tconst versionForeignInput = Buffer.concat(data).toString()\n\t\t\t\t\t\t\tif (!isVersionNumber(versionForeignInput)) {\n\t\t\t\t\t\t\t\tthrow 400\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tres.writeHead(200)\n\t\t\t\t\t\t\tres.end()\n\n\t\t\t\t\t\t\tthis.storage.setItem(`updatePhase`, `notified`)\n\t\t\t\t\t\t\tthis.storage.setItem(`updateAwaitedVersion`, versionForeignInput)\n\t\t\t\t\t\t\tconst { checkAvailability } = options.scripts\n\t\t\t\t\t\t\tif (checkAvailability) {\n\t\t\t\t\t\t\t\tawait this.updateAvailabilityChecker?.stop()\n\t\t\t\t\t\t\t\tawait this.seekUpdate(versionForeignInput)\n\t\t\t\t\t\t\t\tconst updatePhase = this.storage.getItem(`updatePhase`)\n\t\t\t\t\t\t\t\tthis.logger.info(`> storage(\"updatePhase\") >`, updatePhase)\n\t\t\t\t\t\t\t\tif (updatePhase === `notified`) {\n\t\t\t\t\t\t\t\t\tthis.updateAvailabilityChecker = new CronJob(\n\t\t\t\t\t\t\t\t\t\t`*/30 * * * * *`,\n\t\t\t\t\t\t\t\t\t\tasync () => {\n\t\t\t\t\t\t\t\t\t\t\tawait this.seekUpdate(versionForeignInput)\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tthis.updateAvailabilityChecker.start()\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthis.downloadPackage()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (thrown) {\n\t\t\t\t\t\t\tthis.logger.error(thrown, req.url)\n\t\t\t\t\t\t\tif (typeof thrown === `number`) {\n\t\t\t\t\t\t\t\tres.writeHead(thrown)\n\t\t\t\t\t\t\t\tres.end()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} finally {\n\t\t\t\t\t\t\tdata = []\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t}).listen(port, () => {\n\t\t\t\tthis.logger.info(`Server started on port ${port}`)\n\t\t\t})\n\t\t}\n\n\t\tthis.startAllServices()\n\t\t\t.then(() => {\n\t\t\t\tthis.logger.info(`All services started.`)\n\t\t\t})\n\t\t\t.catch((thrown) => {\n\t\t\t\tif (thrown instanceof Error) {\n\t\t\t\t\tthis.logger.error(`Failed to start all services:`, thrown.message)\n\t\t\t\t}\n\t\t\t})\n\t}\n\n\tprotected async seekUpdate(version: string): Promise<void> {\n\t\tthis.logger.info(`Checking for updates...`)\n\t\tconst { checkAvailability } = this.options.scripts\n\t\tif (!checkAvailability) {\n\t\t\tthis.logger.info(`No checkAvailability script found.`)\n\t\t\treturn\n\t\t}\n\t\ttry {\n\t\t\tconst out = execSync(`${checkAvailability} ${version}`)\n\t\t\tthis.logger.info(`Check stdout:`, out.toString())\n\t\t\tawait this.updateAvailabilityChecker?.stop()\n\t\t\tthis.storage.setItem(`updatePhase`, `confirmed`)\n\t\t\tthis.downloadPackage()\n\t\t\tthis.announceUpdate()\n\t\t} catch (thrown) {\n\t\t\tif (thrown instanceof Error) {\n\t\t\t\tthis.logger.error(`Check failed:`, thrown.message)\n\t\t\t} else {\n\t\t\t\tconst thrownType = discoverType(thrown)\n\t\t\t\tthis.logger.error(`Check threw`, thrownType, thrown)\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected announceUpdate(): void {\n\t\tfor (const entry of toEntries(this.services)) {\n\t\t\tconst [serviceName, service] = entry\n\t\t\tif (service) {\n\t\t\t\tif (this.options.services[serviceName].waitFor) {\n\t\t\t\t\tservice.emit(`updatesReady`)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.startService(serviceName)\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected tryUpdate(): void {\n\t\tif (toEntries(this.servicesReadyToUpdate).every(([, isReady]) => isReady)) {\n\t\t\tthis.logger.info(`All services are ready to update.`)\n\t\t\tthis.stopAllServices()\n\t\t\t\t.then(() => {\n\t\t\t\t\tthis.logger.info(`All services stopped; starting up fresh...`)\n\t\t\t\t\tthis.startAllServices()\n\t\t\t\t\t\t.then(() => {\n\t\t\t\t\t\t\tthis.logger.info(`All services started; we're back online.`)\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch((thrown) => {\n\t\t\t\t\t\t\tif (thrown instanceof Error) {\n\t\t\t\t\t\t\t\tthis.logger.error(\n\t\t\t\t\t\t\t\t\t`Failed to start all services:`,\n\t\t\t\t\t\t\t\t\tthrown.message,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t\t.catch((thrown) => {\n\t\t\t\t\tif (thrown instanceof Error) {\n\t\t\t\t\t\tthis.logger.error(`Failed to stop all services:`, thrown.message)\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t}\n\t}\n\n\tprotected startAllServices(): Future<unknown> {\n\t\tthis.logger.info(`Starting all services...`)\n\t\tthis.autoRespawnDeadServices = true\n\t\tconst setupPhase = this.storage.getItem(`setupPhase`)\n\t\tthis.logger.info(`> storage(\"setupPhase\") >`, setupPhase)\n\t\tswitch (setupPhase) {\n\t\t\tcase null:\n\t\t\t\tthis.logger.info(`Starting from scratch.`)\n\t\t\t\tthis.downloadPackage()\n\t\t\t\tthis.installPackage()\n\t\t\t\treturn this.startAllServices()\n\t\t\tcase `downloaded`:\n\t\t\t\tthis.logger.info(`Found package downloaded but not installed.`)\n\t\t\t\tthis.installPackage()\n\t\t\t\treturn this.startAllServices()\n\t\t\tcase `installed`: {\n\t\t\t\tfor (const [serviceName] of toEntries(this.services)) {\n\t\t\t\t\tthis.startService(serviceName)\n\t\t\t\t}\n\t\t\t\treturn this.live\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected startService(serviceName: S): void {\n\t\tthis.logger.info(\n\t\t\t`Starting service ${this.options.packageName}::${serviceName}, try ${this.safety}/2...`,\n\t\t)\n\t\tif (this.safety >= 2) {\n\t\t\tthrow new Error(`Out of tries...`)\n\t\t}\n\t\tthis.safety++\n\n\t\tconst [exe, ...args] = this.options.services[serviceName].run.split(` `)\n\t\tconst serviceProcess = spawn(exe, args, {\n\t\t\tcwd: this.options.flightdeckRootDir,\n\t\t\tenv: import.meta.env as Record<string, string>,\n\t\t})\n\t\tconst serviceLogger = this.serviceLoggers[serviceName]\n\t\tconst service = (this.services[serviceName] = new ChildSocket(\n\t\t\tserviceProcess,\n\t\t\t`${this.options.packageName}::${serviceName}`,\n\t\t\tserviceLogger,\n\t\t))\n\t\tserviceLogger.processCode = service.process.pid ?? -1\n\t\tthis.services[serviceName].onAny((...messages) => {\n\t\t\tserviceLogger.info(`💬`, ...messages)\n\t\t})\n\t\tthis.services[serviceName].on(`readyToUpdate`, () => {\n\t\t\tthis.logger.info(`Service \"${serviceName}\" is ready to update.`)\n\t\t\tthis.servicesReadyToUpdate[serviceName] = true\n\t\t\tthis.tryUpdate()\n\t\t})\n\t\tthis.services[serviceName].on(`alive`, () => {\n\t\t\tthis.servicesLive[this.serviceIdx[serviceName]].use(Promise.resolve())\n\t\t\tthis.servicesDead[this.serviceIdx[serviceName]] = new Future(() => {})\n\t\t\tif (this.dead.done) {\n\t\t\t\tthis.dead = new Future(() => {})\n\t\t\t}\n\t\t\tthis.dead.use(Promise.all(this.servicesDead))\n\t\t})\n\t\tthis.services[serviceName].process.once(`close`, (exitCode) => {\n\t\t\tthis.logger.info(\n\t\t\t\t`Auto-respawn saw \"${serviceName}\" exit with code ${exitCode}`,\n\t\t\t)\n\t\t\tthis.services[serviceName] = null\n\t\t\tif (!this.autoRespawnDeadServices) {\n\t\t\t\tthis.logger.info(`Auto-respawn is off; \"${serviceName}\" rests.`)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst updatePhase = this.storage.getItem(`updatePhase`)\n\t\t\tthis.logger.info(`> storage(\"updatePhase\") >`, updatePhase)\n\t\t\tconst updatesAreReady = updatePhase === `confirmed`\n\t\t\tif (updatesAreReady) {\n\t\t\t\tthis.serviceLoggers[serviceName].info(`Updating before startup...`)\n\t\t\t\tthis.restartTimes = []\n\t\t\t\tthis.installPackage()\n\t\t\t\tthis.startService(serviceName)\n\t\t\t} else {\n\t\t\t\tconst now = Date.now()\n\t\t\t\tconst fiveMinutesAgo = now - 5 * 60 * 1000\n\t\t\t\tthis.restartTimes = this.restartTimes.filter(\n\t\t\t\t\t(time) => time > fiveMinutesAgo,\n\t\t\t\t)\n\t\t\t\tthis.restartTimes.push(now)\n\n\t\t\t\tif (this.restartTimes.length < 5) {\n\t\t\t\t\tthis.serviceLoggers[serviceName].info(`Crashed. Restarting...`)\n\t\t\t\t\tthis.startService(serviceName)\n\t\t\t\t} else {\n\t\t\t\t\tthis.serviceLoggers[serviceName].info(\n\t\t\t\t\t\t`Crashed 5 times in 5 minutes. Not restarting.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\tthis.safety = 0\n\t}\n\n\tprotected downloadPackage(): void {\n\t\tthis.logger.info(`Downloading...`)\n\t\ttry {\n\t\t\tconst out = execSync(this.options.scripts.download)\n\t\t\tthis.logger.info(`Download stdout:`, out.toString())\n\t\t\tthis.storage.setItem(`setupPhase`, `downloaded`)\n\t\t\tthis.logger.info(`Downloaded!`)\n\t\t} catch (thrown) {\n\t\t\tif (thrown instanceof Error) {\n\t\t\t\tthis.logger.error(`Failed to get the latest release: ${thrown.message}`)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t}\n\n\tprotected installPackage(): void {\n\t\tthis.logger.info(`Installing...`)\n\n\t\ttry {\n\t\t\tconst out = execSync(this.options.scripts.install)\n\t\t\tthis.logger.info(`Install stdout:`, out.toString())\n\t\t\tthis.storage.setItem(`setupPhase`, `installed`)\n\t\t\tthis.logger.info(`Installed!`)\n\t\t} catch (thrown) {\n\t\t\tif (thrown instanceof Error) {\n\t\t\t\tthis.logger.error(`Failed to get the latest release: ${thrown.message}`)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t}\n\n\tpublic stopAllServices(): Future<unknown> {\n\t\tthis.logger.info(`Stopping all services... auto-respawn disabled.`)\n\t\tthis.autoRespawnDeadServices = false\n\t\tfor (const [serviceName] of toEntries(this.services)) {\n\t\t\tthis.stopService(serviceName)\n\t\t}\n\t\treturn this.dead\n\t}\n\n\tpublic stopService(serviceName: S): void {\n\t\tconst service = this.services[serviceName]\n\t\tif (service) {\n\t\t\tthis.logger.info(`Stopping service \"${serviceName}\"...`)\n\t\t\tthis.servicesDead[this.serviceIdx[serviceName]].use(\n\t\t\t\tnew Promise((pass) => {\n\t\t\t\t\tservice.emit(`timeToStop`)\n\t\t\t\t\tservice.process.once(`close`, (exitCode) => {\n\t\t\t\t\t\tthis.logger.info(\n\t\t\t\t\t\t\t`Stopped service \"${serviceName}\"; exited with code ${exitCode}`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\tthis.services[serviceName] = null\n\t\t\t\t\t\tpass()\n\t\t\t\t\t})\n\t\t\t\t}),\n\t\t\t)\n\t\t\tthis.dead.use(Promise.all(this.servicesDead))\n\t\t\tthis.servicesLive[this.serviceIdx[serviceName]] = new Future(() => {})\n\t\t\tif (this.live.done) {\n\t\t\t\tthis.live = new Future(() => {})\n\t\t\t}\n\t\t\tthis.live.use(Promise.all(this.servicesLive))\n\t\t} else {\n\t\t\tthis.serviceLoggers[serviceName].error(\n\t\t\t\t`Tried to stop service, but it wasn't running.`,\n\t\t\t)\n\t\t}\n\t}\n}\n\nexport const FLIGHTDECK_INFO = `info`\nexport const FLIGHTDECK_WARN = `warn`\nexport const FLIGHTDECK_ERROR = `ERR!`\n\nexport const flightDeckLogSchema = z.object({\n\tlevel: z.union([\n\t\tz.literal(FLIGHTDECK_INFO),\n\t\tz.literal(FLIGHTDECK_WARN),\n\t\tz.literal(FLIGHTDECK_ERROR),\n\t]),\n\ttimestamp: z.number(),\n\tpackage: z.string(),\n\tservice: z.string().optional(),\n\tprocess: z.number(),\n\tbody: z.string(),\n})\nexport type FlightDeckLog = z.infer<typeof flightDeckLogSchema>\n\nconst LINE_FORMAT = `line-format` satisfies keyof LnavFormat\nconst VALUE = `value` satisfies keyof LnavFormat\n\nexport type LnavFormatVisualComponent = Exclude<\n\tExclude<LnavFormat[`line-format`], undefined>[number],\n\tstring\n>\n\nexport type LnavFormatBreakdown = Exclude<LnavFormat[`value`], undefined>\nexport type MemberOf<T> = T[keyof T]\nexport type LnavFormatValueDefinition = MemberOf<LnavFormatBreakdown>\n\nexport type FlightDeckFormat = {\n\t[LINE_FORMAT]: (\n\t\t| string\n\t\t| (LnavFormatVisualComponent & {\n\t\t\t\tfield: keyof FlightDeckLog | `__level__` | `__timestamp__`\n\t\t })\n\t)[]\n\t[VALUE]: {\n\t\t[K in keyof FlightDeckLog]: LnavFormatValueDefinition & {\n\t\t\tkind: FlightDeckLog[K] extends number | undefined\n\t\t\t\t? `integer`\n\t\t\t\t: FlightDeckLog[K] extends string | undefined\n\t\t\t\t\t? `string`\n\t\t\t\t\t: never\n\t\t}\n\t}\n}\n\nexport const FLIGHTDECK_LNAV_FORMAT = {\n\ttitle: `FlightDeck Log`,\n\tdescription: `Format for events logged by the FlightDeck process manager.`,\n\t\"file-type\": `json`,\n\t\"timestamp-field\": `timestamp`,\n\t\"timestamp-divisor\": 1000,\n\t\"module-field\": `package`,\n\t\"opid-field\": `service`,\n\t\"level-field\": `level`,\n\tlevel: {\n\t\tinfo: FLIGHTDECK_INFO,\n\t\twarning: FLIGHTDECK_WARN,\n\t\terror: FLIGHTDECK_ERROR,\n\t},\n\n\t[LINE_FORMAT]: [\n\t\t{\n\t\t\tfield: `level`,\n\t\t},\n\t\t{\n\t\t\tprefix: ` `,\n\t\t\tfield: `__timestamp__`,\n\t\t\t\"timestamp-format\": `%Y-%m-%dT%H:%M:%S.%L%Z`,\n\t\t},\n\t\t{\n\t\t\tprefix: ` `,\n\t\t\tfield: `process`,\n\t\t\t\"min-width\": 5,\n\t\t},\n\t\t{\n\t\t\tprefix: `:`,\n\t\t\tfield: `package`,\n\t\t},\n\t\t{\n\t\t\tprefix: `:`,\n\t\t\tfield: `service`,\n\t\t\t\"default-value\": ``,\n\t\t},\n\t\t{\n\t\t\tprefix: `: `,\n\t\t\tfield: `body`,\n\t\t},\n\t],\n\n\t[VALUE]: {\n\t\ttimestamp: {\n\t\t\tkind: `integer`,\n\t\t},\n\t\tlevel: {\n\t\t\tkind: `string`,\n\t\t},\n\t\tpackage: {\n\t\t\tkind: `string`,\n\t\t},\n\t\tservice: {\n\t\t\tkind: `string`,\n\t\t},\n\t\tprocess: {\n\t\t\tkind: `integer`,\n\t\t},\n\t\tbody: {\n\t\t\tkind: `string`,\n\t\t},\n\t},\n} as const satisfies FlightDeckFormat & LnavFormat\n\nexport class FlightDeckLogger\n\timplements Pick<Console, `error` | `info` | `warn`>\n{\n\tpublic readonly packageName: string\n\tpublic readonly serviceName?: string\n\tpublic readonly jsonLogging: boolean\n\tpublic processCode: number\n\tpublic constructor(\n\t\tpackageName: string,\n\t\tprocessCode: number,\n\t\tserviceName?: string,\n\t\toptions?: { jsonLogging: boolean },\n\t) {\n\t\tthis.packageName = packageName\n\t\tif (serviceName) {\n\t\t\tthis.serviceName = serviceName\n\t\t}\n\t\tthis.processCode = processCode\n\t\tthis.jsonLogging = options?.jsonLogging ?? false\n\t}\n\tprotected log(\n\t\tlevel:\n\t\t\t| typeof FLIGHTDECK_ERROR\n\t\t\t| typeof FLIGHTDECK_INFO\n\t\t\t| typeof FLIGHTDECK_WARN,\n\t\t...messages: unknown[]\n\t): void {\n\t\tif (this.jsonLogging) {\n\t\t\tlet body = messages\n\t\t\t\t.map((message) =>\n\t\t\t\t\ttypeof message === `string`\n\t\t\t\t\t\t? message\n\t\t\t\t\t\t: inspect(message, false, null, true),\n\t\t\t\t)\n\t\t\t\t.join(` `)\n\t\t\tif (body.includes(`\\n`)) {\n\t\t\t\tbody = `\\n ${body.split(`\\n`).join(`\\n `)}`\n\t\t\t}\n\t\t\tconst log: FlightDeckLog = {\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t\tlevel,\n\t\t\t\tprocess: this.processCode,\n\t\t\t\tpackage: this.packageName,\n\t\t\t\tbody,\n\t\t\t}\n\t\t\tif (this.serviceName) {\n\t\t\t\tlog.service = this.serviceName\n\t\t\t}\n\t\t\tprocess.stdout.write(JSON.stringify(log) + `\\n`)\n\t\t} else {\n\t\t\tconst source = this.serviceName\n\t\t\t\t? `${this.packageName}:${this.serviceName}`\n\t\t\t\t: this.packageName\n\t\t\tswitch (level) {\n\t\t\t\tcase FLIGHTDECK_INFO:\n\t\t\t\t\tconsole.log(`${source}:`, ...messages)\n\t\t\t\t\tbreak\n\t\t\t\tcase FLIGHTDECK_WARN:\n\t\t\t\t\tconsole.warn(`${source}:`, ...messages)\n\t\t\t\t\tbreak\n\t\t\t\tcase FLIGHTDECK_ERROR:\n\t\t\t\t\tconsole.error(`${source}:`, ...messages)\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tpublic info(...messages: unknown[]): void {\n\t\tthis.log(FLIGHTDECK_INFO, ...messages)\n\t}\n\n\tpublic warn(...messages: unknown[]): void {\n\t\tthis.log(FLIGHTDECK_WARN, ...messages)\n\t}\n\n\tpublic error(...messages: unknown[]): void {\n\t\tthis.log(FLIGHTDECK_ERROR, ...messages)\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;AAGA,MAAa,MAAM,UAAU;CAC5B,QAAQ,EAAE,mBAAmB,EAAE,SAAS;CACxC,cAAc;CACd,QAAQ;CACR,YAAY,OAAO,KAAK;CACxB,wBAAwB;;;;;ACUzB,MAAa,0BAA0B,CAAC,cAAc;AAItD,MAAa,2BAA2B,CAAC,YAAY;AAIrD,SAAgB,gBAAgB,SAA0B;AACzD,QACC,kBAAkB,KAAK,YAAY,CAAC,OAAO,MAAM,OAAO,WAAW;;AAiBrE,IAAa,aAAb,MAAm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