Skip to content

Commit ce94866

Browse files
feat: full installation commands
1 parent af3a349 commit ce94866

6 files changed

Lines changed: 63 additions & 28 deletions

File tree

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,8 @@
3232
"@types/react": "^18.3.22",
3333
"ts-node": "^10.9.1",
3434
"typescript": "^5.8.3"
35+
},
36+
"pnpm": {
37+
"onlyBuiltDependencies": ["@biomejs/biome"]
3538
}
3639
}

pnpm-workspace.yaml

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

source/app.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ const App = () => {
2525

2626
const steps: Array<ReactNode> = [
2727
<ProjectName
28-
onSubmit={setProjectName}
2928
onCompletion={finishStep}
29+
onSubmit={setProjectName}
3030
projectName={projectName}
3131
key={1}
3232
/>,
@@ -41,17 +41,18 @@ const App = () => {
4141
key={3}
4242
/>,
4343
<OptionalPackages
44+
installation={setupType?.value}
4445
onCompletion={finishStep}
4546
onSubmit={onSelectCustomOptions}
46-
installation={setupType?.value}
4747
key={4}
4848
/>,
4949
<Install
50+
installation={{ installationType: setupType?.value, customOptions: customOptions }}
5051
onCompletion={finishStep}
5152
projectName={projectName}
52-
installation={setupType?.value}
5353
key={5}
5454
/>,
55+
<Text key={6}>Done! Go fuck yourself.</Text>,
5556
]
5657

5758
return (
@@ -61,11 +62,6 @@ const App = () => {
6162
>
6263
<MainTitle />
6364
{steps.map((item, index) => canShowStep(currentStep, index + 1) && item)}
64-
{customOptions?.map((item) => (
65-
<Text key={item.value}>
66-
{item.label} / {item.value}
67-
</Text>
68-
))}
6965
</Box>
7066
)
7167
}

source/import/components/steps/Install/CustomInstallation.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { Text } from 'ink'
22
import React, { type FC } from 'react'
3+
import type { Item as CustomOptionsItem } from '../OptionalPackages.js'
34

45
interface Props {
5-
projectName: string
6+
installationPackages?: Array<CustomOptionsItem>
67
onCompletion: () => void
8+
projectName: string
79
}
810

9-
const CustomInstallation: FC<Props> = ({ projectName, onCompletion }) => (
11+
const CustomInstallation: FC<Props> = ({ projectName, onCompletion, installationPackages }) => (
1012
<Text>Custom Installation!</Text>
1113
)
1214

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,38 @@
1-
import { Text } from 'ink'
1+
import { join } from 'node:path'
2+
import process from 'node:process'
3+
import { Box, Text } from 'ink'
4+
import { Script, Spawn } from 'ink-spawn'
25
import React, { type FC } from 'react'
36

47
interface Props {
58
projectName: string
69
onCompletion: () => void
710
}
811

9-
const FullInstallation: FC<Props> = ({ projectName, onCompletion }) => (
10-
<Text>Full Installation!</Text>
11-
)
12+
const FullInstallation: FC<Props> = ({ projectName, onCompletion }) => {
13+
const projectDir = join(process.cwd(), projectName)
14+
15+
return (
16+
<Box
17+
flexDirection={'column'}
18+
gap={0}
19+
>
20+
<Script>
21+
<Text color={'whiteBright'}>Installing packages</Text>
22+
<Spawn
23+
shell
24+
cwd={projectDir}
25+
silent
26+
command={'pnpm'}
27+
args={['i']}
28+
runningText={'Working...'}
29+
successText={'Done!'}
30+
failureText={'Error...'}
31+
onCompletion={onCompletion}
32+
/>
33+
</Script>
34+
</Box>
35+
)
36+
}
1237

1338
export default FullInstallation

source/import/components/steps/Install/Install.tsx

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,27 @@ import { Script, Spawn } from 'ink-spawn'
55
import React, { type FC, useState } from 'react'
66
import Divider from '../../Divider.js'
77
import type { Installation } from '../InstallationType.js'
8+
import type { Item as CustomOptionsItem } from '../OptionalPackages.js'
89
import CustomInstallation from './CustomInstallation.js'
910
import FullInstallation from './FullInstallation.js'
1011

1112
interface Props {
12-
installation: Installation | undefined
13+
installation: {
14+
installationType: Installation | undefined
15+
customOptions?: Array<CustomOptionsItem>
16+
}
1317
projectName: string
1418
onCompletion: () => void
1519
}
1620

1721
const Install: FC<Props> = ({ projectName, onCompletion, installation }) => {
22+
const { installationType, customOptions } = installation
1823
const projectDir = join(process.cwd(), projectName)
1924
const [canInstall, setCanInstall] = useState(false)
2025

2126
return (
2227
<>
23-
<Divider title={`Performing ${installation ?? 'full'} installation`} />
28+
<Divider title={`Performing ${installation.installationType ?? 'full'} installation`} />
2429
<Box
2530
flexDirection={'column'}
2631
gap={0}
@@ -50,16 +55,22 @@ const Install: FC<Props> = ({ projectName, onCompletion, installation }) => {
5055
onCompletion={() => setCanInstall(true)}
5156
/>
5257
</Script>
53-
{canInstall && installation === 'full' ? (
54-
<FullInstallation
55-
projectName={projectName}
56-
onCompletion={() => console.log()}
57-
/>
58-
) : (
59-
<CustomInstallation
60-
projectName={projectName}
61-
onCompletion={() => console.log()}
62-
/>
58+
{canInstall && (
59+
<>
60+
{installationType === 'full' && (
61+
<FullInstallation
62+
projectName={projectName}
63+
onCompletion={onCompletion}
64+
/>
65+
)}
66+
{installationType === 'custom' && (
67+
<CustomInstallation
68+
installationPackages={customOptions}
69+
projectName={projectName}
70+
onCompletion={onCompletion}
71+
/>
72+
)}
73+
</>
6374
)}
6475
</Box>
6576
</>

0 commit comments

Comments
 (0)