Skip to content

Commit 8a4e9f1

Browse files
committed
Fixes
1 parent d3b5ef8 commit 8a4e9f1

9 files changed

Lines changed: 53 additions & 19 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"promise-limit": "^2.7.0",
5252
"semver": "^7.7.3",
5353
"serialize-error": "^12.0.0",
54+
"tmp": "^0.2.5",
5455
"uuid": "^13.0.0"
5556
},
5657
"devDependencies": {
@@ -78,7 +79,6 @@
7879
"mustache": "^4.2.0",
7980
"nock": "^14.0.10",
8081
"testdouble": "^3.20.2",
81-
"tmp": "^0.2.5",
8282
"ts-node": "^10.9.2",
8383
"typescript": "^5.9.3"
8484
},

‎src/commands/auth/login.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,18 @@ Once authenticated, the account's current team is set to its configured default
9494
}
9595

9696
if (authMethod === 'Client Certificate' && !flags['secret-file']) {
97-
flags['secret-file'] = await input({
97+
flags['secret-file'] = (await input({
9898
message: 'Path to the PEM formatted private key:',
99-
validate: s => (s ? true : 'Please enter the path to your PEM formatted private key file')
100-
});
99+
validate: s => (s?.trim() ? true : 'Please enter the path to your PEM formatted private key file')
100+
})).trim();
101101
}
102102
this.log('');
103103
}
104104

105105
const sdk = await initSDK({
106106
clientId: flags['client-id'],
107107
clientSecret: flags['client-secret'],
108-
secretFile: flags['secret-file'],
108+
secretFile: flags['secret-file']?.trim(),
109109
env: config.get('env')
110110
});
111111
let account;

‎src/commands/config/profile/create.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ export default class ConfigProfileCreate extends Command {
9898
}
9999
};
100100

