ic-mops 1.11.1 → 2.0.0

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 (352) hide show
  1. package/.DS_Store +0 -0
  2. package/.eslintrc.json +7 -7
  3. package/CHANGELOG.md +15 -0
  4. package/api/actors.ts +41 -37
  5. package/api/downloadPackageFiles.ts +75 -61
  6. package/api/getHighestVersion.ts +5 -5
  7. package/api/index.ts +4 -4
  8. package/api/network.ts +19 -21
  9. package/api/resolveVersion.ts +14 -11
  10. package/bin/mops.js +1 -1
  11. package/bun.lock +234 -198
  12. package/bundle/bench/bench-canister.mo +2 -2
  13. package/bundle/bench/user-bench.mo +0 -4
  14. package/bundle/bin/mops.js +1 -1
  15. package/bundle/cli.js +1000 -924
  16. package/bundle/cli.tgz +0 -0
  17. package/bundle/declarations/bench/bench.did +3 -3
  18. package/bundle/declarations/bench/bench.did.d.ts +3 -3
  19. package/bundle/declarations/bench/index.d.ts +3 -3
  20. package/bundle/declarations/bench/index.js +1 -1
  21. package/bundle/declarations/main/index.d.ts +3 -3
  22. package/bundle/declarations/main/index.js +1 -1
  23. package/bundle/declarations/main/main.did +78 -121
  24. package/bundle/declarations/main/main.did.d.ts +48 -98
  25. package/bundle/declarations/main/main.did.js +53 -107
  26. package/bundle/declarations/storage/index.d.ts +3 -3
  27. package/bundle/declarations/storage/index.js +4 -4
  28. package/bundle/declarations/storage/storage.did.d.ts +3 -3
  29. package/bundle/package.json +6 -5
  30. package/bundle/templates/mops-publish.yml +3 -3
  31. package/bundle/templates/mops-test.yml +3 -3
  32. package/bundle-package-json.ts +8 -8
  33. package/cache.ts +80 -65
  34. package/check-requirements.ts +49 -45
  35. package/cli.ts +577 -376
  36. package/commands/add.ts +142 -129
  37. package/commands/available-updates.ts +55 -28
  38. package/commands/bench/bench-canister.mo +114 -108
  39. package/commands/bench/user-bench.mo +6 -6
  40. package/commands/bench-replica.ts +146 -106
  41. package/commands/bench.ts +563 -497
  42. package/commands/build.ts +177 -0
  43. package/commands/bump.ts +68 -57
  44. package/commands/check-candid.ts +24 -0
  45. package/commands/docs-coverage.ts +124 -102
  46. package/commands/docs.ts +118 -108
  47. package/commands/format.ts +171 -155
  48. package/commands/init.ts +301 -275
  49. package/commands/install/install-all.ts +75 -62
  50. package/commands/install/install-dep.ts +43 -28
  51. package/commands/install/install-deps.ts +23 -15
  52. package/commands/install/install-local-dep.ts +42 -34
  53. package/commands/install/install-mops-dep.ts +154 -123
  54. package/commands/install/sync-local-cache.ts +39 -35
  55. package/commands/maintainer.ts +109 -99
  56. package/commands/outdated.ts +31 -18
  57. package/commands/owner.ts +107 -99
  58. package/commands/publish.ts +534 -443
  59. package/commands/remove.ts +119 -89
  60. package/commands/replica.ts +391 -303
  61. package/commands/search.ts +42 -36
  62. package/commands/self.ts +63 -56
  63. package/commands/sources.ts +66 -49
  64. package/commands/sync.ts +92 -75
  65. package/commands/template.ts +145 -102
  66. package/commands/test/mmf1.ts +146 -119
  67. package/commands/test/reporters/compact-reporter.ts +87 -84
  68. package/commands/test/reporters/files-reporter.ts +56 -51
  69. package/commands/test/reporters/reporter.ts +12 -6
  70. package/commands/test/reporters/silent-reporter.ts +58 -59
  71. package/commands/test/reporters/verbose-reporter.ts +66 -54
  72. package/commands/test/test.ts +497 -460
  73. package/commands/test/utils.ts +85 -6
  74. package/commands/toolchain/index.ts +363 -322
  75. package/commands/toolchain/moc.ts +78 -50
  76. package/commands/toolchain/pocket-ic.ts +41 -34
  77. package/commands/toolchain/toolchain-utils.ts +92 -72
  78. package/commands/toolchain/wasmtime.ts +37 -34
  79. package/commands/update.ts +91 -56
  80. package/commands/user.ts +90 -81
  81. package/commands/watch/deployer.ts +188 -152
  82. package/commands/watch/error-checker.ts +90 -80
  83. package/commands/watch/formatter.ts +72 -60
  84. package/commands/watch/generator.ts +116 -96
  85. package/commands/watch/globMoFiles.ts +13 -13
  86. package/commands/watch/parseDfxJson.ts +63 -57
  87. package/commands/watch/tester.ts +83 -65
  88. package/commands/watch/warning-checker.ts +149 -136
  89. package/commands/watch/watch.ts +123 -95
  90. package/declarations/bench/bench.did.d.ts +3 -3
  91. package/declarations/bench/index.d.ts +3 -3
  92. package/declarations/bench/index.js +1 -1
  93. package/declarations/main/index.d.ts +3 -3
  94. package/declarations/main/index.js +1 -1
  95. package/declarations/main/main.did.d.ts +3 -3
  96. package/declarations/storage/index.d.ts +3 -3
  97. package/declarations/storage/index.js +4 -4
  98. package/declarations/storage/storage.did.d.ts +3 -3
  99. package/dist/api/actors.d.ts +4 -4
  100. package/dist/api/actors.js +8 -8
  101. package/dist/api/downloadPackageFiles.d.ts +2 -2
  102. package/dist/api/downloadPackageFiles.js +10 -10
  103. package/dist/api/getHighestVersion.js +1 -1
  104. package/dist/api/index.d.ts +4 -4
  105. package/dist/api/index.js +4 -4
  106. package/dist/api/network.js +9 -9
  107. package/dist/api/resolveVersion.js +3 -3
  108. package/dist/bin/mops.js +1 -1
  109. package/dist/bundle-package-json.js +8 -8
  110. package/dist/cache.js +22 -17
  111. package/dist/check-requirements.js +11 -11
  112. package/dist/cli.js +283 -186
  113. package/dist/commands/add.d.ts +1 -1
  114. package/dist/commands/add.js +41 -38
  115. package/dist/commands/available-updates.d.ts +1 -1
  116. package/dist/commands/available-updates.js +32 -14
  117. package/dist/commands/bench/bench-canister.mo +114 -108
  118. package/dist/commands/bench/user-bench.mo +6 -6
  119. package/dist/commands/bench-replica.d.ts +6 -5
  120. package/dist/commands/bench-replica.js +58 -36
  121. package/dist/commands/bench.d.ts +5 -5
  122. package/dist/commands/bench.js +134 -118
  123. package/dist/commands/build.d.ts +7 -0
  124. package/dist/commands/build.js +121 -0
  125. package/dist/commands/bump.js +27 -18
  126. package/dist/commands/check-candid.d.ts +4 -0
  127. package/dist/commands/check-candid.js +15 -0
  128. package/dist/commands/docs-coverage.d.ts +1 -1
  129. package/dist/commands/docs-coverage.js +45 -31
  130. package/dist/commands/docs.d.ts +1 -1
  131. package/dist/commands/docs.js +39 -38
  132. package/dist/commands/format.js +31 -27
  133. package/dist/commands/init.js +102 -92
  134. package/dist/commands/install/install-all.d.ts +2 -2
  135. package/dist/commands/install/install-all.js +23 -21
  136. package/dist/commands/install/install-dep.d.ts +1 -1
  137. package/dist/commands/install/install-dep.js +21 -8
  138. package/dist/commands/install/install-deps.d.ts +1 -1
  139. package/dist/commands/install/install-deps.js +1 -1
  140. package/dist/commands/install/install-local-dep.js +11 -9
  141. package/dist/commands/install/install-mops-dep.d.ts +1 -1
  142. package/dist/commands/install/install-mops-dep.js +32 -27
  143. package/dist/commands/install/sync-local-cache.js +10 -10
  144. package/dist/commands/maintainer.js +21 -21
  145. package/dist/commands/outdated.js +16 -6
  146. package/dist/commands/owner.js +21 -21
  147. package/dist/commands/publish.js +148 -128
  148. package/dist/commands/remove.d.ts +1 -1
  149. package/dist/commands/remove.js +42 -30
  150. package/dist/commands/replica.d.ts +9 -8
  151. package/dist/commands/replica.js +105 -65
  152. package/dist/commands/search.js +15 -13
  153. package/dist/commands/self.js +31 -28
  154. package/dist/commands/sources.d.ts +5 -1
  155. package/dist/commands/sources.js +23 -17
  156. package/dist/commands/sync.d.ts +1 -1
  157. package/dist/commands/sync.js +38 -25
  158. package/dist/commands/template.js +66 -56
  159. package/dist/commands/test/mmf1.d.ts +3 -3
  160. package/dist/commands/test/mmf1.js +33 -31
  161. package/dist/commands/test/reporters/compact-reporter.d.ts +3 -3
  162. package/dist/commands/test/reporters/compact-reporter.js +19 -15
  163. package/dist/commands/test/reporters/files-reporter.d.ts +3 -3
  164. package/dist/commands/test/reporters/files-reporter.js +18 -14
  165. package/dist/commands/test/reporters/reporter.d.ts +2 -2
  166. package/dist/commands/test/reporters/silent-reporter.d.ts +3 -3
  167. package/dist/commands/test/reporters/silent-reporter.js +4 -4
  168. package/dist/commands/test/reporters/verbose-reporter.d.ts +3 -3
  169. package/dist/commands/test/reporters/verbose-reporter.js +17 -13
  170. package/dist/commands/test/test.d.ts +4 -4
  171. package/dist/commands/test/test.js +151 -181
  172. package/dist/commands/test/utils.d.ts +6 -0
  173. package/dist/commands/test/utils.js +63 -2
  174. package/dist/commands/toolchain/index.d.ts +1 -1
  175. package/dist/commands/toolchain/index.js +81 -69
  176. package/dist/commands/toolchain/moc.d.ts +1 -1
  177. package/dist/commands/toolchain/moc.js +48 -24
  178. package/dist/commands/toolchain/pocket-ic.js +12 -12
  179. package/dist/commands/toolchain/toolchain-utils.d.ts +2 -0
  180. package/dist/commands/toolchain/toolchain-utils.js +32 -23
  181. package/dist/commands/toolchain/wasmtime.js +11 -11
  182. package/dist/commands/update.d.ts +1 -1
  183. package/dist/commands/update.js +30 -12
  184. package/dist/commands/user.js +31 -28
  185. package/dist/commands/watch/deployer.d.ts +4 -4
  186. package/dist/commands/watch/deployer.js +45 -36
  187. package/dist/commands/watch/error-checker.d.ts +2 -2
  188. package/dist/commands/watch/error-checker.js +27 -27
  189. package/dist/commands/watch/formatter.d.ts +4 -4
  190. package/dist/commands/watch/formatter.js +17 -17
  191. package/dist/commands/watch/generator.d.ts +3 -3
  192. package/dist/commands/watch/generator.js +28 -23
  193. package/dist/commands/watch/globMoFiles.js +8 -8
  194. package/dist/commands/watch/parseDfxJson.d.ts +2 -2
  195. package/dist/commands/watch/parseDfxJson.js +9 -9
  196. package/dist/commands/watch/tester.d.ts +4 -4
  197. package/dist/commands/watch/tester.js +23 -21
  198. package/dist/commands/watch/warning-checker.d.ts +3 -3
  199. package/dist/commands/watch/warning-checker.js +36 -36
  200. package/dist/commands/watch/watch.js +45 -32
  201. package/dist/declarations/bench/bench.did.d.ts +3 -3
  202. package/dist/declarations/bench/index.d.ts +3 -3
  203. package/dist/declarations/bench/index.js +1 -1
  204. package/dist/declarations/main/index.d.ts +3 -3
  205. package/dist/declarations/main/index.js +1 -1
  206. package/dist/declarations/main/main.did.d.ts +3 -3
  207. package/dist/declarations/storage/index.d.ts +3 -3
  208. package/dist/declarations/storage/index.js +4 -4
  209. package/dist/declarations/storage/storage.did.d.ts +3 -3
  210. package/dist/environments/nodejs/cli.d.ts +1 -0
  211. package/dist/environments/nodejs/cli.js +4 -0
  212. package/dist/environments/web/cli.d.ts +1 -0
  213. package/dist/environments/web/cli.js +4 -0
  214. package/dist/error.d.ts +1 -0
  215. package/dist/error.js +5 -0
  216. package/dist/fix-dist.js +5 -5
  217. package/dist/helpers/find-changelog-entry.js +8 -5
  218. package/dist/helpers/get-dep-name.d.ts +1 -0
  219. package/dist/helpers/get-dep-name.js +4 -1
  220. package/dist/helpers/get-dfx-version.js +4 -4
  221. package/dist/helpers/get-moc-path.js +8 -7
  222. package/dist/helpers/get-moc-version.js +10 -7
  223. package/dist/helpers/get-package-id.js +2 -2
  224. package/dist/helpers/is-candid-compatible.d.ts +1 -0
  225. package/dist/helpers/is-candid-compatible.js +20 -0
  226. package/dist/integrity.d.ts +1 -1
  227. package/dist/integrity.js +47 -38
  228. package/dist/jest.config.d.ts +11 -0
  229. package/dist/jest.config.js +14 -0
  230. package/dist/mops.d.ts +6 -6
  231. package/dist/mops.js +87 -80
  232. package/dist/notify-installs.js +4 -4
  233. package/dist/package.json +11 -10
  234. package/dist/pem.d.ts +3 -3
  235. package/dist/pem.js +20 -12
  236. package/dist/release-cli.js +20 -20
  237. package/dist/resolve-packages.d.ts +1 -1
  238. package/dist/resolve-packages.js +52 -36
  239. package/dist/templates/mops-publish.yml +3 -3
  240. package/dist/templates/mops-test.yml +3 -3
  241. package/dist/templates/src/lib.mo +13 -13
  242. package/dist/templates/test/lib.test.mo +2 -2
  243. package/dist/templates.js +1 -1
  244. package/dist/tests/cli.test.d.ts +1 -0
  245. package/dist/tests/cli.test.js +63 -0
  246. package/dist/types.d.ts +14 -4
  247. package/dist/vessel.d.ts +2 -2
  248. package/dist/vessel.js +41 -34
  249. package/dist/wasm/pkg/bundler/package.json +20 -0
  250. package/dist/wasm/pkg/bundler/wasm.d.ts +3 -0
  251. package/dist/wasm/pkg/bundler/wasm.js +5 -0
  252. package/dist/wasm/pkg/bundler/wasm_bg.js +93 -0
  253. package/dist/wasm/pkg/bundler/wasm_bg.wasm +0 -0
  254. package/dist/wasm/pkg/bundler/wasm_bg.wasm.d.ts +8 -0
  255. package/dist/wasm/pkg/nodejs/package.json +14 -0
  256. package/dist/wasm/pkg/nodejs/wasm.d.ts +3 -0
  257. package/dist/wasm/pkg/nodejs/wasm.js +98 -0
  258. package/dist/wasm/pkg/nodejs/wasm_bg.wasm +0 -0
  259. package/dist/wasm/pkg/nodejs/wasm_bg.wasm.d.ts +8 -0
  260. package/dist/wasm/pkg/web/package.json +18 -0
  261. package/dist/wasm/pkg/web/wasm.d.ts +35 -0
  262. package/dist/wasm/pkg/web/wasm.js +191 -0
  263. package/dist/wasm/pkg/web/wasm_bg.wasm +0 -0
  264. package/dist/wasm/pkg/web/wasm_bg.wasm.d.ts +8 -0
  265. package/dist/wasm.d.ts +5 -0
  266. package/dist/wasm.js +10 -0
  267. package/environments/nodejs/cli.ts +6 -0
  268. package/environments/web/cli.ts +6 -0
  269. package/error.ts +6 -0
  270. package/fix-dist.ts +5 -5
  271. package/global.d.ts +3 -3
  272. package/helpers/find-changelog-entry.ts +26 -23
  273. package/helpers/get-dep-name.ts +7 -3
  274. package/helpers/get-dfx-version.ts +8 -9
  275. package/helpers/get-moc-path.ts +25 -26
  276. package/helpers/get-moc-version.ts +21 -19
  277. package/helpers/get-package-id.ts +4 -4
  278. package/helpers/is-candid-compatible.ts +22 -0
  279. package/integrity.ts +270 -236
  280. package/jest.config.js +14 -0
  281. package/mops.ts +238 -215
  282. package/notify-installs.ts +16 -17
  283. package/package.json +21 -15
  284. package/parallel.ts +28 -24
  285. package/pem.ts +55 -47
  286. package/release-cli.ts +73 -39
  287. package/resolve-packages.ts +231 -189
  288. package/templates/mops-publish.yml +3 -3
  289. package/templates/mops-test.yml +3 -3
  290. package/templates/src/lib.mo +13 -13
  291. package/templates/test/lib.test.mo +2 -2
  292. package/templates.ts +4 -4
  293. package/tests/__snapshots__/cli.test.ts.snap +202 -0
  294. package/tests/build/error/candid/bar.did +3 -0
  295. package/tests/build/error/dfx.json +12 -0
  296. package/tests/build/error/mops.toml +9 -0
  297. package/tests/build/error/src/Bar.mo +5 -0
  298. package/tests/build/error/src/Foo.mo +5 -0
  299. package/tests/build/success/.dfx/local/canister_ids.json +17 -0
  300. package/tests/build/success/.dfx/local/canisters/bar/bar.did +3 -0
  301. package/tests/build/success/.dfx/local/canisters/bar/bar.most +4 -0
  302. package/tests/build/success/.dfx/local/canisters/bar/bar.wasm +0 -0
  303. package/tests/build/success/.dfx/local/canisters/bar/constructor.did +3 -0
  304. package/tests/build/success/.dfx/local/canisters/bar/index.js +42 -0
  305. package/tests/build/success/.dfx/local/canisters/bar/init_args.txt +1 -0
  306. package/tests/build/success/.dfx/local/canisters/bar/service.did +3 -0
  307. package/tests/build/success/.dfx/local/canisters/bar/service.did.d.ts +7 -0
  308. package/tests/build/success/.dfx/local/canisters/bar/service.did.js +4 -0
  309. package/tests/build/success/.dfx/local/canisters/foo/constructor.did +3 -0
  310. package/tests/build/success/.dfx/local/canisters/foo/foo.did +3 -0
  311. package/tests/build/success/.dfx/local/canisters/foo/foo.most +4 -0
  312. package/tests/build/success/.dfx/local/canisters/foo/foo.wasm +0 -0
  313. package/tests/build/success/.dfx/local/canisters/foo/index.js +42 -0
  314. package/tests/build/success/.dfx/local/canisters/foo/init_args.txt +1 -0
  315. package/tests/build/success/.dfx/local/canisters/foo/service.did +3 -0
  316. package/tests/build/success/.dfx/local/canisters/foo/service.did.d.ts +7 -0
  317. package/tests/build/success/.dfx/local/canisters/foo/service.did.js +4 -0
  318. package/tests/build/success/.dfx/local/lsp/ucwa4-rx777-77774-qaada-cai.did +3 -0
  319. package/tests/build/success/.dfx/local/lsp/ulvla-h7777-77774-qaacq-cai.did +3 -0
  320. package/tests/build/success/.dfx/local/network-id +4 -0
  321. package/tests/build/success/candid/bar.did +3 -0
  322. package/tests/build/success/dfx.json +12 -0
  323. package/tests/build/success/mops.toml +9 -0
  324. package/tests/build/success/src/Bar.mo +5 -0
  325. package/tests/build/success/src/Foo.mo +5 -0
  326. package/tests/check-candid/a.did +3 -0
  327. package/tests/check-candid/b.did +5 -0
  328. package/tests/check-candid/c.did +3 -0
  329. package/tests/cli.test.ts +82 -0
  330. package/tsconfig.json +26 -19
  331. package/types.ts +41 -31
  332. package/vessel.ts +219 -187
  333. package/wasm/Cargo.lock +1475 -0
  334. package/wasm/Cargo.toml +28 -0
  335. package/wasm/pkg/bundler/package.json +20 -0
  336. package/wasm/pkg/bundler/wasm.d.ts +3 -0
  337. package/wasm/pkg/bundler/wasm.js +5 -0
  338. package/wasm/pkg/bundler/wasm_bg.js +93 -0
  339. package/wasm/pkg/bundler/wasm_bg.wasm +0 -0
  340. package/wasm/pkg/bundler/wasm_bg.wasm.d.ts +8 -0
  341. package/wasm/pkg/nodejs/package.json +14 -0
  342. package/wasm/pkg/nodejs/wasm.d.ts +3 -0
  343. package/wasm/pkg/nodejs/wasm.js +98 -0
  344. package/wasm/pkg/nodejs/wasm_bg.wasm +0 -0
  345. package/wasm/pkg/nodejs/wasm_bg.wasm.d.ts +8 -0
  346. package/wasm/pkg/web/package.json +18 -0
  347. package/wasm/pkg/web/wasm.d.ts +35 -0
  348. package/wasm/pkg/web/wasm.js +191 -0
  349. package/wasm/pkg/web/wasm_bg.wasm +0 -0
  350. package/wasm/pkg/web/wasm_bg.wasm.d.ts +8 -0
  351. package/wasm/src/lib.rs +17 -0
  352. package/wasm.ts +16 -0
