ic-mops 1.11.1 → 2.0.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 (352) hide show
  1. package/.DS_Store +0 -0
  2. package/.eslintrc.json +7 -7
  3. package/CHANGELOG.md +15 -0
  4. package/api/actors.ts +41 -37
  5. package/api/downloadPackageFiles.ts +75 -61
  6. package/api/getHighestVersion.ts +5 -5
  7. package/api/index.ts +4 -4
  8. package/api/network.ts +19 -21
  9. package/api/resolveVersion.ts +14 -11
  10. package/bin/mops.js +1 -1
  11. package/bun.lock +234 -198
  12. package/bundle/bench/bench-canister.mo +2 -2
  13. package/bundle/bench/user-bench.mo +0 -4
  14. package/bundle/bin/mops.js +1 -1
  15. package/bundle/cli.js +1000 -924
  16. package/bundle/cli.tgz +0 -0
  17. package/bundle/declarations/bench/bench.did +3 -3
  18. package/bundle/declarations/bench/bench.did.d.ts +3 -3
  19. package/bundle/declarations/bench/index.d.ts +3 -3
  20. package/bundle/declarations/bench/index.js +1 -1
  21. package/bundle/declarations/main/index.d.ts +3 -3
  22. package/bundle/declarations/main/index.js +1 -1
  23. package/bundle/declarations/main/main.did +78 -121
  24. package/bundle/declarations/main/main.did.d.ts +48 -98
  25. package/bundle/declarations/main/main.did.js +53 -107
  26. package/bundle/declarations/storage/index.d.ts +3 -3
  27. package/bundle/declarations/storage/index.js +4 -4
  28. package/bundle/declarations/storage/storage.did.d.ts +3 -3
  29. package/bundle/package.json +6 -5
  30. package/bundle/templates/mops-publish.yml +3 -3
  31. package/bundle/templates/mops-test.yml +3 -3
  32. package/bundle-package-json.ts +8 -8
  33. package/cache.ts +80 -65
  34. package/check-requirements.ts +49 -45
  35. package/cli.ts +577 -376
  36. package/commands/add.ts +142 -129
  37. package/commands/available-updates.ts +55 -28
  38. package/commands/bench/bench-canister.mo +114 -108
  39. package/commands/bench/user-bench.mo +6 -6
  40. package/commands/bench-replica.ts +146 -106
  41. package/commands/bench.ts +563 -497
  42. package/commands/build.ts +177 -0
  43. package/commands/bump.ts +68 -57
  44. package/commands/check-candid.ts +24 -0
  45. package/commands/docs-coverage.ts +124 -102
  46. package/commands/docs.ts +118 -108
  47. package/commands/format.ts +171 -155
  48. package/commands/init.ts +301 -275
  49. package/commands/install/install-all.ts +75 -62
  50. package/commands/install/install-dep.ts +43 -28
  51. package/commands/install/install-deps.ts +23 -15
  52. package/commands/install/install-local-dep.ts +42 -34
  53. package/commands/install/install-mops-dep.ts +154 -123
  54. package/commands/install/sync-local-cache.ts +39 -35
  55. package/commands/maintainer.ts +109 -99
  56. package/commands/outdated.ts +31 -18
  57. package/commands/owner.ts +107 -99
  58. package/commands/publish.ts +534 -443
  59. package/commands/remove.ts +119 -89
  60. package/commands/replica.ts +391 -303
  61. package/commands/search.ts +42 -36
  62. package/commands/self.ts +63 -56
  63. package/commands/sources.ts +66 -49
  64. package/commands/sync.ts +92 -75
  65. package/commands/template.ts +145 -102
  66. package/commands/test/mmf1.ts +146 -119
  67. package/commands/test/reporters/compact-reporter.ts +87 -84
  68. package/commands/test/reporters/files-reporter.ts +56 -51
  69. package/commands/test/reporters/reporter.ts +12 -6
  70. package/commands/test/reporters/silent-reporter.ts +58 -59
  71. package/commands/test/reporters/verbose-reporter.ts +66 -54
  72. package/commands/test/test.ts +497 -460
  73. package/commands/test/utils.ts +85 -6
  74. package/commands/toolchain/index.ts +363 -322
  75. package/commands/toolchain/moc.ts +78 -50
  76. package/commands/toolchain/pocket-ic.ts +41 -34
  77. package/commands/toolchain/toolchain-utils.ts +92 -72
  78. package/commands/toolchain/wasmtime.ts +37 -34
  79. package/commands/update.ts +91 -56
  80. package/commands/user.ts +90 -81
  81. package/commands/watch/deployer.ts +188 -152
  82. package/commands/watch/error-checker.ts +90 -80
  83. package/commands/watch/formatter.ts +72 -60
  84. package/commands/watch/generator.ts +116 -96
  85. package/commands/watch/globMoFiles.ts +13 -13
  86. package/commands/watch/parseDfxJson.ts +63 -57
  87. package/commands/watch/tester.ts +83 -65
  88. package/commands/watch/warning-checker.ts +149 -136
  89. package/commands/watch/watch.ts +123 -95
  90. package/declarations/bench/bench.did.d.ts +3 -3
  91. package/declarations/bench/index.d.ts +3 -3
  92. package/declarations/bench/index.js +1 -1
  93. package/declarations/main/index.d.ts +3 -3
  94. package/declarations/main/index.js +1 -1
  95. package/declarations/main/main.did.d.ts +3 -3
  96. package/declarations/storage/index.d.ts +3 -3
  97. package/declarations/storage/index.js +4 -4
  98. package/declarations/storage/storage.did.d.ts +3 -3
  99. package/dist/api/actors.d.ts +4 -4
  100. package/dist/api/actors.js +8 -8
  101. package/dist/api/downloadPackageFiles.d.ts +2 -2
  102. package/dist/api/downloadPackageFiles.js +10 -10
  103. package/dist/api/getHighestVersion.js +1 -1
  104. package/dist/api/index.d.ts +4 -4
  105. package/dist/api/index.js +4 -4
  106. package/dist/api/network.js +9 -9
  107. package/dist/api/resolveVersion.js +3 -3
  108. package/dist/bin/mops.js +1 -1
  109. package/dist/bundle-package-json.js +8 -8
  110. package/dist/cache.js +22 -17
  111. package/dist/check-requirements.js +11 -11
  112. package/dist/cli.js +283 -186
  113. package/dist/commands/add.d.ts +1 -1
  114. package/dist/commands/add.js +41 -38
  115. package/dist/commands/available-updates.d.ts +1 -1
  116. package/dist/commands/available-updates.js +32 -14
  117. package/dist/commands/bench/bench-canister.mo +114 -108
  118. package/dist/commands/bench/user-bench.mo +6 -6
  119. package/dist/commands/bench-replica.d.ts +6 -5
  120. package/dist/commands/bench-replica.js +58 -36
  121. package/dist/commands/bench.d.ts +5 -5
  122. package/dist/commands/bench.js +134 -118
  123. package/dist/commands/build.d.ts +7 -0
  124. package/dist/commands/build.js +121 -0
  125. package/dist/commands/bump.js +27 -18
  126. package/dist/commands/check-candid.d.ts +4 -0
  127. package/dist/commands/check-candid.js +15 -0
  128. package/dist/commands/docs-coverage.d.ts +1 -1
  129. package/dist/commands/docs-coverage.js +45 -31
  130. package/dist/commands/docs.d.ts +1 -1
  131. package/dist/commands/docs.js +39 -38
  132. package/dist/commands/format.js +31 -27
  133. package/dist/commands/init.js +102 -92
  134. package/dist/commands/install/install-all.d.ts +2 -2
  135. package/dist/commands/install/install-all.js +23 -21
  136. package/dist/commands/install/install-dep.d.ts +1 -1
  137. package/dist/commands/install/install-dep.js +21 -8
  138. package/dist/commands/install/install-deps.d.ts +1 -1
  139. package/dist/commands/install/install-deps.js +1 -1
  140. package/dist/commands/install/install-local-dep.js +11 -9
  141. package/dist/commands/install/install-mops-dep.d.ts +1 -1
  142. package/dist/commands/install/install-mops-dep.js +32 -27
  143. package/dist/commands/install/sync-local-cache.js +10 -10
  144. package/dist/commands/maintainer.js +21 -21
  145. package/dist/commands/outdated.js +16 -6
  146. package/dist/commands/owner.js +21 -21
  147. package/dist/commands/publish.js +148 -128
  148. package/dist/commands/remove.d.ts +1 -1
  149. package/dist/commands/remove.js +42 -30
  150. package/dist/commands/replica.d.ts +9 -8
  151. package/dist/commands/replica.js +105 -65
  152. package/dist/commands/search.js +15 -13
  153. package/dist/commands/self.js +31 -28
  154. package/dist/commands/sources.d.ts +5 -1
  155. package/dist/commands/sources.js +23 -17
  156. package/dist/commands/sync.d.ts +1 -1
  157. package/dist/commands/sync.js +38 -25
  158. package/dist/commands/template.js +66 -56
  159. package/dist/commands/test/mmf1.d.ts +3 -3
  160. package/dist/commands/test/mmf1.js +33 -31
  161. package/dist/commands/test/reporters/compact-reporter.d.ts +3 -3
  162. package/dist/commands/test/reporters/compact-reporter.js +19 -15
  163. package/dist/commands/test/reporters/files-reporter.d.ts +3 -3
  164. package/dist/commands/test/reporters/files-reporter.js +18 -14
  165. package/dist/commands/test/reporters/reporter.d.ts +2 -2
  166. package/dist/commands/test/reporters/silent-reporter.d.ts +3 -3
  167. package/dist/commands/test/reporters/silent-reporter.js +4 -4
  168. package/dist/commands/test/reporters/verbose-reporter.d.ts +3 -3
  169. package/dist/commands/test/reporters/verbose-reporter.js +17 -13
  170. package/dist/commands/test/test.d.ts +4 -4
  171. package/dist/commands/test/test.js +151 -181
  172. package/dist/commands/test/utils.d.ts +6 -0
  173. package/dist/commands/test/utils.js +63 -2
  174. package/dist/commands/toolchain/index.d.ts +1 -1
  175. package/dist/commands/toolchain/index.js +81 -69
  176. package/dist/commands/toolchain/moc.d.ts +1 -1
  177. package/dist/commands/toolchain/moc.js +48 -24
  178. package/dist/commands/toolchain/pocket-ic.js +12 -12
  179. package/dist/commands/toolchain/toolchain-utils.d.ts +2 -0
  180. package/dist/commands/toolchain/toolchain-utils.js +32 -23
  181. package/dist/commands/toolchain/wasmtime.js +11 -11
  182. package/dist/commands/update.d.ts +1 -1
  183. package/dist/commands/update.js +30 -12
  184. package/dist/commands/user.js +31 -28
  185. package/dist/commands/watch/deployer.d.ts +4 -4
  186. package/dist/commands/watch/deployer.js +45 -36
  187. package/dist/commands/watch/error-checker.d.ts +2 -2
  188. package/dist/commands/watch/error-checker.js +27 -27
  189. package/dist/commands/watch/formatter.d.ts +4 -4
  190. package/dist/commands/watch/formatter.js +17 -17
  191. package/dist/commands/watch/generator.d.ts +3 -3
  192. package/dist/commands/watch/generator.js +28 -23
  193. package/dist/commands/watch/globMoFiles.js +8 -8
  194. package/dist/commands/watch/parseDfxJson.d.ts +2 -2
  195. package/dist/commands/watch/parseDfxJson.js +9 -9
  196. package/dist/commands/watch/tester.d.ts +4 -4
  197. package/dist/commands/watch/tester.js +23 -21
  198. package/dist/commands/watch/warning-checker.d.ts +3 -3
  199. package/dist/commands/watch/warning-checker.js +36 -36
  200. package/dist/commands/watch/watch.js +45 -32
  201. package/dist/declarations/bench/bench.did.d.ts +3 -3
  202. package/dist/declarations/bench/index.d.ts +3 -3
  203. package/dist/declarations/bench/index.js +1 -1
  204. package/dist/declarations/main/index.d.ts +3 -3
  205. package/dist/declarations/main/index.js +1 -1
  206. package/dist/declarations/main/main.did.d.ts +3 -3
  207. package/dist/declarations/storage/index.d.ts +3 -3
  208. package/dist/declarations/storage/index.js +4 -4
  209. package/dist/declarations/storage/storage.did.d.ts +3 -3
  210. package/dist/environments/nodejs/cli.d.ts +1 -0
  211. package/dist/environments/nodejs/cli.js +4 -0
  212. package/dist/environments/web/cli.d.ts +1 -0
  213. package/dist/environments/web/cli.js +4 -0
  214. package/dist/error.d.ts +1 -0
  215. package/dist/error.js +5 -0
  216. package/dist/fix-dist.js +5 -5
  217. package/dist/helpers/find-changelog-entry.js +8 -5
  218. package/dist/helpers/get-dep-name.d.ts +1 -0
  219. package/dist/helpers/get-dep-name.js +4 -1
  220. package/dist/helpers/get-dfx-version.js +4 -4
  221. package/dist/helpers/get-moc-path.js +8 -7
  222. package/dist/helpers/get-moc-version.js +10 -7
  223. package/dist/helpers/get-package-id.js +2 -2
  224. package/dist/helpers/is-candid-compatible.d.ts +1 -0
  225. package/dist/helpers/is-candid-compatible.js +20 -0
  226. package/dist/integrity.d.ts +1 -1
  227. package/dist/integrity.js +47 -38
  228. package/dist/jest.config.d.ts +11 -0
  229. package/dist/jest.config.js +14 -0
  230. package/dist/mops.d.ts +6 -6
  231. package/dist/mops.js +87 -80
  232. package/dist/notify-installs.js +4 -4
  233. package/dist/package.json +11 -10
  234. package/dist/pem.d.ts +3 -3
  235. package/dist/pem.js +20 -12
  236. package/dist/release-cli.js +20 -20
  237. package/dist/resolve-packages.d.ts +1 -1
  238. package/dist/resolve-packages.js +52 -36
  239. package/dist/templates/mops-publish.yml +3 -3
  240. package/dist/templates/mops-test.yml +3 -3
  241. package/dist/templates/src/lib.mo +13 -13
  242. package/dist/templates/test/lib.test.mo +2 -2
  243. package/dist/templates.js +1 -1
  244. package/dist/tests/cli.test.d.ts +1 -0
  245. package/dist/tests/cli.test.js +63 -0
  246. package/dist/types.d.ts +14 -4
  247. package/dist/vessel.d.ts +2 -2
  248. package/dist/vessel.js +41 -34
  249. package/dist/wasm/pkg/bundler/package.json +20 -0
  250. package/dist/wasm/pkg/bundler/wasm.d.ts +3 -0
  251. package/dist/wasm/pkg/bundler/wasm.js +5 -0
  252. package/dist/wasm/pkg/bundler/wasm_bg.js +93 -0
  253. package/dist/wasm/pkg/bundler/wasm_bg.wasm +0 -0
  254. package/dist/wasm/pkg/bundler/wasm_bg.wasm.d.ts +8 -0
  255. package/dist/wasm/pkg/nodejs/package.json +14 -0
  256. package/dist/wasm/pkg/nodejs/wasm.d.ts +3 -0
  257. package/dist/wasm/pkg/nodejs/wasm.js +98 -0
  258. package/dist/wasm/pkg/nodejs/wasm_bg.wasm +0 -0
  259. package/dist/wasm/pkg/nodejs/wasm_bg.wasm.d.ts +8 -0
  260. package/dist/wasm/pkg/web/package.json +18 -0
  261. package/dist/wasm/pkg/web/wasm.d.ts +35 -0
  262. package/dist/wasm/pkg/web/wasm.js +191 -0
  263. package/dist/wasm/pkg/web/wasm_bg.wasm +0 -0
  264. package/dist/wasm/pkg/web/wasm_bg.wasm.d.ts +8 -0
  265. package/dist/wasm.d.ts +5 -0
  266. package/dist/wasm.js +10 -0
  267. package/environments/nodejs/cli.ts +6 -0
  268. package/environments/web/cli.ts +6 -0
  269. package/error.ts +6 -0
  270. package/fix-dist.ts +5 -5
  271. package/global.d.ts +3 -3
  272. package/helpers/find-changelog-entry.ts +26 -23
  273. package/helpers/get-dep-name.ts +7 -3
  274. package/helpers/get-dfx-version.ts +8 -9
  275. package/helpers/get-moc-path.ts +25 -26
  276. package/helpers/get-moc-version.ts +21 -19
  277. package/helpers/get-package-id.ts +4 -4
  278. package/helpers/is-candid-compatible.ts +22 -0
  279. package/integrity.ts +270 -236
  280. package/jest.config.js +14 -0
  281. package/mops.ts +238 -215
  282. package/notify-installs.ts +16 -17
  283. package/package.json +21 -15
  284. package/parallel.ts +28 -24
  285. package/pem.ts +55 -47
  286. package/release-cli.ts +73 -39
  287. package/resolve-packages.ts +231 -189
  288. package/templates/mops-publish.yml +3 -3
  289. package/templates/mops-test.yml +3 -3
  290. package/templates/src/lib.mo +13 -13
  291. package/templates/test/lib.test.mo +2 -2
  292. package/templates.ts +4 -4
  293. package/tests/__snapshots__/cli.test.ts.snap +202 -0
  294. package/tests/build/error/candid/bar.did +3 -0
  295. package/tests/build/error/dfx.json +12 -0
  296. package/tests/build/error/mops.toml +9 -0
  297. package/tests/build/error/src/Bar.mo +5 -0
  298. package/tests/build/error/src/Foo.mo +5 -0
  299. package/tests/build/success/.dfx/local/canister_ids.json +17 -0
  300. package/tests/build/success/.dfx/local/canisters/bar/bar.did +3 -0
  301. package/tests/build/success/.dfx/local/canisters/bar/bar.most +4 -0
  302. package/tests/build/success/.dfx/local/canisters/bar/bar.wasm +0 -0
  303. package/tests/build/success/.dfx/local/canisters/bar/constructor.did +3 -0
  304. package/tests/build/success/.dfx/local/canisters/bar/index.js +42 -0
  305. package/tests/build/success/.dfx/local/canisters/bar/init_args.txt +1 -0
  306. package/tests/build/success/.dfx/local/canisters/bar/service.did +3 -0
  307. package/tests/build/success/.dfx/local/canisters/bar/service.did.d.ts +7 -0
  308. package/tests/build/success/.dfx/local/canisters/bar/service.did.js +4 -0
  309. package/tests/build/success/.dfx/local/canisters/foo/constructor.did +3 -0
  310. package/tests/build/success/.dfx/local/canisters/foo/foo.did +3 -0
  311. package/tests/build/success/.dfx/local/canisters/foo/foo.most +4 -0
  312. package/tests/build/success/.dfx/local/canisters/foo/foo.wasm +0 -0
  313. package/tests/build/success/.dfx/local/canisters/foo/index.js +42 -0
  314. package/tests/build/success/.dfx/local/canisters/foo/init_args.txt +1 -0
  315. package/tests/build/success/.dfx/local/canisters/foo/service.did +3 -0
  316. package/tests/build/success/.dfx/local/canisters/foo/service.did.d.ts +7 -0
  317. package/tests/build/success/.dfx/local/canisters/foo/service.did.js +4 -0
  318. package/tests/build/success/.dfx/local/lsp/ucwa4-rx777-77774-qaada-cai.did +3 -0
  319. package/tests/build/success/.dfx/local/lsp/ulvla-h7777-77774-qaacq-cai.did +3 -0
  320. package/tests/build/success/.dfx/local/network-id +4 -0
  321. package/tests/build/success/candid/bar.did +3 -0
  322. package/tests/build/success/dfx.json +12 -0
  323. package/tests/build/success/mops.toml +9 -0
  324. package/tests/build/success/src/Bar.mo +5 -0
  325. package/tests/build/success/src/Foo.mo +5 -0
  326. package/tests/check-candid/a.did +3 -0
  327. package/tests/check-candid/b.did +5 -0
  328. package/tests/check-candid/c.did +3 -0
  329. package/tests/cli.test.ts +82 -0
  330. package/tsconfig.json +26 -19
  331. package/types.ts +41 -31
  332. package/vessel.ts +219 -187
  333. package/wasm/Cargo.lock +1475 -0
  334. package/wasm/Cargo.toml +28 -0
  335. package/wasm/pkg/bundler/package.json +20 -0
  336. package/wasm/pkg/bundler/wasm.d.ts +3 -0
  337. package/wasm/pkg/bundler/wasm.js +5 -0
  338. package/wasm/pkg/bundler/wasm_bg.js +93 -0
  339. package/wasm/pkg/bundler/wasm_bg.wasm +0 -0
  340. package/wasm/pkg/bundler/wasm_bg.wasm.d.ts +8 -0
  341. package/wasm/pkg/nodejs/package.json +14 -0
  342. package/wasm/pkg/nodejs/wasm.d.ts +3 -0
  343. package/wasm/pkg/nodejs/wasm.js +98 -0
  344. package/wasm/pkg/nodejs/wasm_bg.wasm +0 -0
  345. package/wasm/pkg/nodejs/wasm_bg.wasm.d.ts +8 -0
  346. package/wasm/pkg/web/package.json +18 -0
  347. package/wasm/pkg/web/wasm.d.ts +35 -0
  348. package/wasm/pkg/web/wasm.js +191 -0
  349. package/wasm/pkg/web/wasm_bg.wasm +0 -0
  350. package/wasm/pkg/web/wasm_bg.wasm.d.ts +8 -0
  351. package/wasm/src/lib.rs +17 -0
  352. package/wasm.ts +16 -0
