Socket
Socket
Sign inDemoInstall

@dotenv/cli

Package Overview
Dependencies
109
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0 to 2.2.0

11

lib/commands/push.d.ts

@@ -1,5 +0,14 @@

import { Command } from '@oclif/command';
import { Command, flags } from '@oclif/command';
export default class Push extends Command {
static description: string;
static args: {
name: string;
required: boolean;
description: string;
hidden: boolean;
}[];
static flags: {
dotenv_me: flags.IOptionFlag<string | undefined>;
};
run(): Promise<void>;
}

@@ -11,2 +11,3 @@ "use strict";

async run() {
const { argv, flags } = this.parse(Push);
// 0. check latest version

@@ -18,5 +19,5 @@ await new check_latest_version_service_1.CheckLatestVersionService().run();

await new warn_if_env_project_does_not_exist_service_1.WarnIfEnvProjectDoesNotExistService({ _this: this }).run();
await new warn_if_env_does_not_exist_service_1.WarnIfEnvDoesNotExistService({ _this: this }).run();
await new warn_if_env_does_not_exist_service_1.WarnIfEnvDoesNotExistService({ _this: this, filename: argv[0] }).run();
// 3. push
await new push_service_1.PushService().run();
await new push_service_1.PushService(argv[0], flags.dotenv_me || '').run();
}

@@ -26,1 +27,19 @@ }

Push.description = 'push .env';
Push.args = [
{
name: 'filename',
required: false,
description: 'Set input filename. Defaults to .env for development and .env.{environment} for other environments',
hidden: false,
},
];
Push.flags = {
dotenv_me: command_1.flags.string({
char: 'm',
description: 'pass value for .env.me rather than reading from .env.me file',
hidden: false,
multiple: false,
env: 'DOTENV_ME',
required: false,
}),
};

@@ -58,3 +58,4 @@ import * as dotenv from 'dotenv';

get _smartPullMessage(): string;
get _missingMeFile(): boolean;
}
export { PullService };

16

lib/services/pull-service.js

@@ -20,7 +20,3 @@ "use strict";

async run() {
const meFile = '.env.me';
if (fs.existsSync(meFile)) {
this._pull();
}
else {
if (this._missingMeFile) {
// eslint-disable-next-line no-warning-comments

@@ -31,2 +27,5 @@ // TODO: prompt the user if they want to create a .env.me file - rather than raise an error. in dev maybe prompt but for prod, etc it should raise a stacktrace most likely. since machines won't be able to answer the prompts

}
else {
this._pull();
}
}

@@ -198,3 +197,10 @@ async _pull() {

}
get _missingMeFile() {
// dont' require .env.me if passing dotenv_me as flag
if (this.dotenv_me && this.dotenv_me.length > 0) {
return false;
}
return !fs.existsSync('.env.me');
}
}
exports.PullService = PullService;
import * as dotenv from 'dotenv';
declare class PushService {
filename: string;
dotenv_me: string;
constructor(filename: string, dotenv_me: string);
run(): Promise<void>;

@@ -44,2 +47,4 @@ _push(): Promise<void>;

};
get _envFileName(): string;
get _envInputFileName(): string;
get _envMe(): dotenv.DotenvConfigOutput;

@@ -50,3 +55,5 @@ get _envProject(): dotenv.DotenvConfigOutput;

get _DOTENV_PROJECT_NAME(): string;
get _smartPushMessage(): string;
get _missingMeFile(): boolean;
}
export { PushService };

@@ -12,15 +12,18 @@ "use strict";

class PushService {
constructor(filename, dotenv_me) {
this.filename = filename;
this.dotenv_me = dotenv_me;
}
async run() {
const meFile = '.env.me';
if (fs.existsSync(meFile)) {
this._push();
}
else {
if (this._missingMeFile) {
await new write_env_me_service_1.WriteEnvMeService().run();
this._auth();
}
else {
this._push();
}
}
async _push() {
console.log('remote:');
console.log('remote: Securely pushing .env');
console.log(`remote: Securely pushing ${this._smartPushMessage}`);
console.log('remote:');

@@ -120,3 +123,3 @@ axios(this._pushOptions)

meUid: this._DOTENV_ME,
dotenv: fs.readFileSync('.env', 'UTF-8'),
dotenv: fs.readFileSync(this._envFileName, 'UTF-8'),
};

@@ -131,2 +134,12 @@ const options = {

}
get _envFileName() {
return this._envInputFileName;
}
get _envInputFileName() {
// if user has set a filename for input then use that
if (this.filename) {
return this.filename;
}
return '.env';
}
get _envMe() {

@@ -139,2 +152,5 @@ return dotenv.config({ path: '.env.me' });

get _DOTENV_ME() {
if (this.dotenv_me && this.dotenv_me.length > 0) {
return this.dotenv_me;
}
return (this._envMe.parsed || {}).DOTENV_ME;

@@ -148,3 +164,16 @@ }

}
get _smartPushMessage() {
if (this.filename) {
return `${this._envFileName}`;
}
return this._envFileName;
}
get _missingMeFile() {
// dont' require .env.me if passing dotenv_me as flag
if (this.dotenv_me && this.dotenv_me.length > 0) {
return false;
}
return !fs.existsSync('.env.me');
}
}
exports.PushService = PushService;
interface WarnIfEnvDoesNotExistServiceParams {
_this: any;
filename: any;
}
declare class WarnIfEnvDoesNotExistService {
_this: any;
filename: any;
constructor(params?: WarnIfEnvDoesNotExistServiceParams);
run(): Promise<void>;
get _envFileName(): any;
get _envInputFileName(): any;
}
export { WarnIfEnvDoesNotExistService };

@@ -9,12 +9,22 @@ "use strict";

this._this = params._this;
this.filename = params.filename;
}
async run() {
const envFile = '.env';
// 1. write .env.project
const envFile = this._envFileName;
if (!fs.existsSync(envFile)) {
signale.fatal('Missing .env. To create it, run \'echo "KEY=VALUE" > .env\' (or maybe you meant to run dotenv-cli pull?)');
signale.fatal(`Missing ${envFile}. To create it, run 'echo "KEY=VALUE" > .env' (or maybe you meant to run dotenv-cli pull?)`);
this._this.exit(1);
}
}
get _envFileName() {
return this._envInputFileName;
}
get _envInputFileName() {
// if user has set a filename for input then use that
if (this.filename) {
return this.filename;
}
return '.env';
}
}
exports.WarnIfEnvDoesNotExistService = WarnIfEnvDoesNotExistService;

