weapp-ide-cli 5.2.3 → 5.2.5

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 CHANGED
@@ -202,6 +202,53 @@ if (isWeappIdeTopLevelCommand('preview')) {
202
202
  console.log(WEAPP_IDE_TOP_LEVEL_COMMAND_NAMES)
203
203
  ```
204
204
 
205
+ ### 6. 程序化 opened-session helper
206
+
207
+ 除了官方 CLI 透传和 automator 子命令,`weapp-ide-cli` 也提供了一组面向「已打开 DevTools 会话」的 helper。它们会优先复用当前项目对应的会话,在官方 HTTP / Tool 域能力可用时直接下发指令,减少再次拉起 IDE 或误打开项目选择页的概率。
208
+
209
+ 当前适合通过 helper 复用的能力包括:
210
+
211
+ - 获取当前 DevTools Tool 信息
212
+ - 通过已打开会话触发重新编译
213
+ - 通过已打开会话清理 compile / all 等缓存
214
+ - 获取、设置、刷新当前 ticket
215
+ - 获取当前测试账号列表
216
+
217
+ 如果你在用 `weapp-vite`,更推荐直接使用高层入口:
218
+
219
+ - `wv ide info`
220
+ - `wv ide test-accounts`
221
+ - `wv ide ticket`
222
+ - `wv ide ticket:set --ticket <value>`
223
+ - `wv ide ticket:refresh`
224
+
225
+ `weapp-ide-cli` 负责底层官方 CLI / HTTP / automator helper 封装,`weapp-vite` 则提供更适合开发流的终端交互与项目解析。
226
+
227
+ 程序化调用示例:
228
+
229
+ ```ts
230
+ import {
231
+ clearWechatIdeCacheByAutomator,
232
+ compileWechatIdeByAutomator,
233
+ getWechatIdeTicket,
234
+ getWechatIdeToolInfo,
235
+ } from 'weapp-ide-cli'
236
+
237
+ const projectPath = './dist/dev/mp-weixin'
238
+
239
+ await compileWechatIdeByAutomator({ projectPath })
240
+
241
+ const info = await getWechatIdeToolInfo({ projectPath })
242
+ const ticket = await getWechatIdeTicket({ projectPath })
243
+
244
+ await clearWechatIdeCacheByAutomator({
245
+ projectPath,
246
+ cleanType: 'compile',
247
+ })
248
+
249
+ console.log(info, ticket)
250
+ ```
251
+
205
252
  ## 路径与参数兼容
206
253
 
207
254
  - `-p` 会被自动替换为 `--project`,并且相对路径会解析为绝对路径。