Socket
Socket
Sign inDemoInstall

netlify-plugin-contextual-env

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.2.0

.circleci/config.yml

48

CHANGELOG.md

@@ -10,40 +10,52 @@ # Changelog

## [v0.1.0](https://github.com/cball/netlify-plugin-env/compare/v0.0.7...v0.1.0) - 2020-04-16
## [v0.2.0](https://github.com/cball/netlify-plugin-contextual-env/compare/v0.1.0...v0.2.0) - 2020-04-18
### Merged
- chore(ci): Set up CircleCI [`#3`](https://github.com/cball/netlify-plugin-contextual-env/pull/3)
### Commits
- rename plugin to contextual-env [`16339fe`](https://github.com/cball/netlify-plugin-env/commit/16339fe7b3935660f2f69c27972ba1fc99ff09e4)
- chore(tests): add jest and tests [`fc8b2b1`](https://github.com/cball/netlify-plugin-contextual-env/commit/fc8b2b1d5372aa20f2d9abf9cfd016b2a215e9ee)
- chore: add changelog and package that didn't commit [`266178d`](https://github.com/cball/netlify-plugin-contextual-env/commit/266178d22618b227d497a852b976e89cf22bcec4)
- chore: add prettier.rc [`9c9a8c7`](https://github.com/cball/netlify-plugin-contextual-env/commit/9c9a8c7fb42e1501693b962f07731c228a5c3477)
## [v0.0.7](https://github.com/cball/netlify-plugin-env/compare/v0.0.6...v0.0.7) - 2020-04-13
## [v0.1.0](https://github.com/cball/netlify-plugin-contextual-env/compare/v0.0.7...v0.1.0) - 2020-04-16
### Commits
- rename plugin to contextual-env [`16339fe`](https://github.com/cball/netlify-plugin-contextual-env/commit/16339fe7b3935660f2f69c27972ba1fc99ff09e4)
## [v0.0.7](https://github.com/cball/netlify-plugin-contextual-env/compare/v0.0.6...v0.0.7) - 2020-04-12
### Merged
- Ensure plugin completes [`#1`](https://github.com/cball/netlify-plugin-env/pull/1)
- Ensure plugin completes [`#1`](https://github.com/cball/netlify-plugin-contextual-env/pull/1)
## [v0.0.6](https://github.com/cball/netlify-plugin-env/compare/v0.0.5...v0.0.6) - 2020-04-12
## [v0.0.6](https://github.com/cball/netlify-plugin-contextual-env/compare/v0.0.5...v0.0.6) - 2020-04-12
### Commits
- write an env file and source it [`1801ed6`](https://github.com/cball/netlify-plugin-env/commit/1801ed664c4b72ce17eb88502c34be604293758d)
- update build logs and README [`d107a36`](https://github.com/cball/netlify-plugin-env/commit/d107a366696cb1821e54499778f3d0eb5bd1d8f3)
- write an env file and source it [`1801ed6`](https://github.com/cball/netlify-plugin-contextual-env/commit/1801ed664c4b72ce17eb88502c34be604293758d)
- update build logs and README [`d107a36`](https://github.com/cball/netlify-plugin-contextual-env/commit/d107a366696cb1821e54499778f3d0eb5bd1d8f3)
## [v0.0.5](https://github.com/cball/netlify-plugin-env/compare/v0.0.4...v0.0.5) - 2020-04-12
## [v0.0.5](https://github.com/cball/netlify-plugin-contextual-env/compare/v0.0.4...v0.0.5) - 2020-04-12
### Commits
- write an env file and source it [`def421b`](https://github.com/cball/netlify-plugin-env/commit/def421bcf22d836bb71ad04cb49adcc1d5dbe9ef)
- more [`0ccc961`](https://github.com/cball/netlify-plugin-env/commit/0ccc961dfdedef813a34243e68804324908580a9)
- write an env file and source it [`def421b`](https://github.com/cball/netlify-plugin-contextual-env/commit/def421bcf22d836bb71ad04cb49adcc1d5dbe9ef)
- more [`0ccc961`](https://github.com/cball/netlify-plugin-contextual-env/commit/0ccc961dfdedef813a34243e68804324908580a9)
## [v0.0.4](https://github.com/cball/netlify-plugin-env/compare/v0.0.3...v0.0.4) - 2020-04-12
## [v0.0.4](https://github.com/cball/netlify-plugin-contextual-env/compare/v0.0.3...v0.0.4) - 2020-04-12
### Commits
- Update build logs [`68c140d`](https://github.com/cball/netlify-plugin-env/commit/68c140d2be38f4c138a3eee8219429b473476f5e)
- Add ENV vars image to README [`d04650e`](https://github.com/cball/netlify-plugin-env/commit/d04650e7ce0256ba1f2c3262dbfaf17100be5261)
- Update build logs [`68c140d`](https://github.com/cball/netlify-plugin-contextual-env/commit/68c140d2be38f4c138a3eee8219429b473476f5e)
- Add ENV vars image to README [`d04650e`](https://github.com/cball/netlify-plugin-contextual-env/commit/d04650e7ce0256ba1f2c3262dbfaf17100be5261)
## [v0.0.3](https://github.com/cball/netlify-plugin-env/compare/v0.0.2...v0.0.3) - 2020-04-12
## [v0.0.3](https://github.com/cball/netlify-plugin-contextual-env/compare/v0.0.2...v0.0.3) - 2020-04-12
### Commits
- Release prep [`e80abbb`](https://github.com/cball/netlify-plugin-env/commit/e80abbbf13337c089ce13ad99590bb92bf259d62)
- Release prep [`e80abbb`](https://github.com/cball/netlify-plugin-contextual-env/commit/e80abbbf13337c089ce13ad99590bb92bf259d62)

@@ -54,4 +66,4 @@ ## v0.0.2 - 2020-04-12

- release prep [`f2dcbf8`](https://github.com/cball/netlify-plugin-env/commit/f2dcbf8aa3badd672181530d0036ceba1a29b5a4)
- Initial plugin [`f7145e6`](https://github.com/cball/netlify-plugin-env/commit/f7145e6b64783984e526a908c09a4ac9e7427e36)
- update docs [`0bc851c`](https://github.com/cball/netlify-plugin-env/commit/0bc851cafe4bd64377f7251e3cd7b819193be7c4)
- release prep [`f2dcbf8`](https://github.com/cball/netlify-plugin-contextual-env/commit/f2dcbf8aa3badd672181530d0036ceba1a29b5a4)
- Initial plugin [`f7145e6`](https://github.com/cball/netlify-plugin-contextual-env/commit/f7145e6b64783984e526a908c09a4ac9e7427e36)
- update docs [`0bc851c`](https://github.com/cball/netlify-plugin-contextual-env/commit/0bc851cafe4bd64377f7251e3cd7b819193be7c4)
{
"name": "netlify-plugin-contextual-env",
"version": "0.1.0",
"version": "0.2.0",
"description": "A Netlify plugin to override ENV vars based on a branch or context",

@@ -20,8 +20,10 @@ "main": "src/index",

"version": "auto-changelog -p --template keepachangelog && git add CHANGELOG.md",
"prepublishOnly": "git push && git push --tags && gh-release"
"prepublishOnly": "git push && git push --tags && gh-release",
"test": "jest"
},
"devDependencies": {
"auto-changelog": "^2.0.0",
"gh-release": "^3.5.0"
"gh-release": "^3.5.0",
"jest": "^25.3.0"
}
}

@@ -1,6 +0,5 @@

const fs = require("fs");
const util = require("util")
const fs = require('fs');
const util = require('util');
const pWriteFile = util.promisify(fs.writeFile);
const pWriteFile = util.promisify(fs.writeFile)
/**

@@ -19,4 +18,7 @@ * Overrides an ENV var with a value if it exists

console.log(`Setting ${key} to the value from ${envVar}.`);
process.env[key] = process.env[envVar];
console.log(`Exporting ${key}=${process.env[envVar]}.`);
// Renable this once setting process.env is supported in Netlify builds
// See: https://github.com/netlify/build/issues/1129
// process.env[key] = process.env[envVar];
return `${key}=${process.env[envVar]}\n`;

@@ -27,12 +29,16 @@ }

onPreBuild: async ({ inputs }) => {
const context = `${process.env.CONTEXT}`.toUpperCase().replace(/-/g, "_");
const branch = `${process.env.BRANCH}`.toUpperCase().replace(/-/g, "_");
const context = `${process.env.CONTEXT}`.toUpperCase().replace(/-/g, '_');
const branch = `${process.env.BRANCH}`.toUpperCase().replace(/-/g, '_');
const replaced = [].concat(...Object.keys(process.env)
.map((key) => [setEnvWithValue(key, context, inputs.mode), setEnvWithValue(key, branch, inputs.mode)])
).filter(Boolean)
const envOverrides = Object.keys(process.env).map((key) => [
setEnvWithValue(key, context, inputs.mode),
setEnvWithValue(key, branch, inputs.mode),
]);
const replaced = [].concat(...envOverrides).filter(Boolean);
if (replaced.length) {
// Write an env file so we can source it during build
await pWriteFile(".env", replaced.join(""))
await pWriteFile('.env', replaced.join(''));
console.log(`Replaced ${replaced.length} ENVs and wrote .env file`);

@@ -39,0 +45,0 @@ } else {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc