ic-mops 0.44.1 → 0.45.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 (70) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/bin/moc-wrapper.sh +2 -1
  3. package/bundle/bin/moc-wrapper.sh +2 -1
  4. package/bundle/cli.js +90 -33
  5. package/bundle/cli.tgz +0 -0
  6. package/bundle/declarations/bench/bench.did +2 -2
  7. package/bundle/declarations/bench/bench.did.d.ts +2 -2
  8. package/bundle/declarations/bench/bench.did.js +2 -2
  9. package/bundle/declarations/bench/index.js +8 -0
  10. package/bundle/declarations/main/main.did +5 -0
  11. package/bundle/declarations/main/main.did.d.ts +5 -0
  12. package/bundle/declarations/main/main.did.js +5 -0
  13. package/bundle/package.json +1 -1
  14. package/cache.ts +2 -1
  15. package/check-requirements.ts +2 -1
  16. package/cli.ts +5 -1
  17. package/commands/available-updates.ts +4 -0
  18. package/commands/install/install-mops-dep.ts +7 -5
  19. package/commands/publish.ts +10 -5
  20. package/commands/remove.ts +5 -4
  21. package/declarations/bench/bench.did +2 -2
  22. package/declarations/bench/bench.did.d.ts +2 -2
  23. package/declarations/bench/bench.did.js +2 -2
  24. package/declarations/bench/index.js +8 -0
  25. package/declarations/main/main.did +5 -0
  26. package/declarations/main/main.did.d.ts +5 -0
  27. package/declarations/main/main.did.js +5 -0
  28. package/dist/bin/moc-wrapper.sh +2 -1
  29. package/dist/cache.js +2 -1
  30. package/dist/check-requirements.js +2 -1
  31. package/dist/cli.js +5 -1
  32. package/dist/commands/available-updates.js +3 -0
  33. package/dist/commands/install/install-mops-dep.js +7 -5
  34. package/dist/commands/publish.d.ts +1 -0
  35. package/dist/commands/publish.js +8 -4
  36. package/dist/commands/remove.js +5 -4
  37. package/dist/declarations/bench/bench.did +2 -2
  38. package/dist/declarations/bench/bench.did.d.ts +2 -2
  39. package/dist/declarations/bench/bench.did.js +2 -2
  40. package/dist/declarations/bench/index.js +8 -0
  41. package/dist/declarations/main/main.did +5 -0
  42. package/dist/declarations/main/main.did.d.ts +5 -0
  43. package/dist/declarations/main/main.did.js +5 -0
  44. package/dist/helpers/get-dep-name.d.ts +1 -0
  45. package/dist/helpers/get-dep-name.js +3 -0
  46. package/dist/helpers/get-package-id.d.ts +1 -0
  47. package/dist/helpers/get-package-id.js +4 -0
  48. package/dist/integrity.js +2 -1
  49. package/dist/mops.js +5 -4
  50. package/dist/notify-installs.js +5 -2
  51. package/dist/package.json +1 -1
  52. package/dist/pem.js +1 -1
  53. package/dist/vessel.js +1 -1
  54. package/helpers/get-dep-name.ts +3 -0
  55. package/helpers/get-package-id.ts +5 -0
  56. package/integrity.ts +2 -1
  57. package/mops.ts +5 -4
  58. package/notify-installs.ts +6 -2
  59. package/package.json +2 -2
  60. package/pem.ts +1 -1
  61. package/vessel.ts +1 -1
  62. package/.npmrc +0 -2
  63. package/dist/commands/install-all.d.ts +0 -7
  64. package/dist/commands/install-all.js +0 -45
  65. package/dist/commands/install-local.d.ts +0 -4
  66. package/dist/commands/install-local.js +0 -47
  67. package/dist/commands/install.d.ts +0 -5
  68. package/dist/commands/install.js +0 -109
  69. package/dist/remove-scripts.d.ts +0 -1
  70. package/dist/remove-scripts.js +0 -5
