Skip to content

Commit

Permalink
chore: Update migrage script
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Oct 27, 2022
1 parent a649f39 commit aa2281a
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions bin/rc-test-migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ if (fatherVer) {
const fatherMajor = semver.major(semver.minVersion(fatherVer));

if (fatherMajor < 4) {
console.log("Upgrading father version to ^4.0.0 ...");
console.log("升级 father 至 v4...");
pkg.devDependencies[VER_FATHER] = "^4.0.0";
pkg.devDependencies[VER_PLUGIN] = "^1.0.0";

console.log("Override .fatherrc...");
console.log("覆盖 .fatherrc...");
fs.writeFileSync(
path.resolve(cwd, ".fatherrc.js"),
`
Expand All @@ -38,16 +38,30 @@ export default defineConfig({
);

// Clean up father v2 hooks
console.log("清理遗留 pre-commit...");
fs.removeSync(path.resolve(cwd, ".git/hooks/pre-commit"));
}
}

// Check if exist enzyme
const existEnzyme = pkg.devDependencies["enzyme"];
if (existEnzyme) {
console.log("添加 enzyme adapter 依赖...");
pkg.devDependencies[VER_ENZYME_ADAPTER] = "^1.15.6";
}

// ==================================================================
// tsconfig.json
const tsConfigPath = path.resolve(cwd, "tsconfig.json");
if (fs.existsSync(tsConfigPath)) {
console.log("更新 tsconfig jsx 配置为 'react'...");
const tsConfig = require(path.resolve(cwd, "tsconfig.json"));

tsConfig.compilerOptions.jsx = "react";

fs.writeFileSync(tsConfigPath, JSON.stringify(tsConfig, null, 2));
}

// ==================================================================
// Update script
pkg.scripts.test = "rc-test";
Expand All @@ -65,6 +79,7 @@ fs.writeFileSync(

// ==================================================================
// Print Tips
console.log("");
console.log("更新完成,请检查以下内容:");
console.log(" - 更新 .github/workflows 中 CI node 版本至 16");
console.log(
Expand Down

0 comments on commit aa2281a

Please sign in to comment.