@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.
Files changed (131) hide show
  1. package/dist/index.js +704 -1
  2. package/dist/index.js.map +791 -0
  3. package/package.json +77 -101
  4. package/LICENSE +0 -202
  5. package/bin/dev.cmd +0 -3
  6. package/bin/dev.js +0 -25
  7. package/bin/run.cmd +0 -3
  8. package/bin/run.js +0 -8
  9. package/dist/baseCommand.d.ts +0 -22
  10. package/dist/baseCommand.d.ts.map +0 -1
  11. package/dist/baseCommand.js +0 -92
  12. package/dist/builder/directory.d.ts +0 -3
  13. package/dist/builder/directory.d.ts.map +0 -1
  14. package/dist/builder/directory.js +0 -37
  15. package/dist/builder/docker.d.ts +0 -10
  16. package/dist/builder/docker.d.ts.map +0 -1
  17. package/dist/builder/docker.js +0 -112
  18. package/dist/builder/empty.d.ts +0 -3
  19. package/dist/builder/empty.d.ts.map +0 -1
  20. package/dist/builder/empty.js +0 -21
  21. package/dist/builder/index.d.ts +0 -6
  22. package/dist/builder/index.d.ts.map +0 -1
  23. package/dist/builder/index.js +0 -5
  24. package/dist/builder/none.d.ts +0 -3
  25. package/dist/builder/none.d.ts.map +0 -1
  26. package/dist/builder/none.js +0 -11
  27. package/dist/builder/tar.d.ts +0 -3
  28. package/dist/builder/tar.d.ts.map +0 -1
  29. package/dist/builder/tar.js +0 -30
  30. package/dist/commands/address-book.d.ts +0 -9
  31. package/dist/commands/address-book.d.ts.map +0 -1
  32. package/dist/commands/address-book.js +0 -40
  33. package/dist/commands/build.d.ts +0 -12
  34. package/dist/commands/build.d.ts.map +0 -1
  35. package/dist/commands/build.js +0 -73
  36. package/dist/commands/clean.d.ts +0 -8
  37. package/dist/commands/clean.d.ts.map +0 -1
  38. package/dist/commands/clean.js +0 -11
  39. package/dist/commands/create.d.ts +0 -16
  40. package/dist/commands/create.d.ts.map +0 -1
  41. package/dist/commands/create.js +0 -66
  42. package/dist/commands/deploy/build.d.ts +0 -15
  43. package/dist/commands/deploy/build.d.ts.map +0 -1
  44. package/dist/commands/deploy/build.js +0 -62
  45. package/dist/commands/deploy/index.d.ts +0 -12
  46. package/dist/commands/deploy/index.d.ts.map +0 -1
  47. package/dist/commands/deploy/index.js +0 -78
  48. package/dist/commands/doctor.d.ts +0 -13
  49. package/dist/commands/doctor.d.ts.map +0 -1
  50. package/dist/commands/doctor.js +0 -106
  51. package/dist/commands/hash.d.ts +0 -10
  52. package/dist/commands/hash.d.ts.map +0 -1
  53. package/dist/commands/hash.js +0 -22
  54. package/dist/commands/run.d.ts +0 -21
  55. package/dist/commands/run.d.ts.map +0 -1
  56. package/dist/commands/run.js +0 -191
  57. package/dist/commands/send/erc20.d.ts +0 -14
  58. package/dist/commands/send/erc20.d.ts.map +0 -1
  59. package/dist/commands/send/erc20.js +0 -70
  60. package/dist/commands/send/erc721.d.ts +0 -14
  61. package/dist/commands/send/erc721.d.ts.map +0 -1
  62. package/dist/commands/send/erc721.js +0 -73
  63. package/dist/commands/send/ether.d.ts +0 -13
  64. package/dist/commands/send/ether.d.ts.map +0 -1
  65. package/dist/commands/send/ether.js +0 -32
  66. package/dist/commands/send/generic.d.ts +0 -15
  67. package/dist/commands/send/generic.d.ts.map +0 -1
  68. package/dist/commands/send/generic.js +0 -119
  69. package/dist/commands/send/index.d.ts +0 -28
  70. package/dist/commands/send/index.d.ts.map +0 -1
  71. package/dist/commands/send/index.js +0 -102
  72. package/dist/commands/shell.d.ts +0 -15
  73. package/dist/commands/shell.d.ts.map +0 -1
  74. package/dist/commands/shell.js +0 -65
  75. package/dist/config.d.ts +0 -102
  76. package/dist/config.d.ts.map +0 -1
  77. package/dist/config.js +0 -367
  78. package/dist/contracts.d.ts +0 -4317
  79. package/dist/contracts.d.ts.map +0 -1
  80. package/dist/contracts.js +0 -1799
  81. package/dist/exec/cartesi-machine.d.ts +0 -9
  82. package/dist/exec/cartesi-machine.d.ts.map +0 -1
  83. package/dist/exec/cartesi-machine.js +0 -20
  84. package/dist/exec/crane.d.ts +0 -15
  85. package/dist/exec/crane.d.ts.map +0 -1
  86. package/dist/exec/crane.js +0 -17
  87. package/dist/exec/genext2fs.d.ts +0 -28
  88. package/dist/exec/genext2fs.d.ts.map +0 -1
  89. package/dist/exec/genext2fs.js +0 -44
  90. package/dist/exec/index.d.ts +0 -5
  91. package/dist/exec/index.d.ts.map +0 -1
  92. package/dist/exec/index.js +0 -4
  93. package/dist/exec/mksquashfs.d.ts +0 -21
  94. package/dist/exec/mksquashfs.d.ts.map +0 -1
  95. package/dist/exec/mksquashfs.js +0 -45
  96. package/dist/exec/util.d.ts +0 -36
  97. package/dist/exec/util.d.ts.map +0 -1
  98. package/dist/exec/util.js +0 -80
  99. package/dist/flags.d.ts +0 -17
  100. package/dist/flags.d.ts.map +0 -1
  101. package/dist/flags.js +0 -28
  102. package/dist/index.d.ts +0 -2
  103. package/dist/index.d.ts.map +0 -1
  104. package/dist/machine.d.ts +0 -6
  105. package/dist/machine.d.ts.map +0 -1
  106. package/dist/machine.js +0 -80
  107. package/dist/node/DockerfileDeploy.txt +0 -4
  108. package/dist/node/default.env +0 -27
  109. package/dist/node/docker-compose-anvil.yaml +0 -50
  110. package/dist/node/docker-compose-bundler.yaml +0 -57
  111. package/dist/node/docker-compose-database.yaml +0 -10
  112. package/dist/node/docker-compose-envfile.yaml +0 -4
  113. package/dist/node/docker-compose-explorer.yaml +0 -88
  114. package/dist/node/docker-compose-host.yaml +0 -30
  115. package/dist/node/docker-compose-paymaster.yaml +0 -33
  116. package/dist/node/docker-compose-prompt.yaml +0 -17
  117. package/dist/node/docker-compose-proxy.yaml +0 -48
  118. package/dist/node/docker-compose-snapshot-volume.yaml +0 -8
  119. package/dist/node/docker-compose-validator-cpus.yaml +0 -6
  120. package/dist/node/docker-compose-validator-memory.yaml +0 -6
  121. package/dist/node/docker-compose-validator.yaml +0 -59
  122. package/dist/prompts.d.ts +0 -62
  123. package/dist/prompts.d.ts.map +0 -1
  124. package/dist/prompts.js +0 -158
  125. package/dist/types/docker.d.ts +0 -22
  126. package/dist/types/docker.d.ts.map +0 -1
  127. package/dist/types/docker.js +0 -1
  128. package/dist/wallet.d.ts +0 -24
  129. package/dist/wallet.d.ts.map +0 -1
  130. package/dist/wallet.js +0 -204
  131. package/oclif.manifest.json +0 -876
