Skip to content

Commit

Permalink
fix: show name in prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Mar 27, 2024
1 parent b66760c commit 4d8d947
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion messages/verify.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ A digital signature is specified for this plugin but it didn't verify against th

# InstallConfirmation

This plugin isn't signed by Salesforce. Only install the plugin if you trust its creator. Do you want to continue the installation?,
%s isn't signed by Salesforce. Only install the plugin if you trust its creator. Do you want to continue the installation?,

# SuggestAllowList

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/verifyInstallSignature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const hook: Hook.PluginsPreinstall = async function (options) {
this.error(error);
}
} else {
await doPrompt();
await doPrompt(options.plugin.url);
}
};

Expand Down
11 changes: 8 additions & 3 deletions src/shared/installationVerification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,14 @@ export class VerificationConfig {
}
}

export async function doPrompt(): Promise<void> {
export async function doPrompt(plugin?: string): Promise<void> {
const messages = Messages.loadMessages('@salesforce/plugin-trust', 'verify');
if (!(await prompts.confirm({ message: messages.getMessage('InstallConfirmation'), ms: 30_000 }))) {
if (
!(await prompts.confirm({
message: messages.getMessage('InstallConfirmation', [plugin ?? 'This plugin']),
ms: 30_000,
}))
) {
throw new SfError('The user canceled the plugin installation.', 'InstallationCanceledError');
}
// they approved the plugin. Let them know how to automate this.
Expand Down Expand Up @@ -473,7 +478,7 @@ export async function doInstallationCodeSigningVerification(
if (!verificationConfig.verifier) {
throw new Error('VerificationConfig.verifier is not set.');
}
return await doPrompt();
return await doPrompt(plugin.plugin);
} else if (err.name === 'PluginNotFound' || err.name === 'PluginAccessDenied') {
throw setErrorName(new SfError(err.message ?? 'The user canceled the plugin installation.'), '');
}
Expand Down

0 comments on commit 4d8d947

Please sign in to comment.