@ckeditor/ckeditor5-dev-release-tools 43.0.0 → 44.0.0-alpha.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.
Files changed (53) hide show
  1. package/lib/index.js +23 -52
  2. package/lib/tasks/cleanuppackages.js +5 -7
  3. package/lib/tasks/commitandtag.js +7 -7
  4. package/lib/tasks/creategithubrelease.js +6 -6
  5. package/lib/tasks/generatechangelogformonorepository.js +37 -37
  6. package/lib/tasks/generatechangelogforsinglepackage.js +29 -28
  7. package/lib/tasks/preparerepository.js +11 -12
  8. package/lib/tasks/publishpackages.js +10 -12
  9. package/lib/tasks/push.js +4 -6
  10. package/lib/tasks/reassignnpmtags.js +11 -13
  11. package/lib/tasks/updatedependencies.js +5 -7
  12. package/lib/tasks/updateversions.js +8 -8
  13. package/lib/tasks/verifypackagespublishedcorrectly.js +6 -8
  14. package/lib/utils/abortcontroller.js +2 -11
  15. package/lib/utils/assertfilestopublish.js +5 -7
  16. package/lib/utils/assertnpmauthorization.js +3 -5
  17. package/lib/utils/assertnpmtag.js +5 -7
  18. package/lib/utils/assertpackages.js +4 -6
  19. package/lib/utils/checkversionavailability.js +4 -6
  20. package/lib/utils/configurereleaseoptions.js +43 -0
  21. package/lib/utils/confirmincludingpackage.js +24 -0
  22. package/lib/utils/confirmnpmtag.js +32 -0
  23. package/lib/utils/constants.js +26 -0
  24. package/lib/utils/displaycommits.js +9 -11
  25. package/lib/utils/displayskippedpackages.js +7 -9
  26. package/lib/utils/executeinparallel.js +13 -14
  27. package/lib/utils/generatechangelog.js +5 -7
  28. package/lib/utils/getchangedfilesforcommit.js +3 -5
  29. package/lib/utils/getchangelog.js +22 -0
  30. package/lib/utils/getchangesforversion.js +28 -0
  31. package/lib/utils/getcommits.js +8 -10
  32. package/lib/utils/getformatteddate.js +13 -0
  33. package/lib/utils/getnewversiontype.js +2 -4
  34. package/lib/utils/getnpmtagfromversion.js +3 -5
  35. package/lib/utils/getpackagejson.js +4 -6
  36. package/lib/utils/getpackagespaths.js +7 -9
  37. package/lib/utils/getwriteroptions.js +9 -6
  38. package/lib/utils/isversionpublishablefortag.js +5 -5
  39. package/lib/utils/{parallelworker.cjs → parallelworker.js} +3 -4
  40. package/lib/utils/parseroptions.js +1 -3
  41. package/lib/utils/providenewversionformonorepository.js +51 -0
  42. package/lib/utils/providetoken.js +26 -0
  43. package/lib/utils/provideversion.js +98 -0
  44. package/lib/utils/publishpackageonnpmcallback.js +10 -12
  45. package/lib/utils/savechangelog.js +18 -0
  46. package/lib/utils/transformcommitfactory.js +6 -6
  47. package/lib/utils/transformcommitutils.js +142 -147
  48. package/lib/utils/truncatechangelog.js +42 -0
  49. package/lib/utils/validaterepositorytorelease.js +3 -5
  50. package/lib/utils/versions.js +122 -128
  51. package/package.json +3 -2
  52. package/lib/utils/changelog.js +0 -109
  53. package/lib/utils/cli.js +0 -349
