ic-mops 0.45.4-pre.0 → 1.0.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 (76) hide show
  1. package/CHANGELOG.md +19 -1
  2. package/README.md +1 -1
  3. package/api/actors.ts +1 -1
  4. package/bundle/cli.tgz +0 -0
  5. package/cache.ts +15 -10
  6. package/cli.ts +27 -27
  7. package/commands/add.ts +4 -0
  8. package/commands/bench/bench-canister.mo +34 -8
  9. package/commands/bench-replica.ts +11 -6
  10. package/commands/bench.ts +29 -3
  11. package/commands/publish.ts +1 -1
  12. package/commands/replica.ts +239 -0
  13. package/commands/sources.ts +2 -3
  14. package/commands/test/mmf1.ts +10 -6
  15. package/commands/test/reporters/compact-reporter.ts +2 -1
  16. package/commands/test/reporters/files-reporter.ts +3 -2
  17. package/commands/test/reporters/reporter.ts +2 -1
  18. package/commands/test/reporters/silent-reporter.ts +2 -1
  19. package/commands/test/reporters/verbose-reporter.ts +14 -4
  20. package/commands/test/test.ts +214 -81
  21. package/commands/user.ts +71 -1
  22. package/declarations/bench/bench.did +6 -2
  23. package/declarations/bench/bench.did.d.ts +6 -2
  24. package/declarations/bench/bench.did.js +6 -2
  25. package/dist/cache.js +14 -10
  26. package/dist/cli.d.ts +1 -0
  27. package/dist/cli.js +23 -27
  28. package/dist/commands/add.js +3 -0
  29. package/dist/commands/bench/bench-canister.mo +34 -8
  30. package/dist/commands/bench-replica.d.ts +2 -1
  31. package/dist/commands/bench-replica.js +10 -6
  32. package/dist/commands/bench.js +27 -3
  33. package/dist/commands/publish.js +1 -1
  34. package/dist/commands/replica.d.ts +59 -0
  35. package/dist/commands/replica.js +195 -0
  36. package/dist/commands/sources.d.ts +2 -2
  37. package/dist/commands/sources.js +2 -3
  38. package/dist/commands/test/mmf1.d.ts +2 -2
  39. package/dist/commands/test/mmf1.js +9 -5
  40. package/dist/commands/test/reporters/compact-reporter.d.ts +2 -1
  41. package/dist/commands/test/reporters/compact-reporter.js +1 -1
  42. package/dist/commands/test/reporters/files-reporter.d.ts +2 -1
  43. package/dist/commands/test/reporters/files-reporter.js +2 -2
  44. package/dist/commands/test/reporters/reporter.d.ts +2 -1
  45. package/dist/commands/test/reporters/silent-reporter.d.ts +2 -1
  46. package/dist/commands/test/reporters/silent-reporter.js +1 -1
  47. package/dist/commands/test/reporters/verbose-reporter.d.ts +3 -1
  48. package/dist/commands/test/reporters/verbose-reporter.js +12 -4
  49. package/dist/commands/test/test.d.ts +10 -8
  50. package/dist/commands/test/test.js +171 -78
  51. package/dist/commands/user.d.ts +6 -0
  52. package/dist/commands/user.js +59 -1
  53. package/dist/declarations/bench/bench.did +6 -2
  54. package/dist/declarations/bench/bench.did.d.ts +6 -2
  55. package/dist/declarations/bench/bench.did.js +6 -2
  56. package/dist/mops.d.ts +1 -1
  57. package/dist/mops.js +5 -29
  58. package/dist/package.json +20 -21
  59. package/dist/release-cli.js +5 -2
  60. package/dist/resolve-packages.d.ts +2 -2
  61. package/dist/resolve-packages.js +29 -7
  62. package/dist/types.d.ts +1 -0
  63. package/dist/vessel.js +1 -1
  64. package/mops.ts +5 -32
  65. package/package.json +24 -24
  66. package/release-cli.ts +7 -2
  67. package/resolve-packages.ts +39 -8
  68. package/types.ts +3 -1
  69. package/vessel.ts +1 -1
  70. package/DEVELOPMENT.md +0 -25
  71. package/commands/import-identity.ts +0 -62
  72. package/commands/whoami.ts +0 -12
  73. package/dist/commands/import-identity.d.ts +0 -5
  74. package/dist/commands/import-identity.js +0 -51
  75. package/dist/commands/whoami.d.ts +0 -1
  76. package/dist/commands/whoami.js +0 -11
