-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathconsole.deploy.utils.mjs
38 lines (30 loc) · 1.04 KB
/
console.deploy.utils.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { nextArg } from '@junobuild/cli-tools';
import { readJunoConfig as readJunoConfigTools } from '@junobuild/config-loader';
import { getIdentity } from './console.config.utils.mjs';
import { CONSOLE_ID } from './constants.mjs';
import { targetMainnet } from './utils.mjs';
export const deployConsole = async () => {
const mainnet = targetMainnet();
return {
identity: await getIdentity(mainnet),
consoleId: CONSOLE_ID,
...(!mainnet && { container: 'http://127.0.0.1:5987/' })
};
};
export const JUNO_CONFIG_FILENAME = 'juno.config';
const JUNO_CONFIG_FILE = { filename: JUNO_CONFIG_FILENAME };
const configEnv = (args) => {
const mode = nextArg({ args, option: '-m' }) ?? nextArg({ args, option: '--mode' });
return {
mode: mode ?? 'production'
};
};
export const readJunoConfig = async () => {
const args = process.argv.slice(2);
const env = configEnv(args);
const config = (userConfig) => (typeof userConfig === 'function' ? userConfig(env) : userConfig);
return await readJunoConfigTools({
...JUNO_CONFIG_FILE,
config
});
};