This commit is contained in:
Ruben Fiszel
2025-10-29 08:04:02 +00:00
parent 67fae985fe
commit 2cb214f54e
3 changed files with 27 additions and 26 deletions

View File

@@ -97,13 +97,10 @@ async function dev(opts: GlobalOptions & SyncOptions) {
const splitted = cpath.split(".");
const wmPath = splitted[0];
const lang = inferContentTypeFromFilePath(cpath, conf.defaultTs);
const globalDeps = await findGlobalDeps();
const typed =
(await parseMetadataFile(
removeExtensionToPath(cpath),
undefined,
globalDeps,
[]
)
)?.payload

View File

@@ -282,10 +282,10 @@ export async function handleFile(
path,
workspaceRemote: workspace,
schemaOnly: codebase ? true : undefined,
globalDeps,
codebases
}
: undefined,
globalDeps,
codebases
)
)?.payload;

View File

@@ -246,29 +246,22 @@ export async function generateScriptMetadataInternal(
const language = inferContentTypeFromFilePath(scriptPath, opts.defaultTs);
const metadataWithType = await parseMetadataFile(
remotePath,
undefined,
);
// read script content
const scriptContent = await Deno.readTextFile(scriptPath);
const metadataContent = await Deno.readTextFile(metadataWithType.path);
const rrLang = languagesWithRawReqsSupport.find(
(l) => language == l.language
);
const rawReqs = findClosestRawReqs(rrLang, scriptPath, globalDeps);
if (rawReqs && rrLang) {
log.info(
(await blueColor())(
`Found raw requirements (${rrLang.rrFilename}) for ${scriptPath}, using it`
)
);
}
const metadataWithType = await parseMetadataFile(
remotePath,
undefined,
globalDeps,
codebases
);
// read script content
const scriptContent = await Deno.readTextFile(scriptPath);
const metadataContent = await Deno.readTextFile(metadataWithType.path);
let hash = await generateScriptHash(rawReqs, scriptContent, metadataContent);
@@ -385,6 +378,10 @@ async function updateScriptLock(
) {
return;
}
if (rawDeps) {
log.info(`Generating script lock for ${remotePath} with raw deps`);
}
// generate the script lock running a dependency job in Windmill and update it inplace
// TODO: update this once the client is released
const extraHeaders = getHeaders();
@@ -766,10 +763,11 @@ export async function parseMetadataFile(
path: string;
workspaceRemote: Workspace;
schemaOnly?: boolean;
globalDeps: GlobalDeps;
codebases: SyncCodebase[]
})
| undefined,
globalDeps: GlobalDeps,
codebases: SyncCodebase[]
): Promise<{ isJson: boolean; payload: any; path: string }> {
let metadataFilePath = scriptPath + ".script.json";
try {
@@ -800,13 +798,19 @@ export async function parseMetadataFile(
);
metadataFilePath = scriptPath + ".script.yaml";
let scriptInitialMetadata = defaultScriptMetadata();
const lockPath = scriptPath + ".script.lock";
scriptInitialMetadata.lock = "!inline " + lockPath;
const scriptInitialMetadataYaml = yamlStringify(
scriptInitialMetadata as Record<string, any>,
yamlOptions
);
await Deno.writeTextFile(metadataFilePath, scriptInitialMetadataYaml, {
createNew: true,
});
await Deno.writeTextFile(lockPath, "", {
createNew: true,
});
if (generateMetadataIfMissing) {
log.info(
@@ -821,8 +825,8 @@ export async function parseMetadataFile(
generateMetadataIfMissing,
false,
false,
globalDeps,
codebases,
generateMetadataIfMissing.globalDeps,
generateMetadataIfMissing.codebases,
false
);
scriptInitialMetadata = (await yamlParseFile(