ic-mops 0.41.0 → 0.42.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 (128) hide show
  1. package/.DS_Store +0 -0
  2. package/CHANGELOG.md +12 -0
  3. package/api/actors.ts +2 -3
  4. package/bundle/bin/mops.js +0 -0
  5. package/bundle/cli.js +29 -29
  6. package/bundle/cli.tgz +0 -0
  7. package/bundle/declarations/bench/bench.did.d.ts +1 -1
  8. package/bundle/declarations/bench/index.js +0 -9
  9. package/bundle/declarations/main/index.js +1 -2
  10. package/bundle/declarations/main/main.did +15 -8
  11. package/bundle/declarations/main/main.did.d.ts +12 -9
  12. package/bundle/declarations/main/main.did.js +11 -8
  13. package/bundle/declarations/storage/storage.did.d.ts +3 -0
  14. package/bundle/package.json +2 -2
  15. package/bundle-package-json.ts +3 -0
  16. package/cache.ts +25 -7
  17. package/check-requirements.ts +50 -0
  18. package/cli.ts +3 -2
  19. package/commands/add.ts +13 -7
  20. package/commands/available-updates.ts +1 -0
  21. package/commands/bench-replica.ts +1 -0
  22. package/commands/bench.ts +1 -0
  23. package/commands/bump.ts +1 -0
  24. package/commands/docs.ts +1 -0
  25. package/commands/import-identity.ts +1 -0
  26. package/commands/init.ts +2 -1
  27. package/commands/install/install-all.ts +51 -0
  28. package/commands/install/install-dep.ts +34 -0
  29. package/commands/install/install-deps.ts +31 -0
  30. package/commands/install/install-local-dep.ts +31 -0
  31. package/commands/{install.ts → install/install-mops-dep.ts} +43 -43
  32. package/commands/install/sync-local-cache.ts +34 -0
  33. package/commands/publish.ts +18 -3
  34. package/commands/remove.ts +15 -18
  35. package/commands/search.ts +1 -0
  36. package/commands/self.ts +1 -0
  37. package/commands/sources.ts +1 -0
  38. package/commands/sync.ts +1 -0
  39. package/commands/test/test.ts +1 -0
  40. package/commands/toolchain/index.ts +8 -0
  41. package/commands/toolchain/moc.ts +1 -0
  42. package/commands/toolchain/pocket-ic.ts +1 -0
  43. package/commands/toolchain/toolchain-utils.ts +2 -0
  44. package/commands/toolchain/wasmtime.ts +1 -0
  45. package/commands/transfer-ownership.ts +1 -0
  46. package/commands/user.ts +1 -0
  47. package/declarations/bench/bench.did.d.ts +1 -1
  48. package/declarations/bench/index.js +0 -9
  49. package/declarations/main/index.js +1 -2
  50. package/declarations/main/main.did +15 -8
  51. package/declarations/main/main.did.d.ts +12 -9
  52. package/declarations/main/main.did.js +11 -8
  53. package/declarations/storage/storage.did.d.ts +3 -0
  54. package/dist/api/actors.js +2 -2
  55. package/dist/bin/mops.js +0 -0
  56. package/dist/bundle-package-json.js +2 -0
  57. package/dist/cache.d.ts +7 -3
  58. package/dist/cache.js +21 -7
  59. package/dist/check-requirements.js +9 -4
  60. package/dist/cli.js +3 -2
  61. package/dist/commands/add.js +9 -6
  62. package/dist/commands/available-updates.js +1 -0
  63. package/dist/commands/bench-replica.js +1 -0
  64. package/dist/commands/bench.js +1 -0
  65. package/dist/commands/bump.js +1 -0
  66. package/dist/commands/docs.js +1 -0
  67. package/dist/commands/import-identity.js +1 -0
  68. package/dist/commands/init.js +2 -1
  69. package/dist/commands/install/install-all.d.ts +8 -0
  70. package/dist/commands/install/install-all.js +36 -0
  71. package/dist/commands/install/install-dep.d.ts +8 -0
  72. package/dist/commands/install/install-dep.js +25 -0
  73. package/dist/commands/install/install-deps.d.ts +8 -0
  74. package/dist/commands/install/install-deps.js +21 -0
  75. package/dist/commands/install/install-local-dep.d.ts +6 -0
  76. package/dist/commands/install/install-local-dep.js +23 -0
  77. package/dist/commands/install/install-mops-dep.d.ts +8 -0
  78. package/dist/commands/install/install-mops-dep.js +103 -0
  79. package/dist/commands/install/sync-local-cache.d.ts +3 -0
  80. package/dist/commands/install/sync-local-cache.js +26 -0
  81. package/dist/commands/install-all.js +2 -0
  82. package/dist/commands/publish.js +14 -1
  83. package/dist/commands/remove.js +15 -18
  84. package/dist/commands/search.js +1 -0
  85. package/dist/commands/self.js +1 -0
  86. package/dist/commands/sources.js +1 -0
  87. package/dist/commands/sync.js +1 -0
  88. package/dist/commands/test/test.js +1 -0
  89. package/dist/commands/toolchain/index.js +6 -0
  90. package/dist/commands/toolchain/moc.js +1 -0
  91. package/dist/commands/toolchain/pocket-ic.js +1 -0
  92. package/dist/commands/toolchain/toolchain-utils.js +2 -0
  93. package/dist/commands/toolchain/wasmtime.js +1 -0
  94. package/dist/commands/transfer-ownership.js +1 -0
  95. package/dist/commands/user.js +1 -0
  96. package/dist/declarations/bench/bench.did.d.ts +1 -1
  97. package/dist/declarations/bench/index.js +0 -9
  98. package/dist/declarations/main/index.js +1 -2
  99. package/dist/declarations/main/main.did +15 -8
  100. package/dist/declarations/main/main.did.d.ts +12 -9
  101. package/dist/declarations/main/main.did.js +11 -8
  102. package/dist/declarations/storage/storage.did.d.ts +3 -0
  103. package/dist/fix-dist.d.ts +1 -0
  104. package/dist/fix-dist.js +9 -0
  105. package/dist/helpers/get-moc-path.js +1 -0
  106. package/dist/integrity.js +1 -0
  107. package/dist/mops.js +11 -3
  108. package/dist/notify-installs.d.ts +1 -1
  109. package/dist/notify-installs.js +8 -5
  110. package/dist/package.json +3 -3
  111. package/dist/pem.d.ts +1 -0
  112. package/dist/pem.js +2 -1
  113. package/dist/resolve-packages.js +11 -9
  114. package/dist/types.d.ts +4 -0
  115. package/dist/vessel.js +10 -12
  116. package/{remove-scripts.ts → fix-dist.ts} +6 -0
  117. package/helpers/get-moc-path.ts +1 -0
  118. package/integrity.ts +1 -0
  119. package/mops.ts +13 -3
  120. package/notify-installs.ts +9 -5
  121. package/package.json +7 -7
  122. package/pem.ts +2 -1
  123. package/resolve-packages.ts +11 -9
  124. package/tsconfig.json +1 -0
  125. package/types.ts +7 -2
  126. package/vessel.ts +11 -13
  127. package/commands/install-all.ts +0 -56
  128. package/commands/install-local.ts +0 -52
