🎉 initiate project *astro_rewrite*

This commit is contained in:
sindrekjelsrud 2023-07-19 21:31:30 +02:00
parent ffd4d5e86c
commit 2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions

27
node_modules/astro/dist/core/sync/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,27 @@
/// <reference types="node" />
import type fsMod from 'node:fs';
import type { Arguments } from 'yargs-parser';
import type { AstroSettings } from '../../@types/astro';
import { type LogOptions } from '../logger/core.js';
export type ProcessExit = 0 | 1;
export type SyncOptions = {
logging: LogOptions;
fs: typeof fsMod;
};
export declare function syncCli(settings: AstroSettings, { logging, fs, flags }: {
logging: LogOptions;
fs: typeof fsMod;
flags?: Arguments;
}): Promise<ProcessExit>;
/**
* Generate content collection types, and then returns the process exit signal.
*
* A non-zero process signal is emitted in case there's an error while generating content collection types.
*
* @param {SyncOptions} options
* @param {AstroSettings} settings Astro settings
* @param {typeof fsMod} options.fs The file system
* @param {LogOptions} options.logging Logging options
* @return {Promise<ProcessExit>}
*/
export declare function sync(settings: AstroSettings, { logging, fs }: SyncOptions): Promise<ProcessExit>;

95
node_modules/astro/dist/core/sync/index.js generated vendored Normal file
View file

@ -0,0 +1,95 @@
import { dim } from "kleur/colors";
import { performance } from "node:perf_hooks";
import { createServer } from "vite";
import { createContentTypesGenerator } from "../../content/index.js";
import { globalContentConfigObserver } from "../../content/utils.js";
import { runHookConfigSetup } from "../../integrations/index.js";
import { setUpEnvTs } from "../../vite-plugin-inject-env-ts/index.js";
import { getTimeStat } from "../build/util.js";
import { createVite } from "../create-vite.js";
import { AstroError, AstroErrorData, createSafeError, isAstroError } from "../errors/index.js";
import { info } from "../logger/core.js";
import { printHelp } from "../messages.js";
async function syncCli(settings, { logging, fs, flags }) {
if ((flags == null ? void 0 : flags.help) || (flags == null ? void 0 : flags.h)) {
printHelp({
commandName: "astro sync",
usage: "[...flags]",
tables: {
Flags: [["--help (-h)", "See all available flags."]]
},
description: `Generates TypeScript types for all Astro modules.`
});
return 0;
}
const resolvedSettings = await runHookConfigSetup({
settings,
logging,
command: "build"
});
return sync(resolvedSettings, { logging, fs });
}
async function sync(settings, { logging, fs }) {
const timerStart = performance.now();
const tempViteServer = await createServer(
await createVite(
{
server: { middlewareMode: true, hmr: false, watch: { ignored: ["**"] } },
optimizeDeps: { disabled: true },
ssr: { external: [] },
logLevel: "silent"
},
{ settings, logging, mode: "build", command: "build", fs }
)
);
const wsSend = tempViteServer.ws.send;
tempViteServer.ws.send = (payload) => {
if (payload.type === "error") {
throw payload.err;
}
return wsSend(payload);
};
try {
const contentTypesGenerator = await createContentTypesGenerator({
contentConfigObserver: globalContentConfigObserver,
logging,
fs,
settings,
viteServer: tempViteServer
});
const typesResult = await contentTypesGenerator.init();
const contentConfig = globalContentConfigObserver.get();
if (contentConfig.status === "error") {
throw contentConfig.error;
}
if (typesResult.typesGenerated === false) {
switch (typesResult.reason) {
case "no-content-dir":
default:
info(logging, "content", "No content directory found. Skipping type generation.");
return 0;
}
}
} catch (e) {
const safeError = createSafeError(e);
if (isAstroError(e)) {
throw e;
}
throw new AstroError(
{
...AstroErrorData.GenerateContentTypesError,
message: AstroErrorData.GenerateContentTypesError.message(safeError.message)
},
{ cause: e }
);
} finally {
await tempViteServer.close();
}
info(logging, "content", `Types generated ${dim(getTimeStat(timerStart, performance.now()))}`);
await setUpEnvTs({ settings, logging, fs });
return 0;
}
export {
sync,
syncCli
};