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
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import {installFromGithub} from '../../vessel.js';
|
|
3
|
+
import {installMopsDep} from './install-mops-dep.js';
|
|
4
|
+
import {Dependency} from '../../types.js';
|
|
5
|
+
import {installLocalDep} from './install-local-dep.js';
|
|
6
|
+
import {getRootDir} from '../../mops.js';
|
|
7
|
+
|
|
8
|
+
type InstallDepOptions = {
|
|
9
|
+
verbose ?: boolean;
|
|
10
|
+
silent ?: boolean;
|
|
11
|
+
threads ?: number;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// install dependency
|
|
15
|
+
// returns false if failed
|
|
16
|
+
export async function installDep(dep : Dependency, {verbose, silent, threads} : InstallDepOptions = {}, parentPkgPath ?: string) : Promise<Record<string, string> | false> {
|
|
17
|
+
if (dep.repo) {
|
|
18
|
+
await installFromGithub(dep.name, dep.repo, {silent, verbose});
|
|
19
|
+
return {};
|
|
20
|
+
}
|
|
21
|
+
else if (dep.path) {
|
|
22
|
+
let depPath = dep.path;
|
|
23
|
+
parentPkgPath = parentPkgPath || getRootDir();
|
|
24
|
+
if (parentPkgPath) {
|
|
25
|
+
depPath = path.resolve(parentPkgPath, dep.path);
|
|
26
|
+
}
|
|
27
|
+
return installLocalDep(dep.name, depPath, {silent, verbose});
|
|
28
|
+
}
|
|
29
|
+
else if (dep.version) {
|
|
30
|
+
return installMopsDep(dep.name, dep.version, {silent, verbose, threads});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {Dependency} from '../../types.js';
|
|
2
|
+
import {installDep} from './install-dep.js';
|
|
3
|
+
|
|
4
|
+
type InstallDepsOptions = {
|
|
5
|
+
verbose ?: boolean;
|
|
6
|
+
silent ?: boolean;
|
|
7
|
+
threads ?: number;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// install all dependencies
|
|
11
|
+
// returns actual installed dependencies
|
|
12
|
+
// returns false if failed
|
|
13
|
+
export async function installDeps(deps : Dependency[], {verbose, silent, threads} : InstallDepsOptions = {}, parentPkgPath ?: string) : Promise<Record<string, string> | false> {
|
|
14
|
+
let installedDeps = {};
|
|
15
|
+
let ok = true;
|
|
16
|
+
for (const dep of deps) {
|
|
17
|
+
let res = await installDep(dep, {verbose, silent, threads}, parentPkgPath);
|
|
18
|
+
if (res) {
|
|
19
|
+
installedDeps = {...installedDeps, ...res};
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
ok = false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!ok) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return installedDeps;
|
|
31
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {createLogUpdate} from 'log-update';
|
|
4
|
+
import {getRootDir, readConfig} from '../../mops.js';
|
|
5
|
+
import {installDeps} from './install-deps.js';
|
|
6
|
+
|
|
7
|
+
type InstallLocalDepOptions = {
|
|
8
|
+
verbose ?: boolean;
|
|
9
|
+
silent ?: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// skip install and just find non-local dependencies to install
|
|
13
|
+
// pkgPath should be relative to the current root dir or absolute
|
|
14
|
+
export async function installLocalDep(pkg : string, pkgPath = '', {verbose, silent} : InstallLocalDepOptions = {}) : Promise<Record<string, string> | false> {
|
|
15
|
+
if (!silent) {
|
|
16
|
+
let logUpdate = createLogUpdate(process.stdout, {showCursor: true});
|
|
17
|
+
logUpdate(`Local dependency ${pkg} = "${pkgPath}"`);
|
|
18
|
+
|
|
19
|
+
if (verbose) {
|
|
20
|
+
silent || logUpdate.done();
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
logUpdate.clear();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// install dependencies
|
|
28
|
+
let dir = path.resolve(getRootDir(), pkgPath);
|
|
29
|
+
let config = readConfig(path.join(dir, 'mops.toml'));
|
|
30
|
+
return installDeps(Object.values(config.dependencies || {}), {silent, verbose}, pkgPath);
|
|
31
|
+
}
|
|
@@ -1,17 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import process from 'node:process';
|
|
2
2
|
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import {Buffer} from 'node:buffer';
|
|
3
5
|
import {createLogUpdate} from 'log-update';
|
|
4
6
|
import chalk from 'chalk';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {downloadFile, getPackageFilesInfo} from '
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
import {deleteSync} from 'del';
|
|
8
|
+
import {checkConfigFile, formatDir, progressBar, readConfig} from '../../mops.js';
|
|
9
|
+
import {getHighestVersion} from '../../api/getHighestVersion.js';
|
|
10
|
+
import {storageActor} from '../../api/actors.js';
|
|
11
|
+
import {parallel} from '../../parallel.js';
|
|
12
|
+
import {getDepCacheDir, getMopsDepCacheName, isDepCached} from '../../cache.js';
|
|
13
|
+
import {downloadFile, getPackageFilesInfo} from '../../api/downloadPackageFiles.js';
|
|
14
|
+
import {installDeps} from './install-deps.js';
|
|
15
|
+
|
|
16
|
+
type InstallMopsDepOptions = {
|
|
17
|
+
verbose ?: boolean;
|
|
18
|
+
silent ?: boolean;
|
|
19
|
+
dep ?: boolean;
|
|
20
|
+
threads ?: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export async function installMopsDep(pkg : string, version = '', {verbose, silent, dep, threads} : InstallMopsDepOptions = {}) : Promise<Record<string, string> | false> {
|
|
24
|
+
threads = threads || 12;
|
|
25
|
+
|
|
15
26
|
if (!checkConfigFile()) {
|
|
16
27
|
return false;
|
|
17
28
|
}
|
|
@@ -36,6 +47,8 @@ export async function install(pkg : string, version = '', {verbose = false, sile
|
|
|
36
47
|
}
|
|
37
48
|
|
|
38
49
|
let dir = formatDir(pkg, version);
|
|
50
|
+
let cacheName = getMopsDepCacheName(pkg, version);
|
|
51
|
+
let cacheDir = getDepCacheDir(cacheName);
|
|
39
52
|
let alreadyInstalled = false;
|
|
40
53
|
|
|
41
54
|
// already installed
|
|
@@ -44,14 +57,11 @@ export async function install(pkg : string, version = '', {verbose = false, sile
|
|
|
44
57
|
alreadyInstalled = true;
|
|
45
58
|
}
|
|
46
59
|
// copy from cache
|
|
47
|
-
else if (
|
|
48
|
-
await copyCache(`${pkg}@${version}`, dir);
|
|
60
|
+
else if (isDepCached(cacheName)) {
|
|
49
61
|
silent || logUpdate(`${dep ? 'Dependency' : 'Installing'} ${pkg}@${version} (global cache)`);
|
|
50
62
|
}
|
|
51
63
|
// download
|
|
52
64
|
else {
|
|
53
|
-
let threads = 16;
|
|
54
|
-
|
|
55
65
|
// GitHub Actions fails with "fetch failed" if there are multiple concurrent actions
|
|
56
66
|
if (process.env.GITHUB_ENV) {
|
|
57
67
|
threads = 4;
|
|
@@ -71,10 +81,17 @@ export async function install(pkg : string, version = '', {verbose = false, sile
|
|
|
71
81
|
progress();
|
|
72
82
|
});
|
|
73
83
|
|
|
74
|
-
// write files to
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
84
|
+
// write files to global cache
|
|
85
|
+
try {
|
|
86
|
+
for (let [filePath, data] of filesData.entries()) {
|
|
87
|
+
fs.mkdirSync(path.join(cacheDir, path.dirname(filePath)), {recursive: true});
|
|
88
|
+
fs.writeFileSync(path.join(cacheDir, filePath), Buffer.from(data));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
console.error(chalk.red('Error: ') + err);
|
|
93
|
+
deleteSync([cacheDir], {force: true});
|
|
94
|
+
return false;
|
|
78
95
|
}
|
|
79
96
|
}
|
|
80
97
|
catch (err) {
|
|
@@ -82,9 +99,6 @@ export async function install(pkg : string, version = '', {verbose = false, sile
|
|
|
82
99
|
return false;
|
|
83
100
|
}
|
|
84
101
|
|
|
85
|
-
// add to cache
|
|
86
|
-
await addCache(`${pkg}@${version}`, dir);
|
|
87
|
-
|
|
88
102
|
progress();
|
|
89
103
|
}
|
|
90
104
|
|
|
@@ -96,31 +110,17 @@ export async function install(pkg : string, version = '', {verbose = false, sile
|
|
|
96
110
|
}
|
|
97
111
|
|
|
98
112
|
// install dependencies
|
|
99
|
-
let
|
|
100
|
-
let
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (repo) {
|
|
105
|
-
await installFromGithub(name, repo, {silent, verbose});
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
let res = await (depPath ? installLocal(name, depPath, {silent, verbose}) : install(name, version, {silent, verbose}));
|
|
109
|
-
if (res) {
|
|
110
|
-
installedDeps = {...installedDeps, ...res};
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
ok = false;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
113
|
+
let config = readConfig(path.join(cacheDir, 'mops.toml'));
|
|
114
|
+
let res = await installDeps(Object.values(config.dependencies || {}), {silent, verbose});
|
|
115
|
+
|
|
116
|
+
if (!res) {
|
|
117
|
+
return false;
|
|
116
118
|
}
|
|
119
|
+
let installedDeps = res;
|
|
117
120
|
|
|
121
|
+
// add self to installed deps
|
|
118
122
|
if (!alreadyInstalled) {
|
|
119
123
|
installedDeps = {...installedDeps, [pkg]: version};
|
|
120
124
|
}
|
|
121
|
-
|
|
122
|
-
if (!ok) {
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
125
|
return installedDeps;
|
|
126
126
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {copyCache, getDepCacheName} from '../../cache.js';
|
|
4
|
+
import {getDependencyType, getRootDir} from '../../mops.js';
|
|
5
|
+
import {resolvePackages} from '../../resolve-packages.js';
|
|
6
|
+
|
|
7
|
+
export async function syncLocalCache({verbose = false} = {}) : Promise<Record<string, string>> {
|
|
8
|
+
let resolvedPackages = await resolvePackages();
|
|
9
|
+
let rootDir = getRootDir();
|
|
10
|
+
|
|
11
|
+
verbose && console.log('Syncing local cache...');
|
|
12
|
+
|
|
13
|
+
let installedDeps : Record<string, string> = {};
|
|
14
|
+
|
|
15
|
+
await Promise.all(Object.entries(resolvedPackages).map(([name, value]) => {
|
|
16
|
+
let depType = getDependencyType(value);
|
|
17
|
+
|
|
18
|
+
if (depType === 'mops' || depType === 'github') {
|
|
19
|
+
let cacheName = getDepCacheName(name, value);
|
|
20
|
+
let dest = path.join(rootDir, '.mops', cacheName);
|
|
21
|
+
|
|
22
|
+
if (!fs.existsSync(dest)) {
|
|
23
|
+
if (depType === 'mops') {
|
|
24
|
+
installedDeps[name] = value;
|
|
25
|
+
}
|
|
26
|
+
return copyCache(cacheName, path.join(rootDir, '.mops', cacheName));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return Promise.resolve();
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
return installedDeps;
|
|
34
|
+
}
|
package/commands/publish.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
1
2
|
import fs from 'node:fs';
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import chalk from 'chalk';
|
|
@@ -10,7 +11,7 @@ import {checkConfigFile, getIdentity, getRootDir, progressBar, readConfig} from
|
|
|
10
11
|
import {mainActor} from '../api/actors.js';
|
|
11
12
|
import {parallel} from '../parallel.js';
|
|
12
13
|
import {docs} from './docs.js';
|
|
13
|
-
import {Benchmarks, DependencyV2,
|
|
14
|
+
import {Benchmarks, DependencyV2, PackageConfigV3_Publishing, Requirement} from '../declarations/main/main.did.js';
|
|
14
15
|
import {Dependency} from '../types.js';
|
|
15
16
|
import {testWithReporter} from './test/test.js';
|
|
16
17
|
import {SilentReporter} from './test/reporters/silent-reporter.js';
|
|
@@ -29,7 +30,7 @@ export async function publish(options : {docs ?: boolean, test ?: boolean, bench
|
|
|
29
30
|
|
|
30
31
|
// validate
|
|
31
32
|
for (let key of Object.keys(config)) {
|
|
32
|
-
if (!['package', 'dependencies', 'dev-dependencies', 'toolchain'].includes(key)) {
|
|
33
|
+
if (!['package', 'dependencies', 'dev-dependencies', 'toolchain', 'requirements'].includes(key)) {
|
|
33
34
|
console.log(chalk.red('Error: ') + `Unknown config section [${key}]`);
|
|
34
35
|
process.exit(1);
|
|
35
36
|
}
|
|
@@ -160,6 +161,15 @@ export async function publish(options : {docs ?: boolean, test ?: boolean, bench
|
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
163
|
|
|
164
|
+
if (config.requirements) {
|
|
165
|
+
Object.keys(config.requirements).forEach((name) => {
|
|
166
|
+
if (name !== 'moc') {
|
|
167
|
+
console.log(chalk.red('Error: ') + `Unknown requirement "${name}"`);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
163
173
|
let toBackendDep = (dep : Dependency) : DependencyV2 => {
|
|
164
174
|
return {
|
|
165
175
|
...dep,
|
|
@@ -168,8 +178,12 @@ export async function publish(options : {docs ?: boolean, test ?: boolean, bench
|
|
|
168
178
|
};
|
|
169
179
|
};
|
|
170
180
|
|
|
181
|
+
let toBackendReq = ([name, value] : [string, string]) : Requirement => {
|
|
182
|
+
return {name, value};
|
|
183
|
+
};
|
|
184
|
+
|
|
171
185
|
// map fields
|
|
172
|
-
let backendPkgConfig :
|
|
186
|
+
let backendPkgConfig : PackageConfigV3_Publishing = {
|
|
173
187
|
name: config.package.name,
|
|
174
188
|
version: config.package.version,
|
|
175
189
|
keywords: config.package.keywords || [],
|
|
@@ -186,6 +200,7 @@ export async function publish(options : {docs ?: boolean, test ?: boolean, bench
|
|
|
186
200
|
dependencies: Object.values(config.dependencies || {}).map(toBackendDep),
|
|
187
201
|
devDependencies: Object.values(config['dev-dependencies'] || {}).map(toBackendDep),
|
|
188
202
|
scripts: [],
|
|
203
|
+
requirements: [Object.entries(config.requirements || {}).map((req) => toBackendReq(req))],
|
|
189
204
|
};
|
|
190
205
|
|
|
191
206
|
let defaultFiles = [
|
package/commands/remove.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
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 {Config, Dependency} from '../types.js';
|
|
6
6
|
import {checkIntegrity} from '../integrity.js';
|
|
7
|
+
import {getDepCacheDir, getDepCacheName} from '../cache.js';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import {syncLocalCache} from './install/sync-local-cache.js';
|
|
7
10
|
|
|
8
11
|
type RemoveOptions = {
|
|
9
12
|
verbose ?: boolean;
|
|
@@ -12,7 +15,6 @@ type RemoveOptions = {
|
|
|
12
15
|
lock ?: 'update' | 'ignore';
|
|
13
16
|
};
|
|
14
17
|
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16
18
|
export async function remove(name : string, {dev = false, verbose = false, dryRun = false, lock} : RemoveOptions = {}) {
|
|
17
19
|
if (!checkConfigFile()) {
|
|
18
20
|
return;
|
|
@@ -31,13 +33,12 @@ export async function remove(name : string, {dev = false, verbose = false, dryRu
|
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
function getTransitiveDependenciesOf(name : string, version : string | undefined, repo ?: string) {
|
|
34
|
-
let
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
else if (version) {
|
|
39
|
-
pkgDir = formatDir(name, version);
|
|
36
|
+
let value = version || repo;
|
|
37
|
+
if (!value) {
|
|
38
|
+
return [];
|
|
40
39
|
}
|
|
40
|
+
let cacheName = getDepCacheName(name, value);
|
|
41
|
+
let pkgDir = getDepCacheDir(cacheName);
|
|
41
42
|
let configFile = pkgDir + '/mops.toml';
|
|
42
43
|
if (!fs.existsSync(configFile)) {
|
|
43
44
|
verbose && console.log('no config', configFile);
|
|
@@ -78,16 +79,11 @@ export async function remove(name : string, {dev = false, verbose = false, dryRu
|
|
|
78
79
|
verbose && console.log(`Ignored transitive dependency ${depId} (other deps depend on it)`);
|
|
79
80
|
continue;
|
|
80
81
|
}
|
|
81
|
-
let
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
pkgDir = formatDir(dep.name, dep.version);
|
|
87
|
-
}
|
|
88
|
-
if (pkgDir && fs.existsSync(pkgDir)) {
|
|
89
|
-
dryRun || deleteSync([`${pkgDir}`], {force: true});
|
|
90
|
-
verbose && console.log(`Removed local cache ${pkgDir}`);
|
|
82
|
+
let cacheName = getDepCacheName(dep.name, dep.version || dep.repo || '');
|
|
83
|
+
let localCacheDir = path.join(getRootDir(), '.mops', cacheName);
|
|
84
|
+
if (localCacheDir && fs.existsSync(localCacheDir)) {
|
|
85
|
+
dryRun || deleteSync([localCacheDir], {force: true});
|
|
86
|
+
verbose && console.log(`Removed local cache ${localCacheDir}`);
|
|
91
87
|
}
|
|
92
88
|
}
|
|
93
89
|
|
|
@@ -100,6 +96,7 @@ export async function remove(name : string, {dev = false, verbose = false, dryRu
|
|
|
100
96
|
}
|
|
101
97
|
dryRun || writeConfig(config);
|
|
102
98
|
|
|
99
|
+
await syncLocalCache();
|
|
103
100
|
await checkIntegrity(lock);
|
|
104
101
|
|
|
105
102
|
console.log(chalk.green('Package removed ') + `${name} = "${version}"`);
|
package/commands/search.ts
CHANGED
package/commands/self.ts
CHANGED
package/commands/sources.ts
CHANGED
package/commands/sync.ts
CHANGED
package/commands/test/test.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 os from 'node:os';
|
|
@@ -7,6 +8,7 @@ import prompts from 'prompts';
|
|
|
7
8
|
import {createLogUpdate} from 'log-update';
|
|
8
9
|
import {checkConfigFile, getClosestConfigFile, getRootDir, globalCacheDir, readConfig, writeConfig} from '../../mops.js';
|
|
9
10
|
import {Tool} from '../../types.js';
|
|
11
|
+
import {checkRequirements} from '../../check-requirements.js';
|
|
10
12
|
import * as moc from './moc.js';
|
|
11
13
|
import * as pocketIc from './pocket-ic.js';
|
|
12
14
|
import * as wasmtime from './wasmtime.js';
|
|
@@ -243,6 +245,8 @@ async function use(tool : Tool, version ?: string) {
|
|
|
243
245
|
config.toolchain[tool] = version;
|
|
244
246
|
writeConfig(config);
|
|
245
247
|
|
|
248
|
+
await checkRequirements();
|
|
249
|
+
|
|
246
250
|
if (oldVersion === version) {
|
|
247
251
|
console.log((`${tool} ${version} is already installed`));
|
|
248
252
|
}
|
|
@@ -277,6 +281,10 @@ async function update(tool ?: Tool) {
|
|
|
277
281
|
config.toolchain[tool] = version;
|
|
278
282
|
writeConfig(config);
|
|
279
283
|
|
|
284
|
+
if (tool === 'moc') {
|
|
285
|
+
await checkRequirements();
|
|
286
|
+
}
|
|
287
|
+
|
|
280
288
|
if (oldVersion === version) {
|
|
281
289
|
console.log((`Latest ${tool} ${version} is already installed`));
|
|
282
290
|
}
|
package/commands/user.ts
CHANGED
|
@@ -26,4 +26,4 @@ export interface anon_class_10_1 {
|
|
|
26
26
|
}
|
|
27
27
|
export interface _SERVICE extends anon_class_10_1 {}
|
|
28
28
|
export declare const idlFactory: IDL.InterfaceFactory;
|
|
29
|
-
export declare const init: (
|
|
29
|
+
export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];
|
|
@@ -4,15 +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
|
-
process.env.BENCH_CANISTER_ID;
|
|
15
|
-
|
|
16
7
|
export const createActor = (canisterId, options = {}) => {
|
|
17
8
|
const agent = options.agent || new HttpAgent({ ...options.agentOptions });
|
|
18
9
|
|
|
@@ -10,8 +10,7 @@ export { idlFactory } from "./main.did.js";
|
|
|
10
10
|
* beginning in dfx 0.15.0
|
|
11
11
|
*/
|
|
12
12
|
export const canisterId =
|
|
13
|
-
process.env.CANISTER_ID_MAIN
|
|
14
|
-
process.env.MAIN_CANISTER_ID;
|
|
13
|
+
process.env.CANISTER_ID_MAIN;
|
|
15
14
|
|
|
16
15
|
export const createActor = (canisterId, options = {}) => {
|
|
17
16
|
const agent = options.agent || new HttpAgent({ ...options.agentOptions });
|
|
@@ -132,6 +132,11 @@ type Response =
|
|
|
132
132
|
streaming_strategy: opt StreamingStrategy;
|
|
133
133
|
upgrade: opt bool;
|
|
134
134
|
};
|
|
135
|
+
type Requirement =
|
|
136
|
+
record {
|
|
137
|
+
name: text;
|
|
138
|
+
value: text;
|
|
139
|
+
};
|
|
135
140
|
type Request =
|
|
136
141
|
record {
|
|
137
142
|
body: blob;
|
|
@@ -145,7 +150,7 @@ type PageCount = nat;
|
|
|
145
150
|
type PackageVersion = text;
|
|
146
151
|
type PackageSummary__1 =
|
|
147
152
|
record {
|
|
148
|
-
config:
|
|
153
|
+
config: PackageConfigV3;
|
|
149
154
|
downloadsInLast30Days: nat;
|
|
150
155
|
downloadsInLast7Days: nat;
|
|
151
156
|
downloadsTotal: nat;
|
|
@@ -157,7 +162,7 @@ type PackageSummary__1 =
|
|
|
157
162
|
type PackageSummaryWithChanges__1 =
|
|
158
163
|
record {
|
|
159
164
|
changes: PackageChanges;
|
|
160
|
-
config:
|
|
165
|
+
config: PackageConfigV3;
|
|
161
166
|
downloadsInLast30Days: nat;
|
|
162
167
|
downloadsInLast7Days: nat;
|
|
163
168
|
downloadsTotal: nat;
|
|
@@ -169,7 +174,7 @@ type PackageSummaryWithChanges__1 =
|
|
|
169
174
|
type PackageSummaryWithChanges =
|
|
170
175
|
record {
|
|
171
176
|
changes: PackageChanges;
|
|
172
|
-
config:
|
|
177
|
+
config: PackageConfigV3;
|
|
173
178
|
downloadsInLast30Days: nat;
|
|
174
179
|
downloadsInLast7Days: nat;
|
|
175
180
|
downloadsTotal: nat;
|
|
@@ -180,7 +185,7 @@ type PackageSummaryWithChanges =
|
|
|
180
185
|
};
|
|
181
186
|
type PackageSummary =
|
|
182
187
|
record {
|
|
183
|
-
config:
|
|
188
|
+
config: PackageConfigV3;
|
|
184
189
|
downloadsInLast30Days: nat;
|
|
185
190
|
downloadsInLast7Days: nat;
|
|
186
191
|
downloadsTotal: nat;
|
|
@@ -218,7 +223,7 @@ type PackageDetails =
|
|
|
218
223
|
record {
|
|
219
224
|
benchmarks: Benchmarks__1;
|
|
220
225
|
changes: PackageChanges;
|
|
221
|
-
config:
|
|
226
|
+
config: PackageConfigV3;
|
|
222
227
|
dependents: vec PackageSummary__1;
|
|
223
228
|
deps: vec PackageSummary__1;
|
|
224
229
|
devDeps: vec PackageSummary__1;
|
|
@@ -234,7 +239,7 @@ type PackageDetails =
|
|
|
234
239
|
testStats: TestStats__1;
|
|
235
240
|
versionHistory: vec PackageSummaryWithChanges__1;
|
|
236
241
|
};
|
|
237
|
-
type
|
|
242
|
+
type PackageConfigV3_Publishing =
|
|
238
243
|
record {
|
|
239
244
|
baseDir: text;
|
|
240
245
|
dependencies: vec DependencyV2;
|
|
@@ -250,10 +255,11 @@ type PackageConfigV2__1 =
|
|
|
250
255
|
name: PackageName__1;
|
|
251
256
|
readme: text;
|
|
252
257
|
repository: text;
|
|
258
|
+
requirements: opt vec Requirement;
|
|
253
259
|
scripts: vec Script;
|
|
254
260
|
version: text;
|
|
255
261
|
};
|
|
256
|
-
type
|
|
262
|
+
type PackageConfigV3 =
|
|
257
263
|
record {
|
|
258
264
|
baseDir: text;
|
|
259
265
|
dependencies: vec DependencyV2;
|
|
@@ -269,6 +275,7 @@ type PackageConfigV2 =
|
|
|
269
275
|
name: PackageName__1;
|
|
270
276
|
readme: text;
|
|
271
277
|
repository: text;
|
|
278
|
+
requirements: vec Requirement;
|
|
272
279
|
scripts: vec Script;
|
|
273
280
|
version: text;
|
|
274
281
|
};
|
|
@@ -341,7 +348,7 @@ type Main =
|
|
|
341
348
|
search: (Text, opt nat, opt nat) -> (vec PackageSummary, PageCount) query;
|
|
342
349
|
setUserProp: (text, text) -> (Result_1);
|
|
343
350
|
startFileUpload: (PublishingId, Text, nat, blob) -> (Result_3);
|
|
344
|
-
startPublish: (
|
|
351
|
+
startPublish: (PackageConfigV3_Publishing) -> (Result_2);
|
|
345
352
|
transferOwnership: (PackageName, principal) -> (Result_1);
|
|
346
353
|
transformRequest: (HttpTransformArg) -> (HttpResponse) query;
|
|
347
354
|
uploadBenchmarks: (PublishingId, Benchmarks) -> (Result);
|