@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.
Files changed (62) hide show
  1. package/dist/baseCommand.d.ts +2 -0
  2. package/dist/baseCommand.d.ts.map +1 -1
  3. package/dist/baseCommand.js +10 -5
  4. package/dist/builder/directory.d.ts +3 -0
  5. package/dist/builder/directory.d.ts.map +1 -0
  6. package/dist/builder/directory.js +37 -0
  7. package/dist/builder/docker.d.ts +10 -0
  8. package/dist/builder/docker.d.ts.map +1 -0
  9. package/dist/builder/docker.js +112 -0
  10. package/dist/builder/empty.d.ts +3 -0
  11. package/dist/builder/empty.d.ts.map +1 -0
  12. package/dist/builder/empty.js +21 -0
  13. package/dist/builder/index.d.ts +6 -0
  14. package/dist/builder/index.d.ts.map +1 -0
  15. package/dist/builder/index.js +5 -0
  16. package/dist/builder/none.d.ts +3 -0
  17. package/dist/builder/none.d.ts.map +1 -0
  18. package/dist/builder/none.js +11 -0
  19. package/dist/builder/tar.d.ts +3 -0
  20. package/dist/builder/tar.d.ts.map +1 -0
  21. package/dist/builder/tar.js +30 -0
  22. package/dist/commands/build.d.ts +3 -15
  23. package/dist/commands/build.d.ts.map +1 -1
  24. package/dist/commands/build.js +53 -194
  25. package/dist/commands/shell.d.ts +2 -1
  26. package/dist/commands/shell.d.ts.map +1 -1
  27. package/dist/commands/shell.js +41 -41
  28. package/dist/config.d.ts +103 -0
  29. package/dist/config.d.ts.map +1 -0
  30. package/dist/config.js +378 -0
  31. package/dist/contracts.d.ts +492 -1038
  32. package/dist/contracts.d.ts.map +1 -1
  33. package/dist/contracts.js +223 -498
  34. package/dist/exec/cartesi-machine.d.ts +9 -0
  35. package/dist/exec/cartesi-machine.d.ts.map +1 -0
  36. package/dist/exec/cartesi-machine.js +20 -0
  37. package/dist/exec/crane.d.ts +15 -0
  38. package/dist/exec/crane.d.ts.map +1 -0
  39. package/dist/exec/crane.js +17 -0
  40. package/dist/exec/genext2fs.d.ts +28 -0
  41. package/dist/exec/genext2fs.d.ts.map +1 -0
  42. package/dist/exec/genext2fs.js +44 -0
  43. package/dist/exec/index.d.ts +5 -0
  44. package/dist/exec/index.d.ts.map +1 -0
  45. package/dist/exec/index.js +4 -0
  46. package/dist/exec/mksquashfs.d.ts +21 -0
  47. package/dist/exec/mksquashfs.d.ts.map +1 -0
  48. package/dist/exec/mksquashfs.js +45 -0
  49. package/dist/exec/util.d.ts +36 -0
  50. package/dist/exec/util.d.ts.map +1 -0
  51. package/dist/exec/util.js +78 -0
  52. package/dist/machine.d.ts +6 -0
  53. package/dist/machine.d.ts.map +1 -0
  54. package/dist/machine.js +80 -0
  55. package/dist/node/docker-compose-anvil.yaml +4 -3
  56. package/dist/node/docker-compose-bundler.yaml +1 -1
  57. package/dist/node/docker-compose-paymaster.yaml +1 -1
  58. package/oclif.manifest.json +32 -95
  59. package/package.json +7 -7
  60. package/dist/commands/send/dapp-address.d.ts +0 -9
  61. package/dist/commands/send/dapp-address.d.ts.map +0 -1
  62. package/dist/commands/send/dapp-address.js +0 -20
@@ -1,214 +1,73 @@
1
1
  import { Flags } from "@oclif/core";
2
- import bytes from "bytes";
3
- import { execa } from "execa";
4
2
  import fs from "fs-extra";
5
- import semver from "semver";
3
+ import path from "path";
6
4
  import tmp from "tmp";
7
5
  import { BaseCommand } from "../baseCommand.js";
