ic-mops 0.37.0-pre.0 → 0.37.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.
Files changed (101) hide show
  1. package/bin/moc-wrapper.sh +1 -52
  2. package/cache.ts +2 -2
  3. package/cli.ts +27 -6
  4. package/commands/add.ts +3 -1
  5. package/commands/bench-replica.ts +5 -3
  6. package/commands/docs.ts +9 -6
  7. package/commands/install-all.ts +7 -2
  8. package/commands/install.ts +5 -1
  9. package/commands/publish.ts +2 -0
  10. package/commands/test/test.ts +42 -19
  11. package/commands/toolchain/index.ts +214 -42
  12. package/commands/toolchain/moc.ts +19 -4
  13. package/commands/toolchain/pocket-ic.ts +43 -6
  14. package/commands/toolchain/toolchain-utils.ts +14 -5
  15. package/commands/toolchain/wasmtime.ts +19 -4
  16. package/dist/cache.js +2 -2
  17. package/dist/cli.js +24 -6
  18. package/dist/commands/add.js +2 -1
  19. package/dist/commands/bench-replica.d.ts +1 -1
  20. package/dist/commands/bench-replica.js +5 -3
  21. package/dist/commands/docs.js +9 -6
  22. package/dist/commands/install-all.js +5 -2
  23. package/dist/commands/install.js +5 -1
  24. package/dist/commands/publish.js +1 -0
  25. package/dist/commands/test/test.js +41 -19
  26. package/dist/commands/toolchain/index.d.ts +17 -3
  27. package/dist/commands/toolchain/index.js +187 -40
  28. package/dist/commands/toolchain/moc.d.ts +5 -1
  29. package/dist/commands/toolchain/moc.js +16 -4
  30. package/dist/commands/toolchain/mocv.js +0 -1
  31. package/dist/commands/toolchain/pocket-ic.d.ts +9 -1
  32. package/dist/commands/toolchain/pocket-ic.js +40 -6
  33. package/dist/commands/toolchain/toolchain-utils.d.ts +1 -1
  34. package/dist/commands/toolchain/toolchain-utils.js +13 -4
  35. package/dist/commands/toolchain/wasmtime.d.ts +5 -1
  36. package/dist/commands/toolchain/wasmtime.js +16 -4
  37. package/dist/integrity.js +40 -15
  38. package/dist/mops.js +1 -1
  39. package/dist/package.json +2 -2
  40. package/dist/pic-js/examples/clock/tests/clock/index.d.ts +1 -0
  41. package/dist/pic-js/examples/clock/tests/clock/index.js +5 -0
  42. package/dist/pic-js/examples/clock/tests/jest.config.d.ts +3 -0
  43. package/dist/pic-js/examples/clock/tests/jest.config.js +8 -0
  44. package/dist/pic-js/examples/clock/tests/src/clock.spec.d.ts +1 -0
  45. package/dist/pic-js/examples/clock/tests/src/clock.spec.js +48 -0
  46. package/dist/pic-js/examples/counter/tests/counter/index.d.ts +1 -0
  47. package/dist/pic-js/examples/counter/tests/counter/index.js +5 -0
  48. package/dist/pic-js/examples/counter/tests/jest.config.d.ts +3 -0
  49. package/dist/pic-js/examples/counter/tests/jest.config.js +8 -0
  50. package/dist/pic-js/examples/counter/tests/src/counter.spec.d.ts +1 -0
  51. package/dist/pic-js/examples/counter/tests/src/counter.spec.js +80 -0
  52. package/dist/pic-js/examples/todo/tests/jest.config.d.ts +3 -0
  53. package/dist/pic-js/examples/todo/tests/jest.config.js +8 -0
  54. package/dist/pic-js/examples/todo/tests/src/todo.spec.d.ts +1 -0
  55. package/dist/pic-js/examples/todo/tests/src/todo.spec.js +211 -0
  56. package/dist/pic-js/examples/todo/tests/todo/index.d.ts +1 -0
  57. package/dist/pic-js/examples/todo/tests/todo/index.js +5 -0
  58. package/dist/pic-js/packages/pic/src/error.d.ts +12 -0
  59. package/dist/pic-js/packages/pic/src/error.js +36 -0
  60. package/dist/pic-js/packages/pic/src/http-client.d.ts +15 -0
  61. package/dist/pic-js/packages/pic/src/http-client.js +37 -0
  62. package/dist/pic-js/packages/pic/src/identity.d.ts +66 -0
  63. package/dist/pic-js/packages/pic/src/identity.js +86 -0
  64. package/dist/pic-js/packages/pic/src/index.d.ts +4 -0
  65. package/dist/pic-js/packages/pic/src/index.js +8 -0
  66. package/dist/pic-js/packages/pic/src/management-canister.d.ts +30 -0
  67. package/dist/pic-js/packages/pic/src/management-canister.js +43 -0
  68. package/dist/pic-js/packages/pic/src/pocket-ic-actor.d.ts +83 -0
  69. package/dist/pic-js/packages/pic/src/pocket-ic-actor.js +58 -0
  70. package/dist/pic-js/packages/pic/src/pocket-ic-client-types.d.ts +61 -0
  71. package/dist/pic-js/packages/pic/src/pocket-ic-client-types.js +2 -0
  72. package/dist/pic-js/packages/pic/src/pocket-ic-client.d.ts +24 -0
  73. package/dist/pic-js/packages/pic/src/pocket-ic-client.js +123 -0
  74. package/dist/pic-js/packages/pic/src/pocket-ic-server.d.ts +10 -0
  75. package/dist/pic-js/packages/pic/src/pocket-ic-server.js +55 -0
  76. package/dist/pic-js/packages/pic/src/pocket-ic-types.d.ts +40 -0
  77. package/dist/pic-js/packages/pic/src/pocket-ic-types.js +2 -0
  78. package/dist/pic-js/packages/pic/src/pocket-ic.d.ts +447 -0
  79. package/dist/pic-js/packages/pic/src/pocket-ic.js +551 -0
  80. package/dist/pic-js/packages/pic/src/util/candid.d.ts +1 -0
  81. package/dist/pic-js/packages/pic/src/util/candid.js +7 -0
  82. package/dist/pic-js/packages/pic/src/util/encoding.d.ts +5 -0
  83. package/dist/pic-js/packages/pic/src/util/encoding.js +19 -0
  84. package/dist/pic-js/packages/pic/src/util/fs.d.ts +4 -0
  85. package/dist/pic-js/packages/pic/src/util/fs.js +29 -0
  86. package/dist/pic-js/packages/pic/src/util/index.d.ts +5 -0
  87. package/dist/pic-js/packages/pic/src/util/index.js +21 -0
  88. package/dist/pic-js/packages/pic/src/util/os.d.ts +4 -0
  89. package/dist/pic-js/packages/pic/src/util/os.js +19 -0
  90. package/dist/pic-js/packages/pic/src/util/poll.d.ts +5 -0
  91. package/dist/pic-js/packages/pic/src/util/poll.js +28 -0
  92. package/dist/templates/mops-test.yml +4 -4
  93. package/dist/vessel.js +5 -1
  94. package/integrity.ts +57 -17
  95. package/mops.ts +1 -1
  96. package/package.json +2 -2
  97. package/templates/mops-test.yml +4 -4
  98. package/vessel.ts +6 -1
  99. package/bun.lockb +0 -0
  100. package/commands/toolchain/mocv.ts +0 -313
  101. package/moc-wrapper.ts +0 -10
