@@ -153,6 +153,48 @@ if [[ $VERSION = "canary" ]]; then
153153 fancy_print 3 " Warning: You are using canary Spin, but templates use latest stable SDKs."
154154 fancy_print 3 " Be sure to update templates to point to 'canary' SDKs."
155155fi
156+
157+ # Configure the default Spin environment in the user's shell profile
158+ fancy_print 0 " Step 6: Configuring SPIN_NEW_DEFAULT_ENVIRONMENT in your shell profile"
159+
160+ SPIN_ENV_LINE=' export SPIN_NEW_DEFAULT_ENVIRONMENT=akamai-functions'
161+
162+ # Determine which shell profile to update
163+ case $( basename " ${SHELL:- } " ) in
164+ " zsh" )
165+ PROFILE=" ${HOME} /.zshrc"
166+ ;;
167+ " bash" )
168+ # Prefer whichever profile already exists.
169+ if [[ -f " ${HOME} /.bashrc" ]]; then
170+ PROFILE=" ${HOME} /.bashrc"
171+ elif [[ -f " ${HOME} /.bash_profile" ]]; then
172+ PROFILE=" ${HOME} /.bash_profile"
173+ else
174+ PROFILE=" ${HOME} /.bashrc"
175+ fi
176+ ;;
177+ " fish" )
178+ # Fish uses its own syntax and config location.
179+ PROFILE=" ${HOME} /.config/fish/config.fish"
180+ SPIN_ENV_LINE=' set -gx SPIN_NEW_DEFAULT_ENVIRONMENT akamai-functions'
181+ mkdir -p " $( dirname " $PROFILE " ) "
182+ ;;
183+ * )
184+ PROFILE=" ${HOME} /.profile"
185+ ;;
186+ esac
187+
188+ # Append the export only if it is not already present
189+ if [[ -f " $PROFILE " ]] && grep -qF " $SPIN_ENV_LINE " " $PROFILE " ; then
190+ fancy_print 0 " SPIN_NEW_DEFAULT_ENVIRONMENT is already set in ${PROFILE} "
191+ else
192+ printf ' \n%s\n' " $SPIN_ENV_LINE " >> " $PROFILE "
193+ fancy_print 0 " Added SPIN_NEW_DEFAULT_ENVIRONMENT to ${PROFILE} "
194+ fi
195+ fancy_print 3 " Restart your shell or run 'source ${PROFILE} ' for the change to take effect."
196+ fancy_print 0 " Done...\n"
197+
156198# Direct to quicks-start doc
157199fancy_print 0 " You're good to go. Check here for the next steps: https://developer.fermyon.com/wasm-functions/quickstart"
158200fancy_print 0 " Run './spin' to get started"
0 commit comments