@ckeditor/ckeditor5-dev-release-tools 38.0.2 → 38.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
@@ -16,7 +16,7 @@ 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, getCurrent, getLastTagFromGit } = require( './utils/versions' );
19
+ const { getLastFromChangelog, getLastNightly, getNextNightly, getCurrent, getLastTagFromGit } = require( './utils/versions' );
20
20
  const { getChangesForVersion, getChangelog, saveChangelog } = require( './utils/changelog' );
21
21
  const executeInParallel = require( './utils/executeinparallel' );
22
22
  const validateRepositoryToRelease = require( './utils/validaterepositorytorelease' );
@@ -35,6 +35,8 @@ module.exports = {
35
35
  reassignNpmTags,
36
36
  executeInParallel,
37
37
  getLastFromChangelog,
38
+ getLastNightly,
39
+ getNextNightly,
38
40
  getCurrent,
39
41
  getLastTagFromGit,
40
42
  getChangesForVersion,
@@ -29,6 +29,52 @@ const versions = {
29
29
  return matches ? matches[ 1 ] : null;
30
30
  },
31
31
 
32
+ /**
33
+ * 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
+ * last nightly release and the "X" is the sequential number starting from 0. If the package does not have any nightly releases yet,
35
+ * `null` is returned.
36
+ *
37
+ * @params {String} [cwd=process.cwd()]
38
+ * @returns {Promise.<String|null>}
39
+ */
40
+ getLastNightly( cwd = process.cwd() ) {
41
+ const packageName = getPackageJson( cwd ).name;
42
+
43
+ return tools.shExec( `npm view ${ packageName }@nightly version`, { verbosity: 'silent', async: true } )
44
+ .catch( () => null );
45
+ },
46
+
47
+ /**
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.
51
+ *
52
+ * @params {String} [cwd=process.cwd()]
53
+ * @returns {Promise<String>}
54
+ */
55
+ async getNextNightly( cwd = process.cwd() ) {
56
+ const today = new Date();
57
+ const year = today.getFullYear().toString();
58
+ const month = ( today.getMonth() + 1 ).toString().padStart( 2, '0' );
59
+ const day = today.getDate().toString().padStart( 2, '0' );
60
+
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;
74
+
75
+ return `${ nextNightlyVersion }.${ nextNightlyVersionId }`;
76
+ },
77
+
32
78
  /**
33
79
  * Returns a name of the last created tag.
34
80
  *
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-dev-release-tools",
3
- "version": "38.0.2",
3
+ "version": "38.0.3",
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": "^38.0.2",
8
+ "@ckeditor/ckeditor5-dev-utils": "^38.0.3",
9
9
  "@octokit/rest": "^17.9.2",
10
10
  "chalk": "^4.0.0",
11
11
  "cli-table": "^0.3.1",