package/dist/cli.js CHANGED
@@ -1,58 +1,69 @@
1
- import process from 'node:process';
2
- import fs from 'node:fs';
3
- import events from 'node:events';
4
- import { Command, Argument, Option } from 'commander';
5
- import { init } from './commands/init.js';
6
- import { publish } from './commands/publish.js';
7
- import { sources } from './commands/sources.js';
8
- import { checkApiCompatibility, setNetwork, apiVersion, checkConfigFile, getNetworkFile, version } from './mops.js';
9
- import { getNetwork } from './api/network.js';
10
- import { installAll } from './commands/install/install-all.js';
11
- import { search } from './commands/search.js';
12
- import { add } from './commands/add.js';
13
- import { cacheSize, cleanCache, show } from './cache.js';
14
- import { test } from './commands/test/test.js';
15
- import { template } from './commands/template.js';
16
- import { remove } from './commands/remove.js';
17
- import { importPem, getPrincipal, getUserProp, setUserProp } from './commands/user.js';
18
- import { bump } from './commands/bump.js';
19
- import { sync } from './commands/sync.js';
20
- import { outdated } from './commands/outdated.js';
21
- import { update } from './commands/update.js';
22
- import { bench } from './commands/bench.js';
23
- import { toolchain } from './commands/toolchain/index.js';
24
- import * as self from './commands/self.js';
25
- import { resolvePackages } from './resolve-packages.js';
26
- import { watch } from './commands/watch/watch.js';
27
- import { addOwner, printOwners, removeOwner } from './commands/owner.js';
28
- import { addMaintainer, printMaintainers, removeMaintainer } from './commands/maintainer.js';
29
- import { format } from './commands/format.js';
30
- import { docs } from './commands/docs.js';
31
- import { docsCoverage } from './commands/docs-coverage.js';
1
+ import { Argument, Command, Option } from "commander";
2
+ import events from "node:events";
3
+ import fs from "node:fs";
4
+ import process from "node:process";
5
+ import { resolve } from "node:path";
6
+ import { getNetwork } from "./api/network.js";
7
+ import { cacheSize, cleanCache, show } from "./cache.js";
8
+ import { add } from "./commands/add.js";
9
+ import { bench } from "./commands/bench.js";
10
+ import { build, DEFAULT_BUILD_OUTPUT_DIR } from "./commands/build.js";
11
+ import { bump } from "./commands/bump.js";
12
+ import { checkCandid } from "./commands/check-candid.js";
13
+ import { docsCoverage } from "./commands/docs-coverage.js";
14
+ import { docs } from "./commands/docs.js";
15
+ import { format } from "./commands/format.js";
16
+ import { init } from "./commands/init.js";
17
+ import { installAll } from "./commands/install/install-all.js";
18
+ import { addMaintainer, printMaintainers, removeMaintainer, } from "./commands/maintainer.js";
19
+ import { outdated } from "./commands/outdated.js";
20
+ import { addOwner, printOwners, removeOwner } from "./commands/owner.js";
21
+ import { publish } from "./commands/publish.js";
22
+ import { remove } from "./commands/remove.js";
23
+ import { search } from "./commands/search.js";
24
+ import * as self from "./commands/self.js";
25
+ import { sources } from "./commands/sources.js";
26
+ import { sync } from "./commands/sync.js";
27
+ import { template } from "./commands/template.js";
28
+ import { test } from "./commands/test/test.js";
29
+ import { toolchain } from "./commands/toolchain/index.js";
30
+ import { update } from "./commands/update.js";
31
+ import { getPrincipal, getUserProp, importPem, setUserProp, } from "./commands/user.js";
32
+ import { watch } from "./commands/watch/watch.js";
33
+ import { apiVersion, checkApiCompatibility, checkConfigFile, getNetworkFile, setNetwork, version, } from "./mops.js";
34
+ import { resolvePackages } from "./resolve-packages.js";
32
35
  events.setMaxListeners(20);