@@ -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
- };
@@ -1,3 +0,0 @@
1
- import { EmptyDriveConfig } from "../config.js";
2
- export declare const build: (name: string, drive: EmptyDriveConfig, sdkImage: string, destination: string) => Promise<void>;
3
- //# sourceMappingURL=empty.d.ts.map
@@ -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"}
@@ -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
- };
@@ -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"}
@@ -1,5 +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";
@@ -1,3 +0,0 @@
1
- import { ExistingDriveConfig } from "../config.js";
2
- export declare const build: (name: string, drive: ExistingDriveConfig, destination: string) => Promise<void>;
3
- //# sourceMappingURL=none.d.ts.map
@@ -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"}
@@ -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
- };
@@ -1,3 +0,0 @@
1
- import { TarDriveConfig } from "../config.js";
2
- export declare const build: (name: string, drive: TarDriveConfig, sdkImage: string, destination: string) => Promise<void>;
3
- //# sourceMappingURL=tar.d.ts.map
@@ -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"}
@@ -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;
@@ -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"}
@@ -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;
@@ -1,8 +0,0 @@
1
- import { BaseCommand } from "../baseCommand.js";
2
- export default class Clean extends BaseCommand<typeof Clean> {
3
- static summary: string;
4
- static description: string;
5
- static examples: string[];
6
- run(): Promise<void>;
7
- }
8
- //# sourceMappingURL=clean.d.ts.map
@@ -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"}
@@ -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"}
@@ -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"}