5htp 0.0.3 → 0.0.5

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "5htp",
3
3
  "description": "5-HTP, scientifically called 5-Hydroxytryptophan, is the precursor of happiness neurotransmitter.",
4
- "version": "0.0.3",
4
+ "version": "0.0.5",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp-cli.git",
7
7
  "license": "MIT",
@@ -89,8 +89,5 @@
89
89
  "@types/nodemailer": "^6.4.4",
90
90
  "@types/prompts": "^2.0.14",
91
91
  "@types/webpack-env": "^1.16.2"
92
- },
93
- "peerDependencies": {
94
- "5htp-core": "^0.0.3"
95
- }
92
+ }
96
93
  }
package/src/index.ts CHANGED
@@ -10,7 +10,7 @@ import cp from 'child_process';
10
10
 
11
11
  // Libs
12
12
  import Paths from './paths';
13
- import ConfigParser from '5htp-core/src/server/app/config';
13
+ import ConfigParser from './utils/config';
14
14
 
15
15
  /*----------------------------------
16
16
  - TYPES
@@ -0,0 +1,41 @@
1
+ /*----------------------------------
2
+ - DEPENDANCES
3
+ ----------------------------------*/
4
+
5
+ /*
6
+ WARNING: This file SHOULDN'T import deps from the project
7
+ Because it's imported by the CLI, which should be independant of the app escept for loading config
8
+ */
9
+
10
+ // Npm
11
+ import fs from 'fs-extra';
12
+ import yaml from 'yaml';
13
+
14
+ /*----------------------------------
15
+ - LOADE
16
+ ----------------------------------*/
17
+ export default class ConfigParser {
18
+
19
+ public constructor(
20
+ public appDir: string,
21
+ public envName?: string
22
+ ) {
23
+
24
+ }
25
+
26
+ private loadYaml( filepath: string ) {
27
+ console.info(`Loading config ${filepath}`);
28
+ const rawConfig = fs.readFileSync(filepath, 'utf-8');
29
+ return yaml.parse(rawConfig);
30
+ }
31
+
32
+ public env() {
33
+ const envFile = this.appDir + '/env' + (this.envName === undefined ? '' : '.' + this.envName) + '.yaml';
34
+ return this.loadYaml( envFile );
35
+ }
36
+
37
+ public identity() {
38
+ const identityFile = this.appDir + '/identity.yaml';
39
+ return this.loadYaml( identityFile );
40
+ }
41
+ }