@@ -17,6 +17,8 @@ import { FilesReporter } from './reporters/files-reporter.js';
17
17
  import { CompactReporter } from './reporters/compact-reporter.js';
18
18
  import { SilentReporter } from './reporters/silent-reporter.js';
19
19
  import { toolchain } from '../toolchain/index.js';
20
+ import { Replica } from '../replica.js';
21
+ import { PassThrough } from 'node:stream';
20
22
  let ignore = [
21
23
  '**/node_modules/**',
22
24
  '**/.mops/**',
@@ -27,15 +29,43 @@ let globConfig = {
27
29
  nocase: true,
28
30
  ignore: ignore,
29
31
  };
30
- export async function test(filter = '', { watch = false, reporter = 'verbose', mode = 'interpreter' } = {}) {
32
+ let replica = new Replica();
33
+ let replicaStartPromise;
34
+ async function startReplicaOnce(replica, type) {
35
+ if (!replicaStartPromise) {
36
+ replicaStartPromise = new Promise((resolve) => {
37
+ replica.start({ type, silent: true }).then(resolve);
38
+ });
39
+ }
40
+ return replicaStartPromise;
41
+ }
42
+ export async function test(filter = '', options = {}) {
43
+ let config = readConfig();
31
44
  let rootDir = getRootDir();
32
- if (watch) {
45
+ let replicaType = options.replica ?? (config.toolchain?.['pocket-ic'] ? 'pocket-ic' : 'dfx');
46
+ replica.type = replicaType;
47
+ if (options.watch) {
48
+ replica.ttl = 60 * 15; // 15 minutes
49
+ let sigint = false;
50
+ process.on('SIGINT', () => {
51
+ if (sigint) {
52
+ console.log('Force exit');
53
+ process.exit(0);
54
+ }
55
+ sigint = true;
56
+ if (replicaStartPromise) {
57
+ console.log('Stopping replica...');
58
+ replica.stop(true).then(() => {
59
+ process.exit(0);
60
+ });
61
+ }
62
+ });
33
63
  // todo: run only changed for *.test.mo?
34
64
  // todo: run all for *.mo?
35
65
  let run = debounce(async () => {
36
66
  console.clear();
37
67
  process.stdout.write('\x1Bc');
38
- await runAll(reporter, filter, mode);
68
+ await runAll(options.reporter, filter, options.mode, replicaType, true);
39
69
  console.log('-'.repeat(50));
40
70
  console.log('Waiting for file changes...');
41
71
  console.log(chalk.gray((`Press ${chalk.gray('Ctrl+C')} to exit.`)));
@@ -53,7 +83,7 @@ export async function test(filter = '', { watch = false, reporter = 'verbose', m
53
83
  run();
54
84
  }
55
85
  else {
56
- let passed = await runAll(reporter, filter, mode);
86
+ let passed = await runAll(options.reporter, filter, options.mode, replicaType);
57
87
  if (!passed) {
58
88
  process.exit(1);
59
89
  }
@@ -61,24 +91,11 @@ export async function test(filter = '', { watch = false, reporter = 'verbose', m
61
91
  }
62
92
  let mocPath = '';
63
93
  let wasmtimePath = '';
64
- export async function runAll(reporterName = 'verbose', filter = '', mode = 'interpreter') {
65
- let reporter;
66
- if (reporterName == 'compact') {
67
- reporter = new CompactReporter;
68
- }
69
- else if (reporterName == 'files') {
70
- reporter = new FilesReporter;
71
- }
72
- else if (reporterName == 'silent') {
73
- reporter = new SilentReporter;
74
- }
75
- else {
76
- reporter = new VerboseReporter;
77
- }
78
- let done = await testWithReporter(reporter, filter, mode);
94
+ async function runAll(reporterName, filter = '', mode = 'interpreter', replicaType, watch = false) {
95
+ let done = await testWithReporter(reporterName, filter, mode, replicaType, watch);
79
96
  return done;
80
97
  }
81
- export async function testWithReporter(reporter, filter = '', mode = 'interpreter') {
98
+ export async function testWithReporter(reporterName, filter = '', defaultMode = 'interpreter', replicaType, watch = false) {
82
99
  let rootDir = getRootDir();
83
100
  let files = [];
84
101
  let libFiles = globSync('**/test?(s)/lib.mo', globConfig);
@@ -101,18 +118,48 @@ export async function testWithReporter(reporter, filter = '', mode = 'interprete
101
118
  console.log('Put your tests in \'test\' directory in *.test.mo files');
102
119
  return false;
103
120
  }
121
+ let reporter;
122
+ if (!reporterName || typeof reporterName === 'string') {
123
+ if (!reporterName) {
124
+ reporterName = files.length > 1 ? 'files' : 'verbose';
125
+ }
126
+ if (reporterName == 'compact') {
127
+ reporter = new CompactReporter;
128
+ }
129
+ else if (reporterName == 'files') {
130
+ reporter = new FilesReporter;
131
+ }
132
+ else if (reporterName == 'silent') {
133
+ reporter = new SilentReporter;
134
+ }
135
+ else {
136
+ reporter = new VerboseReporter;
137
+ }
138
+ }
139
+ else {
140
+ reporter = reporterName;
141
+ }
104
142
  reporter.addFiles(files);
105
143
  let config = readConfig();
106
144
  let sourcesArr = await sources();
107
145
  if (!mocPath) {
108
146
  mocPath = await toolchain.bin('moc', { fallback: true });
109
147
  }
110
- let wasmDir = `${getRootDir()}/.mops/.test/`;
111
- fs.mkdirSync(wasmDir, { recursive: true });
148
+ let testTempDir = path.join(getRootDir(), '.mops/.test/');
149
+ replica.dir = testTempDir;
150
+ fs.mkdirSync(testTempDir, { recursive: true });
112
151
  await parallel(os.cpus().length, files, async (file) => {
113
152
  let mmf = new MMF1('store', absToRel(file));
114
- let wasiMode = mode === 'wasi' || fs.readFileSync(file, 'utf8').startsWith('// @testmode wasi');
115
- if (wasiMode && !wasmtimePath) {
153
+ // mode overrides
154
+ let lines = fs.readFileSync(file, 'utf8').split('\n');
155
+ let mode = defaultMode;
156
+ if (lines.includes('// @testmode wasi')) {
157
+ mode = 'wasi';
158
+ }
159
+ else if (lines.includes('actor {') || lines.includes('// @testmode replica')) {
160
+ mode = 'replica';
161
+ }
162
+ if (mode === 'wasi' && !wasmtimePath) {
116
163
  // ensure wasmtime is installed or specified in config
117
164
  if (config.toolchain?.wasmtime) {
118
165
  wasmtimePath = await toolchain.bin('wasmtime');
@@ -126,9 +173,14 @@ export async function testWithReporter(reporter, filter = '', mode = 'interprete
126
173
  }
127
174
  let promise = new Promise((resolve) => {
128
175
  let mocArgs = ['--hide-warnings', '--error-detail=2', ...sourcesArr.join(' ').split(' '), file].filter(x => x);
176
+ // interpret
177
+ if (mode === 'interpreter') {
178
+ let proc = spawn(mocPath, ['-r', '-ref-system-api', ...mocArgs]);
179
+ pipeMMF(proc, mmf).then(resolve);
180
+ }
129
181
  // build and run wasm
130
- if (wasiMode) {
131
- let wasmFile = `${path.join(wasmDir, path.parse(file).name)}.wasm`;
182
+ else if (mode === 'wasi') {
183
+ let wasmFile = `${path.join(testTempDir, path.parse(file).name)}.wasm`;
132
184
  // build
133
185
  let buildProc = spawn(mocPath, [`-o=${wasmFile}`, '-wasi-system-api', ...mocArgs]);
134
186
  pipeMMF(buildProc, mmf).then(async () => {
@@ -149,13 +201,8 @@ export async function testWithReporter(reporter, filter = '', mode = 'interprete
149
201
  ];
150
202
  }
151
203
  else {
152
- wasmtimeArgs = [
153
- '--max-wasm-stack=4000000',
154
- '--enable-cranelift-nan-canonicalization',
155
- '--wasm-features',
156
- 'multi-memory,bulk-memory',
157
- wasmFile,
158
- ];
204
+ console.error(chalk.red('Minimum wasmtime version is 14.0.0. Please update wasmtime to the latest version'));
205
+ process.exit(1);
159
206
  }
160
207
  let proc = spawn(wasmtimePath, wasmtimeArgs);
161
208
  await pipeMMF(proc, mmf);
@@ -163,64 +210,110 @@ export async function testWithReporter(reporter, filter = '', mode = 'interprete
163
210
  fs.rmSync(wasmFile, { force: true });
164
211
  }).then(resolve);
165
212
  }
166
- // interpret
167
- else {
168
- let proc = spawn(mocPath, ['-r', '-ref-system-api', ...mocArgs]);
169
- pipeMMF(proc, mmf).then(resolve);
213
+ // build and execute in replica
214
+ else if (mode === 'replica') {
215
+ // mmf.strategy = 'print'; // because we run replica tests one-by-one
216
+ let wasmFile = `${path.join(testTempDir, path.parse(file).name)}.wasm`;
217
+ // build
218
+ let buildProc = spawn(mocPath, [`-o=${wasmFile}`, ...mocArgs]);
219
+ pipeMMF(buildProc, mmf).then(async () => {
220
+ if (mmf.failed > 0) {
221
+ return;
222
+ }
223
+ await startReplicaOnce(replica, replicaType);
224
+ let canisterName = path.parse(file).name;
225
+ let idlFactory = ({ IDL }) => {
226
+ return IDL.Service({ 'runTests': IDL.Func([], [], []) });
227
+ };
228
+ let { stream } = await replica.deploy(canisterName, wasmFile, idlFactory);
229
+ pipeStdoutToMMF(stream, mmf);
230
+ let actor = await replica.getActor(canisterName);
231
+ try {
232
+ if (globalThis.mopsReplicaTestRunning) {
233
+ await new Promise((resolve) => {
234
+ let timerId = setInterval(() => {
235
+ if (!globalThis.mopsReplicaTestRunning) {
236
+ resolve();
237
+ clearInterval(timerId);
238
+ }
239
+ }, Math.random() * 1000 | 0);
240
+ });
241
+ }
242
+ globalThis.mopsReplicaTestRunning = true;
243
+ await actor.runTests();
244
+ globalThis.mopsReplicaTestRunning = false;
245
+ mmf.pass();
246
+ }
247
+ catch (e) {
248
+ let stderrStream = new PassThrough();
249
+ pipeStderrToMMF(stderrStream, mmf, path.dirname(file));
250
+ stderrStream.write(e.message);
251
+ }
252
+ }).finally(async () => {
253
+ fs.rmSync(wasmFile, { force: true });
254
+ }).then(resolve);
170
255
  }
171
256
  });
172
- reporter.addRun(file, mmf, promise, wasiMode);
257
+ reporter.addRun(file, mmf, promise, mode);
173
258
  await promise;
174
259
  });
175
- fs.rmSync(wasmDir, { recursive: true, force: true });
260
+ if (replicaStartPromise && !watch) {
261
+ await replica.stop();
262
+ fs.rmSync(testTempDir, { recursive: true, force: true });
263
+ }
176
264
  return reporter.done();
177
265
  }
178
- function pipeMMF(proc, mmf) {
179
- return new Promise((resolve) => {
180
- // stdout
181
- proc.stdout.on('data', (data) => {
182
- for (let line of data.toString().split('\n')) {
183
- line = line.trim();
184
- if (line) {
185
- mmf.parseLine(line);
186
- }
266
+ function pipeStdoutToMMF(stdout, mmf) {
267
+ stdout.on('data', (data) => {
268
+ for (let line of data.toString().split('\n')) {
269
+ line = line.trim();
270
+ if (line) {
271
+ mmf.parseLine(line);
187
272
  }
188
- });
189
- // stderr
190
- proc.stderr.on('data', (data) => {
191
- let text = data.toString().trim();
192
- let failedLine = '';
193
- text = text.replace(/([\w+._/-]+):(\d+).(\d+)(-\d+.\d+)/g, (_m0, m1, m2, m3) => {
194
- // change absolute file path to relative
195
- // change :line:col-line:col to :line:col to work in vscode
196
- let res = `${absToRel(m1)}:${m2}:${m3}`;
197
- if (!fs.existsSync(m1)) {
198
- return res;
199
- }
200
- // show failed line
201
- let content = fs.readFileSync(m1);
202
- let lines = content.toString().split('\n') || [];
203
- failedLine += chalk.dim('\n ...');
204
- let lineBefore = lines[+m2 - 2];
205
- if (lineBefore) {
206
- failedLine += chalk.dim(`\n ${+m2 - 1}\t| ${lineBefore.replaceAll('\t', ' ')}`);
207
- }
208
- failedLine += `\n${chalk.redBright `->`} ${m2}\t| ${lines[+m2 - 1]?.replaceAll('\t', ' ')}`;
209
- if (lines.length > +m2) {
210
- failedLine += chalk.dim(`\n ${+m2 + 1}\t| ${lines[+m2]?.replaceAll('\t', ' ')}`);
211
- }
212
- failedLine += chalk.dim('\n ...');
273
+ }
274
+ });
275
+ }
276
+ function pipeStderrToMMF(stderr, mmf, dir = '') {
277
+ stderr.on('data', (data) => {
278
+ let text = data.toString().trim();
279
+ let failedLine = '';
280
+ text = text.replace(/([\w+._/-]+):(\d+).(\d+)(-\d+.\d+)/g, (_m0, m1, m2, m3) => {
281
+ // change absolute file path to relative
282
+ // change :line:col-line:col to :line:col to work in vscode
283
+ let res = `${absToRel(m1)}:${m2}:${m3}`;
284
+ let file = path.join(dir, m1);
285
+ if (!fs.existsSync(file)) {
213
286
  return res;
214
- });
215
- if (failedLine) {
216
- text += failedLine;
217
287
  }
218
- mmf.fail(text);
288
+ // show failed line
289
+ let content = fs.readFileSync(file);
290
+ let lines = content.toString().split('\n') || [];
291
+ failedLine += chalk.dim('\n ...');
292
+ let lineBefore = lines[+m2 - 2];
293
+ if (lineBefore) {
294
+ failedLine += chalk.dim(`\n ${+m2 - 1}\t| ${lineBefore.replaceAll('\t', ' ')}`);
295
+ }
296
+ failedLine += `\n${chalk.redBright `->`} ${m2}\t| ${lines[+m2 - 1]?.replaceAll('\t', ' ')}`;
297
+ if (lines.length > +m2) {
298
+ failedLine += chalk.dim(`\n ${+m2 + 1}\t| ${lines[+m2]?.replaceAll('\t', ' ')}`);
299
+ }
300
+ failedLine += chalk.dim('\n ...');
301
+ return res;
219
302
  });
303
+ if (failedLine) {
304
+ text += failedLine;
305
+ }
306
+ mmf.fail(text);
307
+ });
308
+ }
309
+ function pipeMMF(proc, mmf) {
310
+ return new Promise((resolve) => {
311
+ pipeStdoutToMMF(proc.stdout, mmf);
312
+ pipeStderrToMMF(proc.stderr, mmf);
220
313
  // exit
221
314
  proc.on('close', (code) => {
222
315
  if (code === 0) {
223
- mmf.pass();
316
+ mmf.strategy !== 'print' && mmf.pass();
224
317
  }
225
318
  else if (code !== 1) {
226
319
  mmf.fail(`unknown exit code: ${code}`);
@@ -1,2 +1,8 @@
1
1
  export declare function getUserProp(prop: string): Promise<void>;
2
2
  export declare function setUserProp(prop: string, value: string): Promise<void>;
3
+ export declare function getPrincipal(): Promise<void>;
4
+ type ImportIdentityOptions = {
5
+ encrypt: boolean;
6
+ };
7
+ export declare function importPem(data: string, options?: ImportIdentityOptions): Promise<void>;
8
+ export {};
@@ -1,7 +1,13 @@
1
1
  import process from 'node:process';
2
2
  import chalk from 'chalk';
3
- import { getIdentity } from '../mops.js';
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+ import { Buffer } from 'node:buffer';
6
+ import prompts from 'prompts';
7
+ import { deleteSync } from 'del';
4
8
  import { mainActor } from '../api/actors.js';
9
+ import { getIdentity, globalConfigDir } from '../mops.js';
10
+ import { encrypt } from '../pem.js';
5
11
  export async function getUserProp(prop) {
6
12
  let actor = await mainActor();
7
13
  let identity = await getIdentity();
@@ -24,3 +30,55 @@ export async function setUserProp(prop, value) {
24
30
  console.log(chalk.red('Error: ') + res.err);
25
31
  }
26
32
  }
33
+ export async function getPrincipal() {
34
+ let identity = await getIdentity();
35
+ if (identity) {
36
+ console.log(identity.getPrincipal().toText());
37
+ }
38
+ else {
39
+ console.log(chalk.red('Error: ') + 'identity not found. Run ' + chalk.greenBright('mops user import') + ' command.');
40
+ }
41
+ }
42
+ export async function importPem(data, options = { encrypt: true }) {
43
+ try {
44
+ if (!fs.existsSync(globalConfigDir)) {
45
+ fs.mkdirSync(globalConfigDir);
46
+ }
47
+ let password = '';
48
+ if (options.encrypt) {
49
+ let res = await prompts({
50
+ type: 'invisible',
51
+ name: 'password',
52
+ message: 'Enter password to encrypt identity.pem',
53
+ });
54
+ password = res.password;
55
+ if (!password) {
56
+ let res = await prompts({
57
+ type: 'confirm',
58
+ name: 'ok',
59
+ message: 'Are you sure you don\'t want to protect your identity.pem with a password?',
60
+ });
61
+ if (!res.ok) {
62
+ console.log('aborted');
63
+ return;
64
+ }
65
+ }
66
+ }
67
+ let identityPem = path.resolve(globalConfigDir, 'identity.pem');
68
+ let identityPemEncrypted = path.resolve(globalConfigDir, 'identity.pem.encrypted');
69
+ deleteSync([identityPem, identityPemEncrypted], { force: true });
70
+ // encrypted
71
+ if (password) {
72
+ let encrypted = await encrypt(Buffer.from(data), password);
73
+ fs.writeFileSync(identityPemEncrypted, encrypted);
74
+ }
75
+ // unencrypted
76
+ else {
77
+ fs.writeFileSync(identityPem, data);
78
+ }
79
+ console.log(chalk.green('Success'));
80
+ }
81
+ catch (err) {
82
+ console.log(chalk.red('Error: ') + err);
83
+ }
84
+ }
@@ -1,4 +1,4 @@
1
- type _anon_class_10_1 =
1
+ type _anon_class_13_1 =
2
2
  service {
3
3
  getSchema: () -> (BenchSchema) query;
4
4
  getStats: () -> (BenchResult) query;
@@ -19,8 +19,12 @@ type BenchResult =
19
19
  instructions: int;
20
20
  rts_collector_instructions: int;
21
21
  rts_heap_size: int;
22
+ rts_logical_stable_memory_size: int;
22
23
  rts_memory_size: int;
23
24
  rts_mutator_instructions: int;
25
+ rts_reclaimed: int;
26
+ rts_stable_memory_size: int;
24
27
  rts_total_allocation: int;
28
+ stable_memory_size: int;
25
29
  };
26
- service : () -> _anon_class_10_1
30
+ service : () -> _anon_class_13_1
@@ -3,12 +3,16 @@ import type { ActorMethod } from '@dfinity/agent';
3
3
  import type { IDL } from '@dfinity/candid';
4
4
 
5
5
  export interface BenchResult {
6
+ 'rts_stable_memory_size' : bigint,
7
+ 'stable_memory_size' : bigint,
6
8
  'instructions' : bigint,
7
9
  'rts_memory_size' : bigint,
8
10
  'rts_total_allocation' : bigint,
9
11
  'rts_collector_instructions' : bigint,
10
12
  'rts_mutator_instructions' : bigint,
13
+ 'rts_logical_stable_memory_size' : bigint,
11
14
  'rts_heap_size' : bigint,
15
+ 'rts_reclaimed' : bigint,
12
16
  }
13
17
  export interface BenchSchema {
14
18
  'cols' : Array<string>,
@@ -16,7 +20,7 @@ export interface BenchSchema {
16
20
  'rows' : Array<string>,
17
21
  'description' : string,
18
22
  }
19
- export interface _anon_class_10_1 {
23
+ export interface _anon_class_13_1 {
20
24
  'getSchema' : ActorMethod<[], BenchSchema>,
21
25
  'getStats' : ActorMethod<[], BenchResult>,
22
26
  'init' : ActorMethod<[], BenchSchema>,
@@ -24,6 +28,6 @@ export interface _anon_class_10_1 {
24
28
  'runCellUpdate' : ActorMethod<[bigint, bigint], BenchResult>,
25
29
  'runCellUpdateAwait' : ActorMethod<[bigint, bigint], BenchResult>,
26
30
  }
27
- export interface _SERVICE extends _anon_class_10_1 {}
31
+ export interface _SERVICE extends _anon_class_13_1 {}
28
32
  export declare const idlFactory: IDL.InterfaceFactory;
29
33
  export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];
@@ -6,14 +6,18 @@ export const idlFactory = ({ IDL }) => {
6
6
  'description' : IDL.Text,
7
7
  });
8
8
  const BenchResult = IDL.Record({
9
+ 'rts_stable_memory_size' : IDL.Int,
10
+ 'stable_memory_size' : IDL.Int,
9
11
  'instructions' : IDL.Int,
10
12
  'rts_memory_size' : IDL.Int,
11
13
  'rts_total_allocation' : IDL.Int,
12
14
  'rts_collector_instructions' : IDL.Int,
13
15
  'rts_mutator_instructions' : IDL.Int,
16
+ 'rts_logical_stable_memory_size' : IDL.Int,
14
17
  'rts_heap_size' : IDL.Int,
18
+ 'rts_reclaimed' : IDL.Int,
15
19
  });
16
- const _anon_class_10_1 = IDL.Service({
20
+ const _anon_class_13_1 = IDL.Service({
17
21
  'getSchema' : IDL.Func([], [BenchSchema], ['query']),
18
22
  'getStats' : IDL.Func([], [BenchResult], ['query']),
19
23
  'init' : IDL.Func([], [BenchSchema], []),
@@ -21,6 +25,6 @@ export const idlFactory = ({ IDL }) => {
21
25
  'runCellUpdate' : IDL.Func([IDL.Nat, IDL.Nat], [BenchResult], []),
22
26
  'runCellUpdateAwait' : IDL.Func([IDL.Nat, IDL.Nat], [BenchResult], []),
23
27
  });
24
- return _anon_class_10_1;
28
+ return _anon_class_13_1;
25
29
  };
26
30
  export const init = ({ IDL }) => { return []; };
package/dist/mops.d.ts CHANGED
@@ -11,7 +11,7 @@ export declare function setNetwork(network: string): void;
11
11
  export declare let getIdentity: () => Promise<Identity | undefined>;
12
12
  export declare function getClosestConfigFile(dir?: string): string;
13
13
  export declare function getRootDir(): string;
14
- export declare function checkConfigFile(): boolean;
14
+ export declare function checkConfigFile(exit?: boolean): boolean;
15
15
  export declare function progressBar(step: number, total: number): string;
16
16
  export declare function parseGithubURL(href: string): {
17
17
  org: string;
package/dist/mops.js CHANGED
@@ -4,7 +4,6 @@ import fs from 'node:fs';
4
4
  import TOML from '@iarna/toml';
5
5
  import chalk from 'chalk';
6
6
  import prompts from 'prompts';
7
- import ncp from 'ncp';
8
7
  import fetch from 'node-fetch';
9
8
  import { decodeFile } from './pem.js';
10
9
  import { mainActor, storageActor } from './api/actors.js';
@@ -38,32 +37,6 @@ if (process.env.XDG_CONFIG_HOME) {
38
37
  if (process.env.XDG_CACHE_HOME) {
39
38
  globalCacheDir = path.join(process.env.XDG_CACHE_HOME, 'mops');
40
39
  }
41
- // temp: move old config to new location
42
- let oldGlobalConfigDir = path.resolve(process.env.HOME || process.env.APPDATA || '/', 'mops');
43
- if (fs.existsSync(oldGlobalConfigDir) && !fs.existsSync(globalConfigDir)) {
44
- fs.mkdirSync(globalConfigDir, { recursive: true });
45
- if (fs.existsSync(path.join(oldGlobalConfigDir, 'identity.pem'))) {
46
- fs.copyFileSync(path.join(oldGlobalConfigDir, 'identity.pem'), path.join(globalConfigDir, 'identity.pem'));
47
- }
48
- if (fs.existsSync(path.join(oldGlobalConfigDir, 'identity.pem.encrypted'))) {
49
- fs.copyFileSync(path.join(oldGlobalConfigDir, 'identity.pem.encrypted'), path.join(globalConfigDir, 'identity.pem.encrypted'));
50
- }
51
- console.log('Moved config to ' + chalk.green(globalConfigDir));
52
- }
53
- // temp: move old cache to new location
54
- if (fs.existsSync(oldGlobalConfigDir) && !fs.existsSync(globalCacheDir)) {
55
- fs.mkdirSync(globalCacheDir, { recursive: true });
56
- ncp.ncp(path.join(oldGlobalConfigDir, 'packages'), path.join(globalCacheDir, 'packages'), {
57
- stopOnErr: true,
58
- clobber: false,
59
- }, (err) => {
60
- if (err) {
61
- console.log('Error moving config: ', err);
62
- fs.rmSync(globalCacheDir, { recursive: true, force: true });
63
- }
64
- });
65
- console.log('Moved cache to ' + chalk.green(globalCacheDir));
66
- }
67
40
  export function getNetworkFile() {
68
41
  let networkFile = '';
69
42
  try {
@@ -110,10 +83,13 @@ export function getRootDir() {
110
83
  }
111
84
  return path.dirname(configFile);
112
85
  }
113
- export function checkConfigFile() {
86
+ export function checkConfigFile(exit = false) {
114
87
  let configFile = getClosestConfigFile();
115
88
  if (!configFile) {
116
89
  console.log(chalk.red('Error: ') + `Config file 'mops.toml' not found. Please run ${chalk.green('mops init')} first`);
90
+ if (exit) {
91
+ process.exit(1);
92
+ }
117
93
  return false;
118
94
  }
119
95
  return true;
@@ -211,7 +187,7 @@ export function formatDir(name, version) {
211
187
  }
212
188
  export function formatGithubDir(name, repo) {
213
189
  const { branch, commitHash } = parseGithubURL(repo);
214
- return path.join(getRootDir(), '.mops/_github', `${name}#${branch}` + (commitHash ? `@${commitHash}` : ''));
190
+ return path.join(getRootDir(), '.mops/_github', `${name}#${branch.replaceAll('/', '___')}` + (commitHash ? `@${commitHash}` : ''));
215
191
  }
216
192
  export function readDfxJson() {
217
193
  let dir = process.cwd();
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ic-mops",
3
- "version": "0.45.4-pre.0",
3
+ "version": "1.0.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mops": "bin/mops.js",
@@ -10,6 +10,10 @@
10
10
  "files": [
11
11
  "*",
12
12
  "!network.txt",
13
+ "!Dockerfile",
14
+ "!verify.sh",
15
+ "!build.sh",
16
+ "!DEVELOPMENT.md",
13
17
  "!.mops",
14
18
  "/templates"
15
19
  ],
@@ -24,13 +28,13 @@
24
28
  "node": ">=18.0.0"
25
29
  },
26
30
  "dependencies": {
27
- "@dfinity/agent": "2.0.0",
28
- "@dfinity/candid": "2.0.0",
29
- "@dfinity/identity": "2.0.0",
30
- "@dfinity/identity-secp256k1": "2.0.0",
31
- "@dfinity/principal": "2.0.0",
31
+ "@dfinity/agent": "2.1.0",
32
+ "@dfinity/candid": "2.1.0",
33
+ "@dfinity/identity": "2.1.0",
34
+ "@dfinity/identity-secp256k1": "2.1.0",
35
+ "@dfinity/principal": "2.1.0",
32
36
  "@iarna/toml": "2.2.5",
33
- "@noble/hashes": "1.4.0",
37
+ "@noble/hashes": "1.5.0",
34
38
  "as-table": "1.0.55",
35
39
  "buffer": "6.0.3",
36
40
  "cacheable-request": "12.0.1",
@@ -38,12 +42,13 @@
38
42
  "chalk": "5.3.0",
39
43
  "chokidar": "3.6.0",
40
44
  "commander": "12.1.0",
41
- "debounce": "2.1.0",
45
+ "debounce": "2.1.1",
42
46
  "decomp-tarxz": "0.1.1",
43
47
  "decompress": "4.2.1",
44
48
  "del": "7.1.0",
45
49
  "dhall-to-json-cli": "1.7.6",
46
- "execa": "9.3.0",
50
+ "execa": "9.3.1",
51
+ "filesize": "10.1.6",
47
52
  "fs-extra": "11.2.0",
48
53
  "get-folder-size": "5.0.0",
49
54
  "glob": "11.0.0",
@@ -58,7 +63,7 @@
58
63
  "node-fetch": "3.3.2",
59
64
  "octokit": "3.1.2",
60
65
  "pem-file": "1.0.1",
61
- "pic-ic": "0.3.3",
66
+ "pic-ic": "0.5.3",
62
67
  "prompts": "2.4.2",
63
68
  "semver": "7.6.3",
64
69
  "stream-to-promise": "3.0.0",
@@ -72,21 +77,15 @@
72
77
  "@types/fs-extra": "11.0.4",
73
78
  "@types/glob": "8.1.0",
74
79
  "@types/ncp": "2.0.8",
75
- "@types/node": "22.0.2",
80
+ "@types/node": "22.5.4",
76
81
  "@types/prompts": "2.4.9",
77
82
  "@types/semver": "7.5.8",
78
83
  "@types/stream-to-promise": "2.2.4",
79
84
  "@types/tar": "6.1.13",
85
+ "bun": "1.1.27",
86
+ "esbuild": "0.23.1",
80
87
  "eslint": "8.57.0",
81
- "bun": "1.0.35",
82
- "esbuild": "0.23.0",
83
- "tsx": "4.16.5",
84
- "typescript": "5.5.4"
85
- },
86
- "overrides": {
87
- "@dfinity/agent": "2.0.0",
88
- "@dfinity/identity": "2.0.0",
89
- "@dfinity/principal": "2.0.0",
90
- "@dfinity/candid": "2.0.0"
88
+ "tsx": "4.19.1",
89
+ "typescript": "5.6.2"
91
90
  }
92
91
  }