Skip to content

Commit

Permalink
Merge branch 'master' into remove-delete-ci-generator
Browse files Browse the repository at this point in the history
  • Loading branch information
shazron authored Sep 14, 2022
2 parents 94076c1 + 21266af commit d16f168
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 77 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Two types of generators can be easily contributed to the project:
- add template files into `generators/add-action/<generator-name>/templates/`
- update `generators/add-action/index.js` to reference the newly added generator in the prompt choices.

- web assets generators, e.g. [experience cloud shell react generator](./generators/add-web-assets/exc-react/index.js):
- web assets generators, e.g. [experience cloud shell react generator](https://github.com/adobe/generator-app-excshell/blob/main/index.js):

- add a new web assets template generator into `generators/add-web-assets/<generator-name>/index.js`.
- add template files into `generators/add-web-assets/<generator-name>/templates/`
Expand Down
25 changes: 14 additions & 11 deletions generators/application/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,22 @@ class Application extends Generator {
this.webSrcFolder = path.join(this.appFolder, 'web-src')
this.configPath = path.join(this.appFolder, 'app.config.yaml')
this.keyToManifest = 'application.' + runtimeManifestKey
this.components = ['actions', 'events', 'webAssets'] // defaults when skip prompt
}

async writing () {
// add basic config to point to path, relative to config file
utils.writeKeyAppConfig(this, 'application.actions', path.relative(this.appFolder, this.actionFolder))
utils.writeKeyAppConfig(this, 'application.web', path.relative(this.appFolder, this.webSrcFolder))
// add path to actions in app.config.yaml
if (this.components.includes('actions')) {
utils.writeKeyAppConfig(this, 'application.actions', path.relative(this.appFolder, this.actionFolder))
}

// add path to web assets in app.config.yaml
if (this.components.includes('webAssets')) {
utils.writeKeyAppConfig(this, 'application.web', path.relative(this.appFolder, this.webSrcFolder))
}
}

async composeWithAddGenerators () {
let components = ['actions', 'events', 'webAssets'] // defaults when skip prompt
if (!this.options['skip-prompt']) {
const res = await this.prompt([
{
Expand Down Expand Up @@ -81,15 +87,12 @@ class Application extends Generator {
validate: utils.atLeastOne
}
])
components = res.components
this.components = res.components
}
const addActions = components.includes('actions')
const addEvents = components.includes('events')
const addWebAssets = components.includes('webAssets')

// TODO cleanup unecessary params in all generators
// run add action and add ui generators when applicable
if (addActions) {
if (this.components.includes('actions')) {
this.composeWith(path.join(__dirname, '../add-action/index.js'), {
'skip-prompt': this.options['skip-prompt'],
'adobe-services': this.options['adobe-services'],
Expand All @@ -99,7 +102,7 @@ class Application extends Generator {
'full-key-to-manifest': this.keyToManifest
})
}
if (addEvents) {
if (this.components.includes('events')) {
this.composeWith(path.join(__dirname, '../add-events/index.js'), {
'skip-prompt': this.options['skip-prompt'],
'adobe-services': this.options['adobe-services'],
Expand All @@ -108,7 +111,7 @@ class Application extends Generator {
'full-key-to-manifest': this.keyToManifest
})
}
if (addWebAssets) {
if (this.components.includes('webAssets')) {
this.composeWith(path.join(__dirname, '../add-web-assets/index.js'), {
'skip-prompt': this.options['skip-prompt'],
'adobe-services': this.options['adobe-services'],
Expand Down
18 changes: 7 additions & 11 deletions generators/base-app/templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,26 @@ You can generate this file using the command `aio app use`.
# AIO_RUNTIME_NAMESPACE=
```

### `manifest.yml`
### `app.config.yaml`

- List your backend actions under the `actions` field within the `__APP_PACKAGE__`
package placeholder. We will take care of replacing the package name placeholder
by your project name and version.
- For each action, use the `function` field to indicate the path to the action
code.
- More documentation for supported action fields can be found
[here](https://github.com/apache/incubator-openwhisk-wskdeploy/blob/master/specification/html/spec_actions.md#actions).
- Main configuration file that defines an application's implementation.
- More information on this file, application configuration, and extension configuration
can be found [here](https://developer.adobe.com/app-builder/docs/guides/appbuilder-configuration/#appconfigyaml)

#### Action Dependencies

- You have two options to resolve your actions' dependencies:

1. **Packaged action file**: Add your action's dependencies to the root
`package.json` and install them using `npm install`. Then set the `function`
field in `manifest.yml` to point to the **entry file** of your action
folder. We will use `parcelJS` to package your code and dependencies into a
field in `app.config.yaml` to point to the **entry file** of your action
folder. We will use `webpack` to package your code and dependencies into a
single minified js file. The action will then be deployed as a single file.
Use this method if you want to reduce the size of your actions.

2. **Zipped action folder**: In the folder containing the action code add a
`package.json` with the action's dependencies. Then set the `function`
field in `manifest.yml` to point to the **folder** of that action. We will
field in `app.config.yaml` to point to the **folder** of that action. We will
install the required dependencies within that directory and zip the folder
before deploying it as a zipped action. Use this method if you want to keep
your action's dependencies separated.
Expand Down
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/generator-aio-app",
"version": "3.1.1",
"version": "4.0.1",
"description": "Adobe I/O application yeoman code generator",
"main": "generators/index.js",
"scripts": {
Expand Down Expand Up @@ -28,35 +28,35 @@
},
"homepage": "https://github.com/adobe/generator-aio-app#readme",
"devDependencies": {
"@types/jest": "^25.1.0",
"@types/jest": "^28",
"eol": "^0.9.1",
"eslint": "^7.1.0",
"eslint-config-standard": "^14.1.0",
"eslint": "^8",
"eslint-config-standard": "^17",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-jest": "^23.1.1",
"eslint-plugin-jest": "^26",
"eslint-plugin-n": "^15.2.5",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"jest": "^27",
"eslint-plugin-promise": "^6",
"jest": "^28",
"stdout-stderr": "^0.1.13",
"yeoman-assert": "^3.1.1",
"yeoman-environment": "^3.2.0",
"yeoman-test": "^6.0.0"
},
"dependencies": {
"@adobe/aio-lib-env": "^1.1.0",
"@adobe/aio-lib-env": "^2.0.0",
"@adobe/generator-add-action-asset-compute": "^0.2.1",
"@adobe/generator-add-action-generic": "^0.2.2",
"@adobe/generator-add-web-assets-exc-raw-html": "^0.2.1",
"@adobe/generator-add-web-assets-exc-react": "^0.2.1",
"@adobe/generator-app-asset-compute": "^0.2.0",
"@adobe/generator-app-common-lib": "^0.3.0",
"@adobe/generator-app-common-lib": "^0.3.3",
"@adobe/generator-app-excshell": "^0.2.0",
"fs-extra": "^9.0.0",
"inquirer": "^8.2.0",
"js-yaml": "^3.14.0",
"fs-extra": "^10.0.0",
"inquirer": "^8",
"js-yaml": "^4",
"lodash.clonedeep": "^4.5.0",
"upath": "^1.2.0",
"yeoman-generator": "^5.4.0"
"upath": "^2.0.1",
"yeoman-generator": "^5.7.0"
}
}
10 changes: 5 additions & 5 deletions test/generators/add-action/analytics.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function assertGeneratedFiles (actionName) {

// pkgName is optional
function assertManifestContent (actionName, pkgName) {
const json = yaml.safeLoad(fs.readFileSync('ext.config.yaml').toString())
const json = yaml.load(fs.readFileSync('ext.config.yaml').toString())
expect(json.runtimeManifest.packages).toBeDefined()

// default packageName is path.basename(path.dirname('ext.config.yaml'))
Expand All @@ -53,7 +53,7 @@ function assertManifestContent (actionName, pkgName) {
expect(json.runtimeManifest.packages[pkgName].actions[actionName]).toEqual({
function: `${constants.actionsDirname}/${actionName}/index.js`,
web: 'yes',
runtime: 'nodejs:14',
runtime: constants.defaultRuntimeKind,
inputs: {
LOG_LEVEL: 'debug',
apiKey: '$SERVICE_API_KEY',
Expand Down Expand Up @@ -115,7 +115,7 @@ describe('run', () => {
assertManifestContent(actionName)
assertEnvContent(prevDotEnvContent)
assertDependencies(fs, { '@adobe/aio-sdk': expect.any(String) }, { '@openwhisk/wskdebug': expect.any(String) })
assertNodeEngines(fs, '^10 || ^12 || ^14')
assertNodeEngines(fs, constants.nodeEngines)
})

test('--skip-prompt, and action with default name already exists', async () => {
Expand Down Expand Up @@ -146,7 +146,7 @@ describe('run', () => {
assertManifestContent(actionName, 'somepackage')
assertEnvContent(prevDotEnvContent)
assertDependencies(fs, { '@adobe/aio-sdk': expect.any(String) }, { '@openwhisk/wskdebug': expect.any(String) })
assertNodeEngines(fs, '^10 || ^12 || ^14')
assertNodeEngines(fs, constants.nodeEngines)
})

test('user input actionName=fakeAction', async () => {
Expand All @@ -167,6 +167,6 @@ describe('run', () => {
assertManifestContent(actionName)
assertEnvContent(prevDotEnvContent)
assertDependencies(fs, { '@adobe/aio-sdk': expect.any(String) }, { '@openwhisk/wskdebug': expect.any(String) })
assertNodeEngines(fs, '^10 || ^12 || ^14')
assertNodeEngines(fs, constants.nodeEngines)
})
})
10 changes: 5 additions & 5 deletions test/generators/add-action/audience-manager-cd.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function assertGeneratedFiles (actionName) {

// pkgName is optional
function assertManifestContent (actionName, pkgName) {
const json = yaml.safeLoad(fs.readFileSync('ext.config.yaml').toString())
const json = yaml.load(fs.readFileSync('ext.config.yaml').toString())
expect(json.runtimeManifest.packages).toBeDefined()

// default packageName is path.basename(path.dirname('ext.config.yaml'))
Expand All @@ -50,7 +50,7 @@ function assertManifestContent (actionName, pkgName) {
expect(json.runtimeManifest.packages[pkgName].actions[actionName]).toEqual({
function: `${constants.actionsDirname}/${actionName}/index.js`,
web: 'yes',
runtime: 'nodejs:14',
runtime: constants.defaultRuntimeKind,
inputs: {
LOG_LEVEL: 'debug',
apiKey: '$SERVICE_API_KEY'
Expand Down Expand Up @@ -100,7 +100,7 @@ describe('run', () => {
assertActionCodeContent(actionName)
assertManifestContent(actionName)
assertDependencies(fs, { '@adobe/aio-sdk': expect.any(String) }, { '@openwhisk/wskdebug': expect.any(String) })
assertNodeEngines(fs, '^10 || ^12 || ^14')
assertNodeEngines(fs, constants.nodeEngines)
})

test('--skip-prompt, and action with default name already exists', async () => {
Expand Down Expand Up @@ -128,7 +128,7 @@ describe('run', () => {
assertActionCodeContent(actionName)
assertManifestContent(actionName, 'somepackage')
assertDependencies(fs, { '@adobe/aio-sdk': expect.any(String) }, { '@openwhisk/wskdebug': expect.any(String) })
assertNodeEngines(fs, '^10 || ^12 || ^14')
assertNodeEngines(fs, constants.nodeEngines)
})

test('user input actionName=fakeAction', async () => {
Expand All @@ -144,6 +144,6 @@ describe('run', () => {
assertActionCodeContent(actionName)
assertManifestContent(actionName)
assertDependencies(fs, { '@adobe/aio-sdk': expect.any(String) }, { '@openwhisk/wskdebug': expect.any(String) })
assertNodeEngines(fs, '^10 || ^12 || ^14')
assertNodeEngines(fs, constants.nodeEngines)
})
})
10 changes: 5 additions & 5 deletions test/generators/add-action/campaign-standard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function assertGeneratedFiles (actionName) {

// pkgName is optional
function assertManifestContent (actionName, pkgName) {
const json = yaml.safeLoad(fs.readFileSync('ext.config.yaml').toString())
const json = yaml.load(fs.readFileSync('ext.config.yaml').toString())
expect(json.runtimeManifest.packages).toBeDefined()

// default packageName is path.basename(path.dirname('ext.config.yaml'))
Expand All @@ -53,7 +53,7 @@ function assertManifestContent (actionName, pkgName) {
expect(json.runtimeManifest.packages[pkgName].actions[actionName]).toEqual({
function: `${constants.actionsDirname}/${actionName}/index.js`,
web: 'yes',
runtime: 'nodejs:14',
runtime: constants.defaultRuntimeKind,
inputs: {
LOG_LEVEL: 'debug',
apiKey: '$SERVICE_API_KEY',
Expand Down Expand Up @@ -115,7 +115,7 @@ describe('run', () => {
assertManifestContent(actionName)
assertEnvContent(prevDotEnvContent)
assertDependencies(fs, { '@adobe/aio-sdk': expect.any(String) }, { '@openwhisk/wskdebug': expect.any(String) })
assertNodeEngines(fs, '^10 || ^12 || ^14')
assertNodeEngines(fs, constants.nodeEngines)
})

test('--skip-prompt, and action with default name already exists', async () => {
Expand Down Expand Up @@ -146,7 +146,7 @@ describe('run', () => {
assertManifestContent(actionName, 'somepackage')
assertEnvContent(prevDotEnvContent)
assertDependencies(fs, { '@adobe/aio-sdk': expect.any(String) }, { '@openwhisk/wskdebug': expect.any(String) })
assertNodeEngines(fs, '^10 || ^12 || ^14')
assertNodeEngines(fs, constants.nodeEngines)
})

test('user input actionName=fakeAction', async () => {
Expand All @@ -167,6 +167,6 @@ describe('run', () => {
assertManifestContent(actionName)
assertEnvContent(prevDotEnvContent)
assertDependencies(fs, { '@adobe/aio-sdk': expect.any(String) }, { '@openwhisk/wskdebug': expect.any(String) })
assertNodeEngines(fs, '^10 || ^12 || ^14')
assertNodeEngines(fs, constants.nodeEngines)
})
})
10 changes: 5 additions & 5 deletions test/generators/add-action/customer-profile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function assertGeneratedFiles (actionName) {

// pkgName is optional
function assertManifestContent (actionName, pkgName) {
const json = yaml.safeLoad(fs.readFileSync('ext.config.yaml').toString())
const json = yaml.load(fs.readFileSync('ext.config.yaml').toString())
expect(json.runtimeManifest.packages).toBeDefined()

// default packageName is path.basename(path.dirname('ext.config.yaml'))
Expand All @@ -53,7 +53,7 @@ function assertManifestContent (actionName, pkgName) {
expect(json.runtimeManifest.packages[pkgName].actions[actionName]).toEqual({
function: `${constants.actionsDirname}/${actionName}/index.js`,
web: 'yes',
runtime: 'nodejs:14',
runtime: constants.defaultRuntimeKind,
inputs: {
LOG_LEVEL: 'debug',
tenant: '$CUSTOMER_PROFILE_TENANT',
Expand Down Expand Up @@ -122,7 +122,7 @@ describe('run', () => {
assertManifestContent(actionName)
assertEnvContent(prevDotEnvContent)
assertDependencies(fs, { '@adobe/aio-sdk': expect.any(String) }, { '@openwhisk/wskdebug': expect.any(String) })
assertNodeEngines(fs, '^10 || ^12 || ^14')
assertNodeEngines(fs, constants.nodeEngines)
})

test('--skip-prompt, and action with default name already exists', async () => {
Expand Down Expand Up @@ -153,7 +153,7 @@ describe('run', () => {
assertManifestContent(actionName, 'somepackage')
assertEnvContent(prevDotEnvContent)
assertDependencies(fs, { '@adobe/aio-sdk': expect.any(String) }, { '@openwhisk/wskdebug': expect.any(String) })
assertNodeEngines(fs, '^10 || ^12 || ^14')
assertNodeEngines(fs, constants.nodeEngines)
})

test('user input actionName=fakeAction', async () => {
Expand All @@ -174,6 +174,6 @@ describe('run', () => {
assertManifestContent(actionName)
assertEnvContent(prevDotEnvContent)
assertDependencies(fs, { '@adobe/aio-sdk': expect.any(String) }, { '@openwhisk/wskdebug': expect.any(String) })
assertNodeEngines(fs, '^10 || ^12 || ^14')
assertNodeEngines(fs, constants.nodeEngines)
})
})
10 changes: 5 additions & 5 deletions test/generators/add-action/target.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function assertGeneratedFiles (actionName) {

// pkgName is optional
function assertManifestContent (actionName, pkgName) {
const json = yaml.safeLoad(fs.readFileSync('ext.config.yaml').toString())
const json = yaml.load(fs.readFileSync('ext.config.yaml').toString())
expect(json.runtimeManifest.packages).toBeDefined()

// default packageName is path.basename(path.dirname('ext.config.yaml'))
Expand All @@ -53,7 +53,7 @@ function assertManifestContent (actionName, pkgName) {
expect(json.runtimeManifest.packages[pkgName].actions[actionName]).toEqual({
function: `${constants.actionsDirname}/${actionName}/index.js`,
web: 'yes',
runtime: 'nodejs:14',
runtime: constants.defaultRuntimeKind,
inputs: {
LOG_LEVEL: 'debug',
apiKey: '$SERVICE_API_KEY',
Expand Down Expand Up @@ -115,7 +115,7 @@ describe('run', () => {
assertManifestContent(actionName)
assertEnvContent(prevDotEnvContent)
assertDependencies(fs, { '@adobe/aio-sdk': expect.any(String) }, { '@openwhisk/wskdebug': expect.any(String) })
assertNodeEngines(fs, '^10 || ^12 || ^14')
assertNodeEngines(fs, constants.nodeEngines)
})

test('--skip-prompt, and action with default name already exists', async () => {
Expand Down Expand Up @@ -147,7 +147,7 @@ describe('run', () => {
assertManifestContent(actionName, 'somepackage')
assertEnvContent(prevDotEnvContent)
assertDependencies(fs, { '@adobe/aio-sdk': expect.any(String) }, { '@openwhisk/wskdebug': expect.any(String) })
assertNodeEngines(fs, '^10 || ^12 || ^14')
assertNodeEngines(fs, constants.nodeEngines)
})

test('user input actionName=fakeAction', async () => {
Expand All @@ -168,6 +168,6 @@ describe('run', () => {
assertManifestContent(actionName)
assertEnvContent(prevDotEnvContent)
assertDependencies(fs, { '@adobe/aio-sdk': expect.any(String) }, { '@openwhisk/wskdebug': expect.any(String) })
assertNodeEngines(fs, '^10 || ^12 || ^14')
assertNodeEngines(fs, constants.nodeEngines)
})
})
Loading

0 comments on commit d16f168

Please sign in to comment.