@ckeditor/ckeditor5-dev-release-tools 38.0.0-alpha.0 → 38.0.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.
|
@@ -22,7 +22,7 @@ module.exports = async function commitAndTag( { version, files, cwd = process.cw
|
|
|
22
22
|
const normalizedCwd = toUnix( cwd );
|
|
23
23
|
const filePathsToAdd = await glob( files, { cwd: normalizedCwd, absolute: true, nodir: true } );
|
|
24
24
|
|
|
25
|
-
await tools.shExec( `git add ${ filePathsToAdd.join( ' ' ) }`, { cwd: normalizedCwd, async: true } );
|
|
26
|
-
await tools.shExec( `git commit --message "Release: v${ version }."`, { cwd: normalizedCwd, async: true } );
|
|
27
|
-
await tools.shExec( `git tag v${ version }`, { cwd: normalizedCwd, async: true } );
|
|
25
|
+
await tools.shExec( `git add ${ filePathsToAdd.join( ' ' ) }`, { cwd: normalizedCwd, async: true, verbosity: 'silent' } );
|
|
26
|
+
await tools.shExec( `git commit --message "Release: v${ version }."`, { cwd: normalizedCwd, async: true, verbosity: 'silent' } );
|
|
27
|
+
await tools.shExec( `git tag v${ version }`, { cwd: normalizedCwd, async: true, verbosity: 'silent' } );
|
|
28
28
|
};
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
const { Octokit } = require( '@octokit/rest' );
|
|
9
9
|
const semver = require( 'semver' );
|
|
10
|
+
const { getRepositoryUrl } = require( '../utils/transformcommitutils' );
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Create a GitHub release.
|
|
@@ -14,18 +15,16 @@ const semver = require( 'semver' );
|
|
|
14
15
|
* @param {Object} options
|
|
15
16
|
* @param {String} options.token Token used to authenticate with GitHub.
|
|
16
17
|
* @param {String} options.version Name of tag connected with the release.
|
|
17
|
-
* @param {String} options.repositoryOwner Owner of the repository.
|
|
18
|
-
* @param {String} options.repositoryName Repository name.
|
|
19
18
|
* @param {String} options.description Description of the release.
|
|
19
|
+
* @param {String} [options.cwd=process.cwd()] Current working directory from which all paths will be resolved.
|
|
20
20
|
* @returns {Promise.<String>}
|
|
21
21
|
*/
|
|
22
22
|
module.exports = async function createGithubRelease( options ) {
|
|
23
23
|
const {
|
|
24
24
|
token,
|
|
25
25
|
version,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
description
|
|
26
|
+
description,
|
|
27
|
+
cwd = process.cwd()
|
|
29
28
|
} = options;
|
|
30
29
|
|
|
31
30
|
const github = new Octokit( {
|
|
@@ -33,6 +32,9 @@ module.exports = async function createGithubRelease( options ) {
|
|
|
33
32
|
auth: `token ${ token }`
|
|
34
33
|
} );
|
|
35
34
|
|
|
35
|
+
const repositoryUrl = getRepositoryUrl( cwd );
|
|
36
|
+
const [ repositoryName, repositoryOwner ] = repositoryUrl.split( '/' ).reverse();
|
|
37
|
+
|
|
36
38
|
if ( await shouldCreateRelease( github, repositoryOwner, repositoryName, version ) ) {
|
|
37
39
|
await github.repos.createRelease( {
|
|
38
40
|
tag_name: `v${ version }`,
|
|
@@ -477,6 +477,9 @@ module.exports = async function generateChangelogForMonoRepository( options ) {
|
|
|
477
477
|
// Save the changelog.
|
|
478
478
|
changelogUtils.saveChangelog( newChangelog );
|
|
479
479
|
|
|
480
|
+
// Truncate the changelog to keep the latest five release entries.
|
|
481
|
+
changelogUtils.truncateChangelog( 5 );
|
|
482
|
+
|
|
480
483
|
logInfo( 'Saved.', { indentLevel: 1 } );
|
|
481
484
|
}
|
|
482
485
|
|
package/lib/utils/changelog.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
const fs = require( 'fs' );
|
|
9
9
|
const path = require( 'path' );
|
|
10
|
+
const { getRepositoryUrl } = require( './transformcommitutils' );
|
|
10
11
|
|
|
11
12
|
const utils = {
|
|
12
13
|
/**
|
|
@@ -61,6 +62,39 @@ const utils = {
|
|
|
61
62
|
const changelogFile = path.join( cwd, utils.changelogFile );
|
|
62
63
|
|
|
63
64
|
fs.writeFileSync( changelogFile, content, 'utf-8' );
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @param {Number} length
|
|
69
|
+
* @param {String} [cwd=process.cwd()] Where to look for the changelog file.
|
|
70
|
+
*/
|
|
71
|
+
truncateChangelog( length, cwd = process.cwd() ) {
|
|
72
|
+
const changelog = utils.getChangelog( cwd );
|
|
73
|
+
|
|
74
|
+
if ( !changelog ) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const entryHeader = '## [\\s\\S]+?';
|
|
79
|
+
const entryHeaderRegexp = new RegExp( `\\n(${ entryHeader })(?=\\n${ entryHeader }|$)`, 'g' );
|
|
80
|
+
|
|
81
|
+
const entries = [ ...changelog.matchAll( entryHeaderRegexp ) ]
|
|
82
|
+
.filter( match => match && match[ 1 ] )
|
|
83
|
+
.map( match => match[ 1 ] );
|
|
84
|
+
|
|
85
|
+
if ( !entries.length ) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const truncatedEntries = entries.slice( 0, length );
|
|
90
|
+
|
|
91
|
+
const changelogFooter = entries.length > truncatedEntries.length ?
|
|
92
|
+
`\n\n---\n\nTo see all releases, visit the [release page](${ getRepositoryUrl( cwd ) }/releases).\n` :
|
|
93
|
+
'\n';
|
|
94
|
+
|
|
95
|
+
const truncatedChangelog = utils.changelogHeader + truncatedEntries.join( '\n' ).trim() + changelogFooter;
|
|
96
|
+
|
|
97
|
+
utils.saveChangelog( truncatedChangelog, cwd );
|
|
64
98
|
}
|
|
65
99
|
};
|
|
66
100
|
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-dev-release-tools",
|
|
3
|
-
"version": "38.0.0
|
|
3
|
+
"version": "38.0.0",
|
|
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.0
|
|
8
|
+
"@ckeditor/ckeditor5-dev-utils": "^38.0.0",
|
|
9
9
|
"@octokit/rest": "^17.9.2",
|
|
10
10
|
"chalk": "^4.0.0",
|
|
11
11
|
"cli-table": "^0.3.1",
|