package/bundle/cli.tgz CHANGED
Binary file
@@ -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[];
@@ -4,15 +4,6 @@ import { Actor, HttpAgent } from "@dfinity/agent";
4
4
  import { idlFactory } from "./bench.did.js";
5
5
  export { idlFactory } from "./bench.did.js";
6
6
 
7
- /* CANISTER_ID is replaced by webpack based on node environment
8
- * Note: canister environment variable will be standardized as
9
- * process.env.CANISTER_ID_<CANISTER_NAME_UPPERCASE>
10
- * beginning in dfx 0.15.0
11
- */
12
- export const canisterId =
13
- process.env.CANISTER_ID_BENCH ||
14
- process.env.BENCH_CANISTER_ID;
15
-
16
7
  export const createActor = (canisterId, options = {}) => {
17
8
  const agent = options.agent || new HttpAgent({ ...options.agentOptions });
18
9
 
@@ -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],
@@ -1,5 +1,6 @@
1
1
  import type { Principal } from '@dfinity/principal';
2
2
  import type { ActorMethod } from '@dfinity/agent';
3
+ import type { IDL } from '@dfinity/candid';
3
4
 
4
5
  export type Chunk = Array<number>;
5
6
  export type Err = string;
@@ -35,3 +36,5 @@ export interface StorageStats {
35
36
  'memorySize' : bigint,
36
37
  }
37
38
  export interface _SERVICE extends Storage {}
39
+ export declare const idlFactory: IDL.InterfaceFactory;
40
+ export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ic-mops",
3
- "version": "0.41.0",
3
+ "version": "0.42.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mops": "bin/mops.js",
@@ -24,7 +24,7 @@
24
24
  "node": ">=18.0.0"
25
25
  },
