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