@git.zone/cli 1.21.5 → 2.1.0

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 (61) hide show
  1. package/dist_ts/00_commitinfo_data.js +2 -2
  2. package/dist_ts/mod_commit/index.js +5 -2
  3. package/dist_ts/mod_commit/mod.helpers.js +24 -9
  4. package/dist_ts/mod_format/classes.baseformatter.js +4 -4
  5. package/dist_ts/mod_format/classes.changecache.js +29 -17
  6. package/dist_ts/mod_format/classes.diffreporter.js +10 -4
  7. package/dist_ts/mod_format/classes.formatstats.js +5 -2
  8. package/dist_ts/mod_format/classes.rollbackmanager.js +41 -17
  9. package/dist_ts/mod_format/format.cleanup.js +5 -3
  10. package/dist_ts/mod_format/format.copy.js +12 -4
  11. package/dist_ts/mod_format/format.gitignore.js +14 -5
  12. package/dist_ts/mod_format/format.license.js +4 -2
  13. package/dist_ts/mod_format/format.packagejson.js +6 -2
  14. package/dist_ts/mod_format/format.readme.js +9 -5
  15. package/dist_ts/mod_format/format.tsconfig.js +7 -4
  16. package/dist_ts/mod_format/formatters/cleanup.formatter.js +2 -2
  17. package/dist_ts/mod_format/formatters/prettier.formatter.js +19 -6
  18. package/dist_ts/mod_format/index.js +9 -3
  19. package/dist_ts/mod_meta/meta.classes.meta.js +82 -17
  20. package/dist_ts/mod_services/classes.globalregistry.d.ts +77 -0
  21. package/dist_ts/mod_services/classes.globalregistry.js +133 -0
  22. package/dist_ts/mod_services/classes.serviceconfiguration.d.ts +7 -0
  23. package/dist_ts/mod_services/classes.serviceconfiguration.js +86 -10
  24. package/dist_ts/mod_services/classes.servicemanager.d.ts +38 -0
  25. package/dist_ts/mod_services/classes.servicemanager.js +353 -10
  26. package/dist_ts/mod_services/helpers.d.ts +1 -1
  27. package/dist_ts/mod_services/helpers.js +8 -4
  28. package/dist_ts/mod_services/index.js +194 -28
  29. package/dist_ts/mod_standard/index.js +22 -9
  30. package/dist_ts/mod_template/index.js +2 -2
  31. package/dist_ts/plugins.d.ts +2 -0
  32. package/dist_ts/plugins.js +4 -1
  33. package/package.json +7 -6
  34. package/readme.hints.md +55 -2
  35. package/ts/00_commitinfo_data.ts +1 -1
  36. package/ts/mod_commit/index.ts +4 -4
  37. package/ts/mod_commit/mod.helpers.ts +23 -11
  38. package/ts/mod_format/classes.baseformatter.ts +3 -3
  39. package/ts/mod_format/classes.changecache.ts +28 -16
  40. package/ts/mod_format/classes.diffreporter.ts +9 -8
  41. package/ts/mod_format/classes.formatstats.ts +4 -4
  42. package/ts/mod_format/classes.rollbackmanager.ts +40 -18
  43. package/ts/mod_format/format.cleanup.ts +4 -4
  44. package/ts/mod_format/format.copy.ts +11 -3
  45. package/ts/mod_format/format.gitignore.ts +13 -6
  46. package/ts/mod_format/format.license.ts +3 -3
  47. package/ts/mod_format/format.packagejson.ts +5 -3
  48. package/ts/mod_format/format.readme.ts +8 -11
  49. package/ts/mod_format/format.tsconfig.ts +6 -5
  50. package/ts/mod_format/formatters/cleanup.formatter.ts +1 -1
  51. package/ts/mod_format/formatters/prettier.formatter.ts +18 -8
  52. package/ts/mod_format/index.ts +10 -5
  53. package/ts/mod_meta/meta.classes.meta.ts +84 -41
  54. package/ts/mod_services/classes.globalregistry.ts +190 -0
  55. package/ts/mod_services/classes.serviceconfiguration.ts +121 -35
  56. package/ts/mod_services/classes.servicemanager.ts +405 -32
  57. package/ts/mod_services/helpers.ts +8 -4
  58. package/ts/mod_services/index.ts +257 -48
  59. package/ts/mod_standard/index.ts +23 -10
  60. package/ts/mod_template/index.ts +1 -1
  61. package/ts/plugins.ts +4 -0
