Skip to content

Commit

Permalink
Merge pull request #14 from juan-ayala/feature/aem-universal-editor-s…
Browse files Browse the repository at this point in the history
…ervice

[aem-universal-editor-service] added UES feature for local development
  • Loading branch information
juan-ayala authored Sep 12, 2024
2 parents f559833 + 37a4e65 commit 16142b5
Show file tree
Hide file tree
Showing 22 changed files with 249 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
features:
- aem-sdk
- aem-repo-tool
- aem-universal-editor-service
baseImage:
- mcr.microsoft.com/devcontainers/base:debian
- mcr.microsoft.com/devcontainers/base:ubuntu
Expand All @@ -34,6 +35,7 @@ jobs:
matrix:
features:
- aem-sdk
- aem-universal-editor-service
steps:
- uses: actions/checkout@v3

Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
> You must have access to the AEM SDK. It is proprietary, and not distributed with the feature. This feature only facilitates setting up an author and publish server. Along with the dispatcher tools. See: [Developing AEM Inside a Dev Container](https://theaemmaven.com/post/developing-aem-inside-a-dev-container)
## `aem-repo-tool`
> Installs the [AEM repo tool](https://github.com/Adobe-Marketing-Cloud/tools/tree/master/repo).
> Installs the [AEM repo tool](https://github.com/Adobe-Marketing-Cloud/tools/tree/master/repo).
## `aem-universal-editor-service`
> Install a local Universal Editor Service. See: [Local AEM Development with the Universal Editor](https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/developing/universal-editor/local-dev)
5 changes: 1 addition & 4 deletions src/aem-repo-tool/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "aem-repo-tool",
"version": "1.0.0",
"version": "1.0.1",
"name": "Adobe Experience Manager Repo Tool",
"description": "Setup AEM repo tool, an FTP-like tool for JCR content.",
"options": {
Expand All @@ -13,8 +13,5 @@
"containerEnv": {
"AEM_REPO_TOOL_FEATURE_DIR": "/aem-repo-tool",
"PATH": "/aem-repo-tool:${PATH}"
},
"dependsOn": {
"ghcr.io/devcontainers/features/node:1": {}
}
}
4 changes: 3 additions & 1 deletion src/aem-sdk/NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
* Add the following feature to the `.devcontainer/devcontainer.json` file
```jsonc
"features": {
"ghcr.io/juan-ayala/devcontainer-features/aem-sdk:1": {}
"ghcr.io/juan-ayala/devcontainer-features/aem-sdk:1": {
"sdksDirectory": "${containerWorkspaceFolder}/.devcontainer"
}
}
```

Expand Down
36 changes: 36 additions & 0 deletions src/aem-universal-editor-service/NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Adding the Feature to a Project

## Pre-requisites
* Visual Studio Code
* Docker
* The AEM Universal Editor distribution

## Step 1: The Universal Editor Distribution
* [Download](https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/developing/universal-editor/local-dev#install-ue-service) the AEM Universal Editor form Adobe's [Software Distribuition](https://experience.adobe.com/#/downloads) Site.
* Place the ZIP archive in your project folder (i.e. `.devcontainer/universal-editor-service-vprod-20240912200213.zip)

## Step 2: The Devcontainer Settings
* Add the following feature to the `.devcontainer/devcontainer.json` file
```jsonc
"features": {
"ghcr.io/juan-ayala/devcontainer-features/aem-universal-editor-service:1": {
"uesDownloadsDirectory": "${containerWorkspaceFolder}/.devcontainer"
}
}
```

## Step 3: Visual Studio Code
* Install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). And open the project folder.
* VSCode will detect `.devcontainer/devcontainer.json`. And prompt you to reopen the project in a devcontainer.

## Run Universal Editor Service
In VSCode, open the terminal window. This is a terminal inside the docker container. You can run any command as needed, including Maven and Node.

There will be a script named `start-ues`.
* Start UES: `start-ues`

Once the service has started, verify you can get the core library. Make sure to accept the certificate errors for the self-signed certificate.
* https://localhost:8000/corslib/LATEST

## References
* [Local AEM Development with the Universal Editor](https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/developing/universal-editor/local-dev#install-ue-service)
36 changes: 36 additions & 0 deletions src/aem-universal-editor-service/bin/start-ues
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

source "${AEM_UES_FEATURE_DIR}/options.sh"

function ues_zip_not_found()
{
cat <<EOM
AEM Universal Editor Service zip not found.
uesDownloadsDirectory: '${AEM_UES_DOWNLOADS_DIR:-empty}'
uesVersion: '${AEM_UES_VERSION}'
EOM
exit 42
}

function get_ues_zip()
{
local searchdir="${AEM_UES_DOWNLOADS_DIR}"
[ ! -d ${searchdir} ] && return 1

local zip="${searchdir}/universal-editor-service-vprod-${AEM_UES_VERSION}.zip"
if [ "${AEM_UES_VERSION}" = "automatic" ]; then
zip="$(find ${searchdir} -maxdepth 1 -iname 'universal-editor-service-vprod-*.zip' -type f | sort -V | tail -n1)"
fi

[ ! -f "${zip}" ] && return 1 || echo "${zip}"
}

if [ ! -f "${AEM_UES_FEATURE_DIR}/universal-editor-service.cjs" ]; then
ueszip=$(get_ues_zip) || ues_zip_not_found
sudo unzip -d ${AEM_UES_FEATURE_DIR} ${ueszip}
fi

cd ${AEM_UES_FEATURE_DIR}
nvm install
nvm use
node universal-editor-service.cjs
30 changes: 30 additions & 0 deletions src/aem-universal-editor-service/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"id": "aem-universal-editor-service",
"version": "1.0.0",
"name": "Adobe Experience Manager Universal Editor Service",
"description": "Setup the AEM Universal Editor Service for local development.",
"options": {
"uesDownloadsDirectory": {
"type": "string",
"description": "Path to directory that contains one or more UES zip files downloaded from Adobe's Software Distribution.",
"default": ""
},
"uesVersion": {
"type": "string",
"description": "Universal Editor Service version.",
"default": "automatic"
},
"uesPort": {
"type": "string",
"description": "Universal Editor Service port.",
"default": "8000"
}
},
"containerEnv": {
"AEM_UES_FEATURE_DIR": "/aem-ues",
"PATH": "/aem-ues/bin:${PATH}"
},
"dependsOn": {
"ghcr.io/devcontainers/features/node:1": {}
}
}
29 changes: 29 additions & 0 deletions src/aem-universal-editor-service/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

# create the feature directory
mkdir -p ${AEM_UES_FEATURE_DIR}

# save feature properties
propertiesFile="${AEM_UES_FEATURE_DIR}/options.sh"
echo "AEM_UES_DOWNLOADS_DIR=\"${UESDOWNLOADSDIRECTORY}\"" >> ${propertiesFile}
echo "AEM_UES_VERSION=\"${UESVERSION:-'automatic'}\"" >> ${propertiesFile}
echo "AEM_UES_PORT=\"${UESPORT:-'8000'}\"" >> ${propertiesFile}
source ${propertiesFile}

# copy custom scripts
cp -r "$(dirname $0)/bin" ${AEM_UES_FEATURE_DIR}

# create .nvmrc file
echo "20" > "${AEM_UES_FEATURE_DIR}/.nvmrc"

# create ssl cert and private key
openssl req -newkey rsa:2048 -nodes -keyout "${AEM_UES_FEATURE_DIR}/key.pem" \
-x509 -days 365 -out "${AEM_UES_FEATURE_DIR}/certificate.pem" -subj '/CN=localhost'

# create .env file
envfile="${AEM_UES_FEATURE_DIR}/.env"
echo "UES_PORT=${AEM_UES_PORT}" >> "${envfile}"
echo "UES_PRIVATE_KEY=./key.pem" >> "${envfile}"
echo "UES_CERT=./certificate.pem" >> "${envfile}"
echo "UES_TLS_REJECT_UNAUTHORIZED=false" >> "${envfile}"

6 changes: 3 additions & 3 deletions test/aem-sdk/defaults-with-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ check "start-aem is +x" \
stat -c '%A' $(which start-aem) | grep 'x.*x.*x'
# Check that author/publish/dispatcher installs and starts
check "can install & run author" \
bash -c "start-aem author | grep 'hello, world'"
start-aem author | grep 'hello, world'
check "can install & run publish" \
bash -c "start-aem publish | grep 'hello, world'"
start-aem publish | grep 'hello, world'
check "can install & run dispatcher" \
bash -c "start-aem dispatcher | grep 'All your base are belong to us'"
start-aem dispatcher | grep 'All your base are belong to us'

reportResults
8 changes: 4 additions & 4 deletions test/aem-sdk/options-with-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ source dev-container-features-test-lib
# Check options file created with defaults
source ${AEM_SDK_FEATURE_DIR}/options.sh
check "sdks directory default" \
echo "${AEM_SDK_SDKS_DIRECTORY}" | grep -E "^/workspaces/[0-9]+/.devcontainer/sdksfolder$"
echo "${AEM_SDK_SDKS_DIRECTORY}" | grep -E "^/workspaces/[0-9]+/.devcontainer$"
check "sdk version default" \
[ "${AEM_SDK_VERSION}" = "mock-2024.02.01" ]
check "author port default" \
Expand All @@ -21,10 +21,10 @@ check "start-aem is +x" \
stat -c '%A' $(which start-aem) | grep 'x.*x.*x'
# Check that author/publish/dispatcher installs and starts
check "can install & run author" \
bash -c "start-aem author | grep 'hello, world'"
start-aem author | grep 'hello, world'
check "can install & run publish" \
bash -c "start-aem publish | grep 'hello, world'"
start-aem publish | grep 'hello, world'
check "can install & run dispatcher" \
bash -c "start-aem dispatcher | grep 'All your base are belong to us'"
start-aem dispatcher | grep 'All your base are belong to us'

reportResults
2 changes: 1 addition & 1 deletion test/aem-sdk/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"features": {
"ghcr.io/devcontainers/features/java:1": {},
"aem-sdk": {
"sdksDirectory": "${containerWorkspaceFolder}/.devcontainer/sdksfolder",
"sdksDirectory": "${containerWorkspaceFolder}/.devcontainer",
"sdkVersion": "mock-2024.02.01",
"authorPort": "3001",
"publishPort": "3002",
Expand Down
20 changes: 20 additions & 0 deletions test/aem-universal-editor-service/defaults-with-zip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -e

source dev-container-features-test-lib

# Check options file created with defaults
source ${AEM_UES_FEATURE_DIR}/options.sh
check "downloads directory set" \
echo "${AEM_UES_DOWNLOADS_DIR}" | grep -E "^/workspaces/[0-9]+/.devcontainer$"
check "ues version default" \
[ "${AEM_UES_VERSION}" = "automatic" ]
check "ues port default" \
[ "${AEM_UES_PORT}" = "8000" ]

# Check that ues installs and starts
check "can install & run ues" \
start-ues | grep "hello, world"

reportResults
Binary file not shown.
20 changes: 20 additions & 0 deletions test/aem-universal-editor-service/options-with-zip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -e

source dev-container-features-test-lib

# Check options file created with defaults
source ${AEM_UES_FEATURE_DIR}/options.sh
check "downloads directory set" \
echo "${AEM_UES_DOWNLOADS_DIR}" | grep -E "^/workspaces/[0-9]+/.devcontainer$"
check "ues version default" \
[ "${AEM_UES_VERSION}" = "mock-2024.02.01" ]
check "ues port default" \
[ "${AEM_UES_PORT}" = "9090" ]

# Check that ues installs and starts
check "can install & run ues" \
start-ues | grep "hello, world"

reportResults
Binary file not shown.
20 changes: 20 additions & 0 deletions test/aem-universal-editor-service/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"defaults-with-zip": {
"image": "mcr.microsoft.com/devcontainers/base:debian",
"features": {
"aem-universal-editor-service": {
"uesDownloadsDirectory": "${containerWorkspaceFolder}/.devcontainer"
}
}
},
"options-with-zip": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"aem-universal-editor-service": {
"uesDownloadsDirectory": "${containerWorkspaceFolder}/.devcontainer",
"uesVersion": "mock-2024.02.01",
"uesPort": "9090"
}
}
}
}
40 changes: 40 additions & 0 deletions test/aem-universal-editor-service/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
#
# To run this test only, add the --skip-scenarios flag.
#
# devcontainer features test \
# --features aem-universal-editor-service \
# --skip-scenarios \
# --base-image mcr.microsoft.com/devcontainers/base
#

set -e

# Optional: Import test library bundled with the devcontainer CLI
source dev-container-features-test-lib

# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib.

# Check options file created with defaults
source ${AEM_UES_FEATURE_DIR}/options.sh
check "downloads directory default" \
[ -z "${AEM_UES_DOWNLOADS_DIR}" ]
check "sdk version default" \
[ "${AEM_UES_VERSION}" = "automatic" ]
# Check start-ues in PATH is executable
check "start-ues is +x" \
stat -c '%A' $(which start-ues) | grep 'x.*x.*x'
# Check config files created
check "created .nvmrc" \
[ -f "${AEM_UES_FEATURE_DIR}/.nvmrc" ]
check "created key" \
[ -f "${AEM_UES_FEATURE_DIR}/key.pem" ]
check "created certificate" \
[ -f "${AEM_UES_FEATURE_DIR}/certificate.pem" ]
check "created .env" \
[ -f "${AEM_UES_FEATURE_DIR}/.env" ]

# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults

0 comments on commit 16142b5

Please sign in to comment.