@@ -1,54 +1,3 @@
1
1
  #!/bin/bash
2
-
3
- # FILE_NAME=$(basename "$0");
4
-
5
- # function findMopsTomlFile() {
6
- # if [ -f "mops.toml" ]; then
7
- # printf '%s\n' "${PWD%/}/mops.toml"
8
- # elif [ "$PWD" = / ]; then
9
- # false
10
- # else
11
- # # a subshell so that we don't affect the caller's $PWD
12
- # (cd .. && findMopsTomlFile "mops.toml")
13
- # fi
14
- # }
15
-
16
- # mopsTomlFile="$(findMopsTomlFile)"
17
-
18
- # cat $mopsTomlFile
19
-
20
- # mocPath=""
21
- # if [ -z "$mopsTomlFile" ]
22
- # then
23
- # mocPath="$HOME/.cache/mocv/versions/$(cat $HOME/.cache/mocv/versions/current/version.txt)/$FILE_NAME"
24
- # # mocPath="$(DFX_WARNING=-version_check dfx cache show)/$FILE_NAME"
25
- # else
26
- # mocPath="$HOME/.cache/mocv/versions/$(cat $mopsTomlFile)/$FILE_NAME"
27
- # fi
28
-
29
- # fallback to dfx
30
- # mocPath="$(DFX_WARNING=-version_check dfx cache show)/moc"
31
-
32
- # echo $mocPath
33
-
34
- # # install moc version if not installed yet
35
- # if [[ ! -f "$mocPath" && -f "$mopsTomlFile" ]]; then
36
- # # mocv install --silent $(cat $mopsTomlFile)
37
- # mocv use $(cat $mopsTomlFile)
38
- # fi
39
-
40
- # mocPath="/home/zen/.cache/mocv/versions/current/moc"
41
-
42
- # mocPath=""
43
- # if command -v mops &> /dev/null
44
- # then
45
- # mocPath="/home/zen/.cache/mops/moc/0.9.5/moc"
46
- # else
47
- # mocPath="$(DFX_WARNING=-version_check dfx cache show)/moc" # fallback to dfx
48
- # fi
49
-
50
- mocPath="$(mops toolchain bin moc)"
51
- # mocPath="$(dfx cache show)/moc"
52
- # mocPath="/home/zen/.cache/mops/moc/0.7.5/moc"
53
-
2
+ mocPath="$(mops toolchain bin moc --fallback)"
54
3
  $mocPath "$@"
package/cache.ts CHANGED
@@ -39,7 +39,7 @@ export let copyCache = (pkgId: string, dest: string) => {
39
39
  };
40
40
 
41
41
  export let cacheSize = async () => {
42
- let dir = path.join(globalCacheDir, 'packages');
42
+ let dir = path.join(globalCacheDir);
43
43
  fs.mkdirSync(dir, {recursive: true});
44
44
 
45
45
  let size = await getFolderSize.strict(dir);
@@ -50,6 +50,6 @@ export let cacheSize = async () => {
50
50
  };
51
51
 
52
52
  export let cleanCache = async () => {
53
- let dir = path.join(globalCacheDir, 'packages');
53
+ let dir = path.join(globalCacheDir);
54
54
  fs.rmSync(dir, {recursive: true, force: true});
55
55
  };
package/cli.ts CHANGED
@@ -25,6 +25,7 @@ import {update} from './commands/update.js';
25
25
  import {bench} from './commands/bench.js';
26
26
  import {transferOwnership} from './commands/transfer-ownership.js';
27
27
  import {toolchain} from './commands/toolchain/index.js';
28
+ import {Tool} from './types.js';
28
29
  // import {docs} from './commands/docs.js';
29
30
 
30
31
  declare global {
@@ -101,6 +102,8 @@ program
101
102
  return;
102
103
  }
103
104
 
105
+ await toolchain.ensureToolchainInited({strict: false});
106
+
104
107
  if (pkg) {
105
108
  // @deprecated
106
109
  console.log(chalk.yellow('Consider using the \'mops add\' command to install a specific package.'));
@@ -108,6 +111,7 @@ program
108
111
  }
109
112
  else {
110
113
  await installAll(options);
114
+ await toolchain.installAll(options);
111
115
  }
112
116
  });
113
117
 
@@ -166,6 +170,7 @@ program
166
170
  process.exit(1);
167
171
  }
168
172
  await installAll({silent: true, lock: 'ignore'});
173
+ await toolchain.ensureToolchainInited({strict: false});
169
174
  let sourcesArr = await sources(options);
170
175
  console.log(sourcesArr.join('\n'));
171
176
  });
@@ -335,31 +340,47 @@ toolchainCommand
335
340
  .command('init')
336
341
  .description('One-time initialization of toolchain management')
337
342
  .action(async () => {
338
- toolchain.init();
343
+ await toolchain.init();
339
344
  });
340
345
 
341
346
  toolchainCommand
342
347
  .command('reset')
343
348
  .description('Uninstall toolchain management')
344
349
  .action(async () => {
345
- toolchain.init({reset: true});
350
+ await toolchain.init({reset: true});
346
351
  });
347
352
 
348
353
  toolchainCommand
349
354
  .command('use')
350
355
  .description('Install specified tool version and update mops.toml')
351
356
  .addArgument(new Argument('<tool>').choices(['moc', 'wasmtime', 'pocket-ic']))
352
- .addArgument(new Argument('<version>'))
357
+ .addArgument(new Argument('[version]'))
353
358
  .action(async (tool, version) => {
354
- toolchain.use(tool, version);
359
+ if (!checkConfigFile()) {
360
+ process.exit(1);
361
+ }
362
+ await toolchain.use(tool, version);
363
+ });
364
+
365
+ toolchainCommand
366
+ .command('update')
367
+ .description('Update specified tool or all tools to the latest version and update mops.toml')
368
+ .addArgument(new Argument('[tool]').choices(['moc', 'wasmtime', 'pocket-ic']))
369
+ .action(async (tool?: Tool) => {
370
+ if (!checkConfigFile()) {
371
+ process.exit(1);
372
+ }
373
+ await toolchain.update(tool);
355
374
  });
356
375
 
357
376
  toolchainCommand
358
377
  .command('bin')
359
378
  .description('Get path to the tool binary\n<tool> can be one of "moc", "wasmtime", "pocket-ic"')
360
379
  .addArgument(new Argument('<tool>').choices(['moc', 'wasmtime', 'pocket-ic']))
