@ckeditor/ckeditor5-dev-release-tools 36.0.0 → 37.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -51,6 +51,7 @@ const PACKAGE_JSON_FIELDS = [
51
51
  * @param {String} options.changelogDirectory An absolute path to the directory where the `CHANGELOG.md` file is saved.
52
52
  * @param {String} options.buildScript A name of npm script that builds the package. It is executed per package.
53
53
  * @param {String} options.secureScript A name of npm script that secures the code in the entire repository.
54
+ * @param {Array.<String>} [options.npmScriptsToRemove=[]] An array of npm scripts that should be removed when processing a package.
54
55
  * @returns {Promise}
55
56
  */
56
57
  module.exports = async function preparePackages( options ) {
@@ -58,6 +59,7 @@ module.exports = async function preparePackages( options ) {
58
59
  const packagesDirectory = path.join( options.cwd, options.packages );
59
60
  const releaseDirectory = path.join( options.cwd, options.releaseDirectory );
60
61
  const ckeditor5Version = getLastFromChangelog( options.changelogDirectory );
62
+ const npmScriptsToRemove = options.npmScriptsToRemove || [];
61
63
 
62
64
  // Clean the release directory before doing anything.
63
65
  logProcess( 'Removing the release directory...' );
@@ -91,7 +93,7 @@ module.exports = async function preparePackages( options ) {
91
93
  }
92
94
 
93
95
  logProcess( 'Preparing packages...' );
94
- await preparePackagesToBeReleased( packages );
96
+ await preparePackagesToBeReleased( packages, npmScriptsToRemove );
95
97
 
96
98
  // Secure the entire release directory.
97
99
  logProcess( 'Securing the code...' );
@@ -139,9 +141,10 @@ function filterOutPackagesWithoutChanges( packages, ckeditor5Version ) {
139
141
  * * Remove the `build/` directory. The build script will re-create it from the JavaScript code.
140
142
  *
141
143
  * @param {Map.<String, PackageJson>} packages
144
+ * @param {Array.<String>} npmScriptsToRemove An array of npm scripts that should be removed when processing a package.
142
145
  * @returns {Promise}
143
146
  */
144
- function preparePackagesToBeReleased( packages ) {
147
+ function preparePackagesToBeReleased( packages, npmScriptsToRemove ) {
145
148
  return executeOnPackages( packages.keys(), async packagePath => {
146
149
  const { name: packageName } = packages.get( packagePath );
147
150
 
@@ -167,6 +170,12 @@ function preparePackagesToBeReleased( packages ) {
167
170
  }
168
171
  }
169
172
 
173
+ if ( 'scripts' in packageJson ) {
174
+ for ( const npmScript of npmScriptsToRemove ) {
175
+ delete packageJson.scripts[ npmScript ];
176
+ }
177
+ }
178
+
170
179
  if ( !main ) {
171
180
  return packageJson;
172
181
  }
@@ -284,7 +284,7 @@ module.exports = async function releaseSubRepositories( options ) {
284
284
  const packageJson = getPackageJson( options.cwd );
285
285
  logProcess( 'Verifying the npm tag...' );
286
286
 
287
- const [ versionTag ] = semver.prerelease( packageJson.version ) || [ 'latest' ];
287
+ const versionTag = getVersionTag( packageJson.version );
288
288
 
289
289
  if ( versionTag !== npmTag ) {
290
290
  log.warning( '⚠️ The version tag is different from the npm tag.' );
@@ -427,7 +427,7 @@ module.exports = async function releaseSubRepositories( options ) {
427
427
  throw new Error( MISSING_FILES_MESSAGE );
428
428
  }
429
429
 
430
- const npmVersion = getVersionFromNpm( packageJson.name );
430
+ const npmVersion = getVersionFromNpm( packageJson.name, npmTag );
431
431
 
432
432
  logDryRun( `Versions: package.json: "${ releaseDetails.version }", npm: "${ npmVersion || 'initial release' }".` );
433
433
 
@@ -545,9 +545,9 @@ module.exports = async function releaseSubRepositories( options ) {
545
545
  // Checks whether specified `packageName` has been published on npm.
546
546
  // If so, returns its version. Otherwise returns `null` which means that
547
547
  // this package will be published for the first time.
548
- function getVersionFromNpm( packageName ) {
548
+ function getVersionFromNpm( packageName, npmTag ) {
549
549
  try {
550
- return exec( `npm show ${ packageName } version` ).trim();
550
+ return exec( `npm show ${ packageName }@${ npmTag } version` ).trim();
551
551
  } catch ( err ) {
552
552
  if ( err.message.match( /npm ERR! 404/ ) ) {
553
553
  return null;
@@ -869,11 +869,14 @@ module.exports = async function releaseSubRepositories( options ) {
869
869
  return Promise.resolve();
870
870
  }
871
871
 
872
+ const versionTag = getVersionTag( releaseDetails.version );
873
+
872
874
  const githubReleaseOptions = {
873
875
  repositoryOwner: releaseDetails.repositoryOwner,
874
876
  repositoryName: releaseDetails.repositoryName,
875
877
  version: `v${ releaseDetails.version }`,
876
- description: releaseDetails.changes
878
+ description: releaseDetails.changes,
879
+ isPrerelease: versionTag !== 'latest'
877
880
  };
878
881
 
879
882
  return createGithubRelease( releaseOptions.token, githubReleaseOptions )
@@ -894,6 +897,21 @@ module.exports = async function releaseSubRepositories( options ) {
894
897
  );
895
898
  }
896
899
 
900
+ /**
901
+ * Returns the version tag for the package.
902
+ *
903
+ * For the official release, returns the "latest" tag. For a non-official release (pre-release), returns the version tag extracted from
904
+ * the package version.
905
+ *
906
+ * @param {String} version Version of the package to be released.
907
+ * @returns {String}
908
+ */
909
+ function getVersionTag( version ) {
910
+ const [ versionTag ] = semver.prerelease( version ) || [ 'latest' ];
911
+
912
+ return versionTag;
913
+ }
914
+
897
915
  // Removes all temporary directories that were created for publishing the custom repository.
898
916
  //
899
917
  // @returns {Promise}
@@ -14,7 +14,7 @@ const glob = require( 'glob' );
14
14
  const { diffLines: diff } = require( 'diff' );
15
15
 
16
16
  // The pattern defines CKEditor 5 dependencies.
17
- const CKEDITOR5_DEPENDENCY_PATTERN = /^@ckeditor\/ckeditor5-(.*)|^ckeditor5$/;
17
+ const CKEDITOR5_DEPENDENCY_PATTERN = /^@ckeditor\/ckeditor5-(.*)|^ckeditor5(-collaboration)?$/;
18
18
 
19
19
  // Packages that match the CKEditor 5 pattern but should not be updated because they aren't a dependency of the project.
20
20
  const PATTERNS_TO_SKIP = [
@@ -16,6 +16,7 @@ const { Octokit } = require( '@octokit/rest' );
16
16
  * @param {String} options.repositoryName Repository name.
17
17
  * @param {String} options.version Name of tag connected with the release.
18
18
  * @param {String} options.description Description of the release.
19
+ * @param {Boolean} options.isPrerelease Indicates whether the release is a pre-release.
19
20
  * @returns {Promise}
20
21
  */
21
22
  module.exports = function createGithubRelease( token, options ) {
@@ -28,7 +29,8 @@ module.exports = function createGithubRelease( token, options ) {
28
29
  owner: options.repositoryOwner,
29
30
  repo: options.repositoryName,
30
31
  tag_name: options.version,
31
- body: options.description
32
+ body: options.description,
33
+ prerelease: options.isPrerelease
32
34
  };
33
35
 
34
36
  return github.repos.createRelease( releaseParams );
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-dev-release-tools",
3
- "version": "36.0.0",
3
+ "version": "37.0.0",
4
4
  "description": "Tools used for releasing CKEditor 5 and related packages.",
5
5
  "keywords": [],
6
6
  "main": "lib/index.js",
7
7
  "dependencies": {
8
- "@ckeditor/ckeditor5-dev-utils": "^36.0.0",
8
+ "@ckeditor/ckeditor5-dev-utils": "^37.0.0",
9
9
  "@octokit/rest": "^17.9.2",
10
10
  "chalk": "^4.0.0",
11
11
  "cli-table": "^0.3.1",