wpops 0.1.0 → 0.1.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 CHANGED
@@ -1,5 +1,10 @@
1
1
  # wpops
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/wpops.svg)](https://www.npmjs.com/package/wpops)
4
+ [![npm downloads](https://img.shields.io/npm/dm/wpops.svg)](https://www.npmjs.com/package/wpops)
5
+ [![license](https://img.shields.io/npm/l/wpops.svg)](LICENSE)
6
+ [![node](https://img.shields.io/node/v/wpops.svg)](package.json)
7
+
3
8
  > WordPress REST operations toolkit — a zero-dependency CLI (plus agent skill) to manage posts, pages, media, comments, users and plugins across one or many sites.
4
9
 
5
10
  WordPress REST 操作工具。只依赖 Node 内置能力(无第三方包),用应用密码通过
@@ -33,7 +38,20 @@ cd wpops
33
38
  ./install.ps1 # Windows;macOS/Linux 用 sh install.sh(装 CLI + skill)
34
39
  ```
35
40
 
36
- 不 clone 也行:`pnpm add -g github:qnnp-me/wpops`,再加
41
+ 不想 clone?一行流(脚本不在仓库内时会自动 `git clone`):
42
+
43
+ ```powershell
44
+ iwr -useb https://raw.githubusercontent.com/qnnp-me/wpops/main/install.ps1 | iex # Windows
45
+ ```
46
+
47
+ ```sh
48
+ curl -fsSL https://raw.githubusercontent.com/qnnp-me/wpops/main/install.sh | sh # macOS/Linux
49
+ ```
50
+
51
+ > 若 `raw.githubusercontent.com` 访问不了,可换 jsDelivr 镜像:
52
+ > `https://cdn.jsdelivr.net/gh/qnnp-me/wpops@main/install.ps1`(或 `.sh`)。
53
+
54
+ 也可以直接用 git 依赖:`pnpm add -g github:qnnp-me/wpops`,再加
37
55
  `npx skills add qnnp-me/wpops --skill wpops -a opencode -g`。
38
56
 
39
57
  **发布(维护者)**
package/bin/wpops.js CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { readFileSync } from 'node:fs';
2
3
  import { loadEnv, listSites } from '../lib/env.js';
3
4
  import { buildConfig, createClient, WpError } from '../lib/client.js';
4
5
  import { parseArgs, isMutation } from '../lib/args.js';
@@ -9,11 +10,21 @@ function printJson(value) {
9
10
  console.log(JSON.stringify(value, null, 2));
10
11
  }
11
12
 
13
+ function version() {
14
+ try {
15
+ return JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
16
+ } catch {
17
+ return 'unknown';
18
+ }
19
+ }
20
+
12
21
  function printHelp() {
13
22
  console.log(`wpops —— WordPress REST 操作工具
14
23
 
15
24
  用法: wpops [--site 名字 | --all] <组> <动作> [参数] [--flags]
16
25
 
26
+ --version / -v 显示版本
27
+
17
28
  setup 交互式配置一个站点(写入 sites/<名字>.env 并体检)
18
29
  doctor 连接与权限体检(先跑这个)
19
30
  me 当前用户与能力
@@ -261,6 +272,10 @@ async function main() {
261
272
  const { positionals, flags } = parseArgs(process.argv.slice(2));
262
273
  const [group, action, ...rest] = positionals;
263
274
 
275
+ if (flags.version) {
276
+ console.log(version());
277
+ return;
278
+ }
264
279
  if (!group || group === 'help' || flags.help) {
265
280
  printHelp();
266
281
  return;
package/lib/args.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // 已知的布尔开关:遇到它们不吞下一个参数,避免 `--json -s a` 把 -s 当值。
2
- const BOOLEAN_FLAGS = new Set(['json', 'force', 'activate', 'dry-run', 'yes', 'all', 'help']);
2
+ const BOOLEAN_FLAGS = new Set(['json', 'force', 'activate', 'dry-run', 'yes', 'all', 'help', 'version']);
3
3
 
4
4
  /** 解析命令行。支持 --flag value、--flag=value、布尔 --flag、以及 -s/-a/-h/-y。 */
5
5
  export function parseArgs(argv) {
@@ -23,6 +23,10 @@ export function parseArgs(argv) {
23
23
  flags.yes = true;
24
24
  continue;
25
25
  }
26
+ if (arg === '-v' || arg === '--version') {
27
+ flags.version = true;
28
+ continue;
29
+ }
26
30
  if (arg.startsWith('--')) {
27
31
  const eq = arg.indexOf('=');
28
32
  if (eq !== -1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wpops",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "WordPress REST operations toolkit — manage posts, pages, media, comments, users and plugins from the CLI. Multi-site, safety-first, zero dependencies.",
5
5
  "license": "MIT",
6
6
  "author": "qnnp",