@@ -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.12.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mops": "bin/mops.js",
@@ -15,14 +15,15 @@
15
15
  "!build.sh",
16
16
  "!DEVELOPMENT.md",
17
17
  "!.mops",
18
- "/templates"
18
+ "/templates",
19
+ "/wasm"
19
20
  ],
20
21
  "homepage": "https://mops.one",
21
22
  "repository": {
22
23
  "type": "git",
23
- "url": "https://github.com/ZenVoich/mops.git"
24
+ "url": "https://github.com/dfinity/mops.git"
24
25
  },
25
- "author": "Zen Voich <zen.voich@gmail.com>",
26
+ "author": "DFINITY",
26
27
  "license": "MIT",
27
28
  "engines": {
28
29
  "node": ">=18.0.0"
@@ -32,4 +33,4 @@
32
33
  "decomp-tarxz": "0.1.1",
33
34
  "buffer": "6.0.3"
34
35
  }
35
- }
36
+ }
@@ -9,9 +9,9 @@ jobs:
9
9
  runs-on: ubuntu-latest
10
10
 
11
11
  steps:
12
- - uses: actions/checkout@v4
13
- - uses: ZenVoich/setup-mops@v1
12
+ - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
13
+ - uses: dfinity/setup-mops@v1
14
14
  with:
