Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ governing permissions and limitations under the License.
const execa = require('execa')
const chalk = require('chalk')
const { stdout } = require('stdout-stderr')
const fs = require.requireActual('fs')
const fs = jest.requireActual('fs')

stdout.print = true

Expand Down
35 changes: 13 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@
"@adobe/aio-lib-core-config": "^2.0.0",
"@adobe/aio-lib-core-networking": "^2.0.0",
"@adobe/aio-lib-runtime": "^4.0.0",
"@oclif/command": "^1.5.6",
"@oclif/config": "^1.9.0",
"@oclif/errors": "^1.1.2",
"@oclif/plugin-help": "^2.1.6",
"@types/jest": "^26.0.10",
"chalk": "^4.0.0",
"cli-ux": "^5.2.0",
"@oclif/core": "^1.3.0",
"@types/jest": "^27.4.0",
"chalk": "^4.1.2",
"dayjs": "^1.10.4",
"debug": "^4.1.1",
"inquirer": "^7.3.3",
"inquirer": "^8.2.0",
"js-yaml": "^3.13.1",
"lodash.clonedeep": "^4.5.0",
"openwhisk": "^3.21.2",
Expand All @@ -31,23 +27,21 @@
"devDependencies": {
"@babel/core": "^7.16.12",
"@babel/preset-env": "^7.16.11",
"@oclif/dev-cli": "^1",
"@oclif/test": "^1",
"babel-jest": "^27.0.1",
"@oclif/test": "^1.2.8",
"babel-jest": "^27.5.0",
"babel-runtime": "^6.26.0",
"dedent-js": "^1.0.1",
"eol": "^0.9.1",
"eslint": "^6.0.0",
"eslint-config-oclif": "^3.1.0",
"eslint-config-standard": "^13.0.1",
"eslint": "^7.12.1",
"eslint-config-oclif": "^4.0.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jest": "^23.0.2",
"eslint-plugin-jest": "^26.1.0",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.0.0",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-promise": "^5.0.0",
"execa": "^4.0.0",
"jest": "^24.9.0",
"jest-junit": "^10.0.0",
"jest": "^27.5.0",
"jest-junit": "^13.0.0",
"jest-plugin-fs": "^2.9.0",
"stdout-stderr": "^0.1.9"
},
Expand All @@ -66,9 +60,6 @@
"oclif": {
"commands": "./src/commands",
"bin": "aio",
"devPlugins": [
"@oclif/plugin-help"
],
"repositoryPrefix": "<%- repo %>/blob/<%- version %>/<%- commandPath %>"
},
"repository": "adobe/aio-cli-plugin-runtime",
Expand Down
28 changes: 14 additions & 14 deletions src/RuntimeBaseCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

const { Command, flags } = require('@oclif/command')
const { Command, Flags } = require('@oclif/core')

const { propertiesFile, PropertyEnv, PropertyDefault } = require('./properties')
const createDebug = require('debug')
Expand All @@ -21,7 +21,7 @@ const config = require('@adobe/aio-lib-core-config')

