ic-mops 0.39.2 → 0.41.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.
Files changed (183) hide show
  1. package/.DS_Store +0 -0
  2. package/.eslintrc.json +0 -0
  3. package/.gitignore +1 -0
  4. package/.npmrc +2 -1
  5. package/CHANGELOG.md +8 -0
  6. package/DEVELOPMENT.md +25 -0
  7. package/README.md +0 -0
  8. package/api/actors.ts +2 -2
  9. package/api/downloadPackageFiles.ts +9 -6
  10. package/api/getHighestVersion.ts +1 -1
  11. package/api/index.ts +0 -0
  12. package/api/network.ts +1 -1
  13. package/api/resolveVersion.ts +1 -1
  14. package/bundle/bench/bench-canister.mo +87 -0
  15. package/bundle/bench/user-bench.mo +14 -0
  16. package/bundle/bin/moc-wrapper.sh +3 -0
  17. package/bundle/bin/mops.js +3 -0
  18. package/bundle/cli.js +88 -0
  19. package/bundle/cli.tgz +0 -0
  20. package/bundle/declarations/bench/bench.did +26 -0
  21. package/bundle/declarations/bench/bench.did.d.ts +29 -0
  22. package/bundle/declarations/bench/bench.did.js +26 -0
  23. package/bundle/declarations/bench/index.d.ts +50 -0
  24. package/bundle/declarations/bench/index.js +41 -0
  25. package/bundle/declarations/main/index.d.ts +50 -0
  26. package/bundle/declarations/main/index.js +41 -0
  27. package/bundle/declarations/main/main.did +426 -0
  28. package/bundle/declarations/main/main.did.d.ts +352 -0
  29. package/bundle/declarations/main/main.did.js +404 -0
  30. package/bundle/declarations/storage/index.d.ts +50 -0
  31. package/bundle/declarations/storage/index.js +30 -0
  32. package/bundle/declarations/storage/storage.did +46 -0
  33. package/bundle/declarations/storage/storage.did.d.ts +37 -0
  34. package/bundle/declarations/storage/storage.did.js +38 -0
  35. package/bundle/package.json +31 -0
  36. package/bundle/templates/README.md +13 -0
  37. package/bundle/templates/licenses/Apache-2.0 +202 -0
  38. package/bundle/templates/licenses/Apache-2.0-NOTICE +13 -0
  39. package/bundle/templates/licenses/MIT +21 -0
  40. package/bundle/templates/mops-publish.yml +17 -0
  41. package/bundle/templates/mops-test.yml +22 -0
  42. package/bundle/templates/src/lib.mo +15 -0
  43. package/bundle/templates/test/lib.test.mo +4 -0
  44. package/bundle-package-json.ts +14 -0
  45. package/cache.ts +3 -3
  46. package/cli.ts +25 -21
  47. package/commands/add.ts +6 -6
  48. package/commands/available-updates.ts +2 -2
  49. package/commands/bench/bench-canister.mo +0 -0
  50. package/commands/bench/user-bench.mo +0 -0
  51. package/commands/bench-replica.ts +10 -10
  52. package/commands/bench.ts +96 -56
  53. package/commands/bump.ts +2 -2
  54. package/commands/docs.ts +1 -1
  55. package/commands/import-identity.ts +2 -2
  56. package/commands/init.ts +9 -9
  57. package/commands/install-all.ts +4 -4
  58. package/commands/install-local.ts +1 -1
  59. package/commands/install.ts +2 -2
  60. package/commands/outdated.ts +0 -0
  61. package/commands/publish.ts +34 -35
  62. package/commands/remove.ts +8 -8
  63. package/commands/search.ts +2 -2
  64. package/commands/self.ts +75 -0
  65. package/commands/sources.ts +0 -0
  66. package/commands/sync.ts +8 -8
  67. package/commands/template.ts +11 -12
  68. package/commands/test/mmf1.ts +18 -18
  69. package/commands/test/reporters/compact-reporter.ts +5 -5
  70. package/commands/test/reporters/files-reporter.ts +3 -3
  71. package/commands/test/reporters/reporter.ts +3 -3
  72. package/commands/test/reporters/silent-reporter.ts +4 -4
  73. package/commands/test/reporters/verbose-reporter.ts +3 -3
  74. package/commands/test/test.ts +10 -10
  75. package/commands/test/utils.ts +1 -1
  76. package/commands/toolchain/index.ts +9 -9
  77. package/commands/toolchain/moc.ts +2 -2
  78. package/commands/toolchain/pocket-ic.ts +6 -31
  79. package/commands/toolchain/toolchain-utils.ts +11 -11
  80. package/commands/toolchain/wasmtime.ts +2 -2
  81. package/commands/transfer-ownership.ts +2 -2
  82. package/commands/update.ts +4 -4
  83. package/commands/user.ts +2 -2
  84. package/commands/whoami.ts +0 -0
  85. package/declarations/bench/bench.did.d.ts +3 -0
  86. package/declarations/main/main.did +27 -1
  87. package/declarations/main/main.did.d.ts +26 -1
  88. package/declarations/main/main.did.js +27 -1
  89. package/declarations/storage/index.d.ts +0 -0
  90. package/declarations/storage/index.js +0 -0
  91. package/declarations/storage/storage.did +0 -0
  92. package/declarations/storage/storage.did.d.ts +0 -0
  93. package/declarations/storage/storage.did.js +0 -0
  94. package/dist/api/downloadPackageFiles.d.ts +1 -1
  95. package/dist/api/downloadPackageFiles.js +4 -0
  96. package/dist/bin/moc-wrapper.sh +3 -0
  97. package/dist/bin/mops.d.ts +1 -1
  98. package/dist/bin/mops.js +2 -1
  99. package/dist/bundle-package-json.d.ts +1 -0
  100. package/dist/bundle-package-json.js +11 -0
  101. package/dist/check-requirements.d.ts +3 -0
  102. package/dist/check-requirements.js +39 -0
  103. package/dist/cli.js +19 -18
  104. package/dist/commands/bench/bench-canister.mo +0 -0
  105. package/dist/commands/bench/user-bench.mo +0 -0
  106. package/dist/commands/bench-replica.d.ts +3 -1
  107. package/dist/commands/bench-replica.js +2 -2
  108. package/dist/commands/bench.d.ts +5 -2
  109. package/dist/commands/bench.js +66 -29
  110. package/dist/commands/init.js +1 -1
  111. package/dist/commands/publish.d.ts +1 -0
  112. package/dist/commands/publish.js +25 -25
  113. package/dist/commands/self.d.ts +3 -0
  114. package/dist/commands/self.js +62 -0
  115. package/dist/commands/template.js +9 -10
  116. package/dist/commands/test/mmf1.js +1 -1
  117. package/dist/commands/test/test.js +2 -2
  118. package/dist/commands/toolchain/pocket-ic.d.ts +1 -5
  119. package/dist/commands/toolchain/pocket-ic.js +4 -27
  120. package/dist/commands/toolchain/toolchain-utils.d.ts +1 -1
  121. package/dist/commands/toolchain/toolchain-utils.js +7 -7
  122. package/dist/commands/transfer-ownership.js +1 -1
  123. package/dist/declarations/bench/bench.did.d.ts +3 -0
  124. package/dist/declarations/main/main.did +27 -1
  125. package/dist/declarations/main/main.did.d.ts +26 -1
  126. package/dist/declarations/main/main.did.js +27 -1
  127. package/dist/declarations/storage/index.d.ts +0 -0
  128. package/dist/declarations/storage/index.js +0 -0
  129. package/dist/declarations/storage/storage.did +0 -0
  130. package/dist/declarations/storage/storage.did.d.ts +0 -0
  131. package/dist/declarations/storage/storage.did.js +0 -0
  132. package/dist/helpers/find-changelog-entry.d.ts +1 -0
  133. package/dist/helpers/find-changelog-entry.js +24 -0
  134. package/dist/mops.d.ts +1 -0
  135. package/dist/mops.js +5 -1
  136. package/dist/package.json +20 -26
  137. package/dist/release-cli.d.ts +1 -0
  138. package/dist/release-cli.js +37 -0
  139. package/dist/remove-scripts.d.ts +1 -0
  140. package/dist/remove-scripts.js +5 -0
  141. package/dist/templates/README.md +0 -0
  142. package/dist/templates/licenses/Apache-2.0 +0 -0
  143. package/dist/templates/licenses/Apache-2.0-NOTICE +0 -0
  144. package/dist/templates/licenses/MIT +0 -0
  145. package/dist/templates/mops-publish.yml +0 -0
  146. package/dist/templates/mops-test.yml +0 -0
  147. package/dist/templates/src/lib.mo +0 -0
  148. package/dist/templates/test/lib.test.mo +0 -0
  149. package/dist/templates.d.ts +1 -0
  150. package/dist/templates.js +4 -0
  151. package/dist/vessel.js +1 -1
  152. package/global.d.ts +0 -0
  153. package/helpers/find-changelog-entry.ts +27 -0
  154. package/helpers/get-dfx-version.ts +1 -1
  155. package/helpers/get-moc-path.ts +1 -1
  156. package/helpers/get-moc-version.ts +1 -1
  157. package/integrity.ts +16 -16
  158. package/mops.ts +22 -17
  159. package/notify-installs.ts +2 -2
  160. package/package.json +28 -19
  161. package/parallel.ts +1 -1
  162. package/pem.ts +5 -5
  163. package/release-cli.ts +62 -0
  164. package/remove-scripts.ts +6 -0
  165. package/resolve-packages.ts +9 -9
  166. package/templates/README.md +0 -0
  167. package/templates/licenses/Apache-2.0 +0 -0
  168. package/templates/licenses/Apache-2.0-NOTICE +0 -0
  169. package/templates/licenses/MIT +0 -0
  170. package/templates/mops-publish.yml +0 -0
  171. package/templates/mops-test.yml +0 -0
  172. package/templates/src/lib.mo +0 -0
  173. package/templates/test/lib.test.mo +0 -0
  174. package/templates.ts +5 -0
  175. package/tsconfig.json +1 -1
  176. package/types.ts +25 -25
  177. package/vessel.ts +16 -16
  178. package/commands/self-update.ts +0 -6
  179. package/dist/commands/replica.d.ts +0 -36
  180. package/dist/commands/replica.js +0 -103
  181. package/dist/commands/self-update.d.ts +0 -3
  182. package/dist/commands/self-update.js +0 -5
  183. /package/bin/{mops.ts → mops.js} +0 -0
