ic-mops 0.39.2 → 0.41.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 +0 -0
- package/.gitignore +1 -0
- package/.npmrc +2 -1
- package/CHANGELOG.md +8 -0
- package/DEVELOPMENT.md +25 -0
- package/README.md +0 -0
- package/api/actors.ts +2 -2
- package/api/downloadPackageFiles.ts +9 -6
- package/api/getHighestVersion.ts +1 -1
- package/api/index.ts +0 -0
- package/api/network.ts +1 -1
- package/api/resolveVersion.ts +1 -1
- package/bundle/bench/bench-canister.mo +87 -0
- package/bundle/bench/user-bench.mo +14 -0
- package/bundle/bin/moc-wrapper.sh +3 -0
- package/bundle/bin/mops.js +3 -0
- package/bundle/cli.js +88 -0
- package/bundle/cli.tgz +0 -0
- package/bundle/declarations/bench/bench.did +26 -0
- package/bundle/declarations/bench/bench.did.d.ts +29 -0
- package/bundle/declarations/bench/bench.did.js +26 -0
- package/bundle/declarations/bench/index.d.ts +50 -0
- package/bundle/declarations/bench/index.js +41 -0
- package/bundle/declarations/main/index.d.ts +50 -0
- package/bundle/declarations/main/index.js +41 -0
- package/bundle/declarations/main/main.did +426 -0
- package/bundle/declarations/main/main.did.d.ts +352 -0
- package/bundle/declarations/main/main.did.js +404 -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 +37 -0
- package/bundle/declarations/storage/storage.did.js +38 -0
- package/bundle/package.json +31 -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 +22 -0
- package/bundle/templates/src/lib.mo +15 -0
- package/bundle/templates/test/lib.test.mo +4 -0
- package/bundle-package-json.ts +14 -0
- package/cache.ts +3 -3
- package/cli.ts +25 -21
- package/commands/add.ts +6 -6
- package/commands/available-updates.ts +2 -2
- package/commands/bench/bench-canister.mo +0 -0
- package/commands/bench/user-bench.mo +0 -0
- package/commands/bench-replica.ts +10 -10
- package/commands/bench.ts +96 -56
- package/commands/bump.ts +2 -2
- package/commands/docs.ts +1 -1
- package/commands/import-identity.ts +2 -2
- package/commands/init.ts +9 -9
- package/commands/install-all.ts +4 -4
- package/commands/install-local.ts +1 -1
- package/commands/install.ts +2 -2
- package/commands/outdated.ts +0 -0
- package/commands/publish.ts +34 -35
- package/commands/remove.ts +8 -8
- package/commands/search.ts +2 -2
- package/commands/self.ts +75 -0
- package/commands/sources.ts +0 -0
- package/commands/sync.ts +8 -8
- package/commands/template.ts +11 -12
- package/commands/test/mmf1.ts +18 -18
- package/commands/test/reporters/compact-reporter.ts +5 -5
- package/commands/test/reporters/files-reporter.ts +3 -3
- package/commands/test/reporters/reporter.ts +3 -3
- package/commands/test/reporters/silent-reporter.ts +4 -4
- package/commands/test/reporters/verbose-reporter.ts +3 -3
- package/commands/test/test.ts +10 -10
- package/commands/test/utils.ts +1 -1
- package/commands/toolchain/index.ts +9 -9
- package/commands/toolchain/moc.ts +2 -2
- package/commands/toolchain/pocket-ic.ts +6 -31
- package/commands/toolchain/toolchain-utils.ts +11 -11
- package/commands/toolchain/wasmtime.ts +2 -2
- package/commands/transfer-ownership.ts +2 -2
- package/commands/update.ts +4 -4
- package/commands/user.ts +2 -2
- package/commands/whoami.ts +0 -0
- package/declarations/bench/bench.did.d.ts +3 -0
- package/declarations/main/main.did +27 -1
- package/declarations/main/main.did.d.ts +26 -1
- package/declarations/main/main.did.js +27 -1
- package/declarations/storage/index.d.ts +0 -0
- package/declarations/storage/index.js +0 -0
- package/declarations/storage/storage.did +0 -0
- package/declarations/storage/storage.did.d.ts +0 -0
- package/declarations/storage/storage.did.js +0 -0
- package/dist/api/downloadPackageFiles.d.ts +1 -1
- package/dist/api/downloadPackageFiles.js +4 -0
- package/dist/bin/moc-wrapper.sh +3 -0
- package/dist/bin/mops.d.ts +1 -1
- package/dist/bin/mops.js +2 -1
- package/dist/bundle-package-json.d.ts +1 -0
- package/dist/bundle-package-json.js +11 -0
- package/dist/check-requirements.d.ts +3 -0
- package/dist/check-requirements.js +39 -0
- package/dist/cli.js +19 -18
- package/dist/commands/bench/bench-canister.mo +0 -0
- package/dist/commands/bench/user-bench.mo +0 -0
- package/dist/commands/bench-replica.d.ts +3 -1
- package/dist/commands/bench-replica.js +2 -2
- package/dist/commands/bench.d.ts +5 -2
- package/dist/commands/bench.js +66 -29
- package/dist/commands/init.js +1 -1
- package/dist/commands/publish.d.ts +1 -0
- package/dist/commands/publish.js +25 -25
- package/dist/commands/self.d.ts +3 -0
- package/dist/commands/self.js +62 -0
- package/dist/commands/template.js +9 -10
- package/dist/commands/test/mmf1.js +1 -1
- package/dist/commands/test/test.js +2 -2
- package/dist/commands/toolchain/pocket-ic.d.ts +1 -5
- package/dist/commands/toolchain/pocket-ic.js +4 -27
- package/dist/commands/toolchain/toolchain-utils.d.ts +1 -1
- package/dist/commands/toolchain/toolchain-utils.js +7 -7
- package/dist/commands/transfer-ownership.js +1 -1
- package/dist/declarations/bench/bench.did.d.ts +3 -0
- package/dist/declarations/main/main.did +27 -1
- package/dist/declarations/main/main.did.d.ts +26 -1
- package/dist/declarations/main/main.did.js +27 -1
- package/dist/declarations/storage/index.d.ts +0 -0
- package/dist/declarations/storage/index.js +0 -0
- package/dist/declarations/storage/storage.did +0 -0
- package/dist/declarations/storage/storage.did.d.ts +0 -0
- package/dist/declarations/storage/storage.did.js +0 -0
- package/dist/helpers/find-changelog-entry.d.ts +1 -0
- package/dist/helpers/find-changelog-entry.js +24 -0
- package/dist/mops.d.ts +1 -0
- package/dist/mops.js +5 -1
- package/dist/package.json +20 -26
- package/dist/release-cli.d.ts +1 -0
- package/dist/release-cli.js +37 -0
- package/dist/remove-scripts.d.ts +1 -0
- package/dist/remove-scripts.js +5 -0
- package/dist/templates/README.md +0 -0
- package/dist/templates/licenses/Apache-2.0 +0 -0
- package/dist/templates/licenses/Apache-2.0-NOTICE +0 -0
- package/dist/templates/licenses/MIT +0 -0
- package/dist/templates/mops-publish.yml +0 -0
- package/dist/templates/mops-test.yml +0 -0
- package/dist/templates/src/lib.mo +0 -0
- package/dist/templates/test/lib.test.mo +0 -0
- package/dist/templates.d.ts +1 -0
- package/dist/templates.js +4 -0
- package/dist/vessel.js +1 -1
- package/global.d.ts +0 -0
- package/helpers/find-changelog-entry.ts +27 -0
- package/helpers/get-dfx-version.ts +1 -1
- package/helpers/get-moc-path.ts +1 -1
- package/helpers/get-moc-version.ts +1 -1
- package/integrity.ts +16 -16
- package/mops.ts +22 -17
- package/notify-installs.ts +2 -2
- package/package.json +28 -19
- package/parallel.ts +1 -1
- package/pem.ts +5 -5
- package/release-cli.ts +62 -0
- package/remove-scripts.ts +6 -0
- package/resolve-packages.ts +9 -9
- package/templates/README.md +0 -0
- package/templates/licenses/Apache-2.0 +0 -0
- package/templates/licenses/Apache-2.0-NOTICE +0 -0
- package/templates/licenses/MIT +0 -0
- package/templates/mops-publish.yml +0 -0
- package/templates/mops-test.yml +0 -0
- package/templates/src/lib.mo +0 -0
- package/templates/test/lib.test.mo +0 -0
- package/templates.ts +5 -0
- package/tsconfig.json +1 -1
- package/types.ts +25 -25
- package/vessel.ts +16 -16
- package/commands/self-update.ts +0 -6
- package/dist/commands/replica.d.ts +0 -36
- package/dist/commands/replica.js +0 -103
- package/dist/commands/self-update.d.ts +0 -3
- package/dist/commands/self-update.js +0 -5
- /package/bin/{mops.ts → mops.js} +0 -0
package/.DS_Store
ADDED
|
Binary file
|
package/.eslintrc.json
CHANGED
|
File without changes
|
package/.gitignore
CHANGED
package/.npmrc
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
save-exact = true
|
|
1
|
+
save-exact = true
|
|
2
|
+
# omit = optional
|
package/CHANGELOG.md
ADDED
package/DEVELOPMENT.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Mops CLI
|
|
2
|
+
|
|
3
|
+
1. Update the version in `package.json` using `npm version` command.
|
|
4
|
+
|
|
5
|
+
2. Update changelog in `CHANGELOG.md` file.
|
|
6
|
+
|
|
7
|
+
3. Publish.
|
|
8
|
+
|
|
9
|
+
## Publish to npm
|
|
10
|
+
```
|
|
11
|
+
npm publish
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Publish on chain
|
|
15
|
+
|
|
16
|
+
1. Prepeare release
|
|
17
|
+
```
|
|
18
|
+
npm run release
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
2. Deploy canister
|
|
22
|
+
(from root of the project)
|
|
23
|
+
```
|
|
24
|
+
dfx deploy --network ic --no-wallet cli
|
|
25
|
+
```
|
package/README.md
CHANGED
|
File without changes
|
package/api/actors.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {_SERVICE as _STORAGE_SERVICE} from '../declarations/storage/storage.did.
|
|
|
9
9
|
import {getEndpoint} from './network.js';
|
|
10
10
|
import {getNetwork} from './network.js';
|
|
11
11
|
|
|
12
|
-
export let mainActor = async (identity?: Identity): Promise<_SERVICE> => {
|
|
12
|
+
export let mainActor = async (identity ?: Identity) : Promise<_SERVICE> => {
|
|
13
13
|
let network = getNetwork();
|
|
14
14
|
let host = getEndpoint(network).host;
|
|
15
15
|
let canisterId = getEndpoint(network).canisterId;
|
|
@@ -27,7 +27,7 @@ export let mainActor = async (identity?: Identity): Promise<_SERVICE> => {
|
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
export let storageActor = async (storageId: Principal, identity?: Identity): Promise<_STORAGE_SERVICE> => {
|
|
30
|
+
export let storageActor = async (storageId : Principal, identity ?: Identity) : Promise<_STORAGE_SERVICE> => {
|
|
31
31
|
let network = getNetwork();
|
|
32
32
|
let host = getEndpoint(network).host;
|
|
33
33
|
|
|
@@ -4,14 +4,14 @@ import {resolveVersion} from './resolveVersion.js';
|
|
|
4
4
|
import {parallel} from '../parallel.js';
|
|
5
5
|
import {Storage} from '../declarations/storage/storage.did.js';
|
|
6
6
|
|
|
7
|
-
export async function downloadPackageFiles(pkg: string, version = '', threads = 8, onLoad = (_fileIds: string[], _fileId: string) => {}): Promise<Map<string, Array<number>>> {
|
|
7
|
+
export async function downloadPackageFiles(pkg : string, version = '', threads = 8, onLoad = (_fileIds : string[], _fileId : string) => {}) : Promise<Map<string, Array<number>>> {
|
|
8
8
|
version = await resolveVersion(pkg, version);
|
|
9
9
|
|
|
10
10
|
let {storageId, fileIds} = await getPackageFilesInfo(pkg, version);
|
|
11
11
|
let storage = await storageActor(storageId);
|
|
12
12
|
|
|
13
13
|
let filesData = new Map<string, Array<number>>();
|
|
14
|
-
await parallel(threads, fileIds, async (fileId: string) => {
|
|
14
|
+
await parallel(threads, fileIds, async (fileId : string) => {
|
|
15
15
|
let {path, data} = await downloadFile(storage, fileId);
|
|
16
16
|
filesData.set(path, data);
|
|
17
17
|
onLoad(fileIds, fileId);
|
|
@@ -21,7 +21,7 @@ export async function downloadPackageFiles(pkg: string, version = '', threads =
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
// get package files meta
|
|
24
|
-
export async function getPackageFilesInfo(pkg: string, version: string): Promise<{ storageId: Principal, fileIds: string[] }> {
|
|
24
|
+
export async function getPackageFilesInfo(pkg : string, version : string) : Promise<{ storageId : Principal, fileIds : string[] }> {
|
|
25
25
|
let actor = await mainActor();
|
|
26
26
|
|
|
27
27
|
let [packageDetailsRes, fileIds] = await Promise.all([
|
|
@@ -41,7 +41,7 @@ export async function getPackageFilesInfo(pkg: string, version: string): Promise
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
// get package files ids
|
|
44
|
-
export async function getFileIds(pkg: string, version: string): Promise<string[]> {
|
|
44
|
+
export async function getFileIds(pkg : string, version : string) : Promise<string[]> {
|
|
45
45
|
let actor = await mainActor();
|
|
46
46
|
let fileIdsRes = await actor.getFileIds(pkg, version);
|
|
47
47
|
|
|
@@ -54,14 +54,17 @@ export async function getFileIds(pkg: string, version: string): Promise<string[]
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// download single file
|
|
57
|
-
export async function downloadFile(storage: Storage, fileId: string): Promise<{
|
|
57
|
+
export async function downloadFile(storage : Storage | string, fileId : string) : Promise<{path : string, data : Array<number>;}> {
|
|
58
|
+
if (typeof storage === 'string') {
|
|
59
|
+
storage = await storageActor(Principal.fromText(storage));
|
|
60
|
+
}
|
|
58
61
|
let fileMetaRes = await storage.getFileMeta(fileId);
|
|
59
62
|
if ('err' in fileMetaRes) {
|
|
60
63
|
throw fileMetaRes.err;
|
|
61
64
|
}
|
|
62
65
|
let fileMeta = fileMetaRes.ok;
|
|
63
66
|
|
|
64
|
-
let data: Array<number> = [];
|
|
67
|
+
let data : Array<number> = [];
|
|
65
68
|
for (let i = 0n; i < fileMeta.chunkCount; i++) {
|
|
66
69
|
let chunkRes = await storage.downloadChunk(fileId, i);
|
|
67
70
|
if ('err' in chunkRes) {
|
package/api/getHighestVersion.ts
CHANGED
package/api/index.ts
CHANGED
|
File without changes
|
package/api/network.ts
CHANGED
package/api/resolveVersion.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {getHighestVersion} from './getHighestVersion.js';
|
|
2
2
|
|
|
3
|
-
export async function resolveVersion(pkg: string, version = ''): Promise<string> {
|
|
3
|
+
export async function resolveVersion(pkg : string, version = '') : Promise<string> {
|
|
4
4
|
if (!version) {
|
|
5
5
|
let versionRes = await getHighestVersion(pkg);
|
|
6
6
|
if ('err' in versionRes) {
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import Nat64 "mo:base/Nat64";
|
|
2
|
+
import Nat "mo:base/Nat";
|
|
3
|
+
import Debug "mo:base/Debug";
|
|
4
|
+
import ExperimentalInternetComputer "mo:base/ExperimentalInternetComputer";
|
|
5
|
+
import Prim "mo:prim";
|
|
6
|
+
import Bench "mo:bench";
|
|
7
|
+
|
|
8
|
+
import UserBench "./user-bench"; // file path will be replaced with the *.bench.mo file path
|
|
9
|
+
|
|
10
|
+
actor class() {
|
|
11
|
+
var benchOpt : ?Bench.Bench = null;
|
|
12
|
+
|
|
13
|
+
public func init() : async Bench.BenchSchema {
|
|
14
|
+
let bench = UserBench.init();
|
|
15
|
+
benchOpt := ?bench;
|
|
16
|
+
bench.getSchema();
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
public query func getSchema() : async Bench.BenchSchema {
|
|
20
|
+
let ?bench = benchOpt else Debug.trap("bench not initialized");
|
|
21
|
+
bench.getSchema();
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
func _getStats() : Bench.BenchResult {
|
|
25
|
+
{
|
|
26
|
+
instructions = 0;
|
|
27
|
+
rts_heap_size = Prim.rts_heap_size();
|
|
28
|
+
rts_memory_size = Prim.rts_memory_size();
|
|
29
|
+
rts_total_allocation = Prim.rts_total_allocation();
|
|
30
|
+
rts_mutator_instructions = Prim.rts_mutator_instructions();
|
|
31
|
+
rts_collector_instructions = Prim.rts_collector_instructions();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
func _diffStats(before : Bench.BenchResult, after : Bench.BenchResult) : Bench.BenchResult {
|
|
36
|
+
{
|
|
37
|
+
instructions = after.instructions - before.instructions;
|
|
38
|
+
rts_heap_size = after.rts_heap_size - before.rts_heap_size;
|
|
39
|
+
rts_memory_size = after.rts_memory_size - before.rts_memory_size;
|
|
40
|
+
rts_total_allocation = after.rts_total_allocation - before.rts_total_allocation;
|
|
41
|
+
rts_mutator_instructions = after.rts_mutator_instructions - before.rts_mutator_instructions;
|
|
42
|
+
rts_collector_instructions = after.rts_collector_instructions - before.rts_collector_instructions;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
func _runCell(rowIndex : Nat, colIndex : Nat) : Bench.BenchResult {
|
|
47
|
+
let ?bench = benchOpt else Debug.trap("bench not initialized");
|
|
48
|
+
let statsBefore = _getStats();
|
|
49
|
+
|
|
50
|
+
let instructions = Nat64.toNat(ExperimentalInternetComputer.countInstructions(func() {
|
|
51
|
+
bench.runCell(rowIndex, colIndex);
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
let statsAfter = _getStats();
|
|
55
|
+
_diffStats(statsBefore, { statsAfter with instructions });
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
func _runCellAwait(rowIndex : Nat, colIndex : Nat) : async Bench.BenchResult {
|
|
59
|
+
let ?bench = benchOpt else Debug.trap("bench not initialized");
|
|
60
|
+
let statsBefore = _getStats();
|
|
61
|
+
|
|
62
|
+
let instructions = Nat64.toNat(ExperimentalInternetComputer.countInstructions(func() {
|
|
63
|
+
bench.runCell(rowIndex, colIndex);
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
await (func() : async () {})();
|
|
67
|
+
|
|
68
|
+
let statsAfter = _getStats();
|
|
69
|
+
_diffStats(statsBefore, { statsAfter with instructions });
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
public query func getStats() : async Bench.BenchResult {
|
|
73
|
+
_getStats();
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
public query func runCellQuery(rowIndex : Nat, colIndex : Nat) : async Bench.BenchResult {
|
|
77
|
+
_runCell(rowIndex, colIndex);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
public func runCellUpdate(rowIndex : Nat, colIndex : Nat) : async Bench.BenchResult {
|
|
81
|
+
_runCell(rowIndex, colIndex);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
public func runCellUpdateAwait(rowIndex : Nat, colIndex : Nat) : async Bench.BenchResult {
|
|
85
|
+
await _runCellAwait(rowIndex, colIndex);
|
|
86
|
+
};
|
|
87
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import Nat "mo:base/Nat";
|
|
2
|
+
import Iter "mo:base/Iter";
|
|
3
|
+
import Buffer "mo:base/Buffer";
|
|
4
|
+
import Vector "mo:vector/Class";
|
|
5
|
+
import Bench "mo:bench";
|
|
6
|
+
|
|
7
|
+
// placeholder file that will be replaced with the *.bench.mo file
|
|
8
|
+
module {
|
|
9
|
+
public func init() : Bench.Bench {
|
|
10
|
+
let bench = Bench.Bench();
|
|
11
|
+
// benchmark code goes here...
|
|
12
|
+
bench;
|
|
13
|
+
};
|
|
14
|
+
};
|