@jskit-ai/jskit-cli 0.2.72 → 0.2.73

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.
@@ -0,0 +1,196 @@
1
+ const MOBILE_COMMAND_DEFINITIONS = Object.freeze({
2
+ add: Object.freeze({
3
+ name: "add",
4
+ summary: "Install Capacitor mobile-shell support into the current app.",
5
+ usage: "jskit mobile add capacitor [--dry-run] [--devlinks]",
6
+ options: Object.freeze([
7
+ Object.freeze({
8
+ label: "--devlinks",
9
+ description: "Run npm run --if-present devlinks after install for local development relinking."
10
+ }),
11
+ Object.freeze({
12
+ label: "--dry-run",
13
+ description: "Preview the package install and generated files without mutating package.json, lockfiles, or app files."
14
+ })
15
+ ]),
16
+ defaults: Object.freeze([
17
+ "Installs @jskit-ai/mobile-capacitor plus the required Capacitor packages.",
18
+ "Renders capacitor.config.json and .jskit/mobile-capacitor.md from config.mobile.",
19
+ "Runs npm install and then cap add android unless --dry-run is used.",
20
+ "Use --devlinks only when you want npm run devlinks to relink the app after install.",
21
+ "If android/ already exists, the Capacitor CLI add step is skipped."
22
+ ])
23
+ }),
24
+ sync: Object.freeze({
25
+ name: "sync",
26
+ summary: "Build the JSKIT web client and sync the Android Capacitor shell.",
27
+ usage: "jskit mobile sync android [--dry-run] [--devlinks]",
28
+ options: Object.freeze([
29
+ Object.freeze({
30
+ label: "--devlinks",
31
+ description: "If sync needs to run npm install first, also run npm run --if-present devlinks afterward."
32
+ }),
33
+ Object.freeze({
34
+ label: "--dry-run",
35
+ description: "Preview the build and Capacitor sync commands without writing dist output or mutating the Android shell."
36
+ })
37
+ ]),
38
+ defaults: Object.freeze([
39
+ "Runs npm run build so dist/ matches the current JSKIT web client.",
40
+ "Runs cap sync android after the frontend build succeeds.",
41
+ "Requires capacitor.config.json and android/ from jskit mobile add capacitor."
42
+ ])
43
+ }),
44
+ run: Object.freeze({
45
+ name: "run",
46
+ summary: "Launch the Android Capacitor shell for the current app.",
47
+ usage: "jskit mobile run android [--target <device-id>] [--dry-run]",
48
+ options: Object.freeze([
49
+ Object.freeze({
50
+ label: "--target <device-id>",
51
+ description: "Optional adb device serial forwarded to cap run android --target."
52
+ }),
53
+ Object.freeze({
54
+ label: "--dry-run",
55
+ description: "Preview the sync/run commands without mutating dist output or launching the Android shell."
56
+ })
57
+ ]),
58
+ defaults: Object.freeze([
59
+ "Refreshes dist/ and syncs the Android shell before cap run android.",
60
+ "Dev-server mode still uses the live server URL from config.mobile at runtime."
61
+ ])
62
+ }),
63
+ dev: Object.freeze({
64
+ name: "dev",
65
+ summary: "Run the local Android phone workflow: sync, install/run, then create the adb reverse tunnel.",
66
+ usage: "jskit mobile dev android [--target <device-id>]",
67
+ options: Object.freeze([
68
+ Object.freeze({
69
+ label: "--target <device-id>",
70
+ description: "Optional adb device serial. If omitted, uses the first device from adb devices -l."
71
+ })
72
+ ]),
73
+ defaults: Object.freeze([
74
+ "Runs jskit mobile sync android first.",
75
+ "Runs jskit mobile run android --target <device-id> without re-syncing a second time.",
76
+ "Runs jskit mobile tunnel android --target <device-id> last so local backend traffic reaches your laptop."
77
+ ])
78
+ }),
79
+ devices: Object.freeze({
80
+ name: "devices",
81
+ summary: "List Android devices currently visible to adb.",
82
+ usage: "jskit mobile devices android",
83
+ options: Object.freeze([]),
84
+ defaults: Object.freeze([
85
+ "Runs adb devices -l and prints the currently connected Android targets."
86
+ ])
87
+ }),
88
+ tunnel: Object.freeze({
89
+ name: "tunnel",
90
+ summary: "Create and verify an adb reverse tunnel for local Android testing.",
91
+ usage: "jskit mobile tunnel android --target <device-id> [--port <port>]",
92
+ options: Object.freeze([
93
+ Object.freeze({
94
+ label: "--target <device-id>",
95
+ description: "Required adb device serial to tunnel to."
96
+ }),
97
+ Object.freeze({
98
+ label: "--port <port>",
99
+ description: "Optional local/backend port. Defaults to the loopback port from config.mobile.apiBaseUrl."
100
+ })
101
+ ]),
102
+ defaults: Object.freeze([
103
+ "Runs adb -s <target> reverse tcp:<port> tcp:<port>.",
104
+ "Runs adb -s <target> reverse --list after setup so the active tunnel is visible."
105
+ ])
106
+ }),
107
+ restart: Object.freeze({
108
+ name: "restart",
109
+ summary: "Clear app data and cold-start the Android shell on a chosen device.",
110
+ usage: "jskit mobile restart android --target <device-id>",
111
+ options: Object.freeze([
112
+ Object.freeze({
113
+ label: "--target <device-id>",
114
+ description: "Required adb device serial to restart."
115
+ })
116
+ ]),
117
+ defaults: Object.freeze([
118
+ "Runs adb shell pm clear for the configured Android package name.",
119
+ "Force-stops the app, then cold-starts MainActivity."
120
+ ])
121
+ }),
122
+ build: Object.freeze({
123
+ name: "build",
124
+ summary: "Build a release Android App Bundle for the current app.",
125
+ usage: "jskit mobile build android [--dry-run]",
126
+ options: Object.freeze([
127
+ Object.freeze({
128
+ label: "--dry-run",
129
+ description: "Preview the sync/build commands without writing dist output or running Gradle."
130
+ })
131
+ ]),
132
+ defaults: Object.freeze([
133
+ 'Requires config.mobile.assetMode to stay on "bundled" for release builds.',
134
+ "Runs the JSKIT web build, syncs Android, and then executes the Gradle bundleRelease task."
135
+ ])
136
+ }),
137
+ doctor: Object.freeze({
138
+ name: "doctor",
139
+ summary: "Validate the Android Capacitor shell wiring for the current app.",
140
+ usage: "jskit mobile doctor",
141
+ options: Object.freeze([]),
142
+ defaults: Object.freeze([
143
+ "Checks config.mobile, capacitor.config.json, android/, and the managed AndroidManifest deep-link filter."
144
+ ])
145
+ })
146
+ });
147
+
148
+ function listMobileCommandDefinitions() {
149
+ return Object.values(MOBILE_COMMAND_DEFINITIONS)
150
+ .sort((left, right) => left.name.localeCompare(right.name));
151
+ }
152
+
153
+ function resolveMobileCommandDefinition(rawName = "") {
154
+ const normalizedName = String(rawName || "").trim();
155
+ if (!normalizedName) {
156
+ return null;
157
+ }
158
+ return MOBILE_COMMAND_DEFINITIONS[normalizedName] || null;
159
+ }
160
+
161
+ function buildMobileCommandOptionMeta(subcommandName = "") {
162
+ const definition = resolveMobileCommandDefinition(subcommandName);
163
+ const optionMeta = {
164
+ help: { inputType: "flag" }
165
+ };
166
+
167
+ if (!definition) {
168
+ return optionMeta;
169
+ }
170
+
171
+ if (definition.name === "add" || definition.name === "sync" || definition.name === "run" || definition.name === "build") {
172
+ optionMeta["dry-run"] = { inputType: "flag" };
173
+ }
174
+ if (definition.name === "run") {
175
+ optionMeta.target = { inputType: "text" };
176
+ }
177
+ if (definition.name === "dev") {
178
+ optionMeta.target = { inputType: "text" };
179
+ }
180
+ if (definition.name === "tunnel") {
181
+ optionMeta.target = { inputType: "text" };
182
+ optionMeta.port = { inputType: "text" };
183
+ }
184
+ if (definition.name === "restart") {
185
+ optionMeta.target = { inputType: "text" };
186
+ }
187
+
188
+ return optionMeta;
189
+ }
190
+
191
+ export {
192
+ MOBILE_COMMAND_DEFINITIONS,
193
+ listMobileCommandDefinitions,
194
+ resolveMobileCommandDefinition,
195
+ buildMobileCommandOptionMeta
196
+ };