Skip to content

Commit

Permalink
feat: add override registry URI option for backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mshojaei-txfusion committed Feb 9, 2025
1 parent 24e66dc commit 301a475
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
2 changes: 2 additions & 0 deletions typescript/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
keyCommandOption,
logFormatCommandOption,
logLevelCommandOption,
overrideRegistryUriCommandOption,
registryUrisCommandOption,
skipConfirmationOption,
strategyCommandOption,
Expand Down Expand Up @@ -43,6 +44,7 @@ try {
.option('log', logFormatCommandOption)
.option('verbosity', logLevelCommandOption)
.option('registry', registryUrisCommandOption)
.option('overrides', overrideRegistryUriCommandOption)
.option('key', keyCommandOption)
.option('disableProxy', disableProxyCommandOption)
.option('yes', skipConfirmationOption)
Expand Down
7 changes: 7 additions & 0 deletions typescript/cli/src/commands/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ export const registryUrisCommandOption: Options = {
default: [DEFAULT_GITHUB_REGISTRY, DEFAULT_LOCAL_REGISTRY],
};

export const overrideRegistryUriCommandOption: Options = {
type: 'string',
description: 'Path to a local registry to override the default registry',
default: '',
hidden: true,
};

export const skipConfirmationOption: Options = {
type: 'boolean',
description: 'Skip confirmation prompts',
Expand Down
10 changes: 8 additions & 2 deletions typescript/cli/src/context/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ export async function contextMiddleware(argv: Record<string, any>) {
const isDryRun = !isNullish(argv.dryRun);
const requiresKey = isSignCommand(argv);
const settings: ContextSettings = {
registryUris: argv.registry,
registryUris: [
...argv.registry,
...(argv.overrides ? [argv.overrides] : []),
],
key: argv.key,
fromAddress: argv.fromAddress,
requiresKey,
Expand Down Expand Up @@ -185,7 +188,10 @@ export async function getDryRunContext(
* and an override one (such as a local directory)
* @returns a new MergedRegistry
*/
function getRegistry(registryUris: string[], enableProxy: boolean): IRegistry {
export function getRegistry(
registryUris: string[],
enableProxy: boolean,
): IRegistry {
const logger = rootLogger.child({ module: 'MergedRegistry' });
const registries = registryUris
.map((uri) => uri.trim())
Expand Down
3 changes: 1 addition & 2 deletions typescript/infra/config/warp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ async function getConfigFromMergedRegistry(
warpRouteId: string,
): Promise<ChainMap<HypTokenRouterConfig>> {
const warpRoute = await getRegistry(
DEFAULT_REGISTRY_URI,
'',
[DEFAULT_REGISTRY_URI],
true,
).getWarpDeployConfig(warpRouteId);
assert(warpRoute, `Warp route Config not found for ${warpRouteId}`);
Expand Down
3 changes: 1 addition & 2 deletions typescript/infra/test/warp-configs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ describe('Warp Configs', async function () {
before(async function () {
multiProvider = (await getHyperlaneCore(ENV)).multiProvider;
configsFromGithub = await getRegistry(
DEFAULT_GITHUB_REGISTRY,
'',
[DEFAULT_GITHUB_REGISTRY],
true,
).getWarpDeployConfigs();
});
Expand Down
2 changes: 1 addition & 1 deletion typescript/infra/test/warpIds.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { WarpRouteIds } from '../config/environments/mainnet3/warp/warpIds.js';

describe('Warp IDs', () => {
it('Has all warp IDs in the registry', () => {
const registry = getRegistry(DEFAULT_GITHUB_REGISTRY, '', true);
const registry = getRegistry([DEFAULT_GITHUB_REGISTRY], true);
for (const warpId of Object.values(WarpRouteIds)) {
// That's a long sentence!
expect(
Expand Down

0 comments on commit 301a475

Please sign in to comment.