@@ -1,1 +0,1 @@

{"version":"2.1.0","commands":{"new":{"id":"new","description":"create .env.project file","pluginName":"@dotenv/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"pull":{"id":"pull","description":"pull .env","pluginName":"@dotenv/cli","pluginType":"core","aliases":[],"flags":{"dotenv_me":{"name":"dotenv_me","type":"option","char":"m","description":"pass value for .env.me rather than reading from .env.me file","hidden":false,"required":false}},"args":[{"name":"environment","description":"Pull .env.ci, .env.staging, and .env.production","required":false,"options":["development","ci","staging","production"],"default":"development","hidden":false},{"name":"filename","description":"Set output filename. Defaults to .env for development and .env.{environment} for other environments","required":false,"hidden":false}]},"push":{"id":"push","description":"push .env","pluginName":"@dotenv/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"setup":{"id":"setup","description":"set up .env, .env.project, and .env.me","pluginName":"@dotenv/cli","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"dotenv_project","description":"Uniquely identifies the project","required":true},{"name":"dotenv_me","description":"Uniquely authorizes you to access this project's .env file","required":true}]}}}
{"version":"2.2.0","commands":{"new":{"id":"new","description":"create .env.project file","pluginName":"@dotenv/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"pull":{"id":"pull","description":"pull .env","pluginName":"@dotenv/cli","pluginType":"core","aliases":[],"flags":{"dotenv_me":{"name":"dotenv_me","type":"option","char":"m","description":"pass value for .env.me rather than reading from .env.me file","hidden":false,"required":false}},"args":[{"name":"environment","description":"Pull .env.ci, .env.staging, and .env.production","required":false,"options":["development","ci","staging","production"],"default":"development","hidden":false},{"name":"filename","description":"Set output filename. Defaults to .env for development and .env.{environment} for other environments","required":false,"hidden":false}]},"push":{"id":"push","description":"push .env","pluginName":"@dotenv/cli","pluginType":"core","aliases":[],"flags":{"dotenv_me":{"name":"dotenv_me","type":"option","char":"m","description":"pass value for .env.me rather than reading from .env.me file","hidden":false,"required":false}},"args":[{"name":"filename","description":"Set input filename. Defaults to .env for development and .env.{environment} for other environments","required":false,"hidden":false}]},"setup":{"id":"setup","description":"set up .env, .env.project, and .env.me","pluginName":"@dotenv/cli","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"dotenv_project","description":"Uniquely identifies the project","required":true},{"name":"dotenv_me","description":"Uniquely authorizes you to access this project's .env file","required":true}]}}}
{
"name": "@dotenv/cli",
"description": "CLI to interact with dotenv",
"version": "2.1.0",
"version": "2.2.0",
"author": "motdotla @motdotla",

@@ -6,0 +6,0 @@ "bin": {

@@ -75,5 +75,5 @@ # @dotenv/cli

### `dotenv-cli push`
### `dotenv-cli push [FILENAME]`
Push your `.env` file.
Push your `.env` file to development environment.

@@ -84,4 +84,31 @@ Example:

$ dotenv-cli push
# pushes local .env to remote development
```
#### Arguments
##### [FILENAME]
Set input filename. Defaults to .env.
Example:
```bash
$ dotenv-cli push .env.development
# pushes .env.development to remote development environment
```
#### Options
##### --dotenv_me
Directly pass your `DOTENV_ME` value to the command line, instead of reading from a `.env.me` file.
Examples:
```bash
$ dotenv-cli push .env.development --dotenv_me=me_1234
# pushes local .env.development to remote development
```
### `dotenv-cli pull [ENVIRONMENT] [FILENAME]`

@@ -88,0 +115,0 @@

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