ic-mops 0.36.1 → 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.
@@ -0,0 +1,54 @@
1
+ #!/bin/bash
2
+
3
+ # FILE_NAME=$(basename "$0");
4
+
5
+ # function findMopsTomlFile() {
6
+ # if [ -f "mops.toml" ]; then
7
+ # printf '%s\n' "${PWD%/}/mops.toml"
8
+ # elif [ "$PWD" = / ]; then
9
+ # false
10
+ # else
11
+ # # a subshell so that we don't affect the caller's $PWD
12
+ # (cd .. && findMopsTomlFile "mops.toml")
13
+ # fi
14
+ # }
15
+
16
+ # mopsTomlFile="$(findMopsTomlFile)"
17
+
18
+ # cat $mopsTomlFile
19
+
20
+ # mocPath=""
21
+ # if [ -z "$mopsTomlFile" ]
22
+ # then
23
+ # mocPath="$HOME/.cache/mocv/versions/$(cat $HOME/.cache/mocv/versions/current/version.txt)/$FILE_NAME"
24
+ # # mocPath="$(DFX_WARNING=-version_check dfx cache show)/$FILE_NAME"
25
+ # else
26
+ # mocPath="$HOME/.cache/mocv/versions/$(cat $mopsTomlFile)/$FILE_NAME"
27
+ # fi
28
+
29
+ # fallback to dfx
30
+ # mocPath="$(DFX_WARNING=-version_check dfx cache show)/moc"
31
+
32
+ # echo $mocPath
33
+
34
+ # # install moc version if not installed yet
35
+ # if [[ ! -f "$mocPath" && -f "$mopsTomlFile" ]]; then
36
+ # # mocv install --silent $(cat $mopsTomlFile)
37
+ # mocv use $(cat $mopsTomlFile)
38
+ # fi
39
+
40
+ # mocPath="/home/zen/.cache/mocv/versions/current/moc"
41
+
42
+ # mocPath=""
43
+ # if command -v mops &> /dev/null
44
+ # then
45
+ # mocPath="/home/zen/.cache/mops/moc/0.9.5/moc"
46
+ # else
47
+ # mocPath="$(DFX_WARNING=-version_check dfx cache show)/moc" # fallback to dfx
48
+ # fi
49
+
50
+ mocPath="$(mops toolchain bin moc)"
51
+ # mocPath="$(dfx cache show)/moc"
52
+ # mocPath="/home/zen/.cache/mops/moc/0.7.5/moc"
53
+
54
+ $mocPath "$@"
package/bin/mops.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ import '../cli.js';
package/cli.ts CHANGED
@@ -1,7 +1,5 @@
1
- #!/usr/bin/env node
2
-
3
1
  import fs from 'node:fs';
4
- import {program, Argument, Option} from 'commander';
2
+ import {Command, Argument, Option} from 'commander';
5
3
  import chalk from 'chalk';
6
4
 
7
5
  import {init} from './commands/init.js';
@@ -26,6 +24,7 @@ import {outdated} from './commands/outdated.js';
26
24
  import {update} from './commands/update.js';
27
25
  import {bench} from './commands/bench.js';
28
26
  import {transferOwnership} from './commands/transfer-ownership.js';
27
+ import {toolchain} from './commands/toolchain/index.js';
29
28
  // import {docs} from './commands/docs.js';
30
29
 
