@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
package/lib/index.js
CHANGED
|
@@ -3,20 +3,18 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const cleanUpPackages = require( './tasks/cleanuppackages' );
|
|
19
|
-
const {
|
|
6
|
+
export { default as generateChangelogForSinglePackage } from './tasks/generatechangelogforsinglepackage.js';
|
|
7
|
+
export { default as generateChangelogForMonoRepository } from './tasks/generatechangelogformonorepository.js';
|
|
8
|
+
export { default as updateDependencies } from './tasks/updatedependencies.js';
|
|
9
|
+
export { default as commitAndTag } from './tasks/commitandtag.js';
|
|
10
|
+
export { default as createGithubRelease } from './tasks/creategithubrelease.js';
|
|
11
|
+
export { default as reassignNpmTags } from './tasks/reassignnpmtags.js';
|
|
12
|
+
export { default as prepareRepository } from './tasks/preparerepository.js';
|
|
13
|
+
export { default as push } from './tasks/push.js';
|
|
14
|
+
export { default as publishPackages } from './tasks/publishpackages.js';
|
|
15
|
+
export { default as updateVersions } from './tasks/updateversions.js';
|
|
16
|
+
export { default as cleanUpPackages } from './tasks/cleanuppackages.js';
|
|
17
|
+
export {
|
|
20
18
|
getLastFromChangelog,
|
|
21
19
|
getLastPreRelease,
|
|
22
20
|
getNextPreRelease,
|
|
@@ -24,41 +22,14 @@ const {
|
|
|
24
22
|
getNextNightly,
|
|
25
23
|
getCurrent,
|
|
26
24
|
getLastTagFromGit
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
generateChangelogForMonoRepository,
|
|
39
|
-
updateDependencies,
|
|
40
|
-
updateVersions,
|
|
41
|
-
prepareRepository,
|
|
42
|
-
commitAndTag,
|
|
43
|
-
createGithubRelease,
|
|
44
|
-
push,
|
|
45
|
-
cleanUpPackages,
|
|
46
|
-
publishPackages,
|
|
47
|
-
reassignNpmTags,
|
|
48
|
-
executeInParallel,
|
|
49
|
-
getLastFromChangelog,
|
|
50
|
-
getLastPreRelease,
|
|
51
|
-
getNextPreRelease,
|
|
52
|
-
getLastNightly,
|
|
53
|
-
getNextNightly,
|
|
54
|
-
getCurrent,
|
|
55
|
-
getLastTagFromGit,
|
|
56
|
-
getNpmTagFromVersion,
|
|
57
|
-
getChangesForVersion,
|
|
58
|
-
getChangelog,
|
|
59
|
-
saveChangelog,
|
|
60
|
-
validateRepositoryToRelease,
|
|
61
|
-
verifyPackagesPublishedCorrectly,
|
|
62
|
-
checkVersionAvailability,
|
|
63
|
-
isVersionPublishableForTag
|
|
64
|
-
};
|
|
25
|
+
} from './utils/versions.js';
|
|
26
|
+
export { default as getChangesForVersion } from './utils/getchangesforversion.js';
|
|
27
|
+
export { default as getChangelog } from './utils/getchangelog.js';
|
|
28
|
+
export { default as saveChangelog } from './utils/savechangelog.js';
|
|
29
|
+
export { default as executeInParallel } from './utils/executeinparallel.js';
|
|
30
|
+
export { default as validateRepositoryToRelease } from './utils/validaterepositorytorelease.js';
|
|
31
|
+
export { default as checkVersionAvailability } from './utils/checkversionavailability.js';
|
|
32
|
+
export { default as verifyPackagesPublishedCorrectly } from './tasks/verifypackagespublishedcorrectly.js';
|
|
33
|
+
export { default as getNpmTagFromVersion } from './utils/getnpmtagfromversion.js';
|
|
34
|
+
export { default as isVersionPublishableForTag } from './utils/isversionpublishablefortag.js';
|
|
35
|
+
export { default as provideToken } from './utils/providetoken.js';
|
|
@@ -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
|
* The purpose of the script is to clean all packages prepared for the release. The cleaning consists of two stages:
|
|
@@ -29,7 +27,7 @@ const { glob } = require( 'glob' );
|
|
|
29
27
|
* @param {String} [options.cwd] Current working directory from which all paths will be resolved.
|
|
30
28
|
* @returns {Promise}
|
|
31
29
|
*/
|
|
32
|
-
|
|
30
|
+
export default async function cleanUpPackages( options ) {
|
|
33
31
|
const { packagesDirectory, packageJsonFieldsToRemove, preservePostInstallHook, cwd } = parseOptions( options );
|
|
34
32
|
|
|
35
33
|
const packageJsonPaths = await glob( '*/package.json', {
|
|
@@ -47,7 +45,7 @@ module.exports = async function cleanUpPackages( options ) {
|
|
|
47
45
|
|
|
48
46
|
await fs.writeJson( packageJsonPath, packageJson, { spaces: 2 } );
|
|
49
47
|
}
|
|
50
|
-
}
|
|
48
|
+
}
|
|
51
49
|
|
|
52
50
|
/**
|
|
53
51
|
* Prepares the configuration options for the script.
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
import upath from 'upath';
|
|
7
|
+
import { tools } from '@ckeditor/ckeditor5-dev-utils';
|
|
8
|
+
import { glob } from 'glob';
|
|
9
|
+
import shellEscape from 'shell-escape';
|
|
7
10
|
|
|
8
|
-
const {
|
|
9
|
-
const { toUnix } = require( 'upath' );
|
|
10
|
-
const { glob } = require( 'glob' );
|
|
11
|
-
const shellEscape = require( 'shell-escape' );
|
|
11
|
+
const { toUnix } = upath;
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Creates a commit and a tag for specified version.
|
|
@@ -19,7 +19,7 @@ const shellEscape = require( 'shell-escape' );
|
|
|
19
19
|
* @param {String} [options.cwd=process.cwd()] Current working directory from which all paths will be resolved.
|
|
20
20
|
* @returns {Promise}
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
export default async function commitAndTag( { version, files, cwd = process.cwd() } ) {
|
|
23
23
|
const normalizedCwd = toUnix( cwd );
|
|
24
24
|
const filePathsToAdd = await glob( files, { cwd: normalizedCwd, absolute: true, nodir: true } );
|
|
25
25
|
|
|
@@ -41,4 +41,4 @@ module.exports = async function commitAndTag( { version, files, cwd = process.cw
|
|
|
41
41
|
const escapedVersion = shellEscape( [ version ] );
|
|
42
42
|
await tools.shExec( `git commit --message "Release: v${ escapedVersion }." --no-verify`, shExecOptions );
|
|
43
43
|
await tools.shExec( `git tag v${ escapedVersion }`, shExecOptions );
|
|
44
|
-
}
|
|
44
|
+
}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
import { Octokit } from '@octokit/rest';
|
|
7
|
+
import semver from 'semver';
|
|
8
|
+
import * as transformCommitUtils from '../utils/transformcommitutils.js';
|
|
7
9
|
|
|
8
|
-
const {
|
|
9
|
-
const semver = require( 'semver' );
|
|
10
|
-
const { getRepositoryUrl } = require( '../utils/transformcommitutils' );
|
|
10
|
+
const { getRepositoryUrl } = transformCommitUtils;
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Create a GitHub release.
|
|
@@ -19,7 +19,7 @@ const { getRepositoryUrl } = require( '../utils/transformcommitutils' );
|
|
|
19
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
|
+
export default async function createGithubRelease( options ) {
|
|
23
23
|
const {
|
|
24
24
|
token,
|
|
25
25
|
version,
|
|
@@ -46,7 +46,7 @@ module.exports = async function createGithubRelease( options ) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
return `https://github.com/${ repositoryOwner }/${ repositoryName }/releases/tag/v${ version }`;
|
|
49
|
-
}
|
|
49
|
+
}
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* Returns an npm tag based on the specified release version.
|
|
@@ -3,26 +3,28 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { tools, logger } from '@ckeditor/ckeditor5-dev-utils';
|
|
9
|
+
import compareFunc from 'compare-func';
|
|
10
|
+
import chalk from 'chalk';
|
|
11
|
+
import semver from 'semver';
|
|
12
|
+
import displayCommits from '../utils/displaycommits.js';
|
|
13
|
+
import displaySkippedPackages from '../utils/displayskippedpackages.js';
|
|
14
|
+
import generateChangelog from '../utils/generatechangelog.js';
|
|
15
|
+
import getPackageJson from '../utils/getpackagejson.js';
|
|
16
|
+
import getPackagesPaths from '../utils/getpackagespaths.js';
|
|
17
|
+
import getCommits from '../utils/getcommits.js';
|
|
18
|
+
import getNewVersionType from '../utils/getnewversiontype.js';
|
|
19
|
+
import getWriterOptions from '../utils/getwriteroptions.js';
|
|
20
|
+
import getFormattedDate from '../utils/getformatteddate.js';
|
|
21
|
+
import getChangelog from '../utils/getchangelog.js';
|
|
22
|
+
import saveChangelog from '../utils/savechangelog.js';
|
|
23
|
+
import truncateChangelog from '../utils/truncatechangelog.js';
|
|
24
|
+
import transformCommitFactory from '../utils/transformcommitfactory.js';
|
|
25
|
+
import { getRepositoryUrl } from '../utils/transformcommitutils.js';
|
|
26
|
+
import provideNewVersionForMonoRepository from '../utils/providenewversionformonorepository.js';
|
|
27
|
+
import { CHANGELOG_FILE, CHANGELOG_HEADER, CLI_INDENT_SIZE } from '../utils/constants.js';
|
|
26
28
|
|
|
27
29
|
const VERSIONING_POLICY_URL = 'https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/versioning-policy.html';
|
|
28
30
|
const noteInfo = `[ℹ️](${ VERSIONING_POLICY_URL }#major-and-minor-breaking-changes)`;
|
|
@@ -51,6 +53,8 @@ const noteInfo = `[ℹ️](${ VERSIONING_POLICY_URL }#major-and-minor-breaking-c
|
|
|
51
53
|
*
|
|
52
54
|
* @param {String} [options.releaseBranch='master'] A name of the branch that should be used for releasing packages.
|
|
53
55
|
*
|
|
56
|
+
* @param {String} [options.mainBranch='master'] A name of the main branch in the repository.
|
|
57
|
+
*
|
|
54
58
|
* @param {Array.<ExternalRepository>} [options.externalRepositories=[]] An array of object with additional repositories
|
|
55
59
|
* that the function takes into consideration while gathering commits. It assumes that those directories are also mono repositories.
|
|
56
60
|
*
|
|
@@ -63,7 +67,7 @@ const noteInfo = `[ℹ️](${ VERSIONING_POLICY_URL }#major-and-minor-breaking-c
|
|
|
63
67
|
*
|
|
64
68
|
* @returns {Promise.<undefined|String>}
|
|
65
69
|
*/
|
|
66
|
-
|
|
70
|
+
export default async function generateChangelogForMonoRepository( options ) {
|
|
67
71
|
const log = logger();
|
|
68
72
|
const cwd = process.cwd();
|
|
69
73
|
const rootPkgJson = getPackageJson( options.cwd );
|
|
@@ -83,6 +87,7 @@ module.exports = async function generateChangelogForMonoRepository( options ) {
|
|
|
83
87
|
cwd: options.cwd,
|
|
84
88
|
from: options.from ? options.from : 'v' + rootPkgJson.version,
|
|
85
89
|
releaseBranch: options.releaseBranch || 'master',
|
|
90
|
+
mainBranch: options.mainBranch || 'master',
|
|
86
91
|
externalRepositories: options.externalRepositories || []
|
|
87
92
|
};
|
|
88
93
|
|
|
@@ -125,11 +130,11 @@ module.exports = async function generateChangelogForMonoRepository( options ) {
|
|
|
125
130
|
}
|
|
126
131
|
|
|
127
132
|
if ( !skipFileSave ) {
|
|
128
|
-
await
|
|
133
|
+
await saveChangelogToFile();
|
|
129
134
|
|
|
130
135
|
// Make a commit from the repository where we started.
|
|
131
136
|
process.chdir( options.cwd );
|
|
132
|
-
tools.shExec( `git add ${
|
|
137
|
+
tools.shExec( `git add ${ CHANGELOG_FILE }`, { verbosity: 'error' } );
|
|
133
138
|
tools.shExec( 'git commit -m "Docs: Changelog. [skip ci]"', { verbosity: 'error' } );
|
|
134
139
|
logInfo( 'Committed.', { indentLevel: 1 } );
|
|
135
140
|
}
|
|
@@ -223,7 +228,8 @@ module.exports = async function generateChangelogForMonoRepository( options ) {
|
|
|
223
228
|
|
|
224
229
|
const commitOptions = {
|
|
225
230
|
from: options.from,
|
|
226
|
-
releaseBranch: options.releaseBranch
|
|
231
|
+
releaseBranch: options.releaseBranch,
|
|
232
|
+
mainBranch: options.mainBranch
|
|
227
233
|
};
|
|
228
234
|
|
|
229
235
|
let promise = getCommits( transformCommit, commitOptions )
|
|
@@ -295,7 +301,7 @@ module.exports = async function generateChangelogForMonoRepository( options ) {
|
|
|
295
301
|
bumpType = 'patch';
|
|
296
302
|
}
|
|
297
303
|
|
|
298
|
-
return
|
|
304
|
+
return provideNewVersionForMonoRepository( highestVersion, packageHighestVersion, bumpType, { indentLevel: 1 } )
|
|
299
305
|
.then( version => {
|
|
300
306
|
nextVersion = version;
|
|
301
307
|
|
|
@@ -410,12 +416,12 @@ module.exports = async function generateChangelogForMonoRepository( options ) {
|
|
|
410
416
|
isPatch: semver.diff( version, rootPkgJson.version ) === 'patch',
|
|
411
417
|
skipCommitsLink: Boolean( options.skipLinks ),
|
|
412
418
|
skipCompareLink: Boolean( options.skipLinks ),
|
|
413
|
-
date: options.formatDate ? options.formatDate( new Date() ) :
|
|
419
|
+
date: options.formatDate ? options.formatDate( new Date() ) : getFormattedDate()
|
|
414
420
|
};
|
|
415
421
|
|
|
416
|
-
const writerOptions = getWriterOptions( {
|
|
422
|
+
const writerOptions = getWriterOptions( commit => {
|
|
417
423
|
// We do not allow modifying the commit hash value by the generator itself.
|
|
418
|
-
|
|
424
|
+
return commit;
|
|
419
425
|
} );
|
|
420
426
|
|
|
421
427
|
writerOptions.commitsSort = sortFunctionFactory( 'rawScope' );
|
|
@@ -464,7 +470,7 @@ module.exports = async function generateChangelogForMonoRepository( options ) {
|
|
|
464
470
|
const dependenciesSummary = generateSummaryOfChangesInPackages();
|
|
465
471
|
|
|
466
472
|
return [
|
|
467
|
-
|
|
473
|
+
CHANGELOG_HEADER,
|
|
468
474
|
changesFromCommits.trim(),
|
|
469
475
|
'\n\n',
|
|
470
476
|
dependenciesSummary
|
|
@@ -474,26 +480,24 @@ module.exports = async function generateChangelogForMonoRepository( options ) {
|
|
|
474
480
|
/**
|
|
475
481
|
* Combines the generated changes based on commits and summary of version changes in packages.
|
|
476
482
|
* Appends those changes at the beginning of the changelog file.
|
|
477
|
-
*
|
|
478
|
-
* @param {String} changesFromCommits Generated entries based on commits.
|
|
479
483
|
*/
|
|
480
|
-
async function
|
|
484
|
+
async function saveChangelogToFile() {
|
|
481
485
|
logProcess( 'Saving changelog...' );
|
|
482
486
|
|
|
483
|
-
if ( !fs.existsSync(
|
|
487
|
+
if ( !fs.existsSync( CHANGELOG_FILE ) ) {
|
|
484
488
|
logInfo( 'Changelog file does not exist. Creating...', { isWarning: true, indentLevel: 1 } );
|
|
485
489
|
|
|
486
|
-
|
|
490
|
+
saveChangelog( CHANGELOG_FILE );
|
|
487
491
|
}
|
|
488
492
|
|
|
489
493
|
logInfo( 'Preparing a summary of version changes in packages.', { indentLevel: 1 } );
|
|
490
494
|
|
|
491
|
-
let currentChangelog =
|
|
495
|
+
let currentChangelog = getChangelog();
|
|
492
496
|
|
|
493
497
|
const nextVersionChangelog = await getChangelogForNextVersion();
|
|
494
498
|
|
|
495
499
|
// Remove header from current changelog.
|
|
496
|
-
currentChangelog = currentChangelog.replace(
|
|
500
|
+
currentChangelog = currentChangelog.replace( CHANGELOG_HEADER, '' ).trim();
|
|
497
501
|
|
|
498
502
|
// Concat header, new entries and old changelog to single string.
|
|
499
503
|
let newChangelog = nextVersionChangelog + '\n\n\n' + currentChangelog;
|
|
@@ -501,10 +505,10 @@ module.exports = async function generateChangelogForMonoRepository( options ) {
|
|
|
501
505
|
newChangelog = newChangelog.trim() + '\n';
|
|
502
506
|
|
|
503
507
|
// Save the changelog.
|
|
504
|
-
|
|
508
|
+
saveChangelog( newChangelog );
|
|
505
509
|
|
|
506
510
|
// Truncate the changelog to keep the latest five release entries.
|
|
507
|
-
|
|
511
|
+
truncateChangelog( 5 );
|
|
508
512
|
|
|
509
513
|
logInfo( 'Saved.', { indentLevel: 1 } );
|
|
510
514
|
}
|
|
@@ -721,9 +725,9 @@ module.exports = async function generateChangelogForMonoRepository( options ) {
|
|
|
721
725
|
const startWithNewLine = options.startWithNewLine || false;
|
|
722
726
|
const method = options.isWarning ? 'warning' : 'info';
|
|
723
727
|
|
|
724
|
-
log[ method ]( `${ startWithNewLine ? '\n' : '' }${ ' '.repeat( indentLevel *
|
|
728
|
+
log[ method ]( `${ startWithNewLine ? '\n' : '' }${ ' '.repeat( indentLevel * CLI_INDENT_SIZE ) }` + message );
|
|
725
729
|
}
|
|
726
|
-
}
|
|
730
|
+
}
|
|
727
731
|
|
|
728
732
|
/**
|
|
729
733
|
* @typedef {Object} Version
|
|
@@ -3,22 +3,23 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
import { tools, logger } from '@ckeditor/ckeditor5-dev-utils';
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import semver from 'semver';
|
|
10
|
+
import displayCommits from '../utils/displaycommits.js';
|
|
11
|
+
import generateChangelog from '../utils/generatechangelog.js';
|
|
12
|
+
import getPackageJson from '../utils/getpackagejson.js';
|
|
13
|
+
import getNewVersionType from '../utils/getnewversiontype.js';
|
|
14
|
+
import getCommits from '../utils/getcommits.js';
|
|
15
|
+
import getWriterOptions from '../utils/getwriteroptions.js';
|
|
16
|
+
import { getRepositoryUrl } from '../utils/transformcommitutils.js';
|
|
17
|
+
import transformCommitFactory from '../utils/transformcommitfactory.js';
|
|
18
|
+
import getFormattedDate from '../utils/getformatteddate.js';
|
|
19
|
+
import saveChangelog from '../utils/savechangelog.js';
|
|
20
|
+
import getChangelog from '../utils/getchangelog.js';
|
|
21
|
+
import provideVersion from '../utils/provideversion.js';
|
|
22
|
+
import { CHANGELOG_FILE, CHANGELOG_HEADER, CLI_INDENT_SIZE } from '../utils/constants.js';
|
|
22
23
|
|
|
23
24
|
const SKIP_GENERATE_CHANGELOG = 'Typed "skip" as a new version. Aborting.';
|
|
24
25
|
|
|
@@ -35,12 +36,14 @@ const SKIP_GENERATE_CHANGELOG = 'Typed "skip" as a new version. Aborting.';
|
|
|
35
36
|
*
|
|
36
37
|
* @param {String} [options.releaseBranch='master'] A name of the branch that should be used for releasing packages.
|
|
37
38
|
*
|
|
39
|
+
* @param {String} [options.mainBranch='master'] A name of the main branch in the repository.
|
|
40
|
+
*
|
|
38
41
|
* @param {FormatDateCallback} [options.formatDate] A callback allowing defining a custom format of the date inserted into the changelog.
|
|
39
42
|
* If not specified, the default date matches the `YYYY-MM-DD` pattern.
|
|
40
43
|
*
|
|
41
44
|
* @returns {Promise}
|
|
42
45
|
*/
|
|
43
|
-
|
|
46
|
+
export default async function generateChangelogForSinglePackage( options = {} ) {
|
|
44
47
|
const log = logger();
|
|
45
48
|
const pkgJson = getPackageJson();
|
|
46
49
|
|
|
@@ -52,7 +55,8 @@ module.exports = async function generateChangelogForSinglePackage( options = {}
|
|
|
52
55
|
|
|
53
56
|
const commitOptions = {
|
|
54
57
|
from: options.from ? options.from : 'v' + pkgJson.version,
|
|
55
|
-
releaseBranch: options.releaseBranch
|
|
58
|
+
releaseBranch: options.releaseBranch || 'master',
|
|
59
|
+
mainBranch: options.mainBranch || 'master'
|
|
56
60
|
};
|
|
57
61
|
|
|
58
62
|
// Initial release.
|
|
@@ -79,7 +83,7 @@ module.exports = async function generateChangelogForSinglePackage( options = {}
|
|
|
79
83
|
|
|
80
84
|
displayCommits( allCommits, { indentLevel: 1 } );
|
|
81
85
|
|
|
82
|
-
return
|
|
86
|
+
return provideVersion( pkgJson.version, releaseType, { indentLevel: 1 } );
|
|
83
87
|
} )
|
|
84
88
|
.then( version => {
|
|
85
89
|
if ( version === 'skip' ) {
|
|
@@ -106,12 +110,12 @@ module.exports = async function generateChangelogForSinglePackage( options = {}
|
|
|
106
110
|
isInternalRelease,
|
|
107
111
|
skipCommitsLink: Boolean( options.skipLinks ),
|
|
108
112
|
skipCompareLink: Boolean( options.skipLinks ),
|
|
109
|
-
date: options.formatDate ? options.formatDate( new Date() ) :
|
|
113
|
+
date: options.formatDate ? options.formatDate( new Date() ) : getFormattedDate()
|
|
110
114
|
};
|
|
111
115
|
|
|
112
|
-
const writerOptions = getWriterOptions( {
|
|
116
|
+
const writerOptions = getWriterOptions( commit => {
|
|
113
117
|
// We do not allow modifying the commit hash value by the generator itself.
|
|
114
|
-
|
|
118
|
+
return commit;
|
|
115
119
|
} );
|
|
116
120
|
|
|
117
121
|
const publicCommits = [ ...allCommits ]
|
|
@@ -137,25 +141,25 @@ module.exports = async function generateChangelogForSinglePackage( options = {}
|
|
|
137
141
|
.then( changesFromCommits => {
|
|
138
142
|
logProcess( 'Saving changelog...' );
|
|
139
143
|
|
|
140
|
-
if ( !fs.existsSync(
|
|
144
|
+
if ( !fs.existsSync( CHANGELOG_FILE ) ) {
|
|
141
145
|
logInfo( 'Changelog file does not exist. Creating...', { isWarning: true, indentLevel: 1 } );
|
|
142
146
|
|
|
143
|
-
|
|
147
|
+
saveChangelog( CHANGELOG_HEADER );
|
|
144
148
|
}
|
|
145
149
|
|
|
146
|
-
let currentChangelog =
|
|
150
|
+
let currentChangelog = getChangelog();
|
|
147
151
|
|
|
148
152
|
// Remove header from current changelog.
|
|
149
|
-
currentChangelog = currentChangelog.replace(
|
|
153
|
+
currentChangelog = currentChangelog.replace( CHANGELOG_HEADER, '' );
|
|
150
154
|
|
|
151
155
|
// Concat header, new and current changelog.
|
|
152
|
-
let newChangelog =
|
|
156
|
+
let newChangelog = CHANGELOG_HEADER + changesFromCommits + currentChangelog.trim();
|
|
153
157
|
newChangelog = newChangelog.trim() + '\n';
|
|
154
158
|
|
|
155
159
|
// Save the changelog.
|
|
156
|
-
|
|
160
|
+
saveChangelog( newChangelog );
|
|
157
161
|
|
|
158
|
-
tools.shExec( `git add ${
|
|
162
|
+
tools.shExec( `git add ${ CHANGELOG_FILE }`, { verbosity: 'error' } );
|
|
159
163
|
tools.shExec( 'git commit -m "Docs: Changelog. [skip ci]"', { verbosity: 'error' } );
|
|
160
164
|
|
|
161
165
|
logInfo( 'Saved.', { indentLevel: 1 } );
|
|
@@ -193,9 +197,9 @@ module.exports = async function generateChangelogForSinglePackage( options = {}
|
|
|
193
197
|
const startWithNewLine = options.startWithNewLine || false;
|
|
194
198
|
const method = options.isWarning ? 'warning' : 'info';
|
|
195
199
|
|
|
196
|
-
log[ method ]( `${ startWithNewLine ? '\n' : '' }${ ' '.repeat( indentLevel *
|
|
200
|
+
log[ method ]( `${ startWithNewLine ? '\n' : '' }${ ' '.repeat( indentLevel * CLI_INDENT_SIZE ) }` + message );
|
|
197
201
|
}
|
|
198
|
-
}
|
|
202
|
+
}
|
|
199
203
|
|
|
200
204
|
/**
|
|
201
205
|
* @callback FormatDateCallback
|
|
@@ -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 goal is to prepare the release directory containing the packages we want to publish.
|
|
@@ -23,7 +21,7 @@ const upath = require( 'upath' );
|
|
|
23
21
|
* If not specified, the root package will not be created.
|
|
24
22
|
* @returns {Promise}
|
|
25
23
|
*/
|
|
26
|
-
|
|
24
|
+
export default async function prepareRepository( options ) {
|
|
27
25
|
const {
|
|
28
26
|
outputDirectory,
|
|
29
27
|
packagesDirectory,
|
|
@@ -70,7 +68,7 @@ module.exports = async function prepareRepository( options ) {
|
|
|
70
68
|
}
|
|
71
69
|
|
|
72
70
|
return Promise.all( copyPromises );
|
|
73
|
-
}
|
|
71
|
+
}
|
|
74
72
|
|
|
75
73
|
/**
|
|
76
74
|
* @param {Object} packageJson
|
|
@@ -102,12 +100,13 @@ async function processRootPackage( { cwd, rootPackageJson, outputDirectoryPath }
|
|
|
102
100
|
await fs.ensureDir( rootPackageOutputPath );
|
|
103
101
|
await fs.writeJson( pkgJsonOutputPath, rootPackageJson, { spaces: 2, EOL: '\n' } );
|
|
104
102
|
|
|
105
|
-
return glob
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
return ( await glob( rootPackageJson.files ) )
|
|
104
|
+
.map( absoluteFilePath => {
|
|
105
|
+
const relativeFilePath = upath.relative( cwd, absoluteFilePath );
|
|
106
|
+
const absoluteFileOutputPath = upath.join( rootPackageOutputPath, relativeFilePath );
|
|
108
107
|
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
return fs.copy( absoluteFilePath, absoluteFileOutputPath );
|
|
109
|
+
} );
|
|
111
110
|
}
|
|
112
111
|
|
|
113
112
|
/**
|
|
@@ -3,16 +3,14 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const executeInParallel = require( '../utils/executeinparallel' );
|
|
15
|
-
const publishPackageOnNpmCallback = require( '../utils/publishpackageonnpmcallback' );
|
|
6
|
+
import upath from 'upath';
|
|
7
|
+
import { glob } from 'glob';
|
|
8
|
+
import assertNpmAuthorization from '../utils/assertnpmauthorization.js';
|
|
9
|
+
import assertPackages from '../utils/assertpackages.js';
|
|
10
|
+
import assertNpmTag from '../utils/assertnpmtag.js';
|
|
11
|
+
import assertFilesToPublish from '../utils/assertfilestopublish.js';
|
|
12
|
+
import executeInParallel from '../utils/executeinparallel.js';
|
|
13
|
+
import publishPackageOnNpmCallback from '../utils/publishpackageonnpmcallback.js';
|
|
16
14
|
|
|
17
15
|
/**
|
|
18
16
|
* The purpose of the script is to validate the packages prepared for the release and then release them on npm.
|
|
@@ -46,7 +44,7 @@ const publishPackageOnNpmCallback = require( '../utils/publishpackageonnpmcallba
|
|
|
46
44
|
* @param {Number} [options.concurrency=4] Number of CPUs that will execute the task.
|
|
47
45
|
* @returns {Promise}
|
|
48
46
|
*/
|
|
49
|
-
|
|
47
|
+
export default async function publishPackages( options ) {
|
|
50
48
|
const {
|
|
51
49
|
packagesDirectory,
|
|
52
50
|
npmOwner,
|
|
@@ -87,4 +85,4 @@ module.exports = async function publishPackages( options ) {
|
|
|
87
85
|
concurrency
|
|
88
86
|
} );
|
|
89
87
|
}
|
|
90
|
-
}
|
|
88
|
+
}
|
package/lib/tasks/push.js
CHANGED
|
@@ -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
|
* Push the local changes to a remote server.
|
|
@@ -17,7 +15,7 @@ const shellEscape = require( 'shell-escape' );
|
|
|
17
15
|
* @param {String} [options.cwd] Root of the repository to prepare. `process.cwd()` by default.
|
|
18
16
|
* @returns {Promise}
|
|
19
17
|
*/
|
|
20
|
-
|
|
18
|
+
export default async function push( options ) {
|
|
21
19
|
const {
|
|
22
20
|
releaseBranch,
|
|
23
21
|
version,
|
|
@@ -27,4 +25,4 @@ module.exports = async function push( options ) {
|
|
|
27
25
|
const command = `git push origin ${ shellEscape( [ releaseBranch ] ) } v${ shellEscape( [ version ] ) }`;
|
|
28
26
|
|
|
29
27
|
return tools.shExec( command, { cwd, verbosity: 'error', async: true } );
|
|
30
|
-
}
|
|
28
|
+
}
|