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
Changes from 1 commit
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
6 changes: 4 additions & 2 deletions src/frameworks/astro/utils.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import { dirname, join, relative } from "path";

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

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

View workflow job for this annotation

GitHub Actions / lint (16)

Unsafe assignment of an `any` value

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

View workflow job for this annotation

GitHub Actions / lint (16)

Require statement not part of import statement

export function getBootstrapScript() {

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

View workflow job for this annotation

GitHub Actions / lint (16)

Missing return type on function

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

View workflow job for this annotation

GitHub Actions / lint (16)

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 11 in src/frameworks/astro/utils.ts

View workflow job for this annotation

GitHub Actions / lint (16)

Missing return type on function

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

View workflow job for this annotation

GitHub Actions / lint (16)

Missing JSDoc comment
const astroDirectory = dirname(require.resolve("astro/package.json", { paths: [cwd] }));
const { openConfig }: typeof import("astro/dist/core/config/config") = await dynamicImport(

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

View workflow job for this annotation

GitHub Actions / lint (16)

Unsafe assignment of an `any` value

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

View workflow job for this annotation

GitHub Actions / lint (16)

Unsafe call of an `any` typed value
join(astroDirectory, "dist", "core", "config", "config.js")
);
const logging: any = undefined; // TODO figure out the types here

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

View workflow job for this annotation

GitHub Actions / lint (16)

Unexpected any. Specify a different type
const { astroConfig: config } = await openConfig({ cmd: "build", cwd, logging });

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

View workflow job for this annotation

GitHub Actions / lint (16)

Unsafe assignment of an `any` value
const outDirPath = config.outDir.pathname[0] === '/' ? config.outDir.pathname.substring(1) : config.outDir.pathname

Check failure on line 18 in src/frameworks/astro/utils.ts

View workflow job for this annotation

GitHub Actions / unit (18)

Replace `·config.outDir.pathname[0]·===·'/'·?·config.outDir.pathname.substring(1)·:·config.outDir.pathname` with `⏎····config.outDir.pathname[0]·===·"/"⏎······?·config.outDir.pathname.substring(1)⏎······:·config.outDir.pathname;`

Check failure on line 18 in src/frameworks/astro/utils.ts

View workflow job for this annotation

GitHub Actions / lint (16)

Replace `·config.outDir.pathname[0]·===·'/'·?·config.outDir.pathname.substring(1)·:·config.outDir.pathname` with `⏎····config.outDir.pathname[0]·===·"/"⏎······?·config.outDir.pathname.substring(1)⏎······:·config.outDir.pathname;`
const PublicDirPath = config.publicDir.pathname[0] === '/' ? config.publicDir.pathname.substring(1) : config.publicDir.pathname

Check failure on line 19 in src/frameworks/astro/utils.ts

View workflow job for this annotation

GitHub Actions / unit (18)

Replace `·config.publicDir.pathname[0]·===·'/'·?·config.publicDir.pathname.substring(1)·:·config.publicDir.pathname` with `⏎····config.publicDir.pathname[0]·===·"/"⏎······?·config.publicDir.pathname.substring(1)⏎······:·config.publicDir.pathname;`

Check failure on line 19 in src/frameworks/astro/utils.ts

View workflow job for this annotation

GitHub Actions / lint (16)

Replace `·config.publicDir.pathname[0]·===·'/'·?·config.publicDir.pathname.substring(1)·:·config.publicDir.pathname` with `⏎····config.publicDir.pathname[0]·===·"/"⏎······?·config.publicDir.pathname.substring(1)⏎······:·config.publicDir.pathname;`
return {
outDir: relative(cwd, config.outDir.pathname),
publicDir: relative(cwd, config.publicDir.pathname),
outDir: relative(cwd, outDirPath),
publicDir: relative(cwd, PublicDirPath),
output: config.output,
adapter: config.adapter,
};
Expand Down