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

lucify-deploy-config

v0.1.11

Published

Deploy configuration for Lucify projects

Downloads

10

Readme

Deploy configuration for Lucify environment

This project provides environment-specific default deploy configurations for Lucify projects.

Install

npm install lucify-deploy-config --save-dev

Usage

General

const lucifyDeployConfig = require('lucify-deploy-config');

const env = process.env.NODE_ENV;
const opts = {};

// see configuration for current settings
const config = lucifyDeployConfig(env, opts);
console.log(config.base);

The returned config object has the following keys:

  • env: Environment, resolved as follows:
    1. Provided env option.
    2. LUCIFY_ENV.
    3. NODE_ENV.
    4. If none of the the tree are defined, defaults to test.
  • base: base configuration object, determined by defaults for current environment and provided options. The object has the following keys:
    • bucket: Name of S3 bucket to which to publish. These are the default values for defaults environments:
      • test: lucify-protected
      • development: lucify-dev
      • staging: lucify-staging
      • production: lucify-protected
    • baseUrl: Base URL, not including path. These are the default values for default environments:
      • test: https://protected.lucify.com/
      • development: http://dev.lucify.com/
      • staging: http://staging.lucify.com/
      • production: http://www.lucify.com/
    • maxAge: Cache duration for assets that are not entry points. These are the default values for default environments:
      • test, development and staging: 0
      • production: 3600
    • publicPath: Public path, after baseUrl. These are the defaults for default environments:
      • test, /${project}-${branch}-${commit}/
      • development, staging and production: /
    • project: Name of the project. Resolved by default with project-name.
    • url: Full URL to publicPath. Defaults to string joined from baseUrl and publicPath.
    • dest: Local path to publicPath. Defaults to one joined from the string dist and publicPath.
    • branch: Defaults to current git branch.
    • commit: Defauls to current git commit.
    • flow: The Flowdock flow id for posting notifications. If not given, falls back to the FLOW environment variable.
      • The following snippet might be helpfulf for finding out the correct id
          curl -s -u [user]:[password] https://api.flowdock.com/flows | jq '[.[] | select(.organization.name | test("lucify"; "ix")) | {key: .id, value: {name, org: .organization.name}}] | from_entries'
  • atomicS3: Default configuration object for atomic-s3, resolved from the base object.
  • flowdockDeployNotify: Default configuration object for flowdock-deploy-notify, resolved from the base object.
  • embedSupport, Default configuration object for embed-support, resolved from the base object.

You can override any of values in the base configuration with the opts parameter. The example following overrides maxAge for all environments:

const lucifyDeployConfig = require('lucify-deploy-config');
const env = process.env.NODE_ENV;
const opts = { maxAge: 1000 };
const config = lucifyDeployConfig(env, opts);
console.log(config.base.maxAge);  // outputs 1000

You can also pass a function, taking env as its first parameter.

const lucifyDeployConfig = require('lucify-deploy-config');
const env = process.env.NODE_ENV;
const opts = {
    maxAge: function(env) {
        if (env == 'test') {
            return 100;
        }
        if (env === 'staging') {
            return 200;
        }
        return;
    }
};
const config = lucifyDeployConfig('test', opts);
console.log(config.base.maxAge); // returns 100
const config = lucifyDeployConfig('staging', opts);
console.log(config.base.maxAge); // returns 200
const config = lucifyDeployConfig('production', opts);
console.log(config.base.maxAge); // returns 3600 (default value)

If the function returns undefined, default value for current environment is returned. This way you can use a function to override only some defaults.

Usage with atomic-s3

Example of atomic-s3.config.js:

var lucifyDeployConfig = require('lucify-deploy-config').default;
module.exports = lucifyDeployConfig().atomicS3;

For the test environment, this will export the following configuration:

{
  path: 'dist',
  s3options: {
    params: {
        Bucket: 'lucify-protected'
    },
    region: 'eu-west-1'
  },
  entryPoints: [ '**/*.html', '**/resize.js', '**/embed.js', '*.{png,ico}' ]
}

The project supports providing encrypted aws credentials via the environment variable AWS_CREDENTIALS. The variable must be a JSON string encrypted with libsodium using crypto_secretbox_open_easy. The string should represent a json object with the following fields:

  • access_key_id,
  • secret_access_key,
  • session_token

For decryption to work, you should also define LUCIFY_ENC_NONCE and LUCIFY_ENC_KEY. We are using this for (production) deployments triggered from Heaven.

Usage with embed-support

Example of embed-support.config.js

var lucifyDeployConfig = require('lucify-deploy-config').default;
module.exports = lucifyDeployConfig().embedSupport;

For the test environment, this will export the following configuration:

{
  dest: 'dist/[project]-[branch]-[commit]/',
  destUrl: 'https://protected.lucify.com/[project]-[branch]-[commit]/',
  iframeUrl: 'https://protected.lucify.com/[project]-[branch]-[commit]/'
}

Usage with lucify-notifier

Example of lucify-notifier.config.js

var lucifyDeployConfig = require('lucify-deploy-config').default;
module.exports = lucifyDeployConfig().lucifyNotifier;

This will export the following configuration:

{
  deployment: {
    branch: {
      ref: base.branch,
      owner: process.env.CIRCLE_PROJECT_USERNAME || 'lucified',
      repository: base.project,
    },
    committer: process.env.GITHUB_USERNAME || process.env.CIRCLE_USERNAME,
    url: base.url,
    build_url: process.env.CIRCLE_BUILD_URL,
    environment: env,
  },
  github: {
    s3_credentials: 'lucify-configuration/lucify-notifier/github_integration_credentials.json',
    deploymentOptions: {
      transient_environment: true,
    },
  },
  flowdock: {
    flow_token: '',
    author: {
      email: '[email protected]',
    },
  },
  decryption_key: 's3://lucify-configuration/lucifer/public-key.pem',
}

Test

Make sure you have the correct node version

nvm use

Then run tests with

npm test