ic-mops 1.1.0-pre.0 → 1.1.1

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 (74) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/bin/moc-wrapper.sh +1 -1
  3. package/bundle/cli.tgz +0 -0
  4. package/check-requirements.ts +1 -1
  5. package/cli.ts +18 -0
  6. package/commands/bench.ts +1 -1
  7. package/commands/install/install-all.ts +2 -2
  8. package/commands/replica.ts +33 -3
  9. package/commands/sources.ts +1 -1
  10. package/commands/sync.ts +4 -19
  11. package/commands/test/mmf1.ts +4 -0
  12. package/commands/test/reporters/silent-reporter.ts +22 -4
  13. package/commands/test/test.ts +74 -10
  14. package/commands/watch/deployer.ts +155 -0
  15. package/commands/watch/error-checker.ts +87 -0
  16. package/commands/watch/generator.ts +99 -0
  17. package/commands/watch/globMoFiles.ts +16 -0
  18. package/commands/watch/parseDfxJson.ts +64 -0
  19. package/commands/watch/tester.ts +81 -0
  20. package/commands/watch/warning-checker.ts +133 -0
  21. package/commands/watch/watch.ts +90 -0
  22. package/declarations/main/main.did +16 -10
  23. package/declarations/main/main.did.d.ts +19 -10
  24. package/declarations/main/main.did.js +25 -11
  25. package/dist/bin/moc-wrapper.sh +1 -1
  26. package/dist/check-requirements.js +1 -1
  27. package/dist/cli.js +16 -0
  28. package/dist/commands/bench.js +1 -1
  29. package/dist/commands/install/install-all.js +2 -2
  30. package/dist/commands/replica.d.ts +2 -2
  31. package/dist/commands/replica.js +26 -3
  32. package/dist/commands/sources.d.ts +1 -1
  33. package/dist/commands/sources.js +1 -1
  34. package/dist/commands/sync.js +3 -18
  35. package/dist/commands/test/mmf1.d.ts +1 -0
  36. package/dist/commands/test/mmf1.js +3 -0
  37. package/dist/commands/test/reporters/silent-reporter.d.ts +6 -1
  38. package/dist/commands/test/reporters/silent-reporter.js +18 -5
  39. package/dist/commands/test/test.d.ts +1 -1
  40. package/dist/commands/test/test.js +62 -10
  41. package/dist/commands/watch/deployer.d.ts +24 -0
  42. package/dist/commands/watch/deployer.js +125 -0
  43. package/dist/commands/watch/error-checker.d.ts +13 -0
  44. package/dist/commands/watch/error-checker.js +76 -0
  45. package/dist/commands/watch/generator.d.ts +21 -0
  46. package/dist/commands/watch/generator.js +79 -0
  47. package/dist/commands/watch/globMoFiles.d.ts +1 -0
  48. package/dist/commands/watch/globMoFiles.js +14 -0
  49. package/dist/commands/watch/parseDfxJson.d.ts +2 -0
  50. package/dist/commands/watch/parseDfxJson.js +22 -0
  51. package/dist/commands/watch/tester.d.ts +19 -0
  52. package/dist/commands/watch/tester.js +63 -0
  53. package/dist/commands/watch/warning-checker.d.ts +20 -0
  54. package/dist/commands/watch/warning-checker.js +111 -0
  55. package/dist/commands/watch/watch.d.ts +7 -0
  56. package/dist/commands/watch/watch.js +79 -0
  57. package/dist/declarations/main/main.did +16 -10
  58. package/dist/declarations/main/main.did.d.ts +19 -10
  59. package/dist/declarations/main/main.did.js +25 -11
  60. package/dist/helpers/get-moc-path.d.ts +1 -1
  61. package/dist/helpers/get-moc-path.js +17 -3
  62. package/dist/helpers/get-moc-version.d.ts +1 -1
  63. package/dist/helpers/get-moc-version.js +17 -5
  64. package/dist/integrity.js +3 -2
  65. package/dist/package.json +3 -2
  66. package/dist/parallel.d.ts +1 -1
  67. package/dist/templates/mops-test.yml +4 -2
  68. package/helpers/get-moc-path.ts +19 -3
  69. package/helpers/get-moc-version.ts +17 -5
  70. package/integrity.ts +3 -2
  71. package/package.json +3 -2
  72. package/parallel.ts +2 -2
  73. package/templates/mops-test.yml +4 -2
  74. package/test +0 -4
