ic-mops 2.1.0 → 2.2.1
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/CHANGELOG.md +8 -0
- package/RELEASE.md +19 -0
- package/bundle/bench/bench-canister.mo +130 -0
- package/bundle/bench/user-bench.mo +10 -0
- package/bundle/bin/moc-wrapper.sh +40 -0
- package/bundle/bin/mops.js +3 -0
- package/bundle/cli.js +1569 -0
- package/bundle/cli.tgz +0 -0
- package/bundle/declarations/bench/bench.did +30 -0
- package/bundle/declarations/bench/bench.did.d.ts +33 -0
- package/bundle/declarations/bench/bench.did.js +30 -0
- package/bundle/declarations/bench/index.d.ts +50 -0
- package/bundle/declarations/bench/index.js +40 -0
- package/bundle/declarations/main/index.d.ts +50 -0
- package/bundle/declarations/main/index.js +40 -0
- package/bundle/declarations/main/main.did +428 -0
- package/bundle/declarations/main/main.did.d.ts +348 -0
- package/bundle/declarations/main/main.did.js +406 -0
- package/bundle/declarations/storage/index.d.ts +50 -0
- package/bundle/declarations/storage/index.js +30 -0
- package/bundle/declarations/storage/storage.did +46 -0
- package/bundle/declarations/storage/storage.did.d.ts +40 -0
- package/bundle/declarations/storage/storage.did.js +38 -0
- package/bundle/default-stylesheet.css +415 -0
- package/bundle/package.json +36 -0
- package/bundle/templates/README.md +13 -0
- package/bundle/templates/licenses/Apache-2.0 +202 -0
- package/bundle/templates/licenses/Apache-2.0-NOTICE +13 -0
- package/bundle/templates/licenses/MIT +21 -0
- package/bundle/templates/mops-publish.yml +17 -0
- package/bundle/templates/mops-test.yml +24 -0
- package/bundle/templates/src/lib.mo +15 -0
- package/bundle/templates/test/lib.test.mo +4 -0
- package/bundle/wasm_bg.wasm +0 -0
- package/bundle/xhr-sync-worker.js +51 -0
- package/cli.ts +15 -0
- package/commands/bench.ts +11 -3
- package/commands/build.ts +3 -2
- package/commands/check.ts +4 -0
- package/commands/test/test.ts +3 -1
- package/commands/toolchain/index.ts +4 -0
- package/commands/watch/error-checker.ts +8 -2
- package/commands/watch/warning-checker.ts +8 -2
- package/dist/cli.js +13 -1
- package/dist/commands/bench.js +5 -4
- package/dist/commands/build.js +3 -2
- package/dist/commands/check.js +4 -0
- package/dist/commands/test/test.js +3 -1
- package/dist/commands/toolchain/index.js +3 -0
- package/dist/commands/watch/error-checker.js +8 -2
- package/dist/commands/watch/warning-checker.js +8 -2
- package/dist/error.d.ts +1 -1
- package/dist/helpers/autofix-motoko.js +84 -39
- package/dist/mops.d.ts +1 -0
- package/dist/mops.js +10 -4
- package/dist/package.json +6 -7
- package/dist/tests/check-fix.test.js +16 -0
- package/dist/tests/check.test.js +4 -0
- package/dist/tests/moc-args.test.d.ts +1 -0
- package/dist/tests/moc-args.test.js +17 -0
- package/dist/tests/toolchain.test.js +11 -0
- package/dist/types.d.ts +3 -0
- 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/wasm_bg.wasm +0 -0
- package/dist/wasm/pkg/web/wasm_bg.wasm +0 -0
- package/error.ts +1 -1
- package/helpers/autofix-motoko.ts +119 -49
- package/mops.ts +13 -6
- package/package.json +8 -9
- package/tests/__snapshots__/check-fix.test.ts.snap +25 -6
- package/tests/__snapshots__/check.test.ts.snap +9 -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/check/fix/overlapping.mo +10 -0
- package/tests/check/moc-args/Warning.mo +5 -0
- package/tests/check/moc-args/mops.toml +2 -0
- package/tests/check-fix.test.ts +23 -0
- package/tests/check.test.ts +5 -0
- package/tests/moc-args.test.ts +19 -0
- package/tests/toolchain-local-subpath/bin/moc +2 -0
- package/tests/toolchain-local-subpath/mops.toml +2 -0
- package/tests/toolchain.test.ts +13 -0
- package/types.ts +3 -0
- package/wasm/Cargo.lock +54 -101
- 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/wasm_bg.wasm +0 -0
- package/wasm/pkg/web/wasm_bg.wasm +0 -0
package/.DS_Store
ADDED
|
Binary file
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Next
|
|
4
4
|
|
|
5
|
+
## 2.2.1
|
|
6
|
+
- Fix `mops toolchain` when toolchain version is a local file path with subdirectories.
|
|
7
|
+
|
|
8
|
+
## 2.2.0
|
|
9
|
+
- Add `[moc]` config section for global `moc` compiler flags (applied to `check`, `build`, `test`, `bench`, `watch`)
|
|
10
|
+
- Add `mops moc-args` command to print global `moc` flags from `[moc]` config section
|
|
11
|
+
- Fix `mops check --fix` crash on overlapping diagnostic edits (e.g., nested function calls)
|
|
12
|
+
|
|
5
13
|
## 2.1.0
|
|
6
14
|
- Add `mops check --fix` subcommand (for Motoko files) with autofix logic
|
|
7
15
|
- Add `mops check` subcommand for type-checking Motoko files
|
package/RELEASE.md
CHANGED
|
@@ -130,6 +130,25 @@ dfx deploy --network ic --no-wallet cli --identity mops
|
|
|
130
130
|
|
|
131
131
|
This deploys the `cli-releases` canister (serving `cli.mops.one`) to the Internet Computer mainnet.
|
|
132
132
|
|
|
133
|
+
### 10. Commit and push release artifacts
|
|
134
|
+
|
|
135
|
+
Step 8 generates files in `cli-releases/` that must be committed and pushed:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
git add cli-releases/
|
|
139
|
+
git commit -m "cli-releases: v<version> artifacts"
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Since direct pushes to `main` are not allowed, create a branch and PR:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
git checkout -b <username>/release-X.Y.Z-artifacts
|
|
146
|
+
git push -u origin <username>/release-X.Y.Z-artifacts
|
|
147
|
+
gh pr create --title "cli-releases: vX.Y.Z artifacts" --body "Release artifacts generated by \`npm run release-cli\` for CLI vX.Y.Z."
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Merge this PR after approval.
|
|
151
|
+
|
|
133
152
|
## Verify build
|
|
134
153
|
|
|
135
154
|
Anyone can verify a released version by rebuilding from source:
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import Nat64 "mo:core/Nat64";
|
|
2
|
+
import Nat "mo:core/Nat";
|
|
3
|
+
import Runtime "mo:core/Runtime";
|
|
4
|
+
import InternetComputer "mo:core/InternetComputer";
|
|
5
|
+
import Region "mo:core/Region";
|
|
6
|
+
import Prim "mo:prim";
|
|
7
|
+
|
|
8
|
+
import UserBench "./user-bench"; // file path will be replaced with the *.bench.mo file path
|
|
9
|
+
|
|
10
|
+
persistent actor class () {
|
|
11
|
+
type BenchSchema = {
|
|
12
|
+
name : Text;
|
|
13
|
+
description : Text;
|
|
14
|
+
rows : [Text];
|
|
15
|
+
cols : [Text];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type Bench = {
|
|
19
|
+
getVersion : () -> Nat;
|
|
20
|
+
getSchema : () -> BenchSchema;
|
|
21
|
+
runCell : (Nat, Nat) -> ();
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type BenchResult = {
|
|
25
|
+
instructions : Int;
|
|
26
|
+
rts_mutator_instructions : Int;
|
|
27
|
+
stable_memory_size : Int;
|
|
28
|
+
rts_stable_memory_size : Int;
|
|
29
|
+
rts_logical_stable_memory_size : Int;
|
|
30
|
+
rts_collector_instructions : Int;
|
|
31
|
+
rts_heap_size : Int;
|
|
32
|
+
rts_memory_size : Int;
|
|
33
|
+
rts_total_allocation : Int;
|
|
34
|
+
rts_reclaimed : Int;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
transient var benchOpt : ?Bench = null;
|
|
38
|
+
|
|
39
|
+
public func init() : async BenchSchema {
|
|
40
|
+
let bench = UserBench.init();
|
|
41
|
+
benchOpt := ?bench;
|
|
42
|
+
ignore Region.grow(Region.new(), 1);
|
|
43
|
+
bench.getSchema();
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
public query func getSchema() : async BenchSchema {
|
|
47
|
+
let ?bench = benchOpt else Runtime.trap("bench not initialized");
|
|
48
|
+
bench.getSchema();
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
func _getStats() : BenchResult {
|
|
52
|
+
{
|
|
53
|
+
instructions = 0;
|
|
54
|
+
rts_heap_size = Prim.rts_heap_size();
|
|
55
|
+
stable_memory_size = Prim.rts_stable_memory_size() * 65536;
|
|
56
|
+
rts_stable_memory_size = Prim.rts_stable_memory_size();
|
|
57
|
+
rts_logical_stable_memory_size = Prim.rts_logical_stable_memory_size();
|
|
58
|
+
rts_memory_size = Prim.rts_memory_size();
|
|
59
|
+
rts_total_allocation = Prim.rts_total_allocation();
|
|
60
|
+
rts_reclaimed = Prim.rts_reclaimed();
|
|
61
|
+
rts_mutator_instructions = Prim.rts_mutator_instructions();
|
|
62
|
+
rts_collector_instructions = Prim.rts_collector_instructions();
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
func _diffStats(before : BenchResult, after : BenchResult) : BenchResult {
|
|
67
|
+
{
|
|
68
|
+
instructions = after.instructions - before.instructions;
|
|
69
|
+
rts_heap_size = after.rts_heap_size - before.rts_heap_size;
|
|
70
|
+
stable_memory_size = after.stable_memory_size - before.stable_memory_size;
|
|
71
|
+
rts_stable_memory_size = after.rts_stable_memory_size - before.rts_stable_memory_size;
|
|
72
|
+
rts_logical_stable_memory_size = after.rts_logical_stable_memory_size - before.rts_logical_stable_memory_size;
|
|
73
|
+
rts_memory_size = after.rts_memory_size - before.rts_memory_size;
|
|
74
|
+
rts_total_allocation = after.rts_total_allocation - before.rts_total_allocation;
|
|
75
|
+
rts_reclaimed = after.rts_reclaimed - before.rts_reclaimed;
|
|
76
|
+
rts_mutator_instructions = after.rts_mutator_instructions - before.rts_mutator_instructions;
|
|
77
|
+
rts_collector_instructions = after.rts_collector_instructions - before.rts_collector_instructions;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
func _runCell(rowIndex : Nat, colIndex : Nat) : BenchResult {
|
|
82
|
+
let ?bench = benchOpt else Runtime.trap("bench not initialized");
|
|
83
|
+
let statsBefore = _getStats();
|
|
84
|
+
|
|
85
|
+
let instructions = Nat64.toNat(
|
|
86
|
+
InternetComputer.countInstructions(
|
|
87
|
+
func() {
|
|
88
|
+
bench.runCell(rowIndex, colIndex);
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
let statsAfter = _getStats();
|
|
94
|
+
_diffStats(statsBefore, { statsAfter with instructions });
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
func _runCellAwait(rowIndex : Nat, colIndex : Nat) : async BenchResult {
|
|
98
|
+
let ?bench = benchOpt else Runtime.trap("bench not initialized");
|
|
99
|
+
let statsBefore = _getStats();
|
|
100
|
+
|
|
101
|
+
let instructions = Nat64.toNat(
|
|
102
|
+
InternetComputer.countInstructions(
|
|
103
|
+
func() {
|
|
104
|
+
bench.runCell(rowIndex, colIndex);
|
|
105
|
+
}
|
|
106
|
+
)
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
await (func() : async () {})();
|
|
110
|
+
|
|
111
|
+
let statsAfter = _getStats();
|
|
112
|
+
_diffStats(statsBefore, { statsAfter with instructions });
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
public query func getStats() : async BenchResult {
|
|
116
|
+
_getStats();
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
public query func runCellQuery(rowIndex : Nat, colIndex : Nat) : async BenchResult {
|
|
120
|
+
_runCell(rowIndex, colIndex);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
public func runCellUpdate(rowIndex : Nat, colIndex : Nat) : async BenchResult {
|
|
124
|
+
_runCell(rowIndex, colIndex);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
public func runCellUpdateAwait(rowIndex : Nat, colIndex : Nat) : async BenchResult {
|
|
128
|
+
await _runCellAwait(rowIndex, colIndex);
|
|
129
|
+
};
|
|
130
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# set -e
|
|
4
|
+
|
|
5
|
+
findRootDir() {
|
|
6
|
+
dir="$(pwd)"
|
|
7
|
+
while [[ "$dir" != "" && ! -e "$dir/mops.toml" ]]; do
|
|
8
|
+
dir=${dir%/*}
|
|
9
|
+
done
|
|
10
|
+
echo "$dir"
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
rootDir=$(findRootDir)
|
|
14
|
+
mopsToml="$rootDir/mops.toml"
|
|
15
|
+
|
|
16
|
+
if [[ $rootDir == "" ]] || [[ ! -f $mopsToml ]]; then
|
|
17
|
+
mocPath="$(mops toolchain bin moc --fallback)"
|
|
18
|
+
else
|
|
19
|
+
if command -v openssl >/dev/null 2>&1; then
|
|
20
|
+
mopsTomlHash=$(openssl sha256 $mopsToml | awk -F'= ' '{print $2}')
|
|
21
|
+
else
|
|
22
|
+
mopsTomlHash=$(shasum $mopsToml -a 256 | awk -F' ' '{print $1}')
|
|
23
|
+
fi;
|
|
24
|
+
|
|
25
|
+
cached="$rootDir/.mops/moc-$(uname -n)-$mopsTomlHash"
|
|
26
|
+
|
|
27
|
+
if [ -f $cached ]; then
|
|
28
|
+
mocPath=$(cat $cached)
|
|
29
|
+
if [[ "$mocPath" != *"/moc" ]] ; then
|
|
30
|
+
mocPath="$(mops toolchain bin moc --fallback)"
|
|
31
|
+
echo -n $mocPath > "$cached"
|
|
32
|
+
fi;
|
|
33
|
+
else
|
|
34
|
+
mkdir -p "$(dirname $cached)"
|
|
35
|
+
mocPath="$(mops toolchain bin moc --fallback)"
|
|
36
|
+
echo -n $mocPath > "$cached"
|
|
37
|
+
fi;
|
|
38
|
+
fi;
|
|
39
|
+
|
|
40
|
+
$mocPath "$@"
|