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,7 +9,9 @@ export declare class BenchReplica {
9
9
  }>;
10
10
  pocketIc?: PocketIc;
11
11
  constructor(type: 'dfx' | 'pocket-ic', verbose?: boolean);
12
- start(): Promise<void>;
12
+ start({ silent }?: {
13
+ silent?: boolean | undefined;
14
+ }): Promise<void>;
13
15
  stop(): Promise<void>;
14
16
  deploy(name: string, wasm: string, cwd?: string): Promise<void>;
15
17
  getActor(name: string): unknown;
@@ -13,8 +13,8 @@ export class BenchReplica {
13
13
  this.type = type;
14
14
  this.verbose = verbose;
15
15
  }
16
- async start() {
17
- console.log(`Starting ${this.type} replica...`);
16
+ async start({ silent = false } = {}) {
17
+ silent || console.log(`Starting ${this.type} replica...`);
18
18
  if (this.type == 'dfx') {
19
19
  await this.stop();
20
20
  let dir = path.join(getRootDir(), '.mops/.bench');
@@ -1,12 +1,15 @@
1
+ import { Benchmarks } from '../declarations/main/main.did.js';
1
2
  type BenchOptions = {
2
3
  replica: 'dfx' | 'pocket-ic';
3
4
  replicaVersion: string;
4
- moc: string;
5
+ compiler: 'moc';
6
+ compilerVersion: string;
5
7
  gc: 'copying' | 'compacting' | 'generational' | 'incremental';
6
8
  forceGc: boolean;
7
9
  save: boolean;
8
10
  compare: boolean;
9
11
  verbose: boolean;
12
+ silent: boolean;
10
13
  };
11
- export declare function bench(filter?: string, optionsArg?: Partial<BenchOptions>): Promise<boolean>;
14
+ export declare function bench(filter?: string, optionsArg?: Partial<BenchOptions>): Promise<Benchmarks>;
12
15
  export {};
@@ -7,7 +7,7 @@ import { markdownTable } from 'markdown-table';
7
7
  import logUpdate from 'log-update';
8
8
  import { execaCommand } from 'execa';
9
9
  import stringWidth from 'string-width';
10
- import { getRootDir } from '../mops.js';
10
+ import { getRootDir, readConfig } from '../mops.js';
11
11
  import { parallel } from '../parallel.js';
12
12
  import { absToRel } from './test/utils.js';
13
13
  import { getMocVersion } from '../helpers/get-moc-version.js';
@@ -28,16 +28,24 @@ let globConfig = {
28
28
  export async function bench(filter = '', optionsArg = {}) {
29
29
  let defaultOptions = {
30
30
  replica: 'dfx',
31
- moc: getMocVersion(),
32
- replicaVersion: '0.0.0',
31
+ replicaVersion: '',
32
+ compiler: 'moc',
33
+ compilerVersion: getMocVersion(),
33
34
  gc: 'copying',
34
35
  forceGc: true,
35
36
  save: false,
36
37
  compare: false,
37
38
  verbose: false,
39
+ silent: false,
38
40
  };
39
41
  let options = { ...defaultOptions, ...optionsArg };
40
- options.replicaVersion = options.replica == 'dfx' ? getDfxVersion() : '1.0.0';
42
+ if (options.replica == 'dfx') {
43
+ options.replicaVersion = getDfxVersion();
44
+ }
45
+ else if (options.replica == 'pocket-ic') {
46
+ let config = readConfig();
47
+ options.replicaVersion = config.toolchain?.['pocket-ic'] || '';
48
+ }
41
49
  options.verbose && console.log(options);
42
50
  let replica = new BenchReplica(options.replica, options.verbose);
43
51
  let rootDir = getRootDir();
@@ -48,26 +56,30 @@ export async function bench(filter = '', optionsArg = {}) {
48
56
  let files = globSync(path.join(rootDir, globStr), globConfig);
49
57
  if (!files.length) {
50
58
  if (filter) {
51
- console.log(`No benchmark files found for filter '${filter}'`);
52
- return false;
59
+ options.silent || console.log(`No benchmark files found for filter '${filter}'`);
60
+ return [];
61
+ }
62
+ if (!options.silent) {
63
+ console.log('No *.bench.mo files found');
64
+ console.log('Put your benchmark code in \'bench\' directory in *.bench.mo files');
53
65
  }
54
- console.log('No *.bench.mo files found');
55
- console.log('Put your benchmark code in \'bench\' directory in *.bench.mo files');
56
- return false;
66
+ return [];
57
67
  }
58
68
  files.sort();
59
69
  let benchDir = `${getRootDir()}/.mops/.bench/`;
60
70
  fs.rmSync(benchDir, { recursive: true, force: true });
61
71
  fs.mkdirSync(benchDir, { recursive: true });
62
- console.log('Benchmark files:');
63
- for (let file of files) {
64
- console.log(chalk.gray(`• ${absToRel(file)}`));
72
+ if (!options.silent) {
73
+ console.log('Benchmark files:');
74
+ for (let file of files) {
75
+ console.log(chalk.gray(`• ${absToRel(file)}`));
76
+ }
77
+ console.log('');
78
+ console.log('='.repeat(50));
79
+ console.log('');
65
80
  }
66
- console.log('');
67
- console.log('='.repeat(50));
68
- console.log('');
69
- await replica.start();
70
- console.log('Deploying canisters...');
81
+ await replica.start({ silent: options.silent });
82
+ options.silent || console.log('Deploying canisters...');
71
83
  await parallel(os.cpus().length, files, async (file) => {
72
84
  try {
73
85
  await deployBenchFile(file, options, replica);
@@ -78,12 +90,16 @@ export async function bench(filter = '', optionsArg = {}) {
78
90
  throw err;
79
91
  }
80
92
  });
93
+ let benchResults = [];
81
94
  await parallel(1, files, async (file) => {
82
- console.log('\n' + '—'.repeat(50));
83
- console.log(`\nRunning ${chalk.gray(absToRel(file))}...`);
84
- console.log('');
95
+ if (!options.silent) {
96
+ console.log('\n' + '—'.repeat(50));
97
+ console.log(`\nRunning ${chalk.gray(absToRel(file))}...`);
98
+ console.log('');
99
+ }
85
100
  try {
86
- await runBenchFile(file, options, replica);
101
+ let benchResult = await runBenchFile(file, options, replica);
102
+ benchResults.push(benchResult);
87
103
  }
88
104
  catch (err) {
89
105
  console.error('Unexpected error. Stopping replica...');
@@ -91,10 +107,10 @@ export async function bench(filter = '', optionsArg = {}) {
91
107
  throw err;
92
108
  }
93
109
  });
94
- console.log('Stopping replica...');
110
+ options.silent || console.log('Stopping replica...');
95
111
  await replica.stop();
96
112
  fs.rmSync(benchDir, { recursive: true, force: true });
97
- return true;
113
+ return benchResults;
98
114
  }
99
115
  function getMocArgs(options) {
100
116
  let args = '';
@@ -152,6 +168,8 @@ async function runBenchFile(file, options, replica) {
152
168
  }
153
169
  }
154
170
  let results = new Map();
171
+ let instructionsCells = Array.from({ length: schema.rows.length }, () => []);
172
+ let heapCells = Array.from({ length: schema.rows.length }, () => []);
155
173
  let formatNumber = (n) => {
156
174
  return n.toLocaleString('en-US').replaceAll(',', '_');
157
175
  };
@@ -199,17 +217,19 @@ async function runBenchFile(file, options, replica) {
199
217
  \n\n${chalk.blue('Heap')}\n\n${getTable('rts_heap_size')}
200
218
  `);
201
219
  };
202
- if (!process.env.CI) {
220
+ if (!process.env.CI && !options.silent) {
203
221
  printResults();
204
222
  }
205
223
  // run all cells
206
224
  for (let [rowIndex, row] of schema.rows.entries()) {
207
225
  for (let [colIndex, col] of schema.cols.entries()) {
208
- // let res = await actor.runCellQuery(BigInt(rowIndex), BigInt(colIndex));
209
- // let res = await actor.runCellUpdate(BigInt(rowIndex), BigInt(colIndex));
210
226
  let res = await actor.runCellUpdateAwait(BigInt(rowIndex), BigInt(colIndex));
211
227
  results.set(`${row}:${col}`, res);
212
- if (!process.env.CI) {
228
+ // @ts-ignore
229
+ instructionsCells[rowIndex][colIndex] = res.instructions;
230
+ // @ts-ignore
231
+ heapCells[rowIndex][colIndex] = res.rts_heap_size;
232
+ if (!process.env.CI && !options.silent) {
213
233
  printResults();
214
234
  }
215
235
  }
@@ -223,7 +243,7 @@ async function runBenchFile(file, options, replica) {
223
243
  console.log(`Saving results to ${chalk.gray(absToRel(resultsJsonFile))}`);
224
244
  let json = {
225
245
  version: 1,
226
- moc: options.moc,
246
+ moc: options.compilerVersion,
227
247
  replica: options.replica,
228
248
  replicaVersion: options.replicaVersion,
229
249
  gc: options.gc,
@@ -240,5 +260,22 @@ async function runBenchFile(file, options, replica) {
240
260
  }
241
261
  }, 2));
242
262
  }
243
- return { schema, results };
263
+ // for backend
264
+ return {
265
+ name: schema.name,
266
+ description: schema.description,
267
+ file: absToRel(file),
268
+ gc: options.gc,
269
+ forceGC: options.forceGc,
270
+ replica: options.replica,
271
+ replicaVersion: options.replicaVersion,
272
+ compiler: options.compiler,
273
+ compilerVersion: options.compilerVersion,
274
+ rows: schema.rows,
275
+ cols: schema.cols,
276
+ metrics: [
277
+ ['instructions', instructionsCells],
278
+ ['rts_heap_size', heapCells],
279
+ ],
280
+ };
244
281
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -51,7 +51,7 @@ export async function init({ yes = false } = {}) {
51
51
  onCancel() {
52
52
  console.log('aborted');
53
53
  process.exit(0);
54
- }
54
+ },
55
55
  };
56
56
  // type
57
57
  let { type } = await prompts({
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,4 +1,5 @@
1
1
  export declare function publish(options?: {
2
2
  docs?: boolean;
3
3
  test?: boolean;
4
+ bench?: boolean;
4
5
  }): Promise<void>;
@@ -13,6 +13,7 @@ import { parallel } from '../parallel.js';
13
13
  import { docs } from './docs.js';
14
14
  import { testWithReporter } from './test/test.js';
15
15
  import { SilentReporter } from './test/reporters/silent-reporter.js';
16
+ import { bench } from './bench.js';
16
17
  export async function publish(options = {}) {
17
18
  if (!checkConfigFile()) {
18
19
  return;
@@ -145,7 +146,7 @@ export async function publish(options = {}) {
145
146
  return {
146
147
  ...dep,
147
148
  version: dep.version || '',
148
- repo: dep.repo || ''
149
+ repo: dep.repo || '',
149
150
  };
150
151
  };
151
152
  // map fields
@@ -231,6 +232,24 @@ export async function publish(options = {}) {
231
232
  process.exit(1);
232
233
  }
233
234
  }
235
+ // bench
236
+ let benchmarks = [];
237
+ if (options.bench) {
238
+ console.log('Running benchmarks...');
239
+ try {
240
+ benchmarks = await bench('', {
241
+ replica: config.toolchain?.['pocket-ic'] ? 'pocket-ic' : 'dfx',
242
+ gc: 'copying',
243
+ forceGc: true,
244
+ silent: true,
245
+ });
246
+ }
247
+ catch (err) {
248
+ console.error(err);
249
+ console.log(chalk.red('Error: ') + 'benchmarks failed');
250
+ process.exit(1);
251
+ }
252
+ }
234
253
  // progress
235
254
  let total = files.length + 2;
236
255
  let step = 0;
@@ -255,6 +274,10 @@ export async function publish(options = {}) {
255
274
  passedNames: reporter.passedNamesFlat,
256
275
  });
257
276
  }
277
+ // upload benchmarks
278
+ if (options.bench) {
279
+ await actor.uploadBenchmarks(puiblishingId, benchmarks);
280
+ }
258
281
  // upload changelog
259
282
  if (changelog) {
260
283
  await actor.uploadNotes(puiblishingId, changelog);
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ export declare function getLatestVersion(): Promise<string>;
2
+ export declare function update(): Promise<void>;
3
+ export declare function uninstall(): Promise<void>;
@@ -0,0 +1,62 @@
1
+ import child_process, { execSync } from 'node:child_process';
2
+ import chalk from 'chalk';
3
+ import { version, globalConfigDir } from '../mops.js';
4
+ import { cleanCache } from '../cache.js';
5
+ import { toolchain } from './toolchain/index.js';
6
+ let url = 'https://x344g-ziaaa-aaaap-abl7a-cai.icp0.io';
7
+ function detectPackageManager() {
8
+ let res = '';
9
+ try {
10
+ res = execSync('which mops').toString();
11
+ }
12
+ catch (e) { }
13
+ if (!res) {
14
+ console.error(chalk.red('Couldn\'t detect package manager'));
15
+ process.exit(1);
16
+ }
17
+ if (res.includes('pnpm/')) {
18
+ return 'pnpm';
19
+ }
20
+ // else if (res.includes('bun/')) {
21
+ // return 'bun';
22
+ // }
23
+ else {
24
+ return 'npm';
25
+ }
26
+ }
27
+ export async function getLatestVersion() {
28
+ let res = await fetch(url + '/tags/latest');
29
+ return res.text();
30
+ }
31
+ export async function update() {
32
+ let latest = await getLatestVersion();
33
+ let current = version();
34
+ if (latest === current) {
35
+ console.log(chalk.green('You are up to date. Version: ' + current));
36
+ }
37
+ else {
38
+ console.log('Current version: ' + chalk.yellow(current));
39
+ console.log('Updating to version: ' + chalk.green(latest));
40
+ let pm = detectPackageManager();
41
+ let npmArgs = pm === 'npm' ? ['--no-fund', '--silent'] : [];
42
+ let proc = child_process.spawn(pm, ['add', '-g', ...npmArgs, `${url}/versions/${latest}/cli.tgz`], { stdio: 'inherit', detached: false });
43
+ proc.on('exit', (res) => {
44
+ if (res !== 0) {
45
+ console.log(chalk.red('Failed to update.'));
46
+ process.exit(1);
47
+ }
48
+ console.log(chalk.green('Success'));
49
+ });
50
+ }
51
+ }
52
+ export async function uninstall() {
53
+ console.log('Cleaning cache...');
54
+ cleanCache();
55
+ console.log('Resetting toolchain management...');
56
+ toolchain.init({ reset: true, silent: true });
57
+ console.log('Uninstalling mops CLI...');
58
+ let pm = detectPackageManager();
59
+ child_process.spawn(pm, ['remove', '-g', '--silent', 'ic-mops'], { stdio: 'inherit', detached: false });
60
+ console.log(chalk.yellow('Config directory has not been deleted: ' + globalConfigDir));
61
+ console.log('Uninstalled');
62
+ }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -24,7 +24,7 @@ export class MMF1 {
24
24
  if (this.srategy === 'store') {
25
25
  this.output.push({
26
26
  type,
27
- message: args.join(' ')
27
+ message: args.join(' '),
28
28
  });
29
29
  }
30
30
  else if (this.srategy === 'print') {
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -142,14 +142,14 @@ export async function testWithReporter(reporter, filter = '', mode = 'interprete
142
142
  '-C', 'cache=n',
143
143
  '-W', 'bulk-memory',
144
144
  '-W', 'multi-memory',
145
- '-W', 'max-wasm-stack=2000000',
145
+ '-W', 'max-wasm-stack=4000000',
146
146
  '-W', 'nan-canonicalization=y',
147
147
  wasmFile,
148
148
  ];
149
149
  }
150
150
  else {
151
151
  wasmtimeArgs = [
152
- '--max-wasm-stack=2000000',
152
+ '--max-wasm-stack=4000000',
153
153
  '--enable-cranelift-nan-canonicalization',
154
154
  '--wasm-features',
155
155
  'multi-memory,bulk-memory',
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,10 +1,6 @@
1
1
  export declare let repo: string;
2
2
  export declare let getLatestReleaseTag: () => Promise<string>;
3
- export declare let getReleases: () => Promise<{
4
- tag_name: string;
5
- published_at: Date;
6
- draft: boolean;
7
- }[]>;
3
+ export declare let getReleases: () => Promise<any>;
8
4
  export declare let isCached: (version: string) => boolean;
9
5
  export declare let download: (version: string, { silent, verbose }?: {
10
6
  silent?: boolean | undefined;
@@ -5,28 +5,10 @@ import * as toolchainUtils from './toolchain-utils.js';
5
5
  let cacheDir = path.join(globalCacheDir, 'pocket-ic');
6
6
  export let repo = 'dfinity/pocketic';
7
7
  export let getLatestReleaseTag = async () => {
8
- return '1.0.0';
9
- // return toolchainUtils.getLatestReleaseTag(repo);
8
+ return toolchainUtils.getLatestReleaseTag(repo);
10
9
  };
11
10
  export let getReleases = async () => {
12
- // return toolchainUtils.getReleases(repo);
13
- return [
14
- {
15
- tag_name: '2.0.1',
16
- published_at: new Date('2023-11-23'),
17
- draft: false,
18
- },
19
- {
20
- tag_name: '2.0.0',
21
- published_at: new Date('2023-11-21'),
22
- draft: false,
23
- },
24
- {
25
- tag_name: '1.0.0',
26
- published_at: new Date('2023-10-12'),
27
- draft: false,
28
- },
29
- ];
11
+ return toolchainUtils.getReleases(repo);
30
12
  };
31
13
  export let isCached = (version) => {
32
14
  let dir = path.join(cacheDir, version);
@@ -45,14 +27,9 @@ export let download = async (version, { silent = false, verbose = false } = {})
45
27
  }
46
28
  let platfrom = process.platform == 'darwin' ? 'darwin' : 'linux';
47
29
  let arch = 'x86_64';
48
- let hashes = {
49
- '2.0.1': '69e1408347723dbaa7a6cd2faa9b65c42abbe861',
50
- '2.0.0': '29ec86dc9f9ca4691d4d4386c8b2aa41e14d9d16',
51
- '1.0.0': '307d5847c1d2fe1f5e19181c7d0fcec23f4658b3',
52
- };
53
- let url = `https://download.dfinity.systems/ic/${hashes[version]}/openssl-static-binaries/${arch}-${platfrom}/pocket-ic.gz`;
30
+ let url = `https://github.com/dfinity/pocketic/releases/download/${version}/pocket-ic-${arch}-${platfrom}.gz`;
54
31
  if (verbose && !silent) {
55
32
  console.log(`Downloading ${url}`);
56
33
  }
57
- await toolchainUtils.downloadAndExtract(url, path.join(cacheDir, version));
34
+ await toolchainUtils.downloadAndExtract(url, path.join(cacheDir, version), 'pocket-ic');
58
35
  };
@@ -1,3 +1,3 @@
1
- export declare let downloadAndExtract: (url: string, dest: string) => Promise<void>;
1
+ export declare let downloadAndExtract: (url: string, destDir: string, destFileName?: string) => Promise<void>;
2
2
  export declare let getLatestReleaseTag: (repo: string) => Promise<string>;
3
3
  export declare let getReleases: (repo: string) => Promise<any>;
@@ -8,7 +8,7 @@ import { deleteSync } from 'del';
8
8
  import { Octokit } from 'octokit';
9
9
  import tar from 'tar';
10
10
  import { getRootDir } from '../../mops.js';
11
- export let downloadAndExtract = async (url, dest) => {
11
+ export let downloadAndExtract = async (url, destDir, destFileName = '') => {
12
12
  let res = await fetch(url);
13
13
  if (res.status !== 200) {
14
14
  console.error(`ERROR ${res.status} ${url}`);
@@ -20,7 +20,7 @@ export let downloadAndExtract = async (url, dest) => {
20
20
  let archive = path.join(tmpDir, path.basename(url));
21
21
  fs.mkdirSync(tmpDir, { recursive: true });
22
22
  fs.writeFileSync(archive, buffer);
23
- fs.mkdirSync(dest, { recursive: true });
23
+ fs.mkdirSync(destDir, { recursive: true });
24
24
  if (archive.endsWith('.xz')) {
25
25
  let decompressTarxz = await import('decomp-tarxz');
26
26
  await decompress(archive, tmpDir, {
@@ -28,16 +28,16 @@ export let downloadAndExtract = async (url, dest) => {
28
28
  }).catch(() => {
29
29
  deleteSync([tmpDir]);
30
30
  });
31
- fs.cpSync(path.join(tmpDir, path.parse(archive).name.replace('.tar', '')), dest, { recursive: true });
31
+ fs.cpSync(path.join(tmpDir, path.parse(archive).name.replace('.tar', '')), destDir, { recursive: true });
32
32
  }
33
33
  else if (archive.endsWith('tar.gz')) {
34
34
  await tar.extract({
35
35
  file: archive,
36
- cwd: dest,
36
+ cwd: destDir,
37
37
  });
38
38
  }
39
39
  else if (archive.endsWith('.gz')) {
40
- let destFile = path.join(dest, path.parse(archive).name);
40
+ let destFile = path.join(destDir, destFileName || path.parse(archive).name);
41
41
  fs.writeFileSync(destFile, unzipSync(buffer));
42
42
  chmodSync(destFile, 0o700);
43
43
  }
@@ -57,8 +57,8 @@ export let getReleases = async (repo) => {
57
57
  let res = await octokit.request(`GET /repos/${repo}/releases`, {
58
58
  per_page: 10,
59
59
  headers: {
60
- 'X-GitHub-Api-Version': '2022-11-28'
61
- }
60
+ 'X-GitHub-Api-Version': '2022-11-28',
61
+ },
62
62
  });
63
63
  if (res.status !== 200) {
64
64
  console.log('Releases fetch error');
File without changes
File without changes
File without changes
@@ -13,7 +13,7 @@ export async function transferOwnership(toPrincipal) {
13
13
  onCancel() {
14
14
  console.log('aborted');
15
15
  process.exit(0);
16
- }
16
+ },
17
17
  };
18
18
  console.log(chalk.red('Warning: ') + 'This action cannot be undone!');
19
19
  let { confirm } = await prompts({
File without changes
File without changes
File without changes
File without changes