ic-mops 0.42.1 → 0.44.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.
package/bundle/cli.tgz CHANGED
Binary file
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ic-mops",
3
- "version": "0.42.0",
3
+ "version": "0.43.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mops": "bin/mops.js",
package/cache.ts CHANGED
@@ -5,6 +5,10 @@ import getFolderSize from 'get-folder-size';
5
5
 
6
6
  import {getDependencyType, globalCacheDir, parseGithubURL} from './mops.js';
7
7
 
8
+ export let show = () => {
9
+ return globalCacheDir;
10
+ };
11
+
8
12
  export let getDepCacheDir = (cacheName : string) => {
9
13
  return path.join(globalCacheDir, 'packages', cacheName);
10
14
  };
package/cli.ts CHANGED
@@ -13,7 +13,7 @@ import {whoami} from './commands/whoami.js';
13
13
  import {installAll} from './commands/install/install-all.js';
14
14
  import {search} from './commands/search.js';
15
15
  import {add} from './commands/add.js';
16
- import {cacheSize, cleanCache} from './cache.js';
16
+ import {cacheSize, cleanCache, show} from './cache.js';
17
17
  import {test} from './commands/test/test.js';
18
18
  import {template} from './commands/template.js';
19
19
  import {remove} from './commands/remove.js';
@@ -199,7 +199,7 @@ program
199
199
  program
200
200
  .command('cache')
201
201
  .description('Manage cache')
202
- .addArgument(new Argument('<sub>').choices(['size', 'clean']))
202
+ .addArgument(new Argument('<sub>').choices(['size', 'clean', 'show']))
203
203
  .action(async (sub) => {
204
204
  if (sub == 'clean') {
205
205
  await cleanCache();
@@ -209,6 +209,9 @@ program
209
209
  let size = await cacheSize();
210
210
  console.log('Cache size is ' + size);
211
211
  }
212
+ else if (sub == 'show') {
213
+ console.log(show());
214
+ }
212
215
  });
213
216
 
214
217
  // test
@@ -36,7 +36,7 @@ export async function installAll({verbose = false, silent = false, threads, lock
36
36
  logUpdate('Checking integrity...');
37
37
  }
38
38
 
39
- let installedPackages = await syncLocalCache();
39
+ let installedPackages = await syncLocalCache({verbose});
40
40
 
41
41
  await Promise.all([
42
42
  notifyInstalls(installedPackages),
@@ -28,7 +28,9 @@ export async function syncLocalCache({verbose = false} = {}) : Promise<Record<st
28
28
  }
29
29
 
30
30
  return Promise.resolve();
31
- }));
31
+ })).catch((errors) => {
32
+ throw errors?.[0];
33
+ });
32
34
 
33
35
  return installedDeps;
34
36
  }
@@ -1,3 +1,40 @@
1
1
  #!/bin/bash
2
- mocPath="$(mops toolchain bin moc --fallback)"
3
- $mocPath "$@"
2
+
3
+ # set -e
4
+
5
+ findRootDir() {
6
+ dir="$(pwd)"
7
+ while [[ "$dir" != "" && ! -e "$dir/mops.toml" ]]; do
8
+ dir=${dir%/*}
9
+ done
10
+ echo "$dir"
11
+ }
12
+
13
+ rootDir=$(findRootDir)
14
+ mopsToml="$rootDir/mops.toml"
15
+
16
+ if [[ $rootDir == "" ]] || [[ ! -f $mopsToml ]]; then
17
+ echo "mops.toml not found in $rootDir or its parent directories"
18
+ exit 1;
19
+ fi;
20
+
21
+ if command -v openssl &> /dev/null; then
22
+ mopsTomlHash=$(openssl sha256 $mopsToml | awk -F'= ' '{print $2}')
23
+ else
24
+ mopsTomlHash=$(shasum $mopsToml -a 256 | awk -F' ' '{print $1}')
25
+ fi;
26
+
27
+ cached="$rootDir/.mops/moc-$mopsTomlHash"
28
+
29
+ if [ -f $cached ]; then
30
+ mocPath=$(cat $cached)
31
+ if [[ "$mocPath" != *"/moc" ]] ; then
32
+ mocPath="$(mops toolchain bin moc --fallback)"
33
+ echo -n $mocPath > "$cached"
34
+ fi;
35
+ else
36
+ mocPath="$(mops toolchain bin moc --fallback)"
37
+ echo -n $mocPath > "$cached"
38
+ fi;
39
+
40
+ $mocPath "$@"
package/dist/cache.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export declare let show: () => string;
1
2
  export declare let getDepCacheDir: (cacheName: string) => string;
2
3
  export declare let isDepCached: (cacheName: string) => boolean;
3
4
  export declare function getDepCacheName(name: string, version: string): string;
package/dist/cache.js CHANGED
@@ -3,6 +3,9 @@ import path from 'node:path';
3
3
  import ncp from 'ncp';
4
4
  import getFolderSize from 'get-folder-size';
5
5
  import { getDependencyType, globalCacheDir, parseGithubURL } from './mops.js';
6
+ export let show = () => {
7
+ return globalCacheDir;
8
+ };
6
9
  export let getDepCacheDir = (cacheName) => {
7
10
  return path.join(globalCacheDir, 'packages', cacheName);
8
11
  };
package/dist/cli.js CHANGED
@@ -12,7 +12,7 @@ import { whoami } from './commands/whoami.js';
12
12
  import { installAll } from './commands/install/install-all.js';
13
13
  import { search } from './commands/search.js';
14
14
  import { add } from './commands/add.js';
15
- import { cacheSize, cleanCache } from './cache.js';
15
+ import { cacheSize, cleanCache, show } from './cache.js';
16
16
  import { test } from './commands/test/test.js';
17
17
  import { template } from './commands/template.js';
18
18
  import { remove } from './commands/remove.js';
@@ -172,7 +172,7 @@ program
172
172
  program
173
173
  .command('cache')
174
174
  .description('Manage cache')
175
- .addArgument(new Argument('<sub>').choices(['size', 'clean']))
175
+ .addArgument(new Argument('<sub>').choices(['size', 'clean', 'show']))
176
176
  .action(async (sub) => {
177
177
  if (sub == 'clean') {
178
178
  await cleanCache();
@@ -182,6 +182,9 @@ program
182
182
  let size = await cacheSize();
183
183
  console.log('Cache size is ' + size);
184
184
  }
185
+ else if (sub == 'show') {
186
+ console.log(show());
187
+ }
185
188
  });
186
189
  // test
187
190
  program
@@ -23,7 +23,7 @@ export async function installAll({ verbose = false, silent = false, threads, loc
23
23
  if (!silent && lock !== 'ignore') {
24
24
  logUpdate('Checking integrity...');
25
25
  }
26
- let installedPackages = await syncLocalCache();
26
+ let installedPackages = await syncLocalCache({ verbose });
27
27
  await Promise.all([
28
28
  notifyInstalls(installedPackages),
29
29
  checkIntegrity(lock),
@@ -21,6 +21,8 @@ export async function syncLocalCache({ verbose = false } = {}) {
21
21
  }
22
22
  }
23
23
  return Promise.resolve();
24
- }));
24
+ })).catch((errors) => {
25
+ throw errors?.[0];
26
+ });
25
27
  return installedDeps;
26
28
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ic-mops",
3
- "version": "0.42.1",
3
+ "version": "0.44.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mops": "bin/mops.js",
package/dist/vessel.js CHANGED
@@ -8,7 +8,7 @@ import chalk from 'chalk';
8
8
  import { createLogUpdate } from 'log-update';
9
9
  import got from 'got';
10
10
  import decompress from 'decompress';
11
- import { formatGithubDir, parseGithubURL, progressBar } from './mops.js';
11
+ import { parseGithubURL, progressBar } from './mops.js';
12
12
  import { getDepCacheDir, getGithubDepCacheName, isDepCached } from './cache.js';
13
13
  const dhallFileToJson = async (filePath, silent) => {
14
14
  if (existsSync(filePath)) {
@@ -117,7 +117,6 @@ export const downloadFromGithub = async (repo, dest, onProgress) => {
117
117
  return promise;
118
118
  };
119
119
  export const installFromGithub = async (name, repo, { verbose = false, dep = false, silent = false } = {}) => {
120
- let dir = formatGithubDir(name, repo);
121
120
  let cacheName = getGithubDepCacheName(name, repo);
122
121
  let cacheDir = getDepCacheDir(cacheName);
123
122
  let logUpdate = createLogUpdate(process.stdout, { showCursor: true });
@@ -144,7 +143,7 @@ export const installFromGithub = async (name, repo, { verbose = false, dep = fal
144
143
  else {
145
144
  logUpdate.clear();
146
145
  }
147
- const config = await readVesselConfig(dir, { silent });
146
+ const config = await readVesselConfig(cacheDir, { silent });
148
147
  if (config) {
149
148
  for (const { name, repo } of config.dependencies) {
150
149
  if (repo) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ic-mops",
3
- "version": "0.42.1",
3
+ "version": "0.44.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mops": "dist/bin/mops.js",
package/vessel.ts CHANGED
@@ -8,7 +8,7 @@ import chalk from 'chalk';
8
8
  import {createLogUpdate} from 'log-update';
9
9
  import got from 'got';
10
10
  import decompress from 'decompress';
11
- import {formatGithubDir, parseGithubURL, progressBar} from './mops.js';
11
+ import {parseGithubURL, progressBar} from './mops.js';
12
12
  import {getDepCacheDir, getGithubDepCacheName, isDepCached} from './cache.js';
13
13
 
14
14
  const dhallFileToJson = async (filePath : string, silent : boolean) => {
@@ -150,7 +150,6 @@ export const downloadFromGithub = async (repo : string, dest : string, onProgres
150
150
  };
151
151
 
152
152
  export const installFromGithub = async (name : string, repo : string, {verbose = false, dep = false, silent = false} = {}) => {
153
- let dir = formatGithubDir(name, repo);
154
153
  let cacheName = getGithubDepCacheName(name, repo);
155
154
  let cacheDir = getDepCacheDir(cacheName);
156
155
 
@@ -184,7 +183,7 @@ export const installFromGithub = async (name : string, repo : string, {verbose =
184
183
  logUpdate.clear();
185
184
  }
186
185
 
187
- const config = await readVesselConfig(dir, {silent});
186
+ const config = await readVesselConfig(cacheDir, {silent});
188
187
 
189
188
  if (config) {
190
189
  for (const {name, repo} of config.dependencies) {