ic-mops 1.11.1 → 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.
- package/CHANGELOG.md +9 -0
- package/api/actors.ts +2 -2
- package/api/downloadPackageFiles.ts +1 -1
- package/bun.lock +234 -198
- package/bundle/bench/bench-canister.mo +101 -109
- package/bundle/bench/user-bench.mo +6 -10
- package/bundle/cli.js +960 -889
- package/bundle/cli.tgz +0 -0
- package/bundle/declarations/bench/bench.did +3 -3
- package/bundle/declarations/bench/bench.did.d.ts +3 -3
- package/bundle/declarations/bench/index.d.ts +3 -3
- package/bundle/declarations/bench/index.js +1 -1
- package/bundle/declarations/main/index.d.ts +3 -3
- package/bundle/declarations/main/index.js +1 -1
- package/bundle/declarations/main/main.did +78 -121
- package/bundle/declarations/main/main.did.d.ts +48 -98
- package/bundle/declarations/main/main.did.js +53 -107
- package/bundle/declarations/storage/index.d.ts +3 -3
- package/bundle/declarations/storage/index.js +4 -4
- package/bundle/declarations/storage/storage.did.d.ts +3 -3
- package/bundle/package.json +1 -1
- package/bundle/templates/src/lib.mo +13 -13
- package/bundle/templates/test/lib.test.mo +2 -2
- package/commands/add.ts +1 -1
- package/commands/available-updates.ts +20 -7
- package/commands/bench-replica.ts +21 -9
- package/commands/maintainer.ts +1 -1
- package/commands/outdated.ts +8 -1
- package/commands/owner.ts +1 -1
- package/commands/replica.ts +31 -18
- package/commands/test/test.ts +37 -97
- package/commands/test/utils.ts +75 -1
- package/commands/update.ts +19 -2
- package/declarations/bench/bench.did.d.ts +3 -3
- package/declarations/bench/index.d.ts +3 -3
- package/declarations/bench/index.js +1 -1
- package/declarations/main/index.d.ts +3 -3
- package/declarations/main/index.js +1 -1
- package/declarations/main/main.did.d.ts +3 -3
- package/declarations/storage/index.d.ts +3 -3
- package/declarations/storage/index.js +4 -4
- package/declarations/storage/storage.did.d.ts +3 -3
- package/dist/api/actors.d.ts +2 -2
- package/dist/api/actors.js +1 -1
- package/dist/api/downloadPackageFiles.d.ts +1 -1
- package/dist/api/downloadPackageFiles.js +1 -1
- package/dist/commands/add.js +1 -1
- package/dist/commands/available-updates.js +19 -7
- package/dist/commands/bench-replica.d.ts +3 -2
- package/dist/commands/bench-replica.js +17 -6
- package/dist/commands/maintainer.js +1 -1
- package/dist/commands/outdated.js +7 -1
- package/dist/commands/owner.js +1 -1
- package/dist/commands/replica.d.ts +4 -3
- package/dist/commands/replica.js +25 -13
- package/dist/commands/test/test.js +29 -81
- package/dist/commands/test/utils.d.ts +6 -0
- package/dist/commands/test/utils.js +61 -0
- package/dist/commands/update.js +16 -2
- package/dist/declarations/bench/bench.did.d.ts +3 -3
- package/dist/declarations/bench/index.d.ts +3 -3
- package/dist/declarations/bench/index.js +1 -1
- package/dist/declarations/main/index.d.ts +3 -3
- package/dist/declarations/main/index.js +1 -1
- package/dist/declarations/main/main.did.d.ts +3 -3
- package/dist/declarations/storage/index.d.ts +3 -3
- package/dist/declarations/storage/index.js +4 -4
- package/dist/declarations/storage/storage.did.d.ts +3 -3
- package/dist/helpers/get-dep-name.d.ts +1 -0
- package/dist/helpers/get-dep-name.js +3 -0
- package/dist/mops.d.ts +1 -1
- package/dist/package.json +4 -7
- package/dist/pem.d.ts +2 -2
- package/dist/pem.js +2 -2
- package/helpers/get-dep-name.ts +4 -0
- package/mops.ts +1 -1
- package/package.json +4 -7
- package/pem.ts +2 -2
- package/tsconfig.json +2 -2
package/commands/replica.ts
CHANGED
|
@@ -5,9 +5,10 @@ import fs from 'node:fs';
|
|
|
5
5
|
import {PassThrough} from 'node:stream';
|
|
6
6
|
import {spawn as spawnAsync} from 'promisify-child-process';
|
|
7
7
|
|
|
8
|
-
import {IDL} from '@
|
|
9
|
-
import {Actor, HttpAgent} from '@
|
|
8
|
+
import {IDL} from '@icp-sdk/core/candid';
|
|
9
|
+
import {Actor, HttpAgent} from '@icp-sdk/core/agent';
|
|
10
10
|
import {PocketIc, PocketIcServer} from 'pic-ic';
|
|
11
|
+
import {PocketIc as PocketIcMops, PocketIcServer as PocketIcServerMops} from 'pic-js-mops';
|
|
11
12
|
import chalk from 'chalk';
|
|
12
13
|
|
|
13
14
|
import {readConfig} from '../mops.js';
|
|
@@ -25,8 +26,8 @@ export class Replica {
|
|
|
25
26
|
type : 'dfx' | 'pocket-ic' | 'dfx-pocket-ic' = 'dfx';
|
|
26
27
|
verbose = false;
|
|
27
28
|
canisters : Record<string, {cwd : string; canisterId : string; actor : any; stream : PassThrough;}> = {};
|
|
28
|
-
pocketIcServer ?: PocketIcServer;
|
|
29
|
-
pocketIc ?: PocketIc;
|
|
29
|
+
pocketIcServer ?: PocketIcServer | PocketIcServerMops;
|
|
30
|
+
pocketIc ?: PocketIc | PocketIcMops;
|
|
30
31
|
dfxProcess ?: ChildProcessWithoutNullStreams;
|
|
31
32
|
dir : string = ''; // absolute path (/.../.mops/.test/)
|
|
32
33
|
ttl = 60;
|
|
@@ -85,20 +86,32 @@ export class Replica {
|
|
|
85
86
|
else {
|
|
86
87
|
let pocketIcBin = await toolchain.bin('pocket-ic');
|
|
87
88
|
|
|
88
|
-
// eslint-disable-next-line
|
|
89
89
|
let config = readConfig();
|
|
90
|
-
if (config.toolchain?.['pocket-ic'] !== '4.0.0') {
|
|
91
|
-
console.error('Current Mops CLI only supports pocket-ic 4.0.0');
|
|
90
|
+
if (config.toolchain?.['pocket-ic'] !== '4.0.0' && !config.toolchain?.['pocket-ic']?.startsWith('9.')) {
|
|
91
|
+
console.error('Current Mops CLI only supports pocket-ic 9.x.x and 4.0.0');
|
|
92
92
|
process.exit(1);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
95
|
+
// pocket-ic 9.x.x
|
|
96
|
+
if (config.toolchain?.['pocket-ic']?.startsWith('9.')) {
|
|
97
|
+
this.pocketIcServer = await PocketIcServerMops.start({
|
|
98
|
+
showRuntimeLogs: false,
|
|
99
|
+
showCanisterLogs: false,
|
|
100
|
+
binPath: pocketIcBin,
|
|
101
|
+
ttl: this.ttl,
|
|
102
|
+
});
|
|
103
|
+
this.pocketIc = await PocketIcMops.create(this.pocketIcServer.getUrl());
|
|
104
|
+
}
|
|
105
|
+
// pocket-ic 4.0.0
|
|
106
|
+
else {
|
|
107
|
+
this.pocketIcServer = await PocketIcServer.start({
|
|
108
|
+
showRuntimeLogs: false,
|
|
109
|
+
showCanisterLogs: false,
|
|
110
|
+
binPath: pocketIcBin,
|
|
111
|
+
ttl: this.ttl,
|
|
112
|
+
});
|
|
113
|
+
this.pocketIc = await PocketIc.create(this.pocketIcServer.getUrl());
|
|
114
|
+
}
|
|
102
115
|
|
|
103
116
|
// process canister logs
|
|
104
117
|
this._attachCanisterLogHandler(this.pocketIcServer.serverProcess as ChildProcessWithoutNullStreams);
|
|
@@ -224,17 +237,17 @@ export class Replica {
|
|
|
224
237
|
};
|
|
225
238
|
}
|
|
226
239
|
else if (this.pocketIc) {
|
|
227
|
-
|
|
228
|
-
let {canisterId, actor} = await this.pocketIc.setupCanister({
|
|
229
|
-
idlFactory,
|
|
240
|
+
type PocketIcSetupCanister = PocketIcMops['setupCanister'] & PocketIc['setupCanister'];
|
|
241
|
+
let {canisterId, actor} = await (this.pocketIc.setupCanister as PocketIcSetupCanister)({
|
|
230
242
|
wasm,
|
|
243
|
+
idlFactory,
|
|
231
244
|
});
|
|
232
245
|
|
|
233
246
|
if (signal?.aborted) {
|
|
234
247
|
return;
|
|
235
248
|
}
|
|
236
249
|
|
|
237
|
-
await this.pocketIc.addCycles(canisterId, 1_000_000_000_000);
|
|
250
|
+
await this.pocketIc.addCycles(canisterId as any, 1_000_000_000_000);
|
|
238
251
|
|
|
239
252
|
if (signal?.aborted) {
|
|
240
253
|
return;
|
package/commands/test/test.ts
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
|
-
import {spawn
|
|
2
|
+
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
|
|
|
7
8
|
import chalk from 'chalk';
|
|
8
9
|
import {globSync} from 'glob';
|
|
9
10
|
import chokidar from 'chokidar';
|
|
10
11
|
import debounce from 'debounce';
|
|
11
12
|
import {SemVer} from 'semver';
|
|
13
|
+
import {ActorMethod} from '@icp-sdk/core/agent';
|
|
12
14
|
|
|
13
15
|
import {sources} from '../sources.js';
|
|
14
16
|
import {getRootDir, readConfig} from '../../mops.js';
|
|
15
17
|
import {parallel} from '../../parallel.js';
|
|
16
18
|
|
|
17
19
|
import {MMF1} from './mmf1.js';
|
|
18
|
-
import {absToRel} from './utils.js';
|
|
20
|
+
import {absToRel, pipeMMF, pipeStderrToMMF, pipeStdoutToMMF} from './utils.js';
|
|
19
21
|
import {Reporter} from './reporters/reporter.js';
|
|
20
22
|
import {VerboseReporter} from './reporters/verbose-reporter.js';
|
|
21
23
|
import {FilesReporter} from './reporters/files-reporter.js';
|
|
@@ -23,8 +25,6 @@ import {CompactReporter} from './reporters/compact-reporter.js';
|
|
|
23
25
|
import {SilentReporter} from './reporters/silent-reporter.js';
|
|
24
26
|
import {toolchain} from '../toolchain/index.js';
|
|
25
27
|
import {Replica} from '../replica.js';
|
|
26
|
-
import {ActorMethod} from '@dfinity/agent';
|
|
27
|
-
import {PassThrough, Readable} from 'node:stream';
|
|
28
28
|
import {TestMode} from '../../types.js';
|
|
29
29
|
import {getDfxVersion} from '../../helpers/get-dfx-version.js';
|
|
30
30
|
|
|
@@ -221,14 +221,7 @@ export async function testWithReporter(reporterName : ReporterName | Reporter |
|
|
|
221
221
|
fs.rmSync(testTempDir, {recursive: true, force: true});
|
|
222
222
|
fs.mkdirSync(testTempDir, {recursive: true});
|
|
223
223
|
|
|
224
|
-
|
|
225
|
-
if (signal?.aborted) {
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
let mmf = new MMF1('store', absToRel(file));
|
|
230
|
-
|
|
231
|
-
// mode overrides
|
|
224
|
+
let filesWithMode = files.map((file) => {
|
|
232
225
|
let lines = fs.readFileSync(file, 'utf8').split('\n');
|
|
233
226
|
let mode = defaultMode;
|
|
234
227
|
if (lines.includes('// @testmode wasi')) {
|
|
@@ -237,19 +230,33 @@ export async function testWithReporter(reporterName : ReporterName | Reporter |
|
|
|
237
230
|
else if (lines.includes('// @testmode replica') || lines.find(line => line.match(/^(persistent )?actor( class)?/))) {
|
|
238
231
|
mode = 'replica';
|
|
239
232
|
}
|
|
233
|
+
return {file, mode};
|
|
234
|
+
});
|
|
240
235
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
236
|
+
let hasWasiTests = filesWithMode.some(({mode}) => mode === 'wasi');
|
|
237
|
+
let hasReplicaTests = filesWithMode.some(({mode}) => mode === 'replica');
|
|
238
|
+
|
|
239
|
+
// prepare wasmtime path
|
|
240
|
+
if (hasWasiTests && !wasmtimePath) {
|
|
241
|
+
// ensure wasmtime is installed or specified in config
|
|
242
|
+
if (config.toolchain?.wasmtime) {
|
|
243
|
+
wasmtimePath = await toolchain.bin('wasmtime');
|
|
244
|
+
}
|
|
245
|
+
// fallback wasmtime to global binary if not specified in config (legacy)
|
|
246
|
+
else {
|
|
247
|
+
wasmtimePath = 'wasmtime';
|
|
248
|
+
console.log(chalk.yellow('Warning:'), 'Wasmtime is not specified in config. Using global binary "wasmtime". This will be removed in the future.');
|
|
249
|
+
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.`);
|
|
252
250
|
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
let runTestFile = async ({file, mode} : {file : string, mode : TestMode}) => {
|
|
254
|
+
if (signal?.aborted) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// print logs immediately for replica tests because we run them one-by-one
|
|
259
|
+
let mmf = new MMF1(mode === 'replica' ? 'print' : 'store', absToRel(file));
|
|
253
260
|
|
|
254
261
|
let promise = new Promise<void>((resolve) => {
|
|
255
262
|
let mocArgs = ['--hide-warnings', '--error-detail=2', ...sourcesArr.join(' ').split(' '), file].filter(x => x);
|
|
@@ -315,8 +322,6 @@ export async function testWithReporter(reporterName : ReporterName | Reporter |
|
|
|
315
322
|
}
|
|
316
323
|
// build and execute in replica
|
|
317
324
|
else if (mode === 'replica') {
|
|
318
|
-
// mmf.strategy = 'print'; // because we run replica tests one-by-one
|
|
319
|
-
|
|
320
325
|
let wasmFile = `${path.join(testTempDir, path.parse(file).name)}.wasm`;
|
|
321
326
|
|
|
322
327
|
// build
|
|
@@ -363,7 +368,7 @@ export async function testWithReporter(reporterName : ReporterName | Reporter |
|
|
|
363
368
|
resolve();
|
|
364
369
|
clearInterval(timerId);
|
|
365
370
|
}
|
|
366
|
-
}, Math.random() * 1000 |0);
|
|
371
|
+
}, Math.random() * 1000 | 0);
|
|
367
372
|
});
|
|
368
373
|
}
|
|
369
374
|
|
|
@@ -396,9 +401,12 @@ export async function testWithReporter(reporterName : ReporterName | Reporter |
|
|
|
396
401
|
reporter.addRun(file, mmf, promise, mode);
|
|
397
402
|
|
|
398
403
|
await promise;
|
|
399
|
-
}
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
await parallel(os.cpus().length, filesWithMode.filter(({mode}) => mode !== 'replica'), runTestFile);
|
|
407
|
+
await parallel(1, filesWithMode.filter(({mode}) => mode === 'replica'), runTestFile);
|
|
400
408
|
|
|
401
|
-
if (
|
|
409
|
+
if (hasReplicaTests && !watch) {
|
|
402
410
|
await replica.stop();
|
|
403
411
|
fs.rmSync(testTempDir, {recursive: true, force: true});
|
|
404
412
|
}
|
|
@@ -408,72 +416,4 @@ export async function testWithReporter(reporterName : ReporterName | Reporter |
|
|
|
408
416
|
}
|
|
409
417
|
|
|
410
418
|
return reporter.done();
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
function pipeStdoutToMMF(stdout : Readable, mmf : MMF1) {
|
|
414
|
-
stdout.on('data', (data) => {
|
|
415
|
-
for (let line of data.toString().split('\n')) {
|
|
416
|
-
line = line.trim();
|
|
417
|
-
if (line) {
|
|
418
|
-
mmf.parseLine(line);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
function pipeStderrToMMF(stderr : Readable, mmf : MMF1, dir = '') {
|
|
425
|
-
stderr.on('data', (data) => {
|
|
426
|
-
let text : string = data.toString().trim();
|
|
427
|
-
let failedLine = '';
|
|
428
|
-
|
|
429
|
-
text = text.replace(/([\w+._/-]+):(\d+).(\d+)(-\d+.\d+)/g, (_m0, m1 : string, m2 : string, m3 : string) => {
|
|
430
|
-
// change absolute file path to relative
|
|
431
|
-
// change :line:col-line:col to :line:col to work in vscode
|
|
432
|
-
let res = `${absToRel(m1)}:${m2}:${m3}`;
|
|
433
|
-
let file = path.join(dir, m1);
|
|
434
|
-
|
|
435
|
-
if (!fs.existsSync(file)) {
|
|
436
|
-
return res;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
// show failed line
|
|
440
|
-
let content = fs.readFileSync(file);
|
|
441
|
-
let lines = content.toString().split('\n') || [];
|
|
442
|
-
|
|
443
|
-
failedLine += chalk.dim('\n ...');
|
|
444
|
-
|
|
445
|
-
let lineBefore = lines[+m2 - 2];
|
|
446
|
-
if (lineBefore) {
|
|
447
|
-
failedLine += chalk.dim(`\n ${+m2 - 1}\t| ${lineBefore.replaceAll('\t', ' ')}`);
|
|
448
|
-
}
|
|
449
|
-
failedLine += `\n${chalk.redBright`->`} ${m2}\t| ${lines[+m2 - 1]?.replaceAll('\t', ' ')}`;
|
|
450
|
-
if (lines.length > +m2) {
|
|
451
|
-
failedLine += chalk.dim(`\n ${+m2 + 1}\t| ${lines[+m2]?.replaceAll('\t', ' ')}`);
|
|
452
|
-
}
|
|
453
|
-
failedLine += chalk.dim('\n ...');
|
|
454
|
-
return res;
|
|
455
|
-
});
|
|
456
|
-
if (failedLine) {
|
|
457
|
-
text += failedLine;
|
|
458
|
-
}
|
|
459
|
-
mmf.fail(text);
|
|
460
|
-
});
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
function pipeMMF(proc : ChildProcessWithoutNullStreams, mmf : MMF1) {
|
|
464
|
-
return new Promise<void>((resolve) => {
|
|
465
|
-
pipeStdoutToMMF(proc.stdout, mmf);
|
|
466
|
-
pipeStderrToMMF(proc.stderr, mmf);
|
|
467
|
-
|
|
468
|
-
// exit
|
|
469
|
-
proc.on('close', (code) => {
|
|
470
|
-
if (code === 0) {
|
|
471
|
-
mmf.strategy !== 'print' && mmf.pass();
|
|
472
|
-
}
|
|
473
|
-
else if (code !== 1) {
|
|
474
|
-
mmf.fail(`unknown exit code: ${code}`);
|
|
475
|
-
}
|
|
476
|
-
resolve();
|
|
477
|
-
});
|
|
478
|
-
});
|
|
479
|
-
}
|
|
419
|
+
}
|
package/commands/test/utils.ts
CHANGED
|
@@ -1,7 +1,81 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import {ChildProcessWithoutNullStreams} from 'node:child_process';
|
|
4
|
+
import {Readable} from 'node:stream';
|
|
5
|
+
import chalk from 'chalk';
|
|
2
6
|
import {getRootDir} from '../../mops.js';
|
|
7
|
+
import {MMF1} from './mmf1.js';
|
|
3
8
|
|
|
4
9
|
export function absToRel(p : string) {
|
|
5
10
|
let rootDir = getRootDir();
|
|
6
11
|
return path.relative(rootDir, path.resolve(p));
|
|
7
|
-
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function pipeStdoutToMMF(stdout : Readable, mmf : MMF1) {
|
|
15
|
+
stdout.on('data', (data) => {
|
|
16
|
+
for (let line of data.toString().split('\n')) {
|
|
17
|
+
line = line.trim();
|
|
18
|
+
if (line) {
|
|
19
|
+
mmf.parseLine(line);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function pipeStderrToMMF(stderr : Readable, mmf : MMF1, dir = '') {
|
|
26
|
+
stderr.on('data', (data) => {
|
|
27
|
+
let text : string = data.toString().trim();
|
|
28
|
+
let failedLine = '';
|
|
29
|
+
|
|
30
|
+
text = text.replace(/([\w+._/-]+):(\d+).(\d+)(-\d+.\d+)/g, (_m0, m1 : string, m2 : string, m3 : string) => {
|
|
31
|
+
// change absolute file path to relative
|
|
32
|
+
// change :line:col-line:col to :line:col to work in vscode
|
|
33
|
+
let res = `${absToRel(m1)}:${m2}:${m3}`;
|
|
34
|
+
let file = path.join(dir, m1);
|
|
35
|
+
|
|
36
|
+
if (!fs.existsSync(file)) {
|
|
37
|
+
return res;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// show failed line
|
|
41
|
+
let content = fs.readFileSync(file);
|
|
42
|
+
let lines = content.toString().split('\n') || [];
|
|
43
|
+
|
|
44
|
+
failedLine += chalk.dim('\n ...');
|
|
45
|
+
|
|
46
|
+
let lineBefore = lines[+m2 - 2];
|
|
47
|
+
if (lineBefore) {
|
|
48
|
+
failedLine += chalk.dim(`\n ${+m2 - 1}\t| ${lineBefore.replaceAll('\t', ' ')}`);
|
|
49
|
+
}
|
|
50
|
+
failedLine += `\n${chalk.redBright`->`} ${m2}\t| ${lines[+m2 - 1]?.replaceAll('\t', ' ')}`;
|
|
51
|
+
if (lines.length > +m2) {
|
|
52
|
+
failedLine += chalk.dim(`\n ${+m2 + 1}\t| ${lines[+m2]?.replaceAll('\t', ' ')}`);
|
|
53
|
+
}
|
|
54
|
+
failedLine += chalk.dim('\n ...');
|
|
55
|
+
return res;
|
|
56
|
+
});
|
|
57
|
+
if (failedLine) {
|
|
58
|
+
text += failedLine;
|
|
59
|
+
}
|
|
60
|
+
mmf.fail(text);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function pipeMMF(proc : ChildProcessWithoutNullStreams, mmf : MMF1) {
|
|
65
|
+
return new Promise<void>((resolve) => {
|
|
66
|
+
pipeStdoutToMMF(proc.stdout, mmf);
|
|
67
|
+
pipeStderrToMMF(proc.stderr, mmf);
|
|
68
|
+
|
|
69
|
+
// exit
|
|
70
|
+
proc.on('close', (code) => {
|
|
71
|
+
if (code === 0) {
|
|
72
|
+
mmf.strategy !== 'print' && mmf.pass();
|
|
73
|
+
}
|
|
74
|
+
else if (code !== 1) {
|
|
75
|
+
mmf.fail(`unknown exit code: ${code}`);
|
|
76
|
+
}
|
|
77
|
+
resolve();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
package/commands/update.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {checkConfigFile, getGithubCommit, parseGithubURL, readConfig} from '../m
|
|
|
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
|
|
|
7
8
|
type UpdateOptions = {
|
|
8
9
|
verbose ?: boolean;
|
|
@@ -51,8 +52,24 @@ export async function update(pkg ?: string, {lock} : UpdateOptions = {}) {
|
|
|
51
52
|
}
|
|
52
53
|
else {
|
|
53
54
|
for (let dep of available) {
|
|
54
|
-
let
|
|
55
|
-
|
|
55
|
+
let devDeps = Object.keys(config['dev-dependencies'] || {});
|
|
56
|
+
let allDeps = [...Object.keys(config.dependencies || {}), ...devDeps];
|
|
57
|
+
|
|
58
|
+
let dev = false;
|
|
59
|
+
for (let d of devDeps) {
|
|
60
|
+
let pinnedVersion = getDepPinnedVersion(d);
|
|
61
|
+
if (getDepName(d) === dep[0] && (!pinnedVersion || dep[1].startsWith(pinnedVersion))) {
|
|
62
|
+
dev = true;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let asName = allDeps.find((d) => {
|
|
68
|
+
let pinnedVersion = getDepPinnedVersion(d);
|
|
69
|
+
return getDepName(d) === dep[0] && (!pinnedVersion || dep[1].startsWith(pinnedVersion));
|
|
70
|
+
}) || dep[0];
|
|
71
|
+
|
|
72
|
+
await add(`${dep[0]}@${dep[2]}`, {dev}, asName);
|
|
56
73
|
}
|
|
57
74
|
}
|
|
58
75
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Principal } from '@
|
|
2
|
-
import type { ActorMethod } from '@
|
|
3
|
-
import type { IDL } from '@
|
|
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 "@
|
|
7
|
-
import type { Principal } from "@
|
|
8
|
-
import type { IDL } from "@
|
|
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
|
|
|
@@ -3,9 +3,9 @@ import type {
|
|
|
3
3
|
HttpAgentOptions,
|
|
4
4
|
ActorConfig,
|
|
5
5
|
Agent,
|
|
6
|
-
} from "@
|
|
7
|
-
import type { Principal } from "@
|
|
8
|
-
import type { IDL } from "@
|
|
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,6 +1,6 @@
|
|
|
1
|
-
import type { Principal } from '@
|
|
2
|
-
import type { ActorMethod } from '@
|
|
3
|
-
import type { IDL } from '@
|
|
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 "@
|
|
7
|
-
import type { Principal } from "@
|
|
8
|
-
import type { IDL } from "@
|
|
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 "@
|
|
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("@
|
|
10
|
-
* @param {{agentOptions?: import("@
|
|
11
|
-
* @return {import("@
|
|
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 '@
|
|
2
|
-
import type { ActorMethod } from '@
|
|
3
|
-
import type { IDL } from '@
|
|
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;
|
package/dist/api/actors.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Identity } from '@
|
|
2
|
-
import { Principal } from '@
|
|
1
|
+
import { Identity } from '@icp-sdk/core/agent';
|
|
2
|
+
import { Principal } from '@icp-sdk/core/principal';
|
|
3
3
|
import { _SERVICE } from '../declarations/main/main.did.js';
|
|
4
4
|
import { _SERVICE as _STORAGE_SERVICE } from '../declarations/storage/storage.did.js';
|
|
5
5
|
export declare let mainActor: (identity?: Identity) => Promise<_SERVICE>;
|
package/dist/api/actors.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Actor, HttpAgent } from '@
|
|
1
|
+
import { Actor, HttpAgent } from '@icp-sdk/core/agent';
|
|
2
2
|
import { idlFactory } from '../declarations/main/main.did.js';
|
|
3
3
|
import { idlFactory as storageIdlFactory } from '../declarations/storage/storage.did.js';
|
|
4
4
|
import { getEndpoint } from './network.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Principal } from '@
|
|
1
|
+
import { Principal } from '@icp-sdk/core/principal';
|
|
2
2
|
import { Storage } from '../declarations/storage/storage.did.js';
|
|
3
3
|
export declare function downloadPackageFiles(pkg: string, version?: string, threads?: number, onLoad?: (_fileIds: string[], _fileId: string) => void): Promise<Map<string, Array<number>>>;
|
|
4
4
|
export declare function getPackageFilesInfo(pkg: string, version: string): Promise<{
|
package/dist/commands/add.js
CHANGED
|
@@ -1,28 +1,40 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import { mainActor } from '../api/actors.js';
|
|
4
|
-
import { getDepName } from '../helpers/get-dep-name.js';
|
|
4
|
+
import { getDepName, getDepPinnedVersion } from '../helpers/get-dep-name.js';
|
|
5
5
|
// [pkg, oldVersion, newVersion]
|
|
6
6
|
export async function getAvailableUpdates(config, pkg) {
|
|
7
7
|
let deps = Object.values(config.dependencies || {});
|
|
8
8
|
let devDeps = Object.values(config['dev-dependencies'] || {});
|
|
9
9
|
let allDeps = [...deps, ...devDeps].filter((dep) => dep.version);
|
|
10
10
|
let depsToUpdate = pkg ? allDeps.filter((dep) => dep.name === pkg) : allDeps;
|
|
11
|
-
// skip pinned dependencies
|
|
12
|
-
depsToUpdate = depsToUpdate.filter((dep) => getDepName(dep.name) === dep.name);
|
|
13
|
-
let getCurrentVersion = (pkg) => {
|
|
11
|
+
// skip hard pinned dependencies (e.g. "base@X.Y.Z")
|
|
12
|
+
depsToUpdate = depsToUpdate.filter((dep) => getDepName(dep.name) === dep.name || getDepPinnedVersion(dep.name).split('.').length !== 3);
|
|
13
|
+
let getCurrentVersion = (pkg, updateVersion) => {
|
|
14
14
|
for (let dep of allDeps) {
|
|
15
|
-
if (dep.name === pkg && dep.version) {
|
|
15
|
+
if (getDepName(dep.name) === pkg && dep.version) {
|
|
16
|
+
let pinnedVersion = getDepPinnedVersion(dep.name);
|
|
17
|
+
if (pinnedVersion && !updateVersion.startsWith(pinnedVersion)) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
16
20
|
return dep.version;
|
|
17
21
|
}
|
|
18
22
|
}
|
|
19
23
|
return '';
|
|
20
24
|
};
|
|
21
25
|
let actor = await mainActor();
|
|
22
|
-
let res = await actor.getHighestSemverBatch(depsToUpdate.map((dep) =>
|
|
26
|
+
let res = await actor.getHighestSemverBatch(depsToUpdate.map((dep) => {
|
|
27
|
+
let semverPart = { major: null };
|
|
28
|
+
let name = getDepName(dep.name);
|
|
29
|
+
let pinnedVersion = getDepPinnedVersion(dep.name);
|
|
30
|
+
if (pinnedVersion) {
|
|
31
|
+
semverPart = pinnedVersion.split('.').length === 1 ? { minor: null } : { patch: null };
|
|
32
|
+
}
|
|
33
|
+
return [name, dep.version || '', semverPart];
|
|
34
|
+
}));
|
|
23
35
|
if ('err' in res) {
|
|
24
36
|
console.log(chalk.red('Error:'), res.err);
|
|
25
37
|
process.exit(1);
|
|
26
38
|
}
|
|
27
|
-
return res.ok.filter((dep) => dep[1] !== getCurrentVersion(dep[0])).map((dep) => [dep[0], getCurrentVersion(dep[0]), dep[1]]);
|
|
39
|
+
return res.ok.filter((dep) => dep[1] !== getCurrentVersion(dep[0], dep[1])).map((dep) => [dep[0], getCurrentVersion(dep[0], dep[1]), dep[1]]);
|
|
28
40
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PocketIc, PocketIcServer } from 'pic-ic';
|
|
2
|
+
import { PocketIc as PocketIcMops, PocketIcServer as PocketIcServerMops } from 'pic-js-mops';
|
|
2
3
|
export declare class BenchReplica {
|
|
3
4
|
type: 'dfx' | 'pocket-ic' | 'dfx-pocket-ic';
|
|
4
5
|
verbose: boolean;
|
|
@@ -7,8 +8,8 @@ export declare class BenchReplica {
|
|
|
7
8
|
canisterId: string;
|
|
8
9
|
actor: any;
|
|
9
10
|
}>;
|
|
10
|
-
pocketIcServer?: PocketIcServer;
|
|
11
|
-
pocketIc?: PocketIc;
|
|
11
|
+
pocketIcServer?: PocketIcServer | PocketIcServerMops;
|
|
12
|
+
pocketIc?: PocketIc | PocketIcMops;
|
|
12
13
|
constructor(type: 'dfx' | 'pocket-ic' | 'dfx-pocket-ic', verbose?: boolean);
|
|
13
14
|
start({ silent }?: {
|
|
14
15
|
silent?: boolean | undefined;
|