ic-mops 0.41.0 → 0.42.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/CHANGELOG.md +12 -0
- package/api/actors.ts +2 -3
- package/bundle/bin/mops.js +0 -0
- package/bundle/cli.js +29 -29
- package/bundle/cli.tgz +0 -0
- package/bundle/declarations/bench/bench.did.d.ts +1 -1
- package/bundle/declarations/bench/index.js +0 -9
- package/bundle/declarations/main/index.js +1 -2
- package/bundle/declarations/main/main.did +15 -8
- package/bundle/declarations/main/main.did.d.ts +12 -9
- package/bundle/declarations/main/main.did.js +11 -8
- package/bundle/declarations/storage/storage.did.d.ts +3 -0
- package/bundle/package.json +2 -2
- package/bundle-package-json.ts +3 -0
- package/cache.ts +25 -7
- package/check-requirements.ts +50 -0
- package/cli.ts +3 -2
- package/commands/add.ts +13 -7
- package/commands/available-updates.ts +1 -0
- package/commands/bench-replica.ts +1 -0
- package/commands/bench.ts +1 -0
- package/commands/bump.ts +1 -0
- package/commands/docs.ts +1 -0
- package/commands/import-identity.ts +1 -0
- package/commands/init.ts +2 -1
- package/commands/install/install-all.ts +51 -0
- package/commands/install/install-dep.ts +34 -0
- package/commands/install/install-deps.ts +31 -0
- package/commands/install/install-local-dep.ts +31 -0
- package/commands/{install.ts → install/install-mops-dep.ts} +43 -43
- package/commands/install/sync-local-cache.ts +34 -0
- package/commands/publish.ts +18 -3
- package/commands/remove.ts +15 -18
- package/commands/search.ts +1 -0
- package/commands/self.ts +1 -0
- package/commands/sources.ts +1 -0
- package/commands/sync.ts +1 -0
- package/commands/test/test.ts +1 -0
- package/commands/toolchain/index.ts +8 -0
- package/commands/toolchain/moc.ts +1 -0
- package/commands/toolchain/pocket-ic.ts +1 -0
- package/commands/toolchain/toolchain-utils.ts +2 -0
- package/commands/toolchain/wasmtime.ts +1 -0
- package/commands/transfer-ownership.ts +1 -0
- package/commands/user.ts +1 -0
- package/declarations/bench/bench.did.d.ts +1 -1
- package/declarations/bench/index.js +0 -9
- package/declarations/main/index.js +1 -2
- package/declarations/main/main.did +15 -8
- package/declarations/main/main.did.d.ts +12 -9
- package/declarations/main/main.did.js +11 -8
- package/declarations/storage/storage.did.d.ts +3 -0
- package/dist/api/actors.js +2 -2
- package/dist/bin/mops.js +0 -0
- package/dist/bundle-package-json.js +2 -0
- package/dist/cache.d.ts +7 -3
- package/dist/cache.js +21 -7
- package/dist/check-requirements.js +9 -4
- package/dist/cli.js +3 -2
- package/dist/commands/add.js +9 -6
- package/dist/commands/available-updates.js +1 -0
- package/dist/commands/bench-replica.js +1 -0
- package/dist/commands/bench.js +1 -0
- package/dist/commands/bump.js +1 -0
- package/dist/commands/docs.js +1 -0
- package/dist/commands/import-identity.js +1 -0
- package/dist/commands/init.js +2 -1
- package/dist/commands/install/install-all.d.ts +8 -0
- package/dist/commands/install/install-all.js +36 -0
- package/dist/commands/install/install-dep.d.ts +8 -0
- package/dist/commands/install/install-dep.js +25 -0
- package/dist/commands/install/install-deps.d.ts +8 -0
- package/dist/commands/install/install-deps.js +21 -0
- package/dist/commands/install/install-local-dep.d.ts +6 -0
- package/dist/commands/install/install-local-dep.js +23 -0
- package/dist/commands/install/install-mops-dep.d.ts +8 -0
- package/dist/commands/install/install-mops-dep.js +103 -0
- package/dist/commands/install/sync-local-cache.d.ts +3 -0
- package/dist/commands/install/sync-local-cache.js +26 -0
- package/dist/commands/install-all.js +2 -0
- package/dist/commands/publish.js +14 -1
- package/dist/commands/remove.js +15 -18
- package/dist/commands/search.js +1 -0
- package/dist/commands/self.js +1 -0
- package/dist/commands/sources.js +1 -0
- package/dist/commands/sync.js +1 -0
- package/dist/commands/test/test.js +1 -0
- package/dist/commands/toolchain/index.js +6 -0
- package/dist/commands/toolchain/moc.js +1 -0
- package/dist/commands/toolchain/pocket-ic.js +1 -0
- package/dist/commands/toolchain/toolchain-utils.js +2 -0
- package/dist/commands/toolchain/wasmtime.js +1 -0
- package/dist/commands/transfer-ownership.js +1 -0
- package/dist/commands/user.js +1 -0
- package/dist/declarations/bench/bench.did.d.ts +1 -1
- package/dist/declarations/bench/index.js +0 -9
- package/dist/declarations/main/index.js +1 -2
- package/dist/declarations/main/main.did +15 -8
- package/dist/declarations/main/main.did.d.ts +12 -9
- package/dist/declarations/main/main.did.js +11 -8
- package/dist/declarations/storage/storage.did.d.ts +3 -0
- package/dist/fix-dist.d.ts +1 -0
- package/dist/fix-dist.js +9 -0
- package/dist/helpers/get-moc-path.js +1 -0
- package/dist/integrity.js +1 -0
- package/dist/mops.js +11 -3
- package/dist/notify-installs.d.ts +1 -1
- package/dist/notify-installs.js +8 -5
- package/dist/package.json +3 -3
- package/dist/pem.d.ts +1 -0
- package/dist/pem.js +2 -1
- package/dist/resolve-packages.js +11 -9
- package/dist/types.d.ts +4 -0
- package/dist/vessel.js +10 -12
- package/{remove-scripts.ts → fix-dist.ts} +6 -0
- package/helpers/get-moc-path.ts +1 -0
- package/integrity.ts +1 -0
- package/mops.ts +13 -3
- package/notify-installs.ts +9 -5
- package/package.json +7 -7
- package/pem.ts +2 -1
- package/resolve-packages.ts +11 -9
- package/tsconfig.json +1 -0
- package/types.ts +7 -2
- package/vessel.ts +11 -13
- package/commands/install-all.ts +0 -56
- package/commands/install-local.ts +0 -52
|
@@ -62,7 +62,8 @@ export const idlFactory = ({ IDL }) => {
|
|
|
62
62
|
'repo' : IDL.Text,
|
|
63
63
|
'version' : IDL.Text,
|
|
64
64
|
});
|
|
65
|
-
const
|
|
65
|
+
const Requirement = IDL.Record({ 'value' : IDL.Text, 'name' : IDL.Text });
|
|
66
|
+
const PackageConfigV3 = IDL.Record({
|
|
66
67
|
'dfx' : IDL.Text,
|
|
67
68
|
'moc' : IDL.Text,
|
|
68
69
|
'scripts' : IDL.Vec(Script),
|
|
@@ -77,6 +78,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
77
78
|
'devDependencies' : IDL.Vec(DependencyV2),
|
|
78
79
|
'repository' : IDL.Text,
|
|
79
80
|
'dependencies' : IDL.Vec(DependencyV2),
|
|
81
|
+
'requirements' : IDL.Vec(Requirement),
|
|
80
82
|
'license' : IDL.Text,
|
|
81
83
|
'readme' : IDL.Text,
|
|
82
84
|
});
|
|
@@ -92,7 +94,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
92
94
|
'downloadsTotal' : IDL.Nat,
|
|
93
95
|
'downloadsInLast30Days' : IDL.Nat,
|
|
94
96
|
'downloadsInLast7Days' : IDL.Nat,
|
|
95
|
-
'config' :
|
|
97
|
+
'config' : PackageConfigV3,
|
|
96
98
|
'publication' : PackagePublication,
|
|
97
99
|
});
|
|
98
100
|
const BenchmarkMetric = IDL.Text;
|
|
@@ -118,7 +120,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
118
120
|
'downloadsTotal' : IDL.Nat,
|
|
119
121
|
'downloadsInLast30Days' : IDL.Nat,
|
|
120
122
|
'downloadsInLast7Days' : IDL.Nat,
|
|
121
|
-
'config' :
|
|
123
|
+
'config' : PackageConfigV3,
|
|
122
124
|
'publication' : PackagePublication,
|
|
123
125
|
});
|
|
124
126
|
const TestStats__1 = IDL.Record({
|
|
@@ -158,7 +160,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
158
160
|
'downloadsTotal' : IDL.Nat,
|
|
159
161
|
'downloadsInLast30Days' : IDL.Nat,
|
|
160
162
|
'downloadsInLast7Days' : IDL.Nat,
|
|
161
|
-
'config' :
|
|
163
|
+
'config' : PackageConfigV3,
|
|
162
164
|
'changes' : PackageChanges,
|
|
163
165
|
'publication' : PackagePublication,
|
|
164
166
|
});
|
|
@@ -177,7 +179,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
177
179
|
'dependents' : IDL.Vec(PackageSummary__1),
|
|
178
180
|
'devDeps' : IDL.Vec(PackageSummary__1),
|
|
179
181
|
'downloadsInLast7Days' : IDL.Nat,
|
|
180
|
-
'config' :
|
|
182
|
+
'config' : PackageConfigV3,
|
|
181
183
|
'changes' : PackageChanges,
|
|
182
184
|
'publication' : PackagePublication,
|
|
183
185
|
});
|
|
@@ -189,7 +191,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
189
191
|
'downloadsTotal' : IDL.Nat,
|
|
190
192
|
'downloadsInLast30Days' : IDL.Nat,
|
|
191
193
|
'downloadsInLast7Days' : IDL.Nat,
|
|
192
|
-
'config' :
|
|
194
|
+
'config' : PackageConfigV3,
|
|
193
195
|
'changes' : PackageChanges,
|
|
194
196
|
'publication' : PackagePublication,
|
|
195
197
|
});
|
|
@@ -245,7 +247,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
245
247
|
const PageCount = IDL.Nat;
|
|
246
248
|
const Result_1 = IDL.Variant({ 'ok' : IDL.Null, 'err' : IDL.Text });
|
|
247
249
|
const Result_3 = IDL.Variant({ 'ok' : FileId, 'err' : Err });
|
|
248
|
-
const
|
|
250
|
+
const PackageConfigV3_Publishing = IDL.Record({
|
|
249
251
|
'dfx' : IDL.Text,
|
|
250
252
|
'moc' : IDL.Text,
|
|
251
253
|
'scripts' : IDL.Vec(Script),
|
|
@@ -260,6 +262,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
260
262
|
'devDependencies' : IDL.Vec(DependencyV2),
|
|
261
263
|
'repository' : IDL.Text,
|
|
262
264
|
'dependencies' : IDL.Vec(DependencyV2),
|
|
265
|
+
'requirements' : IDL.Opt(IDL.Vec(Requirement)),
|
|
263
266
|
'license' : IDL.Text,
|
|
264
267
|
'readme' : IDL.Text,
|
|
265
268
|
});
|
|
@@ -379,7 +382,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
379
382
|
[Result_3],
|
|
380
383
|
[],
|
|
381
384
|
),
|
|
382
|
-
'startPublish' : IDL.Func([
|
|
385
|
+
'startPublish' : IDL.Func([PackageConfigV3_Publishing], [Result_2], []),
|
|
383
386
|
'transferOwnership' : IDL.Func(
|
|
384
387
|
[PackageName, IDL.Principal],
|
|
385
388
|
[Result_1],
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Principal } from '@dfinity/principal';
|
|
2
2
|
import type { ActorMethod } from '@dfinity/agent';
|
|
3
|
+
import type { IDL } from '@dfinity/candid';
|
|
3
4
|
|
|
4
5
|
export type Chunk = Array<number>;
|
|
5
6
|
export type Err = string;
|
|
@@ -35,3 +36,5 @@ export interface StorageStats {
|
|
|
35
36
|
'memorySize' : bigint,
|
|
36
37
|
}
|
|
37
38
|
export interface _SERVICE extends Storage {}
|
|
39
|
+
export declare const idlFactory: IDL.InterfaceFactory;
|
|
40
|
+
export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/fix-dist.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
// remove scripts
|
|
3
|
+
let text = readFileSync('dist/package.json', 'utf8');
|
|
4
|
+
let json = JSON.parse(text);
|
|
5
|
+
delete json.scripts;
|
|
6
|
+
// dist/bin/cli.js -> bin/cli.js
|
|
7
|
+
json.bin.mops = 'bin/mops.js';
|
|
8
|
+
json.bin['ic-mops'] = 'bin/mops.js';
|
|
9
|
+
writeFileSync('dist/package.json', JSON.stringify(json, null, 2));
|
package/dist/integrity.js
CHANGED
package/dist/mops.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
1
2
|
import path from 'node:path';
|
|
2
3
|
import fs from 'node:fs';
|
|
3
4
|
import TOML from '@iarna/toml';
|
|
@@ -9,8 +10,8 @@ import { decodeFile } from './pem.js';
|
|
|
9
10
|
import { mainActor, storageActor } from './api/actors.js';
|
|
10
11
|
import { getNetwork } from './api/network.js';
|
|
11
12
|
import { getHighestVersion } from './api/getHighestVersion.js';
|
|
12
|
-
if (!
|
|
13
|
-
|
|
13
|
+
if (!globalThis.fetch) {
|
|
14
|
+
globalThis.fetch = fetch;
|
|
14
15
|
}
|
|
15
16
|
// (!) make changes in pair with backend
|
|
16
17
|
export let apiVersion = '1.2';
|
|
@@ -179,7 +180,14 @@ export function readConfig(configFile = getClosestConfigFile()) {
|
|
|
179
180
|
};
|
|
180
181
|
processDeps(toml.dependencies || {});
|
|
181
182
|
processDeps(toml['dev-dependencies'] || {});
|
|
182
|
-
|
|
183
|
+
let config = { ...toml };
|
|
184
|
+
Object.entries(config.requirements || {}).forEach(([name, value]) => {
|
|
185
|
+
if (name === 'moc') {
|
|
186
|
+
config.requirements = config.requirements || {};
|
|
187
|
+
config.requirements.moc = value;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
return config;
|
|
183
191
|
}
|
|
184
192
|
export function writeConfig(config, configFile = getClosestConfigFile()) {
|
|
185
193
|
let resConfig = JSON.parse(JSON.stringify(config));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function notifyInstalls(
|
|
1
|
+
export declare function notifyInstalls(installedDeps: Record<string, string>): Promise<void>;
|
package/dist/notify-installs.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { getDependencyType } from './mops.js';
|
|
2
2
|
import { mainActor } from './api/actors.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
let resolvedPackages = await resolvePackages();
|
|
6
|
-
let packages = names.map(name => [name, resolvedPackages[name]]);
|
|
3
|
+
export async function notifyInstalls(installedDeps) {
|
|
4
|
+
let packages = Object.entries(installedDeps).filter(([_, version]) => getDependencyType(version) === 'mops');
|
|
7
5
|
if (packages.length) {
|
|
8
6
|
let actor = await mainActor();
|
|
9
|
-
|
|
7
|
+
try {
|
|
8
|
+
await actor.notifyInstalls(packages);
|
|
9
|
+
}
|
|
10
|
+
catch (err) {
|
|
11
|
+
// verbose && console.error('Failed to notify installs:', err);
|
|
12
|
+
}
|
|
10
13
|
}
|
|
11
14
|
}
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ic-mops",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"mops": "bin/mops.js",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"decomp-tarxz": "0.1.1",
|
|
43
43
|
"decompress": "^4.2.1",
|
|
44
44
|
"del": "7.1.0",
|
|
45
|
-
"dhall-to-json-cli": "
|
|
45
|
+
"dhall-to-json-cli": "1.7.6",
|
|
46
46
|
"eslint": "8.57.0",
|
|
47
47
|
"execa": "8.0.1",
|
|
48
48
|
"fs-extra": "11.2.0",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"bun": "1.0.35",
|
|
82
82
|
"esbuild": "0.20.1",
|
|
83
83
|
"tsx": "4.7.1",
|
|
84
|
-
"typescript": "5.3
|
|
84
|
+
"typescript": "5.4.3"
|
|
85
85
|
},
|
|
86
86
|
"overrides": {
|
|
87
87
|
"@dfinity/agent": "^0.19.3",
|
package/dist/pem.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import { Buffer } from 'node:buffer';
|
|
2
3
|
import { Ed25519KeyIdentity } from '@dfinity/identity';
|
|
3
4
|
import { Secp256k1KeyIdentity } from '@dfinity/identity-secp256k1';
|
|
4
5
|
export declare function decodeFile(file: string, password?: string): Secp256k1KeyIdentity | Ed25519KeyIdentity;
|
package/dist/pem.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
|
+
import { Buffer } from 'node:buffer';
|
|
3
|
+
import crypto from 'node:crypto';
|
|
2
4
|
import { Ed25519KeyIdentity } from '@dfinity/identity';
|
|
3
5
|
import { Secp256k1KeyIdentity } from '@dfinity/identity-secp256k1';
|
|
4
6
|
import pemfile from 'pem-file';
|
|
5
|
-
import crypto from 'crypto';
|
|
6
7
|
export function decodeFile(file, password) {
|
|
7
8
|
let rawKey = fs.readFileSync(file);
|
|
8
9
|
if (password) {
|
package/dist/resolve-packages.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
1
2
|
import path from 'node:path';
|
|
2
3
|
import chalk from 'chalk';
|
|
3
|
-
import { checkConfigFile,
|
|
4
|
+
import { checkConfigFile, getRootDir, parseGithubURL, readConfig } from './mops.js';
|
|
4
5
|
import { readVesselConfig } from './vessel.js';
|
|
6
|
+
import { getDepCacheDir, getDepCacheName } from './cache.js';
|
|
5
7
|
export async function resolvePackages({ verbose = false } = {}) {
|
|
6
8
|
if (!checkConfigFile()) {
|
|
7
9
|
return {};
|
|
@@ -61,23 +63,23 @@ export async function resolvePackages({ verbose = false } = {}) {
|
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
let nestedConfig;
|
|
64
|
-
let
|
|
66
|
+
let localNestedDir = '';
|
|
65
67
|
// read nested config
|
|
66
68
|
if (repo) {
|
|
67
|
-
|
|
68
|
-
nestedConfig = await readVesselConfig(
|
|
69
|
+
let cacheDir = getDepCacheName(name, repo);
|
|
70
|
+
nestedConfig = await readVesselConfig(getDepCacheDir(cacheDir), { silent: true }) || {};
|
|
69
71
|
}
|
|
70
72
|
else if (pkgDetails.path) {
|
|
71
|
-
|
|
72
|
-
nestedConfig = readConfig(
|
|
73
|
+
localNestedDir = path.resolve(configDir, pkgDetails.path);
|
|
74
|
+
nestedConfig = readConfig(localNestedDir + '/mops.toml');
|
|
73
75
|
}
|
|
74
76
|
else if (version) {
|
|
75
|
-
|
|
76
|
-
nestedConfig = readConfig(
|
|
77
|
+
let cacheDir = getDepCacheName(name, version);
|
|
78
|
+
nestedConfig = readConfig(getDepCacheDir(cacheDir) + '/mops.toml');
|
|
77
79
|
}
|
|
78
80
|
// collect nested deps
|
|
79
81
|
if (nestedConfig) {
|
|
80
|
-
await collectDeps(nestedConfig,
|
|
82
|
+
await collectDeps(nestedConfig, localNestedDir);
|
|
81
83
|
}
|
|
82
84
|
if (!versions[name]) {
|
|
83
85
|
versions[name] = [];
|
package/dist/types.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export type Config = {
|
|
|
18
18
|
dependencies?: Dependencies;
|
|
19
19
|
'dev-dependencies'?: Dependencies;
|
|
20
20
|
toolchain?: Toolchain;
|
|
21
|
+
requirements?: Requirements;
|
|
21
22
|
};
|
|
22
23
|
export type Dependencies = Record<string, Dependency>;
|
|
23
24
|
export type Dependency = {
|
|
@@ -32,3 +33,6 @@ export type Toolchain = {
|
|
|
32
33
|
'pocket-ic'?: string;
|
|
33
34
|
};
|
|
34
35
|
export type Tool = 'moc' | 'wasmtime' | 'pocket-ic';
|
|
36
|
+
export type Requirements = {
|
|
37
|
+
moc?: string;
|
|
38
|
+
};
|
package/dist/vessel.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
1
2
|
import { existsSync, mkdirSync, createWriteStream, readFileSync, writeFileSync } from 'node:fs';
|
|
2
3
|
import path from 'node:path';
|
|
4
|
+
import { pipeline } from 'node:stream';
|
|
3
5
|
import { deleteSync } from 'del';
|
|
4
6
|
import { execaCommand } from 'execa';
|
|
5
7
|
import chalk from 'chalk';
|
|
6
8
|
import { createLogUpdate } from 'log-update';
|
|
7
9
|
import got from 'got';
|
|
8
10
|
import decompress from 'decompress';
|
|
9
|
-
import { pipeline } from 'stream';
|
|
10
11
|
import { formatGithubDir, parseGithubURL, progressBar } from './mops.js';
|
|
11
|
-
import {
|
|
12
|
+
import { getDepCacheDir, getGithubDepCacheName, isDepCached } from './cache.js';
|
|
12
13
|
const dhallFileToJson = async (filePath, silent) => {
|
|
13
14
|
if (existsSync(filePath)) {
|
|
14
15
|
let cwd = new URL(path.dirname(import.meta.url)).pathname;
|
|
@@ -116,32 +117,29 @@ export const downloadFromGithub = async (repo, dest, onProgress) => {
|
|
|
116
117
|
return promise;
|
|
117
118
|
};
|
|
118
119
|
export const installFromGithub = async (name, repo, { verbose = false, dep = false, silent = false } = {}) => {
|
|
119
|
-
let { branch, commitHash } = parseGithubURL(repo);
|
|
120
120
|
let dir = formatGithubDir(name, repo);
|
|
121
|
-
let cacheName =
|
|
121
|
+
let cacheName = getGithubDepCacheName(name, repo);
|
|
122
|
+
let cacheDir = getDepCacheDir(cacheName);
|
|
122
123
|
let logUpdate = createLogUpdate(process.stdout, { showCursor: true });
|
|
123
124
|
if (existsSync(dir)) {
|
|
124
125
|
silent || logUpdate(`${dep ? 'Dependency' : 'Installing'} ${repo} (local cache)`);
|
|
125
126
|
}
|
|
126
|
-
else if (
|
|
127
|
-
await copyCache(cacheName, dir);
|
|
127
|
+
else if (isDepCached(cacheName)) {
|
|
128
128
|
silent || logUpdate(`${dep ? 'Dependency' : 'Installing'} ${repo} (global cache)`);
|
|
129
129
|
}
|
|
130
130
|
else {
|
|
131
|
-
mkdirSync(dir, { recursive: true });
|
|
132
131
|
let progress = (step, total) => {
|
|
133
132
|
silent || logUpdate(`${dep ? 'Dependency' : 'Installing'} ${repo} ${progressBar(step, total)}`);
|
|
134
133
|
};
|
|
135
|
-
progress(0,
|
|
134
|
+
progress(0, 1024 * 500);
|
|
135
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
136
136
|
try {
|
|
137
|
-
await downloadFromGithub(repo,
|
|
137
|
+
await downloadFromGithub(repo, cacheDir, progress);
|
|
138
138
|
}
|
|
139
139
|
catch (err) {
|
|
140
|
-
deleteSync([
|
|
140
|
+
deleteSync([cacheDir]);
|
|
141
141
|
process.exit(1);
|
|
142
142
|
}
|
|
143
|
-
// add to cache
|
|
144
|
-
await addCache(cacheName, dir);
|
|
145
143
|
}
|
|
146
144
|
if (verbose) {
|
|
147
145
|
silent || logUpdate.done();
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import {readFileSync, writeFileSync} from 'node:fs';
|
|
2
2
|
|
|
3
|
+
// remove scripts
|
|
3
4
|
let text = readFileSync('dist/package.json', 'utf8');
|
|
4
5
|
let json = JSON.parse(text);
|
|
5
6
|
delete json.scripts;
|
|
7
|
+
|
|
8
|
+
// dist/bin/cli.js -> bin/cli.js
|
|
9
|
+
json.bin.mops = 'bin/mops.js';
|
|
10
|
+
json.bin['ic-mops'] = 'bin/mops.js';
|
|
11
|
+
|
|
6
12
|
writeFileSync('dist/package.json', JSON.stringify(json, null, 2));
|
package/helpers/get-moc-path.ts
CHANGED
package/integrity.ts
CHANGED
package/mops.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
1
2
|
import path from 'node:path';
|
|
2
3
|
import fs from 'node:fs';
|
|
3
4
|
import {Identity} from '@dfinity/agent';
|
|
@@ -14,8 +15,8 @@ import {getNetwork} from './api/network.js';
|
|
|
14
15
|
import {getHighestVersion} from './api/getHighestVersion.js';
|
|
15
16
|
|
|
16
17
|
|
|
17
|
-
if (!
|
|
18
|
-
|
|
18
|
+
if (!globalThis.fetch) {
|
|
19
|
+
globalThis.fetch = fetch as any;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
// (!) make changes in pair with backend
|
|
@@ -206,7 +207,16 @@ export function readConfig(configFile = getClosestConfigFile()) : Config {
|
|
|
206
207
|
processDeps(toml.dependencies || {});
|
|
207
208
|
processDeps(toml['dev-dependencies'] || {});
|
|
208
209
|
|
|
209
|
-
|
|
210
|
+
let config : Config = {...toml};
|
|
211
|
+
|
|
212
|
+
Object.entries(config.requirements || {}).forEach(([name, value]) => {
|
|
213
|
+
if (name === 'moc') {
|
|
214
|
+
config.requirements = config.requirements || {};
|
|
215
|
+
config.requirements.moc = value;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
return config;
|
|
210
220
|
}
|
|
211
221
|
|
|
212
222
|
export function writeConfig(config : Config, configFile = getClosestConfigFile()) {
|
package/notify-installs.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import {getDependencyType} from './mops.js';
|
|
2
2
|
import {mainActor} from './api/actors.js';
|
|
3
|
-
import {resolvePackages} from './resolve-packages.js';
|
|
4
3
|
|
|
5
|
-
export async function notifyInstalls(
|
|
6
|
-
let
|
|
7
|
-
let packages : [string, string][] = names.map(name => [name, resolvedPackages[name] as string]);
|
|
4
|
+
export async function notifyInstalls(installedDeps : Record<string, string>) {
|
|
5
|
+
let packages = Object.entries(installedDeps).filter(([_, version]) => getDependencyType(version) === 'mops');
|
|
8
6
|
if (packages.length) {
|
|
9
7
|
let actor = await mainActor();
|
|
10
|
-
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
await actor.notifyInstalls(packages);
|
|
11
|
+
}
|
|
12
|
+
catch (err) {
|
|
13
|
+
// verbose && console.error('Failed to notify installs:', err);
|
|
14
|
+
}
|
|
11
15
|
}
|
|
12
16
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ic-mops",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
|
-
"mops": "bin/mops.js",
|
|
7
|
-
"ic-mops": "bin/mops.js",
|
|
6
|
+
"mops": "dist/bin/mops.js",
|
|
7
|
+
"ic-mops": "dist/bin/mops.js",
|
|
8
8
|
"moc-wrapper": "bin/moc-wrapper.sh"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"bundle:package-json": "tsx bundle-package-json.ts",
|
|
32
32
|
"bundle:tar": "tar -czvf bundle/cli.tgz bundle",
|
|
33
33
|
"copy": "cp -r commands/bench dist/commands && cp -r declarations templates package.json bin dist | true",
|
|
34
|
-
"prepare": "npm run build && npm run copy && npm run
|
|
35
|
-
"
|
|
34
|
+
"prepare": "npm run build && npm run copy && npm run fix-dist",
|
|
35
|
+
"fix-dist": "tsx ./fix-dist.ts",
|
|
36
36
|
"release": "tsx release-cli.ts",
|
|
37
37
|
"check": "tsc --project tsconfig.json --noEmit",
|
|
38
38
|
"tsc": "tsc",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"decomp-tarxz": "0.1.1",
|
|
58
58
|
"decompress": "^4.2.1",
|
|
59
59
|
"del": "7.1.0",
|
|
60
|
-
"dhall-to-json-cli": "
|
|
60
|
+
"dhall-to-json-cli": "1.7.6",
|
|
61
61
|
"eslint": "8.57.0",
|
|
62
62
|
"execa": "8.0.1",
|
|
63
63
|
"fs-extra": "11.2.0",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"bun": "1.0.35",
|
|
97
97
|
"esbuild": "0.20.1",
|
|
98
98
|
"tsx": "4.7.1",
|
|
99
|
-
"typescript": "5.3
|
|
99
|
+
"typescript": "5.4.3"
|
|
100
100
|
},
|
|
101
101
|
"overrides": {
|
|
102
102
|
"@dfinity/agent": "^0.19.3",
|
package/pem.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
|
+
import {Buffer} from 'node:buffer';
|
|
3
|
+
import crypto from 'node:crypto';
|
|
2
4
|
import {Ed25519KeyIdentity} from '@dfinity/identity';
|
|
3
5
|
import {Secp256k1KeyIdentity} from '@dfinity/identity-secp256k1';
|
|
4
6
|
import pemfile from 'pem-file';
|
|
5
|
-
import crypto from 'crypto';
|
|
6
7
|
|
|
7
8
|
export function decodeFile(file : string, password ?: string) {
|
|
8
9
|
let rawKey = fs.readFileSync(file);
|
package/resolve-packages.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
1
2
|
import path from 'node:path';
|
|
2
3
|
import chalk from 'chalk';
|
|
3
|
-
import {checkConfigFile,
|
|
4
|
+
import {checkConfigFile, getRootDir, parseGithubURL, readConfig} from './mops.js';
|
|
4
5
|
import {VesselConfig, readVesselConfig} from './vessel.js';
|
|
5
6
|
import {Config, Dependency} from './types.js';
|
|
7
|
+
import {getDepCacheDir, getDepCacheName} from './cache.js';
|
|
6
8
|
|
|
7
9
|
export async function resolvePackages({verbose = false} = {}) : Promise<Record<string, string>> {
|
|
8
10
|
if (!checkConfigFile()) {
|
|
@@ -75,25 +77,25 @@ export async function resolvePackages({verbose = false} = {}) : Promise<Record<s
|
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
let nestedConfig;
|
|
78
|
-
let
|
|
80
|
+
let localNestedDir = '';
|
|
79
81
|
|
|
80
82
|
// read nested config
|
|
81
83
|
if (repo) {
|
|
82
|
-
|
|
83
|
-
nestedConfig = await readVesselConfig(
|
|
84
|
+
let cacheDir = getDepCacheName(name, repo);
|
|
85
|
+
nestedConfig = await readVesselConfig(getDepCacheDir(cacheDir), {silent: true}) || {};
|
|
84
86
|
}
|
|
85
87
|
else if (pkgDetails.path) {
|
|
86
|
-
|
|
87
|
-
nestedConfig = readConfig(
|
|
88
|
+
localNestedDir = path.resolve(configDir, pkgDetails.path);
|
|
89
|
+
nestedConfig = readConfig(localNestedDir + '/mops.toml');
|
|
88
90
|
}
|
|
89
91
|
else if (version) {
|
|
90
|
-
|
|
91
|
-
nestedConfig = readConfig(
|
|
92
|
+
let cacheDir = getDepCacheName(name, version);
|
|
93
|
+
nestedConfig = readConfig(getDepCacheDir(cacheDir) + '/mops.toml');
|
|
92
94
|
}
|
|
93
95
|
|
|
94
96
|
// collect nested deps
|
|
95
97
|
if (nestedConfig) {
|
|
96
|
-
await collectDeps(nestedConfig,
|
|
98
|
+
await collectDeps(nestedConfig, localNestedDir);
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
if (!versions[name]) {
|
package/tsconfig.json
CHANGED
package/types.ts
CHANGED
|
@@ -18,6 +18,7 @@ export type Config = {
|
|
|
18
18
|
dependencies ?: Dependencies;
|
|
19
19
|
'dev-dependencies' ?: Dependencies;
|
|
20
20
|
toolchain ?: Toolchain;
|
|
21
|
+
requirements ?: Requirements;
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
export type Dependencies = Record<string, Dependency>;
|
|
@@ -27,7 +28,7 @@ export type Dependency = {
|
|
|
27
28
|
version ?: string; // mops package
|
|
28
29
|
repo ?: string; // github package
|
|
29
30
|
path ?: string; // local package
|
|
30
|
-
}
|
|
31
|
+
};
|
|
31
32
|
|
|
32
33
|
export type Toolchain = {
|
|
33
34
|
moc ?: string;
|
|
@@ -35,4 +36,8 @@ export type Toolchain = {
|
|
|
35
36
|
'pocket-ic' ?: string;
|
|
36
37
|
};
|
|
37
38
|
|
|
38
|
-
export type Tool = 'moc' | 'wasmtime' | 'pocket-ic';
|
|
39
|
+
export type Tool = 'moc' | 'wasmtime' | 'pocket-ic';
|
|
40
|
+
|
|
41
|
+
export type Requirements = {
|
|
42
|
+
moc ?: string;
|
|
43
|
+
};
|
package/vessel.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
1
2
|
import {existsSync, mkdirSync, createWriteStream, readFileSync, writeFileSync} from 'node:fs';
|
|
2
3
|
import path from 'node:path';
|
|
4
|
+
import {pipeline} from 'node:stream';
|
|
3
5
|
import {deleteSync} from 'del';
|
|
4
6
|
import {execaCommand} from 'execa';
|
|
5
7
|
import chalk from 'chalk';
|
|
6
8
|
import {createLogUpdate} from 'log-update';
|
|
7
9
|
import got from 'got';
|
|
8
10
|
import decompress from 'decompress';
|
|
9
|
-
import {pipeline} from 'stream';
|
|
10
11
|
import {formatGithubDir, parseGithubURL, progressBar} from './mops.js';
|
|
11
|
-
import {
|
|
12
|
+
import {getDepCacheDir, getGithubDepCacheName, isDepCached} from './cache.js';
|
|
12
13
|
|
|
13
14
|
const dhallFileToJson = async (filePath : string, silent : boolean) => {
|
|
14
15
|
if (existsSync(filePath)) {
|
|
@@ -149,38 +150,35 @@ export const downloadFromGithub = async (repo : string, dest : string, onProgres
|
|
|
149
150
|
};
|
|
150
151
|
|
|
151
152
|
export const installFromGithub = async (name : string, repo : string, {verbose = false, dep = false, silent = false} = {}) => {
|
|
152
|
-
let {branch, commitHash} = parseGithubURL(repo);
|
|
153
153
|
let dir = formatGithubDir(name, repo);
|
|
154
|
-
let cacheName =
|
|
154
|
+
let cacheName = getGithubDepCacheName(name, repo);
|
|
155
|
+
let cacheDir = getDepCacheDir(cacheName);
|
|
155
156
|
|
|
156
157
|
let logUpdate = createLogUpdate(process.stdout, {showCursor: true});
|
|
157
158
|
|
|
158
159
|
if (existsSync(dir)) {
|
|
159
160
|
silent || logUpdate(`${dep ? 'Dependency' : 'Installing'} ${repo} (local cache)`);
|
|
160
161
|
}
|
|
161
|
-
else if (
|
|
162
|
-
await copyCache(cacheName, dir);
|
|
162
|
+
else if (isDepCached(cacheName)) {
|
|
163
163
|
silent || logUpdate(`${dep ? 'Dependency' : 'Installing'} ${repo} (global cache)`);
|
|
164
164
|
}
|
|
165
165
|
else {
|
|
166
|
-
mkdirSync(dir, {recursive: true});
|
|
167
166
|
|
|
168
167
|
let progress = (step : number, total : number) => {
|
|
169
168
|
silent || logUpdate(`${dep ? 'Dependency' : 'Installing'} ${repo} ${progressBar(step, total)}`);
|
|
170
169
|
};
|
|
171
170
|
|
|
172
|
-
progress(0,
|
|
171
|
+
progress(0, 1024 * 500);
|
|
172
|
+
|
|
173
|
+
mkdirSync(cacheDir, {recursive: true});
|
|
173
174
|
|
|
174
175
|
try {
|
|
175
|
-
await downloadFromGithub(repo,
|
|
176
|
+
await downloadFromGithub(repo, cacheDir, progress);
|
|
176
177
|
}
|
|
177
178
|
catch (err) {
|
|
178
|
-
deleteSync([
|
|
179
|
+
deleteSync([cacheDir]);
|
|
179
180
|
process.exit(1);
|
|
180
181
|
}
|
|
181
|
-
|
|
182
|
-
// add to cache
|
|
183
|
-
await addCache(cacheName, dir);
|
|
184
182
|
}
|
|
185
183
|
|
|
186
184
|
if (verbose) {
|