@git.zone/cli 2.13.10 → 2.13.12

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 (105) hide show
  1. package/assets/templates/{npmextra/npmextra.json → smartconfig/_smartconfig.json} +3 -0
  2. package/dist_ts/00_commitinfo_data.js +1 -1
  3. package/dist_ts/classes.gitzoneconfig.js +4 -4
  4. package/dist_ts/gitzone.cli.js +1 -15
  5. package/dist_ts/mod_commit/index.js +4 -4
  6. package/dist_ts/mod_config/classes.commitconfig.d.ts +3 -3
  7. package/dist_ts/mod_config/classes.commitconfig.js +20 -20
  8. package/dist_ts/mod_config/classes.releaseconfig.d.ts +3 -3
  9. package/dist_ts/mod_config/classes.releaseconfig.js +21 -21
  10. package/dist_ts/mod_config/index.js +12 -12
  11. package/dist_ts/mod_format/classes.baseformatter.d.ts +2 -9
  12. package/dist_ts/mod_format/classes.baseformatter.js +13 -26
  13. package/dist_ts/mod_format/classes.formatplanner.d.ts +1 -3
  14. package/dist_ts/mod_format/classes.formatplanner.js +11 -39
  15. package/dist_ts/mod_format/classes.formatstats.d.ts +0 -5
  16. package/dist_ts/mod_format/classes.formatstats.js +3 -35
  17. package/dist_ts/mod_format/formatters/cleanup.formatter.js +1 -2
  18. package/dist_ts/mod_format/formatters/copy.formatter.js +5 -8
  19. package/dist_ts/mod_format/formatters/gitignore.formatter.d.ts +5 -0
  20. package/dist_ts/mod_format/formatters/gitignore.formatter.js +23 -29
  21. package/dist_ts/mod_format/formatters/packagejson.formatter.js +5 -5
  22. package/dist_ts/mod_format/formatters/prettier.formatter.js +4 -12
  23. package/dist_ts/mod_format/formatters/{npmextra.formatter.d.ts → smartconfig.formatter.d.ts} +6 -1
  24. package/dist_ts/mod_format/formatters/smartconfig.formatter.js +180 -0
  25. package/dist_ts/mod_format/formatters/templates.formatter.d.ts +4 -0
  26. package/dist_ts/mod_format/formatters/templates.formatter.js +50 -43
  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 +3 -7
  33. package/dist_ts/mod_format/mod.plugins.js +4 -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 +5 -11
  40. package/ts/00_commitinfo_data.ts +1 -1
  41. package/ts/classes.gitzoneconfig.ts +3 -3
  42. package/ts/gitzone.cli.ts +0 -17
  43. package/ts/mod_commit/index.ts +3 -3
  44. package/ts/mod_config/classes.commitconfig.ts +19 -19
  45. package/ts/mod_config/classes.releaseconfig.ts +20 -20
  46. package/ts/mod_config/index.ts +11 -11
  47. package/ts/mod_format/classes.baseformatter.ts +14 -25
  48. package/ts/mod_format/classes.formatplanner.ts +10 -39
  49. package/ts/mod_format/classes.formatstats.ts +2 -42
  50. package/ts/mod_format/formatters/cleanup.formatter.ts +0 -1
  51. package/ts/mod_format/formatters/copy.formatter.ts +4 -8
  52. package/ts/mod_format/formatters/gitignore.formatter.ts +25 -29
  53. package/ts/mod_format/formatters/packagejson.formatter.ts +4 -4
  54. package/ts/mod_format/formatters/prettier.formatter.ts +3 -13
  55. package/ts/mod_format/formatters/smartconfig.formatter.ts +213 -0
  56. package/ts/mod_format/formatters/templates.formatter.ts +55 -43
  57. package/ts/mod_format/formatters/tsconfig.formatter.ts +6 -3
  58. package/ts/mod_format/index.ts +35 -98
  59. package/ts/mod_format/interfaces.format.ts +16 -19
  60. package/ts/mod_format/mod.plugins.ts +4 -12
  61. package/ts/mod_services/classes.globalregistry.ts +2 -2
  62. package/ts/mod_services/classes.servicemanager.ts +20 -20
  63. package/ts/plugins.ts +2 -2
  64. package/dist_ts/mod_format/classes.changecache.d.ts +0 -26
  65. package/dist_ts/mod_format/classes.changecache.js +0 -181
  66. package/dist_ts/mod_format/classes.dependency-analyzer.d.ts +0 -13
  67. package/dist_ts/mod_format/classes.dependency-analyzer.js +0 -93
  68. package/dist_ts/mod_format/classes.rollbackmanager.d.ts +0 -22
  69. package/dist_ts/mod_format/classes.rollbackmanager.js +0 -259
  70. package/dist_ts/mod_format/format.cleanup.d.ts +0 -2
  71. package/dist_ts/mod_format/format.cleanup.js +0 -25
  72. package/dist_ts/mod_format/format.copy.d.ts +0 -24
  73. package/dist_ts/mod_format/format.copy.js +0 -77
  74. package/dist_ts/mod_format/format.gitignore.d.ts +0 -2
  75. package/dist_ts/mod_format/format.gitignore.js +0 -48
  76. package/dist_ts/mod_format/format.license.d.ts +0 -2
  77. package/dist_ts/mod_format/format.license.js +0 -26
  78. package/dist_ts/mod_format/format.npmextra.d.ts +0 -5
  79. package/dist_ts/mod_format/format.npmextra.js +0 -125
  80. package/dist_ts/mod_format/format.packagejson.d.ts +0 -2
  81. package/dist_ts/mod_format/format.packagejson.js +0 -145
  82. package/dist_ts/mod_format/format.prettier.d.ts +0 -2
  83. package/dist_ts/mod_format/format.prettier.js +0 -56
  84. package/dist_ts/mod_format/format.readme.d.ts +0 -1
  85. package/dist_ts/mod_format/format.readme.js +0 -29
  86. package/dist_ts/mod_format/format.templates.d.ts +0 -5
  87. package/dist_ts/mod_format/format.templates.js +0 -68
  88. package/dist_ts/mod_format/format.tsconfig.d.ts +0 -2
  89. package/dist_ts/mod_format/format.tsconfig.js +0 -28
  90. package/dist_ts/mod_format/formatters/npmextra.formatter.js +0 -142
  91. package/ts/mod_format/classes.changecache.ts +0 -235
  92. package/ts/mod_format/classes.dependency-analyzer.ts +0 -117
  93. package/ts/mod_format/classes.rollbackmanager.ts +0 -340
  94. package/ts/mod_format/format.cleanup.ts +0 -26
  95. package/ts/mod_format/format.copy.ts +0 -93
  96. package/ts/mod_format/format.gitignore.ts +0 -54
  97. package/ts/mod_format/format.license.ts +0 -32
  98. package/ts/mod_format/format.npmextra.ts +0 -151
  99. package/ts/mod_format/format.packagejson.ts +0 -196
  100. package/ts/mod_format/format.prettier.ts +0 -66
  101. package/ts/mod_format/format.readme.ts +0 -29
  102. package/ts/mod_format/format.templates.ts +0 -79
  103. package/ts/mod_format/format.tsconfig.ts +0 -31
  104. package/ts/mod_format/formatters/npmextra.formatter.ts +0 -174
  105. /package/{npmextra.json → .smartconfig.json} +0 -0
