This commit is contained in:
2025-12-14 01:42:59 +00:00
parent 48c4b0c9b2
commit 7bb2f65669
6 changed files with 135 additions and 15 deletions

View File

@@ -1,7 +1,10 @@
import * as plugins from './mod.plugins.js';
export type TAccessLevel = 'public' | 'private';
export interface IReleaseConfig {
registries: string[];
accessLevel: TAccessLevel;
}
/**
@@ -14,7 +17,7 @@ export class ReleaseConfig {
constructor(cwd: string = process.cwd()) {
this.cwd = cwd;
this.config = { registries: [] };
this.config = { registries: [], accessLevel: 'public' };
}
/**
@@ -33,8 +36,12 @@ export class ReleaseConfig {
const npmextraInstance = new plugins.npmextra.Npmextra(this.cwd);
const gitzoneConfig = npmextraInstance.dataFor<any>('@git.zone/cli', {});
// Also check szci for backward compatibility
const szciConfig = npmextraInstance.dataFor<any>('@ship.zone/szci', {});
this.config = {
registries: gitzoneConfig?.release?.registries || [],
accessLevel: gitzoneConfig?.release?.accessLevel || szciConfig?.npmAccessLevel || 'public',
};
}
@@ -61,8 +68,9 @@ export class ReleaseConfig {
npmextraData['@git.zone/cli'].release = {};
}
// Update registries
// Update registries and accessLevel
npmextraData['@git.zone/cli'].release.registries = this.config.registries;
npmextraData['@git.zone/cli'].release.accessLevel = this.config.accessLevel;
// Write back to file
await plugins.smartfs
@@ -123,6 +131,20 @@ export class ReleaseConfig {
this.config.registries = [];
}
/**
* Get the npm access level
*/
public getAccessLevel(): TAccessLevel {
return this.config.accessLevel;
}
/**
* Set the npm access level
*/
public setAccessLevel(level: TAccessLevel): void {
this.config.accessLevel = level;
}
/**
* Normalize a registry URL (ensure it has https:// prefix)
*/