@aztec/aztec 0.0.1-commit.9ee6fcc6 → 0.0.1-commit.9ef841308
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/cli/cmds/compile.d.ts +1 -1
- package/dest/cli/cmds/compile.d.ts.map +1 -1
- package/dest/cli/cmds/compile.js +2 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
- package/dest/cli/cmds/utils/needs_recompile.d.ts +1 -1
- package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -1
- package/dest/cli/cmds/utils/needs_recompile.js +9 -53
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +41 -0
- package/package.json +33 -33
- package/scripts/aztec.sh +1 -1
- package/src/cli/cmds/compile.ts +3 -0
- package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
- package/src/cli/cmds/utils/needs_recompile.ts +8 -61
- package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +54 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { LogFn } from '@aztec/foundation/log';
|
|
2
2
|
import type { Command } from 'commander';
|
|
3
3
|
export declare function injectCompileCommand(program: Command, log: LogFn): Command;
|
|
4
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tcGlsZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL2NvbXBpbGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFHbkQsT0FBTyxLQUFLLEVBQUUsT0FBTyxFQUFFLE1BQU0sV0FBVyxDQUFDO0FBdUt6Qyx3QkFBZ0Isb0JBQW9CLENBQUMsT0FBTyxFQUFFLE9BQU8sRUFBRSxHQUFHLEVBQUUsS0FBSyxHQUFHLE9BQU8sQ0FzQjFFIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/compile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/compile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuKzC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,CAsB1E"}
|
package/dest/cli/cmds/compile.js
CHANGED
|
@@ -5,6 +5,7 @@ import { join } from 'path';
|
|
|
5
5
|
import { readArtifactFiles } from './utils/artifacts.js';
|
|
6
6
|
import { needsRecompile } from './utils/needs_recompile.js';
|
|
7
7
|
import { run } from './utils/spawn.js';
|
|
8
|
+
import { warnIfAztecVersionMismatch } from './utils/warn_if_aztec_version_mismatch.js';
|
|
8
9
|
/** Returns paths to contract artifacts in the target directory. */ async function collectContractArtifacts() {
|
|
9
10
|
let files;
|
|
10
11
|
try {
|
|
@@ -118,6 +119,7 @@ import { run } from './utils/spawn.js';
|
|
|
118
119
|
}
|
|
119
120
|
}
|
|
120
121
|
/** Compiles Aztec Noir contracts and postprocesses artifacts. */ async function compileAztecContract(nargoArgs, log) {
|
|
122
|
+
await warnIfAztecVersionMismatch(log);
|
|
121
123
|
if (!await needsRecompile()) {
|
|
122
124
|
log('No source changes detected, skipping compilation.');
|
|
123
125
|
return;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively collects crate directories starting from startCrateDir by following dependencies declared in Nargo.toml
|
|
3
|
+
* files.
|
|
4
|
+
*
|
|
5
|
+
* When `skipGitDeps` is false (default), git-based deps are followed and fetched into the nargo cache
|
|
6
|
+
* (`$HOME/nargo/<domain>/<repo-path>/<tag>`) if not already present.
|
|
7
|
+
*
|
|
8
|
+
* When `skipGitDeps` is true, git-based deps are ignored entirely.
|
|
9
|
+
*/
|
|
10
|
+
export declare function collectCrateDirs(startCrateDir: string, opts?: {
|
|
11
|
+
skipGitDeps?: boolean;
|
|
12
|
+
}): Promise<string[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Computes the local nargo cache path for a git dependency, mirroring nargo's own `git_dep_location` function.
|
|
15
|
+
* Path format: `$HOME/nargo/<domain>/<repo-path>/<tag>`
|
|
16
|
+
* e.g. `~/nargo/github.com/AztecProtocol/aztec-packages/v0.82.0`
|
|
17
|
+
*
|
|
18
|
+
* Source: noir/noir-repo/tooling/nargo_toml/src/git.rs
|
|
19
|
+
*/
|
|
20
|
+
export declare function nargoGitDepPath(gitUrl: string, tag: string): string;
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29sbGVjdF9jcmF0ZV9kaXJzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvY2xpL2NtZHMvdXRpbHMvY29sbGVjdF9jcmF0ZV9kaXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQVFBOzs7Ozs7OztHQVFHO0FBQ0gsd0JBQXNCLGdCQUFnQixDQUFDLGFBQWEsRUFBRSxNQUFNLEVBQUUsSUFBSSxDQUFDLEVBQUU7SUFBRSxXQUFXLENBQUMsRUFBRSxPQUFPLENBQUE7Q0FBRSxHQUFHLE9BQU8sQ0FBQyxNQUFNLEVBQUUsQ0FBQyxDQWlFakg7QUFFRDs7Ozs7O0dBTUc7QUFDSCx3QkFBZ0IsZUFBZSxDQUFDLE1BQU0sRUFBRSxNQUFNLEVBQUUsR0FBRyxFQUFFLE1BQU0sR0FBRyxNQUFNLENBS25FIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collect_crate_dirs.d.ts","sourceRoot":"","sources":["../../../../src/cli/cmds/utils/collect_crate_dirs.ts"],"names":[],"mappings":"AAQA;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAiEjH;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAKnE"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import TOML from '@iarna/toml';
|
|
2
|
+
import { existsSync } from 'fs';
|
|
3
|
+
import { mkdir, readFile, stat } from 'fs/promises';
|
|
4
|
+
import { homedir } from 'os';
|
|
5
|
+
import { dirname, join, resolve } from 'path';
|
|
6
|
+
import { run } from './spawn.js';
|
|
7
|
+
/**
|
|
8
|
+
* Recursively collects crate directories starting from startCrateDir by following dependencies declared in Nargo.toml
|
|
9
|
+
* files.
|
|
10
|
+
*
|
|
11
|
+
* When `skipGitDeps` is false (default), git-based deps are followed and fetched into the nargo cache
|
|
12
|
+
* (`$HOME/nargo/<domain>/<repo-path>/<tag>`) if not already present.
|
|
13
|
+
*
|
|
14
|
+
* When `skipGitDeps` is true, git-based deps are ignored entirely.
|
|
15
|
+
*/ export async function collectCrateDirs(startCrateDir, opts) {
|
|
16
|
+
const { skipGitDeps = false } = opts ?? {};
|
|
17
|
+
const visited = new Set();
|
|
18
|
+
async function visit(crateDir) {
|
|
19
|
+
const absDir = resolve(crateDir);
|
|
20
|
+
if (visited.has(absDir)) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
visited.add(absDir);
|
|
24
|
+
const tomlPath = join(absDir, 'Nargo.toml');
|
|
25
|
+
const content = await readFile(tomlPath, 'utf-8').catch(()=>{
|
|
26
|
+
throw new Error(`Incorrectly defined dependency. Nargo.toml not found in ${absDir}`);
|
|
27
|
+
});
|
|
28
|
+
const parsed = TOML.parse(content);
|
|
29
|
+
const members = parsed.workspace?.members;
|
|
30
|
+
// A Nargo.toml is either a workspace root (has workspace.members) or a single crate (has dependencies).
|
|
31
|
+
if (Array.isArray(members)) {
|
|
32
|
+
// The crate is a workspace root and has members defined so we visit the members
|
|
33
|
+
for (const member of members){
|
|
34
|
+
await visit(resolve(absDir, member));
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
// Single crate — follow its deps
|
|
38
|
+
const deps = parsed.dependencies ?? {};
|
|
39
|
+
for (const dep of Object.values(deps)){
|
|
40
|
+
if (!dep || typeof dep !== 'object') {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (typeof dep.path === 'string') {
|
|
44
|
+
// Dependency contains "path" hence it's a local dependency. We just check it's a real directory and then we
|
|
45
|
+
// recursively search through it
|
|
46
|
+
const depPath = resolve(absDir, dep.path);
|
|
47
|
+
const s = await stat(depPath);
|
|
48
|
+
if (!s.isDirectory()) {
|
|
49
|
+
throw new Error(`Dependency path "${dep.path}" in ${tomlPath} resolves to ${depPath} which is not a directory`);
|
|
50
|
+
}
|
|
51
|
+
await visit(depPath);
|
|
52
|
+
} else if (!skipGitDeps && typeof dep.git === 'string' && typeof dep.tag === 'string') {
|
|
53
|
+
// Dependency contains "git" hence it's a git dependency. We ensure it has been fetched and fetch it if
|
|
54
|
+
// it's not the case and then we recursively search through it.
|
|
55
|
+
await fetchAndVisit(dep.git, dep.tag, dep.directory);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async function fetchAndVisit(gitUrl, tag, directory) {
|
|
61
|
+
// `directory` is set when the dep lives in a subdirectory of a repository, e.g.:
|
|
62
|
+
// aztec = { git = "https://github.com/AztecProtocol/aztec-packages", tag = "v0.82.0",
|
|
63
|
+
// directory = "noir-projects/aztec-nr/aztec" }
|
|
64
|
+
// In that case nargo clones the whole repo and the crate root is <cachePath>/<directory>.
|
|
65
|
+
const cachePath = nargoGitDepPath(gitUrl, tag);
|
|
66
|
+
const crateDir = directory ? join(cachePath, directory) : cachePath;
|
|
67
|
+
await ensureGitDepCached(gitUrl, tag, cachePath);
|
|
68
|
+
await visit(crateDir);
|
|
69
|
+
}
|
|
70
|
+
await visit(startCrateDir);
|
|
71
|
+
return [
|
|
72
|
+
...visited
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Computes the local nargo cache path for a git dependency, mirroring nargo's own `git_dep_location` function.
|
|
77
|
+
* Path format: `$HOME/nargo/<domain>/<repo-path>/<tag>`
|
|
78
|
+
* e.g. `~/nargo/github.com/AztecProtocol/aztec-packages/v0.82.0`
|
|
79
|
+
*
|
|
80
|
+
* Source: noir/noir-repo/tooling/nargo_toml/src/git.rs
|
|
81
|
+
*/ export function nargoGitDepPath(gitUrl, tag) {
|
|
82
|
+
const url = new URL(gitUrl);
|
|
83
|
+
const domain = url.hostname;
|
|
84
|
+
const repoPath = url.pathname.replace(/^\//, '');
|
|
85
|
+
return join(process.env.HOME ?? homedir(), 'nargo', domain, repoPath, tag);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Ensures a git dep is present in the nargo cache, cloning it if it isn't. Mirrors nargo's `clone_git_repo`.
|
|
89
|
+
* If cloning fails (e.g. no network), throws with a message suggesting `nargo check` to prime the cache.
|
|
90
|
+
*
|
|
91
|
+
* Source: noir/noir-repo/tooling/nargo_toml/src/git.rs
|
|
92
|
+
*/ async function ensureGitDepCached(gitUrl, tag, cachePath) {
|
|
93
|
+
if (existsSync(cachePath)) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
await mkdir(dirname(cachePath), {
|
|
97
|
+
recursive: true
|
|
98
|
+
});
|
|
99
|
+
try {
|
|
100
|
+
await run('git', [
|
|
101
|
+
'-c',
|
|
102
|
+
'advice.detachedHead=false',
|
|
103
|
+
'clone',
|
|
104
|
+
'--depth',
|
|
105
|
+
'1',
|
|
106
|
+
'--branch',
|
|
107
|
+
tag,
|
|
108
|
+
gitUrl,
|
|
109
|
+
cachePath
|
|
110
|
+
]);
|
|
111
|
+
} catch (err) {
|
|
112
|
+
throw new Error(`Failed to fetch git dependency ${gitUrl}@${tag}: ${err?.message ?? err}.\n` + `Try running \`nargo check\` first to prime the dependency cache.`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* Note: The above implies that if there is a random json file in the target dir we would be always recompiling.
|
|
8
8
|
*/
|
|
9
9
|
export declare function needsRecompile(): Promise<boolean>;
|
|
10
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmVlZHNfcmVjb21waWxlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvY2xpL2NtZHMvdXRpbHMvbmVlZHNfcmVjb21waWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUtBOzs7Ozs7O0dBT0c7QUFDSCx3QkFBc0IsY0FBYyxJQUFJLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FXdkQifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"needs_recompile.d.ts","sourceRoot":"","sources":["../../../../src/cli/cmds/utils/needs_recompile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"needs_recompile.d.ts","sourceRoot":"","sources":["../../../../src/cli/cmds/utils/needs_recompile.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CAWvD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { readdir, stat } from 'fs/promises';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { collectCrateDirs } from './collect_crate_dirs.js';
|
|
4
4
|
/**
|
|
5
5
|
* Returns true if recompilation is needed: either no artifacts exist in target/ or any .nr or Nargo.toml source file
|
|
6
6
|
* (including path-based dependencies) is newer than the oldest artifact. We compare against the oldest artifact so
|
|
@@ -13,7 +13,12 @@ import { join, resolve } from 'path';
|
|
|
13
13
|
if (oldestArtifactMs === undefined) {
|
|
14
14
|
return true;
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
// Git deps are pinned to a specific tag in Nargo.toml and nargo always fetches an exact tag, so their contents never
|
|
17
|
+
// change without Nargo.toml itself changing — and Nargo.toml is already tracked as a source file. Hence we can
|
|
18
|
+
// safely ignore checking source files of git deps.
|
|
19
|
+
const crateDirs = await collectCrateDirs('.', {
|
|
20
|
+
skipGitDeps: true
|
|
21
|
+
});
|
|
17
22
|
return hasNewerSourceFile(crateDirs, oldestArtifactMs);
|
|
18
23
|
}
|
|
19
24
|
/**
|
|
@@ -41,55 +46,6 @@ import { join, resolve } from 'path';
|
|
|
41
46
|
}
|
|
42
47
|
return oldest;
|
|
43
48
|
}
|
|
44
|
-
/**
|
|
45
|
-
* Recursively collects crate directories starting from startCrateDir by following path-based dependencies declared in
|
|
46
|
-
* Nargo.toml files. Git-based deps are ignored (they only change when Nargo.toml itself is modified since the deps are
|
|
47
|
-
* tagged).
|
|
48
|
-
*/ async function collectCrateDirs(startCrateDir) {
|
|
49
|
-
// We have a set of visited dirs we check against when entering a new dir because we could stumble upon a directory
|
|
50
|
-
// multiple times in case multiple deps shared a dep (e.g. dep A and dep B both sharing dep C).
|
|
51
|
-
const visited = new Set();
|
|
52
|
-
async function visit(crateDir) {
|
|
53
|
-
const absDir = resolve(crateDir);
|
|
54
|
-
if (visited.has(absDir)) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
visited.add(absDir);
|
|
58
|
-
// Every dep is its own crate and every crate needs to have Nargo.toml defined in the root so we try to load it and
|
|
59
|
-
// error out if it's not the case.
|
|
60
|
-
const tomlPath = join(absDir, 'Nargo.toml');
|
|
61
|
-
const content = await readFile(tomlPath, 'utf-8').catch(()=>{
|
|
62
|
-
throw new Error(`Incorrectly defined dependency. Nargo.toml not found in ${absDir}`);
|
|
63
|
-
});
|
|
64
|
-
const parsed = TOML.parse(content);
|
|
65
|
-
const members = parsed.workspace?.members;
|
|
66
|
-
// A Nargo.toml is either a workspace root (has workspace.members) or a single crate (has dependencies).
|
|
67
|
-
if (Array.isArray(members)) {
|
|
68
|
-
// The crate is a workspace root and has members defined so we visit the members
|
|
69
|
-
for (const member of members){
|
|
70
|
-
const memberPath = resolve(absDir, member);
|
|
71
|
-
await visit(memberPath);
|
|
72
|
-
}
|
|
73
|
-
} else {
|
|
74
|
-
// The crate is not a workspace root so we check for dependencies
|
|
75
|
-
const deps = parsed.dependencies ?? {};
|
|
76
|
-
for (const dep of Object.values(deps)){
|
|
77
|
-
if (dep && typeof dep === 'object' && typeof dep.path === 'string') {
|
|
78
|
-
const depPath = resolve(absDir, dep.path);
|
|
79
|
-
const s = await stat(depPath);
|
|
80
|
-
if (!s.isDirectory()) {
|
|
81
|
-
throw new Error(`Dependency path "${dep.path}" in ${tomlPath} resolves to ${depPath} which is not a directory`);
|
|
82
|
-
}
|
|
83
|
-
await visit(depPath);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
await visit(startCrateDir);
|
|
89
|
-
return [
|
|
90
|
-
...visited
|
|
91
|
-
];
|
|
92
|
-
}
|
|
93
49
|
/**
|
|
94
50
|
* Walks crate dirs looking for .nr and Nargo.toml files newer than thresholdMs. Short-circuits on the first match.
|
|
95
51
|
*/ async function hasNewerSourceFile(crateDirs, thresholdMs) {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
2
|
+
/** Warns if the `aztec` dependency tag in any crate's Nargo.toml doesn't match the CLI version. */
|
|
3
|
+
export declare function warnIfAztecVersionMismatch(log: LogFn, cliVersion?: string): Promise<void>;
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2Fybl9pZl9henRlY192ZXJzaW9uX21pc21hdGNoLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvY2xpL2NtZHMvdXRpbHMvd2Fybl9pZl9henRlY192ZXJzaW9uX21pc21hdGNoLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBU25ELG1HQUFtRztBQUNuRyx3QkFBc0IsMEJBQTBCLENBQUMsR0FBRyxFQUFFLEtBQUssRUFBRSxVQUFVLENBQUMsRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQTJDL0YifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warn_if_aztec_version_mismatch.d.ts","sourceRoot":"","sources":["../../../../src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AASnD,mGAAmG;AACnG,wBAAsB,0BAA0B,CAAC,GAAG,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA2C/F"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
2
|
+
import TOML from '@iarna/toml';
|
|
3
|
+
import { readFile } from 'fs/promises';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
import { collectCrateDirs } from './collect_crate_dirs.js';
|
|
6
|
+
/** Warns if the `aztec` dependency tag in any crate's Nargo.toml doesn't match the CLI version. */ export async function warnIfAztecVersionMismatch(log, cliVersion) {
|
|
7
|
+
const version = cliVersion ?? getPackageVersion();
|
|
8
|
+
if (!version) {
|
|
9
|
+
log(`WARNING: aztec CLI version not found. Skipping dependency compatibility check.`);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const expectedTag = `v${version}`;
|
|
13
|
+
const mismatches = [];
|
|
14
|
+
const crateDirs = await collectCrateDirs('.', {
|
|
15
|
+
skipGitDeps: true
|
|
16
|
+
});
|
|
17
|
+
for (const dir of crateDirs){
|
|
18
|
+
const tomlPath = join(dir, 'Nargo.toml');
|
|
19
|
+
let content;
|
|
20
|
+
try {
|
|
21
|
+
content = await readFile(tomlPath, 'utf-8');
|
|
22
|
+
} catch {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const parsed = TOML.parse(content);
|
|
26
|
+
const aztecDep = parsed.dependencies?.aztec;
|
|
27
|
+
if (!aztecDep || typeof aztecDep !== 'object' || typeof aztecDep.tag !== 'string') {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (aztecDep.tag !== expectedTag) {
|
|
31
|
+
mismatches.push({
|
|
32
|
+
file: tomlPath,
|
|
33
|
+
tag: aztecDep.tag
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (mismatches.length > 0) {
|
|
38
|
+
const details = mismatches.map((m)=>` ${m.file} (${m.tag})`).join('\n');
|
|
39
|
+
log(`WARNING: Aztec dependency version mismatch detected.\n` + `The following crates have an aztec dependency that does not match the CLI version (${expectedTag}):\n` + `${details}\n\n` + `See https://docs.aztec.network/errors/9 for how to update your dependencies.`);
|
|
40
|
+
}
|
|
41
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/aztec",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.9ef841308",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -28,38 +28,38 @@
|
|
|
28
28
|
"../package.common.json"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@aztec/accounts": "0.0.1-commit.
|
|
32
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
33
|
-
"@aztec/aztec-node": "0.0.1-commit.
|
|
34
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
35
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
36
|
-
"@aztec/bb.js": "0.0.1-commit.
|
|
37
|
-
"@aztec/blob-client": "0.0.1-commit.
|
|
38
|
-
"@aztec/bot": "0.0.1-commit.
|
|
39
|
-
"@aztec/builder": "0.0.1-commit.
|
|
40
|
-
"@aztec/cli": "0.0.1-commit.
|
|
41
|
-
"@aztec/constants": "0.0.1-commit.
|
|
42
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
43
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
44
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
45
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
46
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
47
|
-
"@aztec/node-lib": "0.0.1-commit.
|
|
48
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
49
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
50
|
-
"@aztec/p2p": "0.0.1-commit.
|
|
51
|
-
"@aztec/p2p-bootstrap": "0.0.1-commit.
|
|
52
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
53
|
-
"@aztec/prover-client": "0.0.1-commit.
|
|
54
|
-
"@aztec/prover-node": "0.0.1-commit.
|
|
55
|
-
"@aztec/pxe": "0.0.1-commit.
|
|
56
|
-
"@aztec/sequencer-client": "0.0.1-commit.
|
|
57
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
58
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
59
|
-
"@aztec/txe": "0.0.1-commit.
|
|
60
|
-
"@aztec/validator-ha-signer": "0.0.1-commit.
|
|
61
|
-
"@aztec/wallets": "0.0.1-commit.
|
|
62
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
31
|
+
"@aztec/accounts": "0.0.1-commit.9ef841308",
|
|
32
|
+
"@aztec/archiver": "0.0.1-commit.9ef841308",
|
|
33
|
+
"@aztec/aztec-node": "0.0.1-commit.9ef841308",
|
|
34
|
+
"@aztec/aztec.js": "0.0.1-commit.9ef841308",
|
|
35
|
+
"@aztec/bb-prover": "0.0.1-commit.9ef841308",
|
|
36
|
+
"@aztec/bb.js": "0.0.1-commit.9ef841308",
|
|
37
|
+
"@aztec/blob-client": "0.0.1-commit.9ef841308",
|
|
38
|
+
"@aztec/bot": "0.0.1-commit.9ef841308",
|
|
39
|
+
"@aztec/builder": "0.0.1-commit.9ef841308",
|
|
40
|
+
"@aztec/cli": "0.0.1-commit.9ef841308",
|
|
41
|
+
"@aztec/constants": "0.0.1-commit.9ef841308",
|
|
42
|
+
"@aztec/entrypoints": "0.0.1-commit.9ef841308",
|
|
43
|
+
"@aztec/ethereum": "0.0.1-commit.9ef841308",
|
|
44
|
+
"@aztec/foundation": "0.0.1-commit.9ef841308",
|
|
45
|
+
"@aztec/kv-store": "0.0.1-commit.9ef841308",
|
|
46
|
+
"@aztec/l1-artifacts": "0.0.1-commit.9ef841308",
|
|
47
|
+
"@aztec/node-lib": "0.0.1-commit.9ef841308",
|
|
48
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.9ef841308",
|
|
49
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.9ef841308",
|
|
50
|
+
"@aztec/p2p": "0.0.1-commit.9ef841308",
|
|
51
|
+
"@aztec/p2p-bootstrap": "0.0.1-commit.9ef841308",
|
|
52
|
+
"@aztec/protocol-contracts": "0.0.1-commit.9ef841308",
|
|
53
|
+
"@aztec/prover-client": "0.0.1-commit.9ef841308",
|
|
54
|
+
"@aztec/prover-node": "0.0.1-commit.9ef841308",
|
|
55
|
+
"@aztec/pxe": "0.0.1-commit.9ef841308",
|
|
56
|
+
"@aztec/sequencer-client": "0.0.1-commit.9ef841308",
|
|
57
|
+
"@aztec/stdlib": "0.0.1-commit.9ef841308",
|
|
58
|
+
"@aztec/telemetry-client": "0.0.1-commit.9ef841308",
|
|
59
|
+
"@aztec/txe": "0.0.1-commit.9ef841308",
|
|
60
|
+
"@aztec/validator-ha-signer": "0.0.1-commit.9ef841308",
|
|
61
|
+
"@aztec/wallets": "0.0.1-commit.9ef841308",
|
|
62
|
+
"@aztec/world-state": "0.0.1-commit.9ef841308",
|
|
63
63
|
"@iarna/toml": "^2.2.5",
|
|
64
64
|
"@types/chalk": "^2.2.0",
|
|
65
65
|
"abitype": "^0.8.11",
|
package/scripts/aztec.sh
CHANGED
|
@@ -23,7 +23,7 @@ case $cmd in
|
|
|
23
23
|
# Attempt to compile, no-op if there are no changes
|
|
24
24
|
node --no-warnings "$script_dir/../dest/bin/index.js" compile
|
|
25
25
|
|
|
26
|
-
export LOG_LEVEL="${LOG_LEVEL:-"error;trace:
|
|
26
|
+
export LOG_LEVEL="${LOG_LEVEL:-"error;trace:contract"}"
|
|
27
27
|
aztec start --txe --port 8081 &
|
|
28
28
|
server_pid=$!
|
|
29
29
|
trap 'kill $server_pid &>/dev/null || true' EXIT
|
package/src/cli/cmds/compile.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { join } from 'path';
|
|
|
9
9
|
import { readArtifactFiles } from './utils/artifacts.js';
|
|
10
10
|
import { needsRecompile } from './utils/needs_recompile.js';
|
|
11
11
|
import { run } from './utils/spawn.js';
|
|
12
|
+
import { warnIfAztecVersionMismatch } from './utils/warn_if_aztec_version_mismatch.js';
|
|
12
13
|
|
|
13
14
|
/** Returns paths to contract artifacts in the target directory. */
|
|
14
15
|
async function collectContractArtifacts(): Promise<string[]> {
|
|
@@ -139,6 +140,8 @@ async function checkNoTestsInContracts(nargo: string, log: LogFn): Promise<void>
|
|
|
139
140
|
|
|
140
141
|
/** Compiles Aztec Noir contracts and postprocesses artifacts. */
|
|
141
142
|
async function compileAztecContract(nargoArgs: string[], log: LogFn): Promise<void> {
|
|
143
|
+
await warnIfAztecVersionMismatch(log);
|
|
144
|
+
|
|
142
145
|
if (!(await needsRecompile())) {
|
|
143
146
|
log('No source changes detected, skipping compilation.');
|
|
144
147
|
return;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import TOML from '@iarna/toml';
|
|
2
|
+
import { existsSync } from 'fs';
|
|
3
|
+
import { mkdir, readFile, stat } from 'fs/promises';
|
|
4
|
+
import { homedir } from 'os';
|
|
5
|
+
import { dirname, join, resolve } from 'path';
|
|
6
|
+
|
|
7
|
+
import { run } from './spawn.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Recursively collects crate directories starting from startCrateDir by following dependencies declared in Nargo.toml
|
|
11
|
+
* files.
|
|
12
|
+
*
|
|
13
|
+
* When `skipGitDeps` is false (default), git-based deps are followed and fetched into the nargo cache
|
|
14
|
+
* (`$HOME/nargo/<domain>/<repo-path>/<tag>`) if not already present.
|
|
15
|
+
*
|
|
16
|
+
* When `skipGitDeps` is true, git-based deps are ignored entirely.
|
|
17
|
+
*/
|
|
18
|
+
export async function collectCrateDirs(startCrateDir: string, opts?: { skipGitDeps?: boolean }): Promise<string[]> {
|
|
19
|
+
const { skipGitDeps = false } = opts ?? {};
|
|
20
|
+
const visited = new Set<string>();
|
|
21
|
+
|
|
22
|
+
async function visit(crateDir: string): Promise<void> {
|
|
23
|
+
const absDir = resolve(crateDir);
|
|
24
|
+
if (visited.has(absDir)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
visited.add(absDir);
|
|
28
|
+
|
|
29
|
+
const tomlPath = join(absDir, 'Nargo.toml');
|
|
30
|
+
const content = await readFile(tomlPath, 'utf-8').catch(() => {
|
|
31
|
+
throw new Error(`Incorrectly defined dependency. Nargo.toml not found in ${absDir}`);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const parsed = TOML.parse(content) as Record<string, any>;
|
|
35
|
+
const members = (parsed.workspace as Record<string, any>)?.members as string[] | undefined;
|
|
36
|
+
|
|
37
|
+
// A Nargo.toml is either a workspace root (has workspace.members) or a single crate (has dependencies).
|
|
38
|
+
if (Array.isArray(members)) {
|
|
39
|
+
// The crate is a workspace root and has members defined so we visit the members
|
|
40
|
+
for (const member of members) {
|
|
41
|
+
await visit(resolve(absDir, member));
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
// Single crate — follow its deps
|
|
45
|
+
const deps = (parsed.dependencies as Record<string, any>) ?? {};
|
|
46
|
+
for (const dep of Object.values(deps)) {
|
|
47
|
+
if (!dep || typeof dep !== 'object') {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (typeof dep.path === 'string') {
|
|
51
|
+
// Dependency contains "path" hence it's a local dependency. We just check it's a real directory and then we
|
|
52
|
+
// recursively search through it
|
|
53
|
+
const depPath = resolve(absDir, dep.path);
|
|
54
|
+
const s = await stat(depPath);
|
|
55
|
+
if (!s.isDirectory()) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
`Dependency path "${dep.path}" in ${tomlPath} resolves to ${depPath} which is not a directory`,
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
await visit(depPath);
|
|
61
|
+
} else if (!skipGitDeps && typeof dep.git === 'string' && typeof dep.tag === 'string') {
|
|
62
|
+
// Dependency contains "git" hence it's a git dependency. We ensure it has been fetched and fetch it if
|
|
63
|
+
// it's not the case and then we recursively search through it.
|
|
64
|
+
await fetchAndVisit(dep.git, dep.tag, dep.directory);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function fetchAndVisit(gitUrl: string, tag: string, directory?: string): Promise<void> {
|
|
71
|
+
// `directory` is set when the dep lives in a subdirectory of a repository, e.g.:
|
|
72
|
+
// aztec = { git = "https://github.com/AztecProtocol/aztec-packages", tag = "v0.82.0",
|
|
73
|
+
// directory = "noir-projects/aztec-nr/aztec" }
|
|
74
|
+
// In that case nargo clones the whole repo and the crate root is <cachePath>/<directory>.
|
|
75
|
+
const cachePath = nargoGitDepPath(gitUrl, tag);
|
|
76
|
+
const crateDir = directory ? join(cachePath, directory) : cachePath;
|
|
77
|
+
await ensureGitDepCached(gitUrl, tag, cachePath);
|
|
78
|
+
await visit(crateDir);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
await visit(startCrateDir);
|
|
82
|
+
return [...visited];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Computes the local nargo cache path for a git dependency, mirroring nargo's own `git_dep_location` function.
|
|
87
|
+
* Path format: `$HOME/nargo/<domain>/<repo-path>/<tag>`
|
|
88
|
+
* e.g. `~/nargo/github.com/AztecProtocol/aztec-packages/v0.82.0`
|
|
89
|
+
*
|
|
90
|
+
* Source: noir/noir-repo/tooling/nargo_toml/src/git.rs
|
|
91
|
+
*/
|
|
92
|
+
export function nargoGitDepPath(gitUrl: string, tag: string): string {
|
|
93
|
+
const url = new URL(gitUrl);
|
|
94
|
+
const domain = url.hostname;
|
|
95
|
+
const repoPath = url.pathname.replace(/^\//, '');
|
|
96
|
+
return join(process.env.HOME ?? homedir(), 'nargo', domain, repoPath, tag);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Ensures a git dep is present in the nargo cache, cloning it if it isn't. Mirrors nargo's `clone_git_repo`.
|
|
101
|
+
* If cloning fails (e.g. no network), throws with a message suggesting `nargo check` to prime the cache.
|
|
102
|
+
*
|
|
103
|
+
* Source: noir/noir-repo/tooling/nargo_toml/src/git.rs
|
|
104
|
+
*/
|
|
105
|
+
async function ensureGitDepCached(gitUrl: string, tag: string, cachePath: string): Promise<void> {
|
|
106
|
+
if (existsSync(cachePath)) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
await mkdir(dirname(cachePath), { recursive: true });
|
|
110
|
+
try {
|
|
111
|
+
await run('git', ['-c', 'advice.detachedHead=false', 'clone', '--depth', '1', '--branch', tag, gitUrl, cachePath]);
|
|
112
|
+
} catch (err: any) {
|
|
113
|
+
throw new Error(
|
|
114
|
+
`Failed to fetch git dependency ${gitUrl}@${tag}: ${err?.message ?? err}.\n` +
|
|
115
|
+
`Try running \`nargo check\` first to prime the dependency cache.`,
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { readdir, stat } from 'fs/promises';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
|
|
4
|
+
import { collectCrateDirs } from './collect_crate_dirs.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Returns true if recompilation is needed: either no artifacts exist in target/ or any .nr or Nargo.toml source file
|
|
@@ -16,7 +17,10 @@ export async function needsRecompile(): Promise<boolean> {
|
|
|
16
17
|
return true;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
// Git deps are pinned to a specific tag in Nargo.toml and nargo always fetches an exact tag, so their contents never
|
|
21
|
+
// change without Nargo.toml itself changing — and Nargo.toml is already tracked as a source file. Hence we can
|
|
22
|
+
// safely ignore checking source files of git deps.
|
|
23
|
+
const crateDirs = await collectCrateDirs('.', { skipGitDeps: true });
|
|
20
24
|
return hasNewerSourceFile(crateDirs, oldestArtifactMs);
|
|
21
25
|
}
|
|
22
26
|
|
|
@@ -49,63 +53,6 @@ async function getOldestArtifactModificationTime(targetDir: string): Promise<num
|
|
|
49
53
|
return oldest;
|
|
50
54
|
}
|
|
51
55
|
|
|
52
|
-
/**
|
|
53
|
-
* Recursively collects crate directories starting from startCrateDir by following path-based dependencies declared in
|
|
54
|
-
* Nargo.toml files. Git-based deps are ignored (they only change when Nargo.toml itself is modified since the deps are
|
|
55
|
-
* tagged).
|
|
56
|
-
*/
|
|
57
|
-
async function collectCrateDirs(startCrateDir: string): Promise<string[]> {
|
|
58
|
-
// We have a set of visited dirs we check against when entering a new dir because we could stumble upon a directory
|
|
59
|
-
// multiple times in case multiple deps shared a dep (e.g. dep A and dep B both sharing dep C).
|
|
60
|
-
const visited = new Set<string>();
|
|
61
|
-
|
|
62
|
-
async function visit(crateDir: string): Promise<void> {
|
|
63
|
-
const absDir = resolve(crateDir);
|
|
64
|
-
if (visited.has(absDir)) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
visited.add(absDir);
|
|
68
|
-
|
|
69
|
-
// Every dep is its own crate and every crate needs to have Nargo.toml defined in the root so we try to load it and
|
|
70
|
-
// error out if it's not the case.
|
|
71
|
-
const tomlPath = join(absDir, 'Nargo.toml');
|
|
72
|
-
const content = await readFile(tomlPath, 'utf-8').catch(() => {
|
|
73
|
-
throw new Error(`Incorrectly defined dependency. Nargo.toml not found in ${absDir}`);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
const parsed = TOML.parse(content) as Record<string, any>;
|
|
77
|
-
|
|
78
|
-
const members = (parsed.workspace as Record<string, any>)?.members as string[] | undefined;
|
|
79
|
-
|
|
80
|
-
// A Nargo.toml is either a workspace root (has workspace.members) or a single crate (has dependencies).
|
|
81
|
-
if (Array.isArray(members)) {
|
|
82
|
-
// The crate is a workspace root and has members defined so we visit the members
|
|
83
|
-
for (const member of members) {
|
|
84
|
-
const memberPath = resolve(absDir, member);
|
|
85
|
-
await visit(memberPath);
|
|
86
|
-
}
|
|
87
|
-
} else {
|
|
88
|
-
// The crate is not a workspace root so we check for dependencies
|
|
89
|
-
const deps = (parsed.dependencies as Record<string, any>) ?? {};
|
|
90
|
-
for (const dep of Object.values(deps)) {
|
|
91
|
-
if (dep && typeof dep === 'object' && typeof dep.path === 'string') {
|
|
92
|
-
const depPath = resolve(absDir, dep.path);
|
|
93
|
-
const s = await stat(depPath);
|
|
94
|
-
if (!s.isDirectory()) {
|
|
95
|
-
throw new Error(
|
|
96
|
-
`Dependency path "${dep.path}" in ${tomlPath} resolves to ${depPath} which is not a directory`,
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
await visit(depPath);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
await visit(startCrateDir);
|
|
106
|
-
return [...visited];
|
|
107
|
-
}
|
|
108
|
-
|
|
109
56
|
/**
|
|
110
57
|
* Walks crate dirs looking for .nr and Nargo.toml files newer than thresholdMs. Short-circuits on the first match.
|
|
111
58
|
*/
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
2
|
+
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
3
|
+
|
|
4
|
+
import TOML from '@iarna/toml';
|
|
5
|
+
import { readFile } from 'fs/promises';
|
|
6
|
+
import { join } from 'path';
|
|
7
|
+
|
|
8
|
+
import { collectCrateDirs } from './collect_crate_dirs.js';
|
|
9
|
+
|
|
10
|
+
/** Warns if the `aztec` dependency tag in any crate's Nargo.toml doesn't match the CLI version. */
|
|
11
|
+
export async function warnIfAztecVersionMismatch(log: LogFn, cliVersion?: string): Promise<void> {
|
|
12
|
+
const version = cliVersion ?? getPackageVersion();
|
|
13
|
+
if (!version) {
|
|
14
|
+
log(`WARNING: aztec CLI version not found. Skipping dependency compatibility check.`);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const expectedTag = `v${version}`;
|
|
19
|
+
const mismatches: { file: string; tag: string }[] = [];
|
|
20
|
+
|
|
21
|
+
const crateDirs = await collectCrateDirs('.', { skipGitDeps: true });
|
|
22
|
+
|
|
23
|
+
for (const dir of crateDirs) {
|
|
24
|
+
const tomlPath = join(dir, 'Nargo.toml');
|
|
25
|
+
let content: string;
|
|
26
|
+
try {
|
|
27
|
+
content = await readFile(tomlPath, 'utf-8');
|
|
28
|
+
} catch {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const parsed = TOML.parse(content) as Record<string, any>;
|
|
33
|
+
const aztecDep = (parsed.dependencies as Record<string, any>)?.aztec;
|
|
34
|
+
if (!aztecDep || typeof aztecDep !== 'object' || typeof aztecDep.tag !== 'string') {
|
|
35
|
+
// If a dep called "aztec" doesn't exist or it does not get parsed to an object or it doesn't have a tag defined
|
|
36
|
+
// we skip the check.
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (aztecDep.tag !== expectedTag) {
|
|
41
|
+
mismatches.push({ file: tomlPath, tag: aztecDep.tag });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (mismatches.length > 0) {
|
|
46
|
+
const details = mismatches.map(m => ` ${m.file} (${m.tag})`).join('\n');
|
|
47
|
+
log(
|
|
48
|
+
`WARNING: Aztec dependency version mismatch detected.\n` +
|
|
49
|
+
`The following crates have an aztec dependency that does not match the CLI version (${expectedTag}):\n` +
|
|
50
|
+
`${details}\n\n` +
|
|
51
|
+
`See https://docs.aztec.network/errors/9 for how to update your dependencies.`,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|