ic-mops 0.41.1 → 0.42.1
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 +14 -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/check-requirements.ts +3 -2
- package/cli.ts +7 -3
- 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 +53 -0
- package/commands/install/install-dep.ts +34 -0
- package/commands/install/install-deps.ts +24 -0
- package/commands/install/install-local-dep.ts +31 -0
- package/commands/install/install-mops-dep.ts +122 -0
- 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/check-requirements.js +3 -2
- package/dist/cli.js +7 -3
- 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 +37 -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 +14 -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 +97 -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 +11 -16
- 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 +12 -18
- package/commands/install-all.ts +0 -58
- package/commands/install-local.ts +0 -52
- package/commands/install.ts +0 -126
package/dist/commands/remove.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import { deleteSync } from 'del';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
|
-
import {
|
|
4
|
+
import { checkConfigFile, getRootDir, readConfig, writeConfig } from '../mops.js';
|
|
5
5
|
import { checkIntegrity } from '../integrity.js';
|
|
6
|
-
|
|
6
|
+
import { getDepCacheDir, getDepCacheName } from '../cache.js';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { syncLocalCache } from './install/sync-local-cache.js';
|
|
7
9
|
export async function remove(name, { dev = false, verbose = false, dryRun = false, lock } = {}) {
|
|
8
10
|
if (!checkConfigFile()) {
|
|
9
11
|
return;
|
|
@@ -20,13 +22,12 @@ export async function remove(name, { dev = false, verbose = false, dryRun = fals
|
|
|
20
22
|
}).flat();
|
|
21
23
|
}
|
|
22
24
|
function getTransitiveDependenciesOf(name, version, repo) {
|
|
23
|
-
let
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
else if (version) {
|
|
28
|
-
pkgDir = formatDir(name, version);
|
|
25
|
+
let value = version || repo;
|
|
26
|
+
if (!value) {
|
|
27
|
+
return [];
|
|
29
28
|
}
|
|
29
|
+
let cacheName = getDepCacheName(name, value);
|
|
30
|
+
let pkgDir = getDepCacheDir(cacheName);
|
|
30
31
|
let configFile = pkgDir + '/mops.toml';
|
|
31
32
|
if (!fs.existsSync(configFile)) {
|
|
32
33
|
verbose && console.log('no config', configFile);
|
|
@@ -61,16 +62,11 @@ export async function remove(name, { dev = false, verbose = false, dryRun = fals
|
|
|
61
62
|
verbose && console.log(`Ignored transitive dependency ${depId} (other deps depend on it)`);
|
|
62
63
|
continue;
|
|
63
64
|
}
|
|
64
|
-
let
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
pkgDir = formatDir(dep.name, dep.version);
|
|
70
|
-
}
|
|
71
|
-
if (pkgDir && fs.existsSync(pkgDir)) {
|
|
72
|
-
dryRun || deleteSync([`${pkgDir}`], { force: true });
|
|
73
|
-
verbose && console.log(`Removed local cache ${pkgDir}`);
|
|
65
|
+
let cacheName = getDepCacheName(dep.name, dep.version || dep.repo || '');
|
|
66
|
+
let localCacheDir = path.join(getRootDir(), '.mops', cacheName);
|
|
67
|
+
if (localCacheDir && fs.existsSync(localCacheDir)) {
|
|
68
|
+
dryRun || deleteSync([localCacheDir], { force: true });
|
|
69
|
+
verbose && console.log(`Removed local cache ${localCacheDir}`);
|
|
74
70
|
}
|
|
75
71
|
}
|
|
76
72
|
// remove from config
|
|
@@ -81,6 +77,7 @@ export async function remove(name, { dev = false, verbose = false, dryRun = fals
|
|
|
81
77
|
delete config['dev-dependencies'][name];
|
|
82
78
|
}
|
|
83
79
|
dryRun || writeConfig(config);
|
|
80
|
+
await syncLocalCache();
|
|
84
81
|
await checkIntegrity(lock);
|
|
85
82
|
console.log(chalk.green('Package removed ') + `${name} = "${version}"`);
|
|
86
83
|
}
|
package/dist/commands/search.js
CHANGED
package/dist/commands/self.js
CHANGED
package/dist/commands/sources.js
CHANGED
package/dist/commands/sync.js
CHANGED
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.1",
|
|
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,26 @@ 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
|
-
if (
|
|
124
|
-
silent || logUpdate(`${dep ? 'Dependency' : 'Installing'} ${repo} (
|
|
125
|
-
}
|
|
126
|
-
else if (isCached(cacheName)) {
|
|
127
|
-
await copyCache(cacheName, dir);
|
|
128
|
-
silent || logUpdate(`${dep ? 'Dependency' : 'Installing'} ${repo} (global cache)`);
|
|
124
|
+
if (isDepCached(cacheName)) {
|
|
125
|
+
silent || logUpdate(`${dep ? 'Dependency' : 'Installing'} ${repo} (cache)`);
|
|
129
126
|
}
|
|
130
127
|
else {
|
|
131
|
-
mkdirSync(dir, { recursive: true });
|
|
132
128
|
let progress = (step, total) => {
|
|
133
129
|
silent || logUpdate(`${dep ? 'Dependency' : 'Installing'} ${repo} ${progressBar(step, total)}`);
|
|
134
130
|
};
|
|
135
|
-
progress(0,
|
|
131
|
+
progress(0, 1024 * 500);
|
|
132
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
136
133
|
try {
|
|
137
|
-
await downloadFromGithub(repo,
|
|
134
|
+
await downloadFromGithub(repo, cacheDir, progress);
|
|
138
135
|
}
|
|
139
136
|
catch (err) {
|
|
140
|
-
deleteSync([
|
|
137
|
+
deleteSync([cacheDir]);
|
|
141
138
|
process.exit(1);
|
|
142
139
|
}
|
|
143
|
-
// add to cache
|
|
144
|
-
await addCache(cacheName, dir);
|
|
145
140
|
}
|
|
146
141
|
if (verbose) {
|
|
147
142
|
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.1",
|
|
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]) {
|