cli for pub
This commit is contained in:
1 parent
a935db07ef
commit
11606fd9c6
10 files changed
+225
-53
No files matched your search
@@ -6,6 +6,8 @@ import rootPackageJson from "../package.json" with { type: "json" };
|
||||
import desktopPackageJson from "../apps/desktop/package.json" with { type: "json" };
|
||||
import serverPackageJson from "../apps/server/package.json" with { type: "json" };
|
||||
|
||||
import { resolveCatalogDependencies } from "./lib/resolve-catalog.ts";
|
||||
|
||||
import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { Config, Data, Effect, FileSystem, Logger, Option, Path, Schema } from "effect";
|
||||
@@ -319,31 +321,6 @@ function validateBundledClientAssets(clientDir: string) {
|
||||
});
|
||||
}
|
||||
|
||||
function resolveCatalogDependencies(
|
||||
dependencies: Record<string, unknown>,
|
||||
catalog: Record<string, unknown>,
|
||||
dependencySourceLabel: string,
|
||||
): Record<string, unknown> {
|
||||
return Object.fromEntries(
|
||||
Object.entries(dependencies).map(([dependencyName, spec]) => {
|
||||
if (typeof spec !== "string" || !spec.startsWith("catalog:")) {
|
||||
return [dependencyName, spec];
|
||||
}
|
||||
|
||||
const catalogKey = spec.slice("catalog:".length).trim();
|
||||
const lookupKey = catalogKey.length > 0 ? catalogKey : dependencyName;
|
||||
const resolvedSpec = catalog[lookupKey];
|
||||
if (typeof resolvedSpec !== "string" || resolvedSpec.length === 0) {
|
||||
throw new BuildScriptError({
|
||||
message: `Unable to resolve '${spec}' for ${dependencySourceLabel} dependency '${dependencyName}'. Expected key '${lookupKey}' in root workspace catalog.`,
|
||||
});
|
||||
}
|
||||
|
||||
return [dependencyName, resolvedSpec];
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
const createBuildConfig = Effect.fn(function* (
|
||||
platform: typeof BuildPlatform.Type,
|
||||
target: string,
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Resolve `catalog:` dependency specs using the workspace catalog.
|
||||
*
|
||||
* Pure function: returns a new record with every `catalog:…` value replaced by
|
||||
* the concrete version string found in `catalog`. Throws on missing entries.
|
||||
*/
|
||||
export function resolveCatalogDependencies(
|
||||
dependencies: Record<string, unknown>,
|
||||
catalog: Record<string, unknown>,
|
||||
label: string,
|
||||
): Record<string, unknown> {
|
||||
return Object.fromEntries(
|
||||
Object.entries(dependencies).map(([name, spec]) => {
|
||||
if (typeof spec !== "string" || !spec.startsWith("catalog:")) {
|
||||
return [name, spec];
|
||||
}
|
||||
|
||||
const catalogKey = spec.slice("catalog:".length).trim();
|
||||
const lookupKey = catalogKey.length > 0 ? catalogKey : name;
|
||||
const resolved = catalog[lookupKey];
|
||||
|
||||
if (typeof resolved !== "string" || resolved.length === 0) {
|
||||
throw new Error(
|
||||
`Unable to resolve '${spec}' for ${label} dependency '${name}'. Expected key '${lookupKey}' in root workspace catalog.`,
|
||||
);
|
||||
}
|
||||
|
||||
return [name, resolved];
|
||||
}),
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user