@git.zone/cli 1.16.7 → 1.16.8

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 (68) hide show
  1. package/dist_ts/00_commitinfo_data.js +1 -1
  2. package/dist_ts/mod_format/classes.baseformatter.d.ts +0 -2
  3. package/dist_ts/mod_format/classes.baseformatter.js +3 -22
  4. package/dist_ts/mod_format/classes.changecache.js +14 -29
  5. package/dist_ts/mod_format/classes.dependency-analyzer.js +24 -18
  6. package/dist_ts/mod_format/classes.diffreporter.js +4 -4
  7. package/dist_ts/mod_format/classes.formatcontext.d.ts +0 -13
  8. package/dist_ts/mod_format/classes.formatcontext.js +1 -41
  9. package/dist_ts/mod_format/classes.formatplanner.js +25 -45
  10. package/dist_ts/mod_format/classes.formatstats.js +22 -20
  11. package/dist_ts/mod_format/classes.rollbackmanager.js +20 -32
  12. package/dist_ts/mod_format/format.cleanup.js +7 -2
  13. package/dist_ts/mod_format/format.copy.d.ts +1 -1
  14. package/dist_ts/mod_format/format.copy.js +3 -3
  15. package/dist_ts/mod_format/format.gitignore.js +1 -1
  16. package/dist_ts/mod_format/format.license.js +1 -1
  17. package/dist_ts/mod_format/format.npmextra.js +1 -1
  18. package/dist_ts/mod_format/format.packagejson.js +5 -3
  19. package/dist_ts/mod_format/format.prettier.js +7 -2
  20. package/dist_ts/mod_format/format.readme.js +1 -1
  21. package/dist_ts/mod_format/format.templates.js +1 -1
  22. package/dist_ts/mod_format/format.tsconfig.js +4 -2
  23. package/dist_ts/mod_format/formatters/cleanup.formatter.js +8 -3
  24. package/dist_ts/mod_format/formatters/legacy.formatter.js +6 -4
  25. package/dist_ts/mod_format/formatters/prettier.formatter.js +9 -16
  26. package/dist_ts/mod_format/formatters/readme.formatter.js +6 -4
  27. package/dist_ts/mod_format/index.js +13 -71
  28. package/dist_ts/mod_meta/meta.classes.meta.js +1 -1
  29. package/dist_ts/mod_standard/index.js +1 -1
  30. package/dist_ts/mod_start/index.js +1 -1
  31. package/dist_ts/mod_template/index.js +1 -1
  32. package/package.json +1 -1
  33. package/ts/00_commitinfo_data.ts +1 -1
  34. package/ts/mod_format/classes.baseformatter.ts +15 -38
  35. package/ts/mod_format/classes.changecache.ts +74 -80
  36. package/ts/mod_format/classes.dependency-analyzer.ts +46 -36
  37. package/ts/mod_format/classes.diffreporter.ts +44 -28
  38. package/ts/mod_format/classes.formatcontext.ts +3 -54
  39. package/ts/mod_format/classes.formatplanner.ts +56 -70
  40. package/ts/mod_format/classes.formatstats.ts +69 -49
  41. package/ts/mod_format/classes.rollbackmanager.ts +123 -103
  42. package/ts/mod_format/format.cleanup.ts +9 -2
  43. package/ts/mod_format/format.copy.ts +17 -14
  44. package/ts/mod_format/format.gitignore.ts +2 -1
  45. package/ts/mod_format/format.license.ts +3 -1
  46. package/ts/mod_format/format.npmextra.ts +9 -2
  47. package/ts/mod_format/format.packagejson.ts +47 -12
  48. package/ts/mod_format/format.prettier.ts +10 -2
  49. package/ts/mod_format/format.readme.ts +2 -1
  50. package/ts/mod_format/format.templates.ts +15 -7
  51. package/ts/mod_format/format.tsconfig.ts +6 -2
  52. package/ts/mod_format/formatters/cleanup.formatter.ts +13 -8
  53. package/ts/mod_format/formatters/copy.formatter.ts +1 -1
  54. package/ts/mod_format/formatters/gitignore.formatter.ts +1 -1
  55. package/ts/mod_format/formatters/legacy.formatter.ts +19 -12
  56. package/ts/mod_format/formatters/license.formatter.ts +1 -1
  57. package/ts/mod_format/formatters/npmextra.formatter.ts +1 -1
  58. package/ts/mod_format/formatters/packagejson.formatter.ts +1 -1
  59. package/ts/mod_format/formatters/prettier.formatter.ts +50 -47
  60. package/ts/mod_format/formatters/readme.formatter.ts +11 -9
  61. package/ts/mod_format/formatters/templates.formatter.ts +1 -1
  62. package/ts/mod_format/formatters/tsconfig.formatter.ts +1 -1
  63. package/ts/mod_format/index.ts +54 -113
  64. package/ts/mod_format/interfaces.format.ts +3 -3
  65. package/ts/mod_meta/meta.classes.meta.ts +57 -19
  66. package/ts/mod_standard/index.ts +3 -1
  67. package/ts/mod_start/index.ts +3 -1
  68. package/ts/mod_template/index.ts +5 -2
