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.
- package/.DS_Store +0 -0
- package/.eslintrc.json +7 -7
- package/CHANGELOG.md +6 -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/bundle/bench/bench-canister.mo +109 -101
- package/bundle/bench/user-bench.mo +6 -6
- package/bundle/bin/mops.js +1 -1
- package/bundle/cli.js +797 -792
- package/bundle/cli.tgz +0 -0
- package/bundle/package.json +6 -5
- package/bundle/templates/mops-publish.yml +3 -3
- package/bundle/templates/mops-test.yml +3 -3
- package/bundle/templates/src/lib.mo +13 -13
- package/bundle/templates/test/lib.test.mo +2 -2
- 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 -41
- package/commands/bench/bench-canister.mo +114 -108
- package/commands/bench/user-bench.mo +6 -6
- package/commands/bench-replica.ts +146 -118
- 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 +30 -24
- package/commands/owner.ts +107 -99
- package/commands/publish.ts +534 -443
- package/commands/remove.ts +119 -89
- package/commands/replica.ts +391 -316
- 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 +498 -401
- package/commands/test/utils.ts +72 -67
- 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 +82 -64
- 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/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 +40 -37
- package/dist/commands/available-updates.d.ts +1 -1
- package/dist/commands/available-updates.js +18 -12
- 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 +4 -4
- package/dist/commands/bench-replica.js +45 -34
- 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 +12 -8
- 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 +7 -7
- package/dist/commands/replica.js +85 -57
- 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 +134 -112
- package/dist/commands/test/utils.d.ts +3 -3
- package/dist/commands/test/utils.js +17 -17
- 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 +18 -14
- 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/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.js +2 -2
- 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 +9 -5
- 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 +5 -5
- 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 +19 -10
- 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/cli.ts
CHANGED
|
@@ -1,519 +1,720 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
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
|
+
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
71
|
+
globalThis.MOPS_NETWORK = fs.readFileSync(networkFile).toString() || "ic";
|
|
47
72
|
}
|
|
48
73
|
|
|
49
74
|
let program = new Command();
|
|
50
75
|
|
|
51
|
-
program.name(
|
|
76
|
+
program.name("mops");
|
|
52
77
|
|
|
53
78
|
// --version
|
|
54
|
-
program.version(`CLI ${version()}\nAPI ${apiVersion}`,
|
|
79
|
+
program.version(`CLI ${version()}\nAPI ${apiVersion}`, "-v --version");
|
|
55
80
|
|
|
56
81
|
// init
|
|
57
82
|
program
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
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
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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(
|
|
387
|
+
const userCommand = new Command("user").description("User management");
|
|
257
388
|
|
|
258
389
|
// user get-principal
|
|
259
390
|
userCommand
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
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
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
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(
|
|
447
|
+
const ownerCommand = new Command("owner").description(
|
|
448
|
+
"Package owner management",
|
|
449
|
+
);
|
|
299
450
|
|
|
300
451
|
// mops owner list
|
|
301
452
|
ownerCommand
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
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(
|
|
480
|
+
const maintainerCommand = new Command("maintainer").description(
|
|
481
|
+
"Package maintainer management",
|
|
482
|
+
);
|
|
330
483
|
|
|
331
484
|
// mops maintainer list
|
|
332
485
|
maintainerCommand
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
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
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
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
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
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
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
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
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
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
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
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
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
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(
|
|
557
|
+
const toolchainCommand = new Command("toolchain").description(
|
|
558
|
+
"Toolchain management",
|
|
559
|
+
);
|
|
395
560
|
|
|
396
561
|
toolchainCommand
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
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
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
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
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
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
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
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
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
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(
|
|
620
|
+
const selfCommand = new Command("self").description("Mops CLI management");
|
|
447
621
|
|
|
448
622
|
selfCommand
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
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
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
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
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
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
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
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(
|
|
675
|
+
const docsCommand = new Command("docs").description("Documentation management");
|
|
495
676
|
|
|
496
677
|
docsCommand
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
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
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
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();
|