Skip to content

Commit

Permalink
Merge pull request #1017 from ckeditor/i/3827-esm
Browse files Browse the repository at this point in the history
Internal: Improved the `listr2` due to the recent ESM changes.
  • Loading branch information
pomek authored Oct 3, 2024
2 parents 8a91ffa + b62716d commit 4cc0ea6
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = {
'**/dist/*',
'**/coverage/**',
'**/node_modules/**',
'**/release/**',

// ESLint does not understand `import ... with { ... }`.
// See: https://github.com/eslint/eslint/discussions/15305.
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"@ckeditor/ckeditor5-dev-ci": "^44.0.0",
"@ckeditor/ckeditor5-dev-release-tools": "^44.0.0",
"@ckeditor/ckeditor5-dev-bump-year": "^44.0.0",
"@inquirer/prompts": "^6.0.0",
"@listr2/prompt-adapter-inquirer": "^2.0.16",
"eslint": "^8.21.0",
"eslint-config-ckeditor5": "^7.0.0",
"fs-extra": "^11.0.0",
Expand Down
35 changes: 35 additions & 0 deletions scripts/preparepackages.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
/* eslint-env node */

import upath from 'upath';
import fs from 'fs-extra';
import { Listr } from 'listr2';
import { ListrInquirerPromptAdapter } from '@listr2/prompt-adapter-inquirer';
import { confirm } from '@inquirer/prompts';
import { globSync } from 'glob';
import * as releaseTools from '@ckeditor/ckeditor5-dev-release-tools';
import parseArguments from './utils/parsearguments.js';
Expand Down Expand Up @@ -48,6 +51,38 @@ const tasks = new Listr( [
return false;
}
},
{
title: 'Check the release directory.',
task: async ( ctx, task ) => {
const isAvailable = await fs.exists( RELEASE_DIRECTORY );

if ( !isAvailable ) {
return fs.ensureDir( RELEASE_DIRECTORY );
}

const isEmpty = ( await fs.readdir( RELEASE_DIRECTORY ) ).length === 0;

if ( isEmpty ) {
return Promise.resolve();
}

// Do not ask when running on CI.
if ( cliArguments.ci ) {
return fs.emptyDir( RELEASE_DIRECTORY );
}

const shouldContinue = await task.prompt( ListrInquirerPromptAdapter )
.run( confirm, {
message: 'The release directory must be empty. Continue and remove all files?'
} );

if ( !shouldContinue ) {
return Promise.reject( 'Aborting as requested.' );
}

return fs.emptyDir( RELEASE_DIRECTORY );
}
},
{
title: 'Updating the `#version` field.',
task: () => {
Expand Down
5 changes: 4 additions & 1 deletion scripts/publishpackages.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/* eslint-env node */

import { Listr } from 'listr2';
import { ListrInquirerPromptAdapter } from '@listr2/prompt-adapter-inquirer';
import { confirm } from '@inquirer/prompts';
import * as releaseTools from '@ckeditor/ckeditor5-dev-release-tools';
import parseArguments from './utils/parsearguments.js';
import getListrOptions from './utils/getlistroptions.js';
Expand Down Expand Up @@ -37,7 +39,8 @@ const tasks = new Listr( [
return true;
}

return task.prompt( { type: 'Confirm', message: 'Do you want to continue?' } );
return task.prompt( ListrInquirerPromptAdapter )
.run( confirm, { message: 'Do you want to continue?' } );
}
} );
},
Expand Down

0 comments on commit 4cc0ea6

Please sign in to comment.