@git.zone/cli 2.13.8 → 2.13.11

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 (106) hide show
  1. package/assets/templates/gitignore/_gitignore +4 -0
  2. package/assets/templates/{npmextra/npmextra.json → smartconfig/_smartconfig.json} +3 -0
  3. package/dist_ts/00_commitinfo_data.js +2 -2
  4. package/dist_ts/classes.gitzoneconfig.js +4 -4
  5. package/dist_ts/gitzone.cli.js +1 -15
  6. package/dist_ts/mod_commit/index.js +4 -4
  7. package/dist_ts/mod_config/classes.commitconfig.d.ts +3 -3
  8. package/dist_ts/mod_config/classes.commitconfig.js +20 -20
  9. package/dist_ts/mod_config/classes.releaseconfig.d.ts +3 -3
  10. package/dist_ts/mod_config/classes.releaseconfig.js +21 -21
  11. package/dist_ts/mod_config/index.js +12 -12
  12. package/dist_ts/mod_format/classes.baseformatter.d.ts +2 -9
  13. package/dist_ts/mod_format/classes.baseformatter.js +13 -26
  14. package/dist_ts/mod_format/classes.formatplanner.d.ts +1 -3
  15. package/dist_ts/mod_format/classes.formatplanner.js +11 -39
  16. package/dist_ts/mod_format/classes.formatstats.d.ts +0 -5
  17. package/dist_ts/mod_format/classes.formatstats.js +3 -35
  18. package/dist_ts/mod_format/formatters/cleanup.formatter.js +1 -2
  19. package/dist_ts/mod_format/formatters/copy.formatter.js +5 -8
  20. package/dist_ts/mod_format/formatters/gitignore.formatter.d.ts +5 -0
  21. package/dist_ts/mod_format/formatters/gitignore.formatter.js +23 -29
  22. package/dist_ts/mod_format/formatters/packagejson.formatter.js +5 -5
  23. package/dist_ts/mod_format/formatters/prettier.formatter.js +4 -12
  24. package/dist_ts/mod_format/formatters/{npmextra.formatter.d.ts → smartconfig.formatter.d.ts} +6 -1
  25. package/dist_ts/mod_format/formatters/smartconfig.formatter.js +180 -0
  26. package/dist_ts/mod_format/formatters/templates.formatter.js +1 -10
  27. package/dist_ts/mod_format/formatters/tsconfig.formatter.js +6 -4
  28. package/dist_ts/mod_format/index.d.ts +0 -4
  29. package/dist_ts/mod_format/index.js +27 -78
  30. package/dist_ts/mod_format/interfaces.format.d.ts +1 -18
  31. package/dist_ts/mod_format/interfaces.format.js +16 -2
  32. package/dist_ts/mod_format/mod.plugins.d.ts +2 -7
  33. package/dist_ts/mod_format/mod.plugins.js +3 -8
  34. package/dist_ts/mod_services/classes.globalregistry.js +2 -2
  35. package/dist_ts/mod_services/classes.servicemanager.d.ts +2 -2
  36. package/dist_ts/mod_services/classes.servicemanager.js +21 -21
  37. package/dist_ts/plugins.d.ts +2 -2
  38. package/dist_ts/plugins.js +3 -3
  39. package/package.json +11 -17
  40. package/readme.md +231 -218
  41. package/ts/00_commitinfo_data.ts +1 -1
  42. package/ts/classes.gitzoneconfig.ts +3 -3
  43. package/ts/gitzone.cli.ts +0 -17
  44. package/ts/mod_commit/index.ts +3 -3
  45. package/ts/mod_config/classes.commitconfig.ts +19 -19
  46. package/ts/mod_config/classes.releaseconfig.ts +20 -20
  47. package/ts/mod_config/index.ts +11 -11
  48. package/ts/mod_format/classes.baseformatter.ts +14 -25
  49. package/ts/mod_format/classes.formatplanner.ts +10 -39
  50. package/ts/mod_format/classes.formatstats.ts +2 -42
  51. package/ts/mod_format/formatters/cleanup.formatter.ts +0 -1
  52. package/ts/mod_format/formatters/copy.formatter.ts +4 -8
  53. package/ts/mod_format/formatters/gitignore.formatter.ts +25 -29
  54. package/ts/mod_format/formatters/packagejson.formatter.ts +4 -4
  55. package/ts/mod_format/formatters/prettier.formatter.ts +3 -13
  56. package/ts/mod_format/formatters/smartconfig.formatter.ts +213 -0
  57. package/ts/mod_format/formatters/templates.formatter.ts +0 -9
  58. package/ts/mod_format/formatters/tsconfig.formatter.ts +6 -3
  59. package/ts/mod_format/index.ts +35 -98
  60. package/ts/mod_format/interfaces.format.ts +16 -19
  61. package/ts/mod_format/mod.plugins.ts +2 -12
  62. package/ts/mod_services/classes.globalregistry.ts +2 -2
  63. package/ts/mod_services/classes.servicemanager.ts +20 -20
  64. package/ts/plugins.ts +2 -2
  65. package/dist_ts/mod_format/classes.changecache.d.ts +0 -26
  66. package/dist_ts/mod_format/classes.changecache.js +0 -181
  67. package/dist_ts/mod_format/classes.dependency-analyzer.d.ts +0 -13
  68. package/dist_ts/mod_format/classes.dependency-analyzer.js +0 -93
  69. package/dist_ts/mod_format/classes.rollbackmanager.d.ts +0 -22
  70. package/dist_ts/mod_format/classes.rollbackmanager.js +0 -259
  71. package/dist_ts/mod_format/format.cleanup.d.ts +0 -2
  72. package/dist_ts/mod_format/format.cleanup.js +0 -25
  73. package/dist_ts/mod_format/format.copy.d.ts +0 -24
  74. package/dist_ts/mod_format/format.copy.js +0 -77
  75. package/dist_ts/mod_format/format.gitignore.d.ts +0 -2
  76. package/dist_ts/mod_format/format.gitignore.js +0 -48
  77. package/dist_ts/mod_format/format.license.d.ts +0 -2
  78. package/dist_ts/mod_format/format.license.js +0 -26
  79. package/dist_ts/mod_format/format.npmextra.d.ts +0 -5
  80. package/dist_ts/mod_format/format.npmextra.js +0 -125
  81. package/dist_ts/mod_format/format.packagejson.d.ts +0 -2
  82. package/dist_ts/mod_format/format.packagejson.js +0 -145
  83. package/dist_ts/mod_format/format.prettier.d.ts +0 -2
  84. package/dist_ts/mod_format/format.prettier.js +0 -56
  85. package/dist_ts/mod_format/format.readme.d.ts +0 -1
  86. package/dist_ts/mod_format/format.readme.js +0 -29
  87. package/dist_ts/mod_format/format.templates.d.ts +0 -5
  88. package/dist_ts/mod_format/format.templates.js +0 -68
  89. package/dist_ts/mod_format/format.tsconfig.d.ts +0 -2
  90. package/dist_ts/mod_format/format.tsconfig.js +0 -28
  91. package/dist_ts/mod_format/formatters/npmextra.formatter.js +0 -142
  92. package/ts/mod_format/classes.changecache.ts +0 -235
  93. package/ts/mod_format/classes.dependency-analyzer.ts +0 -117
  94. package/ts/mod_format/classes.rollbackmanager.ts +0 -340
  95. package/ts/mod_format/format.cleanup.ts +0 -26
  96. package/ts/mod_format/format.copy.ts +0 -93
  97. package/ts/mod_format/format.gitignore.ts +0 -54
  98. package/ts/mod_format/format.license.ts +0 -32
  99. package/ts/mod_format/format.npmextra.ts +0 -151
  100. package/ts/mod_format/format.packagejson.ts +0 -196
  101. package/ts/mod_format/format.prettier.ts +0 -66
  102. package/ts/mod_format/format.readme.ts +0 -29
  103. package/ts/mod_format/format.templates.ts +0 -79
  104. package/ts/mod_format/format.tsconfig.ts +0 -31
  105. package/ts/mod_format/formatters/npmextra.formatter.ts +0 -174
  106. /package/{npmextra.json → .smartconfig.json} +0 -0
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@git.zone/cli',
6
- version: '2.13.8',
6
+ version: '2.13.10',
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
  }
