Skip to content

Commit

Permalink
Merge pull request #26 from adobe/feature/metadata
Browse files Browse the repository at this point in the history
Add metadata generation hooks and metadata registration
  • Loading branch information
nitinja authored Jun 28, 2024
2 parents 62a346c + 2fcb3da commit e248edc
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 117 deletions.
16 changes: 14 additions & 2 deletions src/generator-add-web-assets-cf-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,16 @@ class CFAdminWebAssetsGenerator extends Generator {
this.fs.writeJSON(this.destinationPath('.babelrc'), {
plugins: ['@babel/plugin-transform-react-jsx']
})

//generate default metadata
this.fs.writeJSON('src/app-metadata.json', {});

// add dependencies
utils.addDependencies(this, {
'@adobe/aio-sdk': commonDependencyVersions['@adobe/aio-sdk'],
'@adobe/exc-app': '^0.2.21',
'@adobe/react-spectrum': '^3.4.0',
'@adobe/uix-guest': '^0.8.0',
'@adobe/uix-guest': '^0.10.3',
'@react-spectrum/list': '^3.0.0-rc.0',
'@spectrum-icons/workflow': '^3.2.0',
'chalk': '^4',
Expand All @@ -81,7 +85,9 @@ class CFAdminWebAssetsGenerator extends Generator {
'react-dom': '^16.13.1',
'react-error-boundary': '^1.2.5',
'react-router-dom': '^6.3.0',
'regenerator-runtime': '^0.13.5'
'regenerator-runtime': '^0.13.5',
"ajv": "^8.12.0",
"js-yaml": "^4.1.0"
})
utils.addDependencies(
this,
Expand All @@ -95,6 +101,12 @@ class CFAdminWebAssetsGenerator extends Generator {
},
true
)
utils.addPkgScript(
this,
{
"transform:yaml-to-json": "node node_modules/@adobe/uix-guest/scripts/generate-metadata.js"
}
)
}

_generateAppRoute() {
Expand Down
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class MainGenerator extends Generator {
}

async writing () {
//generate default metadata
this.fs.writeJSON('src/app-metadata.json', {});

// generate the generic action
if (this.extensionManifest.runtimeActions) {
this.extensionManifest.runtimeActions.forEach((action) => {
Expand Down Expand Up @@ -139,6 +142,8 @@ class MainGenerator extends Generator {
// add hooks path
utils.writeKeyYAMLConfig(this, this.extConfigPath,
'hooks', {
'pre-app-run': 'node node_modules/@adobe/uix-guest/scripts/generate-metadata.js',
'pre-app-build': 'node node_modules/@adobe/uix-guest/scripts/generate-metadata.js',
'post-app-deploy': './hooks/post-deploy.js'
}
)
Expand Down
2 changes: 2 additions & 0 deletions src/templates/_shared/stub-extension-registration.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import { generatePath } from "react-router";
import { Text } from "@adobe/react-spectrum";
import { register } from "@adobe/uix-guest";
import { extensionId } from "./Constants";
import metadata from '../../../../app-metadata.json';

function ExtensionRegistration() {
const init = async () => {
const guestConnection = await register({
id: extensionId,
metadata,
methods: {
<%_ if (extensionManifest.actionBarButtons || extensionManifest.headerMenuButtons) { -%>
<%_ if (extensionManifest.actionBarButtons) { -%>
Expand Down
Loading

0 comments on commit e248edc

Please sign in to comment.