Skip to content

Commit

Permalink
chore(scripts): 调整release脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxinssfd committed Jul 18, 2023
1 parent 0215aa7 commit 2072395
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions scripts/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@ const step = (msg: string) => console.log(chalk.cyan(msg));

const forEachPkgs = async (
config: Config,
cb: (path: string, json: typeof rootPkgJson) => Promise<any> | void,
cb: (
path: string,
json: typeof rootPkgJson,
pkgPath: string,
) => Promise<unknown> | void,
) => {
for (const pkg of config.pkgs) {
const p = path.resolve(getPkgPath(pkg), 'package.json');
const pkgJson = JSON.parse(fs.readFileSync(p, 'utf-8'));
const pkgPath = getPkgPath(pkg);
const _path = path.resolve(getPkgPath(pkg), 'package.json');
const pkgJson = require(_path);
if (pkgJson?.private) continue;
await cb(p, pkgJson);
await cb(_path, pkgJson, pkgPath);
}
};

Expand All @@ -45,16 +50,16 @@ const getPkgPath = (pkg: string) =>
const actions = {
lintCheck: () => exec(npmTool, ['check:all']),
jestCheck: async (config: Config) => {
await forEachPkgs(config, (path, json) => {
await forEachPkgs(config, (_, json, pkgPath) => {
if (!json?.scripts?.test) return;
return exec(npmTool, ['test'], { execPath: path });
return exec(npmTool, ['test'], { execPath: pkgPath });
});
},
build: async (config: Config) => {
await forEachPkgs(config, (p, json) => {
await forEachPkgs(config, (_, json, pkgPath) => {
if (!json?.scripts?.build) return;
console.log(chalk.cyan('build:', p));
return exec(npmTool, ['build'], { execPath: p });
console.log(chalk.cyan('build:', pkgPath));
return exec(npmTool, ['build'], { execPath: pkgPath });
});
},
updateVersions(pkgs: string[], version: string) {
Expand Down Expand Up @@ -276,11 +281,12 @@ async function setup() {
await actions.genChangeLog();

// monorepo才需要重新install依赖
if (isMonoRepo) {
// update pnpm-lock.yaml
step('\nUpdating lockfile...');
await exec(npmTool, ['install', '--prefer-offline']);
}
// 暂时不需要更新依赖
// if (isMonoRepo) {
// // update pnpm-lock.yaml
// step('\nUpdating lockfile...');
// await exec(npmTool, ['install', '--prefer-offline']);
// }

step('\ngit commit...');
await actions.gitCommit(config.targetVersion);
Expand Down

0 comments on commit 2072395

Please sign in to comment.