readme
This commit is contained in:
+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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user