astro 0.21.11 → 0.22.2
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/README.md +1 -1
- package/astro.js +64 -64
- package/components/Code.astro +34 -34
- package/components/Debug.astro +44 -43
- package/components/Markdown.astro +20 -15
- package/components/Prism.astro +20 -23
- package/dist/cli/check.js +1 -1
- package/dist/cli/index.js +22 -19
- package/dist/core/build/index.js +38 -129
- package/dist/core/build/internal.js +19 -0
- package/dist/core/build/page-data.js +92 -0
- package/dist/core/build/scan-based-build.js +50 -0
- package/dist/core/build/static-build.js +226 -0
- package/dist/core/config.js +3 -2
- package/dist/core/create-vite.js +3 -5
- package/dist/core/dev/index.js +9 -5
- package/dist/core/dev/messages.js +1 -1
- package/dist/core/dev/template/4xx.js +1 -1
- package/dist/core/dev/template/5xx.js +1 -1
- package/dist/core/dev/util.js +1 -1
- package/dist/core/logger.js +1 -1
- package/dist/core/preview/index.js +2 -3
- package/dist/core/ssr/css.js +1 -2
- package/dist/core/ssr/html.js +1 -1
- package/dist/core/ssr/index.js +44 -44
- package/dist/core/ssr/paginate.js +1 -1
- package/dist/core/ssr/result.js +72 -0
- package/dist/core/ssr/routing.js +1 -1
- package/dist/core/ssr/rss.js +4 -4
- package/dist/core/ssr/sitemap.js +1 -1
- package/dist/core/util.js +1 -1
- package/dist/runtime/client/hmr.js +1 -1
- package/dist/runtime/client/idle.js +1 -1
- package/dist/runtime/client/load.js +1 -1
- package/dist/runtime/client/media.js +1 -1
- package/dist/runtime/client/only.js +1 -1
- package/dist/runtime/client/visible.js +1 -1
- package/dist/runtime/server/hydration.js +8 -5
- package/dist/runtime/server/index.js +6 -5
- package/dist/runtime/server/metadata.js +34 -17
- package/dist/runtime/server/util.js +11 -1
- package/dist/types/@types/astro.d.ts +3 -0
- package/dist/types/cli/index.d.ts +1 -1
- package/dist/types/core/build/internal.d.ts +14 -0
- package/dist/types/core/build/page-data.d.ts +17 -0
- package/dist/types/core/build/scan-based-build.d.ts +16 -0
- package/dist/types/core/build/static-build.d.ts +16 -0
- package/dist/types/core/config.d.ts +5 -0
- package/dist/types/core/dev/index.d.ts +13 -12
- package/dist/types/core/ssr/index.d.ts +8 -1
- package/dist/types/core/ssr/result.d.ts +9 -0
- package/dist/types/runtime/server/hydration.d.ts +2 -1
- package/dist/types/runtime/server/metadata.d.ts +20 -9
- package/dist/types/runtime/server/util.d.ts +6 -0
- package/dist/types/vite-plugin-astro/compile.d.ts +5 -0
- package/dist/types/vite-plugin-astro/index.d.ts +3 -1
- package/dist/types/vite-plugin-astro/query.d.ts +12 -0
- package/dist/types/vite-plugin-build-css/index.d.ts +2 -5
- package/dist/types/vite-plugin-build-html/index.d.ts +2 -5
- package/dist/vite-plugin-astro/compile.js +93 -0
- package/dist/vite-plugin-astro/index.js +66 -66
- package/dist/vite-plugin-astro/query.js +24 -0
- package/dist/vite-plugin-astro/styles.js +1 -1
- package/dist/vite-plugin-astro-postprocess/index.js +1 -1
- package/dist/vite-plugin-build-css/index.js +26 -22
- package/dist/vite-plugin-build-css/resolve.js +1 -1
- package/dist/vite-plugin-build-html/add-rollup-input.js +1 -1
- package/dist/vite-plugin-build-html/extract-assets.js +1 -1
- package/dist/vite-plugin-build-html/index.js +13 -14
- package/dist/vite-plugin-build-html/util.js +1 -1
- package/dist/vite-plugin-config-alias/index.js +1 -1
- package/dist/vite-plugin-fetch/index.js +1 -1
- package/dist/vite-plugin-jsx/index.js +1 -1
- package/dist/vite-plugin-markdown/index.js +4 -1
- package/package.json +21 -19
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ You can sponsor Astro's development on [Open Collective][oc]. Astro is generousl
|
|
|
44
44
|
<table>
|
|
45
45
|
<tbody>
|
|
46
46
|
<tr>
|
|
47
|
-
<td align="center"><a href="https://sentry.io" target="_blank"><img width="147" height="40" src="https://raw.githubusercontent.com/withastro/astro/main/.github/assets/sentry.svg" alt="Sentry" /></a></td>
|
|
47
|
+
<td align="center"><a href="https://sentry.io" target="_blank"><img width="147" height="40" src="https://raw.githubusercontent.com/withastro/astro/main/.github/assets/sentry.svg" alt="Sentry" /></a></td><td align="center"><a href="https://qoddi.com" target="_blank"><img width="147" height="40" src="https://devcenter.qoddi.com/wp-content/uploads/2021/11/blog-transparent-logo-1.png" alt="Qoddi App Platform" /></a></td>
|
|
48
48
|
</tr>
|
|
49
49
|
</tbody>
|
|
50
50
|
</table>
|
package/astro.js
CHANGED
|
@@ -8,86 +8,86 @@
|
|
|
8
8
|
// Needed for Stackblitz: https://github.com/stackblitz/webcontainer-core/issues/281
|
|
9
9
|
|
|
10
10
|
const CI_INSTRUCTIONS = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
NETLIFY: 'https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript',
|
|
12
|
+
GITHUB_ACTIONS: 'https://docs.github.com/en/actions/guides/building-and-testing-nodejs#specifying-the-nodejs-version',
|
|
13
|
+
VERCEL: 'https://vercel.com/docs/runtimes#official-runtimes/node-js/node-js-version',
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
/** `astro *` */
|
|
17
17
|
async function main() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
// Check for ESM support.
|
|
19
|
+
// Load the "supports-esm" package in an way that works in both ESM & CJS.
|
|
20
|
+
let supportsESM = typeof require !== 'undefined' ? require('supports-esm') : (await import('supports-esm')).default;
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
// Check for CJS->ESM named export support.
|
|
23
|
+
// "path-to-regexp" is a real-world package that we depend on, that only
|
|
24
|
+
// works in later versions of Node with advanced CJS->ESM support.
|
|
25
|
+
// If `import {compile} from 'path-to-regexp'` will fail, we need to know.
|
|
26
|
+
if (supportsESM) {
|
|
27
|
+
const testNamedExportsModule = await import('path-to-regexp');
|
|
28
|
+
supportsESM = !!testNamedExportsModule.compile;
|
|
29
|
+
}
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
// Preflight check complete. Enjoy! ✨
|
|
32
|
+
if (supportsESM) {
|
|
33
|
+
return import('./dist/cli/index.js')
|
|
34
|
+
.then(({ cli }) => cli(process.argv))
|
|
35
|
+
.catch((error) => {
|
|
36
|
+
console.error(error);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
const version = process.versions.node;
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
Please upgrade to a version of Node.js with complete ESM support: "^
|
|
50
|
-
|
|
43
|
+
// Not supported (incomplete ESM): It's very difficult (impossible?) to load the
|
|
44
|
+
// dependencies below in an unknown module type. If `require` is undefined, then this file
|
|
45
|
+
// actually was run as ESM but one of the ESM preflight checks above failed. In that case,
|
|
46
|
+
// it's okay to hard-code the valid Node versions here since they will not change over time.
|
|
47
|
+
if (typeof require === 'undefined') {
|
|
48
|
+
console.error(`\nNode.js v${version} is not supported by Astro!
|
|
49
|
+
Please upgrade to a version of Node.js with complete ESM support: "^14.15.0 || >=16.0.0"\n`);
|
|
50
|
+
}
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
// Not supported: Report the most helpful error message possible.
|
|
53
|
+
const pkg = require('./package.json');
|
|
54
|
+
const ci = require('ci-info');
|
|
55
|
+
const semver = require('semver');
|
|
56
|
+
const engines = pkg.engines.node;
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
// TODO: Remove "semver" in Astro v1.0: This is mainly just to check our work. Once run in
|
|
59
|
+
// the wild for a bit without error, we can assume our engine range is correct and won't
|
|
60
|
+
// change over time.
|
|
61
|
+
const isSupported = semver.satisfies(version, engines);
|
|
62
|
+
if (isSupported) {
|
|
63
|
+
console.error(`\nNode.js v${version} is not supported by Astro!
|
|
64
64
|
Supported versions: ${engines}\n
|
|
65
65
|
Issue Detected! This Node.js version was expected to work, but failed a system check.
|
|
66
66
|
Please file an issue so that we can take a look: https://github.com/withastro/astro/issues/new\n`);
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
} else {
|
|
68
|
+
console.error(`\nNode.js v${version} is not supported by Astro!
|
|
69
69
|
Please upgrade Node.js to a supported version: "${engines}"\n`);
|
|
70
|
-
|
|
70
|
+
}
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
72
|
+
// Special instructions for CI environments, which may have special steps needed.
|
|
73
|
+
// This is a common issue that we can help users with proactively.
|
|
74
|
+
if (ci.isCI) {
|
|
75
|
+
let platform;
|
|
76
|
+
for (const [key, value] of Object.entries(ci)) {
|
|
77
|
+
if (value === true) {
|
|
78
|
+
platform = key;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
console.log(`${ci.name} CI Environment Detected!\nAdditional steps may be needed to set your Node.js version:`);
|
|
83
|
+
console.log(`Documentation: https://docs.astro.build/guides/deploy`);
|
|
84
|
+
if (CI_INSTRUCTIONS[platform]) {
|
|
85
|
+
console.log(`${ci.name} Documentation: ${CI_INSTRUCTIONS[platform]}`);
|
|
86
|
+
}
|
|
87
|
+
console.log(``);
|
|
88
|
+
}
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
process.exit(1);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
main();
|
package/components/Code.astro
CHANGED
|
@@ -2,49 +2,49 @@
|
|
|
2
2
|
import shiki from 'shiki';
|
|
3
3
|
|
|
4
4
|
export interface Props {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
5
|
+
/** The code to highlight. Required. */
|
|
6
|
+
code: string;
|
|
7
|
+
/**
|
|
8
|
+
* The language of your code. Defaults to "plaintext".
|
|
9
|
+
* Supports all languages listed here: https://github.com/shikijs/shiki/blob/main/docs/themes.md
|
|
10
|
+
*/
|
|
11
|
+
lang?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The styling theme. Defaults to "github-dark".
|
|
14
|
+
* Supports all themes listed here: https://github.com/shikijs/shiki/blob/main/docs/themes.md
|
|
15
|
+
* Instructions for loading a custom theme: https://github.com/shikijs/shiki/blob/main/docs/themes.md#loading-theme
|
|
16
|
+
*/
|
|
17
|
+
theme?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Enable word wrapping. Defaults to "false".
|
|
20
|
+
* - true: enabled.
|
|
21
|
+
* - false: enabled.
|
|
22
|
+
* - null: All overflow styling removed. Code will overflow the element by default.
|
|
23
|
+
*/
|
|
24
|
+
wrap?: boolean | null;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const { code, lang = 'plaintext', theme = 'github-dark', wrap = false } = Astro.props;
|
|
28
28
|
|
|
29
29
|
/** Replace the shiki class name with a custom astro class name. */
|
|
30
30
|
function repairShikiTheme(html: string): string {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
// Replace "shiki" class naming with "astro".
|
|
32
|
+
html = html.replace('<pre class="shiki"', '<pre class="astro-code"');
|
|
33
|
+
// Replace "shiki" css variable naming with "astro".
|
|
34
|
+
html = html.replace(/style="(background-)?color: var\(--shiki-/g, 'style="$1color: var(--astro-code-');
|
|
35
|
+
// Handle code wrapping
|
|
36
|
+
// if wrap=null, do nothing.
|
|
37
|
+
if (wrap === false) {
|
|
38
|
+
html = html.replace(/style="(.*?)"/, 'style="$1; overflow-x: auto;"');
|
|
39
|
+
} else if (wrap === true) {
|
|
40
|
+
html = html.replace(/style="(.*?)"/, 'style="$1; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;"');
|
|
41
|
+
}
|
|
42
|
+
return html;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
const highlighter = await shiki.getHighlighter({theme});
|
|
45
|
+
const highlighter = await shiki.getHighlighter({ theme });
|
|
47
46
|
const _html = highlighter.codeToHtml(code, lang);
|
|
48
47
|
const html = repairShikiTheme(_html);
|
|
49
48
|
---
|
|
49
|
+
|
|
50
50
|
{html}
|
package/components/Debug.astro
CHANGED
|
@@ -6,51 +6,52 @@ const value = Astro.props[key];
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
<div class="debug">
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
<div class="debug-header">
|
|
10
|
+
<h2 class="debug-title"><span class="debug-label">Debug</span> <span class="debug-name">"{key}"</span></h2>
|
|
11
|
+
</div>
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
<Code code={JSON.stringify(value, null, 2)} />
|
|
14
14
|
</div>
|
|
15
15
|
|
|
16
16
|
<style>
|
|
17
|
-
.debug {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.debug-header,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
17
|
+
.debug {
|
|
18
|
+
font-size: 14px;
|
|
19
|
+
padding: 1rem 1.5rem;
|
|
20
|
+
background: white;
|
|
21
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.debug-header,
|
|
25
|
+
pre {
|
|
26
|
+
margin: -1rem -1.5rem 1rem;
|
|
27
|
+
padding: 0.25rem 0.75rem;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.debug-header {
|
|
31
|
+
background: #ff1639;
|
|
32
|
+
border-radius: 4px;
|
|
33
|
+
border-bottom-left-radius: 0;
|
|
34
|
+
border-bottom-right-radius: 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.debug-title {
|
|
38
|
+
font-size: 1em;
|
|
39
|
+
color: white;
|
|
40
|
+
margin: 0.5em 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.debug-label {
|
|
44
|
+
font-weight: bold;
|
|
45
|
+
text-transform: uppercase;
|
|
46
|
+
margin-right: 0.75em;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
pre {
|
|
50
|
+
border: 1px solid #eee;
|
|
51
|
+
padding: 1rem 0.75rem;
|
|
52
|
+
border-radius: 4px;
|
|
53
|
+
border-top-left-radius: 0;
|
|
54
|
+
border-top-right-radius: 0;
|
|
55
|
+
font-size: 14px;
|
|
56
|
+
}
|
|
56
57
|
</style>
|
|
@@ -1,39 +1,44 @@
|
|
|
1
1
|
---
|
|
2
2
|
export interface Props {
|
|
3
|
-
|
|
3
|
+
content?: string;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
const dedent = (str: string) =>
|
|
6
|
+
const dedent = (str: string) =>
|
|
7
|
+
str
|
|
8
|
+
.split('\n')
|
|
9
|
+
.map((ln) => ln.trimStart())
|
|
10
|
+
.join('\n');
|
|
7
11
|
|
|
8
12
|
// Internal props that should not be part of the external interface.
|
|
9
13
|
interface InternalProps extends Props {
|
|
10
|
-
|
|
14
|
+
$scope: string;
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
let { content, class: className } = Astro.props as InternalProps;
|
|
14
18
|
let html = null;
|
|
15
19
|
let htmlContent = '';
|
|
16
20
|
|
|
17
|
-
const { privateRenderMarkdownDoNotUse: renderMarkdown } =
|
|
21
|
+
const { privateRenderMarkdownDoNotUse: renderMarkdown } = Astro as any;
|
|
18
22
|
|
|
19
23
|
// If no content prop provided, use the slot.
|
|
20
24
|
if (!content) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const { privateRenderSlotDoNotUse: renderSlot } = Astro as any;
|
|
26
|
+
content = await renderSlot('default');
|
|
27
|
+
if (content !== undefined && content !== null) {
|
|
28
|
+
content = dedent(content);
|
|
29
|
+
}
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
if (content) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
htmlContent = await renderMarkdown(content, {
|
|
34
|
+
mode: 'md',
|
|
35
|
+
$: {
|
|
36
|
+
scopedClassName: className,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
html = htmlContent;
|
|
38
42
|
---
|
|
43
|
+
|
|
39
44
|
{html ? html : <slot />}
|
package/components/Prism.astro
CHANGED
|
@@ -4,49 +4,46 @@ import { addAstro } from '@astrojs/prism';
|
|
|
4
4
|
import loadLanguages from 'prismjs/components/index.js';
|
|
5
5
|
|
|
6
6
|
export interface Props {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
class?: string;
|
|
8
|
+
lang?: string;
|
|
9
|
+
code: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const { class: className, lang, code } = Astro.props as Props;
|
|
13
13
|
|
|
14
|
-
let classLanguage = `language-${lang}
|
|
14
|
+
let classLanguage = `language-${lang}`;
|
|
15
15
|
|
|
16
|
-
const languageMap = new Map([
|
|
17
|
-
['ts', 'typescript']
|
|
18
|
-
]);
|
|
16
|
+
const languageMap = new Map([['ts', 'typescript']]);
|
|
19
17
|
|
|
20
18
|
if (lang == null) {
|
|
21
|
-
|
|
19
|
+
console.warn('Prism.astro: No language provided.');
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
const ensureLoaded = lang => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
const ensureLoaded = (lang) => {
|
|
23
|
+
if (lang && !Prism.languages[lang]) {
|
|
24
|
+
loadLanguages([lang]);
|
|
25
|
+
}
|
|
28
26
|
};
|
|
29
27
|
|
|
30
|
-
if(languageMap.has(lang)) {
|
|
31
|
-
|
|
32
|
-
} else if(lang === 'astro') {
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
if (languageMap.has(lang)) {
|
|
29
|
+
ensureLoaded(languageMap.get(lang));
|
|
30
|
+
} else if (lang === 'astro') {
|
|
31
|
+
ensureLoaded('typescript');
|
|
32
|
+
addAstro(Prism);
|
|
35
33
|
} else {
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
ensureLoaded('markup-templating'); // Prism expects this to exist for a number of other langs
|
|
35
|
+
ensureLoaded(lang);
|
|
38
36
|
}
|
|
39
37
|
|
|
40
|
-
if(lang && !Prism.languages[lang]) {
|
|
41
|
-
|
|
38
|
+
if (lang && !Prism.languages[lang]) {
|
|
39
|
+
console.warn(`Unable to load the language: ${lang}`);
|
|
42
40
|
}
|
|
43
41
|
|
|
44
42
|
const grammar = Prism.languages[lang];
|
|
45
43
|
let html = code;
|
|
46
44
|
if (grammar) {
|
|
47
|
-
|
|
45
|
+
html = Prism.highlight(code, grammar, lang);
|
|
48
46
|
}
|
|
49
|
-
|
|
50
47
|
---
|
|
51
48
|
|
|
52
49
|
<pre class={[className, classLanguage].join(' ')}><code class={classLanguage}>{html}</code></pre>
|
package/dist/cli/check.js
CHANGED
|
@@ -91,4 +91,4 @@ export {
|
|
|
91
91
|
check,
|
|
92
92
|
run
|
|
93
93
|
};
|
|
94
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
94
|
+
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vc3JjL2NsaS9jaGVjay50cyJdLAogICJtYXBwaW5ncyI6ICJBQUNBO0FBR0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUVBLGdDQUFnQyxjQUFtQixtQkFBNkIsU0FBcUI7QUFDcEcsUUFBTSxRQUFRLE1BQU0sS0FBSyxjQUFjO0FBQUEsSUFDdEMsS0FBSyxhQUFhO0FBQUEsSUFDbEIsUUFBUSxDQUFDLG1CQUFtQixPQUFPLGtCQUFrQixJQUFJLENBQUMsV0FBVyxHQUFHO0FBQUE7QUFFekUsUUFBTSxlQUFlLE1BQU0sSUFBSSxDQUFDLE1BQU0sS0FBSyxRQUFRLGFBQWEsVUFBVTtBQUUxRSxhQUFXLGVBQWUsY0FBYztBQUN2QyxVQUFNLE9BQU8sR0FBRyxhQUFhLGFBQWE7QUFDMUMsWUFBUSxlQUFlO0FBQUEsTUFDdEIsS0FBSyxjQUFjLGFBQWE7QUFBQSxNQUNoQztBQUFBO0FBQUE7QUFBQTtBQVVILG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TUFBTSxFQUFFLE1BQU0sTUFBTSxNQUFNLFdBQVcsS0FBSyxLQUFLO0FBQzVFLGNBQUksWUFBWSxTQUFTLEVBQUUsTUFBTSxFQUFFLE1BQU0sTUFBTSxPQUFPLEdBQUcsV0FBVyxLQUFLLEtBQUs7QUFDOUUsY0FBSSxNQUFNLEtBQUssS0FBSyxVQUFVLGFBQWEsWUFBWTtBQUN2RCxnQkFBTSxhQUFhLEVBQUUsTUFBTSxNQUFNLEtBQUs7QUFDdEMsZ0JBQU0sYUFBYSxXQUFXO0FBQzlCLGtCQUFRLE1BQU0sR0FBRyxRQUFRLE1BQU0saUJBQWlCO0FBQ2hELGNBQUksU0FBUyxJQUFJLEtBQUssRUFBRSxNQUFNLElBQUksWUFBWSxFQUFFLE1BQU0sTUFBTTtBQUM1RCxjQUFJLFNBQVMsSUFBSSxLQUFLLEVBQUUsTUFBTSxNQUFNLFlBQVksYUFBYTtBQUM3RCxrQkFBUSxNQUFNLE1BQU0sU0FBUyxLQUFLLElBQUk7QUFBQTtBQUN0QyxpQkFBTztBQUNQO0FBQUE7QUFBQSxhQUVJLG1CQUFtQixTQUFTO0FBQ2hDLGlCQUFPO0FBQ1A7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQU1KLE1BQUksT0FBTyxRQUFRO0FBQ2xCLFlBQVEsTUFBTSxTQUFTLE9BQU87QUFBQTtBQUcvQixRQUFNLFdBQVcsT0FBTyxTQUFTLElBQUk7QUFDckMsU0FBTztBQUFBOyIsCiAgIm5hbWVzIjogW10KfQo=
|
package/dist/cli/index.js
CHANGED
|
@@ -31,7 +31,8 @@ function resolveArgs(flags) {
|
|
|
31
31
|
sitemap: typeof flags.sitemap === "boolean" ? flags.sitemap : void 0,
|
|
32
32
|
port: typeof flags.port === "number" ? flags.port : void 0,
|
|
33
33
|
config: typeof flags.config === "string" ? flags.config : void 0,
|
|
34
|
-
hostname: typeof flags.hostname === "string" ? flags.hostname : void 0
|
|
34
|
+
hostname: typeof flags.hostname === "string" ? flags.hostname : void 0,
|
|
35
|
+
experimentalStaticBuild: typeof flags.experimentalStaticBuild === "boolean" ? flags.experimentalStaticBuild : false
|
|
35
36
|
};
|
|
36
37
|
if (flags.version) {
|
|
37
38
|
return { cmd: "version", options };
|
|
@@ -53,7 +54,7 @@ function resolveArgs(flags) {
|
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
function printHelp() {
|
|
56
|
-
console.
|
|
57
|
+
console.log(` ${colors.bold("astro")} - Futuristic web development tool.
|
|
57
58
|
${colors.bold("Commands:")}
|
|
58
59
|
astro dev Run Astro in development mode.
|
|
59
60
|
astro build Build a pre-compiled production version of your site.
|
|
@@ -64,6 +65,7 @@ function printHelp() {
|
|
|
64
65
|
--config <path> Specify the path to the Astro config file.
|
|
65
66
|
--project-root <path> Specify the path to the project root folder.
|
|
66
67
|
--no-sitemap Disable sitemap generation (build only).
|
|
68
|
+
--experimental-static-build A more performant build that expects assets to be define statically.
|
|
67
69
|
--verbose Enable verbose logging
|
|
68
70
|
--silent Disable logging
|
|
69
71
|
--version Show the version number and exit.
|
|
@@ -71,8 +73,10 @@ function printHelp() {
|
|
|
71
73
|
`);
|
|
72
74
|
}
|
|
73
75
|
async function printVersion() {
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
+
const pkgURL = new URL("../../package.json", import.meta.url);
|
|
77
|
+
const pkg = JSON.parse(await fs.promises.readFile(pkgURL, "utf8"));
|
|
78
|
+
const pkgVersion = pkg.version;
|
|
79
|
+
console.log(pkgVersion);
|
|
76
80
|
}
|
|
77
81
|
function mergeCLIFlags(astroConfig, flags) {
|
|
78
82
|
if (typeof flags.sitemap === "boolean")
|
|
@@ -83,12 +87,22 @@ function mergeCLIFlags(astroConfig, flags) {
|
|
|
83
87
|
astroConfig.devOptions.port = flags.port;
|
|
84
88
|
if (typeof flags.hostname === "string")
|
|
85
89
|
astroConfig.devOptions.hostname = flags.hostname;
|
|
90
|
+
if (typeof flags.experimentalStaticBuild === "boolean")
|
|
91
|
+
astroConfig.buildOptions.experimentalStaticBuild = flags.experimentalStaticBuild;
|
|
86
92
|
}
|
|
87
93
|
async function cli(args) {
|
|
88
94
|
const flags = yargs(args);
|
|
89
95
|
const state = resolveArgs(flags);
|
|
90
96
|
const options = __spreadValues({}, state.options);
|
|
91
97
|
const projectRoot = options.projectRoot || flags._[3];
|
|
98
|
+
switch (state.cmd) {
|
|
99
|
+
case "help":
|
|
100
|
+
printHelp();
|
|
101
|
+
return process.exit(0);
|
|
102
|
+
case "version":
|
|
103
|
+
await printVersion();
|
|
104
|
+
return process.exit(0);
|
|
105
|
+
}
|
|
92
106
|
let logging = {
|
|
93
107
|
dest: defaultLogDestination,
|
|
94
108
|
level: "info"
|
|
@@ -103,26 +117,16 @@ async function cli(args) {
|
|
|
103
117
|
mergeCLIFlags(config, options);
|
|
104
118
|
} catch (err) {
|
|
105
119
|
if (err instanceof z.ZodError) {
|
|
106
|
-
console.
|
|
120
|
+
console.error(formatConfigError(err));
|
|
107
121
|
} else {
|
|
108
122
|
console.error(colors.red(err.toString() || err));
|
|
109
123
|
}
|
|
110
124
|
process.exit(1);
|
|
111
125
|
}
|
|
112
126
|
switch (state.cmd) {
|
|
113
|
-
case "help": {
|
|
114
|
-
printHelp();
|
|
115
|
-
process.exit(1);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
case "version": {
|
|
119
|
-
await printVersion();
|
|
120
|
-
process.exit(0);
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
127
|
case "dev": {
|
|
124
128
|
try {
|
|
125
|
-
|
|
129
|
+
await devServer(config, { logging });
|
|
126
130
|
await new Promise(() => {
|
|
127
131
|
});
|
|
128
132
|
} catch (err) {
|
|
@@ -141,8 +145,7 @@ async function cli(args) {
|
|
|
141
145
|
}
|
|
142
146
|
case "check": {
|
|
143
147
|
const ret = await check(config);
|
|
144
|
-
process.exit(ret);
|
|
145
|
-
return;
|
|
148
|
+
return process.exit(ret);
|
|
146
149
|
}
|
|
147
150
|
case "preview": {
|
|
148
151
|
try {
|
|
@@ -164,4 +167,4 @@ function throwAndExit(err) {
|
|
|
164
167
|
export {
|
|
165
168
|
cli
|
|
166
169
|
};
|
|
167
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
170
|
+
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vc3JjL2NsaS9pbmRleC50cyJdLAogICJtYXBwaW5ncyI6ICI7Ozs7Ozs7Ozs7Ozs7Ozs7QUFLQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQWtCQSxxQkFBcUIsT0FBNEI7QUFDaEQsUUFBTSxVQUErQjtBQUFBLElBQ3BDLGFBQWEsT0FBTyxNQUFNLGdCQUFnQixXQUFXLE1BQU0sY0FBYztBQUFBLElBQ3pFLE1BQU0sT0FBTyxNQUFNLFNBQVMsV0FBVyxNQUFNLE9BQU87QUFBQSxJQUNwRCxTQUFTLE9BQU8sTUFBTSxZQUFZLFlBQVksTUFBTSxVQUFVO0FBQUEsSUFDOUQsTUFBTSxPQUFPLE1BQU0sU0FBUyxXQUFXLE1BQU0sT0FBTztBQUFBLElBQ3BELFFBQVEsT0FBTyxNQUFNLFdBQVcsV0FBVyxNQUFNLFNBQVM7QUFBQSxJQUMxRCxVQUFVLE9BQU8sTUFBTSxhQUFhLFdBQVcsTUFBTSxXQUFXO0FBQUEsSUFDaEUseUJBQXlCLE9BQU8sTUFBTSw0QkFBNEIsWUFBWSxNQUFNLDBCQUEwQjtBQUFBO0FBRy9HLE1BQUksTUFBTSxTQUFTO0FBQ2xCLFdBQU8sRUFBRSxLQUFLLFdBQVc7QUFBQSxhQUNmLE1BQU0sTUFBTTtBQUN0QixXQUFPLEVBQUUsS0FBSyxRQUFRO0FBQUE7QUFHdkIsUUFBTSxNQUFNLE1BQU0sRUFBRTtBQUNwQixVQUFRO0FBQUEsU0FDRjtBQUNKL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