Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Angular SSR deployment on Windows #6544

Merged
Merged
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
10 changes: 7 additions & 3 deletions src/frameworks/angular/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import { AngularI18nConfig } from "./interfaces";
import { relativeRequire, validateLocales } from "../utils";
import { FirebaseError } from "../../error";
import { join } from "path";
import { join, posix, sep } from "path";
import { BUILD_TARGET_PURPOSE } from "../interfaces";
import { AssertionError } from "assert";
import { assertIsString } from "../../utils";

async function localesForTarget(

Check warning on line 13 in src/frameworks/angular/utils.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Missing return type on function
dir: string,
architectHost: WorkspaceNodeModulesArchitectHost,
target: Target,
Expand All @@ -26,7 +26,7 @@
let locales: string[] | undefined = undefined;
let defaultLocale: string | undefined = undefined;
if (targetOptions.localize) {
const i18n: AngularI18nConfig | undefined = workspaceProject.extensions?.i18n as any;

Check warning on line 29 in src/frameworks/angular/utils.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unsafe assignment of an `any` value

Check warning on line 29 in src/frameworks/angular/utils.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unexpected any. Specify a different type
if (!i18n) throw new FirebaseError(`No i18n config on project.`);
if (typeof i18n.sourceLocale === "string") {
throw new FirebaseError(`All your i18n locales must have a baseHref of "" on Firebase, use an object for sourceLocale in your angular.json:
Expand All @@ -48,7 +48,7 @@
for (const [locale, { baseHref }] of Object.entries(i18n.locales)) {
if (baseHref !== "")
throw new FirebaseError(
`All your i18n locales must have a baseHref of \"\" on Firebase, errored on ${locale}.`

Check warning on line 51 in src/frameworks/angular/utils.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unnecessary escape character: \"

Check warning on line 51 in src/frameworks/angular/utils.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unnecessary escape character: \"
);
locales.push(locale);
}
Expand Down Expand Up @@ -91,7 +91,7 @@
];
}

export async function getAllTargets(purpose: BUILD_TARGET_PURPOSE, dir: string) {

Check warning on line 94 in src/frameworks/angular/utils.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Missing return type on function

Check warning on line 94 in src/frameworks/angular/utils.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Missing JSDoc comment
const validBuilders = getValidBuilders(purpose);
const { NodeJsAsyncHost } = relativeRequire(dir, "@angular-devkit/core/node");
const { workspaces } = relativeRequire(dir, "@angular-devkit/core");
Expand All @@ -117,7 +117,7 @@
}

// TODO(jamesdaniels) memoize, dry up
export async function getContext(dir: string, targetOrConfiguration?: string) {

Check warning on line 120 in src/frameworks/angular/utils.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Missing return type on function

Check warning on line 120 in src/frameworks/angular/utils.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Missing JSDoc comment
const { NodeJsAsyncHost } = relativeRequire(dir, "@angular-devkit/core/node");
const { workspaces } = relativeRequire(dir, "@angular-devkit/core");
const { WorkspaceNodeModulesArchitectHost } = relativeRequire(
Expand Down Expand Up @@ -157,7 +157,7 @@
}

if (!project) {
const angularJson = parse(await host.readFile(join(dir, "angular.json")));

Check warning on line 160 in src/frameworks/angular/utils.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unsafe assignment of an `any` value
project = angularJson.defaultProject;
}

Expand Down Expand Up @@ -420,7 +420,9 @@
}
const browserTargetOptions = await architectHost.getOptionsForTarget(buildOrBrowserTarget);
assertIsString(browserTargetOptions?.outputPath);
const browserOutputPath = join(browserTargetOptions.outputPath, buildTarget ? "browser" : "");
const browserOutputPath = join(browserTargetOptions.outputPath, buildTarget ? "browser" : "")
.split(sep)
.join(posix.sep);
const packageJson = JSON.parse(await host.readFile(join(sourceDir, "package.json")));

if (!ssr) {
Expand Down Expand Up @@ -449,7 +451,9 @@
);
const serverTargetOptions = await architectHost.getOptionsForTarget(buildOrServerTarget);
assertIsString(serverTargetOptions?.outputPath);
const serverOutputPath = join(serverTargetOptions.outputPath, buildTarget ? "server" : "");
const serverOutputPath = join(serverTargetOptions.outputPath, buildTarget ? "server" : "")
.split(sep)
.join(posix.sep);
if (serverLocales && !defaultLocale) {
throw new FirebaseError(
"It's required that your source locale to be one of the localize options"
Expand Down
Loading