windmill-cli 1.850.1 → 1.851.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/esm/main.js +160 -54
  2. package/package.json +1 -1
package/esm/main.js CHANGED
@@ -16766,7 +16766,7 @@ var init_OpenAPI = __esm(() => {
16766
16766
  PASSWORD: undefined,
16767
16767
  TOKEN: getEnv3("WM_TOKEN"),
16768
16768
  USERNAME: undefined,
16769
- VERSION: "1.850.0",
16769
+ VERSION: "1.851.0",
16770
16770
  WITH_CREDENTIALS: true,
16771
16771
  interceptors: {
16772
16772
  request: new Interceptors,
@@ -20084,7 +20084,7 @@ var init_auth = __esm(async () => {
20084
20084
  });
20085
20085
 
20086
20086
  // src/core/constants.ts
20087
- var WM_FORK_PREFIX = "wm-fork", VERSION = "1.850.0";
20087
+ var WM_FORK_PREFIX = "wm-fork", VERSION = "1.851.0";
20088
20088
 
20089
20089
  // src/utils/resource_folders.ts
20090
20090
  import { existsSync } from "node:fs";
@@ -34569,6 +34569,60 @@ async function ensureNodeModules(appDir) {
34569
34569
  info(colors.green("✅ npm install completed"));
34570
34570
  }
34571
34571
  }
34572
+ function findSharedUiDir(appDir) {
34573
+ let dir = path6.resolve(appDir);
34574
+ while (true) {
34575
+ if (fs9.existsSync(path6.join(dir, "wmill.yaml"))) {
34576
+ return path6.join(dir, "ui");
34577
+ }
34578
+ const parent = path6.dirname(dir);
34579
+ if (parent === dir)
34580
+ return;
34581
+ dir = parent;
34582
+ }
34583
+ }
34584
+ function createSharedUiPlugin(sharedUiDir, appDir) {
34585
+ const uiPrefix = fs9.realpathSync(sharedUiDir) + path6.sep;
34586
+ const resolveDir = path6.resolve(appDir);
34587
+ return {
34588
+ name: "wmill-shared-ui",
34589
+ setup(build) {
34590
+ build.onResolve({ filter: /^\/ui\// }, (args) => {
34591
+ const rel = args.path.slice("/ui/".length);
34592
+ const candidates = [rel];
34593
+ if (!path6.extname(rel)) {
34594
+ candidates.push(rel + ".tsx", rel + ".ts", rel + ".jsx", rel + ".js", rel + ".css", path6.join(rel, "index.tsx"), path6.join(rel, "index.ts"));
34595
+ }
34596
+ for (const c of candidates) {
34597
+ const full = path6.join(sharedUiDir, c);
34598
+ if (fs9.existsSync(full)) {
34599
+ return { path: fs9.realpathSync(full) };
34600
+ }
34601
+ }
34602
+ return {
34603
+ errors: [
34604
+ {
34605
+ text: `Could not resolve shared UI import "${args.path}" in ${sharedUiDir}`
34606
+ }
34607
+ ]
34608
+ };
34609
+ });
34610
+ build.onResolve({ filter: /^[^./]/ }, async (args) => {
34611
+ if (!args.importer.startsWith(uiPrefix))
34612
+ return;
34613
+ if (args.kind === "import-rule" || args.kind === "url-token") {
34614
+ const sibling = await build.resolve("./" + args.path, {
34615
+ resolveDir: args.resolveDir,
34616
+ kind: args.kind
34617
+ });
34618
+ if (sibling.errors.length === 0)
34619
+ return sibling;
34620
+ }
34621
+ return build.resolve(args.path, { resolveDir, kind: args.kind });
34622
+ });
34623
+ }
34624
+ };
34625
+ }
34572
34626
  async function createBundle(options = {}) {
34573
34627
  const esbuild = await getEsbuild();
34574
34628
  const appDir = options.entryPoint ? path6.dirname(options.entryPoint) : process14.cwd();
@@ -34609,35 +34663,7 @@ async function createBundle(options = {}) {
34609
34663
  });
34610
34664
  }
34611
34665
  };
