feat(cli): Add optional build step to release flow and auto-format npmextra config when registries change

This commit is contained in:
2025-12-14 10:51:16 +00:00
parent ccdca55c9a
commit 7348567a62
6 changed files with 97 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ import { ReleaseConfig } from '../mod_config/classes.releaseconfig.js';
export const run = async (argvArg: any) => {
// Check if release flag is set and validate registries early
const wantsRelease = !!(argvArg.r || argvArg.release);
const wantsBuild = !!(argvArg.b || argvArg.build);
let releaseConfig: ReleaseConfig | null = null;
if (wantsRelease) {
@@ -153,6 +154,7 @@ export const run = async (argvArg: any) => {
const willPush = answerBucket.getAnswerFor('pushToOrigin') && !(process.env.CI === 'true');
const willRelease = answerBucket.getAnswerFor('createRelease') && releaseConfig?.hasRegistries();
let totalSteps = 5; // Base steps: commitinfo, changelog, staging, commit, version
if (wantsBuild) totalSteps += 2; // build step + verification step
if (willPush) totalSteps++;
if (willRelease) totalSteps++;
let currentStep = 0;
@@ -215,7 +217,34 @@ export const run = async (argvArg: any) => {
const projectType = await helpers.detectProjectType();
const newVersion = await helpers.bumpProjectVersion(projectType, commitVersionType, currentStep, totalSteps);
// Step 6: Push to remote (optional)
// Step 6: Run build (optional)
if (wantsBuild) {
currentStep++;
ui.printStep(currentStep, totalSteps, '🔨 Running build', 'in-progress');
const buildResult = await smartshellInstance.exec('pnpm build');
if (buildResult.exitCode !== 0) {
ui.printStep(currentStep, totalSteps, '🔨 Running build', 'error');
logger.log('error', 'Build failed. Aborting release.');
process.exit(1);
}
ui.printStep(currentStep, totalSteps, '🔨 Running build', 'done');
// Step 7: Verify no uncommitted changes
currentStep++;
ui.printStep(currentStep, totalSteps, '🔍 Verifying clean working tree', 'in-progress');
const statusResult = await smartshellInstance.exec('git status --porcelain');
if (statusResult.stdout.trim() !== '') {
ui.printStep(currentStep, totalSteps, '🔍 Verifying clean working tree', 'error');
logger.log('error', 'Build produced uncommitted changes. This usually means build output is not gitignored.');
logger.log('error', 'Uncommitted files:');
console.log(statusResult.stdout);
logger.log('error', 'Aborting release. Please ensure build artifacts are in .gitignore');
process.exit(1);
}
ui.printStep(currentStep, totalSteps, '🔍 Verifying clean working tree', 'done');
}
// Step: Push to remote (optional)
const currentBranch = await helpers.detectCurrentBranch();
if (willPush) {
currentStep++;