@@ -1,45 +0,0 @@
1
- import chalk from 'chalk';
2
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3
- import { createLogUpdate } from 'log-update';
4
- import { checkConfigFile, readConfig } from '../mops.js';
5
- import { install } from './install.js';
6
- import { installFromGithub } from '../vessel.js';
7
- import { notifyInstalls } from '../notify-installs.js';
8
- import { checkIntegrity } from '../integrity.js';
9
- import { installLocal } from './install-local.js';
10
- import { checkRequirements } from '../check-requirements.js';
11
- export async function installAll({ verbose = false, silent = false, lock } = {}) {
12
- if (!checkConfigFile()) {
13
- return;
14
- }
15
- let config = readConfig();
16
- let deps = Object.values(config.dependencies || {});
17
- let devDeps = Object.values(config['dev-dependencies'] || {});
18
- let allDeps = [...deps, ...devDeps];
19
- let installedPackages = {};
20
- for (let { name, repo, path, version } of allDeps) {
21
- if (repo) {
22
- await installFromGithub(name, repo, { verbose, silent });
23
- }
24
- else {
25
- let res = await (path ? installLocal(name, path, { silent, verbose }) : install(name, version, { silent, verbose }));
26
- if (res === false) {
27
- return;
28
- }
29
- installedPackages = { ...installedPackages, ...res };
30
- }
31
- }
32
- let logUpdate = createLogUpdate(process.stdout, { showCursor: true });
33
- if (!silent && lock !== 'ignore') {
34
- logUpdate('Checking integrity...');
35
- }
36
- await Promise.all([
37
- notifyInstalls(Object.keys(installedPackages)),
38
- checkIntegrity(lock),
39
- ]);
40
- if (!silent) {
41
- logUpdate.clear();
42
- await checkRequirements();
43
- console.log(chalk.green('Packages installed'));
44
- }
45
- }
@@ -1,4 +0,0 @@
1
- export declare function installLocal(pkg: string, pkgPath?: string, { verbose, silent }?: {
2
- verbose?: boolean | undefined;
3
- silent?: boolean | undefined;
4
- }): Promise<Record<string, string> | false>;
@@ -1,47 +0,0 @@
1
- import path from 'node:path';
2
- import { createLogUpdate } from 'log-update';
3
- import { checkConfigFile, getRootDir, readConfig } from '../mops.js';
4
- import { installFromGithub } from '../vessel.js';
5
- import { install } from './install.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 installLocal(pkg, pkgPath = '', { verbose = false, silent = false } = {}) {
9
- if (!checkConfigFile()) {
10
- return false;
11
- }
12
- if (!silent) {
13
- let logUpdate = createLogUpdate(process.stdout, { showCursor: true });
14
- logUpdate(`Local dependency ${pkg} = "${pkgPath}"`);
15
- if (verbose) {
16
- silent || logUpdate.done();
17
- }
18
- else {
19
- logUpdate.clear();
20
- }
21
- }
22
- // install dependencies
23
- let ok = true;
24
- let rootDir = getRootDir();
25
- let dir = path.resolve(rootDir, pkgPath);
26
- let config = readConfig(path.join(dir, 'mops.toml'));
27
- let deps = Object.values(config.dependencies || {});
28
- let installedDeps = {};
29
- for (const { name, repo, version, path: depPath } of deps) {
30
- if (repo) {
31
- await installFromGithub(name, repo, { silent, verbose });
32
- }
33
- else {
34
- let res = await (depPath ? installLocal(name, path.resolve(pkgPath, depPath), { silent, verbose }) : install(name, version, { silent, verbose }));
35
- if (res) {
36
- installedDeps = { ...installedDeps, ...res };
37
- }
38
- else {
39
- ok = false;
40
- }
41
- }
42
- }
43
- if (!ok) {
44
- return false;
45
- }
46
- return installedDeps;
47
- }
@@ -1,5 +0,0 @@
1
- export declare function install(pkg: string, version?: string, { verbose, silent, dep }?: {
2
- verbose?: boolean | undefined;
3
- silent?: boolean | undefined;
4
- dep?: boolean | undefined;
5
- }): Promise<Record<string, string> | false>;
@@ -1,109 +0,0 @@
1
- import path from 'node:path';
2
- import fs from 'node:fs';
3
- import { createLogUpdate } from 'log-update';
4
- 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
- export async function install(pkg, version = '', { verbose = false, silent = false, dep = false } = {}) {
14
- if (!checkConfigFile()) {
15
- return false;
16
- }
17
- let logUpdate = createLogUpdate(process.stdout, { showCursor: true });
18
- // progress
19
- let total = Infinity;
20
- let step = 0;
21
- let progress = () => {
22
- step++;
23
- silent || logUpdate(`${dep ? 'Dependency' : 'Installing'} ${pkg}@${version} ${progressBar(step, total)}`);
24
- };
25
- progress();
26
- if (!version) {
27
- let versionRes = await getHighestVersion(pkg);
28
- if ('err' in versionRes) {
29
- console.log(chalk.red('Error: ') + versionRes.err);
30
- return false;
31
- }
32
- version = versionRes.ok;
33
- }
34
- let dir = formatDir(pkg, version);
35
- let alreadyInstalled = false;
36
- // already installed
37
- if (fs.existsSync(dir)) {
38
- silent || logUpdate(`${dep ? 'Dependency' : 'Installing'} ${pkg}@${version} (local cache)`);
39
- alreadyInstalled = true;
40
- }
41
- // copy from cache
42
- else if (isCached(`${pkg}@${version}`)) {
43
- await copyCache(`${pkg}@${version}`, dir);
44
- silent || logUpdate(`${dep ? 'Dependency' : 'Installing'} ${pkg}@${version} (global cache)`);
45
- }
46
- // download
47
- else {
48
- let threads = 16;
49
- // GitHub Actions fails with "fetch failed" if there are multiple concurrent actions
50
- if (process.env.GITHUB_ENV) {
51
- threads = 4;
52
- }
53
- try {
54
- let { storageId, fileIds } = await getPackageFilesInfo(pkg, version);
55
- total = fileIds.length + 2;
56
- let filesData = new Map;
57
- let storage = await storageActor(storageId);
58
- await parallel(threads, fileIds, async (fileId) => {
59
- let { path, data } = await downloadFile(storage, fileId);
60
- filesData.set(path, data);
61
- progress();
62
- });
63
- // write files to disk
64
- for (let [filePath, data] of filesData.entries()) {
65
- fs.mkdirSync(path.join(dir, path.dirname(filePath)), { recursive: true });
66
- fs.writeFileSync(path.join(dir, filePath), Buffer.from(data));
67
- }
68
- }
69
- catch (err) {
70
- console.error(chalk.red('Error: ') + err);
71
- return false;
72
- }
73
- // add to cache
74
- await addCache(`${pkg}@${version}`, dir);
75
- progress();
76
- }
77
- if (verbose) {
78
- silent || logUpdate.done();
79
- }
80
- else {
81
- logUpdate.clear();
82
- }
83
- // install dependencies
84
- let ok = true;
85
- let config = readConfig(path.join(dir, 'mops.toml'));
86
- let deps = Object.values(config.dependencies || {});
87
- let installedDeps = {};
88
- for (const { name, repo, version, path: depPath } of deps) {
89
- if (repo) {
90
- await installFromGithub(name, repo, { silent, verbose });
91
- }
92
- else {
93
- let res = await (depPath ? installLocal(name, depPath, { silent, verbose }) : install(name, version, { silent, verbose }));
94
- if (res) {
95
- installedDeps = { ...installedDeps, ...res };
96
- }
97
- else {
98
- ok = false;
99
- }
100
- }
101
- }
102
- if (!alreadyInstalled) {
103
- installedDeps = { ...installedDeps, [pkg]: version };
104
- }
105
- if (!ok) {
106
- return false;
107
- }
108
- return installedDeps;
109
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- import { readFileSync, writeFileSync } from 'node:fs';
2
- let text = readFileSync('dist/package.json', 'utf8');
3
- let json = JSON.parse(text);
4
- delete json.scripts;
5
- writeFileSync('dist/package.json', JSON.stringify(json, null, 2));