Files
windmill/cli/src/utils/codebase.ts
T
centdix 59f39d860a chore(cli): better folder structure + add config utils (#6319)
* organize in folders

* add config command

* fix

* cleaning

* move utility functions

* merge

* only show token with option

* only show token with option

* fix

* remove config command

* add config utils

* change paths

* nit

* clean path assigner

---------

Co-authored-by: Alexander Petric <alpetric@users.noreply.github.com>
2025-08-05 13:59:07 +00:00

34 lines
1.1 KiB
TypeScript

import { Codebase, SyncOptions } from "../core/conf.ts";
import { log } from "../../deps.ts";
import { digestDir } from "./utils.ts";
export type SyncCodebase = Codebase & { getDigest: () => Promise<string> };
export function listSyncCodebases(
options: SyncOptions
): SyncCodebase[] {
const res: SyncCodebase[] = [];
const nb_codebase = options?.codebases?.length ?? 0;
if (nb_codebase > 0) {
log.info(`Found ${nb_codebase} codebases: ${options?.codebases?.map((c) => c.relative_path).join(", ")}`);
}
for (const codebase of options?.codebases ?? []) {
let _digest: string | undefined = undefined;
const getDigest: () => Promise<string> = async () => {
if (_digest == undefined) {
_digest = await digestDir(
codebase.relative_path,
JSON.stringify(codebase)
);
if (Array.isArray(codebase.assets) && codebase.assets.length > 0) {
_digest += ".tar";
}
log.info(`Codebase ${codebase.relative_path}, digest: ${_digest}`);
}
return _digest;
};
res.push({ ...codebase, getDigest });
}
return res;
}