update to smartconfig
This commit is contained in:
@@ -8,7 +8,7 @@ export interface IReleaseConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Manages release configuration stored in npmextra.json
|
||||
* Manages release configuration stored in .smartconfig.json
|
||||
* under @git.zone/cli.release namespace
|
||||
*/
|
||||
export class ReleaseConfig {
|
||||
@@ -30,14 +30,14 @@ export class ReleaseConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Load configuration from npmextra.json
|
||||
* Load configuration from .smartconfig.json
|
||||
*/
|
||||
public async load(): Promise<void> {
|
||||
const npmextraInstance = new plugins.npmextra.Smartconfig(this.cwd);
|
||||
const gitzoneConfig = npmextraInstance.dataFor<any>('@git.zone/cli', {});
|
||||
const smartconfigInstance = new plugins.smartconfig.Smartconfig(this.cwd);
|
||||
const gitzoneConfig = smartconfigInstance.dataFor<any>('@git.zone/cli', {});
|
||||
|
||||
// Also check szci for backward compatibility
|
||||
const szciConfig = npmextraInstance.dataFor<any>('@ship.zone/szci', {});
|
||||
const szciConfig = smartconfigInstance.dataFor<any>('@ship.zone/szci', {});
|
||||
|
||||
this.config = {
|
||||
registries: gitzoneConfig?.release?.registries || [],
|
||||
@@ -46,37 +46,37 @@ export class ReleaseConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Save configuration to npmextra.json
|
||||
* Save configuration to .smartconfig.json
|
||||
*/
|
||||
public async save(): Promise<void> {
|
||||
const npmextraPath = plugins.path.join(this.cwd, 'smartconfig.json');
|
||||
let npmextraData: any = {};
|
||||
const smartconfigPath = plugins.path.join(this.cwd, '.smartconfig.json');
|
||||
let smartconfigData: any = {};
|
||||
|
||||
// Read existing npmextra.json
|
||||
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 (await plugins.smartfs.file(smartconfigPath).exists()) {
|
||||
const content = await plugins.smartfs.file(smartconfigPath).encoding('utf8').read();
|
||||
smartconfigData = JSON.parse(content as string);
|
||||
}
|
||||
|
||||
// Ensure @git.zone/cli namespace exists
|
||||
if (!npmextraData['@git.zone/cli']) {
|
||||
npmextraData['@git.zone/cli'] = {};
|
||||
if (!smartconfigData['@git.zone/cli']) {
|
||||
smartconfigData['@git.zone/cli'] = {};
|
||||
}
|
||||
|
||||
// Ensure release object exists
|
||||
if (!npmextraData['@git.zone/cli'].release) {
|
||||
npmextraData['@git.zone/cli'].release = {};
|
||||
if (!smartconfigData['@git.zone/cli'].release) {
|
||||
smartconfigData['@git.zone/cli'].release = {};
|
||||
}
|
||||
|
||||
// Update registries and accessLevel
|
||||
npmextraData['@git.zone/cli'].release.registries = this.config.registries;
|
||||
npmextraData['@git.zone/cli'].release.accessLevel = this.config.accessLevel;
|
||||
smartconfigData['@git.zone/cli'].release.registries = this.config.registries;
|
||||
smartconfigData['@git.zone/cli'].release.accessLevel = this.config.accessLevel;
|
||||
|
||||
// Write back to file
|
||||
await plugins.smartfs
|
||||
.file(npmextraPath)
|
||||
.file(smartconfigPath)
|
||||
.encoding('utf8')
|
||||
.write(JSON.stringify(npmextraData, null, 2));
|
||||
.write(JSON.stringify(smartconfigData, null, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user