ic-mops 1.11.0 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/api/actors.ts +2 -2
  3. package/api/downloadPackageFiles.ts +1 -1
  4. package/bun.lock +234 -198
  5. package/bundle/bench/bench-canister.mo +101 -109
  6. package/bundle/bench/user-bench.mo +6 -10
  7. package/bundle/cli.js +960 -889
  8. package/bundle/cli.tgz +0 -0
  9. package/bundle/declarations/bench/bench.did +3 -3
  10. package/bundle/declarations/bench/bench.did.d.ts +3 -3
  11. package/bundle/declarations/bench/index.d.ts +3 -3
  12. package/bundle/declarations/bench/index.js +1 -1
  13. package/bundle/declarations/main/index.d.ts +3 -3
  14. package/bundle/declarations/main/index.js +1 -1
  15. package/bundle/declarations/main/main.did +78 -121
  16. package/bundle/declarations/main/main.did.d.ts +48 -98
  17. package/bundle/declarations/main/main.did.js +53 -107
  18. package/bundle/declarations/storage/index.d.ts +3 -3
  19. package/bundle/declarations/storage/index.js +4 -4
  20. package/bundle/declarations/storage/storage.did.d.ts +3 -3
  21. package/bundle/package.json +1 -1
  22. package/bundle/templates/src/lib.mo +13 -13
  23. package/bundle/templates/test/lib.test.mo +2 -2
  24. package/commands/add.ts +1 -1
  25. package/commands/available-updates.ts +20 -7
  26. package/commands/bench-replica.ts +21 -9
  27. package/commands/maintainer.ts +1 -1
  28. package/commands/outdated.ts +8 -1
  29. package/commands/owner.ts +1 -1
  30. package/commands/replica.ts +31 -18
  31. package/commands/test/test.ts +37 -97
  32. package/commands/test/utils.ts +75 -1
  33. package/commands/update.ts +19 -2
  34. package/declarations/bench/bench.did.d.ts +3 -3
  35. package/declarations/bench/index.d.ts +3 -3
  36. package/declarations/bench/index.js +1 -1
  37. package/declarations/main/index.d.ts +3 -3
  38. package/declarations/main/index.js +1 -1
  39. package/declarations/main/main.did.d.ts +3 -3
  40. package/declarations/storage/index.d.ts +3 -3
  41. package/declarations/storage/index.js +4 -4
  42. package/declarations/storage/storage.did.d.ts +3 -3
  43. package/dist/api/actors.d.ts +2 -2
  44. package/dist/api/actors.js +1 -1
  45. package/dist/api/downloadPackageFiles.d.ts +1 -1
  46. package/dist/api/downloadPackageFiles.js +1 -1
  47. package/dist/commands/add.js +1 -1
  48. package/dist/commands/available-updates.js +19 -7
  49. package/dist/commands/bench-replica.d.ts +3 -2
  50. package/dist/commands/bench-replica.js +17 -6
  51. package/dist/commands/maintainer.js +1 -1
  52. package/dist/commands/outdated.js +7 -1
  53. package/dist/commands/owner.js +1 -1
  54. package/dist/commands/replica.d.ts +4 -3
  55. package/dist/commands/replica.js +25 -13
  56. package/dist/commands/test/test.js +29 -81
  57. package/dist/commands/test/utils.d.ts +6 -0
  58. package/dist/commands/test/utils.js +61 -0
  59. package/dist/commands/update.js +16 -2
  60. package/dist/declarations/bench/bench.did.d.ts +3 -3
  61. package/dist/declarations/bench/index.d.ts +3 -3
  62. package/dist/declarations/bench/index.js +1 -1
  63. package/dist/declarations/main/index.d.ts +3 -3
  64. package/dist/declarations/main/index.js +1 -1
  65. package/dist/declarations/main/main.did.d.ts +3 -3
  66. package/dist/declarations/storage/index.d.ts +3 -3
  67. package/dist/declarations/storage/index.js +4 -4
  68. package/dist/declarations/storage/storage.did.d.ts +3 -3
  69. package/dist/helpers/get-dep-name.d.ts +1 -0
  70. package/dist/helpers/get-dep-name.js +3 -0
  71. package/dist/mops.d.ts +1 -1
  72. package/dist/package.json +5 -15
  73. package/dist/pem.d.ts +2 -2
  74. package/dist/pem.js +2 -2
  75. package/helpers/get-dep-name.ts +4 -0
  76. package/mops.ts +1 -1
  77. package/package.json +5 -15
  78. package/pem.ts +2 -2
  79. package/tsconfig.json +2 -2
