Skip to content

Commit 68e61ca

Browse files
feat: add some file cleanup routines
1 parent 572c9f8 commit 68e61ca

1 file changed

Lines changed: 126 additions & 36 deletions

File tree

source/import/components/steps/FileCleanup.tsx

Lines changed: 126 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import React, { type FC, useMemo } from 'react'
44
import { homeFolder } from '../../constants/config.js'
55
import type { InstallationType, MultiSelectItem } from '../../types/types.js'
66
import { featureSelected, getProjectFolder } from '../../utils/utils.js'
7+
import Divider from '../Divider.js'
78

89
interface Props {
910
onCompletion: () => void
@@ -24,51 +25,140 @@ const FileCleanup: FC<Props> = ({ onCompletion, installationConfig, projectName
2425
const { installationType, selectedFeatures } = installationConfig
2526
const projectFolder = useMemo(() => getProjectFolder(projectName), [projectName])
2627
const currentHomeFolder = `${projectFolder}${homeFolder}`
27-
const cleanHomeFile = `${projectFolder}/.install-files/home/index.tsx`
28+
const cleanHomeFile = './.install-files/home/index.tsx'
2829

2930
return (
30-
<Box
31-
flexDirection={'column'}
32-
gap={0}
33-
>
34-
{!featureSelected('demo', selectedFeatures) && (
31+
<>
32+
<Divider title={'File cleanup'} />
33+
<Box
34+
flexDirection={'column'}
35+
gap={0}
36+
>
3537
<Script>
36-
<Text color={'whiteBright'}>Removing component demos</Text>
38+
{!featureSelected('demo', selectedFeatures) && (
39+
<Script>
40+
<Text color={'whiteBright'}>Demo files</Text>
41+
<Spawn
42+
shell
43+
cwd={projectFolder}
44+
silent
45+
command="rm"
46+
args={['-rf', currentHomeFolder]}
47+
runningText={'Removing home files...'}
48+
successText={'Done!'}
49+
failureText={'Error...'}
50+
/>
51+
<Spawn
52+
shell
53+
cwd={projectFolder}
54+
silent
55+
command="mkdir"
56+
args={['-p', currentHomeFolder]}
57+
runningText={'Creating home folder...'}
58+
successText={'Done!'}
59+
failureText={'Error...'}
60+
/>
61+
<Spawn
62+
shell
63+
cwd={projectFolder}
64+
silent
65+
command="cp"
66+
args={[cleanHomeFile, currentHomeFolder]}
67+
runningText={'Creating new home page file...'}
68+
successText={'Done!'}
69+
failureText={'Error...'}
70+
/>
71+
</Script>
72+
)}
73+
{!featureSelected('typedoc', selectedFeatures) && (
74+
<Script>
75+
<Text color={'whiteBright'}>Typedoc files</Text>
76+
<Spawn
77+
shell
78+
cwd={projectFolder}
79+
silent
80+
command="rm"
81+
args={['typedoc.json']}
82+
runningText={'Removing config...'}
83+
successText={'Done!'}
84+
failureText={'Error...'}
85+
/>
86+
</Script>
87+
)}
88+
{!featureSelected('vocs', selectedFeatures) && (
89+
<Script>
90+
<Text color={'whiteBright'}>Vocs files</Text>
91+
<Spawn
92+
shell
93+
cwd={projectFolder}
94+
silent
95+
command="rm"
96+
args={['vocs.config.ts']}
97+
runningText={'Removing config...'}
98+
successText={'Done!'}
99+
failureText={'Error...'}
100+
/>
101+
<Spawn
102+
shell
103+
cwd={projectFolder}
104+
silent
105+
command="rm"
106+
args={['-rf', 'docs']}
107+
runningText={'Removing docs folder...'}
108+
successText={'Done!'}
109+
failureText={'Error...'}
110+
/>
111+
</Script>
112+
)}
113+
{!featureSelected('husky', selectedFeatures) && (
114+
<Script>
115+
<Text color={'whiteBright'}>Husky files</Text>
116+
<Spawn
117+
shell
118+
cwd={projectFolder}
119+
silent
120+
command="rm"
121+
args={['-rf', '.husky']}
122+
runningText={'Removing Husky folder...'}
123+
successText={'Done!'}
124+
failureText={'Error...'}
125+
/>
126+
<Spawn
127+
shell
128+
cwd={projectFolder}
129+
silent
130+
command="rm"
131+
args={['.lintstagedrc.mjs']}
132+
runningText={'Removing lint-staged config...'}
133+
successText={'Done!'}
134+
failureText={'Error...'}
135+
/>
136+
<Spawn
137+
shell
138+
cwd={projectFolder}
139+
silent
140+
command="rm"
141+
args={['commitlint.config.js']}
142+
runningText={'Removing commitlint config...'}
143+
successText={'Done!'}
144+
failureText={'Error...'}
145+
/>
146+
</Script>
147+
)}
148+
<Text color={'whiteBright'}>Install files</Text>
37149
<Spawn
38150
shell
39151
cwd={projectFolder}
40-
// silent
152+
silent
41153
command="rm"
42-
args={['-rf', currentHomeFolder]}
43-
// runningText={'Working...'}
44-
// successText={'Done!'}
45-
// failureText={'Error...'}
46-
/>
47-
<Text color={'whiteBright'}>Creating new home folder</Text>
48-
<Spawn
49-
shell
50-
cwd={projectFolder}
51-
// silent
52-
command="mkdir"
53-
args={['-p', currentHomeFolder]}
54-
// runningText={'Working...'}
55-
// successText={'Done!'}
56-
// failureText={'Error...'}
57-
/>
58-
<Text color={'whiteBright'}>Creating new home page</Text>
59-
<Spawn
60-
shell
61-
cwd={projectFolder}
62-
// silent
63-
command="cp"
64-
args={[cleanHomeFile, currentHomeFolder]}
65-
// runningText={'Working...'}
66-
// successText={'Done!'}
67-
// failureText={'Error...'}
154+
args={['-rf', '.install-files']}
155+
runningText={'Removing folder...'}
156+
successText={'Done!'}
157+
failureText={'Error...'}
68158
/>
69159
</Script>
70-
)}
71-
</Box>
160+
</Box>
161+
</>
72162
)
73163
}
74164

0 commit comments

Comments
 (0)