Skip to content

Commit 2b1b8af

Browse files
add version flag (#81)
2 parents 6214dd9 + 51926e1 commit 2b1b8af

8 files changed

+60
-3
lines changed

.changeset/slimy-jars-swim.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eth-tech-tree": patch
3+
---
4+
5+
add version flag

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
],
3232
"license": "MIT",
3333
"devDependencies": {
34+
"@rollup/plugin-json": "^6.1.0",
3435
"@rollup/plugin-typescript": "11.1.0",
3536
"@types/ncp": "2.0.5",
3637
"@types/node": "18.16.0",

rollup.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import typescript from "@rollup/plugin-typescript";
22
import autoExternal from "rollup-plugin-auto-external";
3+
import json from '@rollup/plugin-json';
34

45
export default {
56
input: "src/cli.ts",
@@ -8,6 +9,6 @@ export default {
89
format: "es",
910
sourcemap: true,
1011
},
11-
plugins: [autoExternal(), typescript({ exclude: ["challenges/**"] })],
12+
plugins: [autoExternal(), typescript({ exclude: ["challenges/**"] }), json()],
1213
external: ["@inquirer/core"],
1314
};

src/tasks/handle-command.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { CommandOptions } from "./parse-command-arguments-and-options";
22
import { removeStorage, setupChallenge, submitChallenge } from "../actions";
3+
import { version } from '../../package.json'
34

45
export async function handleCommand(commands: CommandOptions) {
56
const { command, installLocation, challenge, contractAddress, dev, help } = commands;
@@ -9,6 +10,11 @@ export async function handleCommand(commands: CommandOptions) {
910
return;
1011
}
1112

13+
if (command === 'version') {
14+
console.log(version)
15+
return
16+
}
17+
1218
if (command === "setup") {
1319
await setupChallenge(challenge as string, installLocation as string);
1420
}

src/tasks/parse-command-arguments-and-options.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ export async function parseCommandArgumentsAndOptions(
6969
"--dev": Boolean,
7070
"--help": Boolean,
7171
"-h": "--help",
72+
"--version": Boolean,
73+
"-v": "--version"
7274
},
7375
{
7476
argv: args,
@@ -79,7 +81,9 @@ export async function parseCommandArgumentsAndOptions(
7981

8082
const help = parsedArgs["--help"] ?? parsedArgs._[0] === 'help' ?? false;
8183

82-
const command = parsedArgs._[0] ?? null;
84+
const version = parsedArgs["--version"] ?? parsedArgs._[0] === 'version' ?? false;
85+
86+
const command = version ? 'version' : parsedArgs._[0] ?? null;
8387

8488
const argumentObject: Partial<CommandOptions> = {
8589
dev,

src/utils/constants.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"esModuleInterop": true,
77
"sourceMap": true,
88
"skipLibCheck": true,
9-
"moduleResolution": "node"
9+
"moduleResolution": "node",
10+
"resolveJsonModule": true
1011
},
1112
"exclude": ["node_modules"]
1213
}

yarn.lock

+38
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,20 @@ __metadata:
557557
languageName: node
558558
linkType: hard
559559

560+
"@rollup/plugin-json@npm:^6.1.0":
561+
version: 6.1.0
562+
resolution: "@rollup/plugin-json@npm:6.1.0"
563+
dependencies:
564+
"@rollup/pluginutils": ^5.1.0
565+
peerDependencies:
566+
rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0
567+
peerDependenciesMeta:
568+
rollup:
569+
optional: true
570+
checksum: cc018d20c80242a2b8b44fae61a968049cf31bb8406218187cc7cda35747616594e79452dd65722e7da6dd825b392e90d4599d43cd4461a02fefa2865945164e
571+
languageName: node
572+
linkType: hard
573+
560574
"@rollup/plugin-typescript@npm:11.1.0":
561575
version: 11.1.0
562576
resolution: "@rollup/plugin-typescript@npm:11.1.0"
@@ -592,6 +606,22 @@ __metadata:
592606
languageName: node
593607
linkType: hard
594608

609+
"@rollup/pluginutils@npm:^5.1.0":
610+
version: 5.1.4
611+
resolution: "@rollup/pluginutils@npm:5.1.4"
612+
dependencies:
613+
"@types/estree": ^1.0.0
614+
estree-walker: ^2.0.2
615+
picomatch: ^4.0.2
616+
peerDependencies:
617+
rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0
618+
peerDependenciesMeta:
619+
rollup:
620+
optional: true
621+
checksum: dc0294580effbf68965ed7939c9e469b8c8847b59842e4691fd10d0a8d0b178600bd912694c409ae33600c9059efce72e96f25917cff983afd57f092a7aeb8d2
622+
languageName: node
623+
linkType: hard
624+
595625
"@samverschueren/stream-to-observable@npm:^0.3.0":
596626
version: 0.3.1
597627
resolution: "@samverschueren/stream-to-observable@npm:0.3.1"
@@ -1784,6 +1814,7 @@ __metadata:
17841814
dependencies:
17851815
"@changesets/cli": ^2.26.2
17861816
"@inquirer/prompts": ^7.1.0
1817+
"@rollup/plugin-json": ^6.1.0
17871818
"@rollup/plugin-typescript": 11.1.0
17881819
"@types/ncp": 2.0.5
17891820
"@types/node": 18.16.0
@@ -3847,6 +3878,13 @@ __metadata:
38473878
languageName: node
38483879
linkType: hard
38493880

3881+
"picomatch@npm:^4.0.2":
3882+
version: 4.0.2
3883+
resolution: "picomatch@npm:4.0.2"
3884+
checksum: a7a5188c954f82c6585720e9143297ccd0e35ad8072231608086ca950bee672d51b0ef676254af0788205e59bd4e4deb4e7708769226bed725bf13370a7d1464
3885+
languageName: node
3886+
linkType: hard
3887+
38503888
"pify@npm:^3.0.0":
38513889
version: 3.0.0
38523890
resolution: "pify@npm:3.0.0"

0 commit comments

Comments
 (0)