ic-mops 1.11.0 → 1.12.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 (79) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/api/actors.ts +2 -2
  3. package/api/downloadPackageFiles.ts +1 -1
  4. package/bun.lock +234 -198
  5. package/bundle/bench/bench-canister.mo +101 -109
  6. package/bundle/bench/user-bench.mo +6 -10
  7. package/bundle/cli.js +960 -889
  8. package/bundle/cli.tgz +0 -0
  9. package/bundle/declarations/bench/bench.did +3 -3
  10. package/bundle/declarations/bench/bench.did.d.ts +3 -3
  11. package/bundle/declarations/bench/index.d.ts +3 -3
  12. package/bundle/declarations/bench/index.js +1 -1
  13. package/bundle/declarations/main/index.d.ts +3 -3
  14. package/bundle/declarations/main/index.js +1 -1
  15. package/bundle/declarations/main/main.did +78 -121
  16. package/bundle/declarations/main/main.did.d.ts +48 -98
  17. package/bundle/declarations/main/main.did.js +53 -107
  18. package/bundle/declarations/storage/index.d.ts +3 -3
  19. package/bundle/declarations/storage/index.js +4 -4
  20. package/bundle/declarations/storage/storage.did.d.ts +3 -3
  21. package/bundle/package.json +1 -1
  22. package/bundle/templates/src/lib.mo +13 -13
  23. package/bundle/templates/test/lib.test.mo +2 -2
  24. package/commands/add.ts +1 -1
  25. package/commands/available-updates.ts +20 -7
  26. package/commands/bench-replica.ts +21 -9
  27. package/commands/maintainer.ts +1 -1
  28. package/commands/outdated.ts +8 -1
  29. package/commands/owner.ts +1 -1
  30. package/commands/replica.ts +31 -18
  31. package/commands/test/test.ts +37 -97
  32. package/commands/test/utils.ts +75 -1
  33. package/commands/update.ts +19 -2
  34. package/declarations/bench/bench.did.d.ts +3 -3
  35. package/declarations/bench/index.d.ts +3 -3
  36. package/declarations/bench/index.js +1 -1
  37. package/declarations/main/index.d.ts +3 -3
  38. package/declarations/main/index.js +1 -1
  39. package/declarations/main/main.did.d.ts +3 -3
  40. package/declarations/storage/index.d.ts +3 -3
  41. package/declarations/storage/index.js +4 -4
  42. package/declarations/storage/storage.did.d.ts +3 -3
  43. package/dist/api/actors.d.ts +2 -2
  44. package/dist/api/actors.js +1 -1
  45. package/dist/api/downloadPackageFiles.d.ts +1 -1
  46. package/dist/api/downloadPackageFiles.js +1 -1
  47. package/dist/commands/add.js +1 -1
  48. package/dist/commands/available-updates.js +19 -7
  49. package/dist/commands/bench-replica.d.ts +3 -2
  50. package/dist/commands/bench-replica.js +17 -6
  51. package/dist/commands/maintainer.js +1 -1
  52. package/dist/commands/outdated.js +7 -1
  53. package/dist/commands/owner.js +1 -1
  54. package/dist/commands/replica.d.ts +4 -3
  55. package/dist/commands/replica.js +25 -13
  56. package/dist/commands/test/test.js +29 -81
  57. package/dist/commands/test/utils.d.ts +6 -0
  58. package/dist/commands/test/utils.js +61 -0
  59. package/dist/commands/update.js +16 -2
  60. package/dist/declarations/bench/bench.did.d.ts +3 -3
  61. package/dist/declarations/bench/index.d.ts +3 -3
  62. package/dist/declarations/bench/index.js +1 -1
  63. package/dist/declarations/main/index.d.ts +3 -3
  64. package/dist/declarations/main/index.js +1 -1
  65. package/dist/declarations/main/main.did.d.ts +3 -3
  66. package/dist/declarations/storage/index.d.ts +3 -3
  67. package/dist/declarations/storage/index.js +4 -4
  68. package/dist/declarations/storage/storage.did.d.ts +3 -3
  69. package/dist/helpers/get-dep-name.d.ts +1 -0
  70. package/dist/helpers/get-dep-name.js +3 -0
  71. package/dist/mops.d.ts +1 -1
  72. package/dist/package.json +5 -15
  73. package/dist/pem.d.ts +2 -2
  74. package/dist/pem.js +2 -2
  75. package/helpers/get-dep-name.ts +4 -0
  76. package/mops.ts +1 -1
  77. package/package.json +5 -15
  78. package/pem.ts +2 -2
  79. package/tsconfig.json +2 -2
