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