diff --git a/src/analyser/__snapshots__/index.test.ts.snap b/src/analyser/__snapshots__/index.test.ts.snap index c70e8324..f5b92c4f 100644 --- a/src/analyser/__snapshots__/index.test.ts.snap +++ b/src/analyser/__snapshots__/index.test.ts.snap @@ -255,7 +255,7 @@ exports[`analyser > should run correctly 1`] = ` ], ], "edges": [], - "id": "18", + "id": "19", "inComponent": null, "languages": {}, "name": "GCP", @@ -275,7 +275,7 @@ exports[`analyser > should run correctly 1`] = ` ], ], "edges": [], - "id": "19", + "id": "20", "inComponent": null, "languages": {}, "name": "Vercel", @@ -285,6 +285,30 @@ exports[`analyser > should run correctly 1`] = ` "tech": "vercel", "techs": [], }, + { + "childs": [], + "dependencies": [ + [ + "rustcargo", + "dotenv", + "0.15.0", + ], + ], + "edges": [], + "id": "17", + "inComponent": null, + "languages": { + "TOML": 1, + }, + "name": "rust-server", + "path": [ + "/pkgs/rust/Cargo.toml", + ], + "tech": null, + "techs": [ + "rust", + ], + }, ], "dependencies": [ [ @@ -515,7 +539,7 @@ exports[`analyser > should run correctly 2`] = ` ], ], "edges": [], - "id": "18", + "id": "19", "inComponent": null, "languages": {}, "name": "GCP", @@ -606,6 +630,7 @@ exports[`analyser > should run correctly 2`] = ` "HTML": 1, "JSON": 3, "SCSS": 1, + "TOML": 1, "YAML": 1, }, "name": "fake", @@ -642,6 +667,30 @@ exports[`analyser > should run correctly 2`] = ` "tech": "redis", "techs": [], }, + { + "childs": [], + "dependencies": [ + [ + "rustcargo", + "dotenv", + "0.15.0", + ], + ], + "edges": [], + "id": "17", + "inComponent": null, + "languages": { + "TOML": 1, + }, + "name": "rust-server", + "path": [ + "/pkgs/rust/Cargo.toml", + ], + "tech": null, + "techs": [ + "rust", + ], + }, { "childs": [], "dependencies": [ @@ -742,6 +791,11 @@ exports[`analyser > should run correctly 2`] = ` "vite", "4.3.3", ], + [ + "rustcargo", + "dotenv", + "0.15.0", + ], [ "terraform", "registry.terraform.io/hashicorp/google", @@ -774,13 +828,14 @@ exports[`analyser > should run correctly 2`] = ` ], ], "edges": [], - "id": "20", + "id": "21", "inComponent": null, "languages": { "HCL": 2, "HTML": 3, "JSON": 8, "SCSS": 3, + "TOML": 3, "YAML": 2, }, "name": "flatten", @@ -790,6 +845,7 @@ exports[`analyser > should run correctly 2`] = ` "/pkgs/api/package.json", "/pkgs/app/package.json", "/terraform/.terraform.lock.hcl", + "/pkgs/rust/Cargo.toml", "/package.json", ], "tech": null, @@ -806,6 +862,7 @@ exports[`analyser > should run correctly 2`] = ` "prisma", "react", "redis", + "rust", "scss", "terraform", "typescript", diff --git a/src/rules/spec/rust/__snapshots__/component.test.ts.snap b/src/rules/spec/rust/__snapshots__/component.test.ts.snap index 26a25d47..075a5163 100644 --- a/src/rules/spec/rust/__snapshots__/component.test.ts.snap +++ b/src/rules/spec/rust/__snapshots__/component.test.ts.snap @@ -225,3 +225,38 @@ exports[`rust (component) > should match everything 2`] = ` ], ] `; + +exports[`rust (component) > should match foreign dependencies 1`] = ` +[ + [ + "rustcargo", + "anyhow", + "1.0.56", + ], + [ + "rustcargo", + "axum", + "0.6.1", + ], + [ + "rustcargo", + "foobar", + "^1.0.0", + ], + [ + "rustcargo", + "hello", + "path:../world:1.0.0", + ], + [ + "rustcargo", + "redis_cluster_async", + "git:https://github.com/redis-rs/redis-cluster-async.git#e6fe168", + ], + [ + "rustcargo", + "test", + "path:../test", + ], +] +`; diff --git a/src/rules/spec/rust/component.test.ts b/src/rules/spec/rust/component.test.ts index 4f673b51..8388229d 100644 --- a/src/rules/spec/rust/component.test.ts +++ b/src/rules/spec/rust/component.test.ts @@ -40,4 +40,39 @@ version = "1.8.0" expect(merged.techs).toMatchSnapshot(); expect(Array.from(merged.dependencies).sort()).toMatchSnapshot(); }); + + it('should match foreign dependencies', async () => { + const lockfile: string[] = [ + `[package] +name = "svix-server" +version = "1.8.0" + +[dependencies] +test = { path = "../test" } +hello = { path = "../world", version = "1.0.0" } +axum = { version = "0.6.1", features = ["headers"] } + +[dev-dependencies] +anyhow = "1.0.56" +redis_cluster_async = { git = "https://github.com/redis-rs/redis-cluster-async.git", rev = "e6fe168" } + +[build-dependencies] +foobar = "^1.0.0" +`, + ]; + + const res = await analyser({ + provider: new FakeProvider({ + paths: { + '/': ['Cargo.toml'], + }, + files: { + '/Cargo.toml': lockfile.join(''), + }, + }), + }); + + const merged = flatten(res, { merge: true }); + expect(Array.from(merged.dependencies).sort()).toMatchSnapshot(); + }); }); diff --git a/src/rules/spec/rust/component.ts b/src/rules/spec/rust/component.ts index 5c6f1a47..3f302fc1 100644 --- a/src/rules/spec/rust/component.ts +++ b/src/rules/spec/rust/component.ts @@ -71,7 +71,7 @@ export const detectRustComponent: ComponentMatcher = async ( return [ 'rustcargo', name, - `path:${value.path}${value.version || ''}`, + `path:${value.path}${value.version ? `:${value.version}` : ''}`, ]; } if ('git' in value) { diff --git a/tests/__fixtures__/pkgs/rust/Cargo.toml b/tests/__fixtures__/pkgs/rust/Cargo.toml new file mode 100644 index 00000000..44c0b449 --- /dev/null +++ b/tests/__fixtures__/pkgs/rust/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "rust-server" +version = "1.0.0" +license = "MIT" +description = "Foobar" + +[dependencies] +dotenv = "0.15.0"