# lucify-deploy-config

> Deploy configuration for Lucify projects

Latest version **0.1.11** (published 2017-01-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install lucify-deploy-config
pnpm add lucify-deploy-config
yarn add lucify-deploy-config
bun add lucify-deploy-config
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.11 |
| Published | 2017-01-06 |
| First published | 2016-06-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 6 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | lucify-master |

## Links

- npm: https://www.npmjs.com/package/lucify-deploy-config
- Repository: https://github.com/lucified/lucify-deploy-config
- Homepage: https://github.com/lucified/lucify-deploy-config#readme
- Issues: https://github.com/lucified/lucify-deploy-config/issues
- npm.io page: https://npm.io/package/lucify-deploy-config

## Dependencies (6)

- [lodash](https://npm.io/package/lodash.md) ^4.13.1
- [shortid](https://npm.io/package/shortid.md) ^2.2.6
- [url-join](https://npm.io/package/url-join.md) ^1.1.0
- [git-rev-sync](https://npm.io/package/git-rev-sync.md) ^1.6.0
- [project-name](https://npm.io/package/project-name.md) ^0.2.5
- [libsodium-wrappers](https://npm.io/package/libsodium-wrappers.md) ^0.2.12

## Recent versions

- 0.1.11 (latest) — 2017-01-06
- 0.1.10 — 2016-08-24
- 0.1.9 — 2016-07-14
- 0.1.8 — 2016-06-23
- 0.1.7 — 2016-06-16
- 0.1.6 — 2016-06-16
- 0.1.5 — 2016-06-16
- 0.1.4 — 2016-06-03
- 0.1.3 — 2016-06-02
- 0.1.2 — 2016-06-02
- 0.1.1 — 2016-06-01

## 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

```js
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](https://www.npmjs.com/package/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
        ```bash
            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](https://github.com/lucified/atomic-s3), resolved from the `base` object.
 - `flowdockDeployNotify`: Default configuration object for [flowdock-deploy-notify](https://github.com/lucified/flowdock-deploy-notify), resolved from the `base` object.
 - `embedSupport`, Default configuration object for [embed-support](https://github.com/lucified/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:

```js
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.

```js
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](https://github.com/lucified/atomic-s3)

Example of `atomic-s3.config.js`:
```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](https://github.com/lucified/embed-support)

Example of `embed-support.config.js`
```js
var lucifyDeployConfig = require('lucify-deploy-config').default;
module.exports = lucifyDeployConfig().embedSupport;
```

For the `test` environment, this will export the following configuration:
```js
{
  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](https://github.com/lucified/lucify-notifier)

Example of `lucify-notifier.config.js`
```js
var lucifyDeployConfig = require('lucify-deploy-config').default;
module.exports = lucifyDeployConfig().lucifyNotifier;
```

This will export the following configuration:
```js
{
  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: 'deploy@lucify.com',
    },
  },
  decryption_key: 's3://lucify-configuration/lucifer/public-key.pem',
}

```

# Test

Make sure you have the correct node version
```shell
nvm use
```

Then run tests with
```shell
npm test
```

---
_Source: https://npm.io/package/lucify-deploy-config · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