36
+ // Change working directory for `npm run mops`
37
+ let cwd = process.env["MOPS_CWD"];
38
+ if (cwd) {
39
+ process.chdir(resolve(cwd));
40
+ }
33
41
  let networkFile = getNetworkFile();
34
42
  if (fs.existsSync(networkFile)) {
35
- globalThis.MOPS_NETWORK = fs.readFileSync(networkFile).toString() || 'ic';
43
+ globalThis.MOPS_NETWORK = fs.readFileSync(networkFile).toString() || "ic";
36
44
  }
37
45
  let program = new Command();
38
- program.name('mops');
46
+ program.name("mops");
39
47
  // --version
40
- program.version(`CLI ${version()}\nAPI ${apiVersion}`, '-v --version');
48
+ program.version(`CLI ${version()}\nAPI ${apiVersion}`, "-v --version");
41
49
  // init
42
50
  program
43
- .command('init')
44
- .description('Initialize a new project or package in the current directory')
45
- .option('-y, --yes', 'Accept all defaults')
51
+ .command("init")
52
+ .description("Initialize a new project or package in the current directory")
53
+ .option("-y, --yes", "Accept all defaults")
46
54
  .action(async (options) => {
47
55
  await init(options);
48
56
  });
49
57
  // add
50
58
  program
