-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tools install script PoC #284
Draft
krystian-panek-vmltech
wants to merge
9
commits into
main
Choose a base branch
from
tools-install-script
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
08cb2b3
Tools install script PoC
krystian-panek-vmltech 0d42a12
Consolidated tasks
krystian-panek-vmltech c35166f
Hardened open in crxde
krystian-panek-vmltech 0366c65
minor
977abed
minor
b1a6c4f
minor
b6cb52c
Revert "minor"
496213f
revert
973f4bf
revert
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -223,3 +223,4 @@ $RECYCLE.BIN/ | |
dist/ | ||
**/aem/home/ | ||
!pkg/instance/resource | ||
/var |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,4 +124,5 @@ export MSYS2_ENV_CONV_EXCL="*" | |
# Execute AEM Compose CLI | ||
# ======================= | ||
|
||
aem "$@" | ||
AEM=$(whereis aem | awk '{print $2}') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In tf aemc this is run without issues. In vscode ext it also is doable to run it without amendment. Please revert this |
||
${AEM} "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
# Check if Taskfile.yml exists | ||
if [ ! -f "Taskfile.yml" ]; then | ||
echo "Taskfile.yml not found in the current directory." | ||
exit 1 | ||
fi | ||
|
||
# Define content to be appended to 'Taskfile.yml' | ||
TASKS_YML_CONTENT=$(cat <<'EOF' | ||
|
||
groovy:execute: | ||
desc: execute Groovy script on AEM instance | ||
cmd: | | ||
INSTANCE="{{.CLI_ARGS | splitArgs | first }}" | ||
if [ "$INSTANCE" = "author" ]; then | ||
INSTANCE_URL="{{.AEM_AUTHOR_HTTP_URL}}" | ||
INSTANCE_CREDENTIALS="{{.AEM_AUTHOR_USER}}:{{.AEM_AUTHOR_PASSWORD}}" | ||
elif [ "$INSTANCE" = "publish" ]; then | ||
INSTANCE_URL="{{.AEM_PUBLISH_HTTP_URL}}" | ||
INSTANCE_CREDENTIALS="{{.AEM_PUBLISH_USER}}:{{.AEM_PUBLISH_PASSWORD}}" | ||
else | ||
echo "Instance type supported are 'author' or 'publish' but got '$INSTANCE'" | ||
exit 1 | ||
fi | ||
|
||
SCRIPT="{{.CLI_ARGS | splitArgs | last }}" | ||
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 "${INSTANCE_CREDENTIALS}" -k -F "script=@${SCRIPT}" -X POST "${INSTANCE_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:open: | ||
desc: open CRX/DE on AEM instance | ||
cmd: | | ||
INSTANCE="{{.CLI_ARGS | splitArgs | first }}" | ||
if [ "$INSTANCE" = "author" ]; then | ||
INSTANCE_URL="{{.AEM_AUTHOR_HTTP_URL}}" | ||
elif [ "$INSTANCE" = "publish" ]; then | ||
INSTANCE_URL="{{.AEM_PUBLISH_HTTP_URL}}" | ||
else | ||
echo "Instance type supported are 'author' or 'publish' but got '$INSTANCE'" | ||
exit 1 | ||
fi | ||
|
||
FILE_PATH="{{.CLI_ARGS | splitArgs | last }}" | ||
if [ ! -e "$FILE_PATH" ]; then | ||
echo "File not found: $FILE_PATH" | ||
exit 1 | ||
fi | ||
if [[ "$FILE_PATH" != *"/jcr_root/"* ]]; then | ||
echo "Path must contain '/jcr_root/' but got '$FILE_PATH'" | ||
exit 1 | ||
fi | ||
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') | ||
|
||
CRXDE_URL="${INSTANCE_URL}/crx/de#${REPO_PATH}" | ||
if [ "{{OS}}" = "windows" ]; then | ||
start "" "$CRXDE_URL" | ||
elif [ "{{OS}}" = "darwin" ]; then | ||
open "$CRXDE_URL" | ||
else | ||
xdg-open "$CRXDE_URL" | ||
fi | ||
EOF | ||
) | ||
|
||
# Define IDEA's 'tools/AEMC.xml' content | ||
AEMC_XML_CONTENT=$(cat <<'EOF' | ||
<toolSet name="AEMC"> | ||
<tool name="Content Clean" showInMainMenu="false" showInEditor="false" showInProject="false" showInSearchPopup="false" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true"> | ||
<exec> | ||
<option name="COMMAND" value="$ProjectFileDir$/aemw" /> | ||
<option name="PARAMETERS" value="content clean --path $FilePath$" /> | ||
<option name="WORKING_DIRECTORY" value="$ProjectFileDir$" /> | ||
</exec> | ||
</tool> | ||
<tool name="Content Pull [author]" description="Content Pull [author]" showInMainMenu="false" showInEditor="false" showInProject="false" showInSearchPopup="false" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true"> | ||
<exec> | ||
<option name="COMMAND" value="$ProjectFileDir$/aemw" /> | ||
<option name="PARAMETERS" value="content pull -A --path $FilePath$ --clean" /> | ||
<option name="WORKING_DIRECTORY" value="$ProjectFileDir$" /> | ||
</exec> | ||
</tool> | ||
<tool name="Content Pull [publish]" showInMainMenu="false" showInEditor="false" showInProject="false" showInSearchPopup="false" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true"> | ||
<exec> | ||
<option name="COMMAND" value="$ProjectFileDir$/aemw" /> | ||
<option name="PARAMETERS" value="content pull -P --path $FilePath$ --clean" /> | ||
<option name="WORKING_DIRECTORY" value="$ProjectFileDir$" /> | ||
</exec> | ||
</tool> | ||
<tool name="Content Push [author]" description="Content Push [author]" showInMainMenu="false" showInEditor="false" showInProject="false" showInSearchPopup="false" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true"> | ||
<exec> | ||
<option name="COMMAND" value="$ProjectFileDir$/aemw" /> | ||
<option name="PARAMETERS" value="content push -A --path $FilePath$" /> | ||
<option name="WORKING_DIRECTORY" value="$ProjectFileDir$" /> | ||
</exec> | ||
</tool> | ||
<tool name="Content Push [publish]" description="Content Push [publish]" showInMainMenu="false" showInEditor="false" showInProject="false" showInSearchPopup="false" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true"> | ||
<exec> | ||
<option name="COMMAND" value="$ProjectFileDir$/aemw" /> | ||
<option name="PARAMETERS" value="content push -P --path $FilePath$" /> | ||
<option name="WORKING_DIRECTORY" value="$ProjectFileDir$" /> | ||
</exec> | ||
</tool> | ||
<tool name="CRXDE Open [author]" showInMainMenu="false" showInEditor="false" showInProject="false" showInSearchPopup="false" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true"> | ||
<exec> | ||
<option name="COMMAND" value="$ProjectFileDir$/taskw" /> | ||
<option name="PARAMETERS" value="crxde:open -- author $FilePath$" /> | ||
<option name="WORKING_DIRECTORY" value="$ProjectFileDir$" /> | ||
</exec> | ||
</tool> | ||
<tool name="CRXDE Open [publish]" showInMainMenu="false" showInEditor="false" showInProject="false" showInSearchPopup="false" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true"> | ||
<exec> | ||
<option name="COMMAND" value="$ProjectFileDir$/taskw" /> | ||
<option name="PARAMETERS" value="crxde:open -- publish $FilePath$" /> | ||
<option name="WORKING_DIRECTORY" value="$ProjectFileDir$" /> | ||
</exec> | ||
</tool> | ||
<tool name="Groovy Console [author]" description="Run currently opened Groovy Script in editor on author instance" showInMainMenu="false" showInEditor="false" showInProject="false" showInSearchPopup="false" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true"> | ||
<exec> | ||
<option name="COMMAND" value="$ProjectFileDir$/taskw" /> | ||
<option name="PARAMETERS" value="groovy:execute -- author $FilePath$" /> | ||
<option name="WORKING_DIRECTORY" value="$ProjectFileDir$" /> | ||
</exec> | ||
</tool> | ||
<tool name="Groovy Console [publish]" description="Run currently opened Groovy Script in editor on publish instance" showInMainMenu="false" showInEditor="false" showInProject="false" showInSearchPopup="false" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true"> | ||
<exec> | ||
<option name="COMMAND" value="$ProjectFileDir$/taskw" /> | ||
<option name="PARAMETERS" value="groovy:execute -- publish $FilePath$" /> | ||
<option name="WORKING_DIRECTORY" value="$ProjectFileDir$" /> | ||
</exec> | ||
</tool> | ||
</toolSet> | ||
EOF | ||
) | ||
|
||
# Function to create 'tools/AEMC.xml' in IntelliJ installations | ||
create_aemc_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/AEMC.xml" | ||
echo "Creating AEMC.xml in $aem_file" | ||
echo "$AEMC_XML_CONTENT" > "$aem_file" | ||
fi | ||
done | ||
} | ||
|
||
# Create AEMC.xml in IntelliJ installations | ||
create_aemc_xml | ||
|
||
# Append tasks.yml content to Taskfile.yml | ||
echo "Appending tasks.yml content to Taskfile.yml" | ||
echo "$TASKS_YML_CONTENT" >> "Taskfile.yml" | ||
|
||
echo "Script execution completed." | ||
echo "Please restart IntelliJ IDEA to see the changes." |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove these flags added