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
@@ -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
  import { Actor, HttpAgent } from '@dfinity/agent';
2
- import { idlFactory } from '../declarations/main/index.js';
3
- import { idlFactory as storageIdlFactory } from '../declarations/storage/index.js';
2
+ import { idlFactory } from '../declarations/main/main.did.js';
3
+ import { idlFactory as storageIdlFactory } from '../declarations/storage/storage.did.js';
4
4
  import { getEndpoint } from './network.js';
5
5
  import { getNetwork } from './network.js';
6
6
  export let mainActor = async (identity) => {
package/dist/bin/mops.js CHANGED
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
@@ -1,5 +1,9 @@
1
- export declare let isCached: (pkgId: string) => boolean;
2
- export declare let addCache: (pkgId: string, source: string) => Promise<void>;
3
- export declare let copyCache: (pkgId: string, dest: string) => Promise<void>;
1
+ export declare let getDepCacheDir: (cacheName: string) => string;
2
+ export declare let isDepCached: (cacheName: string) => boolean;
3
+ export declare function getDepCacheName(name: string, version: string): string;
4
+ export declare function getMopsDepCacheName(name: string, version: string): string;
5
+ export declare function getGithubDepCacheName(name: string, repo: string): string;
6
+ export declare let addCache: (cacheName: string, source: string) => Promise<void>;
7
+ export declare let copyCache: (cacheName: string, dest: string) => Promise<void>;
4
8
  export declare let cacheSize: () => Promise<string>;
5
9
  export declare let cleanCache: () => Promise<void>;
package/dist/cache.js CHANGED
@@ -2,13 +2,27 @@ import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import ncp from 'ncp';
4
4
  import getFolderSize from 'get-folder-size';
5
- import { globalCacheDir } from './mops.js';
6
- export let isCached = (pkgId) => {
7
- let dir = path.join(globalCacheDir, 'packages', pkgId);
5
+ import { getDependencyType, globalCacheDir, parseGithubURL } from './mops.js';
6
+ export let getDepCacheDir = (cacheName) => {
7
+ return path.join(globalCacheDir, 'packages', cacheName);
8
+ };
9
+ export let isDepCached = (cacheName) => {
10
+ let dir = getDepCacheDir(cacheName);
8
11
  return fs.existsSync(dir);
9
12
  };
10
- export let addCache = (pkgId, source) => {
11
- let dest = path.join(globalCacheDir, 'packages', pkgId);
13
+ export function getDepCacheName(name, version) {
14
+ let depType = getDependencyType(version);
15
+ return depType === 'mops' ? getMopsDepCacheName(name, version) : getGithubDepCacheName(name, version);
16
+ }
17
+ export function getMopsDepCacheName(name, version) {
18
+ return `${name}@${version}`;
19
+ }
20
+ export function getGithubDepCacheName(name, repo) {
21
+ const { branch, commitHash } = parseGithubURL(repo);
22
+ return `_github/${name}#${branch}` + (commitHash ? `@${commitHash}` : '');
23
+ }
24
+ export let addCache = (cacheName, source) => {
25
+ let dest = path.join(globalCacheDir, 'packages', cacheName);
12
26
  fs.mkdirSync(dest, { recursive: true });
13
27
  return new Promise((resolve, reject) => {
14
28
  ncp.ncp(source, dest, { stopOnErr: true }, (err) => {
@@ -19,8 +33,8 @@ export let addCache = (pkgId, source) => {
19
33
  });
20
34
  });
21
35
  };
22
- export let copyCache = (pkgId, dest) => {
23
- let source = path.join(globalCacheDir, 'packages', pkgId);
36
+ export let copyCache = (cacheName, dest) => {
37
+ let source = path.join(globalCacheDir, 'packages', cacheName);
24
38
  fs.mkdirSync(dest, { recursive: true });
25
39
  return new Promise((resolve, reject) => {
26
40
  ncp.ncp(source, dest, { stopOnErr: true }, (err) => {
@@ -1,14 +1,19 @@
1
1
  import path from 'node:path';
2
- import { getDependencyType, readConfig } from './mops.js';
3
- import { resolvePackages } from './resolve-packages.js';
4
2
  import { SemVer } from 'semver';
5
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';
6
7
  export async function checkRequirements({ verbose = false } = {}) {
7
8
  let config = readConfig();
8
- if (!config.toolchain?.moc) {
9
+ let mocVersion = config.toolchain?.moc;
10
+ if (!mocVersion) {
11
+ mocVersion = getMocVersion();
12
+ }
13
+ if (!mocVersion) {
9
14
  return;
10
15
  }
11
- let installedMoc = new SemVer(config.toolchain.moc);
16
+ let installedMoc = new SemVer(mocVersion);
12
17
  let highestRequiredMoc = new SemVer('0.0.0');
13
18
  let highestRequiredMocPkgId = '';
14
19
  let resolvedPackages = await resolvePackages();
package/dist/cli.js 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';
@@ -8,7 +9,7 @@ import { sources } from './commands/sources.js';
8
9
  import { checkApiCompatibility, setNetwork, apiVersion, checkConfigFile, getNetworkFile, version } from './mops.js';
9
10
  import { getNetwork } from './api/network.js';
10
11
  import { whoami } from './commands/whoami.js';
11
- import { installAll } from './commands/install-all.js';
12
+ import { installAll } from './commands/install/install-all.js';
12
13
  import { search } from './commands/search.js';
13
14
  import { add } from './commands/add.js';
14
15
  import { cacheSize, cleanCache } from './cache.js';
@@ -145,7 +146,7 @@ program
145
146
  if (!checkConfigFile()) {
146
147
  process.exit(1);
147
148
  }
148
- await installAll({ silent: true, lock: 'ignore' });
149
+ await installAll({ silent: true, lock: 'ignore', threads: 6 });
149
150
  await toolchain.ensureToolchainInited({ strict: false });
150
151
  let sourcesArr = await sources(options);
151
152
  console.log(sourcesArr.join('\n'));
@@ -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
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
11
14
  export async function add(name, { verbose = false, dev = false, lock } = {}, asName) {
12
15
  if (!checkConfigFile()) {
@@ -71,16 +74,14 @@ export async function add(name, { verbose = false, dev = false, lock } = {}, asN
71
74
  version: ver,
72
75
  };
73
76
  }
74
- let installedPackages = {};
75
77
  if (pkgDetails.repo) {
76
78
  await installFromGithub(pkgDetails.name, pkgDetails.repo, { verbose: verbose });
77
79
  }
78
80
  else if (!pkgDetails.path) {
79
- let res = await install(pkgDetails.name, pkgDetails.version, { verbose: verbose });
81
+ let res = await installMopsDep(pkgDetails.name, pkgDetails.version, { verbose: verbose });
80
82
  if (res === false) {
81
83
  return;
82
84
  }
83
- installedPackages = { ...installedPackages, ...res };
84
85
  }
85
86
  const depsProp = dev ? 'dev-dependencies' : 'dependencies';
86
87
  let deps = config[depsProp];
@@ -95,10 +96,12 @@ export async function add(name, { verbose = false, dev = false, lock } = {}, asN
95
96
  if (lock !== 'ignore') {
96
97
  logUpdate('Checking integrity...');
97
98
  }
99
+ let installedPackages = await syncLocalCache();
98
100
  await Promise.all([
99
- notifyInstalls(Object.keys(installedPackages)),
101
+ notifyInstalls(installedPackages),
100
102
  checkIntegrity(lock),
101
103
  ]);
102
104
  logUpdate.clear();
105
+ await checkRequirements({ verbose });
103
106
  console.log(chalk.green('Package installed ') + `${pkgDetails.name} = "${pkgDetails.repo || pkgDetails.path || pkgDetails.version}"`);
104
107
  }
@@ -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
  // [pkg, oldVersion, newVersion]
@@ -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';
@@ -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';
@@ -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';
@@ -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';
@@ -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';
@@ -5,7 +6,7 @@ import chalk from 'chalk';
5
6
  import prompts from 'prompts';
6
7
  import { checkApiCompatibility, writeConfig } from '../mops.js';
7
8
  import { mainActor } from '../api/actors.js';
8
- import { installAll } from './install-all.js';
9
+ import { installAll } from './install/install-all.js';
9
10
  import { readVesselConfig } from '../vessel.js';
10
11
  import { template } from './template.js';
11
12
  export async function init({ yes = false } = {}) {
@@ -0,0 +1,8 @@
1
+ type InstallAllOptions = {
2
+ verbose?: boolean;
3
+ silent?: boolean;
4
+ lock?: 'check' | 'update' | 'ignore';
5
+ threads?: number;
6
+ };
7
+ export declare function installAll({ verbose, silent, threads, lock }?: InstallAllOptions): Promise<void>;
8
+ export {};
@@ -0,0 +1,36 @@
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
+ export async function installAll({ verbose = false, silent = false, threads, lock } = {}) {
11
+ if (!checkConfigFile()) {
12
+ return;
13
+ }
14
+ let config = readConfig();
15
+ let deps = Object.values(config.dependencies || {});
16
+ let devDeps = Object.values(config['dev-dependencies'] || {});
17
+ let allDeps = [...deps, ...devDeps];
18
+ let res = await installDeps(allDeps, { silent, verbose, threads });
19
+ if (!res) {
20
+ return;
21
+ }
22
+ let logUpdate = createLogUpdate(process.stdout, { showCursor: true });
23
+ if (!silent && lock !== 'ignore') {
24
+ logUpdate('Checking integrity...');
25
+ }
26
+ let installedPackages = await syncLocalCache();
27
+ await Promise.all([
28
+ notifyInstalls(installedPackages),
29
+ checkIntegrity(lock),
30
+ ]);
31
+ if (!silent) {
32
+ logUpdate.clear();
33
+ await checkRequirements();
34
+ console.log(chalk.green('Packages installed'));
35
+ }
36
+ }
@@ -0,0 +1,8 @@
1
+ import { Dependency } from '../../types.js';
2
+ type InstallDepOptions = {
3
+ verbose?: boolean;
4
+ silent?: boolean;
5
+ threads?: number;
6
+ };
7
+ export declare function installDep(dep: Dependency, { verbose, silent, threads }?: InstallDepOptions, parentPkgPath?: string): Promise<Record<string, string> | false>;
8
+ export {};
@@ -0,0 +1,25 @@
1
+ import path from 'node:path';
2
+ import { installFromGithub } from '../../vessel.js';
3
+ import { installMopsDep } from './install-mops-dep.js';
4
+ import { installLocalDep } from './install-local-dep.js';
5
+ import { getRootDir } from '../../mops.js';
6
+ // install dependency
7
+ // returns false if failed
8
+ export async function installDep(dep, { verbose, silent, threads } = {}, parentPkgPath) {
9
+ if (dep.repo) {
10
+ await installFromGithub(dep.name, dep.repo, { silent, verbose });
11
+ return {};
12
+ }
13
+ else if (dep.path) {
14
+ let depPath = dep.path;
15
+ parentPkgPath = parentPkgPath || getRootDir();
16
+ if (parentPkgPath) {
17
+ depPath = path.resolve(parentPkgPath, dep.path);
18
+ }
19
+ return installLocalDep(dep.name, depPath, { silent, verbose });
20
+ }
21
+ else if (dep.version) {
22
+ return installMopsDep(dep.name, dep.version, { silent, verbose, threads });
23
+ }
24
+ return {};
25
+ }
@@ -0,0 +1,8 @@
1
+ import { Dependency } from '../../types.js';
2
+ type InstallDepsOptions = {
3
+ verbose?: boolean;
4
+ silent?: boolean;
5
+ threads?: number;
6
+ };
7
+ export declare function installDeps(deps: Dependency[], { verbose, silent, threads }?: InstallDepsOptions, parentPkgPath?: string): Promise<Record<string, string> | false>;
8
+ export {};
@@ -0,0 +1,21 @@
1
+ import { installDep } from './install-dep.js';
2
+ // install all dependencies
3
+ // returns actual installed dependencies
4
+ // returns false if failed
5
+ export async function installDeps(deps, { verbose, silent, threads } = {}, parentPkgPath) {
6
+ let installedDeps = {};
7
+ let ok = true;
8
+ for (const dep of deps) {
9
+ let res = await installDep(dep, { verbose, silent, threads }, parentPkgPath);
10
+ if (res) {
11
+ installedDeps = { ...installedDeps, ...res };
12
+ }
13
+ else {
14
+ ok = false;
15
+ }
16
+ }
17
+ if (!ok) {
18
+ return false;
19
+ }
20
+ return installedDeps;
21
+ }
@@ -0,0 +1,6 @@
1
+ type InstallLocalDepOptions = {
2
+ verbose?: boolean;
3
+ silent?: boolean;
4
+ };
5
+ export declare function installLocalDep(pkg: string, pkgPath?: string, { verbose, silent }?: InstallLocalDepOptions): Promise<Record<string, string> | false>;
6
+ export {};
@@ -0,0 +1,23 @@
1
+ import process from 'node:process';
2
+ import path from 'node:path';
3
+ import { createLogUpdate } from 'log-update';
4
+ import { getRootDir, readConfig } from '../../mops.js';
5
+ import { installDeps } from './install-deps.js';
6
+ // skip install and just find non-local dependencies to install
7
+ // pkgPath should be relative to the current root dir or absolute
8
+ export async function installLocalDep(pkg, pkgPath = '', { verbose, silent } = {}) {
9
+ if (!silent) {
10
+ let logUpdate = createLogUpdate(process.stdout, { showCursor: true });
11
+ logUpdate(`Local dependency ${pkg} = "${pkgPath}"`);
12
+ if (verbose) {
13
+ silent || logUpdate.done();
14
+ }
15
+ else {
16
+ logUpdate.clear();
17
+ }
18
+ }
19
+ // install dependencies
20
+ let dir = path.resolve(getRootDir(), pkgPath);
21
+ let config = readConfig(path.join(dir, 'mops.toml'));
22
+ return installDeps(Object.values(config.dependencies || {}), { silent, verbose }, pkgPath);
23
+ }
@@ -0,0 +1,8 @@
1
+ type InstallMopsDepOptions = {
2
+ verbose?: boolean;
3
+ silent?: boolean;
4
+ dep?: boolean;
5
+ threads?: number;
6
+ };
7
+ export declare function installMopsDep(pkg: string, version?: string, { verbose, silent, dep, threads }?: InstallMopsDepOptions): Promise<Record<string, string> | false>;
8
+ export {};