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.
- package/.DS_Store +0 -0
- package/.eslintrc.json +7 -7
- package/CHANGELOG.md +15 -0
- package/api/actors.ts +41 -37
- package/api/downloadPackageFiles.ts +75 -61
- package/api/getHighestVersion.ts +5 -5
- package/api/index.ts +4 -4
- package/api/network.ts +19 -21
- package/api/resolveVersion.ts +14 -11
- package/bin/mops.js +1 -1
- package/bun.lock +234 -198
- package/bundle/bench/bench-canister.mo +2 -2
- package/bundle/bench/user-bench.mo +0 -4
- package/bundle/bin/mops.js +1 -1
- package/bundle/cli.js +1000 -924
- package/bundle/cli.tgz +0 -0
- package/bundle/declarations/bench/bench.did +3 -3
- package/bundle/declarations/bench/bench.did.d.ts +3 -3
- package/bundle/declarations/bench/index.d.ts +3 -3
- package/bundle/declarations/bench/index.js +1 -1
- package/bundle/declarations/main/index.d.ts +3 -3
- package/bundle/declarations/main/index.js +1 -1
- package/bundle/declarations/main/main.did +78 -121
- package/bundle/declarations/main/main.did.d.ts +48 -98
- package/bundle/declarations/main/main.did.js +53 -107
- package/bundle/declarations/storage/index.d.ts +3 -3
- package/bundle/declarations/storage/index.js +4 -4
- package/bundle/declarations/storage/storage.did.d.ts +3 -3
- package/bundle/package.json +6 -5
- package/bundle/templates/mops-publish.yml +3 -3
- package/bundle/templates/mops-test.yml +3 -3
- package/bundle-package-json.ts +8 -8
- package/cache.ts +80 -65
- package/check-requirements.ts +49 -45
- package/cli.ts +577 -376
- package/commands/add.ts +142 -129
- package/commands/available-updates.ts +55 -28
- package/commands/bench/bench-canister.mo +114 -108
- package/commands/bench/user-bench.mo +6 -6
- package/commands/bench-replica.ts +146 -106
- package/commands/bench.ts +563 -497
- package/commands/build.ts +177 -0
- package/commands/bump.ts +68 -57
- package/commands/check-candid.ts +24 -0
- package/commands/docs-coverage.ts +124 -102
- package/commands/docs.ts +118 -108
- package/commands/format.ts +171 -155
- package/commands/init.ts +301 -275
- package/commands/install/install-all.ts +75 -62
- package/commands/install/install-dep.ts +43 -28
- package/commands/install/install-deps.ts +23 -15
- package/commands/install/install-local-dep.ts +42 -34
- package/commands/install/install-mops-dep.ts +154 -123
- package/commands/install/sync-local-cache.ts +39 -35
- package/commands/maintainer.ts +109 -99
- package/commands/outdated.ts +31 -18
- package/commands/owner.ts +107 -99
- package/commands/publish.ts +534 -443
- package/commands/remove.ts +119 -89
- package/commands/replica.ts +391 -303
- package/commands/search.ts +42 -36
- package/commands/self.ts +63 -56
- package/commands/sources.ts +66 -49
- package/commands/sync.ts +92 -75
- package/commands/template.ts +145 -102
- package/commands/test/mmf1.ts +146 -119
- package/commands/test/reporters/compact-reporter.ts +87 -84
- package/commands/test/reporters/files-reporter.ts +56 -51
- package/commands/test/reporters/reporter.ts +12 -6
- package/commands/test/reporters/silent-reporter.ts +58 -59
- package/commands/test/reporters/verbose-reporter.ts +66 -54
- package/commands/test/test.ts +497 -460
- package/commands/test/utils.ts +85 -6
- package/commands/toolchain/index.ts +363 -322
- package/commands/toolchain/moc.ts +78 -50
- package/commands/toolchain/pocket-ic.ts +41 -34
- package/commands/toolchain/toolchain-utils.ts +92 -72
- package/commands/toolchain/wasmtime.ts +37 -34
- package/commands/update.ts +91 -56
- package/commands/user.ts +90 -81
- package/commands/watch/deployer.ts +188 -152
- package/commands/watch/error-checker.ts +90 -80
- package/commands/watch/formatter.ts +72 -60
- package/commands/watch/generator.ts +116 -96
- package/commands/watch/globMoFiles.ts +13 -13
- package/commands/watch/parseDfxJson.ts +63 -57
- package/commands/watch/tester.ts +83 -65
- package/commands/watch/warning-checker.ts +149 -136
- package/commands/watch/watch.ts +123 -95
- package/declarations/bench/bench.did.d.ts +3 -3
- package/declarations/bench/index.d.ts +3 -3
- package/declarations/bench/index.js +1 -1
- package/declarations/main/index.d.ts +3 -3
- package/declarations/main/index.js +1 -1
- package/declarations/main/main.did.d.ts +3 -3
- package/declarations/storage/index.d.ts +3 -3
- package/declarations/storage/index.js +4 -4
- package/declarations/storage/storage.did.d.ts +3 -3
- package/dist/api/actors.d.ts +4 -4
- package/dist/api/actors.js +8 -8
- package/dist/api/downloadPackageFiles.d.ts +2 -2
- package/dist/api/downloadPackageFiles.js +10 -10
- package/dist/api/getHighestVersion.js +1 -1
- package/dist/api/index.d.ts +4 -4
- package/dist/api/index.js +4 -4
- package/dist/api/network.js +9 -9
- package/dist/api/resolveVersion.js +3 -3
- package/dist/bin/mops.js +1 -1
- package/dist/bundle-package-json.js +8 -8
- package/dist/cache.js +22 -17
- package/dist/check-requirements.js +11 -11
- package/dist/cli.js +283 -186
- package/dist/commands/add.d.ts +1 -1
- package/dist/commands/add.js +41 -38
- package/dist/commands/available-updates.d.ts +1 -1
- package/dist/commands/available-updates.js +32 -14
- package/dist/commands/bench/bench-canister.mo +114 -108
- package/dist/commands/bench/user-bench.mo +6 -6
- package/dist/commands/bench-replica.d.ts +6 -5
- package/dist/commands/bench-replica.js +58 -36
- package/dist/commands/bench.d.ts +5 -5
- package/dist/commands/bench.js +134 -118
- package/dist/commands/build.d.ts +7 -0
- package/dist/commands/build.js +121 -0
- package/dist/commands/bump.js +27 -18
- package/dist/commands/check-candid.d.ts +4 -0
- package/dist/commands/check-candid.js +15 -0
- package/dist/commands/docs-coverage.d.ts +1 -1
- package/dist/commands/docs-coverage.js +45 -31
- package/dist/commands/docs.d.ts +1 -1
- package/dist/commands/docs.js +39 -38
- package/dist/commands/format.js +31 -27
- package/dist/commands/init.js +102 -92
- package/dist/commands/install/install-all.d.ts +2 -2
- package/dist/commands/install/install-all.js +23 -21
- package/dist/commands/install/install-dep.d.ts +1 -1
- package/dist/commands/install/install-dep.js +21 -8
- package/dist/commands/install/install-deps.d.ts +1 -1
- package/dist/commands/install/install-deps.js +1 -1
- package/dist/commands/install/install-local-dep.js +11 -9
- package/dist/commands/install/install-mops-dep.d.ts +1 -1
- package/dist/commands/install/install-mops-dep.js +32 -27
- package/dist/commands/install/sync-local-cache.js +10 -10
- package/dist/commands/maintainer.js +21 -21
- package/dist/commands/outdated.js +16 -6
- package/dist/commands/owner.js +21 -21
- package/dist/commands/publish.js +148 -128
- package/dist/commands/remove.d.ts +1 -1
- package/dist/commands/remove.js +42 -30
- package/dist/commands/replica.d.ts +9 -8
- package/dist/commands/replica.js +105 -65
- package/dist/commands/search.js +15 -13
- package/dist/commands/self.js +31 -28
- package/dist/commands/sources.d.ts +5 -1
- package/dist/commands/sources.js +23 -17
- package/dist/commands/sync.d.ts +1 -1
- package/dist/commands/sync.js +38 -25
- package/dist/commands/template.js +66 -56
- package/dist/commands/test/mmf1.d.ts +3 -3
- package/dist/commands/test/mmf1.js +33 -31
- package/dist/commands/test/reporters/compact-reporter.d.ts +3 -3
- package/dist/commands/test/reporters/compact-reporter.js +19 -15
- package/dist/commands/test/reporters/files-reporter.d.ts +3 -3
- package/dist/commands/test/reporters/files-reporter.js +18 -14
- package/dist/commands/test/reporters/reporter.d.ts +2 -2
- package/dist/commands/test/reporters/silent-reporter.d.ts +3 -3
- package/dist/commands/test/reporters/silent-reporter.js +4 -4
- package/dist/commands/test/reporters/verbose-reporter.d.ts +3 -3
- package/dist/commands/test/reporters/verbose-reporter.js +17 -13
- package/dist/commands/test/test.d.ts +4 -4
- package/dist/commands/test/test.js +151 -181
- package/dist/commands/test/utils.d.ts +6 -0
- package/dist/commands/test/utils.js +63 -2
- package/dist/commands/toolchain/index.d.ts +1 -1
- package/dist/commands/toolchain/index.js +81 -69
- package/dist/commands/toolchain/moc.d.ts +1 -1
- package/dist/commands/toolchain/moc.js +48 -24
- package/dist/commands/toolchain/pocket-ic.js +12 -12
- package/dist/commands/toolchain/toolchain-utils.d.ts +2 -0
- package/dist/commands/toolchain/toolchain-utils.js +32 -23
- package/dist/commands/toolchain/wasmtime.js +11 -11
- package/dist/commands/update.d.ts +1 -1
- package/dist/commands/update.js +30 -12
- package/dist/commands/user.js +31 -28
- package/dist/commands/watch/deployer.d.ts +4 -4
- package/dist/commands/watch/deployer.js +45 -36
- package/dist/commands/watch/error-checker.d.ts +2 -2
- package/dist/commands/watch/error-checker.js +27 -27
- package/dist/commands/watch/formatter.d.ts +4 -4
- package/dist/commands/watch/formatter.js +17 -17
- package/dist/commands/watch/generator.d.ts +3 -3
- package/dist/commands/watch/generator.js +28 -23
- package/dist/commands/watch/globMoFiles.js +8 -8
- package/dist/commands/watch/parseDfxJson.d.ts +2 -2
- package/dist/commands/watch/parseDfxJson.js +9 -9
- package/dist/commands/watch/tester.d.ts +4 -4
- package/dist/commands/watch/tester.js +23 -21
- package/dist/commands/watch/warning-checker.d.ts +3 -3
- package/dist/commands/watch/warning-checker.js +36 -36
- package/dist/commands/watch/watch.js +45 -32
- package/dist/declarations/bench/bench.did.d.ts +3 -3
- package/dist/declarations/bench/index.d.ts +3 -3
- package/dist/declarations/bench/index.js +1 -1
- package/dist/declarations/main/index.d.ts +3 -3
- package/dist/declarations/main/index.js +1 -1
- package/dist/declarations/main/main.did.d.ts +3 -3
- package/dist/declarations/storage/index.d.ts +3 -3
- package/dist/declarations/storage/index.js +4 -4
- package/dist/declarations/storage/storage.did.d.ts +3 -3
- package/dist/environments/nodejs/cli.d.ts +1 -0
- package/dist/environments/nodejs/cli.js +4 -0
- package/dist/environments/web/cli.d.ts +1 -0
- package/dist/environments/web/cli.js +4 -0
- package/dist/error.d.ts +1 -0
- package/dist/error.js +5 -0
- package/dist/fix-dist.js +5 -5
- package/dist/helpers/find-changelog-entry.js +8 -5
- package/dist/helpers/get-dep-name.d.ts +1 -0
- package/dist/helpers/get-dep-name.js +4 -1
- package/dist/helpers/get-dfx-version.js +4 -4
- package/dist/helpers/get-moc-path.js +8 -7
- package/dist/helpers/get-moc-version.js +10 -7
- package/dist/helpers/get-package-id.js +2 -2
- package/dist/helpers/is-candid-compatible.d.ts +1 -0
- package/dist/helpers/is-candid-compatible.js +20 -0
- package/dist/integrity.d.ts +1 -1
- package/dist/integrity.js +47 -38
- package/dist/jest.config.d.ts +11 -0
- package/dist/jest.config.js +14 -0
- package/dist/mops.d.ts +6 -6
- package/dist/mops.js +87 -80
- package/dist/notify-installs.js +4 -4
- package/dist/package.json +11 -10
- package/dist/pem.d.ts +3 -3
- package/dist/pem.js +20 -12
- package/dist/release-cli.js +20 -20
- package/dist/resolve-packages.d.ts +1 -1
- package/dist/resolve-packages.js +52 -36
- package/dist/templates/mops-publish.yml +3 -3
- package/dist/templates/mops-test.yml +3 -3
- package/dist/templates/src/lib.mo +13 -13
- package/dist/templates/test/lib.test.mo +2 -2
- package/dist/templates.js +1 -1
- package/dist/tests/cli.test.d.ts +1 -0
- package/dist/tests/cli.test.js +63 -0
- package/dist/types.d.ts +14 -4
- package/dist/vessel.d.ts +2 -2
- package/dist/vessel.js +41 -34
- package/dist/wasm/pkg/bundler/package.json +20 -0
- package/dist/wasm/pkg/bundler/wasm.d.ts +3 -0
- package/dist/wasm/pkg/bundler/wasm.js +5 -0
- package/dist/wasm/pkg/bundler/wasm_bg.js +93 -0
- package/dist/wasm/pkg/bundler/wasm_bg.wasm +0 -0
- package/dist/wasm/pkg/bundler/wasm_bg.wasm.d.ts +8 -0
- package/dist/wasm/pkg/nodejs/package.json +14 -0
- package/dist/wasm/pkg/nodejs/wasm.d.ts +3 -0
- package/dist/wasm/pkg/nodejs/wasm.js +98 -0
- package/dist/wasm/pkg/nodejs/wasm_bg.wasm +0 -0
- package/dist/wasm/pkg/nodejs/wasm_bg.wasm.d.ts +8 -0
- package/dist/wasm/pkg/web/package.json +18 -0
- package/dist/wasm/pkg/web/wasm.d.ts +35 -0
- package/dist/wasm/pkg/web/wasm.js +191 -0
- package/dist/wasm/pkg/web/wasm_bg.wasm +0 -0
- package/dist/wasm/pkg/web/wasm_bg.wasm.d.ts +8 -0
- package/dist/wasm.d.ts +5 -0
- package/dist/wasm.js +10 -0
- package/environments/nodejs/cli.ts +6 -0
- package/environments/web/cli.ts +6 -0
- package/error.ts +6 -0
- package/fix-dist.ts +5 -5
- package/global.d.ts +3 -3
- package/helpers/find-changelog-entry.ts +26 -23
- package/helpers/get-dep-name.ts +7 -3
- package/helpers/get-dfx-version.ts +8 -9
- package/helpers/get-moc-path.ts +25 -26
- package/helpers/get-moc-version.ts +21 -19
- package/helpers/get-package-id.ts +4 -4
- package/helpers/is-candid-compatible.ts +22 -0
- package/integrity.ts +270 -236
- package/jest.config.js +14 -0
- package/mops.ts +238 -215
- package/notify-installs.ts +16 -17
- package/package.json +21 -15
- package/parallel.ts +28 -24
- package/pem.ts +55 -47
- package/release-cli.ts +73 -39
- package/resolve-packages.ts +231 -189
- package/templates/mops-publish.yml +3 -3
- package/templates/mops-test.yml +3 -3
- package/templates/src/lib.mo +13 -13
- package/templates/test/lib.test.mo +2 -2
- package/templates.ts +4 -4
- package/tests/__snapshots__/cli.test.ts.snap +202 -0
- package/tests/build/error/candid/bar.did +3 -0
- package/tests/build/error/dfx.json +12 -0
- package/tests/build/error/mops.toml +9 -0
- package/tests/build/error/src/Bar.mo +5 -0
- package/tests/build/error/src/Foo.mo +5 -0
- package/tests/build/success/.dfx/local/canister_ids.json +17 -0
- package/tests/build/success/.dfx/local/canisters/bar/bar.did +3 -0
- package/tests/build/success/.dfx/local/canisters/bar/bar.most +4 -0
- package/tests/build/success/.dfx/local/canisters/bar/bar.wasm +0 -0
- package/tests/build/success/.dfx/local/canisters/bar/constructor.did +3 -0
- package/tests/build/success/.dfx/local/canisters/bar/index.js +42 -0
- package/tests/build/success/.dfx/local/canisters/bar/init_args.txt +1 -0
- package/tests/build/success/.dfx/local/canisters/bar/service.did +3 -0
- package/tests/build/success/.dfx/local/canisters/bar/service.did.d.ts +7 -0
- package/tests/build/success/.dfx/local/canisters/bar/service.did.js +4 -0
- package/tests/build/success/.dfx/local/canisters/foo/constructor.did +3 -0
- package/tests/build/success/.dfx/local/canisters/foo/foo.did +3 -0
- package/tests/build/success/.dfx/local/canisters/foo/foo.most +4 -0
- package/tests/build/success/.dfx/local/canisters/foo/foo.wasm +0 -0
- package/tests/build/success/.dfx/local/canisters/foo/index.js +42 -0
- package/tests/build/success/.dfx/local/canisters/foo/init_args.txt +1 -0
- package/tests/build/success/.dfx/local/canisters/foo/service.did +3 -0
- package/tests/build/success/.dfx/local/canisters/foo/service.did.d.ts +7 -0
- package/tests/build/success/.dfx/local/canisters/foo/service.did.js +4 -0
- package/tests/build/success/.dfx/local/lsp/ucwa4-rx777-77774-qaada-cai.did +3 -0
- package/tests/build/success/.dfx/local/lsp/ulvla-h7777-77774-qaacq-cai.did +3 -0
- package/tests/build/success/.dfx/local/network-id +4 -0
- package/tests/build/success/candid/bar.did +3 -0
- package/tests/build/success/dfx.json +12 -0
- package/tests/build/success/mops.toml +9 -0
- package/tests/build/success/src/Bar.mo +5 -0
- package/tests/build/success/src/Foo.mo +5 -0
- package/tests/check-candid/a.did +3 -0
- package/tests/check-candid/b.did +5 -0
- package/tests/check-candid/c.did +3 -0
- package/tests/cli.test.ts +82 -0
- package/tsconfig.json +26 -19
- package/types.ts +41 -31
- package/vessel.ts +219 -187
- package/wasm/Cargo.lock +1475 -0
- package/wasm/Cargo.toml +28 -0
- package/wasm/pkg/bundler/package.json +20 -0
- package/wasm/pkg/bundler/wasm.d.ts +3 -0
- package/wasm/pkg/bundler/wasm.js +5 -0
- package/wasm/pkg/bundler/wasm_bg.js +93 -0
- package/wasm/pkg/bundler/wasm_bg.wasm +0 -0
- package/wasm/pkg/bundler/wasm_bg.wasm.d.ts +8 -0
- package/wasm/pkg/nodejs/package.json +14 -0
- package/wasm/pkg/nodejs/wasm.d.ts +3 -0
- package/wasm/pkg/nodejs/wasm.js +98 -0
- package/wasm/pkg/nodejs/wasm_bg.wasm +0 -0
- package/wasm/pkg/nodejs/wasm_bg.wasm.d.ts +8 -0
- package/wasm/pkg/web/package.json +18 -0
- package/wasm/pkg/web/wasm.d.ts +35 -0
- package/wasm/pkg/web/wasm.js +191 -0
- package/wasm/pkg/web/wasm_bg.wasm +0 -0
- package/wasm/pkg/web/wasm_bg.wasm.d.ts +8 -0
- package/wasm/src/lib.rs +17 -0
- package/wasm.ts +16 -0
package/dist/cli.js
CHANGED
|
@@ -1,58 +1,69 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import * as self from
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
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() ||
|
|
43
|
+
globalThis.MOPS_NETWORK = fs.readFileSync(networkFile).toString() || "ic";
|
|
36
44
|
}
|
|
37
45
|
let program = new Command();
|
|
38
|
-
program.name(
|
|
46
|
+
program.name("mops");
|
|
39
47
|
// --version
|
|
40
|
-
program.version(`CLI ${version()}\nAPI ${apiVersion}`,
|
|
48
|
+
program.version(`CLI ${version()}\nAPI ${apiVersion}`, "-v --version");
|
|
41
49
|
// init
|
|
42
50
|
program
|
|
43
|
-
.command(
|
|
44
|
-
.description(
|
|
45
|
-
.option(
|
|
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(
|
|
52
|
-
.description(
|
|
53
|
-
.option(
|
|
54
|
-
.option(
|
|
55
|
-
.addOption(new Option(
|
|
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(
|
|
65
|
-
.alias(
|
|
66
|
-
.description(
|
|
67
|
-
.option(
|
|
68
|
-
.option(
|
|
69
|
-
.option(
|
|
70
|
-
.addOption(new Option(
|
|
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(
|
|
80
|
-
.alias(
|
|
81
|
-
.description(
|
|
82
|
-
.option(
|
|
83
|
-
.option(
|
|
84
|
-
.addOption(new Option(
|
|
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:
|
|
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(
|
|
109
|
-
.description(
|
|
110
|
-
.option(
|
|
111
|
-
.option(
|
|
112
|
-
.option(
|
|
113
|
-
.option(
|
|
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(
|
|
126
|
-
.alias(
|
|
127
|
-
.description(
|
|
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(
|
|
135
|
-
.alias(
|
|
136
|
-
.description(
|
|
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(
|
|
143
|
-
.description(
|
|
144
|
-
.option(
|
|
145
|
-
.addOption(new Option(
|
|
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({
|
|
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(
|
|
180
|
+
console.log(sourcesArr.join("\n"));
|
|
156
181
|
});
|
|
157
182
|
// search
|
|
158
183
|
program
|
|
159
|
-
.command(
|
|
160
|
-
.description(
|
|
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(
|
|
167
|
-
.description(
|
|
168
|
-
.addArgument(new Argument(
|
|
191
|
+
.command("cache")
|
|
192
|
+
.description("Manage cache")
|
|
193
|
+
.addArgument(new Argument("<sub>").choices(["size", "clean", "show"]))
|
|
169
194
|
.action(async (sub) => {
|
|
170
|
-
if (sub ==
|
|
195
|
+
if (sub == "clean") {
|
|
171
196
|
await cleanCache();
|
|
172
|
-
console.log(
|
|
197
|
+
console.log("Cache cleaned");
|
|
173
198
|
}
|
|
174
|
-
else if (sub ==
|
|
199
|
+
else if (sub == "size") {
|
|
175
200
|
let size = await cacheSize();
|
|
176
|
-
console.log(
|
|
201
|
+
console.log("Cache size is " + size);
|
|
177
202
|
}
|
|
178
|
-
else if (sub ==
|
|
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(
|
|
185
|
-
.description(
|
|
186
|
-
.addOption(new Option(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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({
|
|
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(
|
|
199
|
-
.description(
|
|
200
|
-
.addOption(new Option(
|
|
201
|
-
.addOption(new Option(
|
|
202
|
-
.
|
|
203
|
-
.
|
|
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(
|
|
276
|
+
.addOption(new Option("--verbose", "Show more information"))
|
|
206
277
|
.action(async (filter, options) => {
|
|
207
278
|
checkConfigFile(true);
|
|
208
|
-
await installAll({
|
|
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(
|
|
214
|
-
.description(
|
|
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(
|
|
297
|
+
const userCommand = new Command("user").description("User management");
|
|
223
298
|
// user get-principal
|
|
224
299
|
userCommand
|
|
225
|
-
.command(
|
|
226
|
-
.description(
|
|
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(
|
|
233
|
-
.description(
|
|
234
|
-
.addOption(new Option(
|
|
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(
|
|
242
|
-
.addArgument(new Argument(
|
|
243
|
-
|
|
244
|
-
|
|
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(
|
|
251
|
-
.addArgument(new Argument(
|
|
252
|
-
|
|
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(
|
|
345
|
+
const ownerCommand = new Command("owner").description("Package owner management");
|
|
259
346
|
// mops owner list
|
|
260
347
|
ownerCommand
|
|
261
|
-
.command(
|
|
262
|
-
.description(
|
|
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(
|
|
269
|
-
.description(
|
|
270
|
-
.addOption(new Option(
|
|
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(
|
|
277
|
-
.description(
|
|
278
|
-
.addOption(new Option(
|
|
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(
|
|
371
|
+
const maintainerCommand = new Command("maintainer").description("Package maintainer management");
|
|
285
372
|
// mops maintainer list
|
|
286
373
|
maintainerCommand
|
|
287
|
-
.command(
|
|
288
|
-
.description(
|
|
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(
|
|
295
|
-
.description(
|
|
296
|
-
.addOption(new Option(
|
|
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(
|
|
303
|
-
.description(
|
|
304
|
-
.addOption(new Option(
|
|
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(
|
|
312
|
-
.description(
|
|
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(
|
|
319
|
-
.description(
|
|
320
|
-
.addOption(new Option(
|
|
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(
|
|
327
|
-
.description(
|
|
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(
|
|
334
|
-
.description(
|
|
335
|
-
.addOption(new Option(
|
|
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(
|
|
433
|
+
const toolchainCommand = new Command("toolchain").description("Toolchain management");
|
|
341
434
|
toolchainCommand
|
|
342
|
-
.command(
|
|
343
|
-
.description(
|
|
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(
|
|
349
|
-
.description(
|
|
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(
|
|
355
|
-
.description(
|
|
356
|
-
.addArgument(new Argument(
|
|
357
|
-
.addArgument(new Argument(
|
|
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(
|
|
366
|
-
.description(
|
|
367
|
-
.addArgument(new Argument(
|
|
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(
|
|
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(
|
|
378
|
-
.addOption(new Option(
|
|
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(
|
|
478
|
+
const selfCommand = new Command("self").description("Mops CLI management");
|
|
386
479
|
selfCommand
|
|
387
|
-
.command(
|
|
388
|
-
.description(
|
|
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(
|
|
394
|
-
.description(
|
|
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(
|
|
402
|
-
.description(
|
|
403
|
-
.option(
|
|
404
|
-
.option(
|
|
405
|
-
.option(
|
|
406
|
-
.option(
|
|
407
|
-
.option(
|
|
408
|
-
.option(
|
|
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(
|
|
416
|
-
.alias(
|
|
417
|
-
.description(
|
|
418
|
-
.addOption(new Option(
|
|
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(
|
|
520
|
+
const docsCommand = new Command("docs").description("Documentation management");
|
|
428
521
|
docsCommand
|
|
429
|
-
.command(
|
|
430
|
-
.description(
|
|
431
|
-
.addOption(new Option(
|
|
432
|
-
.addOption(new Option(
|
|
433
|
-
.addOption(new Option(
|
|
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(
|
|
440
|
-
.description(
|
|
441
|
-
.addOption(new Option(
|
|
442
|
-
.addOption(new Option(
|
|
443
|
-
.
|
|
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);
|