trickle-cli 0.1.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 (125) hide show
  1. package/dist/api-client.d.ts +208 -0
  2. package/dist/api-client.js +237 -0
  3. package/dist/commands/annotate.d.ts +6 -0
  4. package/dist/commands/annotate.js +433 -0
  5. package/dist/commands/audit.d.ts +7 -0
  6. package/dist/commands/audit.js +82 -0
  7. package/dist/commands/auto.d.ts +8 -0
  8. package/dist/commands/auto.js +268 -0
  9. package/dist/commands/capture.d.ts +14 -0
  10. package/dist/commands/capture.js +271 -0
  11. package/dist/commands/check.d.ts +6 -0
  12. package/dist/commands/check.js +408 -0
  13. package/dist/commands/codegen.d.ts +21 -0
  14. package/dist/commands/codegen.js +129 -0
  15. package/dist/commands/coverage.d.ts +13 -0
  16. package/dist/commands/coverage.js +126 -0
  17. package/dist/commands/dashboard.d.ts +1 -0
  18. package/dist/commands/dashboard.js +83 -0
  19. package/dist/commands/dev.d.ts +14 -0
  20. package/dist/commands/dev.js +319 -0
  21. package/dist/commands/diff.d.ts +7 -0
  22. package/dist/commands/diff.js +79 -0
  23. package/dist/commands/docs.d.ts +13 -0
  24. package/dist/commands/docs.js +383 -0
  25. package/dist/commands/errors.d.ts +7 -0
  26. package/dist/commands/errors.js +180 -0
  27. package/dist/commands/export.d.ts +18 -0
  28. package/dist/commands/export.js +238 -0
  29. package/dist/commands/functions.d.ts +6 -0
  30. package/dist/commands/functions.js +71 -0
  31. package/dist/commands/infer.d.ts +14 -0
  32. package/dist/commands/infer.js +275 -0
  33. package/dist/commands/init.d.ts +5 -0
  34. package/dist/commands/init.js +395 -0
  35. package/dist/commands/mock.d.ts +5 -0
  36. package/dist/commands/mock.js +232 -0
  37. package/dist/commands/openapi.d.ts +8 -0
  38. package/dist/commands/openapi.js +82 -0
  39. package/dist/commands/overview.d.ts +11 -0
  40. package/dist/commands/overview.js +266 -0
  41. package/dist/commands/pack.d.ts +11 -0
  42. package/dist/commands/pack.js +133 -0
  43. package/dist/commands/proxy.d.ts +13 -0
  44. package/dist/commands/proxy.js +312 -0
  45. package/dist/commands/replay.d.ts +14 -0
  46. package/dist/commands/replay.js +289 -0
  47. package/dist/commands/run.d.ts +17 -0
  48. package/dist/commands/run.js +997 -0
  49. package/dist/commands/sample.d.ts +13 -0
  50. package/dist/commands/sample.js +260 -0
  51. package/dist/commands/search.d.ts +5 -0
  52. package/dist/commands/search.js +80 -0
  53. package/dist/commands/stubs.d.ts +6 -0
  54. package/dist/commands/stubs.js +187 -0
  55. package/dist/commands/tail.d.ts +4 -0
  56. package/dist/commands/tail.js +76 -0
  57. package/dist/commands/test-gen.d.ts +13 -0
  58. package/dist/commands/test-gen.js +237 -0
  59. package/dist/commands/trace.d.ts +14 -0
  60. package/dist/commands/trace.js +417 -0
  61. package/dist/commands/types.d.ts +7 -0
  62. package/dist/commands/types.js +128 -0
  63. package/dist/commands/unpack.d.ts +11 -0
  64. package/dist/commands/unpack.js +166 -0
  65. package/dist/commands/validate.d.ts +13 -0
  66. package/dist/commands/validate.js +310 -0
  67. package/dist/commands/watch.d.ts +9 -0
  68. package/dist/commands/watch.js +267 -0
  69. package/dist/config.d.ts +1 -0
  70. package/dist/config.js +66 -0
  71. package/dist/formatters/diff-formatter.d.ts +5 -0
  72. package/dist/formatters/diff-formatter.js +43 -0
  73. package/dist/formatters/type-formatter.d.ts +22 -0
  74. package/dist/formatters/type-formatter.js +135 -0
  75. package/dist/index.d.ts +2 -0
  76. package/dist/index.js +419 -0
  77. package/dist/local-codegen.d.ts +22 -0
  78. package/dist/local-codegen.js +762 -0
  79. package/dist/ui/badges.d.ts +16 -0
  80. package/dist/ui/badges.js +71 -0
  81. package/dist/ui/helpers.d.ts +13 -0
  82. package/dist/ui/helpers.js +85 -0
  83. package/package.json +23 -0
  84. package/src/api-client.ts +407 -0
  85. package/src/commands/annotate.ts +450 -0
  86. package/src/commands/audit.ts +103 -0
  87. package/src/commands/auto.ts +268 -0
  88. package/src/commands/capture.ts +257 -0
  89. package/src/commands/check.ts +437 -0
  90. package/src/commands/codegen.ts +128 -0
  91. package/src/commands/coverage.ts +170 -0
  92. package/src/commands/dashboard.ts +46 -0
  93. package/src/commands/dev.ts +323 -0
  94. package/src/commands/diff.ts +99 -0
  95. package/src/commands/docs.ts +392 -0
  96. package/src/commands/errors.ts +205 -0
  97. package/src/commands/export.ts +287 -0
  98. package/src/commands/functions.ts +81 -0
  99. package/src/commands/infer.ts +260 -0
  100. package/src/commands/init.ts +419 -0
  101. package/src/commands/mock.ts +220 -0
  102. package/src/commands/openapi.ts +53 -0
  103. package/src/commands/overview.ts +310 -0
  104. package/src/commands/pack.ts +139 -0
  105. package/src/commands/proxy.ts +314 -0
  106. package/src/commands/replay.ts +356 -0
  107. package/src/commands/run.ts +1190 -0
  108. package/src/commands/sample.ts +259 -0
  109. package/src/commands/search.ts +107 -0
  110. package/src/commands/stubs.ts +211 -0
  111. package/src/commands/tail.ts +94 -0
  112. package/src/commands/test-gen.ts +236 -0
  113. package/src/commands/trace.ts +440 -0
  114. package/src/commands/types.ts +161 -0
  115. package/src/commands/unpack.ts +179 -0
  116. package/src/commands/validate.ts +368 -0
  117. package/src/commands/watch.ts +277 -0
  118. package/src/config.ts +38 -0
  119. package/src/formatters/diff-formatter.ts +51 -0
  120. package/src/formatters/type-formatter.ts +161 -0
  121. package/src/index.ts +454 -0
  122. package/src/local-codegen.ts +859 -0
  123. package/src/ui/badges.ts +66 -0
  124. package/src/ui/helpers.ts +80 -0
  125. package/tsconfig.json +8 -0
