astro 1.0.0-beta.3 → 1.0.0-beta.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/cli/index.js +11 -2
- package/dist/cli/open.js +26 -0
- package/dist/core/build/index.js +1 -0
- package/dist/core/config.js +15 -3
- package/dist/core/dev/index.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/routing/manifest/create.js +1 -0
- package/dist/core/routing/manifest/serialization.js +5 -4
- package/dist/integrations/index.js +4 -1
- package/dist/types/@types/astro.d.ts +6 -0
- package/dist/types/cli/open.d.ts +2 -0
- package/dist/types/integrations/index.d.ts +2 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import add from "../core/add/index.js";
|
|
|
7
7
|
import devServer from "../core/dev/index.js";
|
|
8
8
|
import preview from "../core/preview/index.js";
|
|
9
9
|
import { check } from "./check.js";
|
|
10
|
+
import { openInBrowser } from "./open.js";
|
|
10
11
|
import { loadConfig } from "../core/config.js";
|
|
11
12
|
import { printHelp, formatErrorMessage, formatConfigErrorMessage } from "../core/messages.js";
|
|
12
13
|
import { createSafeError } from "../core/util.js";
|
|
@@ -16,6 +17,7 @@ function printAstroHelp() {
|
|
|
16
17
|
headline: "Futuristic web development tool.",
|
|
17
18
|
commands: [
|
|
18
19
|
["add", "Add an integration to your configuration."],
|
|
20
|
+
["docs", "Launch Astro's Doc site directly from the terminal. "],
|
|
19
21
|
["dev", "Run Astro in development mode."],
|
|
20
22
|
["build", "Build a pre-compiled production-ready site."],
|
|
21
23
|
["preview", "Preview your build locally before deploying."],
|
|
@@ -36,7 +38,7 @@ function printAstroHelp() {
|
|
|
36
38
|
});
|
|
37
39
|
}
|
|
38
40
|
async function printVersion() {
|
|
39
|
-
const version = "1.0.0-beta.
|
|
41
|
+
const version = "1.0.0-beta.4";
|
|
40
42
|
console.log();
|
|
41
43
|
console.log(` ${colors.bgGreen(colors.black(` astro `))} ${colors.green(`v${version}`)}`);
|
|
42
44
|
}
|
|
@@ -48,7 +50,7 @@ function resolveCommand(flags) {
|
|
|
48
50
|
return "version";
|
|
49
51
|
else if (flags.help)
|
|
50
52
|
return "help";
|
|
51
|
-
const supportedCommands = /* @__PURE__ */ new Set(["dev", "build", "preview", "check"]);
|
|
53
|
+
const supportedCommands = /* @__PURE__ */ new Set(["dev", "build", "preview", "check", "docs"]);
|
|
52
54
|
if (supportedCommands.has(cmd)) {
|
|
53
55
|
return cmd;
|
|
54
56
|
}
|
|
@@ -119,6 +121,13 @@ async function cli(args) {
|
|
|
119
121
|
return throwAndExit(err);
|
|
120
122
|
}
|
|
121
123
|
}
|
|
124
|
+
case "docs": {
|
|
125
|
+
try {
|
|
126
|
+
return await openInBrowser("https://docs.astro.build/");
|
|
127
|
+
} catch (err) {
|
|
128
|
+
return throwAndExit(err);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
122
131
|
default: {
|
|
123
132
|
throw new Error(`Error running ${cmd}`);
|
|
124
133
|
}
|
package/dist/cli/open.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { execa } from "execa";
|
|
2
|
+
const getPlatformSpecificCommand = () => {
|
|
3
|
+
const isGitPod = Boolean(process.env.GITPOD_REPO_ROOT);
|
|
4
|
+
const platform = isGitPod ? "gitpod" : process.platform;
|
|
5
|
+
switch (platform) {
|
|
6
|
+
case "android":
|
|
7
|
+
case "linux":
|
|
8
|
+
return ["xdg-open"];
|
|
9
|
+
case "darwin":
|
|
10
|
+
return ["open"];
|
|
11
|
+
case "win32":
|
|
12
|
+
return ["cmd", ["/c", "start"]];
|
|
13
|
+
case "gitpod":
|
|
14
|
+
return ["/ide/bin/remote-cli/gitpod-code", ["--openExternal"]];
|
|
15
|
+
default:
|
|
16
|
+
throw new Error(`It looks like your platform ("${platform}") isn't supported!
|
|
17
|
+
To view Astro's docs, please visit https://docs.astro.build`);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
async function openInBrowser(url) {
|
|
21
|
+
const [command, args = []] = getPlatformSpecificCommand();
|
|
22
|
+
return execa(command, [...args, encodeURI(url)]);
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
openInBrowser
|
|
26
|
+
};
|
package/dist/core/build/index.js
CHANGED
package/dist/core/config.js
CHANGED
|
@@ -22,7 +22,7 @@ import path from "path";
|
|
|
22
22
|
import { pathToFileURL, fileURLToPath } from "url";
|
|
23
23
|
import { mergeConfig as mergeViteConfig } from "vite";
|
|
24
24
|
import { z } from "zod";
|
|
25
|
-
import load from "@proload/core";
|
|
25
|
+
import load, { ProloadError } from "@proload/core";
|
|
26
26
|
import loadTypeScript from "@proload/plugin-tsm";
|
|
27
27
|
import postcssrc from "postcss-load-config";
|
|
28
28
|
import { arraify, isObject } from "./util.js";
|
|
@@ -224,9 +224,21 @@ async function loadConfig(configOptions) {
|
|
|
224
224
|
let userConfigPath;
|
|
225
225
|
if (flags == null ? void 0 : flags.config) {
|
|
226
226
|
userConfigPath = /^\.*\//.test(flags.config) ? flags.config : `./${flags.config}`;
|
|
227
|
-
userConfigPath = fileURLToPath(new URL(userConfigPath, pathToFileURL(root)));
|
|
227
|
+
userConfigPath = fileURLToPath(new URL(userConfigPath, appendForwardSlash(pathToFileURL(root).toString())));
|
|
228
|
+
}
|
|
229
|
+
let config;
|
|
230
|
+
try {
|
|
231
|
+
config = await load("astro", {
|
|
232
|
+
mustExist: !!userConfigPath,
|
|
233
|
+
cwd: root,
|
|
234
|
+
filePath: userConfigPath
|
|
235
|
+
});
|
|
236
|
+
} catch (err) {
|
|
237
|
+
if (err instanceof ProloadError && flags.config) {
|
|
238
|
+
throw new Error(`Unable to resolve --config "${flags.config}"! Does the file exist?`);
|
|
239
|
+
}
|
|
240
|
+
throw err;
|
|
228
241
|
}
|
|
229
|
-
const config = await load("astro", { mustExist: false, cwd: root, filePath: userConfigPath });
|
|
230
242
|
if (config) {
|
|
231
243
|
userConfig = config.value;
|
|
232
244
|
}
|
package/dist/core/dev/index.js
CHANGED
|
@@ -36,7 +36,7 @@ async function dev(config, options = { logging: nodeLogOptions }) {
|
|
|
36
36
|
site,
|
|
37
37
|
https: !!((_a = viteConfig.server) == null ? void 0 : _a.https)
|
|
38
38
|
}));
|
|
39
|
-
const currentVersion = "1.0.0-beta.
|
|
39
|
+
const currentVersion = "1.0.0-beta.4";
|
|
40
40
|
if (currentVersion.includes("-")) {
|
|
41
41
|
warn(options.logging, null, msg.prerelease({ currentVersion }));
|
|
42
42
|
}
|
package/dist/core/messages.js
CHANGED
|
@@ -45,7 +45,7 @@ function devStart({
|
|
|
45
45
|
https,
|
|
46
46
|
site
|
|
47
47
|
}) {
|
|
48
|
-
const version = "1.0.0-beta.
|
|
48
|
+
const version = "1.0.0-beta.4";
|
|
49
49
|
const rootPath = site ? site.pathname : "/";
|
|
50
50
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
51
51
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
@@ -170,7 +170,7 @@ function printHelp({
|
|
|
170
170
|
};
|
|
171
171
|
let message = [];
|
|
172
172
|
if (headline) {
|
|
173
|
-
message.push(linebreak(), ` ${bgGreen(black(` ${commandName} `))} ${green(`v${"1.0.0-beta.
|
|
173
|
+
message.push(linebreak(), ` ${bgGreen(black(` ${commandName} `))} ${green(`v${"1.0.0-beta.4"}`)} ${headline}`);
|
|
174
174
|
}
|
|
175
175
|
if (usage) {
|
|
176
176
|
message.push(linebreak(), ` ${green(commandName)} ${bold(usage)}`);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
function createRouteData(pattern, params, component, pathname, type) {
|
|
1
|
+
function createRouteData(pattern, params, component, pathname, type, segments) {
|
|
2
2
|
return {
|
|
3
3
|
type,
|
|
4
4
|
pattern,
|
|
5
5
|
params,
|
|
6
6
|
component,
|
|
7
7
|
generate: () => "",
|
|
8
|
-
pathname: pathname || void 0
|
|
8
|
+
pathname: pathname || void 0,
|
|
9
|
+
segments
|
|
9
10
|
};
|
|
10
11
|
}
|
|
11
12
|
function serializeRouteData(routeData) {
|
|
@@ -14,9 +15,9 @@ function serializeRouteData(routeData) {
|
|
|
14
15
|
return outRouteData;
|
|
15
16
|
}
|
|
16
17
|
function deserializeRouteData(rawRouteData) {
|
|
17
|
-
const { component, params, pathname, type } = rawRouteData;
|
|
18
|
+
const { component, params, pathname, type, segments } = rawRouteData;
|
|
18
19
|
const pattern = new RegExp(rawRouteData.pattern);
|
|
19
|
-
return createRouteData(pattern, params, component, pathname, type);
|
|
20
|
+
return createRouteData(pattern, params, component, pathname, type, segments);
|
|
20
21
|
}
|
|
21
22
|
export {
|
|
22
23
|
deserializeRouteData,
|
|
@@ -16,6 +16,7 @@ var __spreadValues = (a, b) => {
|
|
|
16
16
|
};
|
|
17
17
|
import { mergeConfig } from "../core/config.js";
|
|
18
18
|
import ssgAdapter from "../adapter-ssg/index.js";
|
|
19
|
+
import { isBuildingToSSR } from "../core/util.js";
|
|
19
20
|
async function runHookConfigSetup({
|
|
20
21
|
config: _config,
|
|
21
22
|
command
|
|
@@ -120,14 +121,16 @@ async function runHookBuildSetup({
|
|
|
120
121
|
}
|
|
121
122
|
async function runHookBuildDone({
|
|
122
123
|
config,
|
|
124
|
+
buildConfig,
|
|
123
125
|
pages,
|
|
124
126
|
routes
|
|
125
127
|
}) {
|
|
128
|
+
const dir = isBuildingToSSR(config) ? buildConfig.client : config.outDir;
|
|
126
129
|
for (const integration of config.integrations) {
|
|
127
130
|
if (integration.hooks["astro:build:done"]) {
|
|
128
131
|
await integration.hooks["astro:build:done"]({
|
|
129
132
|
pages: pages.map((p) => ({ pathname: p })),
|
|
130
|
-
dir
|
|
133
|
+
dir,
|
|
131
134
|
routes
|
|
132
135
|
});
|
|
133
136
|
}
|
|
@@ -724,12 +724,18 @@ export interface AstroIntegration {
|
|
|
724
724
|
};
|
|
725
725
|
}
|
|
726
726
|
export declare type RouteType = 'page' | 'endpoint';
|
|
727
|
+
export interface RoutePart {
|
|
728
|
+
content: string;
|
|
729
|
+
dynamic: boolean;
|
|
730
|
+
spread: boolean;
|
|
731
|
+
}
|
|
727
732
|
export interface RouteData {
|
|
728
733
|
component: string;
|
|
729
734
|
generate: (data?: any) => string;
|
|
730
735
|
params: string[];
|
|
731
736
|
pathname?: string;
|
|
732
737
|
pattern: RegExp;
|
|
738
|
+
segments: RoutePart[][];
|
|
733
739
|
type: RouteType;
|
|
734
740
|
}
|
|
735
741
|
export declare type SerializedRouteData = Omit<RouteData, 'generate' | 'pattern'> & {
|
|
@@ -30,8 +30,9 @@ export declare function runHookBuildSetup({ config, vite, target, }: {
|
|
|
30
30
|
vite: ViteConfigWithSSR;
|
|
31
31
|
target: 'server' | 'client';
|
|
32
32
|
}): Promise<void>;
|
|
33
|
-
export declare function runHookBuildDone({ config, pages, routes, }: {
|
|
33
|
+
export declare function runHookBuildDone({ config, buildConfig, pages, routes, }: {
|
|
34
34
|
config: AstroConfig;
|
|
35
|
+
buildConfig: BuildConfig;
|
|
35
36
|
pages: string[];
|
|
36
37
|
routes: RouteData[];
|
|
37
38
|
}): Promise<void>;
|