@@ -38,11 +38,11 @@ export class GitzoneConfig {
38
38
  public data: IGitzoneConfigData;
39
39
 
40
40
  public async readConfigFromCwd() {
41
- const npmextraInstance = new plugins.npmextra.Npmextra(paths.cwd);
42
- this.data = npmextraInstance.dataFor<IGitzoneConfigData>('@git.zone/cli', {});
41
+ const smartconfigInstance = new plugins.smartconfig.Smartconfig(paths.cwd);
42
+ this.data = smartconfigInstance.dataFor<IGitzoneConfigData>('@git.zone/cli', {});
43
43
 
44
44
  // Read szci config for backward compatibility
45
- const szciConfig = npmextraInstance.dataFor<any>('@ship.zone/szci', {});
45
+ const szciConfig = smartconfigInstance.dataFor<any>('@ship.zone/szci', {});
46
46
 
47
47
  // Prefer accessLevel from @git.zone/cli.release, fallback to @ship.zone/szci.npmAccessLevel
48
48
  const accessLevel =
package/ts/gitzone.cli.ts CHANGED
@@ -63,22 +63,6 @@ export let run = async () => {
63
63
  const config = GitzoneConfig.fromCwd();
64
64
  const modFormat = await import('./mod_format/index.js');
65
65
 
66
- // Handle rollback commands
67
- if (argvArg.rollback) {
68
- await modFormat.handleRollback(argvArg.rollback);
69
- return;
70
- }
71
-
72
- if (argvArg['list-backups']) {
73
- await modFormat.handleListBackups();
74
- return;
75
- }
76
-
77
- if (argvArg['clean-backups']) {
78
- await modFormat.handleCleanBackups();
79
- return;
80
- }
81
-
82
66
  // Handle format with options
83
67
  // Default is dry-mode, use --write/-w to apply changes
84
68
  await modFormat.run({
@@ -90,7 +74,6 @@ export let run = async () => {
90
74
  fromPlan: argvArg['from-plan'],
91
75
  detailed: argvArg.detailed,
92
76
  interactive: argvArg.interactive !== false,
93
- parallel: argvArg.parallel !== false,
94
77
  verbose: argvArg.verbose,
95
78
  diff: argvArg.diff,
96
79
  });
@@ -8,9 +8,9 @@ import * as ui from './mod.ui.js';
8
8
  import { ReleaseConfig } from '../mod_config/classes.releaseconfig.js';
9
9
 
10
10
  export const run = async (argvArg: any) => {
11
- // Read commit config from npmextra.json
12
- const npmextraConfig = new plugins.npmextra.Npmextra();
13
- const gitzoneConfig = npmextraConfig.dataFor<{
11
+ // Read commit config from .smartconfig.json
12
+ const smartconfigInstance = new plugins.smartconfig.Smartconfig();
13
+ const gitzoneConfig = smartconfigInstance.dataFor<{
14
14
  commit?: {
15
15
  alwaysTest?: boolean;
16
16
  alwaysBuild?: boolean;
@@ -6,7 +6,7 @@ export interface ICommitConfig {
6
6
  }
7
7
 
8
8
  /**
9
- * Manages commit configuration stored in npmextra.json
9
+ * Manages commit configuration stored in .smartconfig.json
10
10
  * under @git.zone/cli.commit namespace
11
11
  */
12
12
  export class CommitConfig {
@@ -28,11 +28,11 @@ export class CommitConfig {
28
28
  }
29
29
 
30
30
  /**
31
- * Load configuration from npmextra.json
31
+ * Load configuration from .smartconfig.json
32
32
  */
33
33
  public async load(): Promise<void> {
34
- const npmextraInstance = new plugins.npmextra.Npmextra(this.cwd);
35
- const gitzoneConfig = npmextraInstance.dataFor<any>('@git.zone/cli', {});
34
+ const smartconfigInstance = new plugins.smartconfig.Smartconfig(this.cwd);
35
+ const gitzoneConfig = smartconfigInstance.dataFor<any>('@git.zone/cli', {});
36
36
 
37
37
  this.config = {
38
38
  alwaysTest: gitzoneConfig?.commit?.alwaysTest ?? false,
@@ -41,37 +41,37 @@ export class CommitConfig {
41
41
  }
42
42
 
43
43
  /**
44
- * Save configuration to npmextra.json
44
+ * Save configuration to .smartconfig.json
45
45
  */
46
46
  public async save(): Promise<void> {
47
- const npmextraPath = plugins.path.join(this.cwd, 'npmextra.json');
48
- let npmextraData: any = {};
47
+ const smartconfigPath = plugins.path.join(this.cwd, '.smartconfig.json');
48
+ let smartconfigData: any = {};
49
49
 
50
- // Read existing npmextra.json
51
- if (await plugins.smartfs.file(npmextraPath).exists()) {
52
- const content = await plugins.smartfs.file(npmextraPath).encoding('utf8').read();
53
- npmextraData = JSON.parse(content as string);
50
+ // Read existing .smartconfig.json
51
+ if (await plugins.smartfs.file(smartconfigPath).exists()) {
52
+ const content = await plugins.smartfs.file(smartconfigPath).encoding('utf8').read();
53
+ smartconfigData = JSON.parse(content as string);
54
54
  }
55
55
 
56
56
  // Ensure @git.zone/cli namespace exists
57
- if (!npmextraData['@git.zone/cli']) {
58
- npmextraData['@git.zone/cli'] = {};
57
+ if (!smartconfigData['@git.zone/cli']) {
58
+ smartconfigData['@git.zone/cli'] = {};
59
59
  }
60
60
 
61
61
  // Ensure commit object exists
62
- if (!npmextraData['@git.zone/cli'].commit) {
63
- npmextraData['@git.zone/cli'].commit = {};
62
+ if (!smartconfigData['@git.zone/cli'].commit) {
63
+ smartconfigData['@git.zone/cli'].commit = {};
64
64
  }
65
65
 
66
66
  // Update commit settings
67
- npmextraData['@git.zone/cli'].commit.alwaysTest = this.config.alwaysTest;
68
- npmextraData['@git.zone/cli'].commit.alwaysBuild = this.config.alwaysBuild;
67
+ smartconfigData['@git.zone/cli'].commit.alwaysTest = this.config.alwaysTest;
68
+ smartconfigData['@git.zone/cli'].commit.alwaysBuild = this.config.alwaysBuild;
69
69
 
70
70
  // Write back to file
71
71
  await plugins.smartfs
72
- .file(npmextraPath)
72
+ .file(smartconfigPath)
73
73
  .encoding('utf8')
74
- .write(JSON.stringify(npmextraData, null, 2));
74
+ .write(JSON.stringify(smartconfigData, null, 2));
75
75
  }
76
76
 
77
77
  /**
@@ -8,7 +8,7 @@ export interface IReleaseConfig {
8
8
  }
9
9
 
10
10
  /**
11
- * Manages release configuration stored in npmextra.json
11
+ * Manages release configuration stored in .smartconfig.json
12
12
  * under @git.zone/cli.release namespace
13
13
  */
14
14
  export class ReleaseConfig {
@@ -30,14 +30,14 @@ export class ReleaseConfig {
30
30
  }
31
31
 
32
32
  /**
33
- * Load configuration from npmextra.json
33
+ * Load configuration from .smartconfig.json
34
34
  */
35
35
  public async load(): Promise<void> {
36
- const npmextraInstance = new plugins.npmextra.Npmextra(this.cwd);
37
- const gitzoneConfig = npmextraInstance.dataFor<any>('@git.zone/cli', {});
36
+ const smartconfigInstance = new plugins.smartconfig.Smartconfig(this.cwd);
37
+ const gitzoneConfig = smartconfigInstance.dataFor<any>('@git.zone/cli', {});
38
38
 
39
39
  // Also check szci for backward compatibility
40
- const szciConfig = npmextraInstance.dataFor<any>('@ship.zone/szci', {});
40
+ const szciConfig = smartconfigInstance.dataFor<any>('@ship.zone/szci', {});
41
41
 
42
42
  this.config = {
43
43
  registries: gitzoneConfig?.release?.registries || [],
@@ -46,37 +46,37 @@ export class ReleaseConfig {
46
46
  }
47
47
 
48
48
  /**
49
- * Save configuration to npmextra.json
49
+ * Save configuration to .smartconfig.json
50
50
  */
51
51
  public async save(): Promise<void> {
52
- const npmextraPath = plugins.path.join(this.cwd, 'npmextra.json');
53
- let npmextraData: any = {};
52
+ const smartconfigPath = plugins.path.join(this.cwd, '.smartconfig.json');
53
+ let smartconfigData: any = {};
54
54
 
55
- // Read existing npmextra.json
56
- if (await plugins.smartfs.file(npmextraPath).exists()) {
57
- const content = await plugins.smartfs.file(npmextraPath).encoding('utf8').read();
58
- npmextraData = JSON.parse(content as string);
55
+ // Read existing .smartconfig.json
56
+ if (await plugins.smartfs.file(smartconfigPath).exists()) {
57
+ const content = await plugins.smartfs.file(smartconfigPath).encoding('utf8').read();
58
+ smartconfigData = JSON.parse(content as string);
59
59
  }
60
60
 
61
61
  // Ensure @git.zone/cli namespace exists
62
- if (!npmextraData['@git.zone/cli']) {
63
- npmextraData['@git.zone/cli'] = {};
62
+ if (!smartconfigData['@git.zone/cli']) {
63
+ smartconfigData['@git.zone/cli'] = {};
64
64
  }
65
65
 
66
66
  // Ensure release object exists
67
- if (!npmextraData['@git.zone/cli'].release) {
68
- npmextraData['@git.zone/cli'].release = {};
67
+ if (!smartconfigData['@git.zone/cli'].release) {
68
+ smartconfigData['@git.zone/cli'].release = {};
69
69
  }
70
70
 
71
71
  // Update registries and accessLevel
72
- npmextraData['@git.zone/cli'].release.registries = this.config.registries;
73
- npmextraData['@git.zone/cli'].release.accessLevel = this.config.accessLevel;
72
+ smartconfigData['@git.zone/cli'].release.registries = this.config.registries;
73
+ smartconfigData['@git.zone/cli'].release.accessLevel = this.config.accessLevel;
74
74
 
75
75
  // Write back to file
76
76
  await plugins.smartfs
77
- .file(npmextraPath)
77
+ .file(smartconfigPath)
78
78
  .encoding('utf8')
79
- .write(JSON.stringify(npmextraData, null, 2));
79
+ .write(JSON.stringify(smartconfigData, null, 2));
80
80
  }
81
81
 
82
82
  /**
@@ -8,23 +8,23 @@ import { runFormatter, type ICheckResult } from '../mod_format/index.js';
8
8
  export { ReleaseConfig, CommitConfig };
9
9
 
10
10
  /**
11
- * Format npmextra.json with diff preview
11
+ * Format .smartconfig.json with diff preview
12
12
  * Shows diff first, asks for confirmation, then applies
13
13
  */
14
- async function formatNpmextraWithDiff(): Promise<void> {
14
+ async function formatSmartconfigWithDiff(): Promise<void> {
15
15
  // Check for diffs first
16
- const checkResult = await runFormatter('npmextra', {
16
+ const checkResult = await runFormatter('smartconfig', {
17
17
  checkOnly: true,
18
18
  showDiff: true,
19
19
  }) as ICheckResult | void;
20
20
 
21
21
  if (checkResult && checkResult.hasDiff) {
22
22
  const shouldApply = await plugins.smartinteract.SmartInteract.getCliConfirmation(
23
- 'Apply formatting changes to npmextra.json?',
23
+ 'Apply formatting changes to .smartconfig.json?',
24
24
  true
25
25
  );
26
26
  if (shouldApply) {
27
- await runFormatter('npmextra', { silent: true });
27
+ await runFormatter('smartconfig', { silent: true });
28
28
  }
29
29
  }
30
30
  }
@@ -187,7 +187,7 @@ async function handleAdd(url?: string): Promise<void> {
187
187
  if (added) {
188
188
  await config.save();
189
189
  plugins.logger.log('success', `Added registry: ${url}`);
190
- await formatNpmextraWithDiff();
190
+ await formatSmartconfigWithDiff();
191
191
  } else {
192
192
  plugins.logger.log('warn', `Registry already exists: ${url}`);
193
193
  }
@@ -223,7 +223,7 @@ async function handleRemove(url?: string): Promise<void> {
223
223
  if (removed) {
224
224
  await config.save();
225
225
  plugins.logger.log('success', `Removed registry: ${url}`);
226
- await formatNpmextraWithDiff();
226
+ await formatSmartconfigWithDiff();
227
227
  } else {
228
228
  plugins.logger.log('warn', `Registry not found: ${url}`);
229
229
  }
@@ -250,7 +250,7 @@ async function handleClear(): Promise<void> {
250
250
  config.clearRegistries();
251
251
  await config.save();
252
252
  plugins.logger.log('success', 'All registries cleared.');
253
- await formatNpmextraWithDiff();
253
+ await formatSmartconfigWithDiff();
254
254
  } else {
255
255
  plugins.logger.log('info', 'Operation cancelled.');
256
256
  }
@@ -290,7 +290,7 @@ async function handleAccessLevel(level?: string): Promise<void> {
290
290
  config.setAccessLevel(level as 'public' | 'private');
291
291
  await config.save();
292
292
  plugins.logger.log('success', `Access level set to: ${level}`);
293
- await formatNpmextraWithDiff();
293
+ await formatSmartconfigWithDiff();
294
294
  }
295
295
 
296
296
  /**
@@ -350,7 +350,7 @@ async function handleCommitInteractive(config: CommitConfig): Promise<void> {
350
350
  await config.save();
351
351
 
352
352
  plugins.logger.log('success', 'Commit configuration updated');
353
- await formatNpmextraWithDiff();
353
+ await formatSmartconfigWithDiff();
354
354
  }
355
355
 
356
356
  /**
@@ -368,7 +368,7 @@ async function handleCommitSetting(config: CommitConfig, setting: string, value?
368
368
 
369
369
  await config.save();
370
370
  plugins.logger.log('success', `Set ${setting} to ${boolValue}`);
371
- await formatNpmextraWithDiff();
371
+ await formatSmartconfigWithDiff();
372
372
  }
373
373
 
374
374
  /**
@@ -2,11 +2,12 @@ import * as plugins from './mod.plugins.js';
2
2
  import { FormatContext } from './classes.formatcontext.js';
3
3
  import type { IPlannedChange, ICheckResult } from './interfaces.format.js';
4
4
  import { Project } from '../classes.project.js';
5
+ import { FormatStats } from './classes.formatstats.js';
5
6
 
6
7
  export abstract class BaseFormatter {
7
8
  protected context: FormatContext;
8
9
  protected project: Project;
9
- protected stats: any; // Will be FormatStats from context
10
+ protected stats: FormatStats;
10
11
 
11
12
  constructor(context: FormatContext, project: Project) {
12
13
  this.context = context;
@@ -36,9 +37,6 @@ export abstract class BaseFormatter {
36
37
  }
37
38
 
38
39
  await this.postExecute();
39
- } catch (error) {
40
- // Don't rollback here - let the FormatPlanner handle it
41
- throw error;
42
40
  } finally {
43
41
  this.stats.endModule(this.name, startTime);
44
42
  }
@@ -53,13 +51,10 @@ export abstract class BaseFormatter {
53
51
  }
54
52
 
55
53
  protected async modifyFile(filepath: string, content: string): Promise<void> {
56
- // Validate filepath before writing
57
54
  if (!filepath || filepath.trim() === '') {
58
55
  throw new Error(`Invalid empty filepath in modifyFile`);
59
56
  }
60
57
 
61
- // Ensure we have a proper path with directory component
62
- // If the path has no directory component (e.g., "package.json"), prepend "./"
63
58
  let normalizedPath = filepath;
64
59
  if (!plugins.path.parse(filepath).dir) {
65
60
  normalizedPath = './' + filepath;
@@ -69,44 +64,46 @@ export abstract class BaseFormatter {
69
64
  }
70
65
 
71
66
  protected async createFile(filepath: string, content: string): Promise<void> {
72
- await plugins.smartfs.file(filepath).encoding('utf8').write(content);
67
+ let normalizedPath = filepath;
68
+ if (!plugins.path.parse(filepath).dir) {
69
+ normalizedPath = './' + filepath;
70
+ }
71
+
72
+ // Ensure parent directory exists
73
+ const dir = plugins.path.dirname(normalizedPath);
74
+ if (dir && dir !== '.') {
75
+ await plugins.smartfs.directory(dir).recursive().create();
76
+ }
77
+
78
+ await plugins.smartfs.file(normalizedPath).encoding('utf8').write(content);
73
79
  }
74
80
 
75
81
  protected async deleteFile(filepath: string): Promise<void> {
76
82
  await plugins.smartfs.file(filepath).delete();
77
83
  }
78
84
 
79
- protected async shouldProcessFile(filepath: string): Promise<boolean> {
80
- return true;
81
- }
82
-
83
85
  /**
84
86
  * Check for diffs without applying changes
85
- * Returns information about what would change
86
87
  */
87
88
  async check(): Promise<ICheckResult> {
88
89
  const changes = await this.analyze();
89
90
  const diffs: ICheckResult['diffs'] = [];
90
91
 
91
92
  for (const change of changes) {
92
- // Skip generic changes that don't have actual content
93
93
  if (change.path === '<various files>') {
94
94
  continue;
95
95
  }
96
96
 
97
97
  if (change.type === 'modify' || change.type === 'create') {
98
- // Read current content if file exists
99
98
  let currentContent: string | undefined;
100
99
  try {
101
100
  currentContent = await plugins.smartfs.file(change.path).encoding('utf8').read() as string;
102
101
  } catch {
103
- // File doesn't exist yet
104
102
  currentContent = undefined;
105
103
  }
106
104
 
107
105
  const newContent = change.content;
108
106
 
109
- // Check if there's an actual diff
110
107
  if (currentContent !== newContent && newContent !== undefined) {
111
108
  diffs.push({
112
109
  path: change.path,
@@ -116,7 +113,6 @@ export abstract class BaseFormatter {
116
113
  });
117
114
  }
118
115
  } else if (change.type === 'delete') {
119
- // Check if file exists before marking for deletion
120
116
  try {
121
117
  const currentContent = await plugins.smartfs.file(change.path).encoding('utf8').read() as string;
122
118
  diffs.push({
@@ -137,9 +133,6 @@ export abstract class BaseFormatter {
137
133
  };
138
134
  }
139
135
 
140
- /**
141
- * Display a single diff using smartdiff
142
- */
143
136
  displayDiff(diff: ICheckResult['diffs'][0]): void {
144
137
  console.log(`\n--- ${diff.path}`);
145
138
  if (diff.before && diff.after) {
@@ -150,7 +143,6 @@ export abstract class BaseFormatter {
150
143
  }));
151
144
  } else if (diff.after && !diff.before) {
152
145
  console.log(' (new file)');
153
- // Show first few lines of new content
154
146
  const lines = diff.after.split('\n').slice(0, 10);
155
147
  lines.forEach(line => console.log(` + ${line}`));
156
148
  if (diff.after.split('\n').length > 10) {
@@ -161,9 +153,6 @@ export abstract class BaseFormatter {
161
153
  }
162
154
  }
163
155
 
164
- /**
165
- * Display all diffs from a check result
166
- */
167
156
  displayAllDiffs(result: ICheckResult): void {
168
157
  if (!result.hasDiff) {
169
158
  console.log(' No changes detected');
@@ -2,13 +2,12 @@ import * as plugins from './mod.plugins.js';
2
2
  import { FormatContext } from './classes.formatcontext.js';
3
3
  import { BaseFormatter } from './classes.baseformatter.js';
4
4
  import type { IFormatPlan, IPlannedChange } from './interfaces.format.js';
5
+ import { getModuleIcon } from './interfaces.format.js';
5
6
  import { logger } from '../gitzone.logging.js';
6
- import { DependencyAnalyzer } from './classes.dependency-analyzer.js';
7
7
  import { DiffReporter } from './classes.diffreporter.js';
8
8
 
9
9
  export class FormatPlanner {
10
10
  private plannedChanges: Map<string, IPlannedChange[]> = new Map();
11
- private dependencyAnalyzer = new DependencyAnalyzer();
12
11
  private diffReporter = new DiffReporter();
13
12
 
14
13
  async planFormat(modules: BaseFormatter[]): Promise<IFormatPlan> {
@@ -18,7 +17,6 @@ export class FormatPlanner {
18
17
  filesAdded: 0,
19
18
  filesModified: 0,
20
19
  filesRemoved: 0,
21
- estimatedTime: 0,
22
20
  },
23
21
  changes: [],
24
22
  warnings: [],
@@ -32,7 +30,6 @@ export class FormatPlanner {
32
30
  for (const change of changes) {
33
31
  plan.changes.push(change);
34
32
 
35
- // Update summary
36
33
  switch (change.type) {
37
34
  case 'create':
38
35
  plan.summary.filesAdded++;
@@ -58,7 +55,6 @@ export class FormatPlanner {
58
55
  plan.summary.filesAdded +
59
56
  plan.summary.filesModified +
60
57
  plan.summary.filesRemoved;
61
- plan.summary.estimatedTime = plan.summary.totalFiles * 100; // 100ms per file estimate
62
58
 
63
59
  return plan;
64
60
  }
@@ -67,27 +63,20 @@ export class FormatPlanner {
67
63
  plan: IFormatPlan,
68
64
  modules: BaseFormatter[],
69
65
  context: FormatContext,
70
- parallel: boolean = false,
71
66
  ): Promise<void> {
72
67
  const startTime = Date.now();
73
68
 
74
- try {
75
- // Always use sequential execution to avoid race conditions
76
- for (const module of modules) {
77
- const changes = this.plannedChanges.get(module.name) || [];
69
+ for (const module of modules) {
70
+ const changes = this.plannedChanges.get(module.name) || [];
78
71
 
79
- if (changes.length > 0) {
80
- logger.log('info', `Executing ${module.name} formatter...`);
81
- await module.execute(changes);
82
- }
72
+ if (changes.length > 0) {
73
+ logger.log('info', `Executing ${module.name} formatter...`);
74
+ await module.execute(changes);
83
75
  }
84
-
85
- const endTime = Date.now();
86
- const duration = endTime - startTime;
87
- logger.log('info', `Format operations completed in ${duration}ms`);
88
- } catch (error) {
89
- throw error;
90
76
  }
77
+
78
+ const duration = Date.now() - startTime;
79
+ logger.log('info', `Format operations completed in ${duration}ms`);
91
80
  }
92
81
 
93
82
  async displayPlan(
@@ -103,7 +92,6 @@ export class FormatPlanner {
103
92
  console.log('');
104
93
  console.log('Changes by module:');
105
94
 
106
- // Group changes by module
107
95
  const changesByModule = new Map<string, IPlannedChange[]>();
108
96
  for (const change of plan.changes) {
109
97
  const moduleChanges = changesByModule.get(change.module) || [];
@@ -113,14 +101,13 @@ export class FormatPlanner {
113
101
 
114
102
  for (const [module, changes] of changesByModule) {
115
103
  console.log(
116
- `\n${this.getModuleIcon(module)} ${module} (${changes.length} ${changes.length === 1 ? 'file' : 'files'})`,
104
+ `\n${getModuleIcon(module)} ${module} (${changes.length} ${changes.length === 1 ? 'file' : 'files'})`,
117
105
  );
118
106
 
119
107
  for (const change of changes) {
120
108
  const icon = this.getChangeIcon(change.type);
121
109
  console.log(` ${icon} ${change.path} - ${change.description}`);
122
110
 
123
- // Show diff for modified files if detailed view is requested
124
111
  if (detailed && change.type === 'modify') {
125
112
  const diff = await this.diffReporter.generateDiffForChange(change);
126
113
  if (diff) {
@@ -141,22 +128,6 @@ export class FormatPlanner {
141
128
  console.log('\n' + '━'.repeat(50));
142
129
  }
143
130
 
144
- private getModuleIcon(module: string): string {
145
- const icons: Record<string, string> = {
146
- packagejson: '📦',
147
- license: '📝',
148
- tsconfig: '🔧',
149
- cleanup: '🚮',
150
- gitignore: '🔒',
151
- prettier: '✨',
152
- readme: '📖',
153
- templates: '📄',
154
- npmextra: '⚙️',
155
- copy: '📋',
156
- };
157
- return icons[module] || '📁';
158
- }
159
-
160
131
  private getChangeIcon(type: 'create' | 'modify' | 'delete'): string {
161
132
  switch (type) {
162
133
  case 'create':
@@ -1,5 +1,6 @@
1
1
  import * as plugins from './mod.plugins.js';
2
2
  import { logger } from '../gitzone.logging.js';
3
+ import { getModuleIcon } from './interfaces.format.js';
3
4
 
4
5
  export interface IModuleStats {
5
6
  name: string;
@@ -23,8 +24,6 @@ export interface IFormatStats {
23
24
  totalModified: number;
24
25
  totalDeleted: number;
25
26
  totalErrors: number;
26
- cacheHits: number;
27
- cacheMisses: number;
28
27
  };
29
28
  }
30
29
 
@@ -43,8 +42,6 @@ export class FormatStats {
43
42
  totalModified: 0,
44
43
  totalDeleted: 0,
45
44
  totalErrors: 0,
46
- cacheHits: 0,
47
- cacheMisses: 0,
48
45
  },
49
46
  };
50
47
  }
@@ -107,14 +104,6 @@ export class FormatStats {
107
104
  }
108
105
  }
109
106
 
110
- recordCacheHit(): void {
111
- this.stats.overallStats.cacheHits++;
112
- }
113
-
114
- recordCacheMiss(): void {
115
- this.stats.overallStats.cacheMisses++;
116
- }
117
-
118
107
  finish(): void {
119
108
  this.stats.endTime = Date.now();
120
109
  this.stats.totalExecutionTime = this.stats.endTime - this.stats.startTime;
@@ -135,20 +124,6 @@ export class FormatStats {
135
124
  console.log(` • Deleted: ${this.stats.overallStats.totalDeleted}`);
136
125
  console.log(` Errors: ${this.stats.overallStats.totalErrors}`);
137
126
 
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;
147
- console.log(` Cache Hit Rate: ${cacheHitRate.toFixed(1)}%`);
148
- console.log(` • Hits: ${this.stats.overallStats.cacheHits}`);
149
- console.log(` • Misses: ${this.stats.overallStats.cacheMisses}`);
150
- }
151
-
152
127
  // Module stats
153
128
  console.log('\nModule Breakdown:');
154
129
  console.log('─'.repeat(50));
@@ -159,7 +134,7 @@ export class FormatStats {
159
134
 
160
135
  for (const moduleStats of sortedModules) {
161
136
  console.log(
162
- `\n${this.getModuleIcon(moduleStats.name)} ${moduleStats.name}:`,
137
+ `\n${getModuleIcon(moduleStats.name)} ${moduleStats.name}:`,
163
138
  );
164
139
  console.log(
165
140
  ` Execution Time: ${this.formatDuration(moduleStats.executionTime)}`,
@@ -211,19 +186,4 @@ export class FormatStats {
211
186
  }
212
187
  }
213
188
 
214
- private getModuleIcon(module: string): string {
215
- const icons: Record<string, string> = {
216
- packagejson: '📦',
217
- license: '📝',
218
- tsconfig: '🔧',
219
- cleanup: '🚮',
220
- gitignore: '🔒',
221
- prettier: '✨',
222
- readme: '📖',
223
- templates: '📄',
224
- npmextra: '⚙️',
225
- copy: '📋',
226
- };
227
- return icons[module] || '📁';
228
- }
229
189
  }
@@ -1,7 +1,6 @@
1
1
  import { BaseFormatter } from '../classes.baseformatter.js';
2
2
  import type { IPlannedChange } from '../interfaces.format.js';
3
3
  import * as plugins from '../mod.plugins.js';
4
- import * as cleanupFormatter from '../format.cleanup.js';
5
4
 
6
5
  export class CleanupFormatter extends BaseFormatter {
7
6
  get name(): string {