Version bump: Add README and Logger (#34636)
This commit is contained in:
parent
4eccddf140
commit
e3ca9364a4
7184
pnpm-lock.yaml
7184
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,26 @@
|
|||
# Version Bump
|
||||
|
||||
## Description
|
||||
|
||||
`version-bump` is a CLI tool to bump versions in plugins found in the Monorepo.
|
||||
|
||||
## Usage
|
||||
|
||||
Bump WooCommerce to version 7.1.0:
|
||||
|
||||
```
|
||||
pnpm run version --filter version-bump -- bump woocommerce -v 7.1.0
|
||||
```
|
||||
|
||||
**Arguments**:
|
||||
plugin - Monorepo plugin
|
||||
|
||||
**Options**:
|
||||
-v, --version <string> Version to bump to
|
||||
-h, --help display help for command
|
||||
|
||||
### Prereleases
|
||||
|
||||
Prerelease versions such as `7.3.0-dev` and `7.5.0-beta.1` are acceptable.
|
||||
|
||||
When updating with a `-dev` prerelease suffix, the tool will not update the stable tag but will update the readme changelog to prepare for the next release cycle.
|
|
@ -2,6 +2,7 @@
|
|||
* External dependencies
|
||||
*/
|
||||
import { prerelease } from 'semver';
|
||||
import { Logger } from 'cli-core/src/logger';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
|
@ -22,6 +23,8 @@ program
|
|||
.argument( '<plugin>', 'Monorepo plugin' )
|
||||
.requiredOption( '-v, --version <string>', 'Version to bump to' )
|
||||
.action( async ( plugin: string, options ) => {
|
||||
Logger.startTask( `Bumping versions to ${ options.version }` );
|
||||
|
||||
await validateArgs( plugin, options );
|
||||
|
||||
let nextVersion = options.version;
|
||||
|
@ -46,4 +49,6 @@ program
|
|||
await updateJSON( 'composer', plugin, nextVersion );
|
||||
await updateJSON( 'package', plugin, nextVersion );
|
||||
await updateClassPluginFile( plugin, nextVersion );
|
||||
|
||||
Logger.endTask();
|
||||
} );
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
const chalk = require( 'chalk' );
|
||||
|
||||
const { error } = console;
|
||||
|
||||
/**
|
||||
* This is a temporary Logger until a common one is built.
|
||||
*/
|
||||
export class Logger {
|
||||
static error( message: string ) {
|
||||
error( chalk.red( message ) );
|
||||
process.exit( 1 );
|
||||
}
|
||||
}
|
|
@ -3,11 +3,11 @@
|
|||
*/
|
||||
import { readFile, writeFile, stat } from 'fs/promises';
|
||||
import { join } from 'path';
|
||||
import { Logger } from 'cli-core/src/logger';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import { Logger } from './logger';
|
||||
import { MONOREPO_ROOT } from './const';
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { valid, lt as versionLessThan, prerelease, parse } from 'semver';
|
||||
import { valid, lt as versionLessThan, parse } from 'semver';
|
||||
import { join } from 'path';
|
||||
import { readFile } from 'fs/promises';
|
||||
import { Logger } from 'cli-core/src/logger';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import { Logger } from './logger';
|
||||
import { MONOREPO_ROOT } from './const';
|
||||
|
||||
/**
|
||||
* Get a plugin's current version.
|
||||
|
@ -17,10 +19,9 @@ import { Logger } from './logger';
|
|||
export const getCurrentVersion = async (
|
||||
plugin: string
|
||||
): Promise< string | void > => {
|
||||
const filePath = join( MONOREPO_ROOT, `plugins/${ plugin }/composer.json` );
|
||||
try {
|
||||
const composerJSON = JSON.parse(
|
||||
await readFile( `plugins/${ plugin }/composer.json`, 'utf8' )
|
||||
);
|
||||
const composerJSON = JSON.parse( await readFile( filePath, 'utf8' ) );
|
||||
return composerJSON.version;
|
||||
} catch ( e ) {
|
||||
Logger.error( 'Unable to read current version.' );
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
"version": "0.1.0",
|
||||
"description": "Automate version bumping for WooCommerce plugins",
|
||||
"main": " ",
|
||||
"scripts": {},
|
||||
"author": "",
|
||||
"license": "GPL-2.0-or-later",
|
||||
"devDependencies": {
|
||||
|
@ -15,9 +14,14 @@
|
|||
"@commander-js/extra-typings": "^0.1.0",
|
||||
"chalk": "^4.1.2",
|
||||
"commander": "9.4.0",
|
||||
"cli-core": "workspace:*",
|
||||
"express": "^4.18.1",
|
||||
"ora": "^5.4.1",
|
||||
"semver": "^7.3.2",
|
||||
"ts-node": "^10.9.1"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint . --ext .ts --config .eslintrc",
|
||||
"version": "node -r ts-node/register ./index.ts"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue