@ckeditor/ckeditor5-dev-changelog 53.4.0 → 54.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +34 -35
  2. package/package.json +4 -6
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import chalk from 'chalk';
1
+ import { styleText } from 'util';
2
2
  import { parse, isValid, format } from 'date-fns';
3
3
  import { workspaces, npm, tools } from '@ckeditor/ckeditor5-dev-utils';
4
4
  import upath from 'upath';
5
- import fs$1 from 'fs-extra';
5
+ import fs$1 from 'fs/promises';
6
6
  import fs from 'fs';
7
7
  import semver from 'semver';
8
8
  import inquirer from 'inquirer';
@@ -369,12 +369,12 @@ function logInfo(text, { indent } = { indent: 0 }) {
369
369
  function displayChanges(options) {
370
370
  const { sections, isSinglePackage, transformScope } = options;
371
371
  let numberOfEntries = 0;
372
- logInfo(`○ ${chalk.cyan('Listing the changes...')}`);
372
+ logInfo(`○ ${styleText('cyan', 'Listing the changes...')}`);
373
373
  const nonEmptySections = Object.entries(sections)
374
374
  .filter(([, section]) => section.entries.length);
375
375
  for (const [sectionName, section] of nonEmptySections) {
376
376
  const color = getTitleColor(sectionName);
377
- logInfo('◌ ' + color(chalk.underline(`${section.titleInLogs || section.title}:`)), { indent: 1 });
377
+ logInfo('◌ ' + color(styleText('underline', `${section.titleInLogs || section.title}:`)), { indent: 1 });
378
378
  const displayCallback = sectionName === 'invalid' || sectionName === 'warning' ?
379
379
  displayWarningEntry :
380
380
  displayValidEntry;
@@ -384,9 +384,9 @@ function displayChanges(options) {
384
384
  section.entries.forEach(entry => displayCallback(entry, sectionName, isSinglePackage, transformScope));
385
385
  logInfo('');
386
386
  }
387
- logInfo('◌ ' + chalk.underline('Legend:'), { indent: 1 });
388
- logInfo(`- Entries marked with ${chalk.green('+')} symbol are included in the changelog.`, { indent: 2 });
389
- logInfo('- Entries marked with ' + chalk.yellow('x') + ' symbol include invalid references (see and/or closes) ' +
387
+ logInfo('◌ ' + styleText('underline', 'Legend:'), { indent: 1 });
388
+ logInfo(`- Entries marked with ${styleText('green', '+')} symbol are included in the changelog.`, { indent: 2 });
389
+ logInfo('- Entries marked with ' + styleText('yellow', 'x') + ' symbol include invalid references (see and/or closes) ' +
390
390
  'or scope definitions. Please ensure that:', { indent: 2 });
391
391
  logInfo('* Reference entries match one of the following formats:', { indent: 3 });
392
392
  logInfo('1. An issue number (e.g., 1000)', { indent: 4 });
@@ -399,17 +399,15 @@ function displayChanges(options) {
399
399
  }
400
400
  function getTitleColor(sectionName) {
401
401
  if (sectionName === 'warning') {
402
- return chalk.yellow;
402
+ return (text) => styleText('yellow', text);
403
403
  }
404
404
  if (sectionName === 'invalid') {
405
- return chalk.red;
405
+ return (text) => styleText('red', text);
406
406
  }
407
- let defaultColor = chalk.blue;
407
+ let defaultColor = (text) => styleText('blue', text);
408
408
  if (isBreakingChangeSection(sectionName)) {
409
409
  // To avoid tricks in tests, let's simplify the implementation.
410
- defaultColor = (value) => {
411
- return chalk.bold(chalk.blue(value));
412
- };
410
+ defaultColor = (value) => styleText(['bold', 'blue'], value);
413
411
  }
414
412
  return defaultColor;
415
413
  }
@@ -428,9 +426,9 @@ function displayValidEntry(entry, sectionName, isSinglePackage, transformScope)
428
426
  entry.data.scope.map(scope => transformScope(scope).displayName) :
429
427
  entry.data.scope;
430
428
  const scope = entry.data.scope.length ?
431
- chalk.grey(scopeFormatted?.join(', ')) :
432
- `${chalk.italic(chalk.grey('(no scope)'))}`;
433
- const validationIndicator = isEntryFullyValid ? chalk.green('+') : chalk.yellow('x');
429
+ styleText('grey', scopeFormatted?.join(', ')) :
430
+ `${styleText(['italic', 'gray'], '(no scope)')}`;
431
+ const validationIndicator = isEntryFullyValid ? styleText('green', '+') : styleText('yellow', 'x');
434
432
  const shouldTrimMessage = String(entry.data.mainContent).length > 100;
435
433
  const trimmedMessageContent = shouldTrimMessage ? entry.data.mainContent?.slice(0, 100) + '...' : entry.data.mainContent;
436
434
  if (isSinglePackage) {
@@ -504,7 +502,7 @@ async function modifyChangelog(newChangelog, cwd) {
504
502
  const changelogPath = upath.join(cwd, CHANGELOG_FILE);
505
503
  const existingChangelog = await readExistingChangelog(changelogPath);
506
504
  const updatedChangelog = prepareChangelogContent(existingChangelog, newChangelog);
507
- logInfo(`○ ${chalk.cyan('Appending changes to the existing changelog...')}`);
505
+ logInfo(`○ ${styleText('cyan', 'Appending changes to the existing changelog...')}`);
508
506
  await fs$1.writeFile(changelogPath, updatedChangelog, 'utf-8');
509
507
  await truncateChangelog(5, cwd);
510
508
  }
@@ -516,7 +514,7 @@ async function readExistingChangelog(changelogPath) {
516
514
  return await fs$1.readFile(changelogPath, 'utf-8');
517
515
  }
518
516
  catch {
519
- logInfo(`○ ${chalk.yellow('CHANGELOG.md not found.')}`);
517
+ logInfo(`○ ${styleText('yellow', 'CHANGELOG.md not found.')}`);
520
518
  return '';
521
519
  }
522
520
  }
@@ -616,10 +614,10 @@ async function provideNewVersion(options) {
616
614
  */
617
615
  function displayInvalidChangesWarning() {
618
616
  logInfo('');
619
- logInfo(chalk.yellow(chalk.bold(`⚠️ ${chalk.underline('WARNING: Invalid changes detected!')}`)));
617
+ logInfo(styleText(['yellow', 'bold'], `⚠️ ${styleText('underline', 'WARNING: Invalid changes detected!')}`));
620
618
  logInfo('');
621
- logInfo(chalk.yellow('You can cancel the process, fix the invalid files, and run the tool again.'));
622
- logInfo(chalk.yellow('Alternatively, you can continue - but invalid values will be lost.'));
619
+ logInfo(styleText('yellow', 'You can cancel the process, fix the invalid files, and run the tool again.'));
620
+ logInfo(styleText('yellow', 'Alternatively, you can continue - but invalid values will be lost.'));
623
621
  logInfo('');
624
622
  }
625
623
  /**
@@ -631,7 +629,7 @@ async function askContinueConfirmation(indentLevel = 0) {
631
629
  name: 'continue',
632
630
  message: 'Should continue?',
633
631
  default: false,
634
- prefix: ' '.repeat(indentLevel * CLI_INDENT_SIZE) + chalk.cyan('?')
632
+ prefix: ' '.repeat(indentLevel * CLI_INDENT_SIZE) + styleText('cyan', '?')
635
633
  };
636
634
  const answers = await inquirer.prompt(question);
637
635
  return answers.continue;
@@ -651,7 +649,7 @@ function createVersionQuestion(options) {
651
649
  message,
652
650
  filter: (newVersion) => newVersion.trim(),
653
651
  validate: (newVersion) => validateInputVersion({ newVersion, version, releaseType, packageName, suggestedVersion }),
654
- prefix: ' '.repeat(indentLevel * CLI_INDENT_SIZE) + chalk.cyan('?')
652
+ prefix: ' '.repeat(indentLevel * CLI_INDENT_SIZE) + styleText('cyan', '?')
655
653
  }];
656
654
  }
657
655
  function getSuggestedVersion(bumpType, version, releaseChannel) {
@@ -688,7 +686,7 @@ function detectReleaseChannel(version, promotePrerelease = false) {
688
686
  if (currentChannel === 'beta') {
689
687
  return 'rc';
690
688
  }
691
- logInfo(chalk.yellow(`Warning! Unknown release channel to promote from ${currentChannel}.`));
689
+ logInfo(styleText('yellow', `Warning! Unknown release channel to promote from ${currentChannel}.`));
692
690
  return 'alpha';
693
691
  }
694
692
  return currentChannel;
@@ -720,7 +718,7 @@ class InternalError extends Error {
720
718
  async function determineNextVersion(options) {
721
719
  const { sections, currentVersion, packageName, nextVersion, releaseType } = options;
722
720
  if (nextVersion) {
723
- logInfo(`○ ${chalk.cyan(`Determined the next version to be ${nextVersion}.`)}`);
721
+ logInfo(`○ ${styleText('cyan', `Determined the next version to be ${nextVersion}.`)}`);
724
722
  const isNightlyVersion = nextVersion.startsWith('0.0.0-');
725
723
  if (isNightlyVersion) {
726
724
  return nextVersion;
@@ -737,7 +735,7 @@ async function determineNextVersion(options) {
737
735
  }
738
736
  return nextVersion;
739
737
  }
740
- logInfo(`○ ${chalk.cyan('Determining the new version...')}`);
738
+ logInfo(`○ ${styleText('cyan', 'Determining the new version...')}`);
741
739
  let bumpType = 'patch';
742
740
  if (releaseType === 'prerelease' || releaseType === 'prerelease-promote') {
743
741
  bumpType = 'prerelease';
@@ -833,7 +831,8 @@ async function findPackages(options) {
833
831
  ]);
834
832
  return AsyncArray.from(promise)
835
833
  .flat()
836
- .map(packagePath => fs$1.readJson(packagePath))
834
+ .map(packagePath => fs.readFileSync(packagePath, 'utf-8'))
835
+ .map(packageJson => JSON.parse(packageJson))
837
836
  .map(({ name, version }) => [name, version])
838
837
  .then(entries => new Map(entries.sort(([a], [b]) => a.localeCompare(b))));
839
838
  }
@@ -1183,7 +1182,7 @@ async function composeChangelog(options) {
1183
1182
  * and removing any resulting empty directories both in the current repository and in any external repositories.
1184
1183
  */
1185
1184
  async function removeChangelogEntryFiles(entryPaths) {
1186
- logInfo(`○ ${chalk.cyan('Removing the changeset files...')}`);
1185
+ logInfo(`○ ${styleText('cyan', 'Removing the changeset files...')}`);
1187
1186
  await Promise.all(entryPaths
1188
1187
  .flatMap(repo => repo.filePaths)
1189
1188
  .map(file => fs$1.unlink(file)));
@@ -1201,12 +1200,12 @@ async function removeChangelogEntryFiles(entryPaths) {
1201
1200
  async function moveChangelogEntryFiles(entryPaths) {
1202
1201
  const targetDir = PRE_RELEASE_DIRECTORY;
1203
1202
  const modifiedEntryPaths = [];
1204
- logInfo(`○ ${chalk.cyan(`Moving changelog entries to ${targetDir}/ directory...`)}`);
1203
+ logInfo(`○ ${styleText('cyan', `Moving changelog entries to ${targetDir}/ directory...`)}`);
1205
1204
  for (const repo of entryPaths) {
1206
1205
  const { cwd, filePaths } = repo;
1207
1206
  const changelogDir = upath.join(cwd, CHANGESET_DIRECTORY);
1208
1207
  const targetPath = upath.join(changelogDir, targetDir);
1209
- await fs$1.ensureDir(targetPath);
1208
+ await fs$1.mkdir(targetPath, { recursive: true });
1210
1209
  const modifiedFilePaths = [];
1211
1210
  for (const filePath of filePaths) {
1212
1211
  const fileName = upath.basename(filePath);
@@ -1229,7 +1228,7 @@ async function moveChangelogEntryFiles(entryPaths) {
1229
1228
  */
1230
1229
  async function commitChanges(version, repositories) {
1231
1230
  const message = `Changelog for v${version}. [skip ci]`;
1232
- logInfo(`○ ${chalk.cyan('Committing changes...')}`);
1231
+ logInfo(`○ ${styleText('cyan', 'Committing changes...')}`);
1233
1232
  for (const { cwd, isRoot, filePaths } of repositories) {
1234
1233
  // Copy to avoid modifying the original array.
1235
1234
  const files = filePaths.slice(0);
@@ -1240,7 +1239,7 @@ async function commitChanges(version, repositories) {
1240
1239
  await tools.commit({ cwd, message, files })
1241
1240
  .catch(error => {
1242
1241
  logInfo('An error occurred while committing changes.', { indent: 2 });
1243
- logInfo(chalk.red(error.message), { indent: 2 });
1242
+ logInfo(styleText('red', error.message), { indent: 2 });
1244
1243
  });
1245
1244
  }
1246
1245
  }
@@ -1348,7 +1347,7 @@ const main = async (options) => {
1348
1347
  // Exit when no changelog entries exist.
1349
1348
  if (!parsedChangesetFiles.length) {
1350
1349
  logInfo('');
1351
- logInfo(chalk.bold('ℹ️ No changelog entries found, so there is nothing to prepare a changelog from.'));
1350
+ logInfo(styleText('bold', 'ℹ️ No changelog entries found, so there is nothing to prepare a changelog from.'));
1352
1351
  return disableFilesystemOperations ? '' : undefined;
1353
1352
  }
1354
1353
  // Log changes in the console only when `nextVersion` is not provided.
@@ -1395,7 +1394,7 @@ const main = async (options) => {
1395
1394
  }
1396
1395
  await modifyChangelog(newChangelog, cwd);
1397
1396
  await commitChanges(newVersion, pathsToCommit.map(({ cwd, isRoot, filePaths }) => ({ cwd, isRoot, filePaths })));
1398
- logInfo('○ ' + chalk.green('Done!'));
1397
+ logInfo('○ ' + styleText('green', 'Done!'));
1399
1398
  };
1400
1399
  /**
1401
1400
  * Entry point for generating a changelog with error handling.
@@ -1415,7 +1414,7 @@ const generateChangelog = async (options) => {
1415
1414
  throw error;
1416
1415
  }
1417
1416
  else {
1418
- console.error(chalk.red('Error: ' + error.message));
1417
+ console.error(styleText('red', 'Error: ' + error.message));
1419
1418
  process.exit(1);
1420
1419
  }
1421
1420
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-dev-changelog",
3
- "version": "53.4.0",
3
+ "version": "54.1.0",
4
4
  "description": "A CKEditor 5 development tool for handling changelogs.",
5
5
  "keywords": [],
6
6
  "author": "CKSource (http://cksource.com/)",
@@ -13,7 +13,7 @@
13
13
  "directory": "packages/ckeditor5-dev-changelog"
14
14
  },
15
15
  "engines": {
16
- "node": ">=22.0.0",
16
+ "node": ">=24.11.0",
17
17
  "npm": ">=5.7.1"
18
18
  },
19
19
  "type": "module",
@@ -28,14 +28,12 @@
28
28
  "ckeditor5-dev-changelog-create-entry": "bin/generate-template.js"
29
29
  },
30
30
  "dependencies": {
31
- "@ckeditor/ckeditor5-dev-utils": "^53.4.0",
32
- "chalk": "^5.0.0",
31
+ "@ckeditor/ckeditor5-dev-utils": "^54.1.0",
33
32
  "date-fns": "^4.0.0",
34
- "fs-extra": "^11.0.0",
35
33
  "glob": "^11.0.2",
36
34
  "gray-matter": "^4.0.3",
37
35
  "inquirer": "^12.5.2",
38
36
  "semver": "^7.6.3",
39
37
  "upath": "^2.0.1"
40
38
  }
41
- }
39
+ }