ic-mops 0.2.3 → 0.3.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/cli.js +44 -1
- package/commands/init.js +15 -4
- package/declarations/main/index.js +3 -3
- package/mops.js +1 -1
- package/package.json +1 -1
- package/vessel.js +4 -5
package/cli.js
CHANGED
|
@@ -10,17 +10,22 @@ import {install} from './commands/install.js';
|
|
|
10
10
|
import {publish} from './commands/publish.js';
|
|
11
11
|
import {importPem} from './commands/import-identity.js';
|
|
12
12
|
import {sources} from './commands/sources.js';
|
|
13
|
-
import {checkApiCompatibility, getHighestVersion, getNetwork, parseGithubURL, readConfig, setNetwork, writeConfig} from './mops.js';
|
|
13
|
+
import {checkApiCompatibility, getHighestVersion, getNetwork, parseGithubURL, readConfig, setNetwork, writeConfig, apiVersion, mainActor} from './mops.js';
|
|
14
14
|
import {whoami} from './commands/whoami.js';
|
|
15
15
|
import {installAll} from './commands/install-all.js';
|
|
16
16
|
import logUpdate from 'log-update';
|
|
17
17
|
import {installFromGithub} from './vessel.js';
|
|
18
|
+
import asTable from 'as-table';
|
|
18
19
|
|
|
19
20
|
let cwd = process.cwd();
|
|
20
21
|
let configFile = path.join(cwd, 'mops.toml');
|
|
21
22
|
|
|
22
23
|
program.name('mops');
|
|
23
24
|
|
|
25
|
+
// --version
|
|
26
|
+
let packageJson = JSON.parse(fs.readFileSync(new URL('package.json', import.meta.url)));
|
|
27
|
+
program.version(`CLI ${packageJson.version}\nAPI ${apiVersion}`, '-v --version');
|
|
28
|
+
|
|
24
29
|
// init
|
|
25
30
|
program
|
|
26
31
|
.command('init [name]')
|
|
@@ -173,4 +178,42 @@ program
|
|
|
173
178
|
whoami();
|
|
174
179
|
});
|
|
175
180
|
|
|
181
|
+
// search
|
|
182
|
+
program
|
|
183
|
+
.command('search <text>')
|
|
184
|
+
.alias('find')
|
|
185
|
+
.description('Search for packages')
|
|
186
|
+
.action(async (text) => {
|
|
187
|
+
let actor = await mainActor();
|
|
188
|
+
let res = await actor.search(text);
|
|
189
|
+
|
|
190
|
+
let ellipsis = (text, max) => {
|
|
191
|
+
if (text.length <= max) {
|
|
192
|
+
return text;
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
return text.slice(0, max) + '…';
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
let maxNameLength = Math.max(...res.map(a => a.config.name.length));
|
|
200
|
+
|
|
201
|
+
let table = res.map((item) => {
|
|
202
|
+
return {
|
|
203
|
+
NAME: chalk.bold(item.config.name),
|
|
204
|
+
VERSION: item.config.version,
|
|
205
|
+
DESCRIPTION: ellipsis(item.config.description, process.stdout.columns - 40 - maxNameLength),
|
|
206
|
+
UPDATED: new Date(Number(item.publication.time / 1_000_000n)).toISOString().split('T')[0],
|
|
207
|
+
};
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
console.log('');
|
|
211
|
+
console.log(asTable.configure({
|
|
212
|
+
delimiter: chalk.gray(' | '),
|
|
213
|
+
dash: chalk.gray('─'),
|
|
214
|
+
title: t => chalk.gray.bold(t),
|
|
215
|
+
})(table));
|
|
216
|
+
console.log('');
|
|
217
|
+
});
|
|
218
|
+
|
|
176
219
|
program.parse();
|
package/commands/init.js
CHANGED
|
@@ -17,6 +17,7 @@ export async function init(name = '') {
|
|
|
17
17
|
|
|
18
18
|
let config = {};
|
|
19
19
|
let vesselConfig = {};
|
|
20
|
+
let vesselDeps;
|
|
20
21
|
|
|
21
22
|
const vesselFile = path.join(process.cwd(), 'vessel.dhall');
|
|
22
23
|
|
|
@@ -27,10 +28,10 @@ export async function init(name = '') {
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
if (vesselConfig.dependencies) {
|
|
30
|
-
|
|
31
|
+
vesselDeps = {};
|
|
31
32
|
|
|
32
33
|
for (const dep of (vesselConfig.dependencies || [])) {
|
|
33
|
-
|
|
34
|
+
vesselDeps[dep.name] = dep;
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -43,10 +44,15 @@ export async function init(name = '') {
|
|
|
43
44
|
repository: '',
|
|
44
45
|
};
|
|
45
46
|
|
|
47
|
+
if (vesselDeps) {
|
|
48
|
+
config.dependencies = vesselDeps;
|
|
49
|
+
}
|
|
50
|
+
|
|
46
51
|
writeConfig(config);
|
|
47
52
|
|
|
48
|
-
if (Object.keys(config.dependencies || {}).length)
|
|
53
|
+
if (Object.keys(config.dependencies || {}).length) {
|
|
49
54
|
await installAll({verbose: true});
|
|
55
|
+
}
|
|
50
56
|
}
|
|
51
57
|
|
|
52
58
|
// project mode
|
|
@@ -62,8 +68,13 @@ export async function init(name = '') {
|
|
|
62
68
|
let actor = await mainActor();
|
|
63
69
|
let defaultPackages = await actor.getDefaultPackages(dfxVersion);
|
|
64
70
|
|
|
65
|
-
if (!config.dependencies)
|
|
71
|
+
if (!config.dependencies) {
|
|
66
72
|
config.dependencies = {};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (vesselDeps) {
|
|
76
|
+
config.dependencies = vesselDeps;
|
|
77
|
+
}
|
|
67
78
|
|
|
68
79
|
defaultPackages.forEach(([name, version]) => {
|
|
69
80
|
config.dependencies[name] = {version};
|
|
@@ -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>}
|
package/mops.js
CHANGED
package/package.json
CHANGED
package/vessel.js
CHANGED
|
@@ -32,10 +32,7 @@ const dhallFileToJson = async (filePath) => {
|
|
|
32
32
|
return null;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
export const readVesselConfig = async (
|
|
36
|
-
configFile,
|
|
37
|
-
{cache = true} = {cache: true}
|
|
38
|
-
) => {
|
|
35
|
+
export const readVesselConfig = async (configFile, {cache = true} = {cache: true}) => {
|
|
39
36
|
const cachedFile = (configFile || process.cwd()) + '/vessel.json';
|
|
40
37
|
|
|
41
38
|
if (existsSync(cachedFile)) {
|
|
@@ -48,7 +45,9 @@ export const readVesselConfig = async (
|
|
|
48
45
|
dhallFileToJson((configFile || process.cwd()) + '/package-set.dhall')
|
|
49
46
|
]);
|
|
50
47
|
|
|
51
|
-
if (!vessel || !packageSetArray)
|
|
48
|
+
if (!vessel || !packageSetArray) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
52
51
|
|
|
53
52
|
let repos = {};
|
|
54
53
|
for (const {name, repo, version} of packageSetArray) {
|