create-glanceway-source 1.2.0 → 1.3.0
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/dist/index.js +48 -5
- package/package.json +6 -1
- package/templates/scripts/test.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -100,7 +100,7 @@ tags: []
|
|
|
100
100
|
# config:
|
|
101
101
|
# - key: API_TOKEN
|
|
102
102
|
# name: API Token
|
|
103
|
-
# type: secret # string, number, boolean, secret, select, or
|
|
103
|
+
# type: secret # string, number, boolean, secret, select, list, or multiselect
|
|
104
104
|
# required: true
|
|
105
105
|
# description: Your API token
|
|
106
106
|
# - key: SORT
|
|
@@ -111,7 +111,17 @@ tags: []
|
|
|
111
111
|
# options:
|
|
112
112
|
# - hot
|
|
113
113
|
# - new
|
|
114
|
-
# -
|
|
114
|
+
# - label: Top (All Time) # options support label/value format
|
|
115
|
+
# value: top
|
|
116
|
+
# - key: CATEGORIES
|
|
117
|
+
# name: Categories
|
|
118
|
+
# type: multiselect # like select but allows multiple choices
|
|
119
|
+
# options:
|
|
120
|
+
# - label: Technology
|
|
121
|
+
# value: tech
|
|
122
|
+
# - label: Science
|
|
123
|
+
# value: science
|
|
124
|
+
# - sports
|
|
115
125
|
`;
|
|
116
126
|
return manifest;
|
|
117
127
|
}
|
|
@@ -275,7 +285,7 @@ if (response.ok && response.json) {
|
|
|
275
285
|
|
|
276
286
|
### api.config.get(key: string): unknown
|
|
277
287
|
|
|
278
|
-
Get a user-configured value by key (defined in \`manifest.yaml\` config section). Returns \`string\` for most types, \`string[]\` for \`list\`
|
|
288
|
+
Get a user-configured value by key (defined in \`manifest.yaml\` config section). Returns \`string\` for most types, \`string[]\` for \`list\` and \`multiselect\` types.
|
|
279
289
|
|
|
280
290
|
### api.config.getAll(): Record<string, unknown>
|
|
281
291
|
|
|
@@ -330,7 +340,7 @@ min_app_version: 1.2.0 # Optional: minimum Glanceway app version required
|
|
|
330
340
|
config: # Optional: user-configurable values
|
|
331
341
|
- key: API_TOKEN
|
|
332
342
|
name: API Token
|
|
333
|
-
type: secret # string, number, boolean, secret, select, or
|
|
343
|
+
type: secret # string, number, boolean, secret, select, list, or multiselect
|
|
334
344
|
required: true
|
|
335
345
|
description: Description shown to user
|
|
336
346
|
- key: TAGS
|
|
@@ -346,9 +356,40 @@ config: # Optional: user-configurable values
|
|
|
346
356
|
options:
|
|
347
357
|
- hot
|
|
348
358
|
- new
|
|
349
|
-
-
|
|
359
|
+
- label: Top (All Time) # options support label/value format
|
|
360
|
+
value: top
|
|
361
|
+
- key: CATEGORIES
|
|
362
|
+
name: Categories
|
|
363
|
+
type: multiselect # like select but allows multiple choices (value type: string[])
|
|
364
|
+
options:
|
|
365
|
+
- label: Technology
|
|
366
|
+
value: tech
|
|
367
|
+
- label: Science
|
|
368
|
+
value: science
|
|
369
|
+
- sports
|
|
370
|
+
\`\`\`
|
|
371
|
+
|
|
372
|
+
\`select\` and \`multiselect\` options can be plain strings or label/value objects:
|
|
373
|
+
|
|
374
|
+
\`\`\`yaml
|
|
375
|
+
options:
|
|
376
|
+
- plain_value # value = "plain_value", displayed as "plain_value"
|
|
377
|
+
- label: Display Name # value = "actual_value", displayed as "Display Name"
|
|
378
|
+
value: actual_value
|
|
350
379
|
\`\`\`
|
|
351
380
|
|
|
381
|
+
### Config Field Types
|
|
382
|
+
|
|
383
|
+
| Type | Description | Value type |
|
|
384
|
+
|---------------|------------------------------------------------------|-------------|
|
|
385
|
+
| \`string\` | Free-form text input | \`string\` |
|
|
386
|
+
| \`number\` | Numeric input | \`number\` |
|
|
387
|
+
| \`boolean\` | Toggle switch | \`boolean\` |
|
|
388
|
+
| \`secret\` | Stored in macOS Keychain | \`string\` |
|
|
389
|
+
| \`select\` | Dropdown (requires \`options\` list) | \`string\` |
|
|
390
|
+
| \`list\` | Multiple string values | \`string[]\` |
|
|
391
|
+
| \`multiselect\` | Multiple choice from options (like select but multi) | \`string[]\` |
|
|
392
|
+
|
|
352
393
|
## Source Lifecycle
|
|
353
394
|
|
|
354
395
|
JavaScript sources have two distinct phases:
|
|
@@ -398,6 +439,8 @@ import type { GlancewayAPI, SourceMethods } from "./types";
|
|
|
398
439
|
type Config = {
|
|
399
440
|
API_TOKEN: string;
|
|
400
441
|
TAGS: string[];
|
|
442
|
+
SORT: string; // select → string
|
|
443
|
+
CATEGORIES: string[]; // multiselect → string[]
|
|
401
444
|
};
|
|
402
445
|
|
|
403
446
|
// 3. Helper functions (pure utilities, no api dependency)
|
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-glanceway-source",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Scaffold a standalone Glanceway source project",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"homepage": "https://github.com/glanceway/create-glanceway-source",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/glanceway/create-glanceway-source.git"
|
|
10
|
+
},
|
|
6
11
|
"bin": {
|
|
7
12
|
"create-glanceway-source": "dist/index.js"
|
|
8
13
|
},
|
|
@@ -72,7 +72,7 @@ function resolveConfig(
|
|
|
72
72
|
const override = overrides[entry.key];
|
|
73
73
|
|
|
74
74
|
if (override !== undefined) {
|
|
75
|
-
if (entry.type === "list") {
|
|
75
|
+
if (entry.type === "list" || entry.type === "multiselect") {
|
|
76
76
|
resolved[entry.key] = override.split(",").map((s) => s.trim());
|
|
77
77
|
} else if (entry.type === "boolean") {
|
|
78
78
|
resolved[entry.key] = override === "true" || override === "1";
|