Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
623b7de
TypeScript init.
pomek May 19, 2025
e399f7d
Dev-utils as TypeScript.
pomek May 20, 2025
f7243d1
TypeScript in tests.
pomek May 20, 2025
f34815c
Moved common utils between changelog and release-tools to the utils p…
pomek May 20, 2025
b548f54
Removed unnecessary dependency.
pomek May 20, 2025
3323acc
Cleanup.
pomek May 20, 2025
006c775
Expose the CK-Debug-loader (webpack).
pomek May 20, 2025
441f9a7
Moved the "getRepositoryUrl()" and "getPackageJson()" functions to ut…
pomek May 21, 2025
965c1c4
Improved types in tests.
pomek May 21, 2025
98b484c
Unify TypeScript version in ckeditor5-dev.
pomek May 21, 2025
a175b53
Code style in types.
pomek May 21, 2025
e25540d
Revert "Unify TypeScript version in ckeditor5-dev."
pomek May 21, 2025
2bcd0a4
Unify TS version in all ckeditor5-dev (bump).
pomek May 21, 2025
3b911d7
Syntax :D.
pomek May 21, 2025
45d85f9
Custom types.
pomek May 21, 2025
d2ee3e3
Unify Vitest version.
pomek May 21, 2025
58a989e
Unify TS version across the CKEditor 5 project.
pomek May 21, 2025
0fbdf46
Merge branch 'epic/ck/18051-changeset' into ck/18324-changeset-dev-ut…
pomek May 21, 2025
8cfe1aa
Fixed assertion to match the CKEditor code style.
pomek May 21, 2025
521b75d
Extracted external utils to separate files and fixed tests.
martnpaneq May 21, 2025
feab675
Update packages/ckeditor5-dev-changelog/tests/utils/validateversionhi…
martnpaneq May 22, 2025
f0b98e2
Update packages/ckeditor5-dev-changelog/tests/utils/validateversionav…
martnpaneq May 22, 2025
cb52e64
Update packages/ckeditor5-dev-changelog/tests/utils/providenewversion…
martnpaneq May 22, 2025
a5f6b0b
Update packages/ckeditor5-dev-changelog/tests/utils/providenewversion…
martnpaneq May 22, 2025
24cd8a7
Update packages/ckeditor5-dev-changelog/tests/utils/providenewversion…
martnpaneq May 22, 2025
4100267
Update packages/ckeditor5-dev-changelog/tests/utils/providenewversion…
martnpaneq May 22, 2025
edfd050
Fixed eslint.
martnpaneq May 22, 2025
b9c53a9
Fixed eslint.
martnpaneq May 22, 2025
f589dd1
Merge pull request #1135 from ckeditor/ck/18324-fix-external-utils
pomek May 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/ckeditor5-dev-build-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@types/postcss-mixins": "^9.0.5",
"@vitest/coverage-v8": "^3.1.1",
"type-fest": "^4.10.2",
"typescript": "^5.6.0",
"typescript": "5.0.4",
"vitest": "^3.1.1"
},
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

// Test importing JSON.
import settings from './settings.json' with { type: 'json' };
import settings from './settings.json' assert { type: 'json' };

