magic-builder 0.1.0 → 0.1.2

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,139 @@
1
+ # magic-builder
2
+
3
+ CLI for Magic Builder (妙笔): publish HTML pages, deploy FaaS functions, upload assets, generate links, and install the Magic Builder Codex skill.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -g magic-builder
9
+ ```
10
+
11
+ With Bun:
12
+
13
+ ```bash
14
+ bun add -g magic-builder
15
+ ```
16
+
17
+ The package provides three equivalent command names:
18
+
19
+ ```bash
20
+ magic-builder --help
21
+ magic-cli --help
22
+ miaobi --help
23
+ ```
24
+
25
+ You can also run it without installing:
26
+
27
+ ```bash
28
+ npx magic-builder help
29
+ bunx magic-builder help
30
+ ```
31
+
32
+ ## Authentication
33
+
34
+ Most write operations need a Magic developer token.
35
+
36
+ ```bash
37
+ magic-builder auth login
38
+ ```
39
+
40
+ Manual token setup:
41
+
42
+ ```bash
43
+ magic-builder auth set <token>
44
+ magic-builder auth show
45
+ ```
46
+
47
+ Token lookup order:
48
+
49
+ 1. `--token`
50
+ 2. `MAGIC_TOKEN`
51
+ 3. `~/.magic-token`
52
+ 4. project `.magic-token`
53
+
54
+ ## Common Commands
55
+
56
+ Publish an HTML page:
57
+
58
+ ```bash
59
+ magic-builder page publish app.html --title "Dashboard"
60
+ ```
61
+
62
+ List or export pages:
63
+
64
+ ```bash
65
+ magic-builder page list --scope mine
66
+ magic-builder page list --scope public --title demo
67
+ magic-builder page export --id <id> --out app.html
68
+ ```
69
+
70
+ Deploy a FaaS function:
71
+
72
+ ```bash
73
+ magic-builder faas publish handler.js --name report-api
74
+ ```
75
+
76
+ Upload an asset:
77
+
78
+ ```bash
79
+ magic-builder asset upload logo.png
80
+ ```
81
+
82
+ Generate a Magic link:
83
+
84
+ ```bash
85
+ magic-builder link create --title "Weekly Report"
86
+ magic-builder link create --fid <faas-id>
87
+ ```
88
+
89
+ Create or append a Feishu document HTML Box:
90
+
91
+ ```bash
92
+ magic-builder doc create --html app.html --title "Demo"
93
+ magic-builder doc append --html app.html --doc-token <docx-token>
94
+ ```
95
+
96
+ Install or update the Magic Builder Codex skill:
97
+
98
+ ```bash
99
+ magic-builder skill install
100
+ magic-builder skill check-update
101
+ magic-builder skill update
102
+ ```
103
+
104
+ Check local environment:
105
+
106
+ ```bash
107
+ magic-builder doctor
108
+ magic-builder config get
109
+ ```
110
+
111
+ ## Help
112
+
113
+ All of these forms are supported:
114
+
115
+ ```bash
116
+ magic-builder help
117
+ magic-builder help page
118
+ magic-builder page help
119
+ magic-builder page publish help
120
+ magic-builder man
121
+ ```
122
+
123
+ `--help`, `-h`, and `--man` are also supported.
124
+
125
+ ## Global Options
126
+
127
+ ```text
128
+ --base-url, --magic-base-url <url> Magic service base URL
129
+ --token <token> Auth token override
130
+ --format json|table|plain Output format, default json
131
+ --quiet, -q Suppress progress messages
132
+ --version, -v Show version
133
+ ```
134
+
135
+ Default Magic service:
136
+
137
+ ```text
138
+ https://magic.solutionsuite.cn
139
+ ```
@@ -82,6 +82,16 @@ async function main() {
82
82
  process.exit(0);
83
83
  }
84
84
 
85
+ if (argv[0] === 'help') {
86
+ process.stdout.write(renderHelp('help', argv[1]) + '\n');
87
+ process.exit(0);
88
+ }
89
+
90
+ if (argv[0] === 'man') {
91
+ process.stdout.write(renderHelp('man') + '\n');
92
+ process.exit(0);
93
+ }
94
+
85
95
  const { command, args, opts } = parseGlobalArgs(argv);
86
96
 
87
97
  if (!command) {
@@ -89,6 +99,11 @@ async function main() {
89
99
  process.exit(0);
90
100
  }
91
101
 
102
+ if (args[0] === 'help' || args[1] === 'help') {
103
+ process.stdout.write(renderHelp('help', command) + '\n');
104
+ process.exit(0);
105
+ }
106
+
92
107
  try {
93
108
  await COMMANDS[command].run(args, opts);
94
109
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magic-builder",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "CLI for Magic Builder — publish pages, functions, and files",
5
5
  "bin": {
6
6
  "magic-builder": "./bin/magic-builder.js",
package/src/lib/help.js CHANGED
@@ -8,6 +8,10 @@ BRIEF: CLI for Magic Builder (妙笔).
8
8
 
9
9
  SYNTAX:
10
10
  magic-builder <command> <subcommand> [options]
11
+ magic-builder <command> help
12
+ magic-builder <command> <subcommand> help
13
+ magic-builder help [command]
14
+ magic-builder man
11
15
 
12
16
  COMMANDS:
13
17
  auth Login and manage Magic developer tokens
@@ -23,6 +27,9 @@ COMMANDS:
23
27
 
24
28
  EXAMPLES:
25
29
  magic-builder auth login
30
+ magic-builder help page
31
+ magic-builder page help
32
+ magic-builder page publish help
26
33
  magic-builder page publish app.html --title "Dashboard"
27
34
  magic-builder page list --scope mine
28
35
  magic-builder page export --id recxxx --out app.html
@@ -53,6 +60,10 @@ GLOBAL OPTIONS:
53
60
  --version, -v Show version
54
61
  --help, -h Show help
55
62
  --man Show full manual
63
+ help [command] Show general or command help
64
+ <command> help Show command help
65
+ <command> <subcommand> help Show command help
66
+ man Show full manual
56
67
 
57
68
  COMMANDS:
58
69
  auth login [--no-open] [--timeout <seconds>] [--interval <seconds>]