@@ -0,0 +1,28 @@
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 { CHANGELOG_HEADER } from './constants.js';
7
+ import getChangelog from './getchangelog.js';
8
+
9
+ /**
10
+ * Retrieves changes from the changelog for the given version (tag).
11
+ *
12
+ * @param {String} version
13
+ * @param {String} [cwd=process.cwd()] Where to look for the changelog file.
14
+ * @returns {String|null}
15
+ */
16
+ export default function getChangesForVersion( version, cwd = process.cwd() ) {
17
+ version = version.replace( /^v/, '' );
18
+
19
+ const changelog = getChangelog( cwd ).replace( CHANGELOG_HEADER, '\n' );
20
+
21
+ const match = changelog.match( new RegExp( `\\n(## \\[?${ version }\\]?[\\s\\S]+?)(?:\\n## \\[?|$)` ) );
22
+
23
+ if ( !match || !match[ 1 ] ) {
24
+ return null;
25
+ }
26
+
27
+ return match[ 1 ].replace( /##[^\n]+\n/, '' ).trim();
28
+ }
@@ -3,14 +3,12 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const conventionalCommitsParser = require( 'conventional-commits-parser' );
9
- const conventionalCommitsFilter = require( 'conventional-commits-filter' );
10
- const gitRawCommits = require( 'git-raw-commits' );
11
- const concat = require( 'concat-stream' );
12
- const parserOptions = require( './parseroptions' );
13
- const { tools } = require( '@ckeditor/ckeditor5-dev-utils' );
6
+ import conventionalCommitsParser from 'conventional-commits-parser';
7
+ import conventionalCommitsFilter from 'conventional-commits-filter';
8
+ import gitRawCommits from 'git-raw-commits';
9
+ import concat from 'concat-stream';
10
+ import parserOptions from './parseroptions.js';
11
+ import { tools } from '@ckeditor/ckeditor5-dev-utils';
14
12
 
15
13
  /**
16
14
  * Returns a promise that resolves an array of commits since the last tag specified as `options.from`.
@@ -22,7 +20,7 @@ const { tools } = require( '@ckeditor/ckeditor5-dev-utils' );
22
20
  * @param {String} [options.mainBranch='master'] A name of the main branch in the repository.
23
21
  * @returns {Promise.<Array.<Commit>>}
24
22
  */
25
- module.exports = function getCommits( transformCommit, options = {} ) {
23
+ export default function getCommits( transformCommit, options = {} ) {
26
24
  const releaseBranch = options.releaseBranch || 'master';
27
25
  const mainBranch = options.mainBranch || 'master';
28
26
 
@@ -101,4 +99,4 @@ module.exports = function getCommits( transformCommit, options = {} ) {
101
99
  function exec( command ) {
102
100
  return tools.shExec( command, { verbosity: 'error' } );
103
101
  }
104
- };
102
+ }
@@ -0,0 +1,13 @@
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 { format } from 'date-fns';
7
+
8
+ /**
9
+ * @returns {String}
10
+ */
11
+ export default function getFormattedDate() {
12
+ return format( new Date(), 'yyyy-MM-dd' );
13
+ }
@@ -3,15 +3,13 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
6
  /**
9
7
  * Proposes new version based on commits.
10
8
  *
11
9
  * @param {Array.<Commit>} commits
12
10
  * @returns {String|null}
13
11
  */
14
- module.exports = function getNewVersionType( commits ) {
12
+ export default function getNewVersionType( commits ) {
15
13
  // No commits = no changes.
16
14
  if ( !commits.length ) {
17
15
  return 'skip';
@@ -50,4 +48,4 @@ module.exports = function getNewVersionType( commits ) {
50
48
  }
51
49
 
52
50
  return 'patch';
53
- };
51
+ }
@@ -3,16 +3,14 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const semver = require( 'semver' );
6
+ import semver from 'semver';
9
7
 
10
8
  /**
11
9
  * @param {String} version
12
10
  * @returns {String}
13
11
  */
14
- module.exports = function getNpmTagFromVersion( version ) {
12
+ export default function getNpmTagFromVersion( version ) {
15
13
  const [ versionTag ] = semver.prerelease( version ) || [ 'latest' ];
16
14
 
17
15
  return versionTag;
18
- };
16
+ }
@@ -3,10 +3,8 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const fs = require( 'fs' );
9
- const upath = require( 'upath' );
6
+ import fs from 'fs';
7
+ import upath from 'upath';
10
8
 
11
9
  /**
12
10
  * Returns object from `package.json`.
@@ -17,7 +15,7 @@ const upath = require( 'upath' );
17
15
  * @param {String} [cwd=process.cwd()] Where to look for package.json.
18
16
  * @returns {Object}
19
17
  */
20
- module.exports = function getPackageJson( cwd = process.cwd() ) {
18
+ export default function getPackageJson( cwd = process.cwd() ) {
21
19
  let pkgJsonPath = cwd;
22
20
 
23
21
  if ( !pkgJsonPath.endsWith( 'package.json' ) ) {
@@ -25,4 +23,4 @@ module.exports = function getPackageJson( cwd = process.cwd() ) {
25
23
  }
26
24
 
27
25
  return JSON.parse( fs.readFileSync( pkgJsonPath, 'utf-8' ) );
28
- };
26
+ }
@@ -3,19 +3,17 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const path = require( 'path' );
9
- const minimatch = require( 'minimatch' );
10
- const { tools } = require( '@ckeditor/ckeditor5-dev-utils' );
11
- const getPackageJson = require( './getpackagejson' );
6
+ import path from 'path';
7
+ import minimatch from 'minimatch';
8
+ import { tools } from '@ckeditor/ckeditor5-dev-utils';
9
+ import getPackageJson from './getpackagejson.js';
12
10
 
13
11
  /**
14
12
  * Returns an object with two collections of paths to packages which are located in single repository.
15
13
  * Those packages must be defined as dependencies in the repository found in `options.cwd`.
16
14
  *
17
15
  * - The first one is marked as `matched` and means that packages specified in a path (which is a combination of values specified as
18
- * `options.cwd` and `options.packages`) match to given criteria.
16
+ * `options.cwd` and `options.packages`) match to given criteria.
19
17
  * - The second one is marked as `skipped` and means that packages should not be processed. They were listed as packages to skip
20
18
  * (`options.skipPackages` or don't mach to `options.scope`).
21
19
  *
@@ -28,7 +26,7 @@ const getPackageJson = require( './getpackagejson' );
28
26
  * @param {Boolean} [options.skipMainRepository=false] If set on true, package found in `options.cwd` will be skipped.
29
27
  * @returns {PathsCollection}
30
28
  */
31
- module.exports = function getPackagesPaths( options ) {
29
+ export default function getPackagesPaths( options ) {
32
30
  const pathsCollection = {
33
31
  matched: new Set(),
34
32
  skipped: new Set()
@@ -79,7 +77,7 @@ module.exports = function getPackagesPaths( options ) {
79
77
 
80
78
  return true;
81
79
  }
82
- };
80
+ }
83
81
 
84
82
  /**
85
83
  * @typedef {Object} PathsCollection
@@ -3,18 +3,21 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
6
+ import fs from 'fs';
7
+ import path from 'path';
8
+ import { fileURLToPath } from 'url';
9
+ import { getTypeOrder } from './transformcommitutils.js';
10
+
11
+ const __filename = fileURLToPath( import.meta.url );
12
+ const __dirname = path.dirname( __filename );
7
13
 
8
- const fs = require( 'fs' );
9
- const path = require( 'path' );
10
14
  const templatePath = path.join( __dirname, '..', 'templates' );
11
- const { getTypeOrder } = require( './transformcommitutils' );
12
15
 
13
16
  /**
14
17
  * @param {Function|Object} transform
15
18
  * @returns {Object}
16
19
  */
17
- module.exports = function getWriterOptions( transform ) {
20
+ export default function getWriterOptions( transform ) {
18
21
  return {
19
22
  transform,
20
23
  groupBy: 'type',
@@ -26,7 +29,7 @@ module.exports = function getWriterOptions( transform ) {
26
29
  commitPartial: fs.readFileSync( path.join( templatePath, 'commit.hbs' ), 'utf-8' ),
27
30
  footerPartial: fs.readFileSync( path.join( templatePath, 'footer.hbs' ), 'utf-8' )
28
31
  };
29
- };
32
+ }
30
33
 
31
34
  function sortFunction( a, b ) {
32
35
  return getTypeOrder( a.title ) - getTypeOrder( b.title );
@@ -3,9 +3,9 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- const { tools } = require( '@ckeditor/ckeditor5-dev-utils' );
7
- const semver = require( 'semver' );
8
- const shellEscape = require( 'shell-escape' );
6
+ import { tools } from '@ckeditor/ckeditor5-dev-utils';
7
+ import semver from 'semver';
8
+ import shellEscape from 'shell-escape';
9
9
 
10
10
  /**
11
11
  * This util aims to verify if the given `packageName` can be published with the given `version` on the `npmTag`.
@@ -15,7 +15,7 @@ const shellEscape = require( 'shell-escape' );
15
15
  * @param {String} npmTag
16
16
  * @return {Promise.<Boolean>}
17
17
  */
18
- module.exports = async function isVersionPublishableForTag( packageName, version, npmTag ) {
18
+ export default async function isVersionPublishableForTag( packageName, version, npmTag ) {
19
19
  const command = `npm view ${ shellEscape( [ packageName ] ) }@${ shellEscape( [ npmTag ] ) } version --silent`;
20
20
  const npmVersion = await tools.shExec( command, { async: true, verbosity: 'silent' } )
21
21
  .then( value => value.trim() )
@@ -27,4 +27,4 @@ module.exports = async function isVersionPublishableForTag( packageName, version
27
27
  }
28
28
 
29
29
  return true;
30
- };
30
+ }
@@ -3,18 +3,17 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
6
  // This file is covered by the "executeInParallel() - integration" test cases.
9
7
 
8
+ import { parentPort, workerData } from 'worker_threads';
9
+
10
10
  // Required due to top-level await.
11
11
  ( async () => {
12
12
  /**
13
13
  * @param {String} callbackModule
14
14
  * @param {Array.<String>} packages
15
15
  */
16
- const { parentPort, workerData } = require( 'worker_threads' );
17
- const callback = require( workerData.callbackModule );
16
+ const { default: callback } = await import( workerData.callbackModule );
18
17
 
19
18
  for ( const packagePath of workerData.packages ) {
20
19
  await callback( packagePath, workerData.taskOptions );
@@ -3,9 +3,7 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- module.exports = {
6
+ export default {
9
7
  mergePattern: /^Merge .*$/,
10
8
  headerPattern: /^([^:]+): (.*)$/,
11
9
  headerCorrespondence: [
@@ -0,0 +1,51 @@
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 semver from 'semver';
8
+ import chalk from 'chalk';
9
+ import { CLI_INDENT_SIZE } from './constants.js';
10
+
11
+ /**
12
+ * Asks a user for providing the new version for a major release.
13
+ *
14
+ * @param {String} version
15
+ * @param {String} foundPackage
16
+ * @param {String} bumpType
17
+ * @param {Object} [options={}]
18
+ * @param {Number} [options.indentLevel=0] The indent level.
19
+ * @returns {Promise.<String>}
20
+ */
21
+ export default async function provideNewVersionForMonoRepository( version, foundPackage, bumpType, options = {} ) {
22
+ const indentLevel = options.indentLevel || 0;
23
+ const suggestedVersion = semver.inc( version, bumpType );
24
+
25
+ const message = 'Type the new version ' +
26
+ `(current highest: "${ version }" found in "${ chalk.underline( foundPackage ) }", suggested: "${ suggestedVersion }"):`;
27
+
28
+ const versionQuestion = {
29
+ type: 'input',
30
+ name: 'version',
31
+ default: suggestedVersion,
32
+ message,
33
+
34
+ filter( input ) {
35
+ return input.trim();
36
+ },
37
+
38
+ validate( input ) {
39
+ if ( !semver.valid( input ) ) {
40
+ return 'Please provide a valid version.';
41
+ }
42
+
43
+ return semver.gt( input, version ) ? true : `Provided version must be higher than "${ version }".`;
44
+ },
45
+ prefix: ' '.repeat( indentLevel * CLI_INDENT_SIZE ) + chalk.cyan( '?' )
46
+ };
47
+
48
+ const answers = await inquirer.prompt( [ versionQuestion ] );
49
+
50
+ return answers.version;
51
+ }
@@ -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
+ import inquirer from 'inquirer';
7
+
8
+ /**
9
+ * Asks a user for providing the GitHub token.
10
+ *
11
+ * @returns {Promise.<String>}
12
+ */
13
+ export default async function provideToken() {
14
+ const tokenQuestion = {
15
+ type: 'password',
16
+ name: 'token',
17
+ message: 'Provide the GitHub token:',
18
+ validate( input ) {
19
+ return input.length === 40 ? true : 'Please provide a valid token.';
20
+ }
21
+ };
22
+
23
+ const { token } = await inquirer.prompt( [ tokenQuestion ] );
24
+
25
+ return token;
26
+ }
@@ -0,0 +1,98 @@
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 semver from 'semver';
8
+ import chalk from 'chalk';
9
+ import { CLI_INDENT_SIZE } from './constants.js';
10
+
11
+ /**
12
+ * Asks a user for providing the new version.
13
+ *
14
+ * @param {String} packageVersion
15
+ * @param {String|null} releaseTypeOrNewVersion
16
+ * @param {Object} [options]
17
+ * @param {Boolean} [options.disableInternalVersion=false] Whether to "internal" version is enabled.
18
+ * @param {Boolean} [options.disableSkipVersion=false] Whether to "skip" version is enabled.
19
+ * @param {Number} [options.indentLevel=0] The indent level.
20
+ * @returns {Promise.<String>}
21
+ */
22
+ export default function provideVersion( packageVersion, releaseTypeOrNewVersion, options = {} ) {
23
+ const indentLevel = options.indentLevel || 0;
24
+ const suggestedVersion = getSuggestedVersion( {
25
+ packageVersion,
26
+ releaseTypeOrNewVersion,
27
+ disableInternalVersion: options.disableInternalVersion
28
+ } );
29
+
30
+ let message = 'Type the new version, "skip" or "internal"';
31
+
32
+ if ( options.disableInternalVersion ) {
33
+ message = 'Type the new version or "skip"';
34
+ }
35
+
36
+ message += ` (suggested: "${ suggestedVersion }", current: "${ packageVersion }"):`;
37
+
38
+ const versionQuestion = {
39
+ type: 'input',
40
+ name: 'version',
41
+ default: suggestedVersion,
42
+ message,
43
+
44
+ filter( input ) {
45
+ return input.trim();
46
+ },
47
+
48
+ validate( input ) {
49
+ if ( !options.disableSkipVersion && input === 'skip' ) {
50
+ return true;
51
+ }
52
+
53
+ if ( !options.disableInternalVersion && input === 'internal' ) {
54
+ return true;
55
+ }
56
+
57
+ // TODO: Check whether provided version is available.
58
+ return semver.valid( input ) ? true : 'Please provide a valid version.';
59
+ },
60
+
61
+ prefix: ' '.repeat( indentLevel * CLI_INDENT_SIZE ) + chalk.cyan( '?' )
62
+ };
63
+
64
+ return inquirer.prompt( [ versionQuestion ] )
65
+ .then( answers => answers.version );
66
+ }
67
+
68
+ /**
69
+ * @param {Object} options
70
+ * @param {String} options.packageVersion
71
+ * @param {String|null} options.releaseTypeOrNewVersion
72
+ * @param {Boolean} options.disableInternalVersion
73
+ * @return {String}
74
+ */
75
+ function getSuggestedVersion( { packageVersion, releaseTypeOrNewVersion, disableInternalVersion } ) {
76
+ if ( !releaseTypeOrNewVersion || releaseTypeOrNewVersion === 'skip' ) {
77
+ return 'skip';
78
+ }
79
+
80
+ if ( semver.valid( releaseTypeOrNewVersion ) ) {
81
+ return releaseTypeOrNewVersion;
82
+ }
83
+
84
+ if ( releaseTypeOrNewVersion === 'internal' ) {
85
+ return disableInternalVersion ? 'skip' : 'internal';
86
+ }
87
+
88
+ if ( semver.prerelease( packageVersion ) ) {
89
+ releaseTypeOrNewVersion = 'prerelease';
90
+ }
91
+
92
+ // If package's version is below the '1.0.0', bump the 'minor' instead of 'major'
93
+ if ( releaseTypeOrNewVersion === 'major' && semver.gt( '1.0.0', packageVersion ) ) {
94
+ return semver.inc( packageVersion, 'minor' );
95
+ }
96
+
97
+ return semver.inc( packageVersion, releaseTypeOrNewVersion );
98
+ }
@@ -3,10 +3,6 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- /* eslint-env node */
7
-
8
- 'use strict';
9
-
10
6
  /**
11
7
  * Calls the npm command to publish the package. When a package is successfully published, it is removed from the filesystem.
12
8
  *
@@ -15,18 +11,20 @@
15
11
  * @param {String} taskOptions.npmTag
16
12
  * @returns {Promise}
17
13
  */
18
- module.exports = async function publishPackageOnNpmCallback( packagePath, taskOptions ) {
19
- const { tools } = require( '@ckeditor/ckeditor5-dev-utils' );
20
- const upath = require( 'upath' );
21
- const fs = require( 'fs-extra' );
14
+ export default async function publishPackageOnNpmCallback( packagePath, taskOptions ) {
15
+ const { tools } = await import( '@ckeditor/ckeditor5-dev-utils' );
16
+ const { default: fs } = await import( 'fs-extra' );
17
+ const { default: path } = await import( 'upath' );
22
18
 
23
- const result = await tools.shExec( `npm publish --access=public --tag ${ taskOptions.npmTag }`, {
19
+ const options = {
24
20
  cwd: packagePath,
25
21
  async: true,
26
22
  verbosity: 'error'
27
- } )
23
+ };
24
+
25
+ const result = await tools.shExec( `npm publish --access=public --tag ${ taskOptions.npmTag }`, options )
28
26
  .catch( e => {
29
- const packageName = upath.basename( packagePath );
27
+ const packageName = path.basename( packagePath );
30
28
 
31
29
  if ( e.toString().includes( 'code E409' ) ) {
32
30
  return { shouldKeepDirectory: true };
@@ -38,4 +36,4 @@ module.exports = async function publishPackageOnNpmCallback( packagePath, taskOp
38
36
  if ( !result || !result.shouldKeepDirectory ) {
39
37
  await fs.remove( packagePath );
40
38
  }
41
- };
39
+ }
@@ -0,0 +1,18 @@
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 fs from 'fs';
7
+ import path from 'path';
8
+ import { CHANGELOG_FILE } from './constants.js';
9
+
10
+ /**
11
+ * @param {String} content
12
+ * @param {String} [cwd=process.cwd()] Where to look for the changelog file.
13
+ */
14
+ export default function saveChangelog( content, cwd = process.cwd() ) {
15
+ const changelogFile = path.join( cwd, CHANGELOG_FILE );
16
+
17
+ fs.writeFileSync( changelogFile, content, 'utf-8' );
18
+ }
@@ -3,11 +3,11 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
6
+ import lodash from 'lodash';
7
+ import * as utils from './transformcommitutils.js';
8
+ import getChangedFilesForCommit from './getchangedfilesforcommit.js';
7
9
 
8
- const { cloneDeepWith } = require( 'lodash' );
9
- const utils = require( './transformcommitutils' );
10
- const getChangedFilesForCommit = require( './getchangedfilesforcommit' );
10
+ const { cloneDeepWith } = lodash;
11
11
 
12
12
  // Squash commit follows the pattern: "A pull request title (#{number})".
13
13
  const SQUASH_COMMIT_REGEXP = /^[\W\w]+ \(#\d+\)$/;
@@ -31,7 +31,7 @@ const SQUASH_COMMIT_REGEXP = /^[\W\w]+ \(#\d+\)$/;
31
31
  * as "BREAKING CHANGES".
32
32
  * @returns {TransformCommit}
33
33
  */
34
- module.exports = function transformCommitFactory( options = {} ) {
34
+ export default function transformCommitFactory( options = {} ) {
35
35
  return rawCommit => {
36
36
  const commit = transformCommit( rawCommit );
37
37
 
@@ -484,7 +484,7 @@ module.exports = function transformCommitFactory( options = {} ) {
484
484
 
485
485
  return !!squashCommit.header.match( SQUASH_COMMIT_REGEXP );
486
486
  }
487
- };
487
+ }
488
488
 
489
489
  /**
490
490
  * @callback TransformCommit