@cartesi/cli 2.0.0-alpha.3 → 2.0.0-alpha.31
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/index.js +704 -1
- package/dist/index.js.map +791 -0
- package/package.json +77 -101
- package/LICENSE +0 -202
- package/bin/dev.cmd +0 -3
- package/bin/dev.js +0 -25
- package/bin/run.cmd +0 -3
- package/bin/run.js +0 -8
- package/dist/baseCommand.d.ts +0 -22
- package/dist/baseCommand.d.ts.map +0 -1
- package/dist/baseCommand.js +0 -92
- package/dist/builder/directory.d.ts +0 -3
- package/dist/builder/directory.d.ts.map +0 -1
- package/dist/builder/directory.js +0 -37
- package/dist/builder/docker.d.ts +0 -10
- package/dist/builder/docker.d.ts.map +0 -1
- package/dist/builder/docker.js +0 -112
- package/dist/builder/empty.d.ts +0 -3
- package/dist/builder/empty.d.ts.map +0 -1
- package/dist/builder/empty.js +0 -21
- package/dist/builder/index.d.ts +0 -6
- package/dist/builder/index.d.ts.map +0 -1
- package/dist/builder/index.js +0 -5
- package/dist/builder/none.d.ts +0 -3
- package/dist/builder/none.d.ts.map +0 -1
- package/dist/builder/none.js +0 -11
- package/dist/builder/tar.d.ts +0 -3
- package/dist/builder/tar.d.ts.map +0 -1
- package/dist/builder/tar.js +0 -30
- package/dist/commands/address-book.d.ts +0 -9
- package/dist/commands/address-book.d.ts.map +0 -1
- package/dist/commands/address-book.js +0 -40
- package/dist/commands/build.d.ts +0 -12
- package/dist/commands/build.d.ts.map +0 -1
- package/dist/commands/build.js +0 -73
- package/dist/commands/clean.d.ts +0 -8
- package/dist/commands/clean.d.ts.map +0 -1
- package/dist/commands/clean.js +0 -11
- package/dist/commands/create.d.ts +0 -16
- package/dist/commands/create.d.ts.map +0 -1
- package/dist/commands/create.js +0 -66
- package/dist/commands/deploy/build.d.ts +0 -15
- package/dist/commands/deploy/build.d.ts.map +0 -1
- package/dist/commands/deploy/build.js +0 -62
- package/dist/commands/deploy/index.d.ts +0 -12
- package/dist/commands/deploy/index.d.ts.map +0 -1
- package/dist/commands/deploy/index.js +0 -78
- package/dist/commands/doctor.d.ts +0 -13
- package/dist/commands/doctor.d.ts.map +0 -1
- package/dist/commands/doctor.js +0 -106
- package/dist/commands/hash.d.ts +0 -10
- package/dist/commands/hash.d.ts.map +0 -1
- package/dist/commands/hash.js +0 -22
- package/dist/commands/run.d.ts +0 -21
- package/dist/commands/run.d.ts.map +0 -1
- package/dist/commands/run.js +0 -191
- package/dist/commands/send/erc20.d.ts +0 -14
- package/dist/commands/send/erc20.d.ts.map +0 -1
- package/dist/commands/send/erc20.js +0 -70
- package/dist/commands/send/erc721.d.ts +0 -14
- package/dist/commands/send/erc721.d.ts.map +0 -1
- package/dist/commands/send/erc721.js +0 -73
- package/dist/commands/send/ether.d.ts +0 -13
- package/dist/commands/send/ether.d.ts.map +0 -1
- package/dist/commands/send/ether.js +0 -32
- package/dist/commands/send/generic.d.ts +0 -15
- package/dist/commands/send/generic.d.ts.map +0 -1
- package/dist/commands/send/generic.js +0 -119
- package/dist/commands/send/index.d.ts +0 -28
- package/dist/commands/send/index.d.ts.map +0 -1
- package/dist/commands/send/index.js +0 -102
- package/dist/commands/shell.d.ts +0 -15
- package/dist/commands/shell.d.ts.map +0 -1
- package/dist/commands/shell.js +0 -65
- package/dist/config.d.ts +0 -102
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -367
- package/dist/contracts.d.ts +0 -4317
- package/dist/contracts.d.ts.map +0 -1
- package/dist/contracts.js +0 -1799
- package/dist/exec/cartesi-machine.d.ts +0 -9
- package/dist/exec/cartesi-machine.d.ts.map +0 -1
- package/dist/exec/cartesi-machine.js +0 -20
- package/dist/exec/crane.d.ts +0 -15
- package/dist/exec/crane.d.ts.map +0 -1
- package/dist/exec/crane.js +0 -17
- package/dist/exec/genext2fs.d.ts +0 -28
- package/dist/exec/genext2fs.d.ts.map +0 -1
- package/dist/exec/genext2fs.js +0 -44
- package/dist/exec/index.d.ts +0 -5
- package/dist/exec/index.d.ts.map +0 -1
- package/dist/exec/index.js +0 -4
- package/dist/exec/mksquashfs.d.ts +0 -21
- package/dist/exec/mksquashfs.d.ts.map +0 -1
- package/dist/exec/mksquashfs.js +0 -45
- package/dist/exec/util.d.ts +0 -36
- package/dist/exec/util.d.ts.map +0 -1
- package/dist/exec/util.js +0 -80
- package/dist/flags.d.ts +0 -17
- package/dist/flags.d.ts.map +0 -1
- package/dist/flags.js +0 -28
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/machine.d.ts +0 -6
- package/dist/machine.d.ts.map +0 -1
- package/dist/machine.js +0 -80
- package/dist/node/DockerfileDeploy.txt +0 -4
- package/dist/node/default.env +0 -27
- package/dist/node/docker-compose-anvil.yaml +0 -50
- package/dist/node/docker-compose-bundler.yaml +0 -57
- package/dist/node/docker-compose-database.yaml +0 -10
- package/dist/node/docker-compose-envfile.yaml +0 -4
- package/dist/node/docker-compose-explorer.yaml +0 -88
- package/dist/node/docker-compose-host.yaml +0 -30
- package/dist/node/docker-compose-paymaster.yaml +0 -33
- package/dist/node/docker-compose-prompt.yaml +0 -17
- package/dist/node/docker-compose-proxy.yaml +0 -48
- package/dist/node/docker-compose-snapshot-volume.yaml +0 -8
- package/dist/node/docker-compose-validator-cpus.yaml +0 -6
- package/dist/node/docker-compose-validator-memory.yaml +0 -6
- package/dist/node/docker-compose-validator.yaml +0 -59
- package/dist/prompts.d.ts +0 -62
- package/dist/prompts.d.ts.map +0 -1
- package/dist/prompts.js +0 -158
- package/dist/types/docker.d.ts +0 -22
- package/dist/types/docker.d.ts.map +0 -1
- package/dist/types/docker.js +0 -1
- package/dist/wallet.d.ts +0 -24
- package/dist/wallet.d.ts.map +0 -1
- package/dist/wallet.js +0 -204
- package/oclif.manifest.json +0 -876
package/dist/builder/docker.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { execa } from "execa";
|
|
2
|
-
import fs from "fs-extra";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import tmp from "tmp";
|
|
5
|
-
import { crane, genext2fs, mksquashfs } from "../exec/index.js";
|
|
6
|
-
/**
|
|
7
|
-
* Build Docker image (linux/riscv64). Returns image id.
|
|
8
|
-
*/
|
|
9
|
-
const buildImage = async (options) => {
|
|
10
|
-
const { context, dockerfile, tags, target } = options;
|
|
11
|
-
const buildResult = tmp.tmpNameSync();
|
|
12
|
-
const args = [
|
|
13
|
-
"buildx",
|
|
14
|
-
"build",
|
|
15
|
-
"--platform",
|
|
16
|
-
"linux/riscv64",
|
|
17
|
-
"--file",
|
|
18
|
-
dockerfile,
|
|
19
|
-
"--load",
|
|
20
|
-
"--iidfile",
|
|
21
|
-
buildResult,
|
|
22
|
-
context,
|
|
23
|
-
];
|
|
24
|
-
// set tags for the image built
|
|
25
|
-
args.push(...tags.map((tag) => ["--tag", tag]).flat());
|
|
26
|
-
if (target) {
|
|
27
|
-
args.push("--target", target);
|
|
28
|
-
}
|
|
29
|
-
await execa("docker", args, { stdio: "inherit" });
|
|
30
|
-
return fs.readFileSync(buildResult, "utf8");
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Query the image using docker image inspect
|
|
34
|
-
* @param image image id or name
|
|
35
|
-
* @returns Information about the image
|
|
36
|
-
*/
|
|
37
|
-
const getImageInfo = async (image) => {
|
|
38
|
-
const { stdout: jsonStr } = await execa("docker", [
|
|
39
|
-
"image",
|
|
40
|
-
"inspect",
|
|
41
|
-
image,
|
|
42
|
-
]);
|
|
43
|
-
// parse image info from docker inspect output
|
|
44
|
-
const [imageInfo] = JSON.parse(jsonStr);
|
|
45
|
-
// validate image architecture (must be riscv64)
|
|
46
|
-
if (imageInfo["Architecture"] !== "riscv64") {
|
|
47
|
-
throw new Error(`Invalid image Architecture: ${imageInfo["Architecture"]}. Expected riscv64`);
|
|
48
|
-
}
|
|
49
|
-
const info = {
|
|
50
|
-
cmd: imageInfo["Config"]["Cmd"] ?? [],
|
|
51
|
-
entrypoint: imageInfo["Config"]["Entrypoint"] ?? [],
|
|
52
|
-
env: imageInfo["Config"]["Env"] || [],
|
|
53
|
-
workdir: imageInfo["Config"]["WorkingDir"],
|
|
54
|
-
};
|
|
55
|
-
return info;
|
|
56
|
-
};
|
|
57
|
-
export const build = async (name, drive, sdkImage, destination) => {
|
|
58
|
-
const { format } = drive;
|
|
59
|
-
const ocitar = `${name}.oci.tar`;
|
|
60
|
-
const tar = `${name}.tar`;
|
|
61
|
-
const filename = `${name}.${format}`;
|
|
62
|
-
// use pre-existing image or build docker image
|
|
63
|
-
let image;
|
|
64
|
-
if (drive.image) {
|
|
65
|
-
image = drive.image;
|
|
66
|
-
await execa("docker", ["image", "pull", image]);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
image = await buildImage(drive);
|
|
70
|
-
}
|
|
71
|
-
// get image info
|
|
72
|
-
const imageInfo = await getImageInfo(image);
|
|
73
|
-
try {
|
|
74
|
-
// create OCI Docker tarball from Docker image
|
|
75
|
-
await execa("docker", ["image", "save", image, "-o", ocitar], {
|
|
76
|
-
cwd: destination,
|
|
77
|
-
});
|
|
78
|
-
// create rootfs tar from OCI tar
|
|
79
|
-
await crane.exportImage({
|
|
80
|
-
stdin: fs.openSync(path.join(destination, ocitar), "r"),
|
|
81
|
-
stdout: fs.openSync(path.join(destination, tar), "w"),
|
|
82
|
-
image: sdkImage,
|
|
83
|
-
});
|
|
84
|
-
switch (format) {
|
|
85
|
-
case "ext2": {
|
|
86
|
-
await genext2fs.fromTar({
|
|
87
|
-
extraSize: drive.extraSize,
|
|
88
|
-
input: tar,
|
|
89
|
-
output: filename,
|
|
90
|
-
cwd: destination,
|
|
91
|
-
image: sdkImage,
|
|
92
|
-
});
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
case "sqfs": {
|
|
96
|
-
await mksquashfs.fromTar({
|
|
97
|
-
input: path.join(destination, tar),
|
|
98
|
-
output: filename,
|
|
99
|
-
cwd: destination,
|
|
100
|
-
image: sdkImage,
|
|
101
|
-
});
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
finally {
|
|
107
|
-
// delete intermediate files
|
|
108
|
-
await fs.remove(path.join(destination, ocitar));
|
|
109
|
-
await fs.remove(path.join(destination, tar));
|
|
110
|
-
}
|
|
111
|
-
return imageInfo;
|
|
112
|
-
};
|
package/dist/builder/empty.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"empty.d.ts","sourceRoot":"","sources":["../../src/builder/empty.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,eAAO,MAAM,KAAK,SACR,MAAM,SACL,gBAAgB,YACb,MAAM,eACH,MAAM,KACpB,OAAO,CAAC,IAAI,CAoBd,CAAC"}
|
package/dist/builder/empty.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import fs from "fs-extra";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { genext2fs } from "../exec/index.js";
|
|
4
|
-
export const build = async (name, drive, sdkImage, destination) => {
|
|
5
|
-
const filename = `${name}.${drive.format}`;
|
|
6
|
-
switch (drive.format) {
|
|
7
|
-
case "ext2": {
|
|
8
|
-
await genext2fs.empty({
|
|
9
|
-
output: filename,
|
|
10
|
-
size: drive.size,
|
|
11
|
-
cwd: destination,
|
|
12
|
-
image: sdkImage,
|
|
13
|
-
});
|
|
14
|
-
break;
|
|
15
|
-
}
|
|
16
|
-
case "raw": {
|
|
17
|
-
await fs.writeFile(path.join(destination, filename), Buffer.alloc(drive.size));
|
|
18
|
-
break;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
};
|
package/dist/builder/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { build as buildDirectory } from "./directory.js";
|
|
2
|
-
export { build as buildDocker } from "./docker.js";
|
|
3
|
-
export { build as buildEmpty } from "./empty.js";
|
|
4
|
-
export { build as buildNone } from "./none.js";
|
|
5
|
-
export { build as buildTar } from "./tar.js";
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/builder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/builder/index.js
DELETED
package/dist/builder/none.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"none.d.ts","sourceRoot":"","sources":["../../src/builder/none.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAkB,MAAM,cAAc,CAAC;AAEnE,eAAO,MAAM,KAAK,SACR,MAAM,SACL,mBAAmB,eACb,MAAM,KACpB,OAAO,CAAC,IAAI,CAQd,CAAC"}
|
package/dist/builder/none.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import fs from "fs-extra";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { getDriveFormat } from "../config.js";
|
|
4
|
-
export const build = async (name, drive, destination) => {
|
|
5
|
-
// no need to build, drive already exists
|
|
6
|
-
const src = drive.filename;
|
|
7
|
-
const format = getDriveFormat(src);
|
|
8
|
-
const filename = path.join(destination, `${name}.${format}`);
|
|
9
|
-
// just copy it
|
|
10
|
-
await fs.copyFile(src, filename);
|
|
11
|
-
};
|
package/dist/builder/tar.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tar.d.ts","sourceRoot":"","sources":["../../src/builder/tar.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9C,eAAO,MAAM,KAAK,SACR,MAAM,SACL,cAAc,YACX,MAAM,eACH,MAAM,KACpB,OAAO,CAAC,IAAI,CA4Bd,CAAC"}
|
package/dist/builder/tar.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import fs from "fs-extra";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { genext2fs, mksquashfs } from "../exec/index.js";
|
|
4
|
-
export const build = async (name, drive, sdkImage, destination) => {
|
|
5
|
-
const tar = `${name}.tar`;
|
|
6
|
-
const filename = `${name}.${drive.format}`;
|
|
7
|
-
// copy input tar to destination directory (with drive name)
|
|
8
|
-
await fs.copy(drive.filename, path.join(destination, tar));
|
|
9
|
-
switch (drive.format) {
|
|
10
|
-
case "ext2": {
|
|
11
|
-
await genext2fs.fromTar({
|
|
12
|
-
extraSize: drive.extraSize,
|
|
13
|
-
input: tar,
|
|
14
|
-
output: filename,
|
|
15
|
-
cwd: destination,
|
|
16
|
-
image: sdkImage,
|
|
17
|
-
});
|
|
18
|
-
break;
|
|
19
|
-
}
|
|
20
|
-
case "sqfs": {
|
|
21
|
-
await mksquashfs.fromTar({
|
|
22
|
-
input: path.join(destination, tar),
|
|
23
|
-
output: filename,
|
|
24
|
-
cwd: destination,
|
|
25
|
-
image: sdkImage,
|
|
26
|
-
});
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AddressBook as AddressBookType, BaseCommand } from "../baseCommand.js";
|
|
2
|
-
export default class AddressBook extends BaseCommand<typeof AddressBook> {
|
|
3
|
-
static summary: string;
|
|
4
|
-
static description: string;
|
|
5
|
-
static examples: string[];
|
|
6
|
-
static enableJsonFlag: boolean;
|
|
7
|
-
run(): Promise<AddressBookType>;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=address-book.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"address-book.d.ts","sourceRoot":"","sources":["../../src/commands/address-book.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhF,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,WAAW,CAAC,OAAO,WAAW,CAAC;IACpE,MAAM,CAAC,OAAO,SAAmD;IAEjE,MAAM,CAAC,WAAW,SACwF;IAE1G,MAAM,CAAC,QAAQ,WAA2C;IAE1D,OAAc,cAAc,UAAQ;IAEvB,GAAG,IAAI,OAAO,CAAC,eAAe,CAAC;CA+B/C"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import Table from "cli-table3";
|
|
2
|
-
import { BaseCommand } from "../baseCommand.js";
|
|
3
|
-
class AddressBook extends BaseCommand {
|
|
4
|
-
async run() {
|
|
5
|
-
const addressBook = await super.getAddressBook();
|
|
6
|
-
if (!this.jsonEnabled()) {
|
|
7
|
-
// print as a table
|
|
8
|
-
const table = new Table({
|
|
9
|
-
head: ["Contract", "Address"],
|
|
10
|
-
chars: {
|
|
11
|
-
top: "",
|
|
12
|
-
"top-mid": "",
|
|
13
|
-
"top-left": "",
|
|
14
|
-
"top-right": "",
|
|
15
|
-
bottom: "",
|
|
16
|
-
"bottom-mid": "",
|
|
17
|
-
"bottom-left": "",
|
|
18
|
-
"bottom-right": "",
|
|
19
|
-
left: "",
|
|
20
|
-
"left-mid": "",
|
|
21
|
-
mid: "",
|
|
22
|
-
"mid-mid": "",
|
|
23
|
-
right: "",
|
|
24
|
-
"right-mid": "",
|
|
25
|
-
middle: " ",
|
|
26
|
-
},
|
|
27
|
-
style: { "padding-left": 0, "padding-right": 0 },
|
|
28
|
-
});
|
|
29
|
-
table.push(...Object.entries(addressBook));
|
|
30
|
-
console.log(table.toString());
|
|
31
|
-
}
|
|
32
|
-
// return (as json)
|
|
33
|
-
return addressBook;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
AddressBook.summary = "Prints addresses of smart contracts deployed.";
|
|
37
|
-
AddressBook.description = "Prints the addresses of all smart contracts deployed to the runtime environment of the application.";
|
|
38
|
-
AddressBook.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
39
|
-
AddressBook.enableJsonFlag = true;
|
|
40
|
-
export default AddressBook;
|
package/dist/commands/build.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { BaseCommand } from "../baseCommand.js";
|
|
2
|
-
export default class Build extends BaseCommand<typeof Build> {
|
|
3
|
-
static summary: string;
|
|
4
|
-
static description: string;
|
|
5
|
-
static examples: string[];
|
|
6
|
-
static flags: {
|
|
7
|
-
config: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
8
|
-
"drives-only": import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
9
|
-
};
|
|
10
|
-
run(): Promise<void>;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=build.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAoChD,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,WAAW,CAAC,OAAO,KAAK,CAAC;IACxD,MAAM,CAAC,OAAO,SAAwB;IAEtC,MAAM,CAAC,WAAW,SAC+E;IAEjG,MAAM,CAAC,QAAQ,WAA2C;IAE1D,MAAM,CAAC,KAAK;;;MAUV;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA2CpC"}
|
package/dist/commands/build.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { Flags } from "@oclif/core";
|
|
2
|
-
import fs from "fs-extra";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import tmp from "tmp";
|
|
5
|
-
import { BaseCommand } from "../baseCommand.js";
|
|
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);
|
|
12
|
-
}
|
|
13
|
-
case "docker": {
|
|
14
|
-
return buildDocker(name, drive, sdkImage, destination);
|
|
15
|
-
}
|
|
16
|
-
case "empty": {
|
|
17
|
-
return buildEmpty(name, drive, sdkImage, destination);
|
|
18
|
-
}
|
|
19
|
-
case "tar": {
|
|
20
|
-
return buildTar(name, drive, sdkImage, destination);
|
|
21
|
-
}
|
|
22
|
-
case "none": {
|
|
23
|
-
return buildNone(name, drive, destination);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
class Build extends BaseCommand {
|
|
28
|
-
async run() {
|
|
29
|
-
const { flags } = await this.parse(Build);
|
|
30
|
-
// clean up temp files we create along the process
|
|
31
|
-
tmp.setGracefulCleanup();
|
|
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());
|
|
36
|
-
// prepare context directory
|
|
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;
|
|
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);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
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",
|
|
67
|
-
}),
|
|
68
|
-
"drives-only": Flags.boolean({
|
|
69
|
-
default: false,
|
|
70
|
-
summary: "only build drives",
|
|
71
|
-
}),
|
|
72
|
-
};
|
|
73
|
-
export default Build;
|
package/dist/commands/clean.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../src/commands/clean.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,WAAW,CAAC,OAAO,KAAK,CAAC;IACxD,MAAM,CAAC,OAAO,SAA2C;IAEzD,MAAM,CAAC,WAAW,SAAwD;IAE1E,MAAM,CAAC,QAAQ,WAA2C;IAE7C,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAGpC"}
|
package/dist/commands/clean.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import fs from "fs-extra";
|
|
2
|
-
import { BaseCommand } from "../baseCommand.js";
|
|
3
|
-
class Clean extends BaseCommand {
|
|
4
|
-
async run() {
|
|
5
|
-
await fs.emptyDir(this.getContextPath());
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
Clean.summary = "Clean build artifacts of application.";
|
|
9
|
-
Clean.description = "Deletes all cached build artifacts of application.";
|
|
10
|
-
Clean.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
11
|
-
export default Clean;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { BaseCommand } from "../baseCommand.js";
|
|
2
|
-
export declare const DEFAULT_TEMPLATES_BRANCH = "sdk-0.9";
|
|
3
|
-
export default class CreateCommand extends BaseCommand<typeof CreateCommand> {
|
|
4
|
-
static description: string;
|
|
5
|
-
static examples: string[];
|
|
6
|
-
static args: {
|
|
7
|
-
name: import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
|
|
8
|
-
};
|
|
9
|
-
static flags: {
|
|
10
|
-
template: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
|
-
branch: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
12
|
-
};
|
|
13
|
-
private download;
|
|
14
|
-
run(): Promise<void>;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=create.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,eAAO,MAAM,wBAAwB,YAAY,CAAC;AAElD,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,WAAW,CAAC,OAAO,aAAa,CAAC;IACxE,MAAM,CAAC,WAAW,SAAwB;IAE1C,MAAM,CAAC,QAAQ,WAA2C;IAE1D,MAAM,CAAC,IAAI;;MAKT;IAEF,MAAM,CAAC,KAAK;;;MAoBV;YAEY,QAAQ;IAqBT,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAkBpC"}
|
package/dist/commands/create.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { Args, Flags } from "@oclif/core";
|
|
2
|
-
import chalk from "chalk";
|
|
3
|
-
import { downloadTemplate } from "giget";
|
|
4
|
-
import ora from "ora";
|
|
5
|
-
import { BaseCommand } from "../baseCommand.js";
|
|
6
|
-
export const DEFAULT_TEMPLATES_BRANCH = "sdk-0.9";
|
|
7
|
-
class CreateCommand extends BaseCommand {
|
|
8
|
-
async download(template, branch, out) {
|
|
9
|
-
const cartesiProvider = async (input) => {
|
|
10
|
-
return {
|
|
11
|
-
name: "cartesi",
|
|
12
|
-
subdir: input,
|
|
13
|
-
url: "https://github.com/cartesi/application-templates",
|
|
14
|
-
tar: `https://codeload.github.com/cartesi/application-templates/tar.gz/refs/heads/${branch}`,
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
const input = `cartesi:${template}`;
|
|
18
|
-
return downloadTemplate(input, {
|
|
19
|
-
dir: out,
|
|
20
|
-
providers: { cartesi: cartesiProvider },
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
async run() {
|
|
24
|
-
const { args, flags } = await this.parse(CreateCommand);
|
|
25
|
-
const spinner = ora("Creating application...").start();
|
|
26
|
-
try {
|
|
27
|
-
const { dir } = await this.download(flags.template, flags.branch, args.name);
|
|
28
|
-
spinner.succeed(`Application created at ${chalk.cyan(dir)}`);
|
|
29
|
-
}
|
|
30
|
-
catch (e) {
|
|
31
|
-
spinner.fail(e instanceof Error
|
|
32
|
-
? `Error creating application: ${chalk.red(e.message)}`
|
|
33
|
-
: String(e));
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
CreateCommand.description = "Create application";
|
|
38
|
-
CreateCommand.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
39
|
-
CreateCommand.args = {
|
|
40
|
-
name: Args.string({
|
|
41
|
-
description: "application and directory name",
|
|
42
|
-
required: true,
|
|
43
|
-
}),
|
|
44
|
-
};
|
|
45
|
-
CreateCommand.flags = {
|
|
46
|
-
template: Flags.string({
|
|
47
|
-
description: "template name to use",
|
|
48
|
-
required: true,
|
|
49
|
-
options: [
|
|
50
|
-
"cpp",
|
|
51
|
-
"cpp-low-level",
|
|
52
|
-
"go",
|
|
53
|
-
"javascript",
|
|
54
|
-
"lua",
|
|
55
|
-
"python",
|
|
56
|
-
"ruby",
|
|
57
|
-
"rust",
|
|
58
|
-
"typescript",
|
|
59
|
-
],
|
|
60
|
-
}),
|
|
61
|
-
branch: Flags.string({
|
|
62
|
-
description: `cartesi/application-templates repository branch name to use`,
|
|
63
|
-
default: DEFAULT_TEMPLATES_BRANCH,
|
|
64
|
-
}),
|
|
65
|
-
};
|
|
66
|
-
export default CreateCommand;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { BaseCommand } from "../../baseCommand.js";
|
|
2
|
-
export default class DeployBuild extends BaseCommand<typeof DeployBuild> {
|
|
3
|
-
static summary: string;
|
|
4
|
-
static description: string;
|
|
5
|
-
static examples: string[];
|
|
6
|
-
static flags: {
|
|
7
|
-
platform: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
8
|
-
};
|
|
9
|
-
static enableJsonFlag: boolean;
|
|
10
|
-
private buildRollupsImage;
|
|
11
|
-
run(): Promise<{
|
|
12
|
-
image: string;
|
|
13
|
-
}>;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=build.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy/build.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,WAAW,CAAC,OAAO,WAAW,CAAC;IACpE,MAAM,CAAC,OAAO,SAAmD;IAEjE,MAAM,CAAC,WAAW,SACoD;IAEtE,MAAM,CAAC,QAAQ,WAA2C;IAE1D,MAAM,CAAC,KAAK;;MAOV;IAEF,OAAc,cAAc,UAAQ;YAEtB,iBAAiB;IA6BlB,GAAG;;;CAwBnB"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Flags } from "@oclif/core";
|
|
2
|
-
import { execa } from "execa";
|
|
3
|
-
import fs from "fs-extra";
|
|
4
|
-
import path from "path";
|
|
5
|
-
import { tmpNameSync } from "tmp";
|
|
6
|
-
import { URL } from "url";
|
|
7
|
-
import { BaseCommand } from "../../baseCommand.js";
|
|
8
|
-
class DeployBuild extends BaseCommand {
|
|
9
|
-
async buildRollupsImage(platform) {
|
|
10
|
-
const buildResult = tmpNameSync();
|
|
11
|
-
const imagePath = this.getContextPath("image");
|
|
12
|
-
const binPath = path.join(path.dirname(new URL(import.meta.url).pathname), "..", "..");
|
|
13
|
-
const dockerfile = path.join(binPath, "node", "DockerfileDeploy.txt");
|
|
14
|
-
const args = [
|
|
15
|
-
"buildx",
|
|
16
|
-
"build",
|
|
17
|
-
"-f",
|
|
18
|
-
dockerfile,
|
|
19
|
-
"--load",
|
|
20
|
-
"--iidfile",
|
|
21
|
-
buildResult,
|
|
22
|
-
imagePath,
|
|
23
|
-
];
|
|
24
|
-
// optional platform, default to not defining, which will build for the host platform
|
|
25
|
-
if (platform) {
|
|
26
|
-
args.push("--platform", platform);
|
|
27
|
-
}
|
|
28
|
-
await execa("docker", args, { stdio: "inherit" });
|
|
29
|
-
return fs.readFileSync(buildResult, "utf8");
|
|
30
|
-
}
|
|
31
|
-
async run() {
|
|
32
|
-
const { flags } = await this.parse(DeployBuild);
|
|
33
|
-
// print machine hash
|
|
34
|
-
const templateHash = this.getMachineHash();
|
|
35
|
-
if (!templateHash) {
|
|
36
|
-
this.error(`Cartesi machine snapshot not found, run '${this.config.bin} build'`);
|
|
37
|
-
}
|
|
38
|
-
this.logPrompt({
|
|
39
|
-
title: "Cartesi machine templateHash",
|
|
40
|
-
value: templateHash,
|
|
41
|
-
});
|
|
42
|
-
this.log("Building application node Docker image...");
|
|
43
|
-
const image = await this.buildRollupsImage(flags.platform);
|
|
44
|
-
this.logPrompt({
|
|
45
|
-
title: "Application node Docker image",
|
|
46
|
-
value: image,
|
|
47
|
-
});
|
|
48
|
-
return { image };
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
DeployBuild.summary = "Build deployment Docker image of application.";
|
|
52
|
-
DeployBuild.description = "Package the application in a Docker image ready to be deployed.";
|
|
53
|
-
DeployBuild.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
54
|
-
DeployBuild.flags = {
|
|
55
|
-
platform: Flags.string({
|
|
56
|
-
options: ["linux/amd64", "linux/arm64"],
|
|
57
|
-
summary: "Docker image target platform",
|
|
58
|
-
description: "Select the target platform for the produced Docker image. It depends on the platform where the application node will be deployed.",
|
|
59
|
-
}),
|
|
60
|
-
};
|
|
61
|
-
DeployBuild.enableJsonFlag = true;
|
|
62
|
-
export default DeployBuild;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { BaseCommand } from "../../baseCommand.js";
|
|
2
|
-
export default class Deploy extends BaseCommand<typeof Deploy> {
|
|
3
|
-
static summary: string;
|
|
4
|
-
static description: string;
|
|
5
|
-
static examples: string[];
|
|
6
|
-
static flags: {
|
|
7
|
-
hosting: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
8
|
-
webapp: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<import("url").URL, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
9
|
-
};
|
|
10
|
-
run(): Promise<void>;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,WAAW,CAAC,OAAO,MAAM,CAAC;IAC1D,MAAM,CAAC,OAAO,SAA2C;IAEzD,MAAM,CAAC,WAAW,SACoD;IAEtE,MAAM,CAAC,QAAQ,WAA2C;IAE1D,MAAM,CAAC,KAAK;;;MAWV;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAiEpC"}
|