34612
- const sharedUiPlugins = [];
34613
- if (options.sharedUiDir && fs9.existsSync(options.sharedUiDir)) {
34614
- const sharedUiDir = options.sharedUiDir;
34615
- sharedUiPlugins.push({
34616
- name: "wmill-shared-ui",
34617
- setup(build) {
34618
- build.onResolve({ filter: /^\/ui\// }, (args) => {
34619
- const rel = args.path.slice("/ui/".length);
34620
- const candidates = [rel];
34621
- if (!path6.extname(rel)) {
34622
- candidates.push(rel + ".tsx", rel + ".ts", rel + ".jsx", rel + ".js", rel + ".css", path6.join(rel, "index.tsx"), path6.join(rel, "index.ts"));
34623
- }
34624
- for (const c of candidates) {
34625
- const full = path6.join(sharedUiDir, c);
34626
- if (fs9.existsSync(full)) {
34627
- return { path: full };
34628
- }
34629
- }
34630
- return {
34631
- errors: [
34632
- {
34633
- text: `Could not resolve shared UI import "${args.path}" in ${sharedUiDir}`
34634
- }
34635
- ]
34636
- };
34637
- });
34638
- }
34639
- });
34640
- }
34666
+ const sharedUiPlugins = options.sharedUiDir && fs9.existsSync(options.sharedUiDir) ? [createSharedUiPlugin(options.sharedUiDir, appDir)] : [];
34641
34667
  const buildOptions = {
34642
34668
  ...DEFAULT_BUILD_OPTIONS,
34643
34669
  conditions: conditionsFor(frameworks.svelte),
@@ -38122,7 +38148,7 @@ var minimatch = (p, pattern, options = {}) => {
38122
38148
  }, qmarksTestNoExtDot = ([$0]) => {
38123
38149
  const len = $0.length;
38124
38150
  return (f) => f.length === len && f !== "." && f !== "..";
38125
- }, defaultPlatform, path9, sep3, GLOBSTAR, qmark2 = "[^/]", star2, twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?", twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?", filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options), ext = (a, b = {}) => Object.assign({}, a, b), defaults = (def) => {
38151
+ }, defaultPlatform, path9, sep4, GLOBSTAR, qmark2 = "[^/]", star2, twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?", twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?", filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options), ext = (a, b = {}) => Object.assign({}, a, b), defaults = (def) => {
38126
38152
  if (!def || typeof def !== "object" || !Object.keys(def).length) {
38127
38153
  return minimatch;
38128
38154
  }
@@ -38184,8 +38210,8 @@ var init_esm2 = __esm(() => {
38184
38210
  win32: { sep: "\\" },
38185
38211
  posix: { sep: "/" }
38186
38212
  };
38187
- sep3 = defaultPlatform === "win32" ? path9.win32.sep : path9.posix.sep;
38188
- minimatch.sep = sep3;
38213
+ sep4 = defaultPlatform === "win32" ? path9.win32.sep : path9.posix.sep;
38214
+ minimatch.sep = sep4;
38189
38215
  GLOBSTAR = Symbol("globstar **");
38190
38216
  minimatch.GLOBSTAR = GLOBSTAR;
38191
38217
  star2 = qmark2 + "*?";
@@ -58811,7 +58837,7 @@ var init_openflow = __esm(() => {
58811
58837
  openflow_default = {
58812
58838
  openapi: "3.0.3",
58813
58839
  info: {
58814
- version: "1.850.0",
58840
+ version: "1.851.0",
58815
58841
  title: "OpenFlow Spec",
58816
58842
  contact: {
58817
58843
  name: "Ruben Fiszel",
@@ -67141,6 +67167,7 @@ var init_lint = __esm(async () => {
67141
67167
  // src/commands/shared_ui.ts
67142
67168
  import * as fs11 from "node:fs";
67143
67169
  import * as path13 from "node:path";
67170
+ import { createHash } from "node:crypto";
67144
67171
  async function readDirRecursive(dir, rel = "", out = {}) {
67145
67172
  if (!fs11.existsSync(dir))
67146
67173
  return out;
@@ -67156,6 +67183,54 @@ async function readDirRecursive(dir, rel = "", out = {}) {
67156
67183
  }
67157
67184
  return out;
67158
67185
  }
67186
+ function importsSharedUi(files) {
67187
+ return Object.values(files).some((c) => /["'`(]\s*\/ui\//.test(c));
67188
+ }
67189
+ async function sharedUiHash() {
67190
+ const localDir = path13.join(process.cwd(), SHARED_UI_DIR);
67191
+ if (!fs11.existsSync(localDir))
67192
+ return;
67193
+ const files = await readDirRecursive(localDir);
67194
+ const entries = Object.entries(files).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
67195
+ return createHash("sha256").update(JSON.stringify(entries)).digest("hex");
67196
+ }
67197
+ async function rawAppsStaleOnSharedUi(workspace, localMap, skip) {
67198
+ const hash = await sharedUiHash();
67199
+ if (!hash)
67200
+ return [];
67201
+ const apps = new Map;
67202
+ for (const [key, content] of Object.entries(localMap)) {
67203
+ const name = extractResourceName(key, "raw_app");
67204
+ if (!name || skip.has(name))
67205
+ continue;
67206
+ if (!apps.has(name))
67207
+ apps.set(name, { files: {} });
67208
+ const app = apps.get(name);
67209
+ const posix = key.replaceAll("\\", "/");
67210
+ const rel = posix.slice(extractFolderPath(key, "raw_app").length);
67211
+ if (isRawAppFolderMetadataFile(posix)) {
67212
+ app.metaPath = key;
67213
+ } else if (!rel.startsWith(APP_BACKEND_FOLDER + "/")) {
67214
+ app.files[key] = content;
67215
+ }
67216
+ }
67217
+ const stale = await Promise.all([...apps].map(async ([name, { metaPath, files }]) => {
67218
+ if (!metaPath || !importsSharedUi(files))
67219
+ return;
67220
+ try {
67221
+ const app = await getAppByPath({
67222
+ workspace,
67223
+ path: name.replaceAll(path13.sep, "/")
67224
+ });
67225
+ return app.value?.shared_ui_hash === hash ? undefined : metaPath;
67226
+ } catch (e) {
67227
+ if (e?.status === 404)
67228
+ return;
67229
+ throw e;
67230
+ }
67231
+ }));
67232
+ return stale.filter((p) => !!p);
67233
+ }
67159
67234
  async function fetchSharedUi(workspace) {
67160
67235
  try {
67161
67236
  const got = await getSharedUi({ workspace });
@@ -67276,7 +67351,11 @@ var init_shared_ui = __esm(async () => {
67276
67351
  init_log();
67277
67352
  init_colors2();
67278
67353
  init_services_gen();
67279
- await init_utils();
67354
+ await __promiseAll([
67355
+ init_utils(),
67356
+ init_resource_folders(),
67357
+ init_app_metadata()
67358
+ ]);
67280
67359
  });
67281
67360
 
67282
67361
  // src/commands/resource/resource.ts
@@ -70575,6 +70654,19 @@ Push aborted: ${lockIssues.length} script(s) missing locks.`));
70575
70654
  if (unconvertedTree) {
70576
70655
  warn(colors.yellow(`dedupeLockfiles is on but this checkout still holds one lockfile per script. Run 'wmill generate-metadata' (or pull) to convert it — until then every script reads as changed.`));
70577
70656
  }
70657
+ try {
70658
+ const pushedApps = new Set(changes.map((c) => extractResourceName(c.path, "raw_app")).filter((n) => !!n));
70659
+ for (const metaPath of await rawAppsStaleOnSharedUi(workspace.workspaceId, localMap, pushedApps)) {
70660
+ changes.push({
70661
+ name: "edited",
70662
+ path: metaPath,
70663
+ before: localMap[metaPath],
70664
+ after: localMap[metaPath]
70665
+ });
70666
+ }
70667
+ } catch (e) {
70668
+ warn(`Could not check raw apps against the shared UI folder: ${e}`);
70669
+ }
70578
70670
  if (opts.keepDeleted) {
70579
70671
  dropDeletions(changes, "remote");
70580
70672
  }
@@ -71499,7 +71591,8 @@ Run 'wmill folder add-missing' to create them locally, then push again.`;
71499
71591
  try {
71500
71592
  await pushSharedUi(workspace.workspaceId, opts.keepDeleted);
71501
71593
  } catch (e) {
71502
- warn(`Failed to push shared UI folder: ${e}`);
71594
+ error(colors.red(`Failed to push shared UI folder: ${e}`));
71595
+ failedChanges.push({ path: "ui/", error: String(e) });
71503
71596
  }
71504
71597
  try {
71505
71598
  await offerToRunNewMigrations(workspace.workspaceId, newDatatableMigrations, {
@@ -71520,7 +71613,7 @@ Run 'wmill folder add-missing' to create them locally, then push again.`;
71520
71613
  info(colors.gray(`${lockJobs.pending} server-side lock job(s) still running — locks (and inferred assets) land when they finish; check the Runs page if a script stays broken.`));
71521
71614
  }
71522
71615
  }
71523
- const pushedCount = changes.length - failedChanges.length;
71616
+ const pushedCount = changes.length - failedChanges.filter((f) => f.path !== "ui/").length;
71524
71617
  if (opts.jsonOutput) {
71525
71618
  const result = {
71526
71619
  success: failedChanges.length === 0,
@@ -71558,17 +71651,21 @@ Done! All ${changes.length} changes pushed to the remote workspace ${workspace.w
71558
71651
  }
71559
71652
  } else {
71560
71653
  let sharedUiPushed = false;
71654
+ let sharedUiError;
71561
71655
  if (!opts.dryRun) {
71562
71656
  try {
71563
71657
  sharedUiPushed = await pushSharedUi(workspace.workspaceId, opts.keepDeleted);
71564
71658
  } catch (e) {
71565
- warn(`Failed to push shared UI folder: ${e}`);
71659
+ sharedUiError = String(e);
71660
+ error(colors.red(`Failed to push shared UI folder: ${e}`));
71661
+ process.exitCode = 1;
71566
71662
  }
71567
71663
  }
71568
71664
  if (opts.jsonOutput) {
71569
71665
  console.log(JSON.stringify({
71570
- success: true,
71571
- message: sharedUiPushed ? "Pushed shared UI changes" : "No changes to push",
71666
+ success: sharedUiError === undefined,
71667
+ message: sharedUiError !== undefined ? "Failed to push shared UI changes" : sharedUiPushed ? "Pushed shared UI changes" : "No changes to push",
71668
+ ...sharedUiError !== undefined ? { failed: [{ path: "ui/", error: sharedUiError }] } : {},
71572
71669
  total: 0
71573
71670
  }, null, 2));
71574
71671
  }
@@ -72942,6 +73039,10 @@ async function pushRawApp(workspace, remotePath, localPath, message, defaultTs =
72942
73039
  if (localApp.data) {
72943
73040
  value.data = localApp.data;
72944
73041
  }
73042
+ const uiHash = importsSharedUi(files) ? await sharedUiHash() : undefined;
73043
+ if (uiHash) {
73044
+ value.shared_ui_hash = uiHash;
73045
+ }
72945
73046
  const {
72946
73047
  extra_perms: localPerms,
72947
73048
  sandbox: _sandbox,
@@ -72952,7 +73053,7 @@ async function pushRawApp(workspace, remotePath, localPath, message, defaultTs =
72952
73053
  const customPath = customPathFromFile ? localCustomPath : undefined;
72953
73054
  if (app) {
72954
73055
  const metadataUpToDate = isSuperset({ ...localAppNoPerms, runnables }, app) && changedCustomPath(customPath, app) === undefined && isolationUpToDate(isolation, deployedPolicy, true);
72955
- const filesUpToDate = deepEqual(files, app.value?.files);
73056
+ const filesUpToDate = deepEqual(files, app.value?.files) && app.value?.shared_ui_hash === value.shared_ui_hash;
72956
73057
  if (metadataUpToDate && filesUpToDate) {
72957
73058
  info(colors.green(`App ${remotePath} is up to date`));
72958
73059
  } else {
@@ -73042,6 +73143,7 @@ var init_raw_apps = __esm(async () => {
73042
73143
  init_app(),
73043
73144
  init_permissioned_as(),
73044
73145
  init_bundle(),
73146
+ init_shared_ui(),
73045
73147
  init_app_metadata(),
73046
73148
  init_app_files(),
73047
73149
  init_utils(),
@@ -74157,6 +74259,8 @@ data: reload
74157
74259
  }
74158
74260
  const buildOptions = getDevBuildOptions(entryPoint, frameworks.svelte);
74159
74261
  const frameworkPlugins = await createFrameworkPlugins(appDir);
74262
+ const sharedUiDir = findSharedUiDir(appDir);
74263
+ const sharedUiPlugins = sharedUiDir && fs13.existsSync(sharedUiDir) ? [createSharedUiPlugin(sharedUiDir, appDir)] : [];
74160
74264
  const wmillPlugin = {
74161
74265
  name: "wmill-virtual",
74162
74266
  setup(build) {
@@ -74198,7 +74302,8 @@ data: reload
74198
74302
  });
74199
74303
  }
74200
74304
  },
74201
- wmillPlugin
74305
+ wmillPlugin,
74306
+ ...sharedUiPlugins
74202
74307
  ]
74203
74308
  });
74204
74309
  await ctx.watch();
@@ -75523,7 +75628,8 @@ async function validateBuild(appDir) {
75523
75628
  await createBundle({
75524
75629
  entryPoint,
75525
75630
  production: true,
75526
- minify: false
75631
+ minify: false,
75632
+ sharedUiDir: findSharedUiDir(appDir)
75527
75633
  });
75528
75634
  info(colors.green("✅ Build successful"));
75529
75635
  } catch (error) {
@@ -91584,7 +91690,7 @@ var init_freshness_gate = __esm(() => {
91584
91690
  });
91585
91691
 
91586
91692
  // src/guidance/freshness.ts
91587
- import { createHash as createHash2 } from "node:crypto";
91693
+ import { createHash as createHash3 } from "node:crypto";
91588
91694
  import { stat as stat20 } from "node:fs/promises";
91589
91695
  function buildPromptsHashMarker(hash) {
91590
91696
  return `${PROMPTS_HASH_MARKER_PREFIX}${hash} -->`;
@@ -91603,7 +91709,7 @@ function injectPromptsHashMarker(content, hash) {
91603
91709
  `);
91604
91710
  }
91605
91711
  function currentPromptsHash(nonDottedPaths) {
91606
- const hasher = createHash2("sha256");
91712
+ const hasher = createHash3("sha256");
91607
91713
  hasher.update("template:");
91608
91714
  hasher.update(generateAgentsCliMdContent("__PLACEHOLDER__"));
91609
91715
  hasher.update(`
@@ -91684,7 +91790,7 @@ var init_freshness = __esm(async () => {
91684
91790
 
91685
91791
  // src/commands/refresh/tsconfig.ts
91686
91792
  import { execSync as execSync6 } from "node:child_process";
91687
- import { createHash as createHash3 } from "node:crypto";
91793
+ import { createHash as createHash4 } from "node:crypto";
91688
91794
  import { existsSync as existsSync20, readFileSync as readFileSync6, writeFileSync as writeFileSync9 } from "node:fs";
91689
91795
  import path26 from "node:path";
91690
91796
  import process25 from "node:process";
@@ -91707,7 +91813,7 @@ function buildManagedTsconfig() {
91707
91813
  };
91708
91814
  }
91709
91815
  function currentTsconfigHash() {
91710
- return createHash3("sha256").update(JSON.stringify(buildManagedTsconfig())).digest("hex").slice(0, 12);
91816
+ return createHash4("sha256").update(JSON.stringify(buildManagedTsconfig())).digest("hex").slice(0, 12);
91711
91817
  }
91712
91818
  function deepEqual2(a, b) {
91713
91819
  if (a === b)
@@ -93035,7 +93141,7 @@ await __promiseAll([
93035
93141
  init_user(),
93036
93142
  init_variable()
93037
93143
  ]);
93038
- import { realpathSync as realpathSync2 } from "node:fs";
93144
+ import { realpathSync as realpathSync3 } from "node:fs";
93039
93145
  import { fileURLToPath as fileURLToPath2 } from "node:url";
93040
93146
 
93041
93147
  // src/commands/hub/hub.ts
@@ -93748,7 +93854,7 @@ await __promiseAll([
93748
93854
  init_utils(),
93749
93855
  init_yaml()
93750
93856
  ]);
93751
- import { createHash } from "node:crypto";
93857
+ import { createHash as createHash2 } from "node:crypto";
93752
93858
  import { stat as stat18 } from "node:fs/promises";
93753
93859
  import { sep as SEP21 } from "node:path";
93754
93860
  function canonicalJson(value) {
@@ -93764,7 +93870,7 @@ function canonicalJson(value) {
93764
93870
  return JSON.stringify(value);
93765
93871
  }
93766
93872
  function digestOf(value) {
93767
- return createHash("sha256").update(canonicalJson(value), "utf8").digest("hex");
93873
+ return createHash2("sha256").update(canonicalJson(value), "utf8").digest("hex");
93768
93874
  }
93769
93875
  function inlineSteps(modules, steps) {
93770
93876
  for (const m of modules ?? []) {
@@ -100731,12 +100837,12 @@ await __promiseAll([
100731
100837
  import * as http4 from "node:http";
100732
100838
  import * as fs20 from "node:fs";
100733
100839
  import * as path28 from "node:path";
100734
- import { createHash as createHash4, randomBytes as randomBytes2 } from "node:crypto";
100840
+ import { createHash as createHash5, randomBytes as randomBytes2 } from "node:crypto";
100735
100841
  import process27 from "node:process";
100736
100842
  var PORT2 = 3201;
100737
100843
  var LISTEN_HOST = "127.0.0.1";
100738
100844
  async function stableWsToken(remote, workspaceId, root, folder, port) {
100739
- const key = createHash4("sha256").update(`${remote}\x00${workspaceId}\x00${root}\x00${folder}\x00${port}`).digest("hex").slice(0, 32);
100845
+ const key = createHash5("sha256").update(`${remote}\x00${workspaceId}\x00${root}\x00${folder}\x00${port}`).digest("hex").slice(0, 32);
100740
100846
  let tokenFile;
100741
100847
  try {
100742
100848
  tokenFile = path28.join(await getConfigDirPath(), `pipeline-dev-${key}.token`);
@@ -102125,7 +102231,7 @@ function isMain() {
102125
102231
  const scriptPath = process.argv[1];
102126
102232
  if (!scriptPath)
102127
102233
  return false;
102128
- const realScriptPath = realpathSync2(scriptPath);
102234
+ const realScriptPath = realpathSync3(scriptPath);
102129
102235
  const modulePath = fileURLToPath2(import.meta.url);
102130
102236
  return realScriptPath === modulePath;
102131
102237
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windmill-cli",
3
- "version": "1.850.1",
3
+ "version": "1.851.0",
4
4
  "description": "CLI for Windmill",
5
5
  "license": "Apache 2.0",
6
6
  "type": "module",