Skip to content

Commit 3fe95bb

Browse files
authored
Update README for CLI v4 beta (#26)
1 parent 7ebf3ee commit 3fe95bb

File tree

11 files changed

+52
-90
lines changed

11 files changed

+52
-90
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ jobs:
2424
run:
2525
npm install -g fauna-shell
2626
- name: Setup Test Database
27-
run: ./test/setup.sh
27+
run: ./scripts/setup.sh
2828

2929
- name: Test sample app
3030
run: |
3131
./gradlew build
3232
FAUNA_ENDPOINT=http://localhost:8443 FAUNA_SECRET=`cat .fauna_key` ./gradlew bootRun > bootrun.log 2>&1 &
33-
./test/validate.sh
34-
cat bootrun.log
33+
./scripts/validate.sh
34+
cat bootrun.log

README.md

Lines changed: 36 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,17 @@ To run the app, you'll need:
6666
- A [Fauna account](https://dashboard.fauna.com/register). You can sign up for a
6767
free account at https://dashboard.fauna.com/register.
6868

69-
- Your preferred flavor of Java 17
69+
- Your preferred flavor of Java 17.
7070

71-
- [Fauna CLI](https://docs.fauna.com/fauna/current/tools/shell/) v3.0.0 or later.
71+
- [Fauna CLI v4 beta](https://docs.fauna.com/fauna/current/build/cli/v4/) or later.
72+
- [Node.js](https://nodejs.org/en/download/) v20.x or later.
7273

7374
To install the CLI, run:
7475

7576
```sh
76-
npm install -g fauna-shell@latest
77+
npm install -g fauna-shell@">=4.0.0-beta"
7778
```
7879

79-
You should also be familiar with basic Fauna CLI commands and usage. For an
80-
overview, see the [Fauna CLI
81-
docs](https://docs.fauna.com/fauna/current/tools/shell/).
82-
83-
8480
## Setup
8581

8682
1. Clone the repo and navigate to the `java-sample-app` directory:
@@ -90,87 +86,69 @@ docs](https://docs.fauna.com/fauna/current/tools/shell/).
9086
cd java-sample-app
9187
```
9288

93-
2. Log in to Fauna using the Fauna CLI:
89+
2. If you haven't already, log in to Fauna using the Fauna CLI:
9490
9591
```sh
96-
fauna cloud-login
92+
fauna login
9793
```
9894
99-
When prompted, enter:
100-
101-
* **Endpoint name:** `cloud` (Press Enter)
102-
* **Email address:** The email address for your Fauna account.
103-
* **Password:** The password for your Fauna account.
104-
* **Which endpoint would you like to set as default?** The `cloud-*`
105-
endpoint for your preferred region group. For example, to use the US
106-
region group, use `cloud-us`.
107-
108-
The command requires an email and password login. If you log in to Fauna
109-
using GitHub or Netlify, you can enable email and password login using the
110-
[Forgot Password](https://dashboard.fauna.com/forgot-password) workflow.
111-
112-
3. Use the Fauna CLI to create the `ECommerceJava` database:
95+
3. Use the CLI to create the `ECommerceJava` database:
11396
11497
```sh
115-
fauna create-database ECommerceJava
98+
# Replace 'us' with your preferred Region Group:
99+
# 'us' (United States), 'eu' (Europe), or `global` (available to Pro accounts and above).
100+
fauna database create \
101+
--name ECommerceJava \
102+
--database us
116103
```
117104
118-
4. Create a
119-
[`.fauna-project`](https://docs.fauna.com/fauna/current/tools/shell/#proj-config)
120-
config file for the project:
121-
122-
```sh
123-
fauna project init
124-
```
125-
126-
When prompted, enter:
127-
128-
* `schema` as the schema directory.
129-
* `dev` as the environment name.
130-
* The default endpoint.
131-
* `ECommerce` as the database.
132-
133-
5. Push the `.fsl` files in the `schema` directory to the `ECommerceJava`
105+
4. Push the `.fsl` files in the `schema` directory to the `ECommerceJava`
134106
database:
135107
136108
```sh
137-
fauna schema push
109+
# Replace 'us' with your Region Group.
110+
fauna schema push \
111+
--database us/ECommerceJava
138112
```
139113
140114
When prompted, accept and stage the schema.
141115
142-
6. Check the status of the staged schema:
116+
5. Check the status of the staged schema:
143117
144118
```sh
145-
fauna schema status
119+
fauna schema status \
120+
--database us/ECommerceJava
146121
```
147122
148-
7. When the status is `ready`, commit the staged schema to the database:
123+
6. When the status is `ready`, commit the staged schema to the database:
149124
150125
```sh
151-
fauna schema commit
126+
fauna schema commit \
127+
--database us/ECommerceJava
152128
```
153129
154130
The commit applies the staged schema to the database. The commit creates the
155131
collections and user-defined functions (UDFs) defined in the `.fsl` files of the
156132
`schema` directory.
157133
158-
8. Create a key with the `server` role for the `ECommerceJava` database:
134+
7. Create a key with the `server` role for the `ECommerceJava` database:
159135
160136
```sh
161-
fauna create-key --environment='' ECommerceJava server
137+
fauna query "Key.create({ role: 'server' })" \
138+
--database us/ECommerceJava
162139
```
163140
164141
Copy the returned `secret`. The app can use the key's secret to authenticate
165142
requests to the database.
166143

167144
## Add sample data
168145

169-
The app includes a setup script that adds sample documents to the
146+
The app includes a seed script that adds sample documents to the
170147
`ECommerceJava` database. From the root directory, run:
171148

172149
```sh
173-
FAUNA_SECRET=<secret> ./setup.sh
150+
chmod +x ./scripts/seed.sh
151+
FAUNA_SECRET=<secret> ./scripts/seed.sh
174152
```
175153

176154
You can view documents created by the script in the [Fauna
@@ -232,7 +210,7 @@ Customer documents and related API responses:
232210
1. If you haven't already, add the sample data:
233211

234212
```sh
235-
FAUNA_SECRET=<secret> ./setup.sh
213+
FAUNA_SECRET=<secret> ./scripts/seed.sh
236214
```
237215

238216
If the app server is running, stop the server by pressing Ctrl+C.
@@ -263,21 +241,25 @@ Customer documents and related API responses:
263241
database to stage the changes:
264242
265243
```sh
266-
fauna schema push
244+
fauna schema push \
245+
--database us/ECommerceJava
267246
```
268247
269248
When prompted, accept and stage the schema.
270249
271250
4. Check the status of the staged schema:
251+
272252
```sh
273-
fauna schema status
253+
fauna schema status \
254+
--database us/ECommerceJava
274255
```
275256
276257
5. When the status is `ready`, commit the staged schema changes to the
277258
database:
278259
279260
```sh
280-
fauna schema commit
261+
fauna schema commit \
262+
--database us/ECommerceJava
281263
```
282264
283265
6. In `CustomersController.java`, add the

scripts/seed.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fauna query --input seed/categories.fql --secret "$FAUNA_SECRET"
2+
echo -e "\n\n"
3+
fauna query --input seed/customers.fql --secret "$FAUNA_SECRET"
4+
echo -e "\n\n"
5+
fauna query --input seed/products.fql --secret "$FAUNA_SECRET"
6+
echo -e "\n\n"
7+
fauna query --input seed/orders.fql --secret "$FAUNA_SECRET"

test/setup.sh renamed to scripts/setup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fauna eval "Key.create({ role: 'server' }).secret" | xargs > .fauna_key
1818

1919
fauna schema push -y --active --dir=schema
2020

21-
fauna import --collection Category --path seed/categories.json
22-
fauna import --collection Customer --path seed/customers.json
21+
fauna eval --file seed/categories.fql
22+
fauna eval --file seed/customers.fql
2323
fauna eval --file seed/products.fql
2424
fauna eval --file seed/orders.fql
File renamed without changes.

seed/categories.fql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{"query": "[
1+
[
22
{
33
'name': 'electronics'
44
},
@@ -8,4 +8,4 @@
88
{
99
'name': 'movies'
1010
}
11-
].map(c => Category.byName(c.name).first() ?? Category.create({ name: c.name, description: \"Bargain #{c.name}!\" }))"}
11+
].map(c => Category.byName(c.name).first() ?? Category.create({ name: c.name, description: "Bargain #{c.name}!" }))

seed/categories.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

seed/customers.fql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{"query":"[
1+
[
22
{
33
id: '999',
44
name: 'Valued Customer',
@@ -11,4 +11,4 @@
1111
country: 'Netherlands'
1212
}
1313
}
14-
].map(c => Customer.byEmail(c.email).first() ?? Customer.create(c))"}
14+
].map(c => Customer.byEmail(c.email).first() ?? Customer.create(c))

0 commit comments

Comments
 (0)