15
15
  # Make sure you set the MOPS_IDENTITY_PEM secret in your repository settings https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository
16
16
  identity-pem: ${{ secrets.MOPS_IDENTITY_PEM }}
17
- - run: mops publish
17
+ - run: mops publish
@@ -12,8 +12,8 @@ jobs:
12
12
  runs-on: ubuntu-latest
13
13
 
14
14
  steps:
15
- - uses: actions/checkout@v4
16
- - uses: ZenVoich/setup-mops@v1
15
+ - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
16
+ - uses: dfinity/setup-mops@v1
17
17
  with:
18
18
  mops-version: 1
19
19
 
@@ -21,4 +21,4 @@ jobs:
21
21
  run: mops install
22
22
 
23
23
  - name: run tests
24
- run: mops test
24
+ run: mops test
@@ -1,17 +1,17 @@
1
- import {readFileSync, writeFileSync} from 'node:fs';
1
+ import { readFileSync, writeFileSync } from "node:fs";
2
2
 
3
- let packageJson = JSON.parse(readFileSync('./bundle/package.json', 'utf8'));
3
+ let packageJson = JSON.parse(readFileSync("./bundle/package.json", "utf8"));
4
4
 
5
- packageJson.bin.mops = 'bin/mops.js';
6
- packageJson.bin['ic-mops'] = 'bin/mops.js';
5
+ packageJson.bin.mops = "bin/mops.js";
6
+ packageJson.bin["ic-mops"] = "bin/mops.js";
7
7
 
