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] Astro relatives dirs #5709

Merged
merged 17 commits into from
Dec 7, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Addressed an issue preventing Astro applications from being deployed from Windows. (#5709)
- Fixed an issue preventing Angular apps using ng-deploy from being emulated or deployed. (#6584)
- Warn if a Web Framework is outside a well known version range on deploy/emulate. (#6562)
- Use Web Framework's well known version range in `firebase init hosting`. (#6562)
Expand Down
5 changes: 3 additions & 2 deletions src/frameworks/astro/utils.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import { dirname, join, relative } from "path";
import { findDependency } from "../utils";
import { gte } from "semver";
import { fileURLToPath } from "url";

const { dynamicImport } = require(true && "../../dynamicImport");

Check warning on line 6 in src/frameworks/astro/utils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value

Check warning on line 6 in src/frameworks/astro/utils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Require statement not part of import statement

export function getBootstrapScript() {

Check warning on line 8 in src/frameworks/astro/utils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing return type on function

Check warning on line 8 in src/frameworks/astro/utils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
// `astro build` with node adapter in middleware mode will generate a middleware at entry.mjs
// need to convert the export to `handle` to work with express integration
return `const entry = import('./entry.mjs');\nexport const handle = async (req, res) => (await entry).handler(req, res)`;
}

export async function getConfig(cwd: string) {

Check warning on line 14 in src/frameworks/astro/utils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing return type on function

Check warning on line 14 in src/frameworks/astro/utils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
const astroDirectory = dirname(require.resolve("astro/package.json", { paths: [cwd] }));
const version = getAstroVersion(cwd);

let config;
const configPath = join(astroDirectory, "dist", "core", "config", "config.js");
if (gte(version!, "2.9.7")) {

Check warning on line 20 in src/frameworks/astro/utils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Forbidden non-null assertion
const { resolveConfig } = await dynamicImport(configPath);

Check warning on line 21 in src/frameworks/astro/utils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value

Check warning on line 21 in src/frameworks/astro/utils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe call of an `any` typed value
const { astroConfig } = await resolveConfig({ root: cwd }, "build");

Check warning on line 22 in src/frameworks/astro/utils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
config = astroConfig;
} else {
const { openConfig }: typeof import("astro/dist/core/config/config") = await dynamicImport(
Expand All @@ -29,8 +30,8 @@
config = astroConfig;
}
return {
outDir: relative(cwd, config.outDir.pathname),
publicDir: relative(cwd, config.publicDir.pathname),
outDir: relative(cwd, fileURLToPath(config.outDir)),
publicDir: relative(cwd, fileURLToPath(config.publicDir)),
output: config.output,
adapter: config.adapter,
};
Expand Down