Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v22.11.0
v24.3.0
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,35 +50,35 @@
"release": "npm test && tsx scripts/release"
},
"devDependencies": {
"@eslint/js": "^9.29.0",
"@eslint/js": "^9.30.0",
"@ianvs/prettier-plugin-sort-imports": "^4.4.2",
"@rollup/plugin-commonjs": "^28.0.5",
"@rollup/plugin-commonjs": "^28.0.6",
"@rollup/plugin-node-resolve": "^16.0.1",
"@rollup/plugin-replace": "^6.0.2",
"@types/fs-extra": "^11",
"@types/jest": "^30.0.0",
"@types/node": "^22.15.21",
"@types/node": "^24.0.7",
"@types/signale": "^1",
"@types/yargs": "^17.0.33",
"esbuild": "^0.25.5",
"eslint": "^9.29.0",
"execa": "^9.6.0",
"eslint": "^9.30.0",
"fs-extra": "^11.3.0",
"jest": "^30.0.0",
"jest": "^30.0.3",
"new-github-release-url": "^2.0.0",
"open": "^10.1.2",
"prettier": "^3.5.3",
"prettier": "^3.6.2",
"rimraf": "^6.0.1",
"rollup": "^4.43.0",
"rollup": "^4.44.1",
"rollup-plugin-esbuild": "^6.2.1",
"rollup-plugin-node-externals": "^8.0.0",
"rollup-plugin-node-externals": "^8.0.1",
"signale": "^1.4.0",
"simple-git": "^3.28.0",
"ts-jest": "^29.4.0",
"tsx": "^4.20.3",
"typescript": "^5.8.3",
"typescript-eslint": "^8.34.1",
"typescript-eslint": "^8.35.0",
"version-next": "^1.0.2",
"yargs": "^17.7.2"
"yargs": "^18.0.0",
"zx": "^8.6.0"
}
}
4 changes: 2 additions & 2 deletions scripts/generate-dts.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import path from 'node:path';
import { execa } from 'execa';
import fs from 'fs-extra';
import signale from 'signale';
import { $ } from 'zx';

async function generateDts() {
try {
await execa('yarn', ['tsc', '--project', 'tsconfig.build.json']);
await $`yarn tsc --project tsconfig.build.json`;
await fs.copy(
path.join(process.cwd(), 'dist/types/index.d.ts'),
path.join(process.cwd(), 'dist/types/index.d.mts')
Expand Down
6 changes: 3 additions & 3 deletions scripts/pack-test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { execa } from 'execa';
import signale from 'signale';
import { $ } from 'zx';

const ALLOWED_FILES = ['LICENSE', 'README.md', 'package.json'];

async function packCheck() {
const { stdout } = await execa('npm', ['pack', '--dry-run', '--json']);
const files: { path: string }[] = JSON.parse(stdout)[0].files;
const result = await $`npm pack --dry-run --json`;
const files: { path: string }[] = JSON.parse(result.stdout)[0].files;
const extraFiles = files
.filter((file) => !file.path.startsWith('dist/') && !ALLOWED_FILES.includes(file.path))
.map((file) => file.path);
Expand Down
46 changes: 13 additions & 33 deletions scripts/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,13 @@ import path from 'node:path';
import { run } from './run';
import { updateVersion } from './update-version';
import chalk from 'chalk';
import { execa } from 'execa';
import fs from 'fs-extra';
import githubRelease from 'new-github-release-url';
import open from 'open';
import signale from 'signale';
import SimpleGit from 'simple-git';
import { getNextVersion, VersionIncrement, VersionStage } from 'version-next';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';

function getRepositoryInfo(gitUrl: string) {
const [user, repo] = gitUrl.replace('git+https://github.com/', '').replace('.git', '').split('/');
return { user, repo };
}
import { $ } from 'zx';

const packageJsonPath = path.join(process.cwd(), 'package.json');
const packageJson = fs.readJsonSync(packageJsonPath);
Expand All @@ -24,7 +17,6 @@ const git = SimpleGit();

const versionIncrement: VersionIncrement = argv._[0] || 'patch';
const versionStage: VersionStage | undefined = argv.stage;
const publish: boolean = argv.publish ?? true;

async function release() {
await run(git.pull(), {
Expand Down Expand Up @@ -58,51 +50,39 @@ async function release() {
`Current version: ${chalk.cyan(packageJson.version)}, next version: ${chalk.cyan(nextVersion)}`
);

await run(execa('yarn'), {
await run($`yarn`, {
info: 'Installing fresh dependencies',
success: 'Fresh dependencies have been installed',
error: 'Failed to install fresh dependencies',
});

await run(execa('yarn', ['run', 'clean']), {
await run($`yarn run clean`, {
info: 'Removing dist directory',
success: 'dist directory has been removed',
error: 'Failed to remove dist directory',
});

await run(execa('yarn', ['run', 'build']), {
await run($`yarn run build`, {
info: 'Building the package',
success: 'The package has been built',
error: 'Failed to build the package',
});

const revertVersion = await updateVersion(nextVersion);

if (publish) {
await run(
execa('npm', ['publish', '--access', 'public', '--tag', versionStage ? 'next' : 'latest']),
{
info: 'Publishing the package to npm',
success: 'The package has been published to npm',
error: 'Failed to publish the package to npm',
},
revertVersion
);
} else {
signale.warn('Package has not been published to npm due to --no-publish flag');
}
await run(
$`npm publish --access public --tag ${versionStage || 'latest'}`,
{
info: 'Publishing the package to npm',
success: 'The package has been published to npm',
error: 'Failed to publish the package to npm',
},
revertVersion
);

await git.add([packageJsonPath]);
await git.commit(`Release ${nextVersion}`);
await git.push();

open(
githubRelease({
...getRepositoryInfo(packageJson.repository.url),
tag: nextVersion,
title: nextVersion,
})
);
}

release();
Loading