update to smartconfig

This commit is contained in:
2026-03-24 16:10:51 +00:00
parent eda67395fe
commit d0d922e53b
41 changed files with 425 additions and 2091 deletions

View File

@@ -31,7 +31,7 @@ export class ServiceManager {
await this.config.loadOrCreate();
logger.log('info', `📋 Project: ${this.config.getConfig().PROJECT_NAME}`);
// Load service selection from npmextra.json
// Load service selection from .smartconfig.json
await this.loadServiceConfiguration();
// Validate and update ports if needed
@@ -39,11 +39,11 @@ export class ServiceManager {
}
/**
* Load service configuration from npmextra.json
* Load service configuration from .smartconfig.json
*/
private async loadServiceConfiguration(): Promise<void> {
const npmextraConfig = new plugins.npmextra.Smartconfig(process.cwd());
const gitzoneConfig = npmextraConfig.dataFor<any>('@git.zone/cli', {});
const smartconfigInstance = new plugins.smartconfig.Smartconfig(process.cwd());
const gitzoneConfig = smartconfigInstance.dataFor<any>('@git.zone/cli', {});
// Check if services array exists
if (!gitzoneConfig.services || !Array.isArray(gitzoneConfig.services) || gitzoneConfig.services.length === 0) {
@@ -63,7 +63,7 @@ export class ServiceManager {
this.enabledServices = response.value || ['mongodb', 'minio', 'elasticsearch'];
// Save to npmextra.json
// Save to .smartconfig.json
await this.saveServiceConfiguration(this.enabledServices);
} else {
this.enabledServices = gitzoneConfig.services;
@@ -72,31 +72,31 @@ export class ServiceManager {
}
/**
* Save service configuration to npmextra.json
* Save service configuration to .smartconfig.json
*/
private async saveServiceConfiguration(services: string[]): Promise<void> {
const npmextraPath = plugins.path.join(process.cwd(), 'smartconfig.json');
let npmextraData: any = {};
const smartconfigPath = plugins.path.join(process.cwd(), '.smartconfig.json');
let smartconfigData: any = {};
// Read existing npmextra.json if it exists
if (await plugins.smartfs.file(npmextraPath).exists()) {
const content = await plugins.smartfs.file(npmextraPath).encoding('utf8').read();
npmextraData = JSON.parse(content as string);
// Read existing .smartconfig.json if it exists
if (await plugins.smartfs.file(smartconfigPath).exists()) {
const content = await plugins.smartfs.file(smartconfigPath).encoding('utf8').read();
smartconfigData = JSON.parse(content as string);
}
// Update @git.zone/cli.services
if (!npmextraData['@git.zone/cli']) {
npmextraData['@git.zone/cli'] = {};
if (!smartconfigData['@git.zone/cli']) {
smartconfigData['@git.zone/cli'] = {};
}
npmextraData['@git.zone/cli'].services = services;
smartconfigData['@git.zone/cli'].services = services;
// Write back to npmextra.json
// Write back to .smartconfig.json
await plugins.smartfs
.file(npmextraPath)
.file(smartconfigPath)
.encoding('utf8')
.write(JSON.stringify(npmextraData, null, 2));
.write(JSON.stringify(smartconfigData, null, 2));
logger.log('ok', `✅ Saved service configuration to npmextra.json`);
logger.log('ok', `✅ Saved service configuration to .smartconfig.json`);
logger.log('info', `🔧 Enabled services: ${services.join(', ')}`);
}
@@ -904,7 +904,7 @@ export class ServiceManager {
this.enabledServices = response.value || ['mongodb', 'minio', 'elasticsearch'];
// Save to npmextra.json
// Save to .smartconfig.json
await this.saveServiceConfiguration(this.enabledServices);
logger.log('ok', '✅ Service configuration updated');