ic-mops 0.37.1 → 0.37.2

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.
Files changed (65) hide show
  1. package/dist/bin/mops.js +0 -0
  2. package/dist/package.json +1 -1
  3. package/package.json +1 -1
  4. package/dist/cli-local.d.ts +0 -2
  5. package/dist/cli-local.js +0 -2
  6. package/dist/commands/toolchain/mocv.d.ts +0 -1
  7. package/dist/commands/toolchain/mocv.js +0 -271
  8. package/dist/moc-wrapper.d.ts +0 -2
  9. package/dist/moc-wrapper.js +0 -8
  10. package/dist/out/cli.d.ts +0 -2
  11. package/dist/out/cli.js +0 -115242
  12. package/dist/pic-js/examples/clock/tests/clock/index.d.ts +0 -1
  13. package/dist/pic-js/examples/clock/tests/clock/index.js +0 -5
  14. package/dist/pic-js/examples/clock/tests/jest.config.d.ts +0 -3
  15. package/dist/pic-js/examples/clock/tests/jest.config.js +0 -8
  16. package/dist/pic-js/examples/clock/tests/src/clock.spec.d.ts +0 -1
  17. package/dist/pic-js/examples/clock/tests/src/clock.spec.js +0 -48
  18. package/dist/pic-js/examples/counter/tests/counter/index.d.ts +0 -1
  19. package/dist/pic-js/examples/counter/tests/counter/index.js +0 -5
  20. package/dist/pic-js/examples/counter/tests/jest.config.d.ts +0 -3
  21. package/dist/pic-js/examples/counter/tests/jest.config.js +0 -8
  22. package/dist/pic-js/examples/counter/tests/src/counter.spec.d.ts +0 -1
  23. package/dist/pic-js/examples/counter/tests/src/counter.spec.js +0 -80
  24. package/dist/pic-js/examples/todo/tests/jest.config.d.ts +0 -3
  25. package/dist/pic-js/examples/todo/tests/jest.config.js +0 -8
  26. package/dist/pic-js/examples/todo/tests/src/todo.spec.d.ts +0 -1
  27. package/dist/pic-js/examples/todo/tests/src/todo.spec.js +0 -211
  28. package/dist/pic-js/examples/todo/tests/todo/index.d.ts +0 -1
  29. package/dist/pic-js/examples/todo/tests/todo/index.js +0 -5
  30. package/dist/pic-js/packages/pic/src/error.d.ts +0 -12
  31. package/dist/pic-js/packages/pic/src/error.js +0 -36
  32. package/dist/pic-js/packages/pic/src/http-client.d.ts +0 -15
  33. package/dist/pic-js/packages/pic/src/http-client.js +0 -37
  34. package/dist/pic-js/packages/pic/src/identity.d.ts +0 -66
  35. package/dist/pic-js/packages/pic/src/identity.js +0 -86
  36. package/dist/pic-js/packages/pic/src/index.d.ts +0 -4
  37. package/dist/pic-js/packages/pic/src/index.js +0 -8
  38. package/dist/pic-js/packages/pic/src/management-canister.d.ts +0 -30
  39. package/dist/pic-js/packages/pic/src/management-canister.js +0 -43
  40. package/dist/pic-js/packages/pic/src/pocket-ic-actor.d.ts +0 -83
  41. package/dist/pic-js/packages/pic/src/pocket-ic-actor.js +0 -58
  42. package/dist/pic-js/packages/pic/src/pocket-ic-client-types.d.ts +0 -61
  43. package/dist/pic-js/packages/pic/src/pocket-ic-client-types.js +0 -2
  44. package/dist/pic-js/packages/pic/src/pocket-ic-client.d.ts +0 -24
  45. package/dist/pic-js/packages/pic/src/pocket-ic-client.js +0 -123
  46. package/dist/pic-js/packages/pic/src/pocket-ic-server.d.ts +0 -10
  47. package/dist/pic-js/packages/pic/src/pocket-ic-server.js +0 -55
  48. package/dist/pic-js/packages/pic/src/pocket-ic-types.d.ts +0 -40
  49. package/dist/pic-js/packages/pic/src/pocket-ic-types.js +0 -2
  50. package/dist/pic-js/packages/pic/src/pocket-ic.d.ts +0 -447
  51. package/dist/pic-js/packages/pic/src/pocket-ic.js +0 -551
  52. package/dist/pic-js/packages/pic/src/util/candid.d.ts +0 -1
  53. package/dist/pic-js/packages/pic/src/util/candid.js +0 -7
  54. package/dist/pic-js/packages/pic/src/util/encoding.d.ts +0 -5
  55. package/dist/pic-js/packages/pic/src/util/encoding.js +0 -19
  56. package/dist/pic-js/packages/pic/src/util/fs.d.ts +0 -4
  57. package/dist/pic-js/packages/pic/src/util/fs.js +0 -29
  58. package/dist/pic-js/packages/pic/src/util/index.d.ts +0 -5
  59. package/dist/pic-js/packages/pic/src/util/index.js +0 -21
  60. package/dist/pic-js/packages/pic/src/util/os.d.ts +0 -4
  61. package/dist/pic-js/packages/pic/src/util/os.js +0 -19
  62. package/dist/pic-js/packages/pic/src/util/poll.d.ts +0 -5
  63. package/dist/pic-js/packages/pic/src/util/poll.js +0 -28
  64. package/dist/templates/cli.d.ts +0 -2
  65. package/dist/templates/cli.js +0 -3660
