8
0
Просмотр исходного кода

Merge pull request #5841 from ckeditor/i/5660

Internal: Added a script that updates the version of CKEditor 5 in `@ckeditor/ckeditor5-utils` package. Closes #5660.
Piotrek Koszuliński 6 лет назад
Родитель
Сommit
7986935436
2 измененных файлов с 46 добавлено и 0 удалено
  1. 1 0
      package.json
  2. 45 0
      scripts/release/update-utils-version.js

+ 1 - 0
package.json

@@ -138,6 +138,7 @@
     "translations:download": "ckeditor5-dev-env-translations download",
     "translations:upload": "ckeditor5-dev-env-translations upload",
     "changelog": "node ./scripts/release/changelog.js",
+    "postchangelog": "node ./scripts/release/update-utils-version.js",
     "release:bump-version": "node ./scripts/release/bump-versions.js",
     "release:publish": "node ./scripts/release/publish.js",
     "release:stable-branches": "sh ./scripts/update-stable-branches.sh",

+ 45 - 0
scripts/release/update-utils-version.js

@@ -0,0 +1,45 @@
+#!/usr/bin/env node
+
+/**
+ * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+/* eslint-env node */
+
+'use strict';
+
+// This scripts updates version of CKEditor 5 in the `@ckeditor/ckeditor5-utils/src/version` module.
+// It should be called as a post hook, after generating changelogs.
+
+const fs = require( 'fs' );
+const path = require( 'path' );
+const { tools } = require( '@ckeditor/ckeditor5-dev-utils' );
+
+const CWD = process.cwd();
+const UTILS_PACKAGE_PATH = path.join( CWD, 'packages', 'ckeditor5-utils' );
+const UTILS_MODULE_PATH = path.join( UTILS_PACKAGE_PATH, 'src', 'version.js' );
+
+const { version } = require( path.join( CWD, 'package.json' ) );
+
+const fileContent = fs.readFileSync( UTILS_MODULE_PATH, 'utf-8' )
+	.replace( /const version = '\d+\.\d+\.\d+';/, `const version = '${ version }';` );
+
+fs.writeFileSync( UTILS_MODULE_PATH, fileContent );
+
+process.chdir( UTILS_PACKAGE_PATH );
+
+if ( exec( 'git status -s' ).trim().length ) {
+	exec( 'git add src/version.js' );
+	exec( 'git commit -m "Internal: Updated version of CKEditor 5."' );
+
+	console.log( 'The version has been updated and committed.' );
+} else {
+	console.log( 'Nothing to commit. Version is up-to-date.' );
+}
+
+process.chdir( CWD );
+
+function exec( command ) {
+	return tools.shExec( command, { verbosity: 'error' } );
+}