ic-mops 0.40.0 → 0.41.1

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 (193) hide show
  1. package/.DS_Store +0 -0
  2. package/.npmrc +2 -1
  3. package/CHANGELOG.md +8 -0
  4. package/DEVELOPMENT.md +25 -0
  5. package/bundle/bench/bench-canister.mo +87 -0
  6. package/bundle/bench/user-bench.mo +14 -0
  7. package/bundle/bin/moc-wrapper.sh +3 -0
  8. package/bundle/bin/mops.js +3 -0
  9. package/bundle/cli.js +88 -0
  10. package/bundle/cli.tgz +0 -0
  11. package/bundle/declarations/bench/bench.did +26 -0
  12. package/bundle/declarations/bench/bench.did.d.ts +29 -0
  13. package/bundle/declarations/bench/bench.did.js +26 -0
  14. package/bundle/declarations/bench/index.d.ts +50 -0
  15. package/bundle/declarations/bench/index.js +40 -0
  16. package/bundle/declarations/main/index.d.ts +50 -0
  17. package/bundle/declarations/main/index.js +40 -0
  18. package/bundle/declarations/main/main.did +433 -0
  19. package/bundle/declarations/main/main.did.d.ts +355 -0
  20. package/bundle/declarations/main/main.did.js +407 -0
  21. package/bundle/declarations/storage/index.d.ts +50 -0
  22. package/bundle/declarations/storage/index.js +30 -0
  23. package/bundle/declarations/storage/storage.did +46 -0
  24. package/bundle/declarations/storage/storage.did.d.ts +37 -0
  25. package/bundle/declarations/storage/storage.did.js +38 -0
  26. package/bundle/package.json +31 -0
  27. package/bundle/templates/README.md +13 -0
  28. package/bundle/templates/licenses/Apache-2.0 +202 -0
  29. package/bundle/templates/licenses/Apache-2.0-NOTICE +13 -0
  30. package/bundle/templates/licenses/MIT +21 -0
  31. package/bundle/templates/mops-publish.yml +17 -0
  32. package/bundle/templates/mops-test.yml +22 -0
  33. package/bundle/templates/src/lib.mo +15 -0
  34. package/bundle/templates/test/lib.test.mo +4 -0
  35. package/bundle-package-json.ts +17 -0
  36. package/check-requirements.ts +50 -0
  37. package/cli.ts +22 -19
  38. package/commands/add.ts +4 -0
  39. package/commands/install-all.ts +2 -0
  40. package/commands/publish.ts +18 -30
  41. package/commands/self.ts +75 -0
  42. package/commands/template.ts +9 -10
  43. package/commands/toolchain/index.ts +7 -0
  44. package/declarations/bench/bench.did.d.ts +1 -1
  45. package/declarations/bench/index.js +1 -2
  46. package/declarations/main/index.js +1 -2
  47. package/declarations/main/main.did +15 -8
  48. package/declarations/main/main.did.d.ts +12 -9
  49. package/declarations/main/main.did.js +11 -8
  50. package/dist/api/actors.d.ts +0 -0
  51. package/dist/api/actors.js +0 -0
  52. package/dist/api/downloadPackageFiles.d.ts +0 -0
  53. package/dist/api/downloadPackageFiles.js +0 -0
  54. package/dist/api/getHighestVersion.d.ts +0 -0
  55. package/dist/api/getHighestVersion.js +0 -0
  56. package/dist/api/index.d.ts +0 -0
  57. package/dist/api/index.js +0 -0
  58. package/dist/api/network.d.ts +0 -0
  59. package/dist/api/network.js +0 -0
  60. package/dist/api/resolveVersion.d.ts +0 -0
  61. package/dist/api/resolveVersion.js +0 -0
  62. package/dist/bin/mops.d.ts +1 -1
  63. package/dist/bin/mops.js +2 -1
  64. package/dist/bundle-package-json.d.ts +0 -0
  65. package/dist/bundle-package-json.js +2 -0
  66. package/dist/cache.d.ts +0 -0
  67. package/dist/cache.js +0 -0
  68. package/dist/check-requirements.d.ts +3 -0
  69. package/dist/check-requirements.js +44 -0
  70. package/dist/cli.d.ts +0 -0
  71. package/dist/cli.js +18 -18
  72. package/dist/commands/add.d.ts +0 -0
  73. package/dist/commands/add.js +2 -0
  74. package/dist/commands/available-updates.d.ts +0 -0
  75. package/dist/commands/available-updates.js +0 -0
  76. package/dist/commands/bench-replica.d.ts +0 -0
  77. package/dist/commands/bench-replica.js +0 -0
  78. package/dist/commands/bench.d.ts +0 -0
  79. package/dist/commands/bench.js +0 -0
  80. package/dist/commands/bump.d.ts +0 -0
  81. package/dist/commands/bump.js +0 -0
  82. package/dist/commands/docs.d.ts +0 -0
  83. package/dist/commands/docs.js +0 -0
  84. package/dist/commands/import-identity.d.ts +0 -0
  85. package/dist/commands/import-identity.js +0 -0
  86. package/dist/commands/init.d.ts +0 -0
  87. package/dist/commands/init.js +0 -0
  88. package/dist/commands/install-all.d.ts +0 -0
  89. package/dist/commands/install-all.js +2 -0
  90. package/dist/commands/install-local.d.ts +0 -0
  91. package/dist/commands/install-local.js +0 -0
  92. package/dist/commands/install.d.ts +0 -0
  93. package/dist/commands/install.js +0 -0
  94. package/dist/commands/outdated.d.ts +0 -0
  95. package/dist/commands/outdated.js +0 -0
  96. package/dist/commands/publish.d.ts +0 -0
  97. package/dist/commands/publish.js +14 -25
  98. package/dist/commands/remove.d.ts +0 -0
  99. package/dist/commands/remove.js +0 -0
  100. package/dist/commands/search.d.ts +0 -0
  101. package/dist/commands/search.js +0 -0
  102. package/dist/commands/self.js +1 -1
  103. package/dist/commands/sources.d.ts +0 -0
  104. package/dist/commands/sources.js +0 -0
  105. package/dist/commands/sync.d.ts +0 -0
  106. package/dist/commands/sync.js +0 -0
  107. package/dist/commands/template.d.ts +0 -0
  108. package/dist/commands/template.js +9 -10
  109. package/dist/commands/test/mmf1.d.ts +0 -0
  110. package/dist/commands/test/mmf1.js +0 -0
  111. package/dist/commands/test/reporters/compact-reporter.d.ts +0 -0
  112. package/dist/commands/test/reporters/compact-reporter.js +0 -0
  113. package/dist/commands/test/reporters/files-reporter.d.ts +0 -0
  114. package/dist/commands/test/reporters/files-reporter.js +0 -0
  115. package/dist/commands/test/reporters/reporter.d.ts +0 -0
  116. package/dist/commands/test/reporters/reporter.js +0 -0
  117. package/dist/commands/test/reporters/silent-reporter.d.ts +0 -0
  118. package/dist/commands/test/reporters/silent-reporter.js +0 -0
  119. package/dist/commands/test/reporters/verbose-reporter.d.ts +0 -0
  120. package/dist/commands/test/reporters/verbose-reporter.js +0 -0
  121. package/dist/commands/test/test.d.ts +0 -0
  122. package/dist/commands/test/test.js +0 -0
  123. package/dist/commands/test/utils.d.ts +0 -0
  124. package/dist/commands/test/utils.js +0 -0
  125. package/dist/commands/toolchain/index.d.ts +0 -0
  126. package/dist/commands/toolchain/index.js +5 -0
  127. package/dist/commands/toolchain/moc.d.ts +0 -0
  128. package/dist/commands/toolchain/moc.js +0 -0
  129. package/dist/commands/toolchain/pocket-ic.d.ts +0 -0
  130. package/dist/commands/toolchain/pocket-ic.js +0 -0
  131. package/dist/commands/toolchain/toolchain-utils.d.ts +0 -0
  132. package/dist/commands/toolchain/toolchain-utils.js +0 -0
  133. package/dist/commands/toolchain/wasmtime.d.ts +0 -0
  134. package/dist/commands/toolchain/wasmtime.js +0 -0
  135. package/dist/commands/transfer-ownership.d.ts +0 -0
  136. package/dist/commands/transfer-ownership.js +0 -0
  137. package/dist/commands/update.d.ts +0 -0
  138. package/dist/commands/update.js +0 -0
  139. package/dist/commands/user.d.ts +0 -0
  140. package/dist/commands/user.js +0 -0
  141. package/dist/commands/whoami.d.ts +0 -0
  142. package/dist/commands/whoami.js +0 -0
  143. package/dist/declarations/bench/bench.did +0 -0
  144. package/dist/declarations/bench/bench.did.d.ts +1 -1
  145. package/dist/declarations/bench/bench.did.js +0 -0
  146. package/dist/declarations/bench/index.d.ts +0 -0
  147. package/dist/declarations/bench/index.js +1 -2
  148. package/dist/declarations/main/index.d.ts +0 -0
  149. package/dist/declarations/main/index.js +1 -2
  150. package/dist/declarations/main/main.did +15 -8
  151. package/dist/declarations/main/main.did.d.ts +12 -9
  152. package/dist/declarations/main/main.did.js +11 -8
  153. package/dist/helpers/find-changelog-entry.d.ts +0 -0
  154. package/dist/helpers/find-changelog-entry.js +0 -0
  155. package/dist/helpers/get-dfx-version.d.ts +0 -0
  156. package/dist/helpers/get-dfx-version.js +0 -0
  157. package/dist/helpers/get-moc-path.d.ts +0 -0
  158. package/dist/helpers/get-moc-path.js +0 -0
  159. package/dist/helpers/get-moc-version.d.ts +0 -0
  160. package/dist/helpers/get-moc-version.js +0 -0
  161. package/dist/integrity.d.ts +0 -0
  162. package/dist/integrity.js +0 -0
  163. package/dist/mops.d.ts +1 -0
  164. package/dist/mops.js +12 -1
  165. package/dist/notify-installs.d.ts +0 -0
  166. package/dist/notify-installs.js +0 -0
  167. package/dist/package.json +18 -24
  168. package/dist/parallel.d.ts +0 -0
  169. package/dist/parallel.js +0 -0
  170. package/dist/pem.d.ts +0 -0
  171. package/dist/pem.js +0 -0
  172. package/dist/release-cli.d.ts +0 -0
  173. package/dist/release-cli.js +13 -7
  174. package/dist/resolve-packages.d.ts +0 -0
  175. package/dist/resolve-packages.js +0 -0
  176. package/dist/templates.d.ts +1 -0
  177. package/dist/templates.js +4 -0
  178. package/dist/types.d.ts +4 -0
  179. package/dist/types.js +0 -0
  180. package/dist/vessel.d.ts +0 -0
  181. package/dist/vessel.js +0 -0
  182. package/helpers/find-changelog-entry.ts +27 -0
  183. package/mops.ts +15 -1
  184. package/package.json +26 -17
  185. package/release-cli.ts +67 -0
  186. package/remove-scripts.ts +6 -0
  187. package/templates.ts +5 -0
  188. package/tsconfig.json +1 -1
  189. package/types.ts +7 -2
  190. package/commands/self-update.ts +0 -6
  191. package/dist/commands/self-update.d.ts +0 -3
  192. package/dist/commands/self-update.js +0 -5
  193. /package/bin/{mops.ts → mops.js} +0 -0
