@ckeditor/ckeditor5-dev-release-tools 43.0.0 → 44.0.0-alpha.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 +23 -52
- package/lib/tasks/cleanuppackages.js +5 -7
- package/lib/tasks/commitandtag.js +7 -7
- package/lib/tasks/creategithubrelease.js +6 -6
- package/lib/tasks/generatechangelogformonorepository.js +44 -40
- package/lib/tasks/generatechangelogforsinglepackage.js +35 -31
- package/lib/tasks/preparerepository.js +11 -12
- package/lib/tasks/publishpackages.js +10 -12
- package/lib/tasks/push.js +4 -6
- package/lib/tasks/reassignnpmtags.js +11 -13
- package/lib/tasks/updatedependencies.js +5 -7
- package/lib/tasks/updateversions.js +8 -8
- package/lib/tasks/verifypackagespublishedcorrectly.js +6 -8
- package/lib/utils/abortcontroller.js +2 -11
- package/lib/utils/assertfilestopublish.js +5 -7
- package/lib/utils/assertnpmauthorization.js +3 -5
- package/lib/utils/assertnpmtag.js +5 -7
- package/lib/utils/assertpackages.js +4 -6
- package/lib/utils/checkversionavailability.js +4 -6
- package/lib/utils/configurereleaseoptions.js +43 -0
- package/lib/utils/confirmincludingpackage.js +24 -0
- package/lib/utils/confirmnpmtag.js +32 -0
- package/lib/utils/constants.js +26 -0
- package/lib/utils/displaycommits.js +9 -11
- package/lib/utils/displayskippedpackages.js +7 -9
- package/lib/utils/executeinparallel.js +13 -14
- package/lib/utils/generatechangelog.js +6 -8
- package/lib/utils/getchangedfilesforcommit.js +3 -5
- package/lib/utils/getchangelog.js +22 -0
- package/lib/utils/getchangesforversion.js +28 -0
- package/lib/utils/getcommits.js +12 -14
- package/lib/utils/getformatteddate.js +13 -0
- package/lib/utils/getnewversiontype.js +2 -4
- package/lib/utils/getnpmtagfromversion.js +3 -5
- package/lib/utils/getpackagejson.js +4 -6
- package/lib/utils/getpackagespaths.js +7 -9
- package/lib/utils/getwriteroptions.js +16 -7
- package/lib/utils/isversionpublishablefortag.js +5 -5
- package/lib/utils/{parallelworker.cjs → parallelworker.js} +3 -4
- package/lib/utils/parseroptions.js +1 -3
- package/lib/utils/providenewversionformonorepository.js +51 -0
- package/lib/utils/providetoken.js +26 -0
- package/lib/utils/provideversion.js +98 -0
- package/lib/utils/publishpackageonnpmcallback.js +10 -12
- package/lib/utils/savechangelog.js +18 -0
- package/lib/utils/transformcommitfactory.js +5 -7
- package/lib/utils/transformcommitutils.js +142 -147
- package/lib/utils/truncatechangelog.js +42 -0
- package/lib/utils/validaterepositorytorelease.js +3 -5
- package/lib/utils/versions.js +122 -128
- package/package.json +16 -15
- package/lib/utils/changelog.js +0 -109
- package/lib/utils/cli.js +0 -349
|
@@ -5,17 +5,15 @@
|
|
|
5
5
|
* For licensing, see LICENSE.md.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import columns from 'cli-columns';
|
|
10
|
+
import { tools } from '@ckeditor/ckeditor5-dev-utils';
|
|
11
|
+
import util from 'util';
|
|
12
|
+
import shellEscape from 'shell-escape';
|
|
13
|
+
import assertNpmAuthorization from '../utils/assertnpmauthorization.js';
|
|
14
|
+
import { exec } from 'child_process';
|
|
9
15
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const chalk = require( 'chalk' );
|
|
13
|
-
const columns = require( 'cli-columns' );
|
|
14
|
-
const { tools } = require( '@ckeditor/ckeditor5-dev-utils' );
|
|
15
|
-
const util = require( 'util' );
|
|
16
|
-
const shellEscape = require( 'shell-escape' );
|
|
17
|
-
const exec = util.promisify( require( 'child_process' ).exec );
|
|
18
|
-
const assertNpmAuthorization = require( '../utils/assertnpmauthorization' );
|
|
16
|
+
const execPromise = util.promisify( exec );
|
|
19
17
|
|
|
20
18
|
/**
|
|
21
19
|
* Used to switch the tags from `staging` to `latest` for specified array of packages.
|
|
@@ -27,7 +25,7 @@ const assertNpmAuthorization = require( '../utils/assertnpmauthorization' );
|
|
|
27
25
|
* @param {Array.<String>} options.packages Array of packages' names to reassign tags for.
|
|
28
26
|
* @returns {Promise}
|
|
29
27
|
*/
|
|
30
|
-
|
|
28
|
+
export default async function reassignNpmTags( { npmOwner, version, packages } ) {
|
|
31
29
|
const errors = [];
|
|
32
30
|
const packagesSkipped = [];
|
|
33
31
|
const packagesUpdated = [];
|
|
@@ -39,7 +37,7 @@ module.exports = async function reassignNpmTags( { npmOwner, version, packages }
|
|
|
39
37
|
|
|
40
38
|
const updateTagPromises = packages.map( async packageName => {
|
|
41
39
|
const command = `npm dist-tag add ${ shellEscape( [ packageName ] ) }@${ shellEscape( [ version ] ) } latest`;
|
|
42
|
-
const updateLatestTagRetryable = retry( () =>
|
|
40
|
+
const updateLatestTagRetryable = retry( () => execPromise( command ) );
|
|
43
41
|
await updateLatestTagRetryable()
|
|
44
42
|
.then( response => {
|
|
45
43
|
if ( response.stdout ) {
|
|
@@ -78,7 +76,7 @@ module.exports = async function reassignNpmTags( { npmOwner, version, packages }
|
|
|
78
76
|
console.log( chalk.bold.red( '🐛 Errors found:' ) );
|
|
79
77
|
errors.forEach( msg => console.log( `* ${ msg }` ) );
|
|
80
78
|
}
|
|
81
|
-
}
|
|
79
|
+
}
|
|
82
80
|
|
|
83
81
|
/**
|
|
84
82
|
* @param {String} message
|
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const { glob } = require( 'glob' );
|
|
10
|
-
const upath = require( 'upath' );
|
|
6
|
+
import fs from 'fs-extra';
|
|
7
|
+
import { glob } from 'glob';
|
|
8
|
+
import upath from 'upath';
|
|
11
9
|
|
|
12
10
|
/**
|
|
13
11
|
* The purpose of this script is to update all eligible dependencies to a version specified in the `options.version`. The following packages
|
|
@@ -31,7 +29,7 @@ const upath = require( 'upath' );
|
|
|
31
29
|
* @param {String} [options.cwd=process.cwd()] Current working directory from which all paths will be resolved.
|
|
32
30
|
* @returns {Promise}
|
|
33
31
|
*/
|
|
34
|
-
|
|
32
|
+
export default async function updateDependencies( options ) {
|
|
35
33
|
const {
|
|
36
34
|
version,
|
|
37
35
|
packagesDirectory,
|
|
@@ -59,7 +57,7 @@ module.exports = async function updateDependencies( options ) {
|
|
|
59
57
|
|
|
60
58
|
await fs.writeJson( pkgJsonPath, pkgJson, { spaces: 2 } );
|
|
61
59
|
}
|
|
62
|
-
}
|
|
60
|
+
}
|
|
63
61
|
|
|
64
62
|
/**
|
|
65
63
|
* Updates the version for each eligible dependency.
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
import upath from 'upath';
|
|
7
|
+
import fs from 'fs-extra';
|
|
8
|
+
import { glob } from 'glob';
|
|
9
|
+
import semver from 'semver';
|
|
10
|
+
import checkVersionAvailability from '../utils/checkversionavailability.js';
|
|
7
11
|
|
|
8
|
-
const {
|
|
9
|
-
const fs = require( 'fs-extra' );
|
|
10
|
-
const semver = require( 'semver' );
|
|
11
|
-
const { normalizeTrim, toUnix, dirname, join } = require( 'upath' );
|
|
12
|
-
const checkVersionAvailability = require( '../utils/checkversionavailability' );
|
|
12
|
+
const { normalizeTrim, toUnix, dirname, join } = upath;
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* The purpose of the script is to update the version of a root package found in the current working
|
|
@@ -31,7 +31,7 @@ const checkVersionAvailability = require( '../utils/checkversionavailability' );
|
|
|
31
31
|
* @param {String} [options.cwd=process.cwd()] Current working directory from which all paths will be resolved.
|
|
32
32
|
* @returns {Promise}
|
|
33
33
|
*/
|
|
34
|
-
|
|
34
|
+
export default async function updateVersions( options ) {
|
|
35
35
|
const {
|
|
36
36
|
packagesDirectory,
|
|
37
37
|
version,
|
|
@@ -63,7 +63,7 @@ module.exports = async function updateVersions( options ) {
|
|
|
63
63
|
pkgJson.version = version;
|
|
64
64
|
await fs.writeJson( pkgJsonPath, pkgJson, { spaces: 2 } );
|
|
65
65
|
}
|
|
66
|
-
}
|
|
66
|
+
}
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* @param {String} cwd
|
|
@@ -3,12 +3,10 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const fs = require( 'fs-extra' );
|
|
11
|
-
const { checkVersionAvailability } = require( '../utils/checkversionavailability' );
|
|
6
|
+
import upath from 'upath';
|
|
7
|
+
import { glob } from 'glob';
|
|
8
|
+
import fs from 'fs-extra';
|
|
9
|
+
import checkVersionAvailability from '../utils/checkversionavailability.js';
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
12
|
* Npm sometimes throws incorrect error 409 while publishing, while the package uploads correctly.
|
|
@@ -20,7 +18,7 @@ const { checkVersionAvailability } = require( '../utils/checkversionavailability
|
|
|
20
18
|
* @param {Function} options.onSuccess Callback fired when function is successful.
|
|
21
19
|
* @returns {Promise}
|
|
22
20
|
*/
|
|
23
|
-
|
|
21
|
+
export default async function verifyPackagesPublishedCorrectly( options ) {
|
|
24
22
|
const { packagesDirectory, version, onSuccess } = options;
|
|
25
23
|
const packagesToVerify = await glob( upath.join( packagesDirectory, '*' ), { absolute: true } );
|
|
26
24
|
const errors = [];
|
|
@@ -52,4 +50,4 @@ module.exports = async function verifyPackagesPublishedCorrectly( options ) {
|
|
|
52
50
|
}
|
|
53
51
|
|
|
54
52
|
onSuccess( 'All packages that returned 409 were uploaded correctly.' );
|
|
55
|
-
}
|
|
53
|
+
}
|
|
@@ -3,16 +3,12 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
/* eslint-env node */
|
|
7
|
-
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
6
|
/**
|
|
11
7
|
* Creates an AbortController instance and registers the listener function on SIGINT event that aborts the asynchronous process.
|
|
12
8
|
*
|
|
13
9
|
* @returns {AbortController}
|
|
14
10
|
*/
|
|
15
|
-
function registerAbortController() {
|
|
11
|
+
export function registerAbortController() {
|
|
16
12
|
const abortController = new AbortController();
|
|
17
13
|
|
|
18
14
|
const listener = () => {
|
|
@@ -33,15 +29,10 @@ function registerAbortController() {
|
|
|
33
29
|
*
|
|
34
30
|
* @param {AbortController} abortController
|
|
35
31
|
*/
|
|
36
|
-
function deregisterAbortController( abortController ) {
|
|
32
|
+
export function deregisterAbortController( abortController = undefined ) {
|
|
37
33
|
if ( !abortController || !abortController._listener ) {
|
|
38
34
|
return;
|
|
39
35
|
}
|
|
40
36
|
|
|
41
37
|
process.removeListener( 'SIGINT', abortController._listener );
|
|
42
38
|
}
|
|
43
|
-
|
|
44
|
-
module.exports = {
|
|
45
|
-
registerAbortController,
|
|
46
|
-
deregisterAbortController
|
|
47
|
-
};
|
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const upath = require( 'upath' );
|
|
10
|
-
const { glob } = require( 'glob' );
|
|
6
|
+
import fs from 'fs-extra';
|
|
7
|
+
import upath from 'upath';
|
|
8
|
+
import { glob } from 'glob';
|
|
11
9
|
|
|
12
10
|
/**
|
|
13
11
|
* Checks if all files expected to be released actually exist in the package directory. Verification takes place for all packages.
|
|
@@ -16,7 +14,7 @@ const { glob } = require( 'glob' );
|
|
|
16
14
|
* @param {Object.<String, Array.<String>>|null} optionalEntries
|
|
17
15
|
* @returns {Promise}
|
|
18
16
|
*/
|
|
19
|
-
|
|
17
|
+
export default async function assertFilesToPublish( packagePaths, optionalEntries = null ) {
|
|
20
18
|
const errors = [];
|
|
21
19
|
|
|
22
20
|
for ( const packagePath of packagePaths ) {
|
|
@@ -59,7 +57,7 @@ module.exports = async function assertFilesToPublish( packagePaths, optionalEntr
|
|
|
59
57
|
if ( errors.length ) {
|
|
60
58
|
throw new Error( errors.join( '\n' ) );
|
|
61
59
|
}
|
|
62
|
-
}
|
|
60
|
+
}
|
|
63
61
|
|
|
64
62
|
/**
|
|
65
63
|
* Filters out the optional entries from the `files` field and returns only the required ones.
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const { tools } = require( '@ckeditor/ckeditor5-dev-utils' );
|
|
6
|
+
import { tools } from '@ckeditor/ckeditor5-dev-utils';
|
|
9
7
|
|
|
10
8
|
/**
|
|
11
9
|
* Checks whether a user is logged to npm as the provided account name.
|
|
@@ -13,7 +11,7 @@ const { tools } = require( '@ckeditor/ckeditor5-dev-utils' );
|
|
|
13
11
|
* @param {String} npmOwner Expected npm account name that should be logged into npm.
|
|
14
12
|
* @returns {Promise}
|
|
15
13
|
*/
|
|
16
|
-
|
|
14
|
+
export default async function assertNpmAuthorization( npmOwner ) {
|
|
17
15
|
return tools.shExec( 'npm whoami', { verbosity: 'error', async: true } )
|
|
18
16
|
.then( npmCurrentUser => {
|
|
19
17
|
if ( npmOwner !== npmCurrentUser.trim() ) {
|
|
@@ -23,4 +21,4 @@ module.exports = async function assertNpmAuthorization( npmOwner ) {
|
|
|
23
21
|
.catch( () => {
|
|
24
22
|
throw new Error( `You must be logged to npm as "${ npmOwner }" to execute this release step.` );
|
|
25
23
|
} );
|
|
26
|
-
}
|
|
24
|
+
}
|
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const upath = require( 'upath' );
|
|
10
|
-
const semver = require( 'semver' );
|
|
6
|
+
import fs from 'fs-extra';
|
|
7
|
+
import upath from 'upath';
|
|
8
|
+
import semver from 'semver';
|
|
11
9
|
|
|
12
10
|
/**
|
|
13
11
|
* Checks if the npm tag matches the tag calculated from the package version. Verification takes place for all packages.
|
|
@@ -16,7 +14,7 @@ const semver = require( 'semver' );
|
|
|
16
14
|
* @param {String} npmTag
|
|
17
15
|
* @returns {Promise}
|
|
18
16
|
*/
|
|
19
|
-
|
|
17
|
+
export default async function assertNpmTag( packagePaths, npmTag ) {
|
|
20
18
|
const errors = [];
|
|
21
19
|
|
|
22
20
|
for ( const packagePath of packagePaths ) {
|
|
@@ -38,7 +36,7 @@ module.exports = async function assertNpmTag( packagePaths, npmTag ) {
|
|
|
38
36
|
if ( errors.length ) {
|
|
39
37
|
throw new Error( errors.join( '\n' ) );
|
|
40
38
|
}
|
|
41
|
-
}
|
|
39
|
+
}
|
|
42
40
|
|
|
43
41
|
/**
|
|
44
42
|
* Returns the version tag for the package.
|
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const fs = require( 'fs-extra' );
|
|
9
|
-
const upath = require( 'upath' );
|
|
6
|
+
import fs from 'fs-extra';
|
|
7
|
+
import upath from 'upath';
|
|
10
8
|
|
|
11
9
|
/**
|
|
12
10
|
* Checks if all packages in the provided directories contain the `package.json` file.
|
|
@@ -19,7 +17,7 @@ const upath = require( 'upath' );
|
|
|
19
17
|
* this array contains a list of packages that will not be checked. In other words, they do not have to define the entry point.
|
|
20
18
|
* @returns {Promise}
|
|
21
19
|
*/
|
|
22
|
-
|
|
20
|
+
export default async function assertPackages( packagePaths, options ) {
|
|
23
21
|
const errors = [];
|
|
24
22
|
const { requireEntryPoint, optionalEntryPointPackages } = options;
|
|
25
23
|
|
|
@@ -49,4 +47,4 @@ module.exports = async function assertPackages( packagePaths, options ) {
|
|
|
49
47
|
if ( errors.length ) {
|
|
50
48
|
throw new Error( errors.join( '\n' ) );
|
|
51
49
|
}
|
|
52
|
-
}
|
|
50
|
+
}
|
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const { tools } = require( '@ckeditor/ckeditor5-dev-utils' );
|
|
9
|
-
const shellEscape = require( 'shell-escape' );
|
|
6
|
+
import { tools } from '@ckeditor/ckeditor5-dev-utils';
|
|
7
|
+
import shellEscape from 'shell-escape';
|
|
10
8
|
|
|
11
9
|
/**
|
|
12
10
|
* Checks if the provided version for the package exists in the npm registry.
|
|
@@ -18,7 +16,7 @@ const shellEscape = require( 'shell-escape' );
|
|
|
18
16
|
* @param {String} packageName
|
|
19
17
|
* @returns {Promise}
|
|
20
18
|
*/
|
|
21
|
-
|
|
19
|
+
export default async function checkVersionAvailability( version, packageName ) {
|
|
22
20
|
const command = `npm show ${ shellEscape( [ packageName ] ) }@${ shellEscape( [ version ] ) } version`;
|
|
23
21
|
|
|
24
22
|
return tools.shExec( command, { verbosity: 'silent', async: true } )
|
|
@@ -42,4 +40,4 @@ module.exports = async function checkVersionAvailability( version, packageName )
|
|
|
42
40
|
// Npm < 8.13.0 should never reach this line.
|
|
43
41
|
return true;
|
|
44
42
|
} );
|
|
45
|
-
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import inquirer from 'inquirer';
|
|
7
|
+
import provideToken from './providetoken.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Asks a user for selecting services where packages will be released.
|
|
11
|
+
*
|
|
12
|
+
* If the user choices a GitHub, required token also has to be provided.
|
|
13
|
+
*
|
|
14
|
+
* @returns {Promise.<Object>}
|
|
15
|
+
*/
|
|
16
|
+
export default async function configureReleaseOptions() {
|
|
17
|
+
const options = {};
|
|
18
|
+
|
|
19
|
+
const servicesQuestion = {
|
|
20
|
+
type: 'checkbox',
|
|
21
|
+
name: 'services',
|
|
22
|
+
message: 'Select services where packages will be released:',
|
|
23
|
+
choices: [
|
|
24
|
+
'npm',
|
|
25
|
+
'GitHub'
|
|
26
|
+
],
|
|
27
|
+
default: [
|
|
28
|
+
'npm',
|
|
29
|
+
'GitHub'
|
|
30
|
+
]
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const answers = await inquirer.prompt( [ servicesQuestion ] );
|
|
34
|
+
|
|
35
|
+
options.npm = answers.services.includes( 'npm' );
|
|
36
|
+
options.github = answers.services.includes( 'GitHub' );
|
|
37
|
+
|
|
38
|
+
if ( options.github ) {
|
|
39
|
+
options.token = await provideToken();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return options;
|
|
43
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import inquirer from 'inquirer';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Asks a user for a confirmation for including a package that does not contain all required files.
|
|
10
|
+
*
|
|
11
|
+
* @returns {Promise.<Boolean>}
|
|
12
|
+
*/
|
|
13
|
+
export default async function confirmIncludingPackage() {
|
|
14
|
+
const confirmQuestion = {
|
|
15
|
+
message: 'Package does not contain all required files to publish. Include this package in the release and continue?',
|
|
16
|
+
type: 'confirm',
|
|
17
|
+
name: 'confirm',
|
|
18
|
+
default: true
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const { confirm } = await inquirer.prompt( [ confirmQuestion ] );
|
|
22
|
+
|
|
23
|
+
return confirm;
|
|
24
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import inquirer from 'inquirer';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Asks a user for a confirmation for updating and tagging versions of the packages.
|
|
11
|
+
*
|
|
12
|
+
* @param {String} versionTag A version tag based on a package version specified in `package.json`.
|
|
13
|
+
* @param {String} npmTag A tag typed by the user when using the release tools.
|
|
14
|
+
* @returns {Promise.<Boolean>}
|
|
15
|
+
*/
|
|
16
|
+
export default function confirmNpmTag( versionTag, npmTag ) {
|
|
17
|
+
const areVersionsEqual = versionTag === npmTag;
|
|
18
|
+
const color = areVersionsEqual ? chalk.magenta : chalk.red;
|
|
19
|
+
|
|
20
|
+
// eslint-disable-next-line max-len
|
|
21
|
+
const message = `The next release bumps the "${ color( versionTag ) }" version. Should it be published to npm as "${ color( npmTag ) }"?`;
|
|
22
|
+
|
|
23
|
+
const confirmQuestion = {
|
|
24
|
+
message,
|
|
25
|
+
type: 'confirm',
|
|
26
|
+
name: 'confirm',
|
|
27
|
+
default: areVersionsEqual
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return inquirer.prompt( [ confirmQuestion ] )
|
|
31
|
+
.then( answers => answers.confirm );
|
|
32
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Changelog file name.
|
|
8
|
+
*/
|
|
9
|
+
export const CHANGELOG_FILE = 'CHANGELOG.md';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Changelog header.
|
|
13
|
+
*/
|
|
14
|
+
export const CHANGELOG_HEADER = 'Changelog\n=========\n\n';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A size of default indent for a log.
|
|
18
|
+
*/
|
|
19
|
+
export const CLI_INDENT_SIZE = 3;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A size of indent for a second and next lines in a log. The number is equal to length of the log string:
|
|
23
|
+
* '* 1234567 ', where '1234567' is a short commit id.
|
|
24
|
+
* It does not include a value from `cli.INDENT_SIZE`.
|
|
25
|
+
*/
|
|
26
|
+
export const CLI_COMMIT_INDENT_SIZE = 10;
|
|
@@ -3,12 +3,10 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const utils = require( './transformcommitutils' );
|
|
11
|
-
const { INDENT_SIZE, COMMIT_INDENT_SIZE } = require( './cli' );
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
import { logger } from '@ckeditor/ckeditor5-dev-utils';
|
|
8
|
+
import * as utils from './transformcommitutils.js';
|
|
9
|
+
import { CLI_COMMIT_INDENT_SIZE, CLI_INDENT_SIZE } from './constants.js';
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
12
|
* @param {Array.<Commit>|Set.<Commit>} commits
|
|
@@ -16,12 +14,12 @@ const { INDENT_SIZE, COMMIT_INDENT_SIZE } = require( './cli' );
|
|
|
16
14
|
* @param {Boolean} [options.attachLinkToCommit=false] Whether to attach a link to parsed commit.
|
|
17
15
|
* @param {Number} [options.indentLevel=1] The indent level.
|
|
18
16
|
*/
|
|
19
|
-
|
|
17
|
+
export default function displayCommits( commits, options = {} ) {
|
|
20
18
|
const log = logger();
|
|
21
19
|
|
|
22
20
|
const attachLinkToCommit = options.attachLinkToCommit || false;
|
|
23
21
|
const indentLevel = options.indentLevel || 1;
|
|
24
|
-
const listIndent = ' '.repeat(
|
|
22
|
+
const listIndent = ' '.repeat( CLI_INDENT_SIZE * indentLevel );
|
|
25
23
|
|
|
26
24
|
if ( !( commits.length || commits.size ) ) {
|
|
27
25
|
log.info( listIndent + chalk.italic( 'No commits to display.' ) );
|
|
@@ -51,14 +49,14 @@ module.exports = function displayCommits( commits, options = {} ) {
|
|
|
51
49
|
const isCommitIncluded = utils.availableCommitTypes.get( singleCommit.rawType );
|
|
52
50
|
|
|
53
51
|
const indent = commits.size > 1 ? listIndent.slice( 0, listIndent.length - 1 ) + chalk.gray( '|' ) : listIndent;
|
|
54
|
-
const noteIndent = indent + ' '.repeat(
|
|
52
|
+
const noteIndent = indent + ' '.repeat( CLI_COMMIT_INDENT_SIZE );
|
|
55
53
|
|
|
56
54
|
let logMessage = `${ indent }* ${ chalk.yellow( hash.slice( 0, 7 ) ) } "${ utils.truncate( singleCommit.header, 100 ) }" `;
|
|
57
55
|
|
|
58
56
|
if ( hasCorrectType && isCommitIncluded ) {
|
|
59
57
|
logMessage += chalk.green( 'INCLUDED' );
|
|
60
58
|
} else if ( hasCorrectType && !isCommitIncluded ) {
|
|
61
|
-
logMessage += chalk.
|
|
59
|
+
logMessage += chalk.gray( 'SKIPPED' );
|
|
62
60
|
} else {
|
|
63
61
|
logMessage += chalk.red( 'INVALID' );
|
|
64
62
|
}
|
|
@@ -102,4 +100,4 @@ module.exports = function displayCommits( commits, options = {} ) {
|
|
|
102
100
|
|
|
103
101
|
return commitGroups.get( commit.hash );
|
|
104
102
|
}
|
|
105
|
-
}
|
|
103
|
+
}
|
|
@@ -3,24 +3,22 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const getPackageJson = require( './getpackagejson' );
|
|
11
|
-
const { INDENT_SIZE } = require( './cli' );
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
import { logger } from '@ckeditor/ckeditor5-dev-utils';
|
|
8
|
+
import getPackageJson from './getpackagejson.js';
|
|
9
|
+
import { CLI_INDENT_SIZE } from './constants.js';
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
12
|
* Displays skipped packages.
|
|
15
13
|
*
|
|
16
14
|
* @param {Set} skippedPackagesPaths
|
|
17
15
|
*/
|
|
18
|
-
|
|
16
|
+
export default function displaySkippedPackages( skippedPackagesPaths ) {
|
|
19
17
|
if ( !skippedPackagesPaths.size ) {
|
|
20
18
|
return;
|
|
21
19
|
}
|
|
22
20
|
|
|
23
|
-
const indent = ' '.repeat(
|
|
21
|
+
const indent = ' '.repeat( CLI_INDENT_SIZE );
|
|
24
22
|
|
|
25
23
|
const packageNames = Array.from( skippedPackagesPaths )
|
|
26
24
|
.map( packagePath => getPackageJson( packagePath ).name );
|
|
@@ -29,4 +27,4 @@ module.exports = function displaySkippedPackages( skippedPackagesPaths ) {
|
|
|
29
27
|
message += packageNames.map( line => indent + ` * ${ line }` ).join( '\n' );
|
|
30
28
|
|
|
31
29
|
logger().info( message );
|
|
32
|
-
}
|
|
30
|
+
}
|
|
@@ -5,16 +5,15 @@
|
|
|
5
5
|
|
|
6
6
|
/* eslint-env node */
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
import crypto from 'crypto';
|
|
9
|
+
import upath from 'upath';
|
|
10
|
+
import os from 'os';
|
|
11
|
+
import fs from 'fs/promises';
|
|
12
|
+
import { Worker } from 'worker_threads';
|
|
13
|
+
import { glob } from 'glob';
|
|
14
|
+
import { registerAbortController, deregisterAbortController } from './abortcontroller.js';
|
|
9
15
|
|
|
10
|
-
const
|
|
11
|
-
const upath = require( 'upath' );
|
|
12
|
-
const fs = require( 'fs/promises' );
|
|
13
|
-
const { Worker } = require( 'worker_threads' );
|
|
14
|
-
const { glob } = require( 'glob' );
|
|
15
|
-
const { registerAbortController, deregisterAbortController } = require( './abortcontroller' );
|
|
16
|
-
|
|
17
|
-
const WORKER_SCRIPT = upath.join( __dirname, 'parallelworker.cjs' );
|
|
16
|
+
const WORKER_SCRIPT = new URL( './parallelworker.js', import.meta.url );
|
|
18
17
|
|
|
19
18
|
/**
|
|
20
19
|
* This util allows executing a specified task in parallel using Workers. It can be helpful when executing a not resource-consuming
|
|
@@ -37,7 +36,7 @@ const WORKER_SCRIPT = upath.join( __dirname, 'parallelworker.cjs' );
|
|
|
37
36
|
* @param {Number} [options.concurrency=require( 'os' ).cpus().length / 2] Number of CPUs that will execute the task.
|
|
38
37
|
* @returns {Promise}
|
|
39
38
|
*/
|
|
40
|
-
|
|
39
|
+
export default async function executeInParallel( options ) {
|
|
41
40
|
const {
|
|
42
41
|
packagesDirectory,
|
|
43
42
|
taskToExecute,
|
|
@@ -46,7 +45,7 @@ module.exports = async function executeInParallel( options ) {
|
|
|
46
45
|
taskOptions = null,
|
|
47
46
|
packagesDirectoryFilter = null,
|
|
48
47
|
cwd = process.cwd(),
|
|
49
|
-
concurrency =
|
|
48
|
+
concurrency = os.cpus().length / 2
|
|
50
49
|
} = options;
|
|
51
50
|
|
|
52
51
|
const normalizedCwd = upath.toUnix( cwd );
|
|
@@ -61,8 +60,8 @@ module.exports = async function executeInParallel( options ) {
|
|
|
61
60
|
|
|
62
61
|
const packagesInThreads = getPackagesGroupedByThreads( packagesToProcess, concurrency );
|
|
63
62
|
|
|
64
|
-
const callbackModule = upath.join( cwd, crypto.randomUUID() + '.
|
|
65
|
-
await fs.writeFile( callbackModule, `
|
|
63
|
+
const callbackModule = upath.join( cwd, crypto.randomUUID() + '.mjs' );
|
|
64
|
+
await fs.writeFile( callbackModule, `export default ${ taskToExecute };`, 'utf-8' );
|
|
66
65
|
|
|
67
66
|
const onPackageDone = progressFactory( listrTask, packagesToProcess.length );
|
|
68
67
|
|
|
@@ -96,7 +95,7 @@ module.exports = async function executeInParallel( options ) {
|
|
|
96
95
|
deregisterAbortController( defaultAbortController );
|
|
97
96
|
}
|
|
98
97
|
} );
|
|
99
|
-
}
|
|
98
|
+
}
|
|
100
99
|
|
|
101
100
|
/**
|
|
102
101
|
* @param {ListrTaskObject} listrTask
|
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const { stream } = require( '@ckeditor/ckeditor5-dev-utils' );
|
|
10
|
-
const conventionalChangelogWriter = require( 'conventional-changelog-writer' );
|
|
6
|
+
import { Readable } from 'stream';
|
|
7
|
+
import { stream } from '@ckeditor/ckeditor5-dev-utils';
|
|
8
|
+
import { writeChangelogStream } from 'conventional-changelog-writer';
|
|
11
9
|
|
|
12
10
|
const UPDATED_TRANSLATION_COMMIT = '* Updated translations.';
|
|
13
11
|
|
|
@@ -38,7 +36,7 @@ const UPDATED_TRANSLATION_COMMIT = '* Updated translations.';
|
|
|
38
36
|
*
|
|
39
37
|
* @returns {Promise.<String>}
|
|
40
38
|
*/
|
|
41
|
-
|
|
39
|
+
export default function generateChangelog( commits, context, options ) {
|
|
42
40
|
const commitStream = new Readable( { objectMode: true } );
|
|
43
41
|
/* istanbul ignore next */
|
|
44
42
|
commitStream._read = function() {};
|
|
@@ -51,7 +49,7 @@ module.exports = function generateChangelog( commits, context, options ) {
|
|
|
51
49
|
|
|
52
50
|
return new Promise( ( resolve, reject ) => {
|
|
53
51
|
commitStream
|
|
54
|
-
.pipe(
|
|
52
|
+
.pipe( writeChangelogStream( context, options ) )
|
|
55
53
|
.pipe( stream.noop( changes => {
|
|
56
54
|
changes = mergeUpdateTranslationsCommits( changes.toString(), {
|
|
57
55
|
skipCommitsLink: context.skipCommitsLink
|
|
@@ -61,7 +59,7 @@ module.exports = function generateChangelog( commits, context, options ) {
|
|
|
61
59
|
} ) )
|
|
62
60
|
.on( 'error', reject );
|
|
63
61
|
} );
|
|
64
|
-
}
|
|
62
|
+
}
|
|
65
63
|
|
|
66
64
|
/**
|
|
67
65
|
* Merges multiple "Updated translations." entries into the single commit.
|