Skip to content

Instantly share code, notes, and snippets.

@DuaelFr
Last active July 25, 2018 14:36
Show Gist options
  • Save DuaelFr/6ac40cc1f686e227111ec8cd9a46033f to your computer and use it in GitHub Desktop.
Save DuaelFr/6ac40cc1f686e227111ec8cd9a46033f 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
@DuaelFr
Copy link
Author

DuaelFr commented Jun 4, 2018

Example output:

$ defcontent.sh web/modules/content/my_content_install/content/
default_content:
  file:
    - 413ef42a-dc72-4b09-8957-1c7c2990343b
    - a9b80e0e-09fb-4078-bc99-0933d0609884
  menu_link_content:
    - 15d74076-c06b-41c1-82c0-17244dbc849d
    - 16b9dea3-872d-4e8e-a786-0b749d80e44a
    - 2eb98792-d5ff-4dd1-bcbd-8639d61d5d30
    - 35bdaa4d-478a-4c1a-84e0-5c86bca6e62f
    - 799ac119-5c51-4a33-9580-615916dbaee2
    - 7b6bc8ac-4983-4c5a-9814-3dc34d53d27b
    - 8f7fbd72-9b63-4663-83a6-d90091861de1
    - a77c0088-98ea-473f-8565-dd765dd1314b
    - cba0bcfc-ba19-4d60-ac2c-591a8f50f8f6
    - df22bd24-de47-4610-a29b-59c6b6c079db
    - fd230073-9e51-480d-bca9-166293899765
  node:
    - db33c812-0299-49aa-8a39-185f4db340f0
  paragraph:
    - 13451cbc-cc30-435a-a6bf-4177ea0b0265
    - 32b84a16-d310-463b-89bc-76dd8dfed287
    - 3fa604fe-f66e-4209-bacf-743063fe9337
    - 4374888c-117c-4103-aead-9d0a4ec81230
    - 4710c48d-f83f-469e-9471-bd1d6b6260f9
    - 6a17a185-5567-4c2c-9fc5-0808363e275b
    - 6b5b540f-eaff-4c65-a886-7deb6a4c0a6a
    - 727a64f8-5409-4635-bb23-377bf3c1702f
    - 940aa39f-7da2-4ec4-b00a-a8caf7cf3c5a
    - cd42ee0d-51cd-4794-8913-05106dae387c
    - ec62f9a8-62f2-4a27-b2c2-9890bae017e0
    - f5f9d323-323b-4b8c-863c-eead57add016
  taxonomy_term:
    - 0935ff0c-59db-42bb-9479-500230fc1ef2
    - 0b15817a-f947-4524-bf03-96ec19e37ad1
    - 2f992804-b362-48df-8992-3eb35f056a54
    - 38eb2365-0aae-4ff7-93da-948deefeeb5f
    - 5c25cff3-ecf2-4560-903f-c8575bffbf9c
    - 65c58470-5ae9-4c0c-87e4-3cd4aa16bf55
    - 96c10033-c865-46ee-baaa-e8cf9b89d279
    - a3680f42-2d75-472f-971c-723e7e456ba1
    - b062a0e1-35bb-47ec-81b5-0b6fb7fd965c
    - e3a98dcf-4f70-4ff2-af67-6f1830f273bc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment