ic-mops 0.39.2 → 0.40.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 (229) hide show
  1. package/.eslintrc.json +0 -0
  2. package/.gitignore +1 -0
  3. package/README.md +0 -0
  4. package/api/actors.ts +2 -2
  5. package/api/downloadPackageFiles.ts +9 -6
  6. package/api/getHighestVersion.ts +1 -1
  7. package/api/index.ts +0 -0
  8. package/api/network.ts +1 -1
  9. package/api/resolveVersion.ts +1 -1
  10. package/cache.ts +3 -3
  11. package/cli.ts +3 -2
  12. package/commands/add.ts +6 -6
  13. package/commands/available-updates.ts +2 -2
  14. package/commands/bench/bench-canister.mo +0 -0
  15. package/commands/bench/user-bench.mo +0 -0
  16. package/commands/bench-replica.ts +10 -10
  17. package/commands/bench.ts +96 -56
  18. package/commands/bump.ts +2 -2
  19. package/commands/docs.ts +1 -1
  20. package/commands/import-identity.ts +2 -2
  21. package/commands/init.ts +9 -9
  22. package/commands/install-all.ts +4 -4
  23. package/commands/install-local.ts +1 -1
  24. package/commands/install.ts +2 -2
  25. package/commands/outdated.ts +0 -0
  26. package/commands/publish.ts +34 -9
  27. package/commands/remove.ts +8 -8
  28. package/commands/search.ts +2 -2
  29. package/commands/sources.ts +0 -0
  30. package/commands/sync.ts +8 -8
  31. package/commands/template.ts +2 -2
  32. package/commands/test/mmf1.ts +18 -18
  33. package/commands/test/reporters/compact-reporter.ts +5 -5
  34. package/commands/test/reporters/files-reporter.ts +3 -3
  35. package/commands/test/reporters/reporter.ts +3 -3
  36. package/commands/test/reporters/silent-reporter.ts +4 -4
  37. package/commands/test/reporters/verbose-reporter.ts +3 -3
  38. package/commands/test/test.ts +10 -10
  39. package/commands/test/utils.ts +1 -1
  40. package/commands/toolchain/index.ts +9 -9
  41. package/commands/toolchain/moc.ts +2 -2
  42. package/commands/toolchain/pocket-ic.ts +6 -31
  43. package/commands/toolchain/toolchain-utils.ts +11 -11
  44. package/commands/toolchain/wasmtime.ts +2 -2
  45. package/commands/transfer-ownership.ts +2 -2
  46. package/commands/update.ts +4 -4
  47. package/commands/user.ts +2 -2
  48. package/commands/whoami.ts +0 -0
  49. package/declarations/bench/bench.did.d.ts +3 -0
  50. package/declarations/main/main.did +27 -1
  51. package/declarations/main/main.did.d.ts +26 -1
  52. package/declarations/main/main.did.js +27 -1
  53. package/declarations/storage/index.d.ts +0 -0
  54. package/declarations/storage/index.js +0 -0
  55. package/declarations/storage/storage.did +0 -0
  56. package/declarations/storage/storage.did.d.ts +0 -0
  57. package/declarations/storage/storage.did.js +0 -0
  58. package/dist/api/actors.d.ts +0 -0
  59. package/dist/api/actors.js +0 -0
  60. package/dist/api/downloadPackageFiles.d.ts +1 -1
  61. package/dist/api/downloadPackageFiles.js +4 -0
  62. package/dist/api/getHighestVersion.d.ts +0 -0
  63. package/dist/api/getHighestVersion.js +0 -0
  64. package/dist/api/index.d.ts +0 -0
  65. package/dist/api/index.js +0 -0
  66. package/dist/api/network.d.ts +0 -0
  67. package/dist/api/network.js +0 -0
  68. package/dist/api/resolveVersion.d.ts +0 -0
  69. package/dist/api/resolveVersion.js +0 -0
  70. package/dist/bin/moc-wrapper.sh +3 -0
  71. package/dist/bin/mops.d.ts +0 -0
  72. package/dist/bin/mops.js +0 -0
  73. package/dist/bundle-package-json.d.ts +1 -0
  74. package/dist/bundle-package-json.js +11 -0
  75. package/dist/cache.d.ts +0 -0
  76. package/dist/cache.js +0 -0
  77. package/dist/cli.d.ts +0 -0
  78. package/dist/cli.js +1 -0
  79. package/dist/commands/add.d.ts +0 -0
  80. package/dist/commands/add.js +0 -0
  81. package/dist/commands/available-updates.d.ts +0 -0
  82. package/dist/commands/available-updates.js +0 -0
  83. package/dist/commands/bench/bench-canister.mo +0 -0
  84. package/dist/commands/bench/user-bench.mo +0 -0
  85. package/dist/commands/bench-replica.d.ts +3 -1
  86. package/dist/commands/bench-replica.js +2 -2
  87. package/dist/commands/bench.d.ts +5 -2
  88. package/dist/commands/bench.js +66 -29
  89. package/dist/commands/bump.d.ts +0 -0
  90. package/dist/commands/bump.js +0 -0
  91. package/dist/commands/docs.d.ts +0 -0
  92. package/dist/commands/docs.js +0 -0
  93. package/dist/commands/import-identity.d.ts +0 -0
  94. package/dist/commands/import-identity.js +0 -0
  95. package/dist/commands/init.d.ts +0 -0
  96. package/dist/commands/init.js +1 -1
  97. package/dist/commands/install-all.d.ts +0 -0
  98. package/dist/commands/install-all.js +0 -0
  99. package/dist/commands/install-local.d.ts +0 -0
  100. package/dist/commands/install-local.js +0 -0
  101. package/dist/commands/install.d.ts +0 -0
  102. package/dist/commands/install.js +0 -0
  103. package/dist/commands/outdated.d.ts +0 -0
  104. package/dist/commands/outdated.js +0 -0
  105. package/dist/commands/publish.d.ts +1 -0
  106. package/dist/commands/publish.js +24 -1
  107. package/dist/commands/remove.d.ts +0 -0
  108. package/dist/commands/remove.js +0 -0
  109. package/dist/commands/search.d.ts +0 -0
  110. package/dist/commands/search.js +0 -0
  111. package/dist/commands/self-update.d.ts +0 -0
  112. package/dist/commands/self-update.js +0 -0
  113. package/dist/commands/self.d.ts +3 -0
  114. package/dist/commands/self.js +62 -0
  115. package/dist/commands/sources.d.ts +0 -0
  116. package/dist/commands/sources.js +0 -0
  117. package/dist/commands/sync.d.ts +0 -0
  118. package/dist/commands/sync.js +0 -0
  119. package/dist/commands/template.d.ts +0 -0
  120. package/dist/commands/template.js +0 -0
  121. package/dist/commands/test/mmf1.d.ts +0 -0
  122. package/dist/commands/test/mmf1.js +1 -1
  123. package/dist/commands/test/reporters/compact-reporter.d.ts +0 -0
  124. package/dist/commands/test/reporters/compact-reporter.js +0 -0
  125. package/dist/commands/test/reporters/files-reporter.d.ts +0 -0
  126. package/dist/commands/test/reporters/files-reporter.js +0 -0
  127. package/dist/commands/test/reporters/reporter.d.ts +0 -0
  128. package/dist/commands/test/reporters/reporter.js +0 -0
  129. package/dist/commands/test/reporters/silent-reporter.d.ts +0 -0
  130. package/dist/commands/test/reporters/silent-reporter.js +0 -0
  131. package/dist/commands/test/reporters/verbose-reporter.d.ts +0 -0
  132. package/dist/commands/test/reporters/verbose-reporter.js +0 -0
  133. package/dist/commands/test/test.d.ts +0 -0
  134. package/dist/commands/test/test.js +2 -2
  135. package/dist/commands/test/utils.d.ts +0 -0
  136. package/dist/commands/test/utils.js +0 -0
  137. package/dist/commands/toolchain/index.d.ts +0 -0
  138. package/dist/commands/toolchain/index.js +0 -0
  139. package/dist/commands/toolchain/moc.d.ts +0 -0
  140. package/dist/commands/toolchain/moc.js +0 -0
  141. package/dist/commands/toolchain/pocket-ic.d.ts +1 -5
  142. package/dist/commands/toolchain/pocket-ic.js +4 -27
  143. package/dist/commands/toolchain/toolchain-utils.d.ts +1 -1
  144. package/dist/commands/toolchain/toolchain-utils.js +7 -7
  145. package/dist/commands/toolchain/wasmtime.d.ts +0 -0
  146. package/dist/commands/toolchain/wasmtime.js +0 -0
  147. package/dist/commands/transfer-ownership.d.ts +0 -0
  148. package/dist/commands/transfer-ownership.js +1 -1
  149. package/dist/commands/update.d.ts +0 -0
  150. package/dist/commands/update.js +0 -0
  151. package/dist/commands/user.d.ts +0 -0
  152. package/dist/commands/user.js +0 -0
  153. package/dist/commands/whoami.d.ts +0 -0
  154. package/dist/commands/whoami.js +0 -0
  155. package/dist/declarations/bench/bench.did +0 -0
  156. package/dist/declarations/bench/bench.did.d.ts +3 -0
  157. package/dist/declarations/bench/bench.did.js +0 -0
  158. package/dist/declarations/bench/index.d.ts +0 -0
  159. package/dist/declarations/bench/index.js +0 -0
  160. package/dist/declarations/main/index.d.ts +0 -0
  161. package/dist/declarations/main/index.js +0 -0
  162. package/dist/declarations/main/main.did +27 -1
  163. package/dist/declarations/main/main.did.d.ts +26 -1
  164. package/dist/declarations/main/main.did.js +27 -1
  165. package/dist/declarations/storage/index.d.ts +0 -0
  166. package/dist/declarations/storage/index.js +0 -0
  167. package/dist/declarations/storage/storage.did +0 -0
  168. package/dist/declarations/storage/storage.did.d.ts +0 -0
  169. package/dist/declarations/storage/storage.did.js +0 -0
  170. package/dist/helpers/find-changelog-entry.d.ts +1 -0
  171. package/dist/helpers/find-changelog-entry.js +24 -0
  172. package/dist/helpers/get-dfx-version.d.ts +0 -0
  173. package/dist/helpers/get-dfx-version.js +0 -0
  174. package/dist/helpers/get-moc-path.d.ts +0 -0
  175. package/dist/helpers/get-moc-path.js +0 -0
  176. package/dist/helpers/get-moc-version.d.ts +0 -0
  177. package/dist/helpers/get-moc-version.js +0 -0
  178. package/dist/integrity.d.ts +0 -0
  179. package/dist/integrity.js +0 -0
  180. package/dist/mops.d.ts +0 -0
  181. package/dist/mops.js +1 -1
  182. package/dist/notify-installs.d.ts +0 -0
  183. package/dist/notify-installs.js +0 -0
  184. package/dist/package.json +1 -1
  185. package/dist/parallel.d.ts +0 -0
  186. package/dist/parallel.js +0 -0
  187. package/dist/pem.d.ts +0 -0
  188. package/dist/pem.js +0 -0
  189. package/dist/release-cli.d.ts +1 -0
  190. package/dist/release-cli.js +35 -0
  191. package/dist/remove-scripts.d.ts +1 -0
  192. package/dist/remove-scripts.js +5 -0
  193. package/dist/resolve-packages.d.ts +0 -0
  194. package/dist/resolve-packages.js +0 -0
  195. package/dist/templates/README.md +0 -0
  196. package/dist/templates/licenses/Apache-2.0 +0 -0
  197. package/dist/templates/licenses/Apache-2.0-NOTICE +0 -0
  198. package/dist/templates/licenses/MIT +0 -0
  199. package/dist/templates/mops-publish.yml +0 -0
  200. package/dist/templates/mops-test.yml +0 -0
  201. package/dist/templates/src/lib.mo +0 -0
  202. package/dist/templates/test/lib.test.mo +0 -0
  203. package/dist/types.d.ts +0 -0
  204. package/dist/types.js +0 -0
  205. package/dist/vessel.d.ts +0 -0
  206. package/dist/vessel.js +1 -1
  207. package/global.d.ts +0 -0
  208. package/helpers/get-dfx-version.ts +1 -1
  209. package/helpers/get-moc-path.ts +1 -1
  210. package/helpers/get-moc-version.ts +1 -1
  211. package/integrity.ts +16 -16
  212. package/mops.ts +17 -17
  213. package/notify-installs.ts +2 -2
  214. package/package.json +1 -1
  215. package/parallel.ts +1 -1
  216. package/pem.ts +5 -5
  217. package/resolve-packages.ts +9 -9
  218. package/templates/README.md +0 -0
  219. package/templates/licenses/Apache-2.0 +0 -0
  220. package/templates/licenses/Apache-2.0-NOTICE +0 -0
  221. package/templates/licenses/MIT +0 -0
  222. package/templates/mops-publish.yml +0 -0
  223. package/templates/mops-test.yml +0 -0
  224. package/templates/src/lib.mo +0 -0
  225. package/templates/test/lib.test.mo +0 -0
  226. package/types.ts +25 -25
  227. package/vessel.ts +16 -16
  228. package/dist/commands/replica.d.ts +0 -36
  229. package/dist/commands/replica.js +0 -103
@@ -9,12 +9,12 @@ import {checkIntegrity} from '../integrity.js';
9
9
  import {installLocal} from './install-local.js';
10
10
 
11
11
  type InstallAllOptions = {
12
- verbose?: boolean;
13
- silent?: boolean;
14
- lock?: 'check' | 'update' | 'ignore';
12
+ verbose ?: boolean;
13
+ silent ?: boolean;
14
+ lock ?: 'check' | 'update' | 'ignore';
15
15
  }
16
16
 
17
- export async function installAll({verbose = false, silent = false, lock}: InstallAllOptions = {}) {
17
+ export async function installAll({verbose = false, silent = false, lock} : InstallAllOptions = {}) {
18
18
  if (!checkConfigFile()) {
19
19
  return;
20
20
  }
@@ -6,7 +6,7 @@ import {install} from './install.js';
6
6
 
7
7
  // skip install and just find non-local dependencies to install
8
8
  // pkgPath should be relative to the current root dir or absolute
9
- export async function installLocal(pkg: string, pkgPath = '', {verbose = false, silent = false} = {}): Promise<Record<string, string> | false> {
9
+ export async function installLocal(pkg : string, pkgPath = '', {verbose = false, silent = false} = {}) : Promise<Record<string, string> | false> {
10
10
  if (!checkConfigFile()) {
11
11
  return false;
12
12
  }
@@ -11,7 +11,7 @@ import {addCache, copyCache, isCached} from '../cache.js';
11
11
  import {downloadFile, getPackageFilesInfo} from '../api/downloadPackageFiles.js';
12
12
  import {installLocal} from './install-local.js';
13
13
 
14
- export async function install(pkg: string, version = '', {verbose = false, silent = false, dep = false} = {}): Promise<Record<string, string> | false> {
14
+ export async function install(pkg : string, version = '', {verbose = false, silent = false, dep = false} = {}) : Promise<Record<string, string> | false> {
15
15
  if (!checkConfigFile()) {
16
16
  return false;
17
17
  }
@@ -65,7 +65,7 @@ export async function install(pkg: string, version = '', {verbose = false, silen
65
65
  let filesData = new Map;
66
66
  let storage = await storageActor(storageId);
67
67
 
68
- await parallel(threads, fileIds, async (fileId: string) => {
68
+ await parallel(threads, fileIds, async (fileId : string) => {
69
69
  let {path, data} = await downloadFile(storage, fileId);
70
70
  filesData.set(path, data);
71
71
  progress();
File without changes
@@ -12,12 +12,13 @@ import {checkConfigFile, getIdentity, getRootDir, progressBar, readConfig} from
12
12
  import {mainActor} from '../api/actors.js';
13
13
  import {parallel} from '../parallel.js';
14
14
  import {docs} from './docs.js';
15
- import {DependencyV2, PackageConfigV2} from '../declarations/main/main.did.js';
15
+ import {Benchmarks, DependencyV2, PackageConfigV2} from '../declarations/main/main.did.js';
16
16
  import {Dependency} from '../types.js';
17
17
  import {testWithReporter} from './test/test.js';
18
18
  import {SilentReporter} from './test/reporters/silent-reporter.js';
19
+ import {bench} from './bench.js';
19
20
 
20
- export async function publish(options: {docs?: boolean, test?: boolean} = {}) {
21
+ export async function publish(options : {docs ?: boolean, test ?: boolean, bench ?: boolean} = {}) {
21
22
  if (!checkConfigFile()) {
22
23
  return;
23
24
  }
@@ -160,16 +161,16 @@ export async function publish(options: {docs?: boolean, test?: boolean} = {}) {
160
161
  }
161
162
  }
162
163
 
163
- let toBackendDep = (dep: Dependency): DependencyV2 => {
164
+ let toBackendDep = (dep : Dependency) : DependencyV2 => {
164
165
  return {
165
166
  ...dep,
166
167
  version: dep.version || '',
167
- repo: dep.repo || ''
168
+ repo: dep.repo || '',
168
169
  };
169
170
  };
170
171
 
171
172
  // map fields
172
- let backendPkgConfig: PackageConfigV2 = {
173
+ let backendPkgConfig : PackageConfigV2 = {
173
174
  name: config.package.name,
174
175
  version: config.package.version,
175
176
  keywords: config.package.keywords || [],
@@ -258,6 +259,25 @@ export async function publish(options: {docs?: boolean, test?: boolean} = {}) {
258
259
  }
259
260
  }
260
261
 
262
+ // bench
263
+ let benchmarks : Benchmarks = [];
264
+ if (options.bench) {
265
+ console.log('Running benchmarks...');
266
+ try {
267
+ benchmarks = await bench('', {
268
+ replica: config.toolchain?.['pocket-ic'] ? 'pocket-ic' : 'dfx',
269
+ gc: 'copying',
270
+ forceGc: true,
271
+ silent: true,
272
+ });
273
+ }
274
+ catch (err) {
275
+ console.error(err);
276
+ console.log(chalk.red('Error: ') + 'benchmarks failed');
277
+ process.exit(1);
278
+ }
279
+ }
280
+
261
281
  // progress
262
282
  let total = files.length + 2;
263
283
  let step = 0;
@@ -286,13 +306,18 @@ export async function publish(options: {docs?: boolean, test?: boolean} = {}) {
286
306
  });
287
307
  }
288
308
 
309
+ // upload benchmarks
310
+ if (options.bench) {
311
+ await actor.uploadBenchmarks(puiblishingId, benchmarks);
312
+ }
313
+
289
314
  // upload changelog
290
315
  if (changelog) {
291
316
  await actor.uploadNotes(puiblishingId, changelog);
292
317
  }
293
318
 
294
319
  // upload files
295
- await parallel(8, files, async (file: string) => {
320
+ await parallel(8, files, async (file : string) => {
296
321
  progress();
297
322
 
298
323
  let chunkSize = 1024 * 1024 + 512 * 1024; // 1.5mb
@@ -338,7 +363,7 @@ export async function publish(options: {docs?: boolean, test?: boolean} = {}) {
338
363
  console.log(chalk.green('Published ') + `${config.package.name}@${config.package.version}`);
339
364
  }
340
365
 
341
- function parseChangelog(version: string): string {
366
+ function parseChangelog(version : string) : string {
342
367
  let rootDir = getRootDir();
343
368
  let changelogFile = '';
344
369
 
@@ -365,7 +390,7 @@ function parseChangelog(version: string): string {
365
390
  return changelog || '';
366
391
  }
367
392
 
368
- async function fetchGitHubReleaseNotes(repo: string, version: string): Promise<string> {
393
+ async function fetchGitHubReleaseNotes(repo : string, version : string) : Promise<string> {
369
394
  let repoPath = new URL(repo).pathname;
370
395
  let res = await fetch(`https://api.github.com/repos${repoPath}/releases/tags/${version}`);
371
396
  let release = await res.json();
@@ -383,7 +408,7 @@ async function fetchGitHubReleaseNotes(repo: string, version: string): Promise<s
383
408
  return release.body;
384
409
  }
385
410
 
386
- function findChangelogEntry(changelog: string, version: string): string {
411
+ function findChangelogEntry(changelog : string, version : string) : string {
387
412
  let tree = fromMarkdown(changelog);
388
413
  let found = false;
389
414
  let nodes = [];
@@ -6,19 +6,19 @@ import {Config, Dependency} from '../types.js';
6
6
  import {checkIntegrity} from '../integrity.js';
7
7
 
8
8
  type RemoveOptions = {
9
- verbose?: boolean;
10
- dev?: boolean;
11
- dryRun?: boolean;
12
- lock?: 'update' | 'ignore';
9
+ verbose ?: boolean;
10
+ dev ?: boolean;
11
+ dryRun ?: boolean;
12
+ lock ?: 'update' | 'ignore';
13
13
  };
14
14
 
15
15
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16
- export async function remove(name: string, {dev = false, verbose = false, dryRun = false, lock}: RemoveOptions = {}) {
16
+ export async function remove(name : string, {dev = false, verbose = false, dryRun = false, lock} : RemoveOptions = {}) {
17
17
  if (!checkConfigFile()) {
18
18
  return;
19
19
  }
20
20
 
21
- function getTransitiveDependencies(config: Config, exceptPkgId: string) {
21
+ function getTransitiveDependencies(config : Config, exceptPkgId : string) {
22
22
  let deps = Object.values(config.dependencies || {});
23
23
  let devDeps = Object.values(config['dev-dependencies'] || {});
24
24
  return [...deps, ...devDeps]
@@ -30,7 +30,7 @@ export async function remove(name: string, {dev = false, verbose = false, dryRun
30
30
  }).flat();
31
31
  }
32
32
 
33
- function getTransitiveDependenciesOf(name: string, version: string | undefined, repo?: string) {
33
+ function getTransitiveDependenciesOf(name : string, version : string | undefined, repo ?: string) {
34
34
  let pkgDir = '';
35
35
  if (repo) {
36
36
  pkgDir = formatGithubDir(name, repo);
@@ -44,7 +44,7 @@ export async function remove(name: string, {dev = false, verbose = false, dryRun
44
44
  return [];
45
45
  }
46
46
  let config = readConfig(configFile);
47
- let deps: Dependency[] = Object.values(config.dependencies || {}).map((dep) => {
47
+ let deps : Dependency[] = Object.values(config.dependencies || {}).map((dep) => {
48
48
  return [dep, ...getTransitiveDependenciesOf(dep.name, dep.version)];
49
49
  }).flat();
50
50
  return deps;
@@ -2,7 +2,7 @@ import asTable from 'as-table';
2
2
  import chalk from 'chalk';
3
3
  import {mainActor} from '../api/actors.js';
4
4
 
5
- export async function search(text: string) {
5
+ export async function search(text : string) {
6
6
  let actor = await mainActor();
7
7
  let [packages, _pageCount] = await actor.search(text, [], []);
8
8
 
@@ -11,7 +11,7 @@ export async function search(text: string) {
11
11
  return;
12
12
  }
13
13
 
14
- let ellipsis = (text: string, max: number) => {
14
+ let ellipsis = (text : string, max : number) => {
15
15
  if (text.length <= max) {
16
16
  return text;
17
17
  }
File without changes
package/commands/sync.ts CHANGED
@@ -8,10 +8,10 @@ import {remove} from './remove.js';
8
8
  import {checkIntegrity} from '../integrity.js';
9
9
 
10
10
  type SyncOptions = {
11
- lock?: 'update' | 'ignore';
11
+ lock ?: 'update' | 'ignore';
12
12
  };
13
13
 
14
- export async function sync({lock}: SyncOptions = {}) {
14
+ export async function sync({lock} : SyncOptions = {}) {
15
15
  if (!checkConfigFile()) {
16
16
  return;
17
17
  }
@@ -48,7 +48,7 @@ let ignore = [
48
48
  ];
49
49
 
50
50
  let mocPath = '';
51
- function getMocPath(): string {
51
+ function getMocPath() : string {
52
52
  if (!mocPath) {
53
53
  mocPath = process.env.DFX_MOC_PATH || '';
54
54
  }
@@ -64,7 +64,7 @@ function getMocPath(): string {
64
64
  return mocPath;
65
65
  }
66
66
 
67
- async function getUsedPackages(): Promise<string[]> {
67
+ async function getUsedPackages() : Promise<string[]> {
68
68
  let rootDir = getRootDir();
69
69
  let files = globSync('**/*.mo', {
70
70
  cwd: rootDir,
@@ -72,10 +72,10 @@ async function getUsedPackages(): Promise<string[]> {
72
72
  ignore: ignore,
73
73
  });
74
74
 
75
- let packages: Set<string> = new Set;
75
+ let packages : Set<string> = new Set;
76
76
 
77
77
  for (let file of files) {
78
- let deps: string[] = execSync(`${getMocPath()} --print-deps ${path.join(rootDir, file)}`).toString().trim().split('\n');
78
+ let deps : string[] = execSync(`${getMocPath()} --print-deps ${path.join(rootDir, file)}`).toString().trim().split('\n');
79
79
 
80
80
  for (let dep of deps) {
81
81
  if (dep.startsWith('mo:') && !dep.startsWith('mo:prim') && !dep.startsWith('mo:⛔')) {
@@ -87,7 +87,7 @@ async function getUsedPackages(): Promise<string[]> {
87
87
  return [...packages];
88
88
  }
89
89
 
90
- async function getMissingPackages(): Promise<string[]> {
90
+ async function getMissingPackages() : Promise<string[]> {
91
91
  let config = readConfig();
92
92
  let allDeps = [...Object.keys(config.dependencies || {}), ...Object.keys(config['dev-dependencies'] || {})];
93
93
  let missing = new Set(await getUsedPackages());
@@ -97,7 +97,7 @@ async function getMissingPackages(): Promise<string[]> {
97
97
  return [...missing];
98
98
  }
99
99
 
100
- async function getUnusedPackages(): Promise<string[]> {
100
+ async function getUnusedPackages() : Promise<string[]> {
101
101
  let config = readConfig();
102
102
  let allDeps = new Set([...Object.keys(config.dependencies || {}), ...Object.keys(config['dev-dependencies'] || {})]);
103
103
  let used = await getUsedPackages();
@@ -5,7 +5,7 @@ import prompts from 'prompts';
5
5
  import camelCase from 'camelcase';
6
6
  import {getRootDir, readConfig} from '../mops.js';
7
7
 
8
- export async function template(templateName?: string, options: any = {}) {
8
+ export async function template(templateName ?: string, options : any = {}) {
9
9
  if (!templateName) {
10
10
  let res = await prompts({
11
11
  type: 'select',
@@ -55,7 +55,7 @@ export async function template(templateName?: string, options: any = {}) {
55
55
  return;
56
56
  }
57
57
 
58
- let setYearAndOwner = (file: string) => {
58
+ let setYearAndOwner = (file : string) => {
59
59
  let license = fs.readFileSync(file).toString();
60
60
  license = license.replace(/<year>/g, new Date().getFullYear().toString());
61
61
  if (options.copyrightOwner) {
@@ -9,34 +9,34 @@ type TestStatus = 'pass' | 'fail' | 'skip';
9
9
  type MessageType = 'pass' | 'fail' | 'skip' | 'suite' | 'stdout';
10
10
 
11
11
  export class MMF1 {
12
- file: string;
13
- stack: string[] = [];
14
- currSuite: string = '';
12
+ file : string;
13
+ stack : string[] = [];
14
+ currSuite : string = '';
15
15
  failed = 0;
16
16
  passed = 0;
17
17
  skipped = 0;
18
- srategy: Strategy;
19
- output: {
20
- type: MessageType;
21
- message: string;
18
+ srategy : Strategy;
19
+ output : {
20
+ type : MessageType;
21
+ message : string;
22
22
  }[] = [];
23
23
  nestingSymbol = ' › ';
24
24
  // or <file>
25
25
  // or <file> › <test>
26
26
  // or <file> › <suite> › <test>
27
27
  // or <file> › <suite> › <test> › <nested-test>...
28
- passedNamesFlat: string[] = [];
28
+ passedNamesFlat : string[] = [];
29
29
 
30
- constructor(srategy: Strategy, file: string) {
30
+ constructor(srategy : Strategy, file : string) {
31
31
  this.srategy = srategy;
32
32
  this.file = file;
33
33
  }
34
34
 
35
- _log(type: MessageType, ...args: string[]) {
35
+ _log(type : MessageType, ...args : string[]) {
36
36
  if (this.srategy === 'store') {
37
37
  this.output.push({
38
38
  type,
39
- message: args.join(' ')
39
+ message: args.join(' '),
40
40
  });
41
41
  }
42
42
  else if (this.srategy === 'print') {
@@ -44,7 +44,7 @@ export class MMF1 {
44
44
  }
45
45
  }
46
46
 
47
- flush(messageType?: MessageType) {
47
+ flush(messageType ?: MessageType) {
48
48
  for (let out of this.output) {
49
49
  if (!messageType || out.type === messageType) {
50
50
  console.log(out.message);
@@ -53,7 +53,7 @@ export class MMF1 {
53
53
  this.output = [];
54
54
  }
55
55
 
56
- parseLine(line: string) {
56
+ parseLine(line : string) {
57
57
  if (line.startsWith('mops:1:start ')) {
58
58
  this._testStart(line.split('mops:1:start ')[1] || '');
59
59
  }
@@ -71,7 +71,7 @@ export class MMF1 {
71
71
  }
72
72
  }
73
73
 
74
- _testStart(name: string) {
74
+ _testStart(name : string) {
75
75
  let suite = this.stack[this.stack.length - 1];
76
76
  if (suite) {
77
77
  if (this.currSuite !== suite) {
@@ -82,18 +82,18 @@ export class MMF1 {
82
82
  this.stack.push(name);
83
83
  }
84
84
 
85
- _testEnd(name: string) {
85
+ _testEnd(name : string) {
86
86
  if (name !== this.stack.pop()) {
87
87
  throw 'mmf1._testEnd: start and end test mismatch';
88
88
  }
89
89
  this._status(name, 'pass');
90
90
  }
91
91
 
92
- _testSkip(name: string) {
92
+ _testSkip(name : string) {
93
93
  this._status(name, 'skip');
94
94
  }
95
95
 
96
- _status(name: string, status: TestStatus) {
96
+ _status(name : string, status : TestStatus) {
97
97
  if (status === 'pass') {
98
98
  // do not print suite at the end
99
99
  if (name === this.currSuite) {
@@ -113,7 +113,7 @@ export class MMF1 {
113
113
  }
114
114
  }
115
115
 
116
- fail(stderr: string) {
116
+ fail(stderr : string) {
117
117
  let name = this.stack.pop() || '';
118
118
  this._status(name, 'fail');
119
119
  this._log('fail', ' '.repeat(this.stack.length * 2), chalk.red('FAIL'), stderr);
@@ -17,13 +17,13 @@ export class CompactReporter implements Reporter {
17
17
  #finishedFiles = new Set<string>();
18
18
  #startTime = Date.now();
19
19
 
20
- addFiles(files: string[]) {
20
+ addFiles(files : string[]) {
21
21
  this.#allFiles = new Set(files);
22
22
  this.#log();
23
23
  this.#startTimer();
24
24
  }
25
25
 
26
- addRun(file: string, mmf: MMF1, state: Promise<void>, _wasiMode: boolean) {
26
+ addRun(file : string, mmf : MMF1, state : Promise<void>, _wasiMode : boolean) {
27
27
  this.#runningFiles.add(file);
28
28
  this.#log();
29
29
 
@@ -53,14 +53,14 @@ export class CompactReporter implements Reporter {
53
53
  });
54
54
  }
55
55
 
56
- done(): boolean {
56
+ done() : boolean {
57
57
  this.#log();
58
58
  logUpdate.done();
59
59
  this.#clearTimer();
60
60
  return this.failed === 0;
61
61
  }
62
62
 
63
- #timerId: NodeJS.Timeout | null = null;
63
+ #timerId : NodeJS.Timeout | null = null;
64
64
  #startTimer() {
65
65
  this.#timerId = setInterval(() => this.#log(), 55);
66
66
  }
@@ -72,7 +72,7 @@ export class CompactReporter implements Reporter {
72
72
  }
73
73
 
74
74
  #log() {
75
- let res: string[] = [];
75
+ let res : string[] = [];
76
76
  let i = 0;
77
77
  for (let file of this.#allFiles) {
78
78
  if (this.#runningFiles.has(file)) {
@@ -10,12 +10,12 @@ export class FilesReporter implements Reporter {
10
10
 
11
11
  #startTime = Date.now();
12
12
 
13
- addFiles(files: string[]) {
13
+ addFiles(files : string[]) {
14
14
  console.log(`Test files: ${files.length}`);
15
15
  console.log('='.repeat(50));
16
16
  }
17
17
 
18
- addRun(file: string, mmf: MMF1, state: Promise<void>, wasiMode: boolean) {
18
+ addRun(file : string, mmf : MMF1, state : Promise<void>, wasiMode : boolean) {
19
19
  state.then(() => {
20
20
  this.passed += Number(mmf.failed === 0);
21
21
  this.failed += Number(mmf.failed !== 0);
@@ -32,7 +32,7 @@ export class FilesReporter implements Reporter {
32
32
  });
33
33
  }
34
34
 
35
- done(): boolean {
35
+ done() : boolean {
36
36
  console.log('='.repeat(50));
37
37
  if (this.failed) {
38
38
  console.log(chalk.redBright('Tests failed'));
@@ -1,7 +1,7 @@
1
1
  import {MMF1} from '../mmf1.js';
2
2
 
3
3
  export interface Reporter {
4
- addFiles(files: string[]): void;
5
- addRun(file: string, mmf: MMF1, state: Promise<void>, wasiMode: boolean): void;
6
- done(): boolean;
4
+ addFiles(files : string[]) : void;
5
+ addRun(file : string, mmf : MMF1, state : Promise<void>, wasiMode : boolean) : void;
6
+ done() : boolean;
7
7
  }
@@ -9,11 +9,11 @@ export class SilentReporter implements Reporter {
9
9
  skipped = 0;
10
10
  passedFiles = 0;
11
11
  failedFiles = 0;
12
- passedNamesFlat: string[] = [];
12
+ passedNamesFlat : string[] = [];
13
13
 
14
- addFiles(_files: string[]) {}
14
+ addFiles(_files : string[]) {}
15
15
 
16
- addRun(file: string, mmf: MMF1, state: Promise<void>, _wasiMode: boolean) {
16
+ addRun(file : string, mmf : MMF1, state : Promise<void>, _wasiMode : boolean) {
17
17
  state.then(() => {
18
18
  this.passed += mmf.passed;
19
19
  this.failed += mmf.failed;
@@ -36,7 +36,7 @@ export class SilentReporter implements Reporter {
36
36
  });
37
37
  }
38
38
 
39
- done(): boolean {
39
+ done() : boolean {
40
40
  return this.failed === 0;
41
41
  }
42
42
  }
@@ -11,7 +11,7 @@ export class VerboseReporter implements Reporter {
11
11
  #startTime = Date.now();
12
12
  #curFileIndex = 0;
13
13
 
14
- addFiles(files: string[]) {
14
+ addFiles(files : string[]) {
15
15
  console.log('Test files:');
16
16
  for (let file of files) {
17
17
  console.log(chalk.gray(`• ${absToRel(file)}`));
@@ -19,7 +19,7 @@ export class VerboseReporter implements Reporter {
19
19
  console.log('='.repeat(50));
20
20
  }
21
21
 
22
- addRun(file: string, mmf: MMF1, state: Promise<void>, wasiMode: boolean) {
22
+ addRun(file : string, mmf : MMF1, state : Promise<void>, wasiMode : boolean) {
23
23
  state.then(() => {
24
24
  this.passed += mmf.passed;
25
25
  this.failed += mmf.failed;
@@ -35,7 +35,7 @@ export class VerboseReporter implements Reporter {
35
35
  });
36
36
  }
37
37
 
38
- done(): boolean {
38
+ done() : boolean {
39
39
  console.log('='.repeat(50));
40
40
  if (this.failed) {
41
41
  console.log(chalk.redBright('Tests failed'));
@@ -74,8 +74,8 @@ export async function test(filter = '', {watch = false, reporter = 'verbose' as
74
74
  let mocPath = '';
75
75
  let wasmtimePath = '';
76
76
 
77
- export async function runAll(reporterName: ReporterName = 'verbose', filter = '', mode: TestMode = 'interpreter'): Promise<boolean> {
78
- let reporter: Reporter;
77
+ export async function runAll(reporterName : ReporterName = 'verbose', filter = '', mode : TestMode = 'interpreter') : Promise<boolean> {
78
+ let reporter : Reporter;
79
79
  if (reporterName == 'compact') {
80
80
  reporter = new CompactReporter;
81
81
  }
@@ -92,9 +92,9 @@ export async function runAll(reporterName: ReporterName = 'verbose', filter = ''
92
92
  return done;
93
93
  }
94
94
 
95
- export async function testWithReporter(reporter: Reporter, filter = '', mode: TestMode = 'interpreter'): Promise<boolean> {
95
+ export async function testWithReporter(reporter : Reporter, filter = '', mode : TestMode = 'interpreter') : Promise<boolean> {
96
96
  let rootDir = getRootDir();
97
- let files: string[] = [];
97
+ let files : string[] = [];
98
98
  let libFiles = globSync('**/test?(s)/lib.mo', globConfig);
99
99
  if (libFiles[0]) {
100
100
  files = [libFiles[0]];
@@ -128,7 +128,7 @@ export async function testWithReporter(reporter: Reporter, filter = '', mode: Te
128
128
  let wasmDir = `${getRootDir()}/.mops/.test/`;
129
129
  fs.mkdirSync(wasmDir, {recursive: true});
130
130
 
131
- await parallel(os.cpus().length, files, async (file: string) => {
131
+ await parallel(os.cpus().length, files, async (file : string) => {
132
132
  let mmf = new MMF1('store', absToRel(file));
133
133
  let wasiMode = mode === 'wasi' || fs.readFileSync(file, 'utf8').startsWith('// @testmode wasi');
134
134
 
@@ -166,14 +166,14 @@ export async function testWithReporter(reporter: Reporter, filter = '', mode: Te
166
166
  '-C', 'cache=n',
167
167
  '-W', 'bulk-memory',
168
168
  '-W', 'multi-memory',
169
- '-W', 'max-wasm-stack=2000000',
169
+ '-W', 'max-wasm-stack=4000000',
170
170
  '-W', 'nan-canonicalization=y',
171
171
  wasmFile,
172
172
  ];
173
173
  }
174
174
  else {
175
175
  wasmtimeArgs = [
176
- '--max-wasm-stack=2000000',
176
+ '--max-wasm-stack=4000000',
177
177
  '--enable-cranelift-nan-canonicalization',
178
178
  '--wasm-features',
179
179
  'multi-memory,bulk-memory',
@@ -203,7 +203,7 @@ export async function testWithReporter(reporter: Reporter, filter = '', mode: Te
203
203
  return reporter.done();
204
204
  }
205
205
 
206
- function pipeMMF(proc: ChildProcessWithoutNullStreams, mmf: MMF1) {
206
+ function pipeMMF(proc : ChildProcessWithoutNullStreams, mmf : MMF1) {
207
207
  return new Promise<void>((resolve) => {
208
208
  // stdout
209
209
  proc.stdout.on('data', (data) => {
@@ -217,9 +217,9 @@ function pipeMMF(proc: ChildProcessWithoutNullStreams, mmf: MMF1) {
217
217
 
218
218
  // stderr
219
219
  proc.stderr.on('data', (data) => {
220
- let text: string = data.toString().trim();
220
+ let text : string = data.toString().trim();
221
221
  let failedLine = '';
222
- text = text.replace(/([\w+._/-]+):(\d+).(\d+)(-\d+.\d+)/g, (_m0, m1: string, m2: string, m3: string) => {
222
+ text = text.replace(/([\w+._/-]+):(\d+).(\d+)(-\d+.\d+)/g, (_m0, m1 : string, m2 : string, m3 : string) => {
223
223
  // change absolute file path to relative
224
224
  // change :line:col-line:col to :line:col to work in vscode
225
225
  let res = `${absToRel(m1)}:${m2}:${m3}`;
@@ -1,7 +1,7 @@
1
1
  import path from 'node:path';
2
2
  import {getRootDir} from '../../mops.js';
3
3
 
4
- export function absToRel(p: string) {
4
+ export function absToRel(p : string) {
5
5
  let rootDir = getRootDir();
6
6
  return path.relative(rootDir, path.resolve(p));
7
7
  }