@effectstream/orchestrator 0.100.9 → 0.100.10
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/package.json +2 -2
- package/scripts/launch-avail.ts +3 -3
- package/scripts/launch-bitcoin.ts +3 -3
- package/scripts/launch-cardano.ts +3 -3
- package/scripts/launch-evm.ts +3 -3
- package/scripts/launch-midnight.ts +3 -3
- package/scripts/launch-near.ts +3 -3
- package/scripts/resolve-package.ts +48 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effectstream/orchestrator",
|
|
3
|
-
"version": "0.100.
|
|
3
|
+
"version": "0.100.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://effectstream.github.io/docs/",
|
|
6
6
|
"repository": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"start": "bun src/cli.ts start"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@effectstream/db": "0.100.
|
|
34
|
+
"@effectstream/db": "0.100.10"
|
|
35
35
|
},
|
|
36
36
|
"description": "Multi-chain local development environment for EffectStream"
|
|
37
37
|
}
|
package/scripts/launch-avail.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProcessConfig } from "../src/config.ts";
|
|
2
|
-
import { resolvePackageDir } from "./resolve-package.ts";
|
|
2
|
+
import { resolvePackageDir, type ResolveLocation } from "./resolve-package.ts";
|
|
3
3
|
|
|
4
4
|
export const AvailNames = {
|
|
5
5
|
NODE: "avail-node",
|
|
@@ -17,10 +17,10 @@ const REQUIRED_SCRIPTS = {
|
|
|
17
17
|
|
|
18
18
|
export function launchAvail(
|
|
19
19
|
packageName: string,
|
|
20
|
-
|
|
20
|
+
location: ResolveLocation,
|
|
21
21
|
opts?: { nodePorts?: number[]; clientPorts?: number[] },
|
|
22
22
|
): ProcessConfig[] {
|
|
23
|
-
const cwd = resolvePackageDir("launchAvail", packageName,
|
|
23
|
+
const cwd = resolvePackageDir("launchAvail", packageName, location, REQUIRED_SCRIPTS);
|
|
24
24
|
const nodePorts = opts?.nodePorts ?? [9955, 30334];
|
|
25
25
|
const clientPorts = opts?.clientPorts ?? [7007];
|
|
26
26
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProcessConfig } from "../src/config.ts";
|
|
2
|
-
import { resolvePackageDir } from "./resolve-package.ts";
|
|
2
|
+
import { resolvePackageDir, type ResolveLocation } from "./resolve-package.ts";
|
|
3
3
|
|
|
4
4
|
export const BitcoinNames = {
|
|
5
5
|
BITCOIN_CORE: "bitcoin-core",
|
|
@@ -17,10 +17,10 @@ const REQUIRED_SCRIPTS = {
|
|
|
17
17
|
|
|
18
18
|
export function launchBitcoin(
|
|
19
19
|
packageName: string,
|
|
20
|
-
|
|
20
|
+
location: ResolveLocation,
|
|
21
21
|
opts?: { ports?: number[] },
|
|
22
22
|
): ProcessConfig[] {
|
|
23
|
-
const cwd = resolvePackageDir("launchBitcoin", packageName,
|
|
23
|
+
const cwd = resolvePackageDir("launchBitcoin", packageName, location, REQUIRED_SCRIPTS);
|
|
24
24
|
const ports = opts?.ports ?? [18334, 18443];
|
|
25
25
|
|
|
26
26
|
return [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProcessConfig } from "../src/config.ts";
|
|
2
|
-
import { resolvePackageDir } from "./resolve-package.ts";
|
|
2
|
+
import { resolvePackageDir, type ResolveLocation } from "./resolve-package.ts";
|
|
3
3
|
|
|
4
4
|
const waitHttpScript = new URL("./wait-http.ts", import.meta.url).pathname;
|
|
5
5
|
|
|
@@ -24,10 +24,10 @@ const REQUIRED_SCRIPTS = {
|
|
|
24
24
|
|
|
25
25
|
export function launchCardano(
|
|
26
26
|
packageName: string,
|
|
27
|
-
|
|
27
|
+
location: ResolveLocation,
|
|
28
28
|
opts?: { ports?: number[] },
|
|
29
29
|
): ProcessConfig[] {
|
|
30
|
-
const cwd = resolvePackageDir("launchCardano", packageName,
|
|
30
|
+
const cwd = resolvePackageDir("launchCardano", packageName, location, REQUIRED_SCRIPTS);
|
|
31
31
|
const ports = opts?.ports ?? [
|
|
32
32
|
8090, // CARDANO_SUBMIT_TX: cardano-submit-api
|
|
33
33
|
10000, // YACI_DEVKIT: admin port
|
package/scripts/launch-evm.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProcessConfig } from "../src/config.ts";
|
|
2
|
-
import { resolvePackageDir } from "./resolve-package.ts";
|
|
2
|
+
import { resolvePackageDir, type ResolveLocation } from "./resolve-package.ts";
|
|
3
3
|
|
|
4
4
|
export const EvmNames = {
|
|
5
5
|
HARDHAT: "hardhat",
|
|
@@ -18,10 +18,10 @@ const REQUIRED_SCRIPTS = {
|
|
|
18
18
|
|
|
19
19
|
export function launchEvm(
|
|
20
20
|
packageName: string,
|
|
21
|
-
|
|
21
|
+
location: ResolveLocation,
|
|
22
22
|
opts?: { ports?: number[] },
|
|
23
23
|
): ProcessConfig[] {
|
|
24
|
-
const cwd = resolvePackageDir("launchEvm", packageName,
|
|
24
|
+
const cwd = resolvePackageDir("launchEvm", packageName, location, REQUIRED_SCRIPTS);
|
|
25
25
|
const ports = opts?.ports ?? [8545, 8546];
|
|
26
26
|
|
|
27
27
|
return [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProcessConfig } from "../src/config.ts";
|
|
2
|
-
import { resolvePackageDir } from "./resolve-package.ts";
|
|
2
|
+
import { resolvePackageDir, type ResolveLocation } from "./resolve-package.ts";
|
|
3
3
|
|
|
4
4
|
export const MidnightNames = {
|
|
5
5
|
NODE: "midnight-node",
|
|
@@ -23,13 +23,13 @@ const REQUIRED_SCRIPTS = {
|
|
|
23
23
|
|
|
24
24
|
export function launchMidnight(
|
|
25
25
|
packageName: string,
|
|
26
|
-
|
|
26
|
+
location: ResolveLocation,
|
|
27
27
|
opts?: {
|
|
28
28
|
env?: { MIDNIGHT_STORAGE_PASSWORD?: string };
|
|
29
29
|
dependsOn?: string[];
|
|
30
30
|
},
|
|
31
31
|
): ProcessConfig[] {
|
|
32
|
-
const cwd = resolvePackageDir("launchMidnight", packageName,
|
|
32
|
+
const cwd = resolvePackageDir("launchMidnight", packageName, location, REQUIRED_SCRIPTS);
|
|
33
33
|
const deployEnv: Record<string, string> = {};
|
|
34
34
|
if (opts?.env?.MIDNIGHT_STORAGE_PASSWORD) {
|
|
35
35
|
deployEnv.MIDNIGHT_STORAGE_PASSWORD = opts.env.MIDNIGHT_STORAGE_PASSWORD;
|
package/scripts/launch-near.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProcessConfig } from "../src/config.ts";
|
|
2
|
-
import { resolvePackageDir } from "./resolve-package.ts";
|
|
2
|
+
import { resolvePackageDir, type ResolveLocation } from "./resolve-package.ts";
|
|
3
3
|
|
|
4
4
|
export const NearNames = {
|
|
5
5
|
SANDBOX: "near-sandbox",
|
|
@@ -13,10 +13,10 @@ const REQUIRED_SCRIPTS = {
|
|
|
13
13
|
|
|
14
14
|
export function launchNear(
|
|
15
15
|
packageName: string,
|
|
16
|
-
|
|
16
|
+
location: ResolveLocation,
|
|
17
17
|
opts?: { ports?: number[] },
|
|
18
18
|
): ProcessConfig[] {
|
|
19
|
-
const cwd = resolvePackageDir("launchNear", packageName,
|
|
19
|
+
const cwd = resolvePackageDir("launchNear", packageName, location, REQUIRED_SCRIPTS);
|
|
20
20
|
const ports = opts?.ports ?? [3030];
|
|
21
21
|
|
|
22
22
|
return [
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
|
|
4
|
+
export type ResolveLocation =
|
|
5
|
+
| { cwd: string; resolveFrom?: never }
|
|
6
|
+
| { resolveFrom: string; cwd?: never };
|
|
7
|
+
|
|
4
8
|
function resolveEntry(packageName: string, resolveFrom: string): string {
|
|
5
9
|
try {
|
|
6
10
|
return require.resolve(packageName, { paths: [resolveFrom] });
|
|
@@ -9,34 +13,62 @@ function resolveEntry(packageName: string, resolveFrom: string): string {
|
|
|
9
13
|
}
|
|
10
14
|
}
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
function resolveViaRequire(
|
|
13
17
|
launcherName: string,
|
|
14
18
|
packageName: string,
|
|
15
19
|
resolveFrom: string,
|
|
16
|
-
requiredScripts: Record<string, string>,
|
|
17
20
|
): string {
|
|
18
21
|
const resolved = resolveEntry(packageName, resolveFrom);
|
|
19
22
|
let dir = path.dirname(resolved);
|
|
20
23
|
while (dir !== path.dirname(dir)) {
|
|
21
24
|
const pkgJsonPath = path.join(dir, "package.json");
|
|
22
25
|
if (!fs.existsSync(pkgJsonPath)) { dir = path.dirname(dir); continue; }
|
|
23
|
-
|
|
24
26
|
const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
|
|
25
|
-
if (pkg.name
|
|
26
|
-
|
|
27
|
-
const scripts = pkg.scripts ?? {};
|
|
28
|
-
const required = Object.keys(requiredScripts);
|
|
29
|
-
const missing = required.filter((s) => !(s in scripts));
|
|
30
|
-
if (missing.length > 0) {
|
|
31
|
-
throw new Error(
|
|
32
|
-
`${launcherName}: package "${packageName}" is missing required scripts: ${missing.join(", ")}\n` +
|
|
33
|
-
` This launcher expects the following scripts in package.json:\n` +
|
|
34
|
-
missing.map((s) => ` - ${s}: ${requiredScripts[s]}`).join("\n"),
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
return dir;
|
|
27
|
+
if (pkg.name === packageName) return dir;
|
|
28
|
+
dir = path.dirname(dir);
|
|
38
29
|
}
|
|
39
30
|
throw new Error(
|
|
40
31
|
`${launcherName}: could not find package.json for "${packageName}" (resolved to "${resolved}")`,
|
|
41
32
|
);
|
|
42
33
|
}
|
|
34
|
+
|
|
35
|
+
function validatePackageName(
|
|
36
|
+
launcherName: string,
|
|
37
|
+
packageName: string,
|
|
38
|
+
cwd: string,
|
|
39
|
+
): void {
|
|
40
|
+
const pkgPath = path.join(cwd, "package.json");
|
|
41
|
+
if (!fs.existsSync(pkgPath)) {
|
|
42
|
+
throw new Error(`${launcherName}: no package.json found in "${cwd}"`);
|
|
43
|
+
}
|
|
44
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
45
|
+
if (pkg.name !== packageName) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
`${launcherName}: expected package "${packageName}" but found "${pkg.name}" in "${cwd}"`,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function resolvePackageDir(
|
|
53
|
+
launcherName: string,
|
|
54
|
+
packageName: string,
|
|
55
|
+
location: ResolveLocation,
|
|
56
|
+
requiredScripts: Record<string, string>,
|
|
57
|
+
): string {
|
|
58
|
+
const dir = location.cwd
|
|
59
|
+
? (validatePackageName(launcherName, packageName, location.cwd), location.cwd)
|
|
60
|
+
: resolveViaRequire(launcherName, packageName, location.resolveFrom);
|
|
61
|
+
|
|
62
|
+
const pkgPath = path.join(dir, "package.json");
|
|
63
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
64
|
+
const scripts = pkg.scripts ?? {};
|
|
65
|
+
const missing = Object.keys(requiredScripts).filter((s) => !(s in scripts));
|
|
66
|
+
if (missing.length > 0) {
|
|
67
|
+
throw new Error(
|
|
68
|
+
`${launcherName}: package "${packageName}" is missing required scripts: ${missing.join(", ")}\n` +
|
|
69
|
+
` This launcher expects the following scripts in package.json:\n` +
|
|
70
|
+
missing.map((s) => ` - ${s}: ${requiredScripts[s]}`).join("\n"),
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
return dir;
|
|
74
|
+
}
|