Skip to content

Commit

Permalink
Internal: Aligned release tools to the latest CKEditor 5 dev. Closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
pomek committed Jun 2, 2023
1 parent 3c1730c commit 8c0ff25
Show file tree
Hide file tree
Showing 8 changed files with 937 additions and 345 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
coverage/
node_modules/
.idea

# Prepared files to publish to npm.
/release/
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@
"upath": "^2.0.0"
},
"devDependencies": {
"@ckeditor/ckeditor5-dev-bump-year": "^36.0.0",
"@ckeditor/ckeditor5-dev-ci": "^36.0.0",
"@ckeditor/ckeditor5-dev-release-tools": "^36.0.0",
"@ckeditor/ckeditor5-dev-bump-year": "^38.0.0",
"@ckeditor/ckeditor5-dev-ci": "^38.0.0",
"@ckeditor/ckeditor5-dev-release-tools": "^38.0.0",
"chai": "^4.2.0",
"eslint": "^7.7.0",
"eslint-config-ckeditor5": "^4.0.0",
"husky": "^8.0.2",
"lint-staged": "^10.2.11",
"listr2": "^6.5.0",
"mocha": "^9.0.0",
"mockery": "^2.1.0",
"nyc": "^15.1.0",
Expand All @@ -57,16 +58,17 @@
"coverage": "nyc --reporter=lcov --reporter=text-summary yarn run test",
"lint": "eslint --quiet \"**/*.js\"",
"changelog": "node ./scripts/changelog.js",
"release:bump-version": "node ./scripts/bump-version.js",
"release:publish": "node ./scripts/publish.js"
"release:prepare-packages": "node ./scripts/preparepackages.js",
"release:publish-packages": "node ./scripts/publishpackages.js"
},
"bin": {
"mrgit": "./index.js"
},
"files": [
"index.js",
"lib",
"scripts/postinstall.js"
"README.md",
"CHANGELOG.md"
],
"lint-staged": {
"**/*.js": [
Expand Down
15 changes: 0 additions & 15 deletions scripts/bump-version.js

This file was deleted.

79 changes: 79 additions & 0 deletions scripts/preparepackages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/env node

/**
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md.
*/

/* eslint-env node */

'use strict';

const { Listr } = require( 'listr2' );
const releaseTools = require( '@ckeditor/ckeditor5-dev-release-tools' );

const latestVersion = releaseTools.getLastFromChangelog();
const versionChangelog = releaseTools.getChangesForVersion( latestVersion );

const tasks = new Listr( [
{
title: 'Verifying the repository.',
task: async () => {
const errors = await releaseTools.validateRepositoryToRelease( {
version: latestVersion,
changes: versionChangelog,
branch: 'master'
} );

if ( !errors.length ) {
return;
}

return Promise.reject( 'Aborted due to errors.\n' + errors.map( message => `* ${ message }` ).join( '\n' ) );
}
},
{
title: 'Updating the `#version` field.',
task: () => {
return releaseTools.updateVersions( {
version: latestVersion
} );
}
},
{
title: 'Creating the `mrgit2` package in the release directory.',
task: () => {
return releaseTools.prepareRepository( {
outputDirectory: 'release',
rootPackageJson: require( '../package.json' )
} );
}
},
{
title: 'Cleaning-up.',
task: () => {
return releaseTools.cleanUpPackages( {
packagesDirectory: 'release'
} );
}
},
{
title: 'Commit & tag.',
task: () => {
return releaseTools.commitAndTag( {
version: latestVersion,
files: [
'package.json'
]
} );
}
}
] );

tasks.run()
.catch( err => {
process.exitCode = 1;

console.log( '' );
console.error( err );
} );
15 changes: 0 additions & 15 deletions scripts/publish.js

This file was deleted.

70 changes: 70 additions & 0 deletions scripts/publishpackages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env node

/**
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md.
*/

/* eslint-env node */

'use strict';

const { Listr } = require( 'listr2' );
const releaseTools = require( '@ckeditor/ckeditor5-dev-release-tools' );
const { provideToken } = require( '@ckeditor/ckeditor5-dev-release-tools/lib/utils/cli' );
const parseArguments = require( './utils/parsearguments' );

const cliArguments = parseArguments( process.argv.slice( 2 ) );
const latestVersion = releaseTools.getLastFromChangelog();
const versionChangelog = releaseTools.getChangesForVersion( latestVersion );

let githubToken;

const tasks = new Listr( [
{
title: 'Publishing packages.',
task: async ( _, task ) => {
return releaseTools.publishPackages( {
packagesDirectory: 'release',
npmOwner: 'cksource',
npmTag: cliArguments.npmTag,
listrTask: task,
confirmationCallback: () => {
return task.prompt( { type: 'Confirm', message: 'Do you want to continue?' } );
}
} );
},
retry: 3
},
{
title: 'Creating the release page.',
task: async ( _, task ) => {
const releaseUrl = await releaseTools.createGithubRelease( {
token: githubToken,
version: latestVersion,
description: versionChangelog
} );

task.output = `Release page: ${ releaseUrl }`;
}
},
{
title: 'Pushing changes.',
task: () => {
return releaseTools.push( {
releaseBranch: 'master',
version: latestVersion
} );
}
}
] );

( async () => {
try {
githubToken = await provideToken();

await tasks.run();
} catch ( err ) {
console.error( err );
}
} )();
39 changes: 39 additions & 0 deletions scripts/utils/parsearguments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md.
*/

/* eslint-env node */

'use strict';

const minimist = require( 'minimist' );

/**
* @param {Array.<String>} cliArguments
* @returns {ReleaseOptions} options
*/
module.exports = function parseArguments( cliArguments ) {
const config = {
string: [
'npm-tag'
],

default: {
'npm-tag': 'latest'
}
};

const options = minimist( cliArguments, config );

options.npmTag = options[ 'npm-tag' ];
delete options[ 'npm-tag' ];

return options;
};

/**
* @typedef {Object} ReleaseOptions
*
* @property {Array.<String>|null} packages
*/
Loading

0 comments on commit 8c0ff25

Please sign in to comment.