Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fixed `apps:init` writing `google-services.json` to an `app/app` path when the Android module has no `src` directory, by detecting the module from the directory basename instead of the first path segment (#10863).
13 changes: 10 additions & 3 deletions src/management/apps.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { expect } from "chai";
import * as sinon from "sinon";
import * as fs from "fs";
import * as path from "path";
import nock from "../test/helpers/nock";

import * as api from "../api";
Expand Down Expand Up @@ -138,7 +139,7 @@
it("should return the detected platform when only one is found", async () => {
getPlatformsFromFolderStub.resolves([appUtils.Platform.ANDROID]);

const platform = await getPlatform("any-dir", {} as any);

Check warning on line 142 in src/management/apps.spec.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unexpected any. Specify a different type

Check warning on line 142 in src/management/apps.spec.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unsafe argument of type `any` assigned to a parameter of type `Config`

expect(platform).to.equal(AppPlatform.ANDROID);
expect(getPlatformsFromFolderStub.calledOnceWith("any-dir")).to.be.true;
Expand All @@ -148,7 +149,7 @@
getPlatformsFromFolderStub.resolves([appUtils.Platform.ANDROID, appUtils.Platform.IOS]);
promptSelectStub.resolves("IOS");

const platform = await getPlatform("any-dir", {} as any);

Check warning on line 152 in src/management/apps.spec.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unexpected any. Specify a different type

Check warning on line 152 in src/management/apps.spec.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unsafe argument of type `any` assigned to a parameter of type `Config`

expect(platform).to.equal(AppPlatform.IOS);
expect(promptSelectStub.calledOnce).to.be.true;
Expand All @@ -160,7 +161,7 @@
getPlatformsFromFolderStub.withArgs("android-dir").resolves([appUtils.Platform.ANDROID]);
promptForDirectoryStub.resolves("android-dir");

const platform = await getPlatform("initial-dir", {} as any);

Check warning on line 164 in src/management/apps.spec.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unexpected any. Specify a different type

Check warning on line 164 in src/management/apps.spec.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unsafe argument of type `any` assigned to a parameter of type `Config`

expect(platform).to.equal(AppPlatform.ANDROID);
expect(promptForDirectoryStub.calledOnce).to.be.true;
Expand All @@ -171,9 +172,9 @@

let err;
try {
await getPlatform("any-dir", {} as any);

Check warning on line 175 in src/management/apps.spec.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unexpected any. Specify a different type

Check warning on line 175 in src/management/apps.spec.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unsafe argument of type `any` assigned to a parameter of type `Config`
} catch (e: any) {

Check warning on line 176 in src/management/apps.spec.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unexpected any. Specify a different type
err = e;

Check warning on line 177 in src/management/apps.spec.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unsafe assignment of an `any` value
}

expect(err).to.be.an.instanceOf(FirebaseError);
Expand Down Expand Up @@ -741,19 +742,25 @@
desc: "Root of Android project",
folderName: "android/",
folderItems: { app: {} },
output: "android/app",
output: path.join("android", "app"),
},
{
desc: "Inside app folder",
folderName: "android/app",
folderItems: { src: {} },
output: "android/app",
},
{
desc: "Inside app folder without a src directory",
folderName: "android/app",
folderItems: { libs: {}, "build.gradle": "" },
output: "android/app",
},
{
desc: "Folder with many modules",
folderName: "android/",
folderItems: { module1: {}, module2: {}, module3: {} },
output: "android/app",
output: path.join("android", "app"),
},
];
for (const c of cases) {
Expand Down Expand Up @@ -782,7 +789,7 @@
desc: "Root of ios project with xcodeproj files",
folderName: "ios/",
folderItems: { "abc.xcodeproj": "Contents", abc: {} },
output: "ios/abc",
output: path.join("ios", "abc"),
},
{
desc: "Folder with Info.plist",
Expand Down
3 changes: 1 addition & 2 deletions src/management/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -792,9 +792,8 @@ export async function findIntelligentPathForAndroid(appDir: string, options: App
* android/build.gradle // if it's this, choose app
* android/app/build.gradle // if it's this, choose current dir.
*/
const paths = appDir.split("/");
// For when app/build.gradle is found
if (paths[0] === "app") {
if (path.basename(appDir) === "app") {
return appDir;
} else {
const currentFiles: fs.Dirent[] = await fs.readdir(appDir, { withFileTypes: true });
Expand Down
Loading