ic-mops 0.36.0 → 0.37.0-pre.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/bin/moc-wrapper.sh +54 -0
- package/bin/mops.ts +3 -0
- package/cli.ts +40 -4
- package/commands/toolchain/index.ts +153 -0
- package/commands/toolchain/moc.ts +43 -0
- package/commands/toolchain/mocv.ts +313 -0
- package/commands/toolchain/pocket-ic.ts +37 -0
- package/commands/toolchain/toolchain-utils.ts +74 -0
- package/commands/toolchain/wasmtime.ts +30 -0
- package/dist/bin/mops.d.ts +1 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +34 -3
- package/dist/commands/toolchain/index.d.ts +12 -0
- package/dist/commands/toolchain/index.js +127 -0
- package/dist/commands/toolchain/moc.js +4 -4
- package/dist/commands/toolchain/pocket-ic.d.ts +4 -0
- package/dist/commands/toolchain/pocket-ic.js +28 -0
- package/dist/commands/toolchain/toolchain-utils.d.ts +1 -1
- package/dist/commands/toolchain/toolchain-utils.js +9 -2
- package/dist/commands/toolchain/wasmtime.js +2 -2
- package/dist/mops.js +1 -1
- package/dist/package.json +17 -12
- package/dist/types.d.ts +7 -0
- package/global.d.ts +2 -1
- package/moc-wrapper.ts +10 -0
- package/mops.ts +2 -2
- package/package.json +17 -12
- package/types.ts +10 -1
- package/cli-local.ts +0 -3
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import {unzipSync} from 'node:zlib';
|
|
3
|
+
import {chmodSync} from 'node:fs';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import decompress from 'decompress';
|
|
6
|
+
import decompressTarxz from 'decomp-tarxz';
|
|
7
|
+
import {deleteSync} from 'del';
|
|
8
|
+
import {Octokit} from 'octokit';
|
|
9
|
+
import tar from 'tar';
|
|
10
|
+
|
|
11
|
+
import {getRootDir} from '../../mops.js';
|
|
12
|
+
|
|
13
|
+
export let downloadAndExtract = async (url: string, dest: string) => {
|
|
14
|
+
let res = await fetch(url);
|
|
15
|
+
|
|
16
|
+
if (res.status !== 200) {
|
|
17
|
+
console.error(`ERROR ${res.status} ${url}`);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let arrayBuffer = await res.arrayBuffer();
|
|
22
|
+
let buffer = Buffer.from(arrayBuffer);
|
|
23
|
+
|
|
24
|
+
let tmpDir = path.join(getRootDir(), '.mops', '_tmp');
|
|
25
|
+
let archive = path.join(tmpDir, path.basename(url));
|
|
26
|
+
|
|
27
|
+
fs.mkdirSync(tmpDir, {recursive: true});
|
|
28
|
+
fs.writeFileSync(archive, buffer);
|
|
29
|
+
|
|
30
|
+
fs.mkdirSync(dest, {recursive: true});
|
|
31
|
+
|
|
32
|
+
if (archive.endsWith('.xz')) {
|
|
33
|
+
await decompress(archive, dest, {
|
|
34
|
+
strip: 1,
|
|
35
|
+
plugins: [decompressTarxz()],
|
|
36
|
+
}).catch(() => {
|
|
37
|
+
deleteSync([tmpDir]);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
else if (archive.endsWith('tar.gz')) {
|
|
41
|
+
await tar.extract({
|
|
42
|
+
file: archive,
|
|
43
|
+
cwd: dest,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
else if (archive.endsWith('.gz')) {
|
|
47
|
+
let destFile = path.join(dest, path.parse(archive).name);
|
|
48
|
+
fs.writeFileSync(destFile, unzipSync(buffer));
|
|
49
|
+
chmodSync(destFile, 0o700);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
deleteSync([tmpDir], {force: true});
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export let getLatestReleaseTag = async (repo: string): Promise<string | undefined> => {
|
|
56
|
+
let releases = await getReleases(repo);
|
|
57
|
+
let release = releases.find((release: any) => !release.prerelease && !release.draft);
|
|
58
|
+
return release?.tag_name;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export let getReleases = async (repo: string) => {
|
|
62
|
+
let octokit = new Octokit;
|
|
63
|
+
let res = await octokit.request(`GET /repos/${repo}/releases`, {
|
|
64
|
+
per_page: 10,
|
|
65
|
+
headers: {
|
|
66
|
+
'X-GitHub-Api-Version': '2022-11-28'
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
if (res.status !== 200) {
|
|
70
|
+
console.log('Releases fetch error');
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
return res.data;
|
|
74
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
|
|
4
|
+
import {globalCacheDir} from '../../mops.js';
|
|
5
|
+
import {downloadAndExtract} from './toolchain-utils.js';
|
|
6
|
+
|
|
7
|
+
let cacheDir = path.join(globalCacheDir, 'wasmtime');
|
|
8
|
+
|
|
9
|
+
export let isCached = (version: string) => {
|
|
10
|
+
let dir = path.join(cacheDir, version);
|
|
11
|
+
return fs.existsSync(dir) && fs.existsSync(path.join(dir, 'wasmtime'));
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export let download = async (version: string, {silent = false} = {}) => {
|
|
15
|
+
if (!version) {
|
|
16
|
+
console.error('version is not defined');
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
if (isCached(version)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let platfrom = process.platform == 'darwin' ? 'macos' : 'linux';
|
|
24
|
+
let arch = process.arch.startsWith('arm') ? 'aarch64' : 'x86_64';
|
|
25
|
+
let url = `https://github.com/bytecodealliance/wasmtime/releases/download/v${version}/wasmtime-v${version}-${arch}-${platfrom}.tar.xz`;
|
|
26
|
+
|
|
27
|
+
silent || console.log(`Downloading ${url}`);
|
|
28
|
+
|
|
29
|
+
await downloadAndExtract(url, path.join(cacheDir, version));
|
|
30
|
+
};
|
package/dist/bin/mops.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import '../cli.js';
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
import fs from 'node:fs';
|
|
3
|
-
import {
|
|
2
|
+
import { Command, Argument, Option } from 'commander';
|
|
4
3
|
import chalk from 'chalk';
|
|
5
4
|
import { init } from './commands/init.js';
|
|
6
5
|
import { publish } from './commands/publish.js';
|
|
@@ -24,10 +23,12 @@ import { outdated } from './commands/outdated.js';
|
|
|
24
23
|
import { update } from './commands/update.js';
|
|
25
24
|
import { bench } from './commands/bench.js';
|
|
26
25
|
import { transferOwnership } from './commands/transfer-ownership.js';
|
|
26
|
+
import { toolchain } from './commands/toolchain/index.js';
|
|
27
27
|
let networkFile = getNetworkFile();
|
|
28
28
|
if (fs.existsSync(networkFile)) {
|
|
29
29
|
globalThis.MOPS_NETWORK = fs.readFileSync(networkFile).toString() || 'ic';
|
|
30
30
|
}
|
|
31
|
+
let program = new Command();
|
|
31
32
|
program.name('mops');
|
|
32
33
|
// --version
|
|
33
34
|
let packageJson = JSON.parse(fs.readFileSync(new URL('package.json', import.meta.url)).toString());
|
|
@@ -44,7 +45,7 @@ program
|
|
|
44
45
|
program
|
|
45
46
|
.command('add <pkg>')
|
|
46
47
|
.description('Install the package and save it to mops.toml')
|
|
47
|
-
.option('--dev')
|
|
48
|
+
.option('--dev', 'Add to [dev-dependencies] section')
|
|
48
49
|
.option('--verbose')
|
|
49
50
|
.addOption(new Option('--lock <action>', 'Lockfile action').choices(['update', 'ignore']))
|
|
50
51
|
.action(async (pkg, options) => {
|
|
@@ -290,4 +291,34 @@ program
|
|
|
290
291
|
.action(async (toPrincipal) => {
|
|
291
292
|
await transferOwnership(toPrincipal);
|
|
292
293
|
});
|
|
294
|
+
// toolchain
|
|
295
|
+
const toolchainCommand = new Command('toolchain').description('Toolchain management');
|
|
296
|
+
toolchainCommand
|
|
297
|
+
.command('init')
|
|
298
|
+
.description('One-time initialization of toolchain management')
|
|
299
|
+
.action(async () => {
|
|
300
|
+
toolchain.init();
|
|
301
|
+
});
|
|
302
|
+
toolchainCommand
|
|
303
|
+
.command('reset')
|
|
304
|
+
.description('Uninstall toolchain management')
|
|
305
|
+
.action(async () => {
|
|
306
|
+
toolchain.init({ reset: true });
|
|
307
|
+
});
|
|
308
|
+
toolchainCommand
|
|
309
|
+
.command('use')
|
|
310
|
+
.description('Install specified tool version and update mops.toml')
|
|
311
|
+
.addArgument(new Argument('<tool>').choices(['moc', 'wasmtime', 'pocket-ic']))
|
|
312
|
+
.addArgument(new Argument('<version>'))
|
|
313
|
+
.action(async (tool, version) => {
|
|
314
|
+
toolchain.use(tool, version);
|
|
315
|
+
});
|
|
316
|
+
toolchainCommand
|
|
317
|
+
.command('bin')
|
|
318
|
+
.description('Get path to the tool binary\n<tool> can be one of "moc", "wasmtime", "pocket-ic"')
|
|
319
|
+
.addArgument(new Argument('<tool>').choices(['moc', 'wasmtime', 'pocket-ic']))
|
|
320
|
+
.action(async (tool) => {
|
|
321
|
+
toolchain.bin(tool);
|
|
322
|
+
});
|
|
323
|
+
program.addCommand(toolchainCommand);
|
|
293
324
|
program.parse();
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Tool } from '../../types.js';
|
|
2
|
+
declare function init({ reset }?: {
|
|
3
|
+
reset?: boolean | undefined;
|
|
4
|
+
}): Promise<void>;
|
|
5
|
+
declare function use(tool: Tool, version: string): Promise<void>;
|
|
6
|
+
declare function bin(tool: Tool): Promise<void>;
|
|
7
|
+
export declare let toolchain: {
|
|
8
|
+
init: typeof init;
|
|
9
|
+
use: typeof use;
|
|
10
|
+
bin: typeof bin;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import { execSync } from 'node:child_process';
|
|
5
|
+
import { getClosestConfigFile, globalCacheDir, readConfig, writeConfig } from '../../mops.js';
|
|
6
|
+
import * as moc from './moc.js';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
// update shell config files to set DFX_MOC_PATH to moc-wrapper
|
|
9
|
+
async function init({ reset = false } = {}) {
|
|
10
|
+
if (process.platform == 'win32') {
|
|
11
|
+
console.error('Windows is not supported. Please use WSL');
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
let res = execSync('which mocv').toString().trim();
|
|
16
|
+
if (res) {
|
|
17
|
+
console.error('Mops is not compatible with mocv. Please uninstall mocv and try again.');
|
|
18
|
+
console.log('Steps to uninstall mocv:');
|
|
19
|
+
console.log('1. Run "mocv reset"');
|
|
20
|
+
console.log('2. Run "npm uninstall -g mocv"');
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch { }
|
|
25
|
+
let zshrc = path.join(os.homedir(), '.zshrc');
|
|
26
|
+
let bashrc = path.join(os.homedir(), '.bashrc');
|
|
27
|
+
let shellConfigFiles = [bashrc, zshrc].filter((file) => {
|
|
28
|
+
return fs.existsSync(file);
|
|
29
|
+
});
|
|
30
|
+
if (shellConfigFiles.length === 0) {
|
|
31
|
+
console.error('Shell config files not found: ".bashrc" or ".zshrc"');
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
// update all existing shell config files
|
|
35
|
+
for (let configFile of shellConfigFiles) {
|
|
36
|
+
let text = fs.readFileSync(configFile).toString();
|
|
37
|
+
let setDfxLine = '\nexport DFX_MOC_PATH="moc-wrapper"';
|
|
38
|
+
let newLines = [
|
|
39
|
+
setDfxLine,
|
|
40
|
+
];
|
|
41
|
+
let oldLines = [
|
|
42
|
+
// legacy mocv lines
|
|
43
|
+
`\nexport DFX_MOC_PATH=${path.join(path.join(os.homedir(), '.cache/mocv'), 'versions/current')}/moc`,
|
|
44
|
+
'\nexport DFX_MOC_PATH="$HOME/.cache/mocv/versions/current/moc"',
|
|
45
|
+
// new
|
|
46
|
+
setDfxLine,
|
|
47
|
+
];
|
|
48
|
+
// remove old lines
|
|
49
|
+
for (let oldLine of oldLines) {
|
|
50
|
+
text = text.replace(oldLine, '');
|
|
51
|
+
}
|
|
52
|
+
if (text.endsWith('\n\n')) {
|
|
53
|
+
text = text.trimEnd() + '\n';
|
|
54
|
+
}
|
|
55
|
+
// insert new lines
|
|
56
|
+
if (!reset) {
|
|
57
|
+
if (!text.endsWith('\n')) {
|
|
58
|
+
text += '\n';
|
|
59
|
+
}
|
|
60
|
+
for (let newLine of newLines) {
|
|
61
|
+
text += newLine;
|
|
62
|
+
}
|
|
63
|
+
text += '\n';
|
|
64
|
+
}
|
|
65
|
+
fs.writeFileSync(configFile, text);
|
|
66
|
+
}
|
|
67
|
+
console.log(chalk.green('Success!'));
|
|
68
|
+
}
|
|
69
|
+
async function download(tool, version) {
|
|
70
|
+
if (tool === 'moc') {
|
|
71
|
+
await moc.download(version);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// async function downloadAll() {
|
|
75
|
+
// let config = readConfig();
|
|
76
|
+
// if (config.toolchain?.moc) {
|
|
77
|
+
// await download('moc', config.toolchain.moc);
|
|
78
|
+
// }
|
|
79
|
+
// if (config.toolchain?.wasmtime) {
|
|
80
|
+
// await download('wasmtime', config.toolchain.wasmtime);
|
|
81
|
+
// }
|
|
82
|
+
// if (config.toolchain?.['pocket-ic']) {
|
|
83
|
+
// await download('pocket-ic', config.toolchain['pocket-ic']);
|
|
84
|
+
// }
|
|
85
|
+
// }
|
|
86
|
+
// download binary and set version in mops.toml
|
|
87
|
+
async function use(tool, version) {
|
|
88
|
+
await download(tool, version);
|
|
89
|
+
let config = readConfig();
|
|
90
|
+
config.toolchain = config.toolchain || {};
|
|
91
|
+
config.toolchain[tool] = version;
|
|
92
|
+
writeConfig(config);
|
|
93
|
+
}
|
|
94
|
+
// return current version from mops.toml
|
|
95
|
+
async function bin(tool) {
|
|
96
|
+
let hasConfig = getClosestConfigFile();
|
|
97
|
+
// fallback to dfx moc
|
|
98
|
+
if (!hasConfig) {
|
|
99
|
+
console.log(execSync('dfx cache show').toString().trim() + '/moc');
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
let config = readConfig();
|
|
103
|
+
let version = config.toolchain?.[tool];
|
|
104
|
+
if (!version) {
|
|
105
|
+
// fallback to dfx moc
|
|
106
|
+
if (tool === 'moc') {
|
|
107
|
+
console.log(execSync('dfx cache show').toString().trim() + '/moc');
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
console.error(`Toolchain '${tool}' is not defined in mops.toml`);
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
if (version) {
|
|
114
|
+
await download(tool, version);
|
|
115
|
+
if (tool === 'moc') {
|
|
116
|
+
console.log(path.join(globalCacheDir, 'moc', version, 'moc'));
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
console.log(path.join(globalCacheDir, tool, version, 'moc'));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export let toolchain = {
|
|
124
|
+
init,
|
|
125
|
+
use,
|
|
126
|
+
bin,
|
|
127
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import fs from 'fs-extra';
|
|
3
3
|
import { globalCacheDir } from '../../mops.js';
|
|
4
|
-
import {
|
|
4
|
+
import { downloadAndExtract } from './toolchain-utils.js';
|
|
5
5
|
let cacheDir = path.join(globalCacheDir, 'moc');
|
|
6
6
|
export let isCached = (version) => {
|
|
7
7
|
let dir = path.join(cacheDir, version);
|
|
@@ -9,11 +9,11 @@ export let isCached = (version) => {
|
|
|
9
9
|
};
|
|
10
10
|
export let download = async (version, { silent = false } = {}) => {
|
|
11
11
|
if (process.platform == 'win32') {
|
|
12
|
-
console.
|
|
12
|
+
console.error('Windows is not supported. Please use WSL');
|
|
13
13
|
process.exit(1);
|
|
14
14
|
}
|
|
15
15
|
if (!version) {
|
|
16
|
-
console.
|
|
16
|
+
console.error('version is not defined');
|
|
17
17
|
process.exit(1);
|
|
18
18
|
}
|
|
19
19
|
if (isCached(version)) {
|
|
@@ -32,5 +32,5 @@ export let download = async (version, { silent = false } = {}) => {
|
|
|
32
32
|
url = `https://github.com/dfinity/motoko/releases/download/${version}/motoko-${platfrom}-${version}.tar.gz`;
|
|
33
33
|
}
|
|
34
34
|
silent || console.log(`Downloading ${url}`);
|
|
35
|
-
await
|
|
35
|
+
await downloadAndExtract(url, path.join(cacheDir, version));
|
|
36
36
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { globalCacheDir } from '../../mops.js';
|
|
4
|
+
import { downloadAndExtract } from './toolchain-utils.js';
|
|
5
|
+
let cacheDir = path.join(globalCacheDir, 'pocket-ic');
|
|
6
|
+
export let isCached = (version) => {
|
|
7
|
+
let dir = path.join(cacheDir, version);
|
|
8
|
+
return fs.existsSync(dir) && fs.existsSync(path.join(dir, 'pocket-ic'));
|
|
9
|
+
};
|
|
10
|
+
export let download = async (version, { silent = false } = {}) => {
|
|
11
|
+
if (!version) {
|
|
12
|
+
console.error('version is not defined');
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
if (isCached(version)) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
let platfrom = process.platform == 'darwin' ? 'darwin' : 'linux';
|
|
19
|
+
let arch = 'x86_64';
|
|
20
|
+
let hashes = {
|
|
21
|
+
'2.0.1': '69e1408347723dbaa7a6cd2faa9b65c42abbe861',
|
|
22
|
+
'2.0.0': '29ec86dc9f9ca4691d4d4386c8b2aa41e14d9d16',
|
|
23
|
+
'1.0.0': '307d5847c1d2fe1f5e19181c7d0fcec23f4658b3',
|
|
24
|
+
};
|
|
25
|
+
let url = `https://download.dfinity.systems/ic/${hashes[version]}/openssl-static-binaries/${arch}-${platfrom}/pocket-ic.gz`;
|
|
26
|
+
silent || console.log(`Downloading ${url}`);
|
|
27
|
+
await downloadAndExtract(url, path.join(cacheDir, version));
|
|
28
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare let
|
|
1
|
+
export declare let downloadAndExtract: (url: string, dest: string) => Promise<void>;
|
|
2
2
|
export declare let getLatestReleaseTag: (repo: string) => Promise<string | undefined>;
|
|
3
3
|
export declare let getReleases: (repo: string) => Promise<any>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
+
import { unzipSync } from 'node:zlib';
|
|
3
|
+
import { chmodSync } from 'node:fs';
|
|
2
4
|
import fs from 'fs-extra';
|
|
3
5
|
import decompress from 'decompress';
|
|
4
6
|
import decompressTarxz from 'decomp-tarxz';
|
|
@@ -6,7 +8,7 @@ import { deleteSync } from 'del';
|
|
|
6
8
|
import { Octokit } from 'octokit';
|
|
7
9
|
import tar from 'tar';
|
|
8
10
|
import { getRootDir } from '../../mops.js';
|
|
9
|
-
export let
|
|
11
|
+
export let downloadAndExtract = async (url, dest) => {
|
|
10
12
|
let res = await fetch(url);
|
|
11
13
|
if (res.status !== 200) {
|
|
12
14
|
console.error(`ERROR ${res.status} ${url}`);
|
|
@@ -27,12 +29,17 @@ export let downloadGithubRelease = async (url, dest) => {
|
|
|
27
29
|
deleteSync([tmpDir]);
|
|
28
30
|
});
|
|
29
31
|
}
|
|
30
|
-
else {
|
|
32
|
+
else if (archive.endsWith('tar.gz')) {
|
|
31
33
|
await tar.extract({
|
|
32
34
|
file: archive,
|
|
33
35
|
cwd: dest,
|
|
34
36
|
});
|
|
35
37
|
}
|
|
38
|
+
else if (archive.endsWith('.gz')) {
|
|
39
|
+
let destFile = path.join(dest, path.parse(archive).name);
|
|
40
|
+
fs.writeFileSync(destFile, unzipSync(buffer));
|
|
41
|
+
chmodSync(destFile, 0o700);
|
|
42
|
+
}
|
|
36
43
|
deleteSync([tmpDir], { force: true });
|
|
37
44
|
};
|
|
38
45
|
export let getLatestReleaseTag = async (repo) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import fs from 'fs-extra';
|
|
3
3
|
import { globalCacheDir } from '../../mops.js';
|
|
4
|
-
import {
|
|
4
|
+
import { downloadAndExtract } from './toolchain-utils.js';
|
|
5
5
|
let cacheDir = path.join(globalCacheDir, 'wasmtime');
|
|
6
6
|
export let isCached = (version) => {
|
|
7
7
|
let dir = path.join(cacheDir, version);
|
|
@@ -19,5 +19,5 @@ export let download = async (version, { silent = false } = {}) => {
|
|
|
19
19
|
let arch = process.arch.startsWith('arm') ? 'aarch64' : 'x86_64';
|
|
20
20
|
let url = `https://github.com/bytecodealliance/wasmtime/releases/download/v${version}/wasmtime-v${version}-${arch}-${platfrom}.tar.xz`;
|
|
21
21
|
silent || console.log(`Downloading ${url}`);
|
|
22
|
-
await
|
|
22
|
+
await downloadAndExtract(url, path.join(cacheDir, version));
|
|
23
23
|
};
|
package/dist/mops.js
CHANGED
package/dist/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ic-mops",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0-pre.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
|
-
"mops": "dist/
|
|
6
|
+
"mops": "dist/bin/mops.js",
|
|
7
|
+
"moc-wrapper": "bin/moc-wrapper.sh"
|
|
7
8
|
},
|
|
8
9
|
"files": [
|
|
9
10
|
"*",
|
|
@@ -32,11 +33,11 @@
|
|
|
32
33
|
"esbuild": "esbuild"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
|
-
"@dfinity/agent": "^0.
|
|
36
|
-
"@dfinity/candid": "^0.
|
|
37
|
-
"@dfinity/identity": "^0.
|
|
38
|
-
"@dfinity/identity-secp256k1": "^0.
|
|
39
|
-
"@dfinity/principal": "^0.
|
|
36
|
+
"@dfinity/agent": "^0.19.3",
|
|
37
|
+
"@dfinity/candid": "^0.19.3",
|
|
38
|
+
"@dfinity/identity": "^0.19.3",
|
|
39
|
+
"@dfinity/identity-secp256k1": "^0.19.3",
|
|
40
|
+
"@dfinity/principal": "^0.19.3",
|
|
40
41
|
"@hadronous/pic": "0.2.0",
|
|
41
42
|
"@iarna/toml": "^2.2.5",
|
|
42
43
|
"@noble/hashes": "1.3.2",
|
|
@@ -45,13 +46,15 @@
|
|
|
45
46
|
"camelcase": "^7.0.1",
|
|
46
47
|
"chalk": "^5.3.0",
|
|
47
48
|
"chokidar": "^3.5.3",
|
|
48
|
-
"commander": "
|
|
49
|
+
"commander": "11.1.0",
|
|
49
50
|
"debounce": "^1.2.1",
|
|
51
|
+
"decomp-tarxz": "0.1.1",
|
|
50
52
|
"decompress": "^4.2.1",
|
|
51
53
|
"del": "^7.0.0",
|
|
52
54
|
"dhall-to-json-cli": "^1.7.6",
|
|
53
55
|
"eslint": "^8.45.0",
|
|
54
56
|
"execa": "7.1.1",
|
|
57
|
+
"fs-extra": "11.2.0",
|
|
55
58
|
"get-folder-size": "^4.0.0",
|
|
56
59
|
"glob": "^10.3.3",
|
|
57
60
|
"globby": "^13.2.2",
|
|
@@ -63,6 +66,7 @@
|
|
|
63
66
|
"minimatch": "^9.0.3",
|
|
64
67
|
"ncp": "^2.0.0",
|
|
65
68
|
"node-fetch": "^3.3.2",
|
|
69
|
+
"octokit": "3.1.2",
|
|
66
70
|
"pem-file": "^1.0.1",
|
|
67
71
|
"prompts": "^2.4.2",
|
|
68
72
|
"stream-to-promise": "^3.0.0",
|
|
@@ -73,6 +77,7 @@
|
|
|
73
77
|
"@tsconfig/strictest": "^2.0.1",
|
|
74
78
|
"@types/debounce": "^1.2.1",
|
|
75
79
|
"@types/decompress": "^4.2.4",
|
|
80
|
+
"@types/fs-extra": "11.0.4",
|
|
76
81
|
"@types/glob": "^8.1.0",
|
|
77
82
|
"@types/ncp": "^2.0.5",
|
|
78
83
|
"@types/node": "^20.4.4",
|
|
@@ -84,9 +89,9 @@
|
|
|
84
89
|
"typescript": "^5.1.6"
|
|
85
90
|
},
|
|
86
91
|
"overrides": {
|
|
87
|
-
"@dfinity/agent": "^0.
|
|
88
|
-
"@dfinity/identity": "^0.
|
|
89
|
-
"@dfinity/principal": "^0.
|
|
90
|
-
"@dfinity/candid": "^0.
|
|
92
|
+
"@dfinity/agent": "^0.19.3",
|
|
93
|
+
"@dfinity/identity": "^0.19.3",
|
|
94
|
+
"@dfinity/principal": "^0.19.3",
|
|
95
|
+
"@dfinity/candid": "^0.19.3"
|
|
91
96
|
}
|
|
92
97
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export type Config = {
|
|
|
17
17
|
};
|
|
18
18
|
dependencies?: Dependencies;
|
|
19
19
|
'dev-dependencies'?: Dependencies;
|
|
20
|
+
toolchain?: Toolchain;
|
|
20
21
|
};
|
|
21
22
|
export type Dependencies = Record<string, Dependency>;
|
|
22
23
|
export type Dependency = {
|
|
@@ -25,3 +26,9 @@ export type Dependency = {
|
|
|
25
26
|
repo?: string;
|
|
26
27
|
path?: string;
|
|
27
28
|
};
|
|
29
|
+
export type Toolchain = {
|
|
30
|
+
moc?: string;
|
|
31
|
+
wasmtime?: string;
|
|
32
|
+
'pocket-ic'?: string;
|
|
33
|
+
};
|
|
34
|
+
export type Tool = 'moc' | 'wasmtime' | 'pocket-ic';
|
package/global.d.ts
CHANGED
package/moc-wrapper.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
|
|
3
|
+
import {ExecException, execSync} from 'child_process';
|
|
4
|
+
|
|
5
|
+
try {
|
|
6
|
+
execSync('/home/zen/.cache/mocv/versions/current/moc ' + process.argv.slice(2).join(' '), {cwd: process.cwd(), stdio: 'inherit'});
|
|
7
|
+
}
|
|
8
|
+
catch (err: unknown) {
|
|
9
|
+
process.exit((err as ExecException).code || 1);
|
|
10
|
+
}
|
package/mops.ts
CHANGED
|
@@ -106,9 +106,9 @@ export let getIdentity = async (): Promise<Identity | undefined> => {
|
|
|
106
106
|
return undefined;
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
export function getClosestConfigFile(dir = process.cwd()) {
|
|
109
|
+
export function getClosestConfigFile(dir = process.cwd()) : string {
|
|
110
110
|
if (!path.basename(dir)) {
|
|
111
|
-
|
|
111
|
+
return '';
|
|
112
112
|
}
|
|
113
113
|
let configFile = path.join(dir, 'mops.toml');
|
|
114
114
|
if (fs.existsSync(configFile)) {
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ic-mops",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0-pre.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
|
-
"mops": "dist/
|
|
6
|
+
"mops": "dist/bin/mops.js",
|
|
7
|
+
"moc-wrapper": "bin/moc-wrapper.sh"
|
|
7
8
|
},
|
|
8
9
|
"files": [
|
|
9
10
|
"*",
|
|
@@ -32,11 +33,11 @@
|
|
|
32
33
|
"esbuild": "esbuild"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
|
-
"@dfinity/agent": "^0.
|
|
36
|
-
"@dfinity/candid": "^0.
|
|
37
|
-
"@dfinity/identity": "^0.
|
|
38
|
-
"@dfinity/identity-secp256k1": "^0.
|
|
39
|
-
"@dfinity/principal": "^0.
|
|
36
|
+
"@dfinity/agent": "^0.19.3",
|
|
37
|
+
"@dfinity/candid": "^0.19.3",
|
|
38
|
+
"@dfinity/identity": "^0.19.3",
|
|
39
|
+
"@dfinity/identity-secp256k1": "^0.19.3",
|
|
40
|
+
"@dfinity/principal": "^0.19.3",
|
|
40
41
|
"@hadronous/pic": "0.2.0",
|
|
41
42
|
"@iarna/toml": "^2.2.5",
|
|
42
43
|
"@noble/hashes": "1.3.2",
|
|
@@ -45,13 +46,15 @@
|
|
|
45
46
|
"camelcase": "^7.0.1",
|
|
46
47
|
"chalk": "^5.3.0",
|
|
47
48
|
"chokidar": "^3.5.3",
|
|
48
|
-
"commander": "
|
|
49
|
+
"commander": "11.1.0",
|
|
49
50
|
"debounce": "^1.2.1",
|
|
51
|
+
"decomp-tarxz": "0.1.1",
|
|
50
52
|
"decompress": "^4.2.1",
|
|
51
53
|
"del": "^7.0.0",
|
|
52
54
|
"dhall-to-json-cli": "^1.7.6",
|
|
53
55
|
"eslint": "^8.45.0",
|
|
54
56
|
"execa": "7.1.1",
|
|
57
|
+
"fs-extra": "11.2.0",
|
|
55
58
|
"get-folder-size": "^4.0.0",
|
|
56
59
|
"glob": "^10.3.3",
|
|
57
60
|
"globby": "^13.2.2",
|
|
@@ -63,6 +66,7 @@
|
|
|
63
66
|
"minimatch": "^9.0.3",
|
|
64
67
|
"ncp": "^2.0.0",
|
|
65
68
|
"node-fetch": "^3.3.2",
|
|
69
|
+
"octokit": "3.1.2",
|
|
66
70
|
"pem-file": "^1.0.1",
|
|
67
71
|
"prompts": "^2.4.2",
|
|
68
72
|
"stream-to-promise": "^3.0.0",
|
|
@@ -73,6 +77,7 @@
|
|
|
73
77
|
"@tsconfig/strictest": "^2.0.1",
|
|
74
78
|
"@types/debounce": "^1.2.1",
|
|
75
79
|
"@types/decompress": "^4.2.4",
|
|
80
|
+
"@types/fs-extra": "11.0.4",
|
|
76
81
|
"@types/glob": "^8.1.0",
|
|
77
82
|
"@types/ncp": "^2.0.5",
|
|
78
83
|
"@types/node": "^20.4.4",
|
|
@@ -84,9 +89,9 @@
|
|
|
84
89
|
"typescript": "^5.1.6"
|
|
85
90
|
},
|
|
86
91
|
"overrides": {
|
|
87
|
-
"@dfinity/agent": "^0.
|
|
88
|
-
"@dfinity/identity": "^0.
|
|
89
|
-
"@dfinity/principal": "^0.
|
|
90
|
-
"@dfinity/candid": "^0.
|
|
92
|
+
"@dfinity/agent": "^0.19.3",
|
|
93
|
+
"@dfinity/identity": "^0.19.3",
|
|
94
|
+
"@dfinity/principal": "^0.19.3",
|
|
95
|
+
"@dfinity/candid": "^0.19.3"
|
|
91
96
|
}
|
|
92
97
|
}
|