31
30
  declare global {
@@ -38,6 +37,7 @@ if (fs.existsSync(networkFile)) {
38
37
  globalThis.MOPS_NETWORK = fs.readFileSync(networkFile).toString() || 'ic';
39
38
  }
40
39
 
40
+ let program = new Command();
41
41
 
42
42
  program.name('mops');
43
43
 
@@ -58,7 +58,7 @@ program
58
58
  program
59
59
  .command('add <pkg>')
60
60
  .description('Install the package and save it to mops.toml')
61
- .option('--dev')
61
+ .option('--dev', 'Add to [dev-dependencies] section')
62
62
  .option('--verbose')
63
63
  .addOption(new Option('--lock <action>', 'Lockfile action').choices(['update', 'ignore']))
64
64
  .action(async (pkg, options) => {
@@ -328,4 +328,40 @@ program
328
328
  await transferOwnership(toPrincipal);
329
329
  });
330
330
 
331
+ // toolchain
332
+ const toolchainCommand = new Command('toolchain').description('Toolchain management');
333
+
334
+ toolchainCommand
335
+ .command('init')
336
+ .description('One-time initialization of toolchain management')
337
+ .action(async () => {
338
+ toolchain.init();
339
+ });
340
+
341
+ toolchainCommand
342
+ .command('reset')
343
+ .description('Uninstall toolchain management')
344
+ .action(async () => {
345
+ toolchain.init({reset: true});
346
+ });
347
+
348
+ toolchainCommand
349
+ .command('use')
350
+ .description('Install specified tool version and update mops.toml')
351
+ .addArgument(new Argument('<tool>').choices(['moc', 'wasmtime', 'pocket-ic']))
352
+ .addArgument(new Argument('<version>'))
353
+ .action(async (tool, version) => {
354
+ toolchain.use(tool, version);
355
+ });
356
+
357
+ toolchainCommand
358
+ .command('bin')
359
+ .description('Get path to the tool binary\n<tool> can be one of "moc", "wasmtime", "pocket-ic"')
360
+ .addArgument(new Argument('<tool>').choices(['moc', 'wasmtime', 'pocket-ic']))
361
+ .action(async (tool) => {
362
+ toolchain.bin(tool);
363
+ });
364
+
365
+ program.addCommand(toolchainCommand);
366
+
331
367
  program.parse();
@@ -0,0 +1,153 @@
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 {Tool} from '../../types.js';
8
+ import chalk from 'chalk';
9
+
10
+
11
+ // update shell config files to set DFX_MOC_PATH to moc-wrapper
12
+ async function init({reset = false} = {}) {
13
+ if (process.platform == 'win32') {
14
+ console.error('Windows is not supported. Please use WSL');
15
+ process.exit(1);
16
+ }
17
+
18
+ try {
19
+ let res = execSync('which mocv').toString().trim();
20
+ if (res) {
21
+ console.error('Mops is not compatible with mocv. Please uninstall mocv and try again.');
22
+ console.log('Steps to uninstall mocv:');
23
+ console.log('1. Run "mocv reset"');
24
+ console.log('2. Run "npm uninstall -g mocv"');
25
+ process.exit(1);
26
+ }
27
+ }
28
+ catch {}
29
+
30
+ let zshrc = path.join(os.homedir(), '.zshrc');
31
+ let bashrc = path.join(os.homedir(), '.bashrc');
32
+
33
+ let shellConfigFiles = [bashrc, zshrc].filter((file) => {
34
+ return fs.existsSync(file);
35
+ });
36
+
37
+ if (shellConfigFiles.length === 0) {
38
+ console.error('Shell config files not found: ".bashrc" or ".zshrc"');
39
+ process.exit(1);
40
+ }
41
+
42
+ // update all existing shell config files
43
+ for (let configFile of shellConfigFiles) {
44
+ let text = fs.readFileSync(configFile).toString();
45
+ let setDfxLine = '\nexport DFX_MOC_PATH="moc-wrapper"';
46
+
47
+ let newLines = [
48
+ setDfxLine,
49
+ ];
50
+
51
+ let oldLines = [
52
+ // legacy mocv lines
53
+ `\nexport DFX_MOC_PATH=${path.join(path.join(os.homedir(), '.cache/mocv'), 'versions/current')}/moc`,
54
+ '\nexport DFX_MOC_PATH="$HOME/.cache/mocv/versions/current/moc"',
55
+ // new
56
+ setDfxLine,
57
+ ];
58
+
59
+ // remove old lines
60
+ for (let oldLine of oldLines) {
61
+ text = text.replace(oldLine, '');
62
+ }
63
+
64
+ if (text.endsWith('\n\n')) {
65
+ text = text.trimEnd() + '\n';
66
+ }
67
+
68
+ // insert new lines
69
+ if (!reset) {
70
+ if (!text.endsWith('\n')) {
71
+ text += '\n';
72
+ }
73
+ for (let newLine of newLines) {
74
+ text += newLine;
75
+ }
76
+ text += '\n';
77
+ }
78
+
79
+ fs.writeFileSync(configFile, text);
80
+ }
81
+
82
+ console.log(chalk.green('Success!'));
83
+ }
84
+
85
+ async function download(tool: Tool, version: string) {
86
+ if (tool === 'moc') {
87
+ await moc.download(version);
88
+ }
89
+ }
90
+
91
+ // async function downloadAll() {
92
+ // let config = readConfig();
93
+ // if (config.toolchain?.moc) {
94
+ // await download('moc', config.toolchain.moc);
95
+ // }
96
+ // if (config.toolchain?.wasmtime) {
97
+ // await download('wasmtime', config.toolchain.wasmtime);
98
+ // }
99
+ // if (config.toolchain?.['pocket-ic']) {
100
+ // await download('pocket-ic', config.toolchain['pocket-ic']);
101
+ // }
102
+ // }
103
+
104
+ // download binary and set version in mops.toml
105
+ async function use(tool: Tool, version: string) {
106
+ await download(tool, version);
107
+
108
+ let config = readConfig();
109
+ config.toolchain = config.toolchain || {};
110
+ config.toolchain[tool] = version;
111
+ writeConfig(config);
112
+ }
113
+
114
+ // return current version from mops.toml
115
+ async function bin(tool: Tool) {
116
+ let hasConfig = getClosestConfigFile();
117
+
118
+ // fallback to dfx moc
119
+ if (!hasConfig) {
120
+ console.log(execSync('dfx cache show').toString().trim() + '/moc');
121
+ return;
122
+ }
123
+
124
+ let config = readConfig();
125
+ let version = config.toolchain?.[tool];
126
+
127
+ if (!version) {
128
+ // fallback to dfx moc
129
+ if (tool === 'moc') {
130
+ console.log(execSync('dfx cache show').toString().trim() + '/moc');
131
+ return;
132
+ }
133
+ console.error(`Toolchain '${tool}' is not defined in mops.toml`);
134
+ process.exit(1);
135
+ }
136
+
137
+ if (version) {
138
+ await download(tool, version);
139
+
140
+ if (tool === 'moc') {
141
+ console.log(path.join(globalCacheDir, 'moc', version, 'moc'));
142
+ }
143
+ else {
144
+ console.log(path.join(globalCacheDir, tool, version, 'moc'));
145
+ }
146
+ }
147
+ }
148
+
149
+ export let toolchain = {
150
+ init,
151
+ use,
152
+ bin,
153
+ };
@@ -0,0 +1,43 @@
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, 'moc');
8
+
9
+ export let isCached = (version: string) => {
10
+ let dir = path.join(cacheDir, version);
11
+ return fs.existsSync(dir) && fs.existsSync(path.join(dir, 'moc'));
12
+ };
13
+
14
+ export let download = async (version: string, {silent = false} = {}) => {
15
+ if (process.platform == 'win32') {
16
+ console.error('Windows is not supported. Please use WSL');
17
+ process.exit(1);
18
+ }
19
+ if (!version) {
20
+ console.error('version is not defined');
21
+ process.exit(1);
22
+ }
23
+ if (isCached(version)) {
24
+ return;
25
+ }
26
+
27
+ let url;
28
+ if (parseInt(version.replaceAll('.', '')) >= parseInt('0.9.5'.replaceAll('.', ''))) {
29
+ let platfrom = process.platform == 'darwin' ? 'Darwin' : 'Linux';
30
+ let arch = process.arch.startsWith('arm') ? 'arm64' : 'x86_64';
31
+ // currently only x64 binaries are available
32
+ arch = 'x86_64';
33
+ url = `https://github.com/dfinity/motoko/releases/download/${version}/motoko-${platfrom}-${arch}-${version}.tar.gz`;
34
+ }
35
+ else {
36
+ let platfrom = process.platform == 'darwin' ? 'macos' : 'linux64';
37
+ url = `https://github.com/dfinity/motoko/releases/download/${version}/motoko-${platfrom}-${version}.tar.gz`;
38
+ }
39
+
40
+ silent || console.log(`Downloading ${url}`);
41
+
42
+ await downloadAndExtract(url, path.join(cacheDir, version));
43
+ };
@@ -0,0 +1,313 @@
1
+ // @ts-nocheck
2
+ import fs from 'fs-extra';
3
+ import os from 'os';
4
+ import path from 'path';
5
+ import tar from 'tar';
6
+ import {program} from 'commander';
7
+ import prompts from 'prompts';
8
+ import {Octokit} from 'octokit';
9
+ import chalk from 'chalk';
10
+ import fetch from 'node-fetch';
11
+
12
+ if (process.platform == 'win32') {
13
+ console.log('Windows is not supported. Please use WSL');
14
+ process.exit(1);
15
+ }
16
+
17
+ let zshrc = path.join(os.homedir(), '.zshrc');
18
+ let bashrc = path.join(os.homedir(), '.bashrc');
19
+ let cacheDir = path.join(os.homedir(), '.cache/mocv');
20
+ let curVersionFile = path.join(cacheDir, 'versions/current/version.txt');
21
+ let tmpDir = path.join(cacheDir, '.tmp');
22
+ let file = path.join(tmpDir, 'moc.tar.gz');
23
+
24
+ let download = async (version: string, {silent = false} = {}) => {
25
+ if (!version) {
26
+ console.log('version is not defined');
27
+ process.exit(1);
28
+ }
29
+ if (isCached(version)) {
30
+ return;
31
+ }
32
+
33
+
34
+ let url;
35
+ if (parseInt(version.replaceAll('.', '')) >= parseInt('0.9.5'.replaceAll('.', ''))) {
36
+ let platfrom = process.platform == 'darwin' ? 'Darwin' : 'Linux';
37
+ let arch = process.arch.startsWith('arm') ? 'arm64' : 'x86_64';
38
+ // currently only x64 binaries are available
39
+ arch = 'x86_64';
40
+ url = `https://github.com/dfinity/motoko/releases/download/${version}/motoko-${platfrom}-${arch}-${version}.tar.gz`;
41
+ }
42
+ else {
43
+ let platfrom = process.platform == 'darwin' ? 'macos' : 'linux64';
44
+ url = `https://github.com/dfinity/motoko/releases/download/${version}/motoko-${platfrom}-${version}.tar.gz`;
45
+ }
46
+
47
+ silent || console.log(`Downloading ${url}`);
48
+
49
+ let res = await fetch(url);
50
+
51
+ if (res.status !== 200) {
52
+ console.log(`ERR ${res.status} ${url}`);
53
+ console.log(`moc version '${version}' not found`);
54
+ process.exit(1);
55
+ }
56
+
57
+ let arrayBuffer = await res.arrayBuffer();
58
+ let buffer = Buffer.from(arrayBuffer);
59
+
60
+ fs.mkdirSync(tmpDir, {recursive: true});
61
+ fs.writeFileSync(file, buffer);
62
+
63
+ let verDir = path.join(cacheDir, 'versions', version);
64
+ fs.mkdirSync(verDir, {recursive: true});
65
+ await tar.extract({
66
+ file,
67
+ cwd: verDir,
68
+ });
69
+
70
+ fs.rmSync(file);
71
+ };
72
+
73
+ let isCached = (version: string) => {
74
+ let dir = path.join(cacheDir, 'versions', version);
75
+ return fs.existsSync(path.join(dir, 'moc'))
76
+ && fs.existsSync(path.join(dir, 'mo-doc'))
77
+ && fs.existsSync(path.join(dir, 'mo-ide'));
78
+ };
79
+
80
+ let setCurrent = (version: string) => {
81
+ fs.copySync(path.join(cacheDir, 'versions', version), path.join(cacheDir, 'versions/current'), {recursive: true});
82
+ fs.writeFileSync(curVersionFile, version);
83
+ };
84
+
85
+ let getCurrent = () => {
86
+ if (fs.existsSync(curVersionFile)) {
87
+ return fs.readFileSync(curVersionFile).toString();
88
+ }
89
+ };
90
+
91
+ let getLatest = async () => {
92
+ let releases = await getReleases();
93
+ return releases[0].tag_name;
94
+ };
95
+
96
+ let getReleases = async () => {
97
+ let octokit = new Octokit;
98
+ let res = await octokit.request('GET /repos/dfinity/motoko/releases', {
99
+ per_page: 10,
100
+ headers: {
101
+ 'X-GitHub-Api-Version': '2022-11-28'
102
+ }
103
+ });
104
+ if (res.status !== 200) {
105
+ console.log('Releases fetch error');
106
+ process.exit(1);
107
+ }
108
+ return res.data;
109
+ };
110
+
111
+ let use = async (version: string) => {
112
+ if (version === 'latest') {
113
+ version = await getLatest();
114
+ }
115
+ await download(version);
116
+ setCurrent(version);
117
+ console.log(`Selected moc ${version}`);
118
+
119
+ // update github env
120
+ if (process.env.GITHUB_ENV) {
121
+ fs.appendFileSync(process.env.GITHUB_ENV, `DFX_MOC_PATH=${path.join(cacheDir, 'versions', version)}/moc\n`);
122
+ }
123
+ };
124
+
125
+ program.name('mocv')
126
+ .action(async (_, config) => {
127
+ if (config.args.length) {
128
+ console.log(`unknown command '${config.args.join(' ')}'`);
129
+ process.exit(1);
130
+ }
131
+ let releases = await getReleases();
132
+ let versions = releases.map((item: {tag_name: any;}) => item.tag_name);
133
+ let current = getCurrent();
134
+ let currentIndex = versions.indexOf(current);
135
+
136
+ let res = await prompts({
137
+ type: 'select',
138
+ name: 'version',
139
+ message: 'Select moc version',
140
+ choices: releases.map((release: {published_at: string | number | Date; tag_name: string;}, i: any) => {
141
+ let date = new Date(release.published_at).toLocaleDateString(undefined, {year: 'numeric', month: 'short', day: 'numeric'});
142
+ return {
143
+ title: release.tag_name + chalk.gray(` ${date}${currentIndex === i ? chalk.italic(' (current)') : ''}`),
144
+ value: release.tag_name,
145
+ };
146
+ }),
147
+ initial: currentIndex == -1 ? 0 : currentIndex,
148
+ });
149
+
150
+ if (!res.version) {
151
+ return;
152
+ }
153
+
154
+ await use(res.version);
155
+ });
156
+
157
+ let updateShellConfig = async ({reset = false, yes = false} = {}) => {
158
+ let setDfxMocPath = reset || yes;
159
+ let updatePath = reset || yes;
160
+
161
+ if (!setDfxMocPath) {
162
+ let res = await prompts({
163
+ type: 'select',
164
+ name: 'setDfxMocPath',
165
+ message: 'Do you want to set DFX_MOC_PATH, so `dfx` will use the current `moc` version?',
166
+ choices: [
167
+ {
168
+ title: 'Yes',
169
+ value: true,
170
+ },
171
+ {
172
+ title: 'No',
173
+ value: false,
174
+ },
175
+ ],
176
+ });
177
+ setDfxMocPath = res.setDfxMocPath;
178
+ }
179
+
180
+ if (!updatePath) {
181
+ let res = await prompts({
182
+ type: 'select',
183
+ name: 'updatePath',
184
+ message: 'Do you want to update PATH, so you can call `moc`, `mo-doc` and `mo-ide` from the terminal?',
185
+ choices: [
186
+ {
187
+ title: 'Yes',
188
+ value: true,
189
+ },
190
+ {
191
+ title: 'No',
192
+ value: false,
193
+ },
194
+ ],
195
+ });
196
+ updatePath = res.updatePath;
197
+ }
198
+
199
+ if (!setDfxMocPath && !updatePath) {
200
+ console.log('Nothing to do');
201
+ return;
202
+ }
203
+
204
+ let configFiles = [];
205
+ if (reset || yes) {
206
+ configFiles = [bashrc, zshrc];
207
+ }
208
+ else {
209
+ let {configFile} = await prompts({
210
+ type: 'select',
211
+ name: 'configFile',
212
+ message: 'Select your shell config file',
213
+ choices: [
214
+ {
215
+ title: bashrc,
216
+ value: bashrc,
217
+ },
218
+ {
219
+ title: zshrc,
220
+ value: zshrc,
221
+ },
222
+ ],
223
+ });
224
+ configFiles = [configFile];
225
+ }
226
+
227
+ for (let configFile of configFiles) {
228
+ if (!fs.existsSync(configFile)) {
229
+ console.log(`${configFile} not found`);
230
+ process.exit(1);
231
+ }
232
+
233
+ let data = fs.readFileSync(configFile).toString();
234
+ let setDfxLine = '\nexport DFX_MOC_PATH="$HOME/.cache/mocv/versions/current/moc"';
235
+ let updatePathLine = '\nPATH="$HOME/.cache/mocv/versions/current:$PATH"';
236
+
237
+ let newLines = [];
238
+ setDfxMocPath && newLines.push(setDfxLine);
239
+ updatePath && newLines.push(updatePathLine);
240
+
241
+ let oldLines = [
242
+ `\nexport DFX_MOC_PATH=${path.join(cacheDir, 'versions/current')}/moc\n`,
243
+ setDfxLine,
244
+ updatePathLine,
245
+ ];
246
+ for (let oldLine of oldLines) {
247
+ data = data.replace(oldLine, '');
248
+ }
249
+
250
+ if (data.endsWith('\n\n')) {
251
+ data = data.trimEnd() + '\n';
252
+ }
253
+
254
+ if (!reset) {
255
+ if (!data.endsWith('\n')) {
256
+ data += '\n';
257
+ }
258
+ for (let newLine of newLines) {
259
+ data += newLine;
260
+ }
261
+ data += '\n';
262
+ }
263
+
264
+ fs.writeFileSync(configFile, data);
265
+ };
266
+
267
+ console.log('Success!');
268
+ // console.log(`Run "source ${configFile}" to apply changes`);
269
+ console.log('Restart terminal to apply changes');
270
+ };
271
+
272
+ program.command('init')
273
+ .description('mocv one time initialization')
274
+ .option('-y, --yes', 'Skip prompts')
275
+ .action(async (options) => {
276
+ updateShellConfig(options);
277
+ });
278
+
279
+ program.command('reset')
280
+ .description('Reset changes made by `mocv init`')
281
+ .action(async () => {
282
+ updateShellConfig({reset: true});
283
+ });
284
+
285
+ program.command('use <version>')
286
+ .description('Set current moc version.\nExample 1: "mocv use 0.8.4"\nExample 2: "mocv use latest"')
287
+ .action(async (version) => {
288
+ await use(version);
289
+ });
290
+
291
+ program.command('current')
292
+ .description('Print current moc version')
293
+ .action(async () => {
294
+ console.log(getCurrent());
295
+ });
296
+
297
+ program.command('bin [version]')
298
+ .description('Print bin directory')
299
+ .action(async (version = getCurrent()) => {
300
+ if (version === 'latest') {
301
+ version = await getLatest();
302
+ }
303
+ if (!version) {
304
+ console.log('No version selected. Please pass a version arg or run `mocv` or `mocv use <version>`');
305
+ process.exit(1);
306
+ }
307
+ if (!isCached(version)) {
308
+ await download(version, {silent: true});
309
+ }
310
+ console.log(path.join(cacheDir, 'versions', version));
311
+ });
312
+
313
+ program.parse();
@@ -0,0 +1,37 @@
1
+ import path from 'node:path';
2
+ import fs from 'node:fs';
3
+
4
+ import {globalCacheDir} from '../../mops.js';
5
+ import {downloadAndExtract} from './toolchain-utils.js';
6
+
7
+ let cacheDir = path.join(globalCacheDir, 'pocket-ic');
8
+
9
+ export let isCached = (version: string) => {
10
+ let dir = path.join(cacheDir, version);
11
+ return fs.existsSync(dir) && fs.existsSync(path.join(dir, 'pocket-ic'));
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' ? 'darwin' : 'linux';
24
+ let arch = 'x86_64';
25
+
26
+ let hashes: Record<string, string> = {
27
+ '2.0.1': '69e1408347723dbaa7a6cd2faa9b65c42abbe861',
28
+ '2.0.0': '29ec86dc9f9ca4691d4d4386c8b2aa41e14d9d16',
29
+ '1.0.0': '307d5847c1d2fe1f5e19181c7d0fcec23f4658b3',
30
+ };
31
+
32
+ let url = `https://download.dfinity.systems/ic/${hashes[version]}/openssl-static-binaries/${arch}-${platfrom}/pocket-ic.gz`;
33
+
34
+ silent || console.log(`Downloading ${url}`);
35
+
36
+ await downloadAndExtract(url, path.join(cacheDir, version));
37
+ };
@@ -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
+ };
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- export {};
2
+ import '../cli.js';
package/dist/cli.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env node
2
1
  declare global {
3
2
  var MOPS_NETWORK: string;
4
3
  }