8
8
  delete packageJson.scripts;
9
9
  delete packageJson.devDependencies;
10
10
  delete packageJson.overrides;
11
11
  packageJson.dependencies = {
12
- 'dhall-to-json-cli': packageJson.dependencies['dhall-to-json-cli'],
13
- 'decomp-tarxz': packageJson.dependencies['decomp-tarxz'],
14
- 'buffer': packageJson.dependencies['buffer'],
12
+ "dhall-to-json-cli": packageJson.dependencies["dhall-to-json-cli"],
13
+ "decomp-tarxz": packageJson.dependencies["decomp-tarxz"],
14
+ buffer: packageJson.dependencies["buffer"],
15
15
  };
16
16
 
17
- writeFileSync('./bundle/package.json', JSON.stringify(packageJson, null, ' '));
17
+ writeFileSync("./bundle/package.json", JSON.stringify(packageJson, null, " "));
package/cache.ts CHANGED
@@ -1,90 +1,105 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import ncp from 'ncp';
4
- import getFolderSize from 'get-folder-size';
5
-
6
- import {getDependencyType, getNetwork, getRootDir, globalCacheDir, parseGithubURL} from './mops.js';
7
- import {getPackageId} from './helpers/get-package-id.js';
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import ncp from "ncp";
4
+ import getFolderSize from "get-folder-size";
5
+
6
+ import {
7
+ getDependencyType,
8
+ getNetwork,
9
+ getRootDir,
10
+ globalCacheDir,
11
+ parseGithubURL,
12
+ } from "./mops.js";
13
+ import { getPackageId } from "./helpers/get-package-id.js";
8
14
 
