Skip to content

Commit e7b23c6

Browse files
feat: add custom / full installation mockup
1 parent 3f607cf commit e7b23c6

4 files changed

Lines changed: 107 additions & 1 deletion

File tree

source/app.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import MainTitle from './import/MainTitle.js'
44
import Step1 from './import/Step1.js'
55
import Step2 from './import/Step2.js'
66
import Step3, { type Item } from './import/Step3.js'
7+
import Step4 from './import/Step4.js'
78
import { canShowStep } from './import/utils.js'
89

910
const App = () => {
@@ -31,6 +32,12 @@ const App = () => {
3132
onSelect={onSelect}
3233
key={3}
3334
/>,
35+
<Step4
36+
onCompletion={finishStep}
37+
projectName={projectName}
38+
installation={setupOption?.value}
39+
key={4}
40+
/>,
3441
]
3542

3643
return (
@@ -40,7 +47,6 @@ const App = () => {
4047
>
4148
<MainTitle />
4249
{steps.map((item, index) => canShowStep(currentStep, index + 1) && item)}
43-
{canShowStep(currentStep, 4) && <Text>{setupOption?.value}</Text>}
4450
</Box>
4551
)
4652
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Text } from 'ink'
2+
import React, { type FC } from 'react'
3+
4+
interface Props {
5+
projectName: string
6+
onCompletion: () => void
7+
}
8+
9+
const CustomInstallation: FC<Props> = ({ projectName, onCompletion }) => (
10+
<Text>Custom Installation!</Text>
11+
)
12+
13+
export default CustomInstallation

source/import/FullInstallation.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Text } from 'ink'
2+
import React, { type FC } from 'react'
3+
4+
interface Props {
5+
projectName: string
6+
onCompletion: () => void
7+
}
8+
9+
const FullInstallation: FC<Props> = ({ projectName, onCompletion }) => (
10+
<Text>Full Installation!</Text>
11+
)
12+
13+
export default FullInstallation

source/import/Step4.tsx

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { join } from 'node:path'
2+
import process from 'node:process'
3+
import { Box, Text } from 'ink'
4+
import Divider from 'ink-divider'
5+
import { Script, Spawn } from 'ink-spawn'
6+
import React, { type FC, useState } from 'react'
7+
import CustomInstallation from './CustomInstallation.js'
8+
import FullInstallation from './FullInstallation.js'
9+
import fullInstallation from './FullInstallation.js'
10+
import type { Installation } from './Step3.js'
11+
12+
interface Props {
13+
installation: Installation | undefined
14+
projectName: string
15+
onCompletion: () => void
16+
}
17+
18+
const Step4: FC<Props> = ({ projectName, onCompletion, installation }) => {
19+
const projectDir = join(process.cwd(), projectName)
20+
const [canInstall, setCanInstall] = useState(false)
21+
22+
return (
23+
<>
24+
<Divider
25+
titlePadding={2}
26+
titleColor={'whiteBright'}
27+
title={`Performing ${installation ?? 'full'} installation`}
28+
/>
29+
<Box
30+
flexDirection={'column'}
31+
gap={0}
32+
>
33+
<Script>
34+
<Box columnGap={1}>
35+
<Text color={'whiteBright'}>
36+
Creating{' '}
37+
<Text
38+
italic
39+
color={'white'}
40+
>
41+
.env.local
42+
</Text>{' '}
43+
file
44+
</Text>
45+
</Box>
46+
<Spawn
47+
shell
48+
cwd={projectDir}
49+
silent
50+
command={'cp'}
51+
args={['.env.example', '.env.local']}
52+
runningText={'Working...'}
53+
successText={'Done!'}
54+
failureText={'Error...'}
55+
onCompletion={() => setCanInstall(true)}
56+
/>
57+
</Script>
58+
{canInstall && installation === 'full' ? (
59+
<FullInstallation
60+
projectName={projectName}
61+
onCompletion={() => console.log()}
62+
/>
63+
) : (
64+
<CustomInstallation
65+
projectName={projectName}
66+
onCompletion={() => console.log()}
67+
/>
68+
)}
69+
</Box>
70+
</>
71+
)
72+
}
73+
74+
export default Step4

0 commit comments

Comments
 (0)