ic-mops 0.2.0 → 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/.eslintrc.json +1 -21
- package/commands/init.js +3 -3
- package/commands/install-all.js +2 -1
- package/commands/install.js +3 -2
- package/commands/sources.js +18 -12
- package/commands/uninstall.js +3 -2
- package/declarations/main/index.js +3 -3
- package/declarations/main/main.did +2 -2
- package/declarations/main/main.did.js +2 -2
- package/package.json +6 -1
- package/vessel.js +29 -23
package/.eslintrc.json
CHANGED
|
@@ -1,28 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"env": {
|
|
3
|
-
"node": true
|
|
4
|
-
"es2021": true
|
|
3
|
+
"node": true
|
|
5
4
|
},
|
|
6
|
-
"extends": "eslint:recommended",
|
|
7
5
|
"parserOptions": {
|
|
8
6
|
"sourceType": "module"
|
|
9
|
-
},
|
|
10
|
-
"rules": {
|
|
11
|
-
"indent": [
|
|
12
|
-
"error",
|
|
13
|
-
"tab"
|
|
14
|
-
],
|
|
15
|
-
"linebreak-style": [
|
|
16
|
-
"error",
|
|
17
|
-
"unix"
|
|
18
|
-
],
|
|
19
|
-
"quotes": [
|
|
20
|
-
"error",
|
|
21
|
-
"single"
|
|
22
|
-
],
|
|
23
|
-
"semi": [
|
|
24
|
-
"error",
|
|
25
|
-
"always"
|
|
26
|
-
]
|
|
27
7
|
}
|
|
28
8
|
}
|
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 {
|
|
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(), {
|
|
25
|
+
const res = await readVesselConfig(process.cwd(), {cache: false});
|
|
26
26
|
vesselConfig = {...res};
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -66,7 +66,7 @@ export async function init(name = '') {
|
|
|
66
66
|
config.dependencies = {};
|
|
67
67
|
|
|
68
68
|
defaultPackages.forEach(([name, version]) => {
|
|
69
|
-
config.dependencies[name] =
|
|
69
|
+
config.dependencies[name] = {version};
|
|
70
70
|
});
|
|
71
71
|
|
|
72
72
|
writeConfig(config);
|
package/commands/install-all.js
CHANGED
package/commands/install.js
CHANGED
|
@@ -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 {
|
|
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
|
-
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
97
98
|
await install(name, version, {verbose});
|
|
98
99
|
}
|
|
99
100
|
}
|
package/commands/sources.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { readVesselConfig } from '../vessel.js';
|
|
4
|
+
import {formatDir, formatGithubDir, parseGithubURL, readConfig} from '../mops.js';
|
|
5
|
+
import {readVesselConfig} from '../vessel.js';
|
|
7
6
|
|
|
8
7
|
function rootDir(cwd = process.cwd()) {
|
|
9
8
|
let configFile = path.join(cwd, 'mops.toml');
|
|
@@ -50,9 +49,11 @@ export async function sources({verbose} = {}) {
|
|
|
50
49
|
|
|
51
50
|
if (gitVerRegex.test(a) && gitVerRegex.test(b)){
|
|
52
51
|
return compareVersions(a.substring(1) , b.substring(1));
|
|
53
|
-
}
|
|
52
|
+
}
|
|
53
|
+
else if (!gitVerRegex.test(a)){
|
|
54
54
|
return -1;
|
|
55
|
-
}
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
56
57
|
return 1;
|
|
57
58
|
}
|
|
58
59
|
};
|
|
@@ -63,12 +64,15 @@ export async function sources({verbose} = {}) {
|
|
|
63
64
|
|
|
64
65
|
// take root dep version or bigger one
|
|
65
66
|
if (
|
|
66
|
-
isRoot
|
|
67
|
-
!packages[name]
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
isRoot
|
|
68
|
+
|| !packages[name]
|
|
69
|
+
|| !packages[name].isRoot
|
|
70
|
+
&& (
|
|
71
|
+
repo && packages[name].repo && compareGitVersions(packages[name].repo, repo) === -1
|
|
72
|
+
|| compareVersions(packages[name].version, version) === -1)
|
|
70
73
|
) {
|
|
71
74
|
packages[name] = pkgDetails;
|
|
75
|
+
packages[name].isRoot = isRoot;
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
let nestedConfig;
|
|
@@ -77,7 +81,7 @@ export async function sources({verbose} = {}) {
|
|
|
77
81
|
const dir = formatGithubDir(name, repo);
|
|
78
82
|
nestedConfig = await readVesselConfig(dir) || {};
|
|
79
83
|
}
|
|
80
|
-
else{
|
|
84
|
+
else {
|
|
81
85
|
const dir = formatDir(name, version) + '/mops.toml';
|
|
82
86
|
nestedConfig = readConfig(dir);
|
|
83
87
|
}
|
|
@@ -91,7 +95,8 @@ export async function sources({verbose} = {}) {
|
|
|
91
95
|
if (repo){
|
|
92
96
|
const {branch} = parseGithubURL(repo);
|
|
93
97
|
versions[name].push(branch);
|
|
94
|
-
}
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
95
100
|
versions[name].push(version);
|
|
96
101
|
}
|
|
97
102
|
}
|
|
@@ -114,7 +119,8 @@ export async function sources({verbose} = {}) {
|
|
|
114
119
|
let pkgDir;
|
|
115
120
|
if (repo){
|
|
116
121
|
pkgDir = path.relative(process.cwd(), formatGithubDir(name, repo)) + '/src';
|
|
117
|
-
}
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
118
124
|
pkgDir = path.relative(process.cwd(), formatDir(name, version)) + '/src';
|
|
119
125
|
}
|
|
120
126
|
|
package/commands/uninstall.js
CHANGED
|
@@ -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 {
|
|
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
|
-
}
|
|
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
|
|
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.
|
|
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
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
existsSync, mkdirSync, createWriteStream, readFileSync, writeFileSync
|
|
3
|
-
} from 'fs';
|
|
1
|
+
import {existsSync, mkdirSync, createWriteStream, readFileSync, writeFileSync} from 'fs';
|
|
4
2
|
import del from 'del';
|
|
5
3
|
import { execaCommand} from 'execa';
|
|
6
4
|
import chalk from 'chalk';
|
|
@@ -9,12 +7,19 @@ import { formatGithubDir, parseGithubURL, progressBar } from './mops.js';
|
|
|
9
7
|
import path from 'path';
|
|
10
8
|
import got from 'got';
|
|
11
9
|
import decompress from 'decompress';
|
|
12
|
-
import {pipeline} from 'stream
|
|
10
|
+
import {pipeline} from 'stream';
|
|
13
11
|
|
|
14
12
|
const dhallFileToJson = async (filePath) => {
|
|
15
13
|
if (existsSync(filePath)) {
|
|
16
14
|
let cwd = new URL(path.dirname(import.meta.url)).pathname;
|
|
17
|
-
|
|
15
|
+
let res;
|
|
16
|
+
try {
|
|
17
|
+
res = await execaCommand(`dhall-to-json --file ${filePath}`, {preferLocal:true, cwd});
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
console.error('dhall-to-json error:', err);
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
18
23
|
|
|
19
24
|
if (res.exitCode === 0){
|
|
20
25
|
return JSON.parse(res.stdout);
|
|
@@ -93,28 +98,30 @@ export const downloadFromGithub = async (repo, dest, onProgress = null) => {
|
|
|
93
98
|
try {
|
|
94
99
|
mkdirSync(tmpDir, {recursive: true});
|
|
95
100
|
|
|
96
|
-
pipeline(readStream, createWriteStream(tmpFile))
|
|
97
|
-
|
|
101
|
+
pipeline(readStream, createWriteStream(tmpFile), (err) => {
|
|
102
|
+
if (err) {
|
|
103
|
+
del.sync([tmpDir]);
|
|
104
|
+
reject(err);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
98
107
|
let options = {
|
|
99
108
|
extract: true,
|
|
100
109
|
strip: 1,
|
|
101
110
|
headers: {
|
|
102
|
-
accept: 'application/zip'
|
|
103
|
-
}
|
|
111
|
+
accept: 'application/zip',
|
|
112
|
+
},
|
|
104
113
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
} 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) {
|
|
118
125
|
del.sync([tmpDir]);
|
|
119
126
|
reject(err);
|
|
120
127
|
}
|
|
@@ -125,7 +132,6 @@ export const downloadFromGithub = async (repo, dest, onProgress = null) => {
|
|
|
125
132
|
};
|
|
126
133
|
|
|
127
134
|
export const installFromGithub = async (name, repo, options = {})=>{
|
|
128
|
-
|
|
129
135
|
const {verbose, dep, silent} = options;
|
|
130
136
|
|
|
131
137
|
const {branch} = parseGithubURL(repo);
|