@tailor-platform/sdk 0.18.2 → 0.19.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/CHANGELOG.md +12 -0
- package/dist/cli/api.d.mts +24 -14
- package/dist/cli/api.mjs +1 -1
- package/dist/cli/api.mjs.map +1 -1
- package/dist/cli/index.d.mts +8 -1
- package/dist/cli/index.mjs +70 -178
- package/dist/cli/index.mjs.map +1 -1
- package/dist/configure/index.d.mts +2 -2
- package/dist/{index-Ba6ekRxa.d.mts → index-BQ2qAr3Q.d.mts} +2 -2
- package/dist/job-CL8myeqs.mjs.map +1 -1
- package/dist/{resume-8Y9mmXHa.mjs → resume-DSfYKl2w.mjs} +754 -665
- package/dist/{resume-8Y9mmXHa.mjs.map → resume-DSfYKl2w.mjs.map} +1 -1
- package/dist/{types-Dz5wcR2h.d.mts → types-BBF5LRC0.d.mts} +39 -15
- package/dist/utils/test/index.d.mts +2 -2
- package/docs/cli/application.md +3 -3
- package/docs/cli/auth.md +4 -4
- package/docs/cli/secret.md +2 -2
- package/docs/cli/user.md +8 -8
- package/docs/cli/workflow.md +12 -12
- package/docs/cli/workspace.md +6 -6
- package/docs/cli-reference.md +33 -6
- package/docs/services/workflow.md +1 -1
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { PATScope, applyCommand, commonArgs, createCommand, deleteCommand, executionsCommand, fetchAll, fetchLatestToken, fetchUserInfo, generateCommand, getCommand, getCommand$1 as getCommand$2, initOAuth2Client, initOperatorClient, jsonArgs, listCommand as listCommand$1, listCommand$1 as listCommand$7, listCommand$2 as listCommand$8, listCommand$3 as listCommand, loadAccessToken, loadConfig, loadWorkspaceId, printData, readPackageJson, readPlatformConfig, removeCommand, resumeCommand, showCommand, startCommand, tokenCommand, withCommonArgs, writePlatformConfig } from "../resume-
|
|
2
|
+
import { PATScope, applyCommand, commonArgs, createCommand, deleteCommand, deploymentArgs, executionsCommand, fetchAll, fetchLatestToken, fetchUserInfo, generateCommand, getCommand, getCommand$1 as getCommand$2, initOAuth2Client, initOperatorClient, jsonArgs, listCommand as listCommand$1, listCommand$1 as listCommand$7, listCommand$2 as listCommand$8, listCommand$3 as listCommand, loadAccessToken, loadConfig, loadWorkspaceId, logger, printData, readPackageJson, readPlatformConfig, removeCommand, resumeCommand, showCommand, startCommand, tokenCommand, withCommonArgs, workspaceArgs, writePlatformConfig } from "../resume-DSfYKl2w.mjs";
|
|
3
3
|
import "../job-CL8myeqs.mjs";
|
|
4
4
|
import { register } from "node:module";
|
|
5
5
|
import { defineCommand, runCommand, runMain } from "citty";
|
|
@@ -8,11 +8,9 @@ import * as fs from "fs";
|
|
|
8
8
|
import pLimit from "p-limit";
|
|
9
9
|
import * as crypto from "node:crypto";
|
|
10
10
|
import ml from "multiline-ts";
|
|
11
|
-
import { consola as consola$1, createConsola } from "consola";
|
|
12
11
|
import { generateCodeVerifier } from "@badgateway/oauth2-client";
|
|
13
12
|
import { timestampDate } from "@bufbuild/protobuf/wkt";
|
|
14
13
|
import { Code, ConnectError } from "@connectrpc/connect";
|
|
15
|
-
import chalk from "chalk";
|
|
16
14
|
import { spawnSync } from "node:child_process";
|
|
17
15
|
import * as http from "node:http";
|
|
18
16
|
import open from "open";
|
|
@@ -56,7 +54,7 @@ const initCommand = defineCommand({
|
|
|
56
54
|
const version = packageJson$1.version && packageJson$1.version !== "0.0.0" ? packageJson$1.version : "latest";
|
|
57
55
|
let packageManager = detectPackageManager();
|
|
58
56
|
if (!packageManager) {
|
|
59
|
-
|
|
57
|
+
logger.warn("⚠️ Could not detect package manager, defaulting to npm");
|
|
60
58
|
packageManager = "npm";
|
|
61
59
|
}
|
|
62
60
|
const initArgs = [
|
|
@@ -66,7 +64,7 @@ const initCommand = defineCommand({
|
|
|
66
64
|
...packageManager === "npm" ? ["--"] : [],
|
|
67
65
|
...args.template ? ["--template", args.template] : []
|
|
68
66
|
];
|
|
69
|
-
|
|
67
|
+
logger.log(`Running: ${packageManager} ${initArgs.join(" ")}`);
|
|
70
68
|
spawnSync(packageManager, initArgs, { stdio: "inherit" });
|
|
71
69
|
})
|
|
72
70
|
});
|
|
@@ -133,11 +131,11 @@ const startAuthServer = async () => {
|
|
|
133
131
|
state,
|
|
134
132
|
codeVerifier
|
|
135
133
|
});
|
|
136
|
-
|
|
134
|
+
logger.info(`Opening browser for login:\n\n${authorizeUri}\n`);
|
|
137
135
|
try {
|
|
138
136
|
await open(authorizeUri);
|
|
139
137
|
} catch {
|
|
140
|
-
|
|
138
|
+
logger.warn("Failed to open browser automatically. Please open the URL above manually.");
|
|
141
139
|
}
|
|
142
140
|
});
|
|
143
141
|
});
|
|
@@ -150,7 +148,7 @@ const loginCommand = defineCommand({
|
|
|
150
148
|
args: commonArgs,
|
|
151
149
|
run: withCommonArgs(async () => {
|
|
152
150
|
await startAuthServer();
|
|
153
|
-
|
|
151
|
+
logger.success("Successfully logged in to Tailor Platform.");
|
|
154
152
|
})
|
|
155
153
|
});
|
|
156
154
|
|
|
@@ -166,7 +164,7 @@ const logoutCommand = defineCommand({
|
|
|
166
164
|
const pfConfig = readPlatformConfig();
|
|
167
165
|
const tokens = pfConfig.current_user ? pfConfig.users[pfConfig.current_user] : void 0;
|
|
168
166
|
if (!tokens) {
|
|
169
|
-
|
|
167
|
+
logger.warn("You are not logged in.");
|
|
170
168
|
return;
|
|
171
169
|
}
|
|
172
170
|
initOAuth2Client().revoke({
|
|
@@ -177,7 +175,7 @@ const logoutCommand = defineCommand({
|
|
|
177
175
|
delete pfConfig.users[pfConfig.current_user];
|
|
178
176
|
pfConfig.current_user = null;
|
|
179
177
|
writePlatformConfig(pfConfig);
|
|
180
|
-
|
|
178
|
+
logger.success("Successfully logged out from Tailor Platform.");
|
|
181
179
|
})
|
|
182
180
|
});
|
|
183
181
|
|
|
@@ -255,7 +253,7 @@ const createCommand$3 = defineCommand({
|
|
|
255
253
|
workspace_id: args["workspace-id"]
|
|
256
254
|
};
|
|
257
255
|
writePlatformConfig(config);
|
|
258
|
-
if (!args.json)
|
|
256
|
+
if (!args.json) logger.success(`Profile "${args.name}" created successfully.`);
|
|
259
257
|
const profileInfo = {
|
|
260
258
|
name: args.name,
|
|
261
259
|
user: args.user,
|
|
@@ -285,7 +283,7 @@ const deleteCommand$3 = defineCommand({
|
|
|
285
283
|
if (!config.profiles[args.name]) throw new Error(`Profile "${args.name}" not found.`);
|
|
286
284
|
delete config.profiles[args.name];
|
|
287
285
|
writePlatformConfig(config);
|
|
288
|
-
|
|
286
|
+
logger.success(`Profile "${args.name}" deleted successfully.`);
|
|
289
287
|
})
|
|
290
288
|
});
|
|
291
289
|
|
|
@@ -304,7 +302,7 @@ const listCommand$6 = defineCommand({
|
|
|
304
302
|
const config = readPlatformConfig();
|
|
305
303
|
const profiles = Object.entries(config.profiles);
|
|
306
304
|
if (profiles.length === 0) {
|
|
307
|
-
|
|
305
|
+
logger.info(ml`
|
|
308
306
|
No profiles found.
|
|
309
307
|
Please create a profile first using 'tailor-sdk profile create' command.
|
|
310
308
|
`);
|
|
@@ -363,7 +361,7 @@ const updateCommand$1 = defineCommand({
|
|
|
363
361
|
profile.user = newUser;
|
|
364
362
|
profile.workspace_id = newWorkspaceId;
|
|
365
363
|
writePlatformConfig(config);
|
|
366
|
-
if (!args.json)
|
|
364
|
+
if (!args.json) logger.success(`Profile "${args.name}" updated successfully`);
|
|
367
365
|
const profileInfo = {
|
|
368
366
|
name: args.name,
|
|
369
367
|
user: newUser,
|
|
@@ -400,16 +398,7 @@ const createSecretCommand = defineCommand({
|
|
|
400
398
|
},
|
|
401
399
|
args: {
|
|
402
400
|
...commonArgs,
|
|
403
|
-
|
|
404
|
-
type: "string",
|
|
405
|
-
description: "Workspace ID",
|
|
406
|
-
alias: "w"
|
|
407
|
-
},
|
|
408
|
-
profile: {
|
|
409
|
-
type: "string",
|
|
410
|
-
description: "Workspace profile",
|
|
411
|
-
alias: "p"
|
|
412
|
-
},
|
|
401
|
+
...workspaceArgs,
|
|
413
402
|
"vault-name": {
|
|
414
403
|
type: "string",
|
|
415
404
|
description: "Vault name",
|
|
@@ -450,7 +439,7 @@ const createSecretCommand = defineCommand({
|
|
|
450
439
|
}
|
|
451
440
|
throw error;
|
|
452
441
|
}
|
|
453
|
-
|
|
442
|
+
logger.success(`Secret: ${args.name} created in vault: ${args["vault-name"]}`);
|
|
454
443
|
})
|
|
455
444
|
});
|
|
456
445
|
|
|
@@ -463,16 +452,7 @@ const deleteSecretCommand = defineCommand({
|
|
|
463
452
|
},
|
|
464
453
|
args: {
|
|
465
454
|
...commonArgs,
|
|
466
|
-
|
|
467
|
-
type: "string",
|
|
468
|
-
description: "Workspace ID",
|
|
469
|
-
alias: "w"
|
|
470
|
-
},
|
|
471
|
-
profile: {
|
|
472
|
-
type: "string",
|
|
473
|
-
description: "Workspace profile",
|
|
474
|
-
alias: "p"
|
|
475
|
-
},
|
|
455
|
+
...workspaceArgs,
|
|
476
456
|
"vault-name": {
|
|
477
457
|
type: "string",
|
|
478
458
|
description: "Vault name",
|
|
@@ -501,8 +481,8 @@ const deleteSecretCommand = defineCommand({
|
|
|
501
481
|
profile: args.profile
|
|
502
482
|
});
|
|
503
483
|
if (!args.yes) {
|
|
504
|
-
if (await
|
|
505
|
-
|
|
484
|
+
if (await logger.prompt(`Enter the secret name to confirm deletion ("${args.name}"): `, { type: "text" }) !== args.name) {
|
|
485
|
+
logger.info("Secret deletion cancelled.");
|
|
506
486
|
return;
|
|
507
487
|
}
|
|
508
488
|
}
|
|
@@ -516,7 +496,7 @@ const deleteSecretCommand = defineCommand({
|
|
|
516
496
|
if (error instanceof ConnectError && error.code === Code.NotFound) throw new Error(`Secret "${args.name}" not found in vault "${args["vault-name"]}".`);
|
|
517
497
|
throw error;
|
|
518
498
|
}
|
|
519
|
-
|
|
499
|
+
logger.success(`Secret: ${args.name} deleted from vault: ${args["vault-name"]}`);
|
|
520
500
|
})
|
|
521
501
|
});
|
|
522
502
|
|
|
@@ -556,16 +536,7 @@ const listSecretCommand = defineCommand({
|
|
|
556
536
|
args: {
|
|
557
537
|
...commonArgs,
|
|
558
538
|
...jsonArgs,
|
|
559
|
-
|
|
560
|
-
type: "string",
|
|
561
|
-
description: "Workspace ID",
|
|
562
|
-
alias: "w"
|
|
563
|
-
},
|
|
564
|
-
profile: {
|
|
565
|
-
type: "string",
|
|
566
|
-
description: "Workspace profile",
|
|
567
|
-
alias: "p"
|
|
568
|
-
},
|
|
539
|
+
...workspaceArgs,
|
|
569
540
|
"vault-name": {
|
|
570
541
|
type: "string",
|
|
571
542
|
description: "Vault name",
|
|
@@ -596,16 +567,7 @@ const updateSecretCommand = defineCommand({
|
|
|
596
567
|
},
|
|
597
568
|
args: {
|
|
598
569
|
...commonArgs,
|
|
599
|
-
|
|
600
|
-
type: "string",
|
|
601
|
-
description: "Workspace ID",
|
|
602
|
-
alias: "w"
|
|
603
|
-
},
|
|
604
|
-
profile: {
|
|
605
|
-
type: "string",
|
|
606
|
-
description: "Workspace profile",
|
|
607
|
-
alias: "p"
|
|
608
|
-
},
|
|
570
|
+
...workspaceArgs,
|
|
609
571
|
"vault-name": {
|
|
610
572
|
type: "string",
|
|
611
573
|
description: "Vault name",
|
|
@@ -643,7 +605,7 @@ const updateSecretCommand = defineCommand({
|
|
|
643
605
|
if (error instanceof ConnectError && error.code === Code.NotFound) throw new Error(`Secret "${args.name}" not found in vault "${args["vault-name"]}".`);
|
|
644
606
|
throw error;
|
|
645
607
|
}
|
|
646
|
-
|
|
608
|
+
logger.success(`Secret: ${args.name} updated in vault: ${args["vault-name"]}`);
|
|
647
609
|
})
|
|
648
610
|
});
|
|
649
611
|
|
|
@@ -656,16 +618,7 @@ const createCommand$2 = defineCommand({
|
|
|
656
618
|
},
|
|
657
619
|
args: {
|
|
658
620
|
...commonArgs,
|
|
659
|
-
|
|
660
|
-
type: "string",
|
|
661
|
-
description: "Workspace ID",
|
|
662
|
-
alias: "w"
|
|
663
|
-
},
|
|
664
|
-
profile: {
|
|
665
|
-
type: "string",
|
|
666
|
-
description: "Workspace profile",
|
|
667
|
-
alias: "p"
|
|
668
|
-
},
|
|
621
|
+
...workspaceArgs,
|
|
669
622
|
name: {
|
|
670
623
|
type: "string",
|
|
671
624
|
description: "Vault name",
|
|
@@ -691,7 +644,7 @@ const createCommand$2 = defineCommand({
|
|
|
691
644
|
if (error instanceof ConnectError && error.code === Code.AlreadyExists) throw new Error(`Vault "${args.name}" already exists.`);
|
|
692
645
|
throw error;
|
|
693
646
|
}
|
|
694
|
-
|
|
647
|
+
logger.success(`Vault: ${args.name} created`);
|
|
695
648
|
})
|
|
696
649
|
});
|
|
697
650
|
|
|
@@ -704,16 +657,7 @@ const deleteCommand$2 = defineCommand({
|
|
|
704
657
|
},
|
|
705
658
|
args: {
|
|
706
659
|
...commonArgs,
|
|
707
|
-
|
|
708
|
-
type: "string",
|
|
709
|
-
description: "Workspace ID",
|
|
710
|
-
alias: "w"
|
|
711
|
-
},
|
|
712
|
-
profile: {
|
|
713
|
-
type: "string",
|
|
714
|
-
description: "Workspace profile",
|
|
715
|
-
alias: "p"
|
|
716
|
-
},
|
|
660
|
+
...workspaceArgs,
|
|
717
661
|
name: {
|
|
718
662
|
type: "string",
|
|
719
663
|
description: "Vault name",
|
|
@@ -737,8 +681,8 @@ const deleteCommand$2 = defineCommand({
|
|
|
737
681
|
profile: args.profile
|
|
738
682
|
});
|
|
739
683
|
if (!args.yes) {
|
|
740
|
-
if (await
|
|
741
|
-
|
|
684
|
+
if (await logger.prompt(`Enter the vault name to confirm deletion ("${args.name}"): `, { type: "text" }) !== args.name) {
|
|
685
|
+
logger.info("Vault deletion cancelled.");
|
|
742
686
|
return;
|
|
743
687
|
}
|
|
744
688
|
}
|
|
@@ -751,7 +695,7 @@ const deleteCommand$2 = defineCommand({
|
|
|
751
695
|
if (error instanceof ConnectError && error.code === Code.NotFound) throw new Error(`Vault "${args.name}" not found.`);
|
|
752
696
|
throw error;
|
|
753
697
|
}
|
|
754
|
-
|
|
698
|
+
logger.success(`Vault: ${args.name} deleted`);
|
|
755
699
|
})
|
|
756
700
|
});
|
|
757
701
|
|
|
@@ -790,16 +734,7 @@ const listCommand$5 = defineCommand({
|
|
|
790
734
|
args: {
|
|
791
735
|
...commonArgs,
|
|
792
736
|
...jsonArgs,
|
|
793
|
-
|
|
794
|
-
type: "string",
|
|
795
|
-
description: "Workspace ID",
|
|
796
|
-
alias: "w"
|
|
797
|
-
},
|
|
798
|
-
profile: {
|
|
799
|
-
type: "string",
|
|
800
|
-
description: "Workspace profile",
|
|
801
|
-
alias: "p"
|
|
802
|
-
}
|
|
737
|
+
...workspaceArgs
|
|
803
738
|
},
|
|
804
739
|
run: withCommonArgs(async (args) => {
|
|
805
740
|
const vaults = await vaultList({
|
|
@@ -847,7 +782,7 @@ const secretCommand = defineCommand({
|
|
|
847
782
|
});
|
|
848
783
|
|
|
849
784
|
//#endregion
|
|
850
|
-
//#region src/cli/progress.ts
|
|
785
|
+
//#region src/cli/utils/progress.ts
|
|
851
786
|
function createProgress(label, total) {
|
|
852
787
|
let current = 0;
|
|
853
788
|
const update = () => {
|
|
@@ -871,7 +806,6 @@ async function withTimeout(p, ms, message) {
|
|
|
871
806
|
|
|
872
807
|
//#endregion
|
|
873
808
|
//#region src/cli/staticwebsite/deploy.ts
|
|
874
|
-
const noTimeLogger = createConsola({ formatOptions: { date: false } });
|
|
875
809
|
const CHUNK_SIZE = 64 * 1024;
|
|
876
810
|
const IGNORED_FILES = new Set([
|
|
877
811
|
".DS_Store",
|
|
@@ -902,7 +836,7 @@ async function deployStaticWebsite(client, workspaceId, name, distDir, showProgr
|
|
|
902
836
|
async function uploadDirectory(client, workspaceId, deploymentId, rootDir, showProgress) {
|
|
903
837
|
const files = await collectFiles(rootDir);
|
|
904
838
|
if (files.length === 0) {
|
|
905
|
-
|
|
839
|
+
logger.warn(`No files found under ${rootDir}`);
|
|
906
840
|
return [];
|
|
907
841
|
}
|
|
908
842
|
const limit = pLimit(5);
|
|
@@ -969,8 +903,8 @@ async function uploadSingleFile(client, workspaceId, deploymentId, rootDir, rela
|
|
|
969
903
|
}
|
|
970
904
|
function logSkippedFiles(skippedFiles) {
|
|
971
905
|
if (skippedFiles.length === 0) return;
|
|
972
|
-
|
|
973
|
-
for (const file of skippedFiles)
|
|
906
|
+
logger.warn("Deployment completed, but some files failed to upload. These files may have unsupported content types or other validation issues. Please review the list below:");
|
|
907
|
+
for (const file of skippedFiles) logger.log(` - ${file}`);
|
|
974
908
|
}
|
|
975
909
|
const deployCommand = defineCommand({
|
|
976
910
|
meta: {
|
|
@@ -980,16 +914,7 @@ const deployCommand = defineCommand({
|
|
|
980
914
|
args: {
|
|
981
915
|
...commonArgs,
|
|
982
916
|
...jsonArgs,
|
|
983
|
-
|
|
984
|
-
type: "string",
|
|
985
|
-
description: "Workspace ID",
|
|
986
|
-
alias: "w"
|
|
987
|
-
},
|
|
988
|
-
profile: {
|
|
989
|
-
type: "string",
|
|
990
|
-
description: "Workspace profile",
|
|
991
|
-
alias: "p"
|
|
992
|
-
},
|
|
917
|
+
...workspaceArgs,
|
|
993
918
|
name: {
|
|
994
919
|
type: "string",
|
|
995
920
|
description: "Static website name",
|
|
@@ -1004,7 +929,7 @@ const deployCommand = defineCommand({
|
|
|
1004
929
|
}
|
|
1005
930
|
},
|
|
1006
931
|
run: withCommonArgs(async (args) => {
|
|
1007
|
-
|
|
932
|
+
logger.info(`Deploying static website "${args.name}" from directory: ${args.dir}`);
|
|
1008
933
|
const accessToken = await loadAccessToken({
|
|
1009
934
|
useProfile: true,
|
|
1010
935
|
profile: args.profile
|
|
@@ -1018,14 +943,14 @@ const deployCommand = defineCommand({
|
|
|
1018
943
|
});
|
|
1019
944
|
if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory()) throw new Error(`Directory not found or not a directory: ${dir}`);
|
|
1020
945
|
const { url, skippedFiles } = await withTimeout(deployStaticWebsite(client, workspaceId, name, dir, !args.json), 10 * 6e4, "Deployment timed out after 10 minutes.");
|
|
1021
|
-
if (args.json)
|
|
946
|
+
if (args.json) printData({
|
|
1022
947
|
name,
|
|
1023
948
|
workspaceId,
|
|
1024
949
|
url,
|
|
1025
950
|
skippedFiles
|
|
1026
|
-
})
|
|
951
|
+
}, true);
|
|
1027
952
|
else {
|
|
1028
|
-
|
|
953
|
+
logger.success(`Static website "${name}" deployed successfully. URL: ${url}`);
|
|
1029
954
|
logSkippedFiles(skippedFiles);
|
|
1030
955
|
}
|
|
1031
956
|
})
|
|
@@ -1041,20 +966,11 @@ const getCommand$1 = defineCommand({
|
|
|
1041
966
|
args: {
|
|
1042
967
|
...commonArgs,
|
|
1043
968
|
...jsonArgs,
|
|
969
|
+
...workspaceArgs,
|
|
1044
970
|
name: {
|
|
1045
971
|
type: "positional",
|
|
1046
972
|
description: "Static website name",
|
|
1047
973
|
required: true
|
|
1048
|
-
},
|
|
1049
|
-
"workspace-id": {
|
|
1050
|
-
type: "string",
|
|
1051
|
-
description: "Workspace ID",
|
|
1052
|
-
alias: "w"
|
|
1053
|
-
},
|
|
1054
|
-
profile: {
|
|
1055
|
-
type: "string",
|
|
1056
|
-
description: "Workspace profile",
|
|
1057
|
-
alias: "p"
|
|
1058
974
|
}
|
|
1059
975
|
},
|
|
1060
976
|
run: withCommonArgs(async (args) => {
|
|
@@ -1123,16 +1039,7 @@ const listCommand$4 = defineCommand({
|
|
|
1123
1039
|
args: {
|
|
1124
1040
|
...commonArgs,
|
|
1125
1041
|
...jsonArgs,
|
|
1126
|
-
|
|
1127
|
-
type: "string",
|
|
1128
|
-
description: "Workspace ID",
|
|
1129
|
-
alias: "w"
|
|
1130
|
-
},
|
|
1131
|
-
profile: {
|
|
1132
|
-
type: "string",
|
|
1133
|
-
description: "Workspace profile",
|
|
1134
|
-
alias: "p"
|
|
1135
|
-
}
|
|
1042
|
+
...workspaceArgs
|
|
1136
1043
|
},
|
|
1137
1044
|
run: withCommonArgs(async (args) => {
|
|
1138
1045
|
const websites = await listStaticWebsites({
|
|
@@ -1180,14 +1087,14 @@ async function truncateSingleType(options, client) {
|
|
|
1180
1087
|
namespaceName: options.namespaceName,
|
|
1181
1088
|
tailordbTypeName: options.typeName
|
|
1182
1089
|
});
|
|
1183
|
-
|
|
1090
|
+
logger.success(`Truncated type "${options.typeName}" in namespace "${options.namespaceName}"`);
|
|
1184
1091
|
}
|
|
1185
1092
|
async function truncateNamespace(workspaceId, namespaceName, client) {
|
|
1186
1093
|
await client.truncateTailorDBTypes({
|
|
1187
1094
|
workspaceId,
|
|
1188
1095
|
namespaceName
|
|
1189
1096
|
});
|
|
1190
|
-
|
|
1097
|
+
logger.success(`Truncated all types in namespace "${namespaceName}"`);
|
|
1191
1098
|
}
|
|
1192
1099
|
async function getAllNamespaces(configPath) {
|
|
1193
1100
|
const { config } = await loadConfig(configPath);
|
|
@@ -1231,32 +1138,32 @@ async function truncate(options) {
|
|
|
1231
1138
|
const namespaces = await getAllNamespaces(options?.configPath);
|
|
1232
1139
|
if (hasAll) {
|
|
1233
1140
|
if (namespaces.length === 0) {
|
|
1234
|
-
|
|
1141
|
+
logger.warn("No namespaces found in config file.");
|
|
1235
1142
|
return;
|
|
1236
1143
|
}
|
|
1237
1144
|
if (!options?.yes) {
|
|
1238
1145
|
const namespaceList = namespaces.join(", ");
|
|
1239
|
-
if (!await
|
|
1146
|
+
if (!await logger.prompt(`This will truncate ALL tables in the following namespaces: ${namespaceList}. Continue? (yes/no)`, {
|
|
1240
1147
|
type: "confirm",
|
|
1241
1148
|
initial: false
|
|
1242
1149
|
})) {
|
|
1243
|
-
|
|
1150
|
+
logger.info("Truncate cancelled.");
|
|
1244
1151
|
return;
|
|
1245
1152
|
}
|
|
1246
1153
|
}
|
|
1247
1154
|
for (const namespace of namespaces) await truncateNamespace(workspaceId, namespace, client);
|
|
1248
|
-
|
|
1155
|
+
logger.success("Truncated all tables in all namespaces");
|
|
1249
1156
|
return;
|
|
1250
1157
|
}
|
|
1251
1158
|
if (hasNamespace && options?.namespace) {
|
|
1252
1159
|
const namespace = options.namespace;
|
|
1253
1160
|
if (!namespaces.includes(namespace)) throw new Error(`Namespace "${namespace}" not found in config. Available namespaces: ${namespaces.join(", ")}`);
|
|
1254
1161
|
if (!options.yes) {
|
|
1255
|
-
if (!await
|
|
1162
|
+
if (!await logger.prompt(`This will truncate ALL tables in namespace "${namespace}". Continue? (yes/no)`, {
|
|
1256
1163
|
type: "confirm",
|
|
1257
1164
|
initial: false
|
|
1258
1165
|
})) {
|
|
1259
|
-
|
|
1166
|
+
logger.info("Truncate cancelled.");
|
|
1260
1167
|
return;
|
|
1261
1168
|
}
|
|
1262
1169
|
}
|
|
@@ -1275,11 +1182,11 @@ async function truncate(options) {
|
|
|
1275
1182
|
if (notFoundTypes.length > 0) throw new Error(`The following types were not found in any namespace: ${notFoundTypes.join(", ")}`);
|
|
1276
1183
|
if (!options.yes) {
|
|
1277
1184
|
const typeList = typeNames.join(", ");
|
|
1278
|
-
if (!await
|
|
1185
|
+
if (!await logger.prompt(`This will truncate the following types: ${typeList}. Continue? (yes/no)`, {
|
|
1279
1186
|
type: "confirm",
|
|
1280
1187
|
initial: false
|
|
1281
1188
|
})) {
|
|
1282
|
-
|
|
1189
|
+
logger.info("Truncate cancelled.");
|
|
1283
1190
|
return;
|
|
1284
1191
|
}
|
|
1285
1192
|
}
|
|
@@ -1314,7 +1221,7 @@ const truncateCommand = defineCommand({
|
|
|
1314
1221
|
},
|
|
1315
1222
|
namespace: {
|
|
1316
1223
|
type: "string",
|
|
1317
|
-
description: "
|
|
1224
|
+
description: "Truncate all tables in specified namespace",
|
|
1318
1225
|
alias: "n"
|
|
1319
1226
|
},
|
|
1320
1227
|
yes: {
|
|
@@ -1323,22 +1230,7 @@ const truncateCommand = defineCommand({
|
|
|
1323
1230
|
alias: "y",
|
|
1324
1231
|
default: false
|
|
1325
1232
|
},
|
|
1326
|
-
|
|
1327
|
-
type: "string",
|
|
1328
|
-
description: "Workspace ID",
|
|
1329
|
-
alias: "w"
|
|
1330
|
-
},
|
|
1331
|
-
profile: {
|
|
1332
|
-
type: "string",
|
|
1333
|
-
description: "Workspace profile",
|
|
1334
|
-
alias: "p"
|
|
1335
|
-
},
|
|
1336
|
-
config: {
|
|
1337
|
-
type: "string",
|
|
1338
|
-
description: "Path to tailor config file",
|
|
1339
|
-
default: "tailor.config.ts",
|
|
1340
|
-
alias: "c"
|
|
1341
|
-
}
|
|
1233
|
+
...deploymentArgs
|
|
1342
1234
|
},
|
|
1343
1235
|
run: withCommonArgs(async (args) => {
|
|
1344
1236
|
const types = args._.length > 0 ? args._.map((arg) => String(arg)).filter(Boolean) : void 0;
|
|
@@ -1375,7 +1267,7 @@ const currentCommand = defineCommand({
|
|
|
1375
1267
|
run: withCommonArgs(async () => {
|
|
1376
1268
|
const config = readPlatformConfig();
|
|
1377
1269
|
if (!config.current_user) {
|
|
1378
|
-
|
|
1270
|
+
logger.warn(ml`
|
|
1379
1271
|
Current user not set.
|
|
1380
1272
|
Please login first using 'tailor-sdk login' command to register a user.
|
|
1381
1273
|
`);
|
|
@@ -1385,7 +1277,7 @@ const currentCommand = defineCommand({
|
|
|
1385
1277
|
Current user '${config.current_user}' not found in registered users.
|
|
1386
1278
|
Please login again using 'tailor-sdk login' command to register the user.
|
|
1387
1279
|
`);
|
|
1388
|
-
|
|
1280
|
+
logger.log(config.current_user);
|
|
1389
1281
|
})
|
|
1390
1282
|
});
|
|
1391
1283
|
|
|
@@ -1404,19 +1296,19 @@ const listCommand$2 = defineCommand({
|
|
|
1404
1296
|
const config = readPlatformConfig();
|
|
1405
1297
|
const users = Object.keys(config.users);
|
|
1406
1298
|
if (users.length === 0) {
|
|
1407
|
-
|
|
1299
|
+
logger.info(ml`
|
|
1408
1300
|
No users found.
|
|
1409
1301
|
Please login first using 'tailor-sdk login' command to register a user.
|
|
1410
1302
|
`);
|
|
1411
1303
|
return;
|
|
1412
1304
|
}
|
|
1413
1305
|
if (args.json) {
|
|
1414
|
-
|
|
1306
|
+
printData(users, args.json);
|
|
1415
1307
|
return;
|
|
1416
1308
|
}
|
|
1417
1309
|
users.forEach((user) => {
|
|
1418
|
-
if (user === config.current_user)
|
|
1419
|
-
else
|
|
1310
|
+
if (user === config.current_user) logger.success(`${user} (current)`, { mode: "plain" });
|
|
1311
|
+
else logger.log(user);
|
|
1420
1312
|
});
|
|
1421
1313
|
})
|
|
1422
1314
|
});
|
|
@@ -1444,12 +1336,12 @@ function getScopeStringsFromWriteFlag(write) {
|
|
|
1444
1336
|
}
|
|
1445
1337
|
function printCreatedToken(name, token, write, action, json) {
|
|
1446
1338
|
const scopes = getScopeStringsFromWriteFlag(write);
|
|
1447
|
-
if (json)
|
|
1339
|
+
if (json) printData({
|
|
1448
1340
|
name,
|
|
1449
1341
|
scopes,
|
|
1450
1342
|
token
|
|
1451
|
-
})
|
|
1452
|
-
else
|
|
1343
|
+
}, json);
|
|
1344
|
+
else logger.log(ml`
|
|
1453
1345
|
Personal access token ${action} successfully.
|
|
1454
1346
|
|
|
1455
1347
|
name: ${name}
|
|
@@ -1478,8 +1370,8 @@ const createCommand$1 = defineCommand({
|
|
|
1478
1370
|
write: {
|
|
1479
1371
|
type: "boolean",
|
|
1480
1372
|
description: "Grant write permission (default: read-only)",
|
|
1481
|
-
|
|
1482
|
-
|
|
1373
|
+
alias: "W",
|
|
1374
|
+
default: false
|
|
1483
1375
|
}
|
|
1484
1376
|
},
|
|
1485
1377
|
run: withCommonArgs(async (args) => {
|
|
@@ -1523,7 +1415,7 @@ const deleteCommand$1 = defineCommand({
|
|
|
1523
1415
|
`);
|
|
1524
1416
|
const token = await fetchLatestToken(config, config.current_user);
|
|
1525
1417
|
await (await initOperatorClient(token)).deletePersonalAccessToken({ name: args.name });
|
|
1526
|
-
|
|
1418
|
+
logger.success(`Personal access token "${args.name}" deleted successfully.`);
|
|
1527
1419
|
})
|
|
1528
1420
|
});
|
|
1529
1421
|
|
|
@@ -1551,7 +1443,7 @@ const listCommand$3 = defineCommand({
|
|
|
1551
1443
|
return [personalAccessTokens, nextPageToken];
|
|
1552
1444
|
});
|
|
1553
1445
|
if (pats.length === 0) {
|
|
1554
|
-
|
|
1446
|
+
logger.info(ml`
|
|
1555
1447
|
No personal access tokens found.
|
|
1556
1448
|
Please create a token using 'tailor-sdk user pat create' command.
|
|
1557
1449
|
`);
|
|
@@ -1559,14 +1451,14 @@ const listCommand$3 = defineCommand({
|
|
|
1559
1451
|
}
|
|
1560
1452
|
if (args.json) {
|
|
1561
1453
|
const patInfos = pats.map(transformPersonalAccessToken);
|
|
1562
|
-
|
|
1454
|
+
printData(patInfos, args.json);
|
|
1563
1455
|
return;
|
|
1564
1456
|
}
|
|
1565
1457
|
const maxNameLength = Math.max(...pats.map((pat) => pat.name.length));
|
|
1566
1458
|
pats.forEach((pat) => {
|
|
1567
1459
|
const info = transformPersonalAccessToken(pat);
|
|
1568
1460
|
const paddedName = info.name.padStart(maxNameLength);
|
|
1569
|
-
|
|
1461
|
+
logger.log(`${paddedName}: ${info.scopes.join("/")}`);
|
|
1570
1462
|
});
|
|
1571
1463
|
})
|
|
1572
1464
|
});
|
|
@@ -1589,8 +1481,8 @@ const updateCommand = defineCommand({
|
|
|
1589
1481
|
write: {
|
|
1590
1482
|
type: "boolean",
|
|
1591
1483
|
description: "Grant write permission (if not specified, keeps read-only)",
|
|
1592
|
-
|
|
1593
|
-
|
|
1484
|
+
alias: "W",
|
|
1485
|
+
default: false
|
|
1594
1486
|
}
|
|
1595
1487
|
},
|
|
1596
1488
|
run: withCommonArgs(async (args) => {
|
|
@@ -1653,7 +1545,7 @@ const useCommand = defineCommand({
|
|
|
1653
1545
|
`);
|
|
1654
1546
|
config.current_user = args.user;
|
|
1655
1547
|
writePlatformConfig(config);
|
|
1656
|
-
|
|
1548
|
+
logger.success(`Current user set to "${args.user}" successfully.`);
|
|
1657
1549
|
})
|
|
1658
1550
|
});
|
|
1659
1551
|
|
|
@@ -1743,5 +1635,5 @@ const mainCommand = defineCommand({
|
|
|
1743
1635
|
runMain(mainCommand);
|
|
1744
1636
|
|
|
1745
1637
|
//#endregion
|
|
1746
|
-
export {
|
|
1638
|
+
export { mainCommand };
|
|
1747
1639
|
//# sourceMappingURL=index.mjs.map
|