@orion-js/env 3.10.0 → 3.11.6-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cli/index.js CHANGED
@@ -8,6 +8,7 @@ const commander_1 = require("commander");
8
8
  const safe_1 = __importDefault(require("colors/safe"));
9
9
  const init_1 = __importDefault(require("./init"));
10
10
  const add_1 = __importDefault(require("./add"));
11
+ const read_1 = __importDefault(require("./read"));
11
12
  const program = new commander_1.Command();
12
13
  const run = function (action) {
13
14
  return async function (...args) {
@@ -29,6 +30,13 @@ program
29
30
  .description('Adds a new environment to the encrypted env file')
30
31
  .option('--path <path>', 'Specify the env file name')
31
32
  .action(run(add_1.default));
33
+ program
34
+ .command('read')
35
+ .description('Prints the value of the env file in JSON or a specific variable in plain text')
36
+ .option('--path <path>', 'Specify the env file name')
37
+ .option('--key <key>', 'Prints the value of a specific variable in plain text')
38
+ .option('--secret <secret>', 'The password to decrypt the keys')
39
+ .action(run(read_1.default));
32
40
  program.parse(process.argv);
33
41
  if (!process.argv.slice(2).length) {
34
42
  program.outputHelp();
@@ -0,0 +1,5 @@
1
+ export default function envRead({ path, key, secret }: {
2
+ path: any;
3
+ key: any;
4
+ secret: any;
5
+ }): Promise<void>;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const getVariables_1 = require("../../environment/getVariables");
4
+ const getConfig_1 = require("../add/getConfig");
5
+ async function envRead({ path, key, secret }) {
6
+ if (!path) {
7
+ path = '.env.local.yml';
8
+ }
9
+ if (!secret) {
10
+ throw new Error('Secret is required');
11
+ }
12
+ const config = (0, getConfig_1.getConfig)(path);
13
+ const variables = (0, getVariables_1.getVariables)(config, secret);
14
+ if (key) {
15
+ console.log(variables[key]);
16
+ }
17
+ else {
18
+ console.log(JSON.stringify(variables, null, 2));
19
+ }
20
+ }
21
+ exports.default = envRead;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orion-js/env",
3
- "version": "3.10.0",
3
+ "version": "3.11.6-alpha.0",
4
4
  "main": "lib/index.js",
5
5
  "author": "nicolaslopezj",
6
6
  "license": "MIT",
@@ -32,5 +32,5 @@
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "gitHead": "68036a0293066cc23feb3000ab44e58600540615"
35
+ "gitHead": "cdcf47aed25cb864126e624cd808c08d7959b8a4"
36
36
  }