diff --git a/README.md b/README.md index 308a3ad1..bef9b42c 100644 --- a/README.md +++ b/README.md @@ -40,10 +40,10 @@ The `fresh` CLI can scaffold a new project for you. To scaffold a project in the fresh init my-project ``` -To now start the project, call `deno run`: +To now start the project, use `deno task`: ``` -deno run -A --watch main.ts +deno task start ``` To deploy the script to [Deno Deploy](https://deno.com/deploy), push your diff --git a/docs/getting-started.md b/docs/getting-started.md index 96cbf4f3..89019af2 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -4,7 +4,7 @@ Welcome to the `fresh` documentation. ## Requirements -The documentation assumes you have Deno 1.12.0 or later installed. +The documentation assumes you have Deno 1.20.1 or later installed. To install Deno, follow the installation instructions in the manual: https://deno.land/manual/getting_started/installation @@ -45,11 +45,12 @@ To learn more about how projects are structured, take a look at the You can now run your new project locally using the `deno` CLI: ``` -deno run -A --watch main.ts +deno task start ``` -The `--watch` option will cause your script to be reloaded on any changes to the -source. If you do not want this you can omit the `--watch` option. +The `--watch` option in `start` task will cause your script to be reloaded on +any changes to the source. If you do not want this you can omit the `--watch` +option in `deno.json`. After you have started the project, you can view it in your browser at http://localhost:8000. You will first get served a JIT server rendered page, diff --git a/docs/getting-started/running-locally.md b/docs/getting-started/running-locally.md index d7a264b5..0ab72200 100644 --- a/docs/getting-started/running-locally.md +++ b/docs/getting-started/running-locally.md @@ -1,6 +1,14 @@ The next step after scaffolding out a new project, is to actually start it. To -do this you can just `deno run` the `main.ts` file with the appropriate flags. -You will need to provide permission flags for: +do this you can just `deno task start`. + +``` +$ deno task start +Watcher Process started. +Server listening on http://localhost:8000 +``` + +If you want to start manually without Deno task, `deno run` the `main.ts` with +the appropriate flags. You will need to provide permission flags for: - **`--allow-net`**: This is required to start the HTTP server. - **`--allow-read`**: This is required to read (static) files from disk. diff --git a/examples/counter/README.md b/examples/counter/README.md index 2e1dece7..314dc73c 100644 --- a/examples/counter/README.md +++ b/examples/counter/README.md @@ -5,7 +5,7 @@ Start the project: ``` -deno run -A --watch main.ts +deno task start ``` After adding, removing, or moving a page in the `routes` or directory, or diff --git a/examples/counter/deno.json b/examples/counter/deno.json new file mode 100644 index 00000000..d25f7104 --- /dev/null +++ b/examples/counter/deno.json @@ -0,0 +1,5 @@ +{ + "tasks": { + "start": "deno run -A --watch main.ts" + } +} diff --git a/src/cli/init.ts b/src/cli/init.ts index f1d730f2..64c58f14 100644 --- a/src/cli/init.ts +++ b/src/cli/init.ts @@ -186,6 +186,14 @@ await start(manifest); // this throws on windows } + const DENO_CONFIG = `{ + "tasks": { + "start": "deno run -A --watch main.ts" + } +}`; + + await Deno.writeTextFile(join(directory, "deno.json"), DENO_CONFIG); + const README_MD = `# fresh project ### Usage @@ -193,7 +201,7 @@ await start(manifest); Start the project: \`\`\` -deno run -A --watch main.ts +deno task start \`\`\` After adding, removing, or moving a page in the \`routes\` or directory, or adding, diff --git a/www/routes/index.tsx b/www/routes/index.tsx index 52107afb..0ef75858 100644 --- a/www/routes/index.tsx +++ b/www/routes/index.tsx @@ -153,7 +153,7 @@ function GettingStarted() { to start the development server:

-        deno run -A --watch main.ts
+        deno task start
       

You can now open{" "}