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

@@ -22,6 +22,10 @@ export const run = async (argvArg: any) => {
case 'clear':
await handleClear();
break;
case 'access':
case 'accessLevel':
await handleAccessLevel(value);
break;
default:
showHelp();
}
@@ -33,13 +37,18 @@ export const run = async (argvArg: any) => {
async function handleShow(): Promise<void> {
const config = await ReleaseConfig.fromCwd();
const registries = config.getRegistries();
const accessLevel = config.getAccessLevel();
console.log('');
console.log('╭─────────────────────────────────────────────────────────────╮');
console.log('│ Release Registry Configuration │');
console.log('│ Release Configuration │');
console.log('╰─────────────────────────────────────────────────────────────╯');
console.log('');
// Show access level
plugins.logger.log('info', `Access Level: ${accessLevel}`);
console.log('');
if (registries.length === 0) {
plugins.logger.log('info', 'No release registries configured.');
console.log('');
@@ -146,6 +155,42 @@ async function handleClear(): Promise<void> {
}
}
/**
* Set or toggle access level
*/
async function handleAccessLevel(level?: string): Promise<void> {
const config = await ReleaseConfig.fromCwd();
const currentLevel = config.getAccessLevel();
if (!level) {
// Interactive mode - toggle or ask
const interactInstance = new plugins.smartinteract.SmartInteract();
const response = await interactInstance.askQuestion({
type: 'list',
name: 'accessLevel',
message: 'Select npm access level for publishing:',
choices: ['public', 'private'],
default: currentLevel,
});
level = (response as any).value;
}
// Validate the level
if (level !== 'public' && level !== 'private') {
plugins.logger.log('error', `Invalid access level: ${level}. Must be 'public' or 'private'.`);
return;
}
if (level === currentLevel) {
plugins.logger.log('info', `Access level is already set to: ${level}`);
return;
}
config.setAccessLevel(level as 'public' | 'private');
await config.save();
plugins.logger.log('success', `Access level set to: ${level}`);
}
/**
* Show help for config command
*/
@@ -154,10 +199,11 @@ function showHelp(): void {
console.log('Usage: gitzone config <command> [options]');
console.log('');
console.log('Commands:');
console.log(' show Display current registry configuration');
console.log(' add [url] Add a registry URL');
console.log(' remove [url] Remove a registry URL');
console.log(' clear Clear all registries');
console.log(' show Display current release configuration');
console.log(' add [url] Add a registry URL');
console.log(' remove [url] Remove a registry URL');
console.log(' clear Clear all registries');
console.log(' access [public|private] Set npm access level for publishing');
console.log('');
console.log('Examples:');
console.log(' gitzone config show');
@@ -165,5 +211,7 @@ function showHelp(): void {
console.log(' gitzone config add https://verdaccio.example.com');
console.log(' gitzone config remove https://registry.npmjs.org');
console.log(' gitzone config clear');
console.log(' gitzone config access public');
console.log(' gitzone config access private');
console.log('');
}