windmill-cli 1.414.1 → 1.415.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.
@@ -32,7 +32,7 @@ export const OpenAPI = {
32
32
  PASSWORD: undefined,
33
33
  TOKEN: getEnv("WM_TOKEN"),
34
34
  USERNAME: undefined,
35
- VERSION: '1.414.1',
35
+ VERSION: '1.415.0',
36
36
  WITH_CREDENTIALS: true,
37
37
  interceptors: {
38
38
  request: new Interceptors(),
package/esm/instance.js CHANGED
@@ -108,6 +108,16 @@ export function compareInstanceObjects(fromObjects, toObjects, idProp, objectNam
108
108
  }
109
109
  export async function pickInstance(opts, allowNew) {
110
110
  const instances = await allInstances();
111
+ if (opts.baseUrl && opts.token && opts.instance) {
112
+ log.info("Using instance defined by --instance, --base-url and --token");
113
+ setClient(opts.token, opts.baseUrl.endsWith("/") ? opts.baseUrl.slice(0, -1) : opts.baseUrl);
114
+ return {
115
+ name: opts.instance,
116
+ remote: opts.baseUrl,
117
+ token: opts.token,
118
+ prefix: opts.instance,
119
+ };
120
+ }
111
121
  if (opts.baseUrl && opts.token) {
112
122
  log.info("Using instance fully defined by --base-url and --token");
113
123
  setClient(opts.token, opts.baseUrl.endsWith("/") ? opts.baseUrl.slice(0, -1) : opts.baseUrl);
@@ -202,7 +212,7 @@ async function instancePull(opts) {
202
212
  if (opts.includeWorkspaces) {
203
213
  log.info("\nPulling all workspaces");
204
214
  const rootDir = dntShim.Deno.cwd();
205
- const localWorkspaces = await getLocalWorkspaces(rootDir, instance.prefix);
215
+ const localWorkspaces = await getLocalWorkspaces(rootDir, instance.prefix, opts.folderPerInstance);
206
216
  const previousActiveWorkspace = await getActiveWorkspace(undefined);
207
217
  const remoteWorkspaces = await wmill.listWorkspacesAsSuperAdmin({
208
218
  page: 1,
@@ -210,7 +220,9 @@ async function instancePull(opts) {
210
220
  });
211
221
  for (const remoteWorkspace of remoteWorkspaces) {
212
222
  log.info("\nPulling workspace " + remoteWorkspace.id);
213
- const workspaceName = instance.prefix + "_" + remoteWorkspace.id;
223
+ const workspaceName = opts?.folderPerInstance
224
+ ? instance.prefix + "/" + remoteWorkspace.id
225
+ : instance.prefix + "_" + remoteWorkspace.id;
214
226
  await dntShim.Deno.mkdir(path.join(rootDir, workspaceName), {
215
227
  recursive: true,
216
228
  });
@@ -310,22 +322,28 @@ async function instancePush(opts) {
310
322
  if (opts.includeWorkspaces) {
311
323
  instances = await allInstances();
312
324
  const rootDir = dntShim.Deno.cwd();
313
- const localPrefix = (await Select.prompt({
314
- message: "What is the prefix of the local workspaces you want to sync?",
315
- options: [
316
- ...instances.map((i) => ({
317
- name: `${i.prefix} (${i.name} - ${i.remote})`,
318
- value: i.prefix,
319
- })),
320
- ],
321
- default: instance.prefix,
322
- }));
325
+ let localPrefix;
326
+ if (opts.baseUrl && opts.token) {
327
+ localPrefix = "custom";
328
+ }
329
+ else {
330
+ localPrefix = (await Select.prompt({
331
+ message: "What is the prefix of the local workspaces you want to sync?",
332
+ options: [
333
+ ...instances.map((i) => ({
334
+ name: `${i.prefix} (${i.name} - ${i.remote})`,
335
+ value: i.prefix,
336
+ })),
337
+ ],
338
+ default: instance.prefix,
339
+ }));
340
+ }
323
341
  const remoteWorkspaces = await wmill.listWorkspacesAsSuperAdmin({
324
342
  page: 1,
325
343
  perPage: 1000,
326
344
  });
327
345
  const previousActiveWorkspace = await getActiveWorkspace(undefined);
328
- const localWorkspaces = await getLocalWorkspaces(rootDir, localPrefix);
346
+ const localWorkspaces = await getLocalWorkspaces(rootDir, localPrefix, opts.folderPerInstance);
329
347
  log.info(`\nPushing all workspaces: ${localWorkspaces.map((x) => x.id).join(", ")}`);
330
348
  for (const localWorkspace of localWorkspaces) {
331
349
  log.info("\nPushing workspace " + localWorkspace.id);
@@ -383,16 +401,31 @@ async function instancePush(opts) {
383
401
  log.info(colors.green.underline.bold("All workspaces pushed"));
384
402
  }
385
403
  }
386
- async function getLocalWorkspaces(rootDir, localPrefix) {
404
+ async function getLocalWorkspaces(rootDir, localPrefix, folderPerInstance) {
387
405
  const localWorkspaces = [];
388
- for await (const dir of dntShim.Deno.readDir(rootDir)) {
389
- const dirName = dir.name;
390
- if (dirName.startsWith(localPrefix + "_")) {
406
+ if (!(await dntShim.Deno.stat(localPrefix).catch(() => null))) {
407
+ await dntShim.Deno.mkdir(localPrefix);
408
+ }
409
+ if (folderPerInstance) {
410
+ for await (const dir of dntShim.Deno.readDir(rootDir + "/" + localPrefix)) {
411
+ const dirName = dir.name;
391
412
  localWorkspaces.push({
392
- dir: dirName,
393
- id: dirName.substring(localPrefix.length + 1),
413
+ dir: localPrefix + "/" + dirName,
414
+ id: dirName,
394
415
  });
395
416
  }
417
+ log.info(localWorkspaces);
418
+ }
419
+ else {
420
+ for await (const dir of dntShim.Deno.readDir(rootDir)) {
421
+ const dirName = dir.name;
422
+ if (dirName.startsWith(localPrefix + "_")) {
423
+ localWorkspaces.push({
424
+ dir: dirName,
425
+ id: dirName.substring(localPrefix.length + 1),
426
+ });
427
+ }
428
+ }
396
429
  }
397
430
  return localWorkspaces;
398
431
  }
@@ -489,7 +522,8 @@ const command = new Command()
489
522
  .option("--skip-configs", "Skip pulling configs (worker groups and SMTP)")
490
523
  .option("--skip-groups", "Skip pulling instance groups")
491
524
  .option("--include-workspaces", "Also pull workspaces")
492
- .option("--instance <instance:string>", "Name of the instance to push to, override the active instance")
525
+ .option("--folder-per-instance", "Create a folder per instance")
526
+ .option("--instance <instance:string>", "Name of the instance to pull from, override the active instance")
493
527
  .action(instancePull)
494
528
  .command("push")
495
529
  .description("Push instance settings, users, configs, group and overwrite remote")
@@ -499,6 +533,7 @@ const command = new Command()
499
533
  .option("--skip-configs", "Skip pushing configs (worker groups and SMTP)")
500
534
  .option("--skip-groups", "Skip pushing instance groups")
501
535
  .option("--include-workspaces", "Also push workspaces")
536
+ .option("--folder-per-instance", "Create a folder per instance")
502
537
  .option("--instance <instance:string>", "Name of the instance to push to, override the active instance")
503
538
  .action(instancePush)
504
539
  .command("whoami")
package/esm/main.js CHANGED
@@ -33,7 +33,7 @@ export { flow, app, script, workspace, resource, user, variable, hub, folder, sc
33
33
  // console.error(JSON.stringify(event.error, null, 4));
34
34
  // }
35
35
  // });
36
- export const VERSION = "1.414.1";
36
+ export const VERSION = "1.415.0";
37
37
  const command = new Command()
38
38
  .name("wmill")
39
39
  .action(() => log.info(`Welcome to Windmill CLI ${VERSION}. Use -h for help.`))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windmill-cli",
3
- "version": "1.414.1",
3
+ "version": "1.415.0",
4
4
  "description": "CLI for Windmill",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,6 +25,7 @@ export type InstanceSyncOptions = {
25
25
  instance?: string;
26
26
  baseUrl?: string;
27
27
  token?: string;
28
+ folderPerInstance?: boolean;
28
29
  yes?: boolean;
29
30
  };
30
31
  export declare function pickInstance(opts: InstanceSyncOptions, allowNew: boolean): Promise<Instance>;
@@ -1 +1 @@
1
- {"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../src/instance.ts"],"names":[],"mappings":"AACA,OAAO,EAML,OAAO,EAGR,MAAM,WAAW,CAAC;AAgCnB,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,YAAY,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,CAiBxD;AACD,wBAAsB,WAAW,CAC/B,IAAI,EAAE,EAAE,EACR,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,KAAK,EAAE,MAAM,GAAG,SAAS;;;;;GA2C1B;AA4BD,KAAK,aAAa,CAAC,CAAC,SAAS,MAAM,IAAI;KACpC,CAAC,IAAI,CAAC,GAAG,MAAM;CACjB,CAAC;AACF,wBAAgB,sBAAsB,C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,EACjB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CAoBjB;AAGD,wBAAsB,OAAO,CAC3B,kBAAkB,EAAE,MAAM,EAC1B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CAuBjB"}
1
+ {"version":3,"file":"local_encryption.d.ts","sourceRoot":"","sources":["../src/local_encryption.ts"],"names":[],"mappings":"AAmCA,wBAAsB,OAAO,CAC3B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CAoBjB;AAGD,wBAAsB,OAAO,CAC3B,kBAAkB,EAAE,MAAM,EAC1B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CAuBjB"}
package/types/main.d.ts CHANGED
@@ -19,7 +19,7 @@ import { pull as hubPull } from "./hub.js";
19
19
  import { pull, push } from "./sync.js";
20
20
  import { add as workspaceAdd } from "./workspace.js";
21
21
  export { flow, app, script, workspace, resource, user, variable, hub, folder, schedule, sync, instance, dev, hubPull, pull, push, workspaceAdd, };
22
- export declare const VERSION = "1.414.1";
22
+ export declare const VERSION = "1.415.0";
23
23
  declare const command: Command<{
24
24
  workspace?: (import("./deps/jsr.io/@windmill-labs/cliffy-command/1.0.0-rc.5/mod.js").StringType & string) | undefined;
25
25
  } & {