Skip to content

Instantly share code, notes, and snippets.

@flocondetoile
Forked from DuaelFr/defcontent.sh
Created July 11, 2018 16:17
Show Gist options
  • Save flocondetoile/cd23994538788f5d5323d088c3259b31 to your computer and use it in GitHub Desktop.
Save flocondetoile/cd23994538788f5d5323d088c3259b31 to your computer and use it in GitHub Desktop.
Outputs the list of entity types and uuids contained by a content directory of a default_content module
#!/bin/bash
# How to use this script?
#
# 1. create an empty module that depends on default_content or reuse an
# existing one.
# 2. use `drush dcer --folder=path/to/module/content ENTITY_TYPE ID`
# to add default content to your module.
# 3. once all your content is in your module, clean up the content folder
# to only keep the content you need (ie. remove users most of the time).
# 4. run `defcontent.sh path/to/module/content` then copy the output in
# your module info.yml file.
#
# Now, if you only need to update the content, you can just use
# `drush dcem my_module`.
if [ ! $1 ]; then
echo "Usage: $0 [directory]"
echo "where \`directory\` is the path to the 'content' directory of your module"
exit 1
fi
cd $1
echo "default_content:"
for D in */; do
echo " $D" | sed "s#/#\:#"
for F in $D/*.json; do
UUID=`echo $F | sed "s#.json##" | sed "s#$D/##"`
echo " - $UUID"
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment