Skip to content

Commit

Permalink
fix: various aztec-builder issues (AztecProtocol#6233)
Browse files Browse the repository at this point in the history
Fixing random aztec-builder issues.
  • Loading branch information
benesjan authored May 7, 2024
1 parent 5d6d22c commit 9a644ba
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 24 deletions.
2 changes: 1 addition & 1 deletion yarn-project/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"entryPoints": [
"./src/index.ts"
],
"name": "Aztec.nr compiler",
"name": "Aztec builder",
"tsconfig": "./tsconfig.json"
},
"bin": {
Expand Down
29 changes: 7 additions & 22 deletions yarn-project/builder/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,13 @@
#!/usr/bin/env node
import { createConsoleLogger } from '@aztec/foundation/log';

import { Command, Option } from 'commander';
import { lookup } from 'dns/promises';
import { Command } from 'commander';
import { dirname } from 'path';

const program = new Command();
const log = createConsoleLogger('aztec:compiler-cli');

/**
* If we can successfully resolve 'host.docker.internal', then we are running in a container, and we should treat
* localhost as being host.docker.internal.
*/
const getLocalhost = () =>
lookup('host.docker.internal')
.then(() => 'host.docker.internal')
.catch(() => 'localhost');

const LOCALHOST = await getLocalhost();
const log = createConsoleLogger('aztec:builder');

const main = async () => {
const pxeOption = new Option('-u, --rpc-url <string>', 'URL of the PXE')
.env('PXE_URL')
.default(`http://${LOCALHOST}:8080`)
.makeOptionMandatory(true);

program.name('aztec-builder');
program
.command('codegen')
Expand All @@ -43,14 +26,16 @@ const main = async () => {
.argument('[projectPath]', 'Path to the project directory', process.cwd())
.option('--contract [paths...]', 'Paths to contracts to update dependencies', [])
.option('--aztec-version <semver>', 'The version to update Aztec packages to. Defaults to latest', 'latest')
.addOption(pxeOption)
.action(async (projectPath: string, options) => {
const { update } = await import('./cli/update/update.js');
const { contract, aztecVersion, rpcUrl } = options;
await update(projectPath, contract, rpcUrl, aztecVersion, log);
const { contract, aztecVersion } = options;
await update(projectPath, contract, aztecVersion, log);
});

await program.parseAsync(process.argv);
// I force exit here because spawnSync in npm.ts just blocks the process from exiting. Spent a bit of time debugging
// it without success and I think it doesn't make sense to invest more time in this.
process.exit(0);
};

main().catch(err => {
Expand Down
1 change: 0 additions & 1 deletion yarn-project/builder/src/cli/update/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const UPDATE_DOCS_URL = 'https://docs.aztec.network/developers/updating';
export async function update(
projectPath: string,
contracts: string[],
pxeUrl: string,
aztecVersion: string,
log: LogFn,
): Promise<void> {
Expand Down

0 comments on commit 9a644ba

Please sign in to comment.