@@ -1,14 +1,14 @@
1
1
  export const idlFactory = ({ IDL }) => {
2
- const PackageName__1 = IDL.Text;
2
+ const PackageName = IDL.Text;
3
3
  const Result_3 = IDL.Variant({ 'ok' : IDL.Null, 'err' : IDL.Text });
4
4
  const PublishingId = IDL.Text;
5
5
  const Err = IDL.Text;
6
6
  const Result = IDL.Variant({ 'ok' : IDL.Null, 'err' : Err });
7
7
  const Text = IDL.Text;
8
- const PackageVersion__1 = IDL.Text;
8
+ const PackageVersion = IDL.Text;
9
9
  const PackageId = IDL.Text;
10
10
  const Time = IDL.Int;
11
- const DownloadsSnapshot__1 = IDL.Record({
11
+ const DownloadsSnapshot = IDL.Record({
12
12
  'startTime' : Time,
13
13
  'endTime' : Time,
14
14
  'downloads' : IDL.Nat,
@@ -25,10 +25,10 @@ export const idlFactory = ({ IDL }) => {
25
25
  'patch' : IDL.Null,
26
26
  });
27
27
  const Result_6 = IDL.Variant({
28
- 'ok' : IDL.Vec(IDL.Tuple(PackageName__1, PackageVersion__1)),
28
+ 'ok' : IDL.Vec(IDL.Tuple(PackageName, PackageVersion)),
29
29
  'err' : Err,
30
30
  });
31
- const Result_5 = IDL.Variant({ 'ok' : PackageVersion__1, 'err' : Err });
31
+ const Result_5 = IDL.Variant({ 'ok' : PackageVersion, 'err' : Err });
32
32
  const User = IDL.Record({
33
33
  'id' : IDL.Principal,
34
34
  'emailVerified' : IDL.Bool,
@@ -57,9 +57,7 @@ export const idlFactory = ({ IDL }) => {
57
57
  'hasRepository' : IDL.Bool,
58
58
  'hasReleaseNotes' : IDL.Bool,
59
59
  });
60
- const PackageVersion = IDL.Text;
61
60
  const Script = IDL.Record({ 'value' : IDL.Text, 'name' : IDL.Text });
62
- const PackageName = IDL.Text;
63
61
  const DependencyV2 = IDL.Record({
64
62
  'name' : PackageName,
65
63
  'repo' : IDL.Text,
@@ -120,31 +118,11 @@ export const idlFactory = ({ IDL }) => {
120
118
  'replicaVersion' : IDL.Text,
121
119
  'forceGC' : IDL.Bool,
122
120
  });
123
- const Benchmarks__1 = IDL.Vec(Benchmark);
124
- const PackageSummary__1 = IDL.Record({
125
- 'ownerInfo' : User,
126
- 'owners' : IDL.Vec(User),
127
- 'maintainers' : IDL.Vec(User),
128
- 'owner' : IDL.Principal,
129
- 'depAlias' : IDL.Text,
130
- 'quality' : PackageQuality,
131
- 'publisher' : User,
132
- 'highestVersion' : PackageVersion,
133
- 'downloadsTotal' : IDL.Nat,
134
- 'downloadsInLast30Days' : IDL.Nat,
135
- 'downloadsInLast7Days' : IDL.Nat,
136
- 'config' : PackageConfigV3,
137
- 'publication' : PackagePublication,
138
- });
139
- const TestStats__1 = IDL.Record({
121
+ const Benchmarks = IDL.Vec(Benchmark);
122
+ const TestStats = IDL.Record({
140
123
  'passedNames' : IDL.Vec(IDL.Text),
141
124
  'passed' : IDL.Nat,
142
125
  });
143
- const DownloadsSnapshot = IDL.Record({
144
- 'startTime' : Time,
145
- 'endTime' : Time,
146
- 'downloads' : IDL.Nat,
147
- });
148
126
  const PackageFileStatsPublic = IDL.Record({
149
127
  'sourceFiles' : IDL.Nat,
150
128
  'sourceSize' : IDL.Nat,
@@ -161,14 +139,14 @@ export const idlFactory = ({ IDL }) => {
161
139
  const PackageChanges = IDL.Record({
162
140
  'tests' : TestsChanges,
163
141
  'deps' : IDL.Vec(DepChange),
164
- 'curBenchmarks' : Benchmarks__1,
142
+ 'curBenchmarks' : Benchmarks,
165
143
  'prevDocsCoverage' : IDL.Float64,
166
- 'prevBenchmarks' : Benchmarks__1,
144
+ 'prevBenchmarks' : Benchmarks,
167
145
  'notes' : IDL.Text,
168
146
  'curDocsCoverage' : IDL.Float64,
169
147
  'devDeps' : IDL.Vec(DepChange),
170
148
  });
171
- const PackageSummaryWithChanges__1 = IDL.Record({
149
+ const PackageSummaryWithChanges = IDL.Record({
172
150
  'ownerInfo' : User,
173
151
  'owners' : IDL.Vec(User),
174
152
  'maintainers' : IDL.Vec(User),
@@ -185,65 +163,39 @@ export const idlFactory = ({ IDL }) => {
185
163
  'publication' : PackagePublication,
186
164
  });
187
165
  const PackageDetails = IDL.Record({
188
- 'benchmarks' : Benchmarks__1,
166
+ 'benchmarks' : Benchmarks,
189
167
  'ownerInfo' : User,
190
168
  'owners' : IDL.Vec(User),
191
169
  'maintainers' : IDL.Vec(User),
192
170
  'owner' : IDL.Principal,
193
171
  'depAlias' : IDL.Text,
194
- 'deps' : IDL.Vec(PackageSummary__1),
172
+ 'deps' : IDL.Vec(PackageSummary),
195
173
  'quality' : PackageQuality,
196
174
  'publisher' : User,
197
- 'testStats' : TestStats__1,
175
+ 'testStats' : TestStats,
198
176
  'docsCoverage' : IDL.Float64,
199
177
  'highestVersion' : PackageVersion,
200
178
  'downloadsTotal' : IDL.Nat,
201
179
  'downloadsInLast30Days' : IDL.Nat,
180
+ 'dependentsCount' : IDL.Nat,
202
181
  'downloadTrend' : IDL.Vec(DownloadsSnapshot),
203
182
  'fileStats' : PackageFileStatsPublic,
204
- 'versionHistory' : IDL.Vec(PackageSummaryWithChanges__1),
205
- 'dependents' : IDL.Vec(PackageSummary__1),
206
- 'devDeps' : IDL.Vec(PackageSummary__1),
183
+ 'versionHistory' : IDL.Vec(PackageSummaryWithChanges),
184
+ 'dependents' : IDL.Vec(PackageSummary),
185
+ 'devDeps' : IDL.Vec(PackageSummary),
207
186
  'downloadsInLast7Days' : IDL.Nat,
208
187
  'config' : PackageConfigV3,
209
188
  'changes' : PackageChanges,
189
+ 'versions' : IDL.Vec(PackageVersion),
210
190
  'publication' : PackagePublication,
211
191
  });
212
192
  const Result_4 = IDL.Variant({ 'ok' : PackageDetails, 'err' : Err });
213
- const PackageSummaryWithChanges = IDL.Record({
214
- 'ownerInfo' : User,
215
- 'owners' : IDL.Vec(User),
216
- 'maintainers' : IDL.Vec(User),
217
- 'owner' : IDL.Principal,
218
- 'depAlias' : IDL.Text,
219
- 'quality' : PackageQuality,
220
- 'publisher' : User,
221
- 'highestVersion' : PackageVersion,
222
- 'downloadsTotal' : IDL.Nat,
223
- 'downloadsInLast30Days' : IDL.Nat,
224
- 'downloadsInLast7Days' : IDL.Nat,
225
- 'config' : PackageConfigV3,
226
- 'changes' : PackageChanges,
227
- 'publication' : PackagePublication,
228
- });
229
193
  const StorageId = IDL.Principal;
230
194
  const StorageStats = IDL.Record({
231
195
  'fileCount' : IDL.Nat,
232
196
  'cyclesBalance' : IDL.Nat,
233
197
  'memorySize' : IDL.Nat,
234
198
  });
235
- const User__1 = IDL.Record({
236
- 'id' : IDL.Principal,
237
- 'emailVerified' : IDL.Bool,
238
- 'twitter' : IDL.Text,
239
- 'displayName' : IDL.Text,
240
- 'name' : IDL.Text,
241
- 'site' : IDL.Text,
242
- 'email' : IDL.Text,
243
- 'twitterVerified' : IDL.Bool,
244
- 'githubVerified' : IDL.Bool,
245
- 'github' : IDL.Text,
246
- });
247
199
  const Header = IDL.Tuple(IDL.Text, IDL.Text);
248
200
  const Request = IDL.Record({
249
201
  'url' : IDL.Text,
@@ -298,23 +250,18 @@ export const idlFactory = ({ IDL }) => {
298
250
  });
299
251
  const Result_1 = IDL.Variant({ 'ok' : PublishingId, 'err' : Err });
300
252
  const HttpHeader = IDL.Record({ 'value' : IDL.Text, 'name' : IDL.Text });
301
- const HttpResponse = IDL.Record({
253
+ const HttpRequestResult = IDL.Record({
302
254
  'status' : IDL.Nat,
303
255
  'body' : IDL.Vec(IDL.Nat8),
304
256
  'headers' : IDL.Vec(HttpHeader),
305
257
  });
306
- const HttpTransformArg = IDL.Record({
258
+ const TransformArg = IDL.Record({
307
259
  'context' : IDL.Vec(IDL.Nat8),
308
- 'response' : HttpResponse,
309
- });
310
- const Benchmarks = IDL.Vec(Benchmark);
311
- const TestStats = IDL.Record({
312
- 'passedNames' : IDL.Vec(IDL.Text),
313
- 'passed' : IDL.Nat,
260
+ 'response' : HttpRequestResult,
314
261
  });
315
262
  const Main = IDL.Service({
316
- 'addMaintainer' : IDL.Func([PackageName__1, IDL.Principal], [Result_3], []),
317
- 'addOwner' : IDL.Func([PackageName__1, IDL.Principal], [Result_3], []),
263
+ 'addMaintainer' : IDL.Func([PackageName, IDL.Principal], [Result_3], []),
264
+ 'addOwner' : IDL.Func([PackageName, IDL.Principal], [Result_3], []),
318
265
  'backup' : IDL.Func([], [], []),
319
266
  'computeHashesForExistingFiles' : IDL.Func([], [], []),
320
267
  'finishPublish' : IDL.Func([PublishingId], [Result], []),
@@ -322,24 +269,20 @@ export const idlFactory = ({ IDL }) => {
322
269
  'getBackupCanisterId' : IDL.Func([], [IDL.Principal], ['query']),
323
270
  'getDefaultPackages' : IDL.Func(
324
271
  [IDL.Text],
325
- [IDL.Vec(IDL.Tuple(PackageName__1, PackageVersion__1))],
272
+ [IDL.Vec(IDL.Tuple(PackageName, PackageVersion))],
326
273
  ['query'],
327
274
  ),
328
275
  'getDownloadTrendByPackageId' : IDL.Func(
329
276
  [PackageId],
330
- [IDL.Vec(DownloadsSnapshot__1)],
277
+ [IDL.Vec(DownloadsSnapshot)],
331
278
  ['query'],
332
279
  ),
333
280
  'getDownloadTrendByPackageName' : IDL.Func(
334
- [PackageName__1],
335
- [IDL.Vec(DownloadsSnapshot__1)],
281
+ [PackageName],
282
+ [IDL.Vec(DownloadsSnapshot)],
336
283
  ['query'],
337
284
  ),
338
- 'getFileHashes' : IDL.Func(
339
- [PackageName__1, PackageVersion__1],
340
- [Result_8],
341
- [],
342
- ),
285
+ 'getFileHashes' : IDL.Func([PackageName, PackageVersion], [Result_8], []),
343
286
  'getFileHashesByPackageIds' : IDL.Func(
344
287
  [IDL.Vec(PackageId)],
345
288
  [
@@ -350,21 +293,21 @@ export const idlFactory = ({ IDL }) => {
350
293
  [],
351
294
  ),
352
295
  'getFileHashesQuery' : IDL.Func(
353
- [PackageName__1, PackageVersion__1],
296
+ [PackageName, PackageVersion],
354
297
  [Result_8],
355
298
  ['query'],
356
299
  ),
357
300
  'getFileIds' : IDL.Func(
358
- [PackageName__1, PackageVersion__1],
301
+ [PackageName, PackageVersion],
359
302
  [Result_7],
360
303
  ['query'],
361
304
  ),
362
305
  'getHighestSemverBatch' : IDL.Func(
363
- [IDL.Vec(IDL.Tuple(PackageName__1, PackageVersion__1, SemverPart))],
306
+ [IDL.Vec(IDL.Tuple(PackageName, PackageVersion, SemverPart))],
364
307
  [Result_6],
365
308
  ['query'],
366
309
  ),
367
- 'getHighestVersion' : IDL.Func([PackageName__1], [Result_5], ['query']),
310
+ 'getHighestVersion' : IDL.Func([PackageName], [Result_5], ['query']),
368
311
  'getMostDownloadedPackages' : IDL.Func(
369
312
  [],
370
313
  [IDL.Vec(PackageSummary)],
@@ -376,21 +319,31 @@ export const idlFactory = ({ IDL }) => {
376
319
  ['query'],
377
320
  ),
378
321
  'getNewPackages' : IDL.Func([], [IDL.Vec(PackageSummary)], ['query']),
322
+ 'getPackageDependents' : IDL.Func(
323
+ [PackageName, IDL.Nat, IDL.Nat],
324
+ [IDL.Vec(PackageSummary), IDL.Nat],
325
+ ['query'],
326
+ ),
379
327
  'getPackageDetails' : IDL.Func(
380
- [PackageName__1, PackageVersion__1],
328
+ [PackageName, PackageVersion],
381
329
  [Result_4],
382
330
  ['query'],
383
331
  ),
384
332
  'getPackageMaintainers' : IDL.Func(
385
- [PackageName__1],
333
+ [PackageName],
386
334
  [IDL.Vec(IDL.Principal)],
387
335
  ['query'],
388
336
  ),
389
337
  'getPackageOwners' : IDL.Func(
390
- [PackageName__1],
338
+ [PackageName],
391
339
  [IDL.Vec(IDL.Principal)],
392
340
  ['query'],
393
341
  ),
342
+ 'getPackageVersionHistory' : IDL.Func(
343
+ [PackageName],
344
+ [IDL.Vec(PackageSummaryWithChanges)],
345
+ ['query'],
346
+ ),
394
347
  'getPackagesByCategory' : IDL.Func(
395
348
  [],
396
349
  [IDL.Vec(IDL.Tuple(IDL.Text, IDL.Vec(PackageSummary)))],
@@ -408,24 +361,16 @@ export const idlFactory = ({ IDL }) => {
408
361
  ),
409
362
  'getTotalDownloads' : IDL.Func([], [IDL.Nat], ['query']),
410
363
  'getTotalPackages' : IDL.Func([], [IDL.Nat], ['query']),
411
- 'getUser' : IDL.Func([IDL.Principal], [IDL.Opt(User__1)], ['query']),
364
+ 'getUser' : IDL.Func([IDL.Principal], [IDL.Opt(User)], ['query']),
412
365
  'http_request' : IDL.Func([Request], [Response], ['query']),
413
- 'notifyInstall' : IDL.Func(
414
- [PackageName__1, PackageVersion__1],
415
- [],
416
- ['oneway'],
417
- ),
366
+ 'notifyInstall' : IDL.Func([PackageName, PackageVersion], [], ['oneway']),
418
367
  'notifyInstalls' : IDL.Func(
419
- [IDL.Vec(IDL.Tuple(PackageName__1, PackageVersion__1))],
368
+ [IDL.Vec(IDL.Tuple(PackageName, PackageVersion))],
420
369
  [],
421
370
  ['oneway'],
422
371
  ),
423
- 'removeMaintainer' : IDL.Func(
424
- [PackageName__1, IDL.Principal],
425
- [Result_3],
426
- [],
427
- ),
428
- 'removeOwner' : IDL.Func([PackageName__1, IDL.Principal], [Result_3], []),
372
+ 'removeMaintainer' : IDL.Func([PackageName, IDL.Principal], [Result_3], []),
373
+ 'removeOwner' : IDL.Func([PackageName, IDL.Principal], [Result_3], []),
429
374
  'restore' : IDL.Func([IDL.Nat], [], []),
430
375
  'search' : IDL.Func(
431
376
  [Text, IDL.Opt(IDL.Nat), IDL.Opt(IDL.Nat)],
@@ -440,9 +385,10 @@ export const idlFactory = ({ IDL }) => {
440
385
  [],
441
386
  ),
442
387
  'startPublish' : IDL.Func([PackageConfigV3_Publishing], [Result_1], []),
388
+ 'takeSnapshotsIfNeeded' : IDL.Func([], [], []),
443
389
  'transformRequest' : IDL.Func(
444
- [HttpTransformArg],
445
- [HttpResponse],
390
+ [TransformArg],
391
+ [HttpRequestResult],
446
392
  ['query'],
447
393
  ),
448
394
  'uploadBenchmarks' : IDL.Func([PublishingId, Benchmarks], [Result], []),
@@ -3,9 +3,9 @@ import type {
3
3
  HttpAgentOptions,
4
4
  ActorConfig,
5
5
  Agent,
6
- } from "@dfinity/agent";
7
- import type { Principal } from "@dfinity/principal";
8
- import type { IDL } from "@dfinity/candid";
6
+ } from "@icp-sdk/core/agent";
7
+ import type { Principal } from "@icp-sdk/core/principal";
8
+ import type { IDL } from "@icp-sdk/core/candid";
9
9
 
10
10
  import { _SERVICE } from './storage.did';
11
11
 
@@ -1,4 +1,4 @@
1
- import { Actor, HttpAgent } from "@dfinity/agent";
1
+ import { Actor, HttpAgent } from "@icp-sdk/core/agent";
2
2
 
3
3
  // Imports and re-exports candid interface
4
4
  import { idlFactory } from './storage.did.js';
@@ -6,9 +6,9 @@ export { idlFactory } from './storage.did.js';
6
6
 
7
7
  /**
8
8
  *
9
- * @param {string | import("@dfinity/principal").Principal} canisterId Canister ID of Agent
10
- * @param {{agentOptions?: import("@dfinity/agent").HttpAgentOptions; actorOptions?: import("@dfinity/agent").ActorConfig}} [options]
11
- * @return {import("@dfinity/agent").ActorSubclass<import("./storage.did.js")._SERVICE>}
9
+ * @param {string | import("@icp-sdk/core/principal").Principal} canisterId Canister ID of Agent
10
+ * @param {{agentOptions?: import("@icp-sdk/core/agent").HttpAgentOptions; actorOptions?: import("@icp-sdk/core/agent").ActorConfig}} [options]
11
+ * @return {import("@icp-sdk/core/agent").ActorSubclass<import("./storage.did.js")._SERVICE>}
12
12
  */
13
13
  export const createActor = (canisterId, options) => {
14
14
  const agent = new HttpAgent({ ...options?.agentOptions });
@@ -1,6 +1,6 @@
1
- import type { Principal } from '@dfinity/principal';
2
- import type { ActorMethod } from '@dfinity/agent';
3
- import type { IDL } from '@dfinity/candid';
1
+ import type { Principal } from '@icp-sdk/core/principal';
2
+ import type { ActorMethod } from '@icp-sdk/core/agent';
3
+ import type { IDL } from '@icp-sdk/core/candid';
4
4
 
5
5
  export type Chunk = Array<number>;
6
6
  export type Err = string;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ic-mops",
3
- "version": "1.9.0",
3
+ "version": "1.11.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mops": "bin/mops.js",
@@ -1,15 +1,15 @@
1
1
  module {
2
- // This comment will not be included in the documentation
3
- // Use triple slash for documentation
2
+ // This comment will not be included in the documentation
3
+ // Use triple slash for documentation
4
4
 
5
- /// Add two natural numbers
6
- ///
7
- /// Example:
8
- /// ```motoko
9
- /// assert add(1, 2) == 3;
10
- /// assert add(7, 3) == 10;
11
- /// ```
12
- public func add(x : Nat, y : Nat) : Nat {
13
- return x + y;
14
- };
15
- };
5
+ /// Add two natural numbers
6
+ ///
7
+ /// Example:
8
+ /// ```motoko
9
+ /// assert add(1, 2) == 3;
10
+ /// assert add(7, 3) == 10;
11
+ /// ```
12
+ public func add(x : Nat, y : Nat) : Nat {
13
+ return x + y;
14
+ };
15
+ };
@@ -1,4 +1,4 @@
1
- import { add } "../src";
1
+ import {add} "../src";
2
2
 
3
3
  assert add(1, 2) == 3;
4
- assert add(3, 22) == 25;
4
+ assert add(3, 22) == 25;
package/commands/add.ts CHANGED
@@ -83,7 +83,7 @@ export async function add(name : string, {verbose = false, dev = false, lock} :
83
83
  }
84
84
 
85
85
  pkgDetails = {
86
- name: name,
86
+ name: asName || name,
87
87
  repo: '',
88
88
  version: ver,
89
89
  };
@@ -2,7 +2,8 @@ import process from 'node:process';
2
2
  import chalk from 'chalk';
3
3
  import {mainActor} from '../api/actors.js';
4
4
  import {Config} from '../types.js';
5
- import {getDepName} from '../helpers/get-dep-name.js';
5
+ import {getDepName, getDepPinnedVersion} from '../helpers/get-dep-name.js';
6
+ import {SemverPart} from '../declarations/main/main.did.js';
6
7
 
7
8
  // [pkg, oldVersion, newVersion]
8
9
  export async function getAvailableUpdates(config : Config, pkg ?: string) : Promise<Array<[string, string, string]>> {
@@ -11,12 +12,16 @@ export async function getAvailableUpdates(config : Config, pkg ?: string) : Prom
11
12
  let allDeps = [...deps, ...devDeps].filter((dep) => dep.version);
12
13
  let depsToUpdate = pkg ? allDeps.filter((dep) => dep.name === pkg) : allDeps;
13
14
 
14
- // skip pinned dependencies
15
- depsToUpdate = depsToUpdate.filter((dep) => getDepName(dep.name) === dep.name);
15
+ // skip hard pinned dependencies (e.g. "base@X.Y.Z")
16
+ depsToUpdate = depsToUpdate.filter((dep) => getDepName(dep.name) === dep.name || getDepPinnedVersion(dep.name).split('.').length !== 3);
16
17
 
17
- let getCurrentVersion = (pkg : string) => {
18
+ let getCurrentVersion = (pkg : string, updateVersion : string) => {
18
19
  for (let dep of allDeps) {
19
- if (dep.name === pkg && dep.version) {
20
+ if (getDepName(dep.name) === pkg && dep.version) {
21
+ let pinnedVersion = getDepPinnedVersion(dep.name);
22
+ if (pinnedVersion && !updateVersion.startsWith(pinnedVersion)) {
23
+ continue;
24
+ }
20
25
  return dep.version;
21
26
  }
22
27
  }
@@ -24,12 +29,20 @@ export async function getAvailableUpdates(config : Config, pkg ?: string) : Prom
24
29
  };
25
30
 
26
31
  let actor = await mainActor();
27
- let res = await actor.getHighestSemverBatch(depsToUpdate.map((dep) => [dep.name, dep.version || '', {major: null}]));
32
+ let res = await actor.getHighestSemverBatch(depsToUpdate.map((dep) => {
33
+ let semverPart : SemverPart = {major: null};
34
+ let name = getDepName(dep.name);
35
+ let pinnedVersion = getDepPinnedVersion(dep.name);
36
+ if (pinnedVersion) {
37
+ semverPart = pinnedVersion.split('.').length === 1 ? {minor: null} : {patch: null};
38
+ }
39
+ return [name, dep.version || '', semverPart];
40
+ }));
28
41
 
29
42
  if ('err' in res) {
30
43
  console.log(chalk.red('Error:'), res.err);
31
44
  process.exit(1);
32
45
  }
33
46
 
34
- return res.ok.filter((dep) => dep[1] !== getCurrentVersion(dep[0])).map((dep) => [dep[0], getCurrentVersion(dep[0]), dep[1]]);
47
+ return res.ok.filter((dep) => dep[1] !== getCurrentVersion(dep[0], dep[1])).map((dep) => [dep[0], getCurrentVersion(dep[0], dep[1]), dep[1]]);
35
48
  }
@@ -4,6 +4,7 @@ import path from 'node:path';
4
4
  import fs from 'node:fs';
5
5
  import {execaCommand} from 'execa';
6
6
  import {PocketIc, PocketIcServer} from 'pic-ic';
7
+ import {PocketIc as PocketIcMops, PocketIcServer as PocketIcServerMops} from 'pic-js-mops';
7
8
  import {getRootDir, readConfig} from '../mops.js';
8
9
  import {createActor, idlFactory} from '../declarations/bench/index.js';
9
10
  import {toolchain} from './toolchain/index.js';
@@ -13,8 +14,8 @@ export class BenchReplica {
13
14
  type : 'dfx' | 'pocket-ic' | 'dfx-pocket-ic';
14
15
  verbose = false;
15
16
  canisters : Record<string, {cwd : string; canisterId : string; actor : any;}> = {};
16
- pocketIcServer ?: PocketIcServer;
17
- pocketIc ?: PocketIc;
17
+ pocketIcServer ?: PocketIcServer | PocketIcServerMops;
18
+ pocketIc ?: PocketIc | PocketIcMops;
18
19
 
19
20
  constructor(type : 'dfx' | 'pocket-ic' | 'dfx-pocket-ic', verbose = false) {
20
21
  this.type = type;
@@ -35,14 +36,24 @@ export class BenchReplica {
35
36
  else {
36
37
  let pocketIcBin = await toolchain.bin('pocket-ic');
37
38
  let config = readConfig();
38
- if (config.toolchain?.['pocket-ic'] !== '4.0.0') {
39
- console.error('Current Mops CLI only supports pocket-ic 4.0.0');
39
+ if (config.toolchain?.['pocket-ic'] !== '4.0.0' && !config.toolchain?.['pocket-ic']?.startsWith('9.')) {
40
+ console.error('Current Mops CLI only supports pocket-ic 9.x.x and 4.0.0');
40
41
  process.exit(1);
41
42
  }
42
- this.pocketIcServer = await PocketIcServer.start({
43
- binPath: pocketIcBin,
44
- });
45
- this.pocketIc = await PocketIc.create(this.pocketIcServer.getUrl());
43
+ // pocket-ic 9.x.x
44
+ if (config.toolchain?.['pocket-ic']?.startsWith('9.')) {
45
+ this.pocketIcServer = await PocketIcServerMops.start({
46
+ binPath: pocketIcBin,
47
+ });
48
+ this.pocketIc = await PocketIcMops.create(this.pocketIcServer.getUrl());
49
+ }
50
+ // pocket-ic 4.0.0
51
+ else {
52
+ this.pocketIcServer = await PocketIcServer.start({
53
+ binPath: pocketIcBin,
54
+ });
55
+ this.pocketIc = await PocketIc.create(this.pocketIcServer.getUrl());
56
+ }
46
57
  }
47
58
  }
48
59
 
@@ -69,7 +80,8 @@ export class BenchReplica {
69
80
  this.canisters[name] = {cwd, canisterId, actor};
70
81
  }
71
82
  else if (this.pocketIc) {
72
- let {canisterId, actor} = await this.pocketIc.setupCanister({idlFactory, wasm});
83
+ type PocketIcSetupCanister = PocketIcMops['setupCanister'] & PocketIc['setupCanister'];
84
+ let {canisterId, actor} = await (this.pocketIc.setupCanister as PocketIcSetupCanister)({idlFactory, wasm});
73
85
  this.canisters[name] = {
74
86
  cwd,
75
87
  canisterId: canisterId.toText(),
@@ -2,7 +2,7 @@ import process from 'node:process';
2
2
  import chalk from 'chalk';
3
3
  import {checkConfigFile, getIdentity, readConfig} from '../mops.js';
4
4
  import {mainActor} from '../api/actors.js';
5
- import {Principal} from '@dfinity/principal';
5
+ import {Principal} from '@icp-sdk/core/principal';
6
6
  import prompts from 'prompts';
7
7
 
8
8
  export async function printMaintainers() {
@@ -1,6 +1,7 @@
1
1
  import chalk from 'chalk';
2
2
  import {checkConfigFile, readConfig} from '../mops.js';
3
3
  import {getAvailableUpdates} from './available-updates.js';
4
+ import {getDepName, getDepPinnedVersion} from '../helpers/get-dep-name.js';
4
5
 
5
6
  export async function outdated() {
6
7
  if (!checkConfigFile()) {
@@ -15,8 +16,14 @@ export async function outdated() {
15
16
  }
16
17
  else {
17
18
  console.log('Available updates:');
19
+ let allDeps = [...Object.keys(config.dependencies || {}), ...Object.keys(config['dev-dependencies'] || {})];
18
20
  for (let dep of available) {
19
- console.log(`${dep[0]} ${chalk.yellow(dep[1])} -> ${chalk.green(dep[2])}`);
21
+ let name = allDeps.find((d) => {
22
+ let pinnedVersion = getDepPinnedVersion(d);
23
+ return getDepName(d) === dep[0] && (!pinnedVersion || dep[1].startsWith(pinnedVersion));
24
+ }) || dep[0];
25
+
26
+ console.log(`${name} ${chalk.yellow(dep[1])} -> ${chalk.green(dep[2])}`);
20
27
  }
21
28
  }
22
29
  }
package/commands/owner.ts CHANGED
@@ -2,7 +2,7 @@ import process from 'node:process';
2
2
  import chalk from 'chalk';
3
3
  import {checkConfigFile, getIdentity, readConfig} from '../mops.js';
4
4
  import {mainActor} from '../api/actors.js';
5
- import {Principal} from '@dfinity/principal';
5
+ import {Principal} from '@icp-sdk/core/principal';
6
6
  import prompts from 'prompts';
7
7
 
8
8
  export async function printOwners() {