From ad48d09c2d4488b118f40b64361541a8b84e67fd Mon Sep 17 00:00:00 2001 From: Jesse MacFadyen Date: Fri, 15 Nov 2024 19:25:04 -0800 Subject: [PATCH 1/3] add useragent, update oclif, jest --- package.json | 4 ++-- src/RuntimeBaseCommand.js | 9 +++++++++ src/commands/runtime/action/list.js | 4 ++-- src/commands/runtime/activation/list.js | 4 ++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 03ee7380..15e9085f 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "@adobe/aio-lib-core-config": "^5", "@adobe/aio-lib-core-networking": "^5", "@adobe/aio-lib-runtime": "^6", - "@oclif/core": "^1.3.0", + "@oclif/core": "^2.16.0", "@types/jest": "^29.5.3", "chalk": "^4.1.2", "dayjs": "^1.10.4", @@ -42,7 +42,7 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^6.1.1", "execa": "^4.0.0", - "jest": "^29.6.2", + "jest": "^29.7.0", "jest-junit": "^16.0.0", "jest-plugin-fs": "^2.9.0", "oclif": "^3.2.0", diff --git a/src/RuntimeBaseCommand.js b/src/RuntimeBaseCommand.js index ca6f73b0..8ccaeb87 100644 --- a/src/RuntimeBaseCommand.js +++ b/src/RuntimeBaseCommand.js @@ -83,6 +83,15 @@ class RuntimeBaseCommand extends Command { } else if (flags.debug) { createDebug.enable(flags.debug) } + + // set User-Agent for runtime calls + // ex. aio-cli-plugin-runtime/@adobe/aio-cli/10.3.1 (darwin-arm64; node-v18.20.4; zsh) + const vs = this.config.versionDetails + // console.log('init ', this.config.versionDetails) + process.env.__OW_USER_AGENT = + `aio-cli-plugin-runtime/${vs?.cliVersion} (${vs?.architecture}; ${vs?.nodeVersion}; ${vs?.shell})` + + console.log('init ', process.env.__OW_USER_AGENT) } async handleError (msg, err) { diff --git a/src/commands/runtime/action/list.js b/src/commands/runtime/action/list.js index 87f0bd1c..4ebf4c54 100644 --- a/src/commands/runtime/action/list.js +++ b/src/commands/runtime/action/list.js @@ -13,7 +13,7 @@ governing permissions and limitations under the License. const moment = require('dayjs') const RuntimeBaseCommand = require('../../../RuntimeBaseCommand') const { parsePackageName } = require('@adobe/aio-lib-runtime').utils -const { Flags, CliUx: cli } = require('@oclif/core') +const { Flags, ux } = require('@oclif/core') const decorators = require('../../../decorators').decorators() class ActionList extends RuntimeBaseCommand { @@ -86,7 +86,7 @@ class ActionList extends RuntimeBaseCommand { } } } - cli.ux.table(result, columns) + ux.table(result, columns) } } catch (err) { await this.handleError('failed to list the actions', err) diff --git a/src/commands/runtime/activation/list.js b/src/commands/runtime/activation/list.js index 8e447cc6..773081a0 100644 --- a/src/commands/runtime/activation/list.js +++ b/src/commands/runtime/activation/list.js @@ -12,7 +12,7 @@ governing permissions and limitations under the License. const moment = require('dayjs') const RuntimeBaseCommand = require('../../../RuntimeBaseCommand') -const { Flags, CliUx: cli } = require('@oclif/core') +const { Flags, ux } = require('@oclif/core') const decorators = require('../../../decorators').decorators() const statusStrings = ['success', 'app error', 'dev error', 'sys error'] @@ -187,7 +187,7 @@ class ActivationList extends RuntimeBaseCommand { } } if (listActivation) { - cli.ux.table(listActivation, columns, { + ux.table(listActivation, columns, { 'no-truncate': true }) } From b9e0c59140f42badbda1b610bb02fe0f3ab267b7 Mon Sep 17 00:00:00 2001 From: Jesse MacFadyen Date: Thu, 16 Apr 2026 16:53:00 -0700 Subject: [PATCH 2/3] nit: use debug, not console.log --- src/RuntimeBaseCommand.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RuntimeBaseCommand.js b/src/RuntimeBaseCommand.js index 5eb73e9b..f142e4cf 100644 --- a/src/RuntimeBaseCommand.js +++ b/src/RuntimeBaseCommand.js @@ -93,7 +93,7 @@ class RuntimeBaseCommand extends Command { process.env.__OW_USER_AGENT = `aio-cli-plugin-runtime/${vs?.cliVersion} (${vs?.architecture}; ${vs?.nodeVersion}; ${vs?.shell})` - console.log('init ', process.env.__OW_USER_AGENT) + debug('init ', process.env.__OW_USER_AGENT) } async handleError (msg, err) { From c64c1adaa3eed5dd3406deafc9158d6de95da7b6 Mon Sep 17 00:00:00 2001 From: Jesse MacFadyen Date: Thu, 16 Apr 2026 17:01:12 -0700 Subject: [PATCH 3/3] Update src/RuntimeBaseCommand.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/RuntimeBaseCommand.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/RuntimeBaseCommand.js b/src/RuntimeBaseCommand.js index f142e4cf..68a97e70 100644 --- a/src/RuntimeBaseCommand.js +++ b/src/RuntimeBaseCommand.js @@ -89,9 +89,13 @@ class RuntimeBaseCommand extends Command { // set User-Agent for runtime calls // ex. aio-cli-plugin-runtime/@adobe/aio-cli/10.3.1 (darwin-arm64; node-v18.20.4; zsh) const vs = this.config.versionDetails + const baseUserAgent = `aio-cli-plugin-runtime/${vs?.cliVersion || 'unknown'}` + const userAgentDetails = [vs?.architecture, vs?.nodeVersion, vs?.shell] + .filter(detail => typeof detail === 'string' && detail.trim()) // console.log('init ', this.config.versionDetails) - process.env.__OW_USER_AGENT = - `aio-cli-plugin-runtime/${vs?.cliVersion} (${vs?.architecture}; ${vs?.nodeVersion}; ${vs?.shell})` + process.env.__OW_USER_AGENT = userAgentDetails.length > 0 + ? `${baseUserAgent} (${userAgentDetails.join('; ')})` + : baseUserAgent debug('init ', process.env.__OW_USER_AGENT) }