@gopay/minikit-cli 1.2.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.
Files changed (3) hide show
  1. package/README.md +322 -0
  2. package/dist/js/index.js +470 -0
  3. package/package.json +64 -0
package/README.md ADDED
@@ -0,0 +1,322 @@
1
+ # @gopay/minikit-cli
2
+
3
+ A CLI tool for scaffolding and managing GoPay mini-app web projects.
4
+
5
+ ## Prerequisites
6
+
7
+ **Bun** — a fast JavaScript runtime and package manager used to run the CLI.
8
+
9
+ ```bash
10
+ bun --version
11
+ ```
12
+
13
+ If it's not installed:
14
+
15
+ ```bash
16
+ curl -fsSL https://bun.com/install | bash -s "bun-v1.3.14"
17
+ ```
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ bun install -g @gopay/minikit-cli
23
+ ```
24
+
25
+ Verify the installation:
26
+
27
+ ```bash
28
+ minikit-cli --version
29
+ ```
30
+
31
+ ## Complete Command Reference
32
+
33
+ ### Command Groups
34
+
35
+ | Group | Commands |
36
+ |---|---|
37
+ | **Project scaffolding** | `create` |
38
+ | **Feature commands** | `jsbridge:add`, `jsbridge:remove`, `i18n:add`, `snap:add`, `vconsole:add` |
39
+ | **CLI management** | `update`, `migrate` |
40
+ | **Utilities** | `docs`, `--help` |
41
+
42
+ <a name="create"></a>
43
+
44
+ ## `create`
45
+
46
+ Scaffolds a new mini-app project interactively.
47
+
48
+ ```bash
49
+ minikit-cli create [project_name] [options]
50
+ ```
51
+
52
+ **Arguments**
53
+
54
+ | Argument | Required | Description |
55
+ |---|---|---|
56
+ | `project_name` | No (prompted) | Name of the project to create |
57
+
58
+ **Options**
59
+
60
+ | Flag | Description |
61
+ |---|---|
62
+ | `--no-install` | Skip dependency installation |
63
+ | `--project-dir <path>` | Target directory to create the project in (defaults to current directory) |
64
+
65
+ **Examples**
66
+
67
+ ```bash
68
+ # Fully interactive — prompts for everything
69
+ minikit-cli create
70
+
71
+ # Skip the name prompt, still prompts for features
72
+ minikit-cli create my-app
73
+
74
+ # Create project without installing dependencies
75
+ minikit-cli create my-app --no-install
76
+
77
+ # Create project in a specific directory
78
+ minikit-cli create my-app --project-dir /tmp/scaffolds --no-install
79
+ ```
80
+
81
+ **Interactive prompt flow**
82
+
83
+ When run interactively (with a TTY), the wizard walks through the following steps in order:
84
+
85
+ 1. **Project name** — text input (skipped if passed as an argument)
86
+ ```
87
+ Project name? › my-app
88
+ ```
89
+
90
+ 2. **Framework** — single select
91
+ ```
92
+ Choose framework:
93
+ ● React + TypeScript
94
+ ```
95
+
96
+ 3. **Install dependencies** — confirmation
97
+ ```
98
+ Install dependencies with pnpm? › yes / no
99
+ ```
100
+
101
+ 4. **Features** — multi-select (space to toggle, enter to confirm)
102
+ ```
103
+ Select features to include:
104
+ ◯ Auth
105
+ ◯ i18n
106
+ ◯ Snap Checkout
107
+ ```
108
+
109
+ 5. **Per-feature options** — shown immediately after each selected feature. For example, selecting **Auth** shows:
110
+ ```
111
+ When to fetch auth code?
112
+ ● Before app renders (fetch Auth Code first)
113
+ ○ After app renders (fetch Auth Code after UI loads)
114
+ ```
115
+
116
+ 6. **Debug tools** — multi-select
117
+ ```
118
+ Select debug tools:
119
+ ◯ vConsole
120
+ ```
121
+
122
+ **After the wizard completes**, the CLI prints next steps:
123
+
124
+ ```
125
+ 1. cd my-app
126
+ 2. source "$HOME/.nvm/nvm.sh" && nvm use
127
+ 3. cp .env.example .env (update .env values based on your project)
128
+ 4. pnpm install (only shown if deps were not installed)
129
+ 5. pnpm dev
130
+ ```
131
+
132
+ **Important notes:**
133
+
134
+ - **NVM (`source "$HOME/.nvm/nvm.sh" && nvm use`):** Loads the NVM shell integration and switches to the Node version specified in `.nvmrc`. Run this every time you:
135
+ - Switch to a different project folder
136
+ - Open a new terminal/shell session
137
+ - If nvm isn't configured to auto-load in your shell config (`.bashrc`, `.zshrc`)
138
+ - This ensures `pnpm` and other tools use the correct Node version for your project
139
+
140
+ - **`.env` configuration:** After copying `.env.example` to `.env`, **update the values according to your project requirements**. Each environment variable is documented in the `.env.example` file with examples and descriptions.
141
+
142
+ ---
143
+
144
+ <a name="jsbridgeadd"></a>
145
+
146
+ ## `jsbridge:add`
147
+
148
+ Add a Host App method to call from your Mini App.
149
+
150
+ ```bash
151
+ minikit-cli jsbridge:add [className] [methodName] [options]
152
+ ```
153
+
154
+ **Arguments**
155
+
156
+ | Argument | Format | Example |
157
+ |---|---|---|
158
+ | `className` | PascalCase | `GPAuth`, `GPWallet` |
159
+ | `methodName` | camelCase | `getToken`, `getBalance` |
160
+
161
+ Both arguments are optional — omit either to be prompted.
162
+
163
+ **Options**
164
+
165
+ | Option | Alias | Description |
166
+ |---|---|---|
167
+ | `--cache` | `-c` | Cache the result for the session lifetime |
168
+
169
+ **Examples**
170
+
171
+ ```bash
172
+ minikit-cli jsbridge:add
173
+ minikit-cli jsbridge:add GPAuth getToken --cache
174
+ ```
175
+
176
+ This creates a handler in `src/bridge/handlers/` and automatically exports it.
177
+
178
+ <a name="jsbridgeremove"></a>
179
+
180
+ ## `jsbridge:remove`
181
+
182
+ Remove a previously added JS Bridge method and its generated hook.
183
+
184
+ ```bash
185
+ minikit-cli jsbridge:remove [className] [methodName]
186
+ ```
187
+
188
+ Both arguments are optional — omit either to pick from a list.
189
+
190
+ **Examples**
191
+
192
+ ```bash
193
+ minikit-cli jsbridge:remove
194
+ minikit-cli jsbridge:remove GPAuth getToken
195
+ ```
196
+
197
+ This cleans up the handler files and associated exports.
198
+
199
+ <a name="i18nadd"></a>
200
+
201
+ ## `i18n:add`
202
+
203
+ Add multi-language support with JSON-based translations.
204
+
205
+ ```bash
206
+ minikit-cli i18n:add
207
+ ```
208
+
209
+ Translations are stored and managed in local JSON files, which is simple and suitable for projects needing basic internationalization.
210
+
211
+ <a name="snapadd"></a>
212
+
213
+ ## `snap:add`
214
+
215
+ Add Snap Checkout (Midtrans) payment integration.
216
+
217
+ ```bash
218
+ minikit-cli snap:add
219
+ ```
220
+
221
+ No options or prompts — fully automatic. Generates a Snap Checkout page, registers a `/snap-checkout` route, and adds required env keys to `.env.example`.
222
+
223
+ <a name="vconsoleadd"></a>
224
+
225
+ ## `vconsole:add`
226
+
227
+ Add vConsole, an in-app debug panel.
228
+
229
+ ```bash
230
+ minikit-cli vconsole:add
231
+ ```
232
+
233
+ No options or prompts — fully automatic. Provides a mobile-friendly console for viewing logs and debugging the app. Active in dev mode by default.
234
+
235
+ <a name="update"></a>
236
+
237
+ ## `update`
238
+
239
+ Update the MiniKit CLI itself to the latest published version.
240
+
241
+ ```bash
242
+ minikit-cli update [options]
243
+ ```
244
+
245
+ **Options**
246
+
247
+ | Option | Description |
248
+ |---|---|
249
+ | `--check` | Report current vs. latest version without installing |
250
+ | `--tag <tag>` | dist-tag to resolve. Defaults to `beta` for prerelease installs, `latest` for stable. |
251
+
252
+ **Examples**
253
+
254
+ ```bash
255
+ minikit-cli update
256
+ minikit-cli update --check
257
+ minikit-cli update --tag latest
258
+ ```
259
+
260
+ Run `minikit-cli migrate` inside each project after updating to apply project-level migrations.
261
+
262
+ <a name="migrate"></a>
263
+
264
+ ## `migrate`
265
+
266
+ Apply version-to-version migrations to an existing project. Run after `minikit-cli update`.
267
+
268
+ ```bash
269
+ minikit-cli migrate [target-version] [options]
270
+ ```
271
+
272
+ **Options**
273
+
274
+ | Option | Description |
275
+ |---|---|
276
+ | `--to <version>` | Migrate only up to this version |
277
+ | `--dry-run` | Show the migration plan without applying changes |
278
+ | `--check` | Report the project's current version vs. the latest reachable version |
279
+
280
+ **Examples**
281
+
282
+ ```bash
283
+ minikit-cli migrate
284
+ minikit-cli migrate --dry-run
285
+ minikit-cli migrate --to 1.3.0
286
+ minikit-cli migrate --check
287
+ ```
288
+
289
+ <a name="docs"></a>
290
+
291
+ ## `docs`
292
+
293
+ List or search documentation links.
294
+
295
+ ```bash
296
+ minikit-cli docs [keyword]
297
+ ```
298
+
299
+ **Examples**
300
+
301
+ ```bash
302
+ minikit-cli docs
303
+ minikit-cli docs jsbridge
304
+ ```
305
+
306
+ Search is case-insensitive, matches document names and titles.
307
+
308
+ ## Getting help
309
+
310
+ Every command supports `--help`:
311
+
312
+ ```bash
313
+ minikit-cli --help
314
+ minikit-cli create --help
315
+ minikit-cli update --help
316
+ minikit-cli migrate --help
317
+ minikit-cli jsbridge:add --help
318
+ minikit-cli jsbridge:remove --help
319
+ minikit-cli snap:add --help
320
+ minikit-cli vconsole:add --help
321
+ minikit-cli i18n:add --help
322
+ ```