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

quasar-app-extension-qenv-backup

v1.2.0

Published

Load targeted variables into your quasar project

Downloads

5

Readme

This is used for backup to prevent this package from being deleted by the author, who has not maintained it

Quasar App Extension qenv

quasar-app-extension-qenv is a CLI App Extension for Quasar Framework. It is a stand-alone environment-to-browser parser and aggregator.

@quasar/quasar-app-extension-qenv npm

Now compatible with Quasar v2 beta

v1.1.0 now supports expanding environmental variables put inside your .quasar.env.json file!

Demo

Can be found here.

Install

quasar ext add @quasar/qenv

Quasar CLI will retrieve it from NPM and install the extension.

Prompts

  1. "What name would you like to use for your Common Root Object ('none' means to not use one)?" The default is "none" The "common root object" means off of "process.env" you will have a named object, basically for organization purposes.

  2. "For security, would you like your .quasar.env.json file automatically added to .gitignore?" The default is "true" (yes) If you say "yes" to this question, then your .quasar.env.json file will automatically be inserted into the .gitignore. For security purposes, because you may have sensitive data in your .quasar.env.json file, you should not keep it in a repository.

Accessing the Data

Any data in a .quasar.env.json will be placed in process.env at the browser level. DO NOT console.log(process.env) as you will not see anything. For security purposes Quasar abstracts this away from prying eyes. If your env variable is PORT, then you can console.log(process.env.PORT) to see the results.

Tips

If you specified a common root object, say MyData, then the data will be placed at process.env.MyData.

Format

The format of the .quasar.env.json is as follows:

{
  "development": {
    "ENV_TYPE": "Running Development",
    "ENV_DEV": "Development",
    "SHELL: "${SHELL}"
  },
  "production": {
    "ENV_TYPE": "Running Production",
    "ENV_PROD": "Production",
    "SHELL: "${SHELL}"
  },
  "test": {
    "ENV_TYPE": "Running Test",
    "ENV_Test": "Test",
    "SHELL: "${SHELL}"
  }
}

This is the default that is installed and you will need to modify it to fit your needs.

You can add as many environments as needed (top-level keys). You are not restricted to the development, production and test that come by default. And, you can add as many variables under those environment types as you like.

Using Environment Variables

Environment variable are accessed like this: $MyVar or ${MyVar}. If it exists, then it will be expanded.

Let's use the test object from above to expand it out for something that would be used in production:

  "test": {
    NODE_ENV: "test",
    BASIC: "basic",
    BASIC_EXPAND: "$BASIC",
    MACHINE: "machine_env",
    MACHINE_EXPAND: "$MACHINE",
    UNDEFINED_EXPAND: "$UNDEFINED_ENV_KEY",
    ESCAPED_EXPAND: "\$ESCAPED",
    MONGOLAB_DATABASE: "heroku_db",
    MONGOLAB_USER: "username",
    MONGOLAB_PASSWORD: "password",
    MONGOLAB_DOMAIN: "abcd1234.mongolab.com",
    MONGOLAB_PORT: 12345,

    MONGOLAB_URI: "mongodb://${MONGOLAB_USER}:${MONGOLAB_PASSWORD}@${MONGOLAB_DOMAIN}:${MONGOLAB_PORT}/${MONGOLAB_DATABASE}",

    MONGOLAB_USER_RECURSIVELY: "${MONGOLAB_USER}:${MONGOLAB_PASSWORD}",

    MONGOLAB_URI_RECURSIVELY: "mongodb://${MONGOLAB_USER_RECURSIVELY}@${MONGOLAB_DOMAIN}:${MONGOLAB_PORT}/${MONGOLAB_DATABASE}",

    WITHOUT_CURLY_BRACES_URI: "mongodb://$MONGOLAB_USER:$MONGOLAB_PASSWORD@$MONGOLAB_DOMAIN:$MONGOLAB_PORT/$MONGOLAB_DATABASE",

    WITHOUT_CURLY_BRACES_USER_RECURSIVELY: "$MONGOLAB_USER:$MONGOLAB_PASSWORD",

    WITHOUT_CURLY_BRACES_URI_RECURSIVELY: "mongodb://$MONGOLAB_USER_RECURSIVELY@$MONGOLAB_DOMAIN:$MONGOLAB_PORT/$MONGOLAB_DATABASE"
  }

Specifying environment

So, how is this accessed?

You will need to modify your package.json in the scripts area. Let's take a look at an example:

  "scripts": {
    "dev": "QENV=development quasar dev",
    "test-dev": "QENV=test quasar dev",
    "combined": "QENV=development+test quasar dev",
    "build": "QENV=production quasar build"
  },

Basically, you need to set the QENV environment variable for Node. You specifiy the key that you want for the propgated data.

QEnv with Windows

There are several ways to set the QENV enviironment variable on Windows.

CMD

"dev": "set QENV='development' & quasar dev"

PowerShell (VS Code default)

"dev": "$env:QENV='development'; quasar dev"

...and for a solution that works for either:

Many thanks to NicksonYap for the following information:

QEnv will work on Windows by additionally installing cross-env.

npm install --save-dev cross-env

or

yarn add --dev cross-env

Then, in package.json:

"dev": "cross-env QENV=development quasar dev"

QEnv with Docker

QEnv will work with Docker by using the following syntax to inject your QENV variable into Node:

$ sudo docker run [...] -e QENV="development"

Chaining environments

Look at the combined script. Absolutely, you can chain two or more configurations together. When doing this, if there is any conflicting variables, the last one in wins.

In other words:

"combined": "QENV=development+test quasar dev",

will give different results than:

"combined": "QENV=test+development quasar dev",

And to be clear, you would do the following to run it:

# npm
npm run combined

# or

# yarn
yarn combined

Uninstall

quasar ext remove @quasar/qenv

Donate

If you appreciate the work that went into this, please consider donating to Quasar or Jeff.

License

MIT (c) Jeff Galbraith [email protected]