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
@@ -0,0 +1,34 @@
1
+ import path from 'node:path';
2
+ import {installFromGithub} from '../../vessel.js';
3
+ import {installMopsDep} from './install-mops-dep.js';
4
+ import {Dependency} from '../../types.js';
5
+ import {installLocalDep} from './install-local-dep.js';
6
+ import {getRootDir} from '../../mops.js';
7
+
8
+ type InstallDepOptions = {
9
+ verbose ?: boolean;
10
+ silent ?: boolean;
11
+ threads ?: number;
12
+ };
13
+
14
+ // install dependency
15
+ // returns false if failed
16
+ export async function installDep(dep : Dependency, {verbose, silent, threads} : InstallDepOptions = {}, parentPkgPath ?: string) : Promise<Record<string, string> | false> {
17
+ if (dep.repo) {
18
+ await installFromGithub(dep.name, dep.repo, {silent, verbose});
19
+ return {};
20
+ }
21
+ else if (dep.path) {
22
+ let depPath = dep.path;
23
+ parentPkgPath = parentPkgPath || getRootDir();
24
+ if (parentPkgPath) {
25
+ depPath = path.resolve(parentPkgPath, dep.path);
26
+ }
27
+ return installLocalDep(dep.name, depPath, {silent, verbose});
28
+ }
29
+ else if (dep.version) {
30
+ return installMopsDep(dep.name, dep.version, {silent, verbose, threads});
31
+ }
32
+
33
+ return {};
34
+ }
@@ -0,0 +1,31 @@
1
+ import {Dependency} from '../../types.js';
2
+ import {installDep} from './install-dep.js';
3
+
4
+ type InstallDepsOptions = {
5
+ verbose ?: boolean;
6
+ silent ?: boolean;
7
+ threads ?: number;
8
+ };
9
+
10
+ // install all dependencies
11
+ // returns actual installed dependencies
12
+ // returns false if failed
13
+ export async function installDeps(deps : Dependency[], {verbose, silent, threads} : InstallDepsOptions = {}, parentPkgPath ?: string) : Promise<Record<string, string> | false> {
14
+ let installedDeps = {};
15
+ let ok = true;
16
+ for (const dep of deps) {
17
+ let res = await installDep(dep, {verbose, silent, threads}, parentPkgPath);
18
+ if (res) {
19
+ installedDeps = {...installedDeps, ...res};
20
+ }
21
+ else {
22
+ ok = false;
23
+ }
24
+ }
25
+
26
+ if (!ok) {
27
+ return false;
28
+ }
29
+
30
+ return installedDeps;
31
+ }
@@ -0,0 +1,31 @@
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
+
7
+ type InstallLocalDepOptions = {
8
+ verbose ?: boolean;
9
+ silent ?: boolean;
10
+ };
11
+
12
+ // skip install and just find non-local dependencies to install
13
+ // pkgPath should be relative to the current root dir or absolute
14
+ export async function installLocalDep(pkg : string, pkgPath = '', {verbose, silent} : InstallLocalDepOptions = {}) : Promise<Record<string, string> | false> {
15
+ if (!silent) {
16
+ let logUpdate = createLogUpdate(process.stdout, {showCursor: true});
17
+ logUpdate(`Local dependency ${pkg} = "${pkgPath}"`);
18
+
19
+ if (verbose) {
20
+ silent || logUpdate.done();
21
+ }
22
+ else {
23
+ logUpdate.clear();
24
+ }
25
+ }
26
+
27
+ // install dependencies
28
+ let dir = path.resolve(getRootDir(), pkgPath);
29
+ let config = readConfig(path.join(dir, 'mops.toml'));
30
+ return installDeps(Object.values(config.dependencies || {}), {silent, verbose}, pkgPath);
31
+ }
@@ -1,17 +1,28 @@
1
- import path from 'node:path';
1
+ import process from 'node:process';
2
2
  import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import {Buffer} from 'node:buffer';
3
5
  import {createLogUpdate} from 'log-update';
4
6
  import chalk from 'chalk';
