ic-mops 0.41.1 → 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/cli.js +29 -29
- package/bundle/cli.tgz +0 -0
- package/bundle/declarations/bench/index.js +0 -8
- package/bundle/declarations/storage/storage.did.d.ts +3 -0
- package/bundle/package.json +2 -2
- package/cache.ts +25 -7
- package/cli.ts +3 -2
- package/commands/add.ts +9 -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 +1 -0
- 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 +1 -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/index.js +0 -8
- package/declarations/storage/storage.did.d.ts +3 -0
- package/dist/api/actors.js +2 -2
- package/dist/cache.d.ts +7 -3
- package/dist/cache.js +21 -7
- package/dist/cli.js +3 -2
- package/dist/commands/add.js +7 -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/publish.js +1 -0
- 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 +1 -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/index.js +0 -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 +3 -2
- package/dist/notify-installs.d.ts +1 -1
- package/dist/notify-installs.js +8 -5
- package/dist/package.json +5 -5
- package/dist/pem.d.ts +1 -0
- package/dist/pem.js +2 -1
- package/dist/release-cli.js +0 -4
- package/dist/resolve-packages.js +11 -9
- 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 +3 -2
- package/notify-installs.ts +9 -5
- package/package.json +5 -5
- package/pem.ts +2 -1
- package/release-cli.ts +0 -5
- package/resolve-packages.ts +11 -9
- package/tsconfig.json +1 -0
- package/vessel.ts +11 -13
- package/commands/install-all.ts +0 -58
- package/commands/install-local.ts +0 -52
package/dist/commands/user.js
CHANGED
|
@@ -4,14 +4,6 @@ import { Actor, HttpAgent } from "@dfinity/agent";
|
|
|
4
4
|
import { idlFactory } from "./bench.did.js";
|
|
5
5
|
export { idlFactory } from "./bench.did.js";
|
|
6
6
|
|
|
7
|
-
/* CANISTER_ID is replaced by webpack based on node environment
|
|
8
|
-
* Note: canister environment variable will be standardized as
|
|
9
|
-
* process.env.CANISTER_ID_<CANISTER_NAME_UPPERCASE>
|
|
10
|
-
* beginning in dfx 0.15.0
|
|
11
|
-
*/
|
|
12
|
-
export const canisterId =
|
|
13
|
-
process.env.CANISTER_ID_BENCH;
|
|
14
|
-
|
|
15
7
|
export const createActor = (canisterId, options = {}) => {
|
|
16
8
|
const agent = options.agent || new HttpAgent({ ...options.agentOptions });
|
|
17
9
|
|
|
@@ -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';
|
|
@@ -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,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": "
|
|
7
|
-
"ic-mops": "
|
|
6
|
+
"mops": "bin/mops.js",
|
|
7
|
+
"ic-mops": "bin/mops.js",
|
|
8
8
|
"moc-wrapper": "bin/moc-wrapper.sh"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
@@ -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/release-cli.js
CHANGED
|
@@ -10,10 +10,6 @@ import { findChangelogEntry } from './helpers/find-changelog-entry.js';
|
|
|
10
10
|
let __dirname = new URL('.', import.meta.url).pathname;
|
|
11
11
|
execSync('npm run prepare', { stdio: 'inherit', cwd: __dirname });
|
|
12
12
|
execSync('npm run bundle', { stdio: 'inherit', cwd: __dirname });
|
|
13
|
-
// fix package.json paths
|
|
14
|
-
// let packageJson = fs.readFileSync(path.resolve(__dirname, 'bundle/package.json'), 'utf8');
|
|
15
|
-
// packageJson = packageJson.replaceAll('dist/', '');
|
|
16
|
-
// fs.writeFileSync(path.resolve(__dirname, 'bundle/package.json'), packageJson);
|
|
17
13
|
let version = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'package.json'), 'utf8')).version;
|
|
18
14
|
let major = semver.parse(version)?.major;
|
|
19
15
|
let tag = semver.parse(version)?.prerelease[0] || 'latest';
|
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/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
|
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,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": "dist/bin/mops.js",
|
|
@@ -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/release-cli.ts
CHANGED
|
@@ -14,11 +14,6 @@ let __dirname = new URL('.', import.meta.url).pathname;
|
|
|
14
14
|
execSync('npm run prepare', {stdio: 'inherit', cwd: __dirname});
|
|
15
15
|
execSync('npm run bundle', {stdio: 'inherit', cwd: __dirname});
|
|
16
16
|
|
|
17
|
-
// fix package.json paths
|
|
18
|
-
// let packageJson = fs.readFileSync(path.resolve(__dirname, 'bundle/package.json'), 'utf8');
|
|
19
|
-
// packageJson = packageJson.replaceAll('dist/', '');
|
|
20
|
-
// fs.writeFileSync(path.resolve(__dirname, 'bundle/package.json'), packageJson);
|
|
21
|
-
|
|
22
17
|
let version = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'package.json'), 'utf8')).version;
|
|
23
18
|
let major = semver.parse(version)?.major;
|
|
24
19
|
let tag = semver.parse(version)?.prerelease[0] || 'latest';
|
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/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) {
|
package/commands/install-all.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3
|
-
import {createLogUpdate} from 'log-update';
|
|
4
|
-
import {checkConfigFile, readConfig} from '../mops.js';
|
|
5
|
-
import {install} from './install.js';
|
|
6
|
-
import {installFromGithub} from '../vessel.js';
|
|
7
|
-
import {notifyInstalls} from '../notify-installs.js';
|
|
8
|
-
import {checkIntegrity} from '../integrity.js';
|
|
9
|
-
import {installLocal} from './install-local.js';
|
|
10
|
-
import {checkRequirements} from '../check-requirements.js';
|
|
11
|
-
|
|
12
|
-
type InstallAllOptions = {
|
|
13
|
-
verbose ?: boolean;
|
|
14
|
-
silent ?: boolean;
|
|
15
|
-
lock ?: 'check' | 'update' | 'ignore';
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export async function installAll({verbose = false, silent = false, lock} : InstallAllOptions = {}) {
|
|
19
|
-
if (!checkConfigFile()) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
let config = readConfig();
|
|
24
|
-
let deps = Object.values(config.dependencies || {});
|
|
25
|
-
let devDeps = Object.values(config['dev-dependencies'] || {});
|
|
26
|
-
let allDeps = [...deps, ...devDeps];
|
|
27
|
-
let installedPackages = {};
|
|
28
|
-
|
|
29
|
-
for (let {name, repo, path, version} of allDeps) {
|
|
30
|
-
if (repo) {
|
|
31
|
-
await installFromGithub(name, repo, {verbose, silent});
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
let res = await (path ? installLocal(name, path, {silent, verbose}) : install(name, version, {silent, verbose}));
|
|
35
|
-
if (res === false) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
installedPackages = {...installedPackages, ...res};
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
let logUpdate = createLogUpdate(process.stdout, {showCursor: true});
|
|
43
|
-
|
|
44
|
-
if (!silent && lock !== 'ignore') {
|
|
45
|
-
logUpdate('Checking integrity...');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
await Promise.all([
|
|
49
|
-
notifyInstalls(Object.keys(installedPackages)),
|
|
50
|
-
checkIntegrity(lock),
|
|
51
|
-
]);
|
|
52
|
-
|
|
53
|
-
if (!silent) {
|
|
54
|
-
logUpdate.clear();
|
|
55
|
-
await checkRequirements();
|
|
56
|
-
console.log(chalk.green('Packages installed'));
|
|
57
|
-
}
|
|
58
|
-
}
|