@layerzerolabs/build-utils-rust 0.2.120 → 0.2.123
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/.turbo/turbo-build.log +21 -21
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-test.log +18 -6
- package/README.md +5 -3
- package/dist/{457ZJTJH.js → NVUOVNKE.js} +3 -3
- package/dist/{457ZJTJH.js.map → NVUOVNKE.js.map} +1 -1
- package/dist/{SPODHCGD.js → PSAML6YW.js} +3 -3
- package/dist/{SPODHCGD.js.map → PSAML6YW.js.map} +1 -1
- package/dist/{TOEFRNPD.js → UB65DPGZ.js} +5 -5
- package/dist/{TOEFRNPD.js.map → UB65DPGZ.js.map} +1 -1
- package/dist/{WKRDI535.js → XEADETHB.js} +7 -3
- package/dist/XEADETHB.js.map +1 -0
- package/dist/{LQ26FJL3.js → ZH2AZQUX.js} +19 -16
- package/dist/ZH2AZQUX.js.map +1 -0
- package/dist/cli.js +5 -5
- package/dist/index.js +5 -5
- package/dist/resolve/discover.js +3 -3
- package/dist/resolve/exclude.d.ts.map +1 -1
- package/dist/resolve/exclude.js +1 -1
- package/dist/resolve/index.js +5 -5
- package/dist/resolve/io.js +2 -2
- package/dist/resolve/rewrite.d.ts.map +1 -1
- package/dist/resolve/rewrite.js +4 -4
- package/package.json +7 -5
- package/src/resolve/exclude.ts +4 -0
- package/src/resolve/rewrite.ts +35 -14
- package/tests/resolve/discover.test.ts +10 -11
- package/tests/resolve/fixtures/oft-core-with-stale-deep-deps.toml +11 -0
- package/tests/resolve/fixtures/stellar-consumer.toml +2 -2
- package/tests/resolve/fixtures/stellar-workspace-root.toml +4 -4
- package/tests/resolve/fixtures/stellar-workspace-with-tests.toml +2 -2
- package/tests/resolve/index.test.ts +182 -28
- package/tests/resolve/rewrite.test.ts +84 -0
- package/dist/LQ26FJL3.js.map +0 -1
- package/dist/WKRDI535.js.map +0 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -10,34 +10,34 @@
|
|
|
10
10
|
[34mCLI[39m Target: ES2023
|
|
11
11
|
[34mCLI[39m Cleaning output folder
|
|
12
12
|
[34mESM[39m Build start
|
|
13
|
-
[32mESM[39m [1mdist/cli.js [22m[32m1.29 KB[39m
|
|
14
|
-
[32mESM[39m [1mdist/resolve/exclude.js [22m[32m187.00 B[39m
|
|
15
13
|
[32mESM[39m [1mdist/index.js [22m[32m264.00 B[39m
|
|
16
|
-
[32mESM[39m [1mdist/logger.js [22m[32m171.00 B[39m
|
|
17
14
|
[32mESM[39m [1mdist/resolve/index.js [22m[32m297.00 B[39m
|
|
15
|
+
[32mESM[39m [1mdist/cli.js [22m[32m1.29 KB[39m
|
|
16
|
+
[32mESM[39m [1mdist/logger.js [22m[32m171.00 B[39m
|
|
18
17
|
[32mESM[39m [1mdist/resolve/discover.js [22m[32m250.00 B[39m
|
|
19
18
|
[32mESM[39m [1mdist/resolve/io.js [22m[32m224.00 B[39m
|
|
20
|
-
[32mESM[39m [1mdist/
|
|
21
|
-
[32mESM[39m [1mdist/
|
|
22
|
-
[32mESM[39m [1mdist/
|
|
23
|
-
[32mESM[39m [1mdist/
|
|
19
|
+
[32mESM[39m [1mdist/ZH2AZQUX.js [22m[32m4.71 KB[39m
|
|
20
|
+
[32mESM[39m [1mdist/NVUOVNKE.js [22m[32m1.71 KB[39m
|
|
21
|
+
[32mESM[39m [1mdist/UB65DPGZ.js [22m[32m3.20 KB[39m
|
|
22
|
+
[32mESM[39m [1mdist/PSAML6YW.js [22m[32m1.78 KB[39m
|
|
24
23
|
[32mESM[39m [1mdist/UDDAJZY4.js [22m[32m796.00 B[39m
|
|
25
|
-
[32mESM[39m [1mdist/SPODHCGD.js [22m[32m1.78 KB[39m
|
|
26
|
-
[32mESM[39m [1mdist/WKRDI535.js [22m[32m1.20 KB[39m
|
|
27
24
|
[32mESM[39m [1mdist/VUOMXK5T.js [22m[32m222.00 B[39m
|
|
28
|
-
[32mESM[39m [1mdist/
|
|
29
|
-
[32mESM[39m [1mdist/resolve/
|
|
30
|
-
[32mESM[39m [1mdist/resolve/
|
|
25
|
+
[32mESM[39m [1mdist/XEADETHB.js [22m[32m1.29 KB[39m
|
|
26
|
+
[32mESM[39m [1mdist/resolve/rewrite.js [22m[32m333.00 B[39m
|
|
27
|
+
[32mESM[39m [1mdist/resolve/exclude.js [22m[32m187.00 B[39m
|
|
31
28
|
[32mESM[39m [1mdist/index.js.map [22m[32m69.00 B[39m
|
|
32
|
-
[32mESM[39m [1mdist/resolve/
|
|
29
|
+
[32mESM[39m [1mdist/resolve/index.js.map [22m[32m69.00 B[39m
|
|
33
30
|
[32mESM[39m [1mdist/logger.js.map [22m[32m70.00 B[39m
|
|
34
|
-
[32mESM[39m [1mdist/
|
|
35
|
-
[32mESM[39m [1mdist/resolve/
|
|
36
|
-
[32mESM[39m [1mdist/resolve/
|
|
37
|
-
[32mESM[39m [1mdist/
|
|
31
|
+
[32mESM[39m [1mdist/cli.js.map [22m[32m2.44 KB[39m
|
|
32
|
+
[32mESM[39m [1mdist/resolve/discover.js.map [22m[32m72.00 B[39m
|
|
33
|
+
[32mESM[39m [1mdist/resolve/io.js.map [22m[32m66.00 B[39m
|
|
34
|
+
[32mESM[39m [1mdist/ZH2AZQUX.js.map [22m[32m14.05 KB[39m
|
|
35
|
+
[32mESM[39m [1mdist/NVUOVNKE.js.map [22m[32m5.33 KB[39m
|
|
36
|
+
[32mESM[39m [1mdist/UB65DPGZ.js.map [22m[32m8.64 KB[39m
|
|
37
|
+
[32mESM[39m [1mdist/PSAML6YW.js.map [22m[32m4.67 KB[39m
|
|
38
38
|
[32mESM[39m [1mdist/UDDAJZY4.js.map [22m[32m1.55 KB[39m
|
|
39
|
-
[32mESM[39m [1mdist/SPODHCGD.js.map [22m[32m4.67 KB[39m
|
|
40
|
-
[32mESM[39m [1mdist/WKRDI535.js.map [22m[32m2.67 KB[39m
|
|
41
39
|
[32mESM[39m [1mdist/VUOMXK5T.js.map [22m[32m72.00 B[39m
|
|
42
|
-
[32mESM[39m [1mdist/
|
|
43
|
-
[32mESM[39m
|
|
40
|
+
[32mESM[39m [1mdist/resolve/rewrite.js.map [22m[32m71.00 B[39m
|
|
41
|
+
[32mESM[39m [1mdist/XEADETHB.js.map [22m[32m2.82 KB[39m
|
|
42
|
+
[32mESM[39m [1mdist/resolve/exclude.js.map [22m[32m71.00 B[39m
|
|
43
|
+
[32mESM[39m ⚡️ Build success in 165ms
|
package/.turbo/turbo-lint.log
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
> @layerzerolabs/build-utils-rust@0.0.0 lint /home/runner/work/monorepo-internal/monorepo-internal/tools/vm-utils/rust/build-utils
|
|
3
3
|
> eslint . --max-warnings 0 || (eslint . --fix --max-warnings 0 && false)
|
|
4
4
|
|
|
5
|
-
(node:
|
|
5
|
+
(node:123043) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///home/runner/work/monorepo-internal/monorepo-internal/eslint.config.js?mtime=1784049828918 is not specified and it doesn't parse as CommonJS.
|
|
6
6
|
Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
|
|
7
7
|
To eliminate this warning, add "type": "module" to /home/runner/work/monorepo-internal/monorepo-internal/package.json.
|
|
8
8
|
(Use `node --trace-warnings ...` to show where the warning was created)
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -13,14 +13,14 @@ Breaking changes might not follow SemVer, please pin Vitest's version when using
|
|
|
13
13
|
[90mstdout[2m | tests/resolve/index.test.ts[2m > [22m[2mresolveDependencies — workspace mode ([workspace] members)[2m > [22m[2mplaces dependencies/ at workspace root when root Cargo.toml has [workspace]
|
|
14
14
|
[22m[39m[INFO] Resolved 1 Cargo dependencies into dependencies
|
|
15
15
|
|
|
16
|
+
[32m✓[39m tests/resolve/discover.test.ts [2m([22m[2m16 tests[22m[2m)[22m[32m 26[2mms[22m[39m
|
|
16
17
|
[90mstdout[2m | tests/resolve/index.test.ts[2m > [22m[2mresolveDependencies — transitive dep rewriting[2m > [22m[2mrewrites paths inside copied crates to point to flat siblings
|
|
17
18
|
[22m[39m[INFO] Resolved 2 Cargo dependencies into dependencies
|
|
18
19
|
|
|
19
|
-
[32m✓[39m tests/resolve/discover.test.ts [2m([22m[2m16 tests[22m[2m)[22m[32m 30[2mms[22m[39m
|
|
20
20
|
[90mstdout[2m | tests/resolve/index.test.ts[2m > [22m[2mresolveDependencies — transitive dep rewriting[2m > [22m[2mstrips root-only Cargo tables from copied dependency manifests
|
|
21
21
|
[22m[39m[INFO] Resolved 1 Cargo dependencies into dependencies
|
|
22
22
|
|
|
23
|
-
[32m✓[39m tests/resolve/rewrite.test.ts [2m([22m[
|
|
23
|
+
[32m✓[39m tests/resolve/rewrite.test.ts [2m([22m[2m22 tests[22m[2m)[22m[32m 38[2mms[22m[39m
|
|
24
24
|
[90mstdout[2m | tests/resolve/index.test.ts[2m > [22m[2mresolveDependencies — Stellar workspace dependency vendoring[2m > [22m[2mcopies the whole workspace tree, including deeply nested members
|
|
25
25
|
[22m[39m[INFO] Resolved 1 Cargo dependencies into dependencies
|
|
26
26
|
|
|
@@ -33,12 +33,24 @@ Breaking changes might not follow SemVer, please pin Vitest's version when using
|
|
|
33
33
|
[90mstdout[2m | tests/resolve/index.test.ts[2m > [22m[2mresolveDependencies — Stellar workspace dependency vendoring[2m > [22m[2mvendors the deep member the consumer path-deps into
|
|
34
34
|
[22m[39m[INFO] Resolved 1 Cargo dependencies into dependencies
|
|
35
35
|
|
|
36
|
+
[90mstdout[2m | tests/resolve/index.test.ts[2m > [22m[2mresolveDependencies — Stellar workspace dependency vendoring[2m > [22m[2mrewrites arbitrary-depth paths inside a vendored oft-core crate
|
|
37
|
+
[22m[39m[INFO] Resolved 2 Cargo dependencies into dependencies
|
|
38
|
+
|
|
39
|
+
[90mstdout[2m | tests/resolve/index.test.ts[2m > [22m[2mresolveDependencies — production npm dependency closure[2m > [22m[2mvendors the full production closure reachable through npm dependencies only
|
|
40
|
+
[22m[39m[INFO] Resolved 3 Cargo dependencies into dependencies
|
|
41
|
+
|
|
42
|
+
[90mstdout[2m | tests/resolve/index.test.ts[2m > [22m[2mresolveDependencies — production npm dependency closure[2m > [22m[2mdoes not vendor crates that exist only as npm devDependencies
|
|
43
|
+
[22m[39m[INFO] Resolved 1 Cargo dependencies into dependencies
|
|
44
|
+
|
|
36
45
|
[90mstdout[2m | tests/resolve/index.test.ts[2m > [22m[2mresolveDependencies — prune excluded workspace members[2m > [22m[2mdrops the excluded member from the preserved root manifest, keeps real members
|
|
37
46
|
[22m[39m[INFO] Resolved 1 Cargo dependencies into dependencies
|
|
38
47
|
|
|
39
48
|
[90mstdout[2m | tests/resolve/index.test.ts[2m > [22m[2mresolveDependencies — prune excluded workspace members[2m > [22m[2mdoes not vendor the excluded subtree at all
|
|
40
49
|
[22m[39m[INFO] Resolved 1 Cargo dependencies into dependencies
|
|
41
50
|
|
|
51
|
+
[90mstdout[2m | tests/resolve/index.test.ts[2m > [22m[2mresolveDependencies — excludes integration test dirs from vendored crates[2m > [22m[2mdoes not vendor integration-tests/ or integration_tests/ subtrees
|
|
52
|
+
[22m[39m[INFO] Resolved 1 Cargo dependencies into dependencies
|
|
53
|
+
|
|
42
54
|
[90mstdout[2m | tests/resolve/index.test.ts[2m > [22m[2mresolveDependencies — single-crate consumer (no [workspace])[2m > [22m[2mplaces dependencies/ next to the crate Cargo.toml
|
|
43
55
|
[22m[39m[INFO] Resolved 1 Cargo dependencies into dependencies
|
|
44
56
|
|
|
@@ -48,11 +60,11 @@ Breaking changes might not follow SemVer, please pin Vitest's version when using
|
|
|
48
60
|
[90mstdout[2m | tests/resolve/index.test.ts[2m > [22m[2mresolveDependencies — error handling[2m > [22m[2mempty node_modules does not change dependencies state[2m > [22m[2mdependencies already exists
|
|
49
61
|
[22m[39m[INFO] No @layerzerolabs namespaced Cargo dependencies found in node_modules
|
|
50
62
|
|
|
51
|
-
[32m✓[39m tests/resolve/index.test.ts [2m([22m[
|
|
63
|
+
[32m✓[39m tests/resolve/index.test.ts [2m([22m[2m18 tests[22m[2m)[22m[32m 157[2mms[22m[39m
|
|
52
64
|
|
|
53
65
|
[2m Test Files [22m [1m[32m3 passed[39m[22m[90m (3)[39m
|
|
54
|
-
[2m Tests [22m [1m[
|
|
66
|
+
[2m Tests [22m [1m[32m56 passed[39m[22m[90m (56)[39m
|
|
55
67
|
[2mType Errors [22m [2mno errors[22m
|
|
56
|
-
[2m Start at [22m
|
|
57
|
-
[2m Duration [22m
|
|
68
|
+
[2m Start at [22m 17:29:23
|
|
69
|
+
[2m Duration [22m 684ms[2m (transform 236ms, setup 0ms, collect 615ms, tests 221ms, environment 1ms, prepare 350ms)[22m
|
|
58
70
|
|
package/README.md
CHANGED
|
@@ -84,7 +84,8 @@ When a resolved dependency is itself a Cargo workspace (e.g.
|
|
|
84
84
|
into `dependencies/<pkg>/` with its `[workspace]` root manifest preserved. That
|
|
85
85
|
keeps the vendored member crates' workspace inheritance intact, and lets a
|
|
86
86
|
consumer path-dep into a sub-crate any number of levels deep, e.g.
|
|
87
|
-
`dependencies/protocol-stellar-v2/
|
|
87
|
+
`dependencies/protocol-stellar-v2/endpoint-v2` or
|
|
88
|
+
`dependencies/oft-core-stellar-contracts`.
|
|
88
89
|
|
|
89
90
|
#### Consuming the vendored crates
|
|
90
91
|
|
|
@@ -95,8 +96,9 @@ directly (the same way the Solana packages do):
|
|
|
95
96
|
```toml
|
|
96
97
|
# package Cargo.toml
|
|
97
98
|
[dependencies]
|
|
98
|
-
utils = { path = "dependencies/
|
|
99
|
-
oft-core = { path = "dependencies/
|
|
99
|
+
utils = { path = "dependencies/common-utils-stellar-contracts" }
|
|
100
|
+
oft-core = { path = "dependencies/oft-core-stellar-contracts" }
|
|
101
|
+
endpoint-v2 = { path = "dependencies/protocol-stellar-v2/endpoint-v2", features = ["library"] }
|
|
100
102
|
```
|
|
101
103
|
|
|
102
104
|
Typically wired into a package's `build` script ahead of the Cargo build so
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { tryRealpath, tryReaddir } from './
|
|
1
|
+
import { tryRealpath, tryReaddir } from './PSAML6YW.js';
|
|
2
2
|
import { logger } from './UDDAJZY4.js';
|
|
3
3
|
import { __name } from './VUOMXK5T.js';
|
|
4
4
|
import { stat, access, readFile } from 'fs/promises';
|
|
@@ -48,5 +48,5 @@ var discoverPackages = /* @__PURE__ */ __name(async (dir, discovered, visited) =
|
|
|
48
48
|
}, "discoverPackages");
|
|
49
49
|
|
|
50
50
|
export { discoverPackages, isCrate, isWorkspaceRoot };
|
|
51
|
-
//# sourceMappingURL=
|
|
52
|
-
//# sourceMappingURL=
|
|
51
|
+
//# sourceMappingURL=NVUOVNKE.js.map
|
|
52
|
+
//# sourceMappingURL=NVUOVNKE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/resolve/discover.ts"],"names":["LZ_SCOPE","isCrate","dir","stats","stat","isDirectory","access","join","isWorkspaceRoot","crateRoot","manifestPath","raw","readFile","parse","workspace","err","logger","warn","discoverPackages","discovered","visited","realDir","tryRealpath","has","add","nodeModulesDir","pkgName","tryReaddir","realPath","isValidCratePath","set"],"mappings":";;;;;;;AAaA,IAAMA,QAAAA,GAAW,gBAAA;AAmBV,IAAMC,OAAAA,iCAAiBC,GAAAA,KAAAA;AAC1B,EAAA,IAAI;AACA,IAAA,MAAMC,KAAAA,GAAQ,MAAMC,IAAAA,CAAKF,GAAAA,CAAAA;AACzB,IAAA,IAAI,CAACC,KAAAA,CAAME,WAAAA,EAAW,EAAI,OAAO,KAAA;AACjC,IAAA,MAAMC,MAAAA,CAAOC,IAAAA,CAAKL,GAAAA,EAAK,YAAA,CAAA,CAAA;AACvB,IAAA,OAAO,IAAA;EACX,CAAA,CAAA,MAAQ;AACJ,IAAA,OAAO,KAAA;AACX,EAAA;AACJ,CAAA,EATuB,SAAA;AAYhB,IAAMM,eAAAA,iCAAyBC,SAAAA,KAAAA;AAClC,EAAA,MAAMC,YAAAA,GAAeH,IAAAA,CAAKE,SAAA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IAAA,IAAI,CAACV,UAAAA,CAAWI,GAAAA,CAAIG,OAAAA,CAAAA,EAAU;AAC1BP,MAAAA,UAAAA,CAAWW,GAAAA,CAAIJ,SAASE,QAAAA,CAAAA;AAC5B,IAAA;AAGA,IAAA,MAAMV,gBAAAA,CAAiBU,QAAAA,EAAUT,UAAAA,EAAYC,OAAAA,CAAAA;AACjD,EAAA;AACJ,CAAA,EAxBgC,kBAAA","file":"
|
|
1
|
+
{"version":3,"sources":["../src/resolve/discover.ts"],"names":["LZ_SCOPE","isCrate","dir","stats","stat","isDirectory","access","join","isWorkspaceRoot","crateRoot","manifestPath","raw","readFile","parse","workspace","err","logger","warn","discoverPackages","discovered","visited","realDir","tryRealpath","has","add","nodeModulesDir","pkgName","tryReaddir","realPath","isValidCratePath","set"],"mappings":";;;;;;;AAaA,IAAMA,QAAAA,GAAW,gBAAA;AAmBV,IAAMC,OAAAA,iCAAiBC,GAAAA,KAAAA;AAC1B,EAAA,IAAI;AACA,IAAA,MAAMC,KAAAA,GAAQ,MAAMC,IAAAA,CAAKF,GAAAA,CAAAA;AACzB,IAAA,IAAI,CAACC,KAAAA,CAAME,WAAAA,EAAW,EAAI,OAAO,KAAA;AACjC,IAAA,MAAMC,MAAAA,CAAOC,IAAAA,CAAKL,GAAAA,EAAK,YAAA,CAAA,CAAA;AACvB,IAAA,OAAO,IAAA;EACX,CAAA,CAAA,MAAQ;AACJ,IAAA,OAAO,KAAA;AACX,EAAA;AACJ,CAAA,EATuB,SAAA;AAYhB,IAAMM,eAAAA,iCAAyBC,SAAAA,KAAAA;AAClC,EAAA,MAAMC,YAAAA,GAAeH,IAAAA,CAAKE,SAAAA,EAAW,YAAA,CAAA;AACrC,EAAA,IAAIE,GAAAA;AACJ,EAAA,IAAI;AACAA,IAAAA,GAAAA,GAAM,MAAMC,QAAAA,CAASF,YAAAA,EAAc,OAAA,CAAA;EACvC,CAAA,CAAA,MAAQ;AACJ,IAAA,OAAO,KAAA;AACX,EAAA;AACA,EAA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AAYC,OAAAA,CAAAA;AACjD,EAAA;AACJ,CAAA,EAxBgC,kBAAA","file":"NVUOVNKE.js","sourcesContent":["/** Discovery — walk node_modules/@layerzerolabs/ to find all @layerzerolabs Cargo crates. */\n\nimport { access, readFile, stat } from 'fs/promises';\nimport { join } from 'path';\nimport { parse } from 'smol-toml';\n\nimport { logger } from '../logger';\nimport type { CollectedTree } from './io';\nimport { tryReaddir, tryRealpath } from './io';\n\n// ─── Constants ───\n\n/** Only packages under this npm scope are treated as Cargo dependencies. */\nconst LZ_SCOPE = '@layerzerolabs';\n\n// ─── Types ───\n\n/** A discovered package paired with its collected source tree, ready to vendor. */\nexport interface VendorTarget {\n /** npm package name (without scope) — the dependencies/ subdir. */\n pkgName: string;\n /** canonical source path (realpath through pnpm symlinks). */\n npmPkgDir: string;\n /** vendored location: dependencies/<pkgName>. */\n depsPkgDir: string;\n /** included file/dir tree (excluded subtrees already pruned). */\n tree: CollectedTree;\n}\n\n// ─── Crate Helpers ───\n\n/** Checks if the directory contains a Cargo.toml. */\nexport const isCrate = async (dir: string): Promise<boolean> => {\n try {\n const stats = await stat(dir);\n if (!stats.isDirectory()) return false;\n await access(join(dir, 'Cargo.toml'));\n return true;\n } catch {\n return false;\n }\n};\n\n/** True if the directory's Cargo.toml declares a `[workspace]` table. */\nexport const isWorkspaceRoot = async (crateRoot: string): Promise<boolean> => {\n const manifestPath = join(crateRoot, 'Cargo.toml');\n let raw: string;\n try {\n raw = await readFile(manifestPath, 'utf-8');\n } catch {\n return false; // no readable Cargo.toml here — not a workspace root\n }\n try {\n return parse(raw).workspace != null;\n } catch (err) {\n // Warn rather than silently treat a malformed manifest as a non-workspace\n // (which would strip its [workspace] table); the parser is stricter than Cargo.\n logger.warn(`failed to parse ${manifestPath}; treating as non-workspace`, err);\n return false;\n }\n};\n\n// ─── Main Functions ───\n\n/**\n * Recursively discover all @layerzerolabs Cargo packages reachable from `dir`'s node_modules.\n * Resolves pnpm symlinks to canonical paths; `visited` prevents re-walking shared deps.\n */\nexport const discoverPackages = async (\n dir: string,\n discovered: Map<string, string>,\n visited: Set<string>,\n): Promise<void> => {\n const realDir = await tryRealpath(dir);\n if (!realDir || visited.has(realDir)) return;\n visited.add(realDir);\n\n const nodeModulesDir = join(dir, 'node_modules', LZ_SCOPE);\n\n for (const pkgName of await tryReaddir(nodeModulesDir)) {\n // Resolve pnpm symlink to canonical path (deduplicates across dep chains)\n const realPath = await tryRealpath(join(nodeModulesDir, pkgName));\n const isValidCratePath = realPath && (await isCrate(realPath));\n if (!isValidCratePath) continue;\n\n if (!discovered.has(pkgName)) {\n discovered.set(pkgName, realPath);\n }\n\n // Walk this package's own node_modules for transitive Cargo deps\n await discoverPackages(realPath, discovered, visited);\n }\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { logger } from './UDDAJZY4.js';
|
|
2
|
-
import { removeExcludedFiles, COPY_EXTENSIONS } from './
|
|
2
|
+
import { removeExcludedFiles, COPY_EXTENSIONS } from './XEADETHB.js';
|
|
3
3
|
import { __name } from './VUOMXK5T.js';
|
|
4
4
|
import { realpath, stat, readdir } from 'fs/promises';
|
|
5
5
|
import { join, extname, basename, dirname } from 'path';
|
|
@@ -55,5 +55,5 @@ var collectFiles = /* @__PURE__ */ __name(async (root, relativePath = "") => {
|
|
|
55
55
|
}, "collectFiles");
|
|
56
56
|
|
|
57
57
|
export { collectFiles, tryIsDirectory, tryReaddir, tryRealpath };
|
|
58
|
-
//# sourceMappingURL=
|
|
59
|
-
//# sourceMappingURL=
|
|
58
|
+
//# sourceMappingURL=PSAML6YW.js.map
|
|
59
|
+
//# sourceMappingURL=PSAML6YW.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/resolve/io.ts"],"names":["tryRealpath","path","realpath","undefined","tryIsDirectory","stat","isDirectory","tryReaddir","dir","readdir","collectFiles","root","relativePath","dirs","files","manifestDirs","rawFileNames","join","fileNames","removeExcludedFiles","map","e","file","subDir","length","push","logger","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IAAAA,CAAAA,CAAAA,EAAQ;AACxC,MAAA,MAAMC,MAAAA,GAAS,MAAMb,YAAAA,CAAaC,IAAAA,EAAMW,IAAAA,CAAAA;AACxC,MAAA,IAAIC,MAAAA,CAAOT,KAAAA,CAAMU,MAAAA,GAAS,CAAA,EAAG;AACzBX,QAAAA,IAAAA,CAAKY,IAAAA,CAAKH,IAAAA,EAAAA,GAASC,MAAAA,CAAOV,IAAI,CAAA;AAC9BC,QAAAA,KAAAA,CAAMW,IAAAA,CAAI,GAAIF,MAAAA,CAAOT,KAAK,CAAA;AAC1BC,QAAAA,YAAAA,CAAaU,IAAAA,CAAI,GAAIF,MAAAA,CAAOR,YAAY,CAAA;MAC5C,CAAA,MAAO;AACHW,QAAAA,MAAAA,CAAOC,KAAAA,CAAM,CAAA,eAAA,EAAkBL,IAAAA,CAAAA,CAAM,CAAA;AACzC,MAAA;AACJ,IAAA,CAAA,MAAA,IAAWM,eAAAA,CAAgBC,GAAAA,CAAIC,OAAAA,CAAQR,IAAAA,CAAAA,CAAAA,EAAQ;AAC3CR,MAAAA,KAAAA,CAAMW,KAAKH,IAAAA,CAAAA;AACX,MAAA,IAAIS,QAAAA,CAAST,IAAAA,CAAAA,KAAU,YAAA,eAA2BG,IAAAA,CAAKO,OAAAA,CAAQV,IAAAA,CAAAA,CAAAA;AAC/DI,MAAAA,MAAAA,CAAOC,KAAAA,CAAM,CAAA,QAAA,EAAWL,IAAAA,CAAAA,CAAM,CAAA;AAClC,IAAA;AACJ,EAAA;AACA,EAAA,OAAO;AAAET,IAAAA,IAAAA;AAAMC,IAAAA,KAAAA;AAAOC,IAAAA;AAAa,GAAA;AACvC,CAAA,EAzB4B,cAAA","file":"
|
|
1
|
+
{"version":3,"sources":["../src/resolve/io.ts"],"names":["tryRealpath","path","realpath","undefined","tryIsDirectory","stat","isDirectory","tryReaddir","dir","readdir","collectFiles","root","relativePath","dirs","files","manifestDirs","rawFileNames","join","fileNames","removeExcludedFiles","map","e","file","subDir","length","push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AMW,IAAAA,CAAAA,CAAAA,EAAQ;AACxC,MAAA,MAAMC,MAAAA,GAAS,MAAMb,YAAAA,CAAaC,IAAAA,EAAMW,IAAAA,CAAAA;AACxC,MAAA,IAAIC,MAAAA,CAAOT,KAAAA,CAAMU,MAAAA,GAAS,CAAA,EAAG;AACzBX,QAAAA,IAAAA,CAAKY,IAAAA,CAAKH,IAAAA,EAAAA,GAASC,MAAAA,CAAOV,IAAI,CAAA;AAC9BC,QAAAA,KAAAA,CAAMW,IAAAA,CAAI,GAAIF,MAAAA,CAAOT,KAAK,CAAA;AAC1BC,QAAAA,YAAAA,CAAaU,IAAAA,CAAI,GAAIF,MAAAA,CAAOR,YAAY,CAAA;MAC5C,CAAA,MAAO;AACHW,QAAAA,MAAAA,CAAOC,KAAAA,CAAM,CAAA,eAAA,EAAkBL,IAAAA,CAAAA,CAAM,CAAA;AACzC,MAAA;AACJ,IAAA,CAAA,MAAA,IAAWM,eAAAA,CAAgBC,GAAAA,CAAIC,OAAAA,CAAQR,IAAAA,CAAAA,CAAAA,EAAQ;AAC3CR,MAAAA,KAAAA,CAAMW,KAAKH,IAAAA,CAAAA;AACX,MAAA,IAAIS,QAAAA,CAAST,IAAAA,CAAAA,KAAU,YAAA,eAA2BG,IAAAA,CAAKO,OAAAA,CAAQV,IAAAA,CAAAA,CAAAA;AAC/DI,MAAAA,MAAAA,CAAOC,KAAAA,CAAM,CAAA,QAAA,EAAWL,IAAAA,CAAAA,CAAM,CAAA;AAClC,IAAA;AACJ,EAAA;AACA,EAAA,OAAO;AAAET,IAAAA,IAAAA;AAAMC,IAAAA,KAAAA;AAAOC,IAAAA;AAAa,GAAA;AACvC,CAAA,EAzB4B,cAAA","file":"PSAML6YW.js","sourcesContent":["import { readdir, realpath, stat } from 'fs/promises';\nimport { basename, dirname, extname, join } from 'path';\n\nimport { logger } from '../logger';\nimport { COPY_EXTENSIONS, removeExcludedFiles } from './exclude';\n\nexport const tryRealpath = async (path: string): Promise<string | undefined> => {\n try {\n return await realpath(path);\n } catch {\n return undefined;\n }\n};\n\nexport const tryIsDirectory = async (path: string): Promise<boolean> => {\n try {\n return (await stat(path)).isDirectory();\n } catch {\n return false;\n }\n};\n\nexport const tryReaddir = async (dir: string): Promise<string[]> => {\n try {\n return await readdir(dir);\n } catch {\n return [];\n }\n};\n\nexport interface CollectedTree {\n /** directories containing copyable content, relative to root (no empties) */\n dirs: string[];\n /** copyable files (COPY_EXTENSIONS), relative to root (excluded subtrees pruned) */\n files: string[];\n /** dirs that directly contain a Cargo.toml (crate roots), relative to root; '.' is the root */\n manifestDirs: string[];\n}\n\n/**\n * Walk `root` once, applying exclusion per level and keeping only COPY_EXTENSIONS files.\n * Also records `manifestDirs` (dirs holding a Cargo.toml) so consumers don't re-scan.\n */\nexport const collectFiles = async (root: string, relativePath = ''): Promise<CollectedTree> => {\n const dirs: string[] = [];\n const files: string[] = [];\n const manifestDirs: string[] = [];\n\n const rawFileNames = await tryReaddir(join(root, relativePath));\n const fileNames = removeExcludedFiles(rawFileNames).map((e) => join(relativePath, e));\n\n for (const file of fileNames) {\n if (await tryIsDirectory(join(root, file))) {\n const subDir = await collectFiles(root, file);\n if (subDir.files.length > 0) {\n dirs.push(file, ...subDir.dirs);\n files.push(...subDir.files);\n manifestDirs.push(...subDir.manifestDirs);\n } else {\n logger.trace(`skip empty dir ${file}`);\n }\n } else if (COPY_EXTENSIONS.has(extname(file))) {\n files.push(file);\n if (basename(file) === 'Cargo.toml') manifestDirs.push(dirname(file));\n logger.trace(`collect ${file}`);\n }\n }\n return { dirs, files, manifestDirs };\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { rewriteCargoTomls } from './
|
|
2
|
-
import { discoverPackages, isCrate } from './
|
|
3
|
-
import { collectFiles } from './
|
|
1
|
+
import { rewriteCargoTomls } from './ZH2AZQUX.js';
|
|
2
|
+
import { discoverPackages, isCrate } from './NVUOVNKE.js';
|
|
3
|
+
import { collectFiles } from './PSAML6YW.js';
|
|
4
4
|
import { logger } from './UDDAJZY4.js';
|
|
5
5
|
import { __name } from './VUOMXK5T.js';
|
|
6
6
|
import { rm, mkdir, copyFile } from 'fs/promises';
|
|
@@ -79,5 +79,5 @@ var resolveDependencies = /* @__PURE__ */ __name(async ({ cwd, cargoDir } = {})
|
|
|
79
79
|
}, "resolveDependencies");
|
|
80
80
|
|
|
81
81
|
export { buildDependenciesPathMap, resolveDependencies };
|
|
82
|
-
//# sourceMappingURL=
|
|
83
|
-
//# sourceMappingURL=
|
|
82
|
+
//# sourceMappingURL=UB65DPGZ.js.map
|
|
83
|
+
//# sourceMappingURL=UB65DPGZ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/resolve/index.ts"],"names":["buildDependenciesPathMap","targets","pathMap","Map","npmPkgDir","depsPkgDir","tree","dir","manifestDirs","set","join","logger","trace","debug","size","copyCollected","srcRoot","destRoot","mkdir","recursive","Promise","all","dirs","map","files","file","copyFile","resolveCargoRoot","packageRoot","cargoDir","resolved","resolve","isCrate","Error","resolveDependencies","cwd","process","depsRoot","discovered","discoverPackages","Set","info","rm","force","Array","from","pkgName","collectFiles","length","ctx","rewriteCargoTomls","relative"],"mappings":";;;;;;;;AAmBO,IAAMA,wBAAAA,2BAA4BC,OAAAA,KAAAA;AACrC,EAAA,MAAMC,OAAAA,uBAAcC,GAAAA,EAAAA;AAEpB,EAAA,KAAA,MAAW,EAAEC,SAAAA,EAAWC,UAAAA,EAAYC,IAAAA,MAAUL,OAAAA,EAAS;AACnD,IAAA,KAAA,MAAWM,GAAAA,IAAOD,KAAKE,YAAAA,EAAc;AACjCN,MAAAA,OAAAA,CAAQO,GAAAA,CAAIC,KAAKN,SAAAA,EAAWG,GAAAA,GAAMG,IAAAA,CAAKL,UAAAA,EAAYE,GAAAA,CAAAA,CAAAA;AACnDI,MAAAA,MAAAA,CAAOC,KAAAA,CAAM,CAAA,IAAA,EAAOF,IAAAA,CAAKN,SAAAA,EAAWG,GAAAA,CA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CAAA,yBAAA,EAA4BqC,SAASvB,WAAAA,EAAaS,QAAAA,CAAAA,IAAa,iBAAA,CAAA,CAAmB,CAAA;AAErH,CAAA,EAhDmC,qBAAA","file":"
|
|
1
|
+
{"version":3,"sources":["../src/resolve/index.ts"],"names":["buildDependenciesPathMap","targets","pathMap","Map","npmPkgDir","depsPkgDir","tree","dir","manifestDirs","set","join","logger","trace","debug","size","copyCollected","srcRoot","destRoot","mkdir","recursive","Promise","all","dirs","map","files","file","copyFile","resolveCargoRoot","packageRoot","cargoDir","resolved","resolve","isCrate","Error","resolveDependencies","cwd","process","depsRoot","discovered","discoverPackages","Set","info","rm","force","Array","from","pkgName","collectFiles","length","ctx","rewriteCargoTomls","relative"],"mappings":";;;;;;;;AAmBO,IAAMA,wBAAAA,2BAA4BC,OAAAA,KAAAA;AACrC,EAAA,MAAMC,OAAAA,uBAAcC,GAAAA,EAAAA;AAEpB,EAAA,KAAA,MAAW,EAAEC,SAAAA,EAAWC,UAAAA,EAAYC,IAAAA,MAAUL,OAAAA,EAAS;AACnD,IAAA,KAAA,MAAWM,GAAAA,IAAOD,KAAKE,YAAAA,EAAc;AACjCN,MAAAA,OAAAA,CAAQO,GAAAA,CAAIC,KAAKN,SAAAA,EAAWG,GAAAA,GAAMG,IAAAA,CAAKL,UAAAA,EAAYE,GAAAA,CAAAA,CAAAA;AACnDI,MAAAA,MAAAA,CAAOC,KAAAA,CAAM,CAAA,IAAA,EAAOF,IAAAA,CAAKN,SAAAA,EAAWG,GAAAA,CAAAA,CAAAA,IAAAA,EAAWG,IAAAA,CAAKL,UAAAA,EAAYE,GAAAA,CAAAA,CAAAA,CAAM,CAAA;AAC1E,IAAA;AACJ,EAAA;AACAI,EAAAA,MAAAA,CAAOE,KAAAA,CAAM,CAAA,2BAAA,EAA8BX,OAAAA,CAAQY,IAAI,CAAA,QAAA,CAAU,CAAA;AACjE,EAAA,OAAOZ,OAAAA;AACX,CAAA,EAXwC,0BAAA;AAgBxC,IAAMa,aAAA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AAAA,SAAAA;MAAWC,UAAAA,EAAYK,IAAAA,CAAK2B,UAAUS,OAAAA,CAAAA;AAAUxC,MAAAA;AAAK,KAAA;AAC3E,EAAA,CAAA,CAAA,CAAA;AAGJ,EAAA,MAAM2C,GAAAA,GAAsB;AACxB/C,IAAAA,OAAAA,EAASF,yBAAyBC,OAAAA,CAAAA;AAClCqC,IAAAA;AACJ,GAAA;AACA3B,EAAAA,MAAAA,CAAOE,KAAAA,CAAM,CAAA,UAAA,EAAaoC,GAAAA,CAAI/C,OAAAA,CAAQY,IAAI,CAAA,QAAA,CAAU,CAAA;AAEpD,EAAA,MAAMM,OAAAA,CAAQC,GAAAA,CACVpB,OAAAA,CAAQsB,GAAAA,CAAI,OAAO,EAAEuB,OAAAA,EAAS1C,SAAAA,EAAWC,UAAAA,EAAYC,IAAAA,EAAI,KAAE;AACvD,IAAA,MAAMS,aAAAA,CAAcX,SAAAA,EAAWC,UAAAA,EAAYC,IAAAA,CAAAA;AAC3C,IAAA,MAAM4C,iBAAAA,CAAkB9C,SAAAA,EAAWC,UAAAA,EAAYC,IAAAA,EAAM2C,GAAAA,CAAAA;AACrDtC,IAAAA,MAAAA,CAAOE,KAAAA,CAAM,CAAA,EAAA,EAAKiC,OAAAA,CAAAA,IAAAA,EAAc1C,SAAAA,CAAAA,CAAW,CAAA;AAC/C,EAAA,CAAA,CAAA,CAAA;AAGJO,EAAAA,MAAAA,CAAO8B,IAAAA,CACH,CAAA,SAAA,EAAYH,UAAAA,CAAWxB,IAAI,CAAA,yBAAA,EAA4BqC,SAASvB,WAAAA,EAAaS,QAAAA,CAAAA,IAAa,iBAAA,CAAA,CAAmB,CAAA;AAErH,CAAA,EAhDmC,qBAAA","file":"UB65DPGZ.js","sourcesContent":["/**\n * Vendor @layerzerolabs Cargo dependencies from node_modules into a flat\n * dependencies/ directory with rewritten path deps, so a Rust package builds\n * without the rest of the monorepo.\n */\n\nimport { copyFile, mkdir, rm } from 'fs/promises';\nimport { join, relative, resolve } from 'path';\n\nimport { logger } from '../logger';\nimport { discoverPackages, isCrate, type VendorTarget } from './discover';\nimport type { CollectedTree } from './io';\nimport { collectFiles } from './io';\nimport type { RewriteContext } from './rewrite';\nimport { rewriteCargoTomls } from './rewrite';\n\n// ─── Path Map ───\n\n/** Maps each crate's npm package source path to its vendored dependencies/ location. */\nexport const buildDependenciesPathMap = (targets: VendorTarget[]): Map<string, string> => {\n const pathMap = new Map<string, string>();\n\n for (const { npmPkgDir, depsPkgDir, tree } of targets) {\n for (const dir of tree.manifestDirs) {\n pathMap.set(join(npmPkgDir, dir), join(depsPkgDir, dir));\n logger.trace(`map ${join(npmPkgDir, dir)} -> ${join(depsPkgDir, dir)}`);\n }\n }\n logger.debug(`built dependency path map: ${pathMap.size} entries`);\n return pathMap;\n};\n\n// ─── File Operations ───\n\n/** Copy a collected tree into destRoot. */\nconst copyCollected = async (\n srcRoot: string,\n destRoot: string,\n tree: CollectedTree,\n): Promise<void> => {\n await mkdir(destRoot, { recursive: true });\n await Promise.all(tree.dirs.map((dir) => mkdir(join(destRoot, dir), { recursive: true })));\n await Promise.all(\n tree.files.map((file) => copyFile(join(srcRoot, file), join(destRoot, file))),\n );\n};\n\n/** Resolves the Cargo root: `cargoDir` if provided, else `packageRoot`. Throws if no Cargo.toml. */\nconst resolveCargoRoot = async (packageRoot: string, cargoDir?: string): Promise<string> => {\n if (cargoDir) {\n const resolved = resolve(packageRoot, cargoDir);\n if (!(await isCrate(resolved))) {\n throw new Error(`--cargo-dir ${cargoDir} does not contain a Cargo.toml`);\n }\n return resolved;\n }\n\n if (!(await isCrate(packageRoot))) {\n throw new Error(`${packageRoot} does not contain a Cargo.toml`);\n }\n\n return packageRoot;\n};\n\n// ─── Public API ───\n\n/**\n * Entry point: vendor every @layerzerolabs Cargo crate reachable through node_modules\n * into dependencies/, with path deps rewritten to resolve locally.\n *\n * @param cwd pnpm package root (where node_modules/ lives). Default: process.cwd()\n * @param cargoDir Cargo crate directory to vendor into. Default: packageRoot\n */\nexport const resolveDependencies = async ({\n cwd,\n cargoDir,\n}: { cwd?: string; cargoDir?: string } = {}): Promise<void> => {\n const packageRoot = resolve(cwd ?? process.cwd());\n\n const depsRoot = join(await resolveCargoRoot(packageRoot, cargoDir), 'dependencies');\n\n const discovered = new Map<string, string>();\n await discoverPackages(packageRoot, discovered, new Set());\n\n if (discovered.size === 0) {\n logger.info('No @layerzerolabs namespaced Cargo dependencies found in node_modules');\n return;\n }\n\n // Rebuild dependencies/ from scratch each run.\n await rm(depsRoot, { recursive: true, force: true });\n await mkdir(depsRoot, { recursive: true });\n\n // Collect each package's tree once — copy, path map, and rewrite all reuse it.\n const targets: VendorTarget[] = await Promise.all(\n Array.from(discovered, async ([pkgName, npmPkgDir]) => {\n const tree = await collectFiles(npmPkgDir);\n logger.debug(\n `${pkgName}: collected ${tree.files.length} files, ${tree.dirs.length} dirs`,\n );\n return { pkgName, npmPkgDir, depsPkgDir: join(depsRoot, pkgName), tree };\n }),\n );\n\n const ctx: RewriteContext = {\n pathMap: buildDependenciesPathMap(targets),\n discovered,\n };\n logger.debug(`path map: ${ctx.pathMap.size} entries`);\n\n await Promise.all(\n targets.map(async ({ pkgName, npmPkgDir, depsPkgDir, tree }) => {\n await copyCollected(npmPkgDir, depsPkgDir, tree);\n await rewriteCargoTomls(npmPkgDir, depsPkgDir, tree, ctx);\n logger.debug(` ${pkgName} -> ${npmPkgDir}`);\n }),\n );\n\n logger.info(\n `Resolved ${discovered.size} Cargo dependencies into ${relative(packageRoot, depsRoot) || './dependencies/'}`,\n );\n};\n"]}
|
|
@@ -21,7 +21,11 @@ var EXCLUDE_DIR = /* @__PURE__ */ new Set([
|
|
|
21
21
|
".git",
|
|
22
22
|
".github",
|
|
23
23
|
// shared directories
|
|
24
|
-
"tests"
|
|
24
|
+
"tests",
|
|
25
|
+
"integration-tests",
|
|
26
|
+
"integration_tests",
|
|
27
|
+
// stellar test snapshots
|
|
28
|
+
"test_snapshots"
|
|
25
29
|
]);
|
|
26
30
|
var EXCLUDE_FILE = /* @__PURE__ */ new Set([
|
|
27
31
|
// npm
|
|
@@ -47,5 +51,5 @@ var removeExcludedFiles = /* @__PURE__ */ __name((entries) => entries.filter((en
|
|
|
47
51
|
var hasExcludedSegment = /* @__PURE__ */ __name((relPath) => relPath.split(/[\\/]+/).some((segment) => EXCLUDE_DIR.has(segment)), "hasExcludedSegment");
|
|
48
52
|
|
|
49
53
|
export { COPY_EXTENSIONS, hasExcludedSegment, removeExcludedFiles };
|
|
50
|
-
//# sourceMappingURL=
|
|
51
|
-
//# sourceMappingURL=
|
|
54
|
+
//# sourceMappingURL=XEADETHB.js.map
|
|
55
|
+
//# sourceMappingURL=XEADETHB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resolve/exclude.ts"],"names":["COPY_EXTENSIONS","Set","EXCLUDE_DIR","EXCLUDE_FILE","COPY_EXCLUDES","removeExcludedFiles","entries","filter","entry","has","hasExcludedSegment","relPath","split","some","segment"],"mappings":";;;AACO,IAAMA,eAAAA,uBAAsBC,GAAAA,CAAI;AAAC,EAAA,KAAA;AAAO,EAAA,OAAA;AAAS,EAAA;AAAQ,CAAA;AAGhE,IAAMC,WAAAA,uBAAkBD,GAAAA,CAAI;;AAExB,EAAA,cAAA;AACA,EAAA,cAAA;AACA,EAAA,QAAA;AACA,EAAA,QAAA;;AAEA,EAAA,UAAA;AACA,EAAA,SAAA;AACA,EAAA,MAAA;AACA,EAAA,QAAA;;AAEA,EAAA,MAAA;AACA,EAAA,SAAA;;AAEA,EAAA,OAAA;AACA,EAAA,mBAAA;AACA,EAAA,mBAAA;;AAEA,EAAA;AACH,CAAA,CAAA;AAGD,IAAME,YAAAA,uBAAmBF,GAAAA,CAAI;;AAEzB,EAAA,cAAA;AACA,EAAA,gBAAA;;AAEA,EAAA,0BAAA;AACA,EAAA,YAAA;;AAEA,EAAA,YAAA;AACA,EAAA,aAAA;AACA,EAAA,WAAA;AACA,EAAA,qBAAA;AACA,EAAA,cAAA;;AAEA,EAAA;AACH,CAAA,CAAA;AAED,IAAMG,aAAAA,uBAAoBH,GAAAA,CAAI;AAAIC,EAAAA,GAAAA,WAAAA;AAAgBC,EAAAA,GAAAA;AAAa,CAAA,CAAA;AAGxD,IAAME,mBAAAA,mBAAsB,MAAA,CAAA,CAACC,OAAAA,KAChCA,OAAAA,CAAQC,MAAAA,CAAO,CAACC,KAAAA,KAAU,CAACJ,aAAAA,CAAcK,GAAAA,CAAID,KAAAA,CAAAA,CAAAA,EADd,qBAAA;AAO5B,IAAME,kBAAAA,mBAAqB,MAAA,CAAA,CAACC,OAAAA,KAC/BA,OAAAA,CAAQC,MAAM,QAAA,CAAA,CAAUC,IAAAA,CAAK,CAACC,OAAAA,KAAYZ,WAAAA,CAAYO,GAAAA,CAAIK,OAAAA,CAAAA,CAAAA,EAD5B,oBAAA","file":"XEADETHB.js","sourcesContent":["/** Files vendored into dependencies/ — everything else is skipped by type. */\nexport const COPY_EXTENSIONS = new Set(['.rs', '.toml', '.json']);\n\n/** Directories never descended into when copying or scanning. */\nconst EXCLUDE_DIR = new Set([\n // npm directories\n 'dependencies',\n 'node_modules',\n 'target',\n '.turbo',\n // cargo directories\n 'examples',\n 'benches',\n 'fuzz',\n '.cargo',\n // vcs / ci\n '.git',\n '.github',\n // shared directories\n 'tests',\n 'integration-tests',\n 'integration_tests',\n // stellar test snapshots\n 'test_snapshots',\n]);\n\n/** Files matching COPY_EXTENSIONS that must still be skipped — lockfiles, toolchain config, etc. */\nconst EXCLUDE_FILE = new Set([\n // npm\n 'package.json',\n 'pnpm-lock.yaml',\n // turbo\n 'turbo-snapshot.lock.json',\n 'turbo.json',\n // cargo/rust\n 'Cargo.lock',\n 'clippy.toml',\n 'deny.toml',\n 'rust-toolchain.toml',\n 'rustfmt.toml',\n // solana\n 'Anchor.toml',\n]);\n\nconst COPY_EXCLUDES = new Set([...EXCLUDE_DIR, ...EXCLUDE_FILE]);\n\n/** Filter excluded names from a directory listing. */\nexport const removeExcludedFiles = (entries: string[]): string[] =>\n entries.filter((entry) => !COPY_EXCLUDES.has(entry));\n\n/**\n * True if a resolved crate path contains an excluded segment.\n * Do not use on raw `path` dep values — those legitimately pass through node_modules.\n */\nexport const hasExcludedSegment = (relPath: string): boolean =>\n relPath.split(/[\\\\/]+/).some((segment) => EXCLUDE_DIR.has(segment));\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { isWorkspaceRoot } from './
|
|
2
|
-
import { tryRealpath } from './
|
|
1
|
+
import { isWorkspaceRoot } from './NVUOVNKE.js';
|
|
2
|
+
import { tryRealpath } from './PSAML6YW.js';
|
|
3
3
|
import { logger } from './UDDAJZY4.js';
|
|
4
|
-
import { hasExcludedSegment } from './
|
|
4
|
+
import { hasExcludedSegment } from './XEADETHB.js';
|
|
5
5
|
import { __name } from './VUOMXK5T.js';
|
|
6
6
|
import { readFile, writeFile } from 'fs/promises';
|
|
7
7
|
import { relative, dirname, join } from 'path';
|
|
@@ -86,19 +86,22 @@ var resolveViaRealpath = /* @__PURE__ */ __name(async (originalDir, pathValue, p
|
|
|
86
86
|
}, "resolveViaRealpath");
|
|
87
87
|
var resolveViaNameFallback = /* @__PURE__ */ __name((pathValue, ctx) => {
|
|
88
88
|
const segments = pathValue.split("/").filter(Boolean);
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
if (segments.length === 0) return void 0;
|
|
90
|
+
let best;
|
|
91
91
|
for (const [pkgName, realPath] of ctx.discovered) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
92
|
+
const pkgIndex = segments.indexOf(pkgName);
|
|
93
|
+
if (pkgIndex === -1) continue;
|
|
94
|
+
const vendoredBase = ctx.pathMap.get(realPath);
|
|
95
|
+
if (!vendoredBase) continue;
|
|
96
|
+
if (best != null && pkgIndex <= best.pkgIndex) continue;
|
|
97
|
+
best = {
|
|
98
|
+
pkgIndex,
|
|
99
|
+
vendoredBase,
|
|
100
|
+
suffixSegments: segments.slice(pkgIndex + 1)
|
|
101
|
+
};
|
|
100
102
|
}
|
|
101
|
-
return void 0;
|
|
103
|
+
if (!best) return void 0;
|
|
104
|
+
return best.suffixSegments.length === 0 ? best.vendoredBase : join(best.vendoredBase, ...best.suffixSegments);
|
|
102
105
|
}, "resolveViaNameFallback");
|
|
103
106
|
var rewriteCargoTomls = /* @__PURE__ */ __name(async (srcRoot, destRoot, tree, ctx) => {
|
|
104
107
|
for (const manifestDir of tree.manifestDirs) {
|
|
@@ -108,5 +111,5 @@ var rewriteCargoTomls = /* @__PURE__ */ __name(async (srcRoot, destRoot, tree, c
|
|
|
108
111
|
}, "rewriteCargoTomls");
|
|
109
112
|
|
|
110
113
|
export { pruneExcludedLiteralMembers, rewriteCargoToml, rewriteCargoTomls, rewritePathDeps, stripRootOnlyTables };
|
|
111
|
-
//# sourceMappingURL=
|
|
112
|
-
//# sourceMappingURL=
|
|
114
|
+
//# sourceMappingURL=ZH2AZQUX.js.map
|
|
115
|
+
//# sourceMappingURL=ZH2AZQUX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resolve/rewrite.ts"],"names":["isTable","value","Array","isArray","DEP_TABLE_KEYS","pathDepSpecs","manifest","includeWorkspaceDeps","containers","target","Object","values","filter","depTables","flatMap","container","map","key","workspace","dependencies","table","spec","path","pruneExcludedLiteralMembers","changed","members","kept","m","includes","hasExcludedSegment","length","rewritePathDeps","originalDir","manifestDir","ctx","resolveViaRealpath","pathMap","resolveViaNameFallback","rewritten","relative","logger","trace","stripRootOnlyTables","rewriteCargoToml","cargoTomlPath","stripRootTables","parse","readFile","pathsChanged","dirname","tablesChanged","writeFile","stringify","debug","pathValue","resolvedPath","tryRealpath","join","get","undefined","segments","split","Boolean","best","pkgName","realPath","discovered","pkgIndex","indexOf","vendoredBase","suffixSegments","slice","rewriteCargoTomls","srcRoot","destRoot","tree","manifestDirs","pre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,GAAAA,CAAIO,QAAAA,CAAAA;AACrC,IAAA,IAAI,CAACI,YAAAA,EAAc;AAGnB,IAAA,IAAIN,IAAAA,IAAQ,IAAA,IAAQI,QAAAA,IAAYJ,IAAAA,CAAKI,QAAAA,EAAU;AAE/CJ,IAAAA,IAAAA,GAAO;AACHI,MAAAA,QAAAA;AACAE,MAAAA,YAAAA;MACAC,cAAAA,EAAgBV,QAAAA,CAASW,KAAAA,CAAMJ,QAAAA,GAAW,CAAA;AAC9C,KAAA;AACJ,EAAA;AAEA,EAAA,IAAI,CAACJ,MAAM,OAAOJ,MAAAA;AAClB,EAAA,OAAOI,IAAAA,CAAKO,cAAAA,CAAexC,MAAAA,KAAW,CAAA,GAChCiC,IAAAA,CAAKM,YAAAA,GACLZ,IAAAA,CAAKM,IAAAA,CAAKM,YAAAA,EAAY,GAAKN,IAAAA,CAAKO,cAAc,CAAA;AACxD,CAAA,EAjC+B,wBAAA,CAAA;AAuCxB,IAAME,iBAAAA,mBAAoB,MAAA,CAAA,OAC7BC,OAAAA,EACAC,QAAAA,EACAC,MACAzC,GAAAA,KAAAA;AAEA,EAAA,KAAA,MAAWD,WAAAA,IAAe0C,KAAKC,YAAAA,EAAc;AACzC,IAAA,MAAMC,QAAAA,GAAW5C,WAAAA,KAAgB,GAAA,IAAQ,MAAM6C,gBAAgBJ,QAAAA,CAAAA;AAE/D,IAAA,MAAM/B,gBAAAA,CACFc,IAAAA,CAAKgB,OAAAA,EAASxC,WAAAA,CAAAA,EACdwB,IAAAA,CAAKiB,QAAAA,EAAUzC,WAAAA,EAAa,YAAA,CAAA,EAC5BC,GAAAA,EACA,CAAC2C,QAAAA,CAAAA;AAET,EAAA;AACJ,CAAA,EAhBiC,mBAAA","file":"ZH2AZQUX.js","sourcesContent":["/**\n * Rewrite a vendored Cargo.toml's path deps into the flat dependencies/ layout,\n * operating on the parsed TOML (via smol-toml) rather than text.\n */\n\nimport { readFile, writeFile } from 'fs/promises';\nimport { dirname, join, relative } from 'path';\nimport { parse, stringify } from 'smol-toml';\n\nimport { logger } from '../logger';\nimport { isWorkspaceRoot } from './discover';\nimport { hasExcludedSegment } from './exclude';\nimport { type CollectedTree, tryRealpath } from './io';\n\n/** Bundled resolution state passed through the rewrite pipeline. */\nexport interface RewriteContext {\n pathMap: Map<string, string>;\n discovered: Map<string, string>;\n}\n\ntype Table = Record<string, unknown>;\n\n/** A dependency spec that carries a `path` — an inline table like `{ path = \"…\" }`. */\ntype PathDepSpec = Table & { path: string };\n\nconst isTable = (value: unknown): value is Table =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst DEP_TABLE_KEYS = ['dependencies', 'dev-dependencies', 'build-dependencies'] as const;\n\n/**\n * Dependency specs that declare a `path`, across every dependency table (plus\n * `[workspace.dependencies]` when `includeWorkspaceDeps`). Specs are live references\n * into `manifest`, so mutating `.path` updates it.\n */\nconst pathDepSpecs = (manifest: Table, includeWorkspaceDeps: boolean): PathDepSpec[] => {\n // The root manifest and each [target.'cfg(...)'] table both hold DEP_TABLE_KEYS tables.\n const containers = [\n manifest,\n ...(isTable(manifest.target) ? Object.values(manifest.target).filter(isTable) : []),\n ];\n\n const depTables = [\n ...containers.flatMap((container) => DEP_TABLE_KEYS.map((key) => container[key])),\n ...(includeWorkspaceDeps && isTable(manifest.workspace)\n ? [manifest.workspace.dependencies]\n : []),\n ];\n\n return depTables\n .filter(isTable)\n .flatMap((table) => Object.values(table))\n .filter((spec): spec is PathDepSpec => isTable(spec) && typeof spec.path === 'string');\n};\n\n/**\n * Drop literal `members` / `default-members` entries whose path contains an excluded\n * directory segment (e.g. `tests/mock_vault`) — those dirs are never vendored, so the\n * member would dangle and fail Cargo's workspace load. Globs (`tests/*`) are kept; Cargo\n * re-expands them to a harmless empty match. Returns true if any member was removed.\n */\nexport const pruneExcludedLiteralMembers = (manifest: Table): boolean => {\n const workspace = manifest.workspace;\n if (!isTable(workspace)) return false;\n\n let changed = false;\n for (const key of ['members', 'default-members'] as const) {\n const members = workspace[key];\n if (!Array.isArray(members)) continue;\n\n // Keep everything except literal (non-glob) members inside an excluded dir.\n const kept = members.filter(\n (m) => typeof m !== 'string' || m.includes('*') || !hasExcludedSegment(m),\n );\n\n if (kept.length !== members.length) {\n workspace[key] = kept;\n changed = true;\n }\n }\n return changed;\n};\n\n/** Rebase every path dep in `manifest` into the flat dependencies/ layout. Returns true if any changed. */\nexport const rewritePathDeps = async (\n manifest: Table,\n originalDir: string,\n manifestDir: string,\n ctx: RewriteContext,\n includeWorkspaceDeps: boolean,\n): Promise<boolean> => {\n let changed = false;\n for (const spec of pathDepSpecs(manifest, includeWorkspaceDeps)) {\n const target =\n (await resolveViaRealpath(originalDir, spec.path, ctx.pathMap)) ??\n resolveViaNameFallback(spec.path, ctx);\n if (!target) continue;\n\n const rewritten = relative(manifestDir, target);\n if (rewritten === spec.path) continue;\n\n logger.trace(`rewrite path dep ${spec.path} -> ${rewritten}`);\n spec.path = rewritten;\n changed = true;\n }\n\n return changed;\n};\n\n/**\n * Delete the `[workspace]` / `[patch.*]` / `[profile.*]` tables — invalid or ignored in a\n * vendored dependency (only honored at the real workspace root). Returns true if any was removed.\n */\nexport const stripRootOnlyTables = (manifest: Table): boolean => {\n let changed = false;\n for (const table of ['workspace', 'patch', 'profile'] as const) {\n if (manifest[table] != null) {\n delete manifest[table];\n changed = true;\n }\n }\n return changed;\n};\n\n/**\n * Rewrite one vendored Cargo.toml in place: rebase its path deps, then strip the root-only\n * tables — or, for a preserved workspace root (`stripRootTables = false`), prune excluded\n * members instead. Re-serialized only if something changed.\n *\n * @param originalDir source crate dir the manifest was copied from\n * @param cargoTomlPath the vendored Cargo.toml to rewrite\n */\nexport const rewriteCargoToml = async (\n originalDir: string,\n cargoTomlPath: string,\n ctx: RewriteContext,\n stripRootTables = true,\n): Promise<void> => {\n const manifest = parse(await readFile(cargoTomlPath, 'utf-8'));\n\n const pathsChanged = await rewritePathDeps(\n manifest,\n originalDir,\n dirname(cargoTomlPath),\n ctx,\n !stripRootTables,\n );\n\n const tablesChanged = stripRootTables\n ? stripRootOnlyTables(manifest)\n : pruneExcludedLiteralMembers(manifest);\n\n if (pathsChanged || tablesChanged) {\n await writeFile(cargoTomlPath, stringify(manifest));\n logger.debug(`rewrote ${cargoTomlPath}`);\n }\n};\n\n/** Primary resolution: realpath the path through pnpm symlinks, then look it up in pathMap. */\nconst resolveViaRealpath = async (\n originalDir: string,\n pathValue: string,\n pathMap: Map<string, string>,\n): Promise<string | undefined> => {\n const resolvedPath = await tryRealpath(join(originalDir, pathValue));\n return resolvedPath ? pathMap.get(resolvedPath) : undefined;\n};\n\n/**\n * Fallback: locate a discovered npm package stem in the path and preserve every\n * suffix segment after it (e.g. protocol-stellar-v2/message-libs/simple-message-lib).\n *\n * When several discovered package names appear as path segments, pick the\n * **rightmost** (deepest) match — insertion order must not win over specificity.\n */\nconst resolveViaNameFallback = (pathValue: string, ctx: RewriteContext): string | undefined => {\n const segments = pathValue.split('/').filter(Boolean);\n if (segments.length === 0) return undefined;\n\n let best:\n | {\n pkgIndex: number;\n vendoredBase: string;\n suffixSegments: string[];\n }\n | undefined;\n\n for (const [pkgName, realPath] of ctx.discovered) {\n const pkgIndex = segments.indexOf(pkgName);\n if (pkgIndex === -1) continue;\n\n const vendoredBase = ctx.pathMap.get(realPath);\n if (!vendoredBase) continue;\n\n // Prefer the deepest stem. Equal index cannot happen for distinct names.\n if (best != null && pkgIndex <= best.pkgIndex) continue;\n\n best = {\n pkgIndex,\n vendoredBase,\n suffixSegments: segments.slice(pkgIndex + 1),\n };\n }\n\n if (!best) return undefined;\n return best.suffixSegments.length === 0\n ? best.vendoredBase\n : join(best.vendoredBase, ...best.suffixSegments);\n};\n\n/**\n * Rewrite every Cargo.toml in a copied dependency tree. The root manifest keeps its\n * root-only tables when it's a workspace (members inherit from them); all others strip them.\n */\nexport const rewriteCargoTomls = async (\n srcRoot: string,\n destRoot: string,\n tree: CollectedTree,\n ctx: RewriteContext,\n): Promise<void> => {\n for (const manifestDir of tree.manifestDirs) {\n const preserve = manifestDir === '.' && (await isWorkspaceRoot(destRoot));\n\n await rewriteCargoToml(\n join(srcRoot, manifestDir),\n join(destRoot, manifestDir, 'Cargo.toml'),\n ctx,\n !preserve,\n );\n }\n};\n"]}
|
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env tsx
|
|
2
|
-
import { resolveDependencies } from './
|
|
3
|
-
import './
|
|
4
|
-
import './
|
|
5
|
-
import './
|
|
2
|
+
import { resolveDependencies } from './UB65DPGZ.js';
|
|
3
|
+
import './ZH2AZQUX.js';
|
|
4
|
+
import './NVUOVNKE.js';
|
|
5
|
+
import './PSAML6YW.js';
|
|
6
6
|
import { logger, setLogLevel, parseLogLevel } from './UDDAJZY4.js';
|
|
7
|
-
import './
|
|
7
|
+
import './XEADETHB.js';
|
|
8
8
|
import { __name } from './VUOMXK5T.js';
|
|
9
9
|
import { Command } from 'commander';
|
|
10
10
|
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { resolveDependencies } from './
|
|
2
|
-
import './
|
|
3
|
-
import './
|
|
4
|
-
import './
|
|
1
|
+
export { resolveDependencies } from './UB65DPGZ.js';
|
|
2
|
+
import './ZH2AZQUX.js';
|
|
3
|
+
import './NVUOVNKE.js';
|
|
4
|
+
import './PSAML6YW.js';
|
|
5
5
|
import './UDDAJZY4.js';
|
|
6
|
-
import './
|
|
6
|
+
import './XEADETHB.js';
|
|
7
7
|
import './VUOMXK5T.js';
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
package/dist/resolve/discover.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { discoverPackages, isCrate, isWorkspaceRoot } from '../
|
|
2
|
-
import '../
|
|
1
|
+
export { discoverPackages, isCrate, isWorkspaceRoot } from '../NVUOVNKE.js';
|
|
2
|
+
import '../PSAML6YW.js';
|
|
3
3
|
import '../UDDAJZY4.js';
|
|
4
|
-
import '../
|
|
4
|
+
import '../XEADETHB.js';
|
|
5
5
|
import '../VUOMXK5T.js';
|
|
6
6
|
//# sourceMappingURL=discover.js.map
|
|
7
7
|
//# sourceMappingURL=discover.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exclude.d.ts","sourceRoot":"","sources":["../../src/resolve/exclude.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,eAAO,MAAM,eAAe,aAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"exclude.d.ts","sourceRoot":"","sources":["../../src/resolve/exclude.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,eAAO,MAAM,eAAe,aAAqC,CAAC;AA6ClE,sDAAsD;AACtD,eAAO,MAAM,mBAAmB,GAAI,SAAS,MAAM,EAAE,KAAG,MAAM,EACN,CAAC;AAEzD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,MAAM,KAAG,OACkB,CAAC"}
|
package/dist/resolve/exclude.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { COPY_EXTENSIONS, hasExcludedSegment, removeExcludedFiles } from '../
|
|
1
|
+
export { COPY_EXTENSIONS, hasExcludedSegment, removeExcludedFiles } from '../XEADETHB.js';
|
|
2
2
|
import '../VUOMXK5T.js';
|
|
3
3
|
//# sourceMappingURL=exclude.js.map
|
|
4
4
|
//# sourceMappingURL=exclude.js.map
|
package/dist/resolve/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { buildDependenciesPathMap, resolveDependencies } from '../
|
|
2
|
-
import '../
|
|
3
|
-
import '../
|
|
4
|
-
import '../
|
|
1
|
+
export { buildDependenciesPathMap, resolveDependencies } from '../UB65DPGZ.js';
|
|
2
|
+
import '../ZH2AZQUX.js';
|
|
3
|
+
import '../NVUOVNKE.js';
|
|
4
|
+
import '../PSAML6YW.js';
|
|
5
5
|
import '../UDDAJZY4.js';
|
|
6
|
-
import '../
|
|
6
|
+
import '../XEADETHB.js';
|
|
7
7
|
import '../VUOMXK5T.js';
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
package/dist/resolve/io.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { collectFiles, tryIsDirectory, tryReaddir, tryRealpath } from '../
|
|
1
|
+
export { collectFiles, tryIsDirectory, tryReaddir, tryRealpath } from '../PSAML6YW.js';
|
|
2
2
|
import '../UDDAJZY4.js';
|
|
3
|
-
import '../
|
|
3
|
+
import '../XEADETHB.js';
|
|
4
4
|
import '../VUOMXK5T.js';
|
|
5
5
|
//# sourceMappingURL=io.js.map
|
|
6
6
|
//# sourceMappingURL=io.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rewrite.d.ts","sourceRoot":"","sources":["../../src/resolve/rewrite.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,KAAK,aAAa,EAAe,MAAM,MAAM,CAAC;AAEvD,oEAAoE;AACpE,MAAM,WAAW,cAAc;IAC3B,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED,KAAK,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAmCrC;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,GAAI,UAAU,KAAK,KAAG,OAoB7D,CAAC;AAEF,2GAA2G;AAC3G,eAAO,MAAM,eAAe,GACxB,UAAU,KAAK,EACf,aAAa,MAAM,EACnB,aAAa,MAAM,EACnB,KAAK,cAAc,EACnB,sBAAsB,OAAO,KAC9B,OAAO,CAAC,OAAO,CAiBjB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,UAAU,KAAK,KAAG,OASrD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GACzB,aAAa,MAAM,EACnB,eAAe,MAAM,EACrB,KAAK,cAAc,EACnB,yBAAsB,KACvB,OAAO,CAAC,IAAI,CAmBd,CAAC;
|
|
1
|
+
{"version":3,"file":"rewrite.d.ts","sourceRoot":"","sources":["../../src/resolve/rewrite.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,KAAK,aAAa,EAAe,MAAM,MAAM,CAAC;AAEvD,oEAAoE;AACpE,MAAM,WAAW,cAAc;IAC3B,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED,KAAK,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAmCrC;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,GAAI,UAAU,KAAK,KAAG,OAoB7D,CAAC;AAEF,2GAA2G;AAC3G,eAAO,MAAM,eAAe,GACxB,UAAU,KAAK,EACf,aAAa,MAAM,EACnB,aAAa,MAAM,EACnB,KAAK,cAAc,EACnB,sBAAsB,OAAO,KAC9B,OAAO,CAAC,OAAO,CAiBjB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,UAAU,KAAK,KAAG,OASrD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GACzB,aAAa,MAAM,EACnB,eAAe,MAAM,EACrB,KAAK,cAAc,EACnB,yBAAsB,KACvB,OAAO,CAAC,IAAI,CAmBd,CAAC;AAsDF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC1B,SAAS,MAAM,EACf,UAAU,MAAM,EAChB,MAAM,aAAa,EACnB,KAAK,cAAc,KACpB,OAAO,CAAC,IAAI,CAWd,CAAC"}
|
package/dist/resolve/rewrite.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { pruneExcludedLiteralMembers, rewriteCargoToml, rewriteCargoTomls, rewritePathDeps, stripRootOnlyTables } from '../
|
|
2
|
-
import '../
|
|
3
|
-
import '../
|
|
1
|
+
export { pruneExcludedLiteralMembers, rewriteCargoToml, rewriteCargoTomls, rewritePathDeps, stripRootOnlyTables } from '../ZH2AZQUX.js';
|
|
2
|
+
import '../NVUOVNKE.js';
|
|
3
|
+
import '../PSAML6YW.js';
|
|
4
4
|
import '../UDDAJZY4.js';
|
|
5
|
-
import '../
|
|
5
|
+
import '../XEADETHB.js';
|
|
6
6
|
import '../VUOMXK5T.js';
|
|
7
7
|
//# sourceMappingURL=rewrite.js.map
|
|
8
8
|
//# sourceMappingURL=rewrite.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layerzerolabs/build-utils-rust",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.123",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"commander": "13.1.0",
|
|
20
20
|
"smol-toml": "^1.7.0",
|
|
21
|
-
"@layerzerolabs/logger-node": "0.2.
|
|
21
|
+
"@layerzerolabs/logger-node": "0.2.123"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^22.18.6",
|
|
25
25
|
"tsup": "^8.4.0",
|
|
26
26
|
"tsx": "^4.21.0",
|
|
27
27
|
"vitest": "^3.2.6",
|
|
28
|
-
"@layerzerolabs/
|
|
29
|
-
"@layerzerolabs/
|
|
28
|
+
"@layerzerolabs/tsup-configuration": "0.2.123",
|
|
29
|
+
"@layerzerolabs/typescript-configuration": "0.2.123"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "restricted",
|
|
@@ -35,7 +35,9 @@
|
|
|
35
35
|
"externalRepoConfig": {
|
|
36
36
|
"targets": [
|
|
37
37
|
"audit-external",
|
|
38
|
-
"
|
|
38
|
+
"console-pen-test",
|
|
39
|
+
"monorepo-external",
|
|
40
|
+
"onesig-client"
|
|
39
41
|
]
|
|
40
42
|
},
|
|
41
43
|
"scripts": {
|
package/src/resolve/exclude.ts
CHANGED
|
@@ -18,6 +18,10 @@ const EXCLUDE_DIR = new Set([
|
|
|
18
18
|
'.github',
|
|
19
19
|
// shared directories
|
|
20
20
|
'tests',
|
|
21
|
+
'integration-tests',
|
|
22
|
+
'integration_tests',
|
|
23
|
+
// stellar test snapshots
|
|
24
|
+
'test_snapshots',
|
|
21
25
|
]);
|
|
22
26
|
|
|
23
27
|
/** Files matching COPY_EXTENSIONS that must still be skipped — lockfiles, toolchain config, etc. */
|
package/src/resolve/rewrite.ts
CHANGED
|
@@ -166,25 +166,46 @@ const resolveViaRealpath = async (
|
|
|
166
166
|
return resolvedPath ? pathMap.get(resolvedPath) : undefined;
|
|
167
167
|
};
|
|
168
168
|
|
|
169
|
-
/**
|
|
169
|
+
/**
|
|
170
|
+
* Fallback: locate a discovered npm package stem in the path and preserve every
|
|
171
|
+
* suffix segment after it (e.g. protocol-stellar-v2/message-libs/simple-message-lib).
|
|
172
|
+
*
|
|
173
|
+
* When several discovered package names appear as path segments, pick the
|
|
174
|
+
* **rightmost** (deepest) match — insertion order must not win over specificity.
|
|
175
|
+
*/
|
|
170
176
|
const resolveViaNameFallback = (pathValue: string, ctx: RewriteContext): string | undefined => {
|
|
171
177
|
const segments = pathValue.split('/').filter(Boolean);
|
|
172
|
-
|
|
173
|
-
|
|
178
|
+
if (segments.length === 0) return undefined;
|
|
179
|
+
|
|
180
|
+
let best:
|
|
181
|
+
| {
|
|
182
|
+
pkgIndex: number;
|
|
183
|
+
vendoredBase: string;
|
|
184
|
+
suffixSegments: string[];
|
|
185
|
+
}
|
|
186
|
+
| undefined;
|
|
174
187
|
|
|
175
188
|
for (const [pkgName, realPath] of ctx.discovered) {
|
|
176
|
-
|
|
177
|
-
if (
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
189
|
+
const pkgIndex = segments.indexOf(pkgName);
|
|
190
|
+
if (pkgIndex === -1) continue;
|
|
191
|
+
|
|
192
|
+
const vendoredBase = ctx.pathMap.get(realPath);
|
|
193
|
+
if (!vendoredBase) continue;
|
|
194
|
+
|
|
195
|
+
// Prefer the deepest stem. Equal index cannot happen for distinct names.
|
|
196
|
+
if (best != null && pkgIndex <= best.pkgIndex) continue;
|
|
197
|
+
|
|
198
|
+
best = {
|
|
199
|
+
pkgIndex,
|
|
200
|
+
vendoredBase,
|
|
201
|
+
suffixSegments: segments.slice(pkgIndex + 1),
|
|
202
|
+
};
|
|
186
203
|
}
|
|
187
|
-
|
|
204
|
+
|
|
205
|
+
if (!best) return undefined;
|
|
206
|
+
return best.suffixSegments.length === 0
|
|
207
|
+
? best.vendoredBase
|
|
208
|
+
: join(best.vendoredBase, ...best.suffixSegments);
|
|
188
209
|
};
|
|
189
210
|
|
|
190
211
|
/**
|
|
@@ -184,23 +184,22 @@ describe('buildDependenciesPathMap', () => {
|
|
|
184
184
|
|
|
185
185
|
it('maps every crate dir (incl. deeply nested) to its dependencies/ target', async () => {
|
|
186
186
|
const depsDir = join(TMP, 'dependencies');
|
|
187
|
-
const crateDir = join(TMP, 'protocol-stellar');
|
|
188
|
-
createCrate(crateDir, '[workspace]\nmembers = ["
|
|
189
|
-
createCrate(join(crateDir, '
|
|
190
|
-
createCrate(join(crateDir, '
|
|
191
|
-
createCrate(join(crateDir, 'contracts', 'oapps', 'oft-core'));
|
|
187
|
+
const crateDir = join(TMP, 'protocol-stellar-v2');
|
|
188
|
+
createCrate(crateDir, '[workspace]\nmembers = ["endpoint-v2", "message-libs/*"]');
|
|
189
|
+
createCrate(join(crateDir, 'endpoint-v2'));
|
|
190
|
+
createCrate(join(crateDir, 'message-libs', 'simple-message-lib'));
|
|
192
191
|
|
|
193
192
|
const pathMap = buildDependenciesPathMap([
|
|
194
|
-
await toTarget('protocol-stellar', crateDir, depsDir),
|
|
193
|
+
await toTarget('protocol-stellar-v2', crateDir, depsDir),
|
|
195
194
|
]);
|
|
196
195
|
|
|
197
|
-
expect(pathMap.get(crateDir)).toBe(join(depsDir, 'protocol-stellar'));
|
|
198
|
-
expect(pathMap.get(join(crateDir, '
|
|
199
|
-
join(depsDir, 'protocol-stellar', '
|
|
196
|
+
expect(pathMap.get(crateDir)).toBe(join(depsDir, 'protocol-stellar-v2'));
|
|
197
|
+
expect(pathMap.get(join(crateDir, 'endpoint-v2'))).toBe(
|
|
198
|
+
join(depsDir, 'protocol-stellar-v2', 'endpoint-v2'),
|
|
200
199
|
);
|
|
201
200
|
// the deep member — the case the old one-level scan missed
|
|
202
|
-
expect(pathMap.get(join(crateDir, '
|
|
203
|
-
join(depsDir, 'protocol-stellar', '
|
|
201
|
+
expect(pathMap.get(join(crateDir, 'message-libs', 'simple-message-lib'))).toBe(
|
|
202
|
+
join(depsDir, 'protocol-stellar-v2', 'message-libs', 'simple-message-lib'),
|
|
204
203
|
);
|
|
205
204
|
});
|
|
206
205
|
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "oft-core"
|
|
3
|
+
version = "0.0.1"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
|
|
6
|
+
[dependencies]
|
|
7
|
+
endpoint-v2 = { path = "dependencies/protocol-stellar-v2/endpoint-v2" }
|
|
8
|
+
|
|
9
|
+
[dev-dependencies]
|
|
10
|
+
simple-message-lib = { path = "dependencies/protocol-stellar-v2/message-libs/simple-message-lib" }
|
|
11
|
+
message-lib-common = { path = "dependencies/protocol-stellar-v2/message-libs/message-lib-common" }
|
|
@@ -4,5 +4,5 @@ name = "console-oft"
|
|
|
4
4
|
# Like the Solana consumers, the manifest points straight at dependencies/ —
|
|
5
5
|
# the resolve tool only vendors crates there, it does not rewrite this file.
|
|
6
6
|
[dependencies]
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
endpoint-v2 = { path = "dependencies/protocol-stellar-v2/endpoint-v2" }
|
|
8
|
+
simple-message-lib = { path = "dependencies/protocol-stellar-v2/message-libs/simple-message-lib" }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[workspace]
|
|
2
2
|
resolver = "2"
|
|
3
|
-
members = ["
|
|
3
|
+
members = ["endpoint-v2", "message-libs/*", "workers/*"]
|
|
4
4
|
|
|
5
5
|
[workspace.package]
|
|
6
6
|
edition = "2021"
|
|
@@ -9,9 +9,9 @@ license = "MIT"
|
|
|
9
9
|
|
|
10
10
|
[workspace.dependencies]
|
|
11
11
|
soroban-sdk = { version = "25.1.1" }
|
|
12
|
-
|
|
13
|
-
common
|
|
14
|
-
|
|
12
|
+
endpoint-v2 = { path = "endpoint-v2", default-features = false }
|
|
13
|
+
message-lib-common = { path = "message-libs/message-lib-common" }
|
|
14
|
+
simple-message-lib = { path = "message-libs/simple-message-lib" }
|
|
15
15
|
|
|
16
16
|
[profile.release]
|
|
17
17
|
opt-level = "z"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[workspace]
|
|
2
2
|
resolver = "2"
|
|
3
|
-
members = ["
|
|
3
|
+
members = ["endpoint-v2", "tests/mock_vault"]
|
|
4
4
|
|
|
5
5
|
[workspace.package]
|
|
6
6
|
edition = "2021"
|
|
@@ -9,7 +9,7 @@ license = "MIT"
|
|
|
9
9
|
|
|
10
10
|
[workspace.dependencies]
|
|
11
11
|
soroban-sdk = { version = "25.1.1" }
|
|
12
|
-
|
|
12
|
+
endpoint-v2 = { path = "endpoint-v2", default-features = false }
|
|
13
13
|
|
|
14
14
|
[profile.release]
|
|
15
15
|
opt-level = "z"
|
|
@@ -113,25 +113,21 @@ describe('resolveDependencies — transitive dep rewriting', () => {
|
|
|
113
113
|
|
|
114
114
|
describe('resolveDependencies — Stellar workspace dependency vendoring', () => {
|
|
115
115
|
// Build a consumer (single crate) that path-deps into sub-crates of a
|
|
116
|
-
// protocol-stellar workspace dependency living in node_modules.
|
|
116
|
+
// protocol-stellar-v2 workspace dependency living in node_modules.
|
|
117
117
|
const setupStellarConsumer = (root: string) => {
|
|
118
118
|
createCrate(root, fixture('stellar-consumer.toml'));
|
|
119
119
|
|
|
120
|
-
const protocol = join(root, 'node_modules', '@layerzerolabs', 'protocol-stellar');
|
|
120
|
+
const protocol = join(root, 'node_modules', '@layerzerolabs', 'protocol-stellar-v2');
|
|
121
121
|
createCrate(protocol, fixture('stellar-workspace-root.toml'));
|
|
122
122
|
writeFileSync(join(protocol, 'package.json'), '{}');
|
|
123
|
-
// members:
|
|
123
|
+
// members: endpoint-v2 + message-libs/* — incl. a deep inheriting member
|
|
124
|
+
createCrate(join(protocol, 'endpoint-v2'), fixture('stellar-member-inheriting.toml'));
|
|
124
125
|
createCrate(
|
|
125
|
-
join(protocol, '
|
|
126
|
+
join(protocol, 'message-libs', 'message-lib-common'),
|
|
126
127
|
fixture('stellar-member-inheriting.toml'),
|
|
127
128
|
);
|
|
128
129
|
createCrate(
|
|
129
|
-
join(protocol, '
|
|
130
|
-
fixture('stellar-member-inheriting.toml'),
|
|
131
|
-
);
|
|
132
|
-
createCrate(join(protocol, 'contracts', 'oapps'), fixture('minimal.toml')); // grouping crate
|
|
133
|
-
createCrate(
|
|
134
|
-
join(protocol, 'contracts', 'oapps', 'oft-core'),
|
|
130
|
+
join(protocol, 'message-libs', 'simple-message-lib'),
|
|
135
131
|
fixture('stellar-member-inheriting.toml'),
|
|
136
132
|
);
|
|
137
133
|
return protocol;
|
|
@@ -143,11 +139,11 @@ describe('resolveDependencies — Stellar workspace dependency vendoring', () =>
|
|
|
143
139
|
|
|
144
140
|
await resolveDependencies({ cwd: root });
|
|
145
141
|
|
|
146
|
-
const vendored = join(root, 'dependencies', 'protocol-stellar');
|
|
142
|
+
const vendored = join(root, 'dependencies', 'protocol-stellar-v2');
|
|
147
143
|
expect(existsSync(join(vendored, 'Cargo.toml'))).toBe(true);
|
|
148
|
-
expect(existsSync(join(vendored, '
|
|
144
|
+
expect(existsSync(join(vendored, 'endpoint-v2', 'Cargo.toml'))).toBe(true);
|
|
149
145
|
// the deep member — the case the old one-level scan missed
|
|
150
|
-
expect(existsSync(join(vendored, '
|
|
146
|
+
expect(existsSync(join(vendored, 'message-libs', 'simple-message-lib', 'Cargo.toml'))).toBe(
|
|
151
147
|
true,
|
|
152
148
|
);
|
|
153
149
|
});
|
|
@@ -158,7 +154,9 @@ describe('resolveDependencies — Stellar workspace dependency vendoring', () =>
|
|
|
158
154
|
|
|
159
155
|
await resolveDependencies({ cwd: root });
|
|
160
156
|
|
|
161
|
-
const vendoredRoot = readToml(
|
|
157
|
+
const vendoredRoot = readToml(
|
|
158
|
+
join(root, 'dependencies', 'protocol-stellar-v2', 'Cargo.toml'),
|
|
159
|
+
);
|
|
162
160
|
// The root-only-table strip MUST be skipped for a vendored workspace root.
|
|
163
161
|
expect(vendoredRoot).toContain('[workspace]');
|
|
164
162
|
expect(vendoredRoot).toContain('[workspace.package]');
|
|
@@ -183,22 +181,148 @@ describe('resolveDependencies — Stellar workspace dependency vendoring', () =>
|
|
|
183
181
|
|
|
184
182
|
await resolveDependencies({ cwd: root });
|
|
185
183
|
|
|
186
|
-
// The consumer's `path = "dependencies/protocol-stellar/
|
|
184
|
+
// The consumer's `path = "dependencies/protocol-stellar-v2/message-libs/simple-message-lib"`
|
|
187
185
|
// resolves because that crate was vendored at exactly that location.
|
|
188
186
|
expect(
|
|
189
187
|
existsSync(
|
|
190
188
|
join(
|
|
191
189
|
root,
|
|
192
190
|
'dependencies',
|
|
193
|
-
'protocol-stellar',
|
|
194
|
-
'
|
|
195
|
-
'
|
|
196
|
-
'oft-core',
|
|
191
|
+
'protocol-stellar-v2',
|
|
192
|
+
'message-libs',
|
|
193
|
+
'simple-message-lib',
|
|
197
194
|
'Cargo.toml',
|
|
198
195
|
),
|
|
199
196
|
),
|
|
200
197
|
).toBe(true);
|
|
201
198
|
});
|
|
199
|
+
|
|
200
|
+
it('rewrites arbitrary-depth paths inside a vendored oft-core crate', async () => {
|
|
201
|
+
const root = join(TMP, 'stellar-oft-core-deep-paths');
|
|
202
|
+
createCrate(root, fixture('program-with-deps.toml'));
|
|
203
|
+
|
|
204
|
+
const protocol = join(root, 'node_modules', '@layerzerolabs', 'protocol-stellar-v2');
|
|
205
|
+
createCrate(protocol, fixture('stellar-workspace-root.toml'));
|
|
206
|
+
writeFileSync(join(protocol, 'package.json'), '{}');
|
|
207
|
+
createCrate(join(protocol, 'endpoint-v2'), fixture('minimal.toml'));
|
|
208
|
+
createCrate(join(protocol, 'message-libs', 'simple-message-lib'), fixture('minimal.toml'));
|
|
209
|
+
createCrate(join(protocol, 'message-libs', 'message-lib-common'), fixture('minimal.toml'));
|
|
210
|
+
|
|
211
|
+
const oftCore = join(root, 'node_modules', '@layerzerolabs', 'oft-core-stellar-contracts');
|
|
212
|
+
createCrate(oftCore, fixture('oft-core-with-stale-deep-deps.toml'));
|
|
213
|
+
writeFileSync(join(oftCore, 'package.json'), '{}');
|
|
214
|
+
|
|
215
|
+
await resolveDependencies({ cwd: root });
|
|
216
|
+
|
|
217
|
+
const copiedOftCore = readToml(
|
|
218
|
+
join(root, 'dependencies', 'oft-core-stellar-contracts', 'Cargo.toml'),
|
|
219
|
+
);
|
|
220
|
+
expect(copiedOftCore).toContain(
|
|
221
|
+
'path = "../protocol-stellar-v2/message-libs/simple-message-lib"',
|
|
222
|
+
);
|
|
223
|
+
expect(copiedOftCore).toContain(
|
|
224
|
+
'path = "../protocol-stellar-v2/message-libs/message-lib-common"',
|
|
225
|
+
);
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
describe('resolveDependencies — production npm dependency closure', () => {
|
|
230
|
+
const writePkgJson = (dir: string, deps: Record<string, string>) => {
|
|
231
|
+
writeFileSync(
|
|
232
|
+
join(dir, 'package.json'),
|
|
233
|
+
JSON.stringify({ name: 'fixture', version: '0.0.0', dependencies: deps }),
|
|
234
|
+
);
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const setupOappProductionLayout = (root: string) => {
|
|
238
|
+
createCrate(root, fixture('stellar-consumer.toml'));
|
|
239
|
+
writePkgJson(root, {
|
|
240
|
+
'@layerzerolabs/protocol-stellar-v2': '*',
|
|
241
|
+
'@layerzerolabs/common-utils-stellar-contracts': '*',
|
|
242
|
+
'@layerzerolabs/common-utils-macros-stellar-contracts': '*',
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
const protocol = join(root, 'node_modules', '@layerzerolabs', 'protocol-stellar-v2');
|
|
246
|
+
createCrate(protocol, fixture('stellar-workspace-root.toml'));
|
|
247
|
+
writePkgJson(protocol, {
|
|
248
|
+
'@layerzerolabs/common-utils-stellar-contracts': '*',
|
|
249
|
+
});
|
|
250
|
+
createCrate(join(protocol, 'endpoint-v2'), fixture('minimal.toml'));
|
|
251
|
+
createCrate(join(protocol, 'message-libs', 'simple-message-lib'), fixture('minimal.toml'));
|
|
252
|
+
|
|
253
|
+
const utils = join(
|
|
254
|
+
root,
|
|
255
|
+
'node_modules',
|
|
256
|
+
'@layerzerolabs',
|
|
257
|
+
'common-utils-stellar-contracts',
|
|
258
|
+
);
|
|
259
|
+
createCrate(utils, fixture('minimal.toml'));
|
|
260
|
+
writePkgJson(utils, {
|
|
261
|
+
'@layerzerolabs/common-utils-macros-stellar-contracts': '*',
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
// Sibling proc-macro package (published separately from common-utils).
|
|
265
|
+
const macros = join(
|
|
266
|
+
root,
|
|
267
|
+
'node_modules',
|
|
268
|
+
'@layerzerolabs',
|
|
269
|
+
'common-utils-macros-stellar-contracts',
|
|
270
|
+
);
|
|
271
|
+
createCrate(macros, fixture('minimal.toml'));
|
|
272
|
+
writePkgJson(macros, {});
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
it('vendors the full production closure reachable through npm dependencies only', async () => {
|
|
276
|
+
const root = join(TMP, 'production-closure');
|
|
277
|
+
setupOappProductionLayout(root);
|
|
278
|
+
|
|
279
|
+
await resolveDependencies({ cwd: root });
|
|
280
|
+
|
|
281
|
+
expect(existsSync(join(root, 'dependencies', 'protocol-stellar-v2', 'Cargo.toml'))).toBe(
|
|
282
|
+
true,
|
|
283
|
+
);
|
|
284
|
+
expect(
|
|
285
|
+
existsSync(join(root, 'dependencies', 'common-utils-stellar-contracts', 'Cargo.toml')),
|
|
286
|
+
).toBe(true);
|
|
287
|
+
expect(
|
|
288
|
+
existsSync(
|
|
289
|
+
join(root, 'dependencies', 'common-utils-macros-stellar-contracts', 'Cargo.toml'),
|
|
290
|
+
),
|
|
291
|
+
).toBe(true);
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
it('does not vendor crates that exist only as npm devDependencies', async () => {
|
|
295
|
+
const root = join(TMP, 'production-missing-devdep');
|
|
296
|
+
createCrate(root, fixture('stellar-consumer.toml'));
|
|
297
|
+
writeFileSync(
|
|
298
|
+
join(root, 'package.json'),
|
|
299
|
+
JSON.stringify({
|
|
300
|
+
name: 'oapp-stellar-contracts',
|
|
301
|
+
version: '0.0.0',
|
|
302
|
+
dependencies: {
|
|
303
|
+
'@layerzerolabs/protocol-stellar-v2': '*',
|
|
304
|
+
},
|
|
305
|
+
devDependencies: {
|
|
306
|
+
'@layerzerolabs/common-utils-stellar-contracts': '*',
|
|
307
|
+
},
|
|
308
|
+
}),
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
const protocol = join(root, 'node_modules', '@layerzerolabs', 'protocol-stellar-v2');
|
|
312
|
+
createCrate(protocol, fixture('stellar-workspace-root.toml'));
|
|
313
|
+
writePkgJson(protocol, {});
|
|
314
|
+
createCrate(join(protocol, 'endpoint-v2'), fixture('minimal.toml'));
|
|
315
|
+
createCrate(join(protocol, 'message-libs', 'simple-message-lib'), fixture('minimal.toml'));
|
|
316
|
+
|
|
317
|
+
await resolveDependencies({ cwd: root });
|
|
318
|
+
|
|
319
|
+
expect(existsSync(join(root, 'dependencies', 'protocol-stellar-v2', 'Cargo.toml'))).toBe(
|
|
320
|
+
true,
|
|
321
|
+
);
|
|
322
|
+
expect(
|
|
323
|
+
existsSync(join(root, 'dependencies', 'common-utils-stellar-contracts', 'Cargo.toml')),
|
|
324
|
+
).toBe(false);
|
|
325
|
+
});
|
|
202
326
|
});
|
|
203
327
|
|
|
204
328
|
describe('resolveDependencies — prune excluded workspace members', () => {
|
|
@@ -209,13 +333,12 @@ describe('resolveDependencies — prune excluded workspace members', () => {
|
|
|
209
333
|
const setupConsumerWithTestMember = (root: string) => {
|
|
210
334
|
createCrate(root, fixture('stellar-consumer.toml'));
|
|
211
335
|
|
|
212
|
-
const protocol = join(root, 'node_modules', '@layerzerolabs', 'protocol-stellar');
|
|
336
|
+
const protocol = join(root, 'node_modules', '@layerzerolabs', 'protocol-stellar-v2');
|
|
213
337
|
createCrate(protocol, fixture('stellar-workspace-with-tests.toml'));
|
|
214
338
|
writeFileSync(join(protocol, 'package.json'), '{}');
|
|
215
|
-
createCrate(
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
);
|
|
339
|
+
createCrate(join(protocol, 'endpoint-v2'), fixture('stellar-member-inheriting.toml'));
|
|
340
|
+
// Consumer also path-deps into message-libs; create a stub so the layout is complete.
|
|
341
|
+
createCrate(join(protocol, 'message-libs', 'simple-message-lib'), fixture('minimal.toml'));
|
|
219
342
|
|
|
220
343
|
// The excluded test member + extra files — none of this should be vendored.
|
|
221
344
|
const mock = join(protocol, 'tests', 'mock_vault');
|
|
@@ -230,12 +353,14 @@ describe('resolveDependencies — prune excluded workspace members', () => {
|
|
|
230
353
|
|
|
231
354
|
await resolveDependencies({ cwd: root });
|
|
232
355
|
|
|
233
|
-
const vendoredRoot = readToml(
|
|
356
|
+
const vendoredRoot = readToml(
|
|
357
|
+
join(root, 'dependencies', 'protocol-stellar-v2', 'Cargo.toml'),
|
|
358
|
+
);
|
|
234
359
|
// The dangling test member is gone...
|
|
235
360
|
expect(vendoredRoot).not.toContain('tests/mock_vault');
|
|
236
361
|
// ...but the workspace table and real members/globs remain intact.
|
|
237
362
|
expect(vendoredRoot).toContain('[workspace]');
|
|
238
|
-
expect(vendoredRoot).toContain('
|
|
363
|
+
expect(vendoredRoot).toContain('endpoint-v2');
|
|
239
364
|
});
|
|
240
365
|
|
|
241
366
|
it('does not vendor the excluded subtree at all', async () => {
|
|
@@ -244,10 +369,39 @@ describe('resolveDependencies — prune excluded workspace members', () => {
|
|
|
244
369
|
|
|
245
370
|
await resolveDependencies({ cwd: root });
|
|
246
371
|
|
|
247
|
-
const vendored = join(root, 'dependencies', 'protocol-stellar');
|
|
372
|
+
const vendored = join(root, 'dependencies', 'protocol-stellar-v2');
|
|
248
373
|
expect(existsSync(join(vendored, 'tests'))).toBe(false);
|
|
249
374
|
// real members are still vendored
|
|
250
|
-
expect(existsSync(join(vendored, '
|
|
375
|
+
expect(existsSync(join(vendored, 'endpoint-v2', 'Cargo.toml'))).toBe(true);
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
describe('resolveDependencies — excludes integration test dirs from vendored crates', () => {
|
|
380
|
+
// Mirrors the real oft-core → oft leak: a vendored dependency carries
|
|
381
|
+
// integration-tests/ source that is compiled only under #[cfg(test)] (via a
|
|
382
|
+
// #[path] mod). Left in dependencies/ it would never build but would enter the
|
|
383
|
+
// consumer's snapshot + verifiable source zip, coupling test churn to a deployed
|
|
384
|
+
// contract's source_sha256. It must be pruned like the existing tests/ exclusion.
|
|
385
|
+
it('does not vendor integration-tests/ or integration_tests/ subtrees', async () => {
|
|
386
|
+
const root = join(TMP, 'exclude-integration-tests');
|
|
387
|
+
createCrate(root, fixture('program-with-deps.toml'));
|
|
388
|
+
|
|
389
|
+
const dep = join(root, 'node_modules', '@layerzerolabs', 'utils-solana-rbac');
|
|
390
|
+
createCrate(dep, fixture('minimal.toml'));
|
|
391
|
+
writeFileSync(join(dep, 'package.json'), '{}');
|
|
392
|
+
// Both spellings are used across the stellar contracts (hyphen: oft/oft-core;
|
|
393
|
+
// underscore: omni-counter).
|
|
394
|
+
for (const dir of ['integration-tests', 'integration_tests']) {
|
|
395
|
+
mkdirSync(join(dep, dir), { recursive: true });
|
|
396
|
+
writeFileSync(join(dep, dir, 'mod.rs'), '// must NOT be vendored');
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
await resolveDependencies({ cwd: root });
|
|
400
|
+
|
|
401
|
+
const vendored = join(root, 'dependencies', 'utils-solana-rbac');
|
|
402
|
+
expect(existsSync(join(vendored, 'src', 'lib.rs'))).toBe(true);
|
|
403
|
+
expect(existsSync(join(vendored, 'integration-tests'))).toBe(false);
|
|
404
|
+
expect(existsSync(join(vendored, 'integration_tests'))).toBe(false);
|
|
251
405
|
});
|
|
252
406
|
});
|
|
253
407
|
|
|
@@ -73,6 +73,90 @@ describe('rewriteCargoToml', () => {
|
|
|
73
73
|
);
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
+
it('rewrites arbitrary-depth paths below a discovered package stem', async () => {
|
|
77
|
+
const depsDir = join(TMP, 'dependencies');
|
|
78
|
+
const crateDir = join(TMP, 'programs', 'oft-core');
|
|
79
|
+
const cargoToml = join(crateDir, 'Cargo.toml');
|
|
80
|
+
|
|
81
|
+
writeToml(cargoToml, fixture('oft-core-with-stale-deep-deps.toml'));
|
|
82
|
+
|
|
83
|
+
const protocolRoot = join(depsDir, 'protocol-stellar-v2');
|
|
84
|
+
const ctx: RewriteContext = {
|
|
85
|
+
pathMap: new Map([
|
|
86
|
+
['/real/protocol', protocolRoot],
|
|
87
|
+
['/real/protocol/endpoint-v2', join(protocolRoot, 'endpoint-v2')],
|
|
88
|
+
[
|
|
89
|
+
'/real/protocol/message-libs/simple-message-lib',
|
|
90
|
+
join(protocolRoot, 'message-libs', 'simple-message-lib'),
|
|
91
|
+
],
|
|
92
|
+
[
|
|
93
|
+
'/real/protocol/message-libs/message-lib-common',
|
|
94
|
+
join(protocolRoot, 'message-libs', 'message-lib-common'),
|
|
95
|
+
],
|
|
96
|
+
]),
|
|
97
|
+
discovered: new Map([['protocol-stellar-v2', '/real/protocol']]),
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
await rewriteCargoToml(crateDir, cargoToml, ctx);
|
|
101
|
+
const manifest = readParsed(cargoToml);
|
|
102
|
+
|
|
103
|
+
expect(depPath(manifest, 'dependencies', 'endpoint-v2')).toBe(
|
|
104
|
+
join('..', '..', 'dependencies', 'protocol-stellar-v2', 'endpoint-v2'),
|
|
105
|
+
);
|
|
106
|
+
expect(depPath(manifest, 'dev-dependencies', 'simple-message-lib')).toBe(
|
|
107
|
+
join(
|
|
108
|
+
'..',
|
|
109
|
+
'..',
|
|
110
|
+
'dependencies',
|
|
111
|
+
'protocol-stellar-v2',
|
|
112
|
+
'message-libs',
|
|
113
|
+
'simple-message-lib',
|
|
114
|
+
),
|
|
115
|
+
);
|
|
116
|
+
expect(depPath(manifest, 'dev-dependencies', 'message-lib-common')).toBe(
|
|
117
|
+
join(
|
|
118
|
+
'..',
|
|
119
|
+
'..',
|
|
120
|
+
'dependencies',
|
|
121
|
+
'protocol-stellar-v2',
|
|
122
|
+
'message-libs',
|
|
123
|
+
'message-lib-common',
|
|
124
|
+
),
|
|
125
|
+
);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('prefers the deepest discovered package stem over Map insertion order', async () => {
|
|
129
|
+
// Path contains both a shallow parent package name and a nested child package
|
|
130
|
+
// name. Insertion order lists the parent first — first-match would wrongly
|
|
131
|
+
// rewrite under the parent; most-specific must use the child stem.
|
|
132
|
+
const depsDir = join(TMP, 'dependencies');
|
|
133
|
+
const crateDir = join(TMP, 'programs', 'consumer');
|
|
134
|
+
const cargoToml = join(crateDir, 'Cargo.toml');
|
|
135
|
+
|
|
136
|
+
writeToml(
|
|
137
|
+
cargoToml,
|
|
138
|
+
'[dependencies]\nmacros = { path = "../../node_modules/parent-pkg/child-pkg/macros" }\n',
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
const ctx: RewriteContext = {
|
|
142
|
+
pathMap: new Map([
|
|
143
|
+
['/real/parent', join(depsDir, 'parent-pkg')],
|
|
144
|
+
['/real/child', join(depsDir, 'child-pkg')],
|
|
145
|
+
]),
|
|
146
|
+
// Parent inserted first — old first-match behavior would select it.
|
|
147
|
+
discovered: new Map([
|
|
148
|
+
['parent-pkg', '/real/parent'],
|
|
149
|
+
['child-pkg', '/real/child'],
|
|
150
|
+
]),
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
await rewriteCargoToml(crateDir, cargoToml, ctx);
|
|
154
|
+
|
|
155
|
+
expect(depPath(readParsed(cargoToml), 'dependencies', 'macros')).toBe(
|
|
156
|
+
join('..', '..', 'dependencies', 'child-pkg', 'macros'),
|
|
157
|
+
);
|
|
158
|
+
});
|
|
159
|
+
|
|
76
160
|
it('preserves features and other inline attrs', async () => {
|
|
77
161
|
const depsDir = join(TMP, 'dependencies');
|
|
78
162
|
const cargoToml = join(TMP, 'Cargo.toml');
|
package/dist/LQ26FJL3.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/resolve/rewrite.ts"],"names":["isTable","value","Array","isArray","DEP_TABLE_KEYS","pathDepSpecs","manifest","includeWorkspaceDeps","containers","target","Object","values","filter","depTables","flatMap","container","map","key","workspace","dependencies","table","spec","path","pruneExcludedLiteralMembers","changed","members","kept","m","includes","hasExcludedSegment","length","rewritePathDeps","originalDir","manifestDir","ctx","resolveViaRealpath","pathMap","resolveViaNameFallback","rewritten","relative","logger","trace","stripRootOnlyTables","rewriteCargoToml","cargoTomlPath","stripRootTables","parse","readFile","pathsChanged","dirname","tablesChanged","writeFile","stringify","debug","pathValue","resolvedPath","tryRealpath","join","get","undefined","segments","split","Boolean","leafDir","at","pkgName","realPath","discovered","parentDir","subTarget","rewriteCargoTomls","srcRoot","destRoot","tree","manifestDirs","preserve","isWorkspaceRoot"],"mappings":";;;;;;;;;AAyBA,IAAMA,OAAAA,mBAAU,MAAA,CAAA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,YAAYG,SAAAA,EAAW;AACpC,MAAA,MAAMC,YAAYnC,GAAAA,CAAIE,OAAAA,CAAQsB,IAAID,IAAAA,CAAKS,QAAAA,EAAUH,OAAAA,CAAAA,CAAAA;AACjD,MAAA,IAAIM,WAAW,OAAOA,SAAAA;AAC1B,IAAA;AACJ,EAAA;AACA,EAAA,OAAOV,MAAAA;AACX,CAAA,EAlB+B,wBAAA,CAAA;AAwBxB,IAAMW,iBAAAA,mBAAoB,MAAA,CAAA,OAC7BC,OAAAA,EACAC,QAAAA,EACAC,MACAvC,GAAAA,KAAAA;AAEA,EAAA,KAAA,MAAWD,WAAAA,IAAewC,KAAKC,YAAAA,EAAc;AACzC,IAAA,MAAMC,QAAAA,GAAW1C,WAAAA,KAAgB,GAAA,IAAQ,MAAM2C,gBAAgBJ,QAAAA,CAAAA;AAE/D,IAAA,MAAM7B,gBAAAA,CACFc,IAAAA,CAAKc,OAAAA,EAAStC,WAAAA,CAAAA,EACdwB,IAAAA,CAAKe,QAAAA,EAAUvC,WAAAA,EAAa,YAAA,CAAA,EAC5BC,GAAAA,EACA,CAACyC,QAAAA,CAAAA;AAET,EAAA;AACJ,CAAA,EAhBiC,mBAAA","file":"LQ26FJL3.js","sourcesContent":["/**\n * Rewrite a vendored Cargo.toml's path deps into the flat dependencies/ layout,\n * operating on the parsed TOML (via smol-toml) rather than text.\n */\n\nimport { readFile, writeFile } from 'fs/promises';\nimport { dirname, join, relative } from 'path';\nimport { parse, stringify } from 'smol-toml';\n\nimport { logger } from '../logger';\nimport { isWorkspaceRoot } from './discover';\nimport { hasExcludedSegment } from './exclude';\nimport { type CollectedTree, tryRealpath } from './io';\n\n/** Bundled resolution state passed through the rewrite pipeline. */\nexport interface RewriteContext {\n pathMap: Map<string, string>;\n discovered: Map<string, string>;\n}\n\ntype Table = Record<string, unknown>;\n\n/** A dependency spec that carries a `path` — an inline table like `{ path = \"…\" }`. */\ntype PathDepSpec = Table & { path: string };\n\nconst isTable = (value: unknown): value is Table =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst DEP_TABLE_KEYS = ['dependencies', 'dev-dependencies', 'build-dependencies'] as const;\n\n/**\n * Dependency specs that declare a `path`, across every dependency table (plus\n * `[workspace.dependencies]` when `includeWorkspaceDeps`). Specs are live references\n * into `manifest`, so mutating `.path` updates it.\n */\nconst pathDepSpecs = (manifest: Table, includeWorkspaceDeps: boolean): PathDepSpec[] => {\n // The root manifest and each [target.'cfg(...)'] table both hold DEP_TABLE_KEYS tables.\n const containers = [\n manifest,\n ...(isTable(manifest.target) ? Object.values(manifest.target).filter(isTable) : []),\n ];\n\n const depTables = [\n ...containers.flatMap((container) => DEP_TABLE_KEYS.map((key) => container[key])),\n ...(includeWorkspaceDeps && isTable(manifest.workspace)\n ? [manifest.workspace.dependencies]\n : []),\n ];\n\n return depTables\n .filter(isTable)\n .flatMap((table) => Object.values(table))\n .filter((spec): spec is PathDepSpec => isTable(spec) && typeof spec.path === 'string');\n};\n\n/**\n * Drop literal `members` / `default-members` entries whose path contains an excluded\n * directory segment (e.g. `tests/mock_vault`) — those dirs are never vendored, so the\n * member would dangle and fail Cargo's workspace load. Globs (`tests/*`) are kept; Cargo\n * re-expands them to a harmless empty match. Returns true if any member was removed.\n */\nexport const pruneExcludedLiteralMembers = (manifest: Table): boolean => {\n const workspace = manifest.workspace;\n if (!isTable(workspace)) return false;\n\n let changed = false;\n for (const key of ['members', 'default-members'] as const) {\n const members = workspace[key];\n if (!Array.isArray(members)) continue;\n\n // Keep everything except literal (non-glob) members inside an excluded dir.\n const kept = members.filter(\n (m) => typeof m !== 'string' || m.includes('*') || !hasExcludedSegment(m),\n );\n\n if (kept.length !== members.length) {\n workspace[key] = kept;\n changed = true;\n }\n }\n return changed;\n};\n\n/** Rebase every path dep in `manifest` into the flat dependencies/ layout. Returns true if any changed. */\nexport const rewritePathDeps = async (\n manifest: Table,\n originalDir: string,\n manifestDir: string,\n ctx: RewriteContext,\n includeWorkspaceDeps: boolean,\n): Promise<boolean> => {\n let changed = false;\n for (const spec of pathDepSpecs(manifest, includeWorkspaceDeps)) {\n const target =\n (await resolveViaRealpath(originalDir, spec.path, ctx.pathMap)) ??\n resolveViaNameFallback(spec.path, ctx);\n if (!target) continue;\n\n const rewritten = relative(manifestDir, target);\n if (rewritten === spec.path) continue;\n\n logger.trace(`rewrite path dep ${spec.path} -> ${rewritten}`);\n spec.path = rewritten;\n changed = true;\n }\n\n return changed;\n};\n\n/**\n * Delete the `[workspace]` / `[patch.*]` / `[profile.*]` tables — invalid or ignored in a\n * vendored dependency (only honored at the real workspace root). Returns true if any was removed.\n */\nexport const stripRootOnlyTables = (manifest: Table): boolean => {\n let changed = false;\n for (const table of ['workspace', 'patch', 'profile'] as const) {\n if (manifest[table] != null) {\n delete manifest[table];\n changed = true;\n }\n }\n return changed;\n};\n\n/**\n * Rewrite one vendored Cargo.toml in place: rebase its path deps, then strip the root-only\n * tables — or, for a preserved workspace root (`stripRootTables = false`), prune excluded\n * members instead. Re-serialized only if something changed.\n *\n * @param originalDir source crate dir the manifest was copied from\n * @param cargoTomlPath the vendored Cargo.toml to rewrite\n */\nexport const rewriteCargoToml = async (\n originalDir: string,\n cargoTomlPath: string,\n ctx: RewriteContext,\n stripRootTables = true,\n): Promise<void> => {\n const manifest = parse(await readFile(cargoTomlPath, 'utf-8'));\n\n const pathsChanged = await rewritePathDeps(\n manifest,\n originalDir,\n dirname(cargoTomlPath),\n ctx,\n !stripRootTables,\n );\n\n const tablesChanged = stripRootTables\n ? stripRootOnlyTables(manifest)\n : pruneExcludedLiteralMembers(manifest);\n\n if (pathsChanged || tablesChanged) {\n await writeFile(cargoTomlPath, stringify(manifest));\n logger.debug(`rewrote ${cargoTomlPath}`);\n }\n};\n\n/** Primary resolution: realpath the path through pnpm symlinks, then look it up in pathMap. */\nconst resolveViaRealpath = async (\n originalDir: string,\n pathValue: string,\n pathMap: Map<string, string>,\n): Promise<string | undefined> => {\n const resolvedPath = await tryRealpath(join(originalDir, pathValue));\n return resolvedPath ? pathMap.get(resolvedPath) : undefined;\n};\n\n/** Fallback: match the path's leaf dir name against a discovered package (for already-`dependencies/…` paths). */\nconst resolveViaNameFallback = (pathValue: string, ctx: RewriteContext): string | undefined => {\n const segments = pathValue.split('/').filter(Boolean);\n const leafDir = segments.at(-1);\n if (!leafDir) return undefined;\n\n for (const [pkgName, realPath] of ctx.discovered) {\n // Direct match: \"dependencies/utils-solana-rbac\" → match \"utils-solana-rbac\"\n if (pkgName === leafDir) {\n return ctx.pathMap.get(realPath);\n }\n // Subdir match: \"dependencies/utils-solana-rbac/macros\" → match parent\n const parentDir = segments.at(-2);\n if (parentDir && pkgName === parentDir) {\n const subTarget = ctx.pathMap.get(join(realPath, leafDir));\n if (subTarget) return subTarget;\n }\n }\n return undefined;\n};\n\n/**\n * Rewrite every Cargo.toml in a copied dependency tree. The root manifest keeps its\n * root-only tables when it's a workspace (members inherit from them); all others strip them.\n */\nexport const rewriteCargoTomls = async (\n srcRoot: string,\n destRoot: string,\n tree: CollectedTree,\n ctx: RewriteContext,\n): Promise<void> => {\n for (const manifestDir of tree.manifestDirs) {\n const preserve = manifestDir === '.' && (await isWorkspaceRoot(destRoot));\n\n await rewriteCargoToml(\n join(srcRoot, manifestDir),\n join(destRoot, manifestDir, 'Cargo.toml'),\n ctx,\n !preserve,\n );\n }\n};\n"]}
|
package/dist/WKRDI535.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/resolve/exclude.ts"],"names":["COPY_EXTENSIONS","Set","EXCLUDE_DIR","EXCLUDE_FILE","COPY_EXCLUDES","removeExcludedFiles","entries","filter","entry","has","hasExcludedSegment","relPath","split","some","segment"],"mappings":";;;AACO,IAAMA,eAAAA,uBAAsBC,GAAAA,CAAI;AAAC,EAAA,KAAA;AAAO,EAAA,OAAA;AAAS,EAAA;AAAQ,CAAA;AAGhE,IAAMC,WAAAA,uBAAkBD,GAAAA,CAAI;;AAExB,EAAA,cAAA;AACA,EAAA,cAAA;AACA,EAAA,QAAA;AACA,EAAA,QAAA;;AAEA,EAAA,UAAA;AACA,EAAA,SAAA;AACA,EAAA,MAAA;AACA,EAAA,QAAA;;AAEA,EAAA,MAAA;AACA,EAAA,SAAA;;AAEA,EAAA;AACH,CAAA,CAAA;AAGD,IAAME,YAAAA,uBAAmBF,GAAAA,CAAI;;AAEzB,EAAA,cAAA;AACA,EAAA,gBAAA;;AAEA,EAAA,0BAAA;AACA,EAAA,YAAA;;AAEA,EAAA,YAAA;AACA,EAAA,aAAA;AACA,EAAA,WAAA;AACA,EAAA,qBAAA;AACA,EAAA,cAAA;;AAEA,EAAA;AACH,CAAA,CAAA;AAED,IAAMG,aAAAA,uBAAoBH,GAAAA,CAAI;AAAIC,EAAAA,GAAAA,WAAAA;AAAgBC,EAAAA,GAAAA;AAAa,CAAA,CAAA;AAGxD,IAAME,mBAAAA,mBAAsB,MAAA,CAAA,CAACC,OAAAA,KAChCA,OAAAA,CAAQC,MAAAA,CAAO,CAACC,KAAAA,KAAU,CAACJ,aAAAA,CAAcK,GAAAA,CAAID,KAAAA,CAAAA,CAAAA,EADd,qBAAA;AAO5B,IAAME,kBAAAA,mBAAqB,MAAA,CAAA,CAACC,OAAAA,KAC/BA,OAAAA,CAAQC,MAAM,QAAA,CAAA,CAAUC,IAAAA,CAAK,CAACC,OAAAA,KAAYZ,WAAAA,CAAYO,GAAAA,CAAIK,OAAAA,CAAAA,CAAAA,EAD5B,oBAAA","file":"WKRDI535.js","sourcesContent":["/** Files vendored into dependencies/ — everything else is skipped by type. */\nexport const COPY_EXTENSIONS = new Set(['.rs', '.toml', '.json']);\n\n/** Directories never descended into when copying or scanning. */\nconst EXCLUDE_DIR = new Set([\n // npm directories\n 'dependencies',\n 'node_modules',\n 'target',\n '.turbo',\n // cargo directories\n 'examples',\n 'benches',\n 'fuzz',\n '.cargo',\n // vcs / ci\n '.git',\n '.github',\n // shared directories\n 'tests',\n]);\n\n/** Files matching COPY_EXTENSIONS that must still be skipped — lockfiles, toolchain config, etc. */\nconst EXCLUDE_FILE = new Set([\n // npm\n 'package.json',\n 'pnpm-lock.yaml',\n // turbo\n 'turbo-snapshot.lock.json',\n 'turbo.json',\n // cargo/rust\n 'Cargo.lock',\n 'clippy.toml',\n 'deny.toml',\n 'rust-toolchain.toml',\n 'rustfmt.toml',\n // solana\n 'Anchor.toml',\n]);\n\nconst COPY_EXCLUDES = new Set([...EXCLUDE_DIR, ...EXCLUDE_FILE]);\n\n/** Filter excluded names from a directory listing. */\nexport const removeExcludedFiles = (entries: string[]): string[] =>\n entries.filter((entry) => !COPY_EXCLUDES.has(entry));\n\n/**\n * True if a resolved crate path contains an excluded segment.\n * Do not use on raw `path` dep values — those legitimately pass through node_modules.\n */\nexport const hasExcludedSegment = (relPath: string): boolean =>\n relPath.split(/[\\\\/]+/).some((segment) => EXCLUDE_DIR.has(segment));\n"]}
|