@ckeditor/ckeditor5-dev-release-tools 44.0.0-alpha.5 → 44.1.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.
- package/lib/index.js +1 -0
- package/lib/tasks/cleanuppackages.js +24 -28
- package/lib/tasks/commitandtag.js +16 -21
- package/lib/tasks/creategithubrelease.js +11 -23
- package/lib/tasks/generatechangelogformonorepository.js +62 -55
- package/lib/tasks/generatechangelogforsinglepackage.js +17 -14
- package/lib/tasks/preparerepository.js +19 -19
- package/lib/tasks/publishpackages.js +88 -31
- package/lib/tasks/push.js +4 -4
- package/lib/tasks/reassignnpmtags.js +8 -8
- package/lib/tasks/updatedependencies.js +23 -43
- package/lib/tasks/updateversions.js +22 -96
- package/lib/tasks/verifypackagespublishedcorrectly.js +18 -12
- package/lib/utils/assertfilestopublish.js +6 -6
- package/lib/utils/assertnpmauthorization.js +1 -1
- package/lib/utils/assertnpmtag.js +10 -24
- package/lib/utils/assertpackages.js +4 -4
- package/lib/utils/checkversionavailability.js +8 -24
- package/lib/utils/configurereleaseoptions.js +1 -1
- package/lib/utils/confirmincludingpackage.js +1 -1
- package/lib/utils/confirmnpmtag.js +3 -3
- package/lib/utils/displaycommits.js +4 -4
- package/lib/utils/executeinparallel.js +24 -29
- package/lib/utils/findpathstopackages.js +78 -0
- package/lib/utils/generatechangelog.js +23 -23
- package/lib/utils/getchangedfilesforcommit.js +2 -2
- package/lib/utils/getchangelog.js +2 -2
- package/lib/utils/getchangesforversion.js +3 -3
- package/lib/utils/getcommits.js +7 -6
- package/lib/utils/getformatteddate.js +1 -1
- package/lib/utils/getnewversiontype.js +1 -1
- package/lib/utils/getnpmtagfromversion.js +11 -2
- package/lib/utils/getpackagejson.js +2 -2
- package/lib/utils/getpackagespaths.js +9 -9
- package/lib/utils/getwriteroptions.js +1 -1
- package/lib/utils/isversionpublishablefortag.js +8 -10
- package/lib/utils/parallelworker.js +2 -2
- package/lib/utils/providenewversionformonorepository.js +28 -12
- package/lib/utils/providetoken.js +1 -1
- package/lib/utils/provideversion.js +41 -24
- package/lib/utils/publishpackageonnpmcallback.js +10 -20
- package/lib/utils/savechangelog.js +2 -2
- package/lib/utils/transformcommitfactory.js +27 -27
- package/lib/utils/transformcommitutils.js +13 -13
- package/lib/utils/truncatechangelog.js +2 -2
- package/lib/utils/validaterepositorytorelease.js +6 -6
- package/lib/utils/versions.js +17 -16
- package/package.json +3 -2
package/lib/index.js
CHANGED
|
@@ -33,3 +33,4 @@ export { default as verifyPackagesPublishedCorrectly } from './tasks/verifypacka
|
|
|
33
33
|
export { default as getNpmTagFromVersion } from './utils/getnpmtagfromversion.js';
|
|
34
34
|
export { default as isVersionPublishableForTag } from './utils/isversionpublishablefortag.js';
|
|
35
35
|
export { default as provideToken } from './utils/providetoken.js';
|
|
36
|
+
export { default as findPathsToPackages } from './utils/findpathstopackages.js';
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import fs from 'fs-extra';
|
|
7
7
|
import upath from 'upath';
|
|
8
8
|
import { glob } from 'glob';
|
|
9
|
+
import findPathsToPackages from '../utils/findpathstopackages.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* The purpose of the script is to clean all packages prepared for the release. The cleaning consists of two stages:
|
|
@@ -19,22 +20,17 @@ import { glob } from 'glob';
|
|
|
19
20
|
* - file pointed by the `types` field from `package.json`
|
|
20
21
|
* - Removes unnecessary fields from the `package.json` file.
|
|
21
22
|
*
|
|
22
|
-
* @param {
|
|
23
|
-
* @param {
|
|
24
|
-
* @param {Array.<
|
|
23
|
+
* @param {object} options
|
|
24
|
+
* @param {string} options.packagesDirectory Relative path to a location of packages to be cleaned up.
|
|
25
|
+
* @param {Array.<string>|PackageJsonFieldsToRemoveCallback} [options.packageJsonFieldsToRemove] Fields to remove from `package.json`.
|
|
25
26
|
* If not set, a predefined list is used. If the callback is used, the first argument is the list with defaults.
|
|
26
|
-
* @param {
|
|
27
|
-
* @param {
|
|
27
|
+
* @param {boolean} [options.preservePostInstallHook] Whether to preserve the postinstall hook in `package.json`.
|
|
28
|
+
* @param {string} [options.cwd] Current working directory from which all paths will be resolved.
|
|
28
29
|
* @returns {Promise}
|
|
29
30
|
*/
|
|
30
31
|
export default async function cleanUpPackages( options ) {
|
|
31
32
|
const { packagesDirectory, packageJsonFieldsToRemove, preservePostInstallHook, cwd } = parseOptions( options );
|
|
32
|
-
|
|
33
|
-
const packageJsonPaths = await glob( '*/package.json', {
|
|
34
|
-
cwd: upath.join( cwd, packagesDirectory ),
|
|
35
|
-
nodir: true,
|
|
36
|
-
absolute: true
|
|
37
|
-
} );
|
|
33
|
+
const packageJsonPaths = await findPathsToPackages( cwd, packagesDirectory, { includePackageJson: true } );
|
|
38
34
|
|
|
39
35
|
for ( const packageJsonPath of packageJsonPaths ) {
|
|
40
36
|
const packagePath = upath.dirname( packageJsonPath );
|
|
@@ -50,12 +46,12 @@ export default async function cleanUpPackages( options ) {
|
|
|
50
46
|
/**
|
|
51
47
|
* Prepares the configuration options for the script.
|
|
52
48
|
*
|
|
53
|
-
* @param {
|
|
54
|
-
* @param {
|
|
55
|
-
* @param {Array.<
|
|
56
|
-
* @param {
|
|
57
|
-
* @param {
|
|
58
|
-
* @returns {
|
|
49
|
+
* @param {object} options
|
|
50
|
+
* @param {string} options.packagesDirectory
|
|
51
|
+
* @param {Array.<string>|PackageJsonFieldsToRemoveCallback} [options.packageJsonFieldsToRemove=DefaultFieldsToRemove]
|
|
52
|
+
* @param {boolean} [options.preservePostInstallHook]
|
|
53
|
+
* @param {string} [options.cwd=process.cwd()]
|
|
54
|
+
* @returns {object}
|
|
59
55
|
*/
|
|
60
56
|
function parseOptions( options ) {
|
|
61
57
|
const defaultPackageJsonFieldsToRemove = [ 'devDependencies', 'depcheckIgnore', 'scripts', 'private' ];
|
|
@@ -79,8 +75,8 @@ function parseOptions( options ) {
|
|
|
79
75
|
/**
|
|
80
76
|
* Removes unnecessary files and directories from the package directory.
|
|
81
77
|
*
|
|
82
|
-
* @param {
|
|
83
|
-
* @param {
|
|
78
|
+
* @param {object} packageJson
|
|
79
|
+
* @param {string} packagePath
|
|
84
80
|
* @returns {Promise}
|
|
85
81
|
*/
|
|
86
82
|
async function cleanUpPackageDirectory( packageJson, packagePath ) {
|
|
@@ -129,8 +125,8 @@ async function cleanUpPackageDirectory( packageJson, packagePath ) {
|
|
|
129
125
|
/**
|
|
130
126
|
* Creates an array of patterns to ignore for the `glob` calls.
|
|
131
127
|
*
|
|
132
|
-
* @param {
|
|
133
|
-
* @returns {Array.<
|
|
128
|
+
* @param {object} packageJson
|
|
129
|
+
* @returns {Array.<string>}
|
|
134
130
|
*/
|
|
135
131
|
function getIgnoredFilePatterns( packageJson ) {
|
|
136
132
|
// The patterns supported by `package.json` in the `files` field do not correspond 1:1 to the patterns expected by the `glob`.
|
|
@@ -155,9 +151,9 @@ function getIgnoredFilePatterns( packageJson ) {
|
|
|
155
151
|
/**
|
|
156
152
|
* Removes unnecessary fields from the `package.json`.
|
|
157
153
|
*
|
|
158
|
-
* @param {
|
|
159
|
-
* @param {Array.<
|
|
160
|
-
* @param {
|
|
154
|
+
* @param {object} packageJson
|
|
155
|
+
* @param {Array.<string>} packageJsonFieldsToRemove
|
|
156
|
+
* @param {boolean} preservePostInstallHook
|
|
161
157
|
*/
|
|
162
158
|
function cleanUpPackageJson( packageJson, packageJsonFieldsToRemove, preservePostInstallHook ) {
|
|
163
159
|
for ( const key of Object.keys( packageJson ) ) {
|
|
@@ -176,9 +172,9 @@ function cleanUpPackageJson( packageJson, packageJsonFieldsToRemove, preservePos
|
|
|
176
172
|
/**
|
|
177
173
|
* Sort function that defines the order of the paths. It sorts paths from the most nested ones first.
|
|
178
174
|
*
|
|
179
|
-
* @param {
|
|
180
|
-
* @param {
|
|
181
|
-
* @returns {
|
|
175
|
+
* @param {string} firstPath
|
|
176
|
+
* @param {string} secondPath
|
|
177
|
+
* @returns {number}
|
|
182
178
|
*/
|
|
183
179
|
function sortPathsFromDeepestFirst( firstPath, secondPath ) {
|
|
184
180
|
const firstPathSegments = firstPath.split( '/' ).length;
|
|
@@ -194,5 +190,5 @@ function sortPathsFromDeepestFirst( firstPath, secondPath ) {
|
|
|
194
190
|
/**
|
|
195
191
|
* @callback PackageJsonFieldsToRemoveCallback
|
|
196
192
|
* @param {DefaultFieldsToRemove} defaults
|
|
197
|
-
* @returns {Array.<
|
|
193
|
+
* @returns {Array.<string>}
|
|
198
194
|
*/
|
|
@@ -4,19 +4,18 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import upath from 'upath';
|
|
7
|
-
import { tools } from '@ckeditor/ckeditor5-dev-utils';
|
|
8
7
|
import { glob } from 'glob';
|
|
9
|
-
import
|
|
8
|
+
import { simpleGit } from 'simple-git';
|
|
10
9
|
|
|
11
10
|
const { toUnix } = upath;
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Creates a commit and a tag for specified version.
|
|
15
14
|
*
|
|
16
|
-
* @param {
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {Array.<
|
|
19
|
-
* @param {
|
|
15
|
+
* @param {object} options
|
|
16
|
+
* @param {string} options.version The commit will contain this param in its message and the tag will have a `v` prefix.
|
|
17
|
+
* @param {Array.<string>} options.files Array of glob patterns for files to be added to the release commit.
|
|
18
|
+
* @param {string} [options.cwd=process.cwd()] Current working directory from which all paths will be resolved.
|
|
20
19
|
* @returns {Promise}
|
|
21
20
|
*/
|
|
22
21
|
export default async function commitAndTag( { version, files, cwd = process.cwd() } ) {
|
|
@@ -27,22 +26,18 @@ export default async function commitAndTag( { version, files, cwd = process.cwd(
|
|
|
27
26
|
return;
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
verbosity: 'silent'
|
|
34
|
-
};
|
|
29
|
+
const git = simpleGit( {
|
|
30
|
+
baseDir: normalizedCwd
|
|
31
|
+
} );
|
|
35
32
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
await tools.shExec( `git add ${ shellEscape( [ filePath ] ) }`, shExecOptions );
|
|
39
|
-
}
|
|
33
|
+
const { all: availableTags } = await git.tags();
|
|
34
|
+
const tagForVersion = availableTags.find( tag => tag.endsWith( version ) );
|
|
40
35
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
36
|
+
// Do not commit and create tags if a tag is already taken. It might happen when a release job is restarted.
|
|
37
|
+
if ( tagForVersion ) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
45
40
|
|
|
46
|
-
await
|
|
47
|
-
await
|
|
41
|
+
await git.commit( `Release: v${ version }.`, filePathsToAdd );
|
|
42
|
+
await git.addTag( `v${ version }` );
|
|
48
43
|
}
|
|
@@ -4,20 +4,20 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { Octokit } from '@octokit/rest';
|
|
7
|
-
import semver from 'semver';
|
|
8
7
|
import * as transformCommitUtils from '../utils/transformcommitutils.js';
|
|
8
|
+
import getNpmTagFromVersion from '../utils/getnpmtagfromversion.js';
|
|
9
9
|
|
|
10
10
|
const { getRepositoryUrl } = transformCommitUtils;
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Create a GitHub release.
|
|
14
14
|
*
|
|
15
|
-
* @param {
|
|
16
|
-
* @param {
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {
|
|
20
|
-
* @returns {Promise.<
|
|
15
|
+
* @param {object} options
|
|
16
|
+
* @param {string} options.token Token used to authenticate with GitHub.
|
|
17
|
+
* @param {string} options.version Name of tag connected with the release.
|
|
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
|
+
* @returns {Promise.<string>}
|
|
21
21
|
*/
|
|
22
22
|
export default async function createGithubRelease( options ) {
|
|
23
23
|
const {
|
|
@@ -41,32 +41,20 @@ export default async function createGithubRelease( options ) {
|
|
|
41
41
|
owner: repositoryOwner,
|
|
42
42
|
repo: repositoryName,
|
|
43
43
|
body: description,
|
|
44
|
-
prerelease:
|
|
44
|
+
prerelease: getNpmTagFromVersion( version ) !== 'latest'
|
|
45
45
|
} );
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
return `https://github.com/${ repositoryOwner }/${ repositoryName }/releases/tag/v${ version }`;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
/**
|
|
52
|
-
* Returns an npm tag based on the specified release version.
|
|
53
|
-
*
|
|
54
|
-
* @param {String} version
|
|
55
|
-
* @returns {String}
|
|
56
|
-
*/
|
|
57
|
-
function getVersionTag( version ) {
|
|
58
|
-
const [ versionTag ] = semver.prerelease( version ) || [ 'latest' ];
|
|
59
|
-
|
|
60
|
-
return versionTag;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
51
|
/**
|
|
64
52
|
* Resolves a promise containing a flag if the GitHub contains the release page for given version.
|
|
65
53
|
*
|
|
66
54
|
* @param {Octokit} github
|
|
67
|
-
* @param {
|
|
68
|
-
* @param {
|
|
69
|
-
* @param {
|
|
55
|
+
* @param {string} repositoryOwner
|
|
56
|
+
* @param {string} repositoryName
|
|
57
|
+
* @param {string} version
|
|
70
58
|
* @returns {Promise.<boolean>}
|
|
71
59
|
*/
|
|
72
60
|
async function shouldCreateRelease( github, repositoryOwner, repositoryName, version ) {
|
|
@@ -35,37 +35,37 @@ const noteInfo = `[ℹ️](${ VERSIONING_POLICY_URL }#major-and-minor-breaking-c
|
|
|
35
35
|
*
|
|
36
36
|
* The typed version will be the same for all packages. See: https://github.com/ckeditor/ckeditor5/issues/7323.
|
|
37
37
|
*
|
|
38
|
-
* @param {
|
|
38
|
+
* @param {object} options
|
|
39
39
|
*
|
|
40
|
-
* @param {
|
|
40
|
+
* @param {string} options.cwd Current working directory (packages) from which all paths will be resolved.
|
|
41
41
|
*
|
|
42
|
-
* @param {
|
|
42
|
+
* @param {string} options.packages Where to look for packages.
|
|
43
43
|
*
|
|
44
|
-
* @param {
|
|
44
|
+
* @param {function} options.transformScope A function that returns a URL to a package from a scope of a commit.
|
|
45
45
|
*
|
|
46
|
-
* @param {
|
|
46
|
+
* @param {string} [options.scope] Package names have to match to specified glob pattern in order to be processed.
|
|
47
47
|
*
|
|
48
|
-
* @param {Array.<
|
|
48
|
+
* @param {Array.<string>} [options.skipPackages=[]] Name of packages which won't be touched.
|
|
49
49
|
*
|
|
50
|
-
* @param {
|
|
50
|
+
* @param {boolean} [options.skipLinks=false] If set on true, links to release or commits will be omitted.
|
|
51
51
|
*
|
|
52
|
-
* @param {
|
|
52
|
+
* @param {string} [options.from] A commit or tag name that will be the first param of the range of commits to collect.
|
|
53
53
|
*
|
|
54
|
-
* @param {
|
|
54
|
+
* @param {string} [options.releaseBranch='master'] A name of the branch that should be used for releasing packages.
|
|
55
55
|
*
|
|
56
|
-
* @param {
|
|
56
|
+
* @param {string} [options.mainBranch='master'] A name of the main branch in the repository.
|
|
57
57
|
*
|
|
58
58
|
* @param {Array.<ExternalRepository>} [options.externalRepositories=[]] An array of object with additional repositories
|
|
59
59
|
* that the function takes into consideration while gathering commits. It assumes that those directories are also mono repositories.
|
|
60
60
|
*
|
|
61
|
-
* @param {
|
|
61
|
+
* @param {boolean} [options.skipFileSave=false] Whether to resolve the changes instead of saving it to a file.
|
|
62
62
|
*
|
|
63
|
-
* @param {
|
|
63
|
+
* @param {string|null} [options.nextVersion=null] Next version to use. If not provided, a user needs to provide via CLI.
|
|
64
64
|
*
|
|
65
65
|
* @param {FormatDateCallback} [options.formatDate] A callback allowing defining a custom format of the date inserted into the changelog.
|
|
66
66
|
* If not specified, the default date matches the `YYYY-MM-DD` pattern.
|
|
67
67
|
*
|
|
68
|
-
* @returns {Promise.<undefined|
|
|
68
|
+
* @returns {Promise.<undefined|string>}
|
|
69
69
|
*/
|
|
70
70
|
export default async function generateChangelogForMonoRepository( options ) {
|
|
71
71
|
const log = logger();
|
|
@@ -161,11 +161,11 @@ export default async function generateChangelogForMonoRepository( options ) {
|
|
|
161
161
|
/**
|
|
162
162
|
* Returns collections with packages found in the `options.cwd` directory and the external repositories.
|
|
163
163
|
*
|
|
164
|
-
* @param {
|
|
165
|
-
* @param {
|
|
166
|
-
* @param {
|
|
167
|
-
* @param {
|
|
168
|
-
* @param {Array.<
|
|
164
|
+
* @param {object} options
|
|
165
|
+
* @param {string} options.cwd Current working directory (packages) from which all paths will be resolved.
|
|
166
|
+
* @param {string} options.packages Where to look for packages.
|
|
167
|
+
* @param {string} options.scope Package names have to match to specified glob pattern in order to be processed.
|
|
168
|
+
* @param {Array.<string>} options.skipPackages Name of packages which won't be touched.
|
|
169
169
|
* @param {Array.<ExternalRepository>} options.externalRepositories An array of object with additional repositories
|
|
170
170
|
* that the function takes into consideration while gathering packages.
|
|
171
171
|
* @returns {PathsCollection}
|
|
@@ -210,10 +210,10 @@ export default async function generateChangelogForMonoRepository( options ) {
|
|
|
210
210
|
/**
|
|
211
211
|
* Returns a promise that resolves an array of commits since the last tag specified as `options.from`.
|
|
212
212
|
*
|
|
213
|
-
* @param {
|
|
214
|
-
* @param {
|
|
215
|
-
* @param {
|
|
216
|
-
* @param {
|
|
213
|
+
* @param {object} options
|
|
214
|
+
* @param {string} options.cwd Current working directory (packages) from which all paths will be resolved.
|
|
215
|
+
* @param {string} options.from A commit or tag name that will be the first param of the range of commits to collect.
|
|
216
|
+
* @param {string} options.releaseBranch A name of the branch that should be used for releasing packages.
|
|
217
217
|
* @param {Array.<ExternalRepository>} options.externalRepositories An array of object with additional repositories
|
|
218
218
|
* that the function takes into consideration while gathering commits.
|
|
219
219
|
* @returns {Promise.<Array.<Commit>>}
|
|
@@ -301,7 +301,14 @@ export default async function generateChangelogForMonoRepository( options ) {
|
|
|
301
301
|
bumpType = 'patch';
|
|
302
302
|
}
|
|
303
303
|
|
|
304
|
-
|
|
304
|
+
const provideVersionOptions = {
|
|
305
|
+
packageName: packageHighestVersion,
|
|
306
|
+
version: highestVersion,
|
|
307
|
+
bumpType,
|
|
308
|
+
indentLevel: 1
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
return provideNewVersionForMonoRepository( provideVersionOptions )
|
|
305
312
|
.then( version => {
|
|
306
313
|
nextVersion = version;
|
|
307
314
|
|
|
@@ -378,7 +385,7 @@ export default async function generateChangelogForMonoRepository( options ) {
|
|
|
378
385
|
* Finds commits that touched the package under `packagePath` directory.
|
|
379
386
|
*
|
|
380
387
|
* @param {Array.<Commit>} commits
|
|
381
|
-
* @param {
|
|
388
|
+
* @param {string} packagePath
|
|
382
389
|
* @returns {Array.<Commit>}
|
|
383
390
|
*/
|
|
384
391
|
function filterCommitsByPath( commits, packagePath ) {
|
|
@@ -400,7 +407,7 @@ export default async function generateChangelogForMonoRepository( options ) {
|
|
|
400
407
|
/**
|
|
401
408
|
* Generates a list of changes based on the commits in the main repository.
|
|
402
409
|
*
|
|
403
|
-
* @returns {Promise.<
|
|
410
|
+
* @returns {Promise.<string>}
|
|
404
411
|
*/
|
|
405
412
|
function generateChangelogFromCommits() {
|
|
406
413
|
logProcess( 'Generating the changelog...' );
|
|
@@ -516,7 +523,7 @@ export default async function generateChangelogForMonoRepository( options ) {
|
|
|
516
523
|
/**
|
|
517
524
|
* Prepares a summary that describes what has changed in all dependencies.
|
|
518
525
|
*
|
|
519
|
-
* @returns {
|
|
526
|
+
* @returns {string}
|
|
520
527
|
*/
|
|
521
528
|
function generateSummaryOfChangesInPackages() {
|
|
522
529
|
const dependencies = new Map();
|
|
@@ -597,8 +604,8 @@ export default async function generateChangelogForMonoRepository( options ) {
|
|
|
597
604
|
}
|
|
598
605
|
|
|
599
606
|
/**
|
|
600
|
-
* @param {Map.<
|
|
601
|
-
* @returns {Map.<
|
|
607
|
+
* @param {Map.<string, Version>} dependencies
|
|
608
|
+
* @returns {Map.<string, Version>}
|
|
602
609
|
*/
|
|
603
610
|
function getNewPackages( dependencies ) {
|
|
604
611
|
const packages = new Map();
|
|
@@ -616,9 +623,9 @@ export default async function generateChangelogForMonoRepository( options ) {
|
|
|
616
623
|
/**
|
|
617
624
|
* Returns packages where scope of changes described in the commits' notes match to packages' names.
|
|
618
625
|
*
|
|
619
|
-
* @param {Map.<
|
|
620
|
-
* @param {
|
|
621
|
-
* @returns {Map.<
|
|
626
|
+
* @param {Map.<string, Version>} dependencies
|
|
627
|
+
* @param {string} noteTitle
|
|
628
|
+
* @returns {Map.<string, Version>}
|
|
622
629
|
*/
|
|
623
630
|
function getPackagesMatchedToScopesFromNotes( dependencies, noteTitle ) {
|
|
624
631
|
const packages = new Map();
|
|
@@ -649,8 +656,8 @@ export default async function generateChangelogForMonoRepository( options ) {
|
|
|
649
656
|
/**
|
|
650
657
|
* Returns packages that contain new features.
|
|
651
658
|
*
|
|
652
|
-
* @param {Map.<
|
|
653
|
-
* @returns {Map.<
|
|
659
|
+
* @param {Map.<string, Version>} dependencies
|
|
660
|
+
* @returns {Map.<string, Version>}
|
|
654
661
|
*/
|
|
655
662
|
function getPackagesWithNewFeatures( dependencies ) {
|
|
656
663
|
const packages = new Map();
|
|
@@ -672,10 +679,10 @@ export default async function generateChangelogForMonoRepository( options ) {
|
|
|
672
679
|
/**
|
|
673
680
|
* Returns a formatted entry (string) for the changelog.
|
|
674
681
|
*
|
|
675
|
-
* @param {
|
|
676
|
-
* @param {
|
|
677
|
-
* @param {
|
|
678
|
-
* @returns {
|
|
682
|
+
* @param {string} packageName
|
|
683
|
+
* @param {string} nextVersion
|
|
684
|
+
* @param {string} currentVersion
|
|
685
|
+
* @returns {string}
|
|
679
686
|
*/
|
|
680
687
|
function formatChangelogEntry( packageName, nextVersion, currentVersion = null ) {
|
|
681
688
|
const npmUrl = `https://www.npmjs.com/package/${ packageName }/v/${ nextVersion }`;
|
|
@@ -690,7 +697,7 @@ export default async function generateChangelogForMonoRepository( options ) {
|
|
|
690
697
|
/**
|
|
691
698
|
* Returns a function that is being used when sorting commits.
|
|
692
699
|
*
|
|
693
|
-
* @param {
|
|
700
|
+
* @param {string} scopeField A name of the field that saves the commit's scope.
|
|
694
701
|
* @returns {Function}
|
|
695
702
|
*/
|
|
696
703
|
function sortFunctionFactory( scopeField ) {
|
|
@@ -714,11 +721,11 @@ export default async function generateChangelogForMonoRepository( options ) {
|
|
|
714
721
|
}
|
|
715
722
|
|
|
716
723
|
/**
|
|
717
|
-
* @param {
|
|
718
|
-
* @param {
|
|
719
|
-
* @param {
|
|
720
|
-
* @param {
|
|
721
|
-
* @param {
|
|
724
|
+
* @param {string} message
|
|
725
|
+
* @param {object} [options={}]
|
|
726
|
+
* @param {number} [options.indentLevel=0]
|
|
727
|
+
* @param {boolean} [options.startWithNewLine=false] Whether to append a new line before the message.
|
|
728
|
+
* @param {boolean} [options.isWarning=false] Whether to use `warning` method instead of `log`.
|
|
722
729
|
*/
|
|
723
730
|
function logInfo( message, options = {} ) {
|
|
724
731
|
const indentLevel = options.indentLevel || 0;
|
|
@@ -730,30 +737,30 @@ export default async function generateChangelogForMonoRepository( options ) {
|
|
|
730
737
|
}
|
|
731
738
|
|
|
732
739
|
/**
|
|
733
|
-
* @typedef {
|
|
740
|
+
* @typedef {object} Version
|
|
734
741
|
*
|
|
735
|
-
* @param {
|
|
742
|
+
* @param {boolean} current The current version defined in the `package.json` file.
|
|
736
743
|
*
|
|
737
|
-
* @param {
|
|
744
|
+
* @param {boolean} next The next version defined during generating the changelog file.
|
|
738
745
|
*/
|
|
739
746
|
|
|
740
747
|
/**
|
|
741
|
-
* @typedef {
|
|
748
|
+
* @typedef {object} ExternalRepository
|
|
742
749
|
*
|
|
743
|
-
* @param {
|
|
750
|
+
* @param {string} cwd An absolute path to the repository.
|
|
744
751
|
*
|
|
745
|
-
* @param {
|
|
752
|
+
* @param {string} packages Subdirectory in a given `cwd` that should searched for packages. E.g. `'packages'`.
|
|
746
753
|
*
|
|
747
|
-
* @param {
|
|
754
|
+
* @param {string} [scope] Glob pattern for package names to be processed.
|
|
748
755
|
*
|
|
749
|
-
* @param {Array.<
|
|
756
|
+
* @param {Array.<string>} [skipPackages] Name of packages which won't be touched.
|
|
750
757
|
*
|
|
751
|
-
* @param {
|
|
758
|
+
* @param {boolean} [skipLinks] If set on `true`, a URL to commit (hash) will be omitted.
|
|
752
759
|
*
|
|
753
|
-
* @param {
|
|
760
|
+
* @param {string} [from] A commit or tag name that will be the first param of the range of commits to collect. If not specified,
|
|
754
761
|
* the option will inherit its value from the function's `options` object.
|
|
755
762
|
*
|
|
756
|
-
* @param {
|
|
763
|
+
* @param {string} [releaseBranch] A name of the branch that should be used for releasing packages. If not specified, the branch
|
|
757
764
|
* used for the main repository will be used.
|
|
758
765
|
*/
|
|
759
766
|
|
|
@@ -762,5 +769,5 @@ export default async function generateChangelogForMonoRepository( options ) {
|
|
|
762
769
|
*
|
|
763
770
|
* @param {Date} now The current date.
|
|
764
771
|
*
|
|
765
|
-
* @returns {
|
|
772
|
+
* @returns {string} The formatted date inserted into the changelog.
|
|
766
773
|
*/
|
|
@@ -28,15 +28,15 @@ const SKIP_GENERATE_CHANGELOG = 'Typed "skip" as a new version. Aborting.';
|
|
|
28
28
|
*
|
|
29
29
|
* If the package does not have any commit, the user has to confirm whether the changelog should be generated.
|
|
30
30
|
*
|
|
31
|
-
* @param {
|
|
31
|
+
* @param {object} [options={}] Additional options.
|
|
32
32
|
*
|
|
33
|
-
* @param {
|
|
33
|
+
* @param {boolean} [options.skipLinks=false] If set on true, links to release or commits will be omitted.
|
|
34
34
|
*
|
|
35
|
-
* @param {
|
|
35
|
+
* @param {string} [options.from] A commit or tag name that will be the first param of the range of commits to collect.
|
|
36
36
|
*
|
|
37
|
-
* @param {
|
|
37
|
+
* @param {string} [options.releaseBranch='master'] A name of the branch that should be used for releasing packages.
|
|
38
38
|
*
|
|
39
|
-
* @param {
|
|
39
|
+
* @param {string} [options.mainBranch='master'] A name of the main branch in the repository.
|
|
40
40
|
*
|
|
41
41
|
* @param {FormatDateCallback} [options.formatDate] A callback allowing defining a custom format of the date inserted into the changelog.
|
|
42
42
|
* If not specified, the default date matches the `YYYY-MM-DD` pattern.
|
|
@@ -79,11 +79,14 @@ export default async function generateChangelogForSinglePackage( options = {} )
|
|
|
79
79
|
.then( () => {
|
|
80
80
|
logProcess( 'Preparing new version for the package...' );
|
|
81
81
|
|
|
82
|
-
const releaseType = getNewVersionType( allCommits );
|
|
83
|
-
|
|
84
82
|
displayCommits( allCommits, { indentLevel: 1 } );
|
|
85
83
|
|
|
86
|
-
return provideVersion(
|
|
84
|
+
return provideVersion( {
|
|
85
|
+
packageName: pkgJson.name,
|
|
86
|
+
version: pkgJson.version,
|
|
87
|
+
indentLevel: 1,
|
|
88
|
+
releaseTypeOrNewVersion: getNewVersionType( allCommits )
|
|
89
|
+
} );
|
|
87
90
|
} )
|
|
88
91
|
.then( version => {
|
|
89
92
|
if ( version === 'skip' ) {
|
|
@@ -186,11 +189,11 @@ export default async function generateChangelogForSinglePackage( options = {} )
|
|
|
186
189
|
}
|
|
187
190
|
|
|
188
191
|
/**
|
|
189
|
-
* @param {
|
|
190
|
-
* @param {
|
|
191
|
-
* @param {
|
|
192
|
-
* @param {
|
|
193
|
-
* @param {
|
|
192
|
+
* @param {string} message
|
|
193
|
+
* @param {object} [options={}]
|
|
194
|
+
* @param {number} [options.indentLevel=0]
|
|
195
|
+
* @param {boolean} [options.startWithNewLine=false] Whether to append a new line before the message.
|
|
196
|
+
* @param {boolean} [options.isWarning=false] Whether to use `warning` method instead of `log`.
|
|
194
197
|
*/
|
|
195
198
|
function logInfo( message, options = {} ) {
|
|
196
199
|
const indentLevel = options.indentLevel || 0;
|
|
@@ -206,5 +209,5 @@ export default async function generateChangelogForSinglePackage( options = {} )
|
|
|
206
209
|
*
|
|
207
210
|
* @param {Date} now The current date.
|
|
208
211
|
*
|
|
209
|
-
* @returns {
|
|
212
|
+
* @returns {string} The formatted date inserted into the changelog.
|
|
210
213
|
*/
|
|
@@ -10,12 +10,12 @@ import upath from 'upath';
|
|
|
10
10
|
/**
|
|
11
11
|
* The goal is to prepare the release directory containing the packages we want to publish.
|
|
12
12
|
*
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {
|
|
16
|
-
* @param {
|
|
13
|
+
* @param {object} options
|
|
14
|
+
* @param {string} options.outputDirectory Relative path to the destination directory where packages will be stored.
|
|
15
|
+
* @param {string} [options.cwd] Root of the repository to prepare. `process.cwd()` by default.
|
|
16
|
+
* @param {string} [options.packagesDirectory] Relative path to a location of packages.
|
|
17
17
|
* If specified, all of the found packages will be copied.
|
|
18
|
-
* @param {Array.<
|
|
18
|
+
* @param {Array.<string>} [options.packagesToCopy] List of packages that should be processed.
|
|
19
19
|
* If not specified, all packages found in `packagesDirectory` are considered.
|
|
20
20
|
* @param {RootPackageJson} [options.rootPackageJson] Object containing values to use in the created the `package.json` file.
|
|
21
21
|
* If not specified, the root package will not be created.
|
|
@@ -71,9 +71,9 @@ export default async function prepareRepository( options ) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
* @param {
|
|
75
|
-
* @param {
|
|
76
|
-
* @param {Array.<
|
|
74
|
+
* @param {object} packageJson
|
|
75
|
+
* @param {string} [packageJson.name]
|
|
76
|
+
* @param {Array.<string>} [packageJson.files]
|
|
77
77
|
*/
|
|
78
78
|
function validateRootPackage( packageJson ) {
|
|
79
79
|
if ( !packageJson.name ) {
|
|
@@ -86,10 +86,10 @@ function validateRootPackage( packageJson ) {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
|
-
* @param {
|
|
90
|
-
* @param {
|
|
89
|
+
* @param {object} options
|
|
90
|
+
* @param {string} options.cwd
|
|
91
91
|
* @param {RootPackageJson} options.rootPackageJson
|
|
92
|
-
* @param {
|
|
92
|
+
* @param {string} options.outputDirectoryPath
|
|
93
93
|
* @returns {Promise}
|
|
94
94
|
*/
|
|
95
95
|
async function processRootPackage( { cwd, rootPackageJson, outputDirectoryPath } ) {
|
|
@@ -110,11 +110,11 @@ async function processRootPackage( { cwd, rootPackageJson, outputDirectoryPath }
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
|
-
* @param {
|
|
114
|
-
* @param {
|
|
115
|
-
* @param {
|
|
116
|
-
* @param {
|
|
117
|
-
* @param {Array.<
|
|
113
|
+
* @param {object} options
|
|
114
|
+
* @param {string} options.cwd
|
|
115
|
+
* @param {string} options.packagesDirectory
|
|
116
|
+
* @param {string} options.outputDirectoryPath
|
|
117
|
+
* @param {Array.<string>} [options.packagesToCopy]
|
|
118
118
|
* @returns {Promise}
|
|
119
119
|
*/
|
|
120
120
|
async function processMonorepoPackages( { cwd, packagesDirectory, packagesToCopy, outputDirectoryPath } ) {
|
|
@@ -141,9 +141,9 @@ async function processMonorepoPackages( { cwd, packagesDirectory, packagesToCopy
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
|
-
* @typedef {
|
|
144
|
+
* @typedef {object} RootPackageJson
|
|
145
145
|
*
|
|
146
|
-
* @param {
|
|
146
|
+
* @param {string} options.rootPackageJson.name Name of the package. Required value.
|
|
147
147
|
*
|
|
148
|
-
* @param {Array.<
|
|
148
|
+
* @param {Array.<string>} options.rootPackageJson.files Array containing a list of files or directories to copy. Required value.
|
|
149
149
|
*/
|