diff --git a/cli/README.md b/cli/README.md index f4fcc167f5ba3..4ace3da25f620 100644 --- a/cli/README.md +++ b/cli/README.md @@ -8,8 +8,7 @@ You can find more information in ## Installation -Install the `wmill` CLI tool using -`deno install --unstable -A https://deno.land/x/wmill/main.ts`. +Install the `wmill` CLI tool using `npm install -g windmill-cli`. Update to the latest version using `wmill upgrade`. diff --git a/cli/context.ts b/cli/context.ts index 6d6e6c35088d1..e73415f5dc243 100644 --- a/cli/context.ts +++ b/cli/context.ts @@ -96,7 +96,7 @@ export async function requireLogin( } export async function fetchVersion(baseUrl: string): Promise { - const requestHeaders: HeadersInit = new Headers(); + const requestHeaders = new Headers(); const extraHeaders = getHeaders(); if (extraHeaders) { diff --git a/cli/deno.json b/cli/deno.json index 3741d2dc7c975..6276c18bbcf42 100644 --- a/cli/deno.json +++ b/cli/deno.json @@ -12,6 +12,7 @@ "@std/net": "jsr:@std/net@^1.0.2", "@std/path": "jsr:@std/path@^1.0.4", "@std/streams": "jsr:@std/streams@^1.0.4", - "@std/yaml": "jsr:@std/yaml@^1.0.5" + "@std/yaml": "jsr:@std/yaml@^1.0.5", + "@types/diff": "npm:@types/diff@^5.2.2" } } diff --git a/cli/deno.lock b/cli/deno.lock index 3cfeeaeb38236..8ad2b287d3eac 100644 --- a/cli/deno.lock +++ b/cli/deno.lock @@ -5,6 +5,7 @@ "jsr:@david/code-block-writer@^13.0.2": "jsr:@david/code-block-writer@13.0.2", "jsr:@deno/cache-dir@^0.10.3": "jsr:@deno/cache-dir@0.10.3", "jsr:@deno/dnt@0.41.3": "jsr:@deno/dnt@0.41.3", + "jsr:@deno/dnt@^0.41.3": "jsr:@deno/dnt@0.41.3", "jsr:@std/assert@1.0.0-rc.2": "jsr:@std/assert@1.0.0-rc.2", "jsr:@std/assert@^0.223.0": "jsr:@std/assert@0.223.0", "jsr:@std/assert@^0.226.0": "jsr:@std/assert@0.226.0", @@ -13,6 +14,7 @@ "jsr:@std/cli@1.0.0-rc.2": "jsr:@std/cli@1.0.0-rc.2", "jsr:@std/encoding": "jsr:@std/encoding@1.0.4", "jsr:@std/encoding@1.0.0-rc.2": "jsr:@std/encoding@1.0.0-rc.2", + "jsr:@std/encoding@^1.0.4": "jsr:@std/encoding@1.0.4", "jsr:@std/fmt@1": "jsr:@std/fmt@1.0.2", "jsr:@std/fmt@^0.223": "jsr:@std/fmt@0.223.0", "jsr:@std/fmt@^1.0.2": "jsr:@std/fmt@1.0.2", @@ -27,7 +29,9 @@ "jsr:@std/io@^0.224.7": "jsr:@std/io@0.224.7", "jsr:@std/io@~0.224.2": "jsr:@std/io@0.224.7", "jsr:@std/log": "jsr:@std/log@0.224.7", + "jsr:@std/log@^0.224.7": "jsr:@std/log@0.224.7", "jsr:@std/net": "jsr:@std/net@1.0.2", + "jsr:@std/net@^1.0.2": "jsr:@std/net@1.0.2", "jsr:@std/path": "jsr:@std/path@1.0.4", "jsr:@std/path@1": "jsr:@std/path@1.0.4", "jsr:@std/path@1.0.0-rc.1": "jsr:@std/path@1.0.0-rc.1", @@ -35,19 +39,26 @@ "jsr:@std/path@^0.223": "jsr:@std/path@0.223.0", "jsr:@std/path@^0.225.2": "jsr:@std/path@0.225.2", "jsr:@std/path@^1.0.4": "jsr:@std/path@1.0.4", + "jsr:@std/streams@^1.0.4": "jsr:@std/streams@1.0.4", "jsr:@std/text@1.0.0-rc.1": "jsr:@std/text@1.0.0-rc.1", "jsr:@std/yaml": "jsr:@std/yaml@1.0.5", + "jsr:@std/yaml@^1.0.5": "jsr:@std/yaml@1.0.5", "jsr:@ts-morph/bootstrap@^0.24.0": "jsr:@ts-morph/bootstrap@0.24.0", "jsr:@ts-morph/common@^0.24.0": "jsr:@ts-morph/common@0.24.0", "jsr:@windmill-labs/cliffy-ansi@1.0.0-rc.5": "jsr:@windmill-labs/cliffy-ansi@1.0.0-rc.5", + "jsr:@windmill-labs/cliffy-ansi@^1.0.0-rc.5": "jsr:@windmill-labs/cliffy-ansi@1.0.0-rc.5", "jsr:@windmill-labs/cliffy-command@1.0.0-rc.5": "jsr:@windmill-labs/cliffy-command@1.0.0-rc.5", + "jsr:@windmill-labs/cliffy-command@^1.0.0-rc.5": "jsr:@windmill-labs/cliffy-command@1.0.0-rc.5", "jsr:@windmill-labs/cliffy-flags@1.0.0-rc.5": "jsr:@windmill-labs/cliffy-flags@1.0.0-rc.5", "jsr:@windmill-labs/cliffy-internal@1.0.0-rc.5": "jsr:@windmill-labs/cliffy-internal@1.0.0-rc.5", "jsr:@windmill-labs/cliffy-keycode@1.0.0-rc.5": "jsr:@windmill-labs/cliffy-keycode@1.0.0-rc.5", "jsr:@windmill-labs/cliffy-prompt@1.0.0-rc.5": "jsr:@windmill-labs/cliffy-prompt@1.0.0-rc.5", + "jsr:@windmill-labs/cliffy-prompt@^1.0.0-rc.5": "jsr:@windmill-labs/cliffy-prompt@1.0.0-rc.5", "jsr:@windmill-labs/cliffy-table@1.0.0-rc.5": "jsr:@windmill-labs/cliffy-table@1.0.0-rc.5", + "jsr:@windmill-labs/cliffy-table@^1.0.0-rc.5": "jsr:@windmill-labs/cliffy-table@1.0.0-rc.5", "npm:@ayonli/jsext": "npm:@ayonli/jsext@0.9.58", "npm:@oakserver/oak@12": "npm:@oakserver/oak@12.6.2", + "npm:@types/diff@^5.2.2": "npm:@types/diff@5.2.2", "npm:@types/node": "npm:@types/node@18.16.19", "npm:diff": "npm:diff@5.2.0", "npm:es-main": "npm:es-main@1.3.0", @@ -177,6 +188,12 @@ "@std/path@1.0.4": { "integrity": "48dd5d8389bcfcd619338a01bdf862cb7799933390146a54ae59356a0acc7105" }, + "@std/streams@1.0.4": { + "integrity": "a1a5b01c74ca1d2dcaacfe1d4bbb91392e765946d82a3471bd95539adc6da83a", + "dependencies": [ + "jsr:@std/bytes@^1.0.2" + ] + }, "@std/text@1.0.0-rc.1": { "integrity": "34c722203e87ee12792c8d4a0cd2ee0e001341cbce75b860fc21be19d62232b0" }, @@ -381,6 +398,10 @@ "undici": "undici@5.28.4" } }, + "@types/diff@5.2.2": { + "integrity": "sha512-qVqLpd49rmJA2nZzLVsmfS/aiiBpfVE95dHhPVwG0NmSBAt+riPxnj53wq2oBq5m4Q2RF1IWFEUpnZTgrQZfEQ==", + "dependencies": {} + }, "@types/node@18.16.19": { "integrity": "sha512-IXl7o+R9iti9eBW4Wg2hx1xQDig183jj7YLn8F7udNceyfkbn1ZxmzZXuak20gR40D7pIkIY1kYGx5VIGbaHKA==", "dependencies": {} @@ -1008,7 +1029,8 @@ "jsr:@windmill-labs/cliffy-ansi@^1.0.0-rc.5", "jsr:@windmill-labs/cliffy-command@^1.0.0-rc.5", "jsr:@windmill-labs/cliffy-prompt@^1.0.0-rc.5", - "jsr:@windmill-labs/cliffy-table@^1.0.0-rc.5" + "jsr:@windmill-labs/cliffy-table@^1.0.0-rc.5", + "npm:@types/diff@^5.2.2" ] } } diff --git a/cli/deps.ts b/cli/deps.ts index 91e850efc6a3a..4c466b00fea39 100644 --- a/cli/deps.ts +++ b/cli/deps.ts @@ -29,6 +29,7 @@ export { stringify as yamlStringify, parse as yamlParse } from "jsr:@std/yaml"; // other +export * as Diff from "npm:diff"; export { minimatch } from "npm:minimatch"; export { default as JSZip } from "npm:jszip@3.7.1"; diff --git a/cli/dnt.ts b/cli/dnt.ts index 4808a944f4eb8..e823743b0bd8b 100644 --- a/cli/dnt.ts +++ b/cli/dnt.ts @@ -10,20 +10,34 @@ await build({ name: "wmill", // command name path: "./main.ts", }, + "main.ts", ], outDir: "./npm", shims: { // see JS docs for overview and more options deno: true, }, - typeCheck: false, scriptModule: false, + filterDiagnostic(diagnostic) { + if ( + diagnostic.file?.fileName.includes("node_modules/") || + diagnostic.file?.fileName.includes("src/deps/") || + diagnostic.file?.fileName.includes("src/deps.ts") || + diagnostic.file?.fileName.includes("src/utils.ts") + ) { + return false; // ignore all diagnostics in this file + } + // console.log(diagnostic.file?.fileName); + return true; + }, + declaration: "separate", package: { // package.json properties name: "windmill-cli", version: VERSION, description: "CLI for Windmill", license: "Apache 2.0", + main: "esm/main.js", repository: { type: "git", url: "git+https://github.com/windmill-labs/windmill.git", diff --git a/cli/hub.ts b/cli/hub.ts index 9f95c3e1e6c9f..3784003b38235 100644 --- a/cli/hub.ts +++ b/cli/hub.ts @@ -5,7 +5,7 @@ import { pushResourceType } from "./resource-type.ts"; import { GlobalOptions } from "./types.ts"; import { deepEqual } from "./utils.ts"; -async function pull(opts: GlobalOptions) { +export async function pull(opts: GlobalOptions) { const workspace = await resolveWorkspace(opts); if (workspace.workspaceId !== "admins") { @@ -48,7 +48,7 @@ async function pull(opts: GlobalOptions) { }[] = await fetch(hubBaseUrl + "/resource_types/list", { headers, }) - .then((r) => r.json()) + .then((r) => r.json() as Promise<{ id: number; name: string }[]>) .then((list: { id: number; name: string }[]) => list.map((x) => fetch(hubBaseUrl + "/resource_types/" + x.id + "/" + x.name, { @@ -68,7 +68,11 @@ async function pull(opts: GlobalOptions) { ) ) .then((x) => Promise.all(x)) - .then((x) => x.filter((x) => x).map((x) => x.resource_type)); + .then((x) => + (x as { resource_type: any }[]) + .filter((x) => x) + .map((x) => x.resource_type) + ); const resourceTypes = await ResourceService.listResourceType({ workspace: workspace.workspaceId, diff --git a/cli/main.ts b/cli/main.ts index 502e38d2a28ab..30cb7c70ef0cc 100644 --- a/cli/main.ts +++ b/cli/main.ts @@ -14,8 +14,8 @@ import workspace, { getActiveWorkspace } from "./workspace.ts"; import resource from "./resource.ts"; import user from "./user.ts"; import variable from "./variable.ts"; -import push from "./push.ts"; -import pull from "./pull.ts"; +import lgeacyPush from "./push.ts"; +import legacyPull from "./pull.ts"; import hub from "./hub.ts"; import folder from "./folder.ts"; import schedule from "./schedule.ts"; @@ -27,6 +27,29 @@ import { GlobalOptions } from "./types.ts"; import { OpenAPI } from "./deps.ts"; import { getHeaders } from "./utils.ts"; import { NpmProvider } from "./upgrade.ts"; +import { pull as hubPull } from "./hub.ts"; +import { pull, push } from "./sync.ts"; + +export { + flow, + app, + script, + workspace, + resource, + user, + variable, + hub, + folder, + schedule, + sync, + instance, + dev, + lgeacyPush, + legacyPull, + hubPull, + pull, + push, +}; // addEventListener("error", (event) => { // if (event.error) { @@ -37,7 +60,6 @@ import { NpmProvider } from "./upgrade.ts"; export const VERSION = "1.392.0"; - let command: any = new Command() .name("wmill") .action(() => @@ -115,7 +137,7 @@ let command: any = new Command() ) .command("completions", new CompletionsCommand()); if (Number.parseInt(VERSION.replace("v", "").replace(".", "")) > 1700) { - command = command.command("push", push).command("pull", pull); + command = command.command("push", lgeacyPush).command("pull", legacyPull); } export let showDiffs = false; diff --git a/cli/metadata.ts b/cli/metadata.ts index 510b03ee82709..0da0fb1268f68 100644 --- a/cli/metadata.ts +++ b/cli/metadata.ts @@ -406,8 +406,10 @@ export async function updateFlow( let responseText = "reading response failed"; try { - const res = await rawResponse.json(); - return res?.["updated_flow_value"]; + const res = (await rawResponse.json()) as + | { updated_flow_value: any } + | undefined; + return res?.updated_flow_value; } catch (e) { try { responseText = await rawResponse.text(); diff --git a/cli/pull.ts b/cli/pull.ts index 376b02f251864..769f46bf0bb61 100644 --- a/cli/pull.ts +++ b/cli/pull.ts @@ -17,8 +17,7 @@ export async function downloadZip( includeKey?: boolean, defaultTs?: "bun" | "deno" ): Promise { - const requestHeaders: HeadersInit & { set(x: string, y: string): void } = - new Headers(); + const requestHeaders = new Headers(); requestHeaders.set("Authorization", "Bearer " + workspace.token); requestHeaders.set("Content-Type", "application/octet-stream"); diff --git a/cli/script.ts b/cli/script.ts index 5ac01324f6528..94cbb710ed01e 100644 --- a/cli/script.ts +++ b/cli/script.ts @@ -180,6 +180,9 @@ export async function handleFile( target: "node20.15.1", }); bundleContent = out.outputFiles[0].text; + log.info( + "Bundle size: " + (bundleContent.length / 1024).toFixed(0) + "kB" + ); } if (Array.isArray(codebase.assets) && codebase.assets.length > 0) { const archiveNpm = await import("npm:@ayonli/jsext/archive"); @@ -199,6 +202,7 @@ export async function handleFile( const file = new File([blob], asset.to); tarball.append(file); } + log.info("Tarball size: " + (tarball.size / 1024).toFixed(0) + "kB"); bundleContent = tarball; } log.info(`Finished building the bundle for ${path}`); diff --git a/cli/settings.ts b/cli/settings.ts index 061f1f0cae0cd..1d8afafd82fd9 100644 --- a/cli/settings.ts +++ b/cli/settings.ts @@ -301,6 +301,7 @@ export async function pushInstanceSettings( localSettings = localSettings.filter((s) => s.name !== "base_url"); localSettings.push({ name: "base_url", + //@ts-ignore value: baseUrl, }); } diff --git a/cli/types.ts b/cli/types.ts index ecee767fa393a..49f7a42b9a0d8 100644 --- a/cli/types.ts +++ b/cli/types.ts @@ -1,13 +1,20 @@ // deno-lint-ignore-file no-explicit-any -import { SEP, colors, log, path, yamlParse, yamlStringify } from "./deps.ts"; +import { + Diff, + SEP, + colors, + log, + path, + yamlParse, + yamlStringify, +} from "./deps.ts"; import { pushApp } from "./apps.ts"; import { pushFolder } from "./folder.ts"; import { pushFlow } from "./flow.ts"; import { pushResource } from "./resource.ts"; import { pushResourceType } from "./resource-type.ts"; import { pushVariable } from "./variable.ts"; -import * as Diff from "npm:diff"; import { yamlOptions } from "./sync.ts"; import { showDiffs } from "./main.ts"; import { deepEqual } from "./utils.ts"; diff --git a/frontend/src/lib/components/CliHelpBox.svelte b/frontend/src/lib/components/CliHelpBox.svelte index 1d45b2de166c3..e05ba0f763756 100644 --- a/frontend/src/lib/components/CliHelpBox.svelte +++ b/frontend/src/lib/components/CliHelpBox.svelte @@ -11,8 +11,8 @@