| @@ -18,28 +18,22 @@ export const bootServiceLayer = (config: ServerConfig.ServerConfig["Service"]) = · 17 unmodified lines |
| 18 | cliVersion: packageJson.version, | 18 | cliVersion: packageJson.version, |
| 19 | }).pipe(Layer.provide(ProcessRunner.layer)); | 19 | }).pipe(Layer.provide(ProcessRunner.layer)); |
| 20 | | 20 | |
| 21 | export type ServiceReconcileResult = | 21 | export interface ServiceReconcileResult { |
| 22 | | { | 22 | readonly changed: true; |
| 23 | readonly changed: false; | 23 | readonly previouslyInstalled: boolean; |
| 24 | readonly status: BootService.BootServiceStatus; | 24 | readonly previouslyCurrent: boolean; |
| 25 | } | 25 | readonly plan: BootService.BootServicePlan; |
| 26 | | { | 26 | } |
| 27 | readonly changed: true; | | |
| 28 | readonly previouslyInstalled: boolean; | | |
| 29 | readonly plan: BootService.BootServicePlan; | | |
| 30 | }; | | |
| 31 | | 27 | |
| 32 | /** Install, update, or repair the service using the CLI version running this command. */ | 28 | /** Install, update, or repair the service using the CLI version running this command. */ |
| 33 | export const reconcileService = Effect.fn("cli.service.reconcile")(function* () { | 29 | export const reconcileService = Effect.fn("cli.service.reconcile")(function* () { |
| 34 | const service = yield* BootService.BootService; | 30 | const service = yield* BootService.BootService; |
| 35 | const status = yield* service.status; | 31 | const status = yield* service.status; |
| 36 | if (status.installed && status.current) { | | |
| 37 | return { changed: false, status } satisfies ServiceReconcileResult; | | |
| 38 | } | | |
| 39 | const plan = yield* service.install; | 32 | const plan = yield* service.install; |
| 40 | return { | 33 | return { |
| 41 | changed: true, | 34 | changed: true, |
| 42 | previouslyInstalled: status.installed, | 35 | previouslyInstalled: status.installed, |
| | 36 | previouslyCurrent: status.current, |
| 43 | plan, | 37 | plan, |
| 44 | } satisfies ServiceReconcileResult; | 38 | } satisfies ServiceReconcileResult; |
| 45 | }); | 39 | }); |
| @@ -79,14 +73,13 @@ const serviceInstallCommand = Command.make("install", projectLocationFlags).pipe · 33 unmodified lines |
| 79 | flags, | 73 | flags, |
| 80 | Effect.gen(function* () { | 74 | Effect.gen(function* () { |
| 81 | const result = yield* reconcileService(); | 75 | const result = yield* reconcileService(); |
| 82 | if (!result.changed) { | 76 | const action = result.previouslyCurrent |
| 83 | yield* Console.log( | 77 | ? "Restarted" |
| 84 | `T3 Code service is already installed with t3@${packageJson.version}.`, | 78 | : result.previouslyInstalled |
| 85 | ); | 79 | ? "Updated and restarted" |
| 86 | return; | 80 | : "Installed and started"; |
| 87 | } | | |
| 88 | yield* Console.log( | 81 | yield* Console.log( |
| 89 | `${result.previouslyInstalled ? "Updated" : "Installed"} T3 Code service with t3@${packageJson.version}.\nLogs: ${result.plan.logPath}`, | 82 | `${action} T3 Code service with t3@${packageJson.version}.\nLogs: ${result.plan.logPath}`, |
| 90 | ); | 83 | ); |
| 91 | }), | 84 | }), |
| 92 | ), | 85 | ), |
| @@ -102,12 +95,13 @@ const serviceUpdateCommand = Command.make("update", projectLocationFlags).pipe( · 9 unmodified lines |
| 102 | flags, | 95 | flags, |
| 103 | Effect.gen(function* () { | 96 | Effect.gen(function* () { |
| 104 | const result = yield* reconcileService(); | 97 | const result = yield* reconcileService(); |
| 105 | if (!result.changed) { | 98 | const action = result.previouslyCurrent |
| 106 | yield* Console.log(`T3 Code service is already using t3@${packageJson.version}.`); | 99 | ? "Restarted" |
| 107 | return; | 100 | : result.previouslyInstalled |
| 108 | } | 101 | ? "Updated and restarted" |
| | 102 | : "Installed and started"; |
| 109 | yield* Console.log( | 103 | yield* Console.log( |
| 110 | `${result.previouslyInstalled ? "Updated" : "Installed"} T3 Code service with t3@${packageJson.version}.\nLogs: ${result.plan.logPath}`, | 104 | `${action} T3 Code service with t3@${packageJson.version}.\nLogs: ${result.plan.logPath}`, |
| 111 | ); | 105 | ); |
| 112 | }), | 106 | }), |
| 113 | ), | 107 | ), |
| @@ -172,11 +166,9 @@ export const offerServiceDuringOnboarding = Effect.gen(function* () { · 58 unmodified lines |
| 172 | return false; | 166 | return false; |
| 173 | } | 167 | } |
| 174 | const result = yield* reconcileService(); | 168 | const result = yield* reconcileService(); |
| 175 | if (result.changed) { | 169 | yield* Console.log( |
| 176 | yield* Console.log( | 170 | `Background service ${result.previouslyInstalled ? "updated" : "installed"}. Logs: ${result.plan.logPath}`, |
| 177 | `Background service ${result.previouslyInstalled ? "updated" : "installed"}. Logs: ${result.plan.logPath}`, | 171 | ); |
| 178 | ); | | |
| 179 | } | | |
| 180 | return true; | 172 | return true; |
| 181 | }); | 173 | }); |
| 182 | | 174 | |