flightdeck 0.2.0 → 0.2.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.
@@ -37,11 +37,15 @@
37
37
  },
38
38
  "install": {
39
39
  "type": "string"
40
+ },
41
+ "checkAvailability": {
42
+ "type": "string"
40
43
  }
41
44
  },
42
45
  "required": [
43
46
  "download",
44
- "install"
47
+ "install",
48
+ "checkAvailability"
45
49
  ],
46
50
  "additionalProperties": false
47
51
  }
@@ -7,14 +7,16 @@ import { z } from "zod";
7
7
  // src/klaxon.lib.ts
8
8
  async function alert({
9
9
  secret,
10
- endpoint
10
+ endpoint,
11
+ version
11
12
  }) {
12
13
  const response = await fetch(endpoint, {
13
14
  method: `POST`,
14
15
  headers: {
15
- "Content-Type": `application/json`,
16
+ "Content-Type": `text/plain;charset=UTF-8`,
16
17
  Authorization: `Bearer ${secret}`
17
- }
18
+ },
19
+ body: version
18
20
  });
19
21
  return response;
20
22
  }
@@ -29,7 +31,8 @@ async function scramble({
29
31
  const name = publishedPackage.name;
30
32
  const { endpoint } = packageConfig[name];
31
33
  const secret = secretsConfig[name];
32
- const alertResultPromise = alert({ secret, endpoint }).then((alertResult) => [name, alertResult]);
34
+ const version = publishedPackage.version;
35
+ const alertResultPromise = alert({ secret, endpoint, version }).then((alertResult) => [name, alertResult]);
33
36
  alertResults.push(alertResultPromise);
34
37
  }
35
38
  }
package/dist/lib.d.ts CHANGED
@@ -1,7 +1,27 @@
1
1
  import { Server } from 'node:http';
2
2
  import { Future } from 'atom.io/internal';
3
3
  import { ChildSocket } from 'atom.io/realtime-server';
4
+ import { CronJob } from 'cron';
4
5
 
6
+ type FilesystemStorageOptions = {
7
+ path: string;
8
+ };
9
+ declare class FilesystemStorage<T extends Record<string, string> = Record<string, string>> implements Storage {
10
+ rootDir: string;
11
+ constructor(options: FilesystemStorageOptions);
12
+ getItem<K extends string & keyof T>(key: K): T[K] | null;
13
+ setItem<K extends string & keyof T>(key: K, value: T[K]): void;
14
+ removeItem<K extends string & keyof T>(key: K): void;
15
+ key(index: number): (string & keyof T) | null;
16
+ clear(): void;
17
+ get length(): number;
18
+ }
19
+
20
+ declare const FLIGHTDECK_SETUP_PHASES: readonly ["downloaded", "installed"];
21
+ type FlightDeckSetupPhase = (typeof FLIGHTDECK_SETUP_PHASES)[number];
22
+ declare const FLIGHTDECK_UPDATE_PHASES: readonly ["notified", "confirmed"];
23
+ type FlightDeckUpdatePhase = (typeof FLIGHTDECK_UPDATE_PHASES)[number];
24
+ declare function isVersionNumber(version: string): boolean;
5
25
  type FlightDeckOptions<S extends string = string> = {
6
26
  packageName: string;
7
27
  services: {
@@ -13,6 +33,7 @@ type FlightDeckOptions<S extends string = string> = {
13
33
  scripts: {
14
34
  download: string;
15
35
  install: string;
36
+ checkAvailability?: string;
16
37
  };
17
38
  port?: number | undefined;
18
39
  flightdeckRootDir?: string | undefined;
@@ -20,6 +41,11 @@ type FlightDeckOptions<S extends string = string> = {
20
41
  declare class FlightDeck<S extends string = string> {
21
42
  readonly options: FlightDeckOptions<S>;
22
43
  protected safety: number;
44
+ protected storage: FilesystemStorage<{
45
+ setupPhase: FlightDeckSetupPhase;
46
+ updatePhase: FlightDeckUpdatePhase;
47
+ updateAwaitedVersion: string;
48
+ }>;
23
49
  protected webhookServer: Server;
24
50
  protected services: {
25
51
  [service in S]: ChildSocket<{
@@ -39,23 +65,25 @@ declare class FlightDeck<S extends string = string> {
39
65
  servicesReadyToUpdate: {
40
66
  [service in S]: boolean;
41
67
  };
42
- servicesShouldRestart: boolean;
68
+ autoRespawnDeadServices: boolean;
43
69
  protected logger: Pick<Console, `error` | `info` | `warn`>;
44
70
  protected serviceLoggers: {
45
71
  readonly [service in S]: Pick<Console, `error` | `info` | `warn`>;
46
72
  };
73
+ protected updateAvailabilityChecker: CronJob | null;
47
74
  servicesLive: Future<void>[];
48
75
  servicesDead: Future<void>[];
49
76
  live: Future<unknown>;
50
77
  dead: Future<unknown>;
51
78
  protected restartTimes: number[];
52
- protected persistentStateDir: string;
53
79
  constructor(options: FlightDeckOptions<S>);
80
+ protected seekUpdate(version: string): void;
81
+ protected announceUpdate(): void;
54
82
  protected tryUpdate(): void;
55
83
  protected startAllServices(): Future<unknown>;
56
84
  protected startService(serviceName: S): void;
57
- protected applyUpdate(): void;
58
- protected getLatestRelease(): void;
85
+ protected downloadPackage(): void;
86
+ protected installPackage(): void;
59
87
  stopAllServices(): Future<unknown>;
60
88
  stopService(serviceName: S): void;
61
89
  }
@@ -63,8 +91,9 @@ declare class FlightDeck<S extends string = string> {
63
91
  type AlertOptions = {
64
92
  secret: string;
65
93
  endpoint: string;
94
+ version: string;
66
95
  };
67
- declare function alert({ secret, endpoint, }: AlertOptions): Promise<Response>;
96
+ declare function alert({ secret, endpoint, version, }: AlertOptions): Promise<Response>;
68
97
  /**
69
98
  * @see https://github.com/changesets/action/blob/main/src/run.ts
70
99
  */
@@ -112,4 +141,4 @@ declare namespace klaxon_lib {
112
141
  export { type klaxon_lib_AlertOptions as AlertOptions, type klaxon_lib_ChangesetsPublishResult as ChangesetsPublishResult, type klaxon_lib_ChangesetsPublishedPackage as ChangesetsPublishedPackage, type klaxon_lib_PackageConfig as PackageConfig, type klaxon_lib_ScrambleOptions as ScrambleOptions, type klaxon_lib_ScrambleResult as ScrambleResult, type klaxon_lib_SecretsConfig as SecretsConfig, klaxon_lib_alert as alert, klaxon_lib_scramble as scramble };
113
142
  }
114
143
 
115
- export { FlightDeck, type FlightDeckOptions, klaxon_lib as Klaxon };
144
+ export { FLIGHTDECK_SETUP_PHASES, FLIGHTDECK_UPDATE_PHASES, FilesystemStorage, type FilesystemStorageOptions, FlightDeck, type FlightDeckOptions, type FlightDeckSetupPhase, type FlightDeckUpdatePhase, klaxon_lib as Klaxon, isVersionNumber };