Skip to content
This repository was archived by the owner on Sep 19, 2024. It is now read-only.
Merged
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
14 changes: 7 additions & 7 deletions seed/hasura-slack-clone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Snaplet operates in two main steps:

1. **Introspection:** Snaplet analyzes your database, gathering schema, data, and relationship details.
2. **Configuration:** Snaplet generates multiples transforms to generate data based on the introspection result (columns names, data types, relationships, etc).
3. **Script Generation:** Snaplet generates a `seed.mts` file for data generation.
3. **Script Generation:** Snaplet generates a `seed.ts` file for data generation.

To set it up:

Expand Down Expand Up @@ -121,7 +121,7 @@ export default defineConfig({
```

When saving this configuration, our cli watcher will detect that it's now able to connect
and introspect our database, and will finish our client generation generating a `seed.mts` file:
and introspect our database, and will finish our client generation generating a `seed.ts` file:

```ts
import { createSeedClient } from "@snaplet/seed";
Expand All @@ -140,10 +140,10 @@ process.exit()

### Generating Data

Now that we have our `seed.mts` file, we can generate data with the following command:
Now that we have our `seed.ts` file, we can generate data with the following command:

```bash
npx tsx seed.mts
npx tsx seed.ts
```

With our current configuration this will create 3 workspace user types. Not very useful.
Expand All @@ -157,7 +157,7 @@ To build a more realistic environment, we plan to add:

These additions will help us simulate a more authentic workspace environment, giving us a better platform to demonstrate the capabilities of `@snaplet/seed`.

We can update our `seed.mts` like this:
We can update our `seed.ts` like this:

```ts
...
Expand Down Expand Up @@ -195,7 +195,7 @@ Based on our configuration, here's what we expect:
Let's generate the data and explore the result:

```bash
npx tsx seed.mts
npx tsx seed.ts
```

As you can see, we have now a lot of data in our database. Let's explore it in the Hasura console.
Expand Down Expand Up @@ -279,7 +279,7 @@ await seed.workspaces(
After adjusting our data generation strategy, let's run the command again to see the results:

```bash
npx tsx seed.mts
npx tsx seed.ts
```

![snaplet-generate-image-gif](https://github.com/snaplet/examples/assets/8771783/7f466678-6db8-4046-9cb1-8638228e8fce)
Expand Down
12 changes: 6 additions & 6 deletions seed/supabase-twitter-clone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export default defineConfig({
> you can run `npx @snaplet/seed sync` to update your seed client.

When saving this configuration, our cli watcher will detect that it's now able to connect
and introspect our database, and will finish our client generation generating a `seed.mts` file:
and introspect our database, and will finish our client generation generating a `seed.ts` file:

```ts
import { createSeedClient } from '@snaplet/seed';
Expand All @@ -289,7 +289,7 @@ await seed.$resetDatabase()
await seed.HttpResponses(x => x(3))
```

Now, let's edit our `seed.mts` file to generate some tweets:
Now, let's edit our `seed.ts` file to generate some tweets:

```ts
await seed.$resetDatabase()
Expand All @@ -298,7 +298,7 @@ await seed.$resetDatabase()
await seed.tweets(x => x(10))
```

After running `npx tsx seed.mts`, we encounter an error related to invalid `avatar_url` in the Next.js images. To fix this, we adjust the `avatar_url` generation in our `seed.mts`:
After running `npx tsx seed.ts`, we encounter an error related to invalid `avatar_url` in the Next.js images. To fix this, we adjust the `avatar_url` generation in our `seed.ts`:

```ts
import { faker } from '@snaplet/copycat';
Expand All @@ -319,7 +319,7 @@ await seed.$resetDatabase()
await seed.tweets(x => x(10))
```

We can now re-run our script with `npx tsx seed.mts`.
We can now re-run our script with `npx tsx seed.ts`.

Refreshing our page should now display the seeded tweet data correctly.

Expand Down Expand Up @@ -368,7 +368,7 @@ console.log("Profiles created: ", profiles);

This process creates a pool of 5 users with email and password logins, allowing us to easily log in as any tweet creator.

Combining all the steps, our `seed.mts` file becomes:
Combining all the steps, our `seed.ts` file becomes:

<details>
<summary>Click to show the full code</summary>
Expand Down Expand Up @@ -439,7 +439,7 @@ console.log('Profiles created: ', profiles)

Re-run the seed script with the environment variables set to your local Supabase instance:

`NEXT_PUBLIC_SUPABASE_URL=http://127.0.0.1:54321 NEXT_PUBLIC_SUPABASE_ANON_KEY=<anon-key> npx tsx seed.mts`:
`NEXT_PUBLIC_SUPABASE_URL=http://127.0.0.1:54321 NEXT_PUBLIC_SUPABASE_ANON_KEY=<anon-key> npx tsx seed.ts`:

![snaplet-seed-users-and-tweets-asciinema](https://github.com/snaplet/examples/assets/8771783/db797322-d5f4-469b-8860-ca8d9f108943)

Expand Down
8 changes: 4 additions & 4 deletions seed/todonextapp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default defineConfig({
```

When saving this configuration, our cli watcher will detect that it's now able to connect
and introspect our database, and will finish our client generation generating a `seed.mts` file:
and introspect our database, and will finish our client generation generating a `seed.ts` file:

```ts
import { createSeedClient } from "@snaplet/seed";
Expand Down Expand Up @@ -133,7 +133,7 @@ await seed.todo((x) => x(20));
Populating the database is then just a command away:

```bash
npx tsx seed.mts
npx tsx seed.ts
```

And voila !
Expand Down Expand Up @@ -265,7 +265,7 @@ For development, we now want:
2. Twenty todos created by these users.
3. Five votes per todo.

With `snaplet`, our `seed.mts` changes to:
With `snaplet`, our `seed.ts` changes to:

```ts
import { copycat } from "@snaplet/copycat";
Expand Down Expand Up @@ -296,7 +296,7 @@ await seed.todos(
We can now seed our database with:

```bash
npx tsx seed.mts
npx tsx seed.ts
```

This comprehensive approach saves us from maintaining a lengthy and complex seed script (the generated SQL is now 120 lines long), illustrating why at Snaplet, we advocate for a declarative, database-aware, and auto-filled methodology. It's about creating and maintaining a dynamic, production-like development environment with ease.
Expand Down