@@ -4,6 +4,7 @@ import path from 'node:path';
4
4
  import fs from 'node:fs';
5
5
  import { execaCommand } from 'execa';
6
6
  import { PocketIc, PocketIcServer } from 'pic-ic';
7
+ import { PocketIc as PocketIcMops, PocketIcServer as PocketIcServerMops } from 'pic-js-mops';
7
8
  import { getRootDir, readConfig } from '../mops.js';
8
9
  import { createActor, idlFactory } from '../declarations/bench/index.js';
9
10
  import { toolchain } from './toolchain/index.js';
@@ -31,14 +32,24 @@ export class BenchReplica {
31
32
  else {
32
33
  let pocketIcBin = await toolchain.bin('pocket-ic');
33
34
  let config = readConfig();
34
- if (config.toolchain?.['pocket-ic'] !== '4.0.0') {
35
- console.error('Current Mops CLI only supports pocket-ic 4.0.0');
35
+ if (config.toolchain?.['pocket-ic'] !== '4.0.0' && !config.toolchain?.['pocket-ic']?.startsWith('9.')) {
36
+ console.error('Current Mops CLI only supports pocket-ic 9.x.x and 4.0.0');
36
37
  process.exit(1);
37
38
  }
38
- this.pocketIcServer = await PocketIcServer.start({
39
- binPath: pocketIcBin,
40
- });
41
- this.pocketIc = await PocketIc.create(this.pocketIcServer.getUrl());
39
+ // pocket-ic 9.x.x
40
+ if (config.toolchain?.['pocket-ic']?.startsWith('9.')) {
41
+ this.pocketIcServer = await PocketIcServerMops.start({
42
+ binPath: pocketIcBin,
43
+ });
44
+ this.pocketIc = await PocketIcMops.create(this.pocketIcServer.getUrl());
45
+ }
46
+ // pocket-ic 4.0.0
47
+ else {
48
+ this.pocketIcServer = await PocketIcServer.start({
49
+ binPath: pocketIcBin,
50
+ });
51
+ this.pocketIc = await PocketIc.create(this.pocketIcServer.getUrl());
52
+ }
42
53
  }
43
54
  }
44
55
  async stop() {
@@ -2,7 +2,7 @@ import process from 'node:process';
2
2
  import chalk from 'chalk';
3
3
  import { checkConfigFile, getIdentity, readConfig } from '../mops.js';
4
4
  import { mainActor } from '../api/actors.js';
5
- import { Principal } from '@dfinity/principal';
5
+ import { Principal } from '@icp-sdk/core/principal';
6
6
  import prompts from 'prompts';
7
7
  export async function printMaintainers() {
8
8
  if (!checkConfigFile()) {
@@ -1,6 +1,7 @@
1
1
  import chalk from 'chalk';
2
2
  import { checkConfigFile, readConfig } from '../mops.js';
3
3
  import { getAvailableUpdates } from './available-updates.js';
4
+ import { getDepName, getDepPinnedVersion } from '../helpers/get-dep-name.js';
4
5
  export async function outdated() {
5
6
  if (!checkConfigFile()) {
6
7
  return;
@@ -12,8 +13,13 @@ export async function outdated() {
12
13
  }
13
14
  else {
14
15
  console.log('Available updates:');
16
+ let allDeps = [...Object.keys(config.dependencies || {}), ...Object.keys(config['dev-dependencies'] || {})];
15
17
  for (let dep of available) {
16
- console.log(`${dep[0]} ${chalk.yellow(dep[1])} -> ${chalk.green(dep[2])}`);
18
+ let name = allDeps.find((d) => {
19
+ let pinnedVersion = getDepPinnedVersion(d);
20
+ return getDepName(d) === dep[0] && (!pinnedVersion || dep[1].startsWith(pinnedVersion));
21
+ }) || dep[0];
22
+ console.log(`${name} ${chalk.yellow(dep[1])} -> ${chalk.green(dep[2])}`);
17
23
  }
18
24
  }
19
25
  }
@@ -2,7 +2,7 @@ import process from 'node:process';
2
2
  import chalk from 'chalk';
3
3
  import { checkConfigFile, getIdentity, readConfig } from '../mops.js';
4
4
  import { mainActor } from '../api/actors.js';
5
- import { Principal } from '@dfinity/principal';
5
+ import { Principal } from '@icp-sdk/core/principal';
6
6
  import prompts from 'prompts';
7
7
  export async function printOwners() {
8
8
  if (!checkConfigFile()) {
@@ -1,7 +1,8 @@
1
1
  import { ChildProcessWithoutNullStreams } from 'node:child_process';
2
2
  import { PassThrough } from 'node:stream';
3
- import { IDL } from '@dfinity/candid';
3
+ import { IDL } from '@icp-sdk/core/candid';
4
4
  import { PocketIc, PocketIcServer } from 'pic-ic';
5
+ import { PocketIc as PocketIcMops, PocketIcServer as PocketIcServerMops } from 'pic-js-mops';
5
6
  type StartOptions = {
6
7
  type?: 'dfx' | 'pocket-ic' | 'dfx-pocket-ic';
7
8
  dir?: string;
@@ -17,8 +18,8 @@ export declare class Replica {
17
18
  actor: any;
18
19
  stream: PassThrough;
19
20
  }>;
20
- pocketIcServer?: PocketIcServer;
21
- pocketIc?: PocketIc;
21
+ pocketIcServer?: PocketIcServer | PocketIcServerMops;
22
+ pocketIc?: PocketIc | PocketIcMops;
22
23
  dfxProcess?: ChildProcessWithoutNullStreams;
23
24
  dir: string;
24
25
  ttl: number;
@@ -4,8 +4,9 @@ import path from 'node:path';
4
4
  import fs from 'node:fs';
5
5
  import { PassThrough } from 'node:stream';
6
6
  import { spawn as spawnAsync } from 'promisify-child-process';
7
- import { Actor, HttpAgent } from '@dfinity/agent';
7
+ import { Actor, HttpAgent } from '@icp-sdk/core/agent';
8
8
  import { PocketIc, PocketIcServer } from 'pic-ic';
9
+ import { PocketIc as PocketIcMops, PocketIcServer as PocketIcServerMops } from 'pic-js-mops';
9
10
  import chalk from 'chalk';
10
11
  import { readConfig } from '../mops.js';
11
12
  import { toolchain } from './toolchain/index.js';
@@ -64,19 +65,31 @@ export class Replica {
64
65
  }
65
66
  else {
66
67
  let pocketIcBin = await toolchain.bin('pocket-ic');
67
- // eslint-disable-next-line
68
68
  let config = readConfig();
69
- if (config.toolchain?.['pocket-ic'] !== '4.0.0') {
70
- console.error('Current Mops CLI only supports pocket-ic 4.0.0');
69
+ if (config.toolchain?.['pocket-ic'] !== '4.0.0' && !config.toolchain?.['pocket-ic']?.startsWith('9.')) {
70
+ console.error('Current Mops CLI only supports pocket-ic 9.x.x and 4.0.0');
71
71
  process.exit(1);
72
72
  }
73
- this.pocketIcServer = await PocketIcServer.start({
74
- showRuntimeLogs: false,
75
- showCanisterLogs: false,
76
- binPath: pocketIcBin,
77
- ttl: this.ttl,
78
- });
79
- this.pocketIc = await PocketIc.create(this.pocketIcServer.getUrl());
73
+ // pocket-ic 9.x.x
74
+ if (config.toolchain?.['pocket-ic']?.startsWith('9.')) {
75
+ this.pocketIcServer = await PocketIcServerMops.start({
76
+ showRuntimeLogs: false,
77
+ showCanisterLogs: false,
78
+ binPath: pocketIcBin,
79
+ ttl: this.ttl,
80
+ });
81
+ this.pocketIc = await PocketIcMops.create(this.pocketIcServer.getUrl());
82
+ }
83
+ // pocket-ic 4.0.0
84
+ else {
85
+ this.pocketIcServer = await PocketIcServer.start({
86
+ showRuntimeLogs: false,
87
+ showCanisterLogs: false,
88
+ binPath: pocketIcBin,
89
+ ttl: this.ttl,
90
+ });
91
+ this.pocketIc = await PocketIc.create(this.pocketIcServer.getUrl());
92
+ }
80
93
  // process canister logs
81
94
  this._attachCanisterLogHandler(this.pocketIcServer.serverProcess);
82
95
  }
@@ -182,10 +195,9 @@ export class Replica {
182
195
  };
183
196
  }
184
197
  else if (this.pocketIc) {
185
- // let {canisterId, actor} = await this.pocketIc.setupCanister(idlFactory, wasm);
186
198
  let { canisterId, actor } = await this.pocketIc.setupCanister({
187
- idlFactory,
188
199
  wasm,
200
+ idlFactory,
189
201
  });
190
202
  if (signal?.aborted) {
191
203
  return;
@@ -3,6 +3,7 @@ import { spawn } from 'node:child_process';
3
3
  import path from 'node:path';
4
4
  import fs from 'node:fs';
5
5
  import os from 'node:os';
6
+ import { PassThrough } from 'node:stream';
6
7
  import chalk from 'chalk';
7
8
  import { globSync } from 'glob';
8
9
  import chokidar from 'chokidar';
@@ -12,14 +13,13 @@ import { sources } from '../sources.js';
12
13
  import { getRootDir, readConfig } from '../../mops.js';
13
14
  import { parallel } from '../../parallel.js';
14
15
  import { MMF1 } from './mmf1.js';
15
- import { absToRel } from './utils.js';
16
+ import { absToRel, pipeMMF, pipeStderrToMMF, pipeStdoutToMMF } from './utils.js';
16
17
  import { VerboseReporter } from './reporters/verbose-reporter.js';
17
18
  import { FilesReporter } from './reporters/files-reporter.js';
18
19
  import { CompactReporter } from './reporters/compact-reporter.js';
19
20
  import { SilentReporter } from './reporters/silent-reporter.js';
20
21
  import { toolchain } from '../toolchain/index.js';
21
22
  import { Replica } from '../replica.js';
22
- import { PassThrough } from 'node:stream';
23
23
  import { getDfxVersion } from '../../helpers/get-dfx-version.js';
24
24
  let ignore = [
25
25
  '**/node_modules/**',
@@ -171,12 +171,7 @@ export async function testWithReporter(reporterName, filter = '', defaultMode =
171
171
  replica.dir = testTempDir;
172
172
  fs.rmSync(testTempDir, { recursive: true, force: true });
173
173
  fs.mkdirSync(testTempDir, { recursive: true });
174
- await parallel(os.cpus().length, files, async (file) => {
175
- if (signal?.aborted) {
176
- return;
177
- }
178
- let mmf = new MMF1('store', absToRel(file));
179
- // mode overrides
174
+ let filesWithMode = files.map((file) => {
180
175
  let lines = fs.readFileSync(file, 'utf8').split('\n');
181
176
  let mode = defaultMode;
182
177
  if (lines.includes('// @testmode wasi')) {
@@ -185,18 +180,29 @@ export async function testWithReporter(reporterName, filter = '', defaultMode =
185
180
  else if (lines.includes('// @testmode replica') || lines.find(line => line.match(/^(persistent )?actor( class)?/))) {
186
181
  mode = 'replica';
187
182
  }
188
- if (mode === 'wasi' && !wasmtimePath) {
189
- // ensure wasmtime is installed or specified in config
190
- if (config.toolchain?.wasmtime) {
191
- wasmtimePath = await toolchain.bin('wasmtime');
192
- }
193
- // fallback wasmtime to global binary if not specified in config (legacy)
194
- else {
195
- wasmtimePath = 'wasmtime';
196
- console.log(chalk.yellow('Warning:'), 'Wasmtime is not specified in config. Using global binary "wasmtime". This will be removed in the future.');
197
- console.log(`Run ${chalk.green('mops toolchain use wasmtime')} or add ${chalk.green('wasmtime = "<version>"')} in mops.toml to avoid breaking changes with future versions of mops.`);
198
- }
183
+ return { file, mode };
184
+ });
185
+ let hasWasiTests = filesWithMode.some(({ mode }) => mode === 'wasi');
186
+ let hasReplicaTests = filesWithMode.some(({ mode }) => mode === 'replica');
187
+ // prepare wasmtime path
188
+ if (hasWasiTests && !wasmtimePath) {
189
+ // ensure wasmtime is installed or specified in config
190
+ if (config.toolchain?.wasmtime) {
191
+ wasmtimePath = await toolchain.bin('wasmtime');
192
+ }
193
+ // fallback wasmtime to global binary if not specified in config (legacy)
194
+ else {
195
+ wasmtimePath = 'wasmtime';
196
+ console.log(chalk.yellow('Warning:'), 'Wasmtime is not specified in config. Using global binary "wasmtime". This will be removed in the future.');
197
+ console.log(`Run ${chalk.green('mops toolchain use wasmtime')} or add ${chalk.green('wasmtime = "<version>"')} in mops.toml to avoid breaking changes with future versions of mops.`);
198
+ }
199
+ }
200
+ let runTestFile = async ({ file, mode }) => {
201
+ if (signal?.aborted) {
202
+ return;
199
203
  }
204
+ // print logs immediately for replica tests because we run them one-by-one
205
+ let mmf = new MMF1(mode === 'replica' ? 'print' : 'store', absToRel(file));
200
206
  let promise = new Promise((resolve) => {
201
207
  let mocArgs = ['--hide-warnings', '--error-detail=2', ...sourcesArr.join(' ').split(' '), file].filter(x => x);
202
208
  // interpret
@@ -257,7 +263,6 @@ export async function testWithReporter(reporterName, filter = '', defaultMode =
257
263
  }
258
264
  // build and execute in replica
259
265
  else if (mode === 'replica') {
260
- // mmf.strategy = 'print'; // because we run replica tests one-by-one
261
266
  let wasmFile = `${path.join(testTempDir, path.parse(file).name)}.wasm`;
262
267
  // build
263
268
  let buildProc = spawn(mocPath, [`-o=${wasmFile}`, ...mocArgs], { signal });
@@ -320,8 +325,10 @@ export async function testWithReporter(reporterName, filter = '', defaultMode =
320
325
  }
321
326
  reporter.addRun(file, mmf, promise, mode);
322
327
  await promise;
323
- });
324
- if (replicaStartPromise && !watch) {
328
+ };
329
+ await parallel(os.cpus().length, filesWithMode.filter(({ mode }) => mode !== 'replica'), runTestFile);
330
+ await parallel(1, filesWithMode.filter(({ mode }) => mode === 'replica'), runTestFile);
331
+ if (hasReplicaTests && !watch) {
325
332
  await replica.stop();
326
333
  fs.rmSync(testTempDir, { recursive: true, force: true });
327
334
  }
@@ -330,62 +337,3 @@ export async function testWithReporter(reporterName, filter = '', defaultMode =
330
337
  }
331
338
  return reporter.done();
332
339
  }
333
- function pipeStdoutToMMF(stdout, mmf) {
334
- stdout.on('data', (data) => {
335
- for (let line of data.toString().split('\n')) {
336
- line = line.trim();
337
- if (line) {
338
- mmf.parseLine(line);
339
- }
340
- }
341
- });
342
- }
343
- function pipeStderrToMMF(stderr, mmf, dir = '') {
344
- stderr.on('data', (data) => {
345
- let text = data.toString().trim();
346
- let failedLine = '';
347
- text = text.replace(/([\w+._/-]+):(\d+).(\d+)(-\d+.\d+)/g, (_m0, m1, m2, m3) => {
348
- // change absolute file path to relative
349
- // change :line:col-line:col to :line:col to work in vscode
350
- let res = `${absToRel(m1)}:${m2}:${m3}`;
351
- let file = path.join(dir, m1);
352
- if (!fs.existsSync(file)) {
353
- return res;
354
- }
355
- // show failed line
356
- let content = fs.readFileSync(file);
357
- let lines = content.toString().split('\n') || [];
358
- failedLine += chalk.dim('\n ...');
359
- let lineBefore = lines[+m2 - 2];
360
- if (lineBefore) {
361
- failedLine += chalk.dim(`\n ${+m2 - 1}\t| ${lineBefore.replaceAll('\t', ' ')}`);
362
- }
363
- failedLine += `\n${chalk.redBright `->`} ${m2}\t| ${lines[+m2 - 1]?.replaceAll('\t', ' ')}`;
364
- if (lines.length > +m2) {
365
- failedLine += chalk.dim(`\n ${+m2 + 1}\t| ${lines[+m2]?.replaceAll('\t', ' ')}`);
366
- }
367
- failedLine += chalk.dim('\n ...');
368
- return res;
369
- });
370
- if (failedLine) {
371
- text += failedLine;
372
- }
373
- mmf.fail(text);
374
- });
375
- }
376
- function pipeMMF(proc, mmf) {
377
- return new Promise((resolve) => {
378
- pipeStdoutToMMF(proc.stdout, mmf);
379
- pipeStderrToMMF(proc.stderr, mmf);
380
- // exit
381
- proc.on('close', (code) => {
382
- if (code === 0) {
383
- mmf.strategy !== 'print' && mmf.pass();
384
- }
385
- else if (code !== 1) {
386
- mmf.fail(`unknown exit code: ${code}`);
387
- }
388
- resolve();
389
- });
390
- });
391
- }
@@ -1 +1,7 @@
1
+ import { ChildProcessWithoutNullStreams } from 'node:child_process';
2
+ import { Readable } from 'node:stream';
3
+ import { MMF1 } from './mmf1.js';
1
4
  export declare function absToRel(p: string): string;
5
+ export declare function pipeStdoutToMMF(stdout: Readable, mmf: MMF1): void;
6
+ export declare function pipeStderrToMMF(stderr: Readable, mmf: MMF1, dir?: string): void;
7
+ export declare function pipeMMF(proc: ChildProcessWithoutNullStreams, mmf: MMF1): Promise<void>;
@@ -1,6 +1,67 @@
1
1
  import path from 'node:path';
2
+ import fs from 'node:fs';
3
+ import chalk from 'chalk';
2
4
  import { getRootDir } from '../../mops.js';
3
5
  export function absToRel(p) {
4
6
  let rootDir = getRootDir();
5
7
  return path.relative(rootDir, path.resolve(p));
6
8
  }
9
+ export function pipeStdoutToMMF(stdout, mmf) {
10
+ stdout.on('data', (data) => {
11
+ for (let line of data.toString().split('\n')) {
12
+ line = line.trim();
13
+ if (line) {
14
+ mmf.parseLine(line);
15
+ }
16
+ }
17
+ });
18
+ }
19
+ export function pipeStderrToMMF(stderr, mmf, dir = '') {
20
+ stderr.on('data', (data) => {
21
+ let text = data.toString().trim();
22
+ let failedLine = '';
23
+ text = text.replace(/([\w+._/-]+):(\d+).(\d+)(-\d+.\d+)/g, (_m0, m1, m2, m3) => {
24
+ // change absolute file path to relative
25
+ // change :line:col-line:col to :line:col to work in vscode
26
+ let res = `${absToRel(m1)}:${m2}:${m3}`;
27
+ let file = path.join(dir, m1);
28
+ if (!fs.existsSync(file)) {
29
+ return res;
30
+ }
31
+ // show failed line
32
+ let content = fs.readFileSync(file);
33
+ let lines = content.toString().split('\n') || [];
34
+ failedLine += chalk.dim('\n ...');
35
+ let lineBefore = lines[+m2 - 2];
36
+ if (lineBefore) {
37
+ failedLine += chalk.dim(`\n ${+m2 - 1}\t| ${lineBefore.replaceAll('\t', ' ')}`);
38
+ }
39
+ failedLine += `\n${chalk.redBright `->`} ${m2}\t| ${lines[+m2 - 1]?.replaceAll('\t', ' ')}`;
40
+ if (lines.length > +m2) {
41
+ failedLine += chalk.dim(`\n ${+m2 + 1}\t| ${lines[+m2]?.replaceAll('\t', ' ')}`);
42
+ }
43
+ failedLine += chalk.dim('\n ...');
44
+ return res;
45
+ });
46
+ if (failedLine) {
47
+ text += failedLine;
48
+ }
49
+ mmf.fail(text);
50
+ });
51
+ }
52
+ export function pipeMMF(proc, mmf) {
53
+ return new Promise((resolve) => {
54
+ pipeStdoutToMMF(proc.stdout, mmf);
55
+ pipeStderrToMMF(proc.stderr, mmf);
56
+ // exit
57
+ proc.on('close', (code) => {
58
+ if (code === 0) {
59
+ mmf.strategy !== 'print' && mmf.pass();
60
+ }
61
+ else if (code !== 1) {
62
+ mmf.fail(`unknown exit code: ${code}`);
63
+ }
64
+ resolve();
65
+ });
66
+ });
67
+ }
@@ -3,6 +3,7 @@ import { checkConfigFile, getGithubCommit, parseGithubURL, readConfig } from '..
3
3
  import { add } from './add.js';
4
4
  import { getAvailableUpdates } from './available-updates.js';
5
5
  import { checkIntegrity } from '../integrity.js';
6
+ import { getDepName, getDepPinnedVersion } from '../helpers/get-dep-name.js';
6
7
  export async function update(pkg, { lock } = {}) {
7
8
  if (!checkConfigFile()) {
8
9
  return;
@@ -39,8 +40,21 @@ export async function update(pkg, { lock } = {}) {
39
40
  }
40
41
  else {
41
42
  for (let dep of available) {
42
- let dev = !!config['dev-dependencies']?.[dep[0]];
43
- await add(`${dep[0]}@${dep[2]}`, { dev });
43
+ let devDeps = Object.keys(config['dev-dependencies'] || {});
44
+ let allDeps = [...Object.keys(config.dependencies || {}), ...devDeps];
45
+ let dev = false;
46
+ for (let d of devDeps) {
47
+ let pinnedVersion = getDepPinnedVersion(d);
48
+ if (getDepName(d) === dep[0] && (!pinnedVersion || dep[1].startsWith(pinnedVersion))) {
49
+ dev = true;
50
+ break;
51
+ }
52
+ }
53
+ let asName = allDeps.find((d) => {
54
+ let pinnedVersion = getDepPinnedVersion(d);
55
+ return getDepName(d) === dep[0] && (!pinnedVersion || dep[1].startsWith(pinnedVersion));
56
+ }) || dep[0];
57
+ await add(`${dep[0]}@${dep[2]}`, { dev }, asName);
44
58
  }
45
59
  }
46
60
  await checkIntegrity(lock);
@@ -1,6 +1,6 @@
1
- import type { Principal } from '@dfinity/principal';
2
- import type { ActorMethod } from '@dfinity/agent';
3
- import type { IDL } from '@dfinity/candid';
1
+ import type { Principal } from '@icp-sdk/core/principal';
2
+ import type { ActorMethod } from '@icp-sdk/core/agent';
3
+ import type { IDL } from '@icp-sdk/core/candid';
4
4
 
5
5
  export interface BenchResult {
6
6
  'rts_stable_memory_size' : bigint,
@@ -3,9 +3,9 @@ import type {
3
3
  HttpAgentOptions,
4
4
  ActorConfig,
5
5
  Agent,
6
- } from "@dfinity/agent";
7
- import type { Principal } from "@dfinity/principal";
8
- import type { IDL } from "@dfinity/candid";
6
+ } from "@icp-sdk/core/agent";
7
+ import type { Principal } from "@icp-sdk/core/principal";
8
+ import type { IDL } from "@icp-sdk/core/candid";
9
9
 
10
10
  import { _SERVICE } from './bench.did';
11
11
 
@@ -1,4 +1,4 @@
1
- import { Actor, HttpAgent } from "@dfinity/agent";
1
+ import { Actor, HttpAgent } from "@icp-sdk/core/agent";
2
2
 
3
3
  // Imports and re-exports candid interface
4
4
  import { idlFactory } from "./bench.did.js";
@@ -3,9 +3,9 @@ import type {
3
3
  HttpAgentOptions,
4
4
  ActorConfig,
5
5
  Agent,
6
- } from "@dfinity/agent";
7
- import type { Principal } from "@dfinity/principal";
8
- import type { IDL } from "@dfinity/candid";
6
+ } from "@icp-sdk/core/agent";
7
+ import type { Principal } from "@icp-sdk/core/principal";
8
+ import type { IDL } from "@icp-sdk/core/candid";
9
9
 
10
10
  import { _SERVICE } from './main.did';
11
11
 
@@ -1,4 +1,4 @@
1
- import { Actor, HttpAgent } from "@dfinity/agent";
1
+ import { Actor, HttpAgent } from "@icp-sdk/core/agent";
2
2
 
3
3
  // Imports and re-exports candid interface
4
4
  import { idlFactory } from "./main.did.js";
@@ -1,6 +1,6 @@
1
- import type { Principal } from '@dfinity/principal';
2
- import type { ActorMethod } from '@dfinity/agent';
3
- import type { IDL } from '@dfinity/candid';
1
+ import type { Principal } from '@icp-sdk/core/principal';
2
+ import type { ActorMethod } from '@icp-sdk/core/agent';
3
+ import type { IDL } from '@icp-sdk/core/candid';
4
4
 
5
5
  export interface Benchmark {
6
6
  'gc' : string,
@@ -3,9 +3,9 @@ import type {
3
3
  HttpAgentOptions,
4
4
  ActorConfig,
5
5
  Agent,
6
- } from "@dfinity/agent";
7
- import type { Principal } from "@dfinity/principal";
8
- import type { IDL } from "@dfinity/candid";
6
+ } from "@icp-sdk/core/agent";
7
+ import type { Principal } from "@icp-sdk/core/principal";
8
+ import type { IDL } from "@icp-sdk/core/candid";
9
9
 
10
10
  import { _SERVICE } from './storage.did';
11
11
 
@@ -1,4 +1,4 @@
1
- import { Actor, HttpAgent } from "@dfinity/agent";
1
+ import { Actor, HttpAgent } from "@icp-sdk/core/agent";
2
2
 
3
3
  // Imports and re-exports candid interface
4
4
  import { idlFactory } from './storage.did.js';
@@ -6,9 +6,9 @@ export { idlFactory } from './storage.did.js';
6
6
 
7
7
  /**
8
8
  *
9
- * @param {string | import("@dfinity/principal").Principal} canisterId Canister ID of Agent
10
- * @param {{agentOptions?: import("@dfinity/agent").HttpAgentOptions; actorOptions?: import("@dfinity/agent").ActorConfig}} [options]
11
- * @return {import("@dfinity/agent").ActorSubclass<import("./storage.did.js")._SERVICE>}
9
+ * @param {string | import("@icp-sdk/core/principal").Principal} canisterId Canister ID of Agent
10
+ * @param {{agentOptions?: import("@icp-sdk/core/agent").HttpAgentOptions; actorOptions?: import("@icp-sdk/core/agent").ActorConfig}} [options]
11
+ * @return {import("@icp-sdk/core/agent").ActorSubclass<import("./storage.did.js")._SERVICE>}
12
12
  */
13
13
  export const createActor = (canisterId, options) => {
14
14
  const agent = new HttpAgent({ ...options?.agentOptions });
@@ -1,6 +1,6 @@
1
- import type { Principal } from '@dfinity/principal';
2
- import type { ActorMethod } from '@dfinity/agent';
3
- import type { IDL } from '@dfinity/candid';
1
+ import type { Principal } from '@icp-sdk/core/principal';
2
+ import type { ActorMethod } from '@icp-sdk/core/agent';
3
+ import type { IDL } from '@icp-sdk/core/candid';
4
4
 
5
5
  export type Chunk = Array<number>;
6
6
  export type Err = string;
@@ -1 +1,2 @@
1
1
  export declare function getDepName(name: string): string;
2
+ export declare function getDepPinnedVersion(name: string): string;
@@ -1,3 +1,6 @@
1
1
  export function getDepName(name) {
2
2
  return name.split('@')[0] || '';
3
3
  }
4
+ export function getDepPinnedVersion(name) {
5
+ return name.split('@')[1] || '';
6
+ }
package/dist/mops.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Identity } from '@dfinity/agent';
1
+ import { Identity } from '@icp-sdk/core/agent';
2
2
  import { Config, Dependency } from './types.js';
3
3
  import { mainActor, storageActor } from './api/actors.js';
4
4
  import { getNetwork } from './api/network.js';
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ic-mops",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mops": "bin/mops.js",
@@ -28,12 +28,8 @@
28
28
  "node": ">=18.0.0"
29
29
  },
30
30
  "dependencies": {
31
- "@dfinity/agent": "3.1.0",
32
- "@dfinity/candid": "3.1.0",
33
- "@dfinity/identity": "3.1.0",
34
- "@dfinity/identity-secp256k1": "3.1.0",
35
- "@dfinity/principal": "3.1.0",
36
31
  "@iarna/toml": "2.2.5",
32
+ "@icp-sdk/core": "4.0.2",
37
33
  "@noble/hashes": "1.8.0",
38
34
  "as-table": "1.0.55",
39
35
  "buffer": "6.0.3",
@@ -64,7 +60,8 @@
64
60
  "node-fetch": "3.3.2",
65
61
  "octokit": "3.1.2",
66
62
  "pem-file": "1.0.1",
67
- "pic-ic": "0.5.3",
63
+ "pic-ic": "0.5.4",
64
+ "pic-js-mops": "0.14.8",
68
65
  "prettier": "3.5.3",
69
66
  "prettier-plugin-motoko": "0.11.0",
70
67
  "promisify-child-process": "4.1.2",
@@ -92,13 +89,6 @@
92
89
  "eslint": "8.57.0",
93
90
  "rexreplace": "7.1.13",
94
91
  "tsx": "4.19.2",
95
- "typescript": "5.7.3"
96
- },
97
- "overrides": {
98
- "@dfinity/agent": "3.1.0",
99
- "@dfinity/candid": "3.1.0",
100
- "@dfinity/identity": "3.1.0",
101
- "@dfinity/identity-secp256k1": "3.1.0",
102
- "@dfinity/principal": "3.1.0"
92
+ "typescript": "5.9.2"
103
93
  }
104
94
  }
package/dist/pem.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Buffer } from 'node:buffer';
2
- import { Ed25519KeyIdentity } from '@dfinity/identity';
3
- import { Secp256k1KeyIdentity } from '@dfinity/identity-secp256k1';
2
+ import { Ed25519KeyIdentity } from '@icp-sdk/core/identity';
3
+ import { Secp256k1KeyIdentity } from '@icp-sdk/core/identity/secp256k1';
4
4
  export declare function decodeFile(file: string, password?: string): Secp256k1KeyIdentity | Ed25519KeyIdentity;
5
5
  export declare function encrypt(buffer: Buffer, password: string): Buffer<ArrayBuffer>;
package/dist/pem.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import fs from 'node:fs';
2
2
  import { Buffer } from 'node:buffer';
3
3
  import crypto from 'node:crypto';
4
- import { Ed25519KeyIdentity } from '@dfinity/identity';
5
- import { Secp256k1KeyIdentity } from '@dfinity/identity-secp256k1';
4
+ import { Ed25519KeyIdentity } from '@icp-sdk/core/identity';
5
+ import { Secp256k1KeyIdentity } from '@icp-sdk/core/identity/secp256k1';
6
6
  import pemfile from 'pem-file';
7
7
  export function decodeFile(file, password) {
8
8
  let rawKey = fs.readFileSync(file);
@@ -1,3 +1,7 @@
1
1
  export function getDepName(name : string) : string {
2
2
  return name.split('@')[0] || '';
3
+ }
4
+
5
+ export function getDepPinnedVersion(name : string) : string {
6
+ return name.split('@')[1] || '';
3
7
  }