astro 4.15.2 → 4.15.4
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/assets/build/generate.js +8 -5
- package/dist/cli/add/index.d.ts +1 -1
- package/dist/cli/add/index.js +3 -3
- package/dist/cli/create-key/index.d.ts +6 -0
- package/dist/cli/create-key/index.js +27 -0
- package/dist/cli/index.js +7 -0
- package/dist/content/content-layer.d.ts +6 -0
- package/dist/content/content-layer.js +6 -1
- package/dist/content/data-store.js +3 -0
- package/dist/content/vite-plugin-content-virtual-mod.js +19 -13
- package/dist/core/build/index.js +6 -4
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +3 -4
- package/dist/core/encryption.d.ts +12 -0
- package/dist/core/encryption.js +19 -0
- package/dist/core/logger/core.d.ts +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/sync/index.d.ts +3 -3
- package/dist/core/sync/index.js +15 -7
- package/package.json +2 -4
|
@@ -48,9 +48,9 @@ function getFullImagePath(originalFilePath, env) {
|
|
|
48
48
|
return new URL(removeLeadingForwardSlash(originalFilePath), env.serverRoot);
|
|
49
49
|
}
|
|
50
50
|
async function generateImagesForPath(originalFilePath, transformsAndPath, env, queue) {
|
|
51
|
-
|
|
51
|
+
let originalImage;
|
|
52
52
|
for (const [_, transform] of transformsAndPath.transforms) {
|
|
53
|
-
await queue.add(async () => generateImage(
|
|
53
|
+
await queue.add(async () => generateImage(transform.finalPath, transform.transform)).catch((e) => {
|
|
54
54
|
throw e;
|
|
55
55
|
});
|
|
56
56
|
}
|
|
@@ -66,9 +66,9 @@ async function generateImagesForPath(originalFilePath, transformsAndPath, env, q
|
|
|
66
66
|
} catch {
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
async function generateImage(
|
|
69
|
+
async function generateImage(filepath, options) {
|
|
70
70
|
const timeStart = performance.now();
|
|
71
|
-
const generationData = await generateImageInternal(
|
|
71
|
+
const generationData = await generateImageInternal(filepath, options);
|
|
72
72
|
const timeEnd = performance.now();
|
|
73
73
|
const timeChange = getTimeStat(timeStart, timeEnd);
|
|
74
74
|
const timeIncrease = `(+${timeChange})`;
|
|
@@ -80,7 +80,7 @@ async function generateImagesForPath(originalFilePath, transformsAndPath, env, q
|
|
|
80
80
|
);
|
|
81
81
|
env.count.current++;
|
|
82
82
|
}
|
|
83
|
-
async function generateImageInternal(
|
|
83
|
+
async function generateImageInternal(filepath, options) {
|
|
84
84
|
const isLocalImage = isESMImportedImage(options.src);
|
|
85
85
|
const finalFileURL = new URL("." + filepath, env.clientRoot);
|
|
86
86
|
const cacheFile = basename(filepath) + (isLocalImage ? "" : ".json");
|
|
@@ -116,6 +116,9 @@ async function generateImagesForPath(originalFilePath, transformsAndPath, env, q
|
|
|
116
116
|
const finalFolderURL = new URL("./", finalFileURL);
|
|
117
117
|
await fs.promises.mkdir(finalFolderURL, { recursive: true });
|
|
118
118
|
const originalImagePath = isLocalImage ? options.src.src : options.src;
|
|
119
|
+
if (!originalImage) {
|
|
120
|
+
originalImage = await loadImage(originalFilePath, env);
|
|
121
|
+
}
|
|
119
122
|
let resultData = {
|
|
120
123
|
data: void 0,
|
|
121
124
|
expires: originalImage.expires
|
package/dist/cli/add/index.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ interface IntegrationInfo {
|
|
|
10
10
|
type: 'integration' | 'adapter';
|
|
11
11
|
}
|
|
12
12
|
export declare function add(names: string[], { flags }: AddOptions): Promise<void>;
|
|
13
|
-
export declare function setAdapter(mod: ProxifiedModule<any>, adapter: IntegrationInfo): void;
|
|
13
|
+
export declare function setAdapter(mod: ProxifiedModule<any>, adapter: IntegrationInfo, exportName: string): void;
|
|
14
14
|
export {};
|
package/dist/cli/add/index.js
CHANGED
|
@@ -247,7 +247,7 @@ async function add(names, { flags }) {
|
|
|
247
247
|
if (isAdapter(integration)) {
|
|
248
248
|
const officialExportName = OFFICIAL_ADAPTER_TO_IMPORT_MAP[integration.id];
|
|
249
249
|
if (officialExportName) {
|
|
250
|
-
setAdapter(mod, integration);
|
|
250
|
+
setAdapter(mod, integration, officialExportName);
|
|
251
251
|
} else {
|
|
252
252
|
logger.info(
|
|
253
253
|
"SKIP_FORMAT",
|
|
@@ -371,14 +371,14 @@ function addIntegration(mod, integration) {
|
|
|
371
371
|
config.integrations.push(builders.functionCall(integrationId));
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
|
-
function setAdapter(mod, adapter) {
|
|
374
|
+
function setAdapter(mod, adapter, exportName) {
|
|
375
375
|
const config = getDefaultExportOptions(mod);
|
|
376
376
|
const adapterId = toIdent(adapter.id);
|
|
377
377
|
if (!mod.imports.$items.some((imp) => imp.local === adapterId)) {
|
|
378
378
|
mod.imports.$append({
|
|
379
379
|
imported: "default",
|
|
380
380
|
local: adapterId,
|
|
381
|
-
from:
|
|
381
|
+
from: exportName
|
|
382
382
|
});
|
|
383
383
|
}
|
|
384
384
|
if (!config.output) {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createNodeLogger } from "../../core/config/logging.js";
|
|
2
|
+
import { createKey as createCryptoKey, encodeKey } from "../../core/encryption.js";
|
|
3
|
+
import { flagsToAstroInlineConfig } from "../flags.js";
|
|
4
|
+
async function createKey({ flags }) {
|
|
5
|
+
try {
|
|
6
|
+
const inlineConfig = flagsToAstroInlineConfig(flags);
|
|
7
|
+
const logger = createNodeLogger(inlineConfig);
|
|
8
|
+
const keyPromise = createCryptoKey();
|
|
9
|
+
const key = await keyPromise;
|
|
10
|
+
const encoded = await encodeKey(key);
|
|
11
|
+
logger.info(
|
|
12
|
+
"crypto",
|
|
13
|
+
`Generated a key to encrypt props passed to Server islands. To reuse the same key across builds, set this value as ASTRO_KEY in an environment variable on your build server.
|
|
14
|
+
|
|
15
|
+
ASTRO_KEY=${encoded}`
|
|
16
|
+
);
|
|
17
|
+
} catch (err) {
|
|
18
|
+
if (err != null) {
|
|
19
|
+
console.error(err.toString());
|
|
20
|
+
}
|
|
21
|
+
return 1;
|
|
22
|
+
}
|
|
23
|
+
return 0;
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
createKey
|
|
27
|
+
};
|
package/dist/cli/index.js
CHANGED
|
@@ -12,6 +12,7 @@ async function printAstroHelp() {
|
|
|
12
12
|
["add", "Add an integration."],
|
|
13
13
|
["build", "Build your project and write it to disk."],
|
|
14
14
|
["check", "Check your project for errors."],
|
|
15
|
+
["create-key", "Create a cryptography key"],
|
|
15
16
|
["db", "Manage your Astro database."],
|
|
16
17
|
["dev", "Start the development server."],
|
|
17
18
|
["docs", "Open documentation in your web browser."],
|
|
@@ -55,6 +56,7 @@ function resolveCommand(flags) {
|
|
|
55
56
|
"build",
|
|
56
57
|
"preview",
|
|
57
58
|
"check",
|
|
59
|
+
"create-key",
|
|
58
60
|
"docs",
|
|
59
61
|
"db",
|
|
60
62
|
"info",
|
|
@@ -81,6 +83,11 @@ async function runCommand(cmd, flags) {
|
|
|
81
83
|
await printInfo({ flags });
|
|
82
84
|
return;
|
|
83
85
|
}
|
|
86
|
+
case "create-key": {
|
|
87
|
+
const { createKey } = await import("./create-key/index.js");
|
|
88
|
+
const exitCode = await createKey({ flags });
|
|
89
|
+
return process.exit(exitCode);
|
|
90
|
+
}
|
|
84
91
|
case "docs": {
|
|
85
92
|
const { docs } = await import("./docs/index.js");
|
|
86
93
|
await docs({ flags });
|
|
@@ -33,6 +33,12 @@ export declare class ContentLayer {
|
|
|
33
33
|
export declare function simpleLoader<TData extends {
|
|
34
34
|
id: string;
|
|
35
35
|
}>(handler: () => Array<TData> | Promise<Array<TData>>, context: LoaderContext): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Get the path to the data store file.
|
|
38
|
+
* During development, this is in the `.astro` directory so that the Vite watcher can see it.
|
|
39
|
+
* In production, it's in the cache directory so that it's preserved between builds.
|
|
40
|
+
*/
|
|
41
|
+
export declare function getDataStoreFile(settings: AstroSettings, isDev?: boolean): URL;
|
|
36
42
|
export declare const globalContentLayer: {
|
|
37
43
|
init: (options: ContentLayerOptions) => ContentLayer;
|
|
38
44
|
get: () => ContentLayer | null;
|
|
@@ -170,7 +170,7 @@ class ContentLayer {
|
|
|
170
170
|
if (!existsSync(this.#settings.config.cacheDir)) {
|
|
171
171
|
await fs.mkdir(this.#settings.config.cacheDir, { recursive: true });
|
|
172
172
|
}
|
|
173
|
-
const cacheFile =
|
|
173
|
+
const cacheFile = getDataStoreFile(this.#settings);
|
|
174
174
|
await this.#store.writeToDisk(cacheFile);
|
|
175
175
|
if (!existsSync(this.#settings.dotAstroDir)) {
|
|
176
176
|
await fs.mkdir(this.#settings.dotAstroDir, { recursive: true });
|
|
@@ -224,6 +224,10 @@ async function simpleLoader(handler, context) {
|
|
|
224
224
|
context.store.set({ id: raw.id, data: item });
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
|
+
function getDataStoreFile(settings, isDev) {
|
|
228
|
+
isDev ??= process?.env.NODE_ENV === "development";
|
|
229
|
+
return new URL(DATA_STORE_FILE, isDev ? settings.dotAstroDir : settings.config.cacheDir);
|
|
230
|
+
}
|
|
227
231
|
function contentLayerSingleton() {
|
|
228
232
|
let instance = null;
|
|
229
233
|
return {
|
|
@@ -242,6 +246,7 @@ function contentLayerSingleton() {
|
|
|
242
246
|
const globalContentLayer = contentLayerSingleton();
|
|
243
247
|
export {
|
|
244
248
|
ContentLayer,
|
|
249
|
+
getDataStoreFile,
|
|
245
250
|
globalContentLayer,
|
|
246
251
|
simpleLoader
|
|
247
252
|
};
|
|
@@ -39,6 +39,9 @@ class DataStore {
|
|
|
39
39
|
static async fromModule() {
|
|
40
40
|
try {
|
|
41
41
|
const data = await import("astro:data-layer-content");
|
|
42
|
+
if (data.default instanceof Map) {
|
|
43
|
+
return DataStore.fromMap(data.default);
|
|
44
|
+
}
|
|
42
45
|
const map = devalue.unflatten(data.default);
|
|
43
46
|
return DataStore.fromMap(map);
|
|
44
47
|
} catch {
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
CONTENT_FLAG,
|
|
18
18
|
CONTENT_RENDER_FLAG,
|
|
19
19
|
DATA_FLAG,
|
|
20
|
-
DATA_STORE_FILE,
|
|
21
20
|
DATA_STORE_VIRTUAL_ID,
|
|
22
21
|
MODULES_IMPORTS_FILE,
|
|
23
22
|
MODULES_MJS_ID,
|
|
@@ -26,6 +25,7 @@ import {
|
|
|
26
25
|
RESOLVED_VIRTUAL_MODULE_ID,
|
|
27
26
|
VIRTUAL_MODULE_ID
|
|
28
27
|
} from "./consts.js";
|
|
28
|
+
import { getDataStoreFile } from "./content-layer.js";
|
|
29
29
|
import {
|
|
30
30
|
getContentEntryIdAndSlug,
|
|
31
31
|
getContentPaths,
|
|
@@ -44,12 +44,13 @@ function astroContentVirtualModPlugin({
|
|
|
44
44
|
}) {
|
|
45
45
|
let IS_DEV = false;
|
|
46
46
|
const IS_SERVER = isServerLikeOutput(settings.config);
|
|
47
|
-
|
|
47
|
+
let dataStoreFile;
|
|
48
48
|
return {
|
|
49
49
|
name: "astro-content-virtual-mod-plugin",
|
|
50
50
|
enforce: "pre",
|
|
51
51
|
configResolved(config) {
|
|
52
52
|
IS_DEV = config.mode === "development";
|
|
53
|
+
dataStoreFile = getDataStoreFile(settings, IS_DEV);
|
|
53
54
|
},
|
|
54
55
|
async resolveId(id) {
|
|
55
56
|
if (id === VIRTUAL_MODULE_ID) {
|
|
@@ -161,20 +162,25 @@ function astroContentVirtualModPlugin({
|
|
|
161
162
|
},
|
|
162
163
|
configureServer(server) {
|
|
163
164
|
const dataStorePath = fileURLToPath(dataStoreFile);
|
|
164
|
-
if (Array.isArray(server.watcher.options.ignored)) {
|
|
165
|
-
server.watcher.options.ignored.push(`!${dataStorePath}`);
|
|
166
|
-
}
|
|
167
165
|
server.watcher.add(dataStorePath);
|
|
166
|
+
function invalidateDataStore() {
|
|
167
|
+
const module = server.moduleGraph.getModuleById(RESOLVED_DATA_STORE_VIRTUAL_ID);
|
|
168
|
+
if (module) {
|
|
169
|
+
server.moduleGraph.invalidateModule(module);
|
|
170
|
+
}
|
|
171
|
+
server.ws.send({
|
|
172
|
+
type: "full-reload",
|
|
173
|
+
path: "*"
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
server.watcher.on("add", (addedPath) => {
|
|
177
|
+
if (addedPath === dataStorePath) {
|
|
178
|
+
invalidateDataStore();
|
|
179
|
+
}
|
|
180
|
+
});
|
|
168
181
|
server.watcher.on("change", (changedPath) => {
|
|
169
182
|
if (changedPath === dataStorePath) {
|
|
170
|
-
|
|
171
|
-
if (module) {
|
|
172
|
-
server.moduleGraph.invalidateModule(module);
|
|
173
|
-
}
|
|
174
|
-
server.ws.send({
|
|
175
|
-
type: "full-reload",
|
|
176
|
-
path: "*"
|
|
177
|
-
});
|
|
183
|
+
invalidateDataStore();
|
|
178
184
|
}
|
|
179
185
|
});
|
|
180
186
|
}
|
package/dist/core/build/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { resolveConfig } from "../config/config.js";
|
|
|
15
15
|
import { createNodeLogger } from "../config/logging.js";
|
|
16
16
|
import { createSettings } from "../config/settings.js";
|
|
17
17
|
import { createVite } from "../create-vite.js";
|
|
18
|
-
import { createKey } from "../encryption.js";
|
|
18
|
+
import { createKey, getEnvironmentKey, hasEnvironmentKey } from "../encryption.js";
|
|
19
19
|
import { levels, timerMessage } from "../logger/core.js";
|
|
20
20
|
import { apply as applyPolyfill } from "../polyfill.js";
|
|
21
21
|
import { createRouteManifest } from "../routing/index.js";
|
|
@@ -31,6 +31,7 @@ async function build(inlineConfig, options = {}) {
|
|
|
31
31
|
const logger = createNodeLogger(inlineConfig);
|
|
32
32
|
const { userConfig, astroConfig } = await resolveConfig(inlineConfig, "build");
|
|
33
33
|
telemetry.record(eventCliSession("build", userConfig));
|
|
34
|
+
const settings = await createSettings(astroConfig, fileURLToPath(astroConfig.root));
|
|
34
35
|
if (inlineConfig.force) {
|
|
35
36
|
if (astroConfig.experimental.contentCollectionCache) {
|
|
36
37
|
const contentCacheDir = new URL("./content/", astroConfig.cacheDir);
|
|
@@ -40,9 +41,8 @@ async function build(inlineConfig, options = {}) {
|
|
|
40
41
|
logger.warn("content", "content cache cleared (force)");
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
|
-
await clearContentLayerCache({
|
|
44
|
+
await clearContentLayerCache({ settings, logger, fs });
|
|
44
45
|
}
|
|
45
|
-
const settings = await createSettings(astroConfig, fileURLToPath(astroConfig.root));
|
|
46
46
|
const builder = new AstroBuilder(settings, {
|
|
47
47
|
...options,
|
|
48
48
|
logger,
|
|
@@ -131,6 +131,8 @@ class AstroBuilder {
|
|
|
131
131
|
"build",
|
|
132
132
|
green(`\u2713 Completed in ${getTimeStat(this.timer.init, performance.now())}.`)
|
|
133
133
|
);
|
|
134
|
+
const hasKey = hasEnvironmentKey();
|
|
135
|
+
const keyPromise = hasKey ? getEnvironmentKey() : createKey();
|
|
134
136
|
const opts = {
|
|
135
137
|
allPages,
|
|
136
138
|
settings: this.settings,
|
|
@@ -141,7 +143,7 @@ class AstroBuilder {
|
|
|
141
143
|
pageNames,
|
|
142
144
|
teardownCompiler: this.teardownCompiler,
|
|
143
145
|
viteConfig,
|
|
144
|
-
key:
|
|
146
|
+
key: keyPromise
|
|
145
147
|
};
|
|
146
148
|
const { internals, ssrOutputChunkNames, contentFileNames } = await viteBuild(opts);
|
|
147
149
|
await staticBuild(opts, internals, ssrOutputChunkNames, contentFileNames);
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -2,8 +2,7 @@ import fs, { existsSync } from "node:fs";
|
|
|
2
2
|
import { performance } from "node:perf_hooks";
|
|
3
3
|
import { green } from "kleur/colors";
|
|
4
4
|
import { gt, major, minor, patch } from "semver";
|
|
5
|
-
import {
|
|
6
|
-
import { globalContentLayer } from "../../content/content-layer.js";
|
|
5
|
+
import { getDataStoreFile, globalContentLayer } from "../../content/content-layer.js";
|
|
7
6
|
import { attachContentServerListeners } from "../../content/index.js";
|
|
8
7
|
import { MutableDataStore } from "../../content/mutable-data-store.js";
|
|
9
8
|
import { globalContentConfigObserver } from "../../content/utils.js";
|
|
@@ -23,7 +22,7 @@ async function dev(inlineConfig) {
|
|
|
23
22
|
await telemetry.record([]);
|
|
24
23
|
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
25
24
|
const logger = restart.container.logger;
|
|
26
|
-
const currentVersion = "4.15.
|
|
25
|
+
const currentVersion = "4.15.4";
|
|
27
26
|
const isPrerelease = currentVersion.includes("-");
|
|
28
27
|
if (!isPrerelease) {
|
|
29
28
|
try {
|
|
@@ -70,7 +69,7 @@ async function dev(inlineConfig) {
|
|
|
70
69
|
await attachContentServerListeners(restart.container);
|
|
71
70
|
let store;
|
|
72
71
|
try {
|
|
73
|
-
const dataStoreFile =
|
|
72
|
+
const dataStoreFile = getDataStoreFile(restart.container.settings);
|
|
74
73
|
if (existsSync(dataStoreFile)) {
|
|
75
74
|
store = await MutableDataStore.fromFile(dataStoreFile);
|
|
76
75
|
}
|
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
* Creates a CryptoKey object that can be used to encrypt any string.
|
|
3
3
|
*/
|
|
4
4
|
export declare function createKey(): Promise<CryptoKey>;
|
|
5
|
+
/**
|
|
6
|
+
* Get the encoded value of the ASTRO_KEY env var.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getEncodedEnvironmentKey(): string;
|
|
9
|
+
/**
|
|
10
|
+
* See if the environment variable key ASTRO_KEY is set.
|
|
11
|
+
*/
|
|
12
|
+
export declare function hasEnvironmentKey(): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Get the environment variable key and decode it into a CryptoKey.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getEnvironmentKey(): Promise<CryptoKey>;
|
|
5
17
|
/**
|
|
6
18
|
* Takes a key that has been serialized to an array of bytes and returns a CryptoKey
|
|
7
19
|
*/
|
package/dist/core/encryption.js
CHANGED
|
@@ -11,6 +11,22 @@ async function createKey() {
|
|
|
11
11
|
);
|
|
12
12
|
return key;
|
|
13
13
|
}
|
|
14
|
+
const ENVIRONMENT_KEY_NAME = "ASTRO_KEY";
|
|
15
|
+
function getEncodedEnvironmentKey() {
|
|
16
|
+
return process.env[ENVIRONMENT_KEY_NAME] || "";
|
|
17
|
+
}
|
|
18
|
+
function hasEnvironmentKey() {
|
|
19
|
+
return getEncodedEnvironmentKey() !== "";
|
|
20
|
+
}
|
|
21
|
+
async function getEnvironmentKey() {
|
|
22
|
+
if (!hasEnvironmentKey()) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
`There is no environment key defined. If you see this error there is a bug in Astro.`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
const encodedKey = getEncodedEnvironmentKey();
|
|
28
|
+
return decodeKey(encodedKey);
|
|
29
|
+
}
|
|
14
30
|
async function importKey(bytes) {
|
|
15
31
|
const key = await crypto.subtle.importKey("raw", bytes, ALGORITHM, true, ["encrypt", "decrypt"]);
|
|
16
32
|
return key;
|
|
@@ -60,5 +76,8 @@ export {
|
|
|
60
76
|
decryptString,
|
|
61
77
|
encodeKey,
|
|
62
78
|
encryptString,
|
|
79
|
+
getEncodedEnvironmentKey,
|
|
80
|
+
getEnvironmentKey,
|
|
81
|
+
hasEnvironmentKey,
|
|
63
82
|
importKey
|
|
64
83
|
};
|
|
@@ -7,7 +7,7 @@ export type LoggerLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
|
7
7
|
* rather than specific to a single command, function, use, etc. The label will be
|
|
8
8
|
* shown in the log message to the user, so it should be relevant.
|
|
9
9
|
*/
|
|
10
|
-
export type LoggerLabel = 'add' | 'build' | 'check' | 'config' | 'content' | 'deprecated' | 'markdown' | 'router' | 'types' | 'vite' | 'watch' | 'middleware' | 'preferences' | 'redirects' | 'toolbar' | 'assets' | 'env' | 'update' | 'SKIP_FORMAT';
|
|
10
|
+
export type LoggerLabel = 'add' | 'build' | 'check' | 'config' | 'content' | 'crypto' | 'deprecated' | 'markdown' | 'router' | 'types' | 'vite' | 'watch' | 'middleware' | 'preferences' | 'redirects' | 'sync' | 'toolbar' | 'assets' | 'env' | 'update' | 'SKIP_FORMAT';
|
|
11
11
|
export interface LogOptions {
|
|
12
12
|
dest: LogWritable<LogMessage>;
|
|
13
13
|
level: LoggerLevel;
|
package/dist/core/messages.js
CHANGED
|
@@ -38,7 +38,7 @@ function serverStart({
|
|
|
38
38
|
host,
|
|
39
39
|
base
|
|
40
40
|
}) {
|
|
41
|
-
const version = "4.15.
|
|
41
|
+
const version = "4.15.4";
|
|
42
42
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
43
43
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
44
44
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -270,7 +270,7 @@ function printHelp({
|
|
|
270
270
|
message.push(
|
|
271
271
|
linebreak(),
|
|
272
272
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
273
|
-
`v${"4.15.
|
|
273
|
+
`v${"4.15.4"}`
|
|
274
274
|
)} ${headline}`
|
|
275
275
|
);
|
|
276
276
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fsMod from 'node:fs';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AstroInlineConfig, AstroSettings } from '../../@types/astro.js';
|
|
3
3
|
import type { Logger } from '../logger/core.js';
|
|
4
4
|
export type SyncOptions = {
|
|
5
5
|
logger: Logger;
|
|
@@ -16,8 +16,8 @@ export default function sync(inlineConfig: AstroInlineConfig, { fs, telemetry: _
|
|
|
16
16
|
/**
|
|
17
17
|
* Clears the content layer and content collection cache, forcing a full rebuild.
|
|
18
18
|
*/
|
|
19
|
-
export declare function clearContentLayerCache({
|
|
20
|
-
|
|
19
|
+
export declare function clearContentLayerCache({ settings, logger, fs, }: {
|
|
20
|
+
settings: AstroSettings;
|
|
21
21
|
logger: Logger;
|
|
22
22
|
fs?: typeof fsMod;
|
|
23
23
|
}): Promise<void>;
|
package/dist/core/sync/index.js
CHANGED
|
@@ -3,8 +3,8 @@ import { performance } from "node:perf_hooks";
|
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { dim } from "kleur/colors";
|
|
5
5
|
import { createServer } from "vite";
|
|
6
|
-
import { CONTENT_TYPES_FILE
|
|
7
|
-
import { globalContentLayer } from "../../content/content-layer.js";
|
|
6
|
+
import { CONTENT_TYPES_FILE } from "../../content/consts.js";
|
|
7
|
+
import { getDataStoreFile, globalContentLayer } from "../../content/content-layer.js";
|
|
8
8
|
import { createContentTypesGenerator } from "../../content/index.js";
|
|
9
9
|
import { MutableDataStore } from "../../content/mutable-data-store.js";
|
|
10
10
|
import { getContentPaths, globalContentConfigObserver } from "../../content/utils.js";
|
|
@@ -41,15 +41,23 @@ async function sync(inlineConfig, { fs, telemetry: _telemetry = false } = {}) {
|
|
|
41
41
|
settings,
|
|
42
42
|
logger
|
|
43
43
|
});
|
|
44
|
-
|
|
44
|
+
try {
|
|
45
|
+
await runHookConfigDone({ settings, logger });
|
|
46
|
+
} catch (err) {
|
|
47
|
+
if (err instanceof Error) {
|
|
48
|
+
const errorMessage = err.toString();
|
|
49
|
+
logger.error("sync", errorMessage);
|
|
50
|
+
}
|
|
51
|
+
throw err;
|
|
52
|
+
}
|
|
45
53
|
return await syncInternal({ settings, logger, fs, force: inlineConfig.force });
|
|
46
54
|
}
|
|
47
55
|
async function clearContentLayerCache({
|
|
48
|
-
|
|
56
|
+
settings,
|
|
49
57
|
logger,
|
|
50
58
|
fs = fsMod
|
|
51
59
|
}) {
|
|
52
|
-
const dataStore =
|
|
60
|
+
const dataStore = getDataStoreFile(settings);
|
|
53
61
|
if (fs.existsSync(dataStore)) {
|
|
54
62
|
logger.debug("content", "clearing data store");
|
|
55
63
|
await fs.promises.rm(dataStore, { force: true });
|
|
@@ -64,7 +72,7 @@ async function syncInternal({
|
|
|
64
72
|
force
|
|
65
73
|
}) {
|
|
66
74
|
if (force) {
|
|
67
|
-
await clearContentLayerCache({
|
|
75
|
+
await clearContentLayerCache({ settings, logger, fs });
|
|
68
76
|
}
|
|
69
77
|
const timerStart = performance.now();
|
|
70
78
|
try {
|
|
@@ -73,7 +81,7 @@ async function syncInternal({
|
|
|
73
81
|
settings.timer.start("Sync content layer");
|
|
74
82
|
let store;
|
|
75
83
|
try {
|
|
76
|
-
const dataStoreFile =
|
|
84
|
+
const dataStoreFile = getDataStoreFile(settings);
|
|
77
85
|
if (existsSync(dataStoreFile)) {
|
|
78
86
|
store = await MutableDataStore.fromFile(dataStoreFile);
|
|
79
87
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "4.15.
|
|
3
|
+
"version": "4.15.4",
|
|
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",
|
|
@@ -164,7 +164,7 @@
|
|
|
164
164
|
"unist-util-visit": "^5.0.0",
|
|
165
165
|
"vfile": "^6.0.3",
|
|
166
166
|
"vite": "^5.4.2",
|
|
167
|
-
"vitefu": "^0.2
|
|
167
|
+
"vitefu": "^1.0.2",
|
|
168
168
|
"which-pm": "^3.0.0",
|
|
169
169
|
"xxhash-wasm": "^1.0.2",
|
|
170
170
|
"yargs-parser": "^21.1.1",
|
|
@@ -182,8 +182,6 @@
|
|
|
182
182
|
"@astrojs/check": "^0.9.3",
|
|
183
183
|
"@playwright/test": "^1.46.1",
|
|
184
184
|
"@types/aria-query": "^5.0.4",
|
|
185
|
-
"@types/babel__generator": "^7.6.8",
|
|
186
|
-
"@types/babel__traverse": "^7.20.6",
|
|
187
185
|
"@types/common-ancestor-path": "^1.0.2",
|
|
188
186
|
"@types/cssesc": "^3.0.2",
|
|
189
187
|
"@types/debug": "^4.1.12",
|