// Test importing SVG.
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand Down
12 changes: 5 additions & 7 deletions packages/ckeditor5-dev-changelog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,24 @@
"dist"
],
"dependencies": {
"@ckeditor/ckeditor5-dev-release-tools": "^49.0.1",
"@ckeditor/ckeditor5-dev-utils": "^49.0.2",
"chalk": "^5.0.0",
"date-fns": "^4.0.0",
"fs-extra": "^11.0.0",
"glob": "^10.0.0",
"glob": "^11.0.1",
"gray-matter": "^4.0.3",
"inquirer": "^11.0.0",
"pacote": "^19.0.0",
"semver": "^7.6.3",
"upath": "^2.0.1"
},
"devDependencies": {
"@rollup/plugin-typescript": "^11.1.6",
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/pacote": "^11.1.8",
"@types/fs-extra": "^11.0.4",
"@vitest/coverage-v8": "^2.0.0",
"@vitest/coverage-v8": "^3.1.1",
"rollup": "^4.9.5",
"typescript": "^5.6.0",
"vitest": "^2.0.0"
"typescript": "5.0.4",
"vitest": "^3.1.1"
},
"scripts": {
"build": "rollup -c rollup.config.js",
Expand Down
9 changes: 4 additions & 5 deletions packages/ckeditor5-dev-changelog/src/generatechangelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* For licensing, see LICENSE.md.
*/

import { workspaces } from '@ckeditor/ckeditor5-dev-utils';
import { format } from 'date-fns';
import chalk from 'chalk';
import { CHANGESET_DIRECTORY, ORGANISATION_NAMESPACE, PACKAGES_DIRECTORY_NAME } from './constants.js';
Expand All @@ -15,19 +16,17 @@ import { getPackageJsons } from './utils/getreleasepackagespkgjsons.js';
import { getReleasedPackagesInfo } from './utils/getreleasedpackagesinfo.js';
import { getChangesetFilePaths } from './utils/getchangesetfilepaths.js';
import { getChangesetsParsed } from './utils/getchangesetsparsed.js';
import { getPackageJson } from './utils/getpackagejson.js';
import { getSectionsToDisplay } from './utils/getsectionstodisplay.js';
import { logInfo } from './utils/loginfo.js';
import { getDateFormatted } from './utils/getdateformatted.js';
import { defaultTransformScope } from './utils/defaulttransformscope.js';
import { getExternalRepositoriesWithDefaults } from './utils/getexternalrepositorieswithdefaults.js';
import { getRepositoryUrl } from './utils/external/getrepositoryurl.js';
import { getNewChangelog } from './utils/getnewchangelog.js';
import { removeChangesetFiles } from './utils/removechangesetfiles.js';
import { removeScope } from './utils/removescope.js';

export async function generateChangelog(
config: RepositoryConfig & GenerateChangelog & { noWrite?: false | undefined }
config: RepositoryConfig & GenerateChangelog & { noWrite?: false }
): Promise<void>;

export async function generateChangelog(
Expand All @@ -54,8 +53,8 @@ export async function generateChangelog( {
}: RepositoryConfig & GenerateChangelog ): Promise<string | void> { // eslint-disable-line @typescript-eslint/no-invalid-void-type
const externalRepositoriesWithDefaults = getExternalRepositoriesWithDefaults( externalRepositories );
const packageJsons = await getPackageJsons( cwd, packagesDirectory, externalRepositoriesWithDefaults );
const gitHubUrl = await getRepositoryUrl( cwd );
const { version: oldVersion, name: packageName } = await getPackageJson( cwd );
const gitHubUrl = await workspaces.getRepositoryUrl( cwd, { async: true } );
const { version: oldVersion, name: packageName } = await workspaces.getPackageJson( cwd, { async: true } );
const dateFormatted = getDateFormatted( date );
const changesetFilePaths = await getChangesetFilePaths( cwd, changesetsDirectory, externalRepositoriesWithDefaults, skipLinks );
let parsedChangesetFiles = await getChangesetsParsed( changesetFilePaths );
Expand Down
8 changes: 0 additions & 8 deletions packages/ckeditor5-dev-changelog/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,6 @@ export type ReleaseInfo = {
packages: Array<string>;
};

export type PackageJson = {
name: string;
version: string;
repository?: string | {
url: string;
};
};

export type TransformScope = ( name: string ) => {
displayName: string;
npmUrl: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* For licensing, see LICENSE.md.
*/

import { workspaces } from '@ckeditor/ckeditor5-dev-utils';
import { glob } from 'glob';
import upath from 'upath';
import type { ChangesetPathsWithGithubUrl, RepositoryConfig } from '../types.js';
import { getRepositoryUrl } from '../utils/external/getrepositoryurl.js';

/**
* This function collects markdown files that contain changelog entries for processing.
Expand All @@ -22,7 +22,7 @@ export async function getChangesetFilePaths(

return {
changesetPaths: changesetGlob.map( path => upath.normalize( path ) ),
gitHubUrl: await getRepositoryUrl( repo.cwd ),
gitHubUrl: await workspaces.getRepositoryUrl( repo.cwd, { async: true } ),
skipLinks: repo.skipLinks
};
} ) );
Expand All @@ -32,7 +32,7 @@ export async function getChangesetFilePaths(
const resolvedChangesetPaths = await Promise.all( [
{
changesetPaths: mainChangesetGlob.map( path => upath.normalize( path ) ),
gitHubUrl: await getRepositoryUrl( cwd ),
gitHubUrl: await workspaces.getRepositoryUrl( cwd, { async: true } ),
skipLinks
},
...externalChangesetPaths
Expand Down
5 changes: 3 additions & 2 deletions packages/ckeditor5-dev-changelog/src/utils/getnewchangelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
* For licensing, see LICENSE.md.
*/

import type { workspaces } from '@ckeditor/ckeditor5-dev-utils';
import { NPM_URL, SECTIONS, VERSIONING_POLICY_URL } from '../constants.js';
import type { PackageJson, ReleaseInfo, Section } from '../types.js';
import type { ReleaseInfo, Section } from '../types.js';

type NewChangelogOptions = {
oldVersion: string;
Expand All @@ -15,7 +16,7 @@ type NewChangelogOptions = {
releasedPackagesInfo: Array<ReleaseInfo>;
isInternal: boolean;
singlePackage: boolean;
packageJsons: Array<PackageJson>;
packageJsons: Array<workspaces.PackageJson>;
};

export function getNewChangelog( {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import chalk from 'chalk';
import semver, { type ReleaseType } from 'semver';
import type { SectionsWithEntries } from '../types.js';
import { provideNewVersionForMonorepository } from './external/providenewversionformonorepository.js';
import { provideNewVersionForMonorepository } from './providenewversionformonorepository.js';
import { logInfo } from './loginfo.js';

type NewVersionObj = {
Expand Down
15 changes: 0 additions & 15 deletions packages/ckeditor5-dev-changelog/src/utils/getpackagejson.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* For licensing, see LICENSE.md.
*/

import type { Entry, PackageJson, ReleaseInfo, SectionsWithEntries } from '../types.js';
import type { workspaces } from '@ckeditor/ckeditor5-dev-utils';
import type { Entry, ReleaseInfo, SectionsWithEntries } from '../types.js';

/**
* Generates information about packages being released in the new version.
Expand All @@ -13,7 +14,7 @@ export async function getReleasedPackagesInfo( { sections, oldVersion, newVersio
sections: SectionsWithEntries;
oldVersion: string;
newVersion: string;
packageJsons: Array<PackageJson>;
packageJsons: Array<workspaces.PackageJson>;
organisationNamespace: string;
} ): Promise<Array<ReleaseInfo>> {
const versionUpgradeText = `v${ oldVersion } => v${ newVersion }`;
Expand Down Expand Up @@ -44,7 +45,7 @@ export async function getReleasedPackagesInfo( { sections, oldVersion, newVersio
].filter( release => release.packages?.length > 0 );
}

function getNewVersionReleases( packages: Array<PackageJson> ) {
function getNewVersionReleases( packages: Array<workspaces.PackageJson> ) {
return packages
.filter( packageJson => packageJson.version === '0.0.1' )
.map( packageJson => packageJson.name )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import fs from 'fs-extra';
import type { PackageJson, RepositoryConfig } from '../types.js';
import { findPathsToPackages } from '../utils/external/findpathstopackages.js';
import type { RepositoryConfig } from '../types.js';
import { workspaces } from '@ckeditor/ckeditor5-dev-utils';

/**
* This function gathers package information from both internal and external repositories.
Expand All @@ -14,19 +14,25 @@ export async function getPackageJsons(
cwd: string,
packagesDirectory: string,
externalRepositories: Array<Required<RepositoryConfig>>
): Promise<Array<PackageJson>> {
const externalPackagesPromises = externalRepositories.map( externalRepository =>
findPathsToPackages( externalRepository.cwd, externalRepository.packagesDirectory, { includePackageJson: true } )
);
): Promise<Array<workspaces.PackageJson>> {
const externalPackagesPromises = externalRepositories.map( externalRepository => {
return workspaces.findPathsToPackages(
externalRepository.cwd,
externalRepository.packagesDirectory,
{ includePackageJson: true }
);
} );

const packagesPaths = ( await Promise.all( [
findPathsToPackages( cwd, packagesDirectory, { includeCwd: true, includePackageJson: true } ),
const promises = Promise.all( [
workspaces.findPathsToPackages( cwd, packagesDirectory, { includeCwd: true, includePackageJson: true } ),
...externalPackagesPromises
] ) ).flat();
] );

const packagesPromises = packagesPaths.map( packagePath =>
fs.readJson( packagePath )
);
const packagesPromises = ( await promises )
.flat()
.map( packagePath => {
return fs.readJson( packagePath );
} );

return Promise.all( packagesPromises );
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
* For licensing, see LICENSE.md.
*/

import type { workspaces } from '@ckeditor/ckeditor5-dev-utils';
import type {
Entry,
PackageJson,
ParsedFile,
SectionName,
SectionsWithEntries,
TransformScope
} from '../types.js';
import { SECTIONS } from '../constants.js';
import { linkToGitHubUser } from '../utils/external/linktogithubuser.js';
import { linkToGitHubUser } from '../utils/linktogithubuser.js';

type DifferentRepoIssue = { owner: string; repository: string; number: string };
const differentRepoIssuePattern = /^(?<owner>[a-z0-9.-]+)\/(?<repository>[a-z0-9.-]+)#(?<number>\d+)$/;
Expand All @@ -23,7 +23,7 @@ const sameRepoIssuePattern = /^\d+$/;
*/
export function getSectionsWithEntries( { parsedFiles, packageJsons, transformScope, organisationNamespace, singlePackage }: {
parsedFiles: Array<ParsedFile>;
packageJsons: Array<PackageJson>;
packageJsons: Array<workspaces.PackageJson>;
transformScope: TransformScope;
organisationNamespace: string;
singlePackage: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import upath from 'upath';
import fs from 'fs-extra';
import chalk from 'chalk';
import { logInfo } from './loginfo.js';
import { truncateChangelog } from '../utils/external/truncatechangelog.js';
import { truncateChangelog } from '../utils/truncatechangelog.js';
import { CHANGELOG_FILE, CHANGELOG_HEADER } from '../constants.js';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
import semver, { type ReleaseType } from 'semver';
import chalk from 'chalk';
import inquirer from 'inquirer';
import { randomUUID } from 'crypto';
import upath from 'upath';
import os from 'os';
import fs from 'fs-extra';
import pacote from 'pacote';
import { validateVersionAvailability } from './validateversionavailability.js';
import { validateVersionHigherThanCurrent } from './validateversionhigherthancurrent.js';

const CLI_INDENT_SIZE = 3;

Expand All @@ -33,8 +30,6 @@ type Question = {
prefix: string;
};

const manifest = cacheLessPacoteFactory( pacote.manifest );

/**
* This function displays a prompt to provide a new version for all packages in the repository.
* The version is being validated e.g. invalid version format or already used version are not accepted.
Expand Down Expand Up @@ -62,40 +57,6 @@ function validateVersionFormat( version: string ): VersionValidationResult {
return true;
}

/**
* Validates if the provided version is higher than the current one.
*/
export function validateVersionHigherThanCurrent( version: string, currentVersion: string ): VersionValidationResult {
// Skip this validation for 'internal' version
if ( version === 'internal' ) {
return true;
}

if ( !semver.gt( version, currentVersion ) ) {
return `Provided version must be higher than "${ currentVersion }".`;
}

return true;
}

/**
* Validates if the provided version is available in the npm registry.
*/
export async function validateVersionAvailability( version: string, packageName: string ): Promise<VersionValidationResult> {
// Skip this validation for 'internal' version
if ( version === 'internal' ) {
return true;
}

const isAvailable = await checkVersionAvailability( version, packageName );

if ( !isAvailable ) {
return 'Given version is already taken.';
}

return true;
}

/**
* Creates a prompt question for version input with validation.
*/
Expand Down Expand Up @@ -134,42 +95,3 @@ function createVersionQuestion( options: Options ): Array<Question> {
prefix: ' '.repeat( indentLevel * CLI_INDENT_SIZE ) + chalk.cyan( '?' )
} ];
}

/**
* Checks if a specific version of a package is available in the npm registry.
*/
async function checkVersionAvailability( version: string, packageName: string ): Promise<boolean> {
return manifest( `${ packageName }@${ version }` )
.then( () => {
// If `manifest` resolves, a package with the given version exists.
return false;
} )
.catch( () => {
// When throws, the package does not exist.
return true;
} );
}

/**
* Creates a version of a pacote function that doesn't use caching.
*/
function cacheLessPacoteFactory( callback: typeof pacote.manifest ) {
return async ( description: string, options = {} ) => {
const uuid = randomUUID();
const cacheDir = upath.join( os.tmpdir(), `pacote--${ uuid }` );

await fs.ensureDir( cacheDir );

try {
return await callback( description, {
...options,
cache: cacheDir,
memoize: false,
preferOnline: true
} );
} finally {
await fs.remove( cacheDir );
}
};
}

Loading