generated from devcontainers/feature-starter
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from juan-ayala/feature/aem-universal-editor-s…
…ervice [aem-universal-editor-service] added UES feature for local development
- Loading branch information
Showing
22 changed files
with
249 additions
and
14 deletions.
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
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 |
---|---|---|
@@ -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) |
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,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
30
src/aem-universal-editor-service/devcontainer-feature.json
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,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": {} | ||
} | ||
} |
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,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}" | ||
|
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
File renamed without changes.
File renamed without changes.
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
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,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 added
BIN
+235 Bytes
test/aem-universal-editor-service/defaults-with-zip/universal-editor-service-vprod-mock.zip
Binary file not shown.
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,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 |
Empty file.
Binary file added
BIN
+235 Bytes
...versal-editor-service/options-with-zip/universal-editor-service-vprod-mock-2024.02.01.zip
Binary file not shown.
Empty file.
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,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" | ||
} | ||
} | ||
} | ||
} |
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,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 |