package/dist/cli.js CHANGED
@@ -1,6 +1,5 @@
1
- #!/usr/bin/env node
2
1
  import fs from 'node:fs';
3
- import { program, Argument, Option } from 'commander';
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 { downloadGithubRelease } from './toolchain-utils.js';
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.log('Windows is not supported. Please use WSL');
12
+ console.error('Windows is not supported. Please use WSL');
13
13
  process.exit(1);
14
14
  }
15
15
  if (!version) {
16
- console.log('version is not defined');
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 downloadGithubRelease(url, path.join(cacheDir, version));
35
+ await downloadAndExtract(url, path.join(cacheDir, version));
36
36
  };
@@ -0,0 +1,4 @@
1
+ export declare let isCached: (version: string) => boolean;
2
+ export declare let download: (version: string, { silent }?: {
3
+ silent?: boolean | undefined;
4
+ }) => Promise<void>;
@@ -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 downloadGithubRelease: (url: string, dest: string) => Promise<void>;
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 downloadGithubRelease = async (url, dest) => {
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 { downloadGithubRelease } from './toolchain-utils.js';
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 downloadGithubRelease(url, path.join(cacheDir, version));
22
+ await downloadAndExtract(url, path.join(cacheDir, version));
23
23
  };
package/dist/mops.js CHANGED
@@ -93,7 +93,7 @@ export let getIdentity = async () => {
93
93
  };