51
- .command('add <pkg>')
52
- .description('Install the package and save it to mops.toml')
53
- .option('--dev', 'Add to [dev-dependencies] section')
54
- .option('--verbose')
55
- .addOption(new Option('--lock <action>', 'Lockfile action').choices(['update', 'ignore']))
59
+ .command("add <pkg>")
60
+ .description("Install the package and save it to mops.toml")
61
+ .option("--dev", "Add to [dev-dependencies] section")
62
+ .option("--verbose")
63
+ .addOption(new Option("--lock <action>", "Lockfile action").choices([
64
+ "update",
65
+ "ignore",
66
+ ]))
56
67
  .action(async (pkg, options) => {
57
68
  if (!checkConfigFile()) {
58
69
  process.exit(1);
@@ -61,13 +72,16 @@ program
61
72
  });
62
73
  // remove
63
74
  program
64
- .command('remove <pkg>')
65
- .alias('rm')
66
- .description('Remove package and update mops.toml')
67
- .option('--dev', 'Remove from dev-dependencies instead of dependencies')
68
- .option('--verbose', 'Show more information')
69
- .option('--dry-run', 'Do not actually remove anything')
70
- .addOption(new Option('--lock <action>', 'Lockfile action').choices(['update', 'ignore']))
75
+ .command("remove <pkg>")
76
+ .alias("rm")
77
+ .description("Remove package and update mops.toml")
78
+ .option("--dev", "Remove from dev-dependencies instead of dependencies")
79
+ .option("--verbose", "Show more information")
80
+ .option("--dry-run", "Do not actually remove anything")
81
+ .addOption(new Option("--lock <action>", "Lockfile action").choices([
82
+ "update",
83
+ "ignore",
84
+ ]))
71
85
  .action(async (pkg, options) => {
72
86
  if (!checkConfigFile()) {
73
87
  process.exit(1);
@@ -76,12 +90,16 @@ program
76
90
  });
77
91
  // install
78
92
  program
79
- .command('install')
80
- .alias('i')
81
- .description('Install all dependencies specified in mops.toml')
82
- .option('--no-toolchain', 'Do not install toolchain')
83
- .option('--verbose')
84
- .addOption(new Option('--lock <action>', 'Lockfile action').choices(['check', 'update', 'ignore']))
93
+ .command("install")
94
+ .alias("i")
95
+ .description("Install all dependencies specified in mops.toml")
96
+ .option("--no-toolchain", "Do not install toolchain")
97
+ .option("--verbose")
98
+ .addOption(new Option("--lock <action>", "Lockfile action").choices([
99
+ "check",
100
+ "update",
101
+ "ignore",
102
+ ]))
85
103
  .action(async (options) => {
86
104
  if (!checkConfigFile()) {
87
105
  process.exit(1);
@@ -98,19 +116,19 @@ program
98
116
  await toolchain.installAll(options);
99
117
  }
100
118
  // check conflicts
101
- await resolvePackages({ conflicts: 'warning' });
119
+ await resolvePackages({ conflicts: "warning" });
102
120
  if (!ok) {
103
121
  process.exit(1);
104
122
  }
105
123
  });
106
124
  // publish
107
125
  program
108
- .command('publish')
109
- .description('Publish package to the mops registry')
110
- .option('--no-docs', 'Do not generate docs')
111
- .option('--no-test', 'Do not run tests')
112
- .option('--no-bench', 'Do not run benchmarks')
113
- .option('--verbose')
126
+ .command("publish")
127
+ .description("Publish package to the mops registry")
128
+ .option("--no-docs", "Do not generate docs")
129
+ .option("--no-test", "Do not run tests")
130
+ .option("--no-bench", "Do not run benchmarks")
131
+ .option("--verbose")
114
132
  .action(async (options) => {
115
133
  if (!checkConfigFile()) {
116
134
  process.exit(1);
@@ -122,96 +140,153 @@ program
122
140
  });
123
141
  // set-network
124
142
  program
125
- .command('set-network <network>')
126
- .alias('sn')
127
- .description('Set network local|staging|ic')
143
+ .command("set-network <network>")
144
+ .alias("sn")
145
+ .description("Set network local|staging|ic")
128
146
  .action(async (network) => {
129
147
  await setNetwork(network);
130
148
  console.log(`Selected '${network}' network`);
131
149
  });
132
150
  // get-network
133
151
  program
134
- .command('get-network')
135
- .alias('gn')
136
- .description('Get network')
152
+ .command("get-network")
153
+ .alias("gn")
154
+ .description("Get network")
137
155
  .action(async () => {
138
156
  console.log(getNetwork());
139
157
  });
140
158
  // sources
141
159
  program
142
- .command('sources')
143
- .description('for dfx packtool')
144
- .option('--no-install', 'Do not install dependencies before running sources')
145
- .addOption(new Option('--conflicts <action>', 'What to do with dependency version conflicts').choices(['ignore', 'warning', 'error']).default('warning'))
160
+ .command("sources")
161
+ .description("for dfx packtool")
162
+ .option("--no-install", "Do not install dependencies before running sources")
163
+ .addOption(new Option("--conflicts <action>", "What to do with dependency version conflicts")
164
+ .choices(["ignore", "warning", "error"])
165
+ .default("warning"))
146
166
  .action(async (options) => {
147
167
  if (!checkConfigFile()) {
148
168
  process.exit(1);
149
169
  }
150
170
  if (options.install) {
151
- await installAll({ silent: true, lock: 'ignore', threads: 6, installFromLockFile: true });
171
+ await installAll({
172
+ silent: true,
173
+ lock: "ignore",
174
+ threads: 6,
175
+ installFromLockFile: true,
176
+ });
152
177
  }
153
178
  await toolchain.ensureToolchainInited({ strict: false });
154
179
  let sourcesArr = await sources(options);
155
- console.log(sourcesArr.join('\n'));
180
+ console.log(sourcesArr.join("\n"));
156
181
  });
157
182
  // search
158
183
  program
159
- .command('search <text>')
160
- .description('Search for packages')
184
+ .command("search <text>")
185
+ .description("Search for packages")
161
186
  .action(async (text) => {
162
187
  await search(text);
163
188
  });
164
189
  // cache
165
190
  program
166
- .command('cache')
167
- .description('Manage cache')
168
- .addArgument(new Argument('<sub>').choices(['size', 'clean', 'show']))
191
+ .command("cache")
192
+ .description("Manage cache")
193
+ .addArgument(new Argument("<sub>").choices(["size", "clean", "show"]))
169
194
  .action(async (sub) => {
170
- if (sub == 'clean') {
195
+ if (sub == "clean") {
171
196
  await cleanCache();
172
- console.log('Cache cleaned');
197
+ console.log("Cache cleaned");
173
198
  }
174
- else if (sub == 'size') {
199
+ else if (sub == "size") {
175
200
  let size = await cacheSize();
176
- console.log('Cache size is ' + size);
201
+ console.log("Cache size is " + size);
177
202
  }
178
- else if (sub == 'show') {
203
+ else if (sub == "show") {
179
204
  console.log(show());
180
205
  }
181
206
  });
207
+ // build
208
+ program
209
+ .command("build [canisters...]")
210
+ .description("Build a canister")
211
+ .addOption(new Option("--verbose", "Verbose console output"))
212
+ .addOption(new Option("--output, -o <output>", "Output directory").default(DEFAULT_BUILD_OUTPUT_DIR))
213
+ .allowUnknownOption(true) // TODO: restrict unknown before "--"
214
+ .action(async (canisters, options, command) => {
215
+ checkConfigFile(true);
216
+ const extraArgsIndex = command.args.indexOf("--");
217
+ await installAll({
218
+ silent: true,
219
+ lock: "ignore",
220
+ installFromLockFile: true,
221
+ });
222
+ await build(canisters.length ? canisters : undefined, {
223
+ ...options,
224
+ extraArgs: extraArgsIndex !== -1 ? command.args.slice(extraArgsIndex + 1) : [],
225
+ });
226
+ });
227
+ // check-candid
228
+ program
229
+ .command("check-candid <new-candid> <original-candid>")
230
+ .description("Check Candid interface compatibility between two Candid files")
231
+ .action(async (newCandid, originalCandid) => {
232
+ checkConfigFile(true);
233
+ await installAll({
234
+ silent: true,
235
+ lock: "ignore",
236
+ installFromLockFile: true,
237
+ });
238
+ await checkCandid(newCandid, originalCandid);
239
+ });
182
240
  // test
183
241
  program
184
- .command('test [filter]')
185
- .description('Run tests')
186
- .addOption(new Option('-r, --reporter <reporter>', 'Test reporter').choices(['verbose', 'compact', 'files', 'silent']))
187
- .addOption(new Option('--mode <mode>', 'Test mode').choices(['interpreter', 'wasi', 'replica']).default('interpreter'))
188
- .addOption(new Option('--replica <replica>', 'Which replica to use to run tests in replica mode').choices(['dfx', 'pocket-ic']))
189
- .option('-w, --watch', 'Enable watch mode')
190
- .option('--verbose', 'Verbose output')
242
+ .command("test [filter]")
243
+ .description("Run tests")
244
+ .addOption(new Option("-r, --reporter <reporter>", "Test reporter").choices([
245
+ "verbose",
246
+ "compact",
247
+ "files",
248
+ "silent",
249
+ ]))
250
+ .addOption(new Option("--mode <mode>", "Test mode")
251
+ .choices(["interpreter", "wasi", "replica"])
252
+ .default("interpreter"))
253
+ .addOption(new Option("--replica <replica>", "Which replica to use to run tests in replica mode").choices(["dfx", "pocket-ic"]))
254
+ .option("-w, --watch", "Enable watch mode")
255
+ .option("--verbose", "Verbose output")
191
256
  .action(async (filter, options) => {
192
257
  checkConfigFile(true);
193
- await installAll({ silent: true, lock: 'ignore', installFromLockFile: true });
258
+ await installAll({
259
+ silent: true,
260
+ lock: "ignore",
261
+ installFromLockFile: true,
262
+ });
194
263
  await test(filter, options);
195
264
  });
196
265
  // bench
197
266
  program
198
- .command('bench [filter]')
199
- .description('Run benchmarks')
200
- .addOption(new Option('--replica <replica>', 'Which replica to use to run benchmarks').choices(['dfx', 'pocket-ic']))
201
- .addOption(new Option('--gc <gc>', 'Garbage collector').choices(['copying', 'compacting', 'generational', 'incremental']).default('copying'))
202
- .addOption(new Option('--save', 'Save benchmark results to .bench/<filename>.json'))
203
- .addOption(new Option('--compare', 'Run benchmark and compare results with .bench/<filename>.json'))
267
+ .command("bench [filter]")
268
+ .description("Run benchmarks")
269
+ .addOption(new Option("--replica <replica>", "Which replica to use to run benchmarks").choices(["dfx", "pocket-ic"]))
270
+ .addOption(new Option("--gc <gc>", "Garbage collector")
271
+ .choices(["copying", "compacting", "generational", "incremental"])
272
+ .default("copying"))
273
+ .addOption(new Option("--save", "Save benchmark results to .bench/<filename>.json"))
274
+ .addOption(new Option("--compare", "Run benchmark and compare results with .bench/<filename>.json"))
204
275
  // .addOption(new Option('--force-gc', 'Force GC'))
205
- .addOption(new Option('--verbose', 'Show more information'))
276
+ .addOption(new Option("--verbose", "Show more information"))
206
277
  .action(async (filter, options) => {
207
278
  checkConfigFile(true);
208
- await installAll({ silent: true, lock: 'ignore', installFromLockFile: true });
279
+ await installAll({
280
+ silent: true,
281
+ lock: "ignore",
282
+ installFromLockFile: true,
283
+ });
209
284
  await bench(filter, options);
210
285
  });
211
286
  // template
212
287
  program
213
- .command('template')
214
- .description('Apply template')
288
+ .command("template")
289
+ .description("Apply template")
215
290
  .action(async () => {
216
291
  if (!checkConfigFile()) {
217
292
  process.exit(1);
@@ -219,142 +294,160 @@ program
219
294
  await template();
220
295
  });
221
296
  // mops user *
222
- const userCommand = new Command('user').description('User management');
297
+ const userCommand = new Command("user").description("User management");
223
298
  // user get-principal
224
299
  userCommand
225
- .command('get-principal')
226
- .description('Print your principal')
300
+ .command("get-principal")
301
+ .description("Print your principal")
227
302
  .action(async () => {
228
303
  await getPrincipal();
229
304
  });
230
305
  // user import
231
306
  userCommand
232
- .command('import <data>')
233
- .description('Import .pem file data to use as identity')
234
- .addOption(new Option('--no-encrypt', 'Do not ask for a password to encrypt identity'))
307
+ .command("import <data>")
308
+ .description("Import .pem file data to use as identity")
309
+ .addOption(new Option("--no-encrypt", "Do not ask for a password to encrypt identity"))
235
310
  .action(async (data, options) => {
236
311
  await importPem(data, options);
237
312
  await getPrincipal();
238
313
  });
239
314
  // user set <prop> <value>
240
315
  userCommand
241
- .command('set')
242
- .addArgument(new Argument('<prop>').choices(['name', 'site', 'email', 'github', 'twitter']))
243
- .addArgument(new Argument('<value>'))
244
- .description('Set user property')
316
+ .command("set")
317
+ .addArgument(new Argument("<prop>").choices([
318
+ "name",
319
+ "site",
320
+ "email",
321
+ "github",
322
+ "twitter",
323
+ ]))
324
+ .addArgument(new Argument("<value>"))
325
+ .description("Set user property")
245
326
  .action(async (prop, value) => {
246
327
  await setUserProp(prop, value);
247
328
  });
248
329
  // user get <prop>
249
330
  userCommand
250
- .command('get')
251
- .addArgument(new Argument('<prop>').choices(['name', 'site', 'email', 'github', 'twitter']))
252
- .description('Get user property')
331
+ .command("get")
332
+ .addArgument(new Argument("<prop>").choices([
333
+ "name",
334
+ "site",
335
+ "email",
336
+ "github",
337
+ "twitter",
338
+ ]))
339
+ .description("Get user property")
253
340
  .action(async (prop) => {
254
341
  await getUserProp(prop);
255
342
  });
256
343
  program.addCommand(userCommand);
257
344
  // mops owner *
258
- const ownerCommand = new Command('owner').description('Package owner management');
345
+ const ownerCommand = new Command("owner").description("Package owner management");
259
346
  // mops owner list
260
347
  ownerCommand
261
- .command('list')
262
- .description('List package owners')
348
+ .command("list")
349
+ .description("List package owners")
263
350
  .action(async () => {
264
351
  await printOwners();
265
352
  });
266
353
  // mops owner add
267
354
  ownerCommand
268
- .command('add <principal>')
269
- .description('Add package owner')
270
- .addOption(new Option('--yes', 'Do not ask for confirmation'))
355
+ .command("add <principal>")
356
+ .description("Add package owner")
357
+ .addOption(new Option("--yes", "Do not ask for confirmation"))
271
358
  .action(async (data, options) => {
272
359
  await addOwner(data, options.yes);
273
360
  });
274
361
  // mops owner remove
275
362
  ownerCommand
276
- .command('remove <principal>')
277
- .description('Remove package owner')
278
- .addOption(new Option('--yes', 'Do not ask for confirmation'))
363
+ .command("remove <principal>")
364
+ .description("Remove package owner")
365
+ .addOption(new Option("--yes", "Do not ask for confirmation"))
279
366
  .action(async (data, options) => {
280
367
  await removeOwner(data, options.yes);
281
368
  });
282
369
  program.addCommand(ownerCommand);
283
370
  // mops maintainer *
284
- const maintainerCommand = new Command('maintainer').description('Package maintainer management');
371
+ const maintainerCommand = new Command("maintainer").description("Package maintainer management");
285
372
  // mops maintainer list
286
373
  maintainerCommand
287
- .command('list')
288
- .description('List package maintainers')
374
+ .command("list")
375
+ .description("List package maintainers")
289
376
  .action(async () => {
290
377
  await printMaintainers();
291
378
  });
292
379
  // mops maintainer add
293
380
  maintainerCommand
294
- .command('add <principal>')
295
- .description('Add package maintainer')
296
- .addOption(new Option('--yes', 'Do not ask for confirmation'))
381
+ .command("add <principal>")
382
+ .description("Add package maintainer")
383
+ .addOption(new Option("--yes", "Do not ask for confirmation"))
297
384
  .action(async (data, options) => {
298
385
  await addMaintainer(data, options.yes);
299
386
  });
300
387
  // mops maintainer remove
301
388
  maintainerCommand
302
- .command('remove <principal>')
303
- .description('Remove package maintainer')
304
- .addOption(new Option('--yes', 'Do not ask for confirmation'))
389
+ .command("remove <principal>")
390
+ .description("Remove package maintainer")
391
+ .addOption(new Option("--yes", "Do not ask for confirmation"))
305
392
  .action(async (data, options) => {
306
393
  await removeMaintainer(data, options.yes);
307
394
  });
308
395
  program.addCommand(maintainerCommand);
309
396
  // bump
310
397
  program
311
- .command('bump [major|minor|patch]')
312
- .description('Bump current package version')
398
+ .command("bump [major|minor|patch]")
399
+ .description("Bump current package version")
313
400
  .action(async (part) => {
314
401
  await bump(part);
315
402
  });
316
403
  // sync
317
404
  program
318
- .command('sync')
319
- .description('Add missing packages and remove unused packages')
320
- .addOption(new Option('--lock <action>', 'Lockfile action').choices(['update', 'ignore']))
405
+ .command("sync")
406
+ .description("Add missing packages and remove unused packages")
407
+ .addOption(new Option("--lock <action>", "Lockfile action").choices([
408
+ "update",
409
+ "ignore",
410
+ ]))
321
411
  .action(async (options) => {
322
412
  await sync(options);
323
413
  });
324
414
  // outdated
325
415
  program
326
- .command('outdated')
327
- .description('Print outdated dependencies specified in mops.toml')
416
+ .command("outdated")
417
+ .description("Print outdated dependencies specified in mops.toml")
328
418
  .action(async () => {
329
419
  await outdated();
330
420
  });
331
421
  // update
332
422
  program
333
- .command('update [pkg]')
334
- .description('Update dependencies specified in mops.toml')
335
- .addOption(new Option('--lock <action>', 'Lockfile action').choices(['update', 'ignore']))
423
+ .command("update [pkg]")
424
+ .description("Update dependencies specified in mops.toml")
425
+ .addOption(new Option("--lock <action>", "Lockfile action").choices([
426
+ "update",
427
+ "ignore",
428
+ ]))
336
429
  .action(async (pkg, options) => {
337
430
  await update(pkg, options);
338
431
  });
339
432
  // toolchain
340
- const toolchainCommand = new Command('toolchain').description('Toolchain management');
433
+ const toolchainCommand = new Command("toolchain").description("Toolchain management");
341
434
  toolchainCommand
342
- .command('init')
343
- .description('One-time initialization of toolchain management')
435
+ .command("init")
436
+ .description("One-time initialization of toolchain management")
344
437
  .action(async () => {
345
438
  await toolchain.init();
346
439
  });
347
440
  toolchainCommand
348
- .command('reset')
349
- .description('Uninstall toolchain management')
441
+ .command("reset")
442
+ .description("Uninstall toolchain management")
350
443
  .action(async () => {
351
444
  await toolchain.init({ reset: true });
352
445
  });
353
446
  toolchainCommand
354
- .command('use')
355
- .description('Install specified tool version and update mops.toml')
356
- .addArgument(new Argument('<tool>').choices(['moc', 'wasmtime', 'pocket-ic']))
357
- .addArgument(new Argument('[version]'))
447
+ .command("use")
448
+ .description("Install specified tool version and update mops.toml")
449
+ .addArgument(new Argument("<tool>").choices(["moc", "wasmtime", "pocket-ic"]))
450
+ .addArgument(new Argument("[version]"))
358
451
  .action(async (tool, version) => {
359
452
  if (!checkConfigFile()) {
360
453
  process.exit(1);
@@ -362,9 +455,9 @@ toolchainCommand
362
455
  await toolchain.use(tool, version);
363
456
  });
364
457
  toolchainCommand
365
- .command('update')
366
- .description('Update specified tool or all tools to the latest version and update mops.toml')
367
- .addArgument(new Argument('[tool]').choices(['moc', 'wasmtime', 'pocket-ic']))
458
+ .command("update")
459
+ .description("Update specified tool or all tools to the latest version and update mops.toml")
460
+ .addArgument(new Argument("[tool]").choices(["moc", "wasmtime", "pocket-ic"]))
368
461
  .action(async (tool) => {
369
462
  if (!checkConfigFile()) {
370
463
  process.exit(1);
@@ -372,50 +465,50 @@ toolchainCommand
372
465
  await toolchain.update(tool);
373
466
  });
374
467
  toolchainCommand
375
- .command('bin')
468
+ .command("bin")
376
469
  .description('Get path to the tool binary\n<tool> can be one of "moc", "wasmtime", "pocket-ic"')
377
- .addArgument(new Argument('<tool>').choices(['moc', 'wasmtime', 'pocket-ic']))
378
- .addOption(new Option('--fallback', 'Fallback to the moc that comes with dfx if moc is not specified in the [toolchain] section'))
470
+ .addArgument(new Argument("<tool>").choices(["moc", "wasmtime", "pocket-ic"]))
471
+ .addOption(new Option("--fallback", "Fallback to the moc that comes with dfx if moc is not specified in the [toolchain] section"))
379
472
  .action(async (tool, options) => {
380
473
  let bin = await toolchain.bin(tool, options);
381
474
  console.log(bin);
382
475
  });
383
476
  program.addCommand(toolchainCommand);
384
477
  // self
385
- const selfCommand = new Command('self').description('Mops CLI management');
478
+ const selfCommand = new Command("self").description("Mops CLI management");
386
479
  selfCommand
387
- .command('update')
388
- .description('Update mops CLI to the latest version')
480
+ .command("update")
481
+ .description("Update mops CLI to the latest version")
389
482
  .action(async () => {
390
483
  await self.update();
391
484
  });
392
485
  selfCommand
393
- .command('uninstall')
394
- .description('Uninstall mops CLI')
486
+ .command("uninstall")
487
+ .description("Uninstall mops CLI")
395
488
  .action(async () => {
396
489
  await self.uninstall();
397
490
  });
398
491
  program.addCommand(selfCommand);
399
492
  // watch
400
493
  program
401
- .command('watch')
402
- .description('Watch *.mo files and check for syntax errors, warnings, run tests, generate declarations and deploy canisters')
403
- .option('-e, --error', 'Check Motoko canisters or *.mo files for syntax errors')
404
- .option('-w, --warning', 'Check Motoko canisters or *.mo files for warnings')
405
- .option('-f, --format', 'Format Motoko code')
406
- .option('-t, --test', 'Run tests')
407
- .option('-g, --generate', 'Generate declarations for Motoko canisters')
408
- .option('-d, --deploy', 'Deploy Motoko canisters')
494
+ .command("watch")
495
+ .description("Watch *.mo files and check for syntax errors, warnings, run tests, generate declarations and deploy canisters")
496
+ .option("-e, --error", "Check Motoko canisters or *.mo files for syntax errors")
497
+ .option("-w, --warning", "Check Motoko canisters or *.mo files for warnings")
498
+ .option("-f, --format", "Format Motoko code")
499
+ .option("-t, --test", "Run tests")
500
+ .option("-g, --generate", "Generate declarations for Motoko canisters")
501
+ .option("-d, --deploy", "Deploy Motoko canisters")
409
502
  .action(async (options) => {
410
503
  checkConfigFile(true);
411
504
  await watch(options);
412
505
  });
413
506
  // format
414
507
  program
415
- .command('format [filter]')
416
- .alias('fmt')
417
- .description('Format Motoko code')
418
- .addOption(new Option('--check', 'Check code formatting (do not change source files)'))
508
+ .command("format [filter]")
509
+ .alias("fmt")
510
+ .description("Format Motoko code")
511
+ .addOption(new Option("--check", "Check code formatting (do not change source files)"))
419
512
  .action(async (filter, options) => {
420
513
  checkConfigFile(true);
421
514
  let { ok } = await format(filter, options);
@@ -424,23 +517,27 @@ program
424
517
  }
425
518
  });
426
519
  // docs
427
- const docsCommand = new Command('docs').description('Documentation management');
520
+ const docsCommand = new Command("docs").description("Documentation management");
428
521
  docsCommand
429
- .command('generate')
430
- .description('Generate documentation for Motoko code')
431
- .addOption(new Option('--source <source>', 'Source directory').default('src'))
432
- .addOption(new Option('--output <output>', 'Output directory').default('docs'))
433
- .addOption(new Option('--format <format>', 'Output format').default('md').choices(['md', 'adoc', 'html']))
522
+ .command("generate")
523
+ .description("Generate documentation for Motoko code")
524
+ .addOption(new Option("--source <source>", "Source directory").default("src"))
525
+ .addOption(new Option("--output, -o <output>", "Output directory").default("docs"))
526
+ .addOption(new Option("--format <format>", "Output format")
527
+ .default("md")
528
+ .choices(["md", "adoc", "html"]))
434
529
  .action(async (options) => {
435
530
  checkConfigFile(true);
436
531
  await docs(options);
437
532
  });
438
533
  docsCommand
439
- .command('coverage')
440
- .description('Documentation coverage report')
441
- .addOption(new Option('-s, --source <source>', 'Source directory (with .mo files)').default('src'))
442
- .addOption(new Option('-r, --reporter <reporter>', 'Coverage reporter').choices(['files', 'compact', 'missing', 'verbose']).default('files'))
443
- .addOption(new Option('-t, --threshold <threshold>', 'Coverage threshold (0-100). If total coverage is below threshold, exit with error code 1').default(70))
534
+ .command("coverage")
535
+ .description("Documentation coverage report")
536
+ .addOption(new Option("-s, --source <source>", "Source directory (with .mo files)").default("src"))
537
+ .addOption(new Option("-r, --reporter <reporter>", "Coverage reporter")
538
+ .choices(["files", "compact", "missing", "verbose"])
539
+ .default("files"))
540
+ .addOption(new Option("-t, --threshold <threshold>", "Coverage threshold (0-100). If total coverage is below threshold, exit with error code 1").default(70))
444
541
  .action(async (options) => {
445
542
  checkConfigFile(true);
446
543
  await docsCoverage(options);