readme
This commit is contained in:
@@ -1,3 +1,50 @@
|
||||
# fresh
|
||||
|
||||
Preact, but super edgy.
|
||||
|
||||
Fresh is a web framework that lets you build projects very fast, highly dynamic,
|
||||
and without the need of a build step. Fresh embraces isomorphic JavaScript like
|
||||
never before. Write a JSX component, have it render on the edge just-in-time,
|
||||
and then enhance it with client side JS for great interactivity.
|
||||
|
||||
Fresh does not have a build step - you write your code, deploy it to
|
||||
[Deno Deploy](https://deno.com/deploy), and from there everything is handled by
|
||||
the framework.
|
||||
|
||||
- No build step
|
||||
- Zero config
|
||||
- JIT rendering on the edge
|
||||
- Tiny (example is 3KB of JS)
|
||||
- Client side hydration
|
||||
- TypeScript out of the box
|
||||
- File-system routing à la Next.js
|
||||
|
||||
## Install
|
||||
|
||||
To install, run the following command. This will add `fresh` CLI to your PATH.
|
||||
Make sure to have Deno 1.9.1 or later installed.
|
||||
|
||||
```sh
|
||||
deno install -A -f https://deno.land/x/fresh/cli.ts
|
||||
```
|
||||
|
||||
## Getting started
|
||||
|
||||
The `fresh` CLI can scaffold a new project for you. To scaffold a project in the
|
||||
`myproject` folder, run the following:
|
||||
|
||||
```sh
|
||||
fresh init myproject
|
||||
```
|
||||
|
||||
To now start the project, use [`deployctl`](https://deno.land/x/deploy):
|
||||
|
||||
```
|
||||
deployctl run --no-check --watch server.ts
|
||||
```
|
||||
|
||||
To deploy the script to [Deno Deploy](https://deno.com/deploy), push your
|
||||
project to GitHub, create a `fresh` project, and link it to `server.ts` file in
|
||||
the created repository.
|
||||
|
||||
To learn more about how to use `fresh`, visit the documentation.
|
||||
|
||||
@@ -35,7 +35,7 @@ switch (subcommand) {
|
||||
await initSubcommand(args);
|
||||
break;
|
||||
case "routes":
|
||||
await routesSubcommand();
|
||||
await routesSubcommand(args);
|
||||
break;
|
||||
default:
|
||||
if (args.version) {
|
||||
|
||||
+5
-2
@@ -1,5 +1,6 @@
|
||||
import { join } from "./deps.ts";
|
||||
import { error } from "./error.ts";
|
||||
import { routes } from "./routes.ts";
|
||||
|
||||
const help = `fresh init
|
||||
|
||||
@@ -10,10 +11,10 @@ To generate a project in the './foobar' subdirectory:
|
||||
fresh init ./foobar
|
||||
|
||||
To generate a project in the current directory:
|
||||
fresh init .
|
||||
fresh init .
|
||||
|
||||
USAGE:
|
||||
fresh init [OPTIONS] <DIRECTORY>
|
||||
fresh init [OPTIONS] <DIRECTORY>
|
||||
|
||||
OPTIONS:
|
||||
-h, --help Prints help information
|
||||
@@ -143,4 +144,6 @@ fresh routes
|
||||
join(directory, "README.md"),
|
||||
README_MD,
|
||||
);
|
||||
|
||||
await routes(directory);
|
||||
}
|
||||
|
||||
+38
-3
@@ -1,8 +1,43 @@
|
||||
import { join, toFileUrl, walk } from "./deps.ts";
|
||||
|
||||
export async function routesSubcommand() {
|
||||
const help = `fresh routes
|
||||
|
||||
Regenerate the route mapping for your fresh project.
|
||||
|
||||
To regenerate the mapping in the current directory:
|
||||
fresh routes
|
||||
|
||||
To regenerate the mapping in the './foobar' subdirectory:
|
||||
fresh routes ./foobar
|
||||
|
||||
USAGE:
|
||||
fresh routes [OPTIONS] [DIRECTORY]
|
||||
|
||||
OPTIONS:
|
||||
-h, --help Prints help information
|
||||
`;
|
||||
|
||||
export interface Args {
|
||||
help: boolean;
|
||||
}
|
||||
|
||||
export async function routesSubcommand(rawArgs: Record<string, any>) {
|
||||
const args: Args = {
|
||||
help: !!rawArgs.help,
|
||||
};
|
||||
const directory: string | null = typeof rawArgs._[0] === "string"
|
||||
? rawArgs._[0]
|
||||
: Deno.cwd();
|
||||
if (args.help) {
|
||||
console.log(help);
|
||||
Deno.exit(0);
|
||||
}
|
||||
await routes(directory);
|
||||
}
|
||||
|
||||
export async function routes(directory: string) {
|
||||
const files = [];
|
||||
const pagesDir = join(Deno.cwd(), "./pages");
|
||||
const pagesDir = join(Deno.cwd(), directory, "./pages");
|
||||
const pagesUrl = new URL(pagesDir, "file:///");
|
||||
const folder = walk(pagesDir, {
|
||||
includeDirs: false,
|
||||
@@ -30,5 +65,5 @@ setup([${
|
||||
}], import.meta.url);
|
||||
`;
|
||||
|
||||
await Deno.writeTextFile("./server.ts", output);
|
||||
await Deno.writeTextFile(join(directory, "./server.ts"), output);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ addEventListener("DOMContentLoaded", () => {
|
||||
write: false,
|
||||
bundle: true,
|
||||
minify: true,
|
||||
treeShaking: true,
|
||||
platform: "neutral",
|
||||
outfile: "",
|
||||
jsxFactory: "h",
|
||||
|
||||
@@ -14,6 +14,7 @@ globalThis.performance = {
|
||||
return new Date().getTime() - start;
|
||||
},
|
||||
};
|
||||
// @deno-types="https://unpkg.com/esbuild-wasm@0.11.19/esm/browser.d.ts"
|
||||
import * as esbuild from "https://gist.githubusercontent.com/lucacasonato/358c6b7e8198bfb2cf3d220e49fdcf5f/raw/3714cb0f59606eefc29ed0fea36d4cd93549938b/esbuild-wasm.js";
|
||||
export { esbuild };
|
||||
export { denoPlugin } from "https://raw.githubusercontent.com/lucacasonato/esbuild_deno_loader/fa2219c3df9494da6c33e3e4dffb1a33b5cc0345/mod.ts";
|
||||
|
||||
Reference in New Issue
Block a user