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

glabenv

v1.2.0

Published

CLI to export and synchronize Gitlab environment variables

Downloads

90

Readme

GlabENV

CLI to export and synchronize Gitlab environment variables

Demo

How To Install 🚀

Via NPM:

npm install -g glabenv

Via Yarn:

yarn global add glabenv

Gitlab Authentication 🔐

Set the GitLab access token with the --token or -t option:

glabenv [COMMAND] --token <YOUR_GITLAB_ACCESS_TOKEN>

Alternatively, you can use an environment variable:

export GLABENV_ACCESS_TOKEN=<YOUR_GITLAB_ACCESS_TOKEN>

Commands 🛠️

Export

To export all environment variables from a GitLab repository, you need to set the repository URL with the --repoURL or -r option:

glabenv export -r <YOUR_GITLAB_REPO_URL>
# Output :
# DATABASE_HOST=localhost
# DATABASE_USER=dbuser
# ...

You can also set the repository URL as an environment variable:

export GLABENV_REPOSITORY=<YOUR_GITLAB_REPO_URL>
glabenv export
# Output :
# DATABASE_HOST=localhost
# DATABASE_USER=dbuser
# ...

You can write the output to a file with --output or -o option:

glabenv export -o env.example
cat env.example
# Output :
# DATABASE_HOST=localhost
# DATABASE_USER=dbuser
# DATABASE_PASS=pass1234
# DATABASE_NAME=example_db

You can get the output as JSON format with the --format or -f option. The default format is env:

glabenv export -f json
# Output :
#[{"variable_type":"env_var","key":"DATABASE_HOST","value":"localhost","protected":false,"masked":false...

If you want the JSON output in a pretty format, use the --pretty option:

glabenv export -f json --pretty
# Output :
# [
#   {
#     "variable_type": "env_var",
#     "key": "DATABASE_HOST",
#     "value": "localhost",
#     "protected": false,
#     "masked": false,
#     "raw": false,
#     "environment_scope": "*"
#   },
# ...

Sync

To synchronize environment variables from your local env file to a GitLab repository:

glabenv sync --filepath env.example

Synchronization behavior:

  • Create a new variable if there is a key in the local env file that doesn't exist in GitLab env variables.
  • Update the variable if the value of the key in the local env file doesn't match the one in GitLab env variables.
  • Delete the variable if there is a key in GitLab env variables that doesn't exist in the local env file.

You can see the output of this command on the demo gif above

Export and Sync Gitlab Group Env Variables 👥

You can export or synchronize Gitlab group environment variables by set the repository URL with your Gitlab group URL and add -l or --level option with value: group.

Example for export command:

glabenv export -r https://gitlab.example.com/demo-group/demo-subgroup --level group

Example for sync command:

glabenv sync --filepath env.example -r https://gitlab.example.com/demo-group/demo-subgroup --level group

Alternatively, you can use environment variables:

export GLABENV_REPOSITORY=https://gitlab.example.com/demo-group/demo-subgroup
export GLABENV_LEVEL=group

Export and Sync Gitlab Instance Env Variables 👨🏻‍💼

You can export or synchronize Gitlab instance environment variables by set the repository URL with your Gitlab host URL and add -l or --level option with value: instance.

Example for export command:

glabenv export -r https://gitlab.example.com --level instance

Example for sync command:

glabenv sync --filepath env.example -r https://gitlab.example.com --level instance

Alternatively, you can use environment variables:

export GLABENV_REPOSITORY=https://gitlab.example.com
export GLABENV_LEVEL=instance

References 📝

  • https://docs.gitlab.com/ee/api/project_level_variables.html
  • https://docs.gitlab.com/ee/api/group_level_variables.html
  • https://docs.gitlab.com/ee/api/instance_level_ci_variables.html