Skip to content

Commit f8eab0b

Browse files
inlinedjoehan
andauthored
Code to create emulators.yaml uses backend root not project root (#8412)
* Use backend root, not project root to initilaize apphosting.emulators.yaml * Changelog & lint * Update CHANGELOG.md Co-authored-by: joehan <joehanley@google.com> --------- Co-authored-by: joehan <joehanley@google.com>
1 parent b8bbe0f commit f8eab0b

3 files changed

Lines changed: 4 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
- Upgraded `inquirer` library to address some visual bugs with prompting (#8389)
1+
- Fixed an issue where the prompt to create apphosting.emulator.yaml did not work with backends that are not at the project.root (#8412)

src/apphosting/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,11 @@ export async function maybeAddSecretToYaml(
218218
*/
219219
export async function maybeGenerateEmulatorYaml(
220220
projectId: string | undefined,
221-
repoRoot: string,
221+
backendRoot: string,
222222
): Promise<Env[] | null> {
223223
// Even if the app is in /project/app, the user might have their apphosting.yaml file in /project/apphosting.yaml.
224224
// Walk up the tree to see if we find other local files so that we can put apphosting.emulator.yaml in the right place.
225-
const basePath = dynamicDispatch.discoverBackendRoot(repoRoot) || repoRoot;
225+
const basePath = dynamicDispatch.discoverBackendRoot(backendRoot) || backendRoot;
226226
if (fs.fileExistsSync(join(basePath, APPHOSTING_EMULATORS_YAML_FILE))) {
227227
logger.debug(
228228
"apphosting.emulator.yaml already exists, skipping generation and secrets access prompt",

src/emulator/initEmulators.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { detectStartCommand } from "./apphosting/developmentServer";
77
import { EmulatorLogger } from "./emulatorLogger";
88
import { Emulators } from "./types";
99
import { Env, maybeGenerateEmulatorYaml } from "../apphosting/config";
10-
import { detectProjectRoot } from "../detectProjectRoot";
1110
import { Config } from "../config";
1211
import { getProjectId } from "../projectUtils";
1312
import { grantEmailsSecretAccess } from "../apphosting/secrets";
@@ -42,8 +41,7 @@ export const AdditionalInitFns: AdditionalInitFnsType = {
4241
const projectId = getProjectId(config.options);
4342
let env: Env[] | null = [];
4443
try {
45-
const projectRoot = detectProjectRoot({ cwd: config.options.cwd }) ?? backendRoot;
46-
env = await maybeGenerateEmulatorYaml(projectId, projectRoot);
44+
env = await maybeGenerateEmulatorYaml(projectId, backendRoot);
4745
} catch (e) {
4846
logger.log("WARN", "failed to export app hosting configs");
4947
}

0 commit comments

Comments
 (0)