@@ -10,7 +10,7 @@ export class FormatPlanner {
10
10
  private plannedChanges: Map<string, IPlannedChange[]> = new Map();
11
11
  private dependencyAnalyzer = new DependencyAnalyzer();
12
12
  private diffReporter = new DiffReporter();
13
-
13
+
14
14
  async planFormat(modules: BaseFormatter[]): Promise<IFormatPlan> {
15
15
  const plan: IFormatPlan = {
16
16
  summary: {
@@ -18,20 +18,20 @@ export class FormatPlanner {
18
18
  filesAdded: 0,
19
19
  filesModified: 0,
20
20
  filesRemoved: 0,
21
- estimatedTime: 0
21
+ estimatedTime: 0,
22
22
  },
23
23
  changes: [],
24
- warnings: []
24
+ warnings: [],
25
25
  };
26
-
26
+
27
27
  for (const module of modules) {
28
28
  try {
29
29
  const changes = await module.analyze();
30
30
  this.plannedChanges.set(module.name, changes);
31
-
31
+
32
32
  for (const change of changes) {
33
33
  plan.changes.push(change);
34
-
34
+
35
35
  // Update summary
36
36
  switch (change.type) {
37
37
  case 'create':
@@ -49,67 +49,51 @@ export class FormatPlanner {
49
49
  plan.warnings.push({
50
50
  level: 'error',
51
51
  message: `Failed to analyze module ${module.name}: ${error.message}`,
52
- module: module.name
52
+ module: module.name,
53
53
  });
54
54
  }
55
55
  }
56
-
57
- plan.summary.totalFiles = plan.summary.filesAdded + plan.summary.filesModified + plan.summary.filesRemoved;
56
+
57
+ plan.summary.totalFiles =
58
+ plan.summary.filesAdded +
59
+ plan.summary.filesModified +
60
+ plan.summary.filesRemoved;
58
61
  plan.summary.estimatedTime = plan.summary.totalFiles * 100; // 100ms per file estimate
59
-
62
+
60
63
  return plan;
61
64
  }
62
-
63
- async executePlan(plan: IFormatPlan, modules: BaseFormatter[], context: FormatContext, parallel: boolean = true): Promise<void> {
64
- await context.beginOperation();
65
+
66
+ async executePlan(
67
+ plan: IFormatPlan,
68
+ modules: BaseFormatter[],
69
+ context: FormatContext,
70
+ parallel: boolean = false,
71
+ ): Promise<void> {
65
72
  const startTime = Date.now();
66
-
73
+
67
74
  try {
68
- if (parallel) {
69
- // Get execution groups based on dependencies
70
- const executionGroups = this.dependencyAnalyzer.getExecutionGroups(modules);
71
-
72
- logger.log('info', `Executing formatters in ${executionGroups.length} groups...`);
73
-
74
- for (let i = 0; i < executionGroups.length; i++) {
75
- const group = executionGroups[i];
76
- logger.log('info', `Executing group ${i + 1}: ${group.map(m => m.name).join(', ')}`);
77
-
78
- // Execute modules in this group in parallel
79
- const promises = group.map(async (module) => {
80
- const changes = this.plannedChanges.get(module.name) || [];
81
- if (changes.length > 0) {
82
- logger.log('info', `Executing ${module.name} formatter...`);
83
- await module.execute(changes);
84
- }
85
- });
86
-
87
- await Promise.all(promises);
88
- }
89
- } else {
90
- // Sequential execution (original implementation)
91
- for (const module of modules) {
92
- const changes = this.plannedChanges.get(module.name) || [];
93
-
94
- if (changes.length > 0) {
95
- logger.log('info', `Executing ${module.name} formatter...`);
96
- await module.execute(changes);
97
- }
75
+ // Always use sequential execution to avoid race conditions
76
+ for (const module of modules) {
77
+ const changes = this.plannedChanges.get(module.name) || [];
78
+
79
+ if (changes.length > 0) {
80
+ logger.log('info', `Executing ${module.name} formatter...`);
81
+ await module.execute(changes);
98
82
  }
99
83
  }
100
-
84
+
101
85
  const endTime = Date.now();
102
86
  const duration = endTime - startTime;
103
87
  logger.log('info', `Format operations completed in ${duration}ms`);
104
-
105
- await context.commitOperation();
106
88
  } catch (error) {
107
- await context.rollbackOperation();
108
89
  throw error;
109
90
  }
110
91
  }
111
-
112
- async displayPlan(plan: IFormatPlan, detailed: boolean = false): Promise<void> {
92
+
93
+ async displayPlan(
94
+ plan: IFormatPlan,
95
+ detailed: boolean = false,
96
+ ): Promise<void> {
113
97
  console.log('\nFormat Plan:');
114
98
  console.log('━'.repeat(50));
115
99
  console.log(`Summary: ${plan.summary.totalFiles} files will be changed`);
@@ -118,7 +102,7 @@ export class FormatPlanner {
118
102
  console.log(` • ${plan.summary.filesRemoved} deleted files`);
119
103
  console.log('');
120
104
  console.log('Changes by module:');
121
-
105
+
122
106
  // Group changes by module
123
107
  const changesByModule = new Map<string, IPlannedChange[]>();
124
108
  for (const change of plan.changes) {
@@ -126,14 +110,16 @@ export class FormatPlanner {
126
110
  moduleChanges.push(change);
127
111
  changesByModule.set(change.module, moduleChanges);
128
112
  }
129
-
113
+
130
114
  for (const [module, changes] of changesByModule) {
131
- console.log(`\n${this.getModuleIcon(module)} ${module} (${changes.length} ${changes.length === 1 ? 'file' : 'files'})`);
132
-
115
+ console.log(
116
+ `\n${this.getModuleIcon(module)} ${module} (${changes.length} ${changes.length === 1 ? 'file' : 'files'})`,
117
+ );
118
+
133
119
  for (const change of changes) {
134
120
  const icon = this.getChangeIcon(change.type);
135
121
  console.log(` ${icon} ${change.path} - ${change.description}`);
136
-
122
+
137
123
  // Show diff for modified files if detailed view is requested
138
124
  if (detailed && change.type === 'modify') {
139
125
  const diff = await this.diffReporter.generateDiffForChange(change);
@@ -143,7 +129,7 @@ export class FormatPlanner {
143
129
  }
144
130
  }
145
131
  }
146
-
132
+
147
133
  if (plan.warnings.length > 0) {
148
134
  console.log('\nWarnings:');
149
135
  for (const warning of plan.warnings) {
@@ -151,26 +137,26 @@ export class FormatPlanner {
151
137
  console.log(` ${icon} ${warning.message}`);
152
138
  }
153
139
  }
154
-
140
+
155
141
  console.log('\n' + '━'.repeat(50));
156
142
  }
157
-
143
+
158
144
  private getModuleIcon(module: string): string {
159
145
  const icons: Record<string, string> = {
160
- 'packagejson': 'šŸ“¦',
161
- 'license': 'šŸ“',
162
- 'tsconfig': 'šŸ”§',
163
- 'cleanup': '🚮',
164
- 'gitignore': 'šŸ”’',
165
- 'prettier': '✨',
166
- 'readme': 'šŸ“–',
167
- 'templates': 'šŸ“„',
168
- 'npmextra': 'āš™ļø',
169
- 'copy': 'šŸ“‹'
146
+ packagejson: 'šŸ“¦',
147
+ license: 'šŸ“',
148
+ tsconfig: 'šŸ”§',
149
+ cleanup: '🚮',
150
+ gitignore: 'šŸ”’',
151
+ prettier: '✨',
152
+ readme: 'šŸ“–',
153
+ templates: 'šŸ“„',
154
+ npmextra: 'āš™ļø',
155
+ copy: 'šŸ“‹',
170
156
  };
171
157
  return icons[module] || 'šŸ“';
172
158
  }
173
-
159
+
174
160
  private getChangeIcon(type: 'create' | 'modify' | 'delete'): string {
175
161
  switch (type) {
176
162
  case 'create':
@@ -181,4 +167,4 @@ export class FormatPlanner {
181
167
  return 'āŒ';
182
168
  }
183
169
  }
184
- }
170
+ }
@@ -30,7 +30,7 @@ export interface IFormatStats {
30
30
 
31
31
  export class FormatStats {
32
32
  private stats: IFormatStats;
33
-
33
+
34
34
  constructor() {
35
35
  this.stats = {
36
36
  totalExecutionTime: 0,
@@ -44,11 +44,11 @@ export class FormatStats {
44
44
  totalDeleted: 0,
45
45
  totalErrors: 0,
46
46
  cacheHits: 0,
47
- cacheMisses: 0
48
- }
47
+ cacheMisses: 0,
48
+ },
49
49
  };
50
50
  }
51
-
51
+
52
52
  startModule(moduleName: string): void {
53
53
  this.stats.moduleStats.set(moduleName, {
54
54
  name: moduleName,
@@ -58,31 +58,35 @@ export class FormatStats {
58
58
  successes: 0,
59
59
  filesCreated: 0,
60
60
  filesModified: 0,
61
- filesDeleted: 0
61
+ filesDeleted: 0,
62
62
  });
63
63
  }
64
-
64
+
65
65
  moduleStartTime(moduleName: string): number {
66
66
  return Date.now();
67
67
  }
68
-
68
+
69
69
  endModule(moduleName: string, startTime: number): void {
70
70
  const moduleStats = this.stats.moduleStats.get(moduleName);
71
71
  if (moduleStats) {
72
72
  moduleStats.executionTime = Date.now() - startTime;
73
73
  }
74
74
  }
75
-
76
- recordFileOperation(moduleName: string, operation: 'create' | 'modify' | 'delete', success: boolean = true): void {
75
+
76
+ recordFileOperation(
77
+ moduleName: string,
78
+ operation: 'create' | 'modify' | 'delete',
79
+ success: boolean = true,
80
+ ): void {
77
81
  const moduleStats = this.stats.moduleStats.get(moduleName);
78
82
  if (!moduleStats) return;
79
-
83
+
80
84
  moduleStats.filesProcessed++;
81
-
85
+
82
86
  if (success) {
83
87
  moduleStats.successes++;
84
88
  this.stats.overallStats.totalFiles++;
85
-
89
+
86
90
  switch (operation) {
87
91
  case 'create':
88
92
  moduleStats.filesCreated++;
@@ -102,53 +106,66 @@ export class FormatStats {
102
106
  this.stats.overallStats.totalErrors++;
103
107
  }
104
108
  }
105
-
109
+
106
110
  recordCacheHit(): void {
107
111
  this.stats.overallStats.cacheHits++;
108
112
  }
109
-
113
+
110
114
  recordCacheMiss(): void {
111
115
  this.stats.overallStats.cacheMisses++;
112
116
  }
113
-
117
+
114
118
  finish(): void {
115
119
  this.stats.endTime = Date.now();
116
120
  this.stats.totalExecutionTime = this.stats.endTime - this.stats.startTime;
117
121
  }
118
-
122
+
119
123
  displayStats(): void {
120
124
  console.log('\nšŸ“Š Format Operation Statistics:');
121
125
  console.log('═'.repeat(50));
122
-
126
+
123
127
  // Overall stats
124
128
  console.log('\nOverall Summary:');
125
- console.log(` Total Execution Time: ${this.formatDuration(this.stats.totalExecutionTime)}`);
129
+ console.log(
130
+ ` Total Execution Time: ${this.formatDuration(this.stats.totalExecutionTime)}`,
131
+ );
126
132
  console.log(` Files Processed: ${this.stats.overallStats.totalFiles}`);
127
133
  console.log(` • Created: ${this.stats.overallStats.totalCreated}`);
128
134
  console.log(` • Modified: ${this.stats.overallStats.totalModified}`);
129
135
  console.log(` • Deleted: ${this.stats.overallStats.totalDeleted}`);
130
136
  console.log(` Errors: ${this.stats.overallStats.totalErrors}`);
131
-
132
- if (this.stats.overallStats.cacheHits > 0 || this.stats.overallStats.cacheMisses > 0) {
133
- const cacheHitRate = this.stats.overallStats.cacheHits /
134
- (this.stats.overallStats.cacheHits + this.stats.overallStats.cacheMisses) * 100;
137
+
138
+ if (
139
+ this.stats.overallStats.cacheHits > 0 ||
140
+ this.stats.overallStats.cacheMisses > 0
141
+ ) {
142
+ const cacheHitRate =
143
+ (this.stats.overallStats.cacheHits /
144
+ (this.stats.overallStats.cacheHits +
145
+ this.stats.overallStats.cacheMisses)) *
146
+ 100;
135
147
  console.log(` Cache Hit Rate: ${cacheHitRate.toFixed(1)}%`);
136
148
  console.log(` • Hits: ${this.stats.overallStats.cacheHits}`);
137
149
  console.log(` • Misses: ${this.stats.overallStats.cacheMisses}`);
138
150
  }
139
-
151
+
140
152
  // Module stats
141
153
  console.log('\nModule Breakdown:');
142
154
  console.log('─'.repeat(50));
143
-
144
- const sortedModules = Array.from(this.stats.moduleStats.values())
145
- .sort((a, b) => b.filesProcessed - a.filesProcessed);
146
-
155
+
156
+ const sortedModules = Array.from(this.stats.moduleStats.values()).sort(
157
+ (a, b) => b.filesProcessed - a.filesProcessed,
158
+ );
159
+
147
160
  for (const moduleStats of sortedModules) {
148
- console.log(`\n${this.getModuleIcon(moduleStats.name)} ${moduleStats.name}:`);
149
- console.log(` Execution Time: ${this.formatDuration(moduleStats.executionTime)}`);
161
+ console.log(
162
+ `\n${this.getModuleIcon(moduleStats.name)} ${moduleStats.name}:`,
163
+ );
164
+ console.log(
165
+ ` Execution Time: ${this.formatDuration(moduleStats.executionTime)}`,
166
+ );
150
167
  console.log(` Files Processed: ${moduleStats.filesProcessed}`);
151
-
168
+
152
169
  if (moduleStats.filesCreated > 0) {
153
170
  console.log(` • Created: ${moduleStats.filesCreated}`);
154
171
  }
@@ -158,27 +175,30 @@ export class FormatStats {
158
175
  if (moduleStats.filesDeleted > 0) {
159
176
  console.log(` • Deleted: ${moduleStats.filesDeleted}`);
160
177
  }
161
-
178
+
162
179
  if (moduleStats.errors > 0) {
163
180
  console.log(` āŒ Errors: ${moduleStats.errors}`);
164
181
  }
165
182
  }
166
-
183
+
167
184
  console.log('\n' + '═'.repeat(50));
168
185
  }
169
-
186
+
170
187
  async saveReport(outputPath: string): Promise<void> {
171
188
  const report = {
172
189
  timestamp: new Date().toISOString(),
173
190
  executionTime: this.stats.totalExecutionTime,
174
191
  overallStats: this.stats.overallStats,
175
- moduleStats: Array.from(this.stats.moduleStats.values())
192
+ moduleStats: Array.from(this.stats.moduleStats.values()),
176
193
  };
177
-
178
- await plugins.smartfile.memory.toFs(JSON.stringify(report, null, 2), outputPath);
194
+
195
+ await plugins.smartfile.memory.toFs(
196
+ JSON.stringify(report, null, 2),
197
+ outputPath,
198
+ );
179
199
  logger.log('info', `Statistics report saved to ${outputPath}`);
180
200
  }
181
-
201
+
182
202
  private formatDuration(ms: number): string {
183
203
  if (ms < 1000) {
184
204
  return `${ms}ms`;
@@ -190,20 +210,20 @@ export class FormatStats {
190
210
  return `${minutes}m ${seconds}s`;
191
211
  }
192
212
  }
193
-
213
+
194
214
  private getModuleIcon(module: string): string {
195
215
  const icons: Record<string, string> = {
196
- 'packagejson': 'šŸ“¦',
197
- 'license': 'šŸ“',
198
- 'tsconfig': 'šŸ”§',
199
- 'cleanup': '🚮',
200
- 'gitignore': 'šŸ”’',
201
- 'prettier': '✨',
202
- 'readme': 'šŸ“–',
203
- 'templates': 'šŸ“„',
204
- 'npmextra': 'āš™ļø',
205
- 'copy': 'šŸ“‹'
216
+ packagejson: 'šŸ“¦',
217
+ license: 'šŸ“',
218
+ tsconfig: 'šŸ”§',
219
+ cleanup: '🚮',
220
+ gitignore: 'šŸ”’',
221
+ prettier: '✨',
222
+ readme: 'šŸ“–',
223
+ templates: 'šŸ“„',
224
+ npmextra: 'āš™ļø',
225
+ copy: 'šŸ“‹',
206
226
  };
207
227
  return icons[module] || 'šŸ“';
208
228
  }
209
- }
229
+ }