361
- .action(async (tool) => {
362
- toolchain.bin(tool);
380
+ .addOption(new Option('--fallback', 'Fallback to the moc that comes with dfx if moc is not specified in the [toolchain] section'))
381
+ .action(async (tool, options) => {
382
+ let bin = await toolchain.bin(tool, options);
383
+ console.log(bin);
363
384
  });
364
385
 
365
386
  program.addCommand(toolchainCommand);
package/commands/add.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import path from 'node:path';
2
2
  import chalk from 'chalk';
3
- import logUpdate from 'log-update';
3
+ import {createLogUpdate} from 'log-update';
4
4
  import {checkConfigFile, getGithubCommit, parseGithubURL, readConfig, writeConfig} from '../mops.js';
5
5
  import {getHighestVersion} from '../api/getHighestVersion.js';
6
6
  import {installFromGithub} from '../vessel.js';
@@ -109,6 +109,8 @@ export async function add(name: string, {verbose = false, dev = false, lock}: Ad
109
109
 
110
110
  writeConfig(config);
111
111
 
112
+ let logUpdate = createLogUpdate(process.stdout, {showCursor: true});
113
+
112
114
  if (lock !== 'ignore') {
113
115
  logUpdate('Checking integrity...');
114
116
  }
@@ -2,9 +2,10 @@ import {execSync} from 'node:child_process';
2
2
  import path from 'node:path';
3
3
  import fs from 'node:fs';
4
4
  import {execaCommand} from 'execa';
5
- import {PocketIc} from '@hadronous/pic';
5
+ import {PocketIc} from 'pic-ic';
6
6
  import {getRootDir} from '../mops.js';
7
7
  import {createActor, idlFactory} from '../declarations/bench/index.js';
8
+ import {toolchain} from './toolchain/index.js';
8
9
 
9
10
  export class BenchReplica {
10
11
  type : 'dfx' | 'pocket-ic';
@@ -27,7 +28,8 @@ export class BenchReplica {
27
28
  execSync('dfx start --background --clean --artificial-delay 0' + (this.verbose ? '' : ' -qqqq'), {cwd: dir, stdio: ['inherit', this.verbose ? 'inherit' : 'ignore', 'inherit']});
28
29
  }
29
30
  else {
30
- this.pocketIc = await PocketIc.create();
31
+ let pocketIcBin = await toolchain.bin('pocket-ic');
32
+ this.pocketIc = await PocketIc.create(pocketIcBin);
31
33
  }
32
34
  }
33
35
 
@@ -37,7 +39,7 @@ export class BenchReplica {
37
39
  execSync('dfx stop' + (this.verbose ? '' : ' -qqqq'), {cwd: dir, stdio: ['pipe', this.verbose ? 'inherit' : 'ignore', 'pipe']});
38
40
  }
39
41
  else if (this.pocketIc) {
40
- this.pocketIc.tearDown();
42
+ await this.pocketIc.tearDown();
41
43
  }
42
44
  }
43
45
 
package/commands/docs.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {spawn, execSync} from 'node:child_process';
1
+ import {spawn} from 'node:child_process';
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import chalk from 'chalk';
@@ -8,8 +8,9 @@ import tar from 'tar';
8
8
  import streamToPromise from 'stream-to-promise';
9
9
 
10
10
  import {getRootDir} from '../mops.js';
11
+ import {toolchain} from './toolchain/index.js';
11
12
 
12
- let moDoc: string;
13
+ let moDocPath: string;
13
14
 
14
15
  export async function docs({silent = false} = {}) {
15
16
  let rootDir = getRootDir();
@@ -18,17 +19,19 @@ export async function docs({silent = false} = {}) {
18
19
 
19
20
  deleteSync([docsDir], {force: true});
20
21
 
21
- // detect mocv
22
+ // detect mocv (legacy)
22
23
  if (process.env.DFX_MOC_PATH && process.env.DFX_MOC_PATH.includes('mocv/versions')) {
23
- moDoc = process.env.DFX_MOC_PATH.replace(/\/moc$/, '/mo-doc');
24
+ moDocPath = process.env.DFX_MOC_PATH.replace(/\/moc$/, '/mo-doc');
24
25
  }
25
26
  else {
26
- moDoc = execSync('dfx cache show').toString().trim() + '/mo-doc';
27
+ // fallbacks to dfx moc if not specified in config
28
+ let mocPath = await toolchain.bin('moc');
29
+ moDocPath = mocPath.replace(/\/moc$/, '/mo-doc');
27
30
  }
28
31
 
29
32
  // generate docs
30
33
  await new Promise<void>((resolve) => {
31
- let proc = spawn(moDoc, [`--source=${path.join(rootDir, 'src')}`, `--output=${docsDirRelative}`, '--format=adoc']);
34
+ let proc = spawn(moDocPath, [`--source=${path.join(rootDir, 'src')}`, `--output=${docsDirRelative}`, '--format=adoc']);
32
35
 
33
36
  // stdout
34
37
  proc.stdout.on('data', (data) => {
@@ -1,5 +1,6 @@
1
1
  import chalk from 'chalk';
2
- import logUpdate from 'log-update';
2
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3
+ import {createLogUpdate} from 'log-update';
3
4
  import {checkConfigFile, readConfig} from '../mops.js';
4
5
  import {install} from './install.js';
5
6
  import {installFromGithub} from '../vessel.js';
@@ -36,9 +37,13 @@ export async function installAll({verbose = false, silent = false, lock}: Instal
36
37
  }
37
38
  }
38
39
 
40
+ let logUpdate = createLogUpdate(process.stdout, {showCursor: true});
41
+ // let logUpdate = l;
42
+
39
43
  if (!silent && lock !== 'ignore') {
40
44
  logUpdate('Checking integrity...');
41
45
  }
46
+
42
47
  await Promise.all([
43
48
  notifyInstalls(Object.keys(installedPackages)),
44
49
  checkIntegrity(lock),
@@ -46,6 +51,6 @@ export async function installAll({verbose = false, silent = false, lock}: Instal
46
51
 
47
52
  if (!silent) {
48
53
  logUpdate.clear();
49
- console.log(chalk.green('All packages installed'));
54
+ console.log(chalk.green('Packages installed'));
50
55
  }
51
56
  }
@@ -1,6 +1,6 @@
1
1
  import path from 'node:path';
2
2
  import fs from 'node:fs';
3
- import logUpdate from 'log-update';
3
+ import {createLogUpdate} from 'log-update';
4
4
  import chalk from 'chalk';
5
5
  import {checkConfigFile, formatDir, progressBar, readConfig} from '../mops.js';
6
6
  import {getHighestVersion} from '../api/getHighestVersion.js';
@@ -14,6 +14,7 @@ export async function install(pkg: string, version = '', {verbose = false, silen
14
14
  if (!checkConfigFile()) {
15
15
  return false;
16
16
  }
17
+ let logUpdate = createLogUpdate(process.stdout, {showCursor: true});
17
18
 
18
19
  // progress
19
20
  let total = Infinity;
@@ -89,6 +90,9 @@ export async function install(pkg: string, version = '', {verbose = false, silen
89
90
  if (verbose) {
90
91
  silent || logUpdate.done();
91
92
  }
93
+ else {
94
+ logUpdate.clear();
95
+ }
92
96
 
93
97
  // install dependencies
94
98
  let ok = true;
@@ -327,6 +327,8 @@ export async function publish(options: {docs?: boolean, test?: boolean} = {}) {
327
327
 
328
328
  // finish
329
329
  progress();
330
+ logUpdate.done();
331
+
330
332
  let res = await actor.finishPublish(puiblishingId);
331
333
  if ('err' in res) {
332
334
  console.log(chalk.red('Error: ') + res.err);
@@ -1,4 +1,4 @@
1
- import {spawn, execSync, ChildProcessWithoutNullStreams} from 'node:child_process';
1
+ import {spawn, ChildProcessWithoutNullStreams} from 'node:child_process';
2
2
  import path from 'node:path';
3
3
  import fs from 'node:fs';
4
4
  import os from 'node:os';
@@ -8,7 +8,7 @@ import chokidar from 'chokidar';
8
8
  import debounce from 'debounce';
9
9
 
10
10
  import {sources} from '../sources.js';
11
- import {getRootDir} from '../../mops.js';
11
+ import {getRootDir, readConfig} from '../../mops.js';
12
12
  import {parallel} from '../../parallel.js';
13
13
 
14
14
  import {MMF1} from './mmf1.js';
@@ -18,6 +18,7 @@ import {VerboseReporter} from './reporters/verbose-reporter.js';
18
18
  import {FilesReporter} from './reporters/files-reporter.js';
19
19
  import {CompactReporter} from './reporters/compact-reporter.js';
20
20
  import {SilentReporter} from './reporters/silent-reporter.js';
21
+ import {toolchain} from '../toolchain/index.js';
21
22
 
22
23
  let ignore = [
23
24
  '**/node_modules/**',
@@ -70,7 +71,8 @@ export async function test(filter = '', {watch = false, reporter = 'verbose' as
70
71
  }
71
72
  }
72
73
 
73
- let mocPath = process.env.DFX_MOC_PATH;
74
+ let mocPath = '';
75
+ let wasmtimePath = '';
74
76
 
75
77
  export async function runAll(reporterName: ReporterName = 'verbose', filter = '', mode: TestMode = 'interpreter'): Promise<boolean> {
76
78
  let reporter: Reporter;
@@ -116,10 +118,11 @@ export async function testWithReporter(reporter: Reporter, filter = '', mode: Te
116
118
 
117
119
  reporter.addFiles(files);
118
120
 
121
+ let config = readConfig();
119
122
  let sourcesArr = await sources();
120
123
 
121
124
  if (!mocPath) {
122
- mocPath = execSync('dfx cache show').toString().trim() + '/moc';
125
+ mocPath = await toolchain.bin('moc');
123
126
  }
124
127
 
125
128
  let wasmDir = `${getRootDir()}/.mops/.test/`;
@@ -129,11 +132,20 @@ export async function testWithReporter(reporter: Reporter, filter = '', mode: Te
129
132
  let mmf = new MMF1('store', absToRel(file));
130
133
  let wasiMode = mode === 'wasi' || fs.readFileSync(file, 'utf8').startsWith('// @testmode wasi');
131
134
 
132
- let promise = new Promise<void>((resolve) => {
133
- if (!mocPath) {
134
- mocPath = 'moc';
135
+ if (wasiMode && !wasmtimePath) {
136
+ // ensure wasmtime is installed or specified in config
137
+ if (config.toolchain?.wasmtime) {
138
+ wasmtimePath = await toolchain.bin('wasmtime');
139
+ }
140
+ // fallback wasmtime to global binary if not specified in config (legacy)
141
+ else {
142
+ wasmtimePath = 'wasmtime';
143
+ console.log(chalk.yellow('Warning:'), 'Wasmtime is not specified in config. Using global binary "wasmtime". This will be removed in the future.');
144
+ console.log(`Run ${chalk.green('mops toolchain use wasmtime')} or add ${chalk.green('wasmtime = "<version>"')} in mops.toml to avoid breaking changes with future versions of mops.`);
135
145
  }
146
+ }
136
147
 
148
+ let promise = new Promise<void>((resolve) => {
137
149
  let mocArgs = ['--hide-warnings', '--error-detail=2', ...sourcesArr.join(' ').split(' '), file].filter(x => x);
138
150
 
139
151
  // build and run wasm
@@ -147,18 +159,29 @@ export async function testWithReporter(reporter: Reporter, filter = '', mode: Te
147
159
  return;
148
160
  }
149
161
  // run
150
- let proc = spawn('wasmtime', [
151
- '--max-wasm-stack=2000000',
152
- '--enable-cranelift-nan-canonicalization',
153
- '--wasm-features',
154
- 'multi-memory,bulk-memory',
155
- wasmFile,
156
- ], {
157
- env: {
158
- ...process.env,
159
- WASMTIME_NEW_CLI: '0',
160
- }
161
- });
162
+ let wasmtimeArgs = [];
163
+ if (config.toolchain?.wasmtime && config.toolchain?.wasmtime >= '14.0.0') {
164
+ wasmtimeArgs = [
165
+ '-S', 'preview2=n',
166
+ '-C', 'cache=n',
167
+ '-W', 'bulk-memory',
168
+ '-W', 'multi-memory',
169
+ '-W', 'max-wasm-stack=2000000',
170
+ '-W', 'nan-canonicalization=y',
171
+ wasmFile,
172
+ ];
173
+ }
174
+ else {
175
+ wasmtimeArgs = [
176
+ '--max-wasm-stack=2000000',
177
+ '--enable-cranelift-nan-canonicalization',
178
+ '--wasm-features',
179
+ 'multi-memory,bulk-memory',
180
+ wasmFile,
181
+ ];
182
+ }
183
+
184
+ let proc = spawn(wasmtimePath, wasmtimeArgs);
162
185
  await pipeMMF(proc, mmf);
163
186
  }).finally(() => {
164
187
  fs.rmSync(wasmFile, {force: true});