Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Modify setup-django.sh to use yarn instead of bower and npm if availa…
Browse files Browse the repository at this point in the history
…ble re #286,

currently setup-django makes the assumption that yarn.lock exists which it may not initially.

In order to use BS4 and compile from source, we need to move away from bower (at least to install bootstrap, since bower is deprecated), they recommend using yarn instead. Can we get away with simply using npm and django-compressor?

The goal is to have:

 - bootstrap 3 available to the admin
 - bootstrap 4 available to the front end
 - icekit .scss files compiled into the project/overridable where necessary
 - project .scss files that allow for bootstrap variables and overrides and provide a platform to build on that simplifies frontend setups for icekit sites.
 - can we get away with using only django-compressor or is yarn/alternative a necessary step?
 - as simple a setup as possible to avoid painful edge cases and implementation nightmares
 - sourcemaps would be nice

Yarn

 - use bower-away to convert bower.json to yarn (adds yarn specific syntax to package.json)
 - yarn requires Ruby > 2.3
 - you might need to delete bower_components/.DS_Store if bower-away fails with ENOTDIR
  • Loading branch information
Sam Minton committed Nov 2, 2017
1 parent 8ae0e65 commit 31d7117
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
3 changes: 3 additions & 0 deletions icekit/bin/setup-django.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ if [[ -n "$WAITLOCK_ENABLE" ]]; then
EOF
fi

if [[ -f yarn.lock ]]; then
waitlock.sh yarn.sh "$ICEKIT_PROJECT_DIR"
# Install Node modules.
waitlock.sh npm-install.sh "$ICEKIT_PROJECT_DIR"

# Install Bower components.
waitlock.sh bower-install.sh "$ICEKIT_PROJECT_DIR"
fi

# Install Python requirements.
waitlock.sh pip-install.sh "$ICEKIT_PROJECT_DIR"
Expand Down
37 changes: 37 additions & 0 deletions icekit/bin/yarn.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

# Install Node modules in the given directory via yarn, if they have changed.

cat <<EOF
# `whoami`@`hostname`:$PWD$ yarn.sh $@
EOF

set -e

DIR="${1:-$PWD}"

mkdir -p "$DIR"
cd "$DIR"

if [[ ! -s package.json ]]; then
cat <<EOF > package.json
{
"name": "$ICEKIT_PROJECT_NAME",
"dependencies": {
},
"private": true
}
EOF
fi

touch package.json.md5

if [[ ! -s package.json.md5 ]] || ! md5sum --status -c package.json.md5 > /dev/null 2>&1; then
echo "Node modules in '$DIR' directory are out of date."
if [[ -d node_modules ]]; then
echo 'Removing old Node modules directory.'
rm -rf node_modules
fi
yarn
md5sum package.json > package.json.md5
fi

0 comments on commit 31d7117

Please sign in to comment.