ic-mops 0.1.4 → 0.1.5
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/import-identity.js +3 -1
- package/commands/whoami.js +3 -2
- package/mops.js +3 -1
- package/package.json +1 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import {globalCacheDir} from '../mops.js';
|
|
3
5
|
|
|
4
6
|
export async function importPem(data) {
|
|
5
7
|
try {
|
|
6
|
-
let url = new URL('
|
|
8
|
+
let url = new URL(path.resolve(globalCacheDir, 'identity.pem'), import.meta.url);
|
|
7
9
|
fs.writeFileSync(url, data);
|
|
8
10
|
console.log(chalk.green('Success'));
|
|
9
11
|
}
|
package/commands/whoami.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import fs from 'fs';
|
|
3
|
-
import
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import {getIdentity, globalCacheDir} from '../mops.js';
|
|
4
5
|
|
|
5
6
|
export function whoami() {
|
|
6
|
-
let identityPem = new URL('
|
|
7
|
+
let identityPem = new URL(path.resolve(globalCacheDir, 'identity.pem'), import.meta.url);
|
|
7
8
|
if (fs.existsSync(identityPem)) {
|
|
8
9
|
let identity = getIdentity();
|
|
9
10
|
console.log(identity.getPrincipal().toText());
|
package/mops.js
CHANGED
|
@@ -16,6 +16,8 @@ let apiVersion = '0.1';
|
|
|
16
16
|
|
|
17
17
|
let networkFile = new URL('./network.txt', import.meta.url);
|
|
18
18
|
|
|
19
|
+
export let globalCacheDir = path.resolve(process.env.HOME || process.env.APPDATA, '.mops');
|
|
20
|
+
|
|
19
21
|
export function setNetwork(network) {
|
|
20
22
|
fs.writeFileSync(networkFile, network);
|
|
21
23
|
}
|
|
@@ -44,7 +46,7 @@ export function getNetwork() {
|
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
export let getIdentity = () => {
|
|
47
|
-
let identityPem = new URL('
|
|
49
|
+
let identityPem = new URL(path.resolve(globalCacheDir, 'identity.pem'), import.meta.url);
|
|
48
50
|
if (fs.existsSync(identityPem)) {
|
|
49
51
|
return decodeFile(identityPem);
|
|
50
52
|
}
|