@share-crm/sharecrm-cli 1.1.0 → 1.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 CHANGED
@@ -1,293 +1,293 @@
1
- # sharecrm CLI Client
2
-
3
- `fs-cli-client` 是 `sharecrm` 命令行客户端的源码目录,用于访问远程命令能力,支持 OAuth 设备码登录、远程命令执行、命令帮助查询和请求级调试输出。
4
-
5
- - Node.js: `>=18.17`
6
- - npm package: `sharecrm`
7
- - CLI 命令名: `sharecrm`
8
-
9
- ## 功能概览
10
-
11
- - OAuth 设备码登录
12
- - 本地登录状态查询与退出登录
13
- - 远程命令执行
14
- - 本地帮助和远程命令帮助
15
- - `--debug` 调试输出
16
- - 会话元数据与密钥分离存储
17
-
18
- ## 平台支持
19
-
20
- 当前代码按平台选择不同的本地 secret store 后端:
21
-
22
- | 平台 | 默认配置目录 | secret store |
23
- | --- | --- | --- |
24
- | macOS | `~/.sharecrm-cli` | Keychain 保存主密钥,本地文件保存加密后的 secret |
25
- | Linux | `~/.sharecrm-cli` | 本地 `keychain/` 目录保存主密钥和加密后的 secret |
26
- | Windows | `%USERPROFILE%\\.sharecrm-cli` | PowerShell + DPAPI + `HKCU:\\Software\\sharecrm-cli\\keychain` |
27
-
28
- 说明:
29
-
30
- - 所有平台都会在配置目录下保存 `config.json`、会话锁文件和命令缓存。
31
- - Windows 运行依赖 `powershell.exe`。
32
- - `FS_CLI_CONFIG_DIR` 可覆盖默认配置目录。
33
-
34
- ## 安装
35
-
36
- ### 本地开发安装
37
-
38
- ```bash
39
- npm install
40
- npm run build
41
- npm link
42
- ```
43
-
44
- ### npm命令安装
45
- ```bash
46
- npm install -g sharecrm@1.1.6
47
- ```
48
- 安装完成后可直接执行:
49
-
50
- ```bash
51
- sharecrm --help
52
- ```
53
-
54
- ### 不全局链接的运行方式
55
-
56
- 构建后直接运行:
57
-
58
- ```bash
59
- node dist/index.js --help
60
- ```
61
-
62
- 或直接从源码调试启动:
63
-
64
- ```bash
65
- npm run build:debug -- --help
66
- ```
67
-
68
- ## 配置
69
-
70
- 通过环境变量配置认证地址、业务接口地址和本地状态目录:
71
-
72
- | 变量名 | 是否必需 | 默认值 | 说明 |
73
- | --- |-----------| --- | --- |
74
- | `FS_CLI_AUTH_BASE_URL` | 认证相关命令必需 | 构建产物中的运行时配置 | OAuth 设备码登录相关接口地址,必须为 `https://` |
75
- | `FS_CLI_API_BASE_URL` | 否 | 构建产物中的运行时配置 | 远程命令接口地址,必须为 `https://`。登录成功后如服务端返回 `apiUrl`,优先使用登录态中的地址 |
76
- | `FS_CLI_CONFIG_DIR` | 否 | `<homeDir>/.sharecrm-cli` | 本地配置、会话与缓存目录 |
77
- | `FS_CLI_DEFAULT_CLIENT_ID` | 否 | 构建产物中的默认值 | OAuth 设备码登录使用的客户端 ID |
78
-
79
- `homeDir` 的解析规则:
80
-
81
- - macOS / Linux: 优先使用 `os.homedir()`,为空时回退到 `HOME`
82
- - Windows: 优先使用 `os.homedir()`,为空时回退到 `USERPROFILE`,再回退到 `HOMEDRIVE + HOMEPATH`
83
-
84
- ## 快速开始
85
-
86
- ### 1. 设置环境变量
87
-
88
- macOS / Linux:
89
-
90
- ```bash
91
- export FS_CLI_AUTH_BASE_URL="https://your-auth.example.com"
92
- export FS_CLI_API_BASE_URL="https://your-api.example.com/cli/"
93
- ```
94
-
95
- Windows PowerShell:
96
-
97
- ```powershell
98
- $env:FS_CLI_AUTH_BASE_URL = "https://your-auth.example.com"
99
- $env:FS_CLI_API_BASE_URL = "https://your-api.example.com/cli/"
100
- ```
101
-
102
- ### 2. 登录授权
103
-
104
- ```bash
105
- sharecrm auth login
106
- ```
107
-
108
- 执行后 CLI 会输出授权地址、设备验证码,并在授权完成后输出登录结果 JSON。例如:
109
-
110
- ```text
111
- 在浏览器中打开以下链接进行认证:
112
- https://your-auth.example.com/device
113
- 设备验证码: ABCD-EFGH
114
- 等待用户授权中...
115
- {
116
- "success": true,
117
- "userId": "user-1",
118
- "appId": "FSAID_xxx",
119
- "scope": [
120
- "crm"
121
- ]
122
- }
123
- ```
124
-
125
- ### 3. 查看帮助
126
-
127
- ```bash
128
- sharecrm --help
129
- sharecrm help
130
- sharecrm help crm
131
- sharecrm crm QueryRecords --help
132
- ```
133
-
134
- 说明:
135
-
136
- - 无登录态时,`sharecrm` 和 `sharecrm help` 仍会输出本地帮助
137
- - 已登录时,`sharecrm help <command...>` 会继续请求远程命令清单
138
-
139
- ### 4. 执行远程命令
140
-
141
- ```bash
142
- sharecrm knowledge search WebSearchAction -d '{"query":"北京有什么好玩的"}'
143
- ```
144
-
145
- 也可以把 JSON 放在命令最后一个参数:
146
-
147
- ```bash
148
- sharecrm knowledge search WebSearchAction '{"query":"北京有什么好玩的"}'
149
- ```
150
-
151
- 如果未传 `-d` / `--data` 且最后一个参数也不是 JSON,CLI 会默认发送空对象 `{}`。
152
-
153
- ## 命令说明
154
-
155
- ### 本地命令
156
-
157
- ```bash
158
- sharecrm auth login
159
- sharecrm auth status
160
- sharecrm auth logout
161
- sharecrm help [command...]
162
- sharecrm --help
163
- ```
164
-
165
- - `auth login`: 发起 OAuth 设备码登录
166
- - `auth status`: 输出当前登录状态 JSON
167
- - `auth logout`: 清理本地登录态
168
- - `help [command...]`: 显示本地帮助或远程命令帮助
169
-
170
- ### `auth status` 输出
171
-
172
- `sharecrm auth status` 输出 JSON,当前包含以下字段:
173
-
174
- - `appId`
175
- - `expiresAt`
176
- - `grantedAt`
177
- - `identity`
178
- - `scope`
179
- - `tokenStatus`
180
- - `userName`
181
- - `userId`
182
- - `cliVersion`
183
-
184
- 其中:
185
-
186
- - `tokenStatus = normal` 表示本地 access token 存在且未过期
187
- - `tokenStatus = needs_refresh` 表示 access token 缺失、过期,或本地仅剩会话元数据
188
-
189
- ### 远程命令
190
-
191
- ```bash
192
- sharecrm <command> -d '{...}'
193
- sharecrm <command> --data '{...}'
194
- sharecrm <command> '{...}'
195
- sharecrm <command>
196
- ```
197
-
198
- 参数规则:
199
-
200
- - `-d` 与 `--data` 等价
201
- - 如果最后一个参数看起来像 JSON(`{...}` 或 `[...]`),会被识别为请求参数
202
- - 如果都没有提供,则默认使用 `{}` 作为请求参数
203
- - CLI 会要求 `-d/--data` 对应的值必须是合法 JSON 对象
204
-
205
- ## 调试
206
-
207
- 全局 `--debug` 参数会把远程接口请求、响应和异常信息输出到 `stderr`:
208
-
209
- ```bash
210
- sharecrm --debug knowledge search WebSearchAction -d '{"query":"test"}'
211
- ```
212
-
213
- 说明:
214
-
215
- - `--debug` 是全局参数,建议放在命令前面
216
- - 正常结果输出到 `stdout`
217
- - 调试信息输出到 `stderr`
218
- - 遇到 `CliError` 时会附带结构化异常信息
219
-
220
- ## 认证与本地状态
221
-
222
- - `config.json` 仅保存 CLI 元数据和会话元数据,不保存 `accessToken` / `refreshToken`
223
- - `accessToken` / `refreshToken` 通过平台对应的 secret store 保存
224
- - 旧版明文 `session.json` 会在读取时尝试迁移
225
- - 当远程接口返回登录失效时,CLI 会尝试使用 `refreshToken` 刷新登录态
226
- - 刷新成功后会自动重试一次原请求
227
- - 刷新失败或缺少刷新所需信息时,会提示重新登录
228
-
229
- 重新登录提示示例:
230
-
231
- ```text
232
- 提示:登录状态已失效,请重新登录授权。
233
- 执行命令:sharecrm auth login
234
- ```
235
-
236
- ## 常见问题
237
-
238
- ### 1. 未登录无法执行远程命令
239
-
240
- 错误信息:
241
-
242
- ```text
243
- You must login before executing remote commands.
244
- sharecrm auth login
245
- ```
246
-
247
- 处理方式:
248
-
249
- ```bash
250
- sharecrm auth login
251
- ```
252
-
253
- ### 2. 登录状态已失效
254
-
255
- 错误信息:
256
-
257
- ```text
258
- 提示:登录状态已失效,请重新登录授权。
259
- 执行命令:sharecrm auth login
260
- ```
261
-
262
- 处理方式:重新执行登录。
263
-
264
- ### 3. 设备码过期或授权被拒绝
265
-
266
- 可能会看到类似错误:
267
-
268
- - `Device code expired. Please run auth login again.`
269
- - `Authorization was denied. Please try again after granting access.`
270
-
271
- 处理方式:重新执行 `sharecrm auth login`。
272
-
273
- ### 4. 缺少认证地址配置
274
-
275
- 如果 `FS_CLI_AUTH_BASE_URL` 未配置且构建产物中也没有有效默认值,认证相关命令会失败。
276
-
277
- ### 5. Windows secret store 异常
278
-
279
- Windows 下会话 secret 读取依赖 `powershell.exe` 与 DPAPI。若本地 secret 不可读,`sharecrm` 和 `sharecrm help` 会按未登录处理;远程命令执行仍需要重新登录或修复本地环境。
280
-
281
- ## 开发与测试
282
-
283
- ```bash
284
- npm run build
285
- npm run typecheck
286
- npm run lint
287
- npm test
288
- ```
289
-
290
- 说明:
291
-
292
- - `npm test` 会先执行构建,再运行 `vitest`
293
- - `npm run build:debug` 可直接从源码启动 CLI
1
+ # sharecrm CLI Client
2
+
3
+ `fs-cli-client` 是 `sharecrm` 命令行客户端的源码目录,用于访问远程命令能力,支持 OAuth 设备码登录、远程命令执行、命令帮助查询和请求级调试输出。
4
+
5
+ - Node.js: `>=18.17`
6
+ - npm package: `sharecrm`
7
+ - CLI 命令名: `sharecrm`
8
+
9
+ ## 功能概览
10
+
11
+ - OAuth 设备码登录
12
+ - 本地登录状态查询与退出登录
13
+ - 远程命令执行
14
+ - 本地帮助和远程命令帮助
15
+ - `--debug` 调试输出
16
+ - 会话元数据与密钥分离存储
17
+
18
+ ## 平台支持
19
+
20
+ 当前代码按平台选择不同的本地 secret store 后端:
21
+
22
+ | 平台 | 默认配置目录 | secret store |
23
+ | --- | --- | --- |
24
+ | macOS | `~/.sharecrm-cli` | Keychain 保存主密钥,本地文件保存加密后的 secret |
25
+ | Linux | `~/.sharecrm-cli` | 本地 `keychain/` 目录保存主密钥和加密后的 secret |
26
+ | Windows | `%USERPROFILE%\\.sharecrm-cli` | PowerShell + DPAPI + `HKCU:\\Software\\sharecrm-cli\\keychain` |
27
+
28
+ 说明:
29
+
30
+ - 所有平台都会在配置目录下保存 `config.json`、会话锁文件和命令缓存。
31
+ - Windows 运行依赖 `powershell.exe`。
32
+ - `FS_CLI_CONFIG_DIR` 可覆盖默认配置目录。
33
+
34
+ ## 安装
35
+
36
+ ### 本地开发安装
37
+
38
+ ```bash
39
+ npm install
40
+ npm run build
41
+ npm link
42
+ ```
43
+
44
+ ### npm命令安装
45
+ ```bash
46
+ npm install -g sharecrm@1.1.6
47
+ ```
48
+ 安装完成后可直接执行:
49
+
50
+ ```bash
51
+ sharecrm --help
52
+ ```
53
+
54
+ ### 不全局链接的运行方式
55
+
56
+ 构建后直接运行:
57
+
58
+ ```bash
59
+ node dist/index.js --help
60
+ ```
61
+
62
+ 或直接从源码调试启动:
63
+
64
+ ```bash
65
+ npm run build:debug -- --help
66
+ ```
67
+
68
+ ## 配置
69
+
70
+ 通过环境变量配置认证地址、业务接口地址和本地状态目录:
71
+
72
+ | 变量名 | 是否必需 | 默认值 | 说明 |
73
+ | --- |-----------| --- | --- |
74
+ | `FS_CLI_AUTH_BASE_URL` | 认证相关命令必需 | 构建产物中的运行时配置 | OAuth 设备码登录相关接口地址,必须为 `https://` |
75
+ | `FS_CLI_API_BASE_URL` | 否 | 构建产物中的运行时配置 | 远程命令接口地址,必须为 `https://`。登录成功后如服务端返回 `apiUrl`,优先使用登录态中的地址 |
76
+ | `FS_CLI_CONFIG_DIR` | 否 | `<homeDir>/.sharecrm-cli` | 本地配置、会话与缓存目录 |
77
+ | `FS_CLI_DEFAULT_CLIENT_ID` | 否 | 构建产物中的默认值 | OAuth 设备码登录使用的客户端 ID |
78
+
79
+ `homeDir` 的解析规则:
80
+
81
+ - macOS / Linux: 优先使用 `os.homedir()`,为空时回退到 `HOME`
82
+ - Windows: 优先使用 `os.homedir()`,为空时回退到 `USERPROFILE`,再回退到 `HOMEDRIVE + HOMEPATH`
83
+
84
+ ## 快速开始
85
+
86
+ ### 1. 设置环境变量
87
+
88
+ macOS / Linux:
89
+
90
+ ```bash
91
+ export FS_CLI_AUTH_BASE_URL="https://your-auth.example.com"
92
+ export FS_CLI_API_BASE_URL="https://your-api.example.com/cli/"
93
+ ```
94
+
95
+ Windows PowerShell:
96
+
97
+ ```powershell
98
+ $env:FS_CLI_AUTH_BASE_URL = "https://your-auth.example.com"
99
+ $env:FS_CLI_API_BASE_URL = "https://your-api.example.com/cli/"
100
+ ```
101
+
102
+ ### 2. 登录授权
103
+
104
+ ```bash
105
+ sharecrm auth login
106
+ ```
107
+
108
+ 执行后 CLI 会输出授权地址、设备验证码,并在授权完成后输出登录结果 JSON。例如:
109
+
110
+ ```text
111
+ 在浏览器中打开以下链接进行认证:
112
+ https://your-auth.example.com/device
113
+ 设备验证码: ABCD-EFGH
114
+ 等待用户授权中...
115
+ {
116
+ "success": true,
117
+ "userId": "user-1",
118
+ "appId": "FSAID_xxx",
119
+ "scope": [
120
+ "crm"
121
+ ]
122
+ }
123
+ ```
124
+
125
+ ### 3. 查看帮助
126
+
127
+ ```bash
128
+ sharecrm --help
129
+ sharecrm help
130
+ sharecrm help crm
131
+ sharecrm crm QueryRecords --help
132
+ ```
133
+
134
+ 说明:
135
+
136
+ - 无登录态时,`sharecrm` 和 `sharecrm help` 仍会输出本地帮助
137
+ - 已登录时,`sharecrm help <command...>` 会继续请求远程命令清单
138
+
139
+ ### 4. 执行远程命令
140
+
141
+ ```bash
142
+ sharecrm knowledge search WebSearchAction -d '{"query":"北京有什么好玩的"}'
143
+ ```
144
+
145
+ 也可以把 JSON 放在命令最后一个参数:
146
+
147
+ ```bash
148
+ sharecrm knowledge search WebSearchAction '{"query":"北京有什么好玩的"}'
149
+ ```
150
+
151
+ 如果未传 `-d` / `--data` 且最后一个参数也不是 JSON,CLI 会默认发送空对象 `{}`。
152
+
153
+ ## 命令说明
154
+
155
+ ### 本地命令
156
+
157
+ ```bash
158
+ sharecrm auth login
159
+ sharecrm auth status
160
+ sharecrm auth logout
161
+ sharecrm help [command...]
162
+ sharecrm --help
163
+ ```
164
+
165
+ - `auth login`: 发起 OAuth 设备码登录
166
+ - `auth status`: 输出当前登录状态 JSON
167
+ - `auth logout`: 清理本地登录态
168
+ - `help [command...]`: 显示本地帮助或远程命令帮助
169
+
170
+ ### `auth status` 输出
171
+
172
+ `sharecrm auth status` 输出 JSON,当前包含以下字段:
173
+
174
+ - `appId`
175
+ - `expiresAt`
176
+ - `grantedAt`
177
+ - `identity`
178
+ - `scope`
179
+ - `tokenStatus`
180
+ - `userName`
181
+ - `userId`
182
+ - `cliVersion`
183
+
184
+ 其中:
185
+
186
+ - `tokenStatus = normal` 表示本地 access token 存在且未过期
187
+ - `tokenStatus = needs_refresh` 表示 access token 缺失、过期,或本地仅剩会话元数据
188
+
189
+ ### 远程命令
190
+
191
+ ```bash
192
+ sharecrm <command> -d '{...}'
193
+ sharecrm <command> --data '{...}'
194
+ sharecrm <command> '{...}'
195
+ sharecrm <command>
196
+ ```
197
+
198
+ 参数规则:
199
+
200
+ - `-d` 与 `--data` 等价
201
+ - 如果最后一个参数看起来像 JSON(`{...}` 或 `[...]`),会被识别为请求参数
202
+ - 如果都没有提供,则默认使用 `{}` 作为请求参数
203
+ - CLI 会要求 `-d/--data` 对应的值必须是合法 JSON 对象
204
+
205
+ ## 调试
206
+
207
+ 全局 `--debug` 参数会把远程接口请求、响应和异常信息输出到 `stderr`:
208
+
209
+ ```bash
210
+ sharecrm --debug knowledge search WebSearchAction -d '{"query":"test"}'
211
+ ```
212
+
213
+ 说明:
214
+
215
+ - `--debug` 是全局参数,建议放在命令前面
216
+ - 正常结果输出到 `stdout`
217
+ - 调试信息输出到 `stderr`
218
+ - 遇到 `CliError` 时会附带结构化异常信息
219
+
220
+ ## 认证与本地状态
221
+
222
+ - `config.json` 仅保存 CLI 元数据和会话元数据,不保存 `accessToken` / `refreshToken`
223
+ - `accessToken` / `refreshToken` 通过平台对应的 secret store 保存
224
+ - 旧版明文 `session.json` 会在读取时尝试迁移
225
+ - 当远程接口返回登录失效时,CLI 会尝试使用 `refreshToken` 刷新登录态
226
+ - 刷新成功后会自动重试一次原请求
227
+ - 刷新失败或缺少刷新所需信息时,会提示重新登录
228
+
229
+ 重新登录提示示例:
230
+
231
+ ```text
232
+ 提示:登录状态已失效,请重新登录授权。
233
+ 执行命令:sharecrm auth login
234
+ ```
235
+
236
+ ## 常见问题
237
+
238
+ ### 1. 未登录无法执行远程命令
239
+
240
+ 错误信息:
241
+
242
+ ```text
243
+ You must login before executing remote commands.
244
+ sharecrm auth login
245
+ ```
246
+
247
+ 处理方式:
248
+
249
+ ```bash
250
+ sharecrm auth login
251
+ ```
252
+
253
+ ### 2. 登录状态已失效
254
+
255
+ 错误信息:
256
+
257
+ ```text
258
+ 提示:登录状态已失效,请重新登录授权。
259
+ 执行命令:sharecrm auth login
260
+ ```
261
+
262
+ 处理方式:重新执行登录。
263
+
264
+ ### 3. 设备码过期或授权被拒绝
265
+
266
+ 可能会看到类似错误:
267
+
268
+ - `Device code expired. Please run auth login again.`
269
+ - `Authorization was denied. Please try again after granting access.`
270
+
271
+ 处理方式:重新执行 `sharecrm auth login`。
272
+
273
+ ### 4. 缺少认证地址配置
274
+
275
+ 如果 `FS_CLI_AUTH_BASE_URL` 未配置且构建产物中也没有有效默认值,认证相关命令会失败。
276
+
277
+ ### 5. Windows secret store 异常
278
+
279
+ Windows 下会话 secret 读取依赖 `powershell.exe` 与 DPAPI。若本地 secret 不可读,`sharecrm` 和 `sharecrm help` 会按未登录处理;远程命令执行仍需要重新登录或修复本地环境。
280
+
281
+ ## 开发与测试
282
+
283
+ ```bash
284
+ npm run build
285
+ npm run typecheck
286
+ npm run lint
287
+ npm test
288
+ ```
289
+
290
+ 说明:
291
+
292
+ - `npm test` 会先执行构建,再运行 `vitest`
293
+ - `npm run build:debug` 可直接从源码启动 CLI
@@ -8,8 +8,12 @@ function looksLikeJsonArgument(value) {
8
8
  return false;
9
9
  }
10
10
  const trimmed = value.trim();
11
- return (trimmed.startsWith('{') && trimmed.endsWith('}'))
12
- || (trimmed.startsWith('[') && trimmed.endsWith(']'));
11
+ // Strip surrounding single quotes (Windows cmd.exe does not strip them)
12
+ const unwrapped = (trimmed.startsWith("'") && trimmed.endsWith("'"))
13
+ ? trimmed.slice(1, -1).trim()
14
+ : trimmed;
15
+ return (unwrapped.startsWith('{') && unwrapped.endsWith('}'))
16
+ || (unwrapped.startsWith('[') && unwrapped.endsWith(']'));
13
17
  }
14
18
  function parseCliInput(argv) {
15
19
  const tokens = [...argv];
package/dist/cli/root.js CHANGED
@@ -21,7 +21,7 @@ function createRootCommand() {
21
21
  .helpOption(false)
22
22
  .allowUnknownOption(true)
23
23
  .allowExcessArguments(true)
24
- .option('--d, --data', 'URL/query parameters JSON')
24
+ .option('-d, --data', 'URL/query parameters JSON')
25
25
  .option('--help', 'Help about any command\n')
26
26
  .option('--debug', 'Print remote API debug logs to stderr')
27
27
  .action(async () => {
@@ -32,7 +32,8 @@ function createRootCommand() {
32
32
  return;
33
33
  }
34
34
  if (parsed.kind === 'remote') {
35
- await (0, execute_1.runRemoteCommand)(parsed.commandKey ?? '', parsed.arg, parsed.kind);
35
+ const isHelp = Boolean(program.opts().help);
36
+ await (0, execute_1.runRemoteCommand)(parsed.commandKey ?? '', parsed.arg, isHelp ? 'help' : undefined);
36
37
  return;
37
38
  }
38
39
  await (0, help_1.runHelpCommand)(program, []);
@@ -13,7 +13,6 @@ async function runRemoteCommand(commandKey, arg, mode) {
13
13
  throw new errors_1.AuthenticationRequiredCliError();
14
14
  }
15
15
  const isHelpFlag = mode === 'help';
16
- //console.log('arg:' + arg + ',commandKey:' + commandKey + ' ,isHelpFlag:' + mode);
17
16
  const argumentsPayload = parseArguments(arg);
18
17
  let result;
19
18
  try {
@@ -47,23 +46,24 @@ function extractRemoteError(error) {
47
46
  return remoteError;
48
47
  }
49
48
  function formatRemoteErrorSummary(remoteError, isHelpFlag = false) {
49
+ const helpText = remoteError.help ? formatRemoteErrorHelp(remoteError.help, remoteError.commandKey) : '';
50
+ if (isHelpFlag && helpText) {
51
+ return helpText;
52
+ }
50
53
  const lines = [];
51
- if (!isHelpFlag) {
52
- if (remoteError.commandKey) {
53
- lines.push(`\ncommand:${constants_1.CLI_NAME} ${remoteError.commandKey}`);
54
- }
55
- if (remoteError.errorCode) {
56
- lines.push(`errorCode:${remoteError.errorCode}`);
57
- }
58
- if (remoteError.errorMessage) {
59
- lines.push(`errorMsg:${remoteError.errorMessage}`);
60
- }
61
- if (remoteError.hint) {
62
- lines.push(`Tips:${remoteError.hint.replace(/^share-cli\b/, constants_1.CLI_NAME)} view the command help info`);
63
- }
54
+ if (remoteError.commandKey) {
55
+ lines.push(`\ncommand:${constants_1.CLI_NAME} ${remoteError.commandKey}`);
56
+ }
57
+ if (remoteError.errorCode) {
58
+ lines.push(`errorCode:${remoteError.errorCode}`);
59
+ }
60
+ if (remoteError.errorMessage) {
61
+ lines.push(`errorMsg:${remoteError.errorMessage}`);
62
+ }
63
+ if (remoteError.hint) {
64
+ lines.push(`Tips:${remoteError.hint.replace(/^share-cli\b/, constants_1.CLI_NAME)} view the command help info`);
64
65
  }
65
66
  const summary = lines.join('\n');
66
- const helpText = remoteError.help ? formatRemoteErrorHelp(remoteError.help, remoteError.commandKey) : '';
67
67
  if (!helpText) {
68
68
  return summary;
69
69
  }
@@ -97,9 +97,13 @@ function parseArguments(arg) {
97
97
  if (!arg) {
98
98
  throw new errors_1.CliError('The -d option requires a JSON object payload.', 1);
99
99
  }
100
+ // Strip surrounding single quotes (Windows cmd.exe does not strip them)
101
+ const cleaned = (arg.startsWith("'") && arg.endsWith("'"))
102
+ ? arg.slice(1, -1)
103
+ : arg;
100
104
  let parsed;
101
105
  try {
102
- parsed = JSON.parse(arg);
106
+ parsed = JSON.parse(cleaned);
103
107
  }
104
108
  catch {
105
109
  throw new errors_1.CliError('The -d option must be valid JSON.', 1);
package/dist/index.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,40 +1,40 @@
1
- {
2
- "name": "@share-crm/sharecrm-cli",
3
- "version": "1.1.0",
4
- "description": "ShareCRM CLI client skeleton",
5
- "type": "commonjs",
6
- "engines": {
7
- "node": ">=18.17"
8
- },
9
- "bin": {
10
- "sharecrm": "dist/index.js"
11
- },
12
- "files": [
13
- "bin",
14
- "dist"
15
- ],
16
- "scripts": {
17
- "build": "node scripts/build.js production && tsc -p tsconfig.json",
18
- "build:dev": "node scripts/build.js development && tsc -p tsconfig.json",
19
- "build:debug": "node scripts/build.js development && tsx src/index.ts",
20
- "build:prod": "node scripts/build.js production && tsc -p tsconfig.json",
21
- "build:test": "node scripts/build.js test && tsc -p tsconfig.json",
22
- "lint": "eslint . --ext .ts",
23
- "pretest": "npm run build",
24
- "test": "vitest run",
25
- "typecheck": "tsc --noEmit"
26
- },
27
- "dependencies": {
28
- "commander": "^12.1.0"
29
- },
30
- "devDependencies": {
31
- "@types/node": "^24.6.0",
32
- "@typescript-eslint/eslint-plugin": "^8.35.1",
33
- "@typescript-eslint/parser": "^8.35.1",
34
- "eslint": "^9.26.0",
35
- "prettier": "^3.6.2",
36
- "tsx": "^4.20.6",
37
- "typescript": "^5.9.3",
38
- "vitest": "^3.2.4"
39
- }
40
- }
1
+ {
2
+ "name": "@share-crm/sharecrm-cli",
3
+ "version": "1.1.2",
4
+ "description": "ShareCRM CLI client skeleton",
5
+ "type": "commonjs",
6
+ "engines": {
7
+ "node": ">=18.17"
8
+ },
9
+ "bin": {
10
+ "sharecrm": "dist/index.js"
11
+ },
12
+ "files": [
13
+ "bin",
14
+ "dist"
15
+ ],
16
+ "scripts": {
17
+ "build": "node scripts/build.js production && tsc -p tsconfig.json",
18
+ "build:dev": "node scripts/build.js development && tsc -p tsconfig.json",
19
+ "build:debug": "node scripts/build.js development && tsx src/index.ts",
20
+ "build:prod": "node scripts/build.js production && tsc -p tsconfig.json",
21
+ "build:test": "node scripts/build.js test && tsc -p tsconfig.json",
22
+ "lint": "eslint . --ext .ts",
23
+ "pretest": "npm run build",
24
+ "test": "vitest run",
25
+ "typecheck": "tsc --noEmit"
26
+ },
27
+ "dependencies": {
28
+ "commander": "^12.1.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^24.6.0",
32
+ "@typescript-eslint/eslint-plugin": "^8.35.1",
33
+ "@typescript-eslint/parser": "^8.35.1",
34
+ "eslint": "^9.26.0",
35
+ "prettier": "^3.6.2",
36
+ "tsx": "^4.20.6",
37
+ "typescript": "^5.9.3",
38
+ "vitest": "^3.2.4"
39
+ }
40
+ }