ic-mops 1.0.1 → 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 +29 -5
- package/commands/bench.ts +1 -1
- package/commands/install/install-all.ts +28 -6
- package/commands/install/install-dep.ts +5 -4
- package/commands/install/install-deps.ts +3 -2
- package/commands/install/install-local-dep.ts +11 -5
- package/commands/install/install-mops-dep.ts +8 -5
- 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 +26 -5
- package/dist/commands/bench.js +1 -1
- package/dist/commands/install/install-all.d.ts +2 -1
- package/dist/commands/install/install-all.js +24 -6
- package/dist/commands/install/install-dep.d.ts +2 -1
- package/dist/commands/install/install-dep.js +4 -4
- package/dist/commands/install/install-deps.d.ts +2 -1
- package/dist/commands/install/install-deps.js +2 -2
- package/dist/commands/install/install-local-dep.d.ts +2 -1
- package/dist/commands/install/install-local-dep.js +9 -4
- package/dist/commands/install/install-mops-dep.d.ts +2 -1
- package/dist/commands/install/install-mops-dep.js +7 -5
- 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.d.ts +20 -0
- package/dist/integrity.js +42 -10
- package/dist/mops.d.ts +2 -1
- package/dist/mops.js +13 -10
- package/dist/package.json +3 -2
- package/dist/parallel.d.ts +1 -1
- package/dist/resolve-packages.js +7 -0
- package/dist/templates/mops-test.yml +4 -2
- package/dist/vessel.d.ts +2 -1
- package/dist/vessel.js +4 -1
- package/helpers/get-moc-path.ts +19 -3
- package/helpers/get-moc-version.ts +17 -5
- package/integrity.ts +56 -13
- package/mops.ts +15 -11
- package/package.json +3 -2
- package/parallel.ts +2 -2
- package/resolve-packages.ts +9 -0
- package/templates/mops-test.yml +4 -2
- package/vessel.ts +5 -1
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
|
|
13
|
+
let ignore = [
|
|
14
|
+
'**/node_modules/**',
|
|
15
|
+
'**/.mops/**',
|
|
16
|
+
'**/.vessel/**',
|
|
17
|
+
'**/.git/**',
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
export async function watch(options : {error : boolean, warning : boolean, test : boolean, generate : boolean, deploy : boolean}) {
|
|
21
|
+
let hasOptions = Object.values(options).includes(true);
|
|
22
|
+
if (!hasOptions) {
|
|
23
|
+
options = {
|
|
24
|
+
error: true,
|
|
25
|
+
warning: true,
|
|
26
|
+
test: true,
|
|
27
|
+
generate: true,
|
|
28
|
+
deploy: true,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
options.error = true;
|
|
32
|
+
|
|
33
|
+
let rootDir = getRootDir();
|
|
34
|
+
let canisters = getMotokoCanisters();
|
|
35
|
+
let canistersWithDeclarations = getMotokoCanistersWithDeclarations();
|
|
36
|
+
let errorChecker = new ErrorChecker({verbose: true, canisters: canisters});
|
|
37
|
+
let warningChecker = new WarningChecker({errorChecker, verbose: true, canisters: canisters});
|
|
38
|
+
let tester = new Tester({errorChecker, verbose: true});
|
|
39
|
+
let generator = new Generator({errorChecker, verbose: true, canisters: canistersWithDeclarations});
|
|
40
|
+
let deployer = new Deployer({errorChecker, generator, verbose: true, canisters: canisters});
|
|
41
|
+
|
|
42
|
+
let watcher = chokidar.watch([
|
|
43
|
+
path.join(rootDir, '**/*.mo'),
|
|
44
|
+
path.join(rootDir, 'mops.toml'),
|
|
45
|
+
], {
|
|
46
|
+
ignored: ignore,
|
|
47
|
+
ignoreInitial: true,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
let run = debounce(async () => {
|
|
51
|
+
errorChecker.reset();
|
|
52
|
+
warningChecker.reset();
|
|
53
|
+
tester.reset();
|
|
54
|
+
generator.reset();
|
|
55
|
+
deployer.reset();
|
|
56
|
+
|
|
57
|
+
options.error && await errorChecker.run(print);
|
|
58
|
+
options.warning && warningChecker.run(print);
|
|
59
|
+
options.test && tester.run(print);
|
|
60
|
+
options.generate && await generator.run(print);
|
|
61
|
+
options.deploy && deployer.run(print);
|
|
62
|
+
}, 200);
|
|
63
|
+
|
|
64
|
+
let print = () => {
|
|
65
|
+
console.clear();
|
|
66
|
+
process.stdout.write('\x1Bc');
|
|
67
|
+
|
|
68
|
+
options.error && console.log(errorChecker.getOutput());
|
|
69
|
+
options.warning && console.log(warningChecker.getOutput());
|
|
70
|
+
options.test && console.log(tester.getOutput());
|
|
71
|
+
options.generate && console.log(generator.getOutput());
|
|
72
|
+
options.deploy && console.log(deployer.getOutput());
|
|
73
|
+
|
|
74
|
+
let statuses = [];
|
|
75
|
+
options.error && statuses.push(errorChecker.status);
|
|
76
|
+
options.warning && statuses.push(warningChecker.status);
|
|
77
|
+
options.test && statuses.push(tester.status);
|
|
78
|
+
options.generate && statuses.push(generator.status);
|
|
79
|
+
options.deploy && statuses.push(deployer.status);
|
|
80
|
+
|
|
81
|
+
if (statuses.every(status => status !== 'pending' && status !== 'running')) {
|
|
82
|
+
console.log(chalk.dim('-'.repeat(50)));
|
|
83
|
+
console.log(chalk.dim('Waiting for file changes...'));
|
|
84
|
+
console.log(chalk.dim(`Press ${chalk.bold('Ctrl+C')} to exit.`));
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
watcher.on('all', run);
|
|
89
|
+
run();
|
|
90
|
+
}
|
|
@@ -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
|
),
|
|
@@ -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';
|
|
@@ -72,6 +75,7 @@ program
|
|
|
72
75
|
.command('install')
|
|
73
76
|
.alias('i')
|
|
74
77
|
.description('Install all dependencies specified in mops.toml')
|
|
78
|
+
.option('--no-toolchain', 'Do not install toolchain')
|
|
75
79
|
.option('--verbose')
|
|
76
80
|
.addOption(new Option('--lock <action>', 'Lockfile action').choices(['check', 'update', 'ignore']))
|
|
77
81
|
.action(async (options) => {
|
|
@@ -82,9 +86,13 @@ program
|
|
|
82
86
|
if (!compatible) {
|
|
83
87
|
return;
|
|
84
88
|
}
|
|
85
|
-
|
|
89
|
+
if (options.toolchain) {
|
|
90
|
+
await toolchain.ensureToolchainInited({ strict: false });
|
|
91
|
+
}
|
|
86
92
|
let ok = await installAll(options);
|
|
87
|
-
|
|
93
|
+
if (options.toolchain) {
|
|
94
|
+
await toolchain.installAll(options);
|
|
95
|
+
}
|
|
88
96
|
// check conflicts
|
|
89
97
|
await resolvePackages({ conflicts: 'warning' });
|
|
90
98
|
if (!ok) {
|
|
@@ -136,7 +144,7 @@ program
|
|
|
136
144
|
process.exit(1);
|
|
137
145
|
}
|
|
138
146
|
if (options.install) {
|
|
139
|
-
await installAll({ silent: true, lock: 'ignore', threads: 6 });
|
|
147
|
+
await installAll({ silent: true, lock: 'ignore', threads: 6, installFromLockFile: true });
|
|
140
148
|
}
|
|
141
149
|
await toolchain.ensureToolchainInited({ strict: false });
|
|
142
150
|
let sourcesArr = await sources(options);
|
|
@@ -177,7 +185,7 @@ program
|
|
|
177
185
|
.option('-w, --watch', 'Enable watch mode')
|
|
178
186
|
.action(async (filter, options) => {
|
|
179
187
|
checkConfigFile(true);
|
|
180
|
-
await installAll({ silent: true, lock: 'ignore' });
|
|
188
|
+
await installAll({ silent: true, lock: 'ignore', installFromLockFile: true });
|
|
181
189
|
await test(filter, options);
|
|
182
190
|
});
|
|
183
191
|
// bench
|
|
@@ -192,7 +200,7 @@ program
|
|
|
192
200
|
.addOption(new Option('--verbose', 'Show more information'))
|
|
193
201
|
.action(async (filter, options) => {
|
|
194
202
|
checkConfigFile(true);
|
|
195
|
-
await installAll({ silent: true, lock: 'ignore' });
|
|
203
|
+
await installAll({ silent: true, lock: 'ignore', installFromLockFile: true });
|
|
196
204
|
await bench(filter, options);
|
|
197
205
|
});
|
|
198
206
|
// template
|
|
@@ -338,4 +346,17 @@ selfCommand
|
|
|
338
346
|
await self.uninstall();
|
|
339
347
|
});
|
|
340
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
|
+
});
|
|
341
362
|
program.parse();
|
package/dist/commands/bench.js
CHANGED
|
@@ -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,
|
|
@@ -3,6 +3,7 @@ type InstallAllOptions = {
|
|
|
3
3
|
silent?: boolean;
|
|
4
4
|
lock?: 'check' | 'update' | 'ignore';
|
|
5
5
|
threads?: number;
|
|
6
|
+
installFromLockFile?: boolean;
|
|
6
7
|
};
|
|
7
|
-
export declare function installAll({ verbose, silent, threads, lock }?: InstallAllOptions): Promise<boolean>;
|
|
8
|
+
export declare function installAll({ verbose, silent, threads, lock, installFromLockFile }?: InstallAllOptions): Promise<boolean>;
|
|
8
9
|
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import { createLogUpdate } from 'log-update';
|
|
4
|
-
import { checkConfigFile, readConfig } from '../../mops.js';
|
|
5
|
-
import { checkIntegrity } from '../../integrity.js';
|
|
4
|
+
import { checkConfigFile, parseDepValue, readConfig } from '../../mops.js';
|
|
5
|
+
import { checkIntegrity, checkLockFileLight, readLockFile } from '../../integrity.js';
|
|
6
6
|
import { installDeps } from './install-deps.js';
|
|
7
7
|
import { checkRequirements } from '../../check-requirements.js';
|
|
8
8
|
import { syncLocalCache } from './sync-local-cache.js';
|
|
9
9
|
import { notifyInstalls } from '../../notify-installs.js';
|
|
10
|
-
export async function installAll({ verbose = false, silent = false, threads, lock } = {}) {
|
|
10
|
+
export async function installAll({ verbose = false, silent = false, threads, lock, installFromLockFile } = {}) {
|
|
11
11
|
if (!checkConfigFile()) {
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
@@ -15,9 +15,27 @@ export async function installAll({ verbose = false, silent = false, threads, loc
|
|
|
15
15
|
let deps = Object.values(config.dependencies || {});
|
|
16
16
|
let devDeps = Object.values(config['dev-dependencies'] || {});
|
|
17
17
|
let allDeps = [...deps, ...devDeps];
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
let installedFromLockFile = false;
|
|
19
|
+
// install from lock file to avoid installing intermediate dependencies
|
|
20
|
+
if ((lock !== 'ignore' || installFromLockFile) && checkLockFileLight()) {
|
|
21
|
+
let lockFileJson = readLockFile();
|
|
22
|
+
if (lockFileJson && lockFileJson.version === 3) {
|
|
23
|
+
verbose && console.log('Installing from lock file...');
|
|
24
|
+
installedFromLockFile = true;
|
|
25
|
+
let lockedDeps = Object.entries(lockFileJson.deps).map(([name, version]) => {
|
|
26
|
+
return parseDepValue(name, version);
|
|
27
|
+
});
|
|
28
|
+
let ok = await installDeps(lockedDeps, { silent, verbose, threads, ignoreTransitive: true });
|
|
29
|
+
if (!ok) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (!installedFromLockFile) {
|
|
35
|
+
let ok = await installDeps(allDeps, { silent, verbose, threads });
|
|
36
|
+
if (!ok) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
21
39
|
}
|
|
22
40
|
let logUpdate = createLogUpdate(process.stdout, { showCursor: true });
|
|
23
41
|
if (!silent && lock !== 'ignore') {
|
|
@@ -3,6 +3,7 @@ type InstallDepOptions = {
|
|
|
3
3
|
verbose?: boolean;
|
|
4
4
|
silent?: boolean;
|
|
5
5
|
threads?: number;
|
|
6
|
+
ignoreTransitive?: boolean;
|
|
6
7
|
};
|
|
7
|
-
export declare function installDep(dep: Dependency, { verbose, silent, threads }?: InstallDepOptions, parentPkgPath?: string): Promise<boolean>;
|
|
8
|
+
export declare function installDep(dep: Dependency, { verbose, silent, threads, ignoreTransitive }?: InstallDepOptions, parentPkgPath?: string): Promise<boolean>;
|
|
8
9
|
export {};
|
|
@@ -5,9 +5,9 @@ import { installLocalDep } from './install-local-dep.js';
|
|
|
5
5
|
import { getRootDir } from '../../mops.js';
|
|
6
6
|
// install dependency
|
|
7
7
|
// returns false if failed
|
|
8
|
-
export async function installDep(dep, { verbose, silent, threads } = {}, parentPkgPath) {
|
|
8
|
+
export async function installDep(dep, { verbose, silent, threads, ignoreTransitive } = {}, parentPkgPath) {
|
|
9
9
|
if (dep.repo) {
|
|
10
|
-
await installFromGithub(dep.name, dep.repo, { silent, verbose });
|
|
10
|
+
await installFromGithub(dep.name, dep.repo, { silent, verbose, ignoreTransitive });
|
|
11
11
|
return true;
|
|
12
12
|
}
|
|
13
13
|
else if (dep.path) {
|
|
@@ -16,10 +16,10 @@ export async function installDep(dep, { verbose, silent, threads } = {}, parentP
|
|
|
16
16
|
if (parentPkgPath) {
|
|
17
17
|
depPath = path.resolve(parentPkgPath, dep.path);
|
|
18
18
|
}
|
|
19
|
-
return installLocalDep(dep.name, depPath, { silent, verbose });
|
|
19
|
+
return installLocalDep(dep.name, depPath, { silent, verbose, ignoreTransitive });
|
|
20
20
|
}
|
|
21
21
|
else if (dep.version) {
|
|
22
|
-
return installMopsDep(dep.name, dep.version, { silent, verbose, threads });
|
|
22
|
+
return installMopsDep(dep.name, dep.version, { silent, verbose, threads, ignoreTransitive });
|
|
23
23
|
}
|
|
24
24
|
return true;
|
|
25
25
|
}
|
|
@@ -3,6 +3,7 @@ type InstallDepsOptions = {
|
|
|
3
3
|
verbose?: boolean;
|
|
4
4
|
silent?: boolean;
|
|
5
5
|
threads?: number;
|
|
6
|
+
ignoreTransitive?: boolean;
|
|
6
7
|
};
|
|
7
|
-
export declare function installDeps(deps: Dependency[], { verbose, silent, threads }?: InstallDepsOptions, parentPkgPath?: string): Promise<boolean>;
|
|
8
|
+
export declare function installDeps(deps: Dependency[], { verbose, silent, threads, ignoreTransitive }?: InstallDepsOptions, parentPkgPath?: string): Promise<boolean>;
|
|
8
9
|
export {};
|
|
@@ -2,10 +2,10 @@ import { installDep } from './install-dep.js';
|
|
|
2
2
|
// install all dependencies
|
|
3
3
|
// returns actual installed dependencies
|
|
4
4
|
// returns false if failed
|
|
5
|
-
export async function installDeps(deps, { verbose, silent, threads } = {}, parentPkgPath) {
|
|
5
|
+
export async function installDeps(deps, { verbose, silent, threads, ignoreTransitive } = {}, parentPkgPath) {
|
|
6
6
|
let ok = true;
|
|
7
7
|
for (const dep of deps) {
|
|
8
|
-
let res = await installDep(dep, { verbose, silent, threads }, parentPkgPath);
|
|
8
|
+
let res = await installDep(dep, { verbose, silent, threads, ignoreTransitive }, parentPkgPath);
|
|
9
9
|
if (!res) {
|
|
10
10
|
ok = false;
|
|
11
11
|
}
|