forked from supabase/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.handler.ts
More file actions
75 lines (70 loc) · 2.81 KB
/
Copy pathstart.handler.ts
File metadata and controls
75 lines (70 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { Effect } from "effect";
import { StateManager, stackMetadata } from "@supabase/stack/effect";
import { Output } from "../../../shared/output/output.service.ts";
import { Analytics } from "../../../shared/telemetry/analytics.service.ts";
import type { StartFlags } from "./start.command.ts";
import { StartVersionState } from "./start.command.ts";
import { startBackground } from "./flows/background.flow.ts";
import { startForeground } from "./flows/foreground.flow.ts";
import { startNonInteractive } from "./flows/non-interactive.flow.ts";
export const start = Effect.fnUntraced(function* (flags: StartFlags) {
return yield* Effect.scoped(
Effect.gen(function* () {
const output = yield* Output;
const analytics = yield* Analytics;
const stateManager = yield* StateManager;
const startVersionState = yield* StartVersionState;
const { metadata, serviceVersionContext } = startVersionState;
if (serviceVersionContext.activeOverrides.length > 0) {
yield* output.warn(
[
"Local service version overrides are active (at your own risk):",
...serviceVersionContext.activeOverrides.map(
({ service, version, source }) => ` ${service}: ${version} [${source}]`,
),
"These overrides are local to this checkout and may break compatibility.",
].join("\n"),
);
}
if (
serviceVersionContext.updateFingerprint !== undefined &&
metadata.lastNotifiedUpdateFingerprint !== serviceVersionContext.updateFingerprint
) {
yield* output.warn(
[
"Updated linked or default service versions are available for this local stack:",
...serviceVersionContext.availableUpdates.map(
({ service, pinnedVersion, availableVersion }) =>
` ${service}: ${pinnedVersion} -> ${availableVersion}`,
),
"Run `supabase stack update` to adopt these pinned versions.",
].join("\n"),
);
yield* stateManager.writeMetadata(
flags.stack,
stackMetadata({
ports: metadata.ports,
services: metadata.services,
launch: metadata.launch ?? { mode: "auto", excludedServices: [] },
updatedAt: metadata.updatedAt,
lastNotifiedUpdateFingerprint: serviceVersionContext.updateFingerprint,
}),
);
}
let result: void;
if (flags.detach) {
result = yield* startBackground();
} else if (output.interactive) {
result = yield* startForeground();
} else {
result = yield* startNonInteractive();
}
yield* analytics.capture("cli_stack_started", {
mode: flags.mode,
detach: flags.detach,
stack: flags.stack,
});
return result;
}),
);
});