@runtypelabs/cli 2.59.1 → 2.59.4

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 (84) hide show
  1. package/dist/chunk-0x7UKC1U.js +17 -0
  2. package/dist/chunk-2ySxXtcg.js +418 -0
  3. package/dist/chunk-3An_BRHv.js +501 -0
  4. package/dist/chunk-6uTxgdiY.js +16218 -0
  5. package/dist/chunk-87nRnNRG.js +1363 -0
  6. package/dist/chunk-B3wo8uRx.js +322 -0
  7. package/dist/chunk-BGp3ZdBy.js +560 -0
  8. package/dist/chunk-BJQv9Elp.js +107 -0
  9. package/dist/chunk-BOpO6xE-.js +6053 -0
  10. package/dist/chunk-BQXXCL8B.js +102 -0
  11. package/dist/chunk-BV-8isOd.js +34 -0
  12. package/dist/chunk-BVMhjGVe.js +826 -0
  13. package/dist/chunk-BW2fg46T.js +141 -0
  14. package/dist/chunk-BWJdY5Ag.js +36 -0
  15. package/dist/chunk-BYJOrLhh.js +302 -0
  16. package/dist/chunk-BYab8EVL.js +127 -0
  17. package/dist/chunk-BfEKvp7h.js +82 -0
  18. package/dist/chunk-BhgLSfH6.js +1123 -0
  19. package/dist/chunk-BirUxTtH.js +296 -0
  20. package/dist/chunk-BmB6UVZ9.js +1559 -0
  21. package/dist/chunk-BnWhIqW1.js +109 -0
  22. package/dist/chunk-Bpfnfk0t.js +123 -0
  23. package/dist/chunk-BrhgdnM3.js +108 -0
  24. package/dist/chunk-Bt0XAgX5.js +327 -0
  25. package/dist/chunk-Bu0FJr6S.js +84 -0
  26. package/dist/chunk-BvEoKpN3.js +255 -0
  27. package/dist/chunk-BxNJgYbE.js +28 -0
  28. package/dist/chunk-C1OFhd7F.js +6131 -0
  29. package/dist/chunk-C7e7WwbU.js +331 -0
  30. package/dist/chunk-CDTYP6bN.js +558 -0
  31. package/dist/chunk-CGDQoqDC.js +24 -0
  32. package/dist/chunk-CJraEBVd.js +127 -0
  33. package/dist/chunk-CQrNhOtv.js +40 -0
  34. package/dist/chunk-CW6AzBH6.js +128 -0
  35. package/dist/chunk-CXgL4w-9.js +317 -0
  36. package/dist/chunk-CZrqoPyf.js +233 -0
  37. package/dist/chunk-CcFCyqbB.js +83 -0
  38. package/dist/chunk-CdaIvO-y.js +485 -0
  39. package/dist/chunk-CehSXtgK.js +624 -0
  40. package/dist/chunk-Ciqkop65.js +218 -0
  41. package/dist/chunk-CoAWdSiE.js +43 -0
  42. package/dist/chunk-Crb4y7t4.js +830 -0
  43. package/dist/chunk-CrlqIfmb.js +337 -0
  44. package/dist/chunk-Cs4pwCQ-.js +324 -0
  45. package/dist/chunk-CwM_9y01.js +519 -0
  46. package/dist/chunk-CyRbIJg8.js +440 -0
  47. package/dist/chunk-D0OHsyMy.js +212 -0
  48. package/dist/chunk-D3y2bURs.js +1347 -0
  49. package/dist/chunk-D4_mJk03.js +2338 -0
  50. package/dist/chunk-D6C8rned.js +578 -0
  51. package/dist/chunk-D9ZbUnks.js +11 -0
  52. package/dist/chunk-DEPmLshX.js +834 -0
  53. package/dist/chunk-DFj1UPB2.js +330 -0
  54. package/dist/chunk-DGdFdZVf.js +197 -0
  55. package/dist/chunk-DGv7X9S_.js +63 -0
  56. package/dist/chunk-DJQ47WYZ.js +664 -0
  57. package/dist/chunk-DJw3O61j.js +1974 -0
  58. package/dist/chunk-DK4FbWVK.js +100 -0
  59. package/dist/chunk-DPuofXMp.js +3907 -0
  60. package/dist/chunk-DSRYhUus.js +993 -0
  61. package/dist/chunk-DajZ9Eg4.js +299 -0
  62. package/dist/chunk-Df4dunvU.js +195 -0
  63. package/dist/chunk-DjNTPhfO.js +481 -0
  64. package/dist/chunk-Dn8eaJuu.js +1042 -0
  65. package/dist/chunk-DwDWqSxM.js +637 -0
  66. package/dist/chunk-Dz7cEtxl.js +84 -0
  67. package/dist/chunk-E_0bgjrS.js +359 -0
  68. package/dist/chunk-KPYN2vUp.js +776 -0
  69. package/dist/chunk-KcqPQJBi.js +86 -0
  70. package/dist/chunk-N9H0JnoG.js +349 -0
  71. package/dist/chunk-NONFcXkn.js +728 -0
  72. package/dist/chunk-PrFjcpmH.js +256 -0
  73. package/dist/chunk-QSfNYiw9.js +11 -0
  74. package/dist/chunk-R265bzj9.js +226 -0
  75. package/dist/chunk-X9V_r6jM.js +166 -0
  76. package/dist/chunk-ZBtPUtyA.js +55 -0
  77. package/dist/chunk-ZCTfmOs7.js +4939 -0
  78. package/dist/chunk-h6oavj0t.js +97 -0
  79. package/dist/chunk-i7DwkvvD.js +42 -0
  80. package/dist/chunk-mG-4eZ6S.js +203 -0
  81. package/dist/chunk-o0ygUbCf.js +313 -0
  82. package/dist/chunk-ucu5lrDZ.js +5715 -0
  83. package/dist/index.js +11367 -73789
  84. package/package.json +5 -5
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env node
2
+ import { S as selectAccount, _ as projectLinkPath, a as getCliConfig, b as CredentialStore, c as loadEffectiveContext, g as parseProjectLink, h as isFirstPartyApiUrl, l as normalizeApiUrl, m as findProjectLink, n as CliContextError, p as ProjectLinkError, s as getInvocationOptions, t as isTTY, v as removeProjectLink, y as writeProjectLink } from "./index.js";
3
+ import { Command } from "commander";
4
+ import chalk from "chalk";
5
+ import fs from "node:fs";
6
+ import path from "node:path";
7
+ // src/commands/link.ts
8
+ const PRODUCTION_API_URL = "https://api.runtype.com";
9
+ async function chooseOrganization(orgArgument, options) {
10
+ if (orgArgument) return { orgId: orgArgument };
11
+ const accounts = (await new CredentialStore().listAccounts()).filter((account) => account.orgId);
12
+ const requestedOrgId = getInvocationOptions().org || process.env.RUNTYPE_ORG?.trim();
13
+ if (requestedOrgId) {
14
+ const explicitApiUrl = options.apiUrl || getInvocationOptions().apiUrl || process.env.RUNTYPE_API_URL || getCliConfig().get("apiUrl") || void 0;
15
+ return {
16
+ orgId: requestedOrgId,
17
+ apiUrl: selectAccount(accounts, {
18
+ orgId: requestedOrgId,
19
+ apiUrl: explicitApiUrl
20
+ })?.apiUrl
21
+ };
22
+ }
23
+ if (accounts.length > 1 && isTTY(options) && !options.json) {
24
+ console.log(chalk.cyan("Which organization should this directory use?"));
25
+ const { promptForAccount } = await import("./chunk-CGDQoqDC.js");
26
+ const chosen = await promptForAccount(accounts);
27
+ if (!chosen?.orgId) throw new CliContextError("No organization selected.");
28
+ return {
29
+ orgId: chosen.orgId,
30
+ apiUrl: chosen.apiUrl
31
+ };
32
+ }
33
+ const context = await loadEffectiveContext();
34
+ const orgId = context.credentials?.orgId ?? (accounts.length === 1 ? accounts[0].orgId : null);
35
+ if (!orgId) throw new CliContextError("Pass the organization to link (runtype link <orgId>), or log in first with: runtype login");
36
+ return {
37
+ orgId,
38
+ apiUrl: context.credentials?.orgId ? context.credentials.apiUrl : accounts[0]?.apiUrl
39
+ };
40
+ }
41
+ const linkCommand = new Command("link").description("Link this directory to an organization: writes .runtype/project.json (no secrets; commit it)").argument("[orgId]", "Organization ID (defaults to a stored login)").option("--api-url <url>", "Also pin the API URL for this directory").option("--dir <path>", "Directory to link (default: current directory)").option("--force", "Replace an existing link in that directory").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (orgArgument, options) => {
42
+ const directory = path.resolve(options.dir ?? process.cwd());
43
+ const existingPath = projectLinkPath(directory);
44
+ let existingApiUrl;
45
+ if (fs.existsSync(existingPath) && !options.force) {
46
+ let existingOrg = null;
47
+ try {
48
+ const existing = parseProjectLink(fs.readFileSync(existingPath, "utf8"), existingPath);
49
+ existingOrg = existing.orgId;
50
+ existingApiUrl = existing.apiUrl;
51
+ } catch {
52
+ existingOrg = null;
53
+ }
54
+ if (existingOrg !== orgArgument || !orgArgument) throw new CliContextError(`${existingPath} already links ${existingOrg ?? "an unreadable organization"}. Pass --force to replace it.`);
55
+ }
56
+ const chosen = await chooseOrganization(orgArgument, options);
57
+ const candidateApiUrl = options.apiUrl ?? getInvocationOptions().apiUrl ?? existingApiUrl ?? chosen.apiUrl;
58
+ const apiUrl = candidateApiUrl && normalizeApiUrl(candidateApiUrl) !== PRODUCTION_API_URL ? normalizeApiUrl(candidateApiUrl) : void 0;
59
+ if (apiUrl && !isFirstPartyApiUrl(apiUrl)) throw new CliContextError(`${apiUrl} is not a Runtype API host, so it cannot be pinned in a committed link. Use --api-url or RUNTYPE_API_URL for it instead.`);
60
+ const filePath = writeProjectLink(directory, {
61
+ orgId: chosen.orgId,
62
+ apiUrl
63
+ });
64
+ const hasLogin = (await new CredentialStore().listAccounts()).some((account) => account.orgId === chosen.orgId && account.apiUrl === (apiUrl ?? account.apiUrl));
65
+ const next = hasLogin ? null : `No stored login for ${chosen.orgId} yet. Run: runtype login`;
66
+ if (options.json || !isTTY(options)) {
67
+ console.log(JSON.stringify({
68
+ status: "linked",
69
+ path: filePath,
70
+ orgId: chosen.orgId,
71
+ apiUrl: apiUrl ?? null,
72
+ hasLogin,
73
+ ...next ? { next } : {}
74
+ }, null, 2));
75
+ return;
76
+ }
77
+ console.log(chalk.green(`Linked ${directory} to ${chosen.orgId}${apiUrl ? ` (${apiUrl})` : ""}.`));
78
+ console.log(chalk.gray(`Wrote ${filePath}. It holds no secrets; commit it so teammates use the same org.`));
79
+ if (next) console.log(chalk.yellow(next));
80
+ });
81
+ const unlinkCommand = new Command("unlink").description("Remove the nearest .runtype/project.json so commands use the default login again").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (options) => {
82
+ let root = null;
83
+ try {
84
+ root = findProjectLink()?.root ?? null;
85
+ } catch (error) {
86
+ if (!(error instanceof ProjectLinkError)) throw error;
87
+ root = path.dirname(path.dirname(error.path));
88
+ }
89
+ const removedPath = root && removeProjectLink(root) ? projectLinkPath(root) : null;
90
+ if (options.json || !isTTY(options)) {
91
+ console.log(JSON.stringify(removedPath ? {
92
+ status: "unlinked",
93
+ path: removedPath
94
+ } : { status: "not_linked" }, null, 2));
95
+ return;
96
+ }
97
+ console.log(removedPath ? chalk.green(`Removed ${removedPath}. Commands here now use the default login.`) : chalk.yellow("No .runtype/project.json found in this directory or its parents."));
98
+ });
99
+ export { linkCommand, unlinkCommand };
100
+