@ckeditor/ckeditor5-dev-release-tools 40.1.0 → 40.2.1

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
@@ -16,7 +16,15 @@ const push = require( './tasks/push' );
16
16
  const publishPackages = require( './tasks/publishpackages' );
17
17
  const updateVersions = require( './tasks/updateversions' );
18
18
  const cleanUpPackages = require( './tasks/cleanuppackages' );
19
- const { getLastFromChangelog, getLastNightly, getNextNightly, getCurrent, getLastTagFromGit } = require( './utils/versions' );
19
+ const {
20
+ getLastFromChangelog,
21
+ getLastPreRelease,
22
+ getNextPreRelease,
23
+ getLastNightly,
24
+ getNextNightly,
25
+ getCurrent,
26
+ getLastTagFromGit
27
+ } = require( './utils/versions' );
20
28
  const { getChangesForVersion, getChangelog, saveChangelog } = require( './utils/changelog' );
21
29
  const executeInParallel = require( './utils/executeinparallel' );
22
30
  const validateRepositoryToRelease = require( './utils/validaterepositorytorelease' );
@@ -36,6 +44,8 @@ module.exports = {
36
44
  reassignNpmTags,
37
45
  executeInParallel,
38
46
  getLastFromChangelog,
47
+ getLastPreRelease,
48
+ getNextPreRelease,
39
49
  getLastNightly,
40
50
  getNextNightly,
41
51
  getCurrent,
@@ -29,27 +29,69 @@ const versions = {
29
29
  return matches ? matches[ 1 ] : null;
30
30
  },
31
31
 
32
+ /**
33
+ * Returns the current (latest) pre-release version that matches the provided release identifier.
34
+ * If the package does not have any pre-releases with the provided identifier yet, `null` is returned.
35
+ *
36
+ * @param {ReleaseIdentifier} releaseIdentifier
37
+ * @param {String} [cwd=process.cwd()]
38
+ * @returns {Promise.<String|null>}
39
+ */
40
+ getLastPreRelease( releaseIdentifier, cwd = process.cwd() ) {
41
+ const packageName = getPackageJson( cwd ).name;
42
+
43
+ return tools.shExec( `npm view ${ packageName } versions --json`, { verbosity: 'silent', async: true } )
44
+ .then( result => {
45
+ const lastVersion = JSON.parse( result )
46
+ .filter( version => version.startsWith( releaseIdentifier ) )
47
+ .sort()
48
+ .pop();
49
+
50
+ return lastVersion || null;
51
+ } )
52
+ .catch( () => null );
53
+ },
54
+
32
55
  /**
33
56
  * Returns the current (latest) nightly version in the format of "0.0.0-nightly-YYYYMMDD.X", where the "YYYYMMDD" is the date of the
34
57
  * last nightly release and the "X" is the sequential number starting from 0. If the package does not have any nightly releases yet,
35
58
  * `null` is returned.
36
59
  *
37
- * @params {String} [cwd=process.cwd()]
60
+ * @param {String} [cwd=process.cwd()]
38
61
  * @returns {Promise.<String|null>}
39
62
  */
40
63
  getLastNightly( cwd = process.cwd() ) {
41
- const packageName = getPackageJson( cwd ).name;
64
+ return versions.getLastPreRelease( '0.0.0-nightly', cwd );
65
+ },
42
66
 
43
- return tools.shExec( `npm view ${ packageName }@nightly version`, { verbosity: 'silent', async: true } )
44
- .catch( () => null );
67
+ /**
68
+ * Returns the next available pre-release version that matches the following format: "<releaseIdentifier>.X", where "X" is the
69
+ * next available pre-release sequential number starting from 0.
70
+ *
71
+ * @param {ReleaseIdentifier} releaseIdentifier
72
+ * @param {String} [cwd=process.cwd()]
73
+ * @returns {Promise<String>}
74
+ */
75
+ async getNextPreRelease( releaseIdentifier, cwd = process.cwd() ) {
76
+ const currentPreReleaseVersion = await versions.getLastPreRelease( releaseIdentifier, cwd );
77
+
78
+ if ( !currentPreReleaseVersion ) {
79
+ return `${ releaseIdentifier }.0`;
80
+ }
81
+
82
+ const currentPreReleaseVersionTokens = currentPreReleaseVersion.split( '.' );
83
+ const currentPreReleaseSequenceNumber = currentPreReleaseVersionTokens.pop();
84
+ const currentPreReleaseIdentifier = currentPreReleaseVersionTokens.join( '.' );
85
+ const nextPreReleaseSequenceNumber = Number( currentPreReleaseSequenceNumber ) + 1;
86
+
87
+ return `${ currentPreReleaseIdentifier }.${ nextPreReleaseSequenceNumber }`;
45
88
  },
46
89
 
47
90
  /**
48
- * Returns the next available nightly version matching the following format: "0.0.0-nightly-YYYYMMDD.X",
49
- * where "YYYYMMDD" is the date of the latest nightly release,
50
- * and "X" is the following available sequential number starting from 0.
91
+ * Returns the next available nightly version in the format of "0.0.0-nightly-YYYYMMDD.X", where the "YYYYMMDD" is the current date for
92
+ * the nightly release and the "X" is the sequential number starting from 0.
51
93
  *
52
- * @params {String} [cwd=process.cwd()]
94
+ * @param {String} [cwd=process.cwd()]
53
95
  * @returns {Promise<String>}
54
96
  */
55
97
  async getNextNightly( cwd = process.cwd() ) {
@@ -58,21 +100,9 @@ const versions = {
58
100
  const month = ( today.getMonth() + 1 ).toString().padStart( 2, '0' );
59
101
  const day = today.getDate().toString().padStart( 2, '0' );
60
102
 
61
- const nextNightlyVersion = `0.0.0-nightly-${ year }${ month }${ day }`;
62
- const currentNightlyVersion = await versions.getLastNightly( cwd );
63
-
64
- if ( !currentNightlyVersion ) {
65
- return `${ nextNightlyVersion }.0`;
66
- }
67
-
68
- if ( !currentNightlyVersion.startsWith( nextNightlyVersion ) ) {
69
- return `${ nextNightlyVersion }.0`;
70
- }
71
-
72
- const currentNightlyVersionId = currentNightlyVersion.split( '.' ).pop();
73
- const nextNightlyVersionId = Number( currentNightlyVersionId ) + 1;
103
+ const nextNightlyReleaseIdentifier = `0.0.0-nightly-${ year }${ month }${ day }`;
74
104
 
75
- return `${ nextNightlyVersion }.${ nextNightlyVersionId }`;
105
+ return versions.getNextPreRelease( nextNightlyReleaseIdentifier, cwd );
76
106
  },
77
107
 
78
108
  /**
@@ -103,3 +133,13 @@ const versions = {
103
133
  };
104
134
 
105
135
  module.exports = versions;
136
+
137
+ /**
138
+ * @typedef {String} ReleaseIdentifier The pre-release identifier without the last dynamic part (the pre-release sequential number).
139
+ * It consists of the core base version ("<major>.<minor>.<path>"), a hyphen ("-"), and a pre-release identifier name (e.g. "alpha").
140
+ *
141
+ * Examples:
142
+ * * "0.0.0-nightly" - matches the last nightly version regardless of the publication date.
143
+ * * "0.0.0-nightly-20230615" - matches the last nightly version from the 2023-06-15 day.
144
+ * * "42.0.0-alpha" - matches the last alpha version for the 42.0.0 version.
145
+ */
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-dev-release-tools",
3
- "version": "40.1.0",
3
+ "version": "40.2.1",
4
4
  "description": "Tools used for releasing CKEditor 5 and related packages.",
5
5
  "keywords": [],
6
6
  "main": "lib/index.js",
7
7
  "dependencies": {
8
- "@ckeditor/ckeditor5-dev-utils": "^40.1.0",
8
+ "@ckeditor/ckeditor5-dev-utils": "^40.2.1",
9
9
  "@octokit/rest": "^19.0.0",
10
10
  "chalk": "^4.0.0",
11
11
  "cli-table": "^0.3.1",