mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-22 08:03:38 +00:00
refactor(cli): migrate CLI from Deno to Bun/Node.js (#8041)
* fix: only enable EE features in test backend when license key is available Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: skip EE tests without license key and exclude test-skills from test discovery Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: unskip passing tests and add duplicate (remote, workspaceId) check in addWorkspace Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor(cli): migrate from Deno APIs to Node.js/Bun-compatible APIs Replace Deno-specific APIs with Node.js equivalents across the entire CLI codebase to enable running on Node.js/Bun. Switch build system from dnt to bun, update imports from jsr:/npm: prefixed to bare specifiers, and add package.json/tsconfig.json for the Node.js ecosystem. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * all * test(cli): expand test coverage with new integration and unit tests Add standalone_commands.test.ts covering folder list, schedule list, resource-type list/push/update, script show/run/bootstrap, and user commands. Add unit tests for filePathExtensionFromContentType and removeExtensionToPath. Add git_unit, local_encryption_unit, resource_folders_unit, and settings_unit test files. Fix schedule cron expressions (6-field format), add includeSchedules flag, improve test setup with pre-build and auto-cleanup, and support TEST_CLI_RUNTIME=node. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(cli): replace Deno.readFile with node:fs in WASM loaders and add schema parsing tests Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor(cli): switch WASM parsers from local files to npm packages Use published windmill-parser-wasm-* npm packages instead of local wasm/ files. A loadParser() helper uses createRequire to resolve the .wasm binary from node_modules and passes it to init() via readFileSync, avoiding fetch() and Deno.readFile() patches. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * test(cli): add coverage for --locks-required lint feature Add 15 tests covering the lock-checking functionality merged from main: - checkMissingLocks: standalone scripts (python, bun, bash), inline lock file resolution (valid, empty, missing), flow inline rawscripts (with/without locks, nested forloopflow), app inline scripts, raw apps without backend folder - runLint --locks-required integration: reports issues when locks missing, skips checks when flag absent, passes when locks exist Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * ci(cli): replace Deno with Bun in CI workflows - cli-tests.yml: remove Deno setup, use `bun test` instead of `deno test`, add `bun install` step for dependency installation - npm_on_release.yml: replace Deno setup with Bun setup for CLI publishing - build.sh: add `bun install` before building so CI has dependencies Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(cli): pre-start backend in test preload and remove Deno test leftovers Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(cli): normalize path separators for Windows compatibility Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * more tests + windows * ci(cli): use Blacksmith runner for Windows tests Switch test-windows job from windows-latest to blacksmith-16vcpu-windows-2025 for faster CI execution. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(cli): fix Windows path separator expectations in unit tests buildMetadataPath and extractResourceName normalize to forward slashes internally, so tests should not expect platform-specific separators in their output. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(cli): fix Windows CI test failures for dev_server and script_run Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(cli): set BUN_PATH and NODE_BIN_PATH for backend worker on Windows Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * ci(cli): add SSH debug step on Windows test failure Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(cli): use native path separators for ignore check in dev mode on Windows Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
c4de11a406
commit
a2cefdf0a2
@@ -1,18 +1,15 @@
|
||||
// deno-lint-ignore-file no-explicit-any
|
||||
import { GlobalOptions } from "../../types.ts";
|
||||
import { requireLogin } from "../../core/auth.ts";
|
||||
import { resolveWorkspace, validatePath } from "../../core/context.ts";
|
||||
import {
|
||||
colors,
|
||||
Command,
|
||||
Confirm,
|
||||
log,
|
||||
readAll,
|
||||
SEP,
|
||||
Table,
|
||||
writeAllSync,
|
||||
yamlStringify,
|
||||
} from "../../../deps.ts";
|
||||
import { readFile, writeFile, stat } from "node:fs/promises";
|
||||
import { Buffer } from "node:buffer";
|
||||
import { colors } from "@cliffy/ansi/colors";
|
||||
import { Command } from "@cliffy/command";
|
||||
import { Confirm } from "@cliffy/prompt/confirm";
|
||||
import { Table } from "@cliffy/table";
|
||||
import * as log from "@std/log";
|
||||
import { SEPARATOR as SEP } from "@std/path";
|
||||
import { stringify as yamlStringify } from "@std/yaml";
|
||||
import { deepEqual } from "../../utils/utils.ts";
|
||||
import * as wmill from "../../../gen/services.gen.ts";
|
||||
import * as specificItems from "../../core/specific_items.ts";
|
||||
@@ -51,7 +48,7 @@ import {
|
||||
} from "../../core/conf.ts";
|
||||
import { SyncCodebase, listSyncCodebases } from "../../utils/codebase.ts";
|
||||
import fs from "node:fs";
|
||||
import { type Tarball } from "npm:@ayonli/jsext/archive";
|
||||
import { type Tarball } from "@ayonli/jsext/archive";
|
||||
|
||||
import { execSync } from "node:child_process";
|
||||
import { NewScript, Script } from "../../../gen/types.gen.ts";
|
||||
@@ -106,8 +103,8 @@ async function push(opts: PushOptions, filePath: string) {
|
||||
return;
|
||||
}
|
||||
|
||||
const fstat = await Deno.stat(filePath);
|
||||
if (!fstat.isFile) {
|
||||
const fstat = await stat(filePath);
|
||||
if (!fstat.isFile()) {
|
||||
throw new Error("file path must refer to a file.");
|
||||
}
|
||||
|
||||
@@ -159,9 +156,9 @@ export async function findResourceFile(path: string) {
|
||||
const validCandidates = (
|
||||
await Promise.all(
|
||||
candidates.map((x) => {
|
||||
return Deno.stat(x)
|
||||
return stat(x)
|
||||
.catch(() => undefined)
|
||||
.then((x) => x?.isFile)
|
||||
.then((x) => x?.isFile())
|
||||
.then((e) => {
|
||||
return { path: x, file: e };
|
||||
});
|
||||
@@ -261,7 +258,7 @@ export async function handleFile(
|
||||
}).toString();
|
||||
log.info("Custom bundler executed for " + path);
|
||||
} else {
|
||||
const esbuild = await import("npm:esbuild@0.24.2");
|
||||
const esbuild = await import("esbuild");
|
||||
|
||||
log.info(`Started bundling ${path} ...`);
|
||||
const startTime = performance.now();
|
||||
@@ -295,7 +292,7 @@ export async function handleFile(
|
||||
);
|
||||
}
|
||||
if (outputFiles.length > 1) {
|
||||
const archiveNpm = await import("npm:@ayonli/jsext/archive");
|
||||
const archiveNpm = await import("@ayonli/jsext/archive");
|
||||
log.info(
|
||||
`Found multiple output files for ${path}, creating a tarball... ${outputFiles
|
||||
.map((file) => file.path)
|
||||
@@ -314,7 +311,7 @@ export async function handleFile(
|
||||
continue;
|
||||
}
|
||||
log.info(`Adding file: ${file.path.substring(1)}`);
|
||||
// deno-lint-ignore no-explicit-any
|
||||
|
||||
const fil = new File([file.contents as any], file.path.substring(1));
|
||||
tarball.append(fil);
|
||||
}
|
||||
@@ -327,7 +324,7 @@ export async function handleFile(
|
||||
bundleContent = tarball;
|
||||
} else {
|
||||
if (Array.isArray(codebase.assets) && codebase.assets.length > 0) {
|
||||
const archiveNpm = await import("npm:@ayonli/jsext/archive");
|
||||
const archiveNpm = await import("@ayonli/jsext/archive");
|
||||
log.info(
|
||||
`Using the following asset configuration for ${path}: ${JSON.stringify(
|
||||
codebase.assets
|
||||
@@ -384,7 +381,7 @@ export async function handleFile(
|
||||
} catch {
|
||||
log.debug(`Script ${remotePath} does not exist on remote`);
|
||||
}
|
||||
const content = await Deno.readTextFile(path);
|
||||
const content = await readFile(path, "utf-8");
|
||||
|
||||
if (opts?.skipScriptsMetadata) {
|
||||
// if (codebase) {
|
||||
@@ -392,17 +389,6 @@ export async function handleFile(
|
||||
// await updateScriptSchema(content, language, typed, path);
|
||||
// if (typedBefore != typed.schema) {
|
||||
// log.info(`Updated metadata for bundle ${path}`);
|
||||
// showDiff(
|
||||
// yamlStringify(typedBefore, yamlOptions),
|
||||
// yamlStringify(typed.schema, yamlOptions)
|
||||
// );
|
||||
// await Deno.writeTextFile(
|
||||
// remotePath + ".script.yaml",
|
||||
// yamlStringify(typed as Record<string, any>, yamlOptions)
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
typed = structuredClone(remote);
|
||||
// }
|
||||
}
|
||||
@@ -544,7 +530,7 @@ async function streamToBlob(stream: ReadableStream<Uint8Array>): Promise<Blob> {
|
||||
chunks.push(value);
|
||||
}
|
||||
|
||||
// deno-lint-ignore no-explicit-any
|
||||
|
||||
const blob = new Blob(chunks as any);
|
||||
return blob;
|
||||
}
|
||||
@@ -611,9 +597,9 @@ export async function findContentFile(filePath: string) {
|
||||
const validCandidates = (
|
||||
await Promise.all(
|
||||
candidates.map((x) => {
|
||||
return Deno.stat(x)
|
||||
return stat(x)
|
||||
.catch(() => undefined)
|
||||
.then((x) => x?.isFile)
|
||||
.then((x) => x?.isFile())
|
||||
.then((e) => {
|
||||
return { path: x, file: e };
|
||||
});
|
||||
@@ -778,10 +764,12 @@ export async function resolve(input: string): Promise<Record<string, any>> {
|
||||
}
|
||||
|
||||
if (input == "@-") {
|
||||
input = new TextDecoder().decode(await readAll(Deno.stdin));
|
||||
const chunks: Buffer[] = [];
|
||||
for await (const chunk of process.stdin) chunks.push(chunk);
|
||||
input = new TextDecoder().decode(Buffer.concat(chunks));
|
||||
}
|
||||
if (input[0] == "@") {
|
||||
input = await Deno.readTextFile(input.substring(1));
|
||||
input = await readFile(input.substring(1), "utf-8");
|
||||
}
|
||||
try {
|
||||
return JSON.parse(input);
|
||||
@@ -830,7 +818,7 @@ async function run(
|
||||
|
||||
break;
|
||||
} catch {
|
||||
new Promise((resolve, _) => setTimeout(() => resolve(undefined), 100));
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -872,6 +860,7 @@ export async function track_job(workspace: string, id: string) {
|
||||
log.info("failed to get job updated. skipping log streaming.");
|
||||
break;
|
||||
}
|
||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -881,7 +870,7 @@ export async function track_job(workspace: string, id: string) {
|
||||
}
|
||||
|
||||
if (updates.new_logs) {
|
||||
writeAllSync(Deno.stdout, new TextEncoder().encode(updates.new_logs));
|
||||
process.stdout.write(updates.new_logs);
|
||||
logOffset += updates.new_logs.length;
|
||||
}
|
||||
|
||||
@@ -951,8 +940,8 @@ async function bootstrap(
|
||||
const scriptMetadataFileFullPath = scriptPath + ".script.yaml";
|
||||
|
||||
try {
|
||||
await Deno.stat(scriptCodeFileFullPath);
|
||||
await Deno.stat(scriptMetadataFileFullPath);
|
||||
await stat(scriptCodeFileFullPath);
|
||||
await stat(scriptMetadataFileFullPath);
|
||||
throw new Error("File already exists in repository");
|
||||
} catch {
|
||||
// file does not exist, we can continue
|
||||
@@ -971,14 +960,14 @@ async function bootstrap(
|
||||
yamlOptions
|
||||
);
|
||||
|
||||
await Deno.writeTextFile(scriptCodeFileFullPath, scriptInitialCode, {
|
||||
createNew: true,
|
||||
await writeFile(scriptCodeFileFullPath, scriptInitialCode, {
|
||||
flag: 'wx', encoding: 'utf-8',
|
||||
});
|
||||
await Deno.writeTextFile(
|
||||
await writeFile(
|
||||
scriptMetadataFileFullPath,
|
||||
scriptInitialMetadataYaml,
|
||||
{
|
||||
createNew: true,
|
||||
flag: 'wx', encoding: 'utf-8',
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1028,7 +1017,7 @@ async function generateMetadata(
|
||||
// TODO: test this as well.
|
||||
const ignore = await ignoreF(opts);
|
||||
const elems = await elementsToMap(
|
||||
await FSFSElement(Deno.cwd(), codebases, false),
|
||||
await FSFSElement(process.cwd(), codebases, false),
|
||||
(p, isD) => {
|
||||
return (
|
||||
(!isD && !exts.some((ext) => p.endsWith(ext))) ||
|
||||
@@ -1107,8 +1096,8 @@ async function preview(
|
||||
return;
|
||||
}
|
||||
|
||||
const fstat = await Deno.stat(filePath);
|
||||
if (!fstat.isFile) {
|
||||
const fstat = await stat(filePath);
|
||||
if (!fstat.isFile()) {
|
||||
throw new Error("file path must refer to a file.");
|
||||
}
|
||||
|
||||
@@ -1120,7 +1109,7 @@ async function preview(
|
||||
|
||||
const codebases = await listSyncCodebases(opts);
|
||||
const language = inferContentTypeFromFilePath(filePath, opts?.defaultTs);
|
||||
const content = await Deno.readTextFile(filePath);
|
||||
const content = await readFile(filePath, "utf-8");
|
||||
const input = opts.data ? await resolve(opts.data) : {};
|
||||
|
||||
// Check if this is a codebase script
|
||||
@@ -1139,7 +1128,7 @@ async function preview(
|
||||
maxBuffer: 1024 * 1024 * 50,
|
||||
}).toString();
|
||||
} else {
|
||||
const esbuild = await import("npm:esbuild@0.24.2");
|
||||
const esbuild = await import("esbuild");
|
||||
|
||||
if (!opts.silent) {
|
||||
log.info(`Bundling ${filePath} for preview...`);
|
||||
@@ -1166,7 +1155,7 @@ async function preview(
|
||||
|
||||
// Handle multiple output files (create tarball)
|
||||
if (out.outputFiles.length > 1) {
|
||||
const archiveNpm = await import("npm:@ayonli/jsext/archive");
|
||||
const archiveNpm = await import("@ayonli/jsext/archive");
|
||||
if (!opts.silent) {
|
||||
log.info(`Creating tarball for multiple output files...`);
|
||||
}
|
||||
@@ -1177,7 +1166,7 @@ async function preview(
|
||||
tarball.append(new File([mainContent], "main.js", { type: "text/plain" }));
|
||||
for (const file of out.outputFiles) {
|
||||
if (file.path == "/" + mainPath) continue;
|
||||
// deno-lint-ignore no-explicit-any
|
||||
|
||||
const fil = new File([file.contents as any], file.path.substring(1));
|
||||
tarball.append(fil);
|
||||
}
|
||||
@@ -1185,7 +1174,7 @@ async function preview(
|
||||
isTar = true;
|
||||
} else if (Array.isArray(codebase.assets) && codebase.assets.length > 0) {
|
||||
// Handle assets
|
||||
const archiveNpm = await import("npm:@ayonli/jsext/archive");
|
||||
const archiveNpm = await import("@ayonli/jsext/archive");
|
||||
if (!opts.silent) {
|
||||
log.info(`Adding assets to tarball...`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user