Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Sullivan authored Oct 20, 2022
2 parents f730b48 + 863391f commit 01c72fd
Show file tree
Hide file tree
Showing 54 changed files with 371 additions and 129 deletions.
2 changes: 1 addition & 1 deletion examples/basics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.5.1"
"astro": "^1.5.2"
}
}
2 changes: 1 addition & 1 deletion examples/blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.5.1",
"astro": "^1.5.2",
"@astrojs/mdx": "^0.11.4",
"@astrojs/rss": "^1.0.2",
"@astrojs/sitemap": "^1.0.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
],
"scripts": {},
"devDependencies": {
"astro": "^1.5.1"
"astro": "^1.5.2"
},
"peerDependencies": {
"astro": "^1.5.1"
"astro": "^1.5.2"
}
}
2 changes: 1 addition & 1 deletion examples/deno/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.5.1"
"astro": "^1.5.2"
},
"devDependencies": {
"@astrojs/deno": "^1.2.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.5.1",
"astro": "^1.5.2",
"preact": "^10.7.3",
"react": "^18.1.0",
"react-dom": "^18.1.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/docs/src/components/Header/LanguageSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const LanguageSelect: FunctionComponent<{ lang: string }> = ({ lang }) => {
{Object.entries(KNOWN_LANGUAGES).map(([key, value]) => {
return (
<option value={value} key={value}>
<span>{key}</span>
{key}
</option>
);
})}
Expand Down
2 changes: 1 addition & 1 deletion examples/framework-alpine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.5.1",
"astro": "^1.5.2",
"alpinejs": "^3.10.2",
"@astrojs/alpinejs": "^0.1.2",
"@types/alpinejs": "^3.7.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/framework-lit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.5.1",
"astro": "^1.5.2",
"lit": "^2.2.5",
"@astrojs/lit": "^1.0.0",
"@webcomponents/template-shadowroot": "^0.1.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/framework-multiple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.5.1",
"astro": "^1.5.2",
"preact": "^10.7.3",
"react": "^18.1.0",
"react-dom": "^18.1.0",
Expand All @@ -22,6 +22,6 @@
"@astrojs/react": "^1.2.1",
"@astrojs/solid-js": "^1.2.1",
"@astrojs/svelte": "^1.0.2",
"@astrojs/vue": "^1.2.0"
"@astrojs/vue": "^1.2.1"
}
}
2 changes: 1 addition & 1 deletion examples/framework-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.5.1",
"astro": "^1.5.2",
"preact": "^10.7.3",
"@astrojs/preact": "^1.2.0",
"@preact/signals": "^1.1.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/framework-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.5.1",
"astro": "^1.5.2",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"@astrojs/react": "^1.2.1",
Expand Down
2 changes: 1 addition & 1 deletion examples/framework-solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.5.1",
"astro": "^1.5.2",
"solid-js": "^1.4.3",
"@astrojs/solid-js": "^1.2.1"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/framework-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"dependencies": {
"svelte": "^3.48.0",
"@astrojs/svelte": "^1.0.2",
"astro": "^1.5.1"
"astro": "^1.5.2"
}
}
4 changes: 2 additions & 2 deletions examples/framework-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.5.1",
"astro": "^1.5.2",
"vue": "^3.2.37",
"@astrojs/vue": "^1.2.0"
"@astrojs/vue": "^1.2.1"
}
}
4 changes: 2 additions & 2 deletions examples/integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
],
"scripts": {},
"devDependencies": {
"astro": "^1.5.1"
"astro": "^1.5.2"
},
"peerDependencies": {
"astro": "^1.5.1"
"astro": "^1.5.2"
}
}
2 changes: 1 addition & 1 deletion examples/minimal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.5.1"
"astro": "^1.5.2"
}
}
2 changes: 1 addition & 1 deletion examples/non-html-pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.5.1"
"astro": "^1.5.2"
}
}
2 changes: 1 addition & 1 deletion examples/portfolio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.5.1"
"astro": "^1.5.2"
}
}
2 changes: 1 addition & 1 deletion examples/ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"server": "node dist/server/entry.mjs"
},
"dependencies": {
"astro": "^1.5.1",
"astro": "^1.5.2",
"svelte": "^3.48.0",
"@astrojs/svelte": "^1.0.2",
"@astrojs/node": "^2.0.1",
Expand Down
2 changes: 1 addition & 1 deletion examples/with-markdown-plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.5.1",
"astro": "^1.5.2",
"@astrojs/markdown-remark": "^1.1.3",
"hast-util-select": "5.0.1",
"rehype-autolink-headings": "^6.1.1",
Expand Down
2 changes: 1 addition & 1 deletion examples/with-markdown-shiki/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.5.1"
"astro": "^1.5.2"
}
}
2 changes: 1 addition & 1 deletion examples/with-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.5.1",
"astro": "^1.5.2",
"preact": "^10.6.5",
"@astrojs/preact": "^1.2.0",
"@astrojs/mdx": "^0.11.4"
Expand Down
2 changes: 1 addition & 1 deletion examples/with-nanostores/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.5.1",
"astro": "^1.5.2",
"preact": "^10.7.3",
"@astrojs/preact": "^1.2.0",
"nanostores": "^0.5.12",
Expand Down
2 changes: 1 addition & 1 deletion examples/with-tailwindcss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@astrojs/mdx": "^0.11.4",
"@astrojs/tailwind": "^2.1.1",
"@types/canvas-confetti": "^1.4.3",
"astro": "^1.5.1",
"astro": "^1.5.2",
"autoprefixer": "^10.4.7",
"canvas-confetti": "^1.5.1",
"postcss": "^8.4.14",
Expand Down
2 changes: 1 addition & 1 deletion examples/with-vite-plugin-pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.5.1",
"astro": "^1.5.2",
"vite-plugin-pwa": "0.11.11",
"workbox-window": "^6.5.3"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/with-vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"test": "vitest"
},
"dependencies": {
"astro": "^1.5.1",
"astro": "^1.5.2",
"vitest": "^0.20.3"
}
}
10 changes: 10 additions & 0 deletions packages/astro/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# astro

## 1.5.2

### Patch Changes

- [#5119](https://github.com/withastro/astro/pull/5119) [`430e0346c`](https://github.com/withastro/astro/commit/430e0346c9dc0def8af93e0a393dc2847e145d2f) Thanks [@bluwy](https://github.com/bluwy)! - Use `fs.promises.rm` to remove node deprecation warning

- [#5123](https://github.com/withastro/astro/pull/5123) [`9745009ae`](https://github.com/withastro/astro/commit/9745009ae0e7fe8691c75657c5c9586a548bf2e0) Thanks [@matthewp](https://github.com/matthewp)! - Fixes index page with build.format=file

- [#5116](https://github.com/withastro/astro/pull/5116) [`500acb3c1`](https://github.com/withastro/astro/commit/500acb3c117070ee5838a8b567e9bdcf68703227) Thanks [@matthewp](https://github.com/matthewp)! - Throws when using Response.redirect in SSG mode

## 1.5.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "astro",
"version": "1.5.1",
"version": "1.5.2",
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
"type": "module",
"author": "withastro",
Expand Down
3 changes: 2 additions & 1 deletion packages/astro/src/core/build/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export function getOutFolder(
return new URL('.' + appendForwardSlash(pathname), outRoot);
}
case 'file': {
return new URL('.' + appendForwardSlash(npath.dirname(pathname)), outRoot);
const d = pathname === '' ? pathname : npath.dirname(pathname);
return new URL('.' + appendForwardSlash(d), outRoot);
}
}
}
Expand Down
29 changes: 0 additions & 29 deletions packages/astro/src/core/build/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,6 @@ import { eachPageData, getPageDataByComponent, sortedCSS } from './internal.js';
import type { PageBuildData, SingleFileBuiltModule, StaticBuildOptions } from './types';
import { getTimeStat } from './util.js';

// Render is usually compute, which Node.js can't parallelize well.
// In real world testing, dropping from 10->1 showed a notiable perf
// improvement. In the future, we can revisit a smarter parallel
// system, possibly one that parallelizes if async IO is detected.
const MAX_CONCURRENT_RENDERS = 1;

// Throttle the rendering a paths to prevents creating too many Promises on the microtask queue.
function* throttle(max: number, inPaths: string[]) {
let tmp = [];
let i = 0;
for (let path of inPaths) {
tmp.push(path);
if (i === max) {
yield tmp;
// Empties the array, to avoid allocating a new one.
tmp.length = 0;
i = 0;
} else {
i++;
}
}

// If tmp has items in it, that means there were less than {max} paths remaining
// at the end, so we need to yield these too.
if (tmp.length) {
yield tmp;
}
}

function shouldSkipDraft(pageModule: ComponentInstance, settings: AstroSettings): boolean {
return (
// Drafts are disabled
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/static-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ async function cleanSsrOutput(opts: StaticBuildOptions) {
const url = new URL(filename, out);
const folder = await fs.promises.readdir(url);
if (!folder.length) {
await fs.promises.rmdir(url, { recursive: true });
await fs.promises.rm(url, { recursive: true, force: true });
}
})
);
Expand Down
16 changes: 15 additions & 1 deletion packages/astro/src/vite-plugin-astro-server/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type http from 'http';
import mime from 'mime';
import type * as vite from 'vite';
import type { AstroSettings, ManifestData } from '../@types/astro';
import type { AstroConfig, AstroSettings, ManifestData } from '../@types/astro';
import { DevelopmentEnvironment, SSROptions } from '../core/render/dev/index';

import { Readable } from 'stream';
Expand Down Expand Up @@ -296,6 +296,18 @@ async function handleRequest(
}
}

function isRedirect(statusCode: number) {
return statusCode >= 300 && statusCode < 400;
}

function throwIfRedirectNotAllowed(response: Response, config: AstroConfig) {
if (config.output !== 'server' && isRedirect(response.status)) {
throw new Error(
`Redirects are only available when using output: 'server'. Update your Astro config if you need SSR features.`
);
}
}

async function handleRoute(
matchedRoute: AsyncReturnType<typeof matchRoute>,
url: URL,
Expand Down Expand Up @@ -367,6 +379,7 @@ async function handleRoute(
res
);
}
throwIfRedirectNotAllowed(result.response, config);
await writeWebResponse(res, result.response);
} else {
let contentType = 'text/plain';
Expand All @@ -389,6 +402,7 @@ async function handleRoute(
}
} else {
const result = await renderPage(options);
throwIfRedirectNotAllowed(result, config);
return await writeSSRResult(result, res);
}
}
Expand Down
6 changes: 5 additions & 1 deletion packages/astro/test/dev-routing.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { expect } from 'chai';
import * as cheerio from 'cheerio';
import { loadFixture } from './test-utils.js';

describe('Development Routing', () => {
Expand Down Expand Up @@ -42,6 +41,11 @@ describe('Development Routing', () => {
const response = await fixture.fetch('/2');
expect(response.status).to.equal(404);
});

it('500 when redirecting in SSG mode', async () => {
const response = await fixture.fetch('/redirect');
expect(response.status).to.equal(500);
});
});

describe('No subpath used', () => {
Expand Down
Loading

0 comments on commit 01c72fd

Please sign in to comment.