@ckeditor/ckeditor5-dev-release-tools 46.0.1 → 46.0.3

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
@@ -22,6 +22,7 @@ export {
22
22
  getNextNightly,
23
23
  getNextInternal,
24
24
  getCurrent,
25
+ getDateIdentifier,
25
26
  getLastTagFromGit
26
27
  } from './utils/versions.js';
27
28
  export { default as getChangesForVersion } from './utils/getchangesforversion.js';
@@ -17,6 +17,10 @@ import semver from 'semver';
17
17
  export default function getNpmTagFromVersion( version ) {
18
18
  const [ versionTag ] = semver.prerelease( version ) || [ 'latest' ];
19
19
 
20
+ if ( versionTag.startsWith( 'nightly-next' ) ) {
21
+ return 'nightly-next';
22
+ }
23
+
20
24
  if ( versionTag.startsWith( 'nightly' ) ) {
21
25
  return 'nightly';
22
26
  }
@@ -29,8 +29,15 @@ export function getLastFromChangelog( cwd = process.cwd() ) {
29
29
 
30
30
  /**
31
31
  * Returns the current (latest) pre-release version that matches the provided release identifier.
32
+ * It takes into account and distinguishes pre-release tags with different names but starting with the same base name.
32
33
  * If the package does not have any pre-releases with the provided identifier yet, `null` is returned.
33
34
  *
35
+ * Examples:
36
+ * * "0.0.0-nightly" - Matches the last "nightly" version regardless of the publication date.
37
+ * It does not match other nightly tags that start with the same "nightly" base name, e.g. "0.0.0-nightly-next-YYYYMMDD.X".
38
+ * * "0.0.0-nightly-20230615" - Matches the last "nightly" version from the 2023-06-15 day.
39
+ * * "42.0.0-alpha" - Matches the last "alpha" version for the 42.0.0 version.
40
+ *
34
41
  * @param {ReleaseIdentifier} releaseIdentifier
35
42
  * @param {string} [cwd=process.cwd()]
36
43
  * @returns {Promise.<string|null>}
@@ -41,7 +48,13 @@ export function getLastPreRelease( releaseIdentifier, cwd = process.cwd() ) {
41
48
  return packument( packageName )
42
49
  .then( result => {
43
50
  const lastVersion = Object.keys( result.versions )
44
- .filter( version => version.startsWith( releaseIdentifier ) )
51
+ .filter( version => {
52
+ const optionalDateIdentifier = '(-[0-9]{8})?';
53
+ const optionalSequenceNumber = '(\\.[0-9]+)?';
54
+ const versionRegExp = new RegExp( `^${ releaseIdentifier }${ optionalDateIdentifier }${ optionalSequenceNumber }$` );
55
+
56
+ return versionRegExp.test( version );
57
+ } )
45
58
  .sort( ( a, b ) => a.localeCompare( b, undefined, { numeric: true } ) )
46
59
  .pop();
47
60
 
@@ -138,9 +151,11 @@ export function getCurrent( cwd = process.cwd() ) {
138
151
  }
139
152
 
140
153
  /**
154
+ * Returns current date in the "YYYYMMDD" format.
155
+ *
141
156
  * @returns {string}
142
157
  */
143
- function getDateIdentifier() {
158
+ export function getDateIdentifier() {
144
159
  const today = new Date();
145
160
  const year = today.getFullYear().toString();
146
161
  const month = ( today.getMonth() + 1 ).toString().padStart( 2, '0' );
@@ -152,9 +167,4 @@ function getDateIdentifier() {
152
167
  /**
153
168
  * @typedef {string} ReleaseIdentifier The pre-release identifier without the last dynamic part (the pre-release sequential number).
154
169
  * It consists of the core base version ("<major>.<minor>.<path>"), a hyphen ("-"), and a pre-release identifier name (e.g. "alpha").
155
- *
156
- * Examples:
157
- * * "0.0.0-nightly" - matches the last nightly version regardless of the publication date.
158
- * * "0.0.0-nightly-20230615" - matches the last nightly version from the 2023-06-15 day.
159
- * * "42.0.0-alpha" - matches the last alpha version for the 42.0.0 version.
160
170
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-dev-release-tools",
3
- "version": "46.0.1",
3
+ "version": "46.0.3",
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": "^46.0.1",
25
+ "@ckeditor/ckeditor5-dev-utils": "^46.0.3",
26
26
  "@octokit/rest": "^21.0.0",
27
27
  "chalk": "^5.0.0",
28
28
  "cli-columns": "^4.0.0",