Skip to content

Commit 189036b

Browse files
committed
refactor: migrate TUI components to operations layer and feature definitions
Update CloneRepo, Install, FileCleanup, OptionalPackages, and PostInstall to use the extracted operations and featureDefinitions. Remove now-unused components (Commands, CustomInstallation, FullInstallation, InstallAllPackages). Clean up app.tsx by removing hybrid flag pre-population.
1 parent 900e8e6 commit 189036b

10 files changed

Lines changed: 105 additions & 560 deletions

File tree

source/app.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import InstallationMode from './components/steps/InstallationMode.js'
88
import OptionalPackages from './components/steps/OptionalPackages.js'
99
import PostInstall from './components/steps/PostInstall.js'
1010
import ProjectName from './components/steps/ProjectName.js'
11-
import type { InstallationSelectItem, MultiSelectItem } from './types/types.js'
11+
import type { InstallationSelectItem, InstallationType, MultiSelectItem } from './types/types.js'
1212
import { canShowStep } from './utils/utils.js'
1313

1414
const App = () => {
@@ -24,6 +24,8 @@ const App = () => {
2424
[],
2525
)
2626

27+
const skipFeatures = setupType?.value === 'full'
28+
2729
const steps: Array<ReactNode> = useMemo(
2830
() => [
2931
<ProjectName
@@ -42,12 +44,10 @@ const App = () => {
4244
onSelect={onSelectSetupType}
4345
key={3}
4446
/>,
45-
// TODO: add a skip parameter to all (or most) steps
46-
// to allow skipping when testing, etc.
4747
<OptionalPackages
4848
onCompletion={finishStep}
4949
onSubmit={onSelectSelectedFeatures}
50-
skip={setupType?.value === 'full'}
50+
skip={skipFeatures}
5151
key={4}
5252
/>,
5353
<Install
@@ -71,7 +71,7 @@ const App = () => {
7171
<PostInstall
7272
projectName={projectName}
7373
installationConfig={{
74-
installationType: setupType?.value,
74+
installationType: setupType?.value as InstallationType | undefined,
7575
selectedFeatures: selectedFeatures,
7676
}}
7777
key={7}
@@ -84,6 +84,7 @@ const App = () => {
8484
selectedFeatures,
8585
onSelectSetupType,
8686
projectName,
87+
skipFeatures,
8788
],
8889
)
8990

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,45 @@
1-
import type { FC } from 'react'
1+
import { Text } from 'ink'
2+
import { type FC, useEffect, useState } from 'react'
3+
import { cloneRepo } from '../../../operations/index.js'
24
import Divider from '../../Divider.js'
3-
import Commands from './Commands.js'
45

56
interface Props {
67
projectName: string
78
onCompletion: () => void
89
}
910

10-
/**
11-
* Step for cloning the repository.
12-
* @param projectName
13-
* @param onCompletion
14-
* @constructor
15-
*/
16-
const CloneRepo: FC<Props> = ({ projectName, onCompletion }) => (
17-
<>
18-
<Divider title={'Git tasks'} />
19-
<Commands
20-
projectName={projectName}
21-
onCompletion={onCompletion}
22-
/>
23-
</>
24-
)
11+
const CloneRepo: FC<Props> = ({ projectName, onCompletion }) => {
12+
const [status, setStatus] = useState<'running' | 'done' | 'error'>('running')
13+
const [errorMessage, setErrorMessage] = useState('')
14+
15+
useEffect(() => {
16+
cloneRepo(projectName)
17+
.then(() => {
18+
setStatus('done')
19+
onCompletion()
20+
})
21+
.catch((error: Error) => {
22+
setStatus('error')
23+
setErrorMessage(error.message)
24+
})
25+
}, [projectName, onCompletion])
26+
27+
return (
28+
<>
29+
<Divider title={'Git tasks'} />
30+
{status === 'running' && (
31+
<Text color={'whiteBright'}>
32+
Cloning dAppBooster in <Text italic>{projectName}</Text>... Working...
33+
</Text>
34+
)}
35+
{status === 'done' && (
36+
<Text color={'green'}>
37+
Cloned dAppBooster in <Text italic>{projectName}</Text>. Done!
38+
</Text>
39+
)}
40+
{status === 'error' && <Text color={'red'}>Failed to clone: {errorMessage}</Text>}
41+
</>
42+
)
43+
}
2544

2645
export default CloneRepo

source/components/steps/CloneRepo/Commands.tsx

Lines changed: 0 additions & 84 deletions
This file was deleted.

0 commit comments

Comments
 (0)