scriptpal
v1.7.0
Published
A simple npm script palette for lazy people (like me)
Maintainers
Readme
ScriptPal 🤘
A simple npm script palette for lazy people who want a quick way to look through and pick npm scripts!
- keyboard navigation
- autocompletion
- fuzzy finding
- bookmarks
Install ⬇️
Install globally
npm install -g scriptpalUsage 🏁
scriptpalUsage with npx
npx scriptpalAPI 🤖
--nowelcome,-nOmit welcome message--last,-lRun previous command--version,-vVersion number--clipboard,-cCopy command to clipboard--helpHelp me 🙏list,lsList local npm scripts frompackage.jsonbookmark add <name> <command...>Add a bookmarkbookmark edit <name> <command...>Edit a bookmarkbookmark remove <name>,bookmark rm <name>Remove a bookmarkbookmark list,bookmark lsList bookmarksbookmark run <name> [name=value ...]Run a bookmark and resolve wildcards (supports scalar, enum, and array wildcard modifiers)bookmark --last,bookmark -lRun previous bookmark commandbookmarkOpen a fuzzy-findable bookmark picker and run selection
Running Arbitrary Scripts
It's possible to also run arbitrary scripts from your package.json by passing them as sub-commands, similar to yarn.
For example: scriptpal test will run npm run test.
list / ls
list List all scripts found in local package.json.
bookmark
Store reusable command bookmarks globally.
Wildcards use ${...} syntax and are resolved when running bookmarks.
If a required wildcard is not provided, ScriptPal prompts for it.
Wildcard Syntax
Scalar wildcard
${name}Example:
scriptpal bookmark add testpkg "yarn test packages/${package}"
scriptpal bookmark run testpkg package=button
# yarn test packages/buttonEnum-constrained scalar wildcard
${name:enum(button|modal|card)}Only one of the listed values is accepted.
Array wildcard
${name:array}
${name:array:or}
${name:array:brace}
${name:array:space}
${name:array:csv}Array render modes:
:or=>(a|b):brace=>{a,b}:space=>a b:csv=>a,b
${name:array} defaults to :csv.
Enum-constrained array wildcard
${name:array:or:enum(button|modal|card)}Every array entry must be in the enum list.
Accepted array input formats
All of these are accepted as wildcard values for array wildcards:
name=buttonname=button,modalname=button|modalname=[button,modal]name=(button|modal)
End-to-end examples
Single package:
scriptpal bookmark add typecheck "yarn typecheck packages/${pkg:array:or}"
scriptpal bookmark run typecheck pkg=button
# yarn typecheck packages/(button)Multiple packages:
scriptpal bookmark run typecheck pkg=button,modal
# yarn typecheck packages/(button|modal)Enum-constrained:
scriptpal bookmark add typecheck-safe "yarn typecheck packages/${pkg:array:or:enum(button|modal|card)}"
scriptpal bookmark run typecheck-safe pkg=button,modal
# yarn typecheck packages/(button|modal)Invalid enum value:
scriptpal bookmark run typecheck-safe pkg=button,toast
# Error: Invalid value for wildcard "pkg": toast. Allowed: button, modal, card.Examples
$ scriptpal=> Shows a prompt containing a list of npm scripts from the closestpackage.json.$ scriptpal --last=> Runs the previous command$ scriptpal list/$ scriptpal ls=> Prints all npm scripts from the closestpackage.json.$ scriptpal start=> Runsnpm run start. Can be used with other scripts as well.$ scriptpal bookmark add testpkg "yarn test src/packages/${package}"=> Saves a bookmark.$ scriptpal bookmark run testpkg package=ui-button=> Runsyarn test src/packages/ui-button.$ scriptpal bookmark add typecheck "yarn typecheck packages/${pkg:array:or}"=> Saves an array wildcard bookmark.$ scriptpal bookmark run typecheck pkg=button,modal=> Runsyarn typecheck packages/(button|modal).$ scriptpal bookmark --last=> Runs the last executed bookmark command.$ scriptpal bookmark ls=> Lists bookmarks.$ scriptpal bookmark=> Opens fuzzy picker for saved bookmarks and runs selected one.
