aiwf 0.3.15 → 0.3.16
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/README.ko.md +3 -4
- package/README.md +38 -3
- package/docs/API_REFERENCE_FULL.ko.md +979 -0
- package/docs/API_REFERENCE_FULL.md +979 -0
- package/docs/ARCHITECTURE.ko.md +314 -0
- package/docs/ARCHITECTURE.md +314 -0
- package/docs/GETTING_STARTED.ko.md +219 -0
- package/docs/GETTING_STARTED.md +0 -1
- package/docs/PERFORMANCE_GUIDELINES.ko.md +388 -0
- package/docs/TROUBLESHOOTING.ko.md +366 -0
- package/package.json +50 -2
- package/src/DEPENDENCY_MAP.md +90 -0
- package/src/lib/installer.js +1 -0
- package/src/lib/resources/templates/api-server/template/src/controllers/aiwfController.ts +0 -14
- package/src/lib/resources/templates/api-server/template/src/routes/aiwf.ts +0 -11
- package/src/lib/resources/templates/web-app/template/src/pages/AiwfDashboard.tsx +2 -5
- package/src/lib/resources/utils/token-reporter.js +2 -3
- package/src/utils/checkpoint-manager.js +11 -1
- package/src/utils/engineering-guard.js +11 -1
- package/templates/api-server/template/src/controllers/aiwfController.ts +0 -14
- package/templates/api-server/template/src/routes/aiwf.ts +0 -11
- package/templates/web-app/template/src/pages/AiwfDashboard.tsx +2 -5
- package/docs/guides/feature-git-integration-guide-ko.md +0 -481
- package/docs/guides/feature-git-integration-guide.md +0 -481
- package/src/commands/cache-templates.js +0 -209
- package/src/commands/create-offline.js +0 -86
- package/src/commands/state-refactored.js +0 -419
- package/src/lib/resources/commands/feature-ledger.js +0 -565
- package/src/lib/resources/commands/feature_commit_report.js +0 -370
- package/src/lib/resources/commands/scan_git_history.js +0 -234
- package/src/lib/resources/commands/sync_feature_commits.js +0 -154
- package/src/lib/resources/templates/web-app/template/src/components/aiwf/FeatureLedger.tsx +0 -93
- package/src/lib/resources/utils/feature-updater.js +0 -271
- package/src/utils/git-integration.js +0 -173
- package/templates/web-app/template/src/components/aiwf/FeatureLedger.tsx +0 -93
|
@@ -1,481 +0,0 @@
|
|
|
1
|
-
[Read in Korean (한국어로 보기)](feature-git-integration-guide-ko.md)
|
|
2
|
-
|
|
3
|
-
# Feature-Git Integration Setup Guide
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
The Feature-Git integration system is a tool that automatically connects AIWF's Feature Ledger with Git commits to track and manage feature development progress. It automates project management through commit message parsing, automatic status updates, and progress tracking.
|
|
8
|
-
|
|
9
|
-
## Key Features
|
|
10
|
-
|
|
11
|
-
### 1. Automatic Feature Tracking
|
|
12
|
-
- Automatic connection between Git commits and Feature IDs
|
|
13
|
-
- Extract Feature information from commit messages
|
|
14
|
-
- Automatic Feature status updates
|
|
15
|
-
|
|
16
|
-
### 2. Pre-commit Hook
|
|
17
|
-
- Validate Feature ID before commit
|
|
18
|
-
- Check commit message format
|
|
19
|
-
- Automatic Feature Ledger updates
|
|
20
|
-
|
|
21
|
-
### 3. Progress Management
|
|
22
|
-
- Calculate progress based on commit count
|
|
23
|
-
- Track contribution by Feature
|
|
24
|
-
- Generate team productivity metrics
|
|
25
|
-
|
|
26
|
-
## Installation and Setup
|
|
27
|
-
|
|
28
|
-
### 1. Basic Installation
|
|
29
|
-
|
|
30
|
-
**Automatic Installation (Recommended)**:
|
|
31
|
-
```bash
|
|
32
|
-
/project:aiwf:install_git_hooks
|
|
33
|
-
# or
|
|
34
|
-
/프로젝트:aiwf:git_훅_설치
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
**Manual Installation**:
|
|
38
|
-
```bash
|
|
39
|
-
# Navigate to Git hooks directory
|
|
40
|
-
cd .git/hooks
|
|
41
|
-
|
|
42
|
-
# Create Pre-commit hook
|
|
43
|
-
cat > pre-commit << 'EOF'
|
|
44
|
-
#!/bin/bash
|
|
45
|
-
# AIWF Feature-Git Integration Hook
|
|
46
|
-
|
|
47
|
-
# Commit message file path
|
|
48
|
-
COMMIT_MSG_FILE="$1"
|
|
49
|
-
|
|
50
|
-
# Execute AIWF commit validation
|
|
51
|
-
node .aiwf/scripts/validate-commit.js "$COMMIT_MSG_FILE"
|
|
52
|
-
|
|
53
|
-
# Return validation result
|
|
54
|
-
exit $?
|
|
55
|
-
EOF
|
|
56
|
-
|
|
57
|
-
# Grant execution permission
|
|
58
|
-
chmod +x pre-commit
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
### 2. Configuration File Setup
|
|
62
|
-
|
|
63
|
-
`.aiwf/config/git-integration.json`:
|
|
64
|
-
```json
|
|
65
|
-
{
|
|
66
|
-
"featureGitIntegration": {
|
|
67
|
-
"enabled": true,
|
|
68
|
-
"autoLinkCommits": true,
|
|
69
|
-
"updateFeatureStatus": true,
|
|
70
|
-
"commitMessagePattern": "^(feat|fix|docs|style|refactor|test|chore)\\(([A-Z]\\d{3})\\): .+$",
|
|
71
|
-
"featureIdPattern": "[A-Z]\\d{3}",
|
|
72
|
-
"hooks": {
|
|
73
|
-
"preCommit": true,
|
|
74
|
-
"postCommit": true,
|
|
75
|
-
"prePush": false
|
|
76
|
-
},
|
|
77
|
-
"statusMapping": {
|
|
78
|
-
"feat": "in_progress",
|
|
79
|
-
"fix": "in_progress",
|
|
80
|
-
"docs": "in_progress",
|
|
81
|
-
"test": "testing",
|
|
82
|
-
"chore": "in_progress",
|
|
83
|
-
"refactor": "in_progress",
|
|
84
|
-
"style": "in_progress"
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### 3. Feature Ledger Initialization
|
|
91
|
-
|
|
92
|
-
```bash
|
|
93
|
-
/project:aiwf:init_feature_ledger
|
|
94
|
-
# or
|
|
95
|
-
/프로젝트:aiwf:기능_원장_초기화
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
## Commit Message Format
|
|
99
|
-
|
|
100
|
-
### Basic Format
|
|
101
|
-
```
|
|
102
|
-
<type>(<feature-id>): <description>
|
|
103
|
-
|
|
104
|
-
[optional body]
|
|
105
|
-
|
|
106
|
-
[optional footer]
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### Type Categories
|
|
110
|
-
- `feat`: Add new feature
|
|
111
|
-
- `fix`: Fix bug
|
|
112
|
-
- `docs`: Modify documentation
|
|
113
|
-
- `style`: Code formatting, missing semicolons, etc.
|
|
114
|
-
- `refactor`: Code refactoring
|
|
115
|
-
- `test`: Add or modify tests
|
|
116
|
-
- `chore`: Build process or auxiliary tool changes
|
|
117
|
-
|
|
118
|
-
### Feature ID Format
|
|
119
|
-
- Format: `[A-Z][0-9]{3}` (e.g., F001, B023, T456)
|
|
120
|
-
- Customizable per project
|
|
121
|
-
|
|
122
|
-
### Examples
|
|
123
|
-
|
|
124
|
-
**Basic commit**:
|
|
125
|
-
```bash
|
|
126
|
-
git commit -m "feat(F001): Implement user authentication system"
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
**With detailed description**:
|
|
130
|
-
```bash
|
|
131
|
-
git commit -m "fix(B023): Resolve session persistence issue on login
|
|
132
|
-
|
|
133
|
-
- Fixed session timeout settings
|
|
134
|
-
- Added cookie domain configuration
|
|
135
|
-
- Improved refresh token logic"
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
**Multiple Feature references**:
|
|
139
|
-
```bash
|
|
140
|
-
git commit -m "refactor(F001,F002): Integrate authentication modules
|
|
141
|
-
|
|
142
|
-
Integrated login logic from F001 and permission system from F002
|
|
143
|
-
to eliminate code duplication and improve maintainability."
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
## link_feature_commit Command
|
|
147
|
-
|
|
148
|
-
### Basic Usage
|
|
149
|
-
```bash
|
|
150
|
-
/project:aiwf:link_feature_commit <commit-hash> <feature-id>
|
|
151
|
-
# or
|
|
152
|
-
/프로젝트:aiwf:기능_커밋_연결 <커밋해시> <기능ID>
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
### Examples
|
|
156
|
-
```bash
|
|
157
|
-
# Link specific commit to Feature
|
|
158
|
-
/project:aiwf:link_feature_commit abc123def F001
|
|
159
|
-
|
|
160
|
-
# Link recent commit
|
|
161
|
-
/project:aiwf:link_feature_commit HEAD F002
|
|
162
|
-
|
|
163
|
-
# Link range of commits
|
|
164
|
-
/project:aiwf:link_feature_commit abc123..def456 F003
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
### Batch Linking
|
|
168
|
-
```bash
|
|
169
|
-
# Link multiple commits at once
|
|
170
|
-
/project:aiwf:link_feature_commits --batch
|
|
171
|
-
"abc123 -> F001
|
|
172
|
-
def456 -> F002
|
|
173
|
-
ghi789 -> F003"
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
## Automatic Feature Status Updates
|
|
177
|
-
|
|
178
|
-
### Status Transition Rules
|
|
179
|
-
|
|
180
|
-
1. **First commit**: `planned` → `in_progress`
|
|
181
|
-
2. **Test type commit**: → `testing`
|
|
182
|
-
3. **Fix followed by test pass**: → `ready_for_review`
|
|
183
|
-
4. **PR merge**: → `completed`
|
|
184
|
-
|
|
185
|
-
### Custom Rule Configuration
|
|
186
|
-
```json
|
|
187
|
-
{
|
|
188
|
-
"stateTransitions": {
|
|
189
|
-
"planned": {
|
|
190
|
-
"feat": "in_progress",
|
|
191
|
-
"fix": "in_progress"
|
|
192
|
-
},
|
|
193
|
-
"in_progress": {
|
|
194
|
-
"test": "testing",
|
|
195
|
-
"docs": "documenting"
|
|
196
|
-
},
|
|
197
|
-
"testing": {
|
|
198
|
-
"fix": "in_progress",
|
|
199
|
-
"feat": "ready_for_review"
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
## Advanced Configuration
|
|
206
|
-
|
|
207
|
-
### 1. Commit Message Template
|
|
208
|
-
|
|
209
|
-
Create `.gitmessage` file:
|
|
210
|
-
```
|
|
211
|
-
# <type>(<feature-id>): <subject>
|
|
212
|
-
#
|
|
213
|
-
# <body>
|
|
214
|
-
#
|
|
215
|
-
# Feature: <feature-description>
|
|
216
|
-
# Related: <related-features>
|
|
217
|
-
# Closes: <issue-numbers>
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
Git configuration:
|
|
221
|
-
```bash
|
|
222
|
-
git config commit.template .gitmessage
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
### 2. Automatic Feature ID Suggestion
|
|
226
|
-
|
|
227
|
-
```bash
|
|
228
|
-
# Extract Feature ID from current branch name
|
|
229
|
-
/project:aiwf:suggest_feature_id
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
### 3. Post-commit Automation
|
|
233
|
-
|
|
234
|
-
`.aiwf/hooks/post-commit`:
|
|
235
|
-
```bash
|
|
236
|
-
#!/bin/bash
|
|
237
|
-
# Update Feature Ledger
|
|
238
|
-
node .aiwf/scripts/update-feature-ledger.js
|
|
239
|
-
|
|
240
|
-
# Calculate progress
|
|
241
|
-
node .aiwf/scripts/calculate-progress.js
|
|
242
|
-
|
|
243
|
-
# Notify team (optional)
|
|
244
|
-
# node .aiwf/scripts/notify-team.js
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
## Workflow Integration
|
|
248
|
-
|
|
249
|
-
### 1. Branch Strategy Integration
|
|
250
|
-
|
|
251
|
-
**Feature Branch Creation**:
|
|
252
|
-
```bash
|
|
253
|
-
# Create branch with Feature ID
|
|
254
|
-
git checkout -b feature/F001-user-authentication
|
|
255
|
-
|
|
256
|
-
# AIWF automatically recognizes Feature ID
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
**Branch Rules**:
|
|
260
|
-
- `feature/[FEATURE-ID]-description`
|
|
261
|
-
- `bugfix/[BUG-ID]-description`
|
|
262
|
-
- `hotfix/[HOTFIX-ID]-description`
|
|
263
|
-
|
|
264
|
-
### 2. PR/MR Integration
|
|
265
|
-
|
|
266
|
-
**PR Template** (`.github/pull_request_template.md`):
|
|
267
|
-
```markdown
|
|
268
|
-
## Feature ID: [FEATURE-ID]
|
|
269
|
-
|
|
270
|
-
### Changes
|
|
271
|
-
- [ ] Feature implementation completed
|
|
272
|
-
- [ ] Tests written and completed
|
|
273
|
-
- [ ] Documentation updated
|
|
274
|
-
|
|
275
|
-
### Feature Ledger Update
|
|
276
|
-
- Current status: `in_progress`
|
|
277
|
-
- Target status: `completed`
|
|
278
|
-
- Progress: X%
|
|
279
|
-
|
|
280
|
-
### Related Commits
|
|
281
|
-
- commit1: description
|
|
282
|
-
- commit2: description
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
### 3. CI/CD Pipeline Integration
|
|
286
|
-
|
|
287
|
-
**GitHub Actions Example**:
|
|
288
|
-
```yaml
|
|
289
|
-
name: AIWF Feature Tracking
|
|
290
|
-
|
|
291
|
-
on:
|
|
292
|
-
push:
|
|
293
|
-
branches: [ main, develop ]
|
|
294
|
-
pull_request:
|
|
295
|
-
branches: [ main ]
|
|
296
|
-
|
|
297
|
-
jobs:
|
|
298
|
-
feature-tracking:
|
|
299
|
-
runs-on: ubuntu-latest
|
|
300
|
-
steps:
|
|
301
|
-
- uses: actions/checkout@v2
|
|
302
|
-
|
|
303
|
-
- name: Validate Commit Message
|
|
304
|
-
run: |
|
|
305
|
-
node .aiwf/scripts/validate-commit.js ${{ github.event.head_commit.message }}
|
|
306
|
-
|
|
307
|
-
- name: Update Feature Ledger
|
|
308
|
-
run: |
|
|
309
|
-
node .aiwf/scripts/update-feature-ledger.js \
|
|
310
|
-
--commit ${{ github.sha }} \
|
|
311
|
-
--message "${{ github.event.head_commit.message }}"
|
|
312
|
-
|
|
313
|
-
- name: Calculate Progress
|
|
314
|
-
run: |
|
|
315
|
-
node .aiwf/scripts/calculate-progress.js
|
|
316
|
-
|
|
317
|
-
- name: Generate Report
|
|
318
|
-
run: |
|
|
319
|
-
node .aiwf/scripts/generate-feature-report.js
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
## Reports and Analytics
|
|
323
|
-
|
|
324
|
-
### 1. Feature Progress Report
|
|
325
|
-
|
|
326
|
-
```bash
|
|
327
|
-
/project:aiwf:feature_report
|
|
328
|
-
# or
|
|
329
|
-
/프로젝트:aiwf:기능_보고서
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
**Example Output**:
|
|
333
|
-
```
|
|
334
|
-
Feature Progress Report
|
|
335
|
-
=======================
|
|
336
|
-
|
|
337
|
-
Active Features:
|
|
338
|
-
- F001: User Authentication (75% complete)
|
|
339
|
-
- 12 commits, 3 contributors
|
|
340
|
-
- Status: testing
|
|
341
|
-
- Last update: 2 hours ago
|
|
342
|
-
|
|
343
|
-
- F002: Payment Integration (45% complete)
|
|
344
|
-
- 8 commits, 2 contributors
|
|
345
|
-
- Status: in_progress
|
|
346
|
-
- Last update: 1 day ago
|
|
347
|
-
|
|
348
|
-
Completed Features (Last 7 days):
|
|
349
|
-
- F003: Dashboard UI (100% complete)
|
|
350
|
-
- F004: API Documentation (100% complete)
|
|
351
|
-
|
|
352
|
-
Team Velocity: 4.5 features/week
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
### 2. Commit Analysis
|
|
356
|
-
|
|
357
|
-
```bash
|
|
358
|
-
/project:aiwf:analyze_commits --period 7d
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
**Analysis Content**:
|
|
362
|
-
- Commit frequency
|
|
363
|
-
- Commit distribution by Feature
|
|
364
|
-
- Contribution by developer
|
|
365
|
-
- Activity patterns by time
|
|
366
|
-
|
|
367
|
-
## Troubleshooting
|
|
368
|
-
|
|
369
|
-
### 1. Hook Not Working
|
|
370
|
-
|
|
371
|
-
**Check Items**:
|
|
372
|
-
```bash
|
|
373
|
-
# Check if hook file exists
|
|
374
|
-
ls -la .git/hooks/pre-commit
|
|
375
|
-
|
|
376
|
-
# Check execution permission
|
|
377
|
-
test -x .git/hooks/pre-commit && echo "Executable" || echo "Not executable"
|
|
378
|
-
|
|
379
|
-
# Check hook content
|
|
380
|
-
cat .git/hooks/pre-commit
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
**Solutions**:
|
|
384
|
-
```bash
|
|
385
|
-
# Reset permissions
|
|
386
|
-
chmod +x .git/hooks/pre-commit
|
|
387
|
-
|
|
388
|
-
# Reinstall hook
|
|
389
|
-
/project:aiwf:reinstall_hooks
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
### 2. Feature ID Recognition Failure
|
|
393
|
-
|
|
394
|
-
**Symptoms**: Commit succeeds but Feature is not updated
|
|
395
|
-
|
|
396
|
-
**Solutions**:
|
|
397
|
-
1. Check commit message format
|
|
398
|
-
2. Check Feature ID pattern configuration
|
|
399
|
-
3. Check Feature Ledger file permissions
|
|
400
|
-
|
|
401
|
-
### 3. Status Update Errors
|
|
402
|
-
|
|
403
|
-
**Check Logs**:
|
|
404
|
-
```bash
|
|
405
|
-
tail -f .aiwf/logs/git-integration.log
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
**Manual Update**:
|
|
409
|
-
```bash
|
|
410
|
-
/project:aiwf:update_feature_status F001 in_progress
|
|
411
|
-
```
|
|
412
|
-
|
|
413
|
-
## Best Practices
|
|
414
|
-
|
|
415
|
-
### 1. Consistent Commit Messages
|
|
416
|
-
- Use the same format across the entire team
|
|
417
|
-
- Always include Feature ID
|
|
418
|
-
- Write clear and descriptive messages
|
|
419
|
-
|
|
420
|
-
### 2. Small Unit Commits
|
|
421
|
-
- One commit for one logical change
|
|
422
|
-
- Easy to review and track
|
|
423
|
-
- Easy to rollback when issues occur
|
|
424
|
-
|
|
425
|
-
### 3. Regular Synchronization
|
|
426
|
-
```bash
|
|
427
|
-
# Daily Feature Ledger synchronization
|
|
428
|
-
/project:aiwf:sync_features
|
|
429
|
-
|
|
430
|
-
# Weekly report generation
|
|
431
|
-
/project:aiwf:weekly_feature_report
|
|
432
|
-
```
|
|
433
|
-
|
|
434
|
-
### 4. Branch and Feature Mapping
|
|
435
|
-
- Include Feature ID in branch names
|
|
436
|
-
- Specify Feature ID in PR titles
|
|
437
|
-
- Maintain Feature ID in merge commits
|
|
438
|
-
|
|
439
|
-
## Team Collaboration Scenarios
|
|
440
|
-
|
|
441
|
-
### 1. Starting New Feature
|
|
442
|
-
```bash
|
|
443
|
-
# 1. Create Feature
|
|
444
|
-
/project:aiwf:create_feature "User Profile Feature"
|
|
445
|
-
# Returns: F005 created
|
|
446
|
-
|
|
447
|
-
# 2. Create Branch
|
|
448
|
-
git checkout -b feature/F005-user-profile
|
|
449
|
-
|
|
450
|
-
# 3. First Commit
|
|
451
|
-
git commit -m "feat(F005): Create basic user profile structure"
|
|
452
|
-
```
|
|
453
|
-
|
|
454
|
-
### 2. Collaborative Development
|
|
455
|
-
```bash
|
|
456
|
-
# Developer A
|
|
457
|
-
git commit -m "feat(F005): Implement profile image upload"
|
|
458
|
-
|
|
459
|
-
# Developer B
|
|
460
|
-
git commit -m "test(F005): Add profile upload tests"
|
|
461
|
-
|
|
462
|
-
# Check progress
|
|
463
|
-
/project:aiwf:feature_status F005
|
|
464
|
-
```
|
|
465
|
-
|
|
466
|
-
### 3. Completion and Merge
|
|
467
|
-
```bash
|
|
468
|
-
# When creating PR
|
|
469
|
-
# Title: "feat(F005): Complete user profile feature"
|
|
470
|
-
|
|
471
|
-
# After merge, automatically
|
|
472
|
-
# - Feature status → completed
|
|
473
|
-
# - Progress → 100%
|
|
474
|
-
# - Completion time recorded
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
## Conclusion
|
|
478
|
-
|
|
479
|
-
The Feature-Git integration system effectively combines development processes with project management. Through automated tracking and reporting capabilities, it improves team productivity and enables real-time monitoring of project progress.
|
|
480
|
-
|
|
481
|
-
We encourage you to continuously improve and optimize your workflow through ongoing use and team feedback.
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const fs = require('fs-extra');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const https = require('https');
|
|
6
|
-
const tar = require('tar');
|
|
7
|
-
const chalk = require('chalk');
|
|
8
|
-
const ora = require('ora');
|
|
9
|
-
|
|
10
|
-
const CACHE_DIR = path.join(__dirname, '../.cache');
|
|
11
|
-
const TEMPLATES_DIR = path.join(__dirname, '../templates');
|
|
12
|
-
const DEPENDENCIES_CACHE = path.join(CACHE_DIR, 'dependencies');
|
|
13
|
-
|
|
14
|
-
// 각 템플릿의 주요 의존성 목록
|
|
15
|
-
const TEMPLATE_DEPENDENCIES = {
|
|
16
|
-
'web-app': [
|
|
17
|
-
'react@18',
|
|
18
|
-
'react-dom@18',
|
|
19
|
-
'vite@4',
|
|
20
|
-
'typescript@5',
|
|
21
|
-
'tailwindcss@3'
|
|
22
|
-
],
|
|
23
|
-
'api-server': [
|
|
24
|
-
'express@4',
|
|
25
|
-
'typescript@5',
|
|
26
|
-
'jsonwebtoken@9',
|
|
27
|
-
'swagger-ui-express@5'
|
|
28
|
-
],
|
|
29
|
-
'npm-library': [
|
|
30
|
-
'typescript@5',
|
|
31
|
-
'rollup@3',
|
|
32
|
-
'jest@29'
|
|
33
|
-
]
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
async function cacheTemplates() {
|
|
37
|
-
console.log(chalk.cyan('\n📦 AIWF 템플릿 캐시 시스템\n'));
|
|
38
|
-
|
|
39
|
-
const spinner = ora('캐시 디렉토리 준비 중...').start();
|
|
40
|
-
|
|
41
|
-
try {
|
|
42
|
-
// 캐시 디렉토리 생성
|
|
43
|
-
await fs.ensureDir(CACHE_DIR);
|
|
44
|
-
await fs.ensureDir(DEPENDENCIES_CACHE);
|
|
45
|
-
|
|
46
|
-
spinner.text = '템플릿 압축 중...';
|
|
47
|
-
|
|
48
|
-
// 각 템플릿을 압축하여 캐시
|
|
49
|
-
const templates = await fs.readdir(TEMPLATES_DIR);
|
|
50
|
-
|
|
51
|
-
for (const template of templates) {
|
|
52
|
-
const templatePath = path.join(TEMPLATES_DIR, template);
|
|
53
|
-
const stat = await fs.stat(templatePath);
|
|
54
|
-
|
|
55
|
-
if (stat.isDirectory()) {
|
|
56
|
-
const cachePath = path.join(CACHE_DIR, `${template}.tar.gz`);
|
|
57
|
-
|
|
58
|
-
await tar.create(
|
|
59
|
-
{
|
|
60
|
-
gzip: true,
|
|
61
|
-
file: cachePath,
|
|
62
|
-
cwd: TEMPLATES_DIR
|
|
63
|
-
},
|
|
64
|
-
[template]
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
spinner.text = `${template} 템플릿 캐시 완료`;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
spinner.text = '템플릿 메타데이터 생성 중...';
|
|
72
|
-
|
|
73
|
-
// 캐시 메타데이터 생성
|
|
74
|
-
const metadata = {
|
|
75
|
-
version: require('../../package.json').version,
|
|
76
|
-
cachedAt: new Date().toISOString(),
|
|
77
|
-
templates: {},
|
|
78
|
-
dependencies: {}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
for (const template of templates) {
|
|
82
|
-
const configPath = path.join(TEMPLATES_DIR, template, 'config.json');
|
|
83
|
-
if (await fs.pathExists(configPath)) {
|
|
84
|
-
const config = await fs.readJson(configPath);
|
|
85
|
-
metadata.templates[template] = {
|
|
86
|
-
name: config.name,
|
|
87
|
-
displayName: config.displayName,
|
|
88
|
-
description: config.description,
|
|
89
|
-
size: (await fs.stat(path.join(CACHE_DIR, `${template}.tar.gz`))).size
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
await fs.writeJson(path.join(CACHE_DIR, 'metadata.json'), metadata, { spaces: 2 });
|
|
95
|
-
|
|
96
|
-
spinner.succeed('템플릿 캐시 완료!');
|
|
97
|
-
|
|
98
|
-
// 캐시 통계 출력
|
|
99
|
-
console.log(chalk.green('\n✅ 캐시 생성 완료\n'));
|
|
100
|
-
console.log('캐시된 템플릿:');
|
|
101
|
-
for (const [template, info] of Object.entries(metadata.templates)) {
|
|
102
|
-
console.log(chalk.gray(` - ${info.displayName}: ${(info.size / 1024).toFixed(2)} KB`));
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const totalSize = Object.values(metadata.templates)
|
|
106
|
-
.reduce((sum, info) => sum + info.size, 0);
|
|
107
|
-
console.log(chalk.gray(`\n총 캐시 크기: ${(totalSize / 1024 / 1024).toFixed(2)} MB`));
|
|
108
|
-
|
|
109
|
-
} catch (error) {
|
|
110
|
-
spinner.fail('캐시 생성 중 오류가 발생했습니다.');
|
|
111
|
-
console.error(chalk.red(error.message));
|
|
112
|
-
process.exit(1);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async function restoreFromCache(templateName, targetPath) {
|
|
117
|
-
const cachePath = path.join(CACHE_DIR, `${templateName}.tar.gz`);
|
|
118
|
-
|
|
119
|
-
if (!await fs.pathExists(cachePath)) {
|
|
120
|
-
throw new Error(`캐시된 템플릿을 찾을 수 없습니다: ${templateName}`);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
await tar.extract({
|
|
124
|
-
file: cachePath,
|
|
125
|
-
cwd: targetPath
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
// 템플릿 내용을 상위 디렉토리로 이동
|
|
129
|
-
const extractedPath = path.join(targetPath, templateName, 'template');
|
|
130
|
-
const files = await fs.readdir(extractedPath);
|
|
131
|
-
|
|
132
|
-
for (const file of files) {
|
|
133
|
-
await fs.move(
|
|
134
|
-
path.join(extractedPath, file),
|
|
135
|
-
path.join(targetPath, file)
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// 임시 디렉토리 삭제
|
|
140
|
-
await fs.remove(path.join(targetPath, templateName));
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
async function checkCache() {
|
|
144
|
-
const metadataPath = path.join(CACHE_DIR, 'metadata.json');
|
|
145
|
-
|
|
146
|
-
if (!await fs.pathExists(metadataPath)) {
|
|
147
|
-
return { valid: false, reason: '캐시가 존재하지 않습니다' };
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const metadata = await fs.readJson(metadataPath);
|
|
151
|
-
const packageVersion = require('../../package.json').version;
|
|
152
|
-
|
|
153
|
-
if (metadata.version !== packageVersion) {
|
|
154
|
-
return { valid: false, reason: '버전이 일치하지 않습니다' };
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// 캐시가 7일 이상 오래된 경우
|
|
158
|
-
const cacheAge = Date.now() - new Date(metadata.cachedAt).getTime();
|
|
159
|
-
const sevenDays = 7 * 24 * 60 * 60 * 1000;
|
|
160
|
-
|
|
161
|
-
if (cacheAge > sevenDays) {
|
|
162
|
-
return { valid: false, reason: '캐시가 오래되었습니다' };
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return { valid: true, metadata };
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// CLI 명령어 처리
|
|
169
|
-
if (require.main === module) {
|
|
170
|
-
const command = process.argv[2];
|
|
171
|
-
|
|
172
|
-
switch (command) {
|
|
173
|
-
case 'create':
|
|
174
|
-
cacheTemplates().catch(error => {
|
|
175
|
-
console.error(chalk.red('오류:', error.message));
|
|
176
|
-
process.exit(1);
|
|
177
|
-
});
|
|
178
|
-
break;
|
|
179
|
-
|
|
180
|
-
case 'check':
|
|
181
|
-
checkCache().then(result => {
|
|
182
|
-
if (result.valid) {
|
|
183
|
-
console.log(chalk.green('✅ 캐시가 유효합니다'));
|
|
184
|
-
console.log(chalk.gray(`생성일: ${result.metadata.cachedAt}`));
|
|
185
|
-
} else {
|
|
186
|
-
console.log(chalk.yellow(`⚠️ ${result.reason}`));
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
break;
|
|
190
|
-
|
|
191
|
-
case 'clear':
|
|
192
|
-
fs.remove(CACHE_DIR).then(() => {
|
|
193
|
-
console.log(chalk.green('✅ 캐시가 삭제되었습니다'));
|
|
194
|
-
});
|
|
195
|
-
break;
|
|
196
|
-
|
|
197
|
-
default:
|
|
198
|
-
console.log(`
|
|
199
|
-
사용법: node cache-templates.js [command]
|
|
200
|
-
|
|
201
|
-
명령어:
|
|
202
|
-
create 템플릿 캐시 생성
|
|
203
|
-
check 캐시 상태 확인
|
|
204
|
-
clear 캐시 삭제
|
|
205
|
-
`);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
module.exports = { cacheTemplates, restoreFromCache, checkCache };
|