@mg21st/dev-assist 1.0.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 (65) hide show
  1. package/.eslintrc.json +17 -0
  2. package/.github/workflows/ci.yml +42 -0
  3. package/.github/workflows/docs.yml +49 -0
  4. package/.github/workflows/publish.yml +49 -0
  5. package/README.md +117 -0
  6. package/bin/dev-assist.js +4 -0
  7. package/dev-assist.config.js +10 -0
  8. package/dist/cli/index.d.ts +3 -0
  9. package/dist/cli/index.d.ts.map +1 -0
  10. package/dist/cli/index.js +133 -0
  11. package/dist/cli/wizard.d.ts +5 -0
  12. package/dist/cli/wizard.d.ts.map +1 -0
  13. package/dist/cli/wizard.js +66 -0
  14. package/dist/config.d.ts +3 -0
  15. package/dist/config.d.ts.map +1 -0
  16. package/dist/config.js +62 -0
  17. package/dist/generators/docsGenerator.d.ts +15 -0
  18. package/dist/generators/docsGenerator.d.ts.map +1 -0
  19. package/dist/generators/docsGenerator.js +186 -0
  20. package/dist/generators/testGenerator.d.ts +12 -0
  21. package/dist/generators/testGenerator.d.ts.map +1 -0
  22. package/dist/generators/testGenerator.js +185 -0
  23. package/dist/parser/astParser.d.ts +7 -0
  24. package/dist/parser/astParser.d.ts.map +1 -0
  25. package/dist/parser/astParser.js +194 -0
  26. package/dist/server/index.d.ts +5 -0
  27. package/dist/server/index.d.ts.map +1 -0
  28. package/dist/server/index.js +247 -0
  29. package/dist/shared/types.d.ts +77 -0
  30. package/dist/shared/types.d.ts.map +1 -0
  31. package/dist/shared/types.js +3 -0
  32. package/docs/_config.yml +22 -0
  33. package/docs/api-reference.md +173 -0
  34. package/docs/architecture.md +90 -0
  35. package/docs/configuration.md +52 -0
  36. package/docs/contributing.md +101 -0
  37. package/docs/index.md +50 -0
  38. package/docs/installation.md +95 -0
  39. package/docs/usage.md +107 -0
  40. package/package.json +58 -0
  41. package/src/cli/index.ts +108 -0
  42. package/src/cli/wizard.ts +63 -0
  43. package/src/config.ts +29 -0
  44. package/src/generators/docsGenerator.ts +192 -0
  45. package/src/generators/testGenerator.ts +174 -0
  46. package/src/parser/astParser.ts +172 -0
  47. package/src/server/index.ts +238 -0
  48. package/src/shared/types.ts +83 -0
  49. package/tsconfig.build.json +8 -0
  50. package/tsconfig.json +19 -0
  51. package/ui/index.html +13 -0
  52. package/ui/package-lock.json +3086 -0
  53. package/ui/package.json +31 -0
  54. package/ui/postcss.config.js +6 -0
  55. package/ui/src/App.tsx +36 -0
  56. package/ui/src/components/ApiDocsTab.tsx +184 -0
  57. package/ui/src/components/ApiTestingTab.tsx +363 -0
  58. package/ui/src/components/Dashboard.tsx +128 -0
  59. package/ui/src/components/Layout.tsx +76 -0
  60. package/ui/src/components/TestsTab.tsx +149 -0
  61. package/ui/src/main.tsx +10 -0
  62. package/ui/src/styles/index.css +41 -0
  63. package/ui/tailwind.config.js +20 -0
  64. package/ui/tsconfig.json +19 -0
  65. package/ui/vite.config.ts +19 -0
