Skip to content

Commit

Permalink
move relative path correction logic up, add to other command
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-aztec committed Oct 10, 2023
1 parent 0b63a54 commit b6838e7
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 44 deletions.
8 changes: 4 additions & 4 deletions yarn-project/boxes/blank-react/src/artifacts/Blank.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions yarn-project/boxes/blank/src/artifacts/Blank.json

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions yarn-project/boxes/private-token/src/artifacts/PrivateToken.json

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion yarn-project/noir-compiler/src/cli/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ export function compileContract(program: Command, name = 'contract', log: LogFn
if (typescript) {
const tsPath = resolve(projectPath, typescript, `${contract.name}.ts`);
log(`Writing ${contract.name} typescript interface to ${path.relative(currentDir, tsPath)}`);
const relativeArtifactPath = path.relative(path.dirname(tsPath), artifactPath);
let relativeArtifactPath = path.relative(path.dirname(tsPath), artifactPath);
log(`Relative path: ${relativeArtifactPath}`);
if (relativeArtifactPath === `${contract.name}.json`) {
// relative path edge case, prepending ./ for local import - the above logic just does
// `${contract.name}.json`, which is not a valid import for a file in the same directory
relativeArtifactPath = `./${contract.name}.json`;
}
log(`Relative path after correction: ${relativeArtifactPath}`);
const tsWrapper = generateTypescriptContractInterface(contract, relativeArtifactPath);
mkdirpSync(path.dirname(tsPath));
writeFileSync(tsPath, tsWrapper);
Expand Down
10 changes: 5 additions & 5 deletions yarn-project/noir-compiler/src/cli/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ export function generateTypescriptInterface(program: Command, name = 'typescript
const tsPath = resolve(projectPath, outdir, `${contract.name}.ts`);
log(`Writing ${contract.name} typescript interface to ${path.relative(currentDir, tsPath)}`);
let relativeArtifactPath = path.relative(path.dirname(tsPath), artifactPath);
if (relativeArtifactPath === `${contract.name}.json`) {
// relative path edge case, prepending ./ for local import - the above logic just does
// `${contract.name}.json`, which is not a valid import for a file in the same directory
relativeArtifactPath = `./${contract.name}.json`;
}
try {
if (relativeArtifactPath === `${contract.name}.json`) {
// relative path edge case, prepending ./ for local import - the above logic just does
// `${contract.name}.json`, which is not a valid import for a file in the same directory
relativeArtifactPath = `./${contract.name}.json`;
}
const tsWrapper = generateTypescriptContractInterface(contract, relativeArtifactPath);
mkdirpSync(path.dirname(tsPath));
writeFileSync(tsPath, tsWrapper);
Expand Down
3 changes: 0 additions & 3 deletions yarn-project/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6981,7 +6981,6 @@ __metadata:
"@aztec/aztec-ui": ^0.1.14
"@aztec/aztec.js": "workspace:^"
"@aztec/circuits.js": "workspace:^"
"@aztec/cli": "workspace:^"
"@aztec/foundation": "workspace:^"
"@aztec/types": "workspace:^"
"@types/node": ^20.5.9
Expand Down Expand Up @@ -7031,7 +7030,6 @@ __metadata:
"@aztec/aztec-ui": ^0.1.14
"@aztec/aztec.js": "workspace:^"
"@aztec/circuits.js": "workspace:^"
"@aztec/cli": "workspace:^"
"@aztec/foundation": "workspace:^"
"@typescript-eslint/eslint-plugin": ^6.0.0
"@typescript-eslint/parser": ^6.0.0
Expand Down Expand Up @@ -15598,7 +15596,6 @@ __metadata:
"@aztec/aztec-ui": ^0.1.14
"@aztec/aztec.js": "workspace:^"
"@aztec/circuits.js": "workspace:^"
"@aztec/cli": "workspace:^"
"@aztec/foundation": "workspace:^"
"@aztec/types": "workspace:^"
"@types/node": ^20.5.9
Expand Down

0 comments on commit b6838e7

Please sign in to comment.