Command line documentation viewer for node js modules - node.js

Is there a way to display the documentation of installed NodeJS packages in a console window (as a command line tool)? Often - in case of editing on a server - it is easier to view the docs of some specific stuff right in the command window, then to start a browser.
Such as npm docs fs or npm docs express would be perfect, but these try to start a browser and display documentation there instead of displaying README.md directly in the window.
Something similar to Perl's perldoc would be a perfect solution.

Here's what I do when I'm in a hurry:
# nodedoc
# USAGE: nodedoc <name of module>
# e.g. nodedoc http
curl https://raw.githubusercontent.com/nodejs/node/master/doc/api/$1.md | pandoc --from markdown --to plain | less

Related

TYPO3 10.4.16 cli commands missing?

checking which cli commands my installation of TYPO3 10.4.16 offers with php typo3 list in directory /var/www/html/typo3_src/typo3/sysext/core/bin I only get very few commands offered (output of command see below).
E.g. the scheduler extension is installed and works fine when commands are executed manually. Therefore I would expect to at least get the command scheduler:run offered in the cli list.
The Installation is non-composer as the server is behind heavy firewalls.
Has anyone experienced similar behaviour?
Any help is much appreciated.
Thanks,
Ben
Result of list-command:
TYPO3 CMS 10.4.16 (Application Context: Production)
Usage:
command [options] [arguments]
Options:
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
help Displays help for a command
list Lists commands
language
language:update Update the language files of all activated extensions
upgrade
upgrade:list List available upgrade wizards.
upgrade:run Run upgrade wizard. Without arguments all available wizards will be run.
Solved:
When calling the typo3 script, the CWD has to be the root of your TYPO3 Installation while executing the command.
This works:
navigate to root folder of TYPO3
php typo3/sysext/core/bin/typo3
This doesn't work:
navigation to /typo3/sysext/core/bin/
execute php typo3

Open url given by stdout from node --inspect command

Alright here's a fun one, we get the following stdout:
Debugger listening on port 9229.
Warning: This is an experimental feature and could change at any time.
To start debugging, open the following URL in Chrome:
chrome-devtools://devtools/remote/serve_file/#60cd6e859b9f557d2312f5bf532f6aec5f284980/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/a7a2a58d-dfd1-4cc6-875c-47da78adeb1b
when we run a command like so:
node --inspect --debug-brk bin/www.js
I was thinking of creating a bash script like this:
#!/usr/bin/env bash
NODE_DEBUG_OUTPUT=$(node --inspect --debug-brk bin/www.js)
open -a "/Applications/Google Chrome.app"/ getUrl(${NODE_DEBUG_OUTPUT})
but here's where my bash skills end - how can I implement the getUrl function so that I can get the url from the output?
I am pretty certain that if we pass a url to the open function in bash, it will open a browser, in this case though it has to be Google Chrome browser.
Here's a bash command to extract the url
url=$(grep 'chrome-devtools://' <(node --inspect bin/www.js $# 2>&1))
Explanation
The 2>&1 tells the shell to redirect stderr to stdout.
The node command is run within <( node ), this is called process substitution and behaves like a read-only file with the contents being the stdout of the command (node in this case)
Other Issues
There is a bug, filed recently Chrome DevTools not able to connect to Node inspect since 7.5.0
Version 7.4.0 is reported to work
To open a chrome-devtools url from the command line requires some AppleScript, fortunately someone's already done that:
chrome-node-devtools-refresh.sh
So the command would be something like this:
chrome-node-devtools-refresh.sh $(grep 'chrome-devtools://' \
<(node --inspect bin/www.js $# 2>&1))
Alternative
So I am probably not answering your question but I want to give this as a simpler solution to the higher problem you are trying to resolve.
There is a npm package called node-inspector. This package provides the same functionality as you need from chrome dev-tools. Here is the description from their github page :
Node Inspector is a debugger interface for Node.js applications that
uses the Blink Developer Tools (formerly WebKit Web Inspector).
How do you Install?
npm install -g node-inspector
How do you use?
node-debug app.js
where app.js is your js file. you can do node-debug bin/www in your case
What does it do?
Here is a gif for you to show what it does
Summary
The node-inspector package can help you achieve the functionality you desire. i.e. launch chrome to debug your js code. I feel this is a easier option. Also you can read more about this to explore additional use cases if you have
From the developers of this package:
The node-debug command will load Node Inspector in your default
browser.
NOTE: Node Inspector works in Chrome and Opera only. You have to
re-open the inspector page in one of those browsers if another browser
is your default web browser (e.g. Safari or Internet Explorer). Node
Inspector works almost exactly as the Chrome Developer Tools. Read the
excellent DevTools overview to get started.
This is really close! The only thing that's not working is that chrome is not actually opening a url, it just opens to google.com
export PATH=$PATH:/Applications/Google\ Chrome.app/Contents/MacOS/
(node --inspect --debug-brk bin/www.js $# &> debug-server.log) &
sleep 1; // wait for the stdout to get written to file...
LINE=$(grep -n "chrome-devtools" debug-server.log | awk '{print $2}')
echo " => Supposed chrome-devtools link => '$LINE'";
Google\ Chrome "${LINE}"
anybody know why the "Google\ Chrome" command would not open the url provided as the first argument?

How can i generate the response file for my binary installable?

I have the binary file to install a component when i am running using ./filename.bin it comes into console mode and asks for language selection and directory selection and all , i tried ./filename.bin -r path/response.properties, help me if anyone knows.
as you said that you have already tried using ./filename.bin -r path/response.properties and still it does not work then , do one thing go for the console mode while creating the response file like :-
./filename.bin -i console -r path/response.properties
then install what you are installing, the response file will capture that.
And to use that later you can just include tat while running your bin file to take the input from response file.

Any good text editor for which I can write plugin/extensions in nodejs?

Is there any good text editor available for which I can write plugins/extensions using nodejs? I have a node app which I run like this
node app.js -c fileName.js destFile.js
so I want whatever file I am editing, I can select some menu and the node command runs with fileName as current file.
look into Githubs Atom editor. It's a very customizable text editor that uses node.js and other web technologies.
Please try geany.
You can set build command :
- add Execute for examples, add in command : node
And in terminal below, You can stop node with control c

Does any web browser allow writing to stdout?

I plan to write a Hashify command line client, and I'd like to confirm that simply writing to stdout is not an option before getting creative.
(Ideally the command will behave like TextMate's mate, in this case opening hashify.me in a browser and waiting to be fed input.)
WGet (simple http fetching tool) supports redirecting a file to STDOUT with the -qO - optioncalled like wget -qO - http://url/.
Lynx (full CLI browser) supports dumping to STDOUT with the -dump or -crawl option.
You could have a look at Google Native Client, available in the dev channel version of Google Chrome.
When run with the native client flags, it allows you to print to the terminal as stated here. Look into the documentation here and here for details.
Getting it to work on windows could be a pain, but it (supposedly) works great on linux. I'm trying it out right now.

Resources