@@ -1,103 +0,0 @@
1
- import { execSync, spawn } from 'node:child_process';
2
- import path from 'node:path';
3
- import fs from 'node:fs';
4
- import { execaCommand } from 'execa';
5
- import { PocketIc } from 'pic-ic';
6
- import { readConfig } from '../mops.js';
7
- import { createActor, idlFactory } from '../declarations/bench/index.js';
8
- import { toolchain } from './toolchain/index.js';
9
- export class Replica {
10
- constructor(type, cwd, verbose = false) {
11
- this.verbose = false;
12
- this.canisters = {};
13
- this.type = type;
14
- this.verbose = verbose;
15
- this.cwd = cwd;
16
- }
17
- async start() {
18
- console.log(`Starting ${this.type} replica...`);
19
- if (this.type == 'dfx') {
20
- await this.stop();
21
- fs.writeFileSync(path.join(this.cwd, 'dfx.json'), JSON.stringify(this.dfxJson(''), null, 2));
22
- // this.process = spawn('dfx start --background --clean --artificial-delay 0' + (this.verbose ? '' : ' -qqqq'), {cwd: this.cwd, stdio: ['inherit', this.verbose ? 'inherit' : 'ignore', 'inherit']});
23
- this.process = spawn('dfx', ['start', '--background', '--clean', '--artificial-delay=0', this.verbose ? '' : ' -qqqq'].filter(x => x), { cwd: this.cwd });
24
- }
25
- else {
26
- let pocketIcBin = await toolchain.bin('pocket-ic');
27
- let config = readConfig();
28
- if (config.toolchain?.['pocket-ic'] !== '1.0.0') {
29
- console.error('Currently only pocket-ic 1.0.0 is supported');
30
- process.exit(1);
31
- }
32
- this.pocketIc = await PocketIc.create(pocketIcBin);
33
- // @ts-ignore
34
- this.process = this.pocketIc.server.serverProcess;
35
- }
36
- await new Promise((resolve, reject) => {
37
- console.log(1);
38
- this.process?.on('data', (data) => {
39
- console.log(111, data);
40
- });
41
- });
42
- return this.process;
43
- }
44
- async stop() {
45
- if (this.type == 'dfx') {
46
- execSync('dfx stop' + (this.verbose ? '' : ' -qqqq'), { cwd: this.cwd, stdio: ['pipe', this.verbose ? 'inherit' : 'ignore', 'pipe'] });
47
- }
48
- else if (this.pocketIc) {
49
- await this.pocketIc.tearDown();
50
- }
51
- }
52
- async deploy(name, wasm, cwd = process.cwd()) {
53
- if (this.type === 'dfx') {
54
- await execaCommand(`dfx deploy ${name} --mode reinstall --yes --identity anonymous`, { cwd, stdio: this.verbose ? 'pipe' : ['pipe', 'ignore', 'pipe'] });
55
- let canisterId = execSync(`dfx canister id ${name}`, { cwd }).toString().trim();
56
- let actor = await createActor(canisterId, {
57
- agentOptions: {
58
- host: 'http://127.0.0.1:4944',
59
- },
60
- });
61
- this.canisters[name] = { cwd, canisterId, actor };
62
- }
63
- else if (this.pocketIc) {
64
- let { canisterId, actor } = await this.pocketIc.setupCanister(idlFactory, wasm);
65
- this.canisters[name] = {
66
- cwd,
67
- canisterId: canisterId.toText(),
68
- actor,
69
- };
70
- }
71
- }
72
- getActor(name) {
73
- return this.canisters[name]?.actor;
74
- }
75
- getCanisterId(name) {
76
- return this.canisters[name]?.canisterId || '';
77
- }
78
- dfxJson(canisterName) {
79
- let canisters = {};
80
- if (canisterName) {
81
- canisters[canisterName] = {
82
- type: 'custom',
83
- wasm: 'canister.wasm',
84
- candid: 'canister.did',
85
- };
86
- }
87
- return {
88
- version: 1,
89
- canisters,
90
- defaults: {
91
- build: {
92
- packtool: 'mops sources',
93
- },
94
- },
95
- networks: {
96
- local: {
97
- type: 'ephemeral',
98
- bind: '127.0.0.1:4944',
99
- },
100
- },
101
- };
102
- }
103
- }
@@ -1,3 +0,0 @@
1
- export declare function selfUpdate({ detached }?: {
2
- detached?: boolean | undefined;
3
- }): void;
@@ -1,5 +0,0 @@
1
- import child_process from 'node:child_process';
2
- export function selfUpdate({ detached = false } = {}) {
3
- console.log('Updating mops CLI...');
4
- child_process.spawn('npm', ['install', 'ic-mops', '-g'], { stdio: 'inherit', detached });
5
- }
File without changes