@@ -1,79 +0,0 @@
1
- import * as plugins from './mod.plugins.js';
2
- import * as paths from '../paths.js';
3
-
4
- import { logger } from '../gitzone.logging.js';
5
- import { Project } from '../classes.project.js';
6
-
7
- /**
8
- * takes care of updating files from templates
9
- */
10
- export const run = async (project: Project) => {
11
- const templateModule = await import('../mod_template/index.js');
12
-
13
- // update vscode
14
- const vscodeTemplate = await templateModule.getTemplate('vscode');
15
- await vscodeTemplate.writeToDisk(paths.cwd);
16
- logger.log('info', `Updated vscode template!`);
17
-
18
- // update gitlab ci and Dockerfile
19
- switch (project.gitzoneConfig.data.projectType) {
20
- case 'npm':
21
- case 'wcc':
22
- if (project.gitzoneConfig.data.npmciOptions.npmAccessLevel === 'public') {
23
- const ciTemplateDefault =
24
- await templateModule.getTemplate('ci_default');
25
- ciTemplateDefault.writeToDisk(paths.cwd);
26
- } else {
27
- const ciTemplateDefault =
28
- await templateModule.getTemplate('ci_default_private');
29
- ciTemplateDefault.writeToDisk(paths.cwd);
30
- }
31
- logger.log('info', 'Updated .gitlabci.yml!');
32
- break;
33
- case 'service':
34
- case 'website':
35
- const ciTemplateDocker = await templateModule.getTemplate('ci_docker');
36
- await ciTemplateDocker.writeToDisk(paths.cwd);
37
- logger.log('info', 'Updated CI/CD config files!');
38
-
39
- // lets care about docker
40
- const dockerTemplate =
41
- await templateModule.getTemplate('dockerfile_service');
42
- dockerTemplate.writeToDisk(paths.cwd);
43
- logger.log('info', 'Updated Dockerfile!');
44
-
45
- // lets care about cli
46
- const cliTemplate = await templateModule.getTemplate('cli');
47
- await cliTemplate.writeToDisk(paths.cwd);
48
- logger.log('info', 'Updated cli.ts.js and cli.js!');
49
- break;
50
- default:
51
- break;
52
- }
53
-
54
- // update html
55
- if (project.gitzoneConfig.data.projectType === 'website') {
56
- const websiteUpdateTemplate =
57
- await templateModule.getTemplate('website_update');
58
- const variables = {
59
- assetbrokerUrl: project.gitzoneConfig.data.module.assetbrokerUrl,
60
- legalUrl: project.gitzoneConfig.data.module.legalUrl,
61
- };
62
- console.log(
63
- 'updating website template with variables\n',
64
- JSON.stringify(variables, null, 2),
65
- );
66
- websiteUpdateTemplate.supplyVariables(variables);
67
- await websiteUpdateTemplate.writeToDisk(paths.cwd);
68
- logger.log('info', `Updated html for website!`);
69
- } else if (project.gitzoneConfig.data.projectType === 'service') {
70
- const websiteUpdateTemplate =
71
- await templateModule.getTemplate('service_update');
72
- await websiteUpdateTemplate.writeToDisk(paths.cwd);
73
- logger.log('info', `Updated html for element template!`);
74
- } else if (project.gitzoneConfig.data.projectType === 'wcc') {
75
- const wccUpdateTemplate = await templateModule.getTemplate('wcc_update');
76
- await wccUpdateTemplate.writeToDisk(paths.cwd);
77
- logger.log('info', `Updated html for wcc template!`);
78
- }
79
- };
@@ -1,31 +0,0 @@
1
- import * as plugins from './mod.plugins.js';
2
- import * as paths from '../paths.js';
3
-
4
- import { logger } from '../gitzone.logging.js';
5
- import { Project } from '../classes.project.js';
6
-
7
- export const run = async (projectArg: Project) => {
8
- // lets care about tsconfig.json
9
- logger.log('info', 'Formatting tsconfig.json...');
10
- const factory = plugins.smartfile.SmartFileFactory.nodeFs();
11
- const tsconfigSmartfile = await factory.fromFilePath(
12
- plugins.path.join(paths.cwd, 'tsconfig.json'),
13
- );
14
- const tsconfigObject = JSON.parse(tsconfigSmartfile.parseContentAsString());
15
- tsconfigObject.compilerOptions = tsconfigObject.compilerOptions || {};
16
- tsconfigObject.compilerOptions.baseUrl = '.';
17
- tsconfigObject.compilerOptions.paths = {};
18
- const tsPublishMod = await import('@git.zone/tspublish');
19
- const tsPublishInstance = new tsPublishMod.TsPublish();
20
- const publishModules = await tsPublishInstance.getModuleSubDirs(paths.cwd);
21
- for (const publishModule of Object.keys(publishModules)) {
22
- const publishConfig = publishModules[publishModule];
23
- tsconfigObject.compilerOptions.paths[`${publishConfig.name}`] = [
24
- `./${publishModule}/index.js`,
25
- ];
26
- }
27
- await tsconfigSmartfile.editContentAsString(async () => {
28
- return JSON.stringify(tsconfigObject, null, 2);
29
- });
30
- await tsconfigSmartfile.write();
31
- };
@@ -1,174 +0,0 @@
1
- import { BaseFormatter } from '../classes.baseformatter.js';
2
- import type { IPlannedChange } from '../interfaces.format.js';
3
- import * as plugins from '../mod.plugins.js';
4
- import { logger, logVerbose } from '../../gitzone.logging.js';
5
-
6
- /**
7
- * Migrates npmextra.json from old namespace keys to new package-scoped keys
8
- */
9
- const migrateNamespaceKeys = (npmextraJson: any): boolean => {
10
- let migrated = false;
11
- const migrations = [
12
- { oldKey: 'gitzone', newKey: '@git.zone/cli' },
13
- { oldKey: 'tsdoc', newKey: '@git.zone/tsdoc' },
14
- { oldKey: 'npmdocker', newKey: '@git.zone/tsdocker' },
15
- { oldKey: 'npmci', newKey: '@ship.zone/szci' },
16
- { oldKey: 'szci', newKey: '@ship.zone/szci' },
17
- ];
18
- for (const { oldKey, newKey } of migrations) {
19
- if (npmextraJson[oldKey]) {
20
- if (!npmextraJson[newKey]) {
21
- // New key doesn't exist - simple rename
22
- npmextraJson[newKey] = npmextraJson[oldKey];
23
- } else {
24
- // New key exists - merge old into new (old values don't overwrite new)
25
- npmextraJson[newKey] = {
26
- ...npmextraJson[oldKey],
27
- ...npmextraJson[newKey],
28
- };
29
- }
30
- delete npmextraJson[oldKey];
31
- migrated = true;
32
- }
33
- }
34
- return migrated;
35
- };
36
-
37
- /**
38
- * Migrates npmAccessLevel from @ship.zone/szci to @git.zone/cli.release.accessLevel
39
- */
40
- const migrateAccessLevel = (npmextraJson: any): boolean => {
41
- const szciConfig = npmextraJson['@ship.zone/szci'];
42
-
43
- if (!szciConfig?.npmAccessLevel) {
44
- return false;
45
- }
46
-
47
- const gitzoneConfig = npmextraJson['@git.zone/cli'] || {};
48
- if (gitzoneConfig?.release?.accessLevel) {
49
- delete szciConfig.npmAccessLevel;
50
- return true;
51
- }
52
-
53
- if (!npmextraJson['@git.zone/cli']) {
54
- npmextraJson['@git.zone/cli'] = {};
55
- }
56
- if (!npmextraJson['@git.zone/cli'].release) {
57
- npmextraJson['@git.zone/cli'].release = {};
58
- }
59
-
60
- npmextraJson['@git.zone/cli'].release.accessLevel = szciConfig.npmAccessLevel;
61
- delete szciConfig.npmAccessLevel;
62
-
63
- return true;
64
- };
65
-
66
- export class NpmextraFormatter extends BaseFormatter {
67
- get name(): string {
68
- return 'npmextra';
69
- }
70
-
71
- async analyze(): Promise<IPlannedChange[]> {
72
- const changes: IPlannedChange[] = [];
73
- const npmextraPath = 'smartconfig.json';
74
-
75
- // Check if file exists
76
- const exists = await plugins.smartfs.file(npmextraPath).exists();
77
- if (!exists) {
78
- logVerbose('npmextra.json does not exist, skipping');
79
- return changes;
80
- }
81
-
82
- // Read current content
83
- const currentContent = (await plugins.smartfs
84
- .file(npmextraPath)
85
- .encoding('utf8')
86
- .read()) as string;
87
-
88
- // Parse and compute new content
89
- const npmextraJson = JSON.parse(currentContent);
90
-
91
- // Apply migrations (these are automatic, non-interactive)
92
- migrateNamespaceKeys(npmextraJson);
93
- migrateAccessLevel(npmextraJson);
94
-
95
- // Ensure namespaces exist
96
- if (!npmextraJson['@git.zone/cli']) {
97
- npmextraJson['@git.zone/cli'] = {};
98
- }
99
- if (!npmextraJson['@ship.zone/szci']) {
100
- npmextraJson['@ship.zone/szci'] = {};
101
- }
102
-
103
- const newContent = JSON.stringify(npmextraJson, null, 2);
104
-
105
- // Only add change if content differs
106
- if (newContent !== currentContent) {
107
- changes.push({
108
- type: 'modify',
109
- path: npmextraPath,
110
- module: this.name,
111
- description: 'Migrate and format npmextra.json',
112
- content: newContent,
113
- });
114
- }
115
-
116
- return changes;
117
- }
118
-
119
- async applyChange(change: IPlannedChange): Promise<void> {
120
- if (change.type !== 'modify' || !change.content) return;
121
-
122
- // Parse the content to check for missing required fields
123
- const npmextraJson = JSON.parse(change.content);
124
-
125
- // Check for missing required module information
126
- const expectedRepoInformation: string[] = [
127
- 'projectType',
128
- 'module.githost',
129
- 'module.gitscope',
130
- 'module.gitrepo',
131
- 'module.description',
132
- 'module.npmPackagename',
133
- 'module.license',
134
- ];
135
-
136
- const interactInstance = new plugins.smartinteract.SmartInteract();
137
- for (const expectedRepoInformationItem of expectedRepoInformation) {
138
- if (
139
- !plugins.smartobject.smartGet(
140
- npmextraJson['@git.zone/cli'],
141
- expectedRepoInformationItem,
142
- )
143
- ) {
144
- interactInstance.addQuestions([
145
- {
146
- message: `What is the value of ${expectedRepoInformationItem}`,
147
- name: expectedRepoInformationItem,
148
- type: 'input',
149
- default: 'undefined variable',
150
- },
151
- ]);
152
- }
153
- }
154
-
155
- const answerbucket = await interactInstance.runQueue();
156
- for (const expectedRepoInformationItem of expectedRepoInformation) {
157
- const cliProvidedValue = answerbucket.getAnswerFor(
158
- expectedRepoInformationItem,
159
- );
160
- if (cliProvidedValue) {
161
- plugins.smartobject.smartAdd(
162
- npmextraJson['@git.zone/cli'],
163
- expectedRepoInformationItem,
164
- cliProvidedValue,
165
- );
166
- }
167
- }
168
-
169
- // Write the final content
170
- const finalContent = JSON.stringify(npmextraJson, null, 2);
171
- await this.modifyFile(change.path, finalContent);
172
- logger.log('info', 'Updated npmextra.json');
173
- }
174
- }
File without changes