@catladder/cli 1.105.0 → 1.105.2
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/dist/apps/catenv/printVariables.js +1 -0
- package/dist/apps/catenv/printVariables.js.map +1 -1
- package/dist/apps/catenv/writeDotEnvFiles.js +1 -0
- package/dist/apps/catenv/writeDotEnvFiles.js.map +1 -1
- package/dist/bundles/catenv/index.js +3 -3
- package/dist/bundles/cli/index.js +2 -2
- package/dist/config/getProjectConfig.d.ts +2 -6
- package/dist/config/getProjectConfig.js +27 -24
- package/dist/config/getProjectConfig.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/apps/catenv/printVariables.ts +3 -1
- package/src/apps/catenv/writeDotEnvFiles.ts +1 -0
- package/src/config/getProjectConfig.ts +34 -20
package/package.json
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"node": ">=12.0.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@catladder/pipeline": "1.105.
|
|
27
|
+
"@catladder/pipeline": "1.105.2",
|
|
28
28
|
"@kubernetes/client-node": "^0.16.2",
|
|
29
29
|
"@tsconfig/node14": "^1.0.1",
|
|
30
30
|
"@types/common-tags": "^1.8.0",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"typescript": "^4.5.4",
|
|
58
58
|
"vorpal": "^1.12.0"
|
|
59
59
|
},
|
|
60
|
-
"version": "1.105.
|
|
60
|
+
"version": "1.105.2"
|
|
61
61
|
}
|
|
@@ -13,7 +13,7 @@ const getAllVariablesToPrint = async (config: Config, choice?: Choice) => {
|
|
|
13
13
|
choice
|
|
14
14
|
);
|
|
15
15
|
|
|
16
|
-
let variables = {};
|
|
16
|
+
let variables: Record<string, string> = {};
|
|
17
17
|
if (currentComponent) {
|
|
18
18
|
variables = await getEnvVarsResolved(null, env, currentComponent);
|
|
19
19
|
} else {
|
|
@@ -23,6 +23,7 @@ const getAllVariablesToPrint = async (config: Config, choice?: Choice) => {
|
|
|
23
23
|
variables = await Object.keys(config.components).reduce(
|
|
24
24
|
async (acc, componentName) => {
|
|
25
25
|
const subappvars = await getEnvVarsResolved(null, env, componentName);
|
|
26
|
+
delete subappvars["_ALL_ENV_VAR_KEYS"];
|
|
26
27
|
return {
|
|
27
28
|
...(await acc),
|
|
28
29
|
...subappvars,
|
|
@@ -38,6 +39,7 @@ const getAllVariablesToPrint = async (config: Config, choice?: Choice) => {
|
|
|
38
39
|
{}
|
|
39
40
|
);
|
|
40
41
|
}
|
|
42
|
+
|
|
41
43
|
return variables;
|
|
42
44
|
};
|
|
43
45
|
|
|
@@ -32,6 +32,7 @@ export const writeDotEnvFiles = async (config: Config, choice?: Choice) => {
|
|
|
32
32
|
|
|
33
33
|
for (const componentName of componentsToActuallyWriteDotEnvNow) {
|
|
34
34
|
const variables = await getEnvVarsResolved(null, env, componentName);
|
|
35
|
+
delete variables["_ALL_ENV_VAR_KEYS"];
|
|
35
36
|
const componentDir = getComponentFullPath(gitRoot, config, componentName);
|
|
36
37
|
const filePath = join(componentDir, ".env");
|
|
37
38
|
// many .dotenv don't like multiline values, so we sanitize them here
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Config } from "@catladder/pipeline";
|
|
1
|
+
import type { Config, EnvironmentEnvVars } from "@catladder/pipeline";
|
|
2
2
|
import {
|
|
3
3
|
readConfigSync,
|
|
4
4
|
getAllEnvs,
|
|
@@ -124,24 +124,32 @@ export const getGitlabVar = async (
|
|
|
124
124
|
|
|
125
125
|
const resolveSecrets = async (
|
|
126
126
|
vorpal: CommandInstance | null,
|
|
127
|
-
|
|
127
|
+
varSets: EnvironmentEnvVars[]
|
|
128
128
|
) => {
|
|
129
129
|
const allVariablesInGitlab = await getAllVariables(vorpal);
|
|
130
130
|
|
|
131
131
|
return Object.fromEntries(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
132
|
+
varSets.flatMap((set) =>
|
|
133
|
+
Object.entries(set.envVars)
|
|
134
|
+
.map(([key, value]) => {
|
|
135
|
+
const secretKey = set.secretEnvVarKeys.find((k) => k.key === key);
|
|
136
|
+
|
|
137
|
+
if (secretKey) {
|
|
138
|
+
if (secretKey.hidden) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
for (const variable of allVariablesInGitlab) {
|
|
142
|
+
value = value.replace(
|
|
143
|
+
new RegExp("\\$" + variable.key, "g"),
|
|
144
|
+
variable.value
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
return [key, value];
|
|
148
|
+
}
|
|
149
|
+
return [key, value];
|
|
150
|
+
})
|
|
151
|
+
.filter(Boolean)
|
|
152
|
+
)
|
|
145
153
|
);
|
|
146
154
|
};
|
|
147
155
|
|
|
@@ -155,9 +163,15 @@ export const getEnvVarsResolved = async (
|
|
|
155
163
|
}
|
|
156
164
|
try {
|
|
157
165
|
const envionment = await getEnvironment(env, componentName);
|
|
166
|
+
|
|
158
167
|
// in the pipeline the secrets alreadyy exists and bash will expand them
|
|
159
168
|
// but here we need to manually load them
|
|
160
|
-
return resolveSecrets(vorpal,
|
|
169
|
+
return resolveSecrets(vorpal, [
|
|
170
|
+
{
|
|
171
|
+
envVars: envionment.envVars,
|
|
172
|
+
secretEnvVarKeys: envionment.secretEnvVarKeys,
|
|
173
|
+
},
|
|
174
|
+
]);
|
|
161
175
|
} catch (e) {
|
|
162
176
|
// env is disabled
|
|
163
177
|
return {};
|
|
@@ -175,10 +189,10 @@ export const getJobOnlyEnvVarsResolved = async (
|
|
|
175
189
|
) => {
|
|
176
190
|
try {
|
|
177
191
|
const envionment = await getEnvironment(env, componentName);
|
|
178
|
-
return resolveSecrets(vorpal,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
192
|
+
return resolveSecrets(vorpal, [
|
|
193
|
+
envionment.jobOnlyVars.build,
|
|
194
|
+
envionment.jobOnlyVars.deploy,
|
|
195
|
+
]);
|
|
182
196
|
} catch (e) {
|
|
183
197
|
// env is disabled
|
|
184
198
|
return {};
|