Skip to content

Commit

Permalink
fix: file casing consistent with export
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Apr 5, 2024
1 parent cf7563d commit d98792d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/commands/plugins/trust/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
InstallationVerification,
VerificationConfig,
} from '../../../shared/installationVerification.js';
import { type NpmName, parseNpmName } from '../../../shared/NpmName.js';
import { type ParsedNpm, parseNpmName } from '../../../shared/npmName.js';
import { setErrorName } from '../../../shared/errors.js';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
Expand Down Expand Up @@ -41,7 +41,7 @@ export class Verify extends SfCommand<VerifyResponse> {
loglevel,
};

private static getVerifier(npmName: NpmName, config: ConfigContext): InstallationVerification {
private static getVerifier(npmName: ParsedNpm, config: ConfigContext): InstallationVerification {
return new InstallationVerification().setPluginNpmName(npmName).setConfig(config);
}

Expand Down
4 changes: 2 additions & 2 deletions src/hooks/verifyInstallSignature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
isAllowListed,
} from '../shared/installationVerification.js';

import { type NpmName, parseNpmName } from '../shared/NpmName.js';
import { type ParsedNpm, parseNpmName } from '../shared/npmName.js';

export const hook: Hook.PluginsPreinstall = async function (options) {
if (options.plugin && options.plugin.type === 'npm') {
Expand Down Expand Up @@ -87,7 +87,7 @@ export default hook;
/**
* Build a VerificationConfig. Useful for testing.
*/
const buildVerificationConfig = (npmName: NpmName, configContext: ConfigContext): VerificationConfig => {
const buildVerificationConfig = (npmName: ParsedNpm, configContext: ConfigContext): VerificationConfig => {
const vConfig = new VerificationConfig();
vConfig.verifier = new InstallationVerification().setPluginNpmName(npmName).setConfig(configContext);
return vConfig;
Expand Down
8 changes: 4 additions & 4 deletions src/shared/NpmName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { setErrorName } from './errors.js';

const DEFAULT_TAG = 'latest';

export type NpmName = {
export type ParsedNpm = {
tag: string;
scope?: string;
name: string;
Expand All @@ -19,9 +19,9 @@ export type NpmName = {
* Parse an NPM package name into {scope, name, tag}. The tag is 'latest' by default and can be any semver string.
*
* @param {string} npmName - The npm name to parse.
* @return {NpmName} - An object with the parsed components.
* @return {ParsedNpm} - An object with the parsed components.
*/
export const parseNpmName = (npmName: string): NpmName => {
export const parseNpmName = (npmName: string): ParsedNpm => {
const nameWithoutAt = validateNpmNameAndRemoveLeadingAt(npmName);
const hasScope = nameWithoutAt.includes('/');
const hasTag = nameWithoutAt.includes('@');
Expand All @@ -34,7 +34,7 @@ export const parseNpmName = (npmName: string): NpmName => {
};

/** Produces a formatted string version of the object */
export const npmNameToString = (npmName: NpmName): string =>
export const npmNameToString = (npmName: ParsedNpm): string =>
`${npmName.scope ? `@${npmName.scope}/` : ''}${npmName.name}`;

const validateNpmNameAndRemoveLeadingAt = (input: string): string => {
Expand Down
6 changes: 3 additions & 3 deletions src/shared/installationVerification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ux } from '@oclif/core';
import { prompts } from '@salesforce/sf-plugins-core';
import { maxSatisfying } from 'semver';
import { NpmModule, NpmMeta } from './npmCommand.js';
import { NpmName, npmNameToString } from './NpmName.js';
import { ParsedNpm, npmNameToString } from './npmName.js';
import { setErrorName } from './errors.js';

const CRYPTO_LEVEL = 'RSA-SHA256';
Expand Down Expand Up @@ -187,7 +187,7 @@ export async function isAllowListed({
*/
export class InstallationVerification implements Verifier {
// The name of the published plugin
private pluginNpmName?: NpmName;
private pluginNpmName?: ParsedNpm;

// config derived from the cli environment
private config?: ConfigContext;
Expand All @@ -211,7 +211,7 @@ export class InstallationVerification implements Verifier {
*
* @param _pluginName the published plugin name
*/
public setPluginNpmName(_pluginName?: NpmName | undefined): InstallationVerification {
public setPluginNpmName(_pluginName?: ParsedNpm | undefined): InstallationVerification {
if (_pluginName) {
this.pluginNpmName = _pluginName;
return this;
Expand Down
4 changes: 2 additions & 2 deletions test/shared/installationVerification.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
Verifier,
} from '../../src/shared/installationVerification.js';
import { NpmMeta, NpmModule, NpmShowResults } from '../../src/shared/npmCommand.js';
import { NpmName, parseNpmName } from '../../src/shared/NpmName.js';
import { ParsedNpm, parseNpmName } from '../../src/shared/npmName.js';
import { CERTIFICATE, TEST_DATA, TEST_DATA_SIGNATURE } from '../testCert.js';

const BLANK_PLUGIN = { plugin: '', tag: '' };
Expand Down Expand Up @@ -137,7 +137,7 @@ describe('InstallationVerification Tests', () => {
};
const currentRegistry = process.env.SFDX_NPM_REGISTRY;
let fsReaddirSyncStub: Sinon.SinonStub;
let plugin: NpmName;
let plugin: ParsedNpm;
let realpathSyncStub: Sinon.SinonStub;
let sandbox: sinon.SinonSandbox;
let shelljsExecStub: Sinon.SinonStub;
Expand Down
2 changes: 1 addition & 1 deletion test/shared/npmName.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { expect } from 'chai';
import { npmNameToString, parseNpmName } from '../../src/shared/NpmName.js';
import { npmNameToString, parseNpmName } from '../../src/shared/npmName.js';

describe('npmName', () => {
describe('parse', () => {
Expand Down

0 comments on commit d98792d

Please sign in to comment.