Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating a changelog for a monorepository #1090

Open
wants to merge 18 commits into
base: epic/ck/18051-changeset
Choose a base branch
from

Conversation

martnpaneq
Copy link
Contributor

Suggested merge commit message (convention)

Feature: Generating a changelog for a monorepository. Closes ckeditor/ckeditor5#18063.


Additional information

For example – encountered issues, assumptions you had to make, other affected tickets, etc.

@coveralls
Copy link

coveralls commented Mar 26, 2025

Coverage Status

coverage: 88.04% (-0.005%) from 88.045%
when pulling 18a789e on ck/18063-changelog-for-monorepository
into 8ed77ce on epic/ck/18051-changeset.

Copy link
Contributor

@psmyrek psmyrek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First review part.

@psmyrek
Copy link
Contributor

psmyrek commented Mar 27, 2025

Please merge master branch to epic branch and ck/18063-changelog-for-monorepository.

@psmyrek
Copy link
Contributor

psmyrek commented Mar 27, 2025

Is the lack of bin intentional?

@psmyrek
Copy link
Contributor

psmyrek commented Mar 27, 2025

When there is no .changelog directory, the following code:

It seems that current implementation expects that at least one major and at least one minor breaking change is found.
When there is no items without major and minor breaking changes, the following code:

import { generateChangelog } from '@ckeditor/ckeditor5-dev-changelog';

generateChangelog( {
    cwd: process.cwd()
} );

throws an error:

� Listing the changes...

� Determining the new version...

file:///D:/Projects/ckeditor/ckeditor5/external/ckeditor5-dev/packages/ckeditor5-dev-changelog/dist/index.js:427
    if (sectionsWithEntries.minor.entries.length || sectionsWithEntries.Feature.entries.length) {
                                          ^

TypeError: Cannot read properties of undefined (reading 'length')
    at getNewVersion (file:///D:/Projects/ckeditor/ckeditor5/external/ckeditor5-dev/packages/ckeditor5-dev-changelog/dist/index.js:427:43)
    at generateChangelog (file:///D:/Projects/ckeditor/ckeditor5/external/ckeditor5-dev/packages/ckeditor5-dev-changelog/dist/index.js:633:45)

@martnpaneq martnpaneq force-pushed the epic/ck/18051-changeset branch from fd4c5a1 to 8ed77ce Compare March 31, 2025 13:25
@martnpaneq martnpaneq force-pushed the ck/18063-changelog-for-monorepository branch from 483a500 to 0a47dab Compare March 31, 2025 13:28
@martnpaneq martnpaneq force-pushed the ck/18063-changelog-for-monorepository branch from 0a47dab to e787fa7 Compare March 31, 2025 13:31
Copy link
Contributor

@psmyrek psmyrek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a few things to consider. Other than that, LGTM.

  1. Blank line after the version question?

    ○ Determining the new version...
    
    ✔ Type the new version (current: "44.3.0", suggested: "45.0.0"): 45.0.0
    ○ Appending changes to the existing changelog...
    ○ Removing the changeset files...
    
  2. The generated changelog contains a space after the entry, but the source changeset file does not have it:

    obraz

Comment on lines +26 to +35
"@ckeditor/ckeditor5-dev-release-tools": "^47.0.0",
"chalk": "^5.0.0",
"date-fns": "^4.0.0",
"pacote": "^19.0.0",
"fs-extra": "^11.0.0",
"glob": "^10.0.0",
"gray-matter": "^4.0.3",
"inquirer": "^11.0.0",
"semver": "^7.6.3",
"upath": "^2.0.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sort dependencies alphabetically.

Comment on lines +38 to +45
cwd,
packagesDirectory = PACKAGES_DIRECTORY_NAME,
organisationNamespace = ORGANISATION_NAMESPACE,
nextVersion,
externalRepositories = [],
transformScope = defaultTransformScope,
date = format( new Date(), 'yyyy-MM-dd' ) as RawDateString,
changesetsDirectory = CHANGESET_DIRECTORY
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two proposals:

  • The cwd option could also have default value, so you don't have to specify process.cwd() in 5 other places.
  • Options with default values could be listed at the end to quickly find out what is required and what may be skipped.

{
changesetPaths: await glob( '**/*.md', { cwd: upath.join( cwd, changesetsDirectory ), absolute: true } ),
gitHubUrl: await getRepositoryUrl( cwd ),
skipLinks: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we would like to skip links in the generated changelog for the root repository, e.g. when the repository is private?

* Applies default values to the external repositories configuration.
*/
export function getExternalRepositoriesWithDefaults( externalRepositories: Array<RepositoryConfig> ): Array<Required<RepositoryConfig>> {
return externalRepositories.map( repo => ( {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is not consistent with others places:

externalRepositories.map( externalRepository =>  )
externalRepositories.map( repo =>  )

/**
* This function locates package.json files for all packages located in `packagesDirectory` in the repository structure.
*/
export async function findPathsToPackages( cwd: string, packagesDirectory: string | null, options: Options = {} ): Promise<Array<string>> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The findPathsToPackages() function is always called with includePackageJson = true, so maybe this option could be removed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few utils are not mocked: getDateFormatted, defaultTransformScope, getExternalRepositoriesWithDefaults.

};

beforeEach( () => {
vi.clearAllMocks();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that vi.clearAllMocks() is not needed, as we have test.restoreMocks = true in vitest.config.ts.


describe( 'getChangesetFilePaths', () => {
beforeEach( () => {
vi.mocked( upath.join ).mockImplementation( ( ...paths ) => paths.join( '/' ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my point of view it is not needed to mock upath. Let's treat this as an external library, like lodash.

}
} else {
for ( const entry of section.entries ) {
logInfo( `- "${ entry.data.mainContent }" (file://${ entry.changesetPath })`, { indent: 4 } );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It produces paths with backslashes on Windows which are not clickable:

 ◌ Found Invalid changes:
    - "Message." (file://D:\Projects\ckeditor\ckeditor5\.changelog\1.md)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This proposal #1090 (comment) should fix it.

...externalChangesetPaths
] );

return resolvedChangesetPaths;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to normalize all paths. On Windows glob returns paths with backslash separators.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants