Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/upstream'
Browse files Browse the repository at this point in the history
  • Loading branch information
ikxin committed Jul 15, 2024
2 parents d621968 + e727afd commit 645daa3
Show file tree
Hide file tree
Showing 184 changed files with 364 additions and 1,069 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Create web servers that run anywhere! 📖 [**documentation**](https://nitro.unjs.io)

> [!NOTE]
> You are on the v2 branch. Check [main branch](https://github.com/unjs/nitro/tree/main) for v3 development tree.
> You are on the v3 development branch. Check [here](https://github.com/unjs/nitro/pull/2521/) for status.
## Contribution

Expand Down
14 changes: 7 additions & 7 deletions build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ export default defineBuildConfig({
{ input: "src/types/index.ts" },
],
alias: {
nitropack: "nitropack",
"nitropack/meta": resolve(srcDir, "../meta.ts"),
"nitropack/runtime/meta": resolve(srcDir, "../runtime-meta.mjs"),
nitro: "nitro",
"nitro/meta": resolve(srcDir, "../meta.ts"),
"nitro/runtime/meta": resolve(srcDir, "../runtime-meta.mjs"),
...Object.fromEntries(
subpaths.map((subpath) => [
`nitropack/${subpath}`,
`nitro/${subpath}`,
resolve(srcDir, `${subpath}/index.ts`),
])
),
Expand All @@ -63,9 +63,9 @@ export default defineBuildConfig({
},
},
externals: [
"nitropack",
"nitropack/runtime/meta",
...subpaths.map((subpath) => `nitropack/${subpath}`),
"nitro",
"nitro/runtime/meta",
...subpaths.map((subpath) => `nitro/${subpath}`),
"firebase-functions",
"@scalar/api-reference",
],
Expand Down
2 changes: 1 addition & 1 deletion docs/1.guide/9.plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default defineNitroPlugin((nitro) => {

### Available hooks

See the [source code](https://github.com/unjs/nitro/blob/main/src/runtime/types.ts#L24) for list of all available runtime hooks.
See the [source code](https://github.com/unjs/nitro/blob/main/src/types/runtime/nitro.ts#L46) for list of all available runtime hooks.

- `"close", () => {}`
- `"error", (error, { event? }) => {}`
Expand Down
2 changes: 1 addition & 1 deletion examples/graceful-shutdown/nitro.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { defineNitroConfig } from "nitropack/config";
import { defineNitroConfig } from "nitro/config";

export default defineNitroConfig({});
1 change: 1 addition & 0 deletions examples/renderer/api/hello.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default defineEventHandler(() => "Nitro is amazing!");
4 changes: 4 additions & 0 deletions examples/renderer/nitro.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default defineNitroConfig({
compatibilityDate: "2024-06-21",
renderer: "~/renderer",
});
11 changes: 11 additions & 0 deletions examples/renderer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "example-renderer",
"private": true,
"scripts": {
"dev": "nitro dev",
"build": "nitro build"
},
"devDependencies": {
"nitropack": "latest"
}
}
15 changes: 15 additions & 0 deletions examples/renderer/renderer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineRenderHandler } from "nitropack/runtime";

export default defineRenderHandler((_event) => {
return {
body: /* html */ `<!DOCTYPE html>
<html>
<head>
<title>Rendered Page</title>
</head>
<body>
<h1>Rendered by Nitro!</h1>
</body>
</html>`,
};
});
3 changes: 3 additions & 0 deletions examples/renderer/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./.nitro/types/tsconfig.json"
}
13 changes: 0 additions & 13 deletions patches/[email protected]

This file was deleted.

2 changes: 1 addition & 1 deletion playground/nitro.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineNitroConfig } from "nitropack/config";
import { defineNitroConfig } from "nitro/config";

export default defineNitroConfig({
compatibilityDate: "2024-06-12",
Expand Down
15 changes: 7 additions & 8 deletions scripts/gen-presets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { existsSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
import { resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { consola } from "consola";
import createJITI from "jiti";
import { createJiti } from "jiti";
import { findTypeExports } from "mlly";
import type { NitroPreset, NitroPresetMeta } from "nitropack/types";
import type { NitroPreset, NitroPresetMeta } from "nitro/types";
import { camelCase, kebabCase, pascalCase, snakeCase } from "scule";
import { subpaths } from "../build.config";

Expand All @@ -21,14 +21,13 @@ const presetDirs: string[] = readdirSync(presetsDir, { withFileTypes: true })
.map((dir) => dir.name);

// --- Load presets ---
const jitiRequire = createJITI(presetsDir, {
esmResolve: true,
const jiti = createJiti(presetsDir, {
interopDefault: true,
alias: {
nitropack: fileURLToPath(new URL("../src/core/index.ts", import.meta.url)),
nitro: fileURLToPath(new URL("../src/core/index.ts", import.meta.url)),
...Object.fromEntries(
subpaths.map((pkg) => [
`nitropack/${pkg}`,
`nitro/${pkg}`,
fileURLToPath(new URL(`../src/${pkg}/index.ts`, import.meta.url)),
])
),
Expand All @@ -37,7 +36,7 @@ const jitiRequire = createJITI(presetsDir, {
const allPresets: (NitroPreset & { _meta?: NitroPresetMeta })[] = [];
for (const preset of presetDirs) {
const presetPath = resolve(presetsDir, preset, "preset.ts");
const _presets = jitiRequire(presetPath);
const _presets = (await jiti.import(presetPath)) as NitroPreset[];
allPresets.push(..._presets);
}

Expand Down Expand Up @@ -91,7 +90,7 @@ writeFileSync(
${presetsWithType
.map(
(preset) =>
`import { PresetOptions as ${pascalCase(
`import type { PresetOptions as ${pascalCase(
preset
)}Options } from "./${preset}/preset";`
)
Expand Down
6 changes: 3 additions & 3 deletions scripts/release-nightly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set -xe
git restore -s@ -SW -- .

# Bump according to changelog
pnpm changelogen --bump
pnpm changelogen --bump -r 3.0.0-beta

# Bump versions to nightly
pnpm jiti ./scripts/bump-nightly
Expand All @@ -31,8 +31,8 @@ fi
# Release packages

echo "Publishing main package..."
npm publish --access public --tolerate-republish
npm publish --access public --tolerate-republish --tag 3x

echo "Publishing mirror package..."
cd .mirror
npm publish --access public --tolerate-republish
npm publish --access public --tolerate-republish --tag 3x
2 changes: 1 addition & 1 deletion src/cli/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
createNitro,
prepare,
prerender,
} from "nitropack/core";
} from "nitro/core";
import { resolve } from "pathe";
import { commonArgs } from "../common";

Expand Down
4 changes: 2 additions & 2 deletions src/cli/commands/dev.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { defineCommand } from "citty";
import { consola } from "consola";
import { getArgs, parseArgs } from "listhen/cli";
import { build, createDevServer, createNitro, prepare } from "nitropack/core";
import type { Nitro } from "nitropack/types";
import { build, createDevServer, createNitro, prepare } from "nitro/core";
import type { Nitro } from "nitro/types";
import { resolve } from "pathe";
import { commonArgs } from "../common";

Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/prepare.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineCommand } from "citty";
import { createNitro, writeTypes } from "nitropack/core";
import { createNitro, writeTypes } from "nitro/core";
import { resolve } from "pathe";
import { commonArgs } from "../common";

Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/task/list.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineCommand } from "citty";
import { consola } from "consola";
import { listTasks } from "nitropack/core";
import { listTasks } from "nitro/core";
import { resolve } from "pathe";

export default defineCommand({
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/task/run.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineCommand } from "citty";
import { consola } from "consola";
import destr from "destr";
import { runTask } from "nitropack/core";
import { runTask } from "nitro/core";
import { resolve } from "pathe";

export default defineCommand({
Expand Down
2 changes: 1 addition & 1 deletion src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node
import { defineCommand, runMain } from "citty";
import { version as nitroVersion } from "nitropack/meta";
import { version as nitroVersion } from "nitro/meta";

const main = defineCommand({
meta: {
Expand Down
4 changes: 2 additions & 2 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { NitroConfig } from "nitropack/types";
import type { NitroConfig } from "nitro/types";

export type { NitroConfig } from "nitropack/types";
export type { NitroConfig } from "nitro/types";

export function defineNitroConfig(config: NitroConfig): NitroConfig {
return config;
Expand Down
4 changes: 2 additions & 2 deletions src/core/build/assets.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { existsSync, promises as fsp } from "node:fs";
import { globby } from "globby";
import { isDirectory, prettyPath } from "nitropack/kit";
import type { Nitro } from "nitropack/types";
import { isDirectory, prettyPath } from "nitro/kit";
import type { Nitro } from "nitro/types";
import { join, relative, resolve } from "pathe";
import { compressPublicAssets } from "../utils/compress";

Expand Down
4 changes: 2 additions & 2 deletions src/core/build/build.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getRollupConfig } from "nitropack/rollup";
import type { Nitro } from "nitropack/types";
import { getRollupConfig } from "nitro/rollup";
import type { Nitro } from "nitro/types";
import { watchDev } from "./dev";
import { buildProduction } from "./prod";

Expand Down
2 changes: 1 addition & 1 deletion src/core/build/dev.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { watch } from "chokidar";
import defu from "defu";
import type { Nitro, RollupConfig } from "nitropack/types";
import type { Nitro, RollupConfig } from "nitro/types";
import { join } from "pathe";
import { debounce } from "perfect-debounce";
import * as rollup from "rollup";
Expand Down
2 changes: 1 addition & 1 deletion src/core/build/prepare.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fsp from "node:fs/promises";
import fse from "fs-extra";
import type { Nitro } from "nitropack";
import type { Nitro } from "nitro/types";

export async function prepare(nitro: Nitro) {
await prepareDir(nitro.options.output.dir);
Expand Down
6 changes: 3 additions & 3 deletions src/core/build/prod.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { promises as fsp } from "node:fs";
import { formatCompatibilityDate } from "compatx";
import { writeFile } from "nitropack/kit";
import { version as nitroVersion } from "nitropack/meta";
import type { Nitro, NitroBuildInfo, RollupConfig } from "nitropack/types";
import { writeFile } from "nitro/kit";
import { version as nitroVersion } from "nitro/meta";
import type { Nitro, NitroBuildInfo, RollupConfig } from "nitro/types";
import { dirname, join, relative, resolve } from "pathe";
import * as rollup from "rollup";
import { scanHandlers } from "../scan";
Expand Down
Loading

0 comments on commit 645daa3

Please sign in to comment.