ic-mops 1.8.0 → 1.9.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 (47) hide show
  1. package/.DS_Store +0 -0
  2. package/.dockerignore +3 -0
  3. package/CHANGELOG.md +7 -0
  4. package/bun.lock +1278 -0
  5. package/bundle/bench/bench-canister.mo +109 -101
  6. package/bundle/bench/user-bench.mo +6 -6
  7. package/bundle/cli.js +1793 -909
  8. package/bundle/cli.tgz +0 -0
  9. package/bundle/declarations/main/main.did +6 -0
  10. package/bundle/declarations/main/main.did.d.ts +6 -0
  11. package/bundle/declarations/main/main.did.js +6 -0
  12. package/bundle/package.json +1 -1
  13. package/bundle/templates/src/lib.mo +13 -13
  14. package/bundle/templates/test/lib.test.mo +2 -2
  15. package/bundle/xhr-sync-worker.js +59 -0
  16. package/cli.ts +28 -0
  17. package/commands/docs-coverage.ts +110 -0
  18. package/commands/docs.ts +47 -20
  19. package/commands/publish.ts +12 -1
  20. package/declarations/main/main.did +6 -0
  21. package/declarations/main/main.did.d.ts +6 -0
  22. package/declarations/main/main.did.js +6 -0
  23. package/dist/cli.js +25 -0
  24. package/dist/commands/bench-replica.js +5 -2
  25. package/dist/commands/docs-coverage.d.ts +8 -0
  26. package/dist/commands/docs-coverage.js +86 -0
  27. package/dist/commands/docs.d.ts +9 -3
  28. package/dist/commands/docs.js +34 -17
  29. package/dist/commands/publish.js +11 -1
  30. package/dist/commands/replica.js +8 -7
  31. package/dist/commands/test/mmf1.js +14 -12
  32. package/dist/commands/test/reporters/compact-reporter.js +50 -63
  33. package/dist/commands/test/reporters/files-reporter.js +5 -14
  34. package/dist/commands/test/reporters/silent-reporter.js +10 -10
  35. package/dist/commands/test/reporters/verbose-reporter.js +7 -23
  36. package/dist/commands/watch/deployer.js +10 -7
  37. package/dist/commands/watch/error-checker.js +4 -4
  38. package/dist/commands/watch/formatter.js +7 -4
  39. package/dist/commands/watch/generator.js +9 -7
  40. package/dist/commands/watch/tester.js +7 -5
  41. package/dist/commands/watch/warning-checker.js +8 -6
  42. package/dist/declarations/main/main.did +6 -0
  43. package/dist/declarations/main/main.did.d.ts +6 -0
  44. package/dist/declarations/main/main.did.js +6 -0
  45. package/dist/package.json +13 -11
  46. package/package.json +15 -13
  47. package/tsconfig.json +2 -1
package/dist/cli.js CHANGED
@@ -28,6 +28,8 @@ import { watch } from './commands/watch/watch.js';
28
28
  import { addOwner, printOwners, removeOwner } from './commands/owner.js';
29
29
  import { addMaintainer, printMaintainers, removeMaintainer } from './commands/maintainer.js';
30
30
  import { format } from './commands/format.js';
31
+ import { docs } from './commands/docs.js';
32
+ import { docsCoverage } from './commands/docs-coverage.js';
31
33
  events.setMaxListeners(20);
32
34
  let networkFile = getNetworkFile();
33
35
  if (fs.existsSync(networkFile)) {
@@ -426,4 +428,27 @@ program
426
428
  process.exit(1);
427
429
  }
428
430
  });
