@parity/ppn-network-config 0.2.0-rc.1

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.
Files changed (59) hide show
  1. package/LICENSE +202 -0
  2. package/config/ports.env +128 -0
  3. package/dist/bundle.d.ts +36 -0
  4. package/dist/bundle.d.ts.map +1 -0
  5. package/dist/bundle.js +7 -0
  6. package/dist/bundle.js.map +1 -0
  7. package/dist/dashboard-model.d.ts +63 -0
  8. package/dist/dashboard-model.d.ts.map +1 -0
  9. package/dist/dashboard-model.js +126 -0
  10. package/dist/dashboard-model.js.map +1 -0
  11. package/dist/dub.d.ts +98 -0
  12. package/dist/dub.d.ts.map +1 -0
  13. package/dist/dub.js +202 -0
  14. package/dist/dub.js.map +1 -0
  15. package/dist/env-file.d.ts +6 -0
  16. package/dist/env-file.d.ts.map +1 -0
  17. package/dist/env-file.js +30 -0
  18. package/dist/env-file.js.map +1 -0
  19. package/dist/fork-toml.d.ts +35 -0
  20. package/dist/fork-toml.d.ts.map +1 -0
  21. package/dist/fork-toml.js +276 -0
  22. package/dist/fork-toml.js.map +1 -0
  23. package/dist/genesis-patch.d.ts +54 -0
  24. package/dist/genesis-patch.d.ts.map +1 -0
  25. package/dist/genesis-patch.js +223 -0
  26. package/dist/genesis-patch.js.map +1 -0
  27. package/dist/index.d.ts +19 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +19 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/load.d.ts +12 -0
  32. package/dist/load.d.ts.map +1 -0
  33. package/dist/load.js +23 -0
  34. package/dist/load.js.map +1 -0
  35. package/dist/networks.d.ts +214 -0
  36. package/dist/networks.d.ts.map +1 -0
  37. package/dist/networks.js +329 -0
  38. package/dist/networks.js.map +1 -0
  39. package/dist/nginx-routes.d.ts +10 -0
  40. package/dist/nginx-routes.d.ts.map +1 -0
  41. package/dist/nginx-routes.js +37 -0
  42. package/dist/nginx-routes.js.map +1 -0
  43. package/dist/overrides.d.ts +50 -0
  44. package/dist/overrides.d.ts.map +1 -0
  45. package/dist/overrides.js +169 -0
  46. package/dist/overrides.js.map +1 -0
  47. package/dist/repo-root.d.ts +42 -0
  48. package/dist/repo-root.d.ts.map +1 -0
  49. package/dist/repo-root.js +129 -0
  50. package/dist/repo-root.js.map +1 -0
  51. package/dist/toml-generator.d.ts +30 -0
  52. package/dist/toml-generator.d.ts.map +1 -0
  53. package/dist/toml-generator.js +469 -0
  54. package/dist/toml-generator.js.map +1 -0
  55. package/dist/types.d.ts +14 -0
  56. package/dist/types.d.ts.map +1 -0
  57. package/dist/types.js +2 -0
  58. package/dist/types.js.map +1 -0
  59. package/package.json +37 -0
