Skip to content

Commit 675e672

Browse files
committed
Updated packages.
1 parent bc4452e commit 675e672

File tree

8 files changed

+376
-310
lines changed

8 files changed

+376
-310
lines changed

.claude/settings.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(git status *)",
5+
"Bash(git log *)",
6+
"Bash(git diff *)",
7+
"Bash(git branch *)",
8+
"Bash(git worktree *)",
9+
"Bash(git stash *)",
10+
"Bash(git remote *)",
11+
"Bash(ls *)",
12+
"Bash(cat *)",
13+
"Bash(head *)",
14+
"Bash(tail *)",
15+
"Bash(find *)",
16+
"Bash(which *)",
17+
"Bash(echo *)",
18+
"Bash(wc *)",
19+
"Bash(mkdir *)",
20+
"Bash(touch *)",
21+
"Bash(chmod +x *)",
22+
"Bash(npm test *)",
23+
"Bash(npm run test *)",
24+
"Bash(npm run lint *)",
25+
"Bash(npm run build *)"
26+
],
27+
"deny": [
28+
"Bash(rm -rf *)",
29+
"Bash(git push --force *)",
30+
"Bash(git reset --hard *)",
31+
"Bash(git clean -f *)"
32+
]
33+
}
34+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
**/.claude/settings.local.json
22
.pr-in-progress.json
3+
tickets

CLAUDE.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# CLAUDE.md
2+
3+
## Project Overview
4+
GitHub PR Maker — a CLI tool that generates GitHub pull requests from a standard template and user input. Installed globally as a bin command.
5+
6+
## Tech Stack
7+
- **Runtime**: Node.js (ES modules, `"type": "module"`)
8+
- **Templating**: Nunjucks (`nunjucks` package)
9+
- **Prompts**: `@inquirer/prompts` (input, confirm, search)
10+
- **PR Creation**: GitHub CLI (`gh pr create`)
11+
- **Testing**: Jest (with `--experimental-vm-modules` for ESM support)
12+
- **Linting**: ESLint 9 flat config
13+
14+
## Commands
15+
- `npm test` — run all tests
16+
- `npm run lint` — lint
17+
- `npm run lint:fix` — lint and fix
18+
- `npm start` — run the CLI locally
19+
20+
## Project Structure
21+
```
22+
index.js # Main CLI entry point (all logic lives here)
23+
templates/
24+
PULL_REQUEST_TEMPLATE.njk # Nunjucks template for PR body
25+
test/
26+
basic.test.js # Jest tests
27+
tickets/ # Task tracking (kanban-style)
28+
todo/ # Tickets ready to work on
29+
in-progress/ # Tickets currently being worked on
30+
refining/ # Tickets that need more detail
31+
done/ # Completed tickets
32+
```
33+
34+
## Ticket Workflow
35+
Tickets are markdown files in `tickets/`. Move files between directories to track status:
36+
- `todo/``in-progress/``done/`
37+
- `refining/` holds tickets that need more detail before they're actionable
38+
39+
## Code Style
40+
- ES modules (`import`/`export`)
41+
- 2-space indentation, single quotes
42+
- Functions are exported individually for testability
43+
- CLI uses emoji prefixes in console output for UX

index.js

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
import { execSync } from 'child_process';
44
import { input, confirm, search } from '@inquirer/prompts';
5-
import twig from 'twig';
6-
import { promisify } from 'util';
5+
import nunjucks from 'nunjucks';
76
import { existsSync, readFileSync, writeFileSync, unlinkSync, realpathSync } from 'fs';
87
import path from 'path';
98
import { dirname } from 'path';
@@ -13,8 +12,6 @@ import { fileURLToPath } from 'url';
1312
const __dirname = dirname(fileURLToPath(import.meta.url));
1413

1514

16-
const renderFileAsync = promisify(twig.renderFile);
17-
1815
// Get the three most recent commits
1916
export function getRecentCommits(count = 3) {
2017
try {
@@ -202,10 +199,10 @@ const DEFAULT_TEMPLATE = `{% if has_ticket %}
202199
203200
{% if has_tests %}
204201
## Tests
205-
- Includes tests
202+
- Includes tests
206203
{% else %}
207204
## Tests
208-
- No tests included
205+
- No tests included
209206
{% endif %}
210207
`;
211208

@@ -221,7 +218,7 @@ function getScriptDir() {
221218
export function getTemplatePath() {
222219
// Get template ONLY from the script's installation directory
223220
const scriptDir = getScriptDir();
224-
const templatePath = path.join(scriptDir, 'templates', 'PULL_REQUEST_TEMPLATE.twig');
221+
const templatePath = path.join(scriptDir, 'templates', 'PULL_REQUEST_TEMPLATE.njk');
225222

226223
// Check if template exists in the app installation directory
227224
if (!existsSync(templatePath)) {
@@ -401,21 +398,18 @@ export async function main() {
401398
// Get template and render it
402399
const template = getTemplatePath();
403400

401+
const templateData = {
402+
ticket_number: ticketNumber || '',
403+
changes,
404+
has_tests: hasTests,
405+
has_ticket: !!ticketNumber
406+
};
407+
404408
let renderedTemplate;
405409
if (template.isDefault) {
406-
renderedTemplate = twig.twig({ data: template.content }).render({
407-
ticket_number: ticketNumber || '',
408-
changes,
409-
has_tests: hasTests,
410-
has_ticket: !!ticketNumber
411-
});
410+
renderedTemplate = nunjucks.renderString(template.content, templateData);
412411
} else {
413-
renderedTemplate = await renderFileAsync(template.path, {
414-
ticket_number: ticketNumber || '',
415-
changes,
416-
has_tests: hasTests,
417-
has_ticket: !!ticketNumber
418-
});
412+
renderedTemplate = nunjucks.render(template.path, templateData);
419413
}
420414

421415
console.log('\n📋 PR Preview:');

0 commit comments

Comments
 (0)