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

@vgs/netlify-plugin-vgs

v0.0.6

Published

The plugin makes your integration with VGS smoother by helping with: - configuring your vault routes with collect.js confguration - applying all routes from `vgs/routes.yaml` file, so they will be updated with each netlify deployment.

Downloads

68

Readme

VGS Plugin for Netlify

The plugin makes your integration with VGS smoother by helping with:

  • configuring your vault routes with collect.js confguration
  • applying all routes from vgs/routes.yaml file, so they will be updated with each netlify deployment.

Example project

Prerequisites

  1. VGS Dashboard account
  2. VGS CLI service account
  3. Netlify Account
  4. Netlify CLI

Overview

In this guide, we cover:

  • How to install and use vgs-netlify-plugin
  • How to set up a local development environment and work with netlify/VGS collect

Configure Netlify

First, get clientId and clientSecret credentials by following this guide. Then, get the ID of your vault vaultId in the VGS Dashboard

Finally, let's create environment variables on the Netlify side, so they will be available during each build (go to the Platform section and copy it from the top of the page)

netlify env:set VGS_CLIENT_ID <clientId>
netlify env:set VGS_CLIENT_SECRET <clientSecret>
netlify env:set VGS_VAULT_ID <vaultId>

Source Code

First, create a folder and initialize netlify site by running:

netlify init

Create a simple src/index.html file with a form:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>VGS <-> Netlify Plugin demo</title>
  <link rel="stylesheet" href="style.css" />
</head>
<body>
  <form id="vgs-collect-form">
    <label>Email</label>
    <div id="email" class="form-field"></div>
    <label>Password</label>
    <div id="password" class="form-field"></div>
    <button type="submit">Log in</button>
  </form>
  <script src="https://js.verygoodvault.com/vgs-collect/2.14.0/vgs-collect.js"></script>
  <script type="module" src="app.js"></script>
</body>
</html>

Add some styles to src/style.css file

* {
  box-sizing: border-box;
}

html {
  font-size: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI";
}

iframe {
  width: 100%;
  height: 100%;
}

form {
  width: 400px;
  margin: 20px auto;
}

label {
  display: inline-block;
  font-size: 1.2rem;
  margin-bottom: .6rem;
  text-transform: uppercase;
}

.form-field {
  width: 100%;
  height: 4rem;
  position: relative;
  margin-bottom: 1.6rem;
  border-radius: 4px;
  box-shadow: 0 0 3px 0px #bcbcbc;
  padding: 0 10px;
  border: 1px solid transparent;
}

.form-field-group {
  display: flex;
  flex-flow: wrap;
}

.form-field-group div {
  flex: 0 0 50%;
}

.form-field-group div:first-child div {
  border-radius: 4px 0 0 4px;
  clip-path: inset(-3px 0px -3px -3px);
}

.form-field-group div:last-child div {
  border-radius: 0 4px 4px 0;
}

button[type="submit"] {
  width: 100%;
  color: white;
  background-color: #1890FF;
  margin-top: 1.6rem;
  text-transform: uppercase;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI";
  font-size: 1.4rem;
  height: 4rem;
  font-weight: 400;
  text-align: center;
  border: 1px solid transparent;
  padding: 0.375rem 0.75rem;
  border-radius: 0.25rem;
}

.form-field.vgs-collect-container__focused {
  border-color: #1890FF;
}

.form-field-group .form-field.vgs-collect-container__focused {
  clip-path: none;
}

and src/app.js, which initializes the collect.js library. Take a look at env vars:

  • process.env.VGS_VAULT_ID - it contains vaultId we've added to netlify previously
  • process.env.VGS_ROUTE_ID - this one will be created automatically by the plugin during deployment.
const vgsForm = VGSCollect.create(
  process.env.VGS_VAULT_ID,
  'sandbox',
  (state) => {}).setRouteId(process.env.VGS_ROUTE_ID);

const css = {
  boxSizing: 'border-box',
  fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI"',
  color: '#000000',
  '&::placeholder': {
    color: '#bcbcbc'
  }
};

vgsForm.field('#email', {
  type: 'text',
  name: 'login_email',
  placeholder: 'e.g. [email protected]',
  validations: ['required'],
  css
});

vgsForm.field('#password', {
  type: 'password',
  name: 'login_password',
  validations: ['required'],
  placeholder: 'password',
  css
});

document.getElementById('vgs-collect-form').addEventListener('submit', (e) => {
  e.preventDefault();
  vgsForm.tokenize((status, response) => {
    if (status === 200) {
      /**
       * Retrieve tokens from the response and send them to your server.
       */
      console.log(response);
    }
  }, (error) => {
    console.log(error);
  });
});

Now, create netlify.toml file with the following contents:

[build]
  publish = "dist/"
  command = "npm run build"

[dev]
  command = "npm start"

[[plugins]]
  package = "@vgs/netlify-plugin-vgs"

And the last thing, create a package.json file, it should contain:

  • the plugin itself @vgs/netlify-plugin-vgs
  • parcel to help with the build process
  • an entry point declaration "source": "src/index.html":
{
  "name": "netlify-plugin-example",
  "version": "1.0.0",
  "source": "src/index.html",
  "scripts": {
    "start": "parcel",
    "build": "parcel build"
  },
  "devDependencies": {
    "@vgs/netlify-plugin-vgs": "0.0.4",
    "parcel": "^2.6.2"
  }
}

and install dependencies by running

npm install

Now, your directory structure should look like this:

your-app
├─ ...
├─ src
| |─ index.html
| |─ style.css
| └─ app.js
├─ netlify.toml
└─ package.json

Start local server

Now, you are ready to start the development server, you can do it by running. It will build your app and open the browser with your running app at http://localhost:8888

netlify build && netlify dev

Deploy to production

This command will build and deploy your code to production. In the output you will find a public URL with your app.

netlify build && netlify deploy --production