diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index da1e23c..ece27a5 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -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 @@ -34,6 +35,7 @@ jobs: matrix: features: - aem-sdk + - aem-universal-editor-service steps: - uses: actions/checkout@v3 diff --git a/README.md b/README.md index 2501545..28133f2 100644 --- a/README.md +++ b/README.md @@ -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). \ No newline at end of file +> 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) \ No newline at end of file diff --git a/src/aem-repo-tool/devcontainer-feature.json b/src/aem-repo-tool/devcontainer-feature.json index cf2ab07..33e74d7 100644 --- a/src/aem-repo-tool/devcontainer-feature.json +++ b/src/aem-repo-tool/devcontainer-feature.json @@ -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": { @@ -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": {} } } diff --git a/src/aem-sdk/NOTES.md b/src/aem-sdk/NOTES.md index 7d2bcc9..11775e6 100644 --- a/src/aem-sdk/NOTES.md +++ b/src/aem-sdk/NOTES.md @@ -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" + } } ``` diff --git a/src/aem-universal-editor-service/NOTES.md b/src/aem-universal-editor-service/NOTES.md new file mode 100644 index 0000000..b687b28 --- /dev/null +++ b/src/aem-universal-editor-service/NOTES.md @@ -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) \ No newline at end of file diff --git a/src/aem-universal-editor-service/bin/start-ues b/src/aem-universal-editor-service/bin/start-ues new file mode 100644 index 0000000..541e6af --- /dev/null +++ b/src/aem-universal-editor-service/bin/start-ues @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +source "${AEM_UES_FEATURE_DIR}/options.sh" + +function ues_zip_not_found() +{ + cat <> ${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}" + diff --git a/test/aem-sdk/defaults-with-sdk.sh b/test/aem-sdk/defaults-with-sdk.sh index 67d7d09..ac0a955 100644 --- a/test/aem-sdk/defaults-with-sdk.sh +++ b/test/aem-sdk/defaults-with-sdk.sh @@ -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 diff --git a/test/aem-sdk/options-with-sdk.sh b/test/aem-sdk/options-with-sdk.sh index 36e8f9c..c4e8c98 100644 --- a/test/aem-sdk/options-with-sdk.sh +++ b/test/aem-sdk/options-with-sdk.sh @@ -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" \ @@ -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 diff --git a/test/aem-sdk/options-with-sdk/sdksfolder/aem-sdk-mock-2024.01.01.zip b/test/aem-sdk/options-with-sdk/aem-sdk-mock-2024.01.01.zip similarity index 100% rename from test/aem-sdk/options-with-sdk/sdksfolder/aem-sdk-mock-2024.01.01.zip rename to test/aem-sdk/options-with-sdk/aem-sdk-mock-2024.01.01.zip diff --git a/test/aem-sdk/options-with-sdk/sdksfolder/aem-sdk-mock-2024.02.01.zip b/test/aem-sdk/options-with-sdk/aem-sdk-mock-2024.02.01.zip similarity index 100% rename from test/aem-sdk/options-with-sdk/sdksfolder/aem-sdk-mock-2024.02.01.zip rename to test/aem-sdk/options-with-sdk/aem-sdk-mock-2024.02.01.zip diff --git a/test/aem-sdk/options-with-sdk/sdksfolder/aem-sdk-mock-2024.03.01.zip b/test/aem-sdk/options-with-sdk/aem-sdk-mock-2024.03.01.zip similarity index 100% rename from test/aem-sdk/options-with-sdk/sdksfolder/aem-sdk-mock-2024.03.01.zip rename to test/aem-sdk/options-with-sdk/aem-sdk-mock-2024.03.01.zip diff --git a/test/aem-sdk/scenarios.json b/test/aem-sdk/scenarios.json index c62ca76..1863235 100644 --- a/test/aem-sdk/scenarios.json +++ b/test/aem-sdk/scenarios.json @@ -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", diff --git a/test/aem-universal-editor-service/defaults-with-zip.sh b/test/aem-universal-editor-service/defaults-with-zip.sh new file mode 100644 index 0000000..1a7e262 --- /dev/null +++ b/test/aem-universal-editor-service/defaults-with-zip.sh @@ -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 diff --git a/test/aem-universal-editor-service/defaults-with-zip/universal-editor-service-vprod-mock.zip b/test/aem-universal-editor-service/defaults-with-zip/universal-editor-service-vprod-mock.zip new file mode 100644 index 0000000..3742873 Binary files /dev/null and b/test/aem-universal-editor-service/defaults-with-zip/universal-editor-service-vprod-mock.zip differ diff --git a/test/aem-universal-editor-service/options-with-zip.sh b/test/aem-universal-editor-service/options-with-zip.sh new file mode 100644 index 0000000..d4bb346 --- /dev/null +++ b/test/aem-universal-editor-service/options-with-zip.sh @@ -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 diff --git a/test/aem-universal-editor-service/options-with-zip/universal-editor-service-vprod-mock-2024.01.01.zip b/test/aem-universal-editor-service/options-with-zip/universal-editor-service-vprod-mock-2024.01.01.zip new file mode 100644 index 0000000..e69de29 diff --git a/test/aem-universal-editor-service/options-with-zip/universal-editor-service-vprod-mock-2024.02.01.zip b/test/aem-universal-editor-service/options-with-zip/universal-editor-service-vprod-mock-2024.02.01.zip new file mode 100644 index 0000000..3742873 Binary files /dev/null and b/test/aem-universal-editor-service/options-with-zip/universal-editor-service-vprod-mock-2024.02.01.zip differ diff --git a/test/aem-universal-editor-service/options-with-zip/universal-editor-service-vprod-mock-2024.03.01.zip b/test/aem-universal-editor-service/options-with-zip/universal-editor-service-vprod-mock-2024.03.01.zip new file mode 100644 index 0000000..e69de29 diff --git a/test/aem-universal-editor-service/scenarios.json b/test/aem-universal-editor-service/scenarios.json new file mode 100644 index 0000000..a778b88 --- /dev/null +++ b/test/aem-universal-editor-service/scenarios.json @@ -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" + } + } + } +} diff --git a/test/aem-universal-editor-service/test.sh b/test/aem-universal-editor-service/test.sh new file mode 100644 index 0000000..68959fe --- /dev/null +++ b/test/aem-universal-editor-service/test.sh @@ -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