2026-04-10
- corvée: met à jour les deps - corvée: formate
This commit is contained in:
parent
00f87fedcd
commit
b2a0012590
85 changed files with 132083 additions and 31328 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { YAML } from "bun";
|
||||
import { Console, Data, Effect, Array as EffectArray, pipe, Record, Schema, SchemaIssue } from "effect";
|
||||
import { Array as EffectArray, Console, Data, Effect, pipe, Record, Schema, SchemaIssue } from "effect";
|
||||
import { SchemaError } from "effect/Schema";
|
||||
|
||||
const COMPOSE_PATH = "compose.yaml";
|
||||
|
|
@ -21,7 +21,7 @@ class ScriptError extends Data.TaggedError("ScriptError")<{ cause: unknown }> {}
|
|||
* @param compose Le fichier _Compose_ sous forme d'objet.
|
||||
* @returns Les noms des Services sous forme de tableau.
|
||||
*/
|
||||
const getServicesFromComposeYaml: (compose: Compose) => ReadonlyArray<string> = (compose) =>
|
||||
const getServicesFromComposeYaml: (compose: Compose) => ReadonlyArray<string> = compose =>
|
||||
Record.keys(compose.services);
|
||||
|
||||
/**
|
||||
|
|
@ -31,7 +31,7 @@ const getServicesFromComposeYaml: (compose: Compose) => ReadonlyArray<string> =
|
|||
* @returns Le contenu textuel du fichier sous forme de chaîne de caractères.
|
||||
*/
|
||||
const getFileContent: (filePath: string) => Effect.Effect<string, ScriptError> = Effect.fn("getFileContent")(
|
||||
function* (filePath) {
|
||||
function*(filePath) {
|
||||
const fileRef: Bun.BunFile = Bun.file(filePath);
|
||||
|
||||
yield* Effect.tryPromise({
|
||||
|
|
@ -56,12 +56,12 @@ const getFileContent: (filePath: string) => Effect.Effect<string, ScriptError> =
|
|||
const getComposeYaml: <ComposeSchema>(
|
||||
path: string,
|
||||
schema: Schema.Schema<ComposeSchema>,
|
||||
) => Effect.Effect<ComposeSchema, ScriptError, unknown> = Effect.fn("getComposeYaml")(function* (path, schema) {
|
||||
) => Effect.Effect<ComposeSchema, ScriptError, unknown> = Effect.fn("getComposeYaml")(function*(path, schema) {
|
||||
return yield* pipe(
|
||||
getFileContent(path),
|
||||
Effect.map((text: string): unknown => YAML.parse(text)),
|
||||
Effect.flatMap((yaml: unknown) =>
|
||||
Schema.decodeUnknownEffect(schema)(yaml, { errors: "all", onExcessProperty: "ignore" }),
|
||||
Schema.decodeUnknownEffect(schema)(yaml, { errors: "all", onExcessProperty: "ignore" })
|
||||
),
|
||||
Effect.mapError((error): ScriptError => {
|
||||
if (error instanceof SchemaError) {
|
||||
|
|
@ -76,7 +76,7 @@ const getComposeYaml: <ComposeSchema>(
|
|||
const program: Effect.Effect<ReadonlyArray<string>, ScriptError> = pipe(
|
||||
getComposeYaml(COMPOSE_PATH, Compose),
|
||||
Effect.map((compose: Compose) => getServicesFromComposeYaml(compose)),
|
||||
Effect.map((keys: ReadonlyArray<string>) => EffectArray.filter(keys, (key) => key !== "wordpress")),
|
||||
Effect.map((keys: ReadonlyArray<string>) => EffectArray.filter(keys, key => key !== "wordpress")),
|
||||
Effect.orElseSucceed(() => [""]),
|
||||
Effect.tap((services: ReadonlyArray<string>) => {
|
||||
Bun.spawn({ cmd: ["podman", "compose", "pull", ...services], timeout: DEFAULT_CMD_TIMEOUT });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue