ic-mops 0.2.1 → 0.2.2

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/commands/init.js CHANGED
@@ -3,7 +3,7 @@ import path from 'path';
3
3
  import fs from 'fs';
4
4
  import {checkApiCompatibility, mainActor, readDfxJson, writeConfig} from '../mops.js';
5
5
  import {installAll} from './install-all.js';
6
- import { readVesselConfig } from '../vessel.js';
6
+ import {readVesselConfig} from '../vessel.js';
7
7
 
8
8
  export async function init(name = '') {
9
9
  let configFile = path.join(process.cwd(), 'mops.toml');
@@ -22,7 +22,7 @@ export async function init(name = '') {
22
22
 
23
23
  if (fs.existsSync(vesselFile)){
24
24
  console.log('Reading vessel.dhall file');
25
- const res = await readVesselConfig(process.cwd(), { cache: false });
25
+ const res = await readVesselConfig(process.cwd(), {cache: false});
26
26
  vesselConfig = {...res};
27
27
  }
28
28
 
@@ -15,7 +15,8 @@ export async function installAll({verbose} = {}) {
15
15
  for (let {name, repo, version} of deps) {
16
16
  if (repo){
17
17
  await installFromGithub(name, repo, {verbose});
18
- }else{
18
+ }
19
+ else {
19
20
  await install(name, version, {verbose});
20
21
  }
21
22
  }
@@ -4,7 +4,7 @@ import logUpdate from 'log-update';
4
4
  import {checkConfigFile, formatDir, getHighestVersion, mainActor, progressBar, readConfig, storageActor} from '../mops.js';
5
5
  import {parallel} from '../parallel.js';
6
6
  import chalk from 'chalk';
7
- import { installFromGithub } from '../vessel.js';
7
+ import {installFromGithub} from '../vessel.js';
8
8
 
9
9
  export async function install(pkg, version = '', {verbose, silent, dep} = {}) {
10
10
  if (!checkConfigFile()) {
@@ -93,7 +93,8 @@ export async function install(pkg, version = '', {verbose, silent, dep} = {}) {
93
93
  for (const {name, repo, version} of Object.values(config.dependencies || {})) {
94
94
  if (repo){
95
95
  await installFromGithub(name, repo, {verbose});
96
- }else{
96
+ }
97
+ else {
97
98
  await install(name, version, {verbose});
98
99
  }
99
100
  }
@@ -1,8 +1,8 @@
1
1
  import path from 'path';
2
2
  import fs from 'fs';
3
3
  import chalk from 'chalk';
4
- import {formatDir, formatGithubDir, getHighestVersion, parseGithubURL, readConfig} from '../mops.js';
5
- import { readVesselConfig } from '../vessel.js';
4
+ import {formatDir, formatGithubDir, parseGithubURL, readConfig} from '../mops.js';
5
+ import {readVesselConfig} from '../vessel.js';
6
6
 
7
7
  function rootDir(cwd = process.cwd()) {
8
8
  let configFile = path.join(cwd, 'mops.toml');
@@ -49,9 +49,11 @@ export async function sources({verbose} = {}) {
49
49
 
50
50
  if (gitVerRegex.test(a) && gitVerRegex.test(b)){
51
51
  return compareVersions(a.substring(1) , b.substring(1));
52
- }else if (!gitVerRegex.test(a)){
52
+ }
53
+ else if (!gitVerRegex.test(a)){
53
54
  return -1;
54
- }else{
55
+ }
56
+ else {
55
57
  return 1;
56
58
  }
57
59
  };
@@ -79,7 +81,7 @@ export async function sources({verbose} = {}) {
79
81
  const dir = formatGithubDir(name, repo);
80
82
  nestedConfig = await readVesselConfig(dir) || {};
81
83
  }
82
- else{
84
+ else {
83
85
  const dir = formatDir(name, version) + '/mops.toml';
84
86
  nestedConfig = readConfig(dir);
85
87
  }
@@ -93,7 +95,8 @@ export async function sources({verbose} = {}) {
93
95
  if (repo){
94
96
  const {branch} = parseGithubURL(repo);
95
97
  versions[name].push(branch);
96
- }else{
98
+ }
99
+ else {
97
100
  versions[name].push(version);
98
101
  }
99
102
  }
@@ -116,7 +119,8 @@ export async function sources({verbose} = {}) {
116
119
  let pkgDir;
117
120
  if (repo){
118
121
  pkgDir = path.relative(process.cwd(), formatGithubDir(name, repo)) + '/src';
119
- }else{
122
+ }
123
+ else {
120
124
  pkgDir = path.relative(process.cwd(), formatDir(name, version)) + '/src';
121
125
  }
122
126
 
@@ -2,7 +2,7 @@ import {checkConfigFile, readConfig} from '../mops.js';
2
2
  import fs from 'fs';
3
3
  import del from 'del';
4
4
  import chalk from 'chalk';
5
- import { formatDir, formatGithubDir } from '../mops.js';
5
+ import {formatDir, formatGithubDir} from '../mops.js';
6
6
 
7
7
  export async function uninstall(pkg, version) {
8
8
  if (!checkConfigFile()) {
@@ -24,7 +24,8 @@ export async function uninstall(pkg, version) {
24
24
 
25
25
  if (repo){
26
26
  pkgDir = formatGithubDir(pkg, repo);
27
- }else{
27
+ }
28
+ else {
28
29
  pkgDir = formatDir(pkg, version);
29
30
  }
30
31
 
@@ -2,7 +2,7 @@ import { Actor, HttpAgent } from "@dfinity/agent";
2
2
 
3
3
  // Imports and re-exports candid interface
4
4
  import { idlFactory } from './main.did.js';
5
- export { idlFactory } from './main.did.js';
5
+ export { idlFactory} from './main.did.js';
6
6
  // CANISTER_ID is replaced by webpack based on node environment
7
7
  export const canisterId = process.env.MAIN_CANISTER_ID;
8
8
 
@@ -18,7 +18,7 @@ export const createActor = (canisterId, options = {}) => {
18
18
 
19
19
  See https://internetcomputer.org/docs/current/developer-docs/updates/release-notes/ for migration instructions`);
20
20
  const agent = options.agent || new HttpAgent({ ...options.agentOptions });
21
-
21
+
22
22
  // Fetch root key for certificate validation during development
23
23
  if (process.env.DFX_NETWORK !== "ic") {
24
24
  agent.fetchRootKey().catch(err => {
@@ -34,7 +34,7 @@ See https://internetcomputer.org/docs/current/developer-docs/updates/release-not
34
34
  ...(options ? options.actorOptions : {}),
35
35
  });
36
36
  };
37
-
37
+
38
38
  /**
39
39
  * A ready-to-use agent for the main canister
40
40
  * @type {import("@dfinity/agent").ActorSubclass<import("./main.did.js")._SERVICE>}
@@ -124,8 +124,8 @@ service : {
124
124
  StorageId;
125
125
  StorageStats;
126
126
  }) query;
127
- getTotalDownloads: () -> (nat);
128
- getTotalPackages: () -> (nat);
127
+ getTotalDownloads: () -> (nat) query;
128
+ getTotalPackages: () -> (nat) query;
129
129
  notifyInstall: (PackageName__1, Ver) -> () oneway;
130
130
  search: (Text) -> (vec PackageDetails) query;
131
131
  startFileUpload: (PublishingId, Text, nat, blob) -> (Result_2);
@@ -105,8 +105,8 @@ export const idlFactory = ({ IDL }) => {
105
105
  [IDL.Vec(IDL.Tuple(StorageId, StorageStats))],
106
106
  ['query'],
107
107
  ),
108
- 'getTotalDownloads' : IDL.Func([], [IDL.Nat], []),
109
- 'getTotalPackages' : IDL.Func([], [IDL.Nat], []),
108
+ 'getTotalDownloads' : IDL.Func([], [IDL.Nat], ['query']),
109
+ 'getTotalPackages' : IDL.Func([], [IDL.Nat], ['query']),
110
110
  'notifyInstall' : IDL.Func([PackageName__1, Ver], [], ['oneway']),
111
111
  'search' : IDL.Func([Text], [IDL.Vec(PackageDetails)], ['query']),
112
112
  'startFileUpload' : IDL.Func(
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "ic-mops",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mops": "cli.js"
7
7
  },
8
+ "homepage": "http://mops.one/",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/ZenVoich/mops.git"
12
+ },
8
13
  "dependencies": {
9
14
  "@dfinity/agent": "^0.11.0",
10
15
  "@dfinity/candid": "^0.11.0",
package/vessel.js CHANGED
@@ -7,7 +7,7 @@ import { formatGithubDir, parseGithubURL, progressBar } from './mops.js';
7
7
  import path from 'path';
8
8
  import got from 'got';
9
9
  import decompress from 'decompress';
10
- import {pipeline} from 'stream/promises';
10
+ import {pipeline} from 'stream';
11
11
 
12
12
  const dhallFileToJson = async (filePath) => {
13
13
  if (existsSync(filePath)) {
@@ -16,7 +16,8 @@ const dhallFileToJson = async (filePath) => {
16
16
  try {
17
17
  res = await execaCommand(`dhall-to-json --file ${filePath}`, {preferLocal:true, cwd});
18
18
  }
19
- catch (e) {
19
+ catch (err) {
20
+ console.error('dhall-to-json error:', err);
20
21
  return null;
21
22
  }
22
23
 
@@ -97,28 +98,30 @@ export const downloadFromGithub = async (repo, dest, onProgress = null) => {
97
98
  try {
98
99
  mkdirSync(tmpDir, {recursive: true});
99
100
 
100
- pipeline(readStream, createWriteStream(tmpFile))
101
- .then(() => {
101
+ pipeline(readStream, createWriteStream(tmpFile), (err) => {
102
+ if (err) {
103
+ del.sync([tmpDir]);
104
+ reject(err);
105
+ }
106
+ else {
102
107
  let options = {
103
108
  extract: true,
104
109
  strip: 1,
105
110
  headers: {
106
- accept: 'application/zip'
107
- }
111
+ accept: 'application/zip',
112
+ },
108
113
  };
109
-
110
- return decompress(tmpFile, dest, options);
111
-
112
- }).then((unzippedFiles) => {
113
- del.sync([tmpDir]);
114
- resolve(unzippedFiles);
115
-
116
- }).catch(err => {
117
- del.sync([tmpDir]);
118
- reject(err);
119
- });
120
-
121
- } catch (err) {
114
+ decompress(tmpFile, dest, options).then((unzippedFiles) => {
115
+ del.sync([tmpDir]);
116
+ resolve(unzippedFiles);
117
+ }).catch(err => {
118
+ del.sync([tmpDir]);
119
+ reject(err);
120
+ });
121
+ }
122
+ });
123
+ }
124
+ catch (err) {
122
125
  del.sync([tmpDir]);
123
126
  reject(err);
124
127
  }