@better-sol/cli 0.1.0-alpha.1

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/README.md ADDED
@@ -0,0 +1,148 @@
1
+ # @better-sol/cli
2
+
3
+ The Better Sol command-line tool. Scaffold programs, compile and deploy to Solana, generate database schemas, and import external programs.
4
+
5
+ No installation needed. Run with `npx` or `bunx`.
6
+
7
+ ## Commands
8
+
9
+ ### `init`
10
+
11
+ Set up a new project.
12
+
13
+ ```bash
14
+ npx @better-sol/cli init
15
+ ```
16
+
17
+ Creates a payer keypair at `keypair.json`, a `programs/` directory, and a `.gitignore`. Detects your existing Solana CLI keypair at `~/.config/solana/id.json` if you have one. Offers to install `better-sol` if a `package.json` exists.
18
+
19
+ | Flag | Description |
20
+ |---|---|
21
+ | `--force` | Overwrite existing files |
22
+ | `--skip-install` | Skip installing better-sol |
23
+
24
+ ### `create`
25
+
26
+ Scaffold a new program.
27
+
28
+ ```bash
29
+ npx @better-sol/cli create counter
30
+ ```
31
+
32
+ Generates `programs/counter.ts` with a working counter template and `.better-sol/counter.json` with the program keypair.
33
+
34
+ | Flag | Default | Description |
35
+ |---|---|---|
36
+ | `--dir <dir>` | `programs` | Output directory |
37
+ | `--force` | `false` | Overwrite existing files |
38
+
39
+ ### `deploy`
40
+
41
+ Compile and deploy to Solana.
42
+
43
+ ```bash
44
+ npx @better-sol/cli deploy
45
+ ```
46
+
47
+ Parses your TypeScript, generates Anchor Rust, compiles it via the cloud API, and deploys the binary. On devnet and testnet, automatically funds your payer if the balance is low.
48
+
49
+ | Flag | Default | Description |
50
+ |---|---|---|
51
+ | `--src <glob>` | `programs/**/*.ts` | Program source glob |
52
+ | `--program <name>` | all programs | Target a specific program |
53
+ | `--payer <path>` | `keypair.json` | Payer keypair path |
54
+ | `--cluster <cluster>` | `devnet` | `devnet`, `testnet`, `mainnet`, `localnet` |
55
+ | `--dry-run` | `false` | Generate Rust without compiling or deploying |
56
+ | `--verify` | `false` | Write Rust for verified builds |
57
+ | `--output <dir>` | `generated` | Output directory for Rust files |
58
+
59
+ ### `generate idl`
60
+
61
+ Import an external program from an on-chain address or a local IDL file.
62
+
63
+ ```bash
64
+ # From an on-chain program
65
+ npx @better-sol/cli generate idl 12b3t1cNiAUoYLiWFEnFa4w6qYxVAiqCWU7KZuzLPYtH
66
+
67
+ # From a local IDL JSON file
68
+ npx @better-sol/cli generate idl ./staking-idl.json
69
+ ```
70
+
71
+ Produces a typed `.ts` file in `generated/`. Detects whether the argument is an address or a file path automatically.
72
+
73
+ | Flag | Default | Description |
74
+ |---|---|---|
75
+ | `--out <path>` | `generated/<name>.ts` | Output file path |
76
+ | `--name <name>` | from IDL metadata | Override the program name |
77
+ | `--cluster <cluster>` | `mainnet` | Cluster for on-chain IDL fetch |
78
+
79
+ ### `generate db`
80
+
81
+ Generate a Drizzle ORM schema from your account definitions.
82
+
83
+ ```bash
84
+ npx @better-sol/cli generate db
85
+ ```
86
+
87
+ | Flag | Default | Description |
88
+ |---|---|---|
89
+ | `--dialect <dialect>` | `postgres` | `postgres`, `mysql`, or `sqlite` |
90
+ | `--out <path>` | `src/db/better-sol.ts` | Output file path |
91
+ | `--src <glob>` | from config | Program source glob |
92
+
93
+ ### `login`
94
+
95
+ Save your compiler API key.
96
+
97
+ ```bash
98
+ npx @better-sol/cli login
99
+ ```
100
+
101
+ Saves your key to `.better-sol/auth.json`. Without a key you get 5 compiles per hour. With a key, 100 per hour.
102
+
103
+ ### `verify`
104
+
105
+ Submit a deployed program for OtterSec verified-builds.
106
+
107
+ ```bash
108
+ npx @better-sol/cli verify counter --program-id <address>
109
+ ```
110
+
111
+ | Flag | Description |
112
+ |---|---|
113
+ | `--program-id <id>` | On-chain program ID to verify |
114
+ | `--lib-name <name>` | Rust library name (defaults to program name) |
115
+ | `--mount-path <path>` | Subdirectory with `Cargo.toml` (defaults to `generated/<name>`) |
116
+
117
+ ## Configuration
118
+
119
+ Create an optional `better-sol.config.ts` in your project root:
120
+
121
+ ```ts
122
+ import { defineConfig } from "@better-sol/cli"
123
+
124
+ export default defineConfig({
125
+ programs: "programs/**/*.ts",
126
+ cluster: "devnet",
127
+ out: "generated",
128
+ payer: "./keypair.json",
129
+ })
130
+ ```
131
+
132
+ All fields are optional. CLI flags override config values. The `payer` field is only needed when you use a keypair outside the project directory.
133
+
134
+ ## The flow
135
+
136
+ ```
137
+ init ──→ keypair.json + programs/ + .gitignore
138
+
139
+ └──→ create counter ──→ programs/counter.ts + .better-sol/counter.json
140
+
141
+ └──→ deploy ──→ on-chain program
142
+
143
+ └──→ betterSol({ programs: { counter } }) ──→ typed client
144
+ ```
145
+
146
+ ## License
147
+
148
+ MIT