From 0d92e692724ed5e371f41430841da80b47bea200 Mon Sep 17 00:00:00 2001 From: David Snelling Date: Fri, 1 Aug 2025 17:33:28 -0700 Subject: [PATCH] **refactor(scripts): improve readability and consistency in release-workflow.js** - Updated formatting for better readability in console messages and user prompts. - Simplified asynchronous logic in user interaction flow by restructuring `readline` handling. - Adjusted NPM script calls to match conventions (e.g., `_release`, `_github-release`). - Improved maintainability by adhering to consistent code style and linting guidelines. **Purpose**: Enhance code clarity and consistency in the release workflow script to improve developer experience and reduce potential errors. --- scripts/release-workflow.js | 41 ++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/scripts/release-workflow.js b/scripts/release-workflow.js index 3fc4ff59..7d0de1cc 100755 --- a/scripts/release-workflow.js +++ b/scripts/release-workflow.js @@ -53,7 +53,9 @@ function executeStep(command, description) { return true } catch (error) { // eslint-disable-next-line no-console - console.error(`❌ Error during ${description.toLowerCase()}: ${error.message}`) + console.error( + `❌ Error during ${description.toLowerCase()}: ${error.message}` + ) return false } } @@ -72,45 +74,56 @@ async function runReleaseWorkflow() { // Step 2: Run tests to ensure everything is working if (!executeStep('npm test', 'Running tests')) { // eslint-disable-next-line no-console - console.warn('⚠️ Tests failed. This might indicate issues with the release.') - + console.warn( + '⚠️ Tests failed. This might indicate issues with the release.' + ) + // Ask the user if they want to continue despite test failures // eslint-disable-next-line no-console - console.log('\n⚠️ Do you want to continue with the release process despite test failures? (y/N)') - + console.log( + '\n⚠️ Do you want to continue with the release process despite test failures? (y/N)' + ) + const readline = require('readline').createInterface({ input: process.stdin, output: process.stdout }) - - const response = await new Promise(resolve => { - readline.question('', answer => { + + const response = await new Promise((resolve) => { + readline.question('', (answer) => { readline.close() resolve(answer.toLowerCase()) }) }) - + if (response !== 'y' && response !== 'yes') { // eslint-disable-next-line no-console console.error('Release process aborted due to test failures.') // eslint-disable-next-line no-process-exit process.exit(1) } - + // eslint-disable-next-line no-console console.log('Continuing with release process despite test failures...') } // Step 3: Update version and generate changelog - if (!executeStep(`npm run release:${versionType}`, `Updating version (${versionType}) and generating changelog`)) { + if ( + !executeStep( + `npm run _release:${versionType}`, + `Updating version (${versionType}) and generating changelog` + ) + ) { // eslint-disable-next-line no-process-exit process.exit(1) } // Step 4: Create GitHub release - if (!executeStep('npm run github-release', 'Creating GitHub release')) { + if (!executeStep('npm run _github-release', 'Creating GitHub release')) { // eslint-disable-next-line no-console - console.log('Warning: GitHub release creation failed, but continuing with deployment...') + console.log( + 'Warning: GitHub release creation failed, but continuing with deployment...' + ) } // Step 5: Publish to NPM @@ -143,7 +156,7 @@ async function runReleaseWorkflow() { } // Run the workflow -runReleaseWorkflow().catch(error => { +runReleaseWorkflow().catch((error) => { // eslint-disable-next-line no-console console.error('Unexpected error during release workflow:', error) // eslint-disable-next-line no-process-exit