Skip to content

Commit 0d9684a

Browse files
refactor: add skip prop
1 parent 2fc51fc commit 0d9684a

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

source/app.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Box, Text } from 'ink'
2-
import React, { useState, type ReactNode, useMemo, useCallback } from 'react'
1+
import { Box } from 'ink'
2+
import { type ReactNode, useCallback, useMemo, useState } from 'react'
33
import MainTitle from './components/MainTitle.js'
44
import CloneRepo from './components/steps/CloneRepo/CloneRepo.js'
55
import FileCleanup from './components/steps/FileCleanup.js'
@@ -42,10 +42,12 @@ const App = () => {
4242
onSelect={onSelectSetupType}
4343
key={3}
4444
/>,
45+
// TODO: add a skip parameter to all (or most) steps
46+
// to allow skipping when testing, etc.
4547
<OptionalPackages
46-
installation={setupType?.value}
4748
onCompletion={finishStep}
4849
onSubmit={onSelectSelectedFeatures}
50+
skip={setupType?.value === 'full'}
4951
key={4}
5052
/>,
5153
<Install

source/components/steps/OptionalPackages.tsx

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
import { Text } from 'ink'
2-
import React, { useState, type FC, useEffect } from 'react'
3-
import type { InstallationType, MultiSelectItem } from '../../types/types.js'
2+
import { type FC, useState } from 'react'
3+
import type { MultiSelectItem } from '../../types/types.js'
44
import MultiSelect from '../Multiselect/index.js'
55

6-
interface Props {
7-
installation: InstallationType | undefined
8-
onCompletion: () => void
9-
onSubmit: (selectedItems: Array<MultiSelectItem>) => void
10-
}
11-
126
const customPackages: Array<MultiSelectItem> = [
137
{
148
label: 'Component Demos',
@@ -32,23 +26,26 @@ const customPackages: Array<MultiSelectItem> = [
3226
},
3327
]
3428

29+
interface Props {
30+
onCompletion: () => void
31+
onSubmit: (selectedItems: Array<MultiSelectItem>) => void
32+
skip?: boolean
33+
}
34+
3535
/**
3636
* Step for selecting optional packages. Skipped if installation type is 'full'.
3737
* @param onCompletion
3838
* @param onSubmit
3939
* @param installation
40+
* @param skip
4041
*/
41-
const OptionalPackages: FC<Props> = ({ onCompletion, onSubmit, installation }) => {
42+
const OptionalPackages: FC<Props> = ({ onCompletion, onSubmit, skip = false }) => {
4243
const [isFocused, setIsFocused] = useState(true)
43-
const skip = installation === 'full'
4444

45-
// biome-ignore lint/correctness/useExhaustiveDependencies: Run this only once
46-
useEffect(() => {
47-
// full installation, do nothing
48-
if (skip) {
49-
onCompletion()
50-
}
51-
}, [])
45+
// full installation, do nothing
46+
if (skip) {
47+
onCompletion()
48+
}
5249

5350
const onHandleSubmit = (selectedItems: Array<MultiSelectItem>) => {
5451
onSubmit(selectedItems)

0 commit comments

Comments
 (0)