8
- import { DEFAULT_TEMPLATES_BRANCH } from "./create.js";
9
- const CARTESI_LABEL_PREFIX = "io.cartesi.rollups";
10
- const CARTESI_LABEL_RAM_SIZE = `${CARTESI_LABEL_PREFIX}.ram_size`;
11
- const CARTESI_LABEL_DATA_SIZE = `${CARTESI_LABEL_PREFIX}.data_size`;
12
- const CARTESI_DEFAULT_RAM_SIZE = "128Mi";
13
- const CARTESI_LABEL_SDK_VERSION = `${CARTESI_LABEL_PREFIX}.sdk_version`;
14
- const CARTESI_LABEL_SDK_NAME = `${CARTESI_LABEL_PREFIX}.sdk_name`;
15
- const CARTESI_DEFAULT_SDK_VERSION = "0.9.0";
16
- class BuildApplication extends BaseCommand {
17
- /**
18
- * Build DApp image (linux/riscv64). Returns image id.
19
- * @param directory path of context containing Dockerfile
20
- */
21
- async buildImage(options) {
22
- const buildResult = tmp.tmpNameSync();
23
- this.debug(`building docker image and writing result to ${buildResult}`);
24
- const args = ["buildx", "build", "--load", "--iidfile", buildResult];
25
- if (options.target) {
26
- args.push("--target", options.target);
6
+ import { buildDirectory, buildDocker, buildEmpty, buildNone, buildTar, } from "../builder/index.js";
7
+ import { bootMachine } from "../machine.js";
8
+ const buildDrive = async (name, drive, sdkImage, destination) => {
9
+ switch (drive.builder) {
10
+ case "directory": {
11
+ return buildDirectory(name, drive, sdkImage, destination);
27
12
  }
28
- await execa("docker", [...args, process.cwd()], { stdio: "inherit" });
29
- return fs.readFileSync(buildResult, "utf8");
30
- }
31
- async getImageInfo(image) {
32
- const { stdout: jsonStr } = await execa("docker", [
33
- "image",
34
- "inspect",
35
- image,
36
- ]);
37
- // parse image info from docker inspect output
38
- const [imageInfo] = JSON.parse(jsonStr);
39
- // validate image architecture (must be riscv64)
40
- if (imageInfo["Architecture"] !== "riscv64") {
41
- throw new Error(`Invalid image Architecture: ${imageInfo["Architecture"]}. Expected riscv64`);
42
- }
43
- const labels = imageInfo["Config"]["Labels"] || {};
44
- const info = {
45
- cmd: imageInfo["Config"]["Cmd"] ?? [],
46
- dataSize: labels[CARTESI_LABEL_DATA_SIZE] ?? "10Mb",
47
- entrypoint: imageInfo["Config"]["Entrypoint"] ?? [],
48
- env: imageInfo["Config"]["Env"] || [],
49
- ramSize: labels[CARTESI_LABEL_RAM_SIZE] ?? CARTESI_DEFAULT_RAM_SIZE,
50
- sdkName: labels[CARTESI_LABEL_SDK_NAME] ?? "cartesi/sdk",
51
- sdkVersion: labels[CARTESI_LABEL_SDK_VERSION] ??
52
- CARTESI_DEFAULT_SDK_VERSION,
53
- workdir: imageInfo["Config"]["WorkingDir"],
54
- };
55
- if (!info.entrypoint && !info.cmd) {
56
- throw new Error("Undefined image ENTRYPOINT or CMD");
13
+ case "docker": {
14
+ return buildDocker(name, drive, sdkImage, destination);
57
15
  }
58
- // fail if using unsupported sdk version
59
- if (!semver.valid(info.sdkVersion)) {
60
- this.warn("sdk version is not a valid semver");
16
+ case "empty": {
17
+ return buildEmpty(name, drive, sdkImage, destination);
61
18
  }
62
- else if (info.sdkName == "cartesi/sdk" &&
63
- semver.lt(info.sdkVersion, CARTESI_DEFAULT_SDK_VERSION)) {
64
- throw new Error(`Unsupported sdk version: ${info.sdkVersion} (used) < ${CARTESI_DEFAULT_SDK_VERSION} (minimum).
65
- Update your application Dockerfile using one of the templates at https://github.com/cartesi/application-templates/tree/${DEFAULT_TEMPLATES_BRANCH}
66
- `);
19
+ case "tar": {
20
+ return buildTar(name, drive, sdkImage, destination);
67
21
  }
68
- // warn for using default values
69
- info.sdkVersion ||
70
- this.warn(`Undefined ${CARTESI_LABEL_SDK_VERSION} label, defaulting to ${CARTESI_DEFAULT_SDK_VERSION}`);
71
- info.ramSize ||
72
- this.warn(`Undefined ${CARTESI_LABEL_RAM_SIZE} label, defaulting to ${CARTESI_DEFAULT_RAM_SIZE}`);
73
- // validate data size value
74
- if (bytes(info.dataSize) === null) {
75
- throw new Error(`Invalid ${CARTESI_LABEL_DATA_SIZE} value: ${info.dataSize}`);
22
+ case "none": {
23
+ return buildNone(name, drive, destination);
76
24
  }
77
- // XXX: validate other values
78
- return info;
79
- }
80
- // saves the OCI Image to a tarball
81
- async createTarball(image, outputFilePath) {
82
- // create docker tarball from app image
83
- await execa("docker", ["image", "save", image, "-o", outputFilePath]);
84
- }
85
- // this wraps the call to the sdk image with a one-shot approach
86
- // the (inputPath, outputPath) signature will mount the input as a volume and copy the output with docker cp
87
- async sdkRun(sdkImage, cmd, inputPath, outputPath) {
88
- const { stdout: cid } = await execa("docker", [
89
- "container",
90
- "create",
91
- "--volume",
92
- `./${inputPath}:/tmp/input`,
93
- sdkImage,
94
- ...cmd,
95
- ]);
96
- await execa("docker", ["container", "start", "-a", cid], {
97
- stdio: "inherit",
98
- });
99
- await execa("docker", [
100
- "container",
101
- "cp",
102
- `${cid}:/tmp/output`,
103
- outputPath,
104
- ]);
105
- await execa("docker", ["container", "stop", cid]);
106
- await execa("docker", ["container", "rm", cid]);
107
- }
108
- // returns the command to create rootfs tarball from an OCI Image tarball
109
- static createRootfsTarCommand() {
110
- const cmd = [
111
- "cat",
112
- "/tmp/input",
113
- "|",
114
- "crane",
115
- "export",
116
- "-", // OCI Image from stdin
117
- "-", // rootfs tarball to stdout
118
- "|",
119
- "bsdtar",
120
- "-cf",
121
- "/tmp/output",
122
- "--format=gnutar",
123
- "@/dev/stdin", // rootfs tarball from stdin
124
- ];
125
- return ["/usr/bin/env", "bash", "-c", cmd.join(" ")];
126
- }
127
- // returns the command to create ext2 from a rootfs
128
- static createExt2Command(extraBytes) {
129
- const blockSize = 4096;
130
- const extraBlocks = Math.ceil(extraBytes / blockSize);
131
- const extraSize = `+${extraBlocks}`;
132
- return [
133
- "xgenext2fs",
134
- "--tarball",
135
- "/tmp/input",
136
- "--block-size",
137
- blockSize.toString(),
138
- "--faketime",
139
- "-r",
140
- extraSize,
141
- "/tmp/output",
142
- ];
143
- }
144
- static createMachineSnapshotCommand(info) {
145
- const ramSize = info.ramSize;
146
- const driveLabel = "root"; // XXX: does this need to be customizable?
147
- // list of environment variables of docker image
148
- const envs = info.env.map((variable) => `--env=${variable}`);
149
- // ENTRYPOINT and CMD as a space separated string
150
- const entrypoint = [...info.entrypoint, ...info.cmd].join(" ");
151
- // command to change working directory if WORKDIR is defined
152
- const cwd = info.workdir ? `--workdir=${info.workdir}` : "";
153
- return [
154
- "create_machine_snapshot",
155
- `--ram-length=${ramSize}`,
156
- `--drive-label=${driveLabel}`,
157
- `--drive-filename=/tmp/input`,
158
- `--output=/tmp/output`,
159
- cwd,
160
- ...envs,
161
- `--entrypoint=${entrypoint}`,
162
- ];
163
25
  }
26
+ };
27
+ class Build extends BaseCommand {
164
28
  async run() {
165
- const { flags } = await this.parse(BuildApplication);
166
- const snapshotPath = this.getContextPath("image");
167
- const tarPath = this.getContextPath("image.tar");
168
- const gnuTarPath = this.getContextPath("image.gnutar");
169
- const ext2Path = this.getContextPath("image.ext2");
29
+ const { flags } = await this.parse(Build);
170
30
  // clean up temp files we create along the process
171
31
  tmp.setGracefulCleanup();
172
- // use pre-existing image or build dapp image
173
- const appImage = flags["from-image"] || (await this.buildImage(flags));
32
+ // get application configuration from 'cartesi.toml'
33
+ const config = this.getApplicationConfig(flags.config);
34
+ // destination directory for image and intermediate files
35
+ const destination = path.resolve(this.getContextPath());
174
36
  // prepare context directory
175
- await fs.emptyDir(this.getContextPath()); // XXX: make it less error prone
176
- // get and validate image info
177
- const imageInfo = await this.getImageInfo(appImage);
178
- // resolve sdk version
179
- const sdkImage = `${imageInfo.sdkName}:${imageInfo.sdkVersion}`;
180
- try {
181
- // create docker tarball for image specified
182
- await this.createTarball(appImage, tarPath);
183
- // create rootfs tar
184
- await this.sdkRun(sdkImage, BuildApplication.createRootfsTarCommand(), tarPath, gnuTarPath);
185
- // create ext2
186
- await this.sdkRun(sdkImage, BuildApplication.createExt2Command(bytes.parse(imageInfo.dataSize)), gnuTarPath, ext2Path);
187
- // create machine snapshot
188
- await this.sdkRun(sdkImage, BuildApplication.createMachineSnapshotCommand(imageInfo), ext2Path, snapshotPath);
189
- await fs.chmod(snapshotPath, 0o755);
190
- }
191
- finally {
192
- await fs.remove(gnuTarPath);
193
- await fs.remove(tarPath);
37
+ await fs.emptyDir(destination); // XXX: make it less error prone
38
+ // start build of all drives simultaneously
39
+ const results = Object.entries(config.drives).reduce((acc, [name, drive]) => {
40
+ acc[name] = buildDrive(name, drive, config.sdk, destination);
41
+ return acc;
42
+ }, {});
43
+ // await for all drives to be built
44
+ await Promise.all(Object.values(results));
45
+ if (flags["drives-only"]) {
46
+ // only build drives, so quit here
47
+ return;
194
48
  }
49
+ // get image info of root drive
50
+ const root = await results["root"];
51
+ const imageInfo = root || undefined;
52
+ // path of machine snapshot
53
+ const snapshotPath = this.getContextPath("image");
54
+ // create machine snapshot
55
+ await bootMachine(config, imageInfo, destination);
56
+ await fs.chmod(snapshotPath, 0o755);
195
57
  }
196
58
  }
197
- BuildApplication.summary = "Build application.";
198
- BuildApplication.description = "Build application starting from a Dockerfile and ending with a snapshot of the corresponding Cartesi Machine already booted and yielded for the first time. This snapshot can be used to start a Cartesi node for the application using `run`. The process can also start from a Docker image built by the developer using `docker build` using the option `--from-image`";
199
- BuildApplication.examples = [
200
- "<%= config.bin %> <%= command.id %>",
201
- "<%= config.bin %> <%= command.id %> --from-image my-app",
202
- ];
203
- BuildApplication.args = {};
204
- BuildApplication.flags = {
205
- "from-image": Flags.string({
206
- summary: "skip docker build and start from this image.",
207
- description: "if the build process of the application Dockerfile needs more control the developer can build the image using the `docker build` command, and then start the build process of the Cartesi machine starting from that image.",
59
+ Build.summary = "Build application.";
60
+ Build.description = "Build application by building Cartesi machine drives, configuring a machine and booting it";
61
+ Build.examples = ["<%= config.bin %> <%= command.id %>"];
62
+ Build.flags = {
63
+ config: Flags.file({
64
+ char: "c",
65
+ default: "cartesi.toml",
66
+ summary: "path to the configuration file",
208
67
  }),
209
- target: Flags.string({
210
- summary: "target of docker multi-stage build.",
211
- description: "if the application Dockerfile uses a multi-stage strategy, and stage of the image to be exported as a Cartesi machine is not the last stage, use this parameter to specify the target stage.",
68
+ "drives-only": Flags.boolean({
69
+ default: false,
70
+ summary: "only build drives",
212
71
  }),
213
72
  };
214
- export default BuildApplication;
73
+ export default Build;
@@ -6,9 +6,10 @@ export default class Shell extends BaseCommand<typeof Shell> {
6
6
  image: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
7
7
  };
8
8
  static flags: {
9
+ command: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
10
+ config: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
11
  "run-as-root": import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
10
12
  };
11
- private startShell;
12
13
  run(): Promise<void>;
13
14
  }
14
15
  //# sourceMappingURL=shell.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../src/commands/shell.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,WAAW,CAAC,OAAO,KAAK,CAAC;IACxD,MAAM,CAAC,WAAW,SAAqD;IAEvE,MAAM,CAAC,QAAQ,WAA2C;IAE1D,MAAM,CAAC,IAAI;;MAKT;IAEF,MAAM,CAAC,KAAK;;MAKV;YAEY,UAAU;IAsCX,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAcpC"}
1
+ {"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../src/commands/shell.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,WAAW,CAAC,OAAO,KAAK,CAAC;IACxD,MAAM,CAAC,WAAW,SAAqD;IAEvE,MAAM,CAAC,QAAQ,WAA2C;IAE1D,MAAM,CAAC,IAAI;;MAKT;IAEF,MAAM,CAAC,KAAK;;;;MAgBV;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA2CpC"}
@@ -1,51 +1,40 @@
1
1
  import { Args, Flags } from "@oclif/core";
2
- import { execa } from "execa";
3
2
  import fs from "fs-extra";
4
- import { lookpath } from "lookpath";
5
3
  import path from "path";
6
4
  import { BaseCommand } from "../baseCommand.js";
5
+ import { bootMachine } from "../machine.js";
7
6
  class Shell extends BaseCommand {
8
- async startShell(ext2Path, runAsRoot) {
9
- const containerDir = "/mnt";
10
- const bind = `${path.resolve(path.dirname(ext2Path))}:${containerDir}`;
11
- const ext2 = path.join(containerDir, path.basename(ext2Path));
12
- const ramSize = "128Mi";
13
- const driveLabel = "root";
14
- const sdkImage = "cartesi/sdk:0.10.0"; // XXX: how to resolve sdk version?
15
- const args = [
16
- "run",
17
- "--interactive",
18
- "--tty",
19
- "--volume",
20
- bind,
21
- sdkImage,
22
- "cartesi-machine",
23
- `--ram-length=${ramSize}`,
24
- "--append-bootargs=no4lvl",
25
- `--flash-drive=label:${driveLabel},filename:${ext2}`,
26
- ];
27
- if (runAsRoot) {
28
- args.push("--append-init=USER=root");
29
- }
30
- if (!(await lookpath("stty"))) {
31
- args.push("-i");
32
- }
33
- else {
34
- args.push("-it");
35
- }
36
- await execa("docker", [...args, "--", "/bin/bash"], {
37
- stdio: "inherit",
38
- });
39
- }
40
7
  async run() {
41
8
  const { flags } = await this.parse(Shell);
42
- // use pre-existing image or build dapp image
43
- const ext2Path = this.getContextPath("image.ext2");
44
- if (!fs.existsSync(ext2Path)) {
45
- throw new Error(`machine not built, run '${this.config.bin} build'`);
9
+ // get application configuration from 'cartesi.toml'
10
+ const config = this.getApplicationConfig(flags.config);
11
+ // destination directory for image and intermediate files
12
+ const destination = path.resolve(this.getContextPath());
13
+ // check if all drives are built
14
+ for (const [name, drive] of Object.entries(config.drives)) {
15
+ const filename = `${name}.${drive.format}`;
16
+ const pathname = this.getContextPath(filename);
17
+ if (!fs.existsSync(pathname)) {
18
+ throw new Error(`drive '${name}' not built, run '${this.config.bin} build'`);
19
+ }
46
20
  }
47
- // execute the machine and save snapshot
48
- await this.startShell(ext2Path, flags["run-as-root"]);
21
+ // create shell entrypoint
22
+ const info = {
23
+ cmd: [],
24
+ entrypoint: [this.flags.command],
25
+ env: [],
26
+ workdir: "/",
27
+ };
28
+ // start with interactive mode on
29
+ config.machine.interactive = true;
30
+ // interactive mode can't have final hash
31
+ config.machine.finalHash = false;
32
+ // do not store machine in interactive mode
33
+ config.machine.store = undefined;
34
+ // run as root if flag is set
35
+ config.machine.user = flags["run-as-root"] ? "root" : undefined;
36
+ // boot machine
37
+ await bootMachine(config, info, destination);
49
38
  }
50
39
  }
51
40
  Shell.description = "Start a shell in cartesi machine of application";
@@ -57,9 +46,20 @@ Shell.args = {
57
46
  }),
58
47
  };
59
48
  Shell.flags = {
49
+ command: Flags.string({
50
+ default: "/bin/sh",
51
+ description: "shell command to run",
52
+ summary: "shell to run",
53
+ }),
54
+ config: Flags.file({
55
+ char: "c",
56
+ default: "cartesi.toml",
57
+ summary: "path to the configuration file",
58
+ }),
60
59
  "run-as-root": Flags.boolean({
61
- description: "run as root user",
62
60
  default: false,
61
+ description: "run as root user",
62
+ summary: "run the cartesi machine as the root user",
63
63
  }),
64
64
  };
65
65
  export default Shell;
@@ -0,0 +1,103 @@
1
+ import { TomlPrimitive } from "smol-toml";
2
+ /**
3
+ * Typed Errors
4
+ */
5
+ export declare class InvalidBuilderError extends Error {
6
+ constructor(builder: TomlPrimitive);
7
+ }
8
+ export declare class InvalidDriveFormatError extends Error {
9
+ constructor(format: TomlPrimitive);
10
+ }
11
+ export declare class InvalidEmptyDriveFormatError extends Error {
12
+ constructor(format: TomlPrimitive);
13
+ }
14
+ export declare class InvalidStringValueError extends Error {
15
+ constructor(value: TomlPrimitive);
16
+ }
17
+ export declare class InvalidBooleanValueError extends Error {
18
+ constructor(value: TomlPrimitive);
19
+ }
20
+ export declare class InvalidNumberValueError extends Error {
21
+ constructor(value: TomlPrimitive);
22
+ }
23
+ export declare class InvalidBytesValueError extends Error {
24
+ constructor(value: TomlPrimitive);
25
+ }
26
+ export declare class RequiredFieldError extends Error {
27
+ constructor(key: TomlPrimitive);
28
+ }
29
+ export declare class InvalidStringArrayError extends Error {
30
+ constructor();
31
+ }
32
+ export declare const DEFAULT_SDK = "cartesi/sdk:0.12.0-alpha.0";
33
+ type DriveFormat = "ext2" | "sqfs";
34
+ export type ImageInfo = {
35
+ cmd: string[];
36
+ entrypoint: string[];
37
+ env: string[];
38
+ workdir: string;
39
+ };
40
+ export type DriveResult = ImageInfo | undefined | void;
41
+ export type DirectoryDriveConfig = {
42
+ builder: "directory";
43
+ extraSize: number;
44
+ format: DriveFormat;
45
+ directory: string;
46
+ };
47
+ export type DockerDriveConfig = {
48
+ builder: "docker";
49
+ context: string;
50
+ dockerfile: string;
51
+ extraSize: number;
52
+ format: DriveFormat;
53
+ image?: string;
54
+ tags: string[];
55
+ target?: string;
56
+ };
57
+ export type EmptyDriveConfig = {
58
+ builder: "empty";
59
+ format: "ext2" | "raw";
60
+ size: number;
61
+ };
62
+ export type ExistingDriveConfig = {
63
+ builder: "none";
64
+ filename: string;
65
+ format: DriveFormat;
66
+ };
67
+ export type TarDriveConfig = {
68
+ builder: "tar";
69
+ filename: string;
70
+ format: DriveFormat;
71
+ extraSize: number;
72
+ };
73
+ export type DriveConfig = (DirectoryDriveConfig | DockerDriveConfig | EmptyDriveConfig | ExistingDriveConfig | TarDriveConfig) & {
74
+ mount?: string | boolean;
75
+ shared?: boolean;
76
+ user?: string;
77
+ };
78
+ export type MachineConfig = {
79
+ assertRollingTemplate?: boolean;
80
+ bootargs: string[];
81
+ entrypoint?: string;
82
+ finalHash: boolean;
83
+ interactive?: boolean;
84
+ maxMCycle?: bigint;
85
+ noRollup?: boolean;
86
+ ramLength: string;
87
+ ramImage: string;
88
+ store?: string;
89
+ user?: string;
90
+ };
91
+ export type Config = {
92
+ drives: Record<string, DriveConfig>;
93
+ machine: MachineConfig;
94
+ sdk: string;
95
+ };
96
+ export declare const defaultRootDriveConfig: () => DriveConfig;
97
+ export declare const defaultRamImage: () => string;
98
+ export declare const defaultMachineConfig: () => MachineConfig;
99
+ export declare const defaultConfig: () => Config;
100
+ export declare const getDriveFormat: (filename: string) => DriveFormat;
101
+ export declare const parse: (str: string) => Config;
102
+ export {};
103
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,OA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