@@ -0,0 +1,66 @@
1
+ import chalk from "chalk";
2
+ import { relativeTime } from "./helpers";
3
+
4
+ /**
5
+ * Colored badge for environment names.
6
+ */
7
+ export function envBadge(env: string): string {
8
+ const lower = env.toLowerCase();
9
+ if (lower === "prod" || lower === "production") {
10
+ return chalk.bgRed.white.bold(` ${env} `);
11
+ }
12
+ if (lower === "staging" || lower === "stage") {
13
+ return chalk.bgYellow.black.bold(` ${env} `);
14
+ }
15
+ if (lower === "local" || lower === "dev" || lower === "development") {
16
+ return chalk.bgGreen.black.bold(` ${env} `);
17
+ }
18
+ if (lower === "test" || lower === "ci") {
19
+ return chalk.bgCyan.black.bold(` ${env} `);
20
+ }
21
+ return chalk.bgGray.white.bold(` ${env} `);
22
+ }
23
+
24
+ /**
25
+ * Colored badge for language.
26
+ */
27
+ export function langBadge(lang: string): string {
28
+ const lower = lang.toLowerCase();
29
+ if (lower === "js" || lower === "javascript" || lower === "typescript" || lower === "ts") {
30
+ return chalk.bgYellow.black(` ${lang} `);
31
+ }
32
+ if (lower === "python" || lower === "py") {
33
+ return chalk.bgBlue.white(` ${lang} `);
34
+ }
35
+ if (lower === "go" || lower === "golang") {
36
+ return chalk.bgCyan.black(` ${lang} `);
37
+ }
38
+ return chalk.bgGray.white(` ${lang} `);
39
+ }
40
+
41
+ /**
42
+ * Colored badge for error type.
43
+ */
44
+ export function errorTypeBadge(type: string): string {
45
+ const lower = type.toLowerCase();
46
+ if (lower.includes("type")) {
47
+ return chalk.bgMagenta.white.bold(` ${type} `);
48
+ }
49
+ if (lower.includes("reference") || lower.includes("undefined")) {
50
+ return chalk.bgRed.white.bold(` ${type} `);
51
+ }
52
+ if (lower.includes("syntax")) {
53
+ return chalk.bgYellow.black.bold(` ${type} `);
54
+ }
55
+ if (lower.includes("range") || lower.includes("overflow")) {
56
+ return chalk.bgCyan.black.bold(` ${type} `);
57
+ }
58
+ return chalk.bgRed.white.bold(` ${type} `);
59
+ }
60
+
61
+ /**
62
+ * Format a timestamp as a relative time badge.
63
+ */
64
+ export function timeBadge(timestamp: string): string {
65
+ return chalk.gray(relativeTime(timestamp));
66
+ }
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Parse human-readable time strings into ISO date strings.
3
+ * Supports: "30s", "5m", "5 min", "2h", "3d", "1w"
4
+ */
5
+ export function parseSince(since: string): string {
6
+ const now = Date.now();
7
+ const cleaned = since.trim().toLowerCase();
8
+
9
+ const match = cleaned.match(/^(\d+)\s*(s|sec|seconds?|m|min|minutes?|h|hrs?|hours?|d|days?|w|weeks?)$/);
10
+ if (!match) {
11
+ // Try to parse as ISO date directly
12
+ const d = new Date(since);
13
+ if (!isNaN(d.getTime())) {
14
+ return d.toISOString();
15
+ }
16
+ throw new Error(`Cannot parse time string: "${since}". Use formats like "30s", "5m", "2h", "3d", "1w".`);
17
+ }
18
+
19
+ const amount = parseInt(match[1], 10);
20
+ const unit = match[2];
21
+
22
+ let ms: number;
23
+ if (unit.startsWith("s")) {
24
+ ms = amount * 1000;
25
+ } else if (unit.startsWith("m") && !unit.startsWith("mo")) {
26
+ ms = amount * 60 * 1000;
27
+ } else if (unit.startsWith("h")) {
28
+ ms = amount * 60 * 60 * 1000;
29
+ } else if (unit.startsWith("d")) {
30
+ ms = amount * 24 * 60 * 60 * 1000;
31
+ } else if (unit.startsWith("w")) {
32
+ ms = amount * 7 * 24 * 60 * 60 * 1000;
33
+ } else {
34
+ ms = amount * 60 * 1000; // default to minutes
35
+ }
36
+
37
+ // Output in SQLite datetime format to match backend storage
38
+ return new Date(now - ms).toISOString().replace('T', ' ').replace(/\.\d+Z$/, '');
39
+ }
40
+
41
+ /**
42
+ * Truncate a string with ellipsis.
43
+ */
44
+ export function truncate(str: string, maxLen: number): string {
45
+ if (str.length <= maxLen) return str;
46
+ return str.slice(0, maxLen - 1) + "\u2026";
47
+ }
48
+
49
+ /**
50
+ * Convert an ISO date string to a relative time string like "2m ago".
51
+ */
52
+ export function relativeTime(isoDate: string): string {
53
+ const now = Date.now();
54
+ const then = new Date(isoDate).getTime();
55
+ const diff = now - then;
56
+
57
+ if (isNaN(then)) return isoDate;
58
+
59
+ const seconds = Math.floor(diff / 1000);
60
+ if (seconds < 5) return "just now";
61
+ if (seconds < 60) return `${seconds}s ago`;
62
+
63
+ const minutes = Math.floor(seconds / 60);
64
+ if (minutes < 60) return `${minutes}m ago`;
65
+
66
+ const hours = Math.floor(minutes / 60);
67
+ if (hours < 24) return `${hours}h ago`;
68
+
69
+ const days = Math.floor(hours / 24);
70
+ if (days < 7) return `${days}d ago`;
71
+
72
+ const weeks = Math.floor(days / 7);
73
+ if (weeks < 4) return `${weeks}w ago`;
74
+
75
+ const months = Math.floor(days / 30);
76
+ if (months < 12) return `${months}mo ago`;
77
+
78
+ const years = Math.floor(days / 365);
79
+ return `${years}y ago`;
80
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": "./src"
6
+ },
7
+ "include": ["src"]
8
+ }