Skip to content

Commit

Permalink
Merge pull request #25 from adobe/lenaorobei-patch-3
Browse files Browse the repository at this point in the history
Fix for preview URL
  • Loading branch information
lenaorobei authored Apr 17, 2024
2 parents 9bd9645 + e6e9549 commit 62a346c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/aem-cf-admin-ui-ext-tpl",
"version": "2.0.0",
"version": "2.1.0",
"main": "src/index.js",
"description": "Extensibility template for AEM Content Fragment Admin Console",
"engines": {
Expand Down
31 changes: 26 additions & 5 deletions src/templates/hooks/post-deploy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
const chalk = require('chalk')
const chalk = require('chalk');
const fs = require('fs');
const yaml = require('js-yaml');

module.exports = (config) => {
console.log(chalk.magenta(chalk.bold('For a developer preview of your UI extension in the AEM environment, follow the URL:')))
const appUrl = `https://${config.ow.namespace}.${config.app.hostname}`
const base64EncodedUrl = Buffer.from(appUrl).toString('base64')
console.log(chalk.magenta(chalk.bold(` -> https://experience.adobe.com/aem/extension-manager/preview/${base64EncodedUrl}`)))
try {
// read the app.config.yaml file to get the extension points
const yamlFile = fs.readFileSync(`${config.root}/app.config.yaml`, 'utf8');
const yamlData = yaml.load(yamlFile);
const { extensions } = yamlData;

// For now we are ok just to read the first extension point to build the preview link
const extension = Object.keys(extensions)[0];
const previewData = {
extensionPoint: extension,
url: config.project.workspace.app_url,
};

// buid the preview URL
const base64EncodedData = Buffer.from(JSON.stringify(previewData)).toString('base64');
console.log(chalk.magenta(chalk.bold('For a developer preview of your UI extension in the AEM environment, follow the URL:')));

// check if the environment is stage, if so, we need to add the -stage suffix to the URL
const env = process.env.AIO_CLI_ENV === 'stage' ? '-stage' : '';
console.log(chalk.magenta(chalk.bold(` -> https://experience${env}.adobe.com/aem/extension-manager/preview/${base64EncodedData}`)));
} catch (error) {
// if something went wrong, we do nothing, and just don't display the URL
}
};

0 comments on commit 62a346c

Please sign in to comment.