ic-mops 0.1.7 → 0.1.10
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/README.md +2 -2
- package/cli.js +7 -1
- package/commands/install.js +25 -6
- package/commands/sources.js +7 -1
- package/declarations/main/main.did +20 -5
- package/declarations/main/main.did.d.ts +11 -5
- package/declarations/main/main.did.js +9 -10
- package/package.json +1 -1
package/README.md
CHANGED
package/cli.js
CHANGED
|
@@ -64,7 +64,13 @@ program
|
|
|
64
64
|
installAll(options);
|
|
65
65
|
}
|
|
66
66
|
else {
|
|
67
|
-
let
|
|
67
|
+
let versionRes = await getHighestVersion(pkg);
|
|
68
|
+
if (versionRes.err) {
|
|
69
|
+
console.log(chalk.red('Error: ') + versionRes.err);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
let version = versionRes.ok;
|
|
73
|
+
|
|
68
74
|
await install(pkg, version, {verbose: options.verbose});
|
|
69
75
|
|
|
70
76
|
config.dependencies[pkg] = version;
|
package/commands/install.js
CHANGED
|
@@ -11,7 +11,12 @@ export async function install(pkg, version = '', {verbose, silent, dep} = {}) {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
if (!version) {
|
|
14
|
-
|
|
14
|
+
let versionRes = await getHighestVersion(pkg);
|
|
15
|
+
if (versionRes.err) {
|
|
16
|
+
console.log(chalk.red('Error: ') + versionRes.err);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
version = versionRes.ok;
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
let dir = path.join(process.cwd(), '.mops', `${pkg}@${version}`);
|
|
@@ -28,8 +33,21 @@ export async function install(pkg, version = '', {verbose, silent, dep} = {}) {
|
|
|
28
33
|
if (!dep) {
|
|
29
34
|
actor.notifyInstall(pkg, version);
|
|
30
35
|
}
|
|
31
|
-
|
|
32
|
-
let
|
|
36
|
+
|
|
37
|
+
let packageDetailsRes = await actor.getPackageDetails(pkg, version);
|
|
38
|
+
if (packageDetailsRes.err) {
|
|
39
|
+
console.log(chalk.red('Error: ') + packageDetailsRes.err);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
let packageDetails = packageDetailsRes.ok;
|
|
43
|
+
|
|
44
|
+
let filesIdsRes = await actor.getFileIds(pkg, version);
|
|
45
|
+
if (filesIdsRes.err) {
|
|
46
|
+
console.log(chalk.red('Error: ') + filesIdsRes.err);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
let filesIds = filesIdsRes.ok;
|
|
50
|
+
|
|
33
51
|
let storage = await storageActor(packageDetails.publication.storage);
|
|
34
52
|
|
|
35
53
|
// progress
|
|
@@ -50,18 +68,19 @@ export async function install(pkg, version = '', {verbose, silent, dep} = {}) {
|
|
|
50
68
|
}
|
|
51
69
|
let fileMeta = fileMetaRes.ok;
|
|
52
70
|
|
|
53
|
-
let
|
|
71
|
+
let buffer = Buffer.from([]);
|
|
54
72
|
for (let i = 0; i < fileMeta.chunkCount; i++) {
|
|
55
73
|
let chunkRes = await storage.downloadChunk(fileId, i);
|
|
56
74
|
if (chunkRes.err) {
|
|
57
75
|
console.log(chalk.red('ERR: ') + chunkRes.err);
|
|
58
76
|
return;
|
|
59
77
|
}
|
|
60
|
-
|
|
78
|
+
let chunk = chunkRes.ok;
|
|
79
|
+
buffer = Buffer.concat([buffer, Buffer.from(chunk)]);
|
|
61
80
|
}
|
|
62
81
|
|
|
63
82
|
fs.mkdirSync(path.join(dir, path.dirname(fileMeta.path)), {recursive: true});
|
|
64
|
-
fs.writeFileSync(path.join(dir, fileMeta.path),
|
|
83
|
+
fs.writeFileSync(path.join(dir, fileMeta.path), buffer);
|
|
65
84
|
progress();
|
|
66
85
|
});
|
|
67
86
|
}
|
package/commands/sources.js
CHANGED
|
@@ -73,7 +73,13 @@ export async function sources({verbose} = {}) {
|
|
|
73
73
|
packages['base-unofficial'] = downloadedPackages['base-unofficial'];
|
|
74
74
|
}
|
|
75
75
|
else {
|
|
76
|
-
let
|
|
76
|
+
let versionRes = await getHighestVersion('base-unofficial');
|
|
77
|
+
if (versionRes.err) {
|
|
78
|
+
console.log(chalk.red('Error: ') + versionRes.err);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
let version = versionRes.ok;
|
|
82
|
+
|
|
77
83
|
await install('base-unofficial', version, {silent: true, dep: true});
|
|
78
84
|
packages['base-unofficial'] = version;
|
|
79
85
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type
|
|
1
|
+
type Ver = text;
|
|
2
2
|
type Time = int;
|
|
3
3
|
type Text = text;
|
|
4
4
|
type StorageStats =
|
|
@@ -13,6 +13,21 @@ type Script =
|
|
|
13
13
|
name: text;
|
|
14
14
|
value: text;
|
|
15
15
|
};
|
|
16
|
+
type Result_5 =
|
|
17
|
+
variant {
|
|
18
|
+
err: Err;
|
|
19
|
+
ok: vec FileId;
|
|
20
|
+
};
|
|
21
|
+
type Result_4 =
|
|
22
|
+
variant {
|
|
23
|
+
err: Err;
|
|
24
|
+
ok: Ver;
|
|
25
|
+
};
|
|
26
|
+
type Result_3 =
|
|
27
|
+
variant {
|
|
28
|
+
err: Err;
|
|
29
|
+
ok: PackageDetails;
|
|
30
|
+
};
|
|
16
31
|
type Result_2 =
|
|
17
32
|
variant {
|
|
18
33
|
err: Err;
|
|
@@ -90,15 +105,15 @@ type Dependency =
|
|
|
90
105
|
service : {
|
|
91
106
|
finishPublish: (PublishingId) -> (Result);
|
|
92
107
|
getApiVersion: () -> (Text) query;
|
|
93
|
-
getFileIds: (PackageName__1,
|
|
94
|
-
getHighestVersion: (PackageName__1) -> (
|
|
95
|
-
getPackageDetails: (PackageName__1,
|
|
108
|
+
getFileIds: (PackageName__1, Ver) -> (Result_5) query;
|
|
109
|
+
getHighestVersion: (PackageName__1) -> (Result_4) query;
|
|
110
|
+
getPackageDetails: (PackageName__1, Ver) -> (Result_3) query;
|
|
96
111
|
getRecentlyUpdatedPackages: () -> (vec PackageDetails) query;
|
|
97
112
|
getStoragesStats: () -> (vec record {
|
|
98
113
|
StorageId;
|
|
99
114
|
StorageStats;
|
|
100
115
|
}) query;
|
|
101
|
-
notifyInstall: (PackageName__1,
|
|
116
|
+
notifyInstall: (PackageName__1, Ver) -> () oneway;
|
|
102
117
|
search: (Text) -> (vec PackageDetails) query;
|
|
103
118
|
startFileUpload: (PublishingId, Text, nat, blob) -> (Result_2);
|
|
104
119
|
startPublish: (PackageConfig) -> (Result_1);
|
|
@@ -58,6 +58,12 @@ export type Result_1 = { 'ok' : PublishingId } |
|
|
|
58
58
|
{ 'err' : PublishingErr };
|
|
59
59
|
export type Result_2 = { 'ok' : FileId } |
|
|
60
60
|
{ 'err' : Err };
|
|
61
|
+
export type Result_3 = { 'ok' : PackageDetails } |
|
|
62
|
+
{ 'err' : Err };
|
|
63
|
+
export type Result_4 = { 'ok' : Ver } |
|
|
64
|
+
{ 'err' : Err };
|
|
65
|
+
export type Result_5 = { 'ok' : Array<FileId> } |
|
|
66
|
+
{ 'err' : Err };
|
|
61
67
|
export interface Script { 'value' : string, 'name' : string }
|
|
62
68
|
export type StorageId = Principal;
|
|
63
69
|
export interface StorageStats {
|
|
@@ -67,16 +73,16 @@ export interface StorageStats {
|
|
|
67
73
|
}
|
|
68
74
|
export type Text = string;
|
|
69
75
|
export type Time = bigint;
|
|
70
|
-
export type
|
|
76
|
+
export type Ver = string;
|
|
71
77
|
export interface _SERVICE {
|
|
72
78
|
'finishPublish' : ActorMethod<[PublishingId], Result>,
|
|
73
79
|
'getApiVersion' : ActorMethod<[], Text>,
|
|
74
|
-
'getFileIds' : ActorMethod<[PackageName__1,
|
|
75
|
-
'getHighestVersion' : ActorMethod<[PackageName__1],
|
|
76
|
-
'getPackageDetails' : ActorMethod<[PackageName__1,
|
|
80
|
+
'getFileIds' : ActorMethod<[PackageName__1, Ver], Result_5>,
|
|
81
|
+
'getHighestVersion' : ActorMethod<[PackageName__1], Result_4>,
|
|
82
|
+
'getPackageDetails' : ActorMethod<[PackageName__1, Ver], Result_3>,
|
|
77
83
|
'getRecentlyUpdatedPackages' : ActorMethod<[], Array<PackageDetails>>,
|
|
78
84
|
'getStoragesStats' : ActorMethod<[], Array<[StorageId, StorageStats]>>,
|
|
79
|
-
'notifyInstall' : ActorMethod<[PackageName__1,
|
|
85
|
+
'notifyInstall' : ActorMethod<[PackageName__1, Ver], undefined>,
|
|
80
86
|
'search' : ActorMethod<[Text], Array<PackageDetails>>,
|
|
81
87
|
'startFileUpload' : ActorMethod<
|
|
82
88
|
[PublishingId, Text, bigint, Array<number>],
|
|
@@ -4,8 +4,10 @@ export const idlFactory = ({ IDL }) => {
|
|
|
4
4
|
const Result = IDL.Variant({ 'ok' : IDL.Null, 'err' : Err });
|
|
5
5
|
const Text = IDL.Text;
|
|
6
6
|
const PackageName__1 = IDL.Text;
|
|
7
|
-
const
|
|
7
|
+
const Ver = IDL.Text;
|
|
8
8
|
const FileId = IDL.Text;
|
|
9
|
+
const Result_5 = IDL.Variant({ 'ok' : IDL.Vec(FileId), 'err' : Err });
|
|
10
|
+
const Result_4 = IDL.Variant({ 'ok' : Ver, 'err' : Err });
|
|
9
11
|
const Script = IDL.Record({ 'value' : IDL.Text, 'name' : IDL.Text });
|
|
10
12
|
const PackageName = IDL.Text;
|
|
11
13
|
const Dependency = IDL.Record({ 'name' : PackageName, 'version' : IDL.Text });
|
|
@@ -38,6 +40,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
38
40
|
'config' : PackageConfig__1,
|
|
39
41
|
'publication' : PackagePublication,
|
|
40
42
|
});
|
|
43
|
+
const Result_3 = IDL.Variant({ 'ok' : PackageDetails, 'err' : Err });
|
|
41
44
|
const StorageId = IDL.Principal;
|
|
42
45
|
const StorageStats = IDL.Record({
|
|
43
46
|
'fileCount' : IDL.Nat,
|
|
@@ -66,15 +69,11 @@ export const idlFactory = ({ IDL }) => {
|
|
|
66
69
|
return IDL.Service({
|
|
67
70
|
'finishPublish' : IDL.Func([PublishingId], [Result], []),
|
|
68
71
|
'getApiVersion' : IDL.Func([], [Text], ['query']),
|
|
69
|
-
'getFileIds' : IDL.Func(
|
|
70
|
-
|
|
71
|
-
[IDL.Vec(FileId)],
|
|
72
|
-
['query'],
|
|
73
|
-
),
|
|
74
|
-
'getHighestVersion' : IDL.Func([PackageName__1], [Version], ['query']),
|
|
72
|
+
'getFileIds' : IDL.Func([PackageName__1, Ver], [Result_5], ['query']),
|
|
73
|
+
'getHighestVersion' : IDL.Func([PackageName__1], [Result_4], ['query']),
|
|
75
74
|
'getPackageDetails' : IDL.Func(
|
|
76
|
-
[PackageName__1,
|
|
77
|
-
[
|
|
75
|
+
[PackageName__1, Ver],
|
|
76
|
+
[Result_3],
|
|
78
77
|
['query'],
|
|
79
78
|
),
|
|
80
79
|
'getRecentlyUpdatedPackages' : IDL.Func(
|
|
@@ -87,7 +86,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
87
86
|
[IDL.Vec(IDL.Tuple(StorageId, StorageStats))],
|
|
88
87
|
['query'],
|
|
89
88
|
),
|
|
90
|
-
'notifyInstall' : IDL.Func([PackageName__1,
|
|
89
|
+
'notifyInstall' : IDL.Func([PackageName__1, Ver], [], ['oneway']),
|
|
91
90
|
'search' : IDL.Func([Text], [IDL.Vec(PackageDetails)], ['query']),
|
|
92
91
|
'startFileUpload' : IDL.Func(
|
|
93
92
|
[PublishingId, Text, IDL.Nat, IDL.Vec(IDL.Nat8)],
|