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

remove leading "$" character from bash commands #99

Closed
wants to merge 4 commits into from
Closed
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
41 changes: 28 additions & 13 deletions docs/01-get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This page should give you an understanding of how a Serverpod project is structu
Create a new project by running `serverpod create`.

```bash
$ serverpod create mypod
serverpod create mypod
```

:::info
Expand All @@ -24,9 +24,15 @@ This command will create a new directory called `mypod`, with three dart package
Make sure that [Docker Desktop](https://www.docker.com/products/docker-desktop/) is running, then start your Docker containers with `docker compose up --build --detach`. It will start Postgres and Redis. Then, run `dart bin/main.dart --apply-migrations` to start your server.

```bash
$ cd mypod/mypod_server
$ docker compose up --build --detach
$ dart bin/main.dart --apply-migrations
cd mypod/mypod_server
```

```bash
docker compose up --build --detach
```

```bash
dart bin/main.dart --apply-migrations
```

If everything is working, you should see something like this on your terminal:
Expand Down Expand Up @@ -54,8 +60,11 @@ In your development environment it can be helpful to always start Serverpod with
Start the default demo app by changing the directory into the Flutter package that was created and running `flutter run`.

```bash
$ cd mypod/mypod_flutter
$ flutter run -d chrome
cd mypod/mypod_flutter
```

```bash
flutter run -d chrome
```

The flag `-d chrome` runs the app in Chrome, for other run options please see the Flutter documentation.
Expand All @@ -81,8 +90,11 @@ Both the `endpoints` and `models` directories contain sample files that give a q
Whenever you change your code in either the `endpoints` or `models` directory, you will need to regenerate the classes managed by Serverpod. Do this by running `serverpod generate`.

```bash
$ cd mypod/mypod_server
$ serverpod generate
cd mypod/mypod_server
```

```bash
serverpod generate
```

### Working with endpoints
Expand Down Expand Up @@ -165,17 +177,20 @@ development:
With database migrations, Serverpod makes it easy to evolve your database schema. When you make changes to your project that should be reflected in your database, you need to create a migration. A migration is a set of SQL queries that are run to update the database. To create a migration, run `serverpod create-migration` in the home directory of the server.

```bash
$ cd mypod/mypod_server
$ serverpod create-migration
cd mypod/mypod_server
```

```bash
serverpod create-migration
```

Migrations are then applied to the database as part of the server startup by adding the `--apply-migrations` flag.

```bash
$ cd mypod/mypod_server
$ dart bin/main.dart --apply-migrations
```bash
dart bin/main.dart --apply-migrations
```


:::tip

To learn more about database migrations, see the [Migrations](concepts/database/migrations) section.
Expand Down
43 changes: 29 additions & 14 deletions docs/03-tutorials/01-first-app.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,21 @@ Demo of what we will build: ([Full code example](https://github.com/serverpod/no
Create a new project using the Serverpod CLI. Run the following command in your terminal:

```bash
$ serverpod create notes
serverpod create notes
```

To start the server:

```bash
$ cd notes/notes_server
$ docker compose up --build --detach
$ dart bin/main.dart --apply-migrations
cd notes/notes_server
```

```bash
docker compose up --build --detach
```

```bash
dart bin/main.dart --apply-migrations
```

:::info
Expand Down Expand Up @@ -69,7 +75,7 @@ Let's take a closer look at the content of the `note.yaml` file:
Use the code generator to generate the code for the `Note` class from the definition in `note.yaml`. Run the following command from the root of your server project (`notes_server`):

```bash
$ serverpod generate
serverpod generate
```

After the code generation process is complete, you can access the generated code for the `Note` class in `lib/src/generated/note.dart` inside your Serverpod project.
Expand Down Expand Up @@ -98,7 +104,7 @@ fields:
Run the code generator again to generate the necessary code used to access the database table:

```bash
$ serverpod generate
serverpod generate
```

Take a look at the updated `lib/src/generated/note.dart` file. You will notice that the code generator has added new methods for interacting with the database.
Expand All @@ -107,7 +113,7 @@ Take a look at the updated `lib/src/generated/note.dart` file. You will notice t
To create the new `note` table in the database we will use the Serverpod migration system. Run the following command to generate a new database migration:

```bash
$ serverpod create-migration
serverpod create-migration
```

This creates a new migration that contains a description of the database schema and SQL code to add the table. These files can be found in the `migrations` directory in your server project (`notes_server`).
Expand All @@ -117,7 +123,7 @@ This creates a new migration that contains a description of the database schema
To apply the database migration, start the server with the `--apply-migrations` command. We can also run the server in maintenance mode which will shut down the server as soon as its tasks are done.

```bash
$ dart run bin/main.dart --role maintenance --apply-migrations
dart run bin/main.dart --role maintenance --apply-migrations
```

Once command has executed successfully, the database table for storing the note data will have been created.
Expand Down Expand Up @@ -237,7 +243,7 @@ Congratulations! You have now created all the endpoints needed for the notes app
Now run the code generator again to generate the client library for our endpoints. This needs to be run from the server directory `notes_server`.

```bash
$ serverpod generate
serverpod generate
```

You can find the newly generated code in the client directory `notes_client`. You normally don't need to touch this package, but it's good to know where it is located.
Expand Down Expand Up @@ -752,16 +758,25 @@ Start the database and server:
Make sure you reboot the server if you started it earlier.

```bash
$ cd notes_server
$ docker compose up --build --detach
$ dart bin/main.dart --apply-migrations
cd notes_server
```

```bash
docker compose up --build --detach
```

```bash
dart bin/main.dart --apply-migrations
```

Start the Flutter app in Chrome (or the platform of your choice):

```bash
$ cd notes_flutter
$ flutter run -d chrome
cd notes_flutter
```

```bash
flutter run -d chrome
```

<ReactPlayer playing={true} loop controls width="960px" height="720px" url='/img/tutorial/note-app/03-note-create.mp4' />
Expand Down
6 changes: 3 additions & 3 deletions docs/05-concepts/06-database/01-connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ A newly created Serverpod project comes with a preconfigured docker instance wit
:::

```bash
$ docker compose up --build --detach
docker compose up --build --detach
```

To remove the database run (this commands preserve all data).

```bash
$ docker compose down
docker compose down
```

To remove the database and __delete__ all data add the `-v` flag.

```bash
$ docker compose down -v
docker compose down -v
```

24 changes: 12 additions & 12 deletions docs/05-concepts/06-database/11-migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ If you want to transition a manually managed table to then be managed by Serverp
To create a migration navigate to your project's `server` package directory and run the `create-migration` command.

```bash
$ serverpod create-migration
serverpod create-migration
```

The command reads the database schema from the last migration, then compares it to the database schema necessary to accommodate the projects, and any module dependencies, current database requirements. If differences are identified, a new migration is created in the `migrations` directory to roll the database forward.
Expand All @@ -44,15 +44,15 @@ The migration command aborts and displays an error under two conditions:
To override these safeguards and force the creation of a migration, use the `--force` flag.

```bash
$ serverpod create-migration --force
serverpod create-migration --force
```

### Tag migration

Tags can be useful to identify migrations that introduced specific changes to the project. Tags are appended to the migration name and can be added with the `--tag` option.

```bash
$ serverpod create-migration --tag "v1-0-0"
serverpod create-migration --tag "v1-0-0"
```

This would create a migration named `<timestamp>-v1-0-0`:
Expand Down Expand Up @@ -93,14 +93,14 @@ For each migration, five files are created:
Migrations are applied using the server runtime. To apply migrations, navigate to your project's `server` package directory, then start the server with the `--apply-migrations` flag. Migrations are applied as part of the startup sequence and the framework asserts that each migration is only applied once to the database.

```bash
$ dart run bin/main.dart --apply-migrations
dart run bin/main.dart --apply-migrations
```

Migrations can also be applied using the maintenance role. In maintenance, after migrations are applied, the server exits with an exit code indicating if migrations were successfully applied, zero for success or non-zero for failure.


```bash
$ dart run bin/main.dart --role maintenance --apply-migrations
dart run bin/main.dart --role maintenance --apply-migrations
```

This is useful if migrations are applied as part of an automated process.
Expand All @@ -116,7 +116,7 @@ By default, the command connects to and pulls a live database schema from a runn
To create a repair migration, navigate to your project's `server` package directory and run the `create-repair-migration` command.

```bash
$ serverpod create-repair-migration
serverpod create-repair-migration
```

This creates a repair migration in the `repair-migration` directory targeting the project's latest migration.
Expand All @@ -133,7 +133,7 @@ Since each repair migration is created for a specific live database schema, Serv
By default, the repair migration system connects to your `development` database using the information specified in your Serverpod config. To use a different database source, the `--mode` option is used.

```bash
$ serverpod create-repair-migration --mode production
serverpod create-repair-migration --mode production
```

The command connects and pulls the live database schema from a running server.
Expand All @@ -142,7 +142,7 @@ The command connects and pulls the live database schema from a running server.
Repair migrations can also target a specific migration version by specifying the migration name with the `--version` option.

```bash
$ serverpod create-repair-migration --version 20230821135718-v1-0-0
serverpod create-repair-migration --version 20230821135718-v1-0-0
```

This makes it possible to revert your database schema back to any older migration version.
Expand All @@ -155,14 +155,14 @@ The repair migration command aborts and displays an error under two conditions:
To override these safeguards and force the creation of a repair migration, use the `--force` flag.

```bash
$ serverpod create-repair-migration --force
serverpod create-repair-migration --force
```

### Tag repair migration
Repair migrations can be tagged just like regular migrations. Tags are appended to the migration name and can be added with the `--tag` option.

```bash
$ serverpod create-repair-migration --tag "reset-migrations"
serverpod create-repair-migration --tag "reset-migrations"
```

This would create a repair migration named `<timestamp>-reset-migrations` in the `repair` directory:
Expand All @@ -185,14 +185,14 @@ The `repair` directory only exists if a repair migration has been created and co
The repair migration is applied using the server runtime. To apply a repair migration, start the server with the `--apply-repair-migration` flag. The repair migration is applied as part of the startup sequence and the framework asserts that each repair migration is only applied once to the database.

```bash
$ dart run bin/main.dart --apply-repair-migration
dart run bin/main.dart --apply-repair-migration
```

The repair migration can also be applied using the maintenance role. In maintenance, after migrations are applied, the server exits with an exit code indicating if migrations were successfully applied, zero for success or non-zero for failure.


```bash
$ dart run bin/main.dart --role maintenance --apply-repair-migration
dart run bin/main.dart --role maintenance --apply-repair-migration
```

If a repair migration is applied at the same time as migrations, the repair migration is applied first.
Expand Down
18 changes: 12 additions & 6 deletions docs/05-concepts/09-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,21 @@ modules:
Then run `pub get` and `serverpod generate` from your server's directory (e.g., `mypod_server`) to add the module to your project's deserializer.

```bash
$ dart pub get
$ serverpod generate
dart pub get
```

```bash
serverpod generate
```

Finally, since modules might include modifications to the database schema, you should create a new database migration and apply it by running `serverpod create-migration` then `dart bin/main.dart --apply-migrations` from your server's directory.

```bash
$ serverpod create-migration
$ dart bin/main.dart --apply-migrations
serverpod create-migration
```

```bash
dart bin/main.dart --apply-migrations
```

### Client setup
Expand Down Expand Up @@ -81,13 +87,13 @@ fields:
With the `serverpod create` command, it is possible to create new modules for code that is shared between projects or that you want to publish to pub.dev. To create a module instead of a server project, pass `module` to the `--template` flag.

```bash
$ serverpod create --template module my_module
serverpod create --template module my_module
```

The create command will create a server and a client Dart package. If you also want to add custom Flutter code, use `flutter create` to create a package.

```bash
$ flutter create --template package my_module_flutter
flutter create --template package my_module_flutter
```

In your Flutter package, you most likely want to import the client libraries created by `serverpod create`.
Expand Down
6 changes: 3 additions & 3 deletions docs/05-concepts/10-authentication/01-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ modules:
After adding the module to the server project, you need to initialize the database. First you have to create a new migration that includes the auth module tables. This is done by running the `serverpod create-migration` command line tool in the server project.

```bash
$ serverpod create-migration
serverpod create-migration
```


Start your database container from the server project.

```bash
$ docker-compose up --build --detach
docker-compose up --build --detach
```

Then apply the migration by starting the server with the `apply-migration` flag.

```bash
$ dart run bin/main.dart --role maintenance --apply-migrations
dart run bin/main.dart --role maintenance --apply-migrations
```

The full migration instructions can be found in the [migration guide](../database/migrations).
Expand Down
4 changes: 2 additions & 2 deletions docs/05-concepts/10-authentication/04-providers/02-google.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Put the file inside the `android/app/` directory and rename it to `google-servic
For a production app you need to get the SHA-1 key from your production keystore! This can be done by running this command: ([Read more](https://support.google.com/cloud/answer/6158849#installedapplications&android&zippy=%2Cnative-applications%2Candroid)).

```bash
$ keytool -list -v -keystore /path/to/keystore
keytool -list -v -keystore /path/to/keystore
```

:::
Expand All @@ -134,7 +134,7 @@ Navigate to _Credentials_ under _APIs & Services_ and select the server credenti
Force flutter to run on a specific port by running.

```bash
$ flutter run -d chrome --web-port=49660
flutter run -d chrome --web-port=49660
```

:::
Expand Down
Loading
Loading