@profullstack/nichedb 0.35.8 → 0.36.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 -8
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { homedir, tmpdir } from 'node:os';
|
|
|
15
15
|
import { join } from 'node:path';
|
|
16
16
|
import { createInterface } from 'node:readline';
|
|
17
17
|
|
|
18
|
-
export const VERSION = '0.
|
|
18
|
+
export const VERSION = '0.36.0';
|
|
19
19
|
const GEO_FLAGS = ['lat', 'long', 'radius', 'unit', 'bbox', 'sort', 'offset'];
|
|
20
20
|
const DEFAULT_API = process.env.NICHEDB_API ?? 'https://nichedb.dev';
|
|
21
21
|
const CONFIG_DIR = join(process.env.XDG_CONFIG_HOME ?? join(homedir(), '.config'), 'nichedb');
|
|
@@ -244,10 +244,20 @@ export const COMMANDS = [
|
|
|
244
244
|
},
|
|
245
245
|
{
|
|
246
246
|
name: 'profile edit',
|
|
247
|
-
usage:
|
|
247
|
+
usage:
|
|
248
|
+
'profile edit <ref> [--file openprofile.md] [--emoji …] [--pronouns …] [--web …] [--handle …] [--public|--private]',
|
|
248
249
|
summary:
|
|
249
|
-
'Edit a profile you own (key required). Opens $EDITOR on the file when
|
|
250
|
-
options: [
|
|
250
|
+
'Edit a profile you own (key required). Opens $EDITOR on the file when nothing else is given. --emoji, --pronouns and --web set those identity keys alone (--pronouns= clears).',
|
|
251
|
+
options: [
|
|
252
|
+
'--file <path>',
|
|
253
|
+
'--emoji <emoji|:shortcode:>',
|
|
254
|
+
'--pronouns <as written>',
|
|
255
|
+
'--web <url>',
|
|
256
|
+
'--handle <handle>',
|
|
257
|
+
'--public',
|
|
258
|
+
'--private',
|
|
259
|
+
'--json',
|
|
260
|
+
],
|
|
251
261
|
},
|
|
252
262
|
{
|
|
253
263
|
name: 'profile handle',
|
|
@@ -968,7 +978,8 @@ export async function run(
|
|
|
968
978
|
out(p.page);
|
|
969
979
|
continue;
|
|
970
980
|
}
|
|
971
|
-
|
|
981
|
+
const name = `${p.emoji ? `${p.emoji} ` : ''}${p.name}${p.pronouns ? ` (${p.pronouns})` : ''}`;
|
|
982
|
+
out(`${pad(p.ref, 34)} ${pad(p.kind ?? '', 12)} ${name}${p.claimed ? ' (claimed)' : ''}`);
|
|
972
983
|
if (p.headline) out(` ${p.headline}`);
|
|
973
984
|
}
|
|
974
985
|
if (profiles.length === 0) out('(nobody yet)');
|
|
@@ -1000,11 +1011,22 @@ export async function run(
|
|
|
1000
1011
|
}
|
|
1001
1012
|
if (sub === 'edit') {
|
|
1002
1013
|
if (!arg)
|
|
1003
|
-
throw new Error(
|
|
1014
|
+
throw new Error(
|
|
1015
|
+
'profile edit <ref> [--file …] [--emoji …] [--pronouns …] [--web …] [--handle …] [--public|--private]',
|
|
1016
|
+
);
|
|
1004
1017
|
const ref = encodeURIComponent(arg);
|
|
1018
|
+
// Emoji, Pronouns and Web on their own; an empty value (--pronouns=) removes the key.
|
|
1019
|
+
const fields = {};
|
|
1020
|
+
for (const f of ['emoji', 'pronouns', 'web'])
|
|
1021
|
+
if (flags[f] !== undefined) fields[f] = flags[f] === true ? '' : String(flags[f]);
|
|
1005
1022
|
let markdown = null;
|
|
1006
1023
|
if (flags.file) markdown = await readFile(String(flags.file), 'utf8');
|
|
1007
|
-
else if (
|
|
1024
|
+
else if (
|
|
1025
|
+
!flags.handle &&
|
|
1026
|
+
!flags.public &&
|
|
1027
|
+
!flags.private &&
|
|
1028
|
+
Object.keys(fields).length === 0
|
|
1029
|
+
) {
|
|
1008
1030
|
// No file and nothing else to set: the editor, on the file as served.
|
|
1009
1031
|
const current = await client.text(`/api/v1/profiles/${ref}/openprofile.md`);
|
|
1010
1032
|
const path = join(tmpdir(), `nichedb-profile-${Date.now()}.md`);
|
|
@@ -1029,7 +1051,7 @@ export async function run(
|
|
|
1029
1051
|
markdown,
|
|
1030
1052
|
'text/markdown; charset=utf-8',
|
|
1031
1053
|
);
|
|
1032
|
-
const patch = {};
|
|
1054
|
+
const patch = { ...fields };
|
|
1033
1055
|
if (flags.handle) patch.handle = String(flags.handle);
|
|
1034
1056
|
if (flags.public) patch.public = true;
|
|
1035
1057
|
if (flags.private) patch.public = false;
|