trickle-cli 0.1.208 → 0.1.210

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/src/index.ts CHANGED
@@ -250,10 +250,13 @@ program
250
250
  .command("test [command...]")
251
251
  .description("Run tests with observability (default) or generate test files (--generate)")
252
252
  .option("--generate", "Generate test file from observed routes instead of running tests")
253
+ .option("--unit", "Generate function-level unit tests instead of API route tests (with --generate)")
253
254
  .option("--json", "Structured JSON output for agent consumption")
254
255
  .option("-o, --out <path>", "Write tests to a file (with --generate)")
255
- .option("--framework <name>", "Test framework: vitest or jest (with --generate)")
256
+ .option("--framework <name>", "Test framework: vitest, jest, or pytest (with --generate)")
256
257
  .option("--base-url <url>", "Base URL for API requests (with --generate)")
258
+ .option("--function <name>", "Filter by function name (with --generate --unit)")
259
+ .option("--module <name>", "Filter by module name (with --generate --unit)")
257
260
  .action(async (commandParts: string[], opts) => {
258
261
  if (opts.generate) {
259
262
  await testGenCommand(opts);
@@ -1 +0,0 @@
1
- export {};
@@ -1,138 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- /**
40
- * Unit tests for trickle rn command.
41
- *
42
- * Run with: node --experimental-strip-types --test src/commands/rn.test.ts
43
- */
44
- const node_test_1 = require("node:test");
45
- const strict_1 = __importDefault(require("node:assert/strict"));
46
- const os = __importStar(require("os"));
47
- const child_process = __importStar(require("child_process"));
48
- const path = __importStar(require("path"));
49
- const url_1 = require("url");
50
- const __filename = (0, url_1.fileURLToPath)(import.meta.url);
51
- const __dirname2 = path.dirname(__filename);
52
- const CLI = path.resolve(__dirname2, '../../dist/index.js');
53
- function runCli(args) {
54
- try {
55
- const stdout = child_process.execSync(`node ${CLI} ${args.join(' ')}`, {
56
- encoding: 'utf-8',
57
- timeout: 10000,
58
- });
59
- return { stdout, stderr: '', code: 0 };
60
- }
61
- catch (err) {
62
- const e = err;
63
- return { stdout: e.stdout ?? '', stderr: e.stderr ?? '', code: e.status ?? 1 };
64
- }
65
- }
66
- // ── trickle rn --help ─────────────────────────────────────────────────────────
67
- (0, node_test_1.describe)('trickle rn --help', () => {
68
- (0, node_test_1.it)('lists rn as a registered command', () => {
69
- const { stdout } = runCli(['--help']);
70
- strict_1.default.ok(stdout.includes('rn'), 'trickle --help should list rn command');
71
- });
72
- (0, node_test_1.it)('rn --help shows setup and ip subcommands', () => {
73
- const { stdout } = runCli(['rn', '--help']);
74
- strict_1.default.ok(stdout.includes('setup'), 'rn --help should list setup subcommand');
75
- strict_1.default.ok(stdout.includes('ip'), 'rn --help should list ip subcommand');
76
- });
77
- });
78
- // ── trickle rn setup ──────────────────────────────────────────────────────────
79
- (0, node_test_1.describe)('trickle rn setup', () => {
80
- (0, node_test_1.it)('outputs metro.config.js setup instructions', () => {
81
- const { stdout } = runCli(['rn', 'setup']);
82
- strict_1.default.ok(stdout.includes('metro.config.js'), 'should mention metro.config.js');
83
- });
84
- (0, node_test_1.it)('outputs babelTransformerPath configuration', () => {
85
- const { stdout } = runCli(['rn', 'setup']);
86
- strict_1.default.ok(stdout.includes('babelTransformerPath'), 'should show babelTransformerPath config');
87
- });
88
- (0, node_test_1.it)('references trickle-observe/metro-transformer', () => {
89
- const { stdout } = runCli(['rn', 'setup']);
90
- strict_1.default.ok(stdout.includes('trickle-observe/metro-transformer'), 'should reference metro-transformer package');
91
- });
92
- (0, node_test_1.it)('shows Expo and bare RN variants', () => {
93
- const { stdout } = runCli(['rn', 'setup']);
94
- strict_1.default.ok(stdout.includes('expo/metro-config'), 'should show Expo config import');
95
- strict_1.default.ok(stdout.includes('@react-native/metro-config'), 'should show bare RN config import');
96
- });
97
- (0, node_test_1.it)('shows Android emulator IP (10.0.2.2)', () => {
98
- const { stdout } = runCli(['rn', 'setup']);
99
- strict_1.default.ok(stdout.includes('10.0.2.2'), 'should mention Android emulator IP');
100
- });
101
- (0, node_test_1.it)('uses --ip option when provided', () => {
102
- const { stdout } = runCli(['rn', 'setup', '--ip', '10.1.2.3']);
103
- strict_1.default.ok(stdout.includes('10.1.2.3'), 'should use provided IP address');
104
- });
105
- (0, node_test_1.it)('shows npx trickle dev instruction', () => {
106
- const { stdout } = runCli(['rn', 'setup']);
107
- strict_1.default.ok(stdout.includes('trickle dev'), 'should mention trickle dev backend command');
108
- });
109
- });
110
- // ── trickle rn ip ─────────────────────────────────────────────────────────────
111
- (0, node_test_1.describe)('trickle rn ip', () => {
112
- (0, node_test_1.it)('outputs a valid IPv4 address', () => {
113
- const { stdout } = runCli(['rn', 'ip']);
114
- // Extract IP-like patterns
115
- const ipMatch = stdout.match(/\b(\d{1,3}\.){3}\d{1,3}\b/);
116
- strict_1.default.ok(ipMatch, `should output a valid IPv4 address, got: ${stdout}`);
117
- });
118
- (0, node_test_1.it)('outputs TRICKLE_BACKEND_URL env var line', () => {
119
- const { stdout } = runCli(['rn', 'ip']);
120
- strict_1.default.ok(stdout.includes('TRICKLE_BACKEND_URL'), 'should show TRICKLE_BACKEND_URL env var');
121
- });
122
- });
123
- // ── LAN IP detection ──────────────────────────────────────────────────────────
124
- (0, node_test_1.describe)('LAN IP detection (os.networkInterfaces)', () => {
125
- (0, node_test_1.it)('finds at least one non-loopback IPv4 interface', () => {
126
- const interfaces = os.networkInterfaces();
127
- let found = false;
128
- for (const ifaces of Object.values(interfaces)) {
129
- for (const iface of ifaces ?? []) {
130
- if (iface.family === 'IPv4' && !iface.internal) {
131
- found = true;
132
- strict_1.default.ok(/^\d+\.\d+\.\d+\.\d+$/.test(iface.address), `${iface.address} should be a valid IPv4 address`);
133
- }
134
- }
135
- }
136
- strict_1.default.ok(found, 'should find at least one non-loopback IPv4 interface');
137
- });
138
- });