@ckeditor/ckeditor5-dev-release-tools 53.0.0 → 53.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.
package/lib/index.js CHANGED
@@ -23,14 +23,16 @@ export {
23
23
  getNextInternal,
24
24
  getCurrent,
25
25
  getDateIdentifier,
26
- getLastTagFromGit
26
+ getLastTagFromGit,
27
+ getVersionForTag,
28
+ isLatestOrNextStableVersion,
29
+ isVersionPublishableForTag
27
30
  } from './utils/versions.js';
28
31
  export { default as getChangesForVersion } from './utils/getchangesforversion.js';
29
32
  export { default as getChangelog } from './utils/getchangelog.js';
30
33
  export { default as executeInParallel } from './utils/executeinparallel.js';
31
34
  export { default as validateRepositoryToRelease } from './utils/validaterepositorytorelease.js';
32
35
  export { default as getNpmTagFromVersion } from './utils/getnpmtagfromversion.js';
33
- export { default as isVersionPublishableForTag } from './utils/isversionpublishablefortag.js';
34
36
  export { default as provideToken } from './utils/providetoken.js';
35
37
 
36
38
  // Backwards compatibility for the old API.
@@ -3,6 +3,7 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
+ import semver from 'semver';
6
7
  import { npm, tools, workspaces } from '@ckeditor/ckeditor5-dev-utils';
7
8
  import getChangelog from './getchangelog.js';
8
9
 
@@ -162,6 +163,61 @@ export function getDateIdentifier() {
162
163
  return `${ year }${ month }${ day }`;
163
164
  }
164
165
 
166
+ /**
167
+ * Returns the latest version of the package on the npm tag.
168
+ * If the package does not have any version on that tag yet, `null` is returned.
169
+ *
170
+ * @param {string} packageName
171
+ * @param {string} npmTag
172
+ * @returns {Promise.<string|null>}
173
+ */
174
+ export function getVersionForTag( packageName, npmTag ) {
175
+ return npm.manifest( `${ packageName }@${ npmTag }` )
176
+ .then( result => result.version )
177
+ .catch( () => null );
178
+ }
179
+
180
+ /**
181
+ * Checks if the version can be considered as the newest stable release of the package.
182
+ * It checks whether the version given in the argument is or could be the latest version.
183
+ * The package may not have this version published on npm yet, but it is also considered as the latest stable.
184
+ *
185
+ * @param {string} packageName
186
+ * @param {string} version
187
+ * @returns {Promise.<boolean>}
188
+ */
189
+ export async function isLatestOrNextStableVersion( packageName, version ) {
190
+ if ( semver.prerelease( version ) ) {
191
+ return false;
192
+ }
193
+
194
+ const npmVersion = await getVersionForTag( packageName, 'latest' );
195
+
196
+ if ( npmVersion && semver.lt( version, npmVersion ) ) {
197
+ return false;
198
+ }
199
+
200
+ return true;
201
+ }
202
+
203
+ /**
204
+ * Verifies if the package can be published in the provided version on the npm tag.
205
+ *
206
+ * @param {string} packageName
207
+ * @param {string} version
208
+ * @param {string} npmTag
209
+ * @returns {Promise.<boolean>}
210
+ */
211
+ export async function isVersionPublishableForTag( packageName, version, npmTag ) {
212
+ const npmVersion = await getVersionForTag( packageName, npmTag );
213
+
214
+ if ( npmVersion && semver.lte( version, npmVersion ) ) {
215
+ return false;
216
+ }
217
+
218
+ return true;
219
+ }
220
+
165
221
  /**
166
222
  * @typedef {string} ReleaseIdentifier The pre-release identifier without the last dynamic part (the pre-release sequential number).
167
223
  * It consists of the core base version ("<major>.<minor>.<path>"), a hyphen ("-"), and a pre-release identifier name (e.g. "alpha").
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-dev-release-tools",
3
- "version": "53.0.0",
3
+ "version": "53.1.0",
4
4
  "description": "Tools used for releasing CKEditor 5 and related packages.",
5
5
  "keywords": [],
6
6
  "author": "CKSource (http://cksource.com/)",
@@ -22,7 +22,7 @@
22
22
  "lib"
23
23
  ],
24
24
  "dependencies": {
25
- "@ckeditor/ckeditor5-dev-utils": "^53.0.0",
25
+ "@ckeditor/ckeditor5-dev-utils": "^53.1.0",
26
26
  "@octokit/rest": "^22.0.0",
27
27
  "chalk": "^5.0.0",
28
28
  "cli-columns": "^4.0.0",
@@ -1,28 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md.
4
- */
5
-
6
- import { npm } from '@ckeditor/ckeditor5-dev-utils';
7
- import semver from 'semver';
8
-
9
- /**
10
- * This util aims to verify if the given `packageName` can be published with the given `version` on the `npmTag`.
11
- *
12
- * @param {string} packageName
13
- * @param {string} version
14
- * @param {string} npmTag
15
- * @returns {Promise.<boolean>}
16
- */
17
- export default async function isVersionPublishableForTag( packageName, version, npmTag ) {
18
- const npmVersion = await npm.manifest( `${ packageName }@${ npmTag }` )
19
- .then( ( { version } ) => version )
20
- // An `npmTag` does not exist, or it's the first release of a package.
21
- .catch( () => null );
22
-
23
- if ( npmVersion && semver.lte( version, npmVersion ) ) {
24
- return false;
25
- }
26
-
27
- return true;
28
- }