smart-ai-test-suite 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 (46) hide show
  1. package/LOCAL_USAGE.md +107 -0
  2. package/MVP_STATUS.md +54 -0
  3. package/POWERSHELL_FIX.md +89 -0
  4. package/QUICK_START.md +101 -0
  5. package/README.md +69 -0
  6. package/SETUP_LOCAL.md +64 -0
  7. package/bin/sat +4 -0
  8. package/dist/commands/coverage.d.ts +3 -0
  9. package/dist/commands/coverage.d.ts.map +1 -0
  10. package/dist/commands/coverage.js +93 -0
  11. package/dist/commands/coverage.js.map +1 -0
  12. package/dist/commands/gen.d.ts +3 -0
  13. package/dist/commands/gen.d.ts.map +1 -0
  14. package/dist/commands/gen.js +77 -0
  15. package/dist/commands/gen.js.map +1 -0
  16. package/dist/commands/init.d.ts +3 -0
  17. package/dist/commands/init.d.ts.map +1 -0
  18. package/dist/commands/init.js +86 -0
  19. package/dist/commands/init.js.map +1 -0
  20. package/dist/commands/test.d.ts +3 -0
  21. package/dist/commands/test.d.ts.map +1 -0
  22. package/dist/commands/test.js +94 -0
  23. package/dist/commands/test.js.map +1 -0
  24. package/dist/core/analyzer.d.ts +16 -0
  25. package/dist/core/analyzer.d.ts.map +1 -0
  26. package/dist/core/analyzer.js +142 -0
  27. package/dist/core/analyzer.js.map +1 -0
  28. package/dist/core/generator.d.ts +3 -0
  29. package/dist/core/generator.d.ts.map +1 -0
  30. package/dist/core/generator.js +156 -0
  31. package/dist/core/generator.js.map +1 -0
  32. package/dist/index.d.ts +3 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +20 -0
  35. package/dist/index.js.map +1 -0
  36. package/package.json +42 -0
  37. package/src/commands/coverage.ts +55 -0
  38. package/src/commands/gen.ts +44 -0
  39. package/src/commands/init.ts +53 -0
  40. package/src/commands/test.ts +56 -0
  41. package/src/core/analyzer.ts +129 -0
  42. package/src/core/generator.ts +144 -0
  43. package/src/index.ts +23 -0
  44. package/tsconfig.json +21 -0
  45. package/use-sat.bat +7 -0
  46. package/use-sat.sh +7 -0
