@usine/server 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/backend.d.ts +26 -0
- package/dist/backend.d.ts.map +1 -0
- package/dist/backend.js +39 -0
- package/dist/backend.js.map +1 -0
- package/dist/cli.d.ts +58 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +117 -0
- package/dist/cli.js.map +1 -0
- package/dist/http.d.ts +7 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +205 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +21 -0
- package/dist/main.js.map +1 -0
- package/dist/up.d.ts +4 -0
- package/dist/up.d.ts.map +1 -0
- package/dist/up.js +68 -0
- package/dist/up.js.map +1 -0
- package/dist/web/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/dist/web/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/dist/web/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/dist/web/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/dist/web/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
- package/dist/web/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
- package/dist/web/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
- package/dist/web/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
- package/dist/web/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
- package/dist/web/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
- package/dist/web/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/dist/web/assets/index-CjRDHHWF.css +2 -0
- package/dist/web/assets/index-DmN0SkGf.js +295 -0
- package/dist/web/index.html +14 -0
- package/package.json +45 -0
package/dist/up.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { type Port } from "./cli.ts";
|
|
3
|
+
export declare const up: (port: Port) => Effect.Effect<never, import("@usine/github").AppAuthenticationError | import("@usine/engine").AttemptCancellationError | import("@usine/executor").CredentialUnavailableError | import("@usine/engine").EnginePersistenceError | import("@usine/executor").ExecutorOperationError | import("@usine/config").FactoryConfigError | import("./cli.ts").PortInUseError | import("@usine/engine").RunNotFoundError | import("@usine/engine").RunOperationRejectedError | import("./cli.ts").ServerStartError | import("@usine/orchestrator").UnsupportedWorkerError | import("@usine/executor").WorkerCapabilityError, import("effect/unstable/process/ChildProcessSpawner").ChildProcessSpawner>;
|
|
4
|
+
//# sourceMappingURL=up.d.ts.map
|
package/dist/up.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"up.d.ts","sourceRoot":"","sources":["../src/up.ts"],"names":[],"mappings":"AAUA,OAAO,EAAoB,MAAM,EAAiB,MAAM,QAAQ,CAAC;AAEjE,OAAO,EAAE,KAAK,IAAI,EAAiC,MAAM,UAAU,CAAC;AA4CpE,eAAO,MAAM,EAAE,SAAU,IAAI,iqBAsD1B,CAAC"}
|
package/dist/up.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { dirname, resolve } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { NodeServices } from "@effect/platform-node";
|
|
4
|
+
import { ConfigParser, InstanceFolder } from "@usine/config";
|
|
5
|
+
import { Instance } from "@usine/core";
|
|
6
|
+
import { MarcbachmannCelLayer } from "@usine/expression";
|
|
7
|
+
import { GitHubCredentials } from "@usine/github";
|
|
8
|
+
import { loadLocalCredentials } from "@usine/github/local-secrets";
|
|
9
|
+
import { Operator, OperatorObservation, Orchestrator } from "@usine/orchestrator";
|
|
10
|
+
import { operatorObservationLayer, runtimeLayer } from "@usine/orchestrator/local";
|
|
11
|
+
import { Console, Context, Effect, Layer, Result } from "effect";
|
|
12
|
+
import { liveBackendLayer, needsSetupBackendLayer } from "./backend.js";
|
|
13
|
+
import { openBrowser, serverStartError } from "./cli.js";
|
|
14
|
+
import { serverLayer } from "./http.js";
|
|
15
|
+
const loadInstance = (directory) => {
|
|
16
|
+
const parser = ConfigParser.layer.pipe(Layer.provide(MarcbachmannCelLayer));
|
|
17
|
+
const folder = InstanceFolder.layer.pipe(Layer.provide(parser), Layer.provide(NodeServices.layer));
|
|
18
|
+
return Effect.flatMap(InstanceFolder, (service) => service.load(directory)).pipe(Effect.provide(folder));
|
|
19
|
+
};
|
|
20
|
+
const serve = Effect.fn("Server.serve")(function* (options) {
|
|
21
|
+
yield* Layer.build(serverLayer(options.backend, options.webRoot, options.port)).pipe(Effect.mapError((error) => serverStartError(options.port, error)));
|
|
22
|
+
yield* Console.log(options.openSetupPage
|
|
23
|
+
? `usine is waiting for GitHub App setup at ${options.url}`
|
|
24
|
+
: `usine is running at ${options.url}`);
|
|
25
|
+
if (options.openSetupPage) {
|
|
26
|
+
yield* openBrowser(options.url).pipe(Effect.tapError((error) => Effect.logWarning("The setup page could not be opened automatically", {
|
|
27
|
+
command: error.command,
|
|
28
|
+
cause: error.cause,
|
|
29
|
+
url: options.url,
|
|
30
|
+
})), Effect.ignore);
|
|
31
|
+
}
|
|
32
|
+
return yield* Effect.never;
|
|
33
|
+
});
|
|
34
|
+
export const up = (port) => Effect.scoped(Effect.gen(function* () {
|
|
35
|
+
const directory = Instance.Directory.make(process.cwd());
|
|
36
|
+
const instance = yield* loadInstance(directory);
|
|
37
|
+
const credentials = yield* loadLocalCredentials(directory).pipe(Effect.provide(NodeServices.layer), Effect.result);
|
|
38
|
+
const webRoot = resolve(dirname(fileURLToPath(import.meta.url)), "web");
|
|
39
|
+
const url = `http://127.0.0.1:${port}`;
|
|
40
|
+
if (Result.isFailure(credentials)) {
|
|
41
|
+
const error = credentials.failure;
|
|
42
|
+
yield* Effect.logWarning("GitHub App credentials are absent; pollers are idle", {
|
|
43
|
+
errorTag: error._tag,
|
|
44
|
+
message: error.message,
|
|
45
|
+
instanceDirectory: directory,
|
|
46
|
+
});
|
|
47
|
+
const observationContext = yield* Layer.build(operatorObservationLayer(directory));
|
|
48
|
+
const backend = needsSetupBackendLayer(instance, error._tag, Context.get(observationContext, OperatorObservation));
|
|
49
|
+
return yield* serve({ backend, webRoot, port, url, openSetupPage: true });
|
|
50
|
+
}
|
|
51
|
+
const runtime = runtimeLayer(directory, instance, {}).pipe(Layer.provide(Layer.succeed(GitHubCredentials, credentials.success)));
|
|
52
|
+
const context = yield* Layer.build(runtime);
|
|
53
|
+
const operator = Context.get(context, Operator);
|
|
54
|
+
const orchestrator = Context.get(context, Orchestrator);
|
|
55
|
+
// Racing instead of forking: a defect in either the trigger streams or the
|
|
56
|
+
// HTTP server takes the whole process down loudly, never leaving a green
|
|
57
|
+
// "live" UI over a dead factory.
|
|
58
|
+
return yield* Effect.raceFirst(serve({
|
|
59
|
+
backend: liveBackendLayer(instance, operator),
|
|
60
|
+
webRoot,
|
|
61
|
+
port,
|
|
62
|
+
url,
|
|
63
|
+
openSetupPage: false,
|
|
64
|
+
}), orchestrator
|
|
65
|
+
.run(instance)
|
|
66
|
+
.pipe(Effect.tapCause((cause) => Effect.logFatal("Trigger streams stopped; shutting the server down", { cause }))));
|
|
67
|
+
}));
|
|
68
|
+
//# sourceMappingURL=up.js.map
|
package/dist/up.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"up.js","sourceRoot":"","sources":["../src/up.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAA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