9
15
  let getGlobalCacheDir = () => {
10
- let network = getNetwork();
11
- return path.join(globalCacheDir, network === 'ic' ? '' : network);
16
+ let network = getNetwork();
17
+ return path.join(globalCacheDir, network === "ic" ? "" : network);
12
18
  };
13
19
 
14
20
  export let show = () => {
15
- return getGlobalCacheDir();
21
+ return getGlobalCacheDir();
16
22
  };
17
23
 
18
- export let getDepCacheDir = (cacheName : string) => {
19
- return path.join(getGlobalCacheDir(), 'packages', cacheName);
24
+ export let getDepCacheDir = (cacheName: string) => {
25
+ return path.join(getGlobalCacheDir(), "packages", cacheName);
20
26
  };
21
27
 
22
- export let isDepCached = (cacheName : string) => {
23
- let dir = getDepCacheDir(cacheName);
24
- return fs.existsSync(dir);
28
+ export let isDepCached = (cacheName: string) => {
29
+ let dir = getDepCacheDir(cacheName);
30
+ return fs.existsSync(dir);
25
31
  };
26
32
 
27
- export function getDepCacheName(name : string, version : string) {
28
- let depType = getDependencyType(version);
29
- return depType === 'mops' ? getMopsDepCacheName(name, version) : getGithubDepCacheName(name, version);
33
+ export function getDepCacheName(name: string, version: string) {
34
+ let depType = getDependencyType(version);
35
+ return depType === "mops"
36
+ ? getMopsDepCacheName(name, version)
37
+ : getGithubDepCacheName(name, version);
30
38
  }
31
39
 
32
- export function getMopsDepCacheName(name : string, version : string) {
33
- return getPackageId(name, version);
40
+ export function getMopsDepCacheName(name: string, version: string) {
41
+ return getPackageId(name, version);
34
42
  }
35
43
 
36
- export function getGithubDepCacheName(name : string, repo : string) {
37
- const {branch, commitHash} = parseGithubURL(repo);
38
- return `_github/${name}#${branch.replaceAll('/', '___')}` + (commitHash ? `@${commitHash}` : '');
44
+ export function getGithubDepCacheName(name: string, repo: string) {
45
+ const { branch, commitHash } = parseGithubURL(repo);
46
+ return (
47
+ `_github/${name}#${branch.replaceAll("/", "___")}` +
48
+ (commitHash ? `@${commitHash}` : "")
49
+ );
39
50
  }
40
51
 
41
- export let addCache = (cacheName : string, source : string) => {
42
- let dest = path.join(getGlobalCacheDir(), 'packages', cacheName);
43
- fs.mkdirSync(dest, {recursive: true});
44
-
45
- return new Promise<void>((resolve, reject) => {
46
- ncp.ncp(source, dest, {stopOnErr: true}, (err) => {
47
- if (err) {
48
- reject(err);
49
- }
50
- resolve();
51
- });
52
- });
52
+ export let addCache = (cacheName: string, source: string) => {
53
+ let dest = path.join(getGlobalCacheDir(), "packages", cacheName);
54
+ fs.mkdirSync(dest, { recursive: true });
55
+
56
+ return new Promise<void>((resolve, reject) => {
57
+ ncp.ncp(source, dest, { stopOnErr: true }, (err) => {
58
+ if (err) {
59
+ reject(err);
60
+ }
61
+ resolve();
62
+ });
63
+ });
53
64
  };
54
65
 
55
- export let copyCache = (cacheName : string, dest : string) => {
56
- let source = path.join(getGlobalCacheDir(), 'packages', cacheName);
57
- fs.mkdirSync(dest, {recursive: true});
58
-
59
- return new Promise<void>((resolve, reject) => {
60
- ncp.ncp(source, dest, {stopOnErr: true}, (err) => {
61
- if (err) {
62
- reject(err);
63
- }
64
- resolve();
65
- });
66
- });
66
+ export let copyCache = (cacheName: string, dest: string) => {
67
+ let source = path.join(getGlobalCacheDir(), "packages", cacheName);
68
+ fs.mkdirSync(dest, { recursive: true });
69
+
70
+ return new Promise<void>((resolve, reject) => {
71
+ ncp.ncp(source, dest, { stopOnErr: true }, (err) => {
72
+ if (err) {
73
+ reject(err);
74
+ }
75
+ resolve();
76
+ });
77
+ });
67
78
  };
68
79
 
69
80
  export let cacheSize = async () => {
70
- let dir = path.join(getGlobalCacheDir());
71
- fs.mkdirSync(dir, {recursive: true});
72
-
73
- let size = await getFolderSize.strict(dir);
74
- if (size < 1024 * 1024) {
75
- return (size / 1024).toFixed(2) + ' KB';
76
- }
77
- return (size / 1024 / 1024).toFixed(2) + ' MB';
81
+ let dir = path.join(getGlobalCacheDir());
82
+ fs.mkdirSync(dir, { recursive: true });
83
+
84
+ let size = await getFolderSize.strict(dir);
85
+ if (size < 1024 * 1024) {
86
+ return (size / 1024).toFixed(2) + " KB";
87
+ }
88
+ return (size / 1024 / 1024).toFixed(2) + " MB";
78
89
  };
79
90
 
80
91
  export let cleanCache = async () => {
81
- if (!getGlobalCacheDir().endsWith('mops/cache') && !getGlobalCacheDir().endsWith('/mops') && !getGlobalCacheDir().endsWith('/mops/' + getNetwork())) {
82
- throw new Error('Invalid cache directory: ' + getGlobalCacheDir());
83
- }
84
-
85
- // local cache
86
- fs.rmSync(path.join(getRootDir(), '.mops'), {recursive: true, force: true});
87
-
88
- // global cache
89
- fs.rmSync(getGlobalCacheDir(), {recursive: true, force: true});
90
- };
92
+ if (
93
+ !getGlobalCacheDir().endsWith("mops/cache") &&
94
+ !getGlobalCacheDir().endsWith("/mops") &&
95
+ !getGlobalCacheDir().endsWith("/mops/" + getNetwork())
96
+ ) {
97
+ throw new Error("Invalid cache directory: " + getGlobalCacheDir());
98
+ }
99
+
100
+ // local cache
101
+ fs.rmSync(path.join(getRootDir(), ".mops"), { recursive: true, force: true });
102
+
103
+ // global cache
104
+ fs.rmSync(getGlobalCacheDir(), { recursive: true, force: true });
105
+ };