Skip to content

Commit

Permalink
Updated bash script. Fixed imports for 3 files and ran bash script fo…
Browse files Browse the repository at this point in the history
…r testing
  • Loading branch information
sreidthomas committed Feb 5, 2025
1 parent ccec766 commit 9da0342
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 49 deletions.
75 changes: 39 additions & 36 deletions scripts/compile_styles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,50 +21,57 @@ compile_bootstrap () {
replace_rem_w_em "${PROJECT_ROOT}src/shared/themed-bootstrap.css"
format_bootstrap "${PROJECT_ROOT}src/shared/themed-bootstrap.css"
}

compile_components() {
# Variable Setup
folders=("atoms" "molecules" "organisms")
base_path="${PROJECT_ROOT}src/components"
directories_not_found=()

# Check if directories exist
for folder in "${folders[@]}"; do
current_path="${base_path}/${folder}"

if [[ ! -d $current_path ]]; then
echo "Directory '${current_path}' not found."
directories_not_found+=("$folder")
found_scss_files=()

# Handle experimental components with atomic structure
exp_base_path="${PROJECT_ROOT}src/experimental/components"
exp_folders=("atoms" "molecules" "organisms")

# Find SCSS files in experimental atomic folders
for folder in "${exp_folders[@]}"; do
current_path="${exp_base_path}/${folder}"
if [[ -d $current_path ]]; then
while read -r scss_file; do
found_scss_files+=("$scss_file")
done < <(find "$current_path" -type f -name "*.scss" 2>/dev/null)
fi
done

if [[ ${#directories_not_found[@]} -gt 0 ]]; then
echo "Aborting CSS generation. Directories not found: ${directories_not_found[*]}"
exit 1

# Find SCSS files in stable components
stable_base_path="${PROJECT_ROOT}src/stable/components"
if [[ -d $stable_base_path ]]; then
# Look for .scss files recursively in all component folders
while read -r scss_file; do
found_scss_files+=("$scss_file")
done < <(find "$stable_base_path" -type f -name "*.scss" -not -path "*/node_modules/*" 2>/dev/null)
fi

# Find and print .scss files before confirmation
found_scss_files=()
for folder in "${folders[@]}"; do
current_path="${base_path}/${folder}"
# Debug output
echo "Searching in experimental path: $exp_base_path"
echo "Searching in stable path: $stable_base_path"

# Print current working directory for debugging
echo "Current working directory: $(pwd)"

while read -r scss_file; do
found_scss_files+=("$scss_file")
done < <(find "$current_path" -type f -name '*.scss')
done
# Check if any SCSS files were found
if [[ ${#found_scss_files[@]} -eq 0 ]]; then
echo "No .scss files found in any of the directories. Aborting."
ls -la "${stable_base_path}/GovBanner" # Debug line to show contents of GovBanner directory
exit 1
fi

# Display found .scss files
# Rest of the function remains the same...
echo "Found .scss files:"
for scss_file in "${found_scss_files[@]}"; do
echo "$scss_file"
done

# Confirm with the user
read -p "Confirm the conversion of found .scss files (input 'yes' to proceed or 'abort' to stop the script): " user_input

case $user_input in
"yes")
# Continue with the conversion
echo "Starting CSS generation..."
;;
"abort")
Expand All @@ -79,24 +86,20 @@ compile_components() {

# Convert .scss files to .css
for scss_file in "${found_scss_files[@]}"; do

# Get the real path of the file
component_scss_path=$(realpath "$scss_file")

# Replace the file extension to get the CSS output file name.
output_css_file="${component_scss_path%.*}.css"

# Run yarn sass command for each .scss file

yarn sass -I ${PROJECT_ROOT}/node_modules/ "$component_scss_path" "$output_css_file"

# Apply replace_rem_w_em and format_bootstrap functions to the generated CSS file

replace_rem_w_em "$output_css_file"
format_bootstrap "$output_css_file"
done

echo "CSS generation and post-processing completed."
}



replace_rem_w_em () {
echo "Replacing REMs with EMs..."
sed -i.bak -E "s|([0-9])rem|\1em|g" "$1" && rm "$1.bak"
Expand All @@ -118,4 +121,4 @@ format_bootstrap () {
# Call the functions
compile_components
compile_bootstrap
exit $?
exit $?

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/experimental/components/atoms/TableCell/TableCell.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use '../../../scss/mixins/table';
@use '../../../../scss/mixins/table';
@import 'bootstrap/scss/functions';
@import 'bootstrap/scss/variables';
@import 'bootstrap/scss/mixins/breakpoints';
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use '../../../scss/mixins/table';
@use '../../../../scss/mixins/table';
@import 'bootstrap/scss/functions';
@import 'bootstrap/scss/variables';
@import 'bootstrap/scss/mixins/breakpoints';
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/experimental/components/molecules/Nav/Nav.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/experimental/components/organisms/TableV2/TableV2.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@use '../../../scss/mixins/table';
// @use '../../../../../scss/mixins/table';
@use '../../../../scss/mixins/table';
@import 'bootstrap/scss/functions';
@import 'bootstrap/scss/variables';
@import 'bootstrap/scss/mixins/breakpoints';
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9da0342

Please sign in to comment.