@@ -118,22 +118,20 @@ describe('generatePrivateInstallScript', () => {
118118
119119describe ( 'generateInstallScript' , ( ) => {
120120 it ( 'should wrap everything in main() for safe curl|bash piping' , ( ) => {
121- const script = generateInstallScript ( 'testuser' , 'my-config' , '' , '' ) ;
121+ const script = generateInstallScript ( 'testuser' , 'my-config' ) ;
122122
123123 expect ( script ) . toContain ( 'main()' ) ;
124124 expect ( script ) . toMatch ( / m a i n " \$ @ " \s * $ / ) ;
125125 expect ( script ) . toContain ( 'exec < /dev/tty' ) ;
126126
127127 // CRITICAL: main() must never return after exec < /dev/tty redirects stdin.
128- // Every code path inside main() must end with exit or exec, otherwise
129- // bash hangs waiting on /dev/tty when run via "curl | bash".
130128 expect ( script ) . toContain ( 'exit 0\n}' ) ;
131129 // No code should appear between main "$@" and end of script
132130 expect ( script ) . not . toMatch ( / m a i n " \$ @ " [ \s \S ] * e x i t / ) ;
133131 } ) ;
134132
135- it ( 'should generate basic install script without custom content ' , ( ) => {
136- const script = generateInstallScript ( 'testuser' , 'my-config' , '' , '' ) ;
133+ it ( 'should generate basic install script' , ( ) => {
134+ const script = generateInstallScript ( 'testuser' , 'my-config' ) ;
137135
138136 expect ( script ) . toContain ( '#!/bin/bash' ) ;
139137 expect ( script ) . toContain ( 'OpenBoot Installer' ) ;
@@ -143,117 +141,49 @@ describe('generateInstallScript', () => {
143141 } ) ;
144142
145143 it ( 'should include Xcode CLT installation' , ( ) => {
146- const script = generateInstallScript ( 'testuser' , 'my-config' , '' , '' ) ;
144+ const script = generateInstallScript ( 'testuser' , 'my-config' ) ;
147145
148146 expect ( script ) . toContain ( 'install_xcode_clt()' ) ;
149147 expect ( script ) . toContain ( 'xcode-select -p' ) ;
150148 expect ( script ) . toContain ( 'xcode-select --install' ) ;
151149 } ) ;
152150
153151 it ( 'should include Homebrew installation' , ( ) => {
154- const script = generateInstallScript ( 'testuser' , 'my-config' , '' , '' ) ;
152+ const script = generateInstallScript ( 'testuser' , 'my-config' ) ;
155153
156154 expect ( script ) . toContain ( 'install_homebrew()' ) ;
157155 expect ( script ) . toContain ( 'command -v brew' ) ;
158156 expect ( script ) . toContain ( 'Homebrew/install/HEAD/install.sh' ) ;
159157 } ) ;
160158
161159 it ( 'should handle ARM64 architecture' , ( ) => {
162- const script = generateInstallScript ( 'testuser' , 'my-config' , '' , '' ) ;
160+ const script = generateInstallScript ( 'testuser' , 'my-config' ) ;
163161
164162 expect ( script ) . toContain ( 'detect_arch()' ) ;
165163 expect ( script ) . toContain ( '/opt/homebrew/bin/brew' ) ;
166164 expect ( script ) . toContain ( 'arm64)' ) ;
167165 } ) ;
168166
169- it ( 'should include custom script when provided' , ( ) => {
170- const customScript = 'mkdir -p ~/projects\necho "Setup complete"' ;
171- const script = generateInstallScript ( 'testuser' , 'my-config' , customScript , '' ) ;
172-
173- expect ( script ) . toContain ( 'Running Custom Post-Install Script' ) ;
174- expect ( script ) . toContain ( 'base64 -d | bash' ) ;
175- expect ( script ) . toContain ( 'CUSTOM_SCRIPT_EXIT=$?' ) ;
176- } ) ;
177-
178- it ( 'should handle custom script errors gracefully' , ( ) => {
179- const customScript = 'exit 1' ;
180- const script = generateInstallScript ( 'testuser' , 'my-config' , customScript , '' ) ;
181-
182- expect ( script ) . toContain ( 'set +e' ) ;
183- expect ( script ) . toContain ( 'if [ $CUSTOM_SCRIPT_EXIT -ne 0 ]' ) ;
184- expect ( script ) . toContain ( 'Custom script exited with code' ) ;
185- expect ( script ) . toContain ( 'Installation will continue' ) ;
186- } ) ;
187-
188- it ( 'should not include custom script section when empty' , ( ) => {
189- const script = generateInstallScript ( 'testuser' , 'my-config' , '' , '' ) ;
167+ it ( 'should not include custom script or dotfiles sections' , ( ) => {
168+ const script = generateInstallScript ( 'testuser' , 'my-config' ) ;
190169
191170 expect ( script ) . not . toContain ( 'Running Custom Post-Install Script' ) ;
192171 expect ( script ) . not . toContain ( 'base64 -d' ) ;
193- } ) ;
194-
195- it ( 'should include dotfiles setup when repo provided' , ( ) => {
196- const dotfilesRepo = 'https://github.com/testuser/dotfiles.git' ;
197- const script = generateInstallScript ( 'testuser' , 'my-config' , '' , dotfilesRepo ) ;
198-
199- expect ( script ) . toContain ( 'Setting up Dotfiles' ) ;
200- expect ( script ) . toContain ( 'DOTFILES_REPO="https://github.com/testuser/dotfiles.git"' ) ;
201- expect ( script ) . toContain ( 'DOTFILES_DIR="$HOME/.dotfiles"' ) ;
202- expect ( script ) . toContain ( 'git clone "$DOTFILES_REPO"' ) ;
203- expect ( script ) . toContain ( 'stow -v --target="$HOME"' ) ;
204- } ) ;
205-
206- it ( 'should validate dotfiles repo URL is HTTPS' , ( ) => {
207- const dotfilesRepo = 'https://github.com/testuser/dotfiles.git' ;
208- const script = generateInstallScript ( 'testuser' , 'my-config' , '' , dotfilesRepo ) ;
209-
210- expect ( script ) . toContain ( 'if [[ ! "$DOTFILES_REPO" =~ ^https:// ]]' ) ;
211- expect ( script ) . toContain ( 'Invalid dotfiles repo URL (must use HTTPS)' ) ;
212- } ) ;
213-
214- it ( 'should handle existing dotfiles directory with git pull' , ( ) => {
215- const dotfilesRepo = 'https://github.com/testuser/dotfiles.git' ;
216- const script = generateInstallScript ( 'testuser' , 'my-config' , '' , dotfilesRepo ) ;
217-
218- expect ( script ) . toContain ( 'if [ -d "$DOTFILES_DIR" ]' ) ;
219- expect ( script ) . toContain ( 'Pulling latest changes...' ) ;
220- expect ( script ) . toContain ( 'git pull' ) ;
221- } ) ;
222-
223- it ( 'should remove existing zshrc files before stow' , ( ) => {
224- const dotfilesRepo = 'https://github.com/testuser/dotfiles.git' ;
225- const script = generateInstallScript ( 'testuser' , 'my-config' , '' , dotfilesRepo ) ;
226-
227- expect ( script ) . toContain ( 'rm -f "$HOME/.zshrc" "$HOME/.zshrc.pre-oh-my-zsh"' ) ;
228- } ) ;
229-
230- it ( 'should not include dotfiles section when repo not provided' , ( ) => {
231- const script = generateInstallScript ( 'testuser' , 'my-config' , '' , '' ) ;
232-
233172 expect ( script ) . not . toContain ( 'Setting up Dotfiles' ) ;
234173 expect ( script ) . not . toContain ( 'DOTFILES_REPO' ) ;
235174 expect ( script ) . not . toContain ( 'stow' ) ;
236175 } ) ;
237176
238177 it ( 'should sanitize username and slug in all references' , ( ) => {
239- const script = generateInstallScript ( 'user@test' , 'my config!' , '' , '' ) ;
178+ const script = generateInstallScript ( 'user@test' , 'my config!' ) ;
240179
241180 expect ( script ) . toContain ( 'usertest/myconfig' ) ;
242181 expect ( script ) . not . toContain ( 'user@test' ) ;
243182 expect ( script ) . not . toContain ( 'my config!' ) ;
244183 } ) ;
245184
246- it ( 'should include both custom script and dotfiles when both provided' , ( ) => {
247- const customScript = 'echo "Custom setup"' ;
248- const dotfilesRepo = 'https://github.com/testuser/dotfiles.git' ;
249- const script = generateInstallScript ( 'testuser' , 'my-config' , customScript , dotfilesRepo ) ;
250-
251- expect ( script ) . toContain ( 'Running Custom Post-Install Script' ) ;
252- expect ( script ) . toContain ( 'Setting up Dotfiles' ) ;
253- } ) ;
254-
255185 it ( 'should install openboot via Homebrew tap' , ( ) => {
256- const script = generateInstallScript ( 'testuser' , 'my-config' , '' , '' ) ;
186+ const script = generateInstallScript ( 'testuser' , 'my-config' ) ;
257187
258188 expect ( script ) . toContain ( 'TAP_NAME="openbootdotdev/tap"' ) ;
259189 expect ( script ) . toContain ( 'brew install ${TAP_NAME}/openboot' ) ;
@@ -262,7 +192,7 @@ describe('generateInstallScript', () => {
262192 } ) ;
263193
264194 it ( 'should pass through additional arguments to openboot' , ( ) => {
265- const script = generateInstallScript ( 'testuser' , 'my-config' , '' , '' ) ;
195+ const script = generateInstallScript ( 'testuser' , 'my-config' ) ;
266196
267197 expect ( script ) . toContain ( 'openboot --user "testuser/my-config" "$@"' ) ;
268198 } ) ;
0 commit comments