Skip to content

Commit 2dc5565

Browse files
committed
separate dev quality-of-life functionality from devcontainer lifecycle script
1 parent 6d15c34 commit 2dc5565

2 files changed

Lines changed: 59 additions & 6 deletions

File tree

uceap-drupal-dev-refresh-content

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
4+
# ensure we're working in the workspace folder
5+
if [ -n "$WORKSPACE_FOLDER" ]; then
6+
cd $WORKSPACE_FOLDER
7+
else
8+
echo "No WORKSPACE_FOLDER environment variable set, please update your devcontainer.json file."
9+
# as a transitional fallback, check to see if composer.json exists in the current directory, in which case we assume we're in the workspace folder
10+
if [ ! -f composer.json ]; then
11+
echo "No composer.json found in the current directory, please run this script from the root of your project."
12+
exit 1
13+
fi
14+
fi
15+
16+
# re-run composer install (e.g. in case we've switched branches since last time we ran this script)
17+
composer install
18+
19+
# re-build the theme (likewise in case of changes)
20+
composer compile-theme
21+
22+
# during first run, the new PATH from the on-create script is not yet in effect
23+
if ( ! command -v drush > /dev/null ); then
24+
export PATH="`pwd`/vendor/bin:$PATH"
25+
fi
26+
27+
# we need to preserve gitconfig if it already exists
28+
if [ -f ~/.gitconfig ]; then
29+
gitconfig_existed=true
30+
fi
31+
# ownership of the workspace directory won't match when using bindfs
32+
git config --global --add safe.directory "$(pwd)"
33+
# gh runs git, so we need to set the safe.directory in order for it to work
34+
gh release download --clobber --pattern '*.gz'
35+
# but later on vscode will try setting global git config (credential helper, etc) ONLY if gitconfig doesn't exist
36+
if [ ! $gitconfig_existed ]; then
37+
rm ~/.gitconfig
38+
fi
39+
# FWIW vscode will also fix the safe.directory setting
40+
41+
tar zx --no-same-permissions --strip-components 1 -C web/sites/default/files -f files.tar.gz
42+
rm files.tar.gz
43+
44+
# no-same-permissions doesn't seem to work so we fix it here
45+
sudo find web/sites/default/files -type d -exec chmod g+ws {} +
46+
sudo find web/sites/default/files -type f -exec chmod g+w {} +
47+
48+
# the first time we run this script the default umask is still in effect,
49+
# which messes up permissions on the profiler directory that gets created when the caches are rebuilt by db-rebuild.sh
50+
umask 002
51+
52+
sudo service mariadb start
53+
build/db-rebuild.sh database.sql.gz
54+
rm database.sql.gz
55+
56+
# Run local devcontainer lifecycle scripts
57+
if [ -x .devcontainer/updateContent.sh ]; then
58+
.devcontainer/updateContent.sh
59+
fi

uceap-drupal-dev-update-content

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ else
1313
fi
1414
fi
1515

16-
# re-run composer install (e.g. in case we've switched branches since last time we ran this script)
17-
composer install
18-
19-
# re-build the theme (likewise in case of changes)
20-
composer compile-theme
21-
2216
# during first run, the new PATH from the on-create script is not yet in effect
2317
if ( ! command -v drush > /dev/null ); then
2418
export PATH="`pwd`/vendor/bin:$PATH"

0 commit comments

Comments
 (0)