Skip to content

Commit

Permalink
breaking change: extension registry support (#148)
Browse files Browse the repository at this point in the history
*  nui ext generator + new action gen
* asset compute and ff generator
* add blank generator
* support for default legacy generator
* integrate new config changes
* fix application generator
* cleanup skip-install
* fix extensions config naming
* node 10 => 14
* update extension names
* added changes for add action
* fixes for aio app add action
* fixes for add aaction & move delete to app plugin
* add webassets, delete webassets in app plugin
* add events
* expose via index.js
* support for relative path to config
* fix: shared lib relative path in shared lib test file
* fix: shared lib relative path in shared lib test file (#147)
* Ext Reg fixes: extension generator edits (#149)

1. change the e2e test file name from `{action}.e2e.js` to `{action}.e2e.test.js` (pattern matching for tests in jest)
2. add the `test` hook to dx-asset-compute for new `aio app test` functionality
3. `e2e` and `test` folders for now relative to where the actions folder is (as a sibling folder). For a --no-extensions application, it will be in the root of the project, for an extension, it is wherever the extension is installed, not the root.
4. `asset-compute` generator: change the test folder bulk copy location (from the root `test` folder to the new location) and remove the installation of the test script in `package.json`
5.  remove `base-app`  file `test/jest.setup.js` from `test` folder to root folder. If there were extensions installed, having this single file in the `test` folder doesn't make sense.

* worker opcode is apply (#150)
* fix: pass in runtime packagename to e2e test template (#152)
* Fix generator unit tests for ext reg changes (#153)
* Update generator CI/CD templates for ext reg (#155)
* Update generator CI/CD templates to use latest apps action Auth command to generate token
* Update CLI version to be 8.x.x
* Rename nui operation (#154)
* process => worker process

Co-authored-by: Moritz Raho <[email protected]>
Co-authored-by: Shazron Abdullah <[email protected]>
Co-authored-by: sandeep-paliwal <[email protected]>
Co-authored-by: Jesse MacFadyen <[email protected]>
  • Loading branch information
4 people authored Jul 28, 2021
1 parent f2ee2e2 commit f65601c
Show file tree
Hide file tree
Showing 59 changed files with 1,482 additions and 1,774 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
package-lock=false
tag-version-prefix=""
preid="next"
38 changes: 4 additions & 34 deletions generators/add-action/asset-compute/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,6 @@ class AssetComputeGenerator extends ActionGenerator {
devDependencies: {
'@adobe/aio-cli-plugin-asset-compute': '^1.4.1'
},
dotenvStub: {
label: 'please provide the following environment variables for the Asset Compute devtool. You can use AWS or Azure, not both:',
vars: [
'ASSET_COMPUTE_PRIVATE_KEY_FILE_PATH',
'S3_BUCKET',
'AWS_ACCESS_KEY_ID',
'AWS_SECRET_ACCESS_KEY',
'AWS_REGION',
'AZURE_STORAGE_ACCOUNT',
'AZURE_STORAGE_KEY',
'AZURE_STORAGE_CONTAINER_NAME'
]
},
actionManifestConfig: {
limits: {
concurrency: 10
Expand All @@ -60,31 +47,14 @@ class AssetComputeGenerator extends ActionGenerator {
}
})

// modify the package.json to contain the Asset Compute testing and development tools
const packagejsonPath = this.destinationPath('package.json')
const packagejsonContent = this.fs.readJSON(packagejsonPath)

// add asset compute worker-tests in packages.json scripts
if (!packagejsonContent.scripts) {
packagejsonContent.scripts = {}
packagejsonContent.scripts.test = 'adobe-asset-compute test-worker'
packagejsonContent.scripts['post-app-run'] = 'adobe-asset-compute devtool'
} else {
packagejsonContent.scripts['post-app-run'] = 'adobe-asset-compute devtool'
if (packagejsonContent.scripts.test && !packagejsonContent.scripts.test.includes('adobe-asset-compute test-worker')) {
packagejsonContent.scripts.test = packagejsonContent.scripts.test.concat(' && adobe-asset-compute test-worker')
} else {
packagejsonContent.scripts.test = 'adobe-asset-compute test-worker'
}
}
this.fs.writeJSON(packagejsonPath, packagejsonContent)
const testsFilePath = this.destinationPath('test', 'asset-compute', this.props.actionName)
this.fs.delete(this.destinationPath('test/jest.setup.js')) // remove jest test setup since Asset Compute workers do not use jest
const extFolder = path.dirname(this.configPath)

// TODO add support in ActionGenerator for copying test folders instead of files
const destTestFolder = this.destinationPath(extFolder, 'test')
const workerTemplateTestFiles = `${this.templatePath()}/test/` // copy the rest of the worker template files
this.fs.copyTpl(
workerTemplateTestFiles,
testsFilePath,
destTestFolder,
this.props
)
}
Expand Down
20 changes: 10 additions & 10 deletions generators/add-action/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,17 @@ class AddActions extends Generator {
constructor (args, opts) {
super(args, opts)

// required
this.option('action-folder', { type: String })
this.option('config-path', { type: String })
this.option('full-key-to-manifest', { type: String, default: '' }) // key in config path that resolves to manifest e.g. 'application.runtimeManifest'

// options are inputs from CLI or yeoman parent generator
this.option('skip-prompt', { default: false })
this.option('skip-install', { type: String, default: false })
/// Adobe services added to the Console Workspace
this.option('adobe-services', { type: String, default: '' })
/// Adobe services that are supported by the Org
this.option('supported-adobe-services', { type: String, default: '' })
// todo throw meaningful error if add actions in a non existing project, but what defines a project?
}

async prompting () {
Expand Down Expand Up @@ -89,16 +92,13 @@ class AddActions extends Generator {

// run selected generators
actionGenerators.forEach(gen => this.composeWith(gen, {
'skip-prompt': this.options['skip-prompt']
// forward needed args
'skip-prompt': this.options['skip-prompt'],
'action-folder': this.options['action-folder'],
'config-path': this.options['config-path'],
'full-key-to-manifest': this.options['full-key-to-manifest']
}))
}

async install () {
// this condition makes sure it doesn't print any unwanted 'skip install message' into parent generator
if (!this.options['skip-install']) {
return this.installDependencies({ bower: false })
}
}
}

/**
Expand Down
17 changes: 14 additions & 3 deletions generators/add-ci/.github/workflows/deploy_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,30 @@ jobs:
uses: adobe/[email protected]
with:
os: ${{ matrix.os }}
version: 7.x.x
version: 8.x.x
- name: Build
env:
AIO_RUNTIME_NAMESPACE: ${{ secrets.AIO_RUNTIME_NAMESPACE_PROD }}
uses: adobe/aio-apps-action@1.1.0
uses: adobe/aio-apps-action@2.0.0
with:
os: ${{ matrix.os }}
command: build
- name: Auth
uses: adobe/[email protected]
with:
os: ${{ matrix.os }}
command: auth
CLIENTID: ${{ secrets.CLIENTID_PROD }}
CLIENTSECRET: ${{ secrets.CLIENTSECRET_PROD }}
TECHNICALACCOUNTID: ${{ secrets.TECHNICALACCID_PROD }}
IMSORGID: ${{ secrets.IMSORGID_PROD }}
SCOPES: ${{ secrets.SCOPES_PROD }}
KEY: ${{ secrets.KEY_PROD }}
- name: Deploy
env:
AIO_RUNTIME_NAMESPACE: ${{ secrets.AIO_RUNTIME_NAMESPACE_PROD }}
AIO_RUNTIME_AUTH: ${{ secrets.AIO_RUNTIME_AUTH_PROD }}
uses: adobe/aio-apps-action@1.1.0
uses: adobe/aio-apps-action@2.0.0
with:
os: ${{ matrix.os }}
command: deploy
17 changes: 14 additions & 3 deletions generators/add-ci/.github/workflows/deploy_stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,30 @@ jobs:
uses: adobe/[email protected]
with:
os: ${{ matrix.os }}
version: 7.x.x
version: 8.x.x
- name: Build
env:
AIO_RUNTIME_NAMESPACE: ${{ secrets.AIO_RUNTIME_NAMESPACE_STAGE }}
uses: adobe/aio-apps-action@1.1.0
uses: adobe/aio-apps-action@2.0.0
with:
os: ${{ matrix.os }}
command: build
- name: Auth
uses: adobe/[email protected]
with:
os: ${{ matrix.os }}
command: auth
CLIENTID: ${{ secrets.CLIENTID_STAGE }}
CLIENTSECRET: ${{ secrets.CLIENTSECRET_STAGE }}
TECHNICALACCOUNTID: ${{ secrets.TECHNICALACCID_STAGE }}
IMSORGID: ${{ secrets.IMSORGID_STAGE }}
SCOPES: ${{ secrets.SCOPES_STAGE }}
KEY: ${{ secrets.KEY_STAGE }}
- name: Deploy
env:
AIO_RUNTIME_NAMESPACE: ${{ secrets.AIO_RUNTIME_NAMESPACE_STAGE }}
AIO_RUNTIME_AUTH: ${{ secrets.AIO_RUNTIME_AUTH_STAGE }}
uses: adobe/aio-apps-action@1.1.0
uses: adobe/aio-apps-action@2.0.0
with:
os: ${{ matrix.os }}
command: deploy
6 changes: 3 additions & 3 deletions generators/add-ci/.github/workflows/pr_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ jobs:
uses: adobe/[email protected]
with:
os: ${{ matrix.os }}
version: 7.x.x
version: 8.x.x
- name: Build
env:
AIO_RUNTIME_NAMESPACE: ${{ secrets.AIO_RUNTIME_NAMESPACE_STAGE }}
uses: adobe/aio-apps-action@1.1.0
uses: adobe/aio-apps-action@2.0.0
with:
os: ${{ matrix.os }}
command: build
- name: Test
uses: adobe/aio-apps-action@1.1.0
uses: adobe/aio-apps-action@2.0.0
with:
os: ${{ matrix.os }}
command: test
4 changes: 2 additions & 2 deletions generators/add-ci/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ governing permissions and limitations under the License.
*/

const path = require('path')
const ActionGenerator = require('../../lib/ActionGenerator')
const Generator = require('yeoman-generator')
const { ciDirName } = require('../../lib/constants')

class CIGenerator extends ActionGenerator {
class CIGenerator extends Generator {
constructor (args, opts) {
super(args, opts)
this.props = {}
Expand Down
19 changes: 6 additions & 13 deletions generators/add-events/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ class AddEvents extends Generator {
constructor (args, opts) {
super(args, opts)

// options are inputs from CLI or yeoman parent generator
this.option('skip-prompt', { default: false })
this.option('skip-install', { type: String, default: false })

// todo throw meaningful error if add actions in a non existing project, but what defines a project?
// options to be forwarded to publish events action generator
this.option('skip-prompt', { default: false }) // prompt to ask action name
// required
this.option('action-folder', { type: String })
this.option('config-path', { type: String })
this.option('full-key-to-manifest', { type: String, default: '' }) // key in config path that resolves to manifest e.g. 'application.runtimeManifest'
}

async prompting () {
Expand Down Expand Up @@ -62,14 +63,6 @@ class AddEvents extends Generator {
// run action generators
this.composeWith(eventGenerator, this.options)
}

async install () {
// this condition makes sure it doesn't print any unwanted 'skip install message' into parent generator
if (!this.options['skip-install']) {
return this.installDependencies(
{ bower: false })
}
}
}

module.exports = AddEvents
45 changes: 26 additions & 19 deletions generators/add-vscode-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,37 +62,44 @@ class AddVsCodeConfig extends Generator {
}

_verifyConfig () {
const appConfig = this.options[Option.APP_CONFIG]
const _throwOnMissingKeys = function (requiredKeys, obj) {
function getMissingKeys (config, keys) {
const missingKeys = []
requiredKeys.forEach(key => {
if (objGetValue(obj, key) === undefined) {
keys.forEach(key => {
if (objGetValue(appConfig, key) === undefined) {
missingKeys.push(key)
}
})

if (missingKeys.length > 0) {
throw new Error(`App config missing keys: ${missingKeys.join(', ')}`)
}
return missingKeys
}
const verifyKeys = [

const appConfig = this.options[Option.APP_CONFIG]
const verifyKeysCommon = [
'app.hasFrontend',
'app.hasBackend',
'ow.package',
'ow.apihost',
'web.src',
'web.distDev',
'root'
]

_throwOnMissingKeys(verifyKeys, appConfig)
const verifyKeysFrontend = [
'web.src',
'web.distDev'
]

const verifyKeysBackend = [
'ow.package',
'ow.apihost',
'manifest.packagePlaceholder',
'manifest.full.packages'
]

const missingKeys = getMissingKeys(appConfig, verifyKeysCommon)
if (appConfig.app.hasFrontend) {
missingKeys.push(...getMissingKeys(appConfig, verifyKeysFrontend))
}
if (appConfig.app.hasBackend) {
const requiredBackendKeys = [
'manifest.packagePlaceholder',
'manifest.full.packages'
]
_throwOnMissingKeys(requiredBackendKeys, appConfig)
missingKeys.push(...getMissingKeys(appConfig, verifyKeysBackend))
}
if (missingKeys.length > 0) {
throw new Error(`App config missing keys: ${missingKeys.join(', ')}`)
}

const envFile = this.options[Option.ENV_FILE]
Expand Down
28 changes: 7 additions & 21 deletions generators/add-web-assets/exc-react/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,34 @@ const path = require('path')
const Generator = require('yeoman-generator')

const utils = require('../../../lib/utils')
const { webAssetsDirname } = require('../../../lib/constants')
const { sdkCodes } = require('../../../lib/constants')

class ExcReactGenerator extends Generator {
constructor (args, opts) {
super(args, opts)
// todo check that those are set
this.option('adobe-services', { type: String, default: '' })
this.option('project-name', { type: String })
// required
this.option('web-src-folder', { type: String })
// this.option('skip-prompt', { default: false }) // useless for now
this.option('skip-install', { type: Boolean, default: false })
this.option('has-backend', { type: Boolean, default: true })
this.option('config-path', { type: String })

// props are used by templates
this.props = {}
this.props.adobeServices = this.options['adobe-services']
.split(',')
.map((x) => x.trim())
this.props.projectName = this.options['project-name']
this.props.sdkCodes = sdkCodes
this.props.hasBackend = this.options['has-backend']
this.props.projectName = utils.readPackageJson(this).name
}

// nothing for now
// async prompting () {}

writing () {
const destFolder = this.options['web-src-folder']
this.sourceRoot(path.join(__dirname, './templates/'))

this.fs.copyTpl(
this.templatePath('./**/*'),
this.destinationPath(webAssetsDirname),
this.destinationPath(destFolder),
this.props
)
// add .babelrc
/// NOTE this is a global file and might conflict
this.fs.writeJSON(this.destinationPath('.babelrc'), {
presets: [['@babel/preset-env', { targets: { node: 'current' } }]],
plugins: ['@babel/plugin-transform-react-jsx']
Expand Down Expand Up @@ -75,13 +68,6 @@ class ExcReactGenerator extends Generator {
true
)
}

async install () {
// this condition makes sure it doesn't print any unwanted 'skip install message'
if (!this.options['skip-install']) {
return this.installDependencies({ bower: false, skipMessage: true })
}
}
}

module.exports = ExcReactGenerator
2 changes: 1 addition & 1 deletion generators/add-web-assets/exc-react/templates/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ governing permissions and limitations under the License.
import 'core-js/stable'
import 'regenerator-runtime/runtime'

import React from 'react'
window.React = require('react')

This comment has been minimized.

Copy link
@icaraps

icaraps Aug 30, 2021

Contributor

Why is React set on window ?

import ReactDOM from 'react-dom'

import Runtime, { init } from '@adobe/exc-app'
Expand Down
Loading

0 comments on commit f65601c

Please sign in to comment.