-
Notifications
You must be signed in to change notification settings - Fork 9
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 #25 from adobe/lenaorobei-patch-3
Fix for preview URL
- Loading branch information
Showing
2 changed files
with
27 additions
and
6 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
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 | ||
} | ||
}; |