94
94
  export function getClosestConfigFile(dir = process.cwd()) {
95
95
  if (!path.basename(dir)) {
96
- throw '';
96
+ return '';
97
97
  }
98
98
  let configFile = path.join(dir, 'mops.toml');
99
99
  if (fs.existsSync(configFile)) {
package/dist/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "ic-mops",
3
- "version": "0.36.1",
3
+ "version": "0.37.0-pre.0",
4
4
  "type": "module",
5
5
  "bin": {
6
- "mops": "dist/cli.js"
6
+ "mops": "dist/bin/mops.js",
7
+ "moc-wrapper": "bin/moc-wrapper.sh"
7
8
  },
8
9
  "files": [
9
10
  "*",
@@ -45,13 +46,15 @@
45
46
  "camelcase": "^7.0.1",
46
47
  "chalk": "^5.3.0",
47
48
  "chokidar": "^3.5.3",
48
- "commander": "^11.0.0",
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",
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
@@ -1,2 +1,3 @@
1
1
  declare module 'pem-file';
2
- declare module 'get-folder-size';
2
+ declare module 'get-folder-size';
3
+ declare module 'decomp-tarxz';
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
- throw '';
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.36.1",
3
+ "version": "0.37.0-pre.0",
4
4
  "type": "module",
5
5
  "bin": {
6
- "mops": "dist/cli.js"
6
+ "mops": "dist/bin/mops.js",
7
+ "moc-wrapper": "bin/moc-wrapper.sh"
7
8
  },
8
9
  "files": [
9
10
  "*",
@@ -45,13 +46,15 @@
45
46
  "camelcase": "^7.0.1",
46
47
  "chalk": "^5.3.0",
47
48
  "chokidar": "^3.5.3",
48
- "commander": "^11.0.0",
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",
package/types.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
 
22
23
  export type Dependencies = Record<string, Dependency>;
@@ -26,4 +27,12 @@ export type Dependency = {
26
27
  version?: string; // mops package
27
28
  repo?: string; // github package
28
29
  path?: string; // local package
29
- }
30
+ }
31
+
32
+ export type Toolchain = {
33
+ moc?: string;
34
+ wasmtime?: string;
35
+ 'pocket-ic'?: string;
36
+ };
37
+
38
+ export type Tool = 'moc' | 'wasmtime' | 'pocket-ic';
package/cli-local.ts DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env bun
2
-
3
- import './cli.js';