ic-mops 1.1.0-pre.0 → 1.1.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/bundle/cli.tgz +0 -0
- package/check-requirements.ts +1 -1
- package/cli.ts +18 -0
- package/commands/bench.ts +1 -1
- package/commands/install/install-all.ts +2 -2
- package/commands/replica.ts +33 -3
- package/commands/sources.ts +1 -1
- package/commands/sync.ts +4 -19
- package/commands/test/mmf1.ts +4 -0
- package/commands/test/reporters/silent-reporter.ts +22 -4
- package/commands/test/test.ts +74 -10
- package/commands/watch/deployer.ts +155 -0
- package/commands/watch/error-checker.ts +87 -0
- package/commands/watch/generator.ts +99 -0
- package/commands/watch/globMoFiles.ts +16 -0
- package/commands/watch/parseDfxJson.ts +64 -0
- package/commands/watch/tester.ts +81 -0
- package/commands/watch/warning-checker.ts +133 -0
- package/commands/watch/watch.ts +90 -0
- package/declarations/main/main.did +16 -10
- package/declarations/main/main.did.d.ts +19 -10
- package/declarations/main/main.did.js +25 -11
- package/dist/check-requirements.js +1 -1
- package/dist/cli.js +16 -0
- package/dist/commands/bench.js +1 -1
- package/dist/commands/install/install-all.js +2 -2
- package/dist/commands/replica.d.ts +2 -2
- package/dist/commands/replica.js +26 -3
- package/dist/commands/sources.d.ts +1 -1
- package/dist/commands/sources.js +1 -1
- package/dist/commands/sync.js +3 -18
- package/dist/commands/test/mmf1.d.ts +1 -0
- package/dist/commands/test/mmf1.js +3 -0
- package/dist/commands/test/reporters/silent-reporter.d.ts +6 -1
- package/dist/commands/test/reporters/silent-reporter.js +18 -5
- package/dist/commands/test/test.d.ts +1 -1
- package/dist/commands/test/test.js +62 -10
- package/dist/commands/watch/deployer.d.ts +24 -0
- package/dist/commands/watch/deployer.js +125 -0
- package/dist/commands/watch/error-checker.d.ts +13 -0
- package/dist/commands/watch/error-checker.js +76 -0
- package/dist/commands/watch/generator.d.ts +21 -0
- package/dist/commands/watch/generator.js +79 -0
- package/dist/commands/watch/globMoFiles.d.ts +1 -0
- package/dist/commands/watch/globMoFiles.js +14 -0
- package/dist/commands/watch/parseDfxJson.d.ts +2 -0
- package/dist/commands/watch/parseDfxJson.js +22 -0
- package/dist/commands/watch/tester.d.ts +19 -0
- package/dist/commands/watch/tester.js +63 -0
- package/dist/commands/watch/warning-checker.d.ts +20 -0
- package/dist/commands/watch/warning-checker.js +111 -0
- package/dist/commands/watch/watch.d.ts +7 -0
- package/dist/commands/watch/watch.js +79 -0
- package/dist/declarations/main/main.did +16 -10
- package/dist/declarations/main/main.did.d.ts +19 -10
- package/dist/declarations/main/main.did.js +25 -11
- package/dist/helpers/get-moc-path.d.ts +1 -1
- package/dist/helpers/get-moc-path.js +17 -3
- package/dist/helpers/get-moc-version.d.ts +1 -1
- package/dist/helpers/get-moc-version.js +17 -5
- package/dist/integrity.js +3 -2
- package/dist/package.json +3 -2
- package/dist/parallel.d.ts +1 -1
- package/dist/templates/mops-test.yml +4 -2
- package/helpers/get-moc-path.ts +19 -3
- package/helpers/get-moc-version.ts +17 -5
- package/integrity.ts +3 -2
- package/package.json +3 -2
- package/parallel.ts +2 -2
- package/templates/mops-test.yml +4 -2
- package/test +0 -4
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { promisify } from 'node:util';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { getMocPath } from '../../helpers/get-moc-path.js';
|
|
6
|
+
import { getRootDir } from '../../mops.js';
|
|
7
|
+
import { sources } from '../sources.js';
|
|
8
|
+
import { parallel } from '../../parallel.js';
|
|
9
|
+
import { globMoFiles } from './globMoFiles.js';
|
|
10
|
+
export class WarningChecker {
|
|
11
|
+
constructor({ verbose, canisters, errorChecker }) {
|
|
12
|
+
this.verbose = false;
|
|
13
|
+
this.canisters = {};
|
|
14
|
+
this.status = 'pending';
|
|
15
|
+
this.warnings = [];
|
|
16
|
+
this.aborted = false;
|
|
17
|
+
this.controllers = new Map();
|
|
18
|
+
this.verbose = verbose;
|
|
19
|
+
this.canisters = canisters;
|
|
20
|
+
this.errorChecker = errorChecker;
|
|
21
|
+
}
|
|
22
|
+
reset() {
|
|
23
|
+
this.status = 'pending';
|
|
24
|
+
this.warnings = [];
|
|
25
|
+
}
|
|
26
|
+
async abortCurrent() {
|
|
27
|
+
this.aborted = true;
|
|
28
|
+
for (let controller of this.controllers.values()) {
|
|
29
|
+
controller.abort();
|
|
30
|
+
}
|
|
31
|
+
this.controllers.clear();
|
|
32
|
+
await this.currentRun;
|
|
33
|
+
this.reset();
|
|
34
|
+
this.aborted = false;
|
|
35
|
+
}
|
|
36
|
+
async run(onProgress) {
|
|
37
|
+
await this.abortCurrent();
|
|
38
|
+
if (this.errorChecker.status === 'error') {
|
|
39
|
+
this.status = 'syntax-error';
|
|
40
|
+
onProgress();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
this.status = 'running';
|
|
44
|
+
onProgress();
|
|
45
|
+
let rootDir = getRootDir();
|
|
46
|
+
let mocPath = getMocPath();
|
|
47
|
+
let deps = await sources({ cwd: rootDir });
|
|
48
|
+
let paths = [...Object.values(this.canisters)];
|
|
49
|
+
if (!paths.length) {
|
|
50
|
+
paths = globMoFiles(rootDir);
|
|
51
|
+
}
|
|
52
|
+
this.currentRun = parallel(os.cpus().length, paths, async (file) => {
|
|
53
|
+
let controller = new AbortController();
|
|
54
|
+
let { signal } = controller;
|
|
55
|
+
this.controllers.set(file, controller);
|
|
56
|
+
let { stderr } = await promisify(execFile)(mocPath, ['--check', ...deps.flatMap(x => x.split(' ')), file], { cwd: rootDir, signal }).catch((error) => {
|
|
57
|
+
if (error.code === 'ABORT_ERR') {
|
|
58
|
+
return { stderr: '' };
|
|
59
|
+
}
|
|
60
|
+
throw error;
|
|
61
|
+
});
|
|
62
|
+
if (stderr) {
|
|
63
|
+
stderr.split('\n').forEach((line) => {
|
|
64
|
+
// ignore deps warnings
|
|
65
|
+
if (line.startsWith('.mops/')) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
else if (line.includes(': warning [')) {
|
|
69
|
+
// better formatting
|
|
70
|
+
let str = line
|
|
71
|
+
.replace(': warning [', `: ${chalk.yellow('warning')} [`)
|
|
72
|
+
.replace(/unused field (\w+)/, `unused field ${chalk.bold('$1')}`)
|
|
73
|
+
.replace(/unused identifier (\w+)/, `unused identifier ${chalk.bold('$1')}`)
|
|
74
|
+
.trim();
|
|
75
|
+
this.warnings.push(str);
|
|
76
|
+
}
|
|
77
|
+
else if (line.startsWith(' ') && this.warnings.length) {
|
|
78
|
+
this.warnings[this.warnings.length - 1] += '\n ' + line;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
// console.log('UNKNOWN WARNING', line);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
onProgress();
|
|
85
|
+
}
|
|
86
|
+
this.controllers.delete(file);
|
|
87
|
+
});
|
|
88
|
+
await this.currentRun;
|
|
89
|
+
if (!this.aborted) {
|
|
90
|
+
this.status = this.warnings.length ? 'error' : 'success';
|
|
91
|
+
}
|
|
92
|
+
onProgress();
|
|
93
|
+
}
|
|
94
|
+
getOutput() {
|
|
95
|
+
if (this.status === 'pending') {
|
|
96
|
+
return `Warnings: ${chalk.gray('(pending)')}`;
|
|
97
|
+
}
|
|
98
|
+
if (this.status === 'running') {
|
|
99
|
+
return `Warnings: ${chalk.gray('(running)')}`;
|
|
100
|
+
}
|
|
101
|
+
if (this.status === 'syntax-error') {
|
|
102
|
+
return `Warnings: ${chalk.gray('(errors)')}`;
|
|
103
|
+
}
|
|
104
|
+
let output = '';
|
|
105
|
+
output += `Warnings: ${chalk.bold[this.warnings.length ? 'yellowBright' : 'green'](this.warnings.length)}`;
|
|
106
|
+
if (this.verbose && this.warnings.length) {
|
|
107
|
+
output += `\n ${this.warnings.join('\n ')}`;
|
|
108
|
+
}
|
|
109
|
+
return output;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import chokidar from 'chokidar';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import debounce from 'debounce';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { ErrorChecker } from './error-checker.js';
|
|
6
|
+
import { WarningChecker } from './warning-checker.js';
|
|
7
|
+
import { getMotokoCanisters, getMotokoCanistersWithDeclarations } from './parseDfxJson.js';
|
|
8
|
+
import { getRootDir } from '../../mops.js';
|
|
9
|
+
import { Tester } from './tester.js';
|
|
10
|
+
import { Generator } from './generator.js';
|
|
11
|
+
import { Deployer } from './deployer.js';
|
|
12
|
+
let ignore = [
|
|
13
|
+
'**/node_modules/**',
|
|
14
|
+
'**/.mops/**',
|
|
15
|
+
'**/.vessel/**',
|
|
16
|
+
'**/.git/**',
|
|
17
|
+
];
|
|
18
|
+
export async function watch(options) {
|
|
19
|
+
let hasOptions = Object.values(options).includes(true);
|
|
20
|
+
if (!hasOptions) {
|
|
21
|
+
options = {
|
|
22
|
+
error: true,
|
|
23
|
+
warning: true,
|
|
24
|
+
test: true,
|
|
25
|
+
generate: true,
|
|
26
|
+
deploy: true,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
options.error = true;
|
|
30
|
+
let rootDir = getRootDir();
|
|
31
|
+
let canisters = getMotokoCanisters();
|
|
32
|
+
let canistersWithDeclarations = getMotokoCanistersWithDeclarations();
|
|
33
|
+
let errorChecker = new ErrorChecker({ verbose: true, canisters: canisters });
|
|
34
|
+
let warningChecker = new WarningChecker({ errorChecker, verbose: true, canisters: canisters });
|
|
35
|
+
let tester = new Tester({ errorChecker, verbose: true });
|
|
36
|
+
let generator = new Generator({ errorChecker, verbose: true, canisters: canistersWithDeclarations });
|
|
37
|
+
let deployer = new Deployer({ errorChecker, generator, verbose: true, canisters: canisters });
|
|
38
|
+
let watcher = chokidar.watch([
|
|
39
|
+
path.join(rootDir, '**/*.mo'),
|
|
40
|
+
path.join(rootDir, 'mops.toml'),
|
|
41
|
+
], {
|
|
42
|
+
ignored: ignore,
|
|
43
|
+
ignoreInitial: true,
|
|
44
|
+
});
|
|
45
|
+
let run = debounce(async () => {
|
|
46
|
+
errorChecker.reset();
|
|
47
|
+
warningChecker.reset();
|
|
48
|
+
tester.reset();
|
|
49
|
+
generator.reset();
|
|
50
|
+
deployer.reset();
|
|
51
|
+
options.error && await errorChecker.run(print);
|
|
52
|
+
options.warning && warningChecker.run(print);
|
|
53
|
+
options.test && tester.run(print);
|
|
54
|
+
options.generate && await generator.run(print);
|
|
55
|
+
options.deploy && deployer.run(print);
|
|
56
|
+
}, 200);
|
|
57
|
+
let print = () => {
|
|
58
|
+
console.clear();
|
|
59
|
+
process.stdout.write('\x1Bc');
|
|
60
|
+
options.error && console.log(errorChecker.getOutput());
|
|
61
|
+
options.warning && console.log(warningChecker.getOutput());
|
|
62
|
+
options.test && console.log(tester.getOutput());
|
|
63
|
+
options.generate && console.log(generator.getOutput());
|
|
64
|
+
options.deploy && console.log(deployer.getOutput());
|
|
65
|
+
let statuses = [];
|
|
66
|
+
options.error && statuses.push(errorChecker.status);
|
|
67
|
+
options.warning && statuses.push(warningChecker.status);
|
|
68
|
+
options.test && statuses.push(tester.status);
|
|
69
|
+
options.generate && statuses.push(generator.status);
|
|
70
|
+
options.deploy && statuses.push(deployer.status);
|
|
71
|
+
if (statuses.every(status => status !== 'pending' && status !== 'running')) {
|
|
72
|
+
console.log(chalk.dim('-'.repeat(50)));
|
|
73
|
+
console.log(chalk.dim('Waiting for file changes...'));
|
|
74
|
+
console.log(chalk.dim(`Press ${chalk.bold('Ctrl+C')} to exit.`));
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
watcher.on('all', run);
|
|
78
|
+
run();
|
|
79
|
+
}
|
|
@@ -91,13 +91,13 @@ type Result_6 =
|
|
|
91
91
|
err: Err;
|
|
92
92
|
ok: vec record {
|
|
93
93
|
PackageName;
|
|
94
|
-
|
|
94
|
+
PackageVersion__1;
|
|
95
95
|
};
|
|
96
96
|
};
|
|
97
97
|
type Result_5 =
|
|
98
98
|
variant {
|
|
99
99
|
err: Err;
|
|
100
|
-
ok:
|
|
100
|
+
ok: PackageVersion__1;
|
|
101
101
|
};
|
|
102
102
|
type Result_4 =
|
|
103
103
|
variant {
|
|
@@ -147,6 +147,7 @@ type Request =
|
|
|
147
147
|
};
|
|
148
148
|
type PublishingId = text;
|
|
149
149
|
type PageCount = nat;
|
|
150
|
+
type PackageVersion__1 = text;
|
|
150
151
|
type PackageVersion = text;
|
|
151
152
|
type PackageSummary__1 =
|
|
152
153
|
record {
|
|
@@ -155,6 +156,7 @@ type PackageSummary__1 =
|
|
|
155
156
|
downloadsInLast30Days: nat;
|
|
156
157
|
downloadsInLast7Days: nat;
|
|
157
158
|
downloadsTotal: nat;
|
|
159
|
+
highestVersion: PackageVersion;
|
|
158
160
|
owner: principal;
|
|
159
161
|
ownerInfo: User;
|
|
160
162
|
publication: PackagePublication;
|
|
@@ -168,6 +170,7 @@ type PackageSummaryWithChanges__1 =
|
|
|
168
170
|
downloadsInLast30Days: nat;
|
|
169
171
|
downloadsInLast7Days: nat;
|
|
170
172
|
downloadsTotal: nat;
|
|
173
|
+
highestVersion: PackageVersion;
|
|
171
174
|
owner: principal;
|
|
172
175
|
ownerInfo: User;
|
|
173
176
|
publication: PackagePublication;
|
|
@@ -181,6 +184,7 @@ type PackageSummaryWithChanges =
|
|
|
181
184
|
downloadsInLast30Days: nat;
|
|
182
185
|
downloadsInLast7Days: nat;
|
|
183
186
|
downloadsTotal: nat;
|
|
187
|
+
highestVersion: PackageVersion;
|
|
184
188
|
owner: principal;
|
|
185
189
|
ownerInfo: User;
|
|
186
190
|
publication: PackagePublication;
|
|
@@ -193,6 +197,7 @@ type PackageSummary =
|
|
|
193
197
|
downloadsInLast30Days: nat;
|
|
194
198
|
downloadsInLast7Days: nat;
|
|
195
199
|
downloadsTotal: nat;
|
|
200
|
+
highestVersion: PackageVersion;
|
|
196
201
|
owner: principal;
|
|
197
202
|
ownerInfo: User;
|
|
198
203
|
publication: PackagePublication;
|
|
@@ -237,6 +242,7 @@ type PackageDetails =
|
|
|
237
242
|
downloadsInLast7Days: nat;
|
|
238
243
|
downloadsTotal: nat;
|
|
239
244
|
fileStats: PackageFileStatsPublic;
|
|
245
|
+
highestVersion: PackageVersion;
|
|
240
246
|
owner: principal;
|
|
241
247
|
ownerInfo: User;
|
|
242
248
|
publication: PackagePublication;
|
|
@@ -303,13 +309,13 @@ type Main =
|
|
|
303
309
|
getDefaultPackages: (text) ->
|
|
304
310
|
(vec record {
|
|
305
311
|
PackageName;
|
|
306
|
-
|
|
312
|
+
PackageVersion__1;
|
|
307
313
|
}) query;
|
|
308
314
|
getDownloadTrendByPackageId: (PackageId) ->
|
|
309
315
|
(vec DownloadsSnapshot__1) query;
|
|
310
316
|
getDownloadTrendByPackageName: (PackageName) ->
|
|
311
317
|
(vec DownloadsSnapshot__1) query;
|
|
312
|
-
getFileHashes: (PackageName,
|
|
318
|
+
getFileHashes: (PackageName, PackageVersion__1) -> (Result_8);
|
|
313
319
|
getFileHashesByPackageIds: (vec PackageId) ->
|
|
314
320
|
(vec record {
|
|
315
321
|
PackageId;
|
|
@@ -318,19 +324,19 @@ type Main =
|
|
|
318
324
|
blob;
|
|
319
325
|
};
|
|
320
326
|
});
|
|
321
|
-
getFileHashesQuery: (PackageName,
|
|
322
|
-
getFileIds: (PackageName,
|
|
327
|
+
getFileHashesQuery: (PackageName, PackageVersion__1) -> (Result_8) query;
|
|
328
|
+
getFileIds: (PackageName, PackageVersion__1) -> (Result_7) query;
|
|
323
329
|
getHighestSemverBatch:
|
|
324
330
|
(vec record {
|
|
325
331
|
PackageName;
|
|
326
|
-
|
|
332
|
+
PackageVersion__1;
|
|
327
333
|
SemverPart;
|
|
328
334
|
}) -> (Result_6) query;
|
|
329
335
|
getHighestVersion: (PackageName) -> (Result_5) query;
|
|
330
336
|
getMostDownloadedPackages: () -> (vec PackageSummary) query;
|
|
331
337
|
getMostDownloadedPackagesIn7Days: () -> (vec PackageSummary) query;
|
|
332
338
|
getNewPackages: () -> (vec PackageSummary) query;
|
|
333
|
-
getPackageDetails: (PackageName,
|
|
339
|
+
getPackageDetails: (PackageName, PackageVersion__1) -> (Result_4) query;
|
|
334
340
|
getPackagesByCategory: () -> (vec record {
|
|
335
341
|
text;
|
|
336
342
|
vec PackageSummary;
|
|
@@ -344,10 +350,10 @@ type Main =
|
|
|
344
350
|
getTotalPackages: () -> (nat) query;
|
|
345
351
|
getUser: (principal) -> (opt User__1) query;
|
|
346
352
|
http_request: (Request) -> (Response) query;
|
|
347
|
-
notifyInstall: (PackageName,
|
|
353
|
+
notifyInstall: (PackageName, PackageVersion__1) -> () oneway;
|
|
348
354
|
notifyInstalls: (vec record {
|
|
349
355
|
PackageName;
|
|
350
|
-
|
|
356
|
+
PackageVersion__1;
|
|
351
357
|
}) -> () oneway;
|
|
352
358
|
restore: (nat) -> ();
|
|
353
359
|
search: (Text, opt nat, opt nat) -> (vec PackageSummary, PageCount) query;
|
|
@@ -63,7 +63,7 @@ export interface Main {
|
|
|
63
63
|
'getBackupCanisterId' : ActorMethod<[], Principal>,
|
|
64
64
|
'getDefaultPackages' : ActorMethod<
|
|
65
65
|
[string],
|
|
66
|
-
Array<[PackageName,
|
|
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,
|
|
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<
|
|
82
|
-
|
|
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,
|
|
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,
|
|
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,
|
|
108
|
+
'notifyInstall' : ActorMethod<[PackageName, PackageVersion__1], undefined>,
|
|
106
109
|
'notifyInstalls' : ActorMethod<
|
|
107
|
-
[Array<[PackageName,
|
|
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' :
|
|
302
|
+
export type Result_5 = { 'ok' : PackageVersion__1 } |
|
|
294
303
|
{ 'err' : Err };
|
|
295
|
-
export type Result_6 = { 'ok' : Array<[PackageName,
|
|
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
|
|
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,
|
|
27
|
+
'ok' : IDL.Vec(IDL.Tuple(PackageName, PackageVersion__1)),
|
|
28
28
|
'err' : Err,
|
|
29
29
|
});
|
|
30
|
-
const Result_5 = IDL.Variant({ 'ok' :
|
|
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,
|
|
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(
|
|
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,
|
|
332
|
+
[PackageName, PackageVersion__1],
|
|
323
333
|
[Result_8],
|
|
324
334
|
['query'],
|
|
325
335
|
),
|
|
326
336
|
'getFileIds' : IDL.Func(
|
|
327
|
-
[PackageName,
|
|
337
|
+
[PackageName, PackageVersion__1],
|
|
328
338
|
[Result_7],
|
|
329
339
|
['query'],
|
|
330
340
|
),
|
|
331
341
|
'getHighestSemverBatch' : IDL.Func(
|
|
332
|
-
[IDL.Vec(IDL.Tuple(PackageName,
|
|
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,
|
|
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(
|
|
382
|
+
'notifyInstall' : IDL.Func(
|
|
383
|
+
[PackageName, PackageVersion__1],
|
|
384
|
+
[],
|
|
385
|
+
['oneway'],
|
|
386
|
+
),
|
|
373
387
|
'notifyInstalls' : IDL.Func(
|
|
374
|
-
[IDL.Vec(IDL.Tuple(PackageName,
|
|
388
|
+
[IDL.Vec(IDL.Tuple(PackageName, PackageVersion__1))],
|
|
375
389
|
[],
|
|
376
390
|
['oneway'],
|
|
377
391
|
),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function getMocPath(): string;
|
|
1
|
+
export declare function getMocPath(throwIfNotFound?: boolean): string;
|
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
|
-
import {
|
|
3
|
-
export function getMocPath() {
|
|
2
|
+
import { execFileSync } from 'node:child_process';
|
|
3
|
+
export function getMocPath(throwIfNotFound = false) {
|
|
4
4
|
let mocPath = process.env.DFX_MOC_PATH;
|
|
5
5
|
if (!mocPath) {
|
|
6
|
-
|
|
6
|
+
try {
|
|
7
|
+
mocPath = execFileSync('dfx', ['cache', 'show']).toString().trim() + '/moc';
|
|
8
|
+
}
|
|
9
|
+
catch (e) {
|
|
10
|
+
mocPath = '';
|
|
11
|
+
}
|
|
7
12
|
}
|
|
8
13
|
if (!mocPath) {
|
|
9
14
|
mocPath = 'moc';
|
|
10
15
|
}
|
|
16
|
+
if (throwIfNotFound) {
|
|
17
|
+
try {
|
|
18
|
+
execFileSync(mocPath, ['--version']);
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
console.error(e);
|
|
22
|
+
throw new Error('moc not found');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
11
25
|
return mocPath;
|
|
12
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function getMocVersion(): string;
|
|
1
|
+
export declare function getMocVersion(throwOnError?: boolean): string;
|
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
2
|
import { getMocPath } from './get-moc-path.js';
|
|
3
|
-
export function getMocVersion() {
|
|
4
|
-
let mocPath = getMocPath();
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
export function getMocVersion(throwOnError = false) {
|
|
4
|
+
let mocPath = getMocPath(false);
|
|
5
|
+
if (!mocPath) {
|
|
6
|
+
return '';
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
let match = execFileSync(mocPath, ['--version']).toString().trim().match(/Motoko compiler ([^\s]+) .*/);
|
|
10
|
+
return match?.[1] || '';
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
if (throwOnError) {
|
|
14
|
+
console.error(e);
|
|
15
|
+
throw new Error('moc not found');
|
|
16
|
+
}
|
|
17
|
+
return '';
|
|
18
|
+
}
|
|
7
19
|
}
|
package/dist/integrity.js
CHANGED
|
@@ -122,6 +122,7 @@ export async function updateLockFile() {
|
|
|
122
122
|
}
|
|
123
123
|
// compare hashes of local files with hashes from the lock file
|
|
124
124
|
export async function checkLockFile(force = false) {
|
|
125
|
+
let supportedVersions = [1, 2, 3];
|
|
125
126
|
let rootDir = getRootDir();
|
|
126
127
|
let lockFile = path.join(rootDir, 'mops.lock');
|
|
127
128
|
// check if lock file exists
|
|
@@ -135,9 +136,9 @@ export async function checkLockFile(force = false) {
|
|
|
135
136
|
let lockFileJsonGeneric = JSON.parse(fs.readFileSync(lockFile).toString());
|
|
136
137
|
let packageIds = await getResolvedMopsPackageIds();
|
|
137
138
|
// check lock file version
|
|
138
|
-
if (
|
|
139
|
+
if (!supportedVersions.includes(lockFileJsonGeneric.version)) {
|
|
139
140
|
console.error('Integrity check failed');
|
|
140
|
-
console.error(`Invalid lock file version: ${lockFileJsonGeneric.version}. Supported versions:
|
|
141
|
+
console.error(`Invalid lock file version: ${lockFileJsonGeneric.version}. Supported versions: ${supportedVersions.join(', ')}`);
|
|
141
142
|
process.exit(1);
|
|
142
143
|
}
|
|
143
144
|
let lockFileJson = lockFileJsonGeneric;
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ic-mops",
|
|
3
|
-
"version": "1.1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"mops": "bin/mops.js",
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"octokit": "3.1.2",
|
|
65
65
|
"pem-file": "1.0.1",
|
|
66
66
|
"pic-ic": "0.5.3",
|
|
67
|
+
"promisify-child-process": "4.1.2",
|
|
67
68
|
"prompts": "2.4.2",
|
|
68
69
|
"semver": "7.6.3",
|
|
69
70
|
"stream-to-promise": "3.0.0",
|
|
@@ -77,7 +78,7 @@
|
|
|
77
78
|
"@types/fs-extra": "11.0.4",
|
|
78
79
|
"@types/glob": "8.1.0",
|
|
79
80
|
"@types/ncp": "2.0.8",
|
|
80
|
-
"@types/node": "22.
|
|
81
|
+
"@types/node": "22.7.4",
|
|
81
82
|
"@types/prompts": "2.4.9",
|
|
82
83
|
"@types/semver": "7.5.8",
|
|
83
84
|
"@types/stream-to-promise": "2.2.4",
|
package/dist/parallel.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function parallel(threads: number, items:
|
|
1
|
+
export declare function parallel<T>(threads: number, items: T[], fn: (item: T) => Promise<void>): Promise<void>;
|