5
- import {checkConfigFile, formatDir, progressBar, readConfig} from '../mops.js';
6
- import {getHighestVersion} from '../api/getHighestVersion.js';
7
- import {storageActor} from '../api/actors.js';
8
- import {parallel} from '../parallel.js';
9
- import {installFromGithub} from '../vessel.js';
10
- import {addCache, copyCache, isCached} from '../cache.js';
11
- import {downloadFile, getPackageFilesInfo} from '../api/downloadPackageFiles.js';
12
- import {installLocal} from './install-local.js';
13
-
14
- export async function install(pkg : string, version = '', {verbose = false, silent = false, dep = false} = {}) : Promise<Record<string, string> | false> {
7
+ import {deleteSync} from 'del';
8
+ import {checkConfigFile, formatDir, progressBar, readConfig} from '../../mops.js';
9
+ import {getHighestVersion} from '../../api/getHighestVersion.js';
10
+ import {storageActor} from '../../api/actors.js';
11
+ import {parallel} from '../../parallel.js';
12
+ import {getDepCacheDir, getMopsDepCacheName, isDepCached} from '../../cache.js';
13
+ import {downloadFile, getPackageFilesInfo} from '../../api/downloadPackageFiles.js';
14
+ import {installDeps} from './install-deps.js';
15
+
16
+ type InstallMopsDepOptions = {
17
+ verbose ?: boolean;
18
+ silent ?: boolean;
19
+ dep ?: boolean;
20
+ threads ?: number;
21
+ };
22
+
23
+ export async function installMopsDep(pkg : string, version = '', {verbose, silent, dep, threads} : InstallMopsDepOptions = {}) : Promise<Record<string, string> | false> {
24
+ threads = threads || 12;
25
+
15
26
  if (!checkConfigFile()) {
16
27
  return false;
17
28
  }
@@ -36,6 +47,8 @@ export async function install(pkg : string, version = '', {verbose = false, sile
36
47
  }
37
48
 
38
49
  let dir = formatDir(pkg, version);
50
+ let cacheName = getMopsDepCacheName(pkg, version);
51
+ let cacheDir = getDepCacheDir(cacheName);
39
52
  let alreadyInstalled = false;
40
53
 
41
54
  // already installed
@@ -44,14 +57,11 @@ export async function install(pkg : string, version = '', {verbose = false, sile
44
57
  alreadyInstalled = true;
45
58
  }
46
59
  // copy from cache
47
- else if (isCached(`${pkg}@${version}`)) {
48
- await copyCache(`${pkg}@${version}`, dir);
60
+ else if (isDepCached(cacheName)) {
49
61
  silent || logUpdate(`${dep ? 'Dependency' : 'Installing'} ${pkg}@${version} (global cache)`);
50
62
  }
51
63
  // download
52
64
  else {
53
- let threads = 16;
54
-
55
65
  // GitHub Actions fails with "fetch failed" if there are multiple concurrent actions
56
66
  if (process.env.GITHUB_ENV) {
57
67
  threads = 4;
@@ -71,10 +81,17 @@ export async function install(pkg : string, version = '', {verbose = false, sile
71
81
  progress();
72
82
  });
73
83
 
74
- // write files to disk
75
- for (let [filePath, data] of filesData.entries()) {
76
- fs.mkdirSync(path.join(dir, path.dirname(filePath)), {recursive: true});
77
- fs.writeFileSync(path.join(dir, filePath), Buffer.from(data));
84
+ // write files to global cache
85
+ try {
86
+ for (let [filePath, data] of filesData.entries()) {
87
+ fs.mkdirSync(path.join(cacheDir, path.dirname(filePath)), {recursive: true});
88
+ fs.writeFileSync(path.join(cacheDir, filePath), Buffer.from(data));
89
+ }
90
+ }
91
+ catch (err) {
92
+ console.error(chalk.red('Error: ') + err);
93
+ deleteSync([cacheDir], {force: true});
94
+ return false;
78
95
  }
79
96
  }
80
97
  catch (err) {
@@ -82,9 +99,6 @@ export async function install(pkg : string, version = '', {verbose = false, sile
82
99
  return false;
83
100
  }
84
101
 
85
- // add to cache
86
- await addCache(`${pkg}@${version}`, dir);
87
-
88
102
  progress();
89
103
  }
90
104
 
@@ -96,31 +110,17 @@ export async function install(pkg : string, version = '', {verbose = false, sile
96
110
  }
97
111
 
98
112
  // install dependencies
99
- let ok = true;
100
- let config = readConfig(path.join(dir, 'mops.toml'));
101
- let deps = Object.values(config.dependencies || {});
102
- let installedDeps = {};
103
- for (const {name, repo, version, path: depPath} of deps) {
104
- if (repo) {
105
- await installFromGithub(name, repo, {silent, verbose});
106
- }
107
- else {
108
- let res = await (depPath ? installLocal(name, depPath, {silent, verbose}) : install(name, version, {silent, verbose}));
109
- if (res) {
110
- installedDeps = {...installedDeps, ...res};
111
- }
112
- else {
113
- ok = false;
114
- }
115
- }
113
+ let config = readConfig(path.join(cacheDir, 'mops.toml'));
114
+ let res = await installDeps(Object.values(config.dependencies || {}), {silent, verbose});
115
+
116
+ if (!res) {
117
+ return false;
116
118
  }
119
+ let installedDeps = res;
117
120
 
121
+ // add self to installed deps
118
122
  if (!alreadyInstalled) {
119
123
  installedDeps = {...installedDeps, [pkg]: version};
120
124
  }
121
-
122
- if (!ok) {
123
- return false;
124
- }
125
125
  return installedDeps;
126
126
  }
@@ -0,0 +1,34 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import {copyCache, getDepCacheName} from '../../cache.js';
4
+ import {getDependencyType, getRootDir} from '../../mops.js';
5
+ import {resolvePackages} from '../../resolve-packages.js';
6
+
7
+ export async function syncLocalCache({verbose = false} = {}) : Promise<Record<string, string>> {
8
+ let resolvedPackages = await resolvePackages();
9
+ let rootDir = getRootDir();
10
+
11
+ verbose && console.log('Syncing local cache...');
12
+
13
+ let installedDeps : Record<string, string> = {};
14
+
15
+ await Promise.all(Object.entries(resolvedPackages).map(([name, value]) => {
16
+ let depType = getDependencyType(value);
17
+
18
+ if (depType === 'mops' || depType === 'github') {
19
+ let cacheName = getDepCacheName(name, value);
20
+ let dest = path.join(rootDir, '.mops', cacheName);
21
+
22
+ if (!fs.existsSync(dest)) {
23
+ if (depType === 'mops') {
24
+ installedDeps[name] = value;
25
+ }
26
+ return copyCache(cacheName, path.join(rootDir, '.mops', cacheName));
27
+ }
28
+ }
29
+
30
+ return Promise.resolve();
31
+ }));
32
+
33
+ return installedDeps;
34
+ }
@@ -1,3 +1,4 @@
1
+ import process from 'node:process';
1
2
  import fs from 'node:fs';
2
3
  import path from 'node:path';
3
4
  import chalk from 'chalk';
@@ -10,7 +11,7 @@ import {checkConfigFile, getIdentity, getRootDir, progressBar, readConfig} from
10
11
  import {mainActor} from '../api/actors.js';
11
12
  import {parallel} from '../parallel.js';
12
13
  import {docs} from './docs.js';
13
- import {Benchmarks, DependencyV2, PackageConfigV2} from '../declarations/main/main.did.js';
14
+ import {Benchmarks, DependencyV2, PackageConfigV3_Publishing, Requirement} from '../declarations/main/main.did.js';
14
15
  import {Dependency} from '../types.js';
15
16
  import {testWithReporter} from './test/test.js';
16
17
  import {SilentReporter} from './test/reporters/silent-reporter.js';
@@ -29,7 +30,7 @@ export async function publish(options : {docs ?: boolean, test ?: boolean, bench
29
30
 
30
31
  // validate
31
32
  for (let key of Object.keys(config)) {
32
- if (!['package', 'dependencies', 'dev-dependencies', 'toolchain'].includes(key)) {
33
+ if (!['package', 'dependencies', 'dev-dependencies', 'toolchain', 'requirements'].includes(key)) {
33
34
  console.log(chalk.red('Error: ') + `Unknown config section [${key}]`);
34
35
  process.exit(1);
35
36
  }
@@ -160,6 +161,15 @@ export async function publish(options : {docs ?: boolean, test ?: boolean, bench
160
161
  }
161
162
  }
162
163
 
164
+ if (config.requirements) {
165
+ Object.keys(config.requirements).forEach((name) => {
166
+ if (name !== 'moc') {
167
+ console.log(chalk.red('Error: ') + `Unknown requirement "${name}"`);
168
+ return;
169
+ }
170
+ });
171
+ }
172
+
163
173
  let toBackendDep = (dep : Dependency) : DependencyV2 => {
164
174
  return {
165
175
  ...dep,
@@ -168,8 +178,12 @@ export async function publish(options : {docs ?: boolean, test ?: boolean, bench
168
178
  };
169
179
  };
170
180
 
181
+ let toBackendReq = ([name, value] : [string, string]) : Requirement => {
182
+ return {name, value};
183
+ };
184
+
171
185
  // map fields
172
- let backendPkgConfig : PackageConfigV2 = {
186
+ let backendPkgConfig : PackageConfigV3_Publishing = {
173
187
  name: config.package.name,
174
188
  version: config.package.version,
175
189
  keywords: config.package.keywords || [],
@@ -186,6 +200,7 @@ export async function publish(options : {docs ?: boolean, test ?: boolean, bench
186
200
  dependencies: Object.values(config.dependencies || {}).map(toBackendDep),
187
201
  devDependencies: Object.values(config['dev-dependencies'] || {}).map(toBackendDep),
188
202
  scripts: [],
203
+ requirements: [Object.entries(config.requirements || {}).map((req) => toBackendReq(req))],
189
204
  };
190
205
 
191
206
  let defaultFiles = [
@@ -1,9 +1,12 @@
1
1
  import fs from 'node:fs';
2
2
  import {deleteSync} from 'del';
3
3
  import chalk from 'chalk';
4
- import {formatDir, formatGithubDir, checkConfigFile, readConfig, writeConfig} from '../mops.js';
4
+ import {checkConfigFile, getRootDir, readConfig, writeConfig} from '../mops.js';
5
5
  import {Config, Dependency} from '../types.js';
6
6
  import {checkIntegrity} from '../integrity.js';
7
+ import {getDepCacheDir, getDepCacheName} from '../cache.js';
8
+ import path from 'node:path';
9
+ import {syncLocalCache} from './install/sync-local-cache.js';
7
10
 
8
11
  type RemoveOptions = {
9
12
  verbose ?: boolean;
@@ -12,7 +15,6 @@ type RemoveOptions = {
12
15
  lock ?: 'update' | 'ignore';
13
16
  };
14
17
 
15
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
16
18
  export async function remove(name : string, {dev = false, verbose = false, dryRun = false, lock} : RemoveOptions = {}) {
17
19
  if (!checkConfigFile()) {
18
20
  return;
@@ -31,13 +33,12 @@ export async function remove(name : string, {dev = false, verbose = false, dryRu
31
33
  }
32
34
 
33
35
  function getTransitiveDependenciesOf(name : string, version : string | undefined, repo ?: string) {
34
- let pkgDir = '';
35
- if (repo) {
36
- pkgDir = formatGithubDir(name, repo);
37
- }
38
- else if (version) {
39
- pkgDir = formatDir(name, version);
36
+ let value = version || repo;
37
+ if (!value) {
38
+ return [];
40
39
  }
40
+ let cacheName = getDepCacheName(name, value);
41
+ let pkgDir = getDepCacheDir(cacheName);
41
42
  let configFile = pkgDir + '/mops.toml';
42
43
  if (!fs.existsSync(configFile)) {
43
44
  verbose && console.log('no config', configFile);
@@ -78,16 +79,11 @@ export async function remove(name : string, {dev = false, verbose = false, dryRu
78
79
  verbose && console.log(`Ignored transitive dependency ${depId} (other deps depend on it)`);
79
80
  continue;
80
81
  }
81
- let pkgDir;
82
- if (dep.repo) {
83
- pkgDir = formatGithubDir(dep.name, dep.repo);
84
- }
85
- else if (dep.version) {
86
- pkgDir = formatDir(dep.name, dep.version);
87
- }
88
- if (pkgDir && fs.existsSync(pkgDir)) {
89
- dryRun || deleteSync([`${pkgDir}`], {force: true});
90
- verbose && console.log(`Removed local cache ${pkgDir}`);
82
+ let cacheName = getDepCacheName(dep.name, dep.version || dep.repo || '');
83
+ let localCacheDir = path.join(getRootDir(), '.mops', cacheName);
84
+ if (localCacheDir && fs.existsSync(localCacheDir)) {
85
+ dryRun || deleteSync([localCacheDir], {force: true});
86
+ verbose && console.log(`Removed local cache ${localCacheDir}`);
91
87
  }
92
88
  }
93
89
 
@@ -100,6 +96,7 @@ export async function remove(name : string, {dev = false, verbose = false, dryRu
100
96
  }
101
97
  dryRun || writeConfig(config);
102
98
 
99
+ await syncLocalCache();
103
100
  await checkIntegrity(lock);
104
101
 
105
102
  console.log(chalk.green('Package removed ') + `${name} = "${version}"`);
@@ -1,3 +1,4 @@
1
+ import process from 'node:process';
1
2
  import asTable from 'as-table';
2
3
  import chalk from 'chalk';
3
4
  import {mainActor} from '../api/actors.js';
package/commands/self.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import process from 'node:process';
1
2
  import child_process, {execSync} from 'node:child_process';
2
3
  import chalk from 'chalk';
3
4
  import {version, globalConfigDir} from '../mops.js';
@@ -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 {checkConfigFile, formatDir, formatGithubDir, getDependencyType, readConfig} from '../mops.js';
package/commands/sync.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import process from 'node:process';
1
2
  import path from 'node:path';
2
3
  import {execSync} from 'node:child_process';
3
4
  import {globSync} from 'glob';
@@ -1,3 +1,4 @@
1
+ import process from 'node:process';
1
2
  import {spawn, ChildProcessWithoutNullStreams} 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';
@@ -7,6 +8,7 @@ import prompts from 'prompts';
7
8
  import {createLogUpdate} from 'log-update';
8
9
  import {checkConfigFile, getClosestConfigFile, getRootDir, globalCacheDir, readConfig, writeConfig} from '../../mops.js';
9
10
  import {Tool} from '../../types.js';
11
+ import {checkRequirements} from '../../check-requirements.js';
10
12
  import * as moc from './moc.js';
11
13
  import * as pocketIc from './pocket-ic.js';
12
14
  import * as wasmtime from './wasmtime.js';
@@ -243,6 +245,8 @@ async function use(tool : Tool, version ?: string) {
243
245
  config.toolchain[tool] = version;
244
246
  writeConfig(config);
245
247
 
248
+ await checkRequirements();
249
+
246
250
  if (oldVersion === version) {
247
251
  console.log((`${tool} ${version} is already installed`));
248
252
  }
@@ -277,6 +281,10 @@ async function update(tool ?: Tool) {
277
281
  config.toolchain[tool] = version;
278
282
  writeConfig(config);
279
283
 
284
+ if (tool === 'moc') {
285
+ await checkRequirements();
286
+ }
287
+
280
288
  if (oldVersion === version) {
281
289
  console.log((`Latest ${tool} ${version} is already installed`));
282
290
  }
@@ -1,3 +1,4 @@
1
+ import process from 'node:process';
1
2
  import path from 'node:path';
2
3
  import fs from 'fs-extra';
3
4
 
@@ -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
 
@@ -1,4 +1,6 @@
1
+ import process from 'node:process';
1
2
  import path from 'node:path';
3
+ import {Buffer} from 'node:buffer';
2
4
  import {unzipSync} from 'node:zlib';
3
5
  import {chmodSync} from 'node:fs';
4
6
  import fs from 'fs-extra';
@@ -1,3 +1,4 @@
1
+ import process from 'node:process';
1
2
  import path from 'node:path';
2
3
  import fs from 'fs-extra';
3
4
 
@@ -1,3 +1,4 @@
1
+ import process from 'node:process';
1
2
  import chalk from 'chalk';
2
3
  import {checkConfigFile, getIdentity, readConfig} from '../mops.js';
3
4
  import {mainActor} from '../api/actors.js';
package/commands/user.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import process from 'node:process';
1
2
  import chalk from 'chalk';
2
3
  import {getIdentity} from '../mops.js';
3
4
  import {mainActor} from '../api/actors.js';
@@ -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);