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.
- package/.DS_Store +0 -0
- package/.eslintrc.json +7 -7
- package/CHANGELOG.md +15 -0
- package/api/actors.ts +41 -37
- package/api/downloadPackageFiles.ts +75 -61
- package/api/getHighestVersion.ts +5 -5
- package/api/index.ts +4 -4
- package/api/network.ts +19 -21
- package/api/resolveVersion.ts +14 -11
- package/bin/mops.js +1 -1
- package/bun.lock +234 -198
- package/bundle/bench/bench-canister.mo +2 -2
- package/bundle/bench/user-bench.mo +0 -4
- package/bundle/bin/mops.js +1 -1
- package/bundle/cli.js +1000 -924
- package/bundle/cli.tgz +0 -0
- package/bundle/declarations/bench/bench.did +3 -3
- package/bundle/declarations/bench/bench.did.d.ts +3 -3
- package/bundle/declarations/bench/index.d.ts +3 -3
- package/bundle/declarations/bench/index.js +1 -1
- package/bundle/declarations/main/index.d.ts +3 -3
- package/bundle/declarations/main/index.js +1 -1
- package/bundle/declarations/main/main.did +78 -121
- package/bundle/declarations/main/main.did.d.ts +48 -98
- package/bundle/declarations/main/main.did.js +53 -107
- package/bundle/declarations/storage/index.d.ts +3 -3
- package/bundle/declarations/storage/index.js +4 -4
- package/bundle/declarations/storage/storage.did.d.ts +3 -3
- package/bundle/package.json +6 -5
- package/bundle/templates/mops-publish.yml +3 -3
- package/bundle/templates/mops-test.yml +3 -3
- package/bundle-package-json.ts +8 -8
- package/cache.ts +80 -65
- package/check-requirements.ts +49 -45
- package/cli.ts +577 -376
- package/commands/add.ts +142 -129
- package/commands/available-updates.ts +55 -28
- package/commands/bench/bench-canister.mo +114 -108
- package/commands/bench/user-bench.mo +6 -6
- package/commands/bench-replica.ts +146 -106
- package/commands/bench.ts +563 -497
- package/commands/build.ts +177 -0
- package/commands/bump.ts +68 -57
- package/commands/check-candid.ts +24 -0
- package/commands/docs-coverage.ts +124 -102
- package/commands/docs.ts +118 -108
- package/commands/format.ts +171 -155
- package/commands/init.ts +301 -275
- package/commands/install/install-all.ts +75 -62
- package/commands/install/install-dep.ts +43 -28
- package/commands/install/install-deps.ts +23 -15
- package/commands/install/install-local-dep.ts +42 -34
- package/commands/install/install-mops-dep.ts +154 -123
- package/commands/install/sync-local-cache.ts +39 -35
- package/commands/maintainer.ts +109 -99
- package/commands/outdated.ts +31 -18
- package/commands/owner.ts +107 -99
- package/commands/publish.ts +534 -443
- package/commands/remove.ts +119 -89
- package/commands/replica.ts +391 -303
- package/commands/search.ts +42 -36
- package/commands/self.ts +63 -56
- package/commands/sources.ts +66 -49
- package/commands/sync.ts +92 -75
- package/commands/template.ts +145 -102
- package/commands/test/mmf1.ts +146 -119
- package/commands/test/reporters/compact-reporter.ts +87 -84
- package/commands/test/reporters/files-reporter.ts +56 -51
- package/commands/test/reporters/reporter.ts +12 -6
- package/commands/test/reporters/silent-reporter.ts +58 -59
- package/commands/test/reporters/verbose-reporter.ts +66 -54
- package/commands/test/test.ts +497 -460
- package/commands/test/utils.ts +85 -6
- package/commands/toolchain/index.ts +363 -322
- package/commands/toolchain/moc.ts +78 -50
- package/commands/toolchain/pocket-ic.ts +41 -34
- package/commands/toolchain/toolchain-utils.ts +92 -72
- package/commands/toolchain/wasmtime.ts +37 -34
- package/commands/update.ts +91 -56
- package/commands/user.ts +90 -81
- package/commands/watch/deployer.ts +188 -152
- package/commands/watch/error-checker.ts +90 -80
- package/commands/watch/formatter.ts +72 -60
- package/commands/watch/generator.ts +116 -96
- package/commands/watch/globMoFiles.ts +13 -13
- package/commands/watch/parseDfxJson.ts +63 -57
- package/commands/watch/tester.ts +83 -65
- package/commands/watch/warning-checker.ts +149 -136
- package/commands/watch/watch.ts +123 -95
- package/declarations/bench/bench.did.d.ts +3 -3
- package/declarations/bench/index.d.ts +3 -3
- package/declarations/bench/index.js +1 -1
- package/declarations/main/index.d.ts +3 -3
- package/declarations/main/index.js +1 -1
- package/declarations/main/main.did.d.ts +3 -3
- package/declarations/storage/index.d.ts +3 -3
- package/declarations/storage/index.js +4 -4
- package/declarations/storage/storage.did.d.ts +3 -3
- package/dist/api/actors.d.ts +4 -4
- package/dist/api/actors.js +8 -8
- package/dist/api/downloadPackageFiles.d.ts +2 -2
- package/dist/api/downloadPackageFiles.js +10 -10
- package/dist/api/getHighestVersion.js +1 -1
- package/dist/api/index.d.ts +4 -4
- package/dist/api/index.js +4 -4
- package/dist/api/network.js +9 -9
- package/dist/api/resolveVersion.js +3 -3
- package/dist/bin/mops.js +1 -1
- package/dist/bundle-package-json.js +8 -8
- package/dist/cache.js +22 -17
- package/dist/check-requirements.js +11 -11
- package/dist/cli.js +283 -186
- package/dist/commands/add.d.ts +1 -1
- package/dist/commands/add.js +41 -38
- package/dist/commands/available-updates.d.ts +1 -1
- package/dist/commands/available-updates.js +32 -14
- package/dist/commands/bench/bench-canister.mo +114 -108
- package/dist/commands/bench/user-bench.mo +6 -6
- package/dist/commands/bench-replica.d.ts +6 -5
- package/dist/commands/bench-replica.js +58 -36
- package/dist/commands/bench.d.ts +5 -5
- package/dist/commands/bench.js +134 -118
- package/dist/commands/build.d.ts +7 -0
- package/dist/commands/build.js +121 -0
- package/dist/commands/bump.js +27 -18
- package/dist/commands/check-candid.d.ts +4 -0
- package/dist/commands/check-candid.js +15 -0
- package/dist/commands/docs-coverage.d.ts +1 -1
- package/dist/commands/docs-coverage.js +45 -31
- package/dist/commands/docs.d.ts +1 -1
- package/dist/commands/docs.js +39 -38
- package/dist/commands/format.js +31 -27
- package/dist/commands/init.js +102 -92
- package/dist/commands/install/install-all.d.ts +2 -2
- package/dist/commands/install/install-all.js +23 -21
- package/dist/commands/install/install-dep.d.ts +1 -1
- package/dist/commands/install/install-dep.js +21 -8
- package/dist/commands/install/install-deps.d.ts +1 -1
- package/dist/commands/install/install-deps.js +1 -1
- package/dist/commands/install/install-local-dep.js +11 -9
- package/dist/commands/install/install-mops-dep.d.ts +1 -1
- package/dist/commands/install/install-mops-dep.js +32 -27
- package/dist/commands/install/sync-local-cache.js +10 -10
- package/dist/commands/maintainer.js +21 -21
- package/dist/commands/outdated.js +16 -6
- package/dist/commands/owner.js +21 -21
- package/dist/commands/publish.js +148 -128
- package/dist/commands/remove.d.ts +1 -1
- package/dist/commands/remove.js +42 -30
- package/dist/commands/replica.d.ts +9 -8
- package/dist/commands/replica.js +105 -65
- package/dist/commands/search.js +15 -13
- package/dist/commands/self.js +31 -28
- package/dist/commands/sources.d.ts +5 -1
- package/dist/commands/sources.js +23 -17
- package/dist/commands/sync.d.ts +1 -1
- package/dist/commands/sync.js +38 -25
- package/dist/commands/template.js +66 -56
- package/dist/commands/test/mmf1.d.ts +3 -3
- package/dist/commands/test/mmf1.js +33 -31
- package/dist/commands/test/reporters/compact-reporter.d.ts +3 -3
- package/dist/commands/test/reporters/compact-reporter.js +19 -15
- package/dist/commands/test/reporters/files-reporter.d.ts +3 -3
- package/dist/commands/test/reporters/files-reporter.js +18 -14
- package/dist/commands/test/reporters/reporter.d.ts +2 -2
- package/dist/commands/test/reporters/silent-reporter.d.ts +3 -3
- package/dist/commands/test/reporters/silent-reporter.js +4 -4
- package/dist/commands/test/reporters/verbose-reporter.d.ts +3 -3
- package/dist/commands/test/reporters/verbose-reporter.js +17 -13
- package/dist/commands/test/test.d.ts +4 -4
- package/dist/commands/test/test.js +151 -181
- package/dist/commands/test/utils.d.ts +6 -0
- package/dist/commands/test/utils.js +63 -2
- package/dist/commands/toolchain/index.d.ts +1 -1
- package/dist/commands/toolchain/index.js +81 -69
- package/dist/commands/toolchain/moc.d.ts +1 -1
- package/dist/commands/toolchain/moc.js +48 -24
- package/dist/commands/toolchain/pocket-ic.js +12 -12
- package/dist/commands/toolchain/toolchain-utils.d.ts +2 -0
- package/dist/commands/toolchain/toolchain-utils.js +32 -23
- package/dist/commands/toolchain/wasmtime.js +11 -11
- package/dist/commands/update.d.ts +1 -1
- package/dist/commands/update.js +30 -12
- package/dist/commands/user.js +31 -28
- package/dist/commands/watch/deployer.d.ts +4 -4
- package/dist/commands/watch/deployer.js +45 -36
- package/dist/commands/watch/error-checker.d.ts +2 -2
- package/dist/commands/watch/error-checker.js +27 -27
- package/dist/commands/watch/formatter.d.ts +4 -4
- package/dist/commands/watch/formatter.js +17 -17
- package/dist/commands/watch/generator.d.ts +3 -3
- package/dist/commands/watch/generator.js +28 -23
- package/dist/commands/watch/globMoFiles.js +8 -8
- package/dist/commands/watch/parseDfxJson.d.ts +2 -2
- package/dist/commands/watch/parseDfxJson.js +9 -9
- package/dist/commands/watch/tester.d.ts +4 -4
- package/dist/commands/watch/tester.js +23 -21
- package/dist/commands/watch/warning-checker.d.ts +3 -3
- package/dist/commands/watch/warning-checker.js +36 -36
- package/dist/commands/watch/watch.js +45 -32
- package/dist/declarations/bench/bench.did.d.ts +3 -3
- package/dist/declarations/bench/index.d.ts +3 -3
- package/dist/declarations/bench/index.js +1 -1
- package/dist/declarations/main/index.d.ts +3 -3
- package/dist/declarations/main/index.js +1 -1
- package/dist/declarations/main/main.did.d.ts +3 -3
- package/dist/declarations/storage/index.d.ts +3 -3
- package/dist/declarations/storage/index.js +4 -4
- package/dist/declarations/storage/storage.did.d.ts +3 -3
- package/dist/environments/nodejs/cli.d.ts +1 -0
- package/dist/environments/nodejs/cli.js +4 -0
- package/dist/environments/web/cli.d.ts +1 -0
- package/dist/environments/web/cli.js +4 -0
- package/dist/error.d.ts +1 -0
- package/dist/error.js +5 -0
- package/dist/fix-dist.js +5 -5
- package/dist/helpers/find-changelog-entry.js +8 -5
- package/dist/helpers/get-dep-name.d.ts +1 -0
- package/dist/helpers/get-dep-name.js +4 -1
- package/dist/helpers/get-dfx-version.js +4 -4
- package/dist/helpers/get-moc-path.js +8 -7
- package/dist/helpers/get-moc-version.js +10 -7
- package/dist/helpers/get-package-id.js +2 -2
- package/dist/helpers/is-candid-compatible.d.ts +1 -0
- package/dist/helpers/is-candid-compatible.js +20 -0
- package/dist/integrity.d.ts +1 -1
- package/dist/integrity.js +47 -38
- package/dist/jest.config.d.ts +11 -0
- package/dist/jest.config.js +14 -0
- package/dist/mops.d.ts +6 -6
- package/dist/mops.js +87 -80
- package/dist/notify-installs.js +4 -4
- package/dist/package.json +11 -10
- package/dist/pem.d.ts +3 -3
- package/dist/pem.js +20 -12
- package/dist/release-cli.js +20 -20
- package/dist/resolve-packages.d.ts +1 -1
- package/dist/resolve-packages.js +52 -36
- package/dist/templates/mops-publish.yml +3 -3
- package/dist/templates/mops-test.yml +3 -3
- package/dist/templates/src/lib.mo +13 -13
- package/dist/templates/test/lib.test.mo +2 -2
- package/dist/templates.js +1 -1
- package/dist/tests/cli.test.d.ts +1 -0
- package/dist/tests/cli.test.js +63 -0
- package/dist/types.d.ts +14 -4
- package/dist/vessel.d.ts +2 -2
- package/dist/vessel.js +41 -34
- package/dist/wasm/pkg/bundler/package.json +20 -0
- package/dist/wasm/pkg/bundler/wasm.d.ts +3 -0
- package/dist/wasm/pkg/bundler/wasm.js +5 -0
- package/dist/wasm/pkg/bundler/wasm_bg.js +93 -0
- package/dist/wasm/pkg/bundler/wasm_bg.wasm +0 -0
- package/dist/wasm/pkg/bundler/wasm_bg.wasm.d.ts +8 -0
- package/dist/wasm/pkg/nodejs/package.json +14 -0
- package/dist/wasm/pkg/nodejs/wasm.d.ts +3 -0
- package/dist/wasm/pkg/nodejs/wasm.js +98 -0
- package/dist/wasm/pkg/nodejs/wasm_bg.wasm +0 -0
- package/dist/wasm/pkg/nodejs/wasm_bg.wasm.d.ts +8 -0
- package/dist/wasm/pkg/web/package.json +18 -0
- package/dist/wasm/pkg/web/wasm.d.ts +35 -0
- package/dist/wasm/pkg/web/wasm.js +191 -0
- package/dist/wasm/pkg/web/wasm_bg.wasm +0 -0
- package/dist/wasm/pkg/web/wasm_bg.wasm.d.ts +8 -0
- package/dist/wasm.d.ts +5 -0
- package/dist/wasm.js +10 -0
- package/environments/nodejs/cli.ts +6 -0
- package/environments/web/cli.ts +6 -0
- package/error.ts +6 -0
- package/fix-dist.ts +5 -5
- package/global.d.ts +3 -3
- package/helpers/find-changelog-entry.ts +26 -23
- package/helpers/get-dep-name.ts +7 -3
- package/helpers/get-dfx-version.ts +8 -9
- package/helpers/get-moc-path.ts +25 -26
- package/helpers/get-moc-version.ts +21 -19
- package/helpers/get-package-id.ts +4 -4
- package/helpers/is-candid-compatible.ts +22 -0
- package/integrity.ts +270 -236
- package/jest.config.js +14 -0
- package/mops.ts +238 -215
- package/notify-installs.ts +16 -17
- package/package.json +21 -15
- package/parallel.ts +28 -24
- package/pem.ts +55 -47
- package/release-cli.ts +73 -39
- package/resolve-packages.ts +231 -189
- package/templates/mops-publish.yml +3 -3
- package/templates/mops-test.yml +3 -3
- package/templates/src/lib.mo +13 -13
- package/templates/test/lib.test.mo +2 -2
- package/templates.ts +4 -4
- package/tests/__snapshots__/cli.test.ts.snap +202 -0
- package/tests/build/error/candid/bar.did +3 -0
- package/tests/build/error/dfx.json +12 -0
- package/tests/build/error/mops.toml +9 -0
- package/tests/build/error/src/Bar.mo +5 -0
- package/tests/build/error/src/Foo.mo +5 -0
- package/tests/build/success/.dfx/local/canister_ids.json +17 -0
- package/tests/build/success/.dfx/local/canisters/bar/bar.did +3 -0
- package/tests/build/success/.dfx/local/canisters/bar/bar.most +4 -0
- package/tests/build/success/.dfx/local/canisters/bar/bar.wasm +0 -0
- package/tests/build/success/.dfx/local/canisters/bar/constructor.did +3 -0
- package/tests/build/success/.dfx/local/canisters/bar/index.js +42 -0
- package/tests/build/success/.dfx/local/canisters/bar/init_args.txt +1 -0
- package/tests/build/success/.dfx/local/canisters/bar/service.did +3 -0
- package/tests/build/success/.dfx/local/canisters/bar/service.did.d.ts +7 -0
- package/tests/build/success/.dfx/local/canisters/bar/service.did.js +4 -0
- package/tests/build/success/.dfx/local/canisters/foo/constructor.did +3 -0
- package/tests/build/success/.dfx/local/canisters/foo/foo.did +3 -0
- package/tests/build/success/.dfx/local/canisters/foo/foo.most +4 -0
- package/tests/build/success/.dfx/local/canisters/foo/foo.wasm +0 -0
- package/tests/build/success/.dfx/local/canisters/foo/index.js +42 -0
- package/tests/build/success/.dfx/local/canisters/foo/init_args.txt +1 -0
- package/tests/build/success/.dfx/local/canisters/foo/service.did +3 -0
- package/tests/build/success/.dfx/local/canisters/foo/service.did.d.ts +7 -0
- package/tests/build/success/.dfx/local/canisters/foo/service.did.js +4 -0
- package/tests/build/success/.dfx/local/lsp/ucwa4-rx777-77774-qaada-cai.did +3 -0
- package/tests/build/success/.dfx/local/lsp/ulvla-h7777-77774-qaacq-cai.did +3 -0
- package/tests/build/success/.dfx/local/network-id +4 -0
- package/tests/build/success/candid/bar.did +3 -0
- package/tests/build/success/dfx.json +12 -0
- package/tests/build/success/mops.toml +9 -0
- package/tests/build/success/src/Bar.mo +5 -0
- package/tests/build/success/src/Foo.mo +5 -0
- package/tests/check-candid/a.did +3 -0
- package/tests/check-candid/b.did +5 -0
- package/tests/check-candid/c.did +3 -0
- package/tests/cli.test.ts +82 -0
- package/tsconfig.json +26 -19
- package/types.ts +41 -31
- package/vessel.ts +219 -187
- package/wasm/Cargo.lock +1475 -0
- package/wasm/Cargo.toml +28 -0
- package/wasm/pkg/bundler/package.json +20 -0
- package/wasm/pkg/bundler/wasm.d.ts +3 -0
- package/wasm/pkg/bundler/wasm.js +5 -0
- package/wasm/pkg/bundler/wasm_bg.js +93 -0
- package/wasm/pkg/bundler/wasm_bg.wasm +0 -0
- package/wasm/pkg/bundler/wasm_bg.wasm.d.ts +8 -0
- package/wasm/pkg/nodejs/package.json +14 -0
- package/wasm/pkg/nodejs/wasm.d.ts +3 -0
- package/wasm/pkg/nodejs/wasm.js +98 -0
- package/wasm/pkg/nodejs/wasm_bg.wasm +0 -0
- package/wasm/pkg/nodejs/wasm_bg.wasm.d.ts +8 -0
- package/wasm/pkg/web/package.json +18 -0
- package/wasm/pkg/web/wasm.d.ts +35 -0
- package/wasm/pkg/web/wasm.js +191 -0
- package/wasm/pkg/web/wasm_bg.wasm +0 -0
- package/wasm/pkg/web/wasm_bg.wasm.d.ts +8 -0
- package/wasm/src/lib.rs +17 -0
- package/wasm.ts +16 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export const idlFactory = ({ IDL }) => {
|
|
2
|
-
const
|
|
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
|
|
8
|
+
const PackageVersion = IDL.Text;
|
|
9
9
|
const PackageId = IDL.Text;
|
|
10
10
|
const Time = IDL.Int;
|
|
11
|
-
const
|
|
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(
|
|
28
|
+
'ok' : IDL.Vec(IDL.Tuple(PackageName, PackageVersion)),
|
|
29
29
|
'err' : Err,
|
|
30
30
|
});
|
|
31
|
-
const Result_5 = IDL.Variant({ 'ok' :
|
|
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
|
|
124
|
-
const
|
|
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' :
|
|
142
|
+
'curBenchmarks' : Benchmarks,
|
|
165
143
|
'prevDocsCoverage' : IDL.Float64,
|
|
166
|
-
'prevBenchmarks' :
|
|
144
|
+
'prevBenchmarks' : Benchmarks,
|
|
167
145
|
'notes' : IDL.Text,
|
|
168
146
|
'curDocsCoverage' : IDL.Float64,
|
|
169
147
|
'devDeps' : IDL.Vec(DepChange),
|
|
170
148
|
});
|
|
171
|
-
const
|
|
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' :
|
|
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(
|
|
172
|
+
'deps' : IDL.Vec(PackageSummary),
|
|
195
173
|
'quality' : PackageQuality,
|
|
196
174
|
'publisher' : User,
|
|
197
|
-
'testStats' :
|
|
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(
|
|
205
|
-
'dependents' : IDL.Vec(
|
|
206
|
-
'devDeps' : IDL.Vec(
|
|
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
|
|
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
|
|
258
|
+
const TransformArg = IDL.Record({
|
|
307
259
|
'context' : IDL.Vec(IDL.Nat8),
|
|
308
|
-
'response' :
|
|
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([
|
|
317
|
-
'addOwner' : IDL.Func([
|
|
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(
|
|
272
|
+
[IDL.Vec(IDL.Tuple(PackageName, PackageVersion))],
|
|
326
273
|
['query'],
|
|
327
274
|
),
|
|
328
275
|
'getDownloadTrendByPackageId' : IDL.Func(
|
|
329
276
|
[PackageId],
|
|
330
|
-
[IDL.Vec(
|
|
277
|
+
[IDL.Vec(DownloadsSnapshot)],
|
|
331
278
|
['query'],
|
|
332
279
|
),
|
|
333
280
|
'getDownloadTrendByPackageName' : IDL.Func(
|
|
334
|
-
[
|
|
335
|
-
[IDL.Vec(
|
|
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
|
-
[
|
|
296
|
+
[PackageName, PackageVersion],
|
|
354
297
|
[Result_8],
|
|
355
298
|
['query'],
|
|
356
299
|
),
|
|
357
300
|
'getFileIds' : IDL.Func(
|
|
358
|
-
[
|
|
301
|
+
[PackageName, PackageVersion],
|
|
359
302
|
[Result_7],
|
|
360
303
|
['query'],
|
|
361
304
|
),
|
|
362
305
|
'getHighestSemverBatch' : IDL.Func(
|
|
363
|
-
[IDL.Vec(IDL.Tuple(
|
|
306
|
+
[IDL.Vec(IDL.Tuple(PackageName, PackageVersion, SemverPart))],
|
|
364
307
|
[Result_6],
|
|
365
308
|
['query'],
|
|
366
309
|
),
|
|
367
|
-
'getHighestVersion' : IDL.Func([
|
|
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
|
-
[
|
|
328
|
+
[PackageName, PackageVersion],
|
|
381
329
|
[Result_4],
|
|
382
330
|
['query'],
|
|
383
331
|
),
|
|
384
332
|
'getPackageMaintainers' : IDL.Func(
|
|
385
|
-
[
|
|
333
|
+
[PackageName],
|
|
386
334
|
[IDL.Vec(IDL.Principal)],
|
|
387
335
|
['query'],
|
|
388
336
|
),
|
|
389
337
|
'getPackageOwners' : IDL.Func(
|
|
390
|
-
[
|
|
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(
|
|
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(
|
|
368
|
+
[IDL.Vec(IDL.Tuple(PackageName, PackageVersion))],
|
|
420
369
|
[],
|
|
421
370
|
['oneway'],
|
|
422
371
|
),
|
|
423
|
-
'removeMaintainer' : IDL.Func(
|
|
424
|
-
|
|
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
|
-
[
|
|
445
|
-
[
|
|
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 "@
|
|
7
|
-
import type { Principal } from "@
|
|
8
|
-
import type { IDL } from "@
|
|
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 "@
|
|
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("@
|
|
10
|
-
* @param {{agentOptions?: import("@
|
|
11
|
-
* @return {import("@
|
|
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 '@
|
|
2
|
-
import type { ActorMethod } from '@
|
|
3
|
-
import type { IDL } from '@
|
|
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;
|
package/bundle/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ic-mops",
|
|
3
|
-
"version": "1.
|
|
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/
|
|
24
|
+
"url": "https://github.com/dfinity/mops.git"
|
|
24
25
|
},
|
|
25
|
-
"author": "
|
|
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@
|
|
13
|
-
- uses:
|
|
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@
|
|
16
|
-
- uses:
|
|
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
|
package/bundle-package-json.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {readFileSync, writeFileSync} from
|
|
1
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
2
2
|
|
|
3
|
-
let packageJson = JSON.parse(readFileSync(
|
|
3
|
+
let packageJson = JSON.parse(readFileSync("./bundle/package.json", "utf8"));
|
|
4
4
|
|
|
5
|
-
packageJson.bin.mops =
|
|
6
|
-
packageJson.bin[
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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(
|
|
17
|
+
writeFileSync("./bundle/package.json", JSON.stringify(packageJson, null, " "));
|
package/cache.ts
CHANGED
|
@@ -1,90 +1,105 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import path from
|
|
3
|
-
import ncp from
|
|
4
|
-
import getFolderSize from
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
|
|
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
|
-
|
|
11
|
-
|
|
16
|
+
let network = getNetwork();
|
|
17
|
+
return path.join(globalCacheDir, network === "ic" ? "" : network);
|
|
12
18
|
};
|
|
13
19
|
|
|
14
20
|
export let show = () => {
|
|
15
|
-
|
|
21
|
+
return getGlobalCacheDir();
|
|
16
22
|
};
|
|
17
23
|
|
|
18
|
-
export let getDepCacheDir = (cacheName
|
|
19
|
-
|
|
24
|
+
export let getDepCacheDir = (cacheName: string) => {
|
|
25
|
+
return path.join(getGlobalCacheDir(), "packages", cacheName);
|
|
20
26
|
};
|
|
21
27
|
|
|
22
|
-
export let isDepCached = (cacheName
|
|
23
|
-
|
|
24
|
-
|
|
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
|
|
28
|
-
|
|
29
|
-
|
|
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
|
|
33
|
-
|
|
40
|
+
export function getMopsDepCacheName(name: string, version: string) {
|
|
41
|
+
return getPackageId(name, version);
|
|
34
42
|
}
|
|
35
43
|
|
|
36
|
-
export function getGithubDepCacheName(name
|
|
37
|
-
|
|
38
|
-
|
|
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
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
+
};
|