Skip to content

Commit 5f42337

Browse files
refactor: refactor flow to make it simpler
1 parent ce94866 commit 5f42337

1 file changed

Lines changed: 9 additions & 23 deletions

File tree

source/import/components/steps/CloneRepo/Commands.tsx

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,27 @@ interface Props {
1818
*/
1919
const Commands: FC<Props> = ({ projectName, onCompletion }) => {
2020
const projectDir = join(process.cwd(), projectName)
21-
const [currentStep, setCurrentStep] = useState(1)
22-
23-
const finishStep = () => setCurrentStep(currentStep + 1)
2421

2522
return (
2623
<Box
2724
flexDirection={'column'}
2825
gap={0}
2926
>
3027
<Script>
31-
{canShowStep(currentStep, 1) && (
32-
<Box columnGap={1}>
33-
<Text color={'whiteBright'}>Cloning dAppBooster in</Text>
34-
<Text italic>{projectName}</Text>
35-
</Box>
36-
)}
28+
<Box columnGap={1}>
29+
<Text color={'whiteBright'}>Cloning dAppBooster in</Text>
30+
<Text italic>{projectName}</Text>
31+
</Box>
3732
<Spawn
3833
shell
3934
silent
4035
successText={'Done!'}
4136
failureText={`Failed to clone the project, check if a folder called "${projectName}" already exists and your read/write permissions...`}
4237
runningText={'Working...'}
43-
onCompletion={() => finishStep()}
4438
command="git"
4539
args={['clone', '--depth', '1', '--no-checkout', repoUrl, projectName]}
4640
/>
47-
{canShowStep(currentStep, 2) && <Text color={'whiteBright'}>Fetching tags</Text>}
41+
<Text color={'whiteBright'}>Fetching tags</Text>
4842
<Spawn
4943
shell
5044
cwd={projectDir}
@@ -54,42 +48,34 @@ const Commands: FC<Props> = ({ projectName, onCompletion }) => {
5448
runningText={'Working...'}
5549
successText={'Done!'}
5650
failureText={'Error...'}
57-
onCompletion={() => finishStep()}
5851
/>
59-
{canShowStep(currentStep, 3) && <Text color={'whiteBright'}>Checking out latest tag</Text>}
52+
<Text color={'whiteBright'}>Checking out latest tag</Text>
6053
<Spawn
6154
shell
6255
cwd={projectDir}
6356
command="git"
6457
args={['checkout $(git describe --tags `git rev-list --tags --max-count=1`)']}
6558
successText="Done!"
6659
failureText={'Error...'}
67-
onCompletion={() => finishStep()}
6860
/>
69-
{canShowStep(currentStep, 4) && <Text color={'whiteBright'}>Removing .git folder</Text>}
61+
<Text color={'whiteBright'}>Removing .git folder</Text>
7062
<Spawn
7163
shell
7264
cwd={projectDir}
7365
command="rm"
7466
args={['-rf', '.git']}
7567
successText="Done!"
7668
failureText={'Error...'}
77-
onCompletion={() => finishStep()}
7869
/>
79-
{canShowStep(currentStep, 5) && (
80-
<Text color={'whiteBright'}>Initializing Git repository</Text>
81-
)}
70+
<Text color={'whiteBright'}>Initializing Git repository</Text>
8271
<Spawn
8372
shell
8473
cwd={projectDir}
8574
command="git"
8675
args={['init']}
8776
successText="Done!"
8877
failureText={'Error...'}
89-
onCompletion={() => {
90-
finishStep()
91-
onCompletion()
92-
}}
78+
onCompletion={onCompletion}
9379
/>
9480
</Script>
9581
</Box>

0 commit comments

Comments
 (0)