@pkpkpkddea/devdash 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.
- package/PUBLISHING.md +133 -0
- package/README.md +148 -0
- package/bin/cli.js +192 -0
- package/package.json +34 -0
package/PUBLISHING.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# DevDash CLI - Publishing Guide
|
|
2
|
+
|
|
3
|
+
## Package Created Successfully! 🎉
|
|
4
|
+
|
|
5
|
+
Your CLI tool is ready at: `c:\Users\Bosco Leung\.git\DevTool-Suite\DevTool-Suite\devdash-cli`
|
|
6
|
+
|
|
7
|
+
## Testing Locally
|
|
8
|
+
|
|
9
|
+
1. **Navigate to the CLI directory**:
|
|
10
|
+
```bash
|
|
11
|
+
cd "c:\Users\Bosco Leung\.git\DevTool-Suite\DevTool-Suite\devdash-cli"
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
2. **Install dependencies**:
|
|
15
|
+
```bash
|
|
16
|
+
npm install
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
3. **Link the package globally** (for local testing):
|
|
20
|
+
```bash
|
|
21
|
+
npm link
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
4. **Test the CLI**:
|
|
25
|
+
```bash
|
|
26
|
+
# Navigate to any git repository
|
|
27
|
+
cd path/to/your/git/repo
|
|
28
|
+
|
|
29
|
+
# Stage some changes
|
|
30
|
+
git add .
|
|
31
|
+
|
|
32
|
+
# Generate commit message
|
|
33
|
+
devdash commit
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
5. **Test the config command**:
|
|
37
|
+
```bash
|
|
38
|
+
devdash config --show
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Publishing to npm
|
|
42
|
+
|
|
43
|
+
### Prerequisites
|
|
44
|
+
|
|
45
|
+
1. **Create an npm account** (if you don't have one):
|
|
46
|
+
- Visit https://www.npmjs.com/signup
|
|
47
|
+
- Or run: `npm adduser`
|
|
48
|
+
|
|
49
|
+
2. **Login to npm**:
|
|
50
|
+
```bash
|
|
51
|
+
npm login
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Publishing Steps
|
|
55
|
+
|
|
56
|
+
1. **Navigate to the CLI directory**:
|
|
57
|
+
```bash
|
|
58
|
+
cd "c:\Users\Bosco Leung\.git\DevTool-Suite\DevTool-Suite\devdash-cli"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
2. **Verify package contents** (dry run):
|
|
62
|
+
```bash
|
|
63
|
+
npm publish --dry-run
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
This will show you what files will be included in the package.
|
|
67
|
+
|
|
68
|
+
3. **Publish the package**:
|
|
69
|
+
```bash
|
|
70
|
+
npm publish --access public
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
> Note: The `--access public` flag is required for scoped packages (@pkpkpkddea/devdash)
|
|
74
|
+
|
|
75
|
+
4. **Verify publication**:
|
|
76
|
+
- Visit: https://www.npmjs.com/package/@pkpkpkddea/devdash
|
|
77
|
+
- Or run: `npm view @pkpkpkddea/devdash`
|
|
78
|
+
|
|
79
|
+
## After Publishing
|
|
80
|
+
|
|
81
|
+
### Install globally from npm:
|
|
82
|
+
```bash
|
|
83
|
+
npm install -g @pkpkpkddea/devdash
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Update your resume/portfolio:
|
|
87
|
+
- ✅ Published npm package: `@pkpkpkddea/devdash`
|
|
88
|
+
- ✅ Link: https://www.npmjs.com/package/@pkpkpkddea/devdash
|
|
89
|
+
- ✅ Weekly downloads badge (add to README after publishing)
|
|
90
|
+
|
|
91
|
+
## Updating the Package
|
|
92
|
+
|
|
93
|
+
When you make changes:
|
|
94
|
+
|
|
95
|
+
1. **Update version** in `package.json`:
|
|
96
|
+
```bash
|
|
97
|
+
npm version patch # for bug fixes (1.0.0 -> 1.0.1)
|
|
98
|
+
npm version minor # for new features (1.0.0 -> 1.1.0)
|
|
99
|
+
npm version major # for breaking changes (1.0.0 -> 2.0.0)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
2. **Publish the update**:
|
|
103
|
+
```bash
|
|
104
|
+
npm publish
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Troubleshooting
|
|
108
|
+
|
|
109
|
+
### "Package name already exists"
|
|
110
|
+
If someone already published `@pkpkpkddea/devdash`, you'll need to:
|
|
111
|
+
1. Change the package name in `package.json`
|
|
112
|
+
2. Update the README with the new name
|
|
113
|
+
3. Try publishing again
|
|
114
|
+
|
|
115
|
+
### "You must be logged in"
|
|
116
|
+
Run `npm login` and enter your npm credentials.
|
|
117
|
+
|
|
118
|
+
### "You do not have permission to publish"
|
|
119
|
+
Make sure you're logged in with the correct account that owns the `@pkpkpkddea` scope.
|
|
120
|
+
|
|
121
|
+
## Files Created
|
|
122
|
+
|
|
123
|
+
- ✅ `package.json` - Package configuration
|
|
124
|
+
- ✅ `bin/cli.js` - CLI implementation
|
|
125
|
+
- ✅ `README.md` - User documentation
|
|
126
|
+
- ✅ `.npmignore` - Files to exclude from npm package
|
|
127
|
+
|
|
128
|
+
## Next Steps
|
|
129
|
+
|
|
130
|
+
1. Test the CLI locally using `npm link`
|
|
131
|
+
2. Verify everything works as expected
|
|
132
|
+
3. Publish to npm using `npm publish --access public`
|
|
133
|
+
4. Share your package with the world! 🚀
|
package/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# DevDash CLI
|
|
2
|
+
|
|
3
|
+
> AI-powered commit message generator for your git workflow
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@pkpkpkddea/devdash)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- 🤖 Generate descriptive commit messages using Google's Gemini AI
|
|
11
|
+
- 📝 Analyzes your staged git changes automatically
|
|
12
|
+
- ⚡ Simple CLI interface
|
|
13
|
+
- 🔐 Secure API key storage in your home directory
|
|
14
|
+
- 🎨 Beautiful, formatted commit messages
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g @pkpkpkddea/devdash
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
1. **Stage your changes**:
|
|
25
|
+
```bash
|
|
26
|
+
git add .
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
2. **Generate commit message**:
|
|
30
|
+
```bash
|
|
31
|
+
devdash commit
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
3. **On first run**, you'll be prompted to enter your Google Gemini API key:
|
|
35
|
+
```
|
|
36
|
+
🔑 Google Gemini API Key not found.
|
|
37
|
+
Get your free API key at: https://aistudio.google.com/app/apikey
|
|
38
|
+
|
|
39
|
+
Enter your Google Gemini API Key:
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
4. **Review the generated message** and use it:
|
|
43
|
+
```bash
|
|
44
|
+
git commit -m "Your generated message"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Commands
|
|
48
|
+
|
|
49
|
+
### `devdash commit`
|
|
50
|
+
|
|
51
|
+
Generate a commit message from your staged changes.
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
devdash commit
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### `devdash config`
|
|
58
|
+
|
|
59
|
+
Manage your DevDash configuration.
|
|
60
|
+
|
|
61
|
+
**Set API key**:
|
|
62
|
+
```bash
|
|
63
|
+
devdash config --set-key YOUR_API_KEY
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Set AI model**:
|
|
67
|
+
```bash
|
|
68
|
+
devdash config --set-model gemini-2.5-pro
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Show current configuration**:
|
|
72
|
+
```bash
|
|
73
|
+
devdash config --show
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Getting Your API Key
|
|
77
|
+
|
|
78
|
+
1. Visit [Google AI Studio](https://aistudio.google.com/app/apikey)
|
|
79
|
+
2. Sign in with your Google account
|
|
80
|
+
3. Click "Create API key"
|
|
81
|
+
4. Copy the generated key
|
|
82
|
+
5. Run `devdash commit` and paste the key when prompted
|
|
83
|
+
|
|
84
|
+
The API key is **free** for typical personal usage.
|
|
85
|
+
|
|
86
|
+
## Configuration
|
|
87
|
+
|
|
88
|
+
Your configuration is stored in `~/.devdash/config.json`:
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"apiKey": "your-api-key",
|
|
93
|
+
"model": "gemini-2.0-flash"
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Available Models
|
|
98
|
+
|
|
99
|
+
- `gemini-2.0-flash` (default, recommended)
|
|
100
|
+
- `gemini-2.5-flash`
|
|
101
|
+
- `gemini-2.5-pro`
|
|
102
|
+
- `gemini-2.0-flash-lite`
|
|
103
|
+
- `gemini-flash-latest`
|
|
104
|
+
- `gemini-pro-latest`
|
|
105
|
+
|
|
106
|
+
## Example Output
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
$ devdash commit
|
|
110
|
+
|
|
111
|
+
🤖 Generating commit message...
|
|
112
|
+
|
|
113
|
+
📝 Suggested commit message:
|
|
114
|
+
|
|
115
|
+
──────────────────────────────────────────────────
|
|
116
|
+
Add user authentication and update API endpoints
|
|
117
|
+
|
|
118
|
+
- Implemented JWT-based authentication system
|
|
119
|
+
- Updated user login endpoint to return tokens
|
|
120
|
+
- Added middleware for protected routes
|
|
121
|
+
- Refactored error handling in auth module
|
|
122
|
+
──────────────────────────────────────────────────
|
|
123
|
+
|
|
124
|
+
To use this message, run:
|
|
125
|
+
git commit -m "Add user authentication and update API endpoints"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Requirements
|
|
129
|
+
|
|
130
|
+
- Node.js >= 18.0.0
|
|
131
|
+
- Git installed and accessible in PATH
|
|
132
|
+
- Google Gemini API key
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
MIT
|
|
137
|
+
|
|
138
|
+
## Author
|
|
139
|
+
|
|
140
|
+
pkpkpkddea
|
|
141
|
+
|
|
142
|
+
## Contributing
|
|
143
|
+
|
|
144
|
+
Issues and pull requests are welcome!
|
|
145
|
+
|
|
146
|
+
## Repository
|
|
147
|
+
|
|
148
|
+
[https://github.com/pkpkpkddea/DevTool-Suite](https://github.com/pkpkpkddea/DevTool-Suite)
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import { execSync } from 'child_process';
|
|
5
|
+
import { createGoogleGenerativeAI } from '@ai-sdk/google';
|
|
6
|
+
import { generateText } from 'ai';
|
|
7
|
+
import * as fs from 'fs';
|
|
8
|
+
import * as path from 'path';
|
|
9
|
+
import * as os from 'os';
|
|
10
|
+
import * as readline from 'readline';
|
|
11
|
+
|
|
12
|
+
const CONFIG_DIR = path.join(os.homedir(), '.devdash');
|
|
13
|
+
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
|
|
14
|
+
|
|
15
|
+
// Ensure config directory exists
|
|
16
|
+
function ensureConfigDir() {
|
|
17
|
+
if (!fs.existsSync(CONFIG_DIR)) {
|
|
18
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Read config
|
|
23
|
+
function readConfig() {
|
|
24
|
+
ensureConfigDir();
|
|
25
|
+
if (fs.existsSync(CONFIG_FILE)) {
|
|
26
|
+
const data = fs.readFileSync(CONFIG_FILE, 'utf-8');
|
|
27
|
+
return JSON.parse(data);
|
|
28
|
+
}
|
|
29
|
+
return {};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Write config
|
|
33
|
+
function writeConfig(config) {
|
|
34
|
+
ensureConfigDir();
|
|
35
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Prompt user for input
|
|
39
|
+
function promptUser(question) {
|
|
40
|
+
return new Promise((resolve) => {
|
|
41
|
+
const rl = readline.createInterface({
|
|
42
|
+
input: process.stdin,
|
|
43
|
+
output: process.stdout
|
|
44
|
+
});
|
|
45
|
+
rl.question(question, (answer) => {
|
|
46
|
+
rl.close();
|
|
47
|
+
resolve(answer);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Get API key (prompt if not exists)
|
|
53
|
+
async function getApiKey() {
|
|
54
|
+
const config = readConfig();
|
|
55
|
+
|
|
56
|
+
if (config.apiKey) {
|
|
57
|
+
return config.apiKey;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
console.log('🔑 Google Gemini API Key not found.');
|
|
61
|
+
console.log('Get your free API key at: https://aistudio.google.com/app/apikey\n');
|
|
62
|
+
|
|
63
|
+
const apiKey = await promptUser('Enter your Google Gemini API Key: ');
|
|
64
|
+
|
|
65
|
+
if (!apiKey || !apiKey.trim()) {
|
|
66
|
+
console.error('❌ API key is required.');
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
config.apiKey = apiKey.trim();
|
|
71
|
+
writeConfig(config);
|
|
72
|
+
console.log('✅ API key saved to ~/.devdash/config.json\n');
|
|
73
|
+
|
|
74
|
+
return config.apiKey;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Get model (use default or from config)
|
|
78
|
+
function getModel() {
|
|
79
|
+
const config = readConfig();
|
|
80
|
+
return config.model || 'gemini-2.0-flash';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Set model
|
|
84
|
+
function setModel(model) {
|
|
85
|
+
const config = readConfig();
|
|
86
|
+
config.model = model;
|
|
87
|
+
writeConfig(config);
|
|
88
|
+
console.log(`✅ Model set to: ${model}`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Generate commit message
|
|
92
|
+
async function generateCommitMessage() {
|
|
93
|
+
try {
|
|
94
|
+
// Check if git is available
|
|
95
|
+
try {
|
|
96
|
+
execSync('git --version', { stdio: 'ignore' });
|
|
97
|
+
} catch (error) {
|
|
98
|
+
console.error('❌ Git is not installed or not in PATH.');
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Get staged changes
|
|
103
|
+
let diff;
|
|
104
|
+
try {
|
|
105
|
+
diff = execSync('git diff --staged', { encoding: 'utf-8' });
|
|
106
|
+
} catch (error) {
|
|
107
|
+
console.error('❌ Failed to get git diff. Are you in a git repository?');
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (!diff || diff.trim().length === 0) {
|
|
112
|
+
console.log('⚠️ No staged changes found. Stage your changes with "git add" first.');
|
|
113
|
+
process.exit(0);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
console.log('🤖 Generating commit message...\n');
|
|
117
|
+
|
|
118
|
+
// Get API key
|
|
119
|
+
const apiKey = await getApiKey();
|
|
120
|
+
const model = getModel();
|
|
121
|
+
|
|
122
|
+
// Call Gemini API
|
|
123
|
+
const google = createGoogleGenerativeAI({
|
|
124
|
+
apiKey: apiKey,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const { text } = await generateText({
|
|
128
|
+
model: google(model),
|
|
129
|
+
system: `You are a senior DevOps engineer. Summarize this code diff into a descriptive commit message. Format it with a concise subject line (imperative mood), followed by a blank line, and then a bulleted list of changes explaining "what" and "why". Do not use conventional commit prefixes like "feat:" or "chore:".
|
|
130
|
+
|
|
131
|
+
Example format:
|
|
132
|
+
Remove old_file.txt and update new_file.txt
|
|
133
|
+
|
|
134
|
+
- Deleted old_file.txt as it contained outdated information.
|
|
135
|
+
- Added additional context to new_file.txt for clarity on project updates.
|
|
136
|
+
|
|
137
|
+
Only return the commit message, no other text.`,
|
|
138
|
+
prompt: diff,
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
console.log('📝 Suggested commit message:\n');
|
|
142
|
+
console.log('─'.repeat(50));
|
|
143
|
+
console.log(text);
|
|
144
|
+
console.log('─'.repeat(50));
|
|
145
|
+
console.log('\nTo use this message, run:');
|
|
146
|
+
console.log(`git commit -m "${text.split('\n')[0]}"`);
|
|
147
|
+
|
|
148
|
+
} catch (error) {
|
|
149
|
+
console.error('❌ Error:', error.message);
|
|
150
|
+
process.exit(1);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// CLI setup
|
|
155
|
+
const program = new Command();
|
|
156
|
+
|
|
157
|
+
program
|
|
158
|
+
.name('devdash')
|
|
159
|
+
.description('CLI tool for generating commit messages using AI')
|
|
160
|
+
.version('1.0.0');
|
|
161
|
+
|
|
162
|
+
program
|
|
163
|
+
.command('commit')
|
|
164
|
+
.description('Generate a commit message from staged changes')
|
|
165
|
+
.action(generateCommitMessage);
|
|
166
|
+
|
|
167
|
+
program
|
|
168
|
+
.command('config')
|
|
169
|
+
.description('Configure DevDash settings')
|
|
170
|
+
.option('--set-key <key>', 'Set Google Gemini API key')
|
|
171
|
+
.option('--set-model <model>', 'Set AI model (e.g., gemini-2.0-flash)')
|
|
172
|
+
.option('--show', 'Show current configuration')
|
|
173
|
+
.action((options) => {
|
|
174
|
+
if (options.setKey) {
|
|
175
|
+
const config = readConfig();
|
|
176
|
+
config.apiKey = options.setKey;
|
|
177
|
+
writeConfig(config);
|
|
178
|
+
console.log('✅ API key updated.');
|
|
179
|
+
} else if (options.setModel) {
|
|
180
|
+
setModel(options.setModel);
|
|
181
|
+
} else if (options.show) {
|
|
182
|
+
const config = readConfig();
|
|
183
|
+
console.log('Current configuration:');
|
|
184
|
+
console.log(' API Key:', config.apiKey ? '***' + config.apiKey.slice(-4) : 'Not set');
|
|
185
|
+
console.log(' Model:', config.model || 'gemini-2.0-flash (default)');
|
|
186
|
+
console.log(' Config file:', CONFIG_FILE);
|
|
187
|
+
} else {
|
|
188
|
+
console.log('Use --set-key, --set-model, or --show');
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
program.parse(process.argv);
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pkpkpkddea/devdash",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "CLI tool for generating commit messages using AI",
|
|
6
|
+
"main": "bin/cli.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"devdash": "./bin/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"git",
|
|
15
|
+
"commit",
|
|
16
|
+
"ai",
|
|
17
|
+
"cli",
|
|
18
|
+
"devtools"
|
|
19
|
+
],
|
|
20
|
+
"author": "pkpkpkddea",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@ai-sdk/google": "^3.0.10",
|
|
24
|
+
"ai": "^6.0.38",
|
|
25
|
+
"commander": "^12.1.0"
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18.0.0"
|
|
29
|
+
},
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/pkpkpkddea/DevTool-Suite.git"
|
|
33
|
+
}
|
|
34
|
+
}
|