diff --git a/.gitignore b/.gitignore index 5a5a4cb..7630ed2 100644 --- a/.gitignore +++ b/.gitignore @@ -223,3 +223,4 @@ $RECYCLE.BIN/ dist/ **/aem/home/ !pkg/instance/resource +/var diff --git a/README.md b/README.md index 74ebe71..373fe8b 100644 --- a/README.md +++ b/README.md @@ -140,7 +140,7 @@ Supported project types: Run command below to install the AEM Compose tool in your project: ```shell -curl https://raw.githubusercontent.com/wttech/aemc/main/project-install.sh | sh +curl https://raw.githubusercontent.com/wttech/aemc/main/scripts/project-install.sh | sh ``` After successful installation, remember to always use the tool via wrapper script in the following way: diff --git a/project-install.sh b/scripts/project-install.sh similarity index 100% rename from project-install.sh rename to scripts/project-install.sh diff --git a/scripts/tools-install-idea.sh b/scripts/tools-install-idea.sh new file mode 100644 index 0000000..6b3dfbb --- /dev/null +++ b/scripts/tools-install-idea.sh @@ -0,0 +1,181 @@ +# Check if Taskfile.yaml exists +if [ ! -f "Taskfile.yaml" ]; then + echo "Taskfile.yaml not found in the current directory." + exit 1 +fi + +# Define content to be appended to 'Taskfile.yaml' +TASKS_YAML_CONTENT=$(cat <<'EOF' + groovy:author: + desc: execute Groovy script on AEM author instance + cmd: | + SCRIPT="{{.CLI_ARGS}}" + if [[ ! -f "${SCRIPT}" ]] || [[ "${SCRIPT: -7}" != ".groovy" ]]; then + echo "Groovy script not found or the file is not a Groovy script: '${SCRIPT}'" + exit 1 + fi + RESPONSE=$(curl -u "{{.AEM_AUTHOR_USER}}:{{.AEM_AUTHOR_PASSWORD}}" -k -F "script=@${SCRIPT}" -X POST "{{.AEM_AUTHOR_HTTP_URL}}/bin/groovyconsole/post.json") + EXCEPTION=$(echo "$RESPONSE" | jq -r '.exceptionStackTrace') + if [[ $EXCEPTION != "" ]]; then + echo "" + echo "Groovy script exception:" + echo -e "${EXCEPTION}" + echo "" + fi + echo "" + echo "Groovy script output:" + OUTPUT=$(echo "${RESPONSE}" | jq -r '.output') + echo -e "${OUTPUT}" + echo "" + + groovy:publish: + desc: execute Groovy script on AEM publish instance + cmd: | + SCRIPT="{{.CLI_ARGS}}" + if [[ ! -f "${SCRIPT}" ]] || [[ "${SCRIPT: -7}" != ".groovy" ]]; then + echo "Groovy script not found or the file is not a Groovy script: '${SCRIPT}'" + exit 1 + fi + RESPONSE=$(curl -u "{{.AEM_PUBLISH_USER}}:{{.AEM_PUBLISH_PASSWORD}}" -k -F "script=@${SCRIPT}" -X POST "{{.AEM_PUBLISH_HTTP_URL}}/bin/groovyconsole/post.json") + EXCEPTION=$(echo "$RESPONSE" | jq -r '.exceptionStackTrace') + if [[ $EXCEPTION != "" ]]; then + echo "" + echo "Groovy script exception:" + echo -e "${EXCEPTION}" + echo "" + fi + echo "" + echo "Groovy script output:" + OUTPUT=$(echo "${RESPONSE}" | jq -r '.output') + echo -e "${OUTPUT}" + echo "" + + crxde:author: + desc: open CRX/DE on AEM author instance + cmd: | + FILE_PATH="{{.CLI_ARGS}}" + FILE_PATH="${FILE_PATH/.content.xml/jcr:content}" + FILE_PATH="${FILE_PATH%.xml}" + REPO_PATH="${FILE_PATH#*jcr_root}" + REPO_PATH=$(echo "$REPO_PATH" | sed 's/ /%20/g; s/:/%3A/g') + if [ "{{OS}}" = "windows" ]; then + start "" "{{.AEM_AUTHOR_HTTP_URL}}/crx/de#${REPO_PATH}" + elif [ "{{OS}}" = "darwin" ]; then + open "{{.AEM_AUTHOR_HTTP_URL}}/crx/de#${REPO_PATH}" + else + xdg-open "{{.AEM_AUTHOR_HTTP_URL}}/crx/de#${REPO_PATH}" + fi + + crxde:publish: + desc: open CRX/DE on AEM publish instance + cmd: | + FILE_PATH="{{.CLI_ARGS}}" + FILE_PATH="${FILE_PATH/.content.xml/jcr:content}" + FILE_PATH="${FILE_PATH%.xml}" + REPO_PATH="${FILE_PATH#*jcr_root}" + REPO_PATH=$(echo "$REPO_PATH" | sed 's/ /%20/g; s/:/%3A/g') + if [ "{{OS}}" = "windows" ]; then + start "" "{{.AEM_PUBLISH_HTTP_URL}}/crx/de#${REPO_PATH}" + elif [ "{{OS}}" = "darwin" ]; then + open "{{.AEM_PUBLISH_HTTP_URL}}/crx/de#${REPO_PATH}" + else + xdg-open "{{.AEM_PUBLISH_HTTP_URL}}/crx/de#${REPO_PATH}" + fi + +EOF +) + +# Define IDEA's 'tools/AEM.xml' content +AEM_XML_CONTENT=$(cat <<'EOF' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +EOF +) + +# Function to create 'tools/AEM.xml' in IntelliJ installations +create_aem_xml() { + local intellij_dirs=( + "$HOME/Library/Application Support/JetBrains/IntelliJIdea"*/tools + ) + + for dir in "${intellij_dirs[@]}"; do + if [ -d "$dir" ]; then + local aem_file="$dir/AEM.xml" + echo "Creating AEM.xml in $aem_file" + echo "$AEM_XML_CONTENT" > "$aem_file" + fi + done +} + +# Create AEM.xml in IntelliJ installations +create_aem_xml + +# Append tasks.yaml content to Taskfile.yaml +echo "Appending tasks.yaml content to Taskfile.yaml" +echo "$TASKS_YAML_CONTENT" >> "Taskfile.yaml" + +echo "Script execution completed." +echo "Please restart IntelliJ IDEA to see the changes."