@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
@@ -16,7 +16,12 @@ const prettierDefaultMarkdownConfig: prettier.Options = {
16
16
  parser: 'markdown',
17
17
  };
18
18
 
19
- const filesToFormat = [`ts/**/*.ts`, `test/**/*.ts`, `readme.md`, `docs/**/*.md`];
19
+ const filesToFormat = [
20
+ `ts/**/*.ts`,
21
+ `test/**/*.ts`,
22
+ `readme.md`,
23
+ `docs/**/*.md`,
24
+ ];
20
25
 
21
26
  const choosePrettierConfig = (fileArg: plugins.smartfile.SmartFile) => {
22
27
  switch (fileArg.parsedPath.ext) {
@@ -39,7 +44,10 @@ const prettierTypeScriptPipestop = plugins.through2.obj(
39
44
  cb(null);
40
45
  } else {
41
46
  logger.log('info', `${fileArg.path} is being reformated!`);
42
- const formatedFileString = await prettier.format(fileString, chosenConfig);
47
+ const formatedFileString = await prettier.format(
48
+ fileString,
49
+ chosenConfig,
50
+ );
43
51
  fileArg.setContentsFromString(formatedFileString);
44
52
  cb(null, fileArg);
45
53
  }
@@ -18,7 +18,8 @@ export const run = async () => {
18
18
  }
19
19
 
20
20
  // Check and initialize readme.hints.md if it doesn't exist
21
- const readmeHintsExists = await plugins.smartfile.fs.fileExists(readmeHintsPath);
21
+ const readmeHintsExists =
22
+ await plugins.smartfile.fs.fileExists(readmeHintsPath);
22
23
  if (!readmeHintsExists) {
23
24
  await plugins.smartfile.fs.toFs(
24
25
  '# Project Readme Hints\n\nThis is the initial readme hints file.',
@@ -26,10 +26,12 @@ export const run = async (project: Project) => {
26
26
  case 'npm':
27
27
  case 'wcc':
28
28
  if (project.gitzoneConfig.data.npmciOptions.npmAccessLevel === 'public') {
29
- const ciTemplateDefault = await templateModule.getTemplate('ci_default');
29
+ const ciTemplateDefault =
30
+ await templateModule.getTemplate('ci_default');
30
31
  ciTemplateDefault.writeToDisk(paths.cwd);
31
32
  } else {
32
- const ciTemplateDefault = await templateModule.getTemplate('ci_default_private');
33
+ const ciTemplateDefault =
34
+ await templateModule.getTemplate('ci_default_private');
33
35
  ciTemplateDefault.writeToDisk(paths.cwd);
34
36
  }
35
37
  logger.log('info', 'Updated .gitlabci.yml!');
@@ -41,7 +43,8 @@ export const run = async (project: Project) => {
41
43
  logger.log('info', 'Updated CI/CD config files!');
42
44
 
43
45
  // lets care about docker
44
- const dockerTemplate = await templateModule.getTemplate('dockerfile_service');
46
+ const dockerTemplate =
47
+ await templateModule.getTemplate('dockerfile_service');
45
48
  dockerTemplate.writeToDisk(paths.cwd);
46
49
  logger.log('info', 'Updated Dockerfile!');
47
50
 
@@ -56,17 +59,22 @@ export const run = async (project: Project) => {
56
59
 
57
60
  // update html
58
61
  if (project.gitzoneConfig.data.projectType === 'website') {
59
- const websiteUpdateTemplate = await templateModule.getTemplate('website_update');
60
- const variables ={
62
+ const websiteUpdateTemplate =
63
+ await templateModule.getTemplate('website_update');
64
+ const variables = {
61
65
  assetbrokerUrl: project.gitzoneConfig.data.module.assetbrokerUrl,
62
66
  legalUrl: project.gitzoneConfig.data.module.legalUrl,
63
67
  };
64
- console.log('updating website template with variables\n', JSON.stringify(variables, null, 2));
68
+ console.log(
69
+ 'updating website template with variables\n',
70
+ JSON.stringify(variables, null, 2),
71
+ );
65
72
  websiteUpdateTemplate.supplyVariables(variables);
66
73
  await websiteUpdateTemplate.writeToDisk(paths.cwd);
67
74
  logger.log('info', `Updated html for website!`);
68
75
  } else if (project.gitzoneConfig.data.projectType === 'service') {
69
- const websiteUpdateTemplate = await templateModule.getTemplate('service_update');
76
+ const websiteUpdateTemplate =
77
+ await templateModule.getTemplate('service_update');
70
78
  await websiteUpdateTemplate.writeToDisk(paths.cwd);
71
79
  logger.log('info', `Updated html for element template!`);
72
80
  } else if (project.gitzoneConfig.data.projectType === 'wcc') {
@@ -19,8 +19,12 @@ export const run = async (projectArg: Project) => {
19
19
  const publishModules = await tsPublishInstance.getModuleSubDirs(paths.cwd);
20
20
  for (const publishModule of Object.keys(publishModules)) {
21
21
  const publishConfig = publishModules[publishModule];
22
- tsconfigObject.compilerOptions.paths[`${publishConfig.name}`] = [`./${publishModule}/index.js`];
22
+ tsconfigObject.compilerOptions.paths[`${publishConfig.name}`] = [
23
+ `./${publishModule}/index.js`,
24
+ ];
23
25
  }
24
- tsconfigSmartfile.setContentsFromString(JSON.stringify(tsconfigObject, null, 2));
26
+ tsconfigSmartfile.setContentsFromString(
27
+ JSON.stringify(tsconfigObject, null, 2),
28
+ );
25
29
  await tsconfigSmartfile.write();
26
30
  };
@@ -7,13 +7,18 @@ export class CleanupFormatter extends BaseFormatter {
7
7
  get name(): string {
8
8
  return 'cleanup';
9
9
  }
10
-
10
+
11
11
  async analyze(): Promise<IPlannedChange[]> {
12
12
  const changes: IPlannedChange[] = [];
13
-
13
+
14
14
  // List of files to remove
15
- const filesToRemove = ['yarn.lock', 'package-lock.json', 'tslint.json', 'defaults.yml'];
16
-
15
+ const filesToRemove = [
16
+ 'yarn.lock',
17
+ 'package-lock.json',
18
+ 'tslint.json',
19
+ 'defaults.yml',
20
+ ];
21
+
17
22
  for (const file of filesToRemove) {
18
23
  const exists = await plugins.smartfile.fs.fileExists(file);
19
24
  if (exists) {
@@ -21,14 +26,14 @@ export class CleanupFormatter extends BaseFormatter {
21
26
  type: 'delete',
22
27
  path: file,
23
28
  module: this.name,
24
- description: `Remove obsolete file`
29
+ description: `Remove obsolete file`,
25
30
  });
26
31
  }
27
32
  }
28
-
33
+
29
34
  return changes;
30
35
  }
31
-
36
+
32
37
  async applyChange(change: IPlannedChange): Promise<void> {
33
38
  switch (change.type) {
34
39
  case 'delete':
@@ -36,4 +41,4 @@ export class CleanupFormatter extends BaseFormatter {
36
41
  break;
37
42
  }
38
43
  }
39
- }
44
+ }
@@ -5,4 +5,4 @@ export class CopyFormatter extends LegacyFormatter {
5
5
  constructor(context: any, project: any) {
6
6
  super(context, project, 'copy', formatCopy);
7
7
  }
8
- }
8
+ }
@@ -5,4 +5,4 @@ export class GitignoreFormatter extends LegacyFormatter {
5
5
  constructor(context: any, project: any) {
6
6
  super(context, project, 'gitignore', formatGitignore);
7
7
  }
8
- }
8
+ }
@@ -7,30 +7,37 @@ import * as plugins from '../mod.plugins.js';
7
7
  export class LegacyFormatter extends BaseFormatter {
8
8
  private moduleName: string;
9
9
  private formatModule: any;
10
-
11
- constructor(context: any, project: Project, moduleName: string, formatModule: any) {
10
+
11
+ constructor(
12
+ context: any,
13
+ project: Project,
14
+ moduleName: string,
15
+ formatModule: any,
16
+ ) {
12
17
  super(context, project);
13
18
  this.moduleName = moduleName;
14
19
  this.formatModule = formatModule;
15
20
  }
16
-
21
+
17
22
  get name(): string {
18
23
  return this.moduleName;
19
24
  }
20
-
25
+
21
26
  async analyze(): Promise<IPlannedChange[]> {
22
27
  // For legacy modules, we can't easily predict changes
23
28
  // So we'll return a generic change that indicates the module will run
24
- return [{
25
- type: 'modify',
26
- path: '<various files>',
27
- module: this.name,
28
- description: `Run ${this.name} formatter`
29
- }];
29
+ return [
30
+ {
31
+ type: 'modify',
32
+ path: '<various files>',
33
+ module: this.name,
34
+ description: `Run ${this.name} formatter`,
35
+ },
36
+ ];
30
37
  }
31
-
38
+
32
39
  async applyChange(change: IPlannedChange): Promise<void> {
33
40
  // Run the legacy format module
34
41
  await this.formatModule.run(this.project);
35
42
  }
36
- }
43
+ }
@@ -5,4 +5,4 @@ export class LicenseFormatter extends LegacyFormatter {
5
5
  constructor(context: any, project: any) {
6
6
  super(context, project, 'license', formatLicense);
7
7
  }
8
- }
8
+ }
@@ -5,4 +5,4 @@ export class NpmextraFormatter extends LegacyFormatter {
5
5
  constructor(context: any, project: any) {
6
6
  super(context, project, 'npmextra', formatNpmextra);
7
7
  }
8
- }
8
+ }
@@ -5,4 +5,4 @@ export class PackageJsonFormatter extends LegacyFormatter {
5
5
  constructor(context: any, project: any) {
6
6
  super(context, project, 'packagejson', formatPackageJson);
7
7
  }
8
- }
8
+ }
@@ -7,21 +7,16 @@ export class PrettierFormatter extends BaseFormatter {
7
7
  get name(): string {
8
8
  return 'prettier';
9
9
  }
10
-
10
+
11
11
  async analyze(): Promise<IPlannedChange[]> {
12
12
  const changes: IPlannedChange[] = [];
13
-
13
+
14
14
  // Define directories to format (TypeScript directories by default)
15
- const includeDirs = [
16
- 'ts',
17
- 'ts_*',
18
- 'test',
19
- 'tests'
20
- ];
21
-
15
+ const includeDirs = ['ts', 'ts_*', 'test', 'tests'];
16
+
22
17
  // File extensions to format
23
18
  const extensions = '{ts,tsx,js,jsx,json,md,css,scss,html,xml,yaml,yml}';
24
-
19
+
25
20
  // Also format root-level config files
26
21
  const rootConfigFiles = [
27
22
  'package.json',
@@ -36,33 +31,36 @@ export class PrettierFormatter extends BaseFormatter {
36
31
  'CHANGELOG.md',
37
32
  'license',
38
33
  'LICENSE',
39
- '*.md'
34
+ '*.md',
40
35
  ];
41
-
36
+
42
37
  // Collect all files to format
43
38
  const allFiles: string[] = [];
44
-
39
+
45
40
  // Add files from TypeScript directories
46
41
  for (const dir of includeDirs) {
47
42
  const globPattern = `${dir}/**/*.${extensions}`;
48
- const dirFiles = await plugins.smartfile.fs.listFileTree('.', globPattern);
43
+ const dirFiles = await plugins.smartfile.fs.listFileTree(
44
+ '.',
45
+ globPattern,
46
+ );
49
47
  allFiles.push(...dirFiles);
50
48
  }
51
-
49
+
52
50
  // Add root config files
53
51
  for (const pattern of rootConfigFiles) {
54
52
  const rootFiles = await plugins.smartfile.fs.listFileTree('.', pattern);
55
53
  // Only include files at root level (no slashes in path)
56
- const rootLevelFiles = rootFiles.filter(f => !f.includes('/'));
54
+ const rootLevelFiles = rootFiles.filter((f) => !f.includes('/'));
57
55
  allFiles.push(...rootLevelFiles);
58
56
  }
59
-
57
+
60
58
  // Remove duplicates
61
59
  const uniqueFiles = [...new Set(allFiles)];
62
-
60
+
63
61
  // Get all files that match the pattern
64
62
  const files = uniqueFiles;
65
-
63
+
66
64
  // Ensure we only process actual files (not directories)
67
65
  const validFiles: string[] = [];
68
66
  for (const file of files) {
@@ -76,48 +74,52 @@ export class PrettierFormatter extends BaseFormatter {
76
74
  logVerbose(`Skipping ${file} - cannot access: ${error.message}`);
77
75
  }
78
76
  }
79
-
77
+
80
78
  // Check which files need formatting
81
79
  for (const file of validFiles) {
82
80
  // Skip files that haven't changed
83
- if (!await this.shouldProcessFile(file)) {
81
+ if (!(await this.shouldProcessFile(file))) {
84
82
  logVerbose(`Skipping ${file} - no changes detected`);
85
83
  continue;
86
84
  }
87
-
85
+
88
86
  changes.push({
89
87
  type: 'modify',
90
88
  path: file,
91
89
  module: this.name,
92
- description: 'Format with Prettier'
90
+ description: 'Format with Prettier',
93
91
  });
94
92
  }
95
-
93
+
96
94
  logger.log('info', `Found ${changes.length} files to format with Prettier`);
97
95
  return changes;
98
96
  }
99
-
97
+
100
98
  async execute(changes: IPlannedChange[]): Promise<void> {
101
99
  const startTime = this.stats.moduleStartTime(this.name);
102
100
  this.stats.startModule(this.name);
103
-
101
+
104
102
  try {
105
103
  await this.preExecute();
106
-
104
+
107
105
  // Batch process files
108
106
  const batchSize = 10; // Process 10 files at a time
109
107
  const batches: IPlannedChange[][] = [];
110
-
108
+
111
109
  for (let i = 0; i < changes.length; i += batchSize) {
112
110
  batches.push(changes.slice(i, i + batchSize));
113
111
  }
114
-
115
- logVerbose(`Processing ${changes.length} files in ${batches.length} batches`);
116
-
112
+
113
+ logVerbose(
114
+ `Processing ${changes.length} files in ${batches.length} batches`,
115
+ );
116
+
117
117
  for (let i = 0; i < batches.length; i++) {
118
118
  const batch = batches[i];
119
- logVerbose(`Processing batch ${i + 1}/${batches.length} (${batch.length} files)`);
120
-
119
+ logVerbose(
120
+ `Processing batch ${i + 1}/${batches.length} (${batch.length} files)`,
121
+ );
122
+
121
123
  // Process batch in parallel
122
124
  const promises = batch.map(async (change) => {
123
125
  try {
@@ -125,44 +127,45 @@ export class PrettierFormatter extends BaseFormatter {
125
127
  this.stats.recordFileOperation(this.name, change.type, true);
126
128
  } catch (error) {
127
129
  this.stats.recordFileOperation(this.name, change.type, false);
128
- logger.log('error', `Failed to format ${change.path}: ${error.message}`);
130
+ logger.log(
131
+ 'error',
132
+ `Failed to format ${change.path}: ${error.message}`,
133
+ );
129
134
  // Don't throw - continue with other files
130
135
  }
131
136
  });
132
-
137
+
133
138
  await Promise.all(promises);
134
139
  }
135
-
140
+
136
141
  await this.postExecute();
137
142
  } catch (error) {
138
- await this.context.rollbackOperation();
143
+ // Rollback removed - no longer tracking operations
139
144
  throw error;
140
145
  } finally {
141
146
  this.stats.endModule(this.name, startTime);
142
147
  }
143
148
  }
144
-
149
+
145
150
  async applyChange(change: IPlannedChange): Promise<void> {
146
151
  if (change.type !== 'modify') return;
147
-
152
+
148
153
  try {
149
154
  // Read current content
150
155
  const content = plugins.smartfile.fs.toStringSync(change.path);
151
-
156
+
152
157
  // Format with prettier
153
158
  const prettier = await import('prettier');
154
159
  const formatted = await prettier.format(content, {
155
160
  filepath: change.path,
156
- ...(await this.getPrettierConfig())
161
+ ...(await this.getPrettierConfig()),
157
162
  });
158
-
163
+
159
164
  // Only write if content actually changed
160
165
  if (formatted !== content) {
161
166
  await this.modifyFile(change.path, formatted);
162
167
  logVerbose(`Formatted ${change.path}`);
163
168
  } else {
164
- // Still update cache even if content didn't change
165
- await this.cache.updateFileCache(change.path);
166
169
  logVerbose(`No formatting changes for ${change.path}`);
167
170
  }
168
171
  } catch (error) {
@@ -170,7 +173,7 @@ export class PrettierFormatter extends BaseFormatter {
170
173
  throw error;
171
174
  }
172
175
  }
173
-
176
+
174
177
  private async getPrettierConfig(): Promise<any> {
175
178
  // Try to load prettier config from the project
176
179
  const prettierConfig = new plugins.npmextra.Npmextra();
@@ -181,7 +184,7 @@ export class PrettierFormatter extends BaseFormatter {
181
184
  printWidth: 80,
182
185
  tabWidth: 2,
183
186
  semi: true,
184
- arrowParens: 'always'
187
+ arrowParens: 'always',
185
188
  });
186
189
  }
187
- }
190
+ }
@@ -6,17 +6,19 @@ export class ReadmeFormatter extends BaseFormatter {
6
6
  get name(): string {
7
7
  return 'readme';
8
8
  }
9
-
9
+
10
10
  async analyze(): Promise<IPlannedChange[]> {
11
- return [{
12
- type: 'modify',
13
- path: 'readme.md',
14
- module: this.name,
15
- description: 'Ensure readme files exist'
16
- }];
11
+ return [
12
+ {
13
+ type: 'modify',
14
+ path: 'readme.md',
15
+ module: this.name,
16
+ description: 'Ensure readme files exist',
17
+ },
18
+ ];
17
19
  }
18
-
20
+
19
21
  async applyChange(change: IPlannedChange): Promise<void> {
20
22
  await formatReadme.run();
21
23
  }
22
- }
24
+ }
@@ -5,4 +5,4 @@ export class TemplatesFormatter extends LegacyFormatter {
5
5
  constructor(context: any, project: any) {
6
6
  super(context, project, 'templates', formatTemplates);
7
7
  }
8
- }
8
+ }
@@ -5,4 +5,4 @@ export class TsconfigFormatter extends LegacyFormatter {
5
5
  constructor(context: any, project: any) {
6
6
  super(context, project, 'tsconfig', formatTsconfig);
7
7
  }
8
- }
8
+ }