Skip to content

Commit 87b7fb1

Browse files
author
xiazhigang
committed
新增 新增自动更新全部类型模块
1 parent 4ab9d66 commit 87b7fb1

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

src/cli.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const cli = meow(
1010
$ tarocodegen
1111
1212
Options
13-
--type component type
13+
--type command type [routes, icons, all]
1414
1515
Examples
1616
$ tarocodegen --type routes

src/ui.tsx

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const App: FC<{ type?: string }> = ({ type }) => {
2828
console.log(chalk.red(error));
2929
setProcess("failed");
3030
}
31-
} else if (item.value === 'icons') {
31+
} else if (item.value === "icons") {
3232
try {
3333
generateIcons();
3434
setProcess("success");
@@ -37,14 +37,41 @@ const App: FC<{ type?: string }> = ({ type }) => {
3737
setProcess("failed");
3838
}
3939
}
40-
4140
};
4241
const [process, setProcess] = useState<
4342
"init" | "processing" | "success" | "failed"
44-
>("init");
43+
>();
4544
useEffect(() => {
4645
if (type) {
4746
setProcess("processing");
47+
if (type === "routes") {
48+
try {
49+
generateRoutes();
50+
setProcess("success");
51+
} catch (error) {
52+
console.log(chalk.red(error));
53+
setProcess("failed");
54+
}
55+
} else if (type === "icons") {
56+
try {
57+
generateIcons();
58+
setProcess("success");
59+
} catch (error) {
60+
console.log(chalk.red(error));
61+
setProcess("failed");
62+
}
63+
} else if (type === "all") {
64+
try {
65+
generateRoutes();
66+
generateIcons();
67+
setProcess("success");
68+
} catch (error) {
69+
console.log(chalk.red(error));
70+
setProcess("failed");
71+
}
72+
}
73+
} else {
74+
setProcess("init");
4875
}
4976
}, []);
5077
return (
@@ -68,5 +95,3 @@ const App: FC<{ type?: string }> = ({ type }) => {
6895

6996
module.exports = App;
7097
export default App;
71-
72-

0 commit comments

Comments
 (0)