decred / politeiagui

ISC License
62 stars 56 forks source link

[plugin-architecture] "Unknown script" error message on politeiagui-scripts #2837

Closed victorgcramos closed 2 years ago

victorgcramos commented 2 years ago

When you type an invalid command, the politeiagui-scripts toolkit displays the following message:

$ politeiagui-scripts invalid

/politeiagui/plugins-structure/packages/politeiagui-scripts/bin/politeiagui-scripts.js:68
    throw new Error(`Unknown script "${script}".`);
    ^
Error: Unknown script "invalid".
    at runScript (/Users/victorguedes/Documents/decred/politeiagui/plugins-structure/packages/politeiagui-scripts/bin/politeiagui-scripts.js:68:11)
    at Object.<anonymous> (/Users/victorguedes/Documents/decred/politeiagui/plugins-structure/packages/politeiagui-scripts/bin/politeiagui-scripts.js:10:3)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47

We should simplify that and display a clean and objective message. Maybe something like this:

$ politeiagui-scripts invalid 

 Unknown script "invalid". Valid scripts are:
 - build-app
 - build-plugin
 - build
 - lint
 - prettify
 - start-app
 - start-plugin
 - start
 - test