Skip to content

Commit

Permalink
Other (release-tools): Do not use the cached values when asking the n…
Browse files Browse the repository at this point in the history
…pm registry about a package. Closes ckeditor/ckeditor5#17328.
  • Loading branch information
pomek committed Oct 25, 2024
1 parent b2bf6d3 commit 42f5c98
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import pacote from 'pacote';
* @returns {Promise}
*/
export default async function checkVersionAvailability( version, packageName ) {
return pacote.manifest( `${ packageName }@${ version }` )
return pacote.manifest( `${ packageName }@${ version }`, { cache: null } )
.then( () => {
// If `pacote.manifest` resolves, a package with the given version exists.
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import pacote from 'pacote';
* @returns {Promise.<boolean>}
*/
export default async function isVersionPublishableForTag( packageName, version, npmTag ) {
const npmVersion = await pacote.manifest( `${ packageName }@${ npmTag }` )
const npmVersion = await pacote.manifest( `${ packageName }@${ npmTag }`, { cache: null } )
.then( ( { version } ) => version )
// An `npmTag` does not exist, or it's a first release of a package.
.catch( () => null );
Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor5-dev-release-tools/lib/utils/versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function getLastFromChangelog( cwd = process.cwd() ) {
export function getLastPreRelease( releaseIdentifier, cwd = process.cwd() ) {
const packageName = getPackageJson( cwd ).name;

return pacote.packument( packageName )
return pacote.packument( packageName, { cache: null } )
.then( result => {
const lastVersion = Object.keys( result.versions )
.filter( version => version.startsWith( releaseIdentifier ) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe( 'checkVersionAvailability()', () => {

await expect( checkVersionAvailability( '1.0.1', 'stub-package' ) ).resolves.toBe( true );

expect( pacote.manifest ).toHaveBeenCalledExactlyOnceWith( 'stub-package@1.0.1' );
expect( pacote.manifest ).toHaveBeenCalledExactlyOnceWith( 'stub-package@1.0.1', { cache: null } );
} );
it( 'should resolve to false if version exists', async () => {
pacote.manifest.mockResolvedValue( '1.0.1' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe( 'isVersionPublishableForTag()', () => {

expect( result ).to.equal( false );
expect( semver.lte ).toHaveBeenCalledExactlyOnceWith( '1.0.0', '1.0.0' );
expect( pacote.manifest ).toHaveBeenCalledExactlyOnceWith( 'package-name@latest' );
expect( pacote.manifest ).toHaveBeenCalledExactlyOnceWith( 'package-name@latest', { cache: null } );
} );

it( 'should return false if given version is not higher than the latest published', async () => {
Expand All @@ -46,6 +46,6 @@ describe( 'isVersionPublishableForTag()', () => {

expect( result ).to.equal( true );
expect( semver.lte ).not.toHaveBeenCalled();
expect( pacote.manifest ).toHaveBeenCalledExactlyOnceWith( 'package-name@alpha' );
expect( pacote.manifest ).toHaveBeenCalledExactlyOnceWith( 'package-name@alpha', expect.any( Object ) );
} );
} );
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe( 'versions', () => {
return getLastPreRelease( '42.0.0-alpha' )
.then( () => {
expect( vi.mocked( pacote ).packument ).toHaveBeenCalledTimes( 1 );
expect( vi.mocked( pacote ).packument ).toHaveBeenCalledWith( 'ckeditor5' );
expect( vi.mocked( pacote ).packument ).toHaveBeenCalledWith( 'ckeditor5', { cache: null } );
} );
} );

Expand Down

0 comments on commit 42f5c98

Please sign in to comment.