@@ -0,0 +1,101 @@
1
+ ---
2
+ title: Contributing
3
+ nav_order: 7
4
+ ---
5
+
6
+ # Contributing
7
+
8
+ Contributions are welcome! Please read this guide before opening a pull request.
9
+
10
+ ---
11
+
12
+ ## Getting Started
13
+
14
+ 1. **Fork** the repository on GitHub.
15
+
16
+ 2. **Clone** your fork:
17
+
18
+ ```bash
19
+ git clone https://github.com/<your-username>/dev-assist.git
20
+ cd dev-assist
21
+ ```
22
+
23
+ 3. **Install dependencies**:
24
+
25
+ ```bash
26
+ npm install
27
+ cd ui && npm install && cd ..
28
+ ```
29
+
30
+ 4. **Create a feature branch**:
31
+
32
+ ```bash
33
+ git checkout -b feature/my-feature
34
+ ```
35
+
36
+ ---
37
+
38
+ ## Development Workflow
39
+
40
+ ### Run in development mode
41
+
42
+ ```bash
43
+ npm run dev
44
+ ```
45
+
46
+ ### Lint
47
+
48
+ ```bash
49
+ npm run lint
50
+ ```
51
+
52
+ ### Build
53
+
54
+ ```bash
55
+ npm run build
56
+ ```
57
+
58
+ ### Build only the CLI
59
+
60
+ ```bash
61
+ npm run build:cli
62
+ ```
63
+
64
+ ### Build only the UI
65
+
66
+ ```bash
67
+ npm run build:ui
68
+ ```
69
+
70
+ ---
71
+
72
+ ## Project Structure
73
+
74
+ See the [Architecture](./architecture) page for a full breakdown of the project layout.
75
+
76
+ ---
77
+
78
+ ## Pull Request Guidelines
79
+
80
+ - Keep PRs focused โ€” one feature or bug fix per PR.
81
+ - Ensure `npm run lint` passes before submitting.
82
+ - Ensure `npm run build` succeeds.
83
+ - Add or update documentation in the `docs/` folder if your change affects user-facing behaviour.
84
+ - Describe what your PR does and why in the PR description.
85
+
86
+ ---
87
+
88
+ ## Reporting Issues
89
+
90
+ Please open an issue on [GitHub Issues](https://github.com/moazzamgodil/dev-assist/issues) with:
91
+
92
+ - A clear description of the problem.
93
+ - Steps to reproduce it.
94
+ - Expected behaviour vs. actual behaviour.
95
+ - Your Node.js and npm versions (`node -v`, `npm -v`).
96
+
97
+ ---
98
+
99
+ ## License
100
+
101
+ By contributing, you agree that your contributions will be licensed under the [MIT License](https://opensource.org/licenses/MIT).
package/docs/index.md ADDED
@@ -0,0 +1,50 @@
1
+ ---
2
+ title: Home
3
+ layout: home
4
+ nav_order: 1
5
+ ---
6
+
7
+ # DevAssist ๐Ÿš€
8
+
9
+ > All-in-one developer toolkit: Auto Test Generator, API Docs Generator & API Testing UI
10
+
11
+ [![npm version](https://img.shields.io/npm/v/dev-assist.svg)](https://www.npmjs.com/package/dev-assist)
12
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
13
+ [![CI](https://github.com/moazzamgodil/dev-assist/actions/workflows/ci.yml/badge.svg)](https://github.com/moazzamgodil/dev-assist/actions/workflows/ci.yml)
14
+
15
+ ---
16
+
17
+ ## What is DevAssist?
18
+
19
+ **DevAssist** is a command-line toolkit that helps developers work faster by automating repetitive tasks:
20
+
21
+ | Feature | Description |
22
+ |---------|-------------|
23
+ | ๐Ÿงช **Auto Test Generator** | AST-based test stub generation for JavaScript & TypeScript files |
24
+ | ๐Ÿ“š **API Docs Generator** | Extracts Express routes and generates OpenAPI specs and Markdown |
25
+ | ๐ŸŒ **Local UI Server** | React dashboard with test viewer, API docs browser and built-in HTTP client |
26
+ | โšก **API Testing Tab** | Lightweight Postman-like HTTP testing interface |
27
+ | ๐Ÿง™ **Interactive Wizard** | Guided CLI setup experience |
28
+
29
+ ---
30
+
31
+ ## Quick Start
32
+
33
+ ```bash
34
+ # Install globally
35
+ npm install -g dev-assist
36
+
37
+ # Run the interactive wizard
38
+ dev-assist
39
+ ```
40
+
41
+ ---
42
+
43
+ ## Navigation
44
+
45
+ - [Installation](./installation) โ€” How to install and set up DevAssist
46
+ - [Usage](./usage) โ€” CLI commands and options
47
+ - [Configuration](./configuration) โ€” Configuration file reference
48
+ - [API Reference](./api-reference) โ€” Server API endpoints
49
+ - [Architecture](./architecture) โ€” Project internals
50
+ - [Contributing](./contributing) โ€” How to contribute
@@ -0,0 +1,95 @@
1
+ ---
2
+ title: Installation
3
+ nav_order: 2
4
+ ---
5
+
6
+ # Installation
7
+
8
+ ## Prerequisites
9
+
10
+ - **Node.js** >= 16.0.0
11
+ - **npm** >= 7.0.0
12
+
13
+ ---
14
+
15
+ ## Global Installation (Recommended)
16
+
17
+ Install DevAssist as a global CLI tool:
18
+
19
+ ```bash
20
+ npm install -g dev-assist
21
+ ```
22
+
23
+ Verify the installation:
24
+
25
+ ```bash
26
+ dev-assist --version
27
+ ```
28
+
29
+ ---
30
+
31
+ ## Local Installation
32
+
33
+ You can also install DevAssist as a project dependency:
34
+
35
+ ```bash
36
+ npm install --save-dev dev-assist
37
+ ```
38
+
39
+ Then invoke it via `npx`:
40
+
41
+ ```bash
42
+ npx dev-assist
43
+ ```
44
+
45
+ Or add a script to your `package.json`:
46
+
47
+ ```json
48
+ {
49
+ "scripts": {
50
+ "assist": "dev-assist"
51
+ }
52
+ }
53
+ ```
54
+
55
+ ---
56
+
57
+ ## Building from Source
58
+
59
+ 1. **Clone the repository**
60
+
61
+ ```bash
62
+ git clone https://github.com/moazzamgodil/dev-assist.git
63
+ cd dev-assist
64
+ ```
65
+
66
+ 2. **Install root dependencies**
67
+
68
+ ```bash
69
+ npm install
70
+ ```
71
+
72
+ 3. **Install UI dependencies**
73
+
74
+ ```bash
75
+ cd ui && npm install && cd ..
76
+ ```
77
+
78
+ 4. **Build everything**
79
+
80
+ ```bash
81
+ npm run build
82
+ ```
83
+
84
+ 5. **Link globally** (optional)
85
+
86
+ ```bash
87
+ npm link
88
+ ```
89
+
90
+ ---
91
+
92
+ ## Next Steps
93
+
94
+ - [Usage](./usage) โ€” Learn the CLI commands
95
+ - [Configuration](./configuration) โ€” Set up your config file
package/docs/usage.md ADDED
@@ -0,0 +1,107 @@
1
+ ---
2
+ title: Usage
3
+ nav_order: 3
4
+ ---
5
+
6
+ # Usage
7
+
8
+ ## Interactive Wizard
9
+
10
+ The easiest way to get started is the interactive wizard, which guides you through all available options:
11
+
12
+ ```bash
13
+ dev-assist
14
+ ```
15
+
16
+ The wizard will ask you to choose between generating tests, generating API docs, or starting the UI server.
17
+
18
+ ---
19
+
20
+ ## CLI Commands
21
+
22
+ ### `dev-assist generate`
23
+
24
+ Generate tests, API docs, or both.
25
+
26
+ #### Generate Tests
27
+
28
+ ```bash
29
+ dev-assist generate --tests --source ./src --output ./__tests__ --framework jest
30
+ ```
31
+
32
+ | Flag | Alias | Description | Default |
33
+ |------|-------|-------------|---------|
34
+ | `--tests` | | Generate test stubs | |
35
+ | `--source <path>` | `-s` | Source directory to parse | `./src` |
36
+ | `--output <path>` | `-o` | Output directory for tests | `./__tests__` |
37
+ | `--framework <name>` | `-f` | Test framework (`jest` or `vitest`) | `jest` |
38
+
39
+ #### Generate API Docs
40
+
41
+ ```bash
42
+ dev-assist generate --docs --source ./src --output ./docs
43
+ ```
44
+
45
+ | Flag | Alias | Description | Default |
46
+ |------|-------|-------------|---------|
47
+ | `--docs` | | Generate API documentation | |
48
+ | `--source <path>` | `-s` | Source directory to parse | `./src` |
49
+ | `--output <path>` | `-o` | Output directory for docs | `./docs` |
50
+
51
+ #### Generate Both
52
+
53
+ ```bash
54
+ dev-assist generate --source ./src
55
+ ```
56
+
57
+ Omitting `--tests` or `--docs` will generate both.
58
+
59
+ ---
60
+
61
+ ### `dev-assist serve`
62
+
63
+ Start the local UI server and open the dashboard in your browser.
64
+
65
+ ```bash
66
+ dev-assist serve --port 3000
67
+ ```
68
+
69
+ | Flag | Alias | Description | Default |
70
+ |------|-------|-------------|---------|
71
+ | `--port <number>` | `-p` | Port to listen on | `3000` |
72
+
73
+ Once started, open your browser at `http://localhost:3000` (or the configured port).
74
+
75
+ The UI provides:
76
+
77
+ - **Dashboard** โ€” Project summary and statistics
78
+ - **Tests Viewer** โ€” Browse generated test files
79
+ - **API Docs Browser** โ€” Explore generated API documentation
80
+ - **HTTP Client** โ€” Send test requests to your API endpoints
81
+
82
+ ---
83
+
84
+ ## Examples
85
+
86
+ ### Typical Workflow
87
+
88
+ ```bash
89
+ # 1. Install DevAssist
90
+ npm install -g dev-assist
91
+
92
+ # 2. Add a config file to your project
93
+ # (see Configuration page)
94
+
95
+ # 3. Generate tests and docs together
96
+ dev-assist generate --source ./src
97
+
98
+ # 4. Start the UI to review results
99
+ dev-assist serve
100
+ ```
101
+
102
+ ### CI / Automation
103
+
104
+ ```bash
105
+ # Generate docs as part of a CI pipeline
106
+ dev-assist generate --docs --source ./src --output ./docs
107
+ ```
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@mg21st/dev-assist",
3
+ "version": "1.0.0",
4
+ "description": "All-in-one developer toolkit: Auto Test Generator, API Docs Generator, and API Testing UI",
5
+ "main": "dist/cli/index.js",
6
+ "bin": {
7
+ "dev-assist": "./bin/dev-assist.js"
8
+ },
9
+ "scripts": {
10
+ "build": "tsc -p tsconfig.build.json && npm run build:ui",
11
+ "build:cli": "tsc -p tsconfig.build.json",
12
+ "build:ui": "cd ui && npm run build",
13
+ "dev": "ts-node src/cli/index.ts",
14
+ "lint": "eslint src --ext .ts",
15
+ "start": "node bin/dev-assist.js"
16
+ },
17
+ "keywords": [
18
+ "cli",
19
+ "testing",
20
+ "api-docs",
21
+ "developer-tools"
22
+ ],
23
+ "author": "",
24
+ "license": "MIT",
25
+ "dependencies": {
26
+ "@babel/parser": "^7.23.0",
27
+ "@babel/traverse": "^7.23.0",
28
+ "@babel/types": "^7.23.0",
29
+ "chalk": "^4.1.2",
30
+ "chokidar": "^3.5.3",
31
+ "commander": "^11.1.0",
32
+ "cors": "^2.8.5",
33
+ "express": "^4.18.2",
34
+ "express-rate-limit": "^8.2.1",
35
+ "inquirer": "^8.2.6",
36
+ "open": "^8.4.2",
37
+ "ora": "^5.4.1",
38
+ "socket.io": "^4.6.1"
39
+ },
40
+ "devDependencies": {
41
+ "@types/babel__traverse": "^7.20.4",
42
+ "@types/cors": "^2.8.17",
43
+ "@types/express": "^4.17.21",
44
+ "@types/inquirer": "^8.2.10",
45
+ "@types/node": "^20.10.0",
46
+ "@typescript-eslint/eslint-plugin": "^6.13.0",
47
+ "@typescript-eslint/parser": "^6.13.0",
48
+ "eslint": "^8.54.0",
49
+ "ts-node": "^10.9.1",
50
+ "typescript": "^5.3.2"
51
+ },
52
+ "engines": {
53
+ "node": ">=16.0.0"
54
+ },
55
+ "publishConfig": {
56
+ "access": "public"
57
+ }
58
+ }
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+ import chalk from 'chalk';
4
+ import { TestGenerator } from '../generators/testGenerator';
5
+ import { DocsGenerator } from '../generators/docsGenerator';
6
+ import { runWizard } from './wizard';
7
+ import { loadConfig } from '../config';
8
+
9
+ const program = new Command();
10
+
11
+ program
12
+ .name('dev-assist')
13
+ .description('๐Ÿš€ DevAssist - Auto Test Generator, API Docs & Testing UI')
14
+ .version('1.0.0');
15
+
16
+ program
17
+ .command('generate')
18
+ .description('Generate tests and/or API docs')
19
+ .option('--tests', 'Generate test files only')
20
+ .option('--docs', 'Generate API docs only')
21
+ .option('-s, --source <dir>', 'Source directory', './src')
22
+ .option('-o, --output <dir>', 'Output directory', './__tests__')
23
+ .option('-f, --framework <framework>', 'Test framework (jest|vitest)', 'jest')
24
+ .action(async (options) => {
25
+ const config = await loadConfig();
26
+ const generateTests = options.tests || (!options.docs);
27
+ const generateDocs = options.docs || (!options.tests);
28
+
29
+ if (generateTests) {
30
+ console.log(chalk.cyan('\n๐Ÿงช Generating Tests...\n'));
31
+ const generator = new TestGenerator();
32
+ await generator.generate({
33
+ sourceDir: options.source || config.sourceDir || './src',
34
+ outputDir: options.output || config.testOutputDir || './__tests__',
35
+ framework: (options.framework || config.testFramework || 'jest') as 'jest' | 'vitest',
36
+ });
37
+ }
38
+
39
+ if (generateDocs) {
40
+ console.log(chalk.cyan('\n๐Ÿ“š Generating API Docs...\n'));
41
+ const generator = new DocsGenerator();
42
+ await generator.generate({
43
+ sourceDir: options.source || config.sourceDir || './src',
44
+ outputDir: options.output || config.docsOutputDir || './docs',
45
+ });
46
+ }
47
+ });
48
+
49
+ program
50
+ .command('serve')
51
+ .description('Start the local UI server')
52
+ .option('-p, --port <port>', 'Port number', '3000')
53
+ .option('--no-open', 'Do not open browser automatically')
54
+ .action(async (options) => {
55
+ const config = await loadConfig();
56
+ const port = parseInt(options.port || config.port?.toString() || '3000', 10);
57
+
58
+ console.log(chalk.cyan(`\n๐ŸŒ Starting DevAssist UI on port ${port}...\n`));
59
+
60
+ const { startServer } = await import('../server/index');
61
+ await startServer({ port, openBrowser: options.open !== false });
62
+ });
63
+
64
+ program
65
+ .action(async () => {
66
+ try {
67
+ const answers = await runWizard();
68
+
69
+ if (answers.action === 'serve') {
70
+ const { startServer } = await import('../server/index');
71
+ await startServer({ port: answers.port || 3000, openBrowser: true });
72
+ return;
73
+ }
74
+
75
+ const config = await loadConfig();
76
+ const doTests = answers.action === 'tests' || answers.action === 'both';
77
+ const doDocs = answers.action === 'docs' || answers.action === 'both';
78
+
79
+ if (doTests) {
80
+ console.log(chalk.cyan('\n๐Ÿงช Generating Tests...\n'));
81
+ const generator = new TestGenerator();
82
+ await generator.generate({
83
+ sourceDir: answers.sourceDir || config.sourceDir || './src',
84
+ outputDir: answers.testOutputDir || config.testOutputDir || './__tests__',
85
+ framework: (answers.testFramework || config.testFramework || 'jest') as 'jest' | 'vitest',
86
+ });
87
+ }
88
+
89
+ if (doDocs) {
90
+ console.log(chalk.cyan('\n๐Ÿ“š Generating API Docs...\n'));
91
+ const generator = new DocsGenerator();
92
+ await generator.generate({
93
+ sourceDir: answers.sourceDir || config.sourceDir || './src',
94
+ outputDir: answers.docsOutputDir || config.docsOutputDir || './docs',
95
+ });
96
+ }
97
+
98
+ console.log(chalk.green.bold('\nโœ… DevAssist completed successfully!\n'));
99
+ } catch (error) {
100
+ if ((error as NodeJS.ErrnoException).code === 'ERR_USE_AFTER_CLOSE') {
101
+ process.exit(0);
102
+ }
103
+ console.error(chalk.red('\nโŒ Error:', error));
104
+ process.exit(1);
105
+ }
106
+ });
107
+
108
+ program.parse(process.argv);
@@ -0,0 +1,63 @@
1
+ import inquirer from 'inquirer';
2
+ import chalk from 'chalk';
3
+ import { DevAssistConfig } from '../shared/types';
4
+
5
+ export async function runWizard(): Promise<Partial<DevAssistConfig> & { action?: string }> {
6
+ console.log(chalk.cyan.bold('\n๐Ÿš€ Welcome to DevAssist CLI Wizard\n'));
7
+
8
+ const answers = await inquirer.prompt([
9
+ {
10
+ type: 'list',
11
+ name: 'action',
12
+ message: 'What would you like to do?',
13
+ choices: [
14
+ { name: '๐Ÿงช Generate Tests', value: 'tests' },
15
+ { name: '๐Ÿ“š Generate API Docs', value: 'docs' },
16
+ { name: '๐Ÿ”ฅ Generate Both (Tests + Docs)', value: 'both' },
17
+ { name: '๐ŸŒ Start UI Server', value: 'serve' },
18
+ ],
19
+ },
20
+ {
21
+ type: 'input',
22
+ name: 'sourceDir',
23
+ message: 'Source directory to scan:',
24
+ default: './src',
25
+ },
26
+ {
27
+ type: 'list',
28
+ name: 'testFramework',
29
+ message: 'Test framework:',
30
+ choices: ['jest', 'vitest'],
31
+ when: (a) => a.action === 'tests' || a.action === 'both',
32
+ },
33
+ {
34
+ type: 'input',
35
+ name: 'testOutputDir',
36
+ message: 'Test output directory:',
37
+ default: './__tests__',
38
+ when: (a) => a.action === 'tests' || a.action === 'both',
39
+ },
40
+ {
41
+ type: 'input',
42
+ name: 'docsOutputDir',
43
+ message: 'Docs output directory:',
44
+ default: './docs',
45
+ when: (a) => a.action === 'docs' || a.action === 'both',
46
+ },
47
+ {
48
+ type: 'number',
49
+ name: 'port',
50
+ message: 'UI server port:',
51
+ default: 3000,
52
+ when: (a) => a.action === 'serve',
53
+ },
54
+ {
55
+ type: 'confirm',
56
+ name: 'watchMode',
57
+ message: 'Enable watch mode?',
58
+ default: false,
59
+ },
60
+ ]);
61
+
62
+ return answers;
63
+ }
package/src/config.ts ADDED
@@ -0,0 +1,29 @@
1
+ import * as path from 'path';
2
+ import * as fs from 'fs';
3
+ import { DevAssistConfig } from './shared/types';
4
+
5
+ const DEFAULT_CONFIG: DevAssistConfig = {
6
+ testFramework: 'jest',
7
+ sourceDir: './src',
8
+ testOutputDir: './__tests__',
9
+ docsOutputDir: './docs',
10
+ port: 3000,
11
+ watchMode: false,
12
+ baseUrl: 'http://localhost:3000',
13
+ };
14
+
15
+ export async function loadConfig(): Promise<DevAssistConfig> {
16
+ const configPath = path.resolve(process.cwd(), 'dev-assist.config.js');
17
+
18
+ if (fs.existsSync(configPath)) {
19
+ try {
20
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
21
+ const userConfig = require(configPath) as Partial<DevAssistConfig>;
22
+ return { ...DEFAULT_CONFIG, ...userConfig };
23
+ } catch {
24
+ // Ignore config load errors
25
+ }
26
+ }
27
+
28
+ return DEFAULT_CONFIG;
29
+ }