astro 4.10.2 → 4.10.3
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/dist/@types/astro.d.ts +43 -39
- package/dist/container/index.d.ts +32 -1
- package/dist/container/index.js +45 -0
- package/dist/container/vite-plugin-container.d.ts +2 -0
- package/dist/container/vite-plugin-container.js +15 -0
- package/dist/content/types-generator.js +28 -28
- package/dist/content/utils.d.ts +11 -0
- package/dist/content/utils.js +49 -0
- package/dist/content/vite-plugin-content-imports.d.ts +3 -1
- package/dist/content/vite-plugin-content-imports.js +15 -4
- package/dist/core/base-pipeline.js +1 -1
- package/dist/core/build/internal.d.ts +4 -0
- package/dist/core/build/internal.js +2 -1
- package/dist/core/build/page-data.js +2 -4
- package/dist/core/build/plugins/plugin-chunks.js +6 -0
- package/dist/core/build/plugins/plugin-prerender.js +55 -48
- package/dist/core/build/plugins/plugin-ssr.js +15 -12
- package/dist/core/build/static-build.js +36 -44
- package/dist/core/build/types.d.ts +0 -1
- package/dist/core/config/schema.d.ts +4 -156
- package/dist/core/constants.d.ts +4 -0
- package/dist/core/constants.js +3 -1
- package/dist/core/create-vite.js +4 -2
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/errors-data.d.ts +20 -0
- package/dist/core/errors/errors-data.js +6 -0
- package/dist/core/messages.js +2 -2
- package/dist/core/render-context.js +3 -0
- package/dist/core/routing/astro-designed-error-pages.d.ts +1 -0
- package/dist/core/routing/astro-designed-error-pages.js +15 -1
- package/dist/core/util.js +5 -2
- package/dist/env/constants.d.ts +0 -1
- package/dist/env/constants.js +0 -2
- package/dist/env/runtime.d.ts +3 -1
- package/dist/env/runtime.js +8 -1
- package/dist/env/schema.d.ts +2 -78
- package/dist/env/schema.js +1 -17
- package/dist/env/vite-plugin-env.js +15 -15
- package/dist/jsx/server.d.ts +3 -5
- package/dist/jsx/server.js +3 -1
- package/dist/vite-plugin-astro/index.js +1 -1
- package/dist/vite-plugin-astro-server/route.js +18 -1
- package/package.json +8 -8
- package/templates/env/module.mjs +14 -5
- package/templates/env/types.d.ts +1 -12
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ManifestData, RouteData } from '../../@types/astro.js';
|
|
2
2
|
export declare const DEFAULT_404_ROUTE: RouteData;
|
|
3
|
+
export declare const DEFAULT_500_ROUTE: RouteData;
|
|
3
4
|
export declare function ensure404Route(manifest: ManifestData): ManifestData;
|
|
4
5
|
export declare function default404Page({ pathname }: {
|
|
5
6
|
pathname: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import notFoundTemplate from "../../template/4xx.js";
|
|
2
|
-
import { DEFAULT_404_COMPONENT } from "../constants.js";
|
|
2
|
+
import { DEFAULT_404_COMPONENT, DEFAULT_500_COMPONENT } from "../constants.js";
|
|
3
3
|
const DEFAULT_404_ROUTE = {
|
|
4
4
|
component: DEFAULT_404_COMPONENT,
|
|
5
5
|
generate: () => "",
|
|
@@ -13,6 +13,19 @@ const DEFAULT_404_ROUTE = {
|
|
|
13
13
|
fallbackRoutes: [],
|
|
14
14
|
isIndex: false
|
|
15
15
|
};
|
|
16
|
+
const DEFAULT_500_ROUTE = {
|
|
17
|
+
component: DEFAULT_500_COMPONENT,
|
|
18
|
+
generate: () => "",
|
|
19
|
+
params: [],
|
|
20
|
+
pattern: /\/500/,
|
|
21
|
+
prerender: false,
|
|
22
|
+
pathname: "/500",
|
|
23
|
+
segments: [[{ content: "500", dynamic: false, spread: false }]],
|
|
24
|
+
type: "page",
|
|
25
|
+
route: "/500",
|
|
26
|
+
fallbackRoutes: [],
|
|
27
|
+
isIndex: false
|
|
28
|
+
};
|
|
16
29
|
function ensure404Route(manifest) {
|
|
17
30
|
if (!manifest.routes.some((route) => route.route === "/404")) {
|
|
18
31
|
manifest.routes.push(DEFAULT_404_ROUTE);
|
|
@@ -33,6 +46,7 @@ async function default404Page({ pathname }) {
|
|
|
33
46
|
default404Page.isAstroComponentFactory = true;
|
|
34
47
|
export {
|
|
35
48
|
DEFAULT_404_ROUTE,
|
|
49
|
+
DEFAULT_500_ROUTE,
|
|
36
50
|
default404Page,
|
|
37
51
|
ensure404Route
|
|
38
52
|
};
|
package/dist/core/util.js
CHANGED
|
@@ -78,8 +78,11 @@ function isInjectedRoute(file, settings) {
|
|
|
78
78
|
return false;
|
|
79
79
|
}
|
|
80
80
|
function isPublicRoute(file, config) {
|
|
81
|
-
const
|
|
82
|
-
const
|
|
81
|
+
const rootDir = config.root.toString();
|
|
82
|
+
const pagesDir = resolvePages(config).toString();
|
|
83
|
+
const fileDir = file.toString();
|
|
84
|
+
const normalizedDir = fileDir.startsWith(pagesDir) ? fileDir.slice(pagesDir.length) : fileDir.slice(rootDir.length);
|
|
85
|
+
const parts = normalizedDir.replace(pagesDir.toString(), "").split("/").slice(1);
|
|
83
86
|
for (const part of parts) {
|
|
84
87
|
if (part.startsWith("_")) return false;
|
|
85
88
|
}
|
package/dist/env/constants.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ export declare const VIRTUAL_MODULES_IDS: {
|
|
|
4
4
|
internal: string;
|
|
5
5
|
};
|
|
6
6
|
export declare const VIRTUAL_MODULES_IDS_VALUES: Set<string>;
|
|
7
|
-
export declare const PUBLIC_PREFIX = "PUBLIC_";
|
|
8
7
|
export declare const ENV_TYPES_FILE = "env.d.ts";
|
|
9
8
|
export declare const MODULE_TEMPLATE_URL: URL;
|
|
10
9
|
export declare const TYPES_TEMPLATE_URL: URL;
|
package/dist/env/constants.js
CHANGED
|
@@ -4,7 +4,6 @@ const VIRTUAL_MODULES_IDS = {
|
|
|
4
4
|
internal: "virtual:astro:env/internal"
|
|
5
5
|
};
|
|
6
6
|
const VIRTUAL_MODULES_IDS_VALUES = new Set(Object.values(VIRTUAL_MODULES_IDS));
|
|
7
|
-
const PUBLIC_PREFIX = "PUBLIC_";
|
|
8
7
|
const ENV_TYPES_FILE = "env.d.ts";
|
|
9
8
|
const PKG_BASE = new URL("../../", import.meta.url);
|
|
10
9
|
const MODULE_TEMPLATE_URL = new URL("templates/env/module.mjs", PKG_BASE);
|
|
@@ -12,7 +11,6 @@ const TYPES_TEMPLATE_URL = new URL("templates/env/types.d.ts", PKG_BASE);
|
|
|
12
11
|
export {
|
|
13
12
|
ENV_TYPES_FILE,
|
|
14
13
|
MODULE_TEMPLATE_URL,
|
|
15
|
-
PUBLIC_PREFIX,
|
|
16
14
|
TYPES_TEMPLATE_URL,
|
|
17
15
|
VIRTUAL_MODULES_IDS,
|
|
18
16
|
VIRTUAL_MODULES_IDS_VALUES
|
package/dist/env/runtime.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { AstroError, AstroErrorData } from '../core/errors/index.js';
|
|
2
2
|
export { validateEnvVariable } from './validators.js';
|
|
3
3
|
export type GetEnv = (key: string) => string | undefined;
|
|
4
|
-
export declare function setGetEnv(fn: GetEnv): void;
|
|
4
|
+
export declare function setGetEnv(fn: GetEnv, reset?: boolean): void;
|
|
5
|
+
declare let _onSetGetEnv: (reset: boolean) => void;
|
|
6
|
+
export declare function setOnSetGetEnv(fn: typeof _onSetGetEnv): void;
|
|
5
7
|
export declare function getEnv(...args: Parameters<GetEnv>): string | undefined;
|
|
6
8
|
export declare function createInvalidVariableError(...args: Parameters<typeof AstroErrorData.EnvInvalidVariable.message>): AstroError;
|
package/dist/env/runtime.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
2
2
|
import { validateEnvVariable } from "./validators.js";
|
|
3
3
|
let _getEnv = (key) => process.env[key];
|
|
4
|
-
function setGetEnv(fn) {
|
|
4
|
+
function setGetEnv(fn, reset = false) {
|
|
5
5
|
_getEnv = fn;
|
|
6
|
+
_onSetGetEnv(reset);
|
|
7
|
+
}
|
|
8
|
+
let _onSetGetEnv = (reset) => {
|
|
9
|
+
};
|
|
10
|
+
function setOnSetGetEnv(fn) {
|
|
11
|
+
_onSetGetEnv = fn;
|
|
6
12
|
}
|
|
7
13
|
function getEnv(...args) {
|
|
8
14
|
return _getEnv(...args);
|
|
@@ -17,5 +23,6 @@ export {
|
|
|
17
23
|
createInvalidVariableError,
|
|
18
24
|
getEnv,
|
|
19
25
|
setGetEnv,
|
|
26
|
+
setOnSetGetEnv,
|
|
20
27
|
validateEnvVariable
|
|
21
28
|
};
|
package/dist/env/schema.d.ts
CHANGED
|
@@ -220,7 +220,7 @@ declare const EnvFieldMetadata: z.ZodUnion<[z.ZodObject<{
|
|
|
220
220
|
context: "server";
|
|
221
221
|
access: "secret";
|
|
222
222
|
}>]>;
|
|
223
|
-
export declare const EnvSchema: z.
|
|
223
|
+
export declare const EnvSchema: z.ZodRecord<z.ZodString, z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
|
|
224
224
|
context: z.ZodLiteral<"client">;
|
|
225
225
|
access: z.ZodLiteral<"public">;
|
|
226
226
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -344,83 +344,7 @@ export declare const EnvSchema: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodInter
|
|
|
344
344
|
values: string[];
|
|
345
345
|
default?: string | undefined;
|
|
346
346
|
optional?: boolean | undefined;
|
|
347
|
-
}>]
|
|
348
|
-
context: "client";
|
|
349
|
-
access: "public";
|
|
350
|
-
} | {
|
|
351
|
-
context: "server";
|
|
352
|
-
access: "public";
|
|
353
|
-
} | {
|
|
354
|
-
context: "server";
|
|
355
|
-
access: "secret";
|
|
356
|
-
}) & ({
|
|
357
|
-
type: "string";
|
|
358
|
-
length?: number | undefined;
|
|
359
|
-
includes?: string | undefined;
|
|
360
|
-
endsWith?: string | undefined;
|
|
361
|
-
startsWith?: string | undefined;
|
|
362
|
-
default?: string | undefined;
|
|
363
|
-
url?: boolean | undefined;
|
|
364
|
-
optional?: boolean | undefined;
|
|
365
|
-
min?: number | undefined;
|
|
366
|
-
max?: number | undefined;
|
|
367
|
-
} | {
|
|
368
|
-
type: "number";
|
|
369
|
-
default?: number | undefined;
|
|
370
|
-
optional?: boolean | undefined;
|
|
371
|
-
min?: number | undefined;
|
|
372
|
-
max?: number | undefined;
|
|
373
|
-
gt?: number | undefined;
|
|
374
|
-
lt?: number | undefined;
|
|
375
|
-
int?: boolean | undefined;
|
|
376
|
-
} | {
|
|
377
|
-
type: "boolean";
|
|
378
|
-
default?: boolean | undefined;
|
|
379
|
-
optional?: boolean | undefined;
|
|
380
|
-
} | {
|
|
381
|
-
type: "enum";
|
|
382
|
-
values: string[];
|
|
383
|
-
default?: string | undefined;
|
|
384
|
-
optional?: boolean | undefined;
|
|
385
|
-
})>, Record<string, ({
|
|
386
|
-
context: "client";
|
|
387
|
-
access: "public";
|
|
388
|
-
} | {
|
|
389
|
-
context: "server";
|
|
390
|
-
access: "public";
|
|
391
|
-
} | {
|
|
392
|
-
context: "server";
|
|
393
|
-
access: "secret";
|
|
394
|
-
}) & ({
|
|
395
|
-
type: "string";
|
|
396
|
-
length?: number | undefined;
|
|
397
|
-
includes?: string | undefined;
|
|
398
|
-
endsWith?: string | undefined;
|
|
399
|
-
startsWith?: string | undefined;
|
|
400
|
-
default?: string | undefined;
|
|
401
|
-
url?: boolean | undefined;
|
|
402
|
-
optional?: boolean | undefined;
|
|
403
|
-
min?: number | undefined;
|
|
404
|
-
max?: number | undefined;
|
|
405
|
-
} | {
|
|
406
|
-
type: "number";
|
|
407
|
-
default?: number | undefined;
|
|
408
|
-
optional?: boolean | undefined;
|
|
409
|
-
min?: number | undefined;
|
|
410
|
-
max?: number | undefined;
|
|
411
|
-
gt?: number | undefined;
|
|
412
|
-
lt?: number | undefined;
|
|
413
|
-
int?: boolean | undefined;
|
|
414
|
-
} | {
|
|
415
|
-
type: "boolean";
|
|
416
|
-
default?: boolean | undefined;
|
|
417
|
-
optional?: boolean | undefined;
|
|
418
|
-
} | {
|
|
419
|
-
type: "enum";
|
|
420
|
-
values: string[];
|
|
421
|
-
default?: string | undefined;
|
|
422
|
-
optional?: boolean | undefined;
|
|
423
|
-
})>>;
|
|
347
|
+
}>]>>>;
|
|
424
348
|
type Prettify<T> = {
|
|
425
349
|
[K in keyof T]: T[K];
|
|
426
350
|
} & {};
|
package/dist/env/schema.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { PUBLIC_PREFIX } from "./constants.js";
|
|
3
2
|
const StringSchema = z.object({
|
|
4
3
|
type: z.literal("string"),
|
|
5
4
|
optional: z.boolean().optional(),
|
|
@@ -76,22 +75,7 @@ const EnvSchema = z.record(
|
|
|
76
75
|
message: "A valid variable name can only contain uppercase letters and underscores."
|
|
77
76
|
}),
|
|
78
77
|
z.intersection(EnvFieldMetadata, EnvFieldType)
|
|
79
|
-
)
|
|
80
|
-
for (const [key, value] of Object.entries(schema)) {
|
|
81
|
-
if (key.startsWith(PUBLIC_PREFIX) && value.access !== "public") {
|
|
82
|
-
ctx.addIssue({
|
|
83
|
-
code: z.ZodIssueCode.custom,
|
|
84
|
-
message: `An environment variable whose name is prefixed by "${PUBLIC_PREFIX}" must be public.`
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
if (value.access === "public" && !key.startsWith(PUBLIC_PREFIX)) {
|
|
88
|
-
ctx.addIssue({
|
|
89
|
-
code: z.ZodIssueCode.custom,
|
|
90
|
-
message: `An environment variable that is public must have a name prefixed by "${PUBLIC_PREFIX}".`
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
});
|
|
78
|
+
);
|
|
95
79
|
export {
|
|
96
80
|
EnvSchema
|
|
97
81
|
};
|
|
@@ -46,9 +46,8 @@ function astroEnv({
|
|
|
46
46
|
fs,
|
|
47
47
|
content: getDts({
|
|
48
48
|
fs,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
serverSecret: serverTemplates.types.secret
|
|
49
|
+
client: clientTemplates.types,
|
|
50
|
+
server: serverTemplates.types
|
|
52
51
|
})
|
|
53
52
|
});
|
|
54
53
|
},
|
|
@@ -119,13 +118,12 @@ function validatePublicVariables({
|
|
|
119
118
|
return valid;
|
|
120
119
|
}
|
|
121
120
|
function getDts({
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
serverSecret,
|
|
121
|
+
client,
|
|
122
|
+
server,
|
|
125
123
|
fs
|
|
126
124
|
}) {
|
|
127
125
|
const template = fs.readFileSync(TYPES_TEMPLATE_URL, "utf-8");
|
|
128
|
-
return template.replace("// @@CLIENT@@",
|
|
126
|
+
return template.replace("// @@CLIENT@@", client).replace("// @@SERVER@@", server);
|
|
129
127
|
}
|
|
130
128
|
function getClientTemplates({
|
|
131
129
|
validatedVariables
|
|
@@ -148,26 +146,28 @@ function getServerTemplates({
|
|
|
148
146
|
fs
|
|
149
147
|
}) {
|
|
150
148
|
let module = fs.readFileSync(MODULE_TEMPLATE_URL, "utf-8");
|
|
151
|
-
let
|
|
152
|
-
let
|
|
149
|
+
let types = "";
|
|
150
|
+
let onSetGetEnv = "";
|
|
153
151
|
for (const { key, type, value } of validatedVariables.filter((e) => e.context === "server")) {
|
|
154
152
|
module += `export const ${key} = ${JSON.stringify(value)};`;
|
|
155
|
-
|
|
153
|
+
types += `export const ${key}: ${type};
|
|
156
154
|
`;
|
|
157
155
|
}
|
|
158
156
|
for (const [key, options] of Object.entries(schema)) {
|
|
159
157
|
if (!(options.context === "server" && options.access === "secret")) {
|
|
160
158
|
continue;
|
|
161
159
|
}
|
|
162
|
-
|
|
160
|
+
types += `export const ${key}: ${getEnvFieldType(options)};
|
|
161
|
+
`;
|
|
162
|
+
module += `export let ${key} = _internalGetSecret(${JSON.stringify(key)});
|
|
163
|
+
`;
|
|
164
|
+
onSetGetEnv += `${key} = reset ? undefined : _internalGetSecret(${JSON.stringify(key)});
|
|
163
165
|
`;
|
|
164
166
|
}
|
|
167
|
+
module = module.replace("// @@ON_SET_GET_ENV@@", onSetGetEnv);
|
|
165
168
|
return {
|
|
166
169
|
module,
|
|
167
|
-
types
|
|
168
|
-
public: publicTypes,
|
|
169
|
-
secret: secretTypes
|
|
170
|
-
}
|
|
170
|
+
types
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
173
|
export {
|
package/dist/jsx/server.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NamedSSRLoadedRendererValue } from '../@types/astro.js';
|
|
1
2
|
export declare function check(Component: any, props: any, { default: children, ...slotted }?: {
|
|
2
3
|
default?: null | undefined;
|
|
3
4
|
}): Promise<any>;
|
|
@@ -6,8 +7,5 @@ export declare function renderToStaticMarkup(this: any, Component: any, props?:
|
|
|
6
7
|
}): Promise<{
|
|
7
8
|
html: any;
|
|
8
9
|
}>;
|
|
9
|
-
declare const
|
|
10
|
-
|
|
11
|
-
renderToStaticMarkup: typeof renderToStaticMarkup;
|
|
12
|
-
};
|
|
13
|
-
export default _default;
|
|
10
|
+
declare const renderer: NamedSSRLoadedRendererValue;
|
|
11
|
+
export default renderer;
|
package/dist/jsx/server.js
CHANGED
|
@@ -44,10 +44,12 @@ function throwEnhancedErrorIfMdxComponent(error, Component) {
|
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
const renderer = {
|
|
48
|
+
name: "astro:jsx",
|
|
48
49
|
check,
|
|
49
50
|
renderToStaticMarkup
|
|
50
51
|
};
|
|
52
|
+
var server_default = renderer;
|
|
51
53
|
export {
|
|
52
54
|
check,
|
|
53
55
|
server_default as default,
|
|
@@ -148,7 +148,7 @@ File: ${id}`
|
|
|
148
148
|
},
|
|
149
149
|
async transform(source, id) {
|
|
150
150
|
const parsedId = parseAstroRequest(id);
|
|
151
|
-
if (!
|
|
151
|
+
if (!parsedId.filename.endsWith(".astro") || parsedId.query.astro) {
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
154
154
|
const filename = normalizePath(parsedId.filename);
|
|
@@ -21,6 +21,10 @@ function getCustom404Route(manifestData) {
|
|
|
21
21
|
const route404 = /^\/404\/?$/;
|
|
22
22
|
return manifestData.routes.find((r) => route404.test(r.route));
|
|
23
23
|
}
|
|
24
|
+
function getCustom500Route(manifestData) {
|
|
25
|
+
const route500 = /^\/500\/?$/;
|
|
26
|
+
return manifestData.routes.find((r) => route500.test(r.route));
|
|
27
|
+
}
|
|
24
28
|
async function matchRoute(pathname, manifestData, pipeline) {
|
|
25
29
|
const { config, logger, routeCache, serverLike, settings } = pipeline;
|
|
26
30
|
const matches = matchAllRoutes(pathname, manifestData);
|
|
@@ -207,7 +211,20 @@ async function handleRoute({
|
|
|
207
211
|
routeData: route
|
|
208
212
|
});
|
|
209
213
|
}
|
|
210
|
-
let response
|
|
214
|
+
let response;
|
|
215
|
+
try {
|
|
216
|
+
response = await renderContext.render(mod);
|
|
217
|
+
} catch (err) {
|
|
218
|
+
const custom500 = getCustom500Route(manifestData);
|
|
219
|
+
if (!custom500) {
|
|
220
|
+
throw err;
|
|
221
|
+
}
|
|
222
|
+
logger.error("router", err.stack || err.message);
|
|
223
|
+
const filePath = new URL(`./${custom500.component}`, config.root);
|
|
224
|
+
const preloadedComponent = await pipeline.preload(custom500, filePath);
|
|
225
|
+
response = await renderContext.render(preloadedComponent);
|
|
226
|
+
status = 500;
|
|
227
|
+
}
|
|
211
228
|
if (isLoggedRequest(pathname)) {
|
|
212
229
|
const timeEnd = performance.now();
|
|
213
230
|
logger.info(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "4.10.
|
|
3
|
+
"version": "4.10.3",
|
|
4
4
|
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "withastro",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"@babel/types": "^7.24.7",
|
|
119
119
|
"@types/babel__core": "^7.20.5",
|
|
120
120
|
"@types/cookie": "^0.6.0",
|
|
121
|
-
"acorn": "^8.
|
|
121
|
+
"acorn": "^8.12.0",
|
|
122
122
|
"aria-query": "^5.3.0",
|
|
123
123
|
"axobject-query": "^4.0.0",
|
|
124
124
|
"boxen": "^7.1.1",
|
|
@@ -157,21 +157,21 @@
|
|
|
157
157
|
"rehype": "^13.0.1",
|
|
158
158
|
"resolve": "^1.22.8",
|
|
159
159
|
"semver": "^7.6.2",
|
|
160
|
-
"shiki": "^1.6.
|
|
160
|
+
"shiki": "^1.6.5",
|
|
161
161
|
"string-width": "^7.1.0",
|
|
162
162
|
"strip-ansi": "^7.1.0",
|
|
163
163
|
"tsconfck": "^3.1.0",
|
|
164
164
|
"unist-util-visit": "^5.0.0",
|
|
165
165
|
"vfile": "^6.0.1",
|
|
166
|
-
"vite": "^5.
|
|
166
|
+
"vite": "^5.3.1",
|
|
167
167
|
"vitefu": "^0.2.5",
|
|
168
168
|
"which-pm": "^2.2.0",
|
|
169
169
|
"yargs-parser": "^21.1.1",
|
|
170
170
|
"zod": "^3.23.8",
|
|
171
171
|
"zod-to-json-schema": "^3.23.0",
|
|
172
172
|
"@astrojs/internal-helpers": "0.4.0",
|
|
173
|
-
"@astrojs/
|
|
174
|
-
"@astrojs/
|
|
173
|
+
"@astrojs/telemetry": "3.1.0",
|
|
174
|
+
"@astrojs/markdown-remark": "5.1.0"
|
|
175
175
|
},
|
|
176
176
|
"optionalDependencies": {
|
|
177
177
|
"sharp": "^0.33.3"
|
|
@@ -204,7 +204,7 @@
|
|
|
204
204
|
"eol": "^0.9.1",
|
|
205
205
|
"mdast-util-mdx": "^3.0.0",
|
|
206
206
|
"mdast-util-mdx-jsx": "^3.1.2",
|
|
207
|
-
"memfs": "^4.9.
|
|
207
|
+
"memfs": "^4.9.3",
|
|
208
208
|
"node-mocks-http": "^1.14.1",
|
|
209
209
|
"parse-srcset": "^1.0.2",
|
|
210
210
|
"rehype-autolink-headings": "^7.1.0",
|
|
@@ -212,7 +212,7 @@
|
|
|
212
212
|
"rehype-toc": "^3.0.2",
|
|
213
213
|
"remark-code-titles": "^0.1.2",
|
|
214
214
|
"rollup": "^4.18.0",
|
|
215
|
-
"sass": "^1.77.
|
|
215
|
+
"sass": "^1.77.5",
|
|
216
216
|
"srcset-parse": "^1.1.0",
|
|
217
217
|
"unified": "^11.0.4",
|
|
218
218
|
"astro-scripts": "0.0.14"
|
package/templates/env/module.mjs
CHANGED
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
import { schema } from 'virtual:astro:env/internal';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createInvalidVariableError,
|
|
4
|
+
getEnv,
|
|
5
|
+
setOnSetGetEnv,
|
|
6
|
+
validateEnvVariable,
|
|
7
|
+
} from 'astro/env/runtime';
|
|
3
8
|
|
|
4
9
|
export const getSecret = (key) => {
|
|
10
|
+
return getEnv(key);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const _internalGetSecret = (key) => {
|
|
5
14
|
const rawVariable = getEnv(key);
|
|
6
15
|
const variable = rawVariable === '' ? undefined : rawVariable;
|
|
7
16
|
const options = schema[key];
|
|
8
17
|
|
|
9
|
-
if (!options) {
|
|
10
|
-
return variable;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
18
|
const result = validateEnvVariable(variable, options);
|
|
14
19
|
if (result.ok) {
|
|
15
20
|
return result.value;
|
|
16
21
|
}
|
|
17
22
|
throw createInvalidVariableError(key, result.type);
|
|
18
23
|
};
|
|
24
|
+
|
|
25
|
+
setOnSetGetEnv((reset) => {
|
|
26
|
+
// @@ON_SET_GET_ENV@@
|
|
27
|
+
});
|
package/templates/env/types.d.ts
CHANGED
|
@@ -5,16 +5,5 @@ declare module 'astro:env/client' {
|
|
|
5
5
|
declare module 'astro:env/server' {
|
|
6
6
|
// @@SERVER@@
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
// @@SECRET_VALUES@@
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
type SecretValue = keyof SecretValues;
|
|
13
|
-
|
|
14
|
-
type Loose<T> = T | (string & {});
|
|
15
|
-
type Strictify<T extends string> = T extends `${infer _}` ? T : never;
|
|
16
|
-
|
|
17
|
-
export const getSecret: <TKey extends Loose<SecretValue>>(
|
|
18
|
-
key: TKey
|
|
19
|
-
) => TKey extends Strictify<SecretValue> ? SecretValues[TKey] : string | undefined;
|
|
8
|
+
export const getSecret: (key: string) => string | undefined;
|
|
20
9
|
}
|