niranzwp 0.8.3 → 0.8.4
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/bin/niranzwp.js +6 -1
- package/lib/errors.js +6 -1
- package/package.json +1 -1
package/bin/niranzwp.js
CHANGED
|
@@ -164,7 +164,7 @@ const out = (flags, value, pretty) => {
|
|
|
164
164
|
|
|
165
165
|
async function main() {
|
|
166
166
|
const { _: pos, flags } = parseArgs(process.argv.slice(2));
|
|
167
|
-
|
|
167
|
+
let [cmd, sub, ...rest] = pos;
|
|
168
168
|
|
|
169
169
|
if (flags.version || cmd === 'version') {
|
|
170
170
|
console.log(`NiranzWP CLI v${VERSION}`);
|
|
@@ -174,6 +174,11 @@ async function main() {
|
|
|
174
174
|
|
|
175
175
|
if (!cmd || flags.help || cmd === 'help') { console.log(USAGE); return; }
|
|
176
176
|
|
|
177
|
+
// The first outside user's first command was "posts list". Plurals are
|
|
178
|
+
// what people type; refusing them over one letter is a papercut with no
|
|
179
|
+
// upside, so both forms work and the docs keep showing the singular.
|
|
180
|
+
cmd = { posts: 'post', pages: 'page', users: 'user', medias: 'media', setting: 'settings', site: 'sites' }[cmd] ?? cmd;
|
|
181
|
+
|
|
177
182
|
if (cmd === 'auth' && sub === 'login') {
|
|
178
183
|
const url = rest[0];
|
|
179
184
|
if (!url) die('usage: niranzwp auth login <url>');
|
package/lib/errors.js
CHANGED
|
@@ -68,8 +68,13 @@ export function fromRest(status, body, fallback = 'usage_error') {
|
|
|
68
68
|
// capability failure, so keep the two hints apart.
|
|
69
69
|
const scoped = /route|scope/i.test(String(body?.message ?? ''));
|
|
70
70
|
return new CliError('insufficient_scope', body?.message || 'Not permitted.', {
|
|
71
|
+
// The first outside session hit this and the old hint only
|
|
72
|
+
// explained the problem. A hint that names no way forward is a
|
|
73
|
+
// dead end wearing a helpful tone.
|
|
71
74
|
hint: scoped
|
|
72
|
-
? 'This
|
|
75
|
+
? 'This profile\'s OAuth token only covers its provider\'s own routes (abilities, MCP), not core REST. ' +
|
|
76
|
+
'For core commands (post, page, media, settings), connect the same site with an application password: ' +
|
|
77
|
+
'niranzwp auth login <site> --app-password --name <new-profile> (add --manual if the browser is on another machine).'
|
|
73
78
|
: 'This credential belongs to a user without the required capability.',
|
|
74
79
|
});
|
|
75
80
|
}
|