@cartesi/cli 1.5.0 → 2.0.0-alpha.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.
- package/dist/baseCommand.d.ts +2 -0
- package/dist/baseCommand.d.ts.map +1 -1
- package/dist/baseCommand.js +10 -5
- package/dist/builder/directory.d.ts +3 -0
- package/dist/builder/directory.d.ts.map +1 -0
- package/dist/builder/directory.js +37 -0
- package/dist/builder/docker.d.ts +10 -0
- package/dist/builder/docker.d.ts.map +1 -0
- package/dist/builder/docker.js +112 -0
- package/dist/builder/empty.d.ts +3 -0
- package/dist/builder/empty.d.ts.map +1 -0
- package/dist/builder/empty.js +21 -0
- package/dist/builder/index.d.ts +6 -0
- package/dist/builder/index.d.ts.map +1 -0
- package/dist/builder/index.js +5 -0
- package/dist/builder/none.d.ts +3 -0
- package/dist/builder/none.d.ts.map +1 -0
- package/dist/builder/none.js +11 -0
- package/dist/builder/tar.d.ts +3 -0
- package/dist/builder/tar.d.ts.map +1 -0
- package/dist/builder/tar.js +30 -0
- package/dist/commands/build.d.ts +3 -15
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +53 -194
- package/dist/commands/shell.d.ts +2 -1
- package/dist/commands/shell.d.ts.map +1 -1
- package/dist/commands/shell.js +41 -41
- package/dist/config.d.ts +103 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +378 -0
- package/dist/contracts.d.ts +492 -1038
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +223 -498
- package/dist/exec/cartesi-machine.d.ts +9 -0
- package/dist/exec/cartesi-machine.d.ts.map +1 -0
- package/dist/exec/cartesi-machine.js +20 -0
- package/dist/exec/crane.d.ts +15 -0
- package/dist/exec/crane.d.ts.map +1 -0
- package/dist/exec/crane.js +17 -0
- package/dist/exec/genext2fs.d.ts +28 -0
- package/dist/exec/genext2fs.d.ts.map +1 -0
- package/dist/exec/genext2fs.js +44 -0
- package/dist/exec/index.d.ts +5 -0
- package/dist/exec/index.d.ts.map +1 -0
- package/dist/exec/index.js +4 -0
- package/dist/exec/mksquashfs.d.ts +21 -0
- package/dist/exec/mksquashfs.d.ts.map +1 -0
- package/dist/exec/mksquashfs.js +45 -0
- package/dist/exec/util.d.ts +36 -0
- package/dist/exec/util.d.ts.map +1 -0
- package/dist/exec/util.js +78 -0
- package/dist/machine.d.ts +6 -0
- package/dist/machine.d.ts.map +1 -0
- package/dist/machine.js +80 -0
- package/dist/node/docker-compose-anvil.yaml +4 -3
- package/dist/node/docker-compose-bundler.yaml +1 -1
- package/dist/node/docker-compose-paymaster.yaml +1 -1
- package/oclif.manifest.json +32 -95
- package/package.json +7 -7
- package/dist/commands/send/dapp-address.d.ts +0 -9
- package/dist/commands/send/dapp-address.d.ts.map +0 -1
- package/dist/commands/send/dapp-address.js +0 -20
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Range, SemVer } from "semver";
|
|
2
|
+
import { DockerFallbackOptions, ExecaOptionsDockerFallback } from "./util.js";
|
|
3
|
+
export declare const requiredVersion: Range;
|
|
4
|
+
export declare const boot: (args: readonly string[], options: ExecaOptionsDockerFallback) => Promise<import("execa").Result<import("execa").Options & {
|
|
5
|
+
image?: string;
|
|
6
|
+
forceDocker?: false;
|
|
7
|
+
}>>;
|
|
8
|
+
export declare const version: (options?: DockerFallbackOptions) => Promise<SemVer | null>;
|
|
9
|
+
//# sourceMappingURL=cartesi-machine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cartesi-machine.d.ts","sourceRoot":"","sources":["../../src/exec/cartesi-machine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACH,qBAAqB,EAErB,0BAA0B,EAC7B,MAAM,WAAW,CAAC;AAEnB,eAAO,MAAM,eAAe,OAAuB,CAAC;AAEpD,eAAO,MAAM,IAAI,SACP,SAAS,MAAM,EAAE,WACd,0BAA0B;;;GAGtC,CAAC;AAEF,eAAO,MAAM,OAAO,aACN,qBAAqB,KAChC,OAAO,CAAC,MAAM,GAAG,IAAI,CAgBvB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { parse, Range } from "semver";
|
|
2
|
+
import { execaDockerFallback, } from "./util.js";
|
|
3
|
+
export const requiredVersion = new Range("^0.18.1");
|
|
4
|
+
export const boot = async (args, options) => {
|
|
5
|
+
return execaDockerFallback("cartesi-machine", args, options);
|
|
6
|
+
};
|
|
7
|
+
export const version = async (options) => {
|
|
8
|
+
const { image } = options || {};
|
|
9
|
+
try {
|
|
10
|
+
const { stdout } = await execaDockerFallback("cartesi-machine", ["--version-json"], { image });
|
|
11
|
+
if (typeof stdout === "string") {
|
|
12
|
+
const output = JSON.parse(stdout);
|
|
13
|
+
return parse(output.version);
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Range, SemVer } from "semver";
|
|
2
|
+
import { Stream } from "stream";
|
|
3
|
+
import { DockerFallbackOptions } from "./util.js";
|
|
4
|
+
export declare const requiredVersion: Range;
|
|
5
|
+
export declare const exportImage: (options: {
|
|
6
|
+
stdin: Stream | number;
|
|
7
|
+
stdout: Stream | number;
|
|
8
|
+
} & DockerFallbackOptions) => Promise<import("child_process").SpawnSyncReturns<string | Buffer> | {
|
|
9
|
+
error: {
|
|
10
|
+
code: string;
|
|
11
|
+
};
|
|
12
|
+
stdout: string;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const version: (options?: DockerFallbackOptions) => Promise<SemVer | null>;
|
|
15
|
+
//# sourceMappingURL=crane.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crane.d.ts","sourceRoot":"","sources":["../../src/exec/crane.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAA2B,MAAM,WAAW,CAAC;AAE3E,eAAO,MAAM,eAAe,OAAuB,CAAC;AAEpD,eAAO,MAAM,WAAW,YACX;IACL,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B,GAAG,qBAAqB;;;;;EAO5B,CAAC;AAEF,eAAO,MAAM,OAAO,aACN,qBAAqB,KAChC,OAAO,CAAC,MAAM,GAAG,IAAI,CAMvB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { parse, Range } from "semver";
|
|
2
|
+
import { spawnSyncDockerFallback } from "./util.js";
|
|
3
|
+
export const requiredVersion = new Range("^0.19.1");
|
|
4
|
+
export const exportImage = async (options) => {
|
|
5
|
+
const { image, stdin, stdout } = options;
|
|
6
|
+
return spawnSyncDockerFallback("crane", ["export", "-", "-"], {
|
|
7
|
+
image,
|
|
8
|
+
stdio: [stdin, stdout, "inherit"],
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export const version = async (options) => {
|
|
12
|
+
const result = spawnSyncDockerFallback("crane", ["version"], options || {});
|
|
13
|
+
if (result.error) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return parse(result.stdout.toString());
|
|
17
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Range, SemVer } from "semver";
|
|
2
|
+
import { DockerFallbackOptions } from "./util.js";
|
|
3
|
+
export declare const requiredVersion: Range;
|
|
4
|
+
export declare const empty: (options: {
|
|
5
|
+
cwd?: string;
|
|
6
|
+
size: number;
|
|
7
|
+
output: string;
|
|
8
|
+
} & DockerFallbackOptions) => Promise<void>;
|
|
9
|
+
export declare const fromDirectory: (options: {
|
|
10
|
+
cwd?: string;
|
|
11
|
+
extraSize: number;
|
|
12
|
+
input: string;
|
|
13
|
+
output: string;
|
|
14
|
+
} & DockerFallbackOptions) => Promise<import("execa").Result<import("execa").Options & {
|
|
15
|
+
image?: string;
|
|
16
|
+
forceDocker?: false;
|
|
17
|
+
}>>;
|
|
18
|
+
export declare const fromTar: (options: {
|
|
19
|
+
cwd?: string;
|
|
20
|
+
extraSize: number;
|
|
21
|
+
input: string;
|
|
22
|
+
output: string;
|
|
23
|
+
} & DockerFallbackOptions) => Promise<import("execa").Result<import("execa").Options & {
|
|
24
|
+
image?: string;
|
|
25
|
+
forceDocker?: false;
|
|
26
|
+
}>>;
|
|
27
|
+
export declare const version: (options?: DockerFallbackOptions) => Promise<SemVer | null>;
|
|
28
|
+
//# sourceMappingURL=genext2fs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genext2fs.d.ts","sourceRoot":"","sources":["../../src/exec/genext2fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAuB,MAAM,WAAW,CAAC;AAIvE,eAAO,MAAM,eAAe,EAAE,KAA2B,CAAC;AAU1D,eAAO,MAAM,KAAK,YACL;IACL,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAClB,GAAG,qBAAqB,kBAgB5B,CAAC;AAEF,eAAO,MAAM,aAAa,YACb;IACL,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAClB,GAAG,qBAAqB;;;GAS5B,CAAC;AAEF,eAAO,MAAM,OAAO,YACP;IACL,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAClB,GAAG,qBAAqB;;;GAS5B,CAAC;AAEF,eAAO,MAAM,OAAO,aACN,qBAAqB,KAChC,OAAO,CAAC,MAAM,GAAG,IAAI,CAevB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { parse, Range } from "semver";
|
|
2
|
+
import { execaDockerFallback } from "./util.js";
|
|
3
|
+
const BLOCK_SIZE = 4096; // fixed at 4k
|
|
4
|
+
export const requiredVersion = new Range("^1.5.6");
|
|
5
|
+
const baseArgs = (options) => [
|
|
6
|
+
"--block-size",
|
|
7
|
+
BLOCK_SIZE.toString(),
|
|
8
|
+
"--faketime",
|
|
9
|
+
"--readjustment",
|
|
10
|
+
`+${options.extraBlocks}`,
|
|
11
|
+
];
|
|
12
|
+
export const empty = async (options) => {
|
|
13
|
+
const { size, output } = options;
|
|
14
|
+
const blocks = Math.ceil(size / BLOCK_SIZE); // size in blocks
|
|
15
|
+
await execaDockerFallback("xgenext2fs", [
|
|
16
|
+
"--block-size",
|
|
17
|
+
BLOCK_SIZE.toString(),
|
|
18
|
+
"--faketime",
|
|
19
|
+
"--size-in-blocks",
|
|
20
|
+
blocks.toString(),
|
|
21
|
+
output,
|
|
22
|
+
], options);
|
|
23
|
+
};
|
|
24
|
+
export const fromDirectory = async (options) => {
|
|
25
|
+
const { cwd, extraSize, image, input, output } = options;
|
|
26
|
+
const extraBlocks = Math.ceil(extraSize / BLOCK_SIZE);
|
|
27
|
+
return execaDockerFallback("xgenext2fs", [...baseArgs({ extraBlocks }), "--root", input, output], { cwd, image });
|
|
28
|
+
};
|
|
29
|
+
export const fromTar = async (options) => {
|
|
30
|
+
const { cwd, extraSize, image, input, output } = options;
|
|
31
|
+
const extraBlocks = Math.ceil(extraSize / BLOCK_SIZE);
|
|
32
|
+
return execaDockerFallback("xgenext2fs", [...baseArgs({ extraBlocks }), "--tarball", input, output], { cwd, image });
|
|
33
|
+
};
|
|
34
|
+
export const version = async (options) => {
|
|
35
|
+
const { stdout } = await execaDockerFallback("xgenext2fs", ["--version"], options || {});
|
|
36
|
+
if (typeof stdout === "string") {
|
|
37
|
+
const regex = /(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?/;
|
|
38
|
+
const m = stdout.match(regex);
|
|
39
|
+
if (m && m[0]) {
|
|
40
|
+
return parse(m[0]);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exec/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Range, SemVer } from "semver";
|
|
2
|
+
import { DockerFallbackOptions } from "./util.js";
|
|
3
|
+
export declare const requiredVersion: Range;
|
|
4
|
+
export declare const fromDirectory: (options: {
|
|
5
|
+
cwd?: string;
|
|
6
|
+
input: string;
|
|
7
|
+
output: string;
|
|
8
|
+
} & DockerFallbackOptions) => Promise<import("execa").Result<import("execa").Options & {
|
|
9
|
+
image?: string;
|
|
10
|
+
forceDocker?: false;
|
|
11
|
+
}>>;
|
|
12
|
+
export declare const fromTar: (options: {
|
|
13
|
+
cwd?: string;
|
|
14
|
+
input: string;
|
|
15
|
+
output: string;
|
|
16
|
+
} & DockerFallbackOptions) => Promise<import("execa").Result<import("execa").Options & {
|
|
17
|
+
image?: string;
|
|
18
|
+
forceDocker?: false;
|
|
19
|
+
}>>;
|
|
20
|
+
export declare const version: (options?: DockerFallbackOptions) => Promise<SemVer | null>;
|
|
21
|
+
//# sourceMappingURL=mksquashfs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mksquashfs.d.ts","sourceRoot":"","sources":["../../src/exec/mksquashfs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAuB,MAAM,WAAW,CAAC;AAIvE,eAAO,MAAM,eAAe,EAAE,KAA2B,CAAC;AAY1D,eAAO,MAAM,aAAa,YACb;IACL,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAClB,GAAG,qBAAqB;;;GAO5B,CAAC;AAEF,eAAO,MAAM,OAAO,YACP;IACL,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAClB,GAAG,qBAAqB;;;GAY5B,CAAC;AAEF,eAAO,MAAM,OAAO,aACN,qBAAqB,KAChC,OAAO,CAAC,MAAM,GAAG,IAAI,CAoBvB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { parse, Range } from "semver";
|
|
2
|
+
import { execaDockerFallback } from "./util.js";
|
|
3
|
+
const COMPRESSION = "lzo"; // make customizable? default is gzip
|
|
4
|
+
export const requiredVersion = new Range("^4.5.1");
|
|
5
|
+
const baseArgs = () => [
|
|
6
|
+
"-all-time",
|
|
7
|
+
"0",
|
|
8
|
+
"-all-root", // XXX: should we use this?
|
|
9
|
+
"-noappend",
|
|
10
|
+
"-comp",
|
|
11
|
+
COMPRESSION,
|
|
12
|
+
"-no-progress",
|
|
13
|
+
];
|
|
14
|
+
export const fromDirectory = (options) => {
|
|
15
|
+
const { cwd, image, input, output } = options;
|
|
16
|
+
return execaDockerFallback("mksquashfs", [input, output, ...baseArgs()], {
|
|
17
|
+
cwd,
|
|
18
|
+
image,
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
export const fromTar = (options) => {
|
|
22
|
+
const { cwd, image, input, output } = options;
|
|
23
|
+
return execaDockerFallback("mksquashfs", ["-", output, "-tar", ...baseArgs()], {
|
|
24
|
+
cwd,
|
|
25
|
+
image,
|
|
26
|
+
inputFile: input, // use stdin in case of tar file
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
export const version = async (options) => {
|
|
30
|
+
try {
|
|
31
|
+
const { stdout } = await execaDockerFallback("mksquashfs", ["-version"], options || {});
|
|
32
|
+
if (typeof stdout === "string") {
|
|
33
|
+
const regex = /(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?/gm;
|
|
34
|
+
const m = stdout.match(regex);
|
|
35
|
+
if (m && m[0]) {
|
|
36
|
+
return parse(m[0]);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
console.error(e);
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { SpawnSyncOptions } from "child_process";
|
|
2
|
+
import { Options } from "execa";
|
|
3
|
+
export type DockerFallbackOptions = {
|
|
4
|
+
image: string;
|
|
5
|
+
forceDocker: true;
|
|
6
|
+
} | {
|
|
7
|
+
image?: string;
|
|
8
|
+
forceDocker?: false;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Calls execa and falls back to docker run if command (on the host) fails
|
|
12
|
+
* @param command command to be executed
|
|
13
|
+
* @param args arguments to be passed to the command
|
|
14
|
+
* @param options execution options
|
|
15
|
+
* @returns return of execa
|
|
16
|
+
*/
|
|
17
|
+
export type ExecaOptionsDockerFallback = Options & DockerFallbackOptions;
|
|
18
|
+
export declare const execaDockerFallback: (command: string, args: readonly string[], options: ExecaOptionsDockerFallback) => Promise<import("execa").Result<Options & {
|
|
19
|
+
image?: string;
|
|
20
|
+
forceDocker?: false;
|
|
21
|
+
}>>;
|
|
22
|
+
/**
|
|
23
|
+
* Calls spawnSync and falls back to docker run if command (on the host) fails
|
|
24
|
+
* @param command command to be executed
|
|
25
|
+
* @param args arguments to be passed to the command
|
|
26
|
+
* @param options execution options
|
|
27
|
+
* @returns return of execa
|
|
28
|
+
*/
|
|
29
|
+
export type SpawnOptionsDockerFallback = SpawnSyncOptions & DockerFallbackOptions;
|
|
30
|
+
export declare const spawnSyncDockerFallback: (command: string, args: readonly string[], options: SpawnOptionsDockerFallback) => import("child_process").SpawnSyncReturns<string | Buffer> | {
|
|
31
|
+
error: {
|
|
32
|
+
code: string;
|
|
33
|
+
};
|
|
34
|
+
stdout: string;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/exec/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAqB,OAAO,EAAE,MAAM,OAAO,CAAC;AAGnD,MAAM,MAAM,qBAAqB,GAC3B;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,IAAI,CAAA;CAAE,GACpC;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,MAAM,0BAA0B,GAAG,OAAO,GAAG,qBAAqB,CAAC;AACzE,eAAO,MAAM,mBAAmB,YACnB,MAAM,QACT,SAAS,MAAM,EAAE,WACd,0BAA0B;YAbvB,MAAM;kBAAgB,KAAK;GAmD1C,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,0BAA0B,GAAG,gBAAgB,GACrD,qBAAqB,CAAC;AAC1B,eAAO,MAAM,uBAAuB,YACvB,MAAM,QACT,SAAS,MAAM,EAAE,WACd,0BAA0B;;;;;CA6CtC,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { spawnSync } from "child_process";
|
|
2
|
+
import { execa, ExecaError } from "execa";
|
|
3
|
+
import os from "os";
|
|
4
|
+
export const execaDockerFallback = async (command, args, options) => {
|
|
5
|
+
try {
|
|
6
|
+
if (options.forceDocker) {
|
|
7
|
+
const error = new ExecaError();
|
|
8
|
+
error.code = "ENOENT";
|
|
9
|
+
throw error;
|
|
10
|
+
}
|
|
11
|
+
return await execa(command, args, options);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
if (error instanceof ExecaError) {
|
|
15
|
+
if (error.code === "ENOENT" && options.image) {
|
|
16
|
+
if (!options.forceDocker) {
|
|
17
|
+
console.warn(`error executing '${command}', falling back to docker execution using image '${options.image}'`);
|
|
18
|
+
}
|
|
19
|
+
const userInfo = os.userInfo();
|
|
20
|
+
const dockerOpts = [
|
|
21
|
+
"--volume",
|
|
22
|
+
`${options.cwd}:/work`,
|
|
23
|
+
"--workdir",
|
|
24
|
+
"/work",
|
|
25
|
+
"--interactive",
|
|
26
|
+
"--user",
|
|
27
|
+
`${userInfo.uid}:${userInfo.gid}`,
|
|
28
|
+
];
|
|
29
|
+
return await execa("docker", ["run", ...dockerOpts, options.image, command, ...args], options);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
console.error(`error executing '${command}'`, error);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
export const spawnSyncDockerFallback = (command, args, options) => {
|
|
39
|
+
const result = options.forceDocker
|
|
40
|
+
? { error: { code: "ENOENT" }, stdout: "" }
|
|
41
|
+
: spawnSync(command, args, options);
|
|
42
|
+
if (result.error) {
|
|
43
|
+
const code = result.error.code;
|
|
44
|
+
if (code === "ENOENT" && options.image) {
|
|
45
|
+
if (!options.forceDocker) {
|
|
46
|
+
console.warn(`error executing '${command}', falling back to docker execution using image '${options.image}'`);
|
|
47
|
+
}
|
|
48
|
+
const userInfo = os.userInfo();
|
|
49
|
+
const dockerOpts = [
|
|
50
|
+
"--volume",
|
|
51
|
+
`${options.cwd}:/work`,
|
|
52
|
+
"--workdir",
|
|
53
|
+
"/work",
|
|
54
|
+
"--interactive",
|
|
55
|
+
"--user",
|
|
56
|
+
`${userInfo.uid}:${userInfo.gid}`,
|
|
57
|
+
];
|
|
58
|
+
const dockerArgs = [
|
|
59
|
+
"run",
|
|
60
|
+
...dockerOpts,
|
|
61
|
+
options.image,
|
|
62
|
+
command,
|
|
63
|
+
...args,
|
|
64
|
+
];
|
|
65
|
+
const dockerResult = spawnSync("docker", dockerArgs, options);
|
|
66
|
+
if (dockerResult.error) {
|
|
67
|
+
console.error(`error executing '${command}'`, dockerResult.error);
|
|
68
|
+
throw dockerResult.error;
|
|
69
|
+
}
|
|
70
|
+
return dockerResult;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
console.error(`error executing '${command}'`, result.error);
|
|
74
|
+
throw result.error;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Config, ImageInfo } from "./config.js";
|
|
2
|
+
export declare const bootMachine: (config: Config, info: ImageInfo | undefined, destination: string) => Promise<import("execa").Result<import("execa").Options & {
|
|
3
|
+
image?: string;
|
|
4
|
+
forceDocker?: false;
|
|
5
|
+
}>>;
|
|
6
|
+
//# sourceMappingURL=machine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"machine.d.ts","sourceRoot":"","sources":["../src/machine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAe,SAAS,EAAE,MAAM,aAAa,CAAC;AAoB7D,eAAO,MAAM,WAAW,WACZ,MAAM,QACR,SAAS,GAAG,SAAS,eACd,MAAM;;;GAwFtB,CAAC"}
|
package/dist/machine.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { cartesiMachine } from "./exec/index.js";
|
|
2
|
+
const flashDrive = (label, drive) => {
|
|
3
|
+
const { format, mount, shared, user } = drive;
|
|
4
|
+
const filename = `${label}.${format}`;
|
|
5
|
+
const vars = [`label:${label}`, `filename:${filename}`];
|
|
6
|
+
if (mount !== undefined) {
|
|
7
|
+
vars.push(`mount:${mount}`);
|
|
8
|
+
}
|
|
9
|
+
if (user) {
|
|
10
|
+
vars.push(`user:${user}`);
|
|
11
|
+
}
|
|
12
|
+
if (shared) {
|
|
13
|
+
vars.push("shared");
|
|
14
|
+
}
|
|
15
|
+
// don't specify start and length
|
|
16
|
+
return `--flash-drive=${vars.join(",")}`;
|
|
17
|
+
};
|
|
18
|
+
export const bootMachine = async (config, info, destination) => {
|
|
19
|
+
const { machine } = config;
|
|
20
|
+
const { assertRollingTemplate, finalHash, interactive, maxMCycle, noRollup, ramLength, ramImage, store, user, } = machine;
|
|
21
|
+
// list of environment variables of docker image
|
|
22
|
+
const env = info?.env ?? [];
|
|
23
|
+
const envs = env.map((variable) => `--env=${variable}`);
|
|
24
|
+
// check if we need a rootfstype boot arg
|
|
25
|
+
const root = config.drives.root;
|
|
26
|
+
if (root?.format === "sqfs") {
|
|
27
|
+
const definedRootfsType = config.machine.bootargs.find((arg) => arg.startsWith("rootfstype="));
|
|
28
|
+
// not checking here if user intentionally defined wrong type
|
|
29
|
+
if (!definedRootfsType) {
|
|
30
|
+
config.machine.bootargs.push("rootfstype=squashfs");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// bootargs from config string array
|
|
34
|
+
const bootargs = machine.bootargs.map((arg) => `--append-bootargs="${arg}"`);
|
|
35
|
+
// entrypoint from config or image info (Docker ENTRYPOINT + CMD)
|
|
36
|
+
const entrypoint = machine.entrypoint ?? // takes priority
|
|
37
|
+
(info ? [...info.entrypoint, ...info.cmd].join(" ") : undefined); // ENTRYPOINT and CMD as a space separated string
|
|
38
|
+
if (!entrypoint) {
|
|
39
|
+
throw new Error("Undefined machine entrypoint");
|
|
40
|
+
}
|
|
41
|
+
const flashDrives = Object.entries(config.drives).map(([label, drive]) => flashDrive(label, drive));
|
|
42
|
+
// command to change working directory if WORKDIR is defined
|
|
43
|
+
const args = [
|
|
44
|
+
...bootargs,
|
|
45
|
+
...envs,
|
|
46
|
+
...flashDrives,
|
|
47
|
+
`--ram-image=${ramImage}`,
|
|
48
|
+
`--ram-length=${ramLength}`,
|
|
49
|
+
`--append-entrypoint=${entrypoint}`,
|
|
50
|
+
];
|
|
51
|
+
if (assertRollingTemplate) {
|
|
52
|
+
args.push("--assert-rolling-template");
|
|
53
|
+
}
|
|
54
|
+
if (finalHash) {
|
|
55
|
+
args.push("--final-hash");
|
|
56
|
+
}
|
|
57
|
+
if (info?.workdir) {
|
|
58
|
+
args.push(`--workdir="${info.workdir}"`);
|
|
59
|
+
}
|
|
60
|
+
if (interactive) {
|
|
61
|
+
args.push("-it");
|
|
62
|
+
}
|
|
63
|
+
if (noRollup) {
|
|
64
|
+
args.push("--no-rollup");
|
|
65
|
+
}
|
|
66
|
+
if (maxMCycle) {
|
|
67
|
+
args.push(`--max-mcycle=${maxMCycle.toString()}`);
|
|
68
|
+
}
|
|
69
|
+
if (store) {
|
|
70
|
+
args.push(`--store=${store}`);
|
|
71
|
+
}
|
|
72
|
+
if (user) {
|
|
73
|
+
args.push(`--user=${user}`);
|
|
74
|
+
}
|
|
75
|
+
return cartesiMachine.boot(args, {
|
|
76
|
+
cwd: destination,
|
|
77
|
+
image: config.sdk,
|
|
78
|
+
stdio: "inherit",
|
|
79
|
+
});
|
|
80
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
services:
|
|
2
2
|
anvil:
|
|
3
|
-
image: cartesi/sdk:0.
|
|
3
|
+
image: cartesi/sdk:0.12.0-alpha.0
|
|
4
4
|
command:
|
|
5
5
|
[
|
|
6
6
|
"devnet",
|
|
@@ -19,7 +19,7 @@ services:
|
|
|
19
19
|
- 8545:8545
|
|
20
20
|
|
|
21
21
|
dapp_deployer:
|
|
22
|
-
image: cartesi/sdk:0.
|
|
22
|
+
image: cartesi/sdk:0.12.0-alpha.0
|
|
23
23
|
restart: on-failure
|
|
24
24
|
depends_on:
|
|
25
25
|
anvil:
|
|
@@ -32,9 +32,10 @@ services:
|
|
|
32
32
|
"http://anvil:8545",
|
|
33
33
|
"--private-key",
|
|
34
34
|
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
|
|
35
|
-
"
|
|
35
|
+
"0x4C11C7F82D6D56a726f9B53dd99af031AFd86BB6",
|
|
36
36
|
"deployContracts(address,address,bytes32,bytes32)",
|
|
37
37
|
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
38
|
+
"720",
|
|
38
39
|
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
39
40
|
"0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
40
41
|
"0x0000000000000000000000000000000000000000000000000000000000000000",
|