431
+ // docs
432
+ const docsCommand = new Command('docs').description('Documentation management');
433
+ docsCommand
434
+ .command('generate')
435
+ .description('Generate documentation for Motoko code')
436
+ .addOption(new Option('--source <source>', 'Source directory').default('src'))
437
+ .addOption(new Option('--output <output>', 'Output directory').default('docs'))
438
+ .addOption(new Option('--format <format>', 'Output format').default('md').choices(['md', 'adoc', 'html']))
439
+ .action(async (options) => {
440
+ checkConfigFile(true);
441
+ await docs(options);
442
+ });
443
+ docsCommand
444
+ .command('coverage')
445
+ .description('Documentation coverage report')
446
+ .addOption(new Option('-s, --source <source>', 'Source directory (with .mo files)').default('src'))
447
+ .addOption(new Option('-r, --reporter <reporter>', 'Coverage reporter').choices(['files', 'compact', 'missing', 'verbose']).default('files'))
448
+ .addOption(new Option('-t, --threshold <threshold>', 'Coverage threshold (0-100). If total coverage is below threshold, exit with error code 1').default(70))
449
+ .action(async (options) => {
450
+ checkConfigFile(true);
451
+ await docsCoverage(options);
452
+ });
453
+ program.addCommand(docsCommand);
429
454
  program.parse();
@@ -9,9 +9,12 @@ import { createActor, idlFactory } from '../declarations/bench/index.js';
9
9
  import { toolchain } from './toolchain/index.js';
10
10
  import { getDfxVersion } from '../helpers/get-dfx-version.js';
