Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Timeless0911 committed Oct 15, 2024
1 parent 52f1d8c commit bf87a72
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 10 deletions.
11 changes: 11 additions & 0 deletions .pnpmfile.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
hooks: {
readPackage: (pkg) => {
if (pkg.name === 'zx') {
// zx use "@types/node": ">=20" as optionalDependencies, which may bring some unexpected updates in other packages
delete pkg.optionalDependencies['@types/node'];
}
return pkg;
},
},
};
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"changeset": "changeset",
"check-dependency-version": "check-dependency-version-consistency .",
"check-spell": "pnpx cspell",
"generate-release-pr": "npx zx scripts/generateReleasePr.mjs",
"generate-release-pr": "zx scripts/generateReleasePr.mjs",
"lint": "biome check . --diagnostic-level=warn && pnpm run check-spell",
"prebundle": "nx run-many -t prebundle",
"prepare": "pnpm run build && simple-git-hooks",
Expand Down Expand Up @@ -55,7 +55,8 @@
"prettier-plugin-packagejson": "^2.5.3",
"simple-git-hooks": "^2.11.1",
"typescript": "^5.6.3",
"vitest": "^2.1.2"
"vitest": "^2.1.2",
"zx": "^8.1.9"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
14 changes: 14 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 18 additions & 8 deletions scripts/generateReleasePr.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

import fs from 'node:fs/promises';
import path from 'node:path';
import { parseArgs } from 'node:util';
import { $, chalk } from 'zx';

// Exit when error
$.verbose = false;

const args = process.argv.slice(2);
const bumpTypeArgs = args.find((arg) => arg.startsWith('--type='));

async function getCurrentVersion() {
const packageJsonPath = path.join(
process.cwd(),
Expand Down Expand Up @@ -56,20 +53,33 @@ async function main() {
const currentVersion = await getCurrentVersion();
console.log(chalk.blue(`Current version: ${currentVersion}`));

// 2. Determine bump type
const bumpType = bumpTypeArgs ? bumpTypeArgs.split('=')[1] : 'patch';
// 2. Determine bump type and next release version
const options = {
type: {
type: 'string',
short: 't',
default: 'patch',
},
};
const args = process.argv.slice(3);
const { values } = parseArgs({ args, options });

const bumpType = values.type;

if (!['major', 'minor', 'patch'].includes(bumpType)) {
console.error('Invalid bump type. Please select major, minor, or patch.');
process.exit(1);
}

console.log(chalk.blue(`Bump type: ${bumpType}`));

const nextVersion = await getNextVersion(currentVersion, bumpType);
const branchName = `release-v${nextVersion}`;
console.log(chalk.blue(`Next version: ${nextVersion}`));

// 3. Create and switch to new branch
const branchName = `release-v${nextVersion}`;
console.log(chalk.blue(`Creating branch: ${branchName}`));

// 3. Create and switch to new branch
await $`git checkout -b ${branchName}`;

// 4. Generate changeset file
Expand Down

0 comments on commit bf87a72

Please sign in to comment.