Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci] update lockfile #10234

Merged
merged 6 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@
"@babel/plugin-transform-react-jsx": "^7.22.5",
"@babel/traverse": "^7.23.3",
"@babel/types": "^7.23.3",
"@shikijs/core": "^1.1.2",
"@types/babel__core": "^7.20.4",
"acorn": "^8.11.2",
"aria-query": "^5.3.0",
Expand Down Expand Up @@ -155,7 +154,6 @@
"js-yaml": "^4.1.0",
"kleur": "^4.1.4",
"magic-string": "^0.30.3",
"mdast-util-to-hast": "13.0.2",
"mime": "^3.0.0",
"ora": "^7.0.1",
"p-limit": "^5.0.0",
Expand Down
1 change: 0 additions & 1 deletion packages/astro/src/cli/preferences/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { bgGreen, black, bold, dim, yellow } from 'kleur/colors';

import { formatWithOptions } from 'node:util';
import dlv from 'dlv';
// @ts-expect-error flattie types are mispackaged
import { flattie } from 'flattie';
import { resolveConfig } from '../../core/config/config.js';
import { createSettings } from '../../core/config/settings.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export async function generateLookupMap({
message: AstroErrorData.DuplicateContentEntrySlugError.message(
collection,
slug,
lookupMap[collection]!.entries[slug],
lookupMap[collection].entries[slug],
rootRelativePath(root, filePath)
),
hint:
Expand Down
2 changes: 2 additions & 0 deletions packages/astro/src/core/build/static-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ export async function staticBuild(
settings.timer.end('Server generate');
return;
}
default:
return;
}
}

Expand Down
51 changes: 36 additions & 15 deletions packages/astro/src/core/config/schema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {
RehypePlugin,
RemarkPlugin,
RemarkRehype,
RehypePlugin as _RehypePlugin,
RemarkPlugin as _RemarkPlugin,
RemarkRehype as _RemarkRehype,
ShikiConfig,
} from '@astrojs/markdown-remark';
import { markdownConfigDefaults } from '@astrojs/markdown-remark';
Expand All @@ -11,17 +11,39 @@ import type { AstroUserConfig, ViteUserConfig } from '../../@types/astro.js';
import type { OutgoingHttpHeaders } from 'node:http';
import path from 'node:path';
import { pathToFileURL } from 'node:url';
import { type TypeOf, z } from 'zod';
import { z } from 'zod';
import { appendForwardSlash, prependForwardSlash, removeTrailingForwardSlash } from '../path.js';

// These imports are required to appease TypeScript!
// See https://github.com/withastro/astro/pull/8762
import '@shikijs/core';
import 'mdast-util-to-hast';
// The below types are required boilerplate to workaround a Zod issue since v3.21.2. Since that version,
// Zod's compiled TypeScript would "simplify" certain values to their base representation, causing references
// to transitive dependencies that Astro don't depend on (e.g. `mdast-util-to-hast` or `remark-rehype`). For example:
//
// ```ts
// // input
// type Foo = { bar: string };
// export const value: Foo;
//
// // output
// export const value: { bar: string }; // <-- `Foo` is gone
// ```
//
// The types below will "complexify" the types so that TypeScript would not simplify them. This way it will
// reference the complex type directly, instead of referencing non-existent transitive dependencies.
//
// Also, make sure to not index the complexified type, as it would return a simplified value type, which goes
// back to the issue again. The complexified type should be the base representation that we want to expose.

type ShikiLangs = NonNullable<ShikiConfig['langs']>;
type ShikiTheme = NonNullable<ShikiConfig['theme']>;
type ShikiTransformers = NonNullable<ShikiConfig['transformers']>;
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface ComplexifyUnionObj {}
type ComplexifyWithUnion<T> = T & ComplexifyUnionObj;
type ComplexifyWithOmit<T> = Omit<T, '__nonExistent'>;

type ShikiLang = ComplexifyWithUnion<NonNullable<ShikiConfig['langs']>[number]>;
type ShikiTheme = ComplexifyWithUnion<NonNullable<ShikiConfig['theme']>>;
type ShikiTransformer = ComplexifyWithUnion<NonNullable<ShikiConfig['transformers']>[number]>;
type RehypePlugin = ComplexifyWithUnion<_RehypePlugin>;
type RemarkPlugin = ComplexifyWithUnion<_RemarkPlugin>;
type RemarkRehype = ComplexifyWithOmit<_RemarkRehype>;