@@ -4,6 +4,7 @@ import chalk from 'chalk';
4
4
  import prompts from 'prompts';
5
5
  import camelCase from 'camelcase';
6
6
  import {getRootDir, readConfig} from '../mops.js';
7
+ import {copyTemplateFileSync} from '../templates.js';
7
8
 
8
9
  export async function template(templateName ?: string, options : any = {}) {
9
10
  if (!templateName) {
@@ -32,9 +33,8 @@ export async function template(templateName ?: string, options : any = {}) {
32
33
  console.log(chalk.yellow('Workflow already exists:'), path.relative(getRootDir(), dest));
33
34
  return;
34
35
  }
35
- let mopsTestYml = new URL('../templates/mops-test.yml', import.meta.url);
36
36
  fs.mkdirSync(path.resolve(getRootDir(), '.github/workflows'), {recursive: true});
37
- fs.copyFileSync(mopsTestYml, dest);
37
+ copyTemplateFileSync('mops-test.yml', dest);
38
38
  console.log(chalk.green('Created'), path.relative(getRootDir(), dest));
39
39
  }
40
40
  else if (templateName === 'github-workflow:mops-publish') {
@@ -43,9 +43,8 @@ export async function template(templateName ?: string, options : any = {}) {
43
43
  console.log(chalk.yellow('Workflow already exists:'), path.relative(getRootDir(), dest));
44
44
  return;
45
45
  }
46
- let mopsPublishYml = new URL('../templates/mops-publish.yml', import.meta.url);
47
46
  fs.mkdirSync(path.resolve(getRootDir(), '.github/workflows'), {recursive: true});
48
- fs.copyFileSync(mopsPublishYml, dest);
47
+ copyTemplateFileSync('mops-publish.yml', dest);
49
48
  console.log(chalk.green('Created'), path.relative(getRootDir(), dest));
50
49
  }
51
50
  else if (templateName?.startsWith('license:')) {
@@ -65,13 +64,13 @@ export async function template(templateName ?: string, options : any = {}) {
65
64
  };
66
65
 
67
66
  if (templateName === 'license:MIT') {
68
- fs.copyFileSync(new URL('../templates/licenses/MIT', import.meta.url), path.resolve(getRootDir(), 'LICENSE'));
67
+ copyTemplateFileSync('licenses/MIT', path.resolve(getRootDir(), 'LICENSE'));
69
68
  setYearAndOwner(path.resolve(getRootDir(), 'LICENSE'));
70
69
  console.log(chalk.green('Created'), path.relative(getRootDir(), 'LICENSE'));
71
70
  }
72
71
  else if (templateName === 'license:Apache-2.0') {
73
- fs.copyFileSync(new URL('../templates/licenses/Apache-2.0', import.meta.url), path.resolve(getRootDir(), 'LICENSE'));
74
- fs.copyFileSync(new URL('../templates/licenses/Apache-2.0-NOTICE', import.meta.url), path.resolve(getRootDir(), 'NOTICE'));
72
+ copyTemplateFileSync('licenses/Apache-2.0', path.resolve(getRootDir(), 'LICENSE'));
73
+ copyTemplateFileSync('licenses/Apache-2.0-NOTICE', path.resolve(getRootDir(), 'NOTICE'));
75
74
  setYearAndOwner(path.resolve(getRootDir(), 'NOTICE'));
76
75
  console.log(chalk.green('Created'), path.relative(getRootDir(), 'LICENSE'));
77
76
  console.log(chalk.green('Created'), path.relative(getRootDir(), 'NOTICE'));
@@ -79,12 +78,12 @@ export async function template(templateName ?: string, options : any = {}) {
79
78
  }
80
79
  else if (templateName === 'lib.mo') {
81
80
  fs.mkdirSync(path.join(getRootDir(), 'src'), {recursive: true});
82
- fs.copyFileSync(new URL('../templates/src/lib.mo', import.meta.url), path.resolve(getRootDir(), 'src/lib.mo'));
81
+ copyTemplateFileSync('src/lib.mo', path.resolve(getRootDir(), 'src/lib.mo'));
83
82
  console.log(chalk.green('Created'), path.relative(getRootDir(), 'src/lib.mo'));
84
83
  }
85
84
  else if (templateName === 'lib.test.mo') {
86
85
  fs.mkdirSync(path.join(getRootDir(), 'test'), {recursive: true});
87
- fs.copyFileSync(new URL('../templates/test/lib.test.mo', import.meta.url), path.resolve(getRootDir(), 'test/lib.test.mo'));
86
+ copyTemplateFileSync('test/lib.test.mo', path.resolve(getRootDir(), 'test/lib.test.mo'));
88
87
  console.log(chalk.green('Created'), path.relative(getRootDir(), 'test/lib.test.mo'));
89
88
  }
90
89
  else if (templateName === 'readme') {
@@ -93,7 +92,7 @@ export async function template(templateName ?: string, options : any = {}) {
93
92
  console.log(chalk.yellow('README.md already exists'));
94
93
  return;
95
94
  }
96
- fs.copyFileSync(new URL('../templates/README.md', import.meta.url), dest);
95
+ copyTemplateFileSync('README.md', dest);
97
96
 
98
97
  let config = readConfig();
99
98
 
@@ -7,6 +7,7 @@ import prompts from 'prompts';
7
7
  import {createLogUpdate} from 'log-update';
8
8
  import {checkConfigFile, getClosestConfigFile, getRootDir, globalCacheDir, readConfig, writeConfig} from '../../mops.js';
9
9
  import {Tool} from '../../types.js';
10
+ import {checkRequirements} from '../../check-requirements.js';
10
11
  import * as moc from './moc.js';
11
12
  import * as pocketIc from './pocket-ic.js';
12
13
  import * as wasmtime from './wasmtime.js';
@@ -243,6 +244,8 @@ async function use(tool : Tool, version ?: string) {
243
244
  config.toolchain[tool] = version;
244
245
  writeConfig(config);
245
246
 
247
+ await checkRequirements();
248
+
246
249
  if (oldVersion === version) {
247
250
  console.log((`${tool} ${version} is already installed`));
248
251
  }
@@ -277,6 +280,10 @@ async function update(tool ?: Tool) {
277
280
  config.toolchain[tool] = version;
278
281
  writeConfig(config);
279
282
 
283
+ if (tool === 'moc') {
284
+ await checkRequirements();
285
+ }
286
+
280
287
  if (oldVersion === version) {
281
288
  console.log((`Latest ${tool} ${version} is already installed`));
282
289
  }
@@ -26,4 +26,4 @@ export interface anon_class_10_1 {
26
26
  }
27
27
  export interface _SERVICE extends anon_class_10_1 {}
28
28
  export declare const idlFactory: IDL.InterfaceFactory;
29
- export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[];
29
+ export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];
@@ -10,8 +10,7 @@ export { idlFactory } from "./bench.did.js";
10
10
  * beginning in dfx 0.15.0
11
11
  */
12
12
  export const canisterId =
13
- process.env.CANISTER_ID_BENCH ||
14
- process.env.BENCH_CANISTER_ID;
13
+ process.env.CANISTER_ID_BENCH;
15
14
 
16
15
  export const createActor = (canisterId, options = {}) => {
17
16
  const agent = options.agent || new HttpAgent({ ...options.agentOptions });
@@ -10,8 +10,7 @@ export { idlFactory } from "./main.did.js";
10
10
  * beginning in dfx 0.15.0
11
11
  */
12
12
  export const canisterId =
13
- process.env.CANISTER_ID_MAIN ||
14
- process.env.MAIN_CANISTER_ID;
13
+ process.env.CANISTER_ID_MAIN;
15
14
 
16
15
  export const createActor = (canisterId, options = {}) => {
17
16
  const agent = options.agent || new HttpAgent({ ...options.agentOptions });
@@ -132,6 +132,11 @@ type Response =
132
132
  streaming_strategy: opt StreamingStrategy;
133
133
  upgrade: opt bool;
134
134
  };
135
+ type Requirement =
136
+ record {
137
+ name: text;
138
+ value: text;
139
+ };
135
140
  type Request =
136
141
  record {
137
142
  body: blob;
@@ -145,7 +150,7 @@ type PageCount = nat;
145
150
  type PackageVersion = text;
146
151
  type PackageSummary__1 =
147
152
  record {
148
- config: PackageConfigV2__1;
153
+ config: PackageConfigV3;
149
154
  downloadsInLast30Days: nat;
150
155
  downloadsInLast7Days: nat;
151
156
  downloadsTotal: nat;
@@ -157,7 +162,7 @@ type PackageSummary__1 =
157
162
  type PackageSummaryWithChanges__1 =
158
163
  record {
159
164
  changes: PackageChanges;
160
- config: PackageConfigV2__1;
165
+ config: PackageConfigV3;
161
166
  downloadsInLast30Days: nat;
162
167
  downloadsInLast7Days: nat;
163
168
  downloadsTotal: nat;
@@ -169,7 +174,7 @@ type PackageSummaryWithChanges__1 =
169
174
  type PackageSummaryWithChanges =
170
175
  record {
171
176
  changes: PackageChanges;
172
- config: PackageConfigV2__1;
177
+ config: PackageConfigV3;
173
178
  downloadsInLast30Days: nat;
174
179
  downloadsInLast7Days: nat;
175
180
  downloadsTotal: nat;
@@ -180,7 +185,7 @@ type PackageSummaryWithChanges =
180
185
  };
181
186
  type PackageSummary =
182
187
  record {
183
- config: PackageConfigV2__1;
188
+ config: PackageConfigV3;
184
189
  downloadsInLast30Days: nat;
185
190
  downloadsInLast7Days: nat;
186
191
  downloadsTotal: nat;
@@ -218,7 +223,7 @@ type PackageDetails =
218
223
  record {
219
224
  benchmarks: Benchmarks__1;
220
225
  changes: PackageChanges;
221
- config: PackageConfigV2__1;
226
+ config: PackageConfigV3;
222
227
  dependents: vec PackageSummary__1;
223
228
  deps: vec PackageSummary__1;
224
229
  devDeps: vec PackageSummary__1;
@@ -234,7 +239,7 @@ type PackageDetails =
234
239
  testStats: TestStats__1;
235
240
  versionHistory: vec PackageSummaryWithChanges__1;
236
241
  };
237
- type PackageConfigV2__1 =
242
+ type PackageConfigV3_Publishing =
238
243
  record {
239
244
  baseDir: text;
240
245
  dependencies: vec DependencyV2;
@@ -250,10 +255,11 @@ type PackageConfigV2__1 =
250
255
  name: PackageName__1;
251
256
  readme: text;
252
257
  repository: text;
258
+ requirements: opt vec Requirement;
253
259
  scripts: vec Script;
254
260
  version: text;
255
261
  };
256
- type PackageConfigV2 =
262
+ type PackageConfigV3 =
257
263
  record {
258
264
  baseDir: text;
259
265
  dependencies: vec DependencyV2;
@@ -269,6 +275,7 @@ type PackageConfigV2 =
269
275
  name: PackageName__1;
270
276
  readme: text;
271
277
  repository: text;
278
+ requirements: vec Requirement;
272
279
  scripts: vec Script;
273
280
  version: text;
274
281
  };
@@ -341,7 +348,7 @@ type Main =
341
348
  search: (Text, opt nat, opt nat) -> (vec PackageSummary, PageCount) query;
342
349
  setUserProp: (text, text) -> (Result_1);
343
350
  startFileUpload: (PublishingId, Text, nat, blob) -> (Result_3);
344
- startPublish: (PackageConfigV2) -> (Result_2);
351
+ startPublish: (PackageConfigV3_Publishing) -> (Result_2);
345
352
  transferOwnership: (PackageName, principal) -> (Result_1);
346
353
  transformRequest: (HttpTransformArg) -> (HttpResponse) query;
347
354
  uploadBenchmarks: (PublishingId, Benchmarks) -> (Result);
@@ -117,7 +117,7 @@ export interface Main {
117
117
  [PublishingId, Text, bigint, Uint8Array | number[]],
118
118
  Result_3
119
119
  >,
120
- 'startPublish' : ActorMethod<[PackageConfigV2], Result_2>,
120
+ 'startPublish' : ActorMethod<[PackageConfigV3_Publishing], Result_2>,
121
121
  'transferOwnership' : ActorMethod<[PackageName, Principal], Result_1>,
122
122
  'transformRequest' : ActorMethod<[HttpTransformArg], HttpResponse>,
123
123
  'uploadBenchmarks' : ActorMethod<[PublishingId, Benchmarks], Result>,
@@ -136,7 +136,7 @@ export interface PackageChanges {
136
136
  'notes' : string,
137
137
  'devDeps' : Array<DepChange>,
138
138
  }
139
- export interface PackageConfigV2 {
139
+ export interface PackageConfigV3 {
140
140
  'dfx' : string,
141
141
  'moc' : string,
142
142
  'scripts' : Array<Script>,
@@ -151,10 +151,11 @@ export interface PackageConfigV2 {
151
151
  'devDependencies' : Array<DependencyV2>,
152
152
  'repository' : string,
153
153
  'dependencies' : Array<DependencyV2>,
154
+ 'requirements' : Array<Requirement>,
154
155
  'license' : string,
155
156
  'readme' : string,
156
157
  }
157
- export interface PackageConfigV2__1 {
158
+ export interface PackageConfigV3_Publishing {
158
159
  'dfx' : string,
159
160
  'moc' : string,
160
161
  'scripts' : Array<Script>,
@@ -169,6 +170,7 @@ export interface PackageConfigV2__1 {
169
170
  'devDependencies' : Array<DependencyV2>,
170
171
  'repository' : string,
171
172
  'dependencies' : Array<DependencyV2>,
173
+ 'requirements' : [] | [Array<Requirement>],
172
174
  'license' : string,
173
175
  'readme' : string,
174
176
  }
@@ -187,7 +189,7 @@ export interface PackageDetails {
187
189
  'dependents' : Array<PackageSummary__1>,
188
190
  'devDeps' : Array<PackageSummary__1>,
189
191
  'downloadsInLast7Days' : bigint,
190
- 'config' : PackageConfigV2__1,
192
+ 'config' : PackageConfigV3,
191
193
  'changes' : PackageChanges,
192
194
  'publication' : PackagePublication,
193
195
  }
@@ -220,7 +222,7 @@ export interface PackageSummary {
220
222
  'downloadsTotal' : bigint,
221
223
  'downloadsInLast30Days' : bigint,
222
224
  'downloadsInLast7Days' : bigint,
223
- 'config' : PackageConfigV2__1,
225
+ 'config' : PackageConfigV3,
224
226
  'publication' : PackagePublication,
225
227
  }
226
228
  export interface PackageSummaryWithChanges {
@@ -230,7 +232,7 @@ export interface PackageSummaryWithChanges {
230
232
  'downloadsTotal' : bigint,
231
233
  'downloadsInLast30Days' : bigint,
232
234
  'downloadsInLast7Days' : bigint,
233
- 'config' : PackageConfigV2__1,
235
+ 'config' : PackageConfigV3,
234
236
  'changes' : PackageChanges,
235
237
  'publication' : PackagePublication,
236
238
  }
@@ -241,7 +243,7 @@ export interface PackageSummaryWithChanges__1 {
241
243
  'downloadsTotal' : bigint,
242
244
  'downloadsInLast30Days' : bigint,
243
245
  'downloadsInLast7Days' : bigint,
244
- 'config' : PackageConfigV2__1,
246
+ 'config' : PackageConfigV3,
245
247
  'changes' : PackageChanges,
246
248
  'publication' : PackagePublication,
247
249
  }
@@ -252,7 +254,7 @@ export interface PackageSummary__1 {
252
254
  'downloadsTotal' : bigint,
253
255
  'downloadsInLast30Days' : bigint,
254
256
  'downloadsInLast7Days' : bigint,
255
- 'config' : PackageConfigV2__1,
257
+ 'config' : PackageConfigV3,
256
258
  'publication' : PackagePublication,
257
259
  }
258
260
  export type PackageVersion = string;
@@ -265,6 +267,7 @@ export interface Request {
265
267
  'headers' : Array<Header>,
266
268
  'certificate_version' : [] | [number],
267
269
  }
270
+ export interface Requirement { 'value' : string, 'name' : string }
268
271
  export interface Response {
269
272
  'body' : Uint8Array | number[],
270
273
  'headers' : Array<Header>,
@@ -349,4 +352,4 @@ export interface User__1 {
349
352
  }
350
353
  export interface _SERVICE extends Main {}
351
354
  export declare const idlFactory: IDL.InterfaceFactory;
352
- export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[];
355
+ export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];
@@ -62,7 +62,8 @@ export const idlFactory = ({ IDL }) => {
62
62
  'repo' : IDL.Text,
63
63
  'version' : IDL.Text,
64
64
  });
65
- const PackageConfigV2__1 = IDL.Record({
65
+ const Requirement = IDL.Record({ 'value' : IDL.Text, 'name' : IDL.Text });
66
+ const PackageConfigV3 = IDL.Record({
66
67
  'dfx' : IDL.Text,
67
68
  'moc' : IDL.Text,
68
69
  'scripts' : IDL.Vec(Script),
@@ -77,6 +78,7 @@ export const idlFactory = ({ IDL }) => {
77
78
  'devDependencies' : IDL.Vec(DependencyV2),
78
79
  'repository' : IDL.Text,
79
80
  'dependencies' : IDL.Vec(DependencyV2),
81
+ 'requirements' : IDL.Vec(Requirement),
80
82
  'license' : IDL.Text,
81
83
  'readme' : IDL.Text,
82
84
  });
@@ -92,7 +94,7 @@ export const idlFactory = ({ IDL }) => {
92
94
  'downloadsTotal' : IDL.Nat,
93
95
  'downloadsInLast30Days' : IDL.Nat,
94
96
  'downloadsInLast7Days' : IDL.Nat,
95
- 'config' : PackageConfigV2__1,
97
+ 'config' : PackageConfigV3,
96
98
  'publication' : PackagePublication,
97
99
  });
98
100
  const BenchmarkMetric = IDL.Text;
@@ -118,7 +120,7 @@ export const idlFactory = ({ IDL }) => {
118
120
  'downloadsTotal' : IDL.Nat,
119
121
  'downloadsInLast30Days' : IDL.Nat,
120
122
  'downloadsInLast7Days' : IDL.Nat,
121
- 'config' : PackageConfigV2__1,
123
+ 'config' : PackageConfigV3,
122
124
  'publication' : PackagePublication,
123
125
  });
124
126
  const TestStats__1 = IDL.Record({
@@ -158,7 +160,7 @@ export const idlFactory = ({ IDL }) => {
158
160
  'downloadsTotal' : IDL.Nat,
159
161
  'downloadsInLast30Days' : IDL.Nat,
160
162
  'downloadsInLast7Days' : IDL.Nat,
161
- 'config' : PackageConfigV2__1,
163
+ 'config' : PackageConfigV3,
162
164
  'changes' : PackageChanges,
163
165
  'publication' : PackagePublication,
164
166
  });
@@ -177,7 +179,7 @@ export const idlFactory = ({ IDL }) => {
177
179
  'dependents' : IDL.Vec(PackageSummary__1),
178
180
  'devDeps' : IDL.Vec(PackageSummary__1),
179
181
  'downloadsInLast7Days' : IDL.Nat,
180
- 'config' : PackageConfigV2__1,
182
+ 'config' : PackageConfigV3,
181
183
  'changes' : PackageChanges,
182
184
  'publication' : PackagePublication,
183
185
  });
@@ -189,7 +191,7 @@ export const idlFactory = ({ IDL }) => {
189
191
  'downloadsTotal' : IDL.Nat,
190
192
  'downloadsInLast30Days' : IDL.Nat,
191
193
  'downloadsInLast7Days' : IDL.Nat,
192
- 'config' : PackageConfigV2__1,
194
+ 'config' : PackageConfigV3,
193
195
  'changes' : PackageChanges,
194
196
  'publication' : PackagePublication,
195
197
  });
@@ -245,7 +247,7 @@ export const idlFactory = ({ IDL }) => {
245
247
  const PageCount = IDL.Nat;
246
248
  const Result_1 = IDL.Variant({ 'ok' : IDL.Null, 'err' : IDL.Text });
247
249
  const Result_3 = IDL.Variant({ 'ok' : FileId, 'err' : Err });
248
- const PackageConfigV2 = IDL.Record({
250
+ const PackageConfigV3_Publishing = IDL.Record({
249
251
  'dfx' : IDL.Text,
250
252
  'moc' : IDL.Text,
251
253
  'scripts' : IDL.Vec(Script),
@@ -260,6 +262,7 @@ export const idlFactory = ({ IDL }) => {
260
262
  'devDependencies' : IDL.Vec(DependencyV2),
261
263
  'repository' : IDL.Text,
262
264
  'dependencies' : IDL.Vec(DependencyV2),
265
+ 'requirements' : IDL.Opt(IDL.Vec(Requirement)),
263
266
  'license' : IDL.Text,
264
267
  'readme' : IDL.Text,
265
268
  });
@@ -379,7 +382,7 @@ export const idlFactory = ({ IDL }) => {
379
382
  [Result_3],
380
383
  [],
381
384
  ),
382
- 'startPublish' : IDL.Func([PackageConfigV2], [Result_2], []),
385
+ 'startPublish' : IDL.Func([PackageConfigV3_Publishing], [Result_2], []),
383
386
  'transferOwnership' : IDL.Func(
384
387
  [PackageName, IDL.Principal],
385
388
  [Result_1],
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/dist/api/index.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import '../cli.js';
2
+ export {};
package/dist/bin/mops.js CHANGED
@@ -1,2 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import '../cli.js';
2
+
3
+ import '../cli.js';
File without changes
@@ -1,5 +1,7 @@
1
1
  import { readFileSync, writeFileSync } from 'node:fs';
2
2
  let packageJson = JSON.parse(readFileSync('./bundle/package.json', 'utf8'));
3
+ packageJson.bin.mops = 'bin/mops.js';
4
+ packageJson.bin['ic-mops'] = 'bin/mops.js';
3
5
  delete packageJson.scripts;
4
6
  delete packageJson.devDependencies;
5
7
  delete packageJson.overrides;
package/dist/cache.d.ts CHANGED
File without changes
package/dist/cache.js CHANGED
File without changes
@@ -0,0 +1,3 @@
1
+ export declare function checkRequirements({ verbose }?: {
2
+ verbose?: boolean | undefined;
3
+ }): Promise<void>;
@@ -0,0 +1,44 @@
1
+ import path from 'node:path';
2
+ import { SemVer } from 'semver';
3
+ import chalk from 'chalk';
4
+ import { getDependencyType, readConfig } from './mops.js';
5
+ import { resolvePackages } from './resolve-packages.js';
6
+ import { getMocVersion } from './helpers/get-moc-version.js';
7
+ export async function checkRequirements({ verbose = false } = {}) {
8
+ let config = readConfig();
9
+ let mocVersion = config.toolchain?.moc;
10
+ if (!mocVersion) {
11
+ mocVersion = getMocVersion();
12
+ }
13
+ if (!mocVersion) {
14
+ return;
15
+ }
16
+ let installedMoc = new SemVer(mocVersion);
17
+ let highestRequiredMoc = new SemVer('0.0.0');
18
+ let highestRequiredMocPkgId = '';
19
+ let resolvedPackages = await resolvePackages();
20
+ for (let [name, version] of Object.entries(resolvedPackages)) {
21
+ if (getDependencyType(version) === 'mops') {
22
+ let pkgId = `${name}@${version}`;
23
+ let depConfig = readConfig(path.join('.mops', pkgId, 'mops.toml'));
24
+ let moc = depConfig.requirements?.moc;
25
+ if (moc) {
26
+ let requiredMoc = new SemVer(moc);
27
+ if (highestRequiredMoc.compare(requiredMoc) < 0) {
28
+ highestRequiredMoc = requiredMoc;
29
+ highestRequiredMocPkgId = pkgId;
30
+ }
31
+ verbose && _check(pkgId, installedMoc, requiredMoc);
32
+ }
33
+ }
34
+ }
35
+ verbose || _check(highestRequiredMocPkgId, installedMoc, highestRequiredMoc);
36
+ }
37
+ function _check(pkgId, installedMoc, requiredMoc) {
38
+ let comp = installedMoc.compare(requiredMoc);
39
+ if (comp < 0) {
40
+ console.log(chalk.yellow(`moc version does not meet the requirements of ${pkgId}`));
41
+ console.log(chalk.yellow(` Required: >= ${requiredMoc.format()}`));
42
+ console.log(chalk.yellow(` Installed: ${installedMoc.format()}`));
43
+ }
44
+ }
package/dist/cli.d.ts CHANGED
File without changes
package/dist/cli.js CHANGED
@@ -5,7 +5,7 @@ import { init } from './commands/init.js';
5
5
  import { publish } from './commands/publish.js';
6
6
  import { importPem } from './commands/import-identity.js';
7
7
  import { sources } from './commands/sources.js';
8
- import { checkApiCompatibility, setNetwork, apiVersion, checkConfigFile, getNetworkFile } from './mops.js';
8
+ import { checkApiCompatibility, setNetwork, apiVersion, checkConfigFile, getNetworkFile, version } from './mops.js';
9
9
  import { getNetwork } from './api/network.js';
10
10
  import { whoami } from './commands/whoami.js';
11
11
  import { installAll } from './commands/install-all.js';
@@ -14,7 +14,6 @@ import { add } from './commands/add.js';
14
14
  import { cacheSize, cleanCache } from './cache.js';
15
15
  import { test } from './commands/test/test.js';
16
16
  import { template } from './commands/template.js';
17
- import { selfUpdate } from './commands/self-update.js';
18
17
  import { remove } from './commands/remove.js';
19
18
  import { getUserProp, setUserProp } from './commands/user.js';
20
19
  import { bump } from './commands/bump.js';
@@ -24,6 +23,7 @@ import { update } from './commands/update.js';
24
23
  import { bench } from './commands/bench.js';
25
24
  import { transferOwnership } from './commands/transfer-ownership.js';
26
25
  import { toolchain } from './commands/toolchain/index.js';
26
+ import * as self from './commands/self.js';
27
27
  let networkFile = getNetworkFile();
28
28
  if (fs.existsSync(networkFile)) {
29
29
  globalThis.MOPS_NETWORK = fs.readFileSync(networkFile).toString() || 'ic';
@@ -31,8 +31,7 @@ if (fs.existsSync(networkFile)) {
31
31
  let program = new Command();
32
32
  program.name('mops');
33
33
  // --version
34
- let packageJson = JSON.parse(fs.readFileSync(new URL('package.json', import.meta.url)).toString());
35
- program.version(`CLI ${packageJson.version}\nAPI ${apiVersion}`, '-v --version');
34
+ program.version(`CLI ${version()}\nAPI ${apiVersion}`, '-v --version');
36
35
  // init
37
36
  program
38
37
  .command('init')
@@ -225,20 +224,6 @@ program
225
224
  // }
226
225
  // await docs();
227
226
  // });
228
- // self update
229
- program
230
- .command('self-update')
231
- .description('Update mops CLI to the latest version')
232
- .option('--detached')
233
- .option('--force')
234
- .action(async (options) => {
235
- if (options.force) {
236
- selfUpdate(options);
237
- }
238
- else {
239
- console.log('Please run \'npm i -g ic-mops\'');
240
- }
241
- });
242
227
  // user
243
228
  program
244
229
  .command('user')
@@ -340,4 +325,19 @@ toolchainCommand
340
325
  console.log(bin);
341
326
  });
342
327
  program.addCommand(toolchainCommand);
328
+ // self
329
+ const selfCommand = new Command('self').description('Mops CLI management');
330
+ selfCommand
331
+ .command('update')
332
+ .description('Update mops CLI to the latest version')
333
+ .action(async () => {
334
+ await self.update();
335
+ });
336
+ selfCommand
337
+ .command('uninstall')
338
+ .description('Uninstall mops CLI')
339
+ .action(async () => {
340
+ await self.uninstall();
341
+ });
342
+ program.addCommand(selfCommand);
343
343
  program.parse();
File without changes
@@ -7,6 +7,7 @@ import { installFromGithub } from '../vessel.js';
7
7
  import { install } from './install.js';
8
8
  import { notifyInstalls } from '../notify-installs.js';
9
9
  import { checkIntegrity } from '../integrity.js';
10
+ import { checkRequirements } from '../check-requirements.js';
10
11
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
11
12
  export async function add(name, { verbose = false, dev = false, lock } = {}, asName) {
12
13
  if (!checkConfigFile()) {
@@ -100,5 +101,6 @@ export async function add(name, { verbose = false, dev = false, lock } = {}, asN
100
101
  checkIntegrity(lock),
101
102
  ]);
102
103
  logUpdate.clear();
104
+ await checkRequirements({ verbose });
103
105
  console.log(chalk.green('Package installed ') + `${pkgDetails.name} = "${pkgDetails.repo || pkgDetails.path || pkgDetails.version}"`);
104
106
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes