1.0.4 • Published 7 years ago

npm-assistant v1.0.4

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

NPM Assistant license

Allows you to open multiple package.json, and run each of the scripts found in the package.json files by pressing buttons. Its inspired by npm-scripts-gui/screwy project, but it uses a different technology stack (logs are presented through frontail) the project uses npm-scripts-gui styles/images.

Why?

NPM (which uses package.json) has somewhat become a standard/common technology to access frontend/build assets, regardless of the technology used to serve or work with these assets (java/node/python/ruby/etc...). So its common for many server oriented projects to have a package.json, which can be used as a simple build task manager by simply defining scripts within package.json. These can execute any command on the terminal.

Yes, you can open powershell, integrated terminal, xterm, console2, etc... and run npm run ..., but running powershell/terminal/IDE instances/tabs for each script gets annoying when you are dealing with multiple projects, and is a little cumbersome (its a matter of taste). Hopefully this helps you be more efficient. It does the trick for me.

  • For Servers? Nope, this is intended for local development projects. I might gear it towards servers later.

Known issues

  • When running scripts that trigger gradlew.bat or gradle, nativeplatform from rubygrapefruit will complain about not having access to stdout, so you need to start the process on its own window. Use ctrl+click to do so.

Requirements

  • Your environmental PATH should include ./node_modules/.bin (a relative path)
  • Your environamental PATH should include a path for node and npm executables (normally that is the case already)
  • PowerShell If you are on linux/unix. You should install powershell Install Powershell On Linux
  • NodeJS You need to have an up to date version of NodeJS (6.9.2+ although 7 is not supported by edgejs)
  • Windows tail You need to have a tail binary (like linux tail command) available on your path (if you are using scoop, install it using scoop install coreutils)

How to Setup/Use

When using the assistant, it will automatically create an .npm-assistant directory on the root of your project (for each script stdout), use .gitignore to ignore its contents

.npm-assistant/*
!.npm-assistant/highlighter.json

Only use one npm-assistant instance, as it handles multiple projects

Setup

  • Install by running npm install -g --legacy-bundling npm-assistant (legacy-bundling is important until a build is added to this project)
  • Run npm-assistant, or from powershell start-process npm-assistant -WindowStyle hidden to have it running in the background (use -RedirectStandardError or -RedirectStandardOutput to files if desired)
  • Open browser and navigate to http://localhost:61101

Use

  • If you are using chrome you should open open the Menu -> More Tools -> Add To Desktop...
  • Add a package.json (any project)
  • Modify the base path directory of the project (the browser does not know where you loaded the package.json from)
  • Press one of the buttons (it will start the command associated with such npm script). Use ctrl while pressing to start the process on a new window (output will not be redirected to a file)
  • Press the button again to stop it
  • To see the output of one/all running processes, press the tail:std button, then press Open Viewer (important you must have ran a script button at least once to see its logs, I know... not ideal)
  • To customize the logging colors, modify .npm-assistant/highlighter.json at the package.json directory (use !.npm-assistant/highlighter.json to add it to git)
  • The browser will use localStorage to remember all packages loaded, and the server will remember the processes it has started. Basically, you can refresh the page.
  • If you make script modifications to package.json after adding it to the npm-assistant, you need to add it again to update the scripts npm-assistant knows about

Development

  • Run npm start
  • Or, run in powershell npm-assistant.ps1

TODOs

  • Test with linux
  • Google Chrome app to its always a seperate window
  • Build, so it can work with older versions of node and other browsers

Debugging

  • Open .npm-assistant directory on the directory for this project if the tail:std is not starting.
  • Use Visual Studio Code to run this project if you are having some other type of issue. Press F5.

Windows Binary Compilation (node-gyp)

  • To install some of the node_modules (websdk) you might need to install some Windows tools (only when binaries missing for latest nodejs). To install the tools, run npm install --global windows-build-tools (if you have sudo thanks to scoop, then just prefix sudo to the command, otherwise run as administrator)

  • For windows 7 or less. Install .NET 4.5

You might need to set npm config set msvs_version 2015 --global in order to not run npm install --msvs_version 2015 <package> every time