11
11
  export class BenchReplica {
12
+ type;
13
+ verbose = false;
14
+ canisters = {};
15
+ pocketIcServer;
16
+ pocketIc;
12
17
  constructor(type, verbose = false) {
13
- this.verbose = false;
14
- this.canisters = {};
15
18
  this.type = type;
16
19
  this.verbose = verbose;
17
20
  }
@@ -0,0 +1,8 @@
1
+ export type DocsCoverageReporter = 'compact' | 'files' | 'missing' | 'verbose' | 'silent';
2
+ type DocsCoverageOptions = {
3
+ source: string;
4
+ reporter: DocsCoverageReporter;
5
+ threshold: number;
6
+ };
7
+ export declare function docsCoverage(options?: Partial<DocsCoverageOptions>): Promise<number>;
8
+ export {};
@@ -0,0 +1,86 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import chalk from 'chalk';
3
+ import { globSync } from 'glob';
4
+ import { JSDOM } from 'jsdom';
5
+ import { docs } from './docs.js';
6
+ export async function docsCoverage(options = {}) {
7
+ let docsDir = '.mops/.docs';
8
+ let { source, reporter, threshold } = {
9
+ source: 'src',
10
+ reporter: 'files',
11
+ threshold: 0,
12
+ ...options,
13
+ };
14
+ await docs({
15
+ source,
16
+ output: docsDir,
17
+ format: 'html',
18
+ silent: true,
19
+ });
20
+ let files = globSync(`${docsDir}/**/*.html`, { ignore: [`${docsDir}/**/index.html`] });
21
+ let coverages = [];
22
+ for (let file of files) {
23
+ let coverage = docFileCoverage(file);
24
+ coverages.push(coverage);
25
+ if (reporter === 'silent') {
26
+ continue;
27
+ }
28
+ if (reporter !== 'compact' && (reporter !== 'missing' || coverage.coverage < 100)) {
29
+ console.log(`• ${coverage.file} ${colorizeCoverage(coverage.coverage)}`);
30
+ }
31
+ if (reporter === 'missing' && coverage.coverage < 100) {
32
+ for (let item of coverage.items) {
33
+ if (!item.covered) {
34
+ console.log(` ${item.covered ? chalk.green('✓') : chalk.red('✖')} ${item.id} ${chalk.gray(item.type)}`);
35
+ }
36
+ }
37
+ }
38
+ else if (reporter === 'verbose') {
39
+ for (let item of coverage.items) {
40
+ console.log(` ${item.covered ? chalk.green('✓') : chalk.red('✖')} ${item.id} ${chalk.gray(item.type)}`);
41
+ }
42
+ }
43
+ }
44
+ if (reporter !== 'compact' && reporter !== 'silent') {
45
+ console.log('-'.repeat(50));
46
+ }
47
+ let totalCoverage = coverages.reduce((acc, coverage) => acc + coverage.coverage, 0) / (coverages.length || 1);
48
+ if (reporter !== 'silent') {
49
+ console.log(`Documentation coverage: ${colorizeCoverage(totalCoverage)}`);
50
+ }
51
+ if (threshold > 0 && totalCoverage < threshold) {
52
+ process.exit(1);
53
+ }
54
+ return totalCoverage;
55
+ }
56
+ function docFileCoverage(file) {
57
+ let dom = new JSDOM(readFileSync(file, 'utf-8'));
58
+ let module = dom.window.document.querySelector('h1')?.textContent || '';
59
+ let moduleFile = `${module}.mo`;
60
+ let items = [...dom.window.document.querySelectorAll('h4')].map(h4 => {
61
+ let id = h4.getAttribute('id')?.replace('type.', '');
62
+ let type = h4.className.replace('-declaration', '').replace('function', 'func');
63
+ let definition = h4.textContent;
64
+ let comment = h4.parentElement?.querySelector('p + p')?.textContent;
65
+ return { file: moduleFile, id, type, definition, comment, covered: (comment || '').length >= 5 };
66
+ });
67
+ let coverage = 0;
68
+ if (!items.length) {
69
+ coverage = 100;
70
+ }
71
+ else {
72
+ coverage = items.filter(item => item.covered).length / items.length * 100;
73
+ }
74
+ return { file: moduleFile, coverage, items };
75
+ }
76
+ function colorizeCoverage(coverage) {
77
+ if (coverage >= 90) {
78
+ return chalk.green(coverage.toFixed(2) + '%');
79
+ }
80
+ else if (coverage >= 50) {
81
+ return chalk.yellow(coverage.toFixed(2) + '%');
82
+ }
83
+ else {
84
+ return chalk.red(coverage.toFixed(2) + '%');
85
+ }
86
+ }
@@ -1,3 +1,9 @@
1
- export declare function docs({ silent }?: {
2
- silent?: boolean | undefined;
3
- }): Promise<void>;
1
+ type DocsOptions = {
2
+ source: string;
3
+ output: string;
4
+ format: 'md' | 'adoc' | 'html';
5
+ silent: boolean;
6
+ archive: boolean;
7
+ };
8
+ export declare function docs(options?: Partial<DocsOptions>): Promise<void>;
9
+ export {};
@@ -10,9 +10,20 @@ import streamToPromise from 'stream-to-promise';
10
10
  import { getRootDir } from '../mops.js';
11
11
  import { toolchain } from './toolchain/index.js';
12
12
  let moDocPath;
13
- export async function docs({ silent = false } = {}) {
13
+ export async function docs(options = {}) {
14
+ let { source, output, format, silent, archive } = {
15
+ source: 'src',
16
+ output: '.mops/.docs',
17
+ format: 'adoc',
18
+ silent: false,
19
+ archive: false,
20
+ ...options,
21
+ };
22
+ if (format === 'md') {
23
+ format = 'plain';
24
+ }
14
25
  let rootDir = getRootDir();
15
- let docsDir = path.join(rootDir, '.mops/.docs');
26
+ let docsDir = path.join(rootDir, output);
16
27
  let docsDirRelative = path.relative(process.cwd(), docsDir);
17
28
  deleteSync([docsDir], { force: true });
18
29
  // detect mocv (legacy)
@@ -26,13 +37,17 @@ export async function docs({ silent = false } = {}) {
26
37
  }
27
38
  // generate docs
28
39
  await new Promise((resolve) => {
29
- let proc = spawn(moDocPath, [`--source=${path.join(rootDir, 'src')}`, `--output=${docsDirRelative}`, '--format=adoc']);
40
+ let proc = spawn(moDocPath, [
41
+ `--source=${path.join(rootDir, source)}`,
42
+ `--output=${docsDirRelative}`,
43
+ `--format=${format}`,
44
+ ]);
30
45
  // stdout
31
46
  proc.stdout.on('data', (data) => {
32
47
  let text = data.toString().trim();
33
48
  let failedText = 'Failed to extract documentation';
34
49
  if (text.includes(failedText)) {
35
- console.log(text.replaceAll(failedText, chalk.yellow('Warning: ') + failedText));
50
+ silent || console.log(text.replaceAll(failedText, chalk.yellow('Warning: ') + failedText));
36
51
  }
37
52
  silent || console.log('stdout', text);
38
53
  });
@@ -65,19 +80,21 @@ export async function docs({ silent = false } = {}) {
65
80
  });
66
81
  });
67
82
  // create archive
68
- let ignore = [
69
- `${docsDir}/**/*.test.adoc`,
70
- `${docsDir}/test/**/*`,
71
- ];
72
- let files = globSync(`${docsDir}/**/*.adoc`, { ignore }).map(f => path.relative(docsDir, f));
73
- files.sort();
74
- if (files.length) {
75
- let stream = createTar({
76
- cwd: docsDir,
77
- gzip: true,
78
- portable: true,
79
- }, files).pipe(fs.createWriteStream(path.join(docsDir, 'docs.tgz')));
80
- await streamToPromise(stream);
83
+ if (archive) {
84
+ let ignore = [
85
+ `${docsDir}/**/*.test.adoc`,
86
+ `${docsDir}/test/**/*`,
87
+ ];
88
+ let files = globSync(`${docsDir}/**/*.adoc`, { ignore }).map(f => path.relative(docsDir, f));
89
+ files.sort();
90
+ if (files.length) {
91
+ let stream = createTar({
92
+ cwd: docsDir,
93
+ gzip: true,
94
+ portable: true,
95
+ }, files).pipe(fs.createWriteStream(path.join(docsDir, 'docs.tgz')));
96
+ await streamToPromise(stream);
97
+ }
81
98
  }
82
99
  silent || console.log(`${chalk.green('Documentation generated')} at ${docsDirRelative}`);
83
100
  }
@@ -14,6 +14,7 @@ import { testWithReporter } from './test/test.js';
14
14
  import { SilentReporter } from './test/reporters/silent-reporter.js';
15
15
  import { findChangelogEntry } from '../helpers/find-changelog-entry.js';
16
16
  import { bench } from './bench.js';
17
+ import { docsCoverage } from './docs-coverage.js';
17
18
  export async function publish(options = {}) {
18
19
  if (!checkConfigFile()) {
19
20
  return;
@@ -194,6 +195,7 @@ export async function publish(options = {}) {
194
195
  '!benchmark/**',
195
196
  '!**/*.bench.mo',
196
197
  '!**/*.Bench.mo',
198
+ '!**/node_modules/**',
197
199
  ];
198
200
  let files = config.package.files || ['**/*.mo'];
199
201
  files = [...files, ...defaultFiles];
@@ -204,9 +206,13 @@ export async function publish(options = {}) {
204
206
  }
205
207
  // generate docs
206
208
  let docsFile = path.join(rootDir, '.mops/.docs/docs.tgz');
209
+ let docsCov = 0;
207
210
  if (options.docs) {
208
211
  console.log('Generating documentation...');
209
- await docs({ silent: true });
212
+ docsCov = await docsCoverage({
213
+ reporter: 'silent',
214
+ });
215
+ await docs({ silent: true, archive: true });
210
216
  if (fs.existsSync(docsFile)) {
211
217
  files.unshift(docsFile);
212
218
  }
@@ -298,6 +304,10 @@ export async function publish(options = {}) {
298
304
  if (changelog) {
299
305
  await actor.uploadNotes(puiblishingId, changelog);
300
306
  }
307
+ // upload docs coverage
308
+ if (options.docs) {
309
+ await actor.uploadDocsCoverage(puiblishingId, docsCov);
310
+ }
301
311
  // upload files
302
312
  await parallel(8, files, async (file) => {
303
313
  progress();
@@ -11,13 +11,14 @@ import { readConfig } from '../mops.js';
11
11
  import { toolchain } from './toolchain/index.js';
12
12
  import { getDfxVersion } from '../helpers/get-dfx-version.js';
13
13
  export class Replica {
14
- constructor() {
15
- this.type = 'dfx';
16
- this.verbose = false;
17
- this.canisters = {};
18
- this.dir = ''; // absolute path (/.../.mops/.test/)
19
- this.ttl = 60;
20
- }
14
+ type = 'dfx';
15
+ verbose = false;
16
+ canisters = {};
17
+ pocketIcServer;
18
+ pocketIc;
19
+ dfxProcess;
20
+ dir = ''; // absolute path (/.../.mops/.test/)
21
+ ttl = 60;
21
22
  async start({ type, dir, verbose, silent } = {}) {
22
23
  this.type = type ?? this.type;
23
24
  this.verbose = verbose ?? this.verbose;
@@ -4,19 +4,21 @@
4
4
  // mops:1:skip
5
5
  import chalk from 'chalk';
6
6
  export class MMF1 {
7
+ file;
8
+ stack = [];
9
+ currSuite = '';
10
+ failed = 0;
11
+ passed = 0;
12
+ skipped = 0;
13
+ strategy;
14
+ output = [];
15
+ nestingSymbol = ' › ';
16
+ // or <file>
17
+ // or <file> › <test>
18
+ // or <file> › <suite> › <test>
19
+ // or <file> › <suite> › <test> › <nested-test>...
20
+ passedNamesFlat = [];
7
21
  constructor(strategy, file) {
8
- this.stack = [];
9
- this.currSuite = '';
10
- this.failed = 0;
11
- this.passed = 0;
12
- this.skipped = 0;
13
- this.output = [];
14
- this.nestingSymbol = ' › ';
15
- // or <file>
16
- // or <file> › <test>
17
- // or <file> › <suite> › <test>
18
- // or <file> › <suite> › <test> › <nested-test>...
19
- this.passedNamesFlat = [];
20
22
  this.strategy = strategy;
21
23
  this.file = file;
22
24
  }
@@ -1,41 +1,25 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _CompactReporter_instances, _CompactReporter_allFiles, _CompactReporter_runningFiles, _CompactReporter_failedFiles, _CompactReporter_finishedFiles, _CompactReporter_startTime, _CompactReporter_timerId, _CompactReporter_startTimer, _CompactReporter_clearTimer, _CompactReporter_log;
13
1
  import chalk from 'chalk';
14
2
  import logUpdate from 'log-update';
15
3
  import { absToRel } from '../utils.js';
16
4
  export class CompactReporter {
17
- constructor() {
18
- _CompactReporter_instances.add(this);
19
- this.passed = 0;
20
- this.failed = 0;
21
- this.skipped = 0;
22
- this.passedFiles = 0;
23
- this.failedFiles = 0;
24
- _CompactReporter_allFiles.set(this, new Set());
25
- _CompactReporter_runningFiles.set(this, new Set());
26
- _CompactReporter_failedFiles.set(this, new Set());
27
- _CompactReporter_finishedFiles.set(this, new Set());
28
- _CompactReporter_startTime.set(this, Date.now());
29
- _CompactReporter_timerId.set(this, null);
30
- }
5
+ passed = 0;
6
+ failed = 0;
7
+ skipped = 0;
8
+ passedFiles = 0;
9
+ failedFiles = 0;
10
+ #allFiles = new Set();
11
+ #runningFiles = new Set();
12
+ #failedFiles = new Set();
13
+ #finishedFiles = new Set();
14
+ #startTime = Date.now();
31
15
  addFiles(files) {
32
- __classPrivateFieldSet(this, _CompactReporter_allFiles, new Set(files), "f");
33
- __classPrivateFieldGet(this, _CompactReporter_instances, "m", _CompactReporter_log).call(this);
34
- __classPrivateFieldGet(this, _CompactReporter_instances, "m", _CompactReporter_startTimer).call(this);
16
+ this.#allFiles = new Set(files);
17
+ this.#log();
18
+ this.#startTimer();
35
19
  }
36
20
  addRun(file, mmf, state, _mode) {
37
- __classPrivateFieldGet(this, _CompactReporter_runningFiles, "f").add(file);
38
- __classPrivateFieldGet(this, _CompactReporter_instances, "m", _CompactReporter_log).call(this);
21
+ this.#runningFiles.add(file);
22
+ this.#log();
39
23
  state.then(() => {
40
24
  this.passed += mmf.passed;
41
25
  this.failed += mmf.failed;
@@ -46,50 +30,53 @@ export class CompactReporter {
46
30
  this.passedFiles += Number(mmf.failed === 0);
47
31
  this.failedFiles += Number(mmf.failed !== 0);
48
32
  if (mmf.failed) {
49
- __classPrivateFieldGet(this, _CompactReporter_failedFiles, "f").add(file);
33
+ this.#failedFiles.add(file);
50
34
  logUpdate.clear();
51
35
  console.log(chalk.red('✖'), absToRel(file));
52
36
  mmf.flush('fail');
53
37
  console.log('-'.repeat(50));
54
38
  }
55
- __classPrivateFieldGet(this, _CompactReporter_runningFiles, "f").delete(file);
56
- __classPrivateFieldGet(this, _CompactReporter_finishedFiles, "f").add(file);
57
- __classPrivateFieldGet(this, _CompactReporter_instances, "m", _CompactReporter_log).call(this);
39
+ this.#runningFiles.delete(file);
40
+ this.#finishedFiles.add(file);
41
+ this.#log();
58
42
  });
59
43
  }
60
44
  done() {
61
- __classPrivateFieldGet(this, _CompactReporter_instances, "m", _CompactReporter_log).call(this);
45
+ this.#log();
62
46
  logUpdate.done();
63
- __classPrivateFieldGet(this, _CompactReporter_instances, "m", _CompactReporter_clearTimer).call(this);
47
+ this.#clearTimer();
64
48
  return this.failed === 0;
65
49
  }
66
- }
67
- _CompactReporter_allFiles = new WeakMap(), _CompactReporter_runningFiles = new WeakMap(), _CompactReporter_failedFiles = new WeakMap(), _CompactReporter_finishedFiles = new WeakMap(), _CompactReporter_startTime = new WeakMap(), _CompactReporter_timerId = new WeakMap(), _CompactReporter_instances = new WeakSet(), _CompactReporter_startTimer = function _CompactReporter_startTimer() {
68
- __classPrivateFieldSet(this, _CompactReporter_timerId, setInterval(() => __classPrivateFieldGet(this, _CompactReporter_instances, "m", _CompactReporter_log).call(this), 55), "f");
69
- }, _CompactReporter_clearTimer = function _CompactReporter_clearTimer() {
70
- if (__classPrivateFieldGet(this, _CompactReporter_timerId, "f")) {
71
- clearInterval(__classPrivateFieldGet(this, _CompactReporter_timerId, "f"));
50
+ #timerId = null;
51
+ #startTimer() {
52
+ this.#timerId = setInterval(() => this.#log(), 55);
72
53
  }
73
- }, _CompactReporter_log = function _CompactReporter_log() {
74
- let res = [];
75
- let i = 0;
76
- for (let file of __classPrivateFieldGet(this, _CompactReporter_allFiles, "f")) {
77
- if (__classPrivateFieldGet(this, _CompactReporter_runningFiles, "f").has(file)) {
78
- res[Number(i)] = '.';
54
+ #clearTimer() {
55
+ if (this.#timerId) {
56
+ clearInterval(this.#timerId);
79
57
  }
80
- else if (__classPrivateFieldGet(this, _CompactReporter_finishedFiles, "f").has(file)) {
81
- res[Number(i)] = __classPrivateFieldGet(this, _CompactReporter_failedFiles, "f").has(file) ? chalk.red(':') : ':';
82
- }
83
- else {
84
- res[Number(i)] = ' ';
58
+ }
59
+ #log() {
60
+ let res = [];
61
+ let i = 0;
62
+ for (let file of this.#allFiles) {
63
+ if (this.#runningFiles.has(file)) {
64
+ res[Number(i)] = '.';
65
+ }
66
+ else if (this.#finishedFiles.has(file)) {
67
+ res[Number(i)] = this.#failedFiles.has(file) ? chalk.red(':') : ':';
68
+ }
69
+ else {
70
+ res[Number(i)] = ' ';
71
+ }
72
+ i++;
85
73
  }
86
- i++;
74
+ let output = `[${res.join('')}]\n`
75
+ + `${chalk.gray(((Date.now() - this.#startTime) / 1000).toFixed(2) + 's')}`
76
+ + `, total ${this.#allFiles.size} files`
77
+ + `, passed ${chalk.greenBright(this.passedFiles)} files`
78
+ + (this.skipped ? `, skipped ${chalk[this.skipped ? 'yellowBright' : 'gray'](this.skipped)} cases` : '')
79
+ + (this.failed ? `, failed ${chalk[this.failed ? 'redBright' : 'gray'](this.failed)} cases` : '');
80
+ logUpdate(output);
87
81
  }
88
- let output = `[${res.join('')}]\n`
89
- + `${chalk.gray(((Date.now() - __classPrivateFieldGet(this, _CompactReporter_startTime, "f")) / 1000).toFixed(2) + 's')}`
90
- + `, total ${__classPrivateFieldGet(this, _CompactReporter_allFiles, "f").size} files`
91
- + `, passed ${chalk.greenBright(this.passedFiles)} files`
92
- + (this.skipped ? `, skipped ${chalk[this.skipped ? 'yellowBright' : 'gray'](this.skipped)} cases` : '')
93
- + (this.failed ? `, failed ${chalk[this.failed ? 'redBright' : 'gray'](this.failed)} cases` : '');
94
- logUpdate(output);
95
- };
82
+ }
@@ -1,18 +1,10 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var _FilesReporter_startTime;
7
1
  import chalk from 'chalk';
8
2
  import { absToRel } from '../utils.js';
9
3
  export class FilesReporter {
10
- constructor() {
11
- this.passed = 0;
12
- this.failed = 0;
13
- this.skipped = 0;
14
- _FilesReporter_startTime.set(this, Date.now());
15
- }
4
+ passed = 0;
5
+ failed = 0;
6
+ skipped = 0;
7
+ #startTime = Date.now();
16
8
  addFiles(files) {
17
9
  console.log(`Test files: ${files.length}`);
18
10
  console.log('='.repeat(50));
@@ -40,11 +32,10 @@ export class FilesReporter {
40
32
  else {
41
33
  console.log(chalk.greenBright('Tests passed'));
42
34
  }
43
- console.log(`Done in ${chalk.gray(((Date.now() - __classPrivateFieldGet(this, _FilesReporter_startTime, "f")) / 1000).toFixed(2) + 's')}`
35
+ console.log(`Done in ${chalk.gray(((Date.now() - this.#startTime) / 1000).toFixed(2) + 's')}`
44
36
  + `, passed ${chalk.greenBright(this.passed)} files`
45
37
  + (this.skipped ? `, skipped ${chalk[this.skipped ? 'yellowBright' : 'gray'](this.skipped)} cases` : '')
46
38
  + (this.failed ? `, failed ${chalk[this.failed ? 'redBright' : 'gray'](this.failed)} files` : ''));
47
39
  return this.failed === 0;
48
40
  }
49
41
  }
50
- _FilesReporter_startTime = new WeakMap();
@@ -1,17 +1,17 @@
1
1
  import chalk from 'chalk';
2
2
  import { absToRel } from '../utils.js';
3
3
  export class SilentReporter {
4
+ total = 0;
5
+ passed = 0;
6
+ failed = 0;
7
+ skipped = 0;
8
+ passedFiles = 0;
9
+ failedFiles = 0;
10
+ passedNamesFlat = [];
11
+ flushOnError = true;
12
+ errorOutput = '';
13
+ onProgress = () => { };
4
14
  constructor(flushOnError = true, onProgress = () => { }) {
5
- this.total = 0;
6
- this.passed = 0;
7
- this.failed = 0;
8
- this.skipped = 0;
9
- this.passedFiles = 0;
10
- this.failedFiles = 0;
11
- this.passedNamesFlat = [];
12
- this.flushOnError = true;
13
- this.errorOutput = '';
14
- this.onProgress = () => { };
15
15
  this.flushOnError = flushOnError;
16
16
  this.onProgress = onProgress;
17
17
  }
@@ -1,25 +1,11 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
- if (kind === "m") throw new TypeError("Private method is not writable");
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
- };
12
- var _VerboseReporter_startTime, _VerboseReporter_curFileIndex;
13
1
  import chalk from 'chalk';
14
2
  import { absToRel } from '../utils.js';
15
3
  export class VerboseReporter {
16
- constructor() {
17
- this.passed = 0;
18
- this.failed = 0;
19
- this.skipped = 0;
20
- _VerboseReporter_startTime.set(this, Date.now());
21
- _VerboseReporter_curFileIndex.set(this, 0);
22
- }
4
+ passed = 0;
5
+ failed = 0;
6
+ skipped = 0;
7
+ #startTime = Date.now();
8
+ #curFileIndex = 0;
23
9
  addFiles(files) {
24
10
  console.log('Test files:');
25
11
  for (let file of files) {
@@ -52,16 +38,14 @@ export class VerboseReporter {
52
38
  else {
53
39
  console.log(chalk.greenBright('Tests passed'));
54
40
  }
55
- console.log(`Done in ${chalk.gray(((Date.now() - __classPrivateFieldGet(this, _VerboseReporter_startTime, "f")) / 1000).toFixed(2) + 's')}`
41
+ console.log(`Done in ${chalk.gray(((Date.now() - this.#startTime) / 1000).toFixed(2) + 's')}`
56
42
  + `, passed ${chalk.greenBright(this.passed)}`
57
43
  + (this.skipped ? `, skipped ${chalk[this.skipped ? 'yellowBright' : 'gray'](this.skipped)}` : '')
58
44
  + (this.failed ? `, failed ${chalk[this.failed ? 'redBright' : 'gray'](this.failed)}` : ''));
59
45
  return this.failed === 0;
60
46
  }
61
47
  _printStart(file, mode) {
62
- var _a, _b;
63
- (__classPrivateFieldSet(this, _VerboseReporter_curFileIndex, (_b = __classPrivateFieldGet(this, _VerboseReporter_curFileIndex, "f"), _a = _b++, _b), "f"), _a) && console.log('-'.repeat(50));
48
+ this.#curFileIndex++ && console.log('-'.repeat(50));
64
49
  console.log(`Running ${chalk.gray(absToRel(file))} ${mode === 'interpreter' ? '' : chalk.gray(`(${mode})`)}`);
65
50
  }
66
51
  }
67
- _VerboseReporter_startTime = new WeakMap(), _VerboseReporter_curFileIndex = new WeakMap();
@@ -5,14 +5,17 @@ import { execFile, execSync } from 'node:child_process';
5
5
  import { parallel } from '../../parallel.js';
6
6
  import { getRootDir } from '../../mops.js';
7
7
  export class Deployer {
8
+ verbose = false;
9
+ canisters = {};
10
+ status = 'pending';
11
+ errorChecker;
12
+ generator;
13
+ success = 0;
14
+ errors = [];
15
+ aborted = false;
16
+ controllers = new Map();
17
+ currentRun;
8
18
  constructor({ verbose, canisters, errorChecker, generator }) {
9
- this.verbose = false;
10
- this.canisters = {};
11
- this.status = 'pending';
12
- this.success = 0;
13
- this.errors = [];
14
- this.aborted = false;
15
- this.controllers = new Map();
16
19
  this.verbose = verbose;
17
20
  this.canisters = canisters;
18
21
  this.errorChecker = errorChecker;
@@ -8,11 +8,11 @@ import { sources } from '../sources.js';
8
8
  import { parallel } from '../../parallel.js';
9
9
  import { globMoFiles } from './globMoFiles.js';
10
10
  export class ErrorChecker {
11
+ verbose = false;
12
+ canisters = {};
13
+ status = 'pending';
14
+ errors = [];
11
15
  constructor({ verbose, canisters }) {
12
- this.verbose = false;
13
- this.canisters = {};
14
- this.status = 'pending';
15
- this.errors = [];
16
16
  this.verbose = verbose;
17
17
  this.canisters = canisters;
18
18
  }