astro 5.14.7 → 5.14.8
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/cli/create-key/core/create-key.d.ts +11 -2
- package/dist/cli/create-key/core/create-key.js +18 -8
- package/dist/cli/definitions.d.ts +20 -0
- package/dist/cli/definitions.js +0 -0
- package/dist/cli/domain/command.d.ts +8 -0
- package/dist/cli/domain/command.js +6 -0
- package/dist/cli/domain/help-payload.d.ts +7 -0
- package/dist/cli/domain/help-payload.js +0 -0
- package/dist/cli/help/index.d.ts +2 -0
- package/dist/cli/help/index.js +34 -0
- package/dist/cli/index.js +34 -44
- package/dist/cli/infra/build-time-astro-version-provider.d.ts +2 -0
- package/dist/cli/infra/build-time-astro-version-provider.js +10 -0
- package/dist/cli/infra/cli-command-runner.d.ts +6 -0
- package/dist/cli/infra/cli-command-runner.js +14 -0
- package/dist/cli/infra/kleur-text-styler.d.ts +2 -0
- package/dist/cli/infra/kleur-text-styler.js +7 -0
- package/dist/cli/infra/logger-help-display.d.ts +11 -0
- package/dist/cli/infra/logger-help-display.js +60 -0
- package/dist/content/content-layer.js +3 -3
- package/dist/content/utils.js +6 -2
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.d.ts +1 -0
- package/dist/core/messages.js +2 -2
- package/package.json +1 -1
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import type { Logger } from '../../../core/logger/core.js';
|
|
2
2
|
import type { KeyGenerator } from '../definitions.js';
|
|
3
|
-
interface
|
|
3
|
+
interface Options {
|
|
4
4
|
logger: Logger;
|
|
5
5
|
keyGenerator: KeyGenerator;
|
|
6
6
|
}
|
|
7
|
-
export declare
|
|
7
|
+
export declare const createKeyCommand: {
|
|
8
|
+
help: {
|
|
9
|
+
commandName: string;
|
|
10
|
+
tables: {
|
|
11
|
+
Flags: [string, string][];
|
|
12
|
+
};
|
|
13
|
+
description: string;
|
|
14
|
+
};
|
|
15
|
+
run({ logger, keyGenerator }: Options): Promise<void>;
|
|
16
|
+
};
|
|
8
17
|
export {};
|
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
"
|
|
5
|
-
|
|
1
|
+
import { defineCommand } from "../../domain/command.js";
|
|
2
|
+
const createKeyCommand = defineCommand({
|
|
3
|
+
help: {
|
|
4
|
+
commandName: "astro create-key",
|
|
5
|
+
tables: {
|
|
6
|
+
Flags: [["--help (-h)", "See all available flags."]]
|
|
7
|
+
},
|
|
8
|
+
description: "Generates a key to encrypt props passed to server islands."
|
|
9
|
+
},
|
|
10
|
+
async run({ logger, keyGenerator }) {
|
|
11
|
+
const key = await keyGenerator.generate();
|
|
12
|
+
logger.info(
|
|
13
|
+
"crypto",
|
|
14
|
+
`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.
|
|
6
15
|
|
|
7
16
|
ASTRO_KEY=${key}`
|
|
8
|
-
|
|
9
|
-
}
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
10
20
|
export {
|
|
11
|
-
|
|
21
|
+
createKeyCommand
|
|
12
22
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AnyCommand } from './domain/command.js';
|
|
2
|
+
import type { HelpPayload } from './domain/help-payload.js';
|
|
3
|
+
export interface HelpDisplay {
|
|
4
|
+
shouldFire: () => boolean;
|
|
5
|
+
show: (payload: HelpPayload) => void;
|
|
6
|
+
}
|
|
7
|
+
export interface TextStyler {
|
|
8
|
+
bgWhite: (msg: string) => string;
|
|
9
|
+
black: (msg: string) => string;
|
|
10
|
+
dim: (msg: string) => string;
|
|
11
|
+
green: (msg: string) => string;
|
|
12
|
+
bold: (msg: string) => string;
|
|
13
|
+
bgGreen: (msg: string) => string;
|
|
14
|
+
}
|
|
15
|
+
export interface AstroVersionProvider {
|
|
16
|
+
getVersion: () => string;
|
|
17
|
+
}
|
|
18
|
+
export interface CommandRunner {
|
|
19
|
+
run: <T extends AnyCommand>(command: T, ...args: Parameters<T['run']>) => ReturnType<T['run']>;
|
|
20
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { HelpPayload } from './help-payload.js';
|
|
2
|
+
interface Command<T extends (...args: Array<any>) => any> {
|
|
3
|
+
help: HelpPayload;
|
|
4
|
+
run: T;
|
|
5
|
+
}
|
|
6
|
+
export type AnyCommand = Command<(...args: Array<any>) => any>;
|
|
7
|
+
export declare function defineCommand<T extends AnyCommand>(command: T): T;
|
|
8
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const DEFAULT_HELP_PAYLOAD = {
|
|
2
|
+
commandName: "astro",
|
|
3
|
+
usage: "[command] [...flags]",
|
|
4
|
+
headline: "Build faster websites.",
|
|
5
|
+
tables: {
|
|
6
|
+
Commands: [
|
|
7
|
+
["add", "Add an integration."],
|
|
8
|
+
["build", "Build your project and write it to disk."],
|
|
9
|
+
["check", "Check your project for errors."],
|
|
10
|
+
["create-key", "Create a cryptography key"],
|
|
11
|
+
["db", "Manage your Astro database."],
|
|
12
|
+
["dev", "Start the development server."],
|
|
13
|
+
["docs", "Open documentation in your web browser."],
|
|
14
|
+
["info", "List info about your current Astro setup."],
|
|
15
|
+
["preview", "Preview your build locally."],
|
|
16
|
+
["sync", "Generate content collection types."],
|
|
17
|
+
["preferences", "Configure user preferences."],
|
|
18
|
+
["telemetry", "Configure telemetry settings."]
|
|
19
|
+
],
|
|
20
|
+
"Global Flags": [
|
|
21
|
+
["--config <path>", "Specify your config file."],
|
|
22
|
+
["--root <path>", "Specify your project root folder."],
|
|
23
|
+
["--site <url>", "Specify your project site."],
|
|
24
|
+
["--base <pathname>", "Specify your project base."],
|
|
25
|
+
["--verbose", "Enable verbose logging."],
|
|
26
|
+
["--silent", "Disable all logging."],
|
|
27
|
+
["--version", "Show the version number and exit."],
|
|
28
|
+
["--help", "Show this help message."]
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
DEFAULT_HELP_PAYLOAD
|
|
34
|
+
};
|
package/dist/cli/index.js
CHANGED
|
@@ -1,40 +1,6 @@
|
|
|
1
1
|
import * as colors from "kleur/colors";
|
|
2
2
|
import yargs from "yargs-parser";
|
|
3
3
|
import { ASTRO_VERSION } from "../core/constants.js";
|
|
4
|
-
async function printAstroHelp() {
|
|
5
|
-
const { printHelp } = await import("../core/messages.js");
|
|
6
|
-
printHelp({
|
|
7
|
-
commandName: "astro",
|
|
8
|
-
usage: "[command] [...flags]",
|
|
9
|
-
headline: "Build faster websites.",
|
|
10
|
-
tables: {
|
|
11
|
-
Commands: [
|
|
12
|
-
["add", "Add an integration."],
|
|
13
|
-
["build", "Build your project and write it to disk."],
|
|
14
|
-
["check", "Check your project for errors."],
|
|
15
|
-
["create-key", "Create a cryptography key"],
|
|
16
|
-
["db", "Manage your Astro database."],
|
|
17
|
-
["dev", "Start the development server."],
|
|
18
|
-
["docs", "Open documentation in your web browser."],
|
|
19
|
-
["info", "List info about your current Astro setup."],
|
|
20
|
-
["preview", "Preview your build locally."],
|
|
21
|
-
["sync", "Generate content collection types."],
|
|
22
|
-
["preferences", "Configure user preferences."],
|
|
23
|
-
["telemetry", "Configure telemetry settings."]
|
|
24
|
-
],
|
|
25
|
-
"Global Flags": [
|
|
26
|
-
["--config <path>", "Specify your config file."],
|
|
27
|
-
["--root <path>", "Specify your project root folder."],
|
|
28
|
-
["--site <url>", "Specify your project site."],
|
|
29
|
-
["--base <pathname>", "Specify your project base."],
|
|
30
|
-
["--verbose", "Enable verbose logging."],
|
|
31
|
-
["--silent", "Disable all logging."],
|
|
32
|
-
["--version", "Show the version number and exit."],
|
|
33
|
-
["--help", "Show this help message."]
|
|
34
|
-
]
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
4
|
function printVersion() {
|
|
39
5
|
console.log();
|
|
40
6
|
console.log(` ${colors.bgGreen(colors.black(` astro `))} ${colors.green(`v${ASTRO_VERSION}`)}`);
|
|
@@ -66,28 +32,52 @@ function resolveCommand(flags) {
|
|
|
66
32
|
return "help";
|
|
67
33
|
}
|
|
68
34
|
async function runCommand(cmd, flags) {
|
|
35
|
+
const [
|
|
36
|
+
{ createLoggerFromFlags },
|
|
37
|
+
{ createKleurTextStyler },
|
|
38
|
+
{ createBuildTimeAstroVersionProvider },
|
|
39
|
+
{ createLoggerHelpDisplay },
|
|
40
|
+
{ createCliCommandRunner }
|
|
41
|
+
] = await Promise.all([
|
|
42
|
+
import("./flags.js"),
|
|
43
|
+
import("./infra/kleur-text-styler.js"),
|
|
44
|
+
import("./infra/build-time-astro-version-provider.js"),
|
|
45
|
+
import("./infra/logger-help-display.js"),
|
|
46
|
+
import("./infra/cli-command-runner.js")
|
|
47
|
+
]);
|
|
48
|
+
const logger = createLoggerFromFlags(flags);
|
|
49
|
+
const textStyler = createKleurTextStyler();
|
|
50
|
+
const astroVersionProvider = createBuildTimeAstroVersionProvider();
|
|
51
|
+
const helpDisplay = createLoggerHelpDisplay({
|
|
52
|
+
logger,
|
|
53
|
+
flags,
|
|
54
|
+
textStyler,
|
|
55
|
+
astroVersionProvider
|
|
56
|
+
});
|
|
57
|
+
const runner = createCliCommandRunner({ helpDisplay });
|
|
69
58
|
switch (cmd) {
|
|
70
|
-
|
|
71
|
-
|
|
59
|
+
/** Display --help flag */
|
|
60
|
+
case "help": {
|
|
61
|
+
const { DEFAULT_HELP_PAYLOAD } = await import("./help/index.js");
|
|
62
|
+
helpDisplay.show(DEFAULT_HELP_PAYLOAD);
|
|
72
63
|
return;
|
|
73
|
-
|
|
64
|
+
}
|
|
65
|
+
case "version": {
|
|
74
66
|
printVersion();
|
|
75
67
|
return;
|
|
68
|
+
}
|
|
76
69
|
case "info": {
|
|
77
70
|
const { printInfo } = await import("./info/index.js");
|
|
78
71
|
await printInfo({ flags });
|
|
79
72
|
return;
|
|
80
73
|
}
|
|
81
74
|
case "create-key": {
|
|
82
|
-
const [{
|
|
83
|
-
import("./create-key/
|
|
84
|
-
import("./
|
|
85
|
-
import("./create-key/infra/crypto-key-generator.js")
|
|
75
|
+
const [{ createCryptoKeyGenerator }, { createKeyCommand }] = await Promise.all([
|
|
76
|
+
import("./create-key/infra/crypto-key-generator.js"),
|
|
77
|
+
import("./create-key/core/create-key.js")
|
|
86
78
|
]);
|
|
87
|
-
const logger = createLoggerFromFlags(flags);
|
|
88
79
|
const keyGenerator = createCryptoKeyGenerator();
|
|
89
|
-
await
|
|
90
|
-
return;
|
|
80
|
+
return await runner.run(createKeyCommand, { logger, keyGenerator });
|
|
91
81
|
}
|
|
92
82
|
case "docs": {
|
|
93
83
|
const { docs } = await import("./docs/index.js");
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function createCliCommandRunner({ helpDisplay }) {
|
|
2
|
+
return {
|
|
3
|
+
run(command, ...args) {
|
|
4
|
+
if (helpDisplay.shouldFire()) {
|
|
5
|
+
helpDisplay.show(command.help);
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
return command.run(...args);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
createCliCommandRunner
|
|
14
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Logger } from '../../core/logger/core.js';
|
|
2
|
+
import type { AstroVersionProvider, HelpDisplay, TextStyler } from '../definitions.js';
|
|
3
|
+
import type { Flags } from '../flags.js';
|
|
4
|
+
interface Options {
|
|
5
|
+
logger: Logger;
|
|
6
|
+
textStyler: TextStyler;
|
|
7
|
+
astroVersionProvider: AstroVersionProvider;
|
|
8
|
+
flags: Flags;
|
|
9
|
+
}
|
|
10
|
+
export declare function createLoggerHelpDisplay({ logger, flags, textStyler, astroVersionProvider, }: Options): HelpDisplay;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
function createLoggerHelpDisplay({
|
|
2
|
+
logger,
|
|
3
|
+
flags,
|
|
4
|
+
textStyler,
|
|
5
|
+
astroVersionProvider
|
|
6
|
+
}) {
|
|
7
|
+
return {
|
|
8
|
+
shouldFire() {
|
|
9
|
+
return !!(flags.help || flags.h);
|
|
10
|
+
},
|
|
11
|
+
show({ commandName, description, headline, tables, usage }) {
|
|
12
|
+
const linebreak = () => "";
|
|
13
|
+
const title = (label) => ` ${textStyler.bgWhite(textStyler.black(` ${label} `))}`;
|
|
14
|
+
const table = (rows, { padding }) => {
|
|
15
|
+
const split = process.stdout.columns < 60;
|
|
16
|
+
let raw = "";
|
|
17
|
+
for (const row of rows) {
|
|
18
|
+
if (split) {
|
|
19
|
+
raw += ` ${row[0]}
|
|
20
|
+
`;
|
|
21
|
+
} else {
|
|
22
|
+
raw += `${`${row[0]}`.padStart(padding)}`;
|
|
23
|
+
}
|
|
24
|
+
raw += " " + textStyler.dim(row[1]) + "\n";
|
|
25
|
+
}
|
|
26
|
+
return raw.slice(0, -1);
|
|
27
|
+
};
|
|
28
|
+
let message = [];
|
|
29
|
+
if (headline) {
|
|
30
|
+
message.push(
|
|
31
|
+
linebreak(),
|
|
32
|
+
` ${textStyler.bgGreen(textStyler.black(` ${commandName} `))} ${textStyler.green(
|
|
33
|
+
`v${astroVersionProvider.getVersion()}`
|
|
34
|
+
)} ${headline}`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
if (usage) {
|
|
38
|
+
message.push(linebreak(), ` ${textStyler.green(commandName)} ${textStyler.bold(usage)}`);
|
|
39
|
+
}
|
|
40
|
+
if (tables) {
|
|
41
|
+
let calculateTablePadding2 = function(rows) {
|
|
42
|
+
return rows.reduce((val, [first]) => Math.max(val, first.length), 0) + 2;
|
|
43
|
+
};
|
|
44
|
+
var calculateTablePadding = calculateTablePadding2;
|
|
45
|
+
const tableEntries = Object.entries(tables);
|
|
46
|
+
const padding = Math.max(...tableEntries.map(([, rows]) => calculateTablePadding2(rows)));
|
|
47
|
+
for (const [tableTitle, tableRows] of tableEntries) {
|
|
48
|
+
message.push(linebreak(), title(tableTitle), table(tableRows, { padding }));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (description) {
|
|
52
|
+
message.push(linebreak(), `${description}`);
|
|
53
|
+
}
|
|
54
|
+
logger.info("SKIP_FORMAT", message.join("\n") + "\n");
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
createLoggerHelpDisplay
|
|
60
|
+
};
|
|
@@ -164,7 +164,7 @@ ${contentConfig.error.message}`);
|
|
|
164
164
|
logger.info("Content config changed");
|
|
165
165
|
shouldClear = true;
|
|
166
166
|
}
|
|
167
|
-
if (previousAstroVersion && previousAstroVersion !== "5.14.
|
|
167
|
+
if (previousAstroVersion && previousAstroVersion !== "5.14.8") {
|
|
168
168
|
logger.info("Astro version changed");
|
|
169
169
|
shouldClear = true;
|
|
170
170
|
}
|
|
@@ -172,8 +172,8 @@ ${contentConfig.error.message}`);
|
|
|
172
172
|
logger.info("Clearing content store");
|
|
173
173
|
this.#store.clearAll();
|
|
174
174
|
}
|
|
175
|
-
if ("5.14.
|
|
176
|
-
await this.#store.metaStore().set("astro-version", "5.14.
|
|
175
|
+
if ("5.14.8") {
|
|
176
|
+
await this.#store.metaStore().set("astro-version", "5.14.8");
|
|
177
177
|
}
|
|
178
178
|
if (currentConfigDigest) {
|
|
179
179
|
await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
|
package/dist/content/utils.js
CHANGED
|
@@ -127,8 +127,12 @@ async function getEntryDataAndImages(entry, collectionConfig, shouldEmitFile, ex
|
|
|
127
127
|
} else if (collectionConfig.type === CONTENT_LAYER_TYPE) {
|
|
128
128
|
schema = schema({
|
|
129
129
|
image: () => z.string().transform((val) => {
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
let normalizedPath = val;
|
|
131
|
+
if (val && !val.startsWith("./") && !val.startsWith("../") && !val.startsWith("/") && !val.startsWith("~") && !val.startsWith("@") && !val.includes("://")) {
|
|
132
|
+
normalizedPath = `./${val}`;
|
|
133
|
+
}
|
|
134
|
+
imageImports.add(normalizedPath);
|
|
135
|
+
return `${IMAGE_IMPORT_PREFIX}${normalizedPath}`;
|
|
132
136
|
})
|
|
133
137
|
});
|
|
134
138
|
}
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -22,7 +22,7 @@ async function dev(inlineConfig) {
|
|
|
22
22
|
await telemetry.record([]);
|
|
23
23
|
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
24
24
|
const logger = restart.container.logger;
|
|
25
|
-
const currentVersion = "5.14.
|
|
25
|
+
const currentVersion = "5.14.8";
|
|
26
26
|
const isPrerelease = currentVersion.includes("-");
|
|
27
27
|
if (!isPrerelease) {
|
|
28
28
|
try {
|
package/dist/core/messages.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ export declare function actionRequired(message: string): string;
|
|
|
47
47
|
export declare function cancelled(message: string, tip?: string): string;
|
|
48
48
|
export declare function formatConfigErrorMessage(err: ZodError): string;
|
|
49
49
|
export declare function formatErrorMessage(err: ErrorWithMetadata, showFullStacktrace: boolean): string;
|
|
50
|
+
/** @deprecated Migrate to HelpDisplay */
|
|
50
51
|
export declare function printHelp({ commandName, headline, usage, tables, description, }: {
|
|
51
52
|
commandName: string;
|
|
52
53
|
headline?: string;
|
package/dist/core/messages.js
CHANGED
|
@@ -37,7 +37,7 @@ function serverStart({
|
|
|
37
37
|
host,
|
|
38
38
|
base
|
|
39
39
|
}) {
|
|
40
|
-
const version = "5.14.
|
|
40
|
+
const version = "5.14.8";
|
|
41
41
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
42
42
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
43
43
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -274,7 +274,7 @@ function printHelp({
|
|
|
274
274
|
message.push(
|
|
275
275
|
linebreak(),
|
|
276
276
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
277
|
-
`v${"5.14.
|
|
277
|
+
`v${"5.14.8"}`
|
|
278
278
|
)} ${headline}`
|
|
279
279
|
);
|
|
280
280
|
}
|