@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
@@ -1,340 +0,0 @@
1
- import * as plugins from './mod.plugins.js';
2
- import * as paths from '../paths.js';
3
- import type { IFormatOperation } from './interfaces.format.js';
4
-
5
- export class RollbackManager {
6
- private backupDir: string;
7
- private manifestPath: string;
8
-
9
- constructor() {
10
- this.backupDir = plugins.path.join(paths.cwd, '.nogit', 'gitzone-backups');
11
- this.manifestPath = plugins.path.join(this.backupDir, 'manifest.json');
12
- }
13
-
14
- async createOperation(): Promise<IFormatOperation> {
15
- await this.ensureBackupDir();
16
-
17
- const operation: IFormatOperation = {
18
- id: this.generateOperationId(),
19
- timestamp: Date.now(),
20
- files: [],
21
- status: 'pending',
22
- };
23
-
24
- await this.updateManifest(operation);
25
- return operation;
26
- }
27
-
28
- async backupFile(filepath: string, operationId: string): Promise<void> {
29
- const operation = await this.getOperation(operationId);
30
- if (!operation) {
31
- throw new Error(`Operation ${operationId} not found`);
32
- }
33
-
34
- const absolutePath = plugins.path.isAbsolute(filepath)
35
- ? filepath
36
- : plugins.path.join(paths.cwd, filepath);
37
-
38
- // Check if file exists
39
- const exists = await plugins.smartfs.file(absolutePath).exists();
40
- if (!exists) {
41
- // File doesn't exist yet (will be created), so we skip backup
42
- return;
43
- }
44
-
45
- // Read file content and metadata
46
- const content = (await plugins.smartfs
47
- .file(absolutePath)
48
- .encoding('utf8')
49
- .read()) as string;
50
- const stats = await plugins.smartfs.file(absolutePath).stat();
51
- const checksum = this.calculateChecksum(content);
52
-
53
- // Create backup
54
- const backupPath = this.getBackupPath(operationId, filepath);
55
- await plugins.smartfs
56
- .directory(plugins.path.dirname(backupPath))
57
- .recursive()
58
- .create();
59
- await plugins.smartfs.file(backupPath).encoding('utf8').write(content);
60
-
61
- // Update operation
62
- operation.files.push({
63
- path: filepath,
64
- originalContent: content,
65
- checksum,
66
- permissions: stats.mode.toString(8),
67
- });
68
-
69
- await this.updateManifest(operation);
70
- }
71
-
72
- async rollback(operationId: string): Promise<void> {
73
- const operation = await this.getOperation(operationId);
74
- if (!operation) {
75
- // Operation doesn't exist, might have already been rolled back or never created
76
- console.warn(`Operation ${operationId} not found for rollback, skipping`);
77
- return;
78
- }
79
-
80
- if (operation.status === 'rolled-back') {
81
- throw new Error(`Operation ${operationId} has already been rolled back`);
82
- }
83
-
84
- // Restore files in reverse order
85
- for (let i = operation.files.length - 1; i >= 0; i--) {
86
- const file = operation.files[i];
87
- const absolutePath = plugins.path.isAbsolute(file.path)
88
- ? file.path
89
- : plugins.path.join(paths.cwd, file.path);
90
-
91
- // Verify backup integrity
92
- const backupPath = this.getBackupPath(operationId, file.path);
93
- const backupContent = await plugins.smartfs
94
- .file(backupPath)
95
- .encoding('utf8')
96
- .read();
97
- const backupChecksum = this.calculateChecksum(backupContent);
98
-
99
- if (backupChecksum !== file.checksum) {
100
- throw new Error(`Backup integrity check failed for ${file.path}`);
101
- }
102
-
103
- // Restore file
104
- await plugins.smartfs
105
- .file(absolutePath)
106
- .encoding('utf8')
107
- .write(file.originalContent);
108
-
109
- // Restore permissions
110
- const mode = parseInt(file.permissions, 8);
111
- // Note: Permissions restoration may not work on all platforms
112
- }
113
-
114
- // Update operation status
115
- operation.status = 'rolled-back';
116
- await this.updateManifest(operation);
117
- }
118
-
119
- async markComplete(operationId: string): Promise<void> {
120
- const operation = await this.getOperation(operationId);
121
- if (!operation) {
122
- throw new Error(`Operation ${operationId} not found`);
123
- }
124
-
125
- operation.status = 'completed';
126
- await this.updateManifest(operation);
127
- }
128
-
129
- async cleanOldBackups(retentionDays: number): Promise<void> {
130
- const manifest = await this.getManifest();
131
- const cutoffTime = Date.now() - retentionDays * 24 * 60 * 60 * 1000;
132
-
133
- const operationsToDelete = manifest.operations.filter(
134
- (op) => op.timestamp < cutoffTime && op.status === 'completed',
135
- );
136
-
137
- for (const operation of operationsToDelete) {
138
- // Remove backup files
139
- const operationDir = plugins.path.join(
140
- this.backupDir,
141
- 'operations',
142
- operation.id,
143
- );
144
- await plugins.smartfs.directory(operationDir).recursive().delete();
145
-
146
- // Remove from manifest
147
- manifest.operations = manifest.operations.filter(
148
- (op) => op.id !== operation.id,
149
- );
150
- }
151
-
152
- await this.saveManifest(manifest);
153
- }
154
-
155
- async verifyBackup(operationId: string): Promise<boolean> {
156
- const operation = await this.getOperation(operationId);
157
- if (!operation) {
158
- return false;
159
- }
160
-
161
- for (const file of operation.files) {
162
- const backupPath = this.getBackupPath(operationId, file.path);
163
- const exists = await plugins.smartfs.file(backupPath).exists();
164
-
165
- if (!exists) {
166
- return false;
167
- }
168
-
169
- const content = await plugins.smartfs
170
- .file(backupPath)
171
- .encoding('utf8')
172
- .read();
173
- const checksum = this.calculateChecksum(content);
174
-
175
- if (checksum !== file.checksum) {
176
- return false;
177
- }
178
- }
179
-
180
- return true;
181
- }
182
-
183
- async listBackups(): Promise<IFormatOperation[]> {
184
- const manifest = await this.getManifest();
185
- return manifest.operations;
186
- }
187
-
188
- private async ensureBackupDir(): Promise<void> {
189
- await plugins.smartfs.directory(this.backupDir).recursive().create();
190
- await plugins.smartfs
191
- .directory(plugins.path.join(this.backupDir, 'operations'))
192
- .recursive()
193
- .create();
194
- }
195
-
196
- private generateOperationId(): string {
197
- const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
198
- const random = Math.random().toString(36).substring(2, 8);
199
- return `${timestamp}-${random}`;
200
- }
201
-
202
- private getBackupPath(operationId: string, filepath: string): string {
203
- const filename = plugins.path.basename(filepath);
204
- const dir = plugins.path.dirname(filepath);
205
- const safeDir = dir.replace(/[/\\]/g, '__');
206
- return plugins.path.join(
207
- this.backupDir,
208
- 'operations',
209
- operationId,
210
- 'files',
211
- safeDir,
212
- `${filename}.backup`,
213
- );
214
- }
215
-
216
- private calculateChecksum(content: string | Buffer): string {
217
- return plugins.crypto.createHash('sha256').update(content).digest('hex');
218
- }
219
-
220
- private async getManifest(): Promise<{ operations: IFormatOperation[] }> {
221
- const defaultManifest = { operations: [] };
222
-
223
- const exists = await plugins.smartfs.file(this.manifestPath).exists();
224
- if (!exists) {
225
- return defaultManifest;
226
- }
227
-
228
- try {
229
- const content = (await plugins.smartfs
230
- .file(this.manifestPath)
231
- .encoding('utf8')
232
- .read()) as string;
233
- const manifest = JSON.parse(content);
234
-
235
- // Validate the manifest structure
236
- if (this.isValidManifest(manifest)) {
237
- return manifest;
238
- } else {
239
- console.warn(
240
- 'Invalid rollback manifest structure, returning default manifest',
241
- );
242
- return defaultManifest;
243
- }
244
- } catch (error) {
245
- console.warn(
246
- `Failed to read rollback manifest: ${error.message}, returning default manifest`,
247
- );
248
- // Try to delete the corrupted file
249
- try {
250
- await plugins.smartfs.file(this.manifestPath).delete();
251
- } catch (removeError) {
252
- // Ignore removal errors
253
- }
254
- return defaultManifest;
255
- }
256
- }
257
-
258
- private async saveManifest(manifest: {
259
- operations: IFormatOperation[];
260
- }): Promise<void> {
261
- // Validate before saving
262
- if (!this.isValidManifest(manifest)) {
263
- throw new Error('Invalid rollback manifest structure, cannot save');
264
- }
265
-
266
- // Ensure directory exists
267
- await this.ensureBackupDir();
268
-
269
- // Write directly with proper JSON stringification
270
- const jsonContent = JSON.stringify(manifest, null, 2);
271
- await plugins.smartfs
272
- .file(this.manifestPath)
273
- .encoding('utf8')
274
- .write(jsonContent);
275
- }
276
-
277
- private async getOperation(
278
- operationId: string,
279
- ): Promise<IFormatOperation | null> {
280
- const manifest = await this.getManifest();
281
- return manifest.operations.find((op) => op.id === operationId) || null;
282
- }
283
-
284
- private async updateManifest(operation: IFormatOperation): Promise<void> {
285
- const manifest = await this.getManifest();
286
- const existingIndex = manifest.operations.findIndex(
287
- (op) => op.id === operation.id,
288
- );
289
-
290
- if (existingIndex !== -1) {
291
- manifest.operations[existingIndex] = operation;
292
- } else {
293
- manifest.operations.push(operation);
294
- }
295
-
296
- await this.saveManifest(manifest);
297
- }
298
-
299
- private isValidManifest(
300
- manifest: any,
301
- ): manifest is { operations: IFormatOperation[] } {
302
- // Check if manifest has the required structure
303
- if (!manifest || typeof manifest !== 'object') {
304
- return false;
305
- }
306
-
307
- // Check required fields
308
- if (!Array.isArray(manifest.operations)) {
309
- return false;
310
- }
311
-
312
- // Check each operation entry
313
- for (const operation of manifest.operations) {
314
- if (
315
- !operation ||
316
- typeof operation !== 'object' ||
317
- typeof operation.id !== 'string' ||
318
- typeof operation.timestamp !== 'number' ||
319
- typeof operation.status !== 'string' ||
320
- !Array.isArray(operation.files)
321
- ) {
322
- return false;
323
- }
324
-
325
- // Check each file in the operation
326
- for (const file of operation.files) {
327
- if (
328
- !file ||
329
- typeof file !== 'object' ||
330
- typeof file.path !== 'string' ||
331
- typeof file.checksum !== 'string'
332
- ) {
333
- return false;
334
- }
335
- }
336
- }
337
-
338
- return true;
339
- }
340
- }
@@ -1,26 +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
- const filesToDelete = [
8
- 'defaults.yml',
9
- 'yarn.lock',
10
- 'package-lock.json',
11
- 'tslint.json',
12
- ];
13
-
14
- export const run = async (projectArg: Project) => {
15
- for (const relativeFilePath of filesToDelete) {
16
- const fileExists = await plugins.smartfs.file(relativeFilePath).exists();
17
- if (fileExists) {
18
- logger.log('info', `Found ${relativeFilePath}! Removing it!`);
19
- await plugins.smartfs
20
- .file(plugins.path.join(paths.cwd, relativeFilePath))
21
- .delete();
22
- } else {
23
- logger.log('info', `Project is free of ${relativeFilePath}`);
24
- }
25
- }
26
- };
@@ -1,93 +0,0 @@
1
- import type { Project } from '../classes.project.js';
2
- import * as plugins from './mod.plugins.js';
3
- import { logger } from '../gitzone.logging.js';
4
-
5
- export const run = async (projectArg: Project) => {
6
- const gitzoneConfig = await projectArg.gitzoneConfig;
7
-
8
- // Get copy configuration from npmextra.json
9
- const npmextraConfig = new plugins.npmextra.Npmextra();
10
- const copyConfig = npmextraConfig.dataFor<any>('gitzone.format.copy', {
11
- patterns: [],
12
- });
13
-
14
- if (!copyConfig.patterns || copyConfig.patterns.length === 0) {
15
- logger.log('info', 'No copy patterns configured in npmextra.json');
16
- return;
17
- }
18
-
19
- for (const pattern of copyConfig.patterns) {
20
- if (!pattern.from || !pattern.to) {
21
- logger.log('warn', 'Invalid copy pattern - missing "from" or "to" field');
22
- continue;
23
- }
24
-
25
- try {
26
- // Handle glob patterns
27
- const entries = await plugins.smartfs
28
- .directory('.')
29
- .recursive()
30
- .filter(pattern.from)
31
- .list();
32
- const files = entries.map((entry) => entry.path);
33
-
34
- for (const file of files) {
35
- const sourcePath = file;
36
- let destPath = pattern.to;
37
-
38
- // If destination is a directory, preserve filename
39
- if (pattern.to.endsWith('/')) {
40
- const filename = plugins.path.basename(file);
41
- destPath = plugins.path.join(pattern.to, filename);
42
- }
43
-
44
- // Handle template variables in destination path
45
- if (pattern.preservePath) {
46
- const relativePath = plugins.path.relative(
47
- plugins.path.dirname(pattern.from.replace(/\*/g, '')),
48
- file,
49
- );
50
- destPath = plugins.path.join(pattern.to, relativePath);
51
- }
52
-
53
- // Ensure destination directory exists
54
- await plugins.smartfs
55
- .directory(plugins.path.dirname(destPath))
56
- .recursive()
57
- .create();
58
-
59
- // Copy file
60
- await plugins.smartfs.file(sourcePath).copy(destPath);
61
- logger.log('info', `Copied ${sourcePath} to ${destPath}`);
62
- }
63
- } catch (error) {
64
- logger.log(
65
- 'error',
66
- `Failed to copy pattern ${pattern.from}: ${error.message}`,
67
- );
68
- }
69
- }
70
- };
71
-
72
- /**
73
- * Example npmextra.json configuration:
74
- * {
75
- * "gitzone": {
76
- * "format": {
77
- * "copy": {
78
- * "patterns": [
79
- * {
80
- * "from": "src/assets/*",
81
- * "to": "dist/assets/",
82
- * "preservePath": true
83
- * },
84
- * {
85
- * "from": "config/*.json",
86
- * "to": "dist/"
87
- * }
88
- * ]
89
- * }
90
- * }
91
- * }
92
- * }
93
- */
@@ -1,54 +0,0 @@
1
- import * as plugins from './mod.plugins.js';
2
- import * as paths from '../paths.js';
3
-
4
- import { Project } from '../classes.project.js';
5
-
6
- import { logger } from '../gitzone.logging.js';
7
- const gitignorePath = plugins.path.join(paths.cwd, './.gitignore');
8
-
9
- export const run = async (projectArg: Project) => {
10
- const gitignoreExists = await plugins.smartfs.file(gitignorePath).exists();
11
- let customContent = '';
12
-
13
- if (gitignoreExists) {
14
- // lets get the existing gitignore file
15
- const existingGitIgnoreString = (await plugins.smartfs
16
- .file(gitignorePath)
17
- .encoding('utf8')
18
- .read()) as string;
19
-
20
- // Check for different custom section markers
21
- const customMarkers = ['#------# custom', '# custom'];
22
- for (const marker of customMarkers) {
23
- const splitResult = existingGitIgnoreString.split(marker);
24
- if (splitResult.length > 1) {
25
- // Get everything after the marker (excluding the marker itself)
26
- customContent = splitResult[1].trim();
27
- break;
28
- }
29
- }
30
- }
31
-
32
- // Write the template
33
- const templateModule = await import('../mod_template/index.js');
34
- const ciTemplate = await templateModule.getTemplate('gitignore');
35
- await ciTemplate.writeToDisk(paths.cwd);
36
-
37
- // Append the custom content if it exists
38
- if (customContent) {
39
- const newGitignoreContent = (await plugins.smartfs
40
- .file(gitignorePath)
41
- .encoding('utf8')
42
- .read()) as string;
43
- // The template already ends with "#------# custom", so just append the content
44
- const finalContent =
45
- newGitignoreContent.trimEnd() + '\n' + customContent + '\n';
46
- await plugins.smartfs
47
- .file(gitignorePath)
48
- .encoding('utf8')
49
- .write(finalContent);
50
- logger.log('info', 'Updated .gitignore while preserving custom section!');
51
- } else {
52
- logger.log('info', 'Added a .gitignore!');
53
- }
54
- };
@@ -1,32 +0,0 @@
1
- import * as plugins from './mod.plugins.js';
2
- import * as paths from '../paths.js';
3
- import { Project } from '../classes.project.js';
4
-
5
- import { logger } from '../gitzone.logging.js';
6
-
7
- const incompatibleLicenses: string[] = ['AGPL', 'GPL', 'SSPL'];
8
-
9
- export const run = async (projectArg: Project) => {
10
- const nodeModulesInstalled = await plugins.smartfs
11
- .directory(plugins.path.join(paths.cwd, 'node_modules'))
12
- .exists();
13
- if (!nodeModulesInstalled) {
14
- logger.log('warn', 'No node_modules found. Skipping license check');
15
- return;
16
- }
17
- const licenseChecker = await plugins.smartlegal.createLicenseChecker();
18
- const licenseCheckResult = await licenseChecker.excludeLicenseWithinPath(
19
- paths.cwd,
20
- incompatibleLicenses,
21
- );
22
- if (licenseCheckResult.failingModules.length === 0) {
23
- logger.log('info', 'Success -> licenses passed!');
24
- } else {
25
- logger.log('error', 'Error -> licenses failed. Here is why:');
26
- for (const failedModule of licenseCheckResult.failingModules) {
27
- console.log(
28
- `${failedModule.name} fails with license ${failedModule.license}`,
29
- );
30
- }
31
- }
32
- };
@@ -1,151 +0,0 @@
1
- import * as plugins from './mod.plugins.js';
2
- import * as paths from '../paths.js';
3
- import * as gulpFunction from '@push.rocks/gulp-function';
4
- import { Project } from '../classes.project.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
- console.log(`Migrated npmextra.json: ${oldKey} -> ${newKey}`);
33
- }
34
- }
35
- return migrated;
36
- };
37
-
38
- /**
39
- * Migrates npmAccessLevel from @ship.zone/szci to @git.zone/cli.release.accessLevel
40
- * This is a one-time migration for projects using the old location
41
- */
42
- const migrateAccessLevel = (npmextraJson: any): boolean => {
43
- const szciConfig = npmextraJson['@ship.zone/szci'];
44
-
45
- // Check if szci has npmAccessLevel that needs to be migrated
46
- if (!szciConfig?.npmAccessLevel) {
47
- return false;
48
- }
49
-
50
- // Check if we already have the new location
51
- const gitzoneConfig = npmextraJson['@git.zone/cli'] || {};
52
- if (gitzoneConfig?.release?.accessLevel) {
53
- // Already migrated, just remove from szci
54
- delete szciConfig.npmAccessLevel;
55
- return true;
56
- }
57
-
58
- // Ensure @git.zone/cli and release exist
59
- if (!npmextraJson['@git.zone/cli']) {
60
- npmextraJson['@git.zone/cli'] = {};
61
- }
62
- if (!npmextraJson['@git.zone/cli'].release) {
63
- npmextraJson['@git.zone/cli'].release = {};
64
- }
65
-
66
- // Migrate the value
67
- npmextraJson['@git.zone/cli'].release.accessLevel = szciConfig.npmAccessLevel;
68
- delete szciConfig.npmAccessLevel;
69
-
70
- console.log(`Migrated npmAccessLevel to @git.zone/cli.release.accessLevel`);
71
- return true;
72
- };
73
-
74
- /**
75
- * runs the npmextra file checking
76
- */
77
- export const run = async (projectArg: Project) => {
78
- const formatSmartstream = new plugins.smartstream.StreamWrapper([
79
- plugins.smartgulp.src([`npmextra.json`]),
80
- gulpFunction.forEach(async (fileArg: plugins.smartfile.SmartFile) => {
81
- const fileString = fileArg.contents.toString();
82
- const npmextraJson = JSON.parse(fileString);
83
-
84
- // Migrate old namespace keys to new package-scoped keys
85
- migrateNamespaceKeys(npmextraJson);
86
-
87
- // Migrate npmAccessLevel from szci to @git.zone/cli.release.accessLevel
88
- migrateAccessLevel(npmextraJson);
89
-
90
- if (!npmextraJson['@git.zone/cli']) {
91
- npmextraJson['@git.zone/cli'] = {};
92
- }
93
-
94
- const expectedRepoInformation: string[] = [
95
- 'projectType',
96
- 'module.githost',
97
- 'module.gitscope',
98
- 'module.gitrepo',
99
- 'module.description',
100
- 'module.npmPackagename',
101
- 'module.license',
102
- ];
103
-
104
- const interactInstance = new plugins.smartinteract.SmartInteract();
105
- for (const expectedRepoInformationItem of expectedRepoInformation) {
106
- if (
107
- !plugins.smartobject.smartGet(
108
- npmextraJson['@git.zone/cli'],
109
- expectedRepoInformationItem,
110
- )
111
- ) {
112
- interactInstance.addQuestions([
113
- {
114
- message: `What is the value of ${expectedRepoInformationItem}`,
115
- name: expectedRepoInformationItem,
116
- type: 'input',
117
- default: 'undefined variable',
118
- },
119
- ]);
120
- }
121
- }
122
-
123
- const answerbucket = await interactInstance.runQueue();
124
- for (const expectedRepoInformationItem of expectedRepoInformation) {
125
- const cliProvidedValue = answerbucket.getAnswerFor(
126
- expectedRepoInformationItem,
127
- );
128
- if (cliProvidedValue) {
129
- plugins.smartobject.smartAdd(
130
- npmextraJson['@git.zone/cli'],
131
- expectedRepoInformationItem,
132
- cliProvidedValue,
133
- );
134
- }
135
- }
136
-
137
- // delete obsolete
138
- // tbd
139
-
140
- if (!npmextraJson['@ship.zone/szci']) {
141
- npmextraJson['@ship.zone/szci'] = {};
142
- }
143
-
144
- fileArg.setContentsFromString(JSON.stringify(npmextraJson, null, 2));
145
- }),
146
- plugins.smartgulp.replace(),
147
- ]);
148
- await formatSmartstream.run().catch((error) => {
149
- console.log(error);
150
- });
151
- };