const ASTRO_CONFIG_DEFAULTS = {
root: '.',
Expand Down Expand Up @@ -263,7 +285,7 @@ export const AstroConfigSchema = z.object({
shikiConfig: z
.object({
langs: z
.custom<ShikiLangs[number]>()
.custom<ShikiLang>()
.array()
.transform((langs) => {
for (const lang of langs) {
Expand Down Expand Up @@ -295,7 +317,7 @@ export const AstroConfigSchema = z.object({
.default(ASTRO_CONFIG_DEFAULTS.markdown.shikiConfig.themes!),
wrap: z.boolean().or(z.null()).default(ASTRO_CONFIG_DEFAULTS.markdown.shikiConfig.wrap!),
transformers: z
.custom<ShikiTransformers[number]>()
.custom<ShikiTransformer>()
.array()
.transform((transformers) => {
for (const transformer of transformers) {
Expand Down Expand Up @@ -331,7 +353,6 @@ export const AstroConfigSchema = z.object({
.default(ASTRO_CONFIG_DEFAULTS.markdown.rehypePlugins),
remarkRehype: z
.custom<RemarkRehype>((data) => data instanceof Object && !Array.isArray(data))
.optional()
.default(ASTRO_CONFIG_DEFAULTS.markdown.remarkRehype),
gfm: z.boolean().default(ASTRO_CONFIG_DEFAULTS.markdown.gfm),
smartypants: z.boolean().default(ASTRO_CONFIG_DEFAULTS.markdown.smartypants),
Expand Down Expand Up @@ -384,7 +405,7 @@ export const AstroConfigSchema = z.object({
.optional()
.superRefine((i18n, ctx) => {
if (i18n) {
const { defaultLocale, locales: _locales, fallback, domains, routing } = i18n;
const { defaultLocale, locales: _locales, fallback, domains } = i18n;
const locales = _locales.map((locale) => {
if (typeof locale === 'string') {
return locale;
Expand Down
2 changes: 2 additions & 0 deletions packages/astro/src/runtime/server/jsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ let originalConsoleError: any;
let consoleFilterRefs = 0;

export async function renderJSX(result: SSRResult, vnode: any): Promise<any> {
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
switch (true) {
case vnode instanceof HTMLString:
if (vnode.toString().trim() === '') {
Expand Down Expand Up @@ -72,6 +73,7 @@ export async function renderJSX(result: SSRResult, vnode: any): Promise<any> {

async function renderJSXVNode(result: SSRResult, vnode: AstroVNode, skip: Skip): Promise<any> {
if (isVNode(vnode)) {
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
switch (true) {
case !vnode.type: {
throw new Error(`Unable to render ${result.pathname} because it contains an undefined Component!
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/test/astro-markdown-plugins.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('Astro Markdown plugins', () => {

const smartypantsHtml = await fixture.readFile('/with-smartypants/index.html');
const $2 = cheerio.load(smartypantsHtml);
assert.equal($2('p').html(), 'Smartypants” is — awesome');
assert.equal($2('p').html(), 'Smartypants” is — awesome');

testRemark(gfmHtml);
testRehype(gfmHtml, '#github-flavored-markdown-test');
Expand All @@ -82,7 +82,7 @@ describe('Astro Markdown plugins', () => {
const $ = cheerio.load(html);

// test 1: smartypants applied correctly
assert.equal($('p').html(), 'Smartypants” is — awesome');
assert.equal($('p').html(), 'Smartypants” is — awesome');

testRemark(html);
testRehype(html, '#smartypants-test');
Expand Down
4 changes: 2 additions & 2 deletions packages/integrations/mdx/test/mdx-plugins.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('MDX plugins', () => {

const quote = selectSmartypantsQuote(document);
assert.notEqual(quote, null);
assert.equal(quote.textContent.includes('Smartypants” is — awesome'), true);
assert.equal(quote.textContent.includes('Smartypants” is — awesome'), true);
});

it('supports custom rehype plugins', async () => {
Expand Down Expand Up @@ -174,7 +174,7 @@ describe('MDX plugins', () => {
);
} else {
assert.equal(
quote.textContent.includes('Smartypants” is — awesome'),
quote.textContent.includes('Smartypants” is — awesome'),
true,
'Respects `markdown.smartypants` unexpectedly.'
);
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/mdx/test/mdx-vite-env-vars.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('MDX - Vite env vars', () => {
assert.equal(
document
.querySelector('[data-env-variable-exports-unknown]')
?.innerHTML.includes('exports: ””'), // NOTE: these double quotes are special unicode quotes emitted in the HTML file
?.innerHTML.includes('exports: ""'),
true
);
});
Expand Down
Loading
Loading