package/LOCAL_USAGE.md ADDED
@@ -0,0 +1,107 @@
1
+ # Using SAT Locally (Without npm publish)
2
+
3
+ You have several options to use SAT locally in your projects:
4
+
5
+ ## Option 1: Global Link (Already Set Up) ✅
6
+
7
+ Since we ran `npm link` in the `sat-cli` directory, SAT is already available globally:
8
+
9
+ ```bash
10
+ # Use it anywhere:
11
+ cd any-project
12
+ sat init
13
+ sat gen unit src/file.ts
14
+ sat test
15
+ ```
16
+
17
+ **To update after making changes:**
18
+ ```bash
19
+ cd sat-cli
20
+ npm run build
21
+ # Changes are immediately available (no need to re-link)
22
+ ```
23
+
24
+ ## Option 2: Local Dependency in Each Project
25
+
26
+ Add SAT as a local dependency in your project's `package.json`:
27
+
28
+ ```json
29
+ {
30
+ "devDependencies": {
31
+ "smart-ai-test-suite": "file:../sat-cli"
32
+ }
33
+ }
34
+ ```
35
+
36
+ Then install:
37
+ ```bash
38
+ npm install
39
+ ```
40
+
41
+ Use via npx:
42
+ ```bash
43
+ npx sat init
44
+ npx sat gen unit src/file.ts
45
+ ```
46
+
47
+ ## Option 3: Direct Path Usage
48
+
49
+ Use the built version directly:
50
+
51
+ ```bash
52
+ # From any project:
53
+ node /path/to/sat-cli/dist/index.js init
54
+ node /path/to/sat-cli/dist/index.js gen unit src/file.ts
55
+ ```
56
+
57
+ Or create an alias in your shell:
58
+ ```bash
59
+ # In ~/.bashrc or ~/.zshrc:
60
+ alias sat='node /absolute/path/to/sat-cli/dist/index.js'
61
+ ```
62
+
63
+ ## Option 4: Development Script
64
+
65
+ Add a script to your project's `package.json`:
66
+
67
+ ```json
68
+ {
69
+ "scripts": {
70
+ "sat": "node ../sat-cli/dist/index.js"
71
+ }
72
+ }
73
+ ```
74
+
75
+ Then use:
76
+ ```bash
77
+ npm run sat init
78
+ npm run sat gen unit src/file.ts
79
+ ```
80
+
81
+ ## Recommended: Keep Using npm link
82
+
83
+ The `npm link` approach (Option 1) is the simplest:
84
+ - ✅ Works globally
85
+ - ✅ Easy to update (just rebuild)
86
+ - ✅ No need to modify each project
87
+ - ✅ Works exactly like a published package
88
+
89
+ **To verify it's working:**
90
+ ```bash
91
+ which sat # Should show the linked path
92
+ sat --version # Should show 0.1.0
93
+ ```
94
+
95
+ ## Updating SAT
96
+
97
+ When you make changes to SAT:
98
+
99
+ ```bash
100
+ cd sat-cli
101
+ # Make your changes...
102
+ npm run build
103
+ # Changes are immediately available everywhere!
104
+ ```
105
+
106
+ No need to re-link or reinstall in other projects.
107
+
package/MVP_STATUS.md ADDED
@@ -0,0 +1,54 @@
1
+ # MVP Implementation Status
2
+
3
+ ## ✅ Completed
4
+
5
+ ### Project Structure
6
+ - ✅ TypeScript project setup
7
+ - ✅ CLI framework (Commander.js)
8
+ - ✅ Project structure matching product brief
9
+ - ✅ Build system configured
10
+
11
+ ### Core Commands
12
+ - ✅ `sat init` - Project initialization with framework detection
13
+ - ✅ `sat gen unit <file>` - Test generation with AST parsing
14
+ - ✅ `sat test` - Test execution with framework abstraction
15
+ - ✅ `sat coverage` - Coverage reporting
16
+
17
+ ### Core Engine
18
+ - ✅ Code analyzer using TypeScript ESLint parser
19
+ - ✅ Test generator with Jest template
20
+ - ✅ Framework adapter pattern (Jest, Vitest, Mocha support)
21
+ - ✅ File operations and utilities
22
+
23
+ ## 🚧 Next Steps for Hackathon Demo
24
+
25
+ 1. **Test the CLI locally:**
26
+ ```bash
27
+ cd sat-cli
28
+ npm link # Makes 'sat' command available globally
29
+ ```
30
+
31
+ 2. **Create a test project:**
32
+ - Create a simple TypeScript file with functions
33
+ - Run `sat init`
34
+ - Run `sat gen unit <file>`
35
+ - Run `sat test`
36
+
37
+ 3. **Polish for demo:**
38
+ - Add better error messages
39
+ - Improve test generation quality
40
+ - Add example project
41
+
42
+ ## 📋 MVP Features Delivered
43
+
44
+ - ✅ Zero-config initialization
45
+ - ✅ Framework detection (Jest/Vitest/Mocha)
46
+ - ✅ AST-based code analysis
47
+ - ✅ Test file generation
48
+ - ✅ Unified test execution
49
+ - ✅ Coverage reporting
50
+
51
+ ## 🎯 Ready for Hackathon Demo
52
+
53
+ The MVP is functional and ready for demonstration. All 4 core commands are implemented and working.
54
+
@@ -0,0 +1,89 @@
1
+ # Fixing PowerShell Execution Policy Issue
2
+
3
+ ## The Problem
4
+
5
+ PowerShell is blocking npm scripts due to execution policy restrictions.
6
+
7
+ ## Solution 1: Fix PowerShell Execution Policy (Recommended)
8
+
9
+ Run PowerShell as Administrator and execute:
10
+
11
+ ```powershell
12
+ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
13
+ ```
14
+
15
+ This allows local scripts to run while still requiring signed scripts from the internet.
16
+
17
+ **Then verify:**
18
+ ```powershell
19
+ Get-ExecutionPolicy
20
+ # Should show: RemoteSigned
21
+ ```
22
+
23
+ ## Solution 2: Use Git Bash Instead
24
+
25
+ Switch to Git Bash (which you were using before):
26
+ ```bash
27
+ # In Git Bash:
28
+ npm run sat:init
29
+ npm run sat:gen src/utils.ts
30
+ npm run sat:test
31
+ ```
32
+
33
+ ## Solution 3: Use Direct Node Commands (No npm scripts)
34
+
35
+ Instead of `npm run sat:init`, use:
36
+
37
+ ```powershell
38
+ # PowerShell:
39
+ node ..\sat-cli\dist\index.js init
40
+ node ..\sat-cli\dist\index.js gen unit src\utils.ts
41
+ node ..\sat-cli\dist\index.js test
42
+ ```
43
+
44
+ Or create batch files in your project:
45
+
46
+ **sat-init.bat:**
47
+ ```batch
48
+ @echo off
49
+ node ..\sat-cli\dist\index.js init
50
+ ```
51
+
52
+ **sat-gen.bat:**
53
+ ```batch
54
+ @echo off
55
+ node ..\sat-cli\dist\index.js gen unit %1
56
+ ```
57
+
58
+ Then use:
59
+ ```powershell
60
+ .\sat-init.bat
61
+ .\sat-gen.bat src\utils.ts
62
+ ```
63
+
64
+ ## Solution 4: Use CMD Instead of PowerShell
65
+
66
+ Open Command Prompt (cmd.exe) instead of PowerShell:
67
+ ```cmd
68
+ npm run sat:init
69
+ npm run sat:gen src/utils.ts
70
+ npm run sat:test
71
+ ```
72
+
73
+ CMD doesn't have the same execution policy restrictions.
74
+
75
+ ## Recommended: Use Git Bash
76
+
77
+ Since you're already using Git Bash, just stick with it:
78
+ - No execution policy issues
79
+ - Works with npm scripts
80
+ - Better for development
81
+
82
+ ```bash
83
+ # In Git Bash:
84
+ cd example-project
85
+ npm run sat:init
86
+ npm run sat:gen src/utils.ts
87
+ npm run sat:test
88
+ ```
89
+
package/QUICK_START.md ADDED
@@ -0,0 +1,101 @@
1
+ # Quick Start - Using SAT Locally
2
+
3
+ ## Problem: `sat: command not found`
4
+
5
+ If `npm link` didn't work (common on Windows/Git Bash), here are quick solutions:
6
+
7
+ ## Solution 1: Use Direct Path (Easiest)
8
+
9
+ Create an alias or use the full path:
10
+
11
+ **Git Bash / Linux / Mac:**
12
+ ```bash
13
+ # Add to ~/.bashrc or ~/.zshrc:
14
+ alias sat='node /e/ashik/Ashik/Projects/Smart-AI-Test-Suite/sat-cli/dist/index.js'
15
+
16
+ # Then reload:
17
+ source ~/.bashrc
18
+ ```
19
+
20
+ **Windows CMD:**
21
+ ```cmd
22
+ # Add to your PATH or create a batch file
23
+ set PATH=E:\ashik\Ashik\Projects\Smart-AI-Test-Suite\sat-cli\bin;%PATH%
24
+ ```
25
+
26
+ ## Solution 2: Use npx with Path
27
+
28
+ In any project, use:
29
+ ```bash
30
+ npx ../sat-cli/dist/index.js init
31
+ npx ../sat-cli/dist/index.js gen unit src/file.ts
32
+ ```
33
+
34
+ Or create a script in your project's `package.json`:
35
+ ```json
36
+ {
37
+ "scripts": {
38
+ "sat": "node ../sat-cli/dist/index.js",
39
+ "sat:init": "node ../sat-cli/dist/index.js init",
40
+ "sat:gen": "node ../sat-cli/dist/index.js gen unit",
41
+ "sat:test": "node ../sat-cli/dist/index.js test"
42
+ }
43
+ }
44
+ ```
45
+
46
+ Then use:
47
+ ```bash
48
+ npm run sat:init
49
+ npm run sat:gen src/utils.ts
50
+ npm run sat:test
51
+ ```
52
+
53
+ ## Solution 3: Add to PATH Manually
54
+
55
+ **Windows:**
56
+ 1. Add `E:\ashik\Ashik\Projects\Smart-AI-Test-Suite\sat-cli\bin` to your system PATH
57
+ 2. Restart terminal
58
+
59
+ **Git Bash:**
60
+ ```bash
61
+ # Add to ~/.bashrc:
62
+ export PATH="/e/ashik/Ashik/Projects/Smart-AI-Test-Suite/sat-cli/bin:$PATH"
63
+ source ~/.bashrc
64
+ ```
65
+
66
+ ## Solution 4: Use from Project Scripts (Recommended)
67
+
68
+ In each project where you want to use SAT, add to `package.json`:
69
+
70
+ ```json
71
+ {
72
+ "scripts": {
73
+ "sat": "node ../sat-cli/dist/index.js"
74
+ }
75
+ }
76
+ ```
77
+
78
+ Then:
79
+ ```bash
80
+ npm run sat init
81
+ npm run sat gen unit src/file.ts
82
+ npm run sat test
83
+ ```
84
+
85
+ ## Verify It Works
86
+
87
+ ```bash
88
+ # Test the direct path:
89
+ node sat-cli/dist/index.js --version
90
+
91
+ # Should output: 0.1.0
92
+ ```
93
+
94
+ ## Recommended Approach
95
+
96
+ For local development, **Solution 4** (project scripts) is cleanest:
97
+ - No global PATH changes needed
98
+ - Works the same way in all projects
99
+ - Easy to update (just rebuild sat-cli)
100
+ - No npm link issues
101
+
package/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # Smart AI Test Suite (SAT)
2
+
3
+ Unified CLI tool for automated test generation and execution. Generate tests in minutes, not hours.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g smart-ai-test-suite
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ 1. **Initialize SAT in your project:**
14
+ ```bash
15
+ sat init
16
+ ```
17
+
18
+ 2. **Generate tests for a file:**
19
+ ```bash
20
+ sat gen unit src/utils/validator.ts
21
+ ```
22
+
23
+ 3. **Run tests:**
24
+ ```bash
25
+ sat test
26
+ ```
27
+
28
+ 4. **Check coverage:**
29
+ ```bash
30
+ sat coverage
31
+ ```
32
+
33
+ ## Commands
34
+
35
+ ### `sat init`
36
+ Initialize SAT in your project. Detects your test framework (Jest, Vitest, Mocha) and creates configuration.
37
+
38
+ ### `sat gen unit <file>`
39
+ Generate unit tests for a TypeScript/JavaScript file.
40
+
41
+ ### `sat test`
42
+ Run tests using your configured test framework.
43
+
44
+ ### `sat coverage`
45
+ Generate and display test coverage report.
46
+
47
+ ## Requirements
48
+
49
+ - Node.js 18+
50
+ - TypeScript/JavaScript project
51
+ - Jest, Vitest, or Mocha installed
52
+
53
+ ## Development
54
+
55
+ ```bash
56
+ # Install dependencies
57
+ npm install
58
+
59
+ # Build
60
+ npm run build
61
+
62
+ # Development mode
63
+ npm run dev
64
+ ```
65
+
66
+ ## License
67
+
68
+ MIT
69
+
package/SETUP_LOCAL.md ADDED
@@ -0,0 +1,64 @@
1
+ # Setting Up SAT for Local Use
2
+
3
+ ## The Issue
4
+
5
+ `npm link` created the symlink, but Git Bash might not have npm's global bin in PATH.
6
+
7
+ ## Quick Fix: Add npm bin to PATH
8
+
9
+ **For Git Bash, add this to `~/.bashrc`:**
10
+
11
+ ```bash
12
+ # Add npm global bin to PATH
13
+ export PATH="$PATH:/c/Users/Planet/AppData/Roaming/npm"
14
+ ```
15
+
16
+ Then reload:
17
+ ```bash
18
+ source ~/.bashrc
19
+ ```
20
+
21
+ Now `sat` should work!
22
+
23
+ ## Alternative: Use Direct Path
24
+
25
+ If you don't want to modify PATH, use the full path:
26
+
27
+ ```bash
28
+ # From any project:
29
+ /c/Users/Planet/AppData/Roaming/npm/sat init
30
+ /c/Users/Planet/AppData/Roaming/npm/sat gen unit src/file.ts
31
+ ```
32
+
33
+ ## Best Solution: Project Scripts (No PATH needed)
34
+
35
+ In each project's `package.json`, add:
36
+
37
+ ```json
38
+ {
39
+ "scripts": {
40
+ "sat": "node ../sat-cli/dist/index.js",
41
+ "sat:init": "node ../sat-cli/dist/index.js init",
42
+ "sat:gen": "node ../sat-cli/dist/index.js gen unit",
43
+ "sat:test": "node ../sat-cli/dist/index.js test",
44
+ "sat:coverage": "node ../sat-cli/dist/index.js coverage"
45
+ }
46
+ }
47
+ ```
48
+
49
+ Then use:
50
+ ```bash
51
+ npm run sat:init
52
+ npm run sat:gen src/utils.ts
53
+ npm run sat:test
54
+ ```
55
+
56
+ This works without any PATH modifications!
57
+
58
+ ## Verify Setup
59
+
60
+ After adding to PATH or using scripts:
61
+ ```bash
62
+ sat --version # Should show: 0.1.0
63
+ ```
64
+
package/bin/sat ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+
3
+ require('../dist/index.js');
4
+
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function coverageCommand(program: Command): void;
3
+ //# sourceMappingURL=coverage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coverage.d.ts","sourceRoot":"","sources":["../../src/commands/coverage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,QA4C/C"}
@@ -0,0 +1,93 @@
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
+ exports.coverageCommand = coverageCommand;
40
+ const child_process_1 = require("child_process");
41
+ const util_1 = require("util");
42
+ const chalk_1 = __importDefault(require("chalk"));
43
+ const fs = __importStar(require("fs-extra"));
44
+ const path = __importStar(require("path"));
45
+ const execAsync = (0, util_1.promisify)(child_process_1.exec);
46
+ function coverageCommand(program) {
47
+ program
48
+ .command('coverage')
49
+ .description('Generate and display test coverage report')
50
+ .action(async () => {
51
+ const configPath = path.join(process.cwd(), '.satrc');
52
+ let config = null;
53
+ try {
54
+ if (!(await fs.pathExists(configPath))) {
55
+ console.log(chalk_1.default.yellow('SAT not initialized. Run `sat init` first.'));
56
+ return;
57
+ }
58
+ config = await fs.readJson(configPath);
59
+ const framework = config.framework || 'jest';
60
+ // Execute coverage command
61
+ let command = '';
62
+ if (framework === 'jest') {
63
+ command = 'npx jest --coverage';
64
+ }
65
+ else if (framework === 'vitest') {
66
+ command = 'npx vitest run --coverage';
67
+ }
68
+ else if (framework === 'mocha') {
69
+ command = 'npx nyc --reporter=text mocha';
70
+ }
71
+ else {
72
+ console.error(chalk_1.default.red(`Unsupported framework: ${framework}`));
73
+ process.exit(1);
74
+ }
75
+ console.log(chalk_1.default.cyan(`Generating coverage report with ${framework}...`));
76
+ const { stdout, stderr } = await execAsync(command, { cwd: process.cwd() });
77
+ if (stdout)
78
+ console.log(stdout);
79
+ if (stderr)
80
+ console.error(stderr);
81
+ }
82
+ catch (error) {
83
+ if (error.code === 'ENOENT') {
84
+ console.error(chalk_1.default.red(`Test framework not found. Please install ${config?.framework || 'jest'}.`));
85
+ }
86
+ else {
87
+ console.error(chalk_1.default.red('Error generating coverage:'), error.message);
88
+ }
89
+ process.exit(1);
90
+ }
91
+ });
92
+ }
93
+ //# sourceMappingURL=coverage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coverage.js","sourceRoot":"","sources":["../../src/commands/coverage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,0CA4CC;AApDD,iDAAqC;AACrC,+BAAiC;AACjC,kDAA0B;AAC1B,6CAA+B;AAC/B,2CAA6B;AAE7B,MAAM,SAAS,GAAG,IAAA,gBAAS,EAAC,oBAAI,CAAC,CAAC;AAElC,SAAgB,eAAe,CAAC,OAAgB;IAC9C,OAAO;SACJ,OAAO,CAAC,UAAU,CAAC;SACnB,WAAW,CAAC,2CAA2C,CAAC;SACxD,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC;QACtD,IAAI,MAAM,GAAQ,IAAI,CAAC;QAEvB,IAAI,CAAC;YACH,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;gBACvC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,4CAA4C,CAAC,CAAC,CAAC;gBACxE,OAAO;YACT,CAAC;YAED,MAAM,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;YACvC,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC;YAE7C,2BAA2B;YAC3B,IAAI,OAAO,GAAG,EAAE,CAAC;YACjB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CAAC;AACP,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function genCommand(program: Command): void;
3
+ //# sourceMappingURL=gen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gen.d.ts","sourceRoot":"","sources":["../../src/commands/gen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,QAoC1C"}
@@ -0,0 +1,77 @@
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
+ exports.genCommand = genCommand;
40
+ const path = __importStar(require("path"));
41
+ const chalk_1 = __importDefault(require("chalk"));
42
+ const generator_1 = require("../core/generator");
43
+ const analyzer_1 = require("../core/analyzer");
44
+ function genCommand(program) {
45
+ program
46
+ .command('gen')
47
+ .description('Generate test files')
48
+ .argument('<type>', 'Test type (unit, integration, etc.)')
49
+ .argument('<file>', 'Source file to generate tests for')
50
+ .option('-o, --output <dir>', 'Output directory for test files')
51
+ .action(async (type, file, options) => {
52
+ try {
53
+ if (type !== 'unit') {
54
+ console.log(chalk_1.default.yellow(`Test type "${type}" not yet supported. Only "unit" is available.`));
55
+ return;
56
+ }
57
+ const filePath = path.resolve(file);
58
+ console.log(chalk_1.default.cyan(`Analyzing ${filePath}...`));
59
+ // Analyze code
60
+ const analysis = await (0, analyzer_1.analyzeCode)(filePath);
61
+ if (!analysis) {
62
+ console.error(chalk_1.default.red('Failed to analyze code.'));
63
+ process.exit(1);
64
+ }
65
+ // Generate test
66
+ const outputDir = options.output || '__tests__';
67
+ const testFile = await (0, generator_1.generateTest)(filePath, analysis, outputDir);
68
+ console.log(chalk_1.default.green(`✓ Test file generated: ${testFile}`));
69
+ console.log(chalk_1.default.gray(` Run \`sat test\` to execute the tests.`));
70
+ }
71
+ catch (error) {
72
+ console.error(chalk_1.default.red('Error generating test:'), error);
73
+ process.exit(1);
74
+ }
75
+ });
76
+ }
77
+ //# sourceMappingURL=gen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gen.js","sourceRoot":"","sources":["../../src/commands/gen.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,gCAoCC;AAzCD,2CAA6B;AAC7B,kDAA0B;AAC1B,iDAAiD;AACjD,+CAA+C;AAE/C,SAAgB,UAAU,CAAC,OAAgB;IACzC,OAAO;SACJ,OAAO,CAAC,KAAK,CAAC;SACd,WAAW,CAAC,q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