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

feat(cli): prepare command #774

Merged
merged 2 commits into from
Dec 21, 2022
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
1 change: 0 additions & 1 deletion docs/content/1.guide/1.introduction/0.getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ npx nitropack dev

**Tip:** Check `.nitro/dev/index.mjs` if want to know what is happening


You can now build your production-ready server:

```bash
Expand Down
8 changes: 6 additions & 2 deletions docs/content/1.guide/1.introduction/2.auto-imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ description: You might be surprised why in the documentation there are no import

This is because Nitro is integrated with [unjs/unimport](https://github.com/unjs/unimport) and automatically imports utilities by usage with full tree-shaking support!

## Available auto imports
## Available Auto Imports

Check [the source code](https://github.com/unjs/nitro/blob/main/src/imports.ts) for list of available auto imports.

With [Typescript](/guide/introduction/typescript) enabled, you can easily see them as global utilities in your IDE.
With [TypeScript](/guide/introduction/typescript) enabled, you can easily see them as global utilities in your IDE.

::alert{type="info"}
Run `npx nitropack prepare` to generate the types for global auto-imports.
::

## Manual Imports

Expand Down
2 changes: 2 additions & 0 deletions docs/content/1.guide/1.introduction/7.typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ To add type hints within your project, you should add the following to your `tsc
"extends": "./.nitro/types/tsconfig.json"
}
```

Run `npx nitropack prepare` to generate the types for global auto-imports. This can be useful in a CI environment or as a `postinstall` command in your `package.json`.
1 change: 0 additions & 1 deletion docs/content/2.deploy/providers/cloudflare.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ description: 'Discover Cloudflare preset for Nitro!'

**Preset:** `cloudflare` ([switch to this preset](/deploy/#changing-the-deployment-preset))


::alert{type="info"}
**Note:** This preset uses [service-worker syntax](https://developers.cloudflare.com/workers/learning/service-worker/) for deployment.
::
Expand Down
8 changes: 7 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import mri from "mri";
import { resolve } from "pathe";
import { createNitro } from "./nitro";
import { build, prepare, copyPublicAssets } from "./build";
import { build, prepare, copyPublicAssets, writeTypes } from "./build";
import { prerender } from "./prerender";
import { createDevServer } from "./dev/server";

Expand All @@ -12,6 +12,12 @@ async function main() {
const command = args._[0];
const rootDir = resolve(args._[1] || ".");

if (command === "prepare") {
const nitro = await createNitro({ rootDir });
await writeTypes(nitro);
return;
}

if (command === "dev") {
const nitro = await createNitro({
rootDir,
Expand Down