windmill-cli 1.405.4 → 1.406.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.
- package/esm/gen/core/OpenAPI.js +1 -1
- package/esm/instance.js +38 -22
- package/esm/main.js +1 -1
- package/esm/workspace.js +8 -4
- package/package.json +1 -1
- package/types/instance.d.ts.map +1 -1
- package/types/main.d.ts +1 -1
- package/types/workspace.d.ts +2 -1
- package/types/workspace.d.ts.map +1 -1
package/esm/gen/core/OpenAPI.js
CHANGED
package/esm/instance.js
CHANGED
|
@@ -7,9 +7,10 @@ import { getRootStore } from "./store.js";
|
|
|
7
7
|
import { push, pull } from "./sync.js";
|
|
8
8
|
import { showDiff } from "./types.js";
|
|
9
9
|
import { pushInstanceUsers, pullInstanceUsers, pullInstanceGroups, pushInstanceGroups, } from "./user.js";
|
|
10
|
-
import { add as workspaceSetup, addWorkspace,
|
|
10
|
+
import { add as workspaceSetup, addWorkspace, removeWorkspace, setActiveWorkspace, } from "./workspace.js";
|
|
11
11
|
import { pushInstanceSettings, pullInstanceSettings, pullInstanceConfigs, pushInstanceConfigs, } from "./settings.js";
|
|
12
|
-
import {
|
|
12
|
+
import { deepEqual } from "./utils.js";
|
|
13
|
+
import { getActiveWorkspace } from "./workspace.js";
|
|
13
14
|
export async function allInstances() {
|
|
14
15
|
try {
|
|
15
16
|
const file = (await getRootStore()) + "instances.ndjson";
|
|
@@ -198,19 +199,17 @@ async function instancePull(opts) {
|
|
|
198
199
|
else {
|
|
199
200
|
log.info("No instance-level changes to apply");
|
|
200
201
|
}
|
|
201
|
-
sleep(1000);
|
|
202
202
|
if (opts.includeWorkspaces) {
|
|
203
203
|
log.info("\nPulling all workspaces");
|
|
204
|
+
const rootDir = dntShim.Deno.cwd();
|
|
205
|
+
const localWorkspaces = await getLocalWorkspaces(rootDir, instance.prefix);
|
|
206
|
+
const previousActiveWorkspace = await getActiveWorkspace(undefined);
|
|
204
207
|
const remoteWorkspaces = await wmill.listWorkspacesAsSuperAdmin({
|
|
205
208
|
page: 1,
|
|
206
209
|
perPage: 1000,
|
|
207
210
|
});
|
|
208
|
-
let localWorkspaces = await allWorkspaces();
|
|
209
|
-
localWorkspaces = localWorkspaces.filter((w) => w.name.startsWith(instance.prefix + "_"));
|
|
210
|
-
const rootDir = dntShim.Deno.cwd();
|
|
211
211
|
for (const remoteWorkspace of remoteWorkspaces) {
|
|
212
212
|
log.info("\nPulling workspace " + remoteWorkspace.id);
|
|
213
|
-
sleep(1000);
|
|
214
213
|
const workspaceName = instance.prefix + "_" + remoteWorkspace.id;
|
|
215
214
|
await dntShim.Deno.mkdir(path.join(rootDir, workspaceName), {
|
|
216
215
|
recursive: true,
|
|
@@ -237,23 +236,26 @@ async function instancePull(opts) {
|
|
|
237
236
|
yes: opts.yes,
|
|
238
237
|
});
|
|
239
238
|
}
|
|
240
|
-
const localWorkspacesToDelete = localWorkspaces.filter((w) => !remoteWorkspaces.find((r) => r.id === w.
|
|
239
|
+
const localWorkspacesToDelete = localWorkspaces.filter((w) => !remoteWorkspaces.find((r) => r.id === w.id));
|
|
241
240
|
if (localWorkspacesToDelete.length > 0) {
|
|
242
241
|
const confirmDelete = opts.yes ||
|
|
243
242
|
(await Confirm.prompt({
|
|
244
243
|
message: "Do you want to delete the local copy of workspaces that don't exist anymore on the instance?\n" +
|
|
245
|
-
localWorkspacesToDelete.map((w) => w
|
|
244
|
+
localWorkspacesToDelete.map((w) => w).join(", "),
|
|
246
245
|
default: true,
|
|
247
246
|
}));
|
|
248
247
|
if (confirmDelete) {
|
|
249
248
|
for (const workspace of localWorkspacesToDelete) {
|
|
250
|
-
await removeWorkspace(workspace.
|
|
251
|
-
await dntShim.Deno.remove(path.join(rootDir, workspace.
|
|
249
|
+
await removeWorkspace(workspace.id, false, {});
|
|
250
|
+
await dntShim.Deno.remove(path.join(rootDir, workspace.dir), {
|
|
252
251
|
recursive: true,
|
|
253
252
|
});
|
|
254
253
|
}
|
|
255
254
|
}
|
|
256
255
|
}
|
|
256
|
+
if (previousActiveWorkspace) {
|
|
257
|
+
await setActiveWorkspace(previousActiveWorkspace?.name);
|
|
258
|
+
}
|
|
257
259
|
log.info(colors.green.underline.bold("All workspaces pulled"));
|
|
258
260
|
}
|
|
259
261
|
}
|
|
@@ -305,9 +307,9 @@ async function instancePush(opts) {
|
|
|
305
307
|
else {
|
|
306
308
|
log.info("No instance-level changes to apply");
|
|
307
309
|
}
|
|
308
|
-
sleep(1000);
|
|
309
310
|
if (opts.includeWorkspaces) {
|
|
310
311
|
instances = await allInstances();
|
|
312
|
+
const rootDir = dntShim.Deno.cwd();
|
|
311
313
|
const localPrefix = (await Select.prompt({
|
|
312
314
|
message: "What is the prefix of the local workspaces you want to sync?",
|
|
313
315
|
options: [
|
|
@@ -322,15 +324,13 @@ async function instancePush(opts) {
|
|
|
322
324
|
page: 1,
|
|
323
325
|
perPage: 1000,
|
|
324
326
|
});
|
|
325
|
-
|
|
326
|
-
localWorkspaces =
|
|
327
|
-
log.info(
|
|
328
|
-
const rootDir = dntShim.Deno.cwd();
|
|
327
|
+
const previousActiveWorkspace = await getActiveWorkspace(undefined);
|
|
328
|
+
const localWorkspaces = await getLocalWorkspaces(rootDir, localPrefix);
|
|
329
|
+
log.info(`\nPushing all workspaces: ${localWorkspaces.map((x) => x.id).join(", ")}`);
|
|
329
330
|
for (const localWorkspace of localWorkspaces) {
|
|
330
|
-
log.info("\nPushing workspace " + localWorkspace.
|
|
331
|
-
sleep(1000);
|
|
331
|
+
log.info("\nPushing workspace " + localWorkspace.id);
|
|
332
332
|
try {
|
|
333
|
-
await dntShim.Deno.chdir(path.join(rootDir, localWorkspace.
|
|
333
|
+
await dntShim.Deno.chdir(path.join(rootDir, localWorkspace.dir));
|
|
334
334
|
}
|
|
335
335
|
catch (_) {
|
|
336
336
|
throw new Error("Workspace folder not found, are you in the right directory?");
|
|
@@ -344,14 +344,14 @@ async function instancePush(opts) {
|
|
|
344
344
|
create: true,
|
|
345
345
|
createWorkspaceName: workspaceSettings.name,
|
|
346
346
|
createUsername: undefined,
|
|
347
|
-
}, localWorkspace.
|
|
347
|
+
}, localWorkspace.dir, localWorkspace.id, instance.remote);
|
|
348
348
|
}
|
|
349
349
|
catch (_) {
|
|
350
350
|
log.error("Settings file not found in workspace local folder, skipping");
|
|
351
351
|
continue;
|
|
352
352
|
}
|
|
353
353
|
await push({
|
|
354
|
-
workspace: localWorkspace.
|
|
354
|
+
workspace: localWorkspace.dir,
|
|
355
355
|
token: undefined,
|
|
356
356
|
baseUrl: undefined,
|
|
357
357
|
includeGroups: true,
|
|
@@ -362,7 +362,7 @@ async function instancePush(opts) {
|
|
|
362
362
|
yes: opts.yes,
|
|
363
363
|
});
|
|
364
364
|
}
|
|
365
|
-
const workspacesToDelete = remoteWorkspaces.filter((w) => !localWorkspaces.find((l) => l.
|
|
365
|
+
const workspacesToDelete = remoteWorkspaces.filter((w) => !localWorkspaces.find((l) => l.id === w.id));
|
|
366
366
|
if (workspacesToDelete.length > 0) {
|
|
367
367
|
const confirmDelete = opts.yes ||
|
|
368
368
|
(await Confirm.prompt({
|
|
@@ -377,9 +377,25 @@ async function instancePush(opts) {
|
|
|
377
377
|
}
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
|
+
if (previousActiveWorkspace) {
|
|
381
|
+
await setActiveWorkspace(previousActiveWorkspace?.name);
|
|
382
|
+
}
|
|
380
383
|
log.info(colors.green.underline.bold("All workspaces pushed"));
|
|
381
384
|
}
|
|
382
385
|
}
|
|
386
|
+
async function getLocalWorkspaces(rootDir, localPrefix) {
|
|
387
|
+
const localWorkspaces = [];
|
|
388
|
+
for await (const dir of dntShim.Deno.readDir(rootDir)) {
|
|
389
|
+
const dirName = dir.name;
|
|
390
|
+
if (dirName.startsWith(localPrefix + "_")) {
|
|
391
|
+
localWorkspaces.push({
|
|
392
|
+
dir: dirName,
|
|
393
|
+
id: dirName.substring(localPrefix.length + 1),
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return localWorkspaces;
|
|
398
|
+
}
|
|
383
399
|
async function switchI(opts, instanceName) {
|
|
384
400
|
const all = await allInstances();
|
|
385
401
|
if (all.findIndex((x) => x.name === instanceName) === -1) {
|
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.
|
|
36
|
+
export const VERSION = "1.406.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/esm/workspace.js
CHANGED
|
@@ -25,8 +25,8 @@ export async function allWorkspaces() {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
async function getActiveWorkspaceName(opts) {
|
|
28
|
-
if (opts
|
|
29
|
-
return opts
|
|
28
|
+
if (opts?.workspace) {
|
|
29
|
+
return opts?.workspace;
|
|
30
30
|
}
|
|
31
31
|
try {
|
|
32
32
|
return await dntShim.Deno.readTextFile((await getRootStore()) + "/activeWorkspace");
|
|
@@ -84,7 +84,11 @@ async function switchC(opts, workspaceName) {
|
|
|
84
84
|
}
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
await setActiveWorkspace(workspaceName);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
export async function setActiveWorkspace(workspaceName) {
|
|
91
|
+
await dntShim.Deno.writeTextFile((await getRootStore()) + "/activeWorkspace", workspaceName);
|
|
88
92
|
}
|
|
89
93
|
export async function add(opts, workspaceName, workspaceId, remote) {
|
|
90
94
|
if (opts.workspace) {
|
|
@@ -169,7 +173,7 @@ export async function add(opts, workspaceName, workspaceId, remote) {
|
|
|
169
173
|
workspaceId: workspaceId,
|
|
170
174
|
token: token,
|
|
171
175
|
}, opts);
|
|
172
|
-
await
|
|
176
|
+
await setActiveWorkspace(workspaceName);
|
|
173
177
|
log.info(colors.green.underline(`Added workspace ${workspaceName} for ${workspaceId} on ${remote}!`));
|
|
174
178
|
}
|
|
175
179
|
export async function addWorkspace(workspace, opts) {
|
package/package.json
CHANGED
package/types/instance.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../src/instance.ts"],"names":[],"mappings":"AACA,OAAO,EAML,OAAO,EAGR,MAAM,WAAW,CAAC;
|
|
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,CAAC,CAAC,SAAS,MAAM,EACrD,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,EAC/B,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,EAC7B,MAAM,EAAE,CAAC,EACT,UAAU,EAAE,MAAM,UAwBnB;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,wBAAsB,YAAY,CAChC,IAAI,EAAE,mBAAmB,EACzB,QAAQ,EAAE,OAAO,qBAwDlB;AA2TD,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAS9B;AAeD,QAAA,MAAM,OAAO;;;;;;oBAyFW,CAAC;AAEzB,eAAe,OAAO,CAAC"}
|
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.
|
|
22
|
+
export declare const VERSION = "1.406.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
|
} & {
|
package/types/workspace.d.ts
CHANGED
|
@@ -7,8 +7,9 @@ export interface Workspace {
|
|
|
7
7
|
token: string;
|
|
8
8
|
}
|
|
9
9
|
export declare function allWorkspaces(): Promise<Workspace[]>;
|
|
10
|
-
export declare function getActiveWorkspace(opts: GlobalOptions): Promise<Workspace | undefined>;
|
|
10
|
+
export declare function getActiveWorkspace(opts: GlobalOptions | undefined): Promise<Workspace | undefined>;
|
|
11
11
|
export declare function getWorkspaceByName(workspaceName: string): Promise<Workspace | undefined>;
|
|
12
|
+
export declare function setActiveWorkspace(workspaceName: string): Promise<void>;
|
|
12
13
|
export declare function add(opts: GlobalOptions & {
|
|
13
14
|
create: boolean;
|
|
14
15
|
createWorkspaceName: string | undefined;
|
package/types/workspace.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C,OAAO,EAAU,OAAO,EAAgC,MAAM,WAAW,CAAC;AAK1E,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAiB1D;AAeD,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C,OAAO,EAAU,OAAO,EAAgC,MAAM,WAAW,CAAC;AAK1E,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAiB1D;AAeD,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,aAAa,GAAG,SAAS,GAC9B,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAMhC;AAED,wBAAsB,kBAAkB,CACtC,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAQhC;AAqDD,wBAAsB,kBAAkB,CAAC,aAAa,EAAE,MAAM,iBAK7D;AAED,wBAAsB,GAAG,CACvB,IAAI,EAAE,aAAa,GAAG;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC,EACD,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,MAAM,EAAE,MAAM,GAAG,SAAS,iBAuH3B;AAED,wBAAsB,YAAY,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,iBAYjE;AAED,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,GAAG,iBA4BV;AAaD,QAAA,MAAM,OAAO;;;;;;oBA8BW,CAAC;AAEzB,eAAe,OAAO,CAAC"}
|