Skip to content

Commit faac277

Browse files
committed
Robo feedabck
1 parent 60a3bce commit faac277

File tree

3 files changed

+29
-28
lines changed

3 files changed

+29
-28
lines changed

src/apphosting/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { join, dirname, basename } from "path";
1+
import { join, dirname } from "path";
22
import { writeFileSync } from "fs";
33
import * as yaml from "yaml";
44
import * as clc from "colorette";
@@ -63,7 +63,7 @@ export function discoverBackendRoot(cwd: string): string | null {
6363

6464
while (true) {
6565
const files = fs.listFiles(dir);
66-
if (files.some((file) => APPHOSTING_YAML_FILE_REGEX.test(file) || basename(file) === ".env")) {
66+
if (files.some((file) => APPHOSTING_YAML_FILE_REGEX.test(file) || file === ".env")) {
6767
return dir;
6868
}
6969

src/apphosting/env.ts

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,34 @@ export async function diffEnvs(
2929
const matched: string[] = [];
3030
const conflicts: string[] = [];
3131

32-
// Note: Can conceivably optimize this by parallelizing lookups of secret values with fetchSecrets.
33-
// Unlikely to actually cause noticeable benefits.
34-
for (const [key, value] of Object.entries(envs)) {
35-
const existingEnv = config.findEnv(doc, key);
36-
if (!existingEnv) {
37-
newVars.push(key);
38-
continue;
39-
}
32+
await Promise.all(
33+
Object.entries(envs).map(async ([key, value]) => {
34+
const existingEnv = config.findEnv(doc, key);
35+
if (!existingEnv) {
36+
newVars.push(key);
37+
return;
38+
}
4039

41-
let match = false;
42-
if (existingEnv.value) {
43-
match = existingEnv.value === value;
44-
} else {
45-
try {
46-
match =
47-
value ===
48-
(await secretManager.accessSecretVersion(projectId, existingEnv.secret!, "latest"));
49-
} catch (err) {
50-
utils.logLabeledWarning(
51-
"apphosting",
52-
`Cannot read value of existing secret ${existingEnv.secret!} to see if it has changed. Assuming it has changed.`,
53-
);
40+
let match = false;
41+
if (existingEnv.value) {
42+
match = existingEnv.value === value;
43+
} else {
44+
try {
45+
match =
46+
value ===
47+
(await secretManager.accessSecretVersion(projectId, existingEnv.secret!, "latest"));
48+
} catch (err) {
49+
utils.logLabeledWarning(
50+
"apphosting",
51+
`Cannot read value of existing secret ${existingEnv.secret!} to see if it has changed. Assuming it has changed.`,
52+
);
53+
}
5454
}
55-
}
5655

57-
(match ? matched : conflicts).push(key);
58-
}
56+
(match ? matched : conflicts).push(key);
57+
}),
58+
);
59+
5960
return { newVars, matched, conflicts };
6061
}
6162

src/commands/apphosting-env-import.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { fileExistsSync } from "../fsutils";
99
import { FirebaseError } from "../error";
1010
import { promises as fs } from "fs";
1111
import * as path from "path";
12-
import * as env from "../functions/env";
12+
import * as functionsEnv from "../functions/env";
1313
import * as config from "../apphosting/config";
1414
import * as prompt from "../prompt";
1515
import { requirePermissions } from "../requirePermissions";
@@ -57,7 +57,7 @@ export const command = new Command("apphosting:env:import")
5757
}
5858

5959
const envFileContent = await fs.readFile(envFilePath, "utf8");
60-
const { envs, errors } = env.parse(envFileContent);
60+
const { envs, errors } = functionsEnv.parse(envFileContent);
6161

6262
if (errors.length > 0) {
6363
throw new FirebaseError(`Invalid .env file: ${errors.join(", ")}`);

0 commit comments

Comments
 (0)