Skip to content

Commit

Permalink
Merge pull request #18 from lenaorobei/SITES-17571
Browse files Browse the repository at this point in the history
SITES-17571: Update templates with extension preview
  • Loading branch information
lenaorobei authored Nov 28, 2023
2 parents ed8e0e9 + e8f3257 commit bb64b44
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 3 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": "1.0.0-beta.23",
"version": "1.0.0-beta.24",
"main": "src/index.js",
"description": "Extensibility template for AEM Content Fragment Admin Console",
"engines": {
Expand Down
7 changes: 7 additions & 0 deletions src/generator-add-web-assets-cf-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ class CFAdminWebAssetsGenerator extends Generator {
this.props
)

// Copy hooks folder
this.fs.copyTpl(
this.templatePath('./templates/hooks/*'),
this.destinationPath('./hooks')
)

// Generate App.js
this._generateAppRoute()

Expand All @@ -67,6 +73,7 @@ class CFAdminWebAssetsGenerator extends Generator {
'@adobe/uix-guest': '^0.8.0',
'@react-spectrum/list': '^3.0.0-rc.0',
'@spectrum-icons/workflow': '^3.2.0',
'chalk': '^4',
'core-js': '^3.6.4',
'node-fetch': '^2.6.0',
'node-html-parser': '^5.4.2-0',
Expand Down
7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ class MainGenerator extends Generator {

// add web-src path, relative to config file
utils.writeKeyYAMLConfig(this, this.extConfigPath, 'web', path.relative(this.extFolder, this.webSrcFolder))

// add hooks path
utils.writeKeyYAMLConfig(this, this.extConfigPath,
'hooks', {
'post-app-deploy': './hooks/post-deploy.js'
}
)
}

async conflicts () {
Expand Down
8 changes: 8 additions & 0 deletions src/templates/hooks/post-deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const chalk = require('chalk')

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}`)))
};
2 changes: 2 additions & 0 deletions test/generator-add-web-assets-cf-admin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ describe('run', () => {
'@adobe/uix-guest': expect.any(String),
'@react-spectrum/list': expect.any(String),
'@spectrum-icons/workflow': expect.any(String),
'chalk': expect.any(String),
'core-js': expect.any(String),
'node-fetch': expect.any(String),
'node-html-parser': expect.any(String),
Expand Down Expand Up @@ -191,6 +192,7 @@ describe('run', () => {
'@adobe/uix-guest': expect.any(String),
'@react-spectrum/list': expect.any(String),
'@spectrum-icons/workflow': expect.any(String),
'chalk': expect.any(String),
'core-js': expect.any(String),
'node-fetch': expect.any(String),
'node-html-parser': expect.any(String),
Expand Down
4 changes: 2 additions & 2 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('run', () => {
expect.any(Object)
)
expect(writeKeyAppConfig).toHaveBeenCalledTimes(1)
expect(writeKeyYAMLConfig).toHaveBeenCalledTimes(3)
expect(writeKeyYAMLConfig).toHaveBeenCalledTimes(4)
expect(writeKeyAppConfig).toHaveBeenCalledWith(expect.any(CFAdminMainGenerator), `extensions.${configName}`, { $include: `${srcFolder}/${extConfig}` })
expect(writeKeyYAMLConfig).toHaveBeenCalledWith(expect.any(CFAdminMainGenerator), global.n(`${srcFolder}/${extConfig}`), 'operations', { view: [{ impl: 'index.html', type: 'web' }] })
expect(writeKeyYAMLConfig).toHaveBeenCalledWith(expect.any(CFAdminMainGenerator), global.n(`${srcFolder}/${extConfig}`), 'actions', 'actions')
Expand Down Expand Up @@ -86,7 +86,7 @@ describe('run', () => {
expect.any(Object)
)
expect(writeKeyAppConfig).toHaveBeenCalledTimes(1)
expect(writeKeyYAMLConfig).toHaveBeenCalledTimes(3)
expect(writeKeyYAMLConfig).toHaveBeenCalledTimes(4)
expect(writeKeyAppConfig).toHaveBeenCalledWith(expect.any(CFAdminMainGenerator), `extensions.${configName}`, { $include: `${srcFolder}/${extConfig}` })
expect(writeKeyYAMLConfig).toHaveBeenCalledWith(expect.any(CFAdminMainGenerator), global.n(`${srcFolder}/${extConfig}`), 'operations', { view: [{ impl: 'index.html', type: 'web' }] })
expect(writeKeyYAMLConfig).toHaveBeenCalledWith(expect.any(CFAdminMainGenerator), global.n(`${srcFolder}/${extConfig}`), 'actions', 'actions')
Expand Down

0 comments on commit bb64b44

Please sign in to comment.