Skip to content

Commit d5396c0

Browse files
authored
feat: postinstall scripts and bin (#1)
* add constants related to storage * postinstall script directories initialization * add bin cli
1 parent 16fe43d commit d5396c0

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

bin/cli

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env node
2+
require(require("path").join(__dirname, "..", "build", "cli.js"));

src/cli.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Command } from "commander";
2+
3+
export default new Command("cwcli")
4+
.version("0.0.2")
5+
.description("Cosmwasm Command Line Interface")
6+
.usage("[command]")
7+
.parse(process.argv);

src/utils/constants.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import os from "os";
2+
import path from "path";
3+
4+
export const STORAGE_PATH = path.join(os.homedir(), ".cwcli");
5+
6+
export const KEYS_PATH = path.join(STORAGE_PATH, "keys.json");
7+
export const NETWORKS_PATH = path.join(STORAGE_PATH, "custom_networks.json");
8+
export const CONFIG_PATH = path.join(STORAGE_PATH, "config.json");

src/utils/postinstall.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import fs from "fs";
2+
import { KEYS_PATH, CONFIG_PATH, STORAGE_PATH } from "./constants";
3+
4+
(() => {
5+
if (!fs.existsSync(STORAGE_PATH)) fs.mkdirSync(STORAGE_PATH);
6+
if (!fs.existsSync(KEYS_PATH)) fs.writeFileSync(KEYS_PATH, JSON.stringify({}));
7+
if (!fs.existsSync(CONFIG_PATH)) fs.writeFileSync(CONFIG_PATH, JSON.stringify({}));
8+
})();

0 commit comments

Comments
 (0)