package/dist/bin/mops.js CHANGED
File without changes
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ic-mops",
3
- "version": "0.37.1",
3
+ "version": "0.37.2",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mops": "dist/bin/mops.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ic-mops",
3
- "version": "0.37.1",
3
+ "version": "0.37.2",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mops": "dist/bin/mops.js",
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env bun
2
- import './cli.js';
package/dist/cli-local.js DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env bun
2
- import './cli.js';
@@ -1 +0,0 @@
1
- export {};
@@ -1,271 +0,0 @@
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
- if (process.platform == 'win32') {
12
- console.log('Windows is not supported. Please use WSL');
13
- process.exit(1);
14
- }
15
- let zshrc = path.join(os.homedir(), '.zshrc');
16
- let bashrc = path.join(os.homedir(), '.bashrc');
17
- let cacheDir = path.join(os.homedir(), '.cache/mocv');
18
- let curVersionFile = path.join(cacheDir, 'versions/current/version.txt');
19
- let tmpDir = path.join(cacheDir, '.tmp');
20
- let file = path.join(tmpDir, 'moc.tar.gz');
21
- let download = async (version, { silent = false } = {}) => {
22
- if (!version) {
23
- console.log('version is not defined');
24
- process.exit(1);
25
- }
26
- if (isCached(version)) {
27
- return;
28
- }
29
- let url;
30
- if (parseInt(version.replaceAll('.', '')) >= parseInt('0.9.5'.replaceAll('.', ''))) {
31
- let platfrom = process.platform == 'darwin' ? 'Darwin' : 'Linux';
32
- let arch = process.arch.startsWith('arm') ? 'arm64' : 'x86_64';
33
- // currently only x64 binaries are available
34
- arch = 'x86_64';
35
- url = `https://github.com/dfinity/motoko/releases/download/${version}/motoko-${platfrom}-${arch}-${version}.tar.gz`;
36
- }
37
- else {
38
- let platfrom = process.platform == 'darwin' ? 'macos' : 'linux64';
39
- url = `https://github.com/dfinity/motoko/releases/download/${version}/motoko-${platfrom}-${version}.tar.gz`;
40
- }
41
- silent || console.log(`Downloading ${url}`);
42
- let res = await fetch(url);
43
- if (res.status !== 200) {
44
- console.log(`ERR ${res.status} ${url}`);
45
- console.log(`moc version '${version}' not found`);
46
- process.exit(1);
47
- }
48
- let arrayBuffer = await res.arrayBuffer();
49
- let buffer = Buffer.from(arrayBuffer);
50
- fs.mkdirSync(tmpDir, { recursive: true });
51
- fs.writeFileSync(file, buffer);
52
- let verDir = path.join(cacheDir, 'versions', version);
53
- fs.mkdirSync(verDir, { recursive: true });
54
- await tar.extract({
55
- file,
56
- cwd: verDir,
57
- });
58
- fs.rmSync(file);
59
- };
60
- let isCached = (version) => {
61
- let dir = path.join(cacheDir, 'versions', version);
62
- return fs.existsSync(path.join(dir, 'moc'))
63
- && fs.existsSync(path.join(dir, 'mo-doc'))
64
- && fs.existsSync(path.join(dir, 'mo-ide'));
65
- };
66
- let setCurrent = (version) => {
67
- fs.copySync(path.join(cacheDir, 'versions', version), path.join(cacheDir, 'versions/current'), { recursive: true });
68
- fs.writeFileSync(curVersionFile, version);
69
- };
70
- let getCurrent = () => {
71
- if (fs.existsSync(curVersionFile)) {
72
- return fs.readFileSync(curVersionFile).toString();
73
- }
74
- };
75
- let getLatest = async () => {
76
- let releases = await getReleases();
77
- return releases[0].tag_name;
78
- };
79
- let getReleases = async () => {
80
- let octokit = new Octokit;
81
- let res = await octokit.request('GET /repos/dfinity/motoko/releases', {
82
- per_page: 10,
83
- headers: {
84
- 'X-GitHub-Api-Version': '2022-11-28'
85
- }
86
- });
87
- if (res.status !== 200) {
88
- console.log('Releases fetch error');
89
- process.exit(1);
90
- }
91
- return res.data;
92
- };
93
- let use = async (version) => {
94
- if (version === 'latest') {
95
- version = await getLatest();
96
- }
97
- await download(version);
98
- setCurrent(version);
99
- console.log(`Selected moc ${version}`);
100
- // update github env
101
- if (process.env.GITHUB_ENV) {
102
- fs.appendFileSync(process.env.GITHUB_ENV, `DFX_MOC_PATH=${path.join(cacheDir, 'versions', version)}/moc\n`);
103
- }
104
- };
105
- program.name('mocv')
106
- .action(async (_, config) => {
107
- if (config.args.length) {
108
- console.log(`unknown command '${config.args.join(' ')}'`);
109
- process.exit(1);
110
- }
111
- let releases = await getReleases();
112
- let versions = releases.map((item) => item.tag_name);
113
- let current = getCurrent();
114
- let currentIndex = versions.indexOf(current);
115
- let res = await prompts({
116
- type: 'select',
117
- name: 'version',
118
- message: 'Select moc version',
119
- choices: releases.map((release, i) => {
120
- let date = new Date(release.published_at).toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' });
121
- return {
122
- title: release.tag_name + chalk.gray(` ${date}${currentIndex === i ? chalk.italic(' (current)') : ''}`),
123
- value: release.tag_name,
124
- };
125
- }),
126
- initial: currentIndex == -1 ? 0 : currentIndex,
127
- });
128
- if (!res.version) {
129
- return;
130
- }
131
- await use(res.version);
132
- });
133
- let updateShellConfig = async ({ reset = false, yes = false } = {}) => {
134
- let setDfxMocPath = reset || yes;
135
- let updatePath = reset || yes;
136
- if (!setDfxMocPath) {
137
- let res = await prompts({
138
- type: 'select',
139
- name: 'setDfxMocPath',
140
- message: 'Do you want to set DFX_MOC_PATH, so `dfx` will use the current `moc` version?',
141
- choices: [
142
- {
143
- title: 'Yes',
144
- value: true,
145
- },
146
- {
147
- title: 'No',
148
- value: false,
149
- },
150
- ],
151
- });
152
- setDfxMocPath = res.setDfxMocPath;
153
- }
154
- if (!updatePath) {
155
- let res = await prompts({
156
- type: 'select',
157
- name: 'updatePath',
158
- message: 'Do you want to update PATH, so you can call `moc`, `mo-doc` and `mo-ide` from the terminal?',
159
- choices: [
160
- {
161
- title: 'Yes',
162
- value: true,
163
- },
164
- {
165
- title: 'No',
166
- value: false,
167
- },
168
- ],
169
- });
170
- updatePath = res.updatePath;
171
- }
172
- if (!setDfxMocPath && !updatePath) {
173
- console.log('Nothing to do');
174
- return;
175
- }
176
- let configFiles = [];
177
- if (reset || yes) {
178
- configFiles = [bashrc, zshrc];
179
- }
180
- else {
181
- let { configFile } = await prompts({
182
- type: 'select',
183
- name: 'configFile',
184
- message: 'Select your shell config file',
185
- choices: [
186
- {
187
- title: bashrc,
188
- value: bashrc,
189
- },
190
- {
191
- title: zshrc,
192
- value: zshrc,
193
- },
194
- ],
195
- });
196
- configFiles = [configFile];
197
- }
198
- for (let configFile of configFiles) {
199
- if (!fs.existsSync(configFile)) {
200
- console.log(`${configFile} not found`);
201
- process.exit(1);
202
- }
203
- let data = fs.readFileSync(configFile).toString();
204
- let setDfxLine = '\nexport DFX_MOC_PATH="$HOME/.cache/mocv/versions/current/moc"';
205
- let updatePathLine = '\nPATH="$HOME/.cache/mocv/versions/current:$PATH"';
206
- let newLines = [];
207
- setDfxMocPath && newLines.push(setDfxLine);
208
- updatePath && newLines.push(updatePathLine);
209
- let oldLines = [
210
- `\nexport DFX_MOC_PATH=${path.join(cacheDir, 'versions/current')}/moc\n`,
211
- setDfxLine,
212
- updatePathLine,
213
- ];
214
- for (let oldLine of oldLines) {
215
- data = data.replace(oldLine, '');
216
- }
217
- if (data.endsWith('\n\n')) {
218
- data = data.trimEnd() + '\n';
219
- }
220
- if (!reset) {
221
- if (!data.endsWith('\n')) {
222
- data += '\n';
223
- }
224
- for (let newLine of newLines) {
225
- data += newLine;
226
- }
227
- data += '\n';
228
- }
229
- fs.writeFileSync(configFile, data);
230
- }
231
- console.log('Success!');
232
- // console.log(`Run "source ${configFile}" to apply changes`);
233
- console.log('Restart terminal to apply changes');
234
- };
235
- program.command('init')
236
- .description('mocv one time initialization')
237
- .option('-y, --yes', 'Skip prompts')
238
- .action(async (options) => {
239
- updateShellConfig(options);
240
- });
241
- program.command('reset')
242
- .description('Reset changes made by `mocv init`')
243
- .action(async () => {
244
- updateShellConfig({ reset: true });
245
- });
246
- program.command('use <version>')
247
- .description('Set current moc version.\nExample 1: "mocv use 0.8.4"\nExample 2: "mocv use latest"')
248
- .action(async (version) => {
249
- await use(version);
250
- });
251
- program.command('current')
252
- .description('Print current moc version')
253
- .action(async () => {
254
- console.log(getCurrent());
255
- });
256
- program.command('bin [version]')
257
- .description('Print bin directory')
258
- .action(async (version = getCurrent()) => {
259
- if (version === 'latest') {
260
- version = await getLatest();
261
- }
262
- if (!version) {
263
- console.log('No version selected. Please pass a version arg or run `mocv` or `mocv use <version>`');
264
- process.exit(1);
265
- }
266
- if (!isCached(version)) {
267
- await download(version, { silent: true });
268
- }
269
- console.log(path.join(cacheDir, 'versions', version));
270
- });
271
- program.parse();
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env tsx
2
- export {};
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env tsx
2
- import { execSync } from 'child_process';
3
- try {
4
- execSync('/home/zen/.cache/mocv/versions/current/moc ' + process.argv.slice(2).join(' '), { cwd: process.cwd(), stdio: 'inherit' });
5
- }
6
- catch (err) {
7
- process.exit(err.code || 1);
8
- }
package/dist/out/cli.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};