Skip to content

Commit 50717c2

Browse files
authored
Merge pull request #626 from wayofdev/feat/docs
2 parents 3a2dce3 + 45cd7e9 commit 50717c2

39 files changed

+936
-274
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"cycle/annotated": "^4.1",
2121
"cycle/database": "^2.8",
2222
"cycle/entity-behavior": "^1.3",
23+
"cycle/entity-behavior-uuid": "^1.2",
2324
"cycle/migrations": "^4.2",
2425
"cycle/orm": "^2.7",
2526
"cycle/schema-migrations-generator": "^2.2",

composer.lock

Lines changed: 146 additions & 80 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/components/env-table/index.tsx

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1+
import React from 'react';
12
import styles from './style.module.css'
23

3-
export function OptionTable({ options }: { options: [string, string, string, string][] }) {
4-
const createMarkup = (htmlContent: string) => {
5-
return { __html: htmlContent };
6-
};
4+
export const createMarkup = (htmlContent: string) => {
5+
return {__html: htmlContent};
6+
};
77

8+
type ColumnConfig = {
9+
key: string;
10+
header: string;
11+
headerClassName?: string;
12+
cellClassName?: string;
13+
render?: (value: any, row: any) => React.ReactNode;
14+
};
15+
16+
export function OptionTable({
17+
options,
18+
columns,
19+
}: {
20+
options: Record<string, any>[];
21+
columns: ColumnConfig[];
22+
}) {
823
return (
924
<div
1025
className={
@@ -15,32 +30,29 @@ export function OptionTable({ options }: { options: [string, string, string, str
1530
<table className="w-full border-collapse text-sm">
1631
<thead>
1732
<tr className="border-b py-4 text-left dark:border-neutral-700">
18-
<th className="py-2 font-semibold">Environment Variable</th>
19-
<th className="py-2 pl-6 font-semibold">Available Values</th>
20-
<th className="py-2 pl-6 font-semibold">Default</th>
21-
<th className="px-6 py-2 font-semibold">Description</th>
33+
{columns.map(({header, headerClassName}) => (
34+
<th key={header} className={`py-2 font-semibold ${headerClassName || ''}`}>
35+
{header}
36+
</th>
37+
))}
2238
</tr>
2339
</thead>
2440
<tbody className="align-baseline text-gray-900 dark:text-gray-100">
25-
{options.map(([variable, values, defaultValue, description]) => (
41+
{options.map((row, rowIndex) => (
2642
<tr
27-
key={variable}
43+
key={rowIndex}
2844
className="border-b border-gray-100 dark:border-neutral-700/50"
2945
>
30-
<td className="whitespace-pre py-2 font-mono text-xs font-semibold leading-6 text-violet-600 dark:text-violet-500">
31-
{variable}
32-
</td>
33-
<td className="whitespace-pre py-2 pl-6 font-mono text-xs font-semibold leading-6 text-slate-500 dark:text-slate-400">
34-
{values}
35-
</td>
36-
<td className="whitespace-pre py-2 pl-6 font-mono text-xs font-semibold leading-6 text-slate-500 dark:text-slate-400">
37-
{defaultValue}
38-
</td>
39-
<td className="py-2 pl-6" dangerouslySetInnerHTML={createMarkup(description)}></td>
46+
{columns.map(({key, cellClassName, render}) => (
47+
<td key={key}
48+
className={cellClassName}>
49+
{render ? render(row[key], row) : row[key]}
50+
</td>
51+
))}
4052
</tr>
4153
))}
4254
</tbody>
4355
</table>
4456
</div>
45-
)
57+
);
4658
}

docs/components/external-link/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ArrowTopRightOnSquareIcon } from "@heroicons/react/20/solid";
33

44
const ExternalLink = ({ href, children }) => {
55
return (
6-
<a href={href} target="_blank" className="nx-text-primary-600 nx-underline nx-decoration-from-font [text-underline-position:from-font] inline-flex items-center gap-0.5">
6+
<a href={href} rel="noopener" target="_blank" className="nx-text-primary-600 nx-underline nx-decoration-from-font [text-underline-position:from-font] inline-flex items-center gap-0.5">
77
{children}
88
<ArrowTopRightOnSquareIcon className="size-4" />
99
</a>

docs/pages/_meta.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"index": "Introduction",
3-
"installation": "Installation",
4-
"configuration": "Configuration",
5-
"usage": "Usage",
3+
"getting-started": "Getting Started",
4+
"working-with-entities": "Working with Entities",
5+
"working-with-relationships": "Working with Relationships",
6+
"console-commands": "Console Commands",
67
"services": "Services",
78
"contributing": "Contributing"
89
}

docs/pages/configuration.mdx

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

docs/pages/console-commands.mdx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Card, Cards } from 'nextra/components'
2+
import {BookOpenIcon} from "@heroicons/react/20/solid";
3+
4+
# Console Commands
5+
6+
This package includes CycleORM commands implemented as Laravel Console Commands, you can use them to manage your database schema and perform migrations.
7+
8+
The package extends Laravel's artisan commands, introducing a set of commands specifically designed for managing CycleORM migrations and database schema. These commands are intuitive for Laravel developers and follow the framework's conventions.
9+
10+
11+
## 📚 Explore each Console Command
12+
13+
<Cards>
14+
<Card
15+
title="Migration Commands"
16+
href="/console-commands/migrations"
17+
icon={<BookOpenIcon className="h-5 w-5 text-gray-500" />}
18+
children=""
19+
/>
20+
<Card
21+
title="ORM Commands"
22+
href="/console-commands/database"
23+
icon={<BookOpenIcon className="h-5 w-5 text-gray-500" />}
24+
children=""
25+
/>
26+
<Card
27+
title="Database Commands"
28+
href="/console-commands/has-many"
29+
icon={<BookOpenIcon className="h-5 w-5 text-gray-500" />}
30+
children=""
31+
/>
32+
</Cards>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"migration-commands": "Migration Commands",
3+
"orm-commands": "ORM Commands",
4+
"database-commands": "Database Commands"
5+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import {Callout} from "nextra-theme-docs";
2+
import {OptionTable} from "../../components/env-table";
3+
4+
# Database Commands
5+
6+
The following commands are available for managing the database.
7+
8+
### Command Reference Table
9+
10+
export const columns = [
11+
{
12+
key: 'command',
13+
header: 'Command',
14+
headerClassName: '',
15+
cellClassName: 'whitespace-pre py-2 font-mono text-xs font-semibold leading-6 text-violet-600 dark:text-violet-500'
16+
},
17+
{
18+
key: 'description',
19+
header: 'Description',
20+
headerClassName: 'px-6',
21+
cellClassName: 'py-2 pl-6',
22+
}
23+
]
24+
25+
export const commands = [
26+
["cycle:db:list", "Get list of available databases, their tables and records count."],
27+
["cycle:db:table", "Describe table schema of specific database"],
28+
];
29+
30+
<OptionTable
31+
options={commands.map(([command, description]) => ({
32+
command,
33+
description
34+
}))}
35+
columns={columns}
36+
/>
Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,51 @@
11
import {Callout} from "nextra-theme-docs";
2+
import {OptionTable} from "../../components/env-table";
23

3-
This package includes CycleORM commands implemented as Laravel Console Commands, you can use them to manage your database schema and perform migrations.
4-
5-
The package extends Laravel's artisan commands, introducing a set of commands specifically designed for managing CycleORM migrations and database schema. These commands are intuitive for Laravel developers and follow the framework's conventions.
6-
7-
8-
## 🛠️ Commands for Migrations
4+
# Migration Commands
95

106
Migration commands are essential for managing your database's evolution over time. They allow for the creation, execution, rollback, and status checking of migrations.
117

12-
### Command List
13-
14-
| Command | Description |
15-
|--------------------------|-------------------------------------------------------------------------------------------------------------------|
16-
| `cycle:migrate:init` | Initializes the migration system by creating the necessary migrations table. |
17-
| `cycle:migrate` | Executes pending migrations. Use the `--one` flag to execute only the first pending migration. |
18-
| `cycle:migrate:replay` | Replays migrations by rolling them back and then re-applying them. Use the `--all` flag to replay all migrations. |
19-
| `cycle:migrate:rollback` | Rolls back the last batch of migrations by default. Use the `--all` flag to roll back all migrations. |
20-
| `cycle:migrate:status` | Displays the status of all migrations, indicating which have been applied. |
21-
| `cycle:migrate:fresh` | Drops all tables and re-runs all migrations, providing a clean slate. ⚠️ |
8+
### Command Reference Table
9+
10+
export const columns = [
11+
{
12+
key: 'command',
13+
header: 'Command',
14+
headerClassName: '',
15+
cellClassName: 'whitespace-pre py-2 font-mono text-xs font-semibold leading-6 text-violet-600 dark:text-violet-500'
16+
},
17+
{
18+
key: 'description',
19+
header: 'Description',
20+
headerClassName: 'px-6',
21+
cellClassName: 'py-2 pl-6',
22+
}
23+
]
24+
25+
export const commands = [
26+
["cycle:migrate:init", "Initializes the migration system by creating the necessary migrations table."],
27+
["cycle:migrate", "Executes pending migrations. Use the `--one` flag to execute only the first pending migration."],
28+
["cycle:migrate:replay", "Replays migrations by rolling them back and then re-applying them. Use the `--all` flag to replay all migrations."],
29+
["cycle:migrate:rollback", "Rolls back the last batch of migrations by default. Use the `--all` flag to roll back all migrations."],
30+
["cycle:migrate:status", "Displays the status of all migrations, indicating which have been applied."],
31+
["cycle:migrate:fresh", "Drops all tables and re-runs all migrations, providing a clean slate. ⚠️"]
32+
];
33+
34+
<OptionTable
35+
options={commands.map(([command, description]) => ({
36+
command,
37+
description
38+
}))}
39+
columns={columns}
40+
/>
2241

2342
### Initializing Migrations
2443

2544
`cycle:migrate:init`
2645

2746
This command is your starting point for migration management. It initializes the migration system by creating the necessary migrations table in your database, ensuring that you can start tracking and executing migrations.
2847

29-
#### Usage:
48+
#### Usage
3049

3150
```bash
3251
php artisan cycle:migrate:init
@@ -38,13 +57,13 @@ php artisan cycle:migrate:init
3857

3958
To apply pending migrations to your database, use the `cycle:migrate` command. This will execute all migrations that have not yet been applied, updating your database schema accordingly.
4059

41-
#### Usage:
60+
#### Usage
4261

4362
```bash
4463
php artisan cycle:migrate
4564
```
4665

47-
#### Options:
66+
#### Options
4867

4968
`--one`: Executes only the first pending migration, allowing for more granular control over the migration process.
5069

@@ -54,13 +73,13 @@ php artisan cycle:migrate
5473

5574
This command facilitates the replaying of migrations by first rolling them back and then re-applying them. It's particularly useful for development environments where you need to quickly test changes to migrations.
5675

57-
#### Usage:
76+
#### Usage
5877

5978
```bash
6079
php artisan cycle:migrate:replay
6180
```
6281

63-
#### Options:
82+
#### Options
6483

6584
`--all`: Replays all migrations, effectively refreshing your entire database schema.
6685

@@ -71,13 +90,13 @@ php artisan cycle:migrate:replay
7190

7291
To undo the last batch of migrations, you can use the `cycle:migrate:rollback` command. This is useful when you need to revert changes made by the most recent migrations.
7392

74-
#### Usage:
93+
#### Usage
7594

7695
```bash
7796
php artisan cycle:migrate:rollback
7897
```
7998

80-
#### Options:
99+
#### Options
81100

82101
`--all`: Rolls back all migrations, allowing you to revert your database schema to its initial state.
83102

@@ -88,7 +107,7 @@ php artisan cycle:migrate:rollback
88107

89108
Keeping track of which migrations have been applied is crucial for database management. The `cycle:migrate:status` command displays the status of all migrations, indicating which have been applied and which are pending.
90109

91-
#### Usage:
110+
#### Usage
92111

93112
```bash
94113
php artisan cycle:migrate:status
@@ -100,7 +119,7 @@ php artisan cycle:migrate:status
100119

101120
When you need to start from a clean slate, the `cycle:migrate:fresh` command drops all tables from the database and re-runs all migrations. This is particularly useful for resetting the database to a known state during development or testing.
102121

103-
#### Usage:
122+
#### Usage
104123

105124
```bash
106125
php artisan cycle:migrate:fresh
@@ -110,6 +129,6 @@ php artisan cycle:migrate:fresh
110129
Be cautious when using the `cycle:migrate:fresh` command, as it will permanently delete all data in your database.
111130
</Callout>
112131

113-
#### Options:
132+
#### Options
114133

115134
`--seed`: Seeds the database after running the migrations, populating it with initial data.

0 commit comments

Comments
 (0)