Skip to content

Commit

Permalink
feat(ports): version resolution v1
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohe-Am committed Dec 28, 2023
1 parent 364739f commit 33a73fa
Show file tree
Hide file tree
Showing 9 changed files with 594 additions and 238 deletions.
155 changes: 89 additions & 66 deletions ghjk.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions ghjk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ ghjk.install();

// these are used for developing ghjk
ghjk.install(
// act(),
// ...pipi({ packageName: "pre-commit" }),
act(),
...pipi({ packageName: "pre-commit" }),
);

export const secureConfig = ghjk.secureConfig({
Expand Down
27 changes: 15 additions & 12 deletions modules/ports/mod.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
export * from "./types.ts";

import { cliffy_cmd } from "../../deps/cli.ts";
import { $, JSONValue } from "../../utils/mod.ts";
import { JSONValue } from "../../utils/mod.ts";
import logger from "../../utils/logger.ts";
import validators from "./types.ts";
import type { PortsModuleConfigX } from "./types.ts";
import type { GhjkCtx, ModuleManifest } from "../types.ts";
import { ModuleBase } from "../mod.ts";
import { buildInstallGraph, installAndShimEnv, InstallGraph } from "./sync.ts";
import { installsDbKv } from "./db.ts";
import {
buildInstallGraph,
installAndShimEnv,
InstallGraph,
syncCtxFromGhjk,
} from "./sync.ts";

export type PortsModuleManifest = {
config: PortsModuleConfigX;
Expand All @@ -16,7 +21,7 @@ export type PortsModuleManifest = {

export class PortsModule extends ModuleBase<PortsModuleManifest> {
async processManifest(
_ctx: GhjkCtx,
ctx: GhjkCtx,
manifest: ModuleManifest,
) {
const res = validators.portsModuleConfig.safeParse(manifest.config);
Expand All @@ -28,9 +33,11 @@ export class PortsModule extends ModuleBase<PortsModuleManifest> {
},
});
}
await using syncCx = await syncCtxFromGhjk(ctx);
const graph = await buildInstallGraph(syncCx, res.data);
return {
config: res.data,
graph: await buildInstallGraph(res.data),
graph,
};
}
command(
Expand All @@ -47,15 +54,11 @@ export class PortsModule extends ModuleBase<PortsModuleManifest> {
"sync",
new cliffy_cmd.Command().description("Syncs the environment.")
.action(async () => {
const portsDir = await $.path(ctx.ghjkDir).resolve("ports")
.ensureDir();
using db = await installsDbKv(
portsDir.resolve("installs.db").toString(),
);
logger().debug("syncing ports");
await using syncCx = await syncCtxFromGhjk(ctx);
void await installAndShimEnv(
portsDir.toString(),
syncCx,
ctx.envDir,
db,
manifest.graph,
);
}),
Expand Down
Loading

0 comments on commit 33a73fa

Please sign in to comment.