Skip to content

Commit

Permalink
ci: 🎡 dev scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
charlzyx committed Jan 15, 2024
1 parent f8b1ee1 commit dd09e48
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ dist-ssr
*.sln
*.sw?
doc_build
src/adaptor
src/adaptor/
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@proformily/antd",
"name": "@proformily/antd-v5",
"version": "1.0.0",
"private": true,
"scripts": {
"d4": "node scripts/switch.js antd dev && rspress dev",
"d5": "node scripts/switch.js antd dev && rspress dev",
"d5": "node scripts/switch.js antd-v5 dev && rspress dev",
"build:docs": "rspress build",
"preview": "rspress preview"
},
Expand All @@ -19,8 +19,8 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-resizable": "^3.0.5",
"@formily/antd": "^2.*.*",
"antd": "^4.*.*"
"@formily/antd-v5": "^1.*.*",
"antd": "^5.*.*"
},
"devDependencies": {
"@biomejs/biome": "^1.5.0",
Expand Down
7 changes: 6 additions & 1 deletion rspress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ export default defineConfig({
builderConfig: {
...RsBuildConfig,
},
plugins: [pluginPreview()],
plugins: [
pluginPreview(),
() => {
require("./scripts/patch.js");
},
],
themeConfig: {
socialLinks: [
{
Expand Down
1 change: 0 additions & 1 deletion scripts/patch.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const { execSync } = require("child_process");
const path = require("path");
const fs = require("fs");

Expand Down
41 changes: 18 additions & 23 deletions scripts/switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,34 +44,29 @@ const docs = () => {
return list;
};

const replaeer = (c) => {
if (adaptor === "antd") {
return c
.replace(`@formily/antd-v5"`, `@formily/antd"`)
.replace(`@proformily/antd-v5"`, `@proformily/antd"`)
.replace(`proformily-antd-v5"`, `proformily-antd"`)
.replace("antd/dist/reset.css", "antd/dist/antd.css");
} else {
return c
.replace(`@formily/antd"`, `@formily/antd-v5"`)
.replace(`@proformily/antd"`, `@proformily/antd-v5"`)
.replace(`proformily-antd"`, `proformily-antd-v5"`)
.replace("antd/dist/antd.css", "antd/dist/reset.css");
}
};
docs()
.filter((x) => /\.(mdx|md|tsx|ts|js|js)$/.test(x))
.forEach((item) => {
rewite(item, (c) => {
if (adaptor === "antd") {
return c
.replace("formily/antd-v5", "formily/antd")
.replace("antd/dist/reset.css", "antd/dist/antd.css");
} else {
return c
.replace("formily/antd", "formily/antd-v5")
.replace("antd/dist/antd.css", "antd/dist/reset.css");
}
});
rewite(item, replaeer);
});

files.forEach((item) => {
rewite(item, (c) => {
if (adaptor === "antd") {
return c
.replace("formily/antd-v5", "formily/antd")
.replace("proformily-antd-v5", "proformily-antd");
} else {
return c
.replace("formily/antd", "formily/antd-v5")
.replace("proformily-antd", "proformily-antd-v5");
}
});
rewite(item, replaeer);
});

const shadow = path.resolve(__dirname, "../src/adaptor");
Expand Down Expand Up @@ -105,13 +100,13 @@ const deps = {
};

// sed -i 's/@proformily\/antd/@proformily\/antd-v5/g' *
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2), "utf-8");

if (!pkg.dependencies[`@formily/${adaptor}`]) {
pkg.dependencies = {
...deps,
...adaptorPkg.dependencies,
};
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2), "utf-8");
rmrf.sync(path.resolve(__dirname, "../node_modules"));
}

Expand Down

0 comments on commit dd09e48

Please sign in to comment.