@profullstack/nichedb 0.9.0 → 0.11.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/package.json +1 -1
- package/src/index.js +30 -1
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import { homedir } from 'node:os';
|
|
|
14
14
|
import { join } from 'node:path';
|
|
15
15
|
import { createInterface } from 'node:readline';
|
|
16
16
|
|
|
17
|
-
export const VERSION = '0.
|
|
17
|
+
export const VERSION = '0.11.0';
|
|
18
18
|
const DEFAULT_API = process.env.NICHEDB_API ?? 'https://nichedb.dev';
|
|
19
19
|
const CONFIG_DIR = join(process.env.XDG_CONFIG_HOME ?? join(homedir(), '.config'), 'nichedb');
|
|
20
20
|
const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
|
|
@@ -36,6 +36,12 @@ export const COMMANDS = [
|
|
|
36
36
|
summary: 'Sources with status, last run and item counts.',
|
|
37
37
|
options: ['--collection <slug>', '--json'],
|
|
38
38
|
},
|
|
39
|
+
{
|
|
40
|
+
name: 'submit',
|
|
41
|
+
usage: 'submit <url> [--collection <slug>] [--note …] [--email …]',
|
|
42
|
+
summary: 'Suggest a feed for the index. No key needed; an admin reviews it.',
|
|
43
|
+
options: ['--collection <slug>', '--note <text>', '--email <address>', '--json'],
|
|
44
|
+
},
|
|
39
45
|
{
|
|
40
46
|
name: 'source',
|
|
41
47
|
usage: 'source <slug>',
|
|
@@ -398,6 +404,29 @@ export async function run(
|
|
|
398
404
|
}
|
|
399
405
|
return 0;
|
|
400
406
|
}
|
|
407
|
+
case 'submit': {
|
|
408
|
+
const [url] = rest;
|
|
409
|
+
if (!url) {
|
|
410
|
+
process.stderr.write(
|
|
411
|
+
'usage: nichedb submit <url> [--collection <slug>] [--note …] [--email …]\n',
|
|
412
|
+
);
|
|
413
|
+
return 2;
|
|
414
|
+
}
|
|
415
|
+
const { submission, duplicate } = await client.post('/api/v1/submissions', {
|
|
416
|
+
url,
|
|
417
|
+
collection: flags.collection,
|
|
418
|
+
note: flags.note,
|
|
419
|
+
email: flags.email,
|
|
420
|
+
});
|
|
421
|
+
out(
|
|
422
|
+
json
|
|
423
|
+
? JSON.stringify({ submission, duplicate }, null, 2)
|
|
424
|
+
: duplicate
|
|
425
|
+
? `Already suggested and waiting for review: ${submission.feed_url}`
|
|
426
|
+
: `Suggested ${submission.feed_url}. An admin will review it.`,
|
|
427
|
+
);
|
|
428
|
+
return 0;
|
|
429
|
+
}
|
|
401
430
|
case 'sources': {
|
|
402
431
|
const qs = flags.collection ? `?collection=${encodeURIComponent(flags.collection)}` : '';
|
|
403
432
|
const { sources } = await client.get(`/api/v1/sources${qs}`);
|