npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

runconfig-generator

v1.0.7

Published

Automatically generate Webstorm run configurations from npm run scripts of package.json

Downloads

10

Readme

Run Configuration Generator

How to install

npm i -g runconfig-generator

How to use

Add entries to the script section of your package.json. E.g.:

{
  "name": "example project",
  "main": "index.js",
  "scripts": {
    "unit-tests": "mocha ./test"
    "start": "node index.js"
  }
}

Go to your project folder and run runconfig-generator.

How to specify environment variables

Global variables
Create a .env file in your project for variables that shall be used by ALL run configurations.

Script-specific variables
Create a folder called .env-files in your project for variables that should only be used for a certain run script.
In this folder create files named after your run scripts with a .env extension.
For the package.json example above, you could create .env-files/unit-tests.env and .env-files/start.env.

.env files are optional and will only be taken into consideration when using the below provided dotenv-code in your project (for npm run ...) or when the --env-flag is being passed (for WebStorm Run Configurations).
If you specify the same variable in the global .env and a script-specific.env one, the script-specific variable will be used.

If you want to load the environment variables when running the scripts using e.g. npm run myscript and not just using the WebStorm GUI, then add this to the very beginning of your projects source code:

const dotenv = require('dotenv')
if (process.env.npm_lifecycle_event) { // if run using npm
    dotenv.config({silent: true, path: `./.env-files/${process.env.npm_lifecycle_event}.env`}) // load script specific env vars from .env-files folder
    dotenv.config({silent: true}) // load global env vars from .env file
}

If you want to load the environment variables when running the scripts using the Run Configuration GUI in WebStorm, you can have to pass the --env flag:
runconfig-generator --env
This will embed the env vars in the Run Configurations.

Clean Run Configurations before generating new ones

If you want to delete all old Run Configurations before generating the new ones you can pass the --clean flag.
Note: If a Run Configuration is generated it will always automatically overwrite the old one if the old one was also generated (no matter if --clean has been set).

How it works

This tool parses your package.json's script section and uses the entries to create npm run configuration files (or node or mocha configuration files if the script begins with a mocha or node command) under .idea/runConfigurations in your project so that WebStorm will automatically recognize them.