From 503bdc384fdb60df5819d37e62d1a7ea51753780 Mon Sep 17 00:00:00 2001
From: Marvin Hagemeister
Date: Sat, 10 Jun 2023 15:48:02 +0200
Subject: [PATCH] feat(init): make directory argument optional (#1263)
---
README.md | 18 ++++++++++++++----
docs/getting-started/create-a-project.md | 4 ++--
init.ts | 17 +++++++++++------
www/routes/index.tsx | 2 +-
www/routes/update.tsx | 2 +-
5 files changed, 29 insertions(+), 14 deletions(-)
diff --git a/README.md b/README.md
index 5b577df7..281019db 100644
--- a/README.md
+++ b/README.md
@@ -28,10 +28,10 @@ The [documentation](https://fresh.deno.dev/docs/) is available on
Install [Deno CLI](https://deno.land/) version 1.25.0 or higher.
You can scaffold a new project by running the Fresh init script. To scaffold a
-project in the `deno-fresh-demo` folder, run the following:
+project run the following:
```sh
-deno run -A -r https://fresh.deno.dev deno-fresh-demo
+deno run -A -r https://fresh.deno.dev
```
Then navigate to the newly created project folder:
@@ -90,7 +90,12 @@ preferably with source code on GitHub, but not required.
```html
-
+
```
@@ -102,6 +107,11 @@ preferably with source code on GitHub, but not required.
```html
-
+
```
diff --git a/docs/getting-started/create-a-project.md b/docs/getting-started/create-a-project.md
index ee24aa01..30e998f5 100644
--- a/docs/getting-started/create-a-project.md
+++ b/docs/getting-started/create-a-project.md
@@ -10,8 +10,8 @@ will scaffold out a new project with some example files to get you started.
To create a new project, run:
```
-deno run -A -r https://fresh.deno.dev deno-fresh-demo
-cd deno-fresh-demo
+deno run -A -r https://fresh.deno.dev
+cd fresh-project
deno task start
```
diff --git a/init.ts b/init.ts
index 106fd346..f59cdf22 100644
--- a/init.ts
+++ b/init.ts
@@ -21,7 +21,7 @@ To generate a project in the current directory:
fresh-init .
USAGE:
- fresh-init
+ fresh-init [DIRECTORY]
OPTIONS:
--force Overwrite existing files
@@ -42,17 +42,22 @@ const flags = parse(Deno.args, {
default: { "force": null, "twind": null, "vscode": null },
});
-if (flags._.length !== 1) {
- error(help);
-}
-
console.log(
`\n%c 🍋 Fresh: the next-gen web framework. %c\n`,
"background-color: #86efac; color: black; font-weight: bold",
"",
);
-const unresolvedDirectory = Deno.args[0];
+let unresolvedDirectory = Deno.args[0];
+if (flags._.length !== 1) {
+ const userInput = prompt("Projet Name", "fresh-project");
+ if (!userInput) {
+ error(help);
+ }
+
+ unresolvedDirectory = userInput;
+}
+
const resolvedDirectory = resolve(unresolvedDirectory);
try {
diff --git a/www/routes/index.tsx b/www/routes/index.tsx
index 7c17a636..c84683cd 100644
--- a/www/routes/index.tsx
+++ b/www/routes/index.tsx
@@ -212,7 +212,7 @@ function GettingStarted(props: { origin: string }) {
- {`deno run -A -r ${props.origin} deno-fresh-demo`}
+ {`deno run -A -r ${props.origin}`}
diff --git a/www/routes/update.tsx b/www/routes/update.tsx
index 2c6726a7..eb0900de 100644
--- a/www/routes/update.tsx
+++ b/www/routes/update.tsx
@@ -199,7 +199,7 @@ function GettingStarted(props: { origin: string }) {
- {`deno run -A -r ${props.origin} deno-fresh-demo`}
+ {`deno run -A -r ${props.origin}`}