@git.zone/cli 1.16.7 → 1.16.9
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/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/mod_format/classes.baseformatter.d.ts +0 -2
- package/dist_ts/mod_format/classes.baseformatter.js +14 -23
- package/dist_ts/mod_format/classes.changecache.js +14 -29
- package/dist_ts/mod_format/classes.dependency-analyzer.js +24 -18
- package/dist_ts/mod_format/classes.diffreporter.js +4 -4
- package/dist_ts/mod_format/classes.formatcontext.d.ts +0 -13
- package/dist_ts/mod_format/classes.formatcontext.js +1 -41
- package/dist_ts/mod_format/classes.formatplanner.js +25 -45
- package/dist_ts/mod_format/classes.formatstats.js +22 -20
- package/dist_ts/mod_format/classes.rollbackmanager.js +20 -32
- package/dist_ts/mod_format/format.cleanup.js +7 -2
- package/dist_ts/mod_format/format.copy.d.ts +1 -1
- package/dist_ts/mod_format/format.copy.js +3 -3
- package/dist_ts/mod_format/format.gitignore.js +27 -7
- package/dist_ts/mod_format/format.license.js +1 -1
- package/dist_ts/mod_format/format.npmextra.js +1 -1
- package/dist_ts/mod_format/format.packagejson.js +5 -3
- package/dist_ts/mod_format/format.prettier.js +7 -2
- package/dist_ts/mod_format/format.readme.js +1 -1
- package/dist_ts/mod_format/format.templates.js +1 -1
- package/dist_ts/mod_format/format.tsconfig.js +4 -2
- package/dist_ts/mod_format/formatters/cleanup.formatter.js +8 -3
- package/dist_ts/mod_format/formatters/legacy.formatter.js +6 -4
- package/dist_ts/mod_format/formatters/prettier.formatter.js +68 -51
- package/dist_ts/mod_format/formatters/readme.formatter.js +6 -4
- package/dist_ts/mod_format/index.js +13 -71
- package/dist_ts/mod_meta/meta.classes.meta.js +1 -1
- package/dist_ts/mod_standard/index.js +1 -1
- package/dist_ts/mod_start/index.js +1 -1
- package/dist_ts/mod_template/index.js +1 -1
- package/npmextra.json +1 -1
- package/package.json +1 -1
- package/readme.hints.md +8 -3
- package/readme.md +30 -3
- package/readme.plan.md +21 -1
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/mod_format/classes.baseformatter.ts +28 -39
- package/ts/mod_format/classes.changecache.ts +74 -80
- package/ts/mod_format/classes.dependency-analyzer.ts +46 -36
- package/ts/mod_format/classes.diffreporter.ts +44 -28
- package/ts/mod_format/classes.formatcontext.ts +3 -54
- package/ts/mod_format/classes.formatplanner.ts +56 -70
- package/ts/mod_format/classes.formatstats.ts +69 -49
- package/ts/mod_format/classes.rollbackmanager.ts +123 -103
- package/ts/mod_format/format.cleanup.ts +9 -2
- package/ts/mod_format/format.copy.ts +17 -14
- package/ts/mod_format/format.gitignore.ts +33 -7
- package/ts/mod_format/format.license.ts +3 -1
- package/ts/mod_format/format.npmextra.ts +9 -2
- package/ts/mod_format/format.packagejson.ts +47 -12
- package/ts/mod_format/format.prettier.ts +10 -2
- package/ts/mod_format/format.readme.ts +2 -1
- package/ts/mod_format/format.templates.ts +15 -7
- package/ts/mod_format/format.tsconfig.ts +6 -2
- package/ts/mod_format/formatters/cleanup.formatter.ts +13 -8
- package/ts/mod_format/formatters/copy.formatter.ts +1 -1
- package/ts/mod_format/formatters/gitignore.formatter.ts +1 -1
- package/ts/mod_format/formatters/legacy.formatter.ts +19 -12
- package/ts/mod_format/formatters/license.formatter.ts +1 -1
- package/ts/mod_format/formatters/npmextra.formatter.ts +1 -1
- package/ts/mod_format/formatters/packagejson.formatter.ts +1 -1
- package/ts/mod_format/formatters/prettier.formatter.ts +114 -78
- package/ts/mod_format/formatters/readme.formatter.ts +11 -9
- package/ts/mod_format/formatters/templates.formatter.ts +1 -1
- package/ts/mod_format/formatters/tsconfig.formatter.ts +1 -1
- package/ts/mod_format/index.ts +57 -113
- package/ts/mod_format/interfaces.format.ts +3 -3
- package/ts/mod_meta/meta.classes.meta.ts +57 -19
- package/ts/mod_standard/index.ts +3 -1
- package/ts/mod_start/index.ts +3 -1
- package/ts/mod_template/index.ts +5 -2
package/readme.md
CHANGED
|
@@ -47,12 +47,14 @@ gitzone template [template-name]
|
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
**Available templates:**
|
|
50
|
+
|
|
50
51
|
- **`npm`** - TypeScript npm package with testing, CI/CD, and full tooling
|
|
51
52
|
- **`service`** - Microservice architecture with Docker support
|
|
52
|
-
- **`website`** - Modern web application with LitElement and service workers
|
|
53
|
+
- **`website`** - Modern web application with LitElement and service workers
|
|
53
54
|
- **`wcc`** - Web Component Collection for reusable UI components
|
|
54
55
|
|
|
55
56
|
Each template comes pre-configured with:
|
|
57
|
+
|
|
56
58
|
- ✅ TypeScript with modern configurations
|
|
57
59
|
- ✅ Automated testing setup
|
|
58
60
|
- ✅ CI/CD pipelines (GitLab/GitHub)
|
|
@@ -81,6 +83,7 @@ gitzone format --verbose
|
|
|
81
83
|
```
|
|
82
84
|
|
|
83
85
|
**Format features:**
|
|
86
|
+
|
|
84
87
|
- 🔄 **Smart caching** - Only processes changed files
|
|
85
88
|
- 🛡️ **Rollback support** - Undo formatting changes if needed
|
|
86
89
|
- 📊 **Detailed reporting** - See exactly what changed
|
|
@@ -88,6 +91,7 @@ gitzone format --verbose
|
|
|
88
91
|
- 🎯 **Module-specific formatting** - Target specific formatters
|
|
89
92
|
|
|
90
93
|
**Rollback capabilities:**
|
|
94
|
+
|
|
91
95
|
```bash
|
|
92
96
|
# List all available backups
|
|
93
97
|
gitzone format --list-backups
|
|
@@ -103,6 +107,7 @@ gitzone format --clean-backups
|
|
|
103
107
|
```
|
|
104
108
|
|
|
105
109
|
**Formatters included:**
|
|
110
|
+
|
|
106
111
|
- **Prettier** - JavaScript/TypeScript code formatting
|
|
107
112
|
- **License** - Ensure proper licensing
|
|
108
113
|
- **Package.json** - Standardize package configurations
|
|
@@ -121,6 +126,7 @@ gitzone commit
|
|
|
121
126
|
```
|
|
122
127
|
|
|
123
128
|
Features:
|
|
129
|
+
|
|
124
130
|
- 📝 Interactive commit message builder
|
|
125
131
|
- 🏷️ Automatic version bumping (major/minor/patch)
|
|
126
132
|
- 📜 Changelog generation
|
|
@@ -128,6 +134,7 @@ Features:
|
|
|
128
134
|
- 🎯 Conventional commit compliance
|
|
129
135
|
|
|
130
136
|
The commit wizard guides you through:
|
|
137
|
+
|
|
131
138
|
1. **Type selection** (feat/fix/docs/style/refactor/perf/test/chore)
|
|
132
139
|
2. **Scope definition** (component/module affected)
|
|
133
140
|
3. **Description crafting**
|
|
@@ -153,6 +160,7 @@ gitzone meta remove [name]
|
|
|
153
160
|
```
|
|
154
161
|
|
|
155
162
|
Perfect for:
|
|
163
|
+
|
|
156
164
|
- Monorepo management
|
|
157
165
|
- Multi-package projects
|
|
158
166
|
- Coordinated deployments
|
|
@@ -168,6 +176,7 @@ gitzone docker prune
|
|
|
168
176
|
```
|
|
169
177
|
|
|
170
178
|
This command removes:
|
|
179
|
+
|
|
171
180
|
- Stopped containers
|
|
172
181
|
- Unused images
|
|
173
182
|
- Dangling volumes
|
|
@@ -196,6 +205,7 @@ gitzone deprecate
|
|
|
196
205
|
```
|
|
197
206
|
|
|
198
207
|
Interactive wizard for:
|
|
208
|
+
|
|
199
209
|
- Setting deprecation notices
|
|
200
210
|
- Guiding users to replacements
|
|
201
211
|
- Updating registry metadata
|
|
@@ -210,6 +220,7 @@ gitzone start
|
|
|
210
220
|
```
|
|
211
221
|
|
|
212
222
|
Automatically:
|
|
223
|
+
|
|
213
224
|
- Checks out master branch
|
|
214
225
|
- Pulls latest changes
|
|
215
226
|
- Installs dependencies
|
|
@@ -266,18 +277,21 @@ Customize gitzone behavior through `npmextra.json`:
|
|
|
266
277
|
## 🏆 Best Practices
|
|
267
278
|
|
|
268
279
|
### For New Projects
|
|
280
|
+
|
|
269
281
|
1. Start with a template: `gitzone template npm`
|
|
270
282
|
2. Customize the generated structure
|
|
271
283
|
3. Run initial format: `gitzone format`
|
|
272
284
|
4. Set up CI/CD: `gitzone open ci`
|
|
273
285
|
|
|
274
286
|
### For Existing Projects
|
|
287
|
+
|
|
275
288
|
1. Initialize: `gitzone start`
|
|
276
289
|
2. Format codebase: `gitzone format --dry-run` (preview first!)
|
|
277
290
|
3. Apply formatting: `gitzone format --yes`
|
|
278
291
|
4. Commit changes: `gitzone commit`
|
|
279
292
|
|
|
280
293
|
### For Teams
|
|
294
|
+
|
|
281
295
|
1. Document format preferences in `npmextra.json`
|
|
282
296
|
2. Use `--save-plan` for reviewable format changes
|
|
283
297
|
3. Enable rollback for safety
|
|
@@ -286,6 +300,7 @@ Customize gitzone behavior through `npmextra.json`:
|
|
|
286
300
|
## 🎯 Common Workflows
|
|
287
301
|
|
|
288
302
|
### Clean Development Cycle
|
|
303
|
+
|
|
289
304
|
```bash
|
|
290
305
|
# 1. Start fresh
|
|
291
306
|
gitzone start
|
|
@@ -304,6 +319,7 @@ gitzone commit
|
|
|
304
319
|
```
|
|
305
320
|
|
|
306
321
|
### Multi-Repository Management
|
|
322
|
+
|
|
307
323
|
```bash
|
|
308
324
|
# 1. Set up meta repository
|
|
309
325
|
gitzone meta init
|
|
@@ -318,6 +334,7 @@ gitzone meta update
|
|
|
318
334
|
```
|
|
319
335
|
|
|
320
336
|
### Safe Formatting with Rollback
|
|
337
|
+
|
|
321
338
|
```bash
|
|
322
339
|
# 1. Preview changes
|
|
323
340
|
gitzone format --dry-run
|
|
@@ -335,17 +352,20 @@ gitzone format --rollback
|
|
|
335
352
|
## 🔌 Integrations
|
|
336
353
|
|
|
337
354
|
### CI/CD Platforms
|
|
355
|
+
|
|
338
356
|
- **GitLab CI** - Full pipeline support with templates
|
|
339
357
|
- **GitHub Actions** - Automated workflows
|
|
340
358
|
- **Docker** - Container-based deployments
|
|
341
359
|
|
|
342
360
|
### Development Tools
|
|
361
|
+
|
|
343
362
|
- **TypeScript** - First-class support
|
|
344
363
|
- **Prettier** - Code formatting
|
|
345
364
|
- **ESLint** - Linting (via format modules)
|
|
346
365
|
- **npm/pnpm** - Package management
|
|
347
366
|
|
|
348
367
|
### Version Control
|
|
368
|
+
|
|
349
369
|
- **Git** - Deep integration
|
|
350
370
|
- **Semantic Versioning** - Automatic version bumping
|
|
351
371
|
- **Conventional Commits** - Standardized commit messages
|
|
@@ -361,19 +381,25 @@ gitzone format --rollback
|
|
|
361
381
|
## 🐛 Troubleshooting
|
|
362
382
|
|
|
363
383
|
### Format Command Shows "Cancelled"
|
|
384
|
+
|
|
364
385
|
If the format command shows cancelled even after confirming:
|
|
386
|
+
|
|
365
387
|
- Check your `npmextra.json` configuration
|
|
366
388
|
- Try with `--yes` flag to skip confirmation
|
|
367
389
|
- Use `--verbose` for detailed output
|
|
368
390
|
|
|
369
391
|
### Docker Commands Fail
|
|
392
|
+
|
|
370
393
|
Ensure Docker daemon is running:
|
|
394
|
+
|
|
371
395
|
```bash
|
|
372
396
|
docker info
|
|
373
397
|
```
|
|
374
398
|
|
|
375
399
|
### Template Creation Issues
|
|
400
|
+
|
|
376
401
|
Verify npm/pnpm is properly configured:
|
|
402
|
+
|
|
377
403
|
```bash
|
|
378
404
|
npm config get registry
|
|
379
405
|
```
|
|
@@ -381,6 +407,7 @@ npm config get registry
|
|
|
381
407
|
## 📈 Performance
|
|
382
408
|
|
|
383
409
|
gitzone is optimized for speed:
|
|
410
|
+
|
|
384
411
|
- **Parallel processing** for format operations
|
|
385
412
|
- **Smart caching** to avoid redundant work
|
|
386
413
|
- **Incremental updates** for meta repositories
|
|
@@ -388,7 +415,7 @@ gitzone is optimized for speed:
|
|
|
388
415
|
|
|
389
416
|
## License and Legal Information
|
|
390
417
|
|
|
391
|
-
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
|
418
|
+
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
|
392
419
|
|
|
393
420
|
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
|
394
421
|
|
|
@@ -403,4 +430,4 @@ Registered at District court Bremen HRB 35230 HB, Germany
|
|
|
403
430
|
|
|
404
431
|
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
|
405
432
|
|
|
406
|
-
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
|
433
|
+
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
package/readme.plan.md
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
Please reread /home/philkunz/.claude/CLAUDE.md before proceeding with any implementation.
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
|
+
|
|
6
7
|
This plan outlines improvements for the gitzone format module to enhance its functionality, reliability, and maintainability.
|
|
7
8
|
|
|
8
9
|
## Phase 1: Core Improvements (High Priority) - COMPLETED ✅
|
|
9
10
|
|
|
10
11
|
### 1. Enhanced Error Handling & Recovery ✅
|
|
12
|
+
|
|
11
13
|
- [x] Implement rollback mechanism for failed format operations
|
|
12
14
|
- [x] Add detailed error messages with recovery suggestions
|
|
13
15
|
- [x] Create a `--dry-run` flag to preview changes before applying
|
|
@@ -15,12 +17,14 @@ This plan outlines improvements for the gitzone format module to enhance its fun
|
|
|
15
17
|
- [x] Implement plan → action workflow as default behavior
|
|
16
18
|
|
|
17
19
|
### 2. Complete Missing Functionality ✅
|
|
20
|
+
|
|
18
21
|
- [x] Implement the `ensureDependency` function in format.packagejson.ts
|
|
19
22
|
- [x] Develop the copy module for file pattern-based copying
|
|
20
23
|
- [x] Add dependency version constraint management
|
|
21
24
|
- [x] Support workspace/monorepo configurations (via configuration)
|
|
22
25
|
|
|
23
26
|
### 3. Configuration & Flexibility ✅
|
|
27
|
+
|
|
24
28
|
- [x] Extend npmextra.json gitzone configuration section
|
|
25
29
|
- [x] Allow custom license exclusion/inclusion lists
|
|
26
30
|
- [x] Make format steps configurable (skip/include specific modules)
|
|
@@ -28,6 +32,7 @@ This plan outlines improvements for the gitzone format module to enhance its fun
|
|
|
28
32
|
- [x] Add format profiles for different project types
|
|
29
33
|
|
|
30
34
|
### 4. Architecture Changes ✅
|
|
35
|
+
|
|
31
36
|
- [x] Introduce a `FormatContext` class to manage state across modules
|
|
32
37
|
- [x] Create abstract `BaseFormatter` class for consistent module structure
|
|
33
38
|
- [x] Implement event system for inter-module communication (via context)
|
|
@@ -37,12 +42,14 @@ This plan outlines improvements for the gitzone format module to enhance its fun
|
|
|
37
42
|
## Phase 2: Performance & Reporting (Medium Priority) - COMPLETED ✅
|
|
38
43
|
|
|
39
44
|
### 5. Performance Optimizations ✅
|
|
45
|
+
|
|
40
46
|
- [x] Implement parallel execution for independent format modules
|
|
41
47
|
- [x] Add file change detection to skip unchanged files
|
|
42
48
|
- [x] Create format cache to track last formatted state
|
|
43
49
|
- [x] Optimize Prettier runs by batching files
|
|
44
50
|
|
|
45
51
|
### 6. Enhanced Reporting & Visibility ✅
|
|
52
|
+
|
|
46
53
|
- [x] Generate comprehensive format report showing all changes
|
|
47
54
|
- [x] Add diff view for file modifications
|
|
48
55
|
- [x] Create verbose logging option
|
|
@@ -51,30 +58,35 @@ This plan outlines improvements for the gitzone format module to enhance its fun
|
|
|
51
58
|
## Phase 3: Advanced Features (Lower Priority) - PARTIALLY COMPLETED
|
|
52
59
|
|
|
53
60
|
### 7. Better Integration & Extensibility ⏳
|
|
61
|
+
|
|
54
62
|
- [ ] Create plugin system for custom format modules
|
|
55
63
|
- [ ] Add hooks for pre/post format operations
|
|
56
64
|
- [ ] Support custom validation rules
|
|
57
65
|
- [ ] Integrate with git hooks for pre-commit formatting
|
|
58
66
|
|
|
59
67
|
### 8. Improved Template Integration ⏳
|
|
68
|
+
|
|
60
69
|
- [ ] Better error handling when smartscaf operations fail
|
|
61
70
|
- [ ] Add pre/post template hooks for custom processing
|
|
62
71
|
- [ ] Validate template results before proceeding with format
|
|
63
72
|
- [ ] Support skipping template updates via configuration
|
|
64
73
|
|
|
65
74
|
### 9. Enhanced License Management ⏳
|
|
75
|
+
|
|
66
76
|
- [ ] Make license checking configurable (partial)
|
|
67
77
|
- [ ] Add license compatibility matrix
|
|
68
78
|
- [x] Support license exceptions for specific packages
|
|
69
79
|
- [ ] Generate license report for compliance
|
|
70
80
|
|
|
71
81
|
### 10. Better Package.json Management ⏳
|
|
82
|
+
|
|
72
83
|
- [ ] Smart dependency sorting and grouping
|
|
73
84
|
- [ ] Automated script generation based on project type
|
|
74
85
|
- [ ] Support for pnpm workspace configurations
|
|
75
86
|
- [ ] Validation of package.json schema
|
|
76
87
|
|
|
77
88
|
### 11. Quality of Life Improvements ⏳
|
|
89
|
+
|
|
78
90
|
- [ ] Interactive mode for format configuration
|
|
79
91
|
- [ ] Undo/redo capability for format operations
|
|
80
92
|
- [ ] Format presets for common scenarios
|
|
@@ -85,28 +97,33 @@ This plan outlines improvements for the gitzone format module to enhance its fun
|
|
|
85
97
|
### ✅ Completed Features
|
|
86
98
|
|
|
87
99
|
1. **Rollback Mechanism**
|
|
100
|
+
|
|
88
101
|
- Full backup/restore functionality
|
|
89
102
|
- Manifest tracking and integrity checks
|
|
90
103
|
- CLI commands for rollback operations
|
|
91
104
|
|
|
92
105
|
2. **Plan → Action Workflow**
|
|
106
|
+
|
|
93
107
|
- Two-phase approach (analyze then execute)
|
|
94
108
|
- Interactive confirmation
|
|
95
109
|
- Dry-run support
|
|
96
110
|
|
|
97
111
|
3. **Configuration System**
|
|
112
|
+
|
|
98
113
|
- Comprehensive npmextra.json support
|
|
99
114
|
- Module control (skip/only/order)
|
|
100
115
|
- Cache configuration
|
|
101
116
|
- Parallel execution settings
|
|
102
117
|
|
|
103
118
|
4. **Performance Improvements**
|
|
119
|
+
|
|
104
120
|
- Parallel execution by dependency analysis
|
|
105
121
|
- File change caching
|
|
106
122
|
- Prettier batching
|
|
107
123
|
- Execution time tracking
|
|
108
124
|
|
|
109
125
|
5. **Reporting & Statistics**
|
|
126
|
+
|
|
110
127
|
- Detailed diff views
|
|
111
128
|
- Execution statistics
|
|
112
129
|
- Verbose logging mode
|
|
@@ -121,6 +138,7 @@ This plan outlines improvements for the gitzone format module to enhance its fun
|
|
|
121
138
|
### 🚧 Partially Completed
|
|
122
139
|
|
|
123
140
|
1. **License Management**
|
|
141
|
+
|
|
124
142
|
- Basic configuration support
|
|
125
143
|
- Exception handling for specific packages
|
|
126
144
|
- Need: compatibility matrix, compliance reports
|
|
@@ -132,11 +150,13 @@ This plan outlines improvements for the gitzone format module to enhance its fun
|
|
|
132
150
|
### ⏳ Not Started
|
|
133
151
|
|
|
134
152
|
1. **Plugin System**
|
|
153
|
+
|
|
135
154
|
- Need to design plugin API
|
|
136
155
|
- Hook system for pre/post operations
|
|
137
156
|
- Custom validation rules
|
|
138
157
|
|
|
139
158
|
2. **Git Integration**
|
|
159
|
+
|
|
140
160
|
- Pre-commit hooks
|
|
141
161
|
- Automatic formatting on commit
|
|
142
162
|
|
|
@@ -167,4 +187,4 @@ This plan outlines improvements for the gitzone format module to enhance its fun
|
|
|
167
187
|
- ✅ Faster execution through parallel processing and caching
|
|
168
188
|
- ✅ Enhanced user control through configuration
|
|
169
189
|
- ✅ Better visibility through reporting and statistics
|
|
170
|
-
- ✅ Improved maintainability through better architecture
|
|
190
|
+
- ✅ Improved maintainability through better architecture
|
package/ts/00_commitinfo_data.ts
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@git.zone/cli',
|
|
6
|
-
version: '1.16.
|
|
6
|
+
version: '1.16.9',
|
|
7
7
|
description: 'A comprehensive CLI tool for enhancing and managing local development workflows with gitzone utilities, focusing on project setup, version control, code formatting, and template management.'
|
|
8
8
|
}
|
|
@@ -2,32 +2,29 @@ import * as plugins from './mod.plugins.js';
|
|
|
2
2
|
import { FormatContext } from './classes.formatcontext.js';
|
|
3
3
|
import type { IPlannedChange } from './interfaces.format.js';
|
|
4
4
|
import { Project } from '../classes.project.js';
|
|
5
|
-
import { ChangeCache } from './classes.changecache.js';
|
|
6
5
|
|
|
7
6
|
export abstract class BaseFormatter {
|
|
8
7
|
protected context: FormatContext;
|
|
9
8
|
protected project: Project;
|
|
10
|
-
protected cache: ChangeCache;
|
|
11
9
|
protected stats: any; // Will be FormatStats from context
|
|
12
|
-
|
|
10
|
+
|
|
13
11
|
constructor(context: FormatContext, project: Project) {
|
|
14
12
|
this.context = context;
|
|
15
13
|
this.project = project;
|
|
16
|
-
this.cache = context.getChangeCache();
|
|
17
14
|
this.stats = context.getFormatStats();
|
|
18
15
|
}
|
|
19
|
-
|
|
16
|
+
|
|
20
17
|
abstract get name(): string;
|
|
21
18
|
abstract analyze(): Promise<IPlannedChange[]>;
|
|
22
19
|
abstract applyChange(change: IPlannedChange): Promise<void>;
|
|
23
|
-
|
|
20
|
+
|
|
24
21
|
async execute(changes: IPlannedChange[]): Promise<void> {
|
|
25
22
|
const startTime = this.stats.moduleStartTime(this.name);
|
|
26
23
|
this.stats.startModule(this.name);
|
|
27
|
-
|
|
24
|
+
|
|
28
25
|
try {
|
|
29
26
|
await this.preExecute();
|
|
30
|
-
|
|
27
|
+
|
|
31
28
|
for (const change of changes) {
|
|
32
29
|
try {
|
|
33
30
|
await this.applyChange(change);
|
|
@@ -37,57 +34,49 @@ export abstract class BaseFormatter {
|
|
|
37
34
|
throw error;
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
|
-
|
|
37
|
+
|
|
41
38
|
await this.postExecute();
|
|
42
39
|
} catch (error) {
|
|
43
|
-
|
|
40
|
+
// Don't rollback here - let the FormatPlanner handle it
|
|
44
41
|
throw error;
|
|
45
42
|
} finally {
|
|
46
43
|
this.stats.endModule(this.name, startTime);
|
|
47
44
|
}
|
|
48
45
|
}
|
|
49
|
-
|
|
46
|
+
|
|
50
47
|
protected async preExecute(): Promise<void> {
|
|
51
48
|
// Override in subclasses if needed
|
|
52
49
|
}
|
|
53
|
-
|
|
50
|
+
|
|
54
51
|
protected async postExecute(): Promise<void> {
|
|
55
52
|
// Override in subclasses if needed
|
|
56
53
|
}
|
|
57
|
-
|
|
54
|
+
|
|
58
55
|
protected async modifyFile(filepath: string, content: string): Promise<void> {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
// Validate filepath before writing
|
|
57
|
+
if (!filepath || filepath.trim() === '') {
|
|
58
|
+
throw new Error(`Invalid empty filepath in modifyFile`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Ensure we have a proper path with directory component
|
|
62
|
+
// If the path has no directory component (e.g., "package.json"), prepend "./"
|
|
63
|
+
let normalizedPath = filepath;
|
|
64
|
+
if (!plugins.path.parse(filepath).dir) {
|
|
65
|
+
normalizedPath = './' + filepath;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
await plugins.smartfile.memory.toFs(content, normalizedPath);
|
|
62
69
|
}
|
|
63
|
-
|
|
70
|
+
|
|
64
71
|
protected async createFile(filepath: string, content: string): Promise<void> {
|
|
65
72
|
await plugins.smartfile.memory.toFs(content, filepath);
|
|
66
|
-
await this.cache.updateFileCache(filepath);
|
|
67
73
|
}
|
|
68
|
-
|
|
74
|
+
|
|
69
75
|
protected async deleteFile(filepath: string): Promise<void> {
|
|
70
|
-
await this.context.trackFileChange(filepath);
|
|
71
76
|
await plugins.smartfile.fs.remove(filepath);
|
|
72
77
|
}
|
|
73
|
-
|
|
78
|
+
|
|
74
79
|
protected async shouldProcessFile(filepath: string): Promise<boolean> {
|
|
75
|
-
|
|
76
|
-
const useCache = config.dataFor('gitzone.format.cache.enabled', true);
|
|
77
|
-
|
|
78
|
-
if (!useCache) {
|
|
79
|
-
return true; // Process all files if cache is disabled
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const hasChanged = await this.cache.hasFileChanged(filepath);
|
|
83
|
-
|
|
84
|
-
// Record cache statistics
|
|
85
|
-
if (hasChanged) {
|
|
86
|
-
this.stats.recordCacheMiss();
|
|
87
|
-
} else {
|
|
88
|
-
this.stats.recordCacheHit();
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return hasChanged;
|
|
80
|
+
return true;
|
|
92
81
|
}
|
|
93
|
-
}
|
|
82
|
+
}
|