Skip to content

Instantly share code, notes, and snippets.

@igasi
Last active March 10, 2017 18:01
Show Gist options
  • Save igasi/9d67b05eea8f3b4bf888213ded790b39 to your computer and use it in GitHub Desktop.
Save igasi/9d67b05eea8f3b4bf888213ded790b39 to your computer and use it in GitHub Desktop.
Automation to run a chain global definition from profile
#
# Add here all chain yml file for my_profile.
#
commands:
# Override Default Content Type Article created by Standard profile.
- command: chain
options:
file: modules/custom/features/my_feature/console/chain/overrideDefaultContentTypeArticle.yml
ansi: true
uri: 'http://default'
# Override Default Content Type Pgae created by Standard profile.
- command: chain
options:
file: modules/custom/features/my_feature_2/console/chain/overrideDefaultContentTypesPage.yml
ansi: true
uri: 'http://default'
#
# Blog Post overrides (aka article).
#
commands:
- command: config:import:single
options:
name: node.type.article
file: modules/custom/features/my_feature/config/optional/node.type.article.yml
ansi: true
uri: 'http://default'
#
# Basic Page overrides (aka page).
#
commands:
- command: config:import:single
options:
name: core.entity_form_display.node.page.default
file: modules/custom/features/my_feature_2/config/optional/core.entity_form_display.node.page.default.yml
ansi: true
uri: 'http://default'
- command: config:import:single
options:
name: core.entity_form_display.node.page.default
file: modules/custom/features/my_feature_2/config/optional/core.entity_form_display.node.page.default.yml
ansi: true
uri: 'http://default'
#!/usr/bin/env bash
#
# vim: set ft=sh:
#
parse_yaml() {
local prefix=$2
local s
local w
local fs
s='[[:space:]]*'
w='[a-zA-Z0-9_]*'
fs="$(echo @|tr @ '\034')"
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s[:-]$s\(.*\)$s\$|\1$fs\2$fs\3|p" "$1" |
awk -F"$fs" '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
if (length($3) > 0) {
vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
f=vn $2
if (f == "commands__options_file") {
printf("Running %s\n ...", $3)
system("drupal chain --file="$3)
}
}
}'
}
parse_yaml src/profiles/my_profile/console/chain/my_profile_chain_global.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment