@svgicons-com/cli 0.1.0-alpha.2 → 0.1.0-alpha.3
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 +6 -4
- package/RELEASE_NOTES.md +5 -1
- package/package.json +1 -1
- package/src/cli.js +24 -4
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Public icon search works without changing the default endpoint. Pro workflows re
|
|
|
8
8
|
|
|
9
9
|
The scanner is read-only by default. It never edits project files unless a future command explicitly adds that behavior.
|
|
10
10
|
|
|
11
|
-
Current package version: `0.1.0-alpha.
|
|
11
|
+
Current package version: `0.1.0-alpha.3`.
|
|
12
12
|
|
|
13
13
|
## Requirements
|
|
14
14
|
|
|
@@ -18,17 +18,19 @@ Current package version: `0.1.0-alpha.2`.
|
|
|
18
18
|
## Login
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
|
-
svgicons login --token YOUR_PRO_API_TOKEN
|
|
21
|
+
svgicons login --token "YOUR_PRO_API_TOKEN"
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
The explicit auth namespace is also supported:
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
|
-
svgicons auth login --token YOUR_PRO_API_TOKEN
|
|
27
|
+
svgicons auth login --token "YOUR_PRO_API_TOKEN"
|
|
28
28
|
svgicons auth status
|
|
29
29
|
svgicons doctor
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
Pro API tokens may start with a numeric prefix and a pipe character, such as `10|...`. Keep the full token and wrap it in quotes when using a shell command.
|
|
33
|
+
|
|
32
34
|
You can also avoid writing a config file by setting `SVGICONS_TOKEN` or `SVGICONS_API_TOKEN`.
|
|
33
35
|
|
|
34
36
|
Inspect local config without exposing the stored token:
|
|
@@ -43,7 +45,7 @@ svgicons config set baseUrl https://svgicons.com
|
|
|
43
45
|
|
|
44
46
|
```bash
|
|
45
47
|
svgicons version
|
|
46
|
-
svgicons auth login --token YOUR_PRO_API_TOKEN
|
|
48
|
+
svgicons auth login --token "YOUR_PRO_API_TOKEN"
|
|
47
49
|
svgicons auth status --json
|
|
48
50
|
svgicons config list --json
|
|
49
51
|
svgicons doctor --json
|
package/RELEASE_NOTES.md
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
# Svg/icons CLI 0.1.0-alpha.
|
|
1
|
+
# Svg/icons CLI 0.1.0-alpha.3
|
|
2
|
+
|
|
3
|
+
This alpha refresh improves token setup safety. `login` now rejects obviously truncated numeric tokens, which commonly happens when a shell command is run without quoting a Sanctum-style token containing `|`.
|
|
4
|
+
|
|
5
|
+
## 0.1.0-alpha.2
|
|
2
6
|
|
|
3
7
|
This alpha refresh removes local-development wording from the public npm README. Runtime behavior is unchanged from `0.1.0-alpha.1`.
|
|
4
8
|
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -181,11 +181,9 @@ export async function run(argv) {
|
|
|
181
181
|
|
|
182
182
|
async function login(args, globalOptions = {}) {
|
|
183
183
|
const options = parseOptions(args);
|
|
184
|
-
const
|
|
184
|
+
const rawToken = options.token || globalOptions.token || process.env.SVGICONS_TOKEN || process.env.SVGICONS_API_TOKEN;
|
|
185
185
|
|
|
186
|
-
|
|
187
|
-
throw new Error('Missing token. Use: svgicons login --token <token>');
|
|
188
|
-
}
|
|
186
|
+
const token = normalizeLoginToken(rawToken);
|
|
189
187
|
|
|
190
188
|
const baseUrl = normalizeBaseUrl(options['base-url'] || globalOptions['base-url'] || defaultBaseUrl());
|
|
191
189
|
await writeConfig({
|
|
@@ -197,6 +195,28 @@ async function login(args, globalOptions = {}) {
|
|
|
197
195
|
console.log(`Svg/icons CLI token saved for ${baseUrl}.`);
|
|
198
196
|
}
|
|
199
197
|
|
|
198
|
+
function normalizeLoginToken(token) {
|
|
199
|
+
if (!token) {
|
|
200
|
+
throw usageError('Missing token. Use: svgicons login --token "<token>"');
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const value = String(token).trim();
|
|
204
|
+
|
|
205
|
+
if (value === '') {
|
|
206
|
+
throw usageError('Missing token. Use: svgicons login --token "<token>"');
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (/^\d+$/.test(value)) {
|
|
210
|
+
throw usageError('The token looks truncated. Svg/icons Pro API tokens can start with an id prefix like "10|". Wrap the full token in quotes: svgicons auth login --token "10|..."');
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (value.length < 20) {
|
|
214
|
+
throw usageError('The token value is too short. Copy the full Pro API token from your account page and wrap it in quotes when it contains "|".');
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return value;
|
|
218
|
+
}
|
|
219
|
+
|
|
200
220
|
async function logout() {
|
|
201
221
|
await clearConfig();
|
|
202
222
|
console.log('Svg/icons CLI credentials removed.');
|