astro 1.4.6 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Code.astro +1 -1
- package/dist/@types/astro.d.ts +201 -29
- package/dist/cli/index.js +35 -36
- package/dist/config/index.js +2 -7
- package/dist/core/add/index.js +140 -23
- package/dist/core/build/index.js +3 -3
- package/dist/core/build/vite-plugin-css.js +6 -17
- package/dist/core/config/config.d.ts +1 -1
- package/dist/core/config/config.js +6 -2
- package/dist/core/config/index.d.ts +1 -1
- package/dist/core/config/index.js +2 -1
- package/dist/core/config/schema.d.ts +139 -1
- package/dist/core/config/schema.js +24 -2
- package/dist/core/config/settings.d.ts +1 -7
- package/dist/core/config/settings.js +7 -4
- package/dist/core/config/tsconfig.d.ts +10 -1
- package/dist/core/config/tsconfig.js +73 -7
- package/dist/core/constants.d.ts +1 -0
- package/dist/core/constants.js +4 -0
- package/dist/core/cookies/cookies.d.ts +1 -1
- package/dist/core/dev/index.js +7 -2
- package/dist/core/endpoint/dev/index.js +4 -1
- package/dist/core/endpoint/index.d.ts +1 -1
- package/dist/core/endpoint/index.js +44 -4
- package/dist/core/messages.js +2 -2
- package/dist/core/preview/index.d.ts +2 -11
- package/dist/core/preview/index.js +31 -125
- package/dist/core/preview/static-preview-server.d.ts +17 -0
- package/dist/core/preview/static-preview-server.js +127 -0
- package/dist/core/render/core.d.ts +1 -1
- package/dist/core/render/result.js +2 -2
- package/dist/core/util.d.ts +3 -14
- package/dist/core/util.js +4 -2
- package/dist/events/index.js +1 -1
- package/dist/integrations/index.d.ts +3 -2
- package/dist/integrations/index.js +39 -2
- package/dist/runtime/server/astro-global.js +1 -1
- package/dist/runtime/server/hydration.js +1 -1
- package/dist/runtime/server/render/page.js +1 -0
- package/dist/vite-plugin-jsx/index.js +9 -5
- package/dist/vite-plugin-jsx/tag.d.ts +3 -2
- package/dist/vite-plugin-jsx/tag.js +10 -4
- package/package.json +4 -2
package/dist/core/add/index.js
CHANGED
|
@@ -2,13 +2,18 @@ import boxen from "boxen";
|
|
|
2
2
|
import { diffWords } from "diff";
|
|
3
3
|
import { execa } from "execa";
|
|
4
4
|
import { existsSync, promises as fs } from "fs";
|
|
5
|
-
import { bold, cyan, dim, green, magenta, yellow } from "kleur/colors";
|
|
5
|
+
import { bold, cyan, dim, green, magenta, red, yellow } from "kleur/colors";
|
|
6
6
|
import ora from "ora";
|
|
7
7
|
import path from "path";
|
|
8
8
|
import preferredPM from "preferred-pm";
|
|
9
9
|
import prompts from "prompts";
|
|
10
10
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
11
|
-
import { resolveConfigPath } from "../config/index.js";
|
|
11
|
+
import { loadTSConfig, resolveConfigPath } from "../config/index.js";
|
|
12
|
+
import {
|
|
13
|
+
defaultTSConfig,
|
|
14
|
+
presets,
|
|
15
|
+
updateTSConfigForFramework
|
|
16
|
+
} from "../config/tsconfig.js";
|
|
12
17
|
import { debug, info } from "../logger/core.js";
|
|
13
18
|
import * as msg from "../messages.js";
|
|
14
19
|
import { printHelp } from "../messages.js";
|
|
@@ -212,7 +217,7 @@ async function add(names, { cwd, flags, logging, telemetry }) {
|
|
|
212
217
|
switch (configResult) {
|
|
213
218
|
case UpdateResult.cancelled: {
|
|
214
219
|
info(logging, null, msg.cancelled(`Your configuration has ${bold("NOT")} been updated.`));
|
|
215
|
-
|
|
220
|
+
break;
|
|
216
221
|
}
|
|
217
222
|
case UpdateResult.none: {
|
|
218
223
|
const pkgURL = new URL("./package.json", configURL);
|
|
@@ -224,11 +229,11 @@ async function add(names, { cwd, flags, logging, telemetry }) {
|
|
|
224
229
|
);
|
|
225
230
|
if (missingDeps.length === 0) {
|
|
226
231
|
info(logging, null, msg.success(`Configuration up-to-date.`));
|
|
227
|
-
|
|
232
|
+
break;
|
|
228
233
|
}
|
|
229
234
|
}
|
|
230
235
|
info(logging, null, msg.success(`Configuration up-to-date.`));
|
|
231
|
-
|
|
236
|
+
break;
|
|
232
237
|
}
|
|
233
238
|
default: {
|
|
234
239
|
const list = integrations.map((integration) => ` - ${integration.packageName}`).join("\n");
|
|
@@ -242,6 +247,27 @@ ${list}`
|
|
|
242
247
|
);
|
|
243
248
|
}
|
|
244
249
|
}
|
|
250
|
+
const updateTSConfigResult = await updateTSConfig(cwd, logging, integrations, flags);
|
|
251
|
+
switch (updateTSConfigResult) {
|
|
252
|
+
case UpdateResult.none: {
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
case UpdateResult.cancelled: {
|
|
256
|
+
info(
|
|
257
|
+
logging,
|
|
258
|
+
null,
|
|
259
|
+
msg.cancelled(`Your TypeScript configuration has ${bold("NOT")} been updated.`)
|
|
260
|
+
);
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
case UpdateResult.failure: {
|
|
264
|
+
throw new Error(
|
|
265
|
+
`Unknown error parsing tsconfig.json or jsconfig.json. Could not update TypeScript settings.`
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
default:
|
|
269
|
+
info(logging, null, msg.success(`Successfully updated TypeScript settings`));
|
|
270
|
+
}
|
|
245
271
|
}
|
|
246
272
|
function isAdapter(integration) {
|
|
247
273
|
return integration.type === "adapter";
|
|
@@ -392,27 +418,12 @@ ${defaultExport}`);
|
|
|
392
418
|
if (input === output) {
|
|
393
419
|
return 0 /* none */;
|
|
394
420
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
let lines = change.value.trim().split("\n").slice(0, change.count);
|
|
398
|
-
if (lines.length === 0)
|
|
399
|
-
continue;
|
|
400
|
-
if (change.added) {
|
|
401
|
-
if (!change.value.trim())
|
|
402
|
-
continue;
|
|
403
|
-
changes.push(change.value);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
if (changes.length === 0) {
|
|
421
|
+
const diff = getDiffContent(input, output);
|
|
422
|
+
if (!diff) {
|
|
407
423
|
return 0 /* none */;
|
|
408
424
|
}
|
|
409
|
-
let diffed = output;
|
|
410
|
-
for (let newContent of changes) {
|
|
411
|
-
const coloredOutput = newContent.split("\n").map((ln) => ln ? green(ln) : "").join("\n");
|
|
412
|
-
diffed = diffed.replace(newContent, coloredOutput);
|
|
413
|
-
}
|
|
414
425
|
const message = `
|
|
415
|
-
${boxen(
|
|
426
|
+
${boxen(diff, {
|
|
416
427
|
margin: 0.5,
|
|
417
428
|
padding: 0.5,
|
|
418
429
|
borderStyle: "round",
|
|
@@ -616,6 +627,90 @@ async function validateIntegrations(integrations) {
|
|
|
616
627
|
}
|
|
617
628
|
}
|
|
618
629
|
}
|
|
630
|
+
async function updateTSConfig(cwd = process.cwd(), logging, integrationsInfo, flags) {
|
|
631
|
+
var _a, _b;
|
|
632
|
+
const integrations = integrationsInfo.map(
|
|
633
|
+
(integration) => integration.id
|
|
634
|
+
);
|
|
635
|
+
const firstIntegrationWithTSSettings = integrations.find(
|
|
636
|
+
(integration) => presets.has(integration)
|
|
637
|
+
);
|
|
638
|
+
if (!firstIntegrationWithTSSettings) {
|
|
639
|
+
return 0 /* none */;
|
|
640
|
+
}
|
|
641
|
+
const inputConfig = loadTSConfig(cwd, false);
|
|
642
|
+
const configFileName = inputConfig.exists ? inputConfig.path.split("/").pop() : "tsconfig.json";
|
|
643
|
+
if (inputConfig.reason === "invalid-config") {
|
|
644
|
+
return 3 /* failure */;
|
|
645
|
+
}
|
|
646
|
+
if (inputConfig.reason === "not-found") {
|
|
647
|
+
debug("add", "Couldn't find tsconfig.json or jsconfig.json, generating one");
|
|
648
|
+
}
|
|
649
|
+
const outputConfig = updateTSConfigForFramework(
|
|
650
|
+
inputConfig.exists ? inputConfig.config : defaultTSConfig,
|
|
651
|
+
firstIntegrationWithTSSettings
|
|
652
|
+
);
|
|
653
|
+
const input = inputConfig.exists ? JSON.stringify(inputConfig.config, null, 2) : "";
|
|
654
|
+
const output = JSON.stringify(outputConfig, null, 2);
|
|
655
|
+
const diff = getDiffContent(input, output);
|
|
656
|
+
if (!diff) {
|
|
657
|
+
return 0 /* none */;
|
|
658
|
+
}
|
|
659
|
+
const message = `
|
|
660
|
+
${boxen(diff, {
|
|
661
|
+
margin: 0.5,
|
|
662
|
+
padding: 0.5,
|
|
663
|
+
borderStyle: "round",
|
|
664
|
+
title: configFileName
|
|
665
|
+
})}
|
|
666
|
+
`;
|
|
667
|
+
info(
|
|
668
|
+
logging,
|
|
669
|
+
null,
|
|
670
|
+
`
|
|
671
|
+
${magenta(`Astro will make the following changes to your ${configFileName}:`)}
|
|
672
|
+
${message}`
|
|
673
|
+
);
|
|
674
|
+
const conflictingIntegrations = [...Object.keys(presets).filter((config) => config !== "vue")];
|
|
675
|
+
const hasConflictingIntegrations = integrations.filter((integration) => presets.has(integration)).length > 1 && integrations.filter((integration) => conflictingIntegrations.includes(integration)).length > 0;
|
|
676
|
+
if (hasConflictingIntegrations) {
|
|
677
|
+
info(
|
|
678
|
+
logging,
|
|
679
|
+
null,
|
|
680
|
+
red(
|
|
681
|
+
` ${bold(
|
|
682
|
+
"Caution:"
|
|
683
|
+
)} Selected UI frameworks require conflicting tsconfig.json settings, as such only settings for ${bold(
|
|
684
|
+
firstIntegrationWithTSSettings
|
|
685
|
+
)} were used.
|
|
686
|
+
More information: https://docs.astro.build/en/guides/typescript/#errors-typing-multiple-jsx-frameworks-at-the-same-time
|
|
687
|
+
`
|
|
688
|
+
)
|
|
689
|
+
);
|
|
690
|
+
}
|
|
691
|
+
if (integrations.includes("vue") && hasConflictingIntegrations && (((_a = outputConfig.compilerOptions) == null ? void 0 : _a.jsx) !== "preserve" && ((_b = outputConfig.compilerOptions) == null ? void 0 : _b.jsxImportSource) !== void 0 || integrations.includes("react"))) {
|
|
692
|
+
info(
|
|
693
|
+
logging,
|
|
694
|
+
null,
|
|
695
|
+
red(
|
|
696
|
+
` ${bold(
|
|
697
|
+
"Caution:"
|
|
698
|
+
)} Using Vue together with a JSX framework can lead to type checking issues inside Vue files.
|
|
699
|
+
More information: https://docs.astro.build/en/guides/typescript/#vue-components-are-mistakenly-typed-by-the-typesreact-package-when-installed
|
|
700
|
+
`
|
|
701
|
+
)
|
|
702
|
+
);
|
|
703
|
+
}
|
|
704
|
+
if (await askToContinue({ flags })) {
|
|
705
|
+
await fs.writeFile((inputConfig == null ? void 0 : inputConfig.path) ?? path.join(cwd, "tsconfig.json"), output, {
|
|
706
|
+
encoding: "utf-8"
|
|
707
|
+
});
|
|
708
|
+
debug("add", `Updated ${configFileName} file`);
|
|
709
|
+
return 1 /* updated */;
|
|
710
|
+
} else {
|
|
711
|
+
return 2 /* cancelled */;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
619
714
|
function parseIntegrationName(spec) {
|
|
620
715
|
const result = parseNpmName(spec);
|
|
621
716
|
if (!result)
|
|
@@ -643,6 +738,28 @@ async function askToContinue({ flags }) {
|
|
|
643
738
|
});
|
|
644
739
|
return Boolean(response.askToContinue);
|
|
645
740
|
}
|
|
741
|
+
function getDiffContent(input, output) {
|
|
742
|
+
let changes = [];
|
|
743
|
+
for (const change of diffWords(input, output)) {
|
|
744
|
+
let lines = change.value.trim().split("\n").slice(0, change.count);
|
|
745
|
+
if (lines.length === 0)
|
|
746
|
+
continue;
|
|
747
|
+
if (change.added) {
|
|
748
|
+
if (!change.value.trim())
|
|
749
|
+
continue;
|
|
750
|
+
changes.push(change.value);
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
if (changes.length === 0) {
|
|
754
|
+
return null;
|
|
755
|
+
}
|
|
756
|
+
let diffed = output;
|
|
757
|
+
for (let newContent of changes) {
|
|
758
|
+
const coloredOutput = newContent.split("\n").map((ln) => ln ? green(ln) : "").join("\n");
|
|
759
|
+
diffed = diffed.replace(newContent, coloredOutput);
|
|
760
|
+
}
|
|
761
|
+
return diffed;
|
|
762
|
+
}
|
|
646
763
|
export {
|
|
647
764
|
add as default,
|
|
648
765
|
validateIntegrations
|
package/dist/core/build/index.js
CHANGED
|
@@ -59,9 +59,9 @@ class AstroBuilder {
|
|
|
59
59
|
}
|
|
60
60
|
async build({ viteConfig }) {
|
|
61
61
|
const buildConfig = {
|
|
62
|
-
client:
|
|
63
|
-
server:
|
|
64
|
-
serverEntry:
|
|
62
|
+
client: this.settings.config.build.client,
|
|
63
|
+
server: this.settings.config.build.server,
|
|
64
|
+
serverEntry: this.settings.config.build.serverEntry
|
|
65
65
|
};
|
|
66
66
|
await runHookBuildStart({ config: this.settings.config, buildConfig, logging: this.logging });
|
|
67
67
|
this.validateConfig();
|
|
@@ -2,7 +2,6 @@ import crypto from "crypto";
|
|
|
2
2
|
import esbuild from "esbuild";
|
|
3
3
|
import npath from "path";
|
|
4
4
|
import { isCSSRequest } from "../render/util.js";
|
|
5
|
-
import { relativeToSrcDir } from "../util.js";
|
|
6
5
|
import { getTopLevelPages, moduleIsTopLevelPage, walkParentInfos } from "./graph.js";
|
|
7
6
|
import {
|
|
8
7
|
eachPageData,
|
|
@@ -11,32 +10,22 @@ import {
|
|
|
11
10
|
getPageDatasByHoistedScriptId,
|
|
12
11
|
isHoistedScript
|
|
13
12
|
} from "./internal.js";
|
|
14
|
-
const MAX_NAME_LENGTH = 70;
|
|
15
13
|
function rollupPluginAstroBuildCSS(options) {
|
|
16
14
|
const { internals, buildOptions } = options;
|
|
17
15
|
const { settings } = buildOptions;
|
|
18
16
|
let resolvedConfig;
|
|
19
|
-
function nameifyPage(id) {
|
|
20
|
-
let rel = relativeToSrcDir(settings.config, id);
|
|
21
|
-
if (rel.startsWith("pages/")) {
|
|
22
|
-
rel = rel.slice(6);
|
|
23
|
-
}
|
|
24
|
-
const ext = npath.extname(rel);
|
|
25
|
-
const noext = rel.slice(0, rel.length - ext.length);
|
|
26
|
-
const named = noext.replace(/\//g, "-");
|
|
27
|
-
return named;
|
|
28
|
-
}
|
|
29
17
|
function createNameForParentPages(id, ctx) {
|
|
18
|
+
var _a;
|
|
30
19
|
const parents = Array.from(getTopLevelPages(id, ctx));
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
return proposedName;
|
|
34
|
-
}
|
|
20
|
+
const firstParentId = (_a = parents[0]) == null ? void 0 : _a[0].id;
|
|
21
|
+
const firstParentName = firstParentId ? npath.parse(firstParentId).name : "index";
|
|
35
22
|
const hash = crypto.createHash("sha256");
|
|
36
23
|
for (const [page] of parents) {
|
|
37
24
|
hash.update(page.id, "utf-8");
|
|
38
25
|
}
|
|
39
|
-
|
|
26
|
+
const h = hash.digest("hex").slice(0, 8);
|
|
27
|
+
const proposedName = firstParentName + "." + h;
|
|
28
|
+
return proposedName;
|
|
40
29
|
}
|
|
41
30
|
function* getParentClientOnlys(id, ctx) {
|
|
42
31
|
for (const [info] of walkParentInfos(id, ctx)) {
|
|
@@ -14,7 +14,7 @@ interface LoadConfigOptions {
|
|
|
14
14
|
validate?: boolean;
|
|
15
15
|
logging: LogOptions;
|
|
16
16
|
/** Invalidate when reloading a previously loaded config */
|
|
17
|
-
|
|
17
|
+
isRestart?: boolean;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Resolve the file URL of the user's `astro.config.js|cjs|mjs|ts` file
|
|
@@ -6,7 +6,7 @@ import path from "path";
|
|
|
6
6
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
7
7
|
import * as vite from "vite";
|
|
8
8
|
import { mergeConfig as mergeViteConfig } from "vite";
|
|
9
|
-
import { arraify, isObject } from "../util.js";
|
|
9
|
+
import { arraify, isObject, isURL } from "../util.js";
|
|
10
10
|
import { createRelativeSchema } from "./schema.js";
|
|
11
11
|
load.use([loadTypeScript]);
|
|
12
12
|
const LEGACY_ASTRO_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -150,7 +150,7 @@ async function tryLoadConfig(configOptions, flags, root) {
|
|
|
150
150
|
});
|
|
151
151
|
if (!configPath)
|
|
152
152
|
return void 0;
|
|
153
|
-
if (configOptions.
|
|
153
|
+
if (configOptions.isRestart) {
|
|
154
154
|
const tempConfigPath = path.join(
|
|
155
155
|
root,
|
|
156
156
|
`.temp.${Date.now()}.config${path.extname(configPath)}`
|
|
@@ -237,6 +237,10 @@ function mergeConfigRecursively(defaults, overrides, rootPath) {
|
|
|
237
237
|
merged[key] = [...arraify(existing ?? []), ...arraify(value ?? [])];
|
|
238
238
|
continue;
|
|
239
239
|
}
|
|
240
|
+
if (isURL(existing) && isURL(value)) {
|
|
241
|
+
merged[key] = value;
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
240
244
|
if (isObject(existing) && isObject(value)) {
|
|
241
245
|
merged[key] = mergeConfigRecursively(existing, value, rootPath ? `${rootPath}.${key}` : key);
|
|
242
246
|
continue;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { openConfig, resolveConfigPath, resolveFlags, resolveRoot, validateConfig, } from './config.js';
|
|
2
2
|
export type { AstroConfigSchema } from './schema';
|
|
3
3
|
export { createSettings } from './settings.js';
|
|
4
|
-
export { loadTSConfig } from './tsconfig.js';
|
|
4
|
+
export { loadTSConfig, updateTSConfigForFramework } from './tsconfig.js';
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
validateConfig
|
|
7
7
|
} from "./config.js";
|
|
8
8
|
import { createSettings } from "./settings.js";
|
|
9
|
-
import { loadTSConfig } from "./tsconfig.js";
|
|
9
|
+
import { loadTSConfig, updateTSConfigForFramework } from "./tsconfig.js";
|
|
10
10
|
export {
|
|
11
11
|
createSettings,
|
|
12
12
|
loadTSConfig,
|
|
@@ -14,5 +14,6 @@ export {
|
|
|
14
14
|
resolveConfigPath,
|
|
15
15
|
resolveFlags,
|
|
16
16
|
resolveRoot,
|
|
17
|
+
updateTSConfigForFramework,
|
|
17
18
|
validateConfig
|
|
18
19
|
};
|
|
@@ -36,10 +36,19 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
36
36
|
}[], unknown>;
|
|
37
37
|
build: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
38
38
|
format: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"file">, z.ZodLiteral<"directory">]>>>;
|
|
39
|
+
client: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
|
|
40
|
+
server: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
|
|
41
|
+
serverEntry: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
39
42
|
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
server: URL;
|
|
40
44
|
format: "file" | "directory";
|
|
45
|
+
client: URL;
|
|
46
|
+
serverEntry: string;
|
|
41
47
|
}, {
|
|
48
|
+
server?: string | undefined;
|
|
42
49
|
format?: "file" | "directory" | undefined;
|
|
50
|
+
client?: string | undefined;
|
|
51
|
+
serverEntry?: string | undefined;
|
|
43
52
|
}>>>;
|
|
44
53
|
server: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
45
54
|
host: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>>;
|
|
@@ -164,7 +173,10 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
164
173
|
hooks: {};
|
|
165
174
|
}[];
|
|
166
175
|
build: {
|
|
176
|
+
server: URL;
|
|
167
177
|
format: "file" | "directory";
|
|
178
|
+
client: URL;
|
|
179
|
+
serverEntry: string;
|
|
168
180
|
};
|
|
169
181
|
style: {
|
|
170
182
|
postcss: {
|
|
@@ -205,7 +217,10 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
205
217
|
} | undefined;
|
|
206
218
|
integrations?: unknown;
|
|
207
219
|
build?: {
|
|
220
|
+
server?: string | undefined;
|
|
208
221
|
format?: "file" | "directory" | undefined;
|
|
222
|
+
client?: string | undefined;
|
|
223
|
+
serverEntry?: string | undefined;
|
|
209
224
|
} | undefined;
|
|
210
225
|
style?: {
|
|
211
226
|
postcss?: {
|
|
@@ -218,7 +233,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
218
233
|
astroFlavoredMarkdown?: boolean | undefined;
|
|
219
234
|
} | undefined;
|
|
220
235
|
}>;
|
|
221
|
-
export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL): z.ZodObject<z.extendShape<{
|
|
236
|
+
export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL): z.ZodEffects<z.ZodObject<z.extendShape<{
|
|
222
237
|
root: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
|
|
223
238
|
srcDir: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
|
|
224
239
|
publicDir: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
|
|
@@ -252,10 +267,19 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
252
267
|
}[], unknown>;
|
|
253
268
|
build: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
254
269
|
format: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"file">, z.ZodLiteral<"directory">]>>>;
|
|
270
|
+
client: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
|
|
271
|
+
server: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
|
|
272
|
+
serverEntry: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
255
273
|
}, "strip", z.ZodTypeAny, {
|
|
274
|
+
server: URL;
|
|
256
275
|
format: "file" | "directory";
|
|
276
|
+
client: URL;
|
|
277
|
+
serverEntry: string;
|
|
257
278
|
}, {
|
|
279
|
+
server?: string | undefined;
|
|
258
280
|
format?: "file" | "directory" | undefined;
|
|
281
|
+
client?: string | undefined;
|
|
282
|
+
serverEntry?: string | undefined;
|
|
259
283
|
}>>>;
|
|
260
284
|
server: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
261
285
|
host: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>>;
|
|
@@ -350,6 +374,22 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
350
374
|
srcDir: z.ZodEffects<z.ZodDefault<z.ZodString>, URL, string | undefined>;
|
|
351
375
|
publicDir: z.ZodEffects<z.ZodDefault<z.ZodString>, URL, string | undefined>;
|
|
352
376
|
outDir: z.ZodEffects<z.ZodDefault<z.ZodString>, URL, string | undefined>;
|
|
377
|
+
build: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
378
|
+
format: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"file">, z.ZodLiteral<"directory">]>>>;
|
|
379
|
+
client: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
|
|
380
|
+
server: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
|
|
381
|
+
serverEntry: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
382
|
+
}, "strip", z.ZodTypeAny, {
|
|
383
|
+
server: URL;
|
|
384
|
+
format: "file" | "directory";
|
|
385
|
+
client: URL;
|
|
386
|
+
serverEntry: string;
|
|
387
|
+
}, {
|
|
388
|
+
server?: string | undefined;
|
|
389
|
+
format?: "file" | "directory" | undefined;
|
|
390
|
+
client?: string | undefined;
|
|
391
|
+
serverEntry?: string | undefined;
|
|
392
|
+
}>>>;
|
|
353
393
|
server: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
354
394
|
host: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>>;
|
|
355
395
|
port: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
@@ -425,7 +465,102 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
425
465
|
hooks: {};
|
|
426
466
|
}[];
|
|
427
467
|
build: {
|
|
468
|
+
server: URL;
|
|
469
|
+
format: "file" | "directory";
|
|
470
|
+
client: URL;
|
|
471
|
+
serverEntry: string;
|
|
472
|
+
};
|
|
473
|
+
style: {
|
|
474
|
+
postcss: {
|
|
475
|
+
options?: any;
|
|
476
|
+
plugins: any[];
|
|
477
|
+
};
|
|
478
|
+
};
|
|
479
|
+
vite: ViteUserConfig;
|
|
480
|
+
legacy: {
|
|
481
|
+
astroFlavoredMarkdown: boolean;
|
|
482
|
+
};
|
|
483
|
+
}, {
|
|
484
|
+
site?: string | undefined;
|
|
485
|
+
base?: string | undefined;
|
|
486
|
+
markdown?: {
|
|
487
|
+
drafts?: boolean | undefined;
|
|
488
|
+
syntaxHighlight?: false | "shiki" | "prism" | undefined;
|
|
489
|
+
shikiConfig?: {
|
|
490
|
+
langs?: ILanguageRegistration[] | undefined;
|
|
491
|
+
theme?: string | import("shiki").IShikiTheme | undefined;
|
|
492
|
+
wrap?: boolean | null | undefined;
|
|
493
|
+
} | undefined;
|
|
494
|
+
remarkPlugins?: (string | [string, any] | RemarkPlugin<any[]> | [RemarkPlugin<any[]>, any])[] | undefined;
|
|
495
|
+
rehypePlugins?: (string | [string, any] | RehypePlugin<any[]> | [RehypePlugin<any[]>, any])[] | undefined;
|
|
496
|
+
remarkRehype?: RemarkRehype | undefined;
|
|
497
|
+
extendDefaultPlugins?: boolean | undefined;
|
|
498
|
+
} | undefined;
|
|
499
|
+
root?: string | undefined;
|
|
500
|
+
srcDir?: string | undefined;
|
|
501
|
+
publicDir?: string | undefined;
|
|
502
|
+
outDir?: string | undefined;
|
|
503
|
+
trailingSlash?: "never" | "always" | "ignore" | undefined;
|
|
504
|
+
server?: unknown;
|
|
505
|
+
output?: "static" | "server" | undefined;
|
|
506
|
+
adapter?: {
|
|
507
|
+
hooks?: {} | undefined;
|
|
508
|
+
name: string;
|
|
509
|
+
} | undefined;
|
|
510
|
+
integrations?: unknown;
|
|
511
|
+
build?: {
|
|
512
|
+
server?: string | undefined;
|
|
513
|
+
format?: "file" | "directory" | undefined;
|
|
514
|
+
client?: string | undefined;
|
|
515
|
+
serverEntry?: string | undefined;
|
|
516
|
+
} | undefined;
|
|
517
|
+
style?: {
|
|
518
|
+
postcss?: unknown;
|
|
519
|
+
} | undefined;
|
|
520
|
+
vite?: ViteUserConfig | undefined;
|
|
521
|
+
legacy?: {
|
|
522
|
+
astroFlavoredMarkdown?: boolean | undefined;
|
|
523
|
+
} | undefined;
|
|
524
|
+
}>, {
|
|
525
|
+
site?: string | undefined;
|
|
526
|
+
adapter?: {
|
|
527
|
+
name: string;
|
|
528
|
+
hooks: {};
|
|
529
|
+
} | undefined;
|
|
530
|
+
base: string;
|
|
531
|
+
markdown: {
|
|
532
|
+
drafts: boolean;
|
|
533
|
+
syntaxHighlight: false | "shiki" | "prism";
|
|
534
|
+
shikiConfig: {
|
|
535
|
+
langs: ILanguageRegistration[];
|
|
536
|
+
theme: string | import("shiki").IShikiTheme;
|
|
537
|
+
wrap: boolean | null;
|
|
538
|
+
};
|
|
539
|
+
remarkPlugins: (string | [string, any] | RemarkPlugin<any[]> | [RemarkPlugin<any[]>, any])[];
|
|
540
|
+
rehypePlugins: (string | [string, any] | RehypePlugin<any[]> | [RehypePlugin<any[]>, any])[];
|
|
541
|
+
remarkRehype: RemarkRehype;
|
|
542
|
+
extendDefaultPlugins: boolean;
|
|
543
|
+
};
|
|
544
|
+
root: URL;
|
|
545
|
+
srcDir: URL;
|
|
546
|
+
publicDir: URL;
|
|
547
|
+
outDir: URL;
|
|
548
|
+
trailingSlash: "never" | "always" | "ignore";
|
|
549
|
+
server: {
|
|
550
|
+
host: string | boolean;
|
|
551
|
+
port: number;
|
|
552
|
+
streaming: boolean;
|
|
553
|
+
};
|
|
554
|
+
output: "static" | "server";
|
|
555
|
+
integrations: {
|
|
556
|
+
name: string;
|
|
557
|
+
hooks: {};
|
|
558
|
+
}[];
|
|
559
|
+
build: {
|
|
560
|
+
server: URL;
|
|
428
561
|
format: "file" | "directory";
|
|
562
|
+
client: URL;
|
|
563
|
+
serverEntry: string;
|
|
429
564
|
};
|
|
430
565
|
style: {
|
|
431
566
|
postcss: {
|
|
@@ -466,7 +601,10 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
|
|
|
466
601
|
} | undefined;
|
|
467
602
|
integrations?: unknown;
|
|
468
603
|
build?: {
|
|
604
|
+
server?: string | undefined;
|
|
469
605
|
format?: "file" | "directory" | undefined;
|
|
606
|
+
client?: string | undefined;
|
|
607
|
+
serverEntry?: string | undefined;
|
|
470
608
|
} | undefined;
|
|
471
609
|
style?: {
|
|
472
610
|
postcss?: unknown;
|
|
@@ -11,7 +11,12 @@ const ASTRO_CONFIG_DEFAULTS = {
|
|
|
11
11
|
outDir: "./dist",
|
|
12
12
|
base: "/",
|
|
13
13
|
trailingSlash: "ignore",
|
|
14
|
-
build: {
|
|
14
|
+
build: {
|
|
15
|
+
format: "directory",
|
|
16
|
+
client: "./dist/client/",
|
|
17
|
+
server: "./dist/server/",
|
|
18
|
+
serverEntry: "entry.mjs"
|
|
19
|
+
},
|
|
15
20
|
server: {
|
|
16
21
|
host: false,
|
|
17
22
|
port: 3e3,
|
|
@@ -51,7 +56,10 @@ const AstroConfigSchema = z.object({
|
|
|
51
56
|
z.array(z.object({ name: z.string(), hooks: z.object({}).passthrough().default({}) })).default(ASTRO_CONFIG_DEFAULTS.integrations)
|
|
52
57
|
),
|
|
53
58
|
build: z.object({
|
|
54
|
-
format: z.union([z.literal("file"), z.literal("directory")]).optional().default(ASTRO_CONFIG_DEFAULTS.build.format)
|
|
59
|
+
format: z.union([z.literal("file"), z.literal("directory")]).optional().default(ASTRO_CONFIG_DEFAULTS.build.format),
|
|
60
|
+
client: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.client).transform((val) => new URL(val)),
|
|
61
|
+
server: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.server).transform((val) => new URL(val)),
|
|
62
|
+
serverEntry: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.serverEntry)
|
|
55
63
|
}).optional().default({}),
|
|
56
64
|
server: z.preprocess(
|
|
57
65
|
(val) => typeof val === "function" ? val({ command: "error" }) : val,
|
|
@@ -122,6 +130,12 @@ function createRelativeSchema(cmd, fileProtocolRoot) {
|
|
|
122
130
|
srcDir: z.string().default(ASTRO_CONFIG_DEFAULTS.srcDir).transform((val) => new URL(appendForwardSlash(val), fileProtocolRoot)),
|
|
123
131
|
publicDir: z.string().default(ASTRO_CONFIG_DEFAULTS.publicDir).transform((val) => new URL(appendForwardSlash(val), fileProtocolRoot)),
|
|
124
132
|
outDir: z.string().default(ASTRO_CONFIG_DEFAULTS.outDir).transform((val) => new URL(appendForwardSlash(val), fileProtocolRoot)),
|
|
133
|
+
build: z.object({
|
|
134
|
+
format: z.union([z.literal("file"), z.literal("directory")]).optional().default(ASTRO_CONFIG_DEFAULTS.build.format),
|
|
135
|
+
client: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.client).transform((val) => new URL(val, fileProtocolRoot)),
|
|
136
|
+
server: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.server).transform((val) => new URL(val, fileProtocolRoot)),
|
|
137
|
+
serverEntry: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.serverEntry)
|
|
138
|
+
}).optional().default({}),
|
|
125
139
|
server: z.preprocess(
|
|
126
140
|
(val) => typeof val === "function" ? val({ command: cmd === "dev" ? "dev" : "preview" }) : val,
|
|
127
141
|
z.object({
|
|
@@ -139,6 +153,14 @@ function createRelativeSchema(cmd, fileProtocolRoot) {
|
|
|
139
153
|
}).optional().default(ASTRO_CONFIG_DEFAULTS.style.postcss)
|
|
140
154
|
)
|
|
141
155
|
}).optional().default({})
|
|
156
|
+
}).transform((config) => {
|
|
157
|
+
if (!config.build.server.toString().startsWith(config.outDir.toString()) && config.build.server.toString().endsWith("dist/server/")) {
|
|
158
|
+
config.build.server = new URL("./dist/server/", config.outDir);
|
|
159
|
+
}
|
|
160
|
+
if (!config.build.client.toString().startsWith(config.outDir.toString()) && config.build.client.toString().endsWith("dist/client/")) {
|
|
161
|
+
config.build.client = new URL("./dist/client/", config.outDir);
|
|
162
|
+
}
|
|
163
|
+
return config;
|
|
142
164
|
});
|
|
143
165
|
return AstroConfigRelativeSchema;
|
|
144
166
|
}
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import type { TsConfigJson } from 'tsconfig-resolver';
|
|
2
1
|
import type { AstroConfig, AstroSettings } from '../../@types/astro';
|
|
3
|
-
export
|
|
4
|
-
config: AstroConfig;
|
|
5
|
-
tsConfig?: TsConfigJson;
|
|
6
|
-
tsConfigPath?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function createSettings({ config, tsConfig, tsConfigPath }: CreateSettings): AstroSettings;
|
|
2
|
+
export declare function createSettings(config: AstroConfig, cwd?: string): AstroSettings;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import jsxRenderer from "../../jsx/renderer.js";
|
|
2
|
-
|
|
2
|
+
import { loadTSConfig } from "./tsconfig.js";
|
|
3
|
+
function createSettings(config, cwd) {
|
|
4
|
+
const tsconfig = loadTSConfig(cwd);
|
|
3
5
|
return {
|
|
4
6
|
config,
|
|
5
|
-
tsConfig,
|
|
6
|
-
tsConfigPath,
|
|
7
|
+
tsConfig: tsconfig == null ? void 0 : tsconfig.config,
|
|
8
|
+
tsConfigPath: tsconfig == null ? void 0 : tsconfig.path,
|
|
7
9
|
adapter: void 0,
|
|
8
10
|
injectedRoutes: [],
|
|
9
11
|
pageExtensions: [".astro", ".md", ".html"],
|
|
10
12
|
renderers: [jsxRenderer],
|
|
11
|
-
scripts: []
|
|
13
|
+
scripts: [],
|
|
14
|
+
watchFiles: (tsconfig == null ? void 0 : tsconfig.exists) ? [tsconfig.path, ...tsconfig.extendedPaths] : []
|
|
12
15
|
};
|
|
13
16
|
}
|
|
14
17
|
export {
|
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
import * as tsr from 'tsconfig-resolver';
|
|
2
|
-
export declare
|
|
2
|
+
export declare const defaultTSConfig: tsr.TsConfigJson;
|
|
3
|
+
export declare type frameworkWithTSSettings = 'vue' | 'react' | 'preact' | 'solid-js';
|
|
4
|
+
export declare const presets: Map<frameworkWithTSSettings, tsr.TsConfigJson>;
|
|
5
|
+
/**
|
|
6
|
+
* Load a tsconfig.json or jsconfig.json is the former is not found
|
|
7
|
+
* @param cwd Directory to start from
|
|
8
|
+
* @param resolve Determine if the function should go up directories like TypeScript would
|
|
9
|
+
*/
|
|
10
|
+
export declare function loadTSConfig(cwd: string | undefined, resolve?: boolean): tsr.TsConfigResult;
|
|
11
|
+
export declare function updateTSConfigForFramework(target: tsr.TsConfigJson, framework: frameworkWithTSSettings): tsr.TsConfigJson;
|