@@ -19,6 +19,11 @@ export interface IServiceConfig {
19
19
  S3_BUCKET: string;
20
20
  S3_ENDPOINT: string;
21
21
  S3_USESSL: boolean;
22
+ ELASTICSEARCH_HOST: string;
23
+ ELASTICSEARCH_PORT: string;
24
+ ELASTICSEARCH_USER: string;
25
+ ELASTICSEARCH_PASS: string;
26
+ ELASTICSEARCH_URL: string;
22
27
  }
23
28
 
24
29
  export class ServiceConfiguration {
@@ -61,10 +66,10 @@ export class ServiceConfiguration {
61
66
  * Save the configuration to file
62
67
  */
63
68
  public async saveConfig(): Promise<void> {
64
- await plugins.smartfile.memory.toFs(
65
- JSON.stringify(this.config, null, 2),
66
- this.configPath
67
- );
69
+ await plugins.smartfs
70
+ .file(this.configPath)
71
+ .encoding('utf8')
72
+ .write(JSON.stringify(this.config, null, 2));
68
73
  }
69
74
 
70
75
  /**
@@ -72,21 +77,24 @@ export class ServiceConfiguration {
72
77
  */
73
78
  private async ensureNogitDirectory(): Promise<void> {
74
79
  const nogitPath = plugins.path.join(process.cwd(), '.nogit');
75
- await plugins.smartfile.fs.ensureDir(nogitPath);
80
+ await plugins.smartfs.directory(nogitPath).recursive().create();
76
81
  }
77
82
 
78
83
  /**
79
84
  * Check if configuration file exists
80
85
  */
81
86
  private async configExists(): Promise<boolean> {
82
- return plugins.smartfile.fs.fileExists(this.configPath);
87
+ return plugins.smartfs.file(this.configPath).exists();
83
88
  }
84
89
 
85
90
  /**
86
91
  * Load configuration from file
87
92
  */
88
93
  private async loadConfig(): Promise<void> {
89
- const configContent = plugins.smartfile.fs.toStringSync(this.configPath);
94
+ const configContent = (await plugins.smartfs
95
+ .file(this.configPath)
96
+ .encoding('utf8')
97
+ .read()) as string;
90
98
  this.config = JSON.parse(configContent);
91
99
  }
92
100
 
@@ -94,16 +102,16 @@ export class ServiceConfiguration {
94
102
  * Create default configuration
95
103
  */
96
104
  private async createDefaultConfig(): Promise<void> {
97
- const projectName = helpers.getProjectName();
105
+ const projectName = await helpers.getProjectName();
98
106
  const mongoPort = await helpers.getRandomAvailablePort();
99
107
  const s3Port = await helpers.getRandomAvailablePort();
100
108
  let s3ConsolePort = s3Port + 1;
101
-
109
+
102
110
  // Ensure console port is also available
103
111
  while (!(await helpers.isPortAvailable(s3ConsolePort))) {
104
112
  s3ConsolePort++;
105
113
  }
106
-
114
+
107
115
  const mongoUser = 'defaultadmin';
108
116
  const mongoPass = 'defaultpass';
109
117
  const mongoHost = 'localhost';
@@ -111,7 +119,11 @@ export class ServiceConfiguration {
111
119
  const mongoPortStr = mongoPort.toString();
112
120
  const s3Host = 'localhost';
113
121
  const s3PortStr = s3Port.toString();
114
-
122
+ const esHost = 'localhost';
123
+ const esPort = '9200';
124
+ const esUser = 'elastic';
125
+ const esPass = 'elastic';
126
+
115
127
  this.config = {
116
128
  PROJECT_NAME: projectName,
117
129
  MONGODB_HOST: mongoHost,
@@ -127,22 +139,28 @@ export class ServiceConfiguration {
127
139
  S3_SECRETKEY: 'defaultpass',
128
140
  S3_BUCKET: `${projectName}-documents`,
129
141
  S3_ENDPOINT: s3Host,
130
- S3_USESSL: false
142
+ S3_USESSL: false,
143
+ ELASTICSEARCH_HOST: esHost,
144
+ ELASTICSEARCH_PORT: esPort,
145
+ ELASTICSEARCH_USER: esUser,
146
+ ELASTICSEARCH_PASS: esPass,
147
+ ELASTICSEARCH_URL: `http://${esUser}:${esPass}@${esHost}:${esPort}`
131
148
  };
132
-
149
+
133
150
  await this.saveConfig();
134
-
151
+
135
152
  logger.log('ok', '✅ Created .nogit/env.json with project defaults');
136
153
  logger.log('info', `📍 MongoDB port: ${mongoPort}`);
137
154
  logger.log('info', `📍 S3 API port: ${s3Port}`);
138
155
  logger.log('info', `📍 S3 Console port: ${s3ConsolePort}`);
156
+ logger.log('info', `📍 Elasticsearch port: ${esPort}`);
139
157
  }
140
158
 
141
159
  /**
142
160
  * Update missing fields in existing configuration
143
161
  */
144
162
  private async updateMissingFields(): Promise<void> {
145
- const projectName = helpers.getProjectName();
163
+ const projectName = await helpers.getProjectName();
146
164
  let updated = false;
147
165
  const fieldsAdded: string[] = [];
148
166
 
@@ -249,7 +267,39 @@ export class ServiceConfiguration {
249
267
  fieldsAdded.push('S3_ENDPOINT');
250
268
  updated = true;
251
269
  }
252
-
270
+
271
+ if (!this.config.ELASTICSEARCH_HOST) {
272
+ this.config.ELASTICSEARCH_HOST = 'localhost';
273
+ fieldsAdded.push('ELASTICSEARCH_HOST');
274
+ updated = true;
275
+ }
276
+
277
+ if (!this.config.ELASTICSEARCH_PORT) {
278
+ this.config.ELASTICSEARCH_PORT = '9200';
279
+ fieldsAdded.push('ELASTICSEARCH_PORT');
280
+ updated = true;
281
+ }
282
+
283
+ if (!this.config.ELASTICSEARCH_USER) {
284
+ this.config.ELASTICSEARCH_USER = 'elastic';
285
+ fieldsAdded.push('ELASTICSEARCH_USER');
286
+ updated = true;
287
+ }
288
+
289
+ if (!this.config.ELASTICSEARCH_PASS) {
290
+ this.config.ELASTICSEARCH_PASS = 'elastic';
291
+ fieldsAdded.push('ELASTICSEARCH_PASS');
292
+ updated = true;
293
+ }
294
+
295
+ // Always update ELASTICSEARCH_URL based on current settings
296
+ const oldEsUrl = this.config.ELASTICSEARCH_URL;
297
+ this.config.ELASTICSEARCH_URL = `http://${this.config.ELASTICSEARCH_USER}:${this.config.ELASTICSEARCH_PASS}@${this.config.ELASTICSEARCH_HOST}:${this.config.ELASTICSEARCH_PORT}`;
298
+ if (oldEsUrl !== this.config.ELASTICSEARCH_URL) {
299
+ fieldsAdded.push('ELASTICSEARCH_URL');
300
+ updated = true;
301
+ }
302
+
253
303
  if (updated) {
254
304
  await this.saveConfig();
255
305
  logger.log('ok', `✅ Added missing fields: ${fieldsAdded.join(', ')}`);
@@ -272,17 +322,19 @@ export class ServiceConfiguration {
272
322
  public getContainerNames() {
273
323
  return {
274
324
  mongo: `${this.config.PROJECT_NAME}-mongodb`,
275
- minio: `${this.config.PROJECT_NAME}-minio`
325
+ minio: `${this.config.PROJECT_NAME}-minio`,
326
+ elasticsearch: `${this.config.PROJECT_NAME}-elasticsearch`
276
327
  };
277
328
  }
278
-
329
+
279
330
  /**
280
331
  * Get data directories
281
332
  */
282
333
  public getDataDirectories() {
283
334
  return {
284
335
  mongo: plugins.path.join(process.cwd(), '.nogit', 'mongodata'),
285
- minio: plugins.path.join(process.cwd(), '.nogit', 'miniodata')
336
+ minio: plugins.path.join(process.cwd(), '.nogit', 'miniodata'),
337
+ elasticsearch: plugins.path.join(process.cwd(), '.nogit', 'esdata')
286
338
  };
287
339
  }
288
340
 
@@ -330,12 +382,27 @@ export class ServiceConfiguration {
330
382
  }
331
383
  }
332
384
  }
333
-
385
+
386
+ // Check Elasticsearch container
387
+ const esStatus = await this.docker.getStatus(containers.elasticsearch);
388
+ if (esStatus !== 'not_exists') {
389
+ const portMappings = await this.docker.getPortMappings(containers.elasticsearch);
390
+ if (portMappings && portMappings['9200']) {
391
+ const dockerPort = portMappings['9200'];
392
+ if (this.config.ELASTICSEARCH_PORT !== dockerPort) {
393
+ logger.log('note', `📍 Syncing Elasticsearch port from Docker: ${dockerPort}`);
394
+ this.config.ELASTICSEARCH_PORT = dockerPort;
395
+ updated = true;
396
+ }
397
+ }
398
+ }
399
+
334
400
  if (updated) {
335
401
  // Update derived fields
336
402
  this.config.MONGODB_URL = `mongodb://${this.config.MONGODB_USER}:${this.config.MONGODB_PASS}@${this.config.MONGODB_HOST}:${this.config.MONGODB_PORT}/${this.config.MONGODB_NAME}?authSource=admin`;
337
403
  this.config.S3_ENDPOINT = this.config.S3_HOST;
338
-
404
+ this.config.ELASTICSEARCH_URL = `http://${this.config.ELASTICSEARCH_USER}:${this.config.ELASTICSEARCH_PASS}@${this.config.ELASTICSEARCH_HOST}:${this.config.ELASTICSEARCH_PORT}`;
405
+
339
406
  await this.saveConfig();
340
407
  logger.log('ok', '✅ Configuration synced with Docker containers');
341
408
  }
@@ -347,11 +414,12 @@ export class ServiceConfiguration {
347
414
  public async validateAndUpdatePorts(): Promise<boolean> {
348
415
  let updated = false;
349
416
  const containers = this.getContainerNames();
350
-
417
+
351
418
  // Check if containers exist - if they do, ports are fine
352
419
  const mongoExists = await this.docker.exists(containers.mongo);
353
420
  const minioExists = await this.docker.exists(containers.minio);
354
-
421
+ const esExists = await this.docker.exists(containers.elasticsearch);
422
+
355
423
  // Only check port availability if containers don't exist
356
424
  if (!mongoExists) {
357
425
  const mongoPort = parseInt(this.config.MONGODB_PORT);
@@ -363,11 +431,11 @@ export class ServiceConfiguration {
363
431
  updated = true;
364
432
  }
365
433
  }
366
-
434
+
367
435
  if (!minioExists) {
368
436
  const s3Port = parseInt(this.config.S3_PORT);
369
437
  const s3ConsolePort = parseInt(this.config.S3_CONSOLE_PORT);
370
-
438
+
371
439
  if (!(await helpers.isPortAvailable(s3Port))) {
372
440
  logger.log('note', `⚠️ S3 API port ${s3Port} is in use, finding new port...`);
373
441
  const newPort = await helpers.getRandomAvailablePort();
@@ -375,7 +443,7 @@ export class ServiceConfiguration {
375
443
  logger.log('ok', `✅ New S3 API port: ${newPort}`);
376
444
  updated = true;
377
445
  }
378
-
446
+
379
447
  if (!(await helpers.isPortAvailable(s3ConsolePort))) {
380
448
  logger.log('note', `⚠️ S3 Console port ${s3ConsolePort} is in use, finding new port...`);
381
449
  let newPort = parseInt(this.config.S3_PORT) + 1;
@@ -387,15 +455,27 @@ export class ServiceConfiguration {
387
455
  updated = true;
388
456
  }
389
457
  }
390
-
458
+
459
+ if (!esExists) {
460
+ const esPort = parseInt(this.config.ELASTICSEARCH_PORT);
461
+ if (!(await helpers.isPortAvailable(esPort))) {
462
+ logger.log('note', `⚠️ Elasticsearch port ${esPort} is in use, finding new port...`);
463
+ const newPort = await helpers.getRandomAvailablePort();
464
+ this.config.ELASTICSEARCH_PORT = newPort.toString();
465
+ logger.log('ok', `✅ New Elasticsearch port: ${newPort}`);
466
+ updated = true;
467
+ }
468
+ }
469
+
391
470
  if (updated) {
392
471
  // Update derived fields
393
472
  this.config.MONGODB_URL = `mongodb://${this.config.MONGODB_USER}:${this.config.MONGODB_PASS}@${this.config.MONGODB_HOST}:${this.config.MONGODB_PORT}/${this.config.MONGODB_NAME}?authSource=admin`;
394
473
  this.config.S3_ENDPOINT = this.config.S3_HOST;
395
-
474
+ this.config.ELASTICSEARCH_URL = `http://${this.config.ELASTICSEARCH_USER}:${this.config.ELASTICSEARCH_PASS}@${this.config.ELASTICSEARCH_HOST}:${this.config.ELASTICSEARCH_PORT}`;
475
+
396
476
  await this.saveConfig();
397
477
  }
398
-
478
+
399
479
  return updated;
400
480
  }
401
481
 
@@ -404,29 +484,35 @@ export class ServiceConfiguration {
404
484
  */
405
485
  public async reconfigurePorts(): Promise<void> {
406
486
  logger.log('note', '🔄 Finding new available ports...');
407
-
487
+
408
488
  const mongoPort = await helpers.getRandomAvailablePort();
409
489
  const s3Port = await helpers.getRandomAvailablePort();
410
490
  let s3ConsolePort = s3Port + 1;
411
-
491
+
412
492
  // Ensure console port is also available
413
493
  while (!(await helpers.isPortAvailable(s3ConsolePort))) {
414
494
  s3ConsolePort++;
415
495
  }
416
-
496
+
497
+ // Elasticsearch uses standard port 9200
498
+ const esPort = '9200';
499
+
417
500
  this.config.MONGODB_PORT = mongoPort.toString();
418
501
  this.config.S3_PORT = s3Port.toString();
419
502
  this.config.S3_CONSOLE_PORT = s3ConsolePort.toString();
420
-
503
+ this.config.ELASTICSEARCH_PORT = esPort;
504
+
421
505
  // Update derived fields
422
506
  this.config.MONGODB_URL = `mongodb://${this.config.MONGODB_USER}:${this.config.MONGODB_PASS}@${this.config.MONGODB_HOST}:${this.config.MONGODB_PORT}/${this.config.MONGODB_NAME}?authSource=admin`;
423
507
  this.config.S3_ENDPOINT = this.config.S3_HOST;
424
-
508
+ this.config.ELASTICSEARCH_URL = `http://${this.config.ELASTICSEARCH_USER}:${this.config.ELASTICSEARCH_PASS}@${this.config.ELASTICSEARCH_HOST}:${this.config.ELASTICSEARCH_PORT}`;
509
+
425
510
  await this.saveConfig();
426
-
511
+
427
512
  logger.log('ok', '✅ New port configuration:');
428
513
  logger.log('info', ` 📍 MongoDB: ${mongoPort}`);
429
514
  logger.log('info', ` 📍 S3 API: ${s3Port}`);
430
515
  logger.log('info', ` 📍 S3 Console: ${s3ConsolePort}`);
516
+ logger.log('info', ` 📍 Elasticsearch: ${esPort}`);
431
517
  }
432
518
  }