class RuntimeBaseCommand extends Command {
async getOptions () {
const { flags } = this.parse(this.constructor)
const { flags } = await this.parse(this.constructor)
const properties = propertiesFile()

const options = {
Expand Down Expand Up @@ -55,8 +55,8 @@ class RuntimeBaseCommand extends Command {

// .env var is given priority, then the flag, which has a default value
// of aio-cli-plugin-runtime@VERSION
if (!process.env['__OW_USER_AGENT']) {
process.env['__OW_USER_AGENT'] = flags.useragent
if (!process.env.__OW_USER_AGENT) {
process.env.__OW_USER_AGENT = flags.useragent
}

return options
Expand All @@ -74,7 +74,7 @@ class RuntimeBaseCommand extends Command {
}

async init () {
const { flags } = this.parse(this.constructor)
const { flags } = await this.parse(this.constructor)

// See https://www.npmjs.com/package/debug for usage in commands
if (flags.verbose) {
Expand All @@ -85,8 +85,8 @@ class RuntimeBaseCommand extends Command {
}
}

handleError (msg, err) {
this.parse(this.constructor)
async handleError (msg, err) {
await this.parse(this.constructor)

msg = msg || 'unknown error'

Expand Down Expand Up @@ -136,19 +136,19 @@ RuntimeBaseCommand.propertyFlags = ({ asBoolean = false } = {}) => {
Object
.keys(propData)
.forEach((key) => {
newData[key] = (asBoolean ? flags.boolean(propData[key]) : flags.string(propData[key]))
newData[key] = (asBoolean ? Flags.boolean(propData[key]) : Flags.string(propData[key]))
})
return newData
}

RuntimeBaseCommand.flags = {
...RuntimeBaseCommand.propertyFlags(),
insecure: flags.boolean({ char: 'i', description: 'bypass certificate check' }),
debug: flags.string({ description: 'Debug level output' }),
verbose: flags.boolean({ char: 'v', description: 'Verbose output' }),
version: flags.boolean({ description: 'Show version' }),
help: flags.boolean({ description: 'Show help' }),
useragent: flags.string({
insecure: Flags.boolean({ char: 'i', description: 'bypass certificate check' }),
debug: Flags.string({ description: 'Debug level output' }),
verbose: Flags.boolean({ char: 'v', description: 'Verbose output' }),
version: Flags.boolean({ description: 'Show version' }),
help: Flags.boolean({ description: 'Show help' }),
useragent: Flags.string({
hidden: true,
description: 'Use custom user-agent string',
default: 'aio-cli-plugin-runtime@' + require('../package.json').version
Expand Down
42 changes: 21 additions & 21 deletions src/commands/runtime/action/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ const fs = require('fs')
const RuntimeBaseCommand = require('../../../RuntimeBaseCommand')
const { createKeyValueArrayFromFlag, createKeyValueArrayFromFile, createComponentsfromSequence, getKeyValueArrayFromMergedParameters } = require('@adobe/aio-lib-runtime').utils
const { kindForFileExtension } = require('../../../kinds')
const { flags } = require('@oclif/command')
const { Flags } = require('@oclif/core')

class ActionCreate extends RuntimeBaseCommand {
isUpdate () { return false }

async run () {
const { args, flags } = this.parse(ActionCreate)
const { args, flags } = await this.parse(ActionCreate)
const name = args.actionName
let exec
let paramsAction
Expand Down Expand Up @@ -197,7 +197,7 @@ class ActionCreate extends RuntimeBaseCommand {
const ow = await this.wsk()
await this.syncAction(ow, name, options, flags, method)
} catch (err) {
this.handleError(`failed to ${method} the action`, err)
await this.handleError(`failed to ${method} the action`, err)
}
}

Expand Down Expand Up @@ -232,72 +232,72 @@ ActionCreate.args = [

ActionCreate.flags = {
...RuntimeBaseCommand.flags,
param: flags.string({
param: Flags.string({
char: 'p',
description: 'parameter values in KEY VALUE format', // help description for flag
multiple: true // allow setting this flag multiple times
}),
copy: flags.string({
copy: Flags.string({
description: 'copy an existing action' // help description for flag
}),
env: flags.string({
env: Flags.string({
char: 'e',
description: 'environment values in KEY VALUE format', // help description for flag
multiple: true // allow setting this flag multiple times
}),
web: flags.string({
web: Flags.string({
description: 'treat ACTION as a web action or as a raw HTTP web action', // help description for flag
options: ['true', 'yes', 'false', 'no', 'raw']
}),
'web-secure': flags.string({
'web-secure': Flags.string({
description: 'secure the web action (valid values are true, false, or any string)', // help description for flag
dependsOn: ['web']
}),
'param-file': flags.string({
'param-file': Flags.string({
char: 'P',
description: 'FILE containing parameter values in JSON format' // help description for flag
}),
'env-file': flags.string({
'env-file': Flags.string({
char: 'E',
description: 'FILE containing environment variables in JSON format' // help description for flag
}),
timeout: flags.integer({
timeout: Flags.integer({
char: 't',
description: 'the timeout LIMIT in milliseconds after which the action is terminated (default 60000)' // help description for flag
}),
memory: flags.integer({
memory: Flags.integer({
char: 'm',
description: 'the maximum memory LIMIT in MB for the action (default 256)' // help description for flag
}),
logsize: flags.integer({
logsize: Flags.integer({
char: 'l',
description: 'the maximum log size LIMIT in MB for the action (default 10)' // help description for flag
}),
kind: flags.string({
kind: Flags.string({
description: 'the KIND of the action runtime (example: swift:default, nodejs:default)' // help description for flag
}),
annotation: flags.string({
annotation: Flags.string({
char: 'a',
description: 'annotation values in KEY VALUE format', // help description for flag
multiple: true // allow setting this flag multiple times
}),
'annotation-file': flags.string({
'annotation-file': Flags.string({
char: 'A',
description: 'FILE containing annotation values in JSON format' // help description for flag
}),
sequence: flags.string({
sequence: Flags.string({
description: 'treat ACTION as comma separated sequence of actions to invoke' // help description for flag
}),
docker: flags.string({
docker: Flags.string({
description: '[Restricted Access] use provided Docker image (a path on DockerHub) to run the action' // help description for flag
}),
main: flags.string({
main: Flags.string({
description: 'the name of the action entry point (function or fully-qualified method name when applicable)'
}),
binary: flags.boolean({
binary: Flags.boolean({
description: 'treat code artifact as binary'
}),
json: flags.boolean({
json: Flags.boolean({
description: 'output raw json'
})
}
Expand Down
8 changes: 4 additions & 4 deletions src/commands/runtime/action/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ governing permissions and limitations under the License.
*/

const RuntimeBaseCommand = require('../../../RuntimeBaseCommand')
const { flags } = require('@oclif/command')
const { Flags } = require('@oclif/core')

class ActionDelete extends RuntimeBaseCommand {
async run () {
const { flags, args } = this.parse(ActionDelete)
const { flags, args } = await this.parse(ActionDelete)
const name = args.actionName
try {
const ow = await this.wsk()
Expand All @@ -24,7 +24,7 @@ class ActionDelete extends RuntimeBaseCommand {
this.logJSON('', result)
}
} catch (err) {
this.handleError('failed to delete the action', err)
await this.handleError('failed to delete the action', err)
}
}
}
Expand All @@ -38,7 +38,7 @@ ActionDelete.args = [

ActionDelete.flags = {
...RuntimeBaseCommand.flags,
json: flags.boolean({
json: Flags.boolean({
description: 'output raw json'
})
}
Expand Down
22 changes: 12 additions & 10 deletions src/commands/runtime/action/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ governing permissions and limitations under the License.
const fs = require('fs')
const RuntimeBaseCommand = require('../../../RuntimeBaseCommand')
const { fileExtensionForKind } = require('../../../kinds')
const { flags } = require('@oclif/command')
const { Flags } = require('@oclif/core')

class ActionGet extends RuntimeBaseCommand {
async run () {
const { args, flags } = this.parse(ActionGet)
const { args, flags } = await this.parse(ActionGet)
const name = args.actionName
const ow = await this.wsk()
const saveCode = flags.save || flags['save-as']
Expand Down Expand Up @@ -74,18 +74,20 @@ class ActionGet extends RuntimeBaseCommand {
}
} else {
// destructure getAction to remove the exec.code
this.logJSON(`${result.name}\n`, { ...result,
exec: { ...result.exec,
this.logJSON(`${result.name}\n`, {
...result,
exec: {
...result.exec,
code: undefined
}
})
}
}
} catch (err) {
if (err.message === ActionGet.codeNotText) {
this.handleError(err.message)
await this.handleError(err.message)
} else {
this.handleError('failed to retrieve the action', err)
await this.handleError('failed to retrieve the action', err)
}
}
}
Expand All @@ -100,20 +102,20 @@ ActionGet.args = [

ActionGet.flags = {
...RuntimeBaseCommand.flags,
url: flags.boolean({
url: Flags.boolean({
char: 'r',
description: 'get action url'
}),
code: flags.boolean({
code: Flags.boolean({
char: 'c',
description: 'show action code (only works if code is not a zip file)',
default: false
}),
save: flags.boolean({
save: Flags.boolean({
description: 'save action code to file corresponding with action name',
default: false
}),
'save-as': flags.string({
'save-as': Flags.string({
description: 'file to save action code to'
})
}
Expand Down
6 changes: 3 additions & 3 deletions src/commands/runtime/action/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

const HHelp = require('@oclif/plugin-help').default
const { Help } = require('@oclif/core')
const RuntimeBaseCommand = require('../../../RuntimeBaseCommand')

class IndexCommand extends RuntimeBaseCommand {
async run () {
const help = new HHelp(this.config)
help.showHelp(['runtime:action', '--help'])
const help = new Help(this.config)
await help.showHelp(['runtime:action', '--help'])
}
}

Expand Down
Loading