101+
if (profile.auth) {
102+
for (const key of [ 'baseUrl', 'platformUrl', 'engageUrl', 'region' ] as const) {
103+
if (typeof profile.auth[key] === 'string') {
104+
profile.auth[key] = profile.auth[key].trim();
105+
}
106+
}
107+
}
108+
101109
const exists = config.has(`profiles.${profileName}`);
102110
if (exists) {
103111
return this.error(`Profile "${profileName}" already exists.`);
@@ -115,7 +123,7 @@ export default class ConfigProfileCreate extends Command {
115123

116124
function urlValidate(input: string): boolean {
117125
try {
118-
new URL(input);
126+
new URL(input.trim());
119127
return true;
120128
} catch {
121129
return false;

‎src/commands/engage/completion.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import Command from '../../lib/command.js';
2+
import { highlight } from '../../lib/logger.js';
3+
4+
export default class EngageCompletion extends Command {
5+
static override summary = 'Set autocompletion for Axway CLI commands.';
6+
7+
static override aliases = [ 'central:completion' ];
8+
9+
static override description = `Autocompletion is provided by the Axway CLI autocomplete command.
10+
Run ${highlight('"axway autocomplete"')} to install and set up autocompletion.`;
11+
12+
async run(): Promise<any> {
13+
this.log('Autocompletion is managed by the Axway CLI autocomplete command.\n');
14+
this.log('To set up autocompletion, run:\n');
15+
this.log(` ${highlight('axway autocomplete')}\n`);
16+
this.log('Follow the instructions to setup autocompletion.');
17+
}
18+
}

‎src/commands/engage/get.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ export default class EngageGet extends Command {
113113
let teamGuid: string | undefined;
114114
if (flags.team) {
115115
const match = teams?.teams?.find((t: PlatformTeam) =>
116-
t.guid.toLowerCase() === flags.team.toLowerCase()
117-
|| t.name.toLowerCase() === flags.team.toLowerCase()
116+
t?.guid.toLowerCase() === flags.team.toLowerCase()
117+
|| t?.name.toLowerCase() === flags.team.toLowerCase()
118118
);
119119
if (!match) {
120120
throw new Error(`Unable to find team "${flags.team}" in the "${account.org.name}" organization`);
121121
}
122-
teamGuid = match.metadata.guid;
122+
teamGuid = match?.guid;
123123
}
124124

125125
// Warn if both simple and advanced query params were provided.

‎src/commands/engage/index.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ Run ${highlight('"<%= config.bin %> auth login"')} to authenticate.`;
2222
command: '<%= config.bin %> <%= command.id %> completion',
2323
description: 'Output shell completion code'
2424
},
25-
{
26-
command: '<%= config.bin %> <%= command.id %> config',
27-
description: 'Configure Engage CLI settings'
28-
},
2925
{
3026
command: '<%= config.bin %> <%= command.id %> create',
3127
description: 'Create one or more resources from a file or stdin'

‎src/hooks/init/init.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ const hook: Hook.Init = async function (opts) {
2424
return this.error(err);
2525
}
2626

27-
if (config.get('update.check') === false || opts.argv.includes('--no-banner') || opts.argv.includes('--json')) {
27+
const hasStructuredOutput = opts.argv.some((arg, i) =>
28+
(arg === '-o' || arg === '--output') && (opts.argv[i + 1] === 'json' || opts.argv[i + 1] === 'yaml')
29+
);
30+
31+
if (config.get('update.check') === false || opts.argv.includes('--no-banner') || opts.argv.includes('--json') || hasStructuredOutput) {
2832
log('Skipping update check');
2933
} else {
3034
// Trigger the update check fetch and let it continue asynchronously while the command runs
@@ -38,12 +42,14 @@ const hook: Hook.Init = async function (opts) {
3842
}
3943

4044
const command = opts.config.commands.find(cmd => cmd.id === opts.id);
45+
4146
// Include the banner if not disabled
4247
if (config.get('banner.enabled') !== false
4348
// Not opted-out
4449
&& !opts.argv.includes('--no-banner')
45-
// Not requesting JSON output
50+
// Not requesting JSON output (oclif built-in or engage -o/--output flag)
4651
&& !opts.argv.includes('--json')
52+
&& !hasStructuredOutput
4753
// And for commands that do not have it disabled (other than for help output)
4854
&& (command?.enableBanner !== false || opts.argv.includes('--help'))
4955
) {

‎src/lib/engage/clients-external/apiserverclient.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,16 @@ export class ApiServerClient {
7171
this.forceGetAuthInfo = forceGetAuthInfo;
7272
this.basePath = basePath;
7373
if (baseUrl) {
74-
this._baseUrl = baseUrl + (basePath || BasePaths.ApiServer);
74+
this._baseUrl = baseUrl.replace(/\/$/, '') + (basePath || BasePaths.ApiServer);
7575
}
7676
}
7777

7878
private async initializeDataService() {
79+
const config = await loadConfig();
7980
if (this._baseUrl === undefined) {
80-
const config = await loadConfig();
8181
const envBaseUrl = process.env.AXWAY_CENTRAL_BASE_URL || config.get('auth.engageUrl');
8282
if (envBaseUrl) {
83-
this._baseUrl = envBaseUrl + (this.basePath || BasePaths.ApiServer);
83+
this._baseUrl = envBaseUrl.replace(/\/$/, '') + (this.basePath || BasePaths.ApiServer);
8484
} else {
8585
const regionKey = String(
8686
this.region || this.account?.org?.region || Regions.US
@@ -94,6 +94,10 @@ export class ApiServerClient {
9494
this._baseUrl = prodBaseUrl + (this.basePath || BasePaths.ApiServer);
9595
}
9696
}
97+
if (config.profile && config.get('engage.authToken')) {
98+
return dataService({ account: this.account, baseUrl: this._baseUrl, authToken: config.get('engage.authToken') });
99+
}
100+
97101
return dataService({ account: this.account, baseUrl: this._baseUrl });
98102
}
99103

‎src/lib/request.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,13 @@ const updateRequestError = (err: Error) => {
288288
export const dataService = async ({
289289
account,
290290
baseUrl = '',
291+
authToken = ''
291292
}: {
292293
account?: Account;
293294
baseUrl?: string;
295+
authToken?: string;
294296
}): Promise<DataServiceMethods> => {
295-
const token = account.auth?.tokens?.access_token;
297+
const token = authToken ? authToken : account?.auth?.tokens?.access_token;
296298
if (!token) {
297299
throw new Error('Invalid/expired account');
298300
}

0 commit comments

Comments
 (0)