@benshawmean/envedit 1.4.1-3 → 1.4.1
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/config.ts +5 -5
- package/package.json +1 -1
package/lib/config.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface VariableConfiguration {
|
|
|
19
19
|
type: VariableType;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export interface
|
|
22
|
+
export interface EnvironmentConfiguration {
|
|
23
23
|
name: string;
|
|
24
24
|
prefix: string;
|
|
25
25
|
file: string;
|
|
@@ -28,13 +28,13 @@ export interface EnviornmentConfiguration {
|
|
|
28
28
|
|
|
29
29
|
export interface GeneralConfiguration {
|
|
30
30
|
version: number;
|
|
31
|
-
environments:
|
|
31
|
+
environments: EnvironmentConfiguration[];
|
|
32
32
|
variables: VariableConfiguration[];
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export class Configuration {
|
|
36
36
|
public readonly vars: Map<string, VariableConfiguration> = new Map();
|
|
37
|
-
public readonly envs: Map<string,
|
|
37
|
+
public readonly envs: Map<string, EnvironmentConfiguration> = new Map();
|
|
38
38
|
public readonly version: number = 1;
|
|
39
39
|
private readonly configFilePath: string = 'env.config.yaml';
|
|
40
40
|
|
|
@@ -48,18 +48,18 @@ export class Configuration {
|
|
|
48
48
|
const configContent = Bun.YAML.parse(read(this.configFilePath, "utf-8")) as GeneralConfiguration;
|
|
49
49
|
|
|
50
50
|
const setWrapper = <
|
|
51
|
-
K extends
|
|
51
|
+
K extends EnvironmentConfiguration | VariableConfiguration
|
|
52
52
|
>(map: Map<string, K>): ((item: K) => void) => (item: K) => void map.set(item.name, item);
|
|
53
53
|
|
|
54
54
|
configContent.environments.forEach(setWrapper(this.envs))
|
|
55
55
|
configContent.variables.forEach(setWrapper(this.vars))
|
|
56
|
-
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
public save() {
|
|
60
59
|
write(
|
|
61
60
|
this.configFilePath,
|
|
62
61
|
Bun.YAML.stringify({
|
|
62
|
+
"$schema": "https://benshawmean.com/api/schema/envedit",
|
|
63
63
|
version: this.version,
|
|
64
64
|
environments: Array.from(this.envs.values()),
|
|
65
65
|
variables: Array.from(this.vars.values()),
|