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/commands/watch/watch.ts
CHANGED
|
@@ -1,111 +1,139 @@
|
|
|
1
|
-
import chokidar from
|
|
2
|
-
import path from
|
|
3
|
-
import debounce from
|
|
4
|
-
import chalk from
|
|
5
|
-
import {ErrorChecker} from
|
|
6
|
-
import {WarningChecker} from
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
1
|
+
import chokidar from "chokidar";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import debounce from "debounce";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import { ErrorChecker } from "./error-checker.js";
|
|
6
|
+
import { WarningChecker } from "./warning-checker.js";
|
|
7
|
+
import {
|
|
8
|
+
getMotokoCanisters,
|
|
9
|
+
getMotokoCanistersWithDeclarations,
|
|
10
|
+
} from "./parseDfxJson.js";
|
|
11
|
+
import { getRootDir } from "../../mops.js";
|
|
12
|
+
import { Tester } from "./tester.js";
|
|
13
|
+
import { Generator } from "./generator.js";
|
|
14
|
+
import { Deployer } from "./deployer.js";
|
|
15
|
+
import { Formatter } from "./formatter.js";
|
|
13
16
|
|
|
14
17
|
let ignore = [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
"**/node_modules/**",
|
|
19
|
+
"**/.mops/**",
|
|
20
|
+
"**/.vessel/**",
|
|
21
|
+
"**/.git/**",
|
|
19
22
|
];
|
|
20
23
|
|
|
21
|
-
export async function watch(options
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
export async function watch(options: {
|
|
25
|
+
error: boolean;
|
|
26
|
+
warning: boolean;
|
|
27
|
+
test: boolean;
|
|
28
|
+
generate: boolean;
|
|
29
|
+
deploy: boolean;
|
|
30
|
+
format: boolean;
|
|
31
|
+
}) {
|
|
32
|
+
let hasOptions = Object.values(options).includes(true);
|
|
33
|
+
if (!hasOptions) {
|
|
34
|
+
options = {
|
|
35
|
+
error: true,
|
|
36
|
+
warning: true,
|
|
37
|
+
test: true,
|
|
38
|
+
generate: true,
|
|
39
|
+
deploy: true,
|
|
40
|
+
format: false,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
options.error = true;
|
|
34
44
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
let rootDir = getRootDir();
|
|
46
|
+
let canisters = getMotokoCanisters();
|
|
47
|
+
let canistersWithDeclarations = getMotokoCanistersWithDeclarations();
|
|
48
|
+
let errorChecker = new ErrorChecker({ verbose: true, canisters: canisters });
|
|
49
|
+
let warningChecker = new WarningChecker({
|
|
50
|
+
errorChecker,
|
|
51
|
+
verbose: true,
|
|
52
|
+
canisters: canisters,
|
|
53
|
+
});
|
|
54
|
+
let tester = new Tester({ errorChecker, verbose: true });
|
|
55
|
+
let generator = new Generator({
|
|
56
|
+
errorChecker,
|
|
57
|
+
verbose: true,
|
|
58
|
+
canisters: canistersWithDeclarations,
|
|
59
|
+
});
|
|
60
|
+
let deployer = new Deployer({
|
|
61
|
+
errorChecker,
|
|
62
|
+
generator,
|
|
63
|
+
verbose: true,
|
|
64
|
+
canisters: canisters,
|
|
65
|
+
});
|
|
66
|
+
let formatter = new Formatter({ errorChecker, verbose: true });
|
|
44
67
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
68
|
+
let watcher = chokidar.watch(
|
|
69
|
+
[path.join(rootDir, "**/*.mo"), path.join(rootDir, "mops.toml")],
|
|
70
|
+
{
|
|
71
|
+
ignored: ignore,
|
|
72
|
+
ignoreInitial: true,
|
|
73
|
+
},
|
|
74
|
+
);
|
|
52
75
|
|
|
53
|
-
|
|
76
|
+
let formatting = false;
|
|
54
77
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
78
|
+
let run = debounce(async () => {
|
|
79
|
+
if (formatting) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
59
82
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
83
|
+
errorChecker.reset();
|
|
84
|
+
warningChecker.reset();
|
|
85
|
+
tester.reset();
|
|
86
|
+
generator.reset();
|
|
87
|
+
deployer.reset();
|
|
88
|
+
formatter.reset();
|
|
66
89
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
90
|
+
if (options.format) {
|
|
91
|
+
formatting = true;
|
|
92
|
+
}
|
|
70
93
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
94
|
+
options.error && (await errorChecker.run(print));
|
|
95
|
+
options.warning && warningChecker.run(print);
|
|
96
|
+
options.format &&
|
|
97
|
+
formatter
|
|
98
|
+
.run(print)
|
|
99
|
+
.then(() => setTimeout(() => (formatting = false), 500));
|
|
100
|
+
options.test && tester.run(print);
|
|
101
|
+
options.generate && (await generator.run(print));
|
|
102
|
+
options.deploy && deployer.run(print);
|
|
103
|
+
}, 200);
|
|
78
104
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
105
|
+
let print = () => {
|
|
106
|
+
console.clear();
|
|
107
|
+
process.stdout.write("\x1Bc");
|
|
82
108
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
109
|
+
options.error && console.log(errorChecker.getOutput());
|
|
110
|
+
options.warning && console.log(warningChecker.getOutput());
|
|
111
|
+
options.format && console.log(formatter.getOutput());
|
|
112
|
+
options.test && console.log(tester.getOutput());
|
|
113
|
+
options.generate && console.log(generator.getOutput());
|
|
114
|
+
options.deploy && console.log(deployer.getOutput());
|
|
89
115
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
116
|
+
let statuses = [];
|
|
117
|
+
options.error && statuses.push(errorChecker.status);
|
|
118
|
+
options.warning && statuses.push(warningChecker.status);
|
|
119
|
+
options.format && statuses.push(formatter.status);
|
|
120
|
+
options.test && statuses.push(tester.status);
|
|
121
|
+
options.generate && statuses.push(generator.status);
|
|
122
|
+
options.deploy && statuses.push(deployer.status);
|
|
97
123
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
124
|
+
if (
|
|
125
|
+
statuses.every((status) => status !== "pending" && status !== "running")
|
|
126
|
+
) {
|
|
127
|
+
console.log(chalk.dim("-".repeat(50)));
|
|
128
|
+
console.log(chalk.dim("Waiting for file changes..."));
|
|
129
|
+
console.log(chalk.dim(`Press ${chalk.bold("Ctrl+C")} to exit.`));
|
|
130
|
+
}
|
|
131
|
+
};
|
|
104
132
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
133
|
+
watcher.on("all", () => {
|
|
134
|
+
if (!formatting) {
|
|
135
|
+
run();
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
run();
|
|
139
|
+
}
|
package/dist/api/actors.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Identity } from
|
|
2
|
-
import { Principal } from
|
|
3
|
-
import { _SERVICE } from
|
|
4
|
-
import { _SERVICE as _STORAGE_SERVICE } from
|
|
1
|
+
import { Identity } from "@icp-sdk/core/agent";
|
|
2
|
+
import { Principal } from "@icp-sdk/core/principal";
|
|
3
|
+
import { _SERVICE } from "../declarations/main/main.did.js";
|
|
4
|
+
import { _SERVICE as _STORAGE_SERVICE } from "../declarations/storage/storage.did.js";
|
|
5
5
|
export declare let mainActor: (identity?: Identity) => Promise<_SERVICE>;
|
|
6
6
|
export declare let storageActor: (storageId: Principal, identity?: Identity) => Promise<_STORAGE_SERVICE>;
|
package/dist/api/actors.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Actor, HttpAgent } from
|
|
2
|
-
import { idlFactory } from
|
|
3
|
-
import { idlFactory as storageIdlFactory } from
|
|
4
|
-
import { getEndpoint } from
|
|
5
|
-
import { getNetwork } from
|
|
1
|
+
import { Actor, HttpAgent } from "@icp-sdk/core/agent";
|
|
2
|
+
import { idlFactory } from "../declarations/main/main.did.js";
|
|
3
|
+
import { idlFactory as storageIdlFactory } from "../declarations/storage/storage.did.js";
|
|
4
|
+
import { getEndpoint } from "./network.js";
|
|
5
|
+
import { getNetwork } from "./network.js";
|
|
6
6
|
let agentPromiseByPrincipal = new Map();
|
|
7
7
|
let getAgent = async (identity) => {
|
|
8
|
-
let principal = identity ? identity?.getPrincipal().toText() :
|
|
8
|
+
let principal = identity ? identity?.getPrincipal().toText() : "";
|
|
9
9
|
let agentPromise = agentPromiseByPrincipal.get(principal);
|
|
10
10
|
if (!agentPromise) {
|
|
11
11
|
let network = getNetwork();
|
|
@@ -13,8 +13,8 @@ let getAgent = async (identity) => {
|
|
|
13
13
|
agentPromise = HttpAgent.create({
|
|
14
14
|
host,
|
|
15
15
|
identity,
|
|
16
|
-
shouldFetchRootKey: network ===
|
|
17
|
-
verifyQuerySignatures: process.env.MOPS_VERIFY_QUERY_SIGNATURES !==
|
|
16
|
+
shouldFetchRootKey: network === "local",
|
|
17
|
+
verifyQuerySignatures: process.env.MOPS_VERIFY_QUERY_SIGNATURES !== "false",
|
|
18
18
|
shouldSyncTime: true,
|
|
19
19
|
});
|
|
20
20
|
agentPromiseByPrincipal.set(principal, agentPromise);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Principal } from
|
|
2
|
-
import { Storage } from
|
|
1
|
+
import { Principal } from "@icp-sdk/core/principal";
|
|
2
|
+
import { Storage } from "../declarations/storage/storage.did.js";
|
|
3
3
|
export declare function downloadPackageFiles(pkg: string, version?: string, threads?: number, onLoad?: (_fileIds: string[], _fileId: string) => void): Promise<Map<string, Array<number>>>;
|
|
4
4
|
export declare function getPackageFilesInfo(pkg: string, version: string): Promise<{
|
|
5
5
|
storageId: Principal;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Principal } from
|
|
2
|
-
import { mainActor, storageActor } from
|
|
3
|
-
import { resolveVersion } from
|
|
4
|
-
import { parallel } from
|
|
5
|
-
export async function downloadPackageFiles(pkg, version =
|
|
1
|
+
import { Principal } from "@icp-sdk/core/principal";
|
|
2
|
+
import { mainActor, storageActor } from "./actors.js";
|
|
3
|
+
import { resolveVersion } from "./resolveVersion.js";
|
|
4
|
+
import { parallel } from "../parallel.js";
|
|
5
|
+
export async function downloadPackageFiles(pkg, version = "", threads = 8, onLoad = (_fileIds, _fileId) => { }) {
|
|
6
6
|
version = await resolveVersion(pkg, version);
|
|
7
7
|
let { storageId, fileIds } = await getPackageFilesInfo(pkg, version);
|
|
8
8
|
let storage = await storageActor(storageId);
|
|
@@ -21,7 +21,7 @@ export async function getPackageFilesInfo(pkg, version) {
|
|
|
21
21
|
actor.getPackageDetails(pkg, version),
|
|
22
22
|
getFileIds(pkg, version),
|
|
23
23
|
]);
|
|
24
|
-
if (
|
|
24
|
+
if ("err" in packageDetailsRes) {
|
|
25
25
|
throw packageDetailsRes.err;
|
|
26
26
|
}
|
|
27
27
|
let packageDetails = packageDetailsRes.ok;
|
|
@@ -34,7 +34,7 @@ export async function getPackageFilesInfo(pkg, version) {
|
|
|
34
34
|
export async function getFileIds(pkg, version) {
|
|
35
35
|
let actor = await mainActor();
|
|
36
36
|
let fileIdsRes = await actor.getFileIds(pkg, version);
|
|
37
|
-
if (
|
|
37
|
+
if ("err" in fileIdsRes) {
|
|
38
38
|
throw fileIdsRes.err;
|
|
39
39
|
}
|
|
40
40
|
let filesIds = fileIdsRes.ok;
|
|
@@ -42,18 +42,18 @@ export async function getFileIds(pkg, version) {
|
|
|
42
42
|
}
|
|
43
43
|
// download single file
|
|
44
44
|
export async function downloadFile(storage, fileId) {
|
|
45
|
-
if (typeof storage ===
|
|
45
|
+
if (typeof storage === "string") {
|
|
46
46
|
storage = await storageActor(Principal.fromText(storage));
|
|
47
47
|
}
|
|
48
48
|
let fileMetaRes = await storage.getFileMeta(fileId);
|
|
49
|
-
if (
|
|
49
|
+
if ("err" in fileMetaRes) {
|
|
50
50
|
throw fileMetaRes.err;
|
|
51
51
|
}
|
|
52
52
|
let fileMeta = fileMetaRes.ok;
|
|
53
53
|
let data = [];
|
|
54
54
|
for (let i = 0n; i < fileMeta.chunkCount; i++) {
|
|
55
55
|
let chunkRes = await storage.downloadChunk(fileId, i);
|
|
56
|
-
if (
|
|
56
|
+
if ("err" in chunkRes) {
|
|
57
57
|
throw chunkRes.err;
|
|
58
58
|
}
|
|
59
59
|
let chunk = chunkRes.ok;
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { mainActor, storageActor } from
|
|
2
|
-
export { downloadPackageFiles } from
|
|
3
|
-
export { getEndpoint, getNetwork } from
|
|
4
|
-
export { resolveVersion } from
|
|
1
|
+
export { mainActor, storageActor } from "./actors.js";
|
|
2
|
+
export { downloadPackageFiles } from "./downloadPackageFiles.js";
|
|
3
|
+
export { getEndpoint, getNetwork } from "./network.js";
|
|
4
|
+
export { resolveVersion } from "./resolveVersion.js";
|
package/dist/api/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { mainActor, storageActor } from
|
|
2
|
-
export { downloadPackageFiles } from
|
|
3
|
-
export { getEndpoint, getNetwork } from
|
|
4
|
-
export { resolveVersion } from
|
|
1
|
+
export { mainActor, storageActor } from "./actors.js";
|
|
2
|
+
export { downloadPackageFiles } from "./downloadPackageFiles.js";
|
|
3
|
+
export { getEndpoint, getNetwork } from "./network.js";
|
|
4
|
+
export { resolveVersion } from "./resolveVersion.js";
|
package/dist/api/network.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
export function getNetwork() {
|
|
2
|
-
return globalThis.MOPS_NETWORK ||
|
|
2
|
+
return globalThis.MOPS_NETWORK || "ic";
|
|
3
3
|
}
|
|
4
4
|
export function getEndpoint(network) {
|
|
5
|
-
if (network ===
|
|
5
|
+
if (network === "staging") {
|
|
6
6
|
return {
|
|
7
|
-
host:
|
|
8
|
-
canisterId:
|
|
7
|
+
host: "https://icp-api.io",
|
|
8
|
+
canisterId: "2d2zu-vaaaa-aaaak-qb6pq-cai",
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
-
else if (network ===
|
|
11
|
+
else if (network === "ic") {
|
|
12
12
|
return {
|
|
13
|
-
host:
|
|
14
|
-
canisterId:
|
|
13
|
+
host: "https://icp-api.io",
|
|
14
|
+
canisterId: "oknww-riaaa-aaaam-qaf6a-cai",
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
else {
|
|
18
18
|
return {
|
|
19
|
-
host:
|
|
20
|
-
canisterId:
|
|
19
|
+
host: "http://127.0.0.1:4943",
|
|
20
|
+
canisterId: "2d2zu-vaaaa-aaaak-qb6pq-cai",
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { getHighestVersion } from
|
|
2
|
-
export async function resolveVersion(pkg, version =
|
|
1
|
+
import { getHighestVersion } from "./getHighestVersion.js";
|
|
2
|
+
export async function resolveVersion(pkg, version = "") {
|
|
3
3
|
if (!version) {
|
|
4
4
|
let versionRes = await getHighestVersion(pkg);
|
|
5
|
-
if (
|
|
5
|
+
if ("err" in versionRes) {
|
|
6
6
|
throw versionRes.err;
|
|
7
7
|
}
|
|
8
8
|
version = versionRes.ok;
|
package/dist/bin/mops.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync } from
|
|
2
|
-
let packageJson = JSON.parse(readFileSync(
|
|
3
|
-
packageJson.bin.mops =
|
|
4
|
-
packageJson.bin[
|
|
1
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
let packageJson = JSON.parse(readFileSync("./bundle/package.json", "utf8"));
|
|
3
|
+
packageJson.bin.mops = "bin/mops.js";
|
|
4
|
+
packageJson.bin["ic-mops"] = "bin/mops.js";
|
|
5
5
|
delete packageJson.scripts;
|
|
6
6
|
delete packageJson.devDependencies;
|
|
7
7
|
delete packageJson.overrides;
|
|
8
8
|
packageJson.dependencies = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
"dhall-to-json-cli": packageJson.dependencies["dhall-to-json-cli"],
|
|
10
|
+
"decomp-tarxz": packageJson.dependencies["decomp-tarxz"],
|
|
11
|
+
buffer: packageJson.dependencies["buffer"],
|
|
12
12
|
};
|
|
13
|
-
writeFileSync(
|
|
13
|
+
writeFileSync("./bundle/package.json", JSON.stringify(packageJson, null, " "));
|
package/dist/cache.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import path from
|
|
3
|
-
import ncp from
|
|
4
|
-
import getFolderSize from
|
|
5
|
-
import { getDependencyType, getNetwork, getRootDir, globalCacheDir, parseGithubURL } from
|
|
6
|
-
import { getPackageId } from
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import ncp from "ncp";
|
|
4
|
+
import getFolderSize from "get-folder-size";
|
|
5
|
+
import { getDependencyType, getNetwork, getRootDir, globalCacheDir, parseGithubURL, } from "./mops.js";
|
|
6
|
+
import { getPackageId } from "./helpers/get-package-id.js";
|
|
7
7
|
let getGlobalCacheDir = () => {
|
|
8
8
|
let network = getNetwork();
|
|
9
|
-
return path.join(globalCacheDir, network ===
|
|
9
|
+
return path.join(globalCacheDir, network === "ic" ? "" : network);
|
|
10
10
|
};
|
|
11
11
|
export let show = () => {
|
|
12
12
|
return getGlobalCacheDir();
|
|
13
13
|
};
|
|
14
14
|
export let getDepCacheDir = (cacheName) => {
|
|
15
|
-
return path.join(getGlobalCacheDir(),
|
|
15
|
+
return path.join(getGlobalCacheDir(), "packages", cacheName);
|
|
16
16
|
};
|
|
17
17
|
export let isDepCached = (cacheName) => {
|
|
18
18
|
let dir = getDepCacheDir(cacheName);
|
|
@@ -20,17 +20,20 @@ export let isDepCached = (cacheName) => {
|
|
|
20
20
|
};
|
|
21
21
|
export function getDepCacheName(name, version) {
|
|
22
22
|
let depType = getDependencyType(version);
|
|
23
|
-
return depType ===
|
|
23
|
+
return depType === "mops"
|
|
24
|
+
? getMopsDepCacheName(name, version)
|
|
25
|
+
: getGithubDepCacheName(name, version);
|
|
24
26
|
}
|
|
25
27
|
export function getMopsDepCacheName(name, version) {
|
|
26
28
|
return getPackageId(name, version);
|
|
27
29
|
}
|
|
28
30
|
export function getGithubDepCacheName(name, repo) {
|
|
29
31
|
const { branch, commitHash } = parseGithubURL(repo);
|
|
30
|
-
return `_github/${name}#${branch.replaceAll(
|
|
32
|
+
return (`_github/${name}#${branch.replaceAll("/", "___")}` +
|
|
33
|
+
(commitHash ? `@${commitHash}` : ""));
|
|
31
34
|
}
|
|
32
35
|
export let addCache = (cacheName, source) => {
|
|
33
|
-
let dest = path.join(getGlobalCacheDir(),
|
|
36
|
+
let dest = path.join(getGlobalCacheDir(), "packages", cacheName);
|
|
34
37
|
fs.mkdirSync(dest, { recursive: true });
|
|
35
38
|
return new Promise((resolve, reject) => {
|
|
36
39
|
ncp.ncp(source, dest, { stopOnErr: true }, (err) => {
|
|
@@ -42,7 +45,7 @@ export let addCache = (cacheName, source) => {
|
|
|
42
45
|
});
|
|
43
46
|
};
|
|
44
47
|
export let copyCache = (cacheName, dest) => {
|
|
45
|
-
let source = path.join(getGlobalCacheDir(),
|
|
48
|
+
let source = path.join(getGlobalCacheDir(), "packages", cacheName);
|
|
46
49
|
fs.mkdirSync(dest, { recursive: true });
|
|
47
50
|
return new Promise((resolve, reject) => {
|
|
48
51
|
ncp.ncp(source, dest, { stopOnErr: true }, (err) => {
|
|
@@ -58,16 +61,18 @@ export let cacheSize = async () => {
|
|
|
58
61
|
fs.mkdirSync(dir, { recursive: true });
|
|
59
62
|
let size = await getFolderSize.strict(dir);
|
|
60
63
|
if (size < 1024 * 1024) {
|
|
61
|
-
return (size / 1024).toFixed(2) +
|
|
64
|
+
return (size / 1024).toFixed(2) + " KB";
|
|
62
65
|
}
|
|
63
|
-
return (size / 1024 / 1024).toFixed(2) +
|
|
66
|
+
return (size / 1024 / 1024).toFixed(2) + " MB";
|
|
64
67
|
};
|
|
65
68
|
export let cleanCache = async () => {
|
|
66
|
-
if (!getGlobalCacheDir().endsWith(
|
|
67
|
-
|
|
69
|
+
if (!getGlobalCacheDir().endsWith("mops/cache") &&
|
|
70
|
+
!getGlobalCacheDir().endsWith("/mops") &&
|
|
71
|
+
!getGlobalCacheDir().endsWith("/mops/" + getNetwork())) {
|
|
72
|
+
throw new Error("Invalid cache directory: " + getGlobalCacheDir());
|
|
68
73
|
}
|
|
69
74
|
// local cache
|
|
70
|
-
fs.rmSync(path.join(getRootDir(),
|
|
75
|
+
fs.rmSync(path.join(getRootDir(), ".mops"), { recursive: true, force: true });
|
|
71
76
|
// global cache
|
|
72
77
|
fs.rmSync(getGlobalCacheDir(), { recursive: true, force: true });
|
|
73
78
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import { SemVer } from
|
|
3
|
-
import chalk from
|
|
4
|
-
import { getDependencyType, getRootDir, readConfig } from
|
|
5
|
-
import { resolvePackages } from
|
|
6
|
-
import { getMocVersion } from
|
|
7
|
-
import { getPackageId } from
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { SemVer } from "semver";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { getDependencyType, getRootDir, readConfig } from "./mops.js";
|
|
5
|
+
import { resolvePackages } from "./resolve-packages.js";
|
|
6
|
+
import { getMocVersion } from "./helpers/get-moc-version.js";
|
|
7
|
+
import { getPackageId } from "./helpers/get-package-id.js";
|
|
8
8
|
export async function checkRequirements({ verbose = false } = {}) {
|
|
9
9
|
let config = readConfig();
|
|
10
10
|
let mocVersion = config.toolchain?.moc;
|
|
@@ -15,14 +15,14 @@ export async function checkRequirements({ verbose = false } = {}) {
|
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
let installedMoc = new SemVer(mocVersion);
|
|
18
|
-
let highestRequiredMoc = new SemVer(
|
|
19
|
-
let highestRequiredMocPkgId =
|
|
18
|
+
let highestRequiredMoc = new SemVer("0.0.0");
|
|
19
|
+
let highestRequiredMocPkgId = "";
|
|
20
20
|
let rootDir = getRootDir();
|
|
21
21
|
let resolvedPackages = await resolvePackages();
|
|
22
22
|
for (let [name, version] of Object.entries(resolvedPackages)) {
|
|
23
|
-
if (getDependencyType(version) ===
|
|
23
|
+
if (getDependencyType(version) === "mops") {
|
|
24
24
|
let pkgId = getPackageId(name, version);
|
|
25
|
-
let depConfig = readConfig(path.join(rootDir,
|
|
25
|
+
let depConfig = readConfig(path.join(rootDir, ".mops", pkgId, "mops.toml"));
|
|
26
26
|
let moc = depConfig.requirements?.moc;
|
|
27
27
|
if (moc) {
|
|
28
28
|
let requiredMoc = new SemVer(moc);
|