Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): allow CLI command configurations #2972

Merged
merged 8 commits into from
Sep 28, 2019
39 changes: 39 additions & 0 deletions __tests__/unit/core-container/__stubs__/config/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = {
cli: {
core: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
relay: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
forger: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
chain: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
snapshot: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
},
}
39 changes: 39 additions & 0 deletions __tests__/utils/config/testnet/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = {
cli: {
core: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
relay: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
forger: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
chain: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
snapshot: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
},
}
39 changes: 39 additions & 0 deletions __tests__/utils/config/unitnet/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = {
cli: {
core: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
relay: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
forger: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
chain: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
snapshot: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
},
}
39 changes: 39 additions & 0 deletions packages/core/bin/config/devnet/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = {
cli: {
core: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
relay: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
forger: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
chain: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
snapshot: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
},
}
39 changes: 39 additions & 0 deletions packages/core/bin/config/mainnet/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = {
cli: {
core: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
relay: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
forger: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
chain: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
snapshot: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
},
}
39 changes: 39 additions & 0 deletions packages/core/bin/config/testnet/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = {
cli: {
core: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
relay: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
forger: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
chain: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
snapshot: {
run: {
plugins: {
include: ["@arkecosystem/core-marketplace"],
},
},
},
},
}
3 changes: 3 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
"cli-table3": "^0.5.1",
"cli-ux": "^5.3.1",
"dayjs": "^1.8.15",
"deepmerge": "^4.0.0",
"dottie": "^2.0.1",
"env-paths": "^2.2.0",
"envfile": "^3.0.0",
"execa": "^2.0.3",
Expand All @@ -96,6 +98,7 @@
"@types/bip39": "^2.4.2",
"@types/bytebuffer": "^5.0.40",
"@types/cli-progress": "^1.8.1",
"@types/dottie": "^2.0.3",
"@types/execa": "^0.9.0",
"@types/fast-levenshtein": "^0.0.1",
"@types/fs-extra": "^8.0.0",
Expand Down
22 changes: 14 additions & 8 deletions packages/core/src/commands/core/run.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { app } from "@arkecosystem/core-container";
import { flags } from "@oclif/command";
import deepmerge from "deepmerge";
import { CommandFlags } from "../../types";
import { getCliConfig } from "../../utils";
import { BaseCommand } from "../command";

export class RunCommand extends BaseCommand {
Expand Down Expand Up @@ -43,14 +45,18 @@ $ ark core:run --launchMode=seed
public async run(): Promise<void> {
const { flags } = await this.parseWithNetwork(RunCommand);

await this.buildApplication(app, flags, {
options: {
"@arkecosystem/core-p2p": this.buildPeerOptions(flags),
"@arkecosystem/core-blockchain": {
networkStart: flags.networkStart,
await this.buildApplication(
app,
flags,
deepmerge(getCliConfig(flags), {
options: {
"@arkecosystem/core-p2p": this.buildPeerOptions(flags),
"@arkecosystem/core-blockchain": {
networkStart: flags.networkStart,
},
"@arkecosystem/core-forger": await this.buildBIP38(flags),
},
"@arkecosystem/core-forger": await this.buildBIP38(flags),
},
});
}),
);
}
}
30 changes: 18 additions & 12 deletions packages/core/src/commands/forger/run.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { app } from "@arkecosystem/core-container";
import { flags } from "@oclif/command";
import deepmerge from "deepmerge";
import { CommandFlags } from "../../types";
import { getCliConfig } from "../../utils";
import { BaseCommand } from "../command";

export class RunCommand extends BaseCommand {
Expand All @@ -26,17 +28,21 @@ $ ark forger:run --bip38="..." --password="..."
public async run(): Promise<void> {
const { flags } = await this.parseWithNetwork(RunCommand);

await this.buildApplication(app, flags, {
include: [
"@arkecosystem/core-event-emitter",
"@arkecosystem/core-config",
"@arkecosystem/core-logger",
"@arkecosystem/core-logger-pino",
"@arkecosystem/core-forger",
],
options: {
"@arkecosystem/core-forger": await this.buildBIP38(flags),
},
});
await this.buildApplication(
app,
flags,
deepmerge(getCliConfig(flags), {
include: [
"@arkecosystem/core-event-emitter",
"@arkecosystem/core-config",
"@arkecosystem/core-logger",
"@arkecosystem/core-logger-pino",
"@arkecosystem/core-forger",
],
options: {
"@arkecosystem/core-forger": await this.buildBIP38(flags),
},
}),
);
}
}
22 changes: 14 additions & 8 deletions packages/core/src/commands/relay/run.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { app } from "@arkecosystem/core-container";
import { flags } from "@oclif/command";
import deepmerge from "deepmerge";
import { CommandFlags } from "../../types";
import { getCliConfig } from "../../utils";
import { BaseCommand } from "../command";

export class RunCommand extends BaseCommand {
Expand Down Expand Up @@ -42,14 +44,18 @@ $ ark relay:run --launchMode=seed
public async run(): Promise<void> {
const { flags } = await this.parseWithNetwork(RunCommand);

await super.buildApplication(app, flags, {
exclude: ["@arkecosystem/core-forger"],
options: {
"@arkecosystem/core-p2p": this.buildPeerOptions(flags),
"@arkecosystem/core-blockchain": {
networkStart: flags.networkStart,
await super.buildApplication(
app,
flags,
deepmerge(getCliConfig(flags), {
exclude: ["@arkecosystem/core-forger"],
options: {
"@arkecosystem/core-p2p": this.buildPeerOptions(flags),
"@arkecosystem/core-blockchain": {
networkStart: flags.networkStart,
},
},
},
});
}),
);
}
}
Loading