@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
package/dist/config.js DELETED
@@ -1,367 +0,0 @@
1
- import bytes from "bytes";
2
- import { extname } from "path";
3
- import { parse as parseToml } from "smol-toml";
4
- /**
5
- * Typed Errors
6
- */
7
- export class InvalidBuilderError extends Error {
8
- constructor(builder) {
9
- super(`Invalid builder: ${builder}`);
10
- this.name = "InvalidBuilder";
11
- }
12
- }
13
- export class InvalidDriveFormatError extends Error {
14
- constructor(format) {
15
- super(`Invalid drive format: ${format}`);
16
- this.name = "InvalidDriveFormatError";
17
- }
18
- }
19
- export class InvalidEmptyDriveFormatError extends Error {
20
- constructor(format) {
21
- super(`Invalid empty drive format: ${format}`);
22
- this.name = "InvalidEmptyDriveFormatError";
23
- }
24
- }
25
- export class InvalidStringValueError extends Error {
26
- constructor(value) {
27
- super(`Invalid string value: ${value}`);
28
- this.name = "InvalidStringValueError";
29
- }
30
- }
31
- export class InvalidBooleanValueError extends Error {
32
- constructor(value) {
33
- super(`Invalid boolean value: ${value}`);
34
- this.name = "InvalidBooleanValueError";
35
- }
36
- }
37
- export class InvalidNumberValueError extends Error {
38
- constructor(value) {
39
- super(`Invalid number value: ${value}`);
40
- this.name = "InvalidNumberValueError";
41
- }
42
- }
43
- export class InvalidBytesValueError extends Error {
44
- constructor(value) {
45
- super(`Invalid bytes value: ${value}`);
46
- this.name = "InvalidBytesValueError";
47
- }
48
- }
49
- export class RequiredFieldError extends Error {
50
- constructor(key) {
51
- super(`Missing required field: ${key}`);
52
- this.name = "RequiredFieldError";
53
- }
54
- }
55
- export class InvalidStringArrayError extends Error {
56
- constructor() {
57
- super(`Invalid string array`);
58
- this.name = "InvalidStringArrayError";
59
- }
60
- }
61
- /**
62
- * Configuration for drives of a Cartesi Machine. A drive may already exist or be built by a builder
63
- */
64
- const DEFAULT_FORMAT = "ext2";
65
- const DEFAULT_RAM = "128Mi";
66
- const DEFAULT_RAM_IMAGE = "/usr/share/cartesi-machine/images/linux.bin";
67
- export const DEFAULT_SDK = "cartesi/sdk:0.12.0-alpha.1";
68
- export const defaultRootDriveConfig = () => ({
69
- builder: "docker",
70
- context: ".",
71
- dockerfile: "Dockerfile", // file on current working directory
72
- extraSize: 0,
73
- format: DEFAULT_FORMAT,
74
- tags: [],
75
- });
76
- export const defaultMachineConfig = () => ({
77
- assertRollingTemplate: undefined,
78
- bootargs: [],
79
- entrypoint: undefined,
80
- finalHash: true,
81
- interactive: undefined,
82
- maxMCycle: undefined,
83
- noRollup: undefined,
84
- ramLength: DEFAULT_RAM,
85
- ramImage: DEFAULT_RAM_IMAGE,
86
- store: "image",
87
- user: undefined,
88
- });
89
- export const defaultConfig = () => ({
90
- drives: { root: defaultRootDriveConfig() },
91
- machine: defaultMachineConfig(),
92
- sdk: DEFAULT_SDK,
93
- });
94
- const parseBoolean = (value, defaultValue) => {
95
- if (value === undefined) {
96
- return defaultValue;
97
- }
98
- else if (typeof value === "boolean") {
99
- return value;
100
- }
101
- throw new InvalidBooleanValueError(value);
102
- };
103
- const parseOptionalBoolean = (value) => {
104
- if (value === undefined) {
105
- return undefined;
106
- }
107
- else if (typeof value === "boolean") {
108
- return value;
109
- }
110
- throw new InvalidBooleanValueError(value);
111
- };
112
- const parseString = (value, defaultValue) => {
113
- if (value === undefined) {
114
- return defaultValue;
115
- }
116
- else if (typeof value === "string") {
117
- return value;
118
- }
119
- throw new InvalidStringValueError(value);
120
- };
121
- const parseStringArray = (value) => {
122
- if (value === undefined) {
123
- return [];
124
- }
125
- else if (typeof value === "string") {
126
- return [value];
127
- }
128
- else if (typeof value === "object" && Array.isArray(value)) {
129
- return value.map((v) => {
130
- if (typeof v === "string") {
131
- return v;
132
- }
133
- throw new InvalidStringValueError(v);
134
- });
135
- }
136
- throw new InvalidStringArrayError();
137
- };
138
- const parseRequiredString = (value, key) => {
139
- if (value === undefined) {
140
- throw new RequiredFieldError(key);
141
- }
142
- else if (typeof value === "string") {
143
- return value;
144
- }
145
- throw new InvalidStringValueError(value);
146
- };
147
- const parseOptionalString = (value) => {
148
- if (value === undefined) {
149
- return undefined;
150
- }
151
- else if (typeof value === "string") {
152
- return value;
153
- }
154
- throw new InvalidStringValueError(value);
155
- };
156
- const parseOptionalStringBoolean = (value) => {
157
- if (value === undefined) {
158
- return undefined;
159
- }
160
- else if (typeof value === "string") {
161
- return value;
162
- }
163
- else if (typeof value === "boolean") {
164
- return value;
165
- }
166
- throw new InvalidStringValueError(value);
167
- };
168
- const parseOptionalNumber = (value) => {
169
- if (value === undefined) {
170
- return undefined;
171
- }
172
- else if (typeof value === "bigint") {
173
- return value;
174
- }
175
- else if (typeof value === "number") {
176
- return BigInt(value);
177
- }
178
- throw new InvalidNumberValueError(value);
179
- };
180
- const parseBytes = (value, defaultValue) => {
181
- if (value === undefined) {
182
- return defaultValue;
183
- }
184
- else if (typeof value === "bigint") {
185
- return Number(value);
186
- }
187
- else if (typeof value === "number" || typeof value === "string") {
188
- const output = bytes.parse(value);
189
- if (output !== null) {
190
- return output;
191
- }
192
- }
193
- throw new InvalidBytesValueError(value);
194
- };
195
- const parseBuilder = (value) => {
196
- if (value === undefined) {
197
- return "docker";
198
- }
199
- else if (typeof value === "string") {
200
- switch (value) {
201
- case "directory":
202
- return "directory";
203
- case "docker":
204
- return "docker";
205
- case "empty":
206
- return "empty";
207
- case "none":
208
- return "none";
209
- case "tar":
210
- return "tar";
211
- }
212
- }
213
- throw new InvalidBuilderError(value);
214
- };
215
- const parseFormat = (value) => {
216
- if (value === undefined) {
217
- return DEFAULT_FORMAT;
218
- }
219
- else if (typeof value === "string") {
220
- switch (value) {
221
- case "ext2":
222
- return "ext2";
223
- case "sqfs":
224
- return "sqfs";
225
- }
226
- }
227
- throw new InvalidDriveFormatError(value);
228
- };
229
- const parseEmptyFormat = (value) => {
230
- if (value === undefined) {
231
- return DEFAULT_FORMAT;
232
- }
233
- else if (typeof value === "string") {
234
- switch (value) {
235
- case "ext2":
236
- return "ext2";
237
- case "raw":
238
- return "raw";
239
- }
240
- }
241
- throw new InvalidEmptyDriveFormatError(value);
242
- };
243
- const parseMachine = (value) => {
244
- if (value === undefined) {
245
- // default machine
246
- return defaultMachineConfig();
247
- }
248
- if (typeof value !== "object") {
249
- throw new Error(`Invalid machine configuration: ${value}`);
250
- }
251
- const toml = value;
252
- return {
253
- assertRollingTemplate: parseOptionalBoolean(toml["assert-rolling-template"]),
254
- bootargs: parseStringArray(toml.bootargs),
255
- finalHash: parseBoolean(toml["final-hash"], true),
256
- interactive: undefined,
257
- maxMCycle: parseOptionalNumber(toml["max-mcycle"]),
258
- noRollup: parseBoolean(toml["no-rollup"], false),
259
- ramLength: parseString(toml["ram-length"], DEFAULT_RAM),
260
- ramImage: parseString(toml["ram-image"], DEFAULT_RAM_IMAGE),
261
- store: "image",
262
- user: parseOptionalString(toml.user),
263
- };
264
- };
265
- export const getDriveFormat = (filename) => {
266
- const extension = extname(filename);
267
- switch (extension) {
268
- case ".ext2":
269
- return "ext2";
270
- case ".sqfs":
271
- return "sqfs";
272
- default:
273
- throw new InvalidDriveFormatError(extension);
274
- }
275
- };
276
- const parseDrive = (drive) => {
277
- const builder = parseBuilder(drive.builder);
278
- switch (builder) {
279
- case "directory": {
280
- const { extraSize, format, mount, directory, shared, user } = drive;
281
- return {
282
- builder: "directory",
283
- extraSize: parseBytes(extraSize, 0),
284
- format: parseFormat(format),
285
- mount: parseOptionalStringBoolean(mount),
286
- directory: parseRequiredString(directory, "directory"),
287
- shared: parseOptionalBoolean(shared),
288
- user: parseOptionalString(user),
289
- };
290
- }
291
- case "docker": {
292
- const { context, dockerfile, extraSize, format, image, mount, shared, tags, target, user, } = drive;
293
- return {
294
- builder: "docker",
295
- image: parseOptionalString(image),
296
- context: parseString(context, "."),
297
- dockerfile: parseString(dockerfile, "Dockerfile"),
298
- extraSize: parseBytes(extraSize, 0),
299
- format: parseFormat(format),
300
- mount: parseOptionalStringBoolean(mount),
301
- shared: parseOptionalBoolean(shared),
302
- user: parseOptionalString(user),
303
- tags: parseStringArray(tags),
304
- target: parseOptionalString(target),
305
- };
306
- }
307
- case "empty": {
308
- const { format, mount, size, shared, user } = drive;
309
- return {
310
- builder: "empty",
311
- format: parseEmptyFormat(format),
312
- mount: parseOptionalStringBoolean(mount),
313
- shared: parseOptionalBoolean(shared),
314
- size: parseBytes(size, 0),
315
- user: parseOptionalString(user),
316
- };
317
- }
318
- case "tar": {
319
- const { extraSize, filename, format, mount, shared, user } = drive;
320
- return {
321
- builder: "tar",
322
- extraSize: parseBytes(extraSize, 0),
323
- filename: parseRequiredString(filename, "filename"),
324
- format: parseFormat(format),
325
- mount: parseOptionalStringBoolean(mount),
326
- shared: parseOptionalBoolean(shared),
327
- user: parseOptionalString(user),
328
- };
329
- }
330
- case "none": {
331
- const { shared, mount, user } = drive;
332
- const filename = parseRequiredString(drive.filename, "filename");
333
- const format = getDriveFormat(filename);
334
- return {
335
- builder: "none",
336
- filename,
337
- format,
338
- mount: parseOptionalStringBoolean(mount),
339
- shared: parseOptionalBoolean(shared),
340
- user: parseOptionalString(user),
341
- };
342
- }
343
- }
344
- };
345
- const parseDrives = (config) => {
346
- // load drives from configuration
347
- const drives = Object.entries(config ?? {}).reduce((acc, [name, drive]) => {
348
- acc[name] = parseDrive(drive);
349
- return acc;
350
- }, {});
351
- // check if there is a root drive
352
- const hasRoot = drives.root !== undefined;
353
- if (!hasRoot) {
354
- // there is no root drive, add a default one
355
- drives.root = defaultRootDriveConfig();
356
- }
357
- return drives;
358
- };
359
- export const parse = (str) => {
360
- const toml = parseToml(str);
361
- const config = {
362
- drives: parseDrives(toml.drives),
363
- machine: parseMachine(toml.machine),
364
- sdk: parseString(toml.sdk, DEFAULT_SDK),
365
- };
366
- return config;
367
- };