@@ -0,0 +1,37 @@
1
+ // nginx upstreams and location blocks, generated from the dashboard model.
2
+ //
3
+ // These blocks used to be hand-maintained in server/nginx/ppn.conf.template — one upstream
4
+ // and one location per chain and service, edited by hand whenever the network changed, and
5
+ // nothing kept them in step with what actually ran. They are now emitted from the same route
6
+ // table the dashboard serves and proxies, so nginx on a server and the local proxy on a
7
+ // laptop cannot disagree about a path.
8
+ //
9
+ // Only the *chain* routes are generated: they are uniform (a proxy_pass plus the websocket
10
+ // snippet) and they are what changes when a descriptor changes — a new parachain is a new
11
+ // route. The service blocks (eth-rpc, dub, the storage provider, ipfs) stay hand-written in
12
+ // the template: each carries bespoke CORS, body-size and header-stripping rules that are
13
+ // behaviour, not routing, and flattening them into a generator would erase it. TLS, certbot,
14
+ // the p2p WSS streams, logs and health stay in the template too.
15
+ const sanitize = (id) => id.replace(/[^a-z0-9]/g, '_');
16
+ /**
17
+ * The `upstream` blocks (http context) and `location` blocks (server context), as two
18
+ * strings, so the caller can splice each into the right place in the template.
19
+ */
20
+ export function nginxRoutes(model) {
21
+ const entries = model.chains;
22
+ const upstreams = entries
23
+ .map((e) => `upstream ${sanitize(e.id)} {
24
+ server 127.0.0.1:${e.port};
25
+ keepalive 32;
26
+ }`)
27
+ .join('\n\n');
28
+ const locations = entries
29
+ .map((e) => ` # ${e.label}
30
+ location ${e.path} {
31
+ proxy_pass http://${sanitize(e.id)}/;
32
+ include /etc/nginx/snippets/websocket-proxy.conf;
33
+ }`)
34
+ .join('\n\n');
35
+ return { upstreams, locations };
36
+ }
37
+ //# sourceMappingURL=nginx-routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nginx-routes.js","sourceRoot":"","sources":["../src/nginx-routes.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,EAAE;AACF,2FAA2F;AAC3F,2FAA2F;AAC3F,6FAA6F;AAC7F,wFAAwF;AACxF,uCAAuC;AACvC,EAAE;AACF,2FAA2F;AAC3F,0FAA0F;AAC1F,4FAA4F;AAC5F,yFAAyF;AACzF,6FAA6F;AAC7F,iEAAiE;AAIjE,MAAM,QAAQ,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;AAE/D;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,KAAqB;IAC/C,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC;IAE7B,MAAM,SAAS,GAAG,OAAO;SACtB,GAAG,CACF,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;uBAChB,CAAC,CAAC,IAAI;;EAE3B,CACG;SACA,IAAI,CAAC,MAAM,CAAC,CAAC;IAEhB,MAAM,SAAS,GAAG,OAAO;SACtB,GAAG,CACF,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,KAAK;eACd,CAAC,CAAC,IAAI;4BACO,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;;MAEpC,CACD;SACA,IAAI,CAAC,MAAM,CAAC,CAAC;IAEhB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAClC,CAAC"}
@@ -0,0 +1,50 @@
1
+ import type { NetworkDef, ReleasePin } from './networks.js';
2
+ /** One parsed override: which slot, and where it now comes from. */
3
+ export interface Override {
4
+ /** Release key (`--release`) or binary name (`--binary`). */
5
+ key: string;
6
+ pin: ReleasePin;
7
+ }
8
+ export interface OverrideSet {
9
+ releases: Override[];
10
+ binaries: Override[];
11
+ /** Keyed by chain (`asset-hub`), not by file: a chain has exactly one runtime. */
12
+ runtimes: Override[];
13
+ }
14
+ /** Synthetic release key for a per-binary override, so validation still sees a declared pin. */
15
+ export declare const overrideReleaseKey: (binary: string) => string;
16
+ /**
17
+ * Parse `name=owner/repo@tag`. Also accepts `name=file:/abs/path` for a locally built
18
+ * artifact, which is the honest spelling of what pre-seeding bin/ was doing implicitly.
19
+ */
20
+ export declare function parseOverride(spec: string, what: string): Override;
21
+ /**
22
+ * Overrides from the environment. Flags cannot reach every caller — zombienet spawns custom
23
+ * processes with no arguments, and a cloud VM gets env — so both channels exist and the flag
24
+ * wins.
25
+ *
26
+ * PPN_RELEASES="polkadot-sdk=paritytech/polkadot-sdk@polkadot-stable2606-1"
27
+ * PPN_BINARIES="polkadot-omni-node=paritytech/release-automation@polkadot-weekly2026w33-rc2"
28
+ */
29
+ export declare function overridesFromEnv(env?: NodeJS.ProcessEnv): OverrideSet;
30
+ /** Later wins, so a flag overrides the same key set in the environment. */
31
+ export declare function mergeOverrides(...sets: OverrideSet[]): OverrideSet;
32
+ /**
33
+ * Apply overrides to a validated descriptor. Mutates nothing the caller owns: the returned
34
+ * definition is a shallow-cloned structure with new releases and binary refs.
35
+ *
36
+ * A release override repoints every binary and runtime on that key. A binary override moves
37
+ * one file only, through a synthetic release, so `polkadot` can stay on the weekly build
38
+ * while `polkadot-omni-node` comes from somewhere else.
39
+ */
40
+ export declare function applyOverrides(net: NetworkDef, set: OverrideSet): NetworkDef;
41
+ /** Which slots an override set touched, for `show` and for logging what a run actually used. */
42
+ export declare function overriddenKeys(set: OverrideSet): Set<string>;
43
+ /**
44
+ * Everything that will actually be applied: the environment, plus flags on top. Callers report
45
+ * from this rather than from their own flags — otherwise `ppn show` marks a flag override and
46
+ * stays silent about an identical one arriving through PPN_BINARIES, which is the same
47
+ * "reported one thing, ran another" trap the overrides exist to remove.
48
+ */
49
+ export declare function effectiveOverrides(extra?: OverrideSet): OverrideSet;
50
+ //# sourceMappingURL=overrides.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overrides.d.ts","sourceRoot":"","sources":["../src/overrides.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAc,MAAM,eAAe,CAAC;AAExE,oEAAoE;AACpE,MAAM,WAAW,QAAQ;IACvB,6DAA6D;IAC7D,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,UAAU,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrB,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrB,kFAAkF;IAClF,QAAQ,EAAE,QAAQ,EAAE,CAAC;CACtB;AAED,gGAAgG;AAChG,eAAO,MAAM,kBAAkB,GAAI,QAAQ,MAAM,WAAyB,CAAC;AAE3E;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,CAwBlE;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,WAAW,CAYlF;AAED,2EAA2E;AAC3E,wBAAgB,cAAc,CAAC,GAAG,IAAI,EAAE,WAAW,EAAE,GAAG,WAAW,CAWlE;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,GAAG,UAAU,CAsF5E;AAED,gGAAgG;AAChG,wBAAgB,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAE5D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,EAAE,WAAW,GAAG,WAAW,CAEnE"}
@@ -0,0 +1,169 @@
1
+ // Repointing a binary or a whole release at a different source, without editing the descriptor.
2
+ //
3
+ // Why this exists: a consumer (triangle-e2e's release gate, a CI job testing one PR build)
4
+ // needs "previewnet, but this binary from that tag". Its options before this were to edit
5
+ // networks/<name>.json, duplicate it, or pre-seed bin/ and rely on `fetch --if-needed`
6
+ // skipping — and that skip is all-or-nothing, so a partial pre-seed makes PPN refetch and
7
+ // silently overwrite the pins it was given. A gate that reports pinned versions while running
8
+ // different ones is the worst failure that path can produce.
9
+ //
10
+ // Applied inside loadNetwork, so `fetch`, `generate`, `show` and `bite` cannot disagree about
11
+ // what a network is made of, and `ppn show --json` reports exactly what will run.
12
+ /** Synthetic release key for a per-binary override, so validation still sees a declared pin. */
13
+ export const overrideReleaseKey = (binary) => `override:${binary}`;
14
+ /**
15
+ * Parse `name=owner/repo@tag`. Also accepts `name=file:/abs/path` for a locally built
16
+ * artifact, which is the honest spelling of what pre-seeding bin/ was doing implicitly.
17
+ */
18
+ export function parseOverride(spec, what) {
19
+ const eq = spec.indexOf('=');
20
+ if (eq <= 0) {
21
+ throw new Error(`${what} "${spec}" must be <name>=<owner/repo@tag> (or <name>=file:/path)`);
22
+ }
23
+ const key = spec.slice(0, eq).trim();
24
+ const source = spec.slice(eq + 1).trim();
25
+ if (!key)
26
+ throw new Error(`${what} "${spec}" has an empty name`);
27
+ if (source.startsWith('file:')) {
28
+ const file = source.slice('file:'.length);
29
+ if (!file)
30
+ throw new Error(`${what} "${spec}" has an empty file path`);
31
+ return { key, pin: { repo: source, tag: 'local' } };
32
+ }
33
+ const at = source.lastIndexOf('@');
34
+ if (at <= 0) {
35
+ throw new Error(`${what} "${spec}": "${source}" must be <owner/repo@tag> or file:/path`);
36
+ }
37
+ const repo = source.slice(0, at);
38
+ const tag = source.slice(at + 1);
39
+ if (!repo.includes('/'))
40
+ throw new Error(`${what} "${spec}": "${repo}" must be owner/repo`);
41
+ if (!tag)
42
+ throw new Error(`${what} "${spec}": missing tag after @`);
43
+ return { key, pin: { repo, tag } };
44
+ }
45
+ /**
46
+ * Overrides from the environment. Flags cannot reach every caller — zombienet spawns custom
47
+ * processes with no arguments, and a cloud VM gets env — so both channels exist and the flag
48
+ * wins.
49
+ *
50
+ * PPN_RELEASES="polkadot-sdk=paritytech/polkadot-sdk@polkadot-stable2606-1"
51
+ * PPN_BINARIES="polkadot-omni-node=paritytech/release-automation@polkadot-weekly2026w33-rc2"
52
+ */
53
+ export function overridesFromEnv(env = process.env) {
54
+ const parse = (value, what) => (value ?? '')
55
+ .split(',')
56
+ .map((s) => s.trim())
57
+ .filter(Boolean)
58
+ .map((s) => parseOverride(s, what));
59
+ return {
60
+ releases: parse(env.PPN_RELEASES, 'PPN_RELEASES entry'),
61
+ binaries: parse(env.PPN_BINARIES, 'PPN_BINARIES entry'),
62
+ runtimes: parse(env.PPN_RUNTIMES, 'PPN_RUNTIMES entry'),
63
+ };
64
+ }
65
+ /** Later wins, so a flag overrides the same key set in the environment. */
66
+ export function mergeOverrides(...sets) {
67
+ const pick = (all) => {
68
+ const byKey = new Map();
69
+ for (const o of all)
70
+ byKey.set(o.key, o);
71
+ return [...byKey.values()];
72
+ };
73
+ return {
74
+ releases: pick(sets.flatMap((s) => s.releases)),
75
+ binaries: pick(sets.flatMap((s) => s.binaries)),
76
+ runtimes: pick(sets.flatMap((s) => s.runtimes)),
77
+ };
78
+ }
79
+ /**
80
+ * Apply overrides to a validated descriptor. Mutates nothing the caller owns: the returned
81
+ * definition is a shallow-cloned structure with new releases and binary refs.
82
+ *
83
+ * A release override repoints every binary and runtime on that key. A binary override moves
84
+ * one file only, through a synthetic release, so `polkadot` can stay on the weekly build
85
+ * while `polkadot-omni-node` comes from somewhere else.
86
+ */
87
+ export function applyOverrides(net, set) {
88
+ if (set.releases.length === 0 && set.binaries.length === 0 && set.runtimes.length === 0)
89
+ return net;
90
+ const releases = { ...net.releases };
91
+ const applied = [];
92
+ for (const o of set.releases) {
93
+ if (!(o.key in releases)) {
94
+ throw new Error(`--release "${o.key}" is not a release of ${net.name} ` +
95
+ `(declared: ${Object.keys(net.releases).join(', ')})`);
96
+ }
97
+ releases[o.key] = o.pin;
98
+ applied.push(o.key);
99
+ }
100
+ const binaryPins = new Map(set.binaries.map((o) => [o.key, o.pin]));
101
+ const known = new Set();
102
+ const repoint = (ref) => {
103
+ known.add(ref.name);
104
+ const pin = binaryPins.get(ref.name);
105
+ if (!pin)
106
+ return ref;
107
+ const key = overrideReleaseKey(ref.name);
108
+ releases[key] = pin;
109
+ return { ...ref, release: key };
110
+ };
111
+ // A runtime is keyed by the chain that runs it: `--runtime asset-hub=file:/path` is how a
112
+ // wasm built elsewhere — a CI artifact from a polkadot-fellows/runtimes branch, an srtool
113
+ // build on a laptop — is fed in without publishing it anywhere first. `--release` could only
114
+ // ever move a whole release, which is the wrong grain for one chain under test.
115
+ const runtimePins = new Map(set.runtimes.map((o) => [o.key, o.pin]));
116
+ const knownChains = new Set();
117
+ const repointRuntime = (ref, chainKey) => {
118
+ knownChains.add(chainKey);
119
+ const pin = runtimePins.get(chainKey);
120
+ if (!pin)
121
+ return ref;
122
+ if (!ref.runtime) {
123
+ throw new Error(`--runtime "${chainKey}" names a chain of ${net.name} that declares no runtime ` +
124
+ '(a fork carries every runtime in the state it restores — use `ppn bite --upgrade` there)');
125
+ }
126
+ const key = overrideReleaseKey(`runtime:${chainKey}`);
127
+ releases[key] = pin;
128
+ return { ...ref, runtime: { ...ref.runtime, release: key } };
129
+ };
130
+ const out = {
131
+ ...net,
132
+ releases,
133
+ relay: repointRuntime({ ...net.relay, binary: repoint(net.relay.binary) }, 'relay'),
134
+ parachains: net.parachains.map((p) => repointRuntime({ ...p, binary: repoint(p.binary) }, p.key)),
135
+ services: Object.fromEntries(Object.entries(net.services).map(([name, cfg]) => cfg && typeof cfg === 'object' && cfg.binary
136
+ ? [name, { ...cfg, binary: repoint(cfg.binary) }]
137
+ : [name, cfg])),
138
+ tools: Object.fromEntries(Object.entries(net.tools).map(([name, ref]) => [name, repoint(ref)])),
139
+ };
140
+ // A typo in a chain name would silently leave the declared runtime in place, and the run
141
+ // would then test the runtime it was trying to replace.
142
+ for (const chain of runtimePins.keys()) {
143
+ if (!knownChains.has(chain)) {
144
+ throw new Error(`--runtime "${chain}" is not a chain of ${net.name} (declared: ${[...knownChains].join(', ')})`);
145
+ }
146
+ }
147
+ // A typo in a binary name would otherwise be silently ignored, and the gate would test the
148
+ // binary it was trying to replace.
149
+ for (const name of binaryPins.keys()) {
150
+ if (!known.has(name)) {
151
+ throw new Error(`--binary "${name}" is not a binary of ${net.name} (has: ${[...known].sort().join(', ')})`);
152
+ }
153
+ }
154
+ return out;
155
+ }
156
+ /** Which slots an override set touched, for `show` and for logging what a run actually used. */
157
+ export function overriddenKeys(set) {
158
+ return new Set([...set.releases.map((o) => o.key), ...set.binaries.map((o) => overrideReleaseKey(o.key))]);
159
+ }
160
+ /**
161
+ * Everything that will actually be applied: the environment, plus flags on top. Callers report
162
+ * from this rather than from their own flags — otherwise `ppn show` marks a flag override and
163
+ * stays silent about an identical one arriving through PPN_BINARIES, which is the same
164
+ * "reported one thing, ran another" trap the overrides exist to remove.
165
+ */
166
+ export function effectiveOverrides(extra) {
167
+ return mergeOverrides(overridesFromEnv(), extra ?? { releases: [], binaries: [], runtimes: [] });
168
+ }
169
+ //# sourceMappingURL=overrides.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overrides.js","sourceRoot":"","sources":["../src/overrides.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,EAAE;AACF,2FAA2F;AAC3F,0FAA0F;AAC1F,uFAAuF;AACvF,0FAA0F;AAC1F,8FAA8F;AAC9F,6DAA6D;AAC7D,EAAE;AACF,8FAA8F;AAC9F,kFAAkF;AAkBlF,gGAAgG;AAChG,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,YAAY,MAAM,EAAE,CAAC;AAE3E;;;GAGG;AACH,MAAM,U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,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7G,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAmB;IACpD,OAAO,cAAc,CAAC,gBAAgB,EAAE,EAAE,KAAK,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;AACnG,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Where the shipped, read-only half lives.
3
+ *
4
+ * Searched from several starting points, because this module and the data are not always in
5
+ * the same package. In a checkout they are: walking up from here finds the repo root. Once
6
+ * published they are not — the launchers and the defaults ship in @parity/ppn, while this code
7
+ * ships in @parity/ppn-network-config, so walking up from here only ever reaches
8
+ * node_modules. The entry point is the reliable anchor: it lives inside the package that
9
+ * carries the data.
10
+ */
11
+ export declare function packageRoot(from?: string): string;
12
+ /**
13
+ * The per-user home an install falls back to, for a `ppn` that is on the PATH rather than in a
14
+ * checkout. Honours XDG when it is set, since that is where a Linux user expects a tool's data.
15
+ */
16
+ export declare function defaultHome(): string;
17
+ /**
18
+ * Where this run's state and network definitions live:
19
+ *
20
+ * 1. `$PPN_HOME`, when set — the explicit answer, and the one CI and the servers use.
21
+ * 2. the nearest directory above the working directory that has `networks/` — which makes a
22
+ * git checkout behave exactly as it always has.
23
+ * 3. the per-user home (`~/.ppn`, or $XDG_DATA_HOME/ppn) — where an installed `ppn` keeps
24
+ * everything it owns, so one copy of the ~540 MB of binaries serves every network the
25
+ * user runs, and nothing is written into node_modules or into whatever directory the
26
+ * command happened to be typed in.
27
+ *
28
+ * A checkout reached through the entry point (rather than the cwd) still counts as a
29
+ * workspace — zombienet's custom processes run from the spawn's temp directory, not the repo.
30
+ * An installed package never does: anything under node_modules is read-only by nature and
31
+ * replaced wholesale by the next install. Descriptors are read from it (`networksDirs`);
32
+ * state is never written to it.
33
+ */
34
+ export declare function workspaceRoot(cwd?: string): string;
35
+ /**
36
+ * The repo root, for code that predates the split. Same as the package root: in a checkout
37
+ * that is also the workspace. New code should say which half it means.
38
+ */
39
+ export declare function repoRoot(from?: string): string;
40
+ /** Where the descriptor for `name` lives: the workspace first, then whatever shipped. */
41
+ export declare function networksDirs(): string[];
42
+ //# sourceMappingURL=repo-root.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repo-root.d.ts","sourceRoot":"","sources":["../src/repo-root.ts"],"names":[],"mappings":"AAiDA;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAoBjD;AAED;;;GAGG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAGpC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAAC,GAAG,GAAE,MAAsB,GAAG,MAAM,CAejE;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,yFAAyF;AACzF,wBAAgB,YAAY,IAAI,MAAM,EAAE,CAGvC"}
@@ -0,0 +1,129 @@
1
+ // Two roots, because PPN is two things.
2
+ //
3
+ // **The package** is what ships: compiled code, the launchers zombienet execs by path, and the
4
+ // neutral defaults (config/ports.env, the zombienet config templates). Read-only.
5
+ //
6
+ // **The workspace** is what a run owns: the network descriptors it may run, the downloaded
7
+ // binaries, chain state, fork bundles, generated config. Writable, and per-user.
8
+ //
9
+ // They were the same directory for as long as PPN could only be a git checkout, which is why
10
+ // `repoRoot()` conflated them. Splitting them is what lets the tool run from node_modules —
11
+ // and it puts the descriptors on the workspace side, so a published package carries no
12
+ // deployment detail (endpoints, hostnames) at all.
13
+ //
14
+ // In a checkout both resolve to the repo root, so nothing changes for anyone working in one.
15
+ //
16
+ // Never count `..` from import.meta.dirname to find either. That count differs between src/
17
+ // under tsx and dist/ after a build, and again between packages nested at different depths;
18
+ // this session shipped two bugs that way — a fork config pointing at `packages/bin/polkadot`,
19
+ // and a `generate` writing to `packages/bin/`, invisible locally because make passes the path.
20
+ import fs from 'node:fs';
21
+ import os from 'node:os';
22
+ import path from 'node:path';
23
+ /**
24
+ * Ships inside the package, so its presence identifies the package root. Just ports.env: it is
25
+ * this library's own default and travels with it, while the shell launchers travel with the
26
+ * CLI. Requiring both would make the library unable to find its own configuration when
27
+ * installed on its own.
28
+ */
29
+ const PACKAGE_MARKERS = [path.join('config', 'ports.env')];
30
+ /** Identifies a workspace: the networks a run is allowed to spawn. */
31
+ const WORKSPACE_MARKER = 'networks';
32
+ function searchUp(from, has) {
33
+ let dir = path.resolve(from);
34
+ for (let i = 0; i < 8; i++) {
35
+ if (has(dir))
36
+ return dir;
37
+ const parent = path.dirname(dir);
38
+ if (parent === dir)
39
+ break;
40
+ dir = parent;
41
+ }
42
+ return null;
43
+ }
44
+ const isPackageRoot = (dir) => PACKAGE_MARKERS.every((m) => fs.existsSync(path.join(dir, m)));
45
+ /**
46
+ * Where the shipped, read-only half lives.
47
+ *
48
+ * Searched from several starting points, because this module and the data are not always in
49
+ * the same package. In a checkout they are: walking up from here finds the repo root. Once
50
+ * published they are not — the launchers and the defaults ship in @parity/ppn, while this code
51
+ * ships in @parity/ppn-network-config, so walking up from here only ever reaches
52
+ * node_modules. The entry point is the reliable anchor: it lives inside the package that
53
+ * carries the data.
54
+ */
55
+ export function packageRoot(from) {
56
+ const candidates = [
57
+ from,
58
+ process.env.PPN_PACKAGE_ROOT,
59
+ import.meta.dirname,
60
+ // The running CLI, which is inside the package that ships scripts/ and config/.
61
+ process.argv[1] ? path.dirname(process.argv[1]) : undefined,
62
+ process.cwd(),
63
+ ].filter((c) => Boolean(c));
64
+ for (const start of candidates) {
65
+ const found = searchUp(start, isPackageRoot);
66
+ if (found)
67
+ return found;
68
+ }
69
+ throw new Error('PPN package root not found — no directory above ' +
70
+ candidates.join(', ') +
71
+ ` holds ${PACKAGE_MARKERS.join(' + ')}.\n` +
72
+ ' Set PPN_PACKAGE_ROOT if the package layout is unusual.');
73
+ }
74
+ /**
75
+ * The per-user home an install falls back to, for a `ppn` that is on the PATH rather than in a
76
+ * checkout. Honours XDG when it is set, since that is where a Linux user expects a tool's data.
77
+ */
78
+ export function defaultHome() {
79
+ const xdg = process.env.XDG_DATA_HOME;
80
+ return xdg ? path.join(xdg, 'ppn') : path.join(os.homedir(), '.ppn');
81
+ }
82
+ /**
83
+ * Where this run's state and network definitions live:
84
+ *
85
+ * 1. `$PPN_HOME`, when set — the explicit answer, and the one CI and the servers use.
86
+ * 2. the nearest directory above the working directory that has `networks/` — which makes a
87
+ * git checkout behave exactly as it always has.
88
+ * 3. the per-user home (`~/.ppn`, or $XDG_DATA_HOME/ppn) — where an installed `ppn` keeps
89
+ * everything it owns, so one copy of the ~540 MB of binaries serves every network the
90
+ * user runs, and nothing is written into node_modules or into whatever directory the
91
+ * command happened to be typed in.
92
+ *
93
+ * A checkout reached through the entry point (rather than the cwd) still counts as a
94
+ * workspace — zombienet's custom processes run from the spawn's temp directory, not the repo.
95
+ * An installed package never does: anything under node_modules is read-only by nature and
96
+ * replaced wholesale by the next install. Descriptors are read from it (`networksDirs`);
97
+ * state is never written to it.
98
+ */
99
+ export function workspaceRoot(cwd = process.cwd()) {
100
+ const home = process.env.PPN_HOME;
101
+ if (home)
102
+ return path.resolve(home);
103
+ const found = searchUp(cwd, (dir) => fs.existsSync(path.join(dir, WORKSPACE_MARKER)));
104
+ if (found)
105
+ return found;
106
+ // A checkout is a workspace even when the working directory is elsewhere — zombienet gives
107
+ // its custom processes a cwd in the spawn's temp tree, and before this fallback existed they
108
+ // found the repo through the entry point. An *installed* package is not: it lives under
109
+ // node_modules, is replaced wholesale by the next `npm install -g`, and must never absorb
110
+ // 540 MB of binaries and a chain database. The path says which of the two this is.
111
+ const pkg = packageRoot();
112
+ if (!pkg.split(path.sep).includes('node_modules') && fs.existsSync(path.join(pkg, WORKSPACE_MARKER))) {
113
+ return pkg;
114
+ }
115
+ return defaultHome();
116
+ }
117
+ /**
118
+ * The repo root, for code that predates the split. Same as the package root: in a checkout
119
+ * that is also the workspace. New code should say which half it means.
120
+ */
121
+ export function repoRoot(from) {
122
+ return packageRoot(from);
123
+ }
124
+ /** Where the descriptor for `name` lives: the workspace first, then whatever shipped. */
125
+ export function networksDirs() {
126
+ const dirs = [path.join(workspaceRoot(), 'networks'), path.join(packageRoot(), 'networks')];
127
+ return [...new Set(dirs)].filter((d) => fs.existsSync(d));
128
+ }
129
+ //# sourceMappingURL=repo-root.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repo-root.js","sourceRoot":"","sources":["../src/repo-root.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,+FAA+F;AAC/F,kFAAkF;AAClF,EAAE;AACF,2FAA2F;AAC3F,iFAAiF;AACjF,EAAE;AACF,6FAA6F;AAC7F,4FAA4F;AAC5F,uFAAuF;AACvF,mDAAmD;AACnD,EAAE;AACF,6FAA6F;AAC7F,EAAE;AACF,4FAA4F;AAC5F,4FAA4F;AAC5F,8FAA8F;AAC9F,+FAA+F;AAE/F,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;;;GAKG;AACH,MAAM,eAAe,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;AAE3D,sEAAsE;AACtE,MAAM,gBAAgB,GAAG,UAAU,CAAC;AAEpC,SAAS,QAAQ,CAAC,IAAY,EAAE,GAA6B;IAC3D,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,IAAI,GAAG,CAAC,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YAAY;IAC1B,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,UAAU,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC;IAC5F,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { Parachain, ChainKey, ChainDef, LogLevel, GenerateTomlOptions } from './types.js';
2
+ declare const VALIDATORS: readonly ["alice", "bob", "charlie", "dave", "eve", "ferdie"];
3
+ declare const VALID_PARACHAINS: Parachain[];
4
+ declare function requiredPort(key: string): number;
5
+ declare const RELAY_BASE_PORT: number;
6
+ declare const PORTS: Record<Parachain, number>;
7
+ declare const paraIds: () => Record<Parachain, number>;
8
+ declare const P2P_PORTS: Record<ChainKey, number>;
9
+ declare const CHAIN_ARGS: Record<ChainKey, ChainDef>;
10
+ declare const POPULAR_LOG_TARGETS: string[];
11
+ declare const LOG_LEVELS: LogLevel[];
12
+ declare function buildArgs(chainKey: ChainKey, logTargets?: Record<string, LogLevel>, enableHop?: boolean): string[];
13
+ declare function addMissing(args: string[], extra: string[]): string[];
14
+ declare function tomlArgs(args: string[]): string;
15
+ export interface HrmpChannel {
16
+ sender: number;
17
+ recipient: number;
18
+ maxCapacity: number;
19
+ maxMessageSize: number;
20
+ }
21
+ /**
22
+ * The HRMP channels a network wants, in both directions. The genesis config declares them
23
+ * and the force-open-hrmp service opens them on a running chain — from this one list, so
24
+ * the two cannot disagree. `present` narrows it to a spawned subset.
25
+ */
26
+ export declare function hrmpChannels(present?: Parachain[]): HrmpChannel[];
27
+ declare function calcValidatorCount(parachains: Parachain[] | null): number;
28
+ declare function generateToml(parachains: Parachain[] | null, options?: GenerateTomlOptions): string;
29
+ export { generateToml, calcValidatorCount, VALID_PARACHAINS, CHAIN_ARGS, P2P_PORTS, POPULAR_LOG_TARGETS, LOG_LEVELS, VALIDATORS, PORTS, paraIds, RELAY_BASE_PORT, buildArgs, addMissing, tomlArgs, requiredPort, };
30
+ //# sourceMappingURL=toml-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toml-generator.d.ts","sourceRoot":"","sources":["../src/toml-generator.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAK/F,QAAA,MAAM,UAAU,+DAAgE,CAAC;AAEjF,QAAA,MAAM,gBAAgB,EAAE,SAAS,EAAmB,CAAC;AA0ErD,iBAAS,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIzC;AAID,QAAA,MAAM,eAAe,QAAmC,CAAC;AACzD,QAAA,MAAM,KAAK,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAKpC,CAAC;AAGF,QAAA,MAAM,OAAO,iCAUX,CAAC;AACH,QAAA,MAAM,SAAS,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAMvC,CAAC;AAEF,QAAA,MAAM,UAAU,EAAE,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAyD1C,CAAC;AAEF,QAAA,MAAM,mBAAmB,EAAE,MAAM,EAIhC,CAAC;AAEF,QAAA,MAAM,UAAU,EAAE,QAAQ,EAAgD,CAAC;AAW3E,iBAAS,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAe3G;AAID,iBAAS,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAI7D;AAoBD,iBAAS,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