
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
sd-release-plus
Advanced tools
pnpm add -D sd-release-plus
scripts/release.tsimport defaultMain from sd-release-plus;
defaultMain();
package.json 增加 scripts 钩子For example:
{
"scripts": {
"release": "ts-node ./scripts/release.ts"
},
"devDependencies": {
"sd-release-plus": "^1.0.0"
}
}
pnpm run release
上面几个流程是这个包自带流程顺序,你可以配自己的顺序,
import { getNextVersion, gitPush, setChangelog, build, publishNpm, addTag, compose } from '@mx-design/release';
// getNextVersion 获取下个版本号函数
// updateVersion 修改版本号 返回值是回退版本号的函数
// gitPush push代码函数
// setChangelog 设置changeLog函数
// build 执行npm run build函数
// publish 执行npm publish函数
// addTag 打tag函数
// compose函数组合器
// 使用方法,这些函数顺序可以自己换位置,或者增删减
const middle = [getNextVersion, updateVersion, gitPush, setChangelog, build, publishNpm, addTag];
function execRelease() {
compose(middle);
}
// compose 函数
export function compose(middleware) {
// 共享数据仓库,每个函数都可以往里面加数据,所有函数都可以访问到里面的数据
const otherOptions = {};
// 函数发射器,一个函数执行完毕调用next(),就执行下一个函数
function dispatch(index, otherOptions) {
// 每次从middleware中间件里面选取一个函数执行,直到执行了全部函数
if (index == middleware.length) return;
const currMiddleware = middleware[index];
// 执行函数,传入了一下一个函数的dispatch,已经更新共享数据
currMiddleware((addOptions) => {
dispatch(++index, { ...otherOptions, ...addOptions });
}, otherOptions).catch((error) => {
console.log('💣 发布失败,失败原因:', error);
});
}
dispatch(0, otherOptions);
}
// middleware 写法
// 获取版本号函数,固定参数第一个是next,表示调用middleware里下一个函数
const getNextVersion = async (next) => {
// _selectNextVersion会查看你package.json里的version参数是啥版本
const nextVersion = await _selectNextVersion();
// 缓存老的package.json数据,为了后面可以回退版本有老版本数据做准备
const originPackageJson = getOriginPackageJson();
// next传入的数据都会放到共享数据仓库,下面的函数都可以拿到这些数据
next({
nextVersion,
originVersion: originPackageJson.version,
originPackageJson,
});
};
// 更新版本号方法
const updateVersion = async (next, otherOptions) => {
if (!otherOptions?.nextVersion) {
throw new Error('请传入package.json新版本号');
}
// 返回一个回退版本号的方法,上面的函数共享的originPackageJson数据就是给他用的
// basicCatchError如果命令执行失败,就打印失败原因,并且返回false
const backVersionFn = await _updateVersion(otherOptions.nextVersion, otherOptions.originPackageJson).catch(
basicCatchError,
);
// 把回退版本的函数共享出来,给下面需要用的地方自己调用
next({ backVersionFn });
};
// 调用
compose([getNextVersion, updateVersion]);
FAQs
Lightweight release script for Front-end project
We found that sd-release-plus demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.