@@ -63,7 +63,7 @@ export interface Main {
63
63
  'getBackupCanisterId' : ActorMethod<[], Principal>,
64
64
  'getDefaultPackages' : ActorMethod<
65
65
  [string],
66
- Array<[PackageName, PackageVersion]>
66
+ Array<[PackageName, PackageVersion__1]>
67
67
  >,
68
68
  'getDownloadTrendByPackageId' : ActorMethod<
69
69
  [PackageId],
@@ -73,22 +73,25 @@ export interface Main {
73
73
  [PackageName],
74
74
  Array<DownloadsSnapshot__1>
75
75
  >,
76
- 'getFileHashes' : ActorMethod<[PackageName, PackageVersion], Result_8>,
76
+ 'getFileHashes' : ActorMethod<[PackageName, PackageVersion__1], Result_8>,
77
77
  'getFileHashesByPackageIds' : ActorMethod<
78
78
  [Array<PackageId>],
79
79
  Array<[PackageId, Array<[FileId, Uint8Array | number[]]>]>
80
80
  >,
81
- 'getFileHashesQuery' : ActorMethod<[PackageName, PackageVersion], Result_8>,
82
- 'getFileIds' : ActorMethod<[PackageName, PackageVersion], Result_7>,
81
+ 'getFileHashesQuery' : ActorMethod<
82
+ [PackageName, PackageVersion__1],
83
+ Result_8
84
+ >,
85
+ 'getFileIds' : ActorMethod<[PackageName, PackageVersion__1], Result_7>,
83
86
  'getHighestSemverBatch' : ActorMethod<
84
- [Array<[PackageName, PackageVersion, SemverPart]>],
87
+ [Array<[PackageName, PackageVersion__1, SemverPart]>],
85
88
  Result_6
86
89
  >,
87
90
  'getHighestVersion' : ActorMethod<[PackageName], Result_5>,
88
91
  'getMostDownloadedPackages' : ActorMethod<[], Array<PackageSummary>>,
89
92
  'getMostDownloadedPackagesIn7Days' : ActorMethod<[], Array<PackageSummary>>,
90
93
  'getNewPackages' : ActorMethod<[], Array<PackageSummary>>,
91
- 'getPackageDetails' : ActorMethod<[PackageName, PackageVersion], Result_4>,
94
+ 'getPackageDetails' : ActorMethod<[PackageName, PackageVersion__1], Result_4>,
92
95
  'getPackagesByCategory' : ActorMethod<
93
96
  [],
94
97
  Array<[string, Array<PackageSummary>]>
@@ -102,9 +105,9 @@ export interface Main {
102
105
  'getTotalPackages' : ActorMethod<[], bigint>,
103
106
  'getUser' : ActorMethod<[Principal], [] | [User__1]>,
104
107
  'http_request' : ActorMethod<[Request], Response>,
105
- 'notifyInstall' : ActorMethod<[PackageName, PackageVersion], undefined>,
108
+ 'notifyInstall' : ActorMethod<[PackageName, PackageVersion__1], undefined>,
106
109
  'notifyInstalls' : ActorMethod<
107
- [Array<[PackageName, PackageVersion]>],
110
+ [Array<[PackageName, PackageVersion__1]>],
108
111
  undefined
109
112
  >,
110
113
  'restore' : ActorMethod<[bigint], undefined>,
@@ -182,6 +185,7 @@ export interface PackageDetails {
182
185
  'deps' : Array<PackageSummary__1>,
183
186
  'quality' : PackageQuality,
184
187
  'testStats' : TestStats__1,
188
+ 'highestVersion' : PackageVersion,
185
189
  'downloadsTotal' : bigint,
186
190
  'downloadsInLast30Days' : bigint,
187
191
  'downloadTrend' : Array<DownloadsSnapshot>,
@@ -221,6 +225,7 @@ export interface PackageSummary {
221
225
  'owner' : Principal,
222
226
  'depAlias' : string,
223
227
  'quality' : PackageQuality,
228
+ 'highestVersion' : PackageVersion,
224
229
  'downloadsTotal' : bigint,
225
230
  'downloadsInLast30Days' : bigint,
226
231
  'downloadsInLast7Days' : bigint,
@@ -232,6 +237,7 @@ export interface PackageSummaryWithChanges {
232
237
  'owner' : Principal,
233
238
  'depAlias' : string,
234
239
  'quality' : PackageQuality,
240
+ 'highestVersion' : PackageVersion,
235
241
  'downloadsTotal' : bigint,
236
242
  'downloadsInLast30Days' : bigint,
237
243
  'downloadsInLast7Days' : bigint,
@@ -244,6 +250,7 @@ export interface PackageSummaryWithChanges__1 {
244
250
  'owner' : Principal,
245
251
  'depAlias' : string,
246
252
  'quality' : PackageQuality,
253
+ 'highestVersion' : PackageVersion,
247
254
  'downloadsTotal' : bigint,
248
255
  'downloadsInLast30Days' : bigint,
249
256
  'downloadsInLast7Days' : bigint,
@@ -256,6 +263,7 @@ export interface PackageSummary__1 {
256
263
  'owner' : Principal,
257
264
  'depAlias' : string,
258
265
  'quality' : PackageQuality,
266
+ 'highestVersion' : PackageVersion,
259
267
  'downloadsTotal' : bigint,
260
268
  'downloadsInLast30Days' : bigint,
261
269
  'downloadsInLast7Days' : bigint,
@@ -263,6 +271,7 @@ export interface PackageSummary__1 {
263
271
  'publication' : PackagePublication,
264
272
  }
265
273
  export type PackageVersion = string;
274
+ export type PackageVersion__1 = string;
266
275
  export type PageCount = bigint;
267
276
  export type PublishingId = string;
268
277
  export interface Request {
@@ -290,9 +299,9 @@ export type Result_3 = { 'ok' : FileId } |
290
299
  { 'err' : Err };
291
300
  export type Result_4 = { 'ok' : PackageDetails } |
292
301
  { 'err' : Err };
293
- export type Result_5 = { 'ok' : PackageVersion } |
302
+ export type Result_5 = { 'ok' : PackageVersion__1 } |
294
303
  { 'err' : Err };
295
- export type Result_6 = { 'ok' : Array<[PackageName, PackageVersion]> } |
304
+ export type Result_6 = { 'ok' : Array<[PackageName, PackageVersion__1]> } |
296
305
  { 'err' : Err };
297
306
  export type Result_7 = { 'ok' : Array<FileId> } |
298
307
  { 'err' : Err };
@@ -4,7 +4,7 @@ export const idlFactory = ({ IDL }) => {
4
4
  const Result = IDL.Variant({ 'ok' : IDL.Null, 'err' : Err });
5
5
  const Text = IDL.Text;
6
6
  const PackageName = IDL.Text;
7
- const PackageVersion = IDL.Text;
7
+ const PackageVersion__1 = IDL.Text;
8
8
  const PackageId = IDL.Text;
9
9
  const Time = IDL.Int;
10
10
  const DownloadsSnapshot__1 = IDL.Record({
@@ -24,10 +24,10 @@ export const idlFactory = ({ IDL }) => {
24
24
  'patch' : IDL.Null,
25
25
  });
26
26
  const Result_6 = IDL.Variant({
27
- 'ok' : IDL.Vec(IDL.Tuple(PackageName, PackageVersion)),
27
+ 'ok' : IDL.Vec(IDL.Tuple(PackageName, PackageVersion__1)),
28
28
  'err' : Err,
29
29
  });
30
- const Result_5 = IDL.Variant({ 'ok' : PackageVersion, 'err' : Err });
30
+ const Result_5 = IDL.Variant({ 'ok' : PackageVersion__1, 'err' : Err });
31
31
  const User = IDL.Record({
32
32
  'id' : IDL.Principal,
33
33
  'emailVerified' : IDL.Bool,
@@ -55,6 +55,7 @@ export const idlFactory = ({ IDL }) => {
55
55
  'hasRepository' : IDL.Bool,
56
56
  'hasReleaseNotes' : IDL.Bool,
57
57
  });
58
+ const PackageVersion = IDL.Text;
58
59
  const Script = IDL.Record({ 'value' : IDL.Text, 'name' : IDL.Text });
59
60
  const PackageName__1 = IDL.Text;
60
61
  const DependencyV2 = IDL.Record({
@@ -92,6 +93,7 @@ export const idlFactory = ({ IDL }) => {
92
93
  'owner' : IDL.Principal,
93
94
  'depAlias' : IDL.Text,
94
95
  'quality' : PackageQuality,
96
+ 'highestVersion' : PackageVersion,
95
97
  'downloadsTotal' : IDL.Nat,
96
98
  'downloadsInLast30Days' : IDL.Nat,
97
99
  'downloadsInLast7Days' : IDL.Nat,
@@ -119,6 +121,7 @@ export const idlFactory = ({ IDL }) => {
119
121
  'owner' : IDL.Principal,
120
122
  'depAlias' : IDL.Text,
121
123
  'quality' : PackageQuality,
124
+ 'highestVersion' : PackageVersion,
122
125
  'downloadsTotal' : IDL.Nat,
123
126
  'downloadsInLast30Days' : IDL.Nat,
124
127
  'downloadsInLast7Days' : IDL.Nat,
@@ -160,6 +163,7 @@ export const idlFactory = ({ IDL }) => {
160
163
  'owner' : IDL.Principal,
161
164
  'depAlias' : IDL.Text,
162
165
  'quality' : PackageQuality,
166
+ 'highestVersion' : PackageVersion,
163
167
  'downloadsTotal' : IDL.Nat,
164
168
  'downloadsInLast30Days' : IDL.Nat,
165
169
  'downloadsInLast7Days' : IDL.Nat,
@@ -175,6 +179,7 @@ export const idlFactory = ({ IDL }) => {
175
179
  'deps' : IDL.Vec(PackageSummary__1),
176
180
  'quality' : PackageQuality,
177
181
  'testStats' : TestStats__1,
182
+ 'highestVersion' : PackageVersion,
178
183
  'downloadsTotal' : IDL.Nat,
179
184
  'downloadsInLast30Days' : IDL.Nat,
180
185
  'downloadTrend' : IDL.Vec(DownloadsSnapshot),
@@ -193,6 +198,7 @@ export const idlFactory = ({ IDL }) => {
193
198
  'owner' : IDL.Principal,
194
199
  'depAlias' : IDL.Text,
195
200
  'quality' : PackageQuality,
201
+ 'highestVersion' : PackageVersion,
196
202
  'downloadsTotal' : IDL.Nat,
197
203
  'downloadsInLast30Days' : IDL.Nat,
198
204
  'downloadsInLast7Days' : IDL.Nat,
@@ -295,7 +301,7 @@ export const idlFactory = ({ IDL }) => {
295
301
  'getBackupCanisterId' : IDL.Func([], [IDL.Principal], ['query']),
296
302
  'getDefaultPackages' : IDL.Func(
297
303
  [IDL.Text],
298
- [IDL.Vec(IDL.Tuple(PackageName, PackageVersion))],
304
+ [IDL.Vec(IDL.Tuple(PackageName, PackageVersion__1))],
299
305
  ['query'],
300
306
  ),
301
307
  'getDownloadTrendByPackageId' : IDL.Func(
@@ -308,7 +314,11 @@ export const idlFactory = ({ IDL }) => {
308
314
  [IDL.Vec(DownloadsSnapshot__1)],
309
315
  ['query'],
310
316
  ),
311
- 'getFileHashes' : IDL.Func([PackageName, PackageVersion], [Result_8], []),
317
+ 'getFileHashes' : IDL.Func(
318
+ [PackageName, PackageVersion__1],
319
+ [Result_8],
320
+ [],
321
+ ),
312
322
  'getFileHashesByPackageIds' : IDL.Func(
313
323
  [IDL.Vec(PackageId)],
314
324
  [
@@ -319,17 +329,17 @@ export const idlFactory = ({ IDL }) => {
319
329
  [],
320
330
  ),
321
331
  'getFileHashesQuery' : IDL.Func(
322
- [PackageName, PackageVersion],
332
+ [PackageName, PackageVersion__1],
323
333
  [Result_8],
324
334
  ['query'],
325
335
  ),
326
336
  'getFileIds' : IDL.Func(
327
- [PackageName, PackageVersion],
337
+ [PackageName, PackageVersion__1],
328
338
  [Result_7],
329
339
  ['query'],
330
340
  ),
331
341
  'getHighestSemverBatch' : IDL.Func(
332
- [IDL.Vec(IDL.Tuple(PackageName, PackageVersion, SemverPart))],
342
+ [IDL.Vec(IDL.Tuple(PackageName, PackageVersion__1, SemverPart))],
333
343
  [Result_6],
334
344
  ['query'],
335
345
  ),
@@ -346,7 +356,7 @@ export const idlFactory = ({ IDL }) => {
346
356
  ),
347
357
  'getNewPackages' : IDL.Func([], [IDL.Vec(PackageSummary)], ['query']),
348
358
  'getPackageDetails' : IDL.Func(
349
- [PackageName, PackageVersion],
359
+ [PackageName, PackageVersion__1],
350
360
  [Result_4],
351
361
  ['query'],
352
362
  ),
@@ -369,9 +379,13 @@ export const idlFactory = ({ IDL }) => {
369
379
  'getTotalPackages' : IDL.Func([], [IDL.Nat], ['query']),
370
380
  'getUser' : IDL.Func([IDL.Principal], [IDL.Opt(User__1)], ['query']),
371
381
  'http_request' : IDL.Func([Request], [Response], ['query']),
372
- 'notifyInstall' : IDL.Func([PackageName, PackageVersion], [], ['oneway']),
382
+ 'notifyInstall' : IDL.Func(
383
+ [PackageName, PackageVersion__1],
384
+ [],
385
+ ['oneway'],
386
+ ),
373
387
  'notifyInstalls' : IDL.Func(
374
- [IDL.Vec(IDL.Tuple(PackageName, PackageVersion))],
388
+ [IDL.Vec(IDL.Tuple(PackageName, PackageVersion__1))],
375
389
  [],
376
390
  ['oneway'],
377
391
  ),
@@ -22,7 +22,7 @@ else
22
22
  mopsTomlHash=$(shasum $mopsToml -a 256 | awk -F' ' '{print $1}')
23
23
  fi;
24
24
 
25
- cached="$rootDir/.mops/moc-$mopsTomlHash"
25
+ cached="$rootDir/.mops/moc-$(uname -n)-$mopsTomlHash"
26
26
 
27
27
  if [ -f $cached ]; then
28
28
  mocPath=$(cat $cached)
@@ -9,7 +9,7 @@ export async function checkRequirements({ verbose = false } = {}) {
9
9
  let config = readConfig();
10
10
  let mocVersion = config.toolchain?.moc;
11
11
  if (!mocVersion) {
12
- mocVersion = getMocVersion();
12
+ mocVersion = getMocVersion(false);
13
13
  }
14
14
  if (!mocVersion) {
15
15
  return;
package/dist/cli.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import process from 'node:process';
2
2
  import fs from 'node:fs';
3
+ import events from 'node:events';
3
4
  import { Command, Argument, Option } from 'commander';
4
5
  import { init } from './commands/init.js';
5
6
  import { publish } from './commands/publish.js';
@@ -23,6 +24,8 @@ import { transferOwnership } from './commands/transfer-ownership.js';
23
24
  import { toolchain } from './commands/toolchain/index.js';
24
25
  import * as self from './commands/self.js';
25
26
  import { resolvePackages } from './resolve-packages.js';
27
+ import { watch } from './commands/watch/watch.js';
28
+ events.setMaxListeners(20);
26
29
  let networkFile = getNetworkFile();
27
30
  if (fs.existsSync(networkFile)) {
28
31
  globalThis.MOPS_NETWORK = fs.readFileSync(networkFile).toString() || 'ic';
@@ -343,4 +346,17 @@ selfCommand
343
346
  await self.uninstall();
344
347
  });
345
348
  program.addCommand(selfCommand);
349
+ // watch
350
+ program
351
+ .command('watch')
352
+ .description('Watch *.mo files and check for syntax errors, warnings, run tests, generate declarations and deploy canisters')
353
+ .option('-e, --error', 'Check Motoko canisters or *.mo files for syntax errors')
354
+ .option('-w, --warning', 'Check Motoko canisters or *.mo files for warnings')
355
+ .option('-t, --test', 'Run tests')
356
+ .option('-g, --generate', 'Generate declarations for Motoko canisters')
357
+ .option('-d, --deploy', 'Deploy Motoko canisters')
358
+ .action(async (options) => {
359
+ checkConfigFile(true);
360
+ await watch(options);
361
+ });
346
362
  program.parse();
@@ -33,7 +33,7 @@ export async function bench(filter = '', optionsArg = {}) {
33
33
  replica: config.toolchain?.['pocket-ic'] ? 'pocket-ic' : 'dfx',
34
34
  replicaVersion: '',
35
35
  compiler: 'moc',
36
- compilerVersion: getMocVersion(),
36
+ compilerVersion: getMocVersion(true),
37
37
  gc: 'copying',
38
38
  forceGc: true,
39
39
  save: false,
@@ -22,10 +22,10 @@ export async function installAll({ verbose = false, silent = false, threads, loc
22
22
  if (lockFileJson && lockFileJson.version === 3) {
23
23
  verbose && console.log('Installing from lock file...');
24
24
  installedFromLockFile = true;
25
- let deps = Object.entries(lockFileJson.deps).map(([name, version]) => {
25
+ let lockedDeps = Object.entries(lockFileJson.deps).map(([name, version]) => {
26
26
  return parseDepValue(name, version);
27
27
  });
28
- let ok = await installDeps(deps, { silent, verbose, threads, ignoreTransitive: true });
28
+ let ok = await installDeps(lockedDeps, { silent, verbose, threads, ignoreTransitive: true });
29
29
  if (!ok) {
30
30
  return false;
31
31
  }
@@ -25,12 +25,12 @@ export declare class Replica {
25
25
  start({ type, dir, verbose, silent }?: StartOptions): Promise<void>;
26
26
  _attachCanisterLogHandler(proc: ChildProcessWithoutNullStreams): void;
27
27
  stop(sigint?: boolean): Promise<void>;
28
- deploy(name: string, wasm: string, idlFactory: IDL.InterfaceFactory, cwd?: string): Promise<{
28
+ deploy(name: string, wasm: string, idlFactory: IDL.InterfaceFactory, cwd?: string, signal?: AbortSignal): Promise<{
29
29
  cwd: string;
30
30
  canisterId: string;
31
31
  actor: any;
32
32
  stream: PassThrough;
33
- }>;
33
+ } | undefined>;
34
34
  getActor(name: string): unknown;
35
35
  getCanister(name: string): {
36
36
  cwd: string;
@@ -3,6 +3,7 @@ import { execSync, spawn } from 'node:child_process';
3
3
  import path from 'node:path';
4
4
  import fs from 'node:fs';
5
5
  import { PassThrough } from 'node:stream';
6
+ import { spawn as spawnAsync } from 'promisify-child-process';
6
7
  import { Actor, HttpAgent } from '@dfinity/agent';
7
8
  import { PocketIc, PocketIcServer } from 'pic-ic';
8
9
  import { readConfig } from '../mops.js';
@@ -97,7 +98,7 @@ export class Replica {
97
98
  await this.pocketIcServer.stop();
98
99
  }
99
100
  }
100
- async deploy(name, wasm, idlFactory, cwd = process.cwd()) {
101
+ async deploy(name, wasm, idlFactory, cwd = process.cwd(), signal) {
101
102
  if (this.type === 'dfx') {
102
103
  // prepare dfx.json for current canister
103
104
  let dfxJson = path.join(this.dir, 'dfx.json');
@@ -111,8 +112,24 @@ export class Replica {
111
112
  }
112
113
  fs.mkdirSync(this.dir, { recursive: true });
113
114
  fs.writeFileSync(dfxJson, JSON.stringify(newDfxJsonData, null, 2));
114
- execSync(`dfx deploy ${name} --mode reinstall --yes --identity anonymous`, { cwd: this.dir, stdio: this.verbose ? 'pipe' : ['pipe', 'ignore', 'pipe'] });
115
- execSync(`dfx ledger fabricate-cycles --canister ${name} --t 100`, { cwd: this.dir, stdio: this.verbose ? 'pipe' : ['pipe', 'ignore', 'pipe'] });
115
+ await spawnAsync('dfx', ['deploy', name, '--mode', 'reinstall', '--yes', '--identity', 'anonymous'], { cwd: this.dir, signal, stdio: this.verbose ? 'pipe' : ['pipe', 'ignore', 'pipe'] }).catch((error) => {
116
+ if (error.code === 'ABORT_ERR') {
117
+ return { stderr: '' };
118
+ }
119
+ throw error;
120
+ });
121
+ if (signal?.aborted) {
122
+ return;
123
+ }
124
+ await spawnAsync('dfx', ['ledger', 'fabricate-cycles', '--canister', name, '--t', '100'], { cwd: this.dir, signal, stdio: this.verbose ? 'pipe' : ['pipe', 'ignore', 'pipe'] }).catch((error) => {
125
+ if (error.code === 'ABORT_ERR') {
126
+ return { stderr: '' };
127
+ }
128
+ throw error;
129
+ });
130
+ if (signal?.aborted) {
131
+ return;
132
+ }
116
133
  let canisterId = execSync(`dfx canister id ${name}`, { cwd: this.dir }).toString().trim();
117
134
  let actor = Actor.createActor(idlFactory, {
118
135
  agent: await HttpAgent.create({
@@ -134,7 +151,13 @@ export class Replica {
134
151
  idlFactory,
135
152
  wasm,
136
153
  });
154
+ if (signal?.aborted) {
155
+ return;
156
+ }
137
157
  await this.pocketIc.addCycles(canisterId, 1_000_000_000_000);
158
+ if (signal?.aborted) {
159
+ return;
160
+ }
138
161
  this.canisters[name] = {
139
162
  cwd,
140
163
  canisterId: canisterId.toText(),
@@ -1,4 +1,4 @@
1
1
  export declare function sources({ conflicts, cwd }?: {
2
2
  conflicts?: "ignore" | "error" | "warning" | undefined;
3
3
  cwd?: string | undefined;
4
- }): Promise<(string | undefined)[]>;
4
+ }): Promise<string[]>;
@@ -38,5 +38,5 @@ export async function sources({ conflicts = 'ignore', cwd = process.cwd() } = {}
38
38
  pkgBaseDir = pkgDir;
39
39
  }
40
40
  return `--package ${name} ${pkgBaseDir}`;
41
- });
41
+ }).filter(x => x != null);
42
42
  }
@@ -1,4 +1,3 @@
1
- import process from 'node:process';
2
1
  import path from 'node:path';
3
2
  import { execSync } from 'node:child_process';
4
3
  import { globSync } from 'glob';
@@ -7,6 +6,7 @@ import { checkConfigFile, getRootDir, readConfig } from '../mops.js';
7
6
  import { add } from './add.js';
8
7
  import { remove } from './remove.js';
9
8
  import { checkIntegrity } from '../integrity.js';
9
+ import { getMocPath } from '../helpers/get-moc-path.js';
10
10
  export async function sync({ lock } = {}) {
11
11
  if (!checkConfigFile()) {
12
12
  return;
@@ -35,24 +35,9 @@ let ignore = [
35
35
  '**/.git/**',
36
36
  '**/.mops/**',
37
37
  ];
38
- let mocPath = '';
39
- function getMocPath() {
40
- if (!mocPath) {
41
- mocPath = process.env.DFX_MOC_PATH || '';
42
- }
43
- if (!mocPath) {
44
- try {
45
- mocPath = execSync('dfx cache show').toString().trim() + '/moc';
46
- }
47
- catch { }
48
- }
49
- if (!mocPath) {
50
- mocPath = 'moc';
51
- }
52
- return mocPath;
53
- }
54
38
  async function getUsedPackages() {
55
39
  let rootDir = getRootDir();
40
+ let mocPath = getMocPath();
56
41
  let files = globSync('**/*.mo', {
57
42
  cwd: rootDir,
58
43
  nocase: true,
@@ -60,7 +45,7 @@ async function getUsedPackages() {
60
45
  });
61
46
  let packages = new Set;
62
47
  for (let file of files) {
63
- let deps = execSync(`${getMocPath()} --print-deps ${path.join(rootDir, file)}`).toString().trim().split('\n');
48
+ let deps = execSync(`${mocPath} --print-deps ${path.join(rootDir, file)}`).toString().trim().split('\n');
64
49
  for (let dep of deps) {
65
50
  if (dep.startsWith('mo:') && !dep.startsWith('mo:prim') && !dep.startsWith('mo:⛔')) {
66
51
  packages.add(dep.replace(/^mo:([^/]+).*$/, '$1'));
@@ -18,6 +18,7 @@ export declare class MMF1 {
18
18
  constructor(strategy: Strategy, file: string);
19
19
  _log(type: MessageType, ...args: string[]): void;
20
20
  flush(messageType?: MessageType): void;
21
+ getErrorMessages(): string[];
21
22
  parseLine(line: string): void;
22
23
  _testStart(name: string): void;
23
24
  _testEnd(name: string): void;
@@ -39,6 +39,9 @@ export class MMF1 {
39
39
  }
40
40
  this.output = [];
41
41
  }
42
+ getErrorMessages() {
43
+ return this.output.filter(out => out.type === 'fail').map(out => out.message);
44
+ }
42
45
  parseLine(line) {
43
46
  if (line.startsWith('mops:1:start ')) {
44
47
  this._testStart(line.split('mops:1:start ')[1] || '');
@@ -2,13 +2,18 @@ import { MMF1 } from '../mmf1.js';
2
2
  import { Reporter } from './reporter.js';
3
3
  import { TestMode } from '../../../types.js';
4
4
  export declare class SilentReporter implements Reporter {
5
+ total: number;
5
6
  passed: number;
6
7
  failed: number;
7
8
  skipped: number;
8
9
  passedFiles: number;
9
10
  failedFiles: number;
10
11
  passedNamesFlat: string[];
11
- addFiles(_files: string[]): void;
12
+ flushOnError: boolean;
13
+ errorOutput: string;
14
+ onProgress: () => void;
15
+ constructor(flushOnError?: boolean, onProgress?: () => void);
16
+ addFiles(files: string[]): void;
12
17
  addRun(file: string, mmf: MMF1, state: Promise<void>, _mode: TestMode): void;
13
18
  done(): boolean;
14
19
  }
@@ -1,15 +1,23 @@
1
1
  import chalk from 'chalk';
2
2
  import { absToRel } from '../utils.js';
3
3
  export class SilentReporter {
4
- constructor() {
4
+ constructor(flushOnError = true, onProgress = () => { }) {
5
+ this.total = 0;
5
6
  this.passed = 0;
6
7
  this.failed = 0;
7
8
  this.skipped = 0;
8
9
  this.passedFiles = 0;
9
10
  this.failedFiles = 0;
10
11
  this.passedNamesFlat = [];
12
+ this.flushOnError = true;
13
+ this.errorOutput = '';
14
+ this.onProgress = () => { };
15
+ this.flushOnError = flushOnError;
16
+ this.onProgress = onProgress;
17
+ }
18
+ addFiles(files) {
19
+ this.total = files.length;
11
20
  }
12
- addFiles(_files) { }
13
21
  addRun(file, mmf, state, _mode) {
14
22
  state.then(() => {
15
23
  this.passed += mmf.passed;
@@ -23,10 +31,15 @@ export class SilentReporter {
23
31
  this.passedFiles += Number(mmf.failed === 0);
24
32
  this.failedFiles += Number(mmf.failed !== 0);
25
33
  if (mmf.failed) {
26
- console.log(chalk.red('✖'), absToRel(file));
27
- mmf.flush('fail');
28
- console.log('-'.repeat(50));
34
+ let output = `${chalk.red('✖')} ${absToRel(file)}\n${mmf.getErrorMessages().join('\n')}\n${'-'.repeat(50)}`;
35
+ if (this.flushOnError) {
36
+ console.log(output);
37
+ }
38
+ else {
39
+ this.errorOutput = `${this.errorOutput}\n${output}`.trim();
40
+ }
29
41
  }
42
+ this.onProgress();
30
43
  });
31
44
  }
32
45
  done() {
@@ -9,5 +9,5 @@ type TestOptions = {
9
9
  replica: ReplicaName;
10
10
  };
11
11
  export declare function test(filter?: string, options?: Partial<TestOptions>): Promise<void>;
12
- export declare function testWithReporter(reporterName: ReporterName | Reporter | undefined, filter: string | undefined, defaultMode: TestMode | undefined, replicaType: ReplicaName, watch?: boolean): Promise<boolean>;
12
+ export declare function testWithReporter(reporterName: ReporterName | Reporter | undefined, filter: string | undefined, defaultMode: TestMode | undefined, replicaType: ReplicaName, watch?: boolean, signal?: AbortSignal): Promise<boolean>;
13
13
  export {};