26
26
  "dependencies": {
27
- "dhall-to-json-cli": "^1.7.6",
27
+ "dhall-to-json-cli": "1.7.6",
28
28
  "decomp-tarxz": "0.1.1",
29
29
  "buffer": "6.0.3"
30
30
  }
@@ -2,6 +2,9 @@ import {readFileSync, writeFileSync} from 'node:fs';
2
2
 
3
3
  let packageJson = JSON.parse(readFileSync('./bundle/package.json', 'utf8'));
4
4
 
5
+ packageJson.bin.mops = 'bin/mops.js';
6
+ packageJson.bin['ic-mops'] = 'bin/mops.js';
7
+
5
8
  delete packageJson.scripts;
6
9
  delete packageJson.devDependencies;
7
10
  delete packageJson.overrides;
package/cache.ts CHANGED
@@ -3,15 +3,33 @@ import path from 'node:path';
3
3
  import ncp from 'ncp';
4
4
  import getFolderSize from 'get-folder-size';
5
5
 
6
- import {globalCacheDir} from './mops.js';
6
+ import {getDependencyType, globalCacheDir, parseGithubURL} from './mops.js';
7
7
 
8
- export let isCached = (pkgId : string) => {
9
- let dir = path.join(globalCacheDir, 'packages', pkgId);
8
+ export let getDepCacheDir = (cacheName : string) => {
9
+ return path.join(globalCacheDir, 'packages', cacheName);
10
+ };
11
+
12
+ export let isDepCached = (cacheName : string) => {
13
+ let dir = getDepCacheDir(cacheName);
10
14
  return fs.existsSync(dir);
11
15
  };
12
16
 
13
- export let addCache = (pkgId : string, source : string) => {
14
- let dest = path.join(globalCacheDir, 'packages', pkgId);
17
+ export function getDepCacheName(name : string, version : string) {
18
+ let depType = getDependencyType(version);
19
+ return depType === 'mops' ? getMopsDepCacheName(name, version) : getGithubDepCacheName(name, version);
20
+ }
21
+
22
+ export function getMopsDepCacheName(name : string, version : string) {
23
+ return `${name}@${version}`;
24
+ }
25
+
26
+ export function getGithubDepCacheName(name : string, repo : string) {
27
+ const {branch, commitHash} = parseGithubURL(repo);
28
+ return `_github/${name}#${branch}` + (commitHash ? `@${commitHash}` : '');
29
+ }
30
+
31
+ export let addCache = (cacheName : string, source : string) => {
32
+ let dest = path.join(globalCacheDir, 'packages', cacheName);
15
33
  fs.mkdirSync(dest, {recursive: true});
16
34
 
17
35
  return new Promise<void>((resolve, reject) => {
@@ -24,8 +42,8 @@ export let addCache = (pkgId : string, source : string) => {
24
42
  });
25
43
  };
26
44
 
27
- export let copyCache = (pkgId : string, dest : string) => {
28
- let source = path.join(globalCacheDir, 'packages', pkgId);
45
+ export let copyCache = (cacheName : string, dest : string) => {
46
+ let source = path.join(globalCacheDir, 'packages', cacheName);
29
47
  fs.mkdirSync(dest, {recursive: true});
30
48
 
31
49
  return new Promise<void>((resolve, reject) => {
@@ -0,0 +1,50 @@
1
+ import path from 'node:path';
2
+ import {SemVer} from 'semver';
3
+ import chalk from 'chalk';
4
+
5
+ import {getDependencyType, readConfig} from './mops.js';
6
+ import {resolvePackages} from './resolve-packages.js';
7
+ import {getMocVersion} from './helpers/get-moc-version.js';
8
+
9
+ export async function checkRequirements({verbose = false} = {}) {
10
+ let config = readConfig();
11
+ let mocVersion = config.toolchain?.moc;
12
+ if (!mocVersion) {
13
+ mocVersion = getMocVersion();
14
+ }
15
+ if (!mocVersion) {
16
+ return;
17
+ }
18
+ let installedMoc = new SemVer(mocVersion);
19
+ let highestRequiredMoc = new SemVer('0.0.0');
20
+ let highestRequiredMocPkgId = '';
21
+
22
+ let resolvedPackages = await resolvePackages();
23
+ for (let [name, version] of Object.entries(resolvedPackages)) {
24
+ if (getDependencyType(version) === 'mops') {
25
+ let pkgId = `${name}@${version}`;
26
+ let depConfig = readConfig(path.join('.mops', pkgId, 'mops.toml'));
27
+ let moc = depConfig.requirements?.moc;
28
+
29
+ if (moc) {
30
+ let requiredMoc = new SemVer(moc);
31
+ if (highestRequiredMoc.compare(requiredMoc) < 0) {
32
+ highestRequiredMoc = requiredMoc;
33
+ highestRequiredMocPkgId = pkgId;
34
+ }
35
+ verbose && _check(pkgId, installedMoc, requiredMoc);
36
+ }
37
+ }
38
+ }
39
+
40
+ verbose || _check(highestRequiredMocPkgId, installedMoc, highestRequiredMoc);
41
+ }
42
+
43
+ function _check(pkgId : string, installedMoc : SemVer, requiredMoc : SemVer) {
44
+ let comp = installedMoc.compare(requiredMoc);
45
+ if (comp < 0) {
46
+ console.log(chalk.yellow(`moc version does not meet the requirements of ${pkgId}`));
47
+ console.log(chalk.yellow(` Required: >= ${requiredMoc.format()}`));
48
+ console.log(chalk.yellow(` Installed: ${installedMoc.format()}`));
49
+ }
50
+ }
package/cli.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import process from 'node:process';
1
2
  import fs from 'node:fs';
2
3
  import {Command, Argument, Option} from 'commander';
3
4
  import chalk from 'chalk';
@@ -9,7 +10,7 @@ import {sources} from './commands/sources.js';
9
10
  import {checkApiCompatibility, setNetwork, apiVersion, checkConfigFile, getNetworkFile, version} from './mops.js';
10
11
  import {getNetwork} from './api/network.js';
11
12
  import {whoami} from './commands/whoami.js';
12
- import {installAll} from './commands/install-all.js';
13
+ import {installAll} from './commands/install/install-all.js';
13
14
  import {search} from './commands/search.js';
14
15
  import {add} from './commands/add.js';
15
16
  import {cacheSize, cleanCache} from './cache.js';
@@ -169,7 +170,7 @@ program
169
170
  if (!checkConfigFile()) {
170
171
  process.exit(1);
171
172
  }
172
- await installAll({silent: true, lock: 'ignore'});
173
+ await installAll({silent: true, lock: 'ignore', threads: 6});
173
174
  await toolchain.ensureToolchainInited({strict: false});
174
175
  let sourcesArr = await sources(options);
175
176
  console.log(sourcesArr.join('\n'));
package/commands/add.ts CHANGED
@@ -1,12 +1,15 @@
1
+ import process from 'node:process';
1
2
  import path from 'node:path';
2
3
  import chalk from 'chalk';
3
4
  import {createLogUpdate} from 'log-update';
4
5
  import {checkConfigFile, getGithubCommit, parseGithubURL, readConfig, writeConfig} from '../mops.js';
5
6
  import {getHighestVersion} from '../api/getHighestVersion.js';
7
+ import {installMopsDep} from './install/install-mops-dep.js';
6
8
  import {installFromGithub} from '../vessel.js';
7
- import {install} from './install.js';
8
- import {notifyInstalls} from '../notify-installs.js';
9
9
  import {checkIntegrity} from '../integrity.js';
10
+ import {checkRequirements} from '../check-requirements.js';
11
+ import {syncLocalCache} from './install/sync-local-cache.js';
12
+ import {notifyInstalls} from '../notify-installs.js';
10
13
 
11
14
  type AddOptions = {
12
15
  verbose ?: boolean;
@@ -85,17 +88,14 @@ export async function add(name : string, {verbose = false, dev = false, lock} :
85
88
  };
86
89
  }
87
90
 
88
- let installedPackages = {};
89
-
90
91
  if (pkgDetails.repo) {
91
92
  await installFromGithub(pkgDetails.name, pkgDetails.repo, {verbose: verbose});
92
93
  }
93
94
  else if (!pkgDetails.path) {
94
- let res = await install(pkgDetails.name, pkgDetails.version, {verbose: verbose});
95
+ let res = await installMopsDep(pkgDetails.name, pkgDetails.version, {verbose: verbose});
95
96
  if (res === false) {
96
97
  return;
97
98
  }
98
- installedPackages = {...installedPackages, ...res};
99
99
  }
100
100
 
101
101
  const depsProp = dev ? 'dev-dependencies' : 'dependencies';
@@ -114,11 +114,17 @@ export async function add(name : string, {verbose = false, dev = false, lock} :
114
114
  if (lock !== 'ignore') {
115
115
  logUpdate('Checking integrity...');
116
116
  }
117
+
118
+ let installedPackages = await syncLocalCache();
119
+
117
120
  await Promise.all([
118
- notifyInstalls(Object.keys(installedPackages)),
121
+ notifyInstalls(installedPackages),
119
122
  checkIntegrity(lock),
120
123
  ]);
121
124
 
122
125
  logUpdate.clear();
126
+
127
+ await checkRequirements({verbose});
128
+
123
129
  console.log(chalk.green('Package installed ') + `${pkgDetails.name} = "${pkgDetails.repo || pkgDetails.path || pkgDetails.version}"`);
124
130
  }
@@ -1,3 +1,4 @@
1
+ import process from 'node:process';
1
2
  import chalk from 'chalk';
2
3
  import {mainActor} from '../api/actors.js';
3
4
  import {Config} from '../types.js';
@@ -1,3 +1,4 @@
1
+ import process from 'node:process';
1
2
  import {execSync} from 'node:child_process';
2
3
  import path from 'node:path';
3
4
  import fs from 'node:fs';
package/commands/bench.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import process from 'node:process';
1
2
  import path from 'node:path';
2
3
  import fs from 'node:fs';
3
4
  import os from 'node:os';
package/commands/bump.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import process from 'node:process';
1
2
  import prompts from 'prompts';
2
3
  import chalk from 'chalk';
3
4
  import {checkConfigFile, readConfig, writeConfig} from '../mops.js';
package/commands/docs.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import process from 'node:process';
1
2
  import {spawn} from 'node:child_process';
2
3
  import fs from 'node:fs';
3
4
  import path from 'node:path';
@@ -1,5 +1,6 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
+ import {Buffer} from 'node:buffer';
3
4
  import chalk from 'chalk';
4
5
  import prompts from 'prompts';
5
6
  import {deleteSync} from 'del';
package/commands/init.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import process from 'node:process';
1
2
  import {execSync} from 'node:child_process';
2
3
  import path from 'node:path';
3
4
  import {existsSync, readFileSync, writeFileSync} from 'node:fs';
@@ -6,7 +7,7 @@ import prompts from 'prompts';
6
7
 
7
8
  import {checkApiCompatibility, writeConfig} from '../mops.js';
8
9
  import {mainActor} from '../api/actors.js';
9
- import {installAll} from './install-all.js';
10
+ import {installAll} from './install/install-all.js';
10
11
  import {VesselConfig, readVesselConfig} from '../vessel.js';
11
12
  import {Config, Dependencies} from '../types.js';
12
13
  import {template} from './template.js';
@@ -0,0 +1,51 @@
1
+ import process from 'node:process';
2
+ import chalk from 'chalk';
3
+ import {createLogUpdate} from 'log-update';
4
+ import {checkConfigFile, readConfig} from '../../mops.js';
5
+ import {checkIntegrity} from '../../integrity.js';
6
+ import {installDeps} from './install-deps.js';
7
+ import {checkRequirements} from '../../check-requirements.js';
8
+ import {syncLocalCache} from './sync-local-cache.js';
9
+ import {notifyInstalls} from '../../notify-installs.js';
10
+
11
+ type InstallAllOptions = {
12
+ verbose ?: boolean;
13
+ silent ?: boolean;
14
+ lock ?: 'check' | 'update' | 'ignore';
15
+ threads ?: number;
16
+ }
17
+
18
+ export async function installAll({verbose = false, silent = false, threads, lock} : InstallAllOptions = {}) {
19
+ if (!checkConfigFile()) {
20
+ return;
21
+ }
22
+
23
+ let config = readConfig();
24
+ let deps = Object.values(config.dependencies || {});
25
+ let devDeps = Object.values(config['dev-dependencies'] || {});
26
+ let allDeps = [...deps, ...devDeps];
27
+
28
+ let res = await installDeps(allDeps, {silent, verbose, threads});
29
+ if (!res) {
30
+ return;
31
+ }
32
+
33
+ let logUpdate = createLogUpdate(process.stdout, {showCursor: true});
34
+
35
+ if (!silent && lock !== 'ignore') {
36
+ logUpdate('Checking integrity...');
37
+ }
38
+
39
+ let installedPackages = await syncLocalCache();
40
+
41
+ await Promise.all([
42
+ notifyInstalls(installedPackages),
43
+ checkIntegrity(lock),
44
+ ]);
45
+
46
+ if (!silent) {
47
+ logUpdate.clear();
48
+ await checkRequirements();
49
+ console.log(chalk.green('Packages installed'));
50
+ }
51
+ }