Skip to content

Commit 6d4947f

Browse files
authored
Merge pull request #628 from wayofdev/feat/docs
2 parents ad14018 + 4e8160b commit 6d4947f

File tree

14 files changed

+299
-30
lines changed

14 files changed

+299
-30
lines changed

docs/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
enable-pre-post-scripts=true
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import "asciinema-player/dist/bundle/asciinema-player.css";
2+
import React, { useEffect, useRef } from 'react';
3+
4+
const AsciinemaPlayer = ({ src, options = {}, ...rest }) => {
5+
const ref = useRef(null);
6+
7+
useEffect(() => {
8+
if (typeof window !== 'undefined') {
9+
import('asciinema-player').then((module) => {
10+
if (ref.current) {
11+
module.create(src, ref.current, options);
12+
}
13+
});
14+
}
15+
}, [src, JSON.stringify(options)]);
16+
17+
return <div ref={ref} {...rest} />;
18+
};
19+
20+
export default AsciinemaPlayer;

docs/next-sitemap.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/** @type {import('next-sitemap').IConfig} */
2+
module.exports = {
3+
siteUrl: 'https://laravel-cycle-orm-adapter.wayof.dev',
4+
generateRobotsTxt: true,
5+
}

docs/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"scripts": {
66
"dev": "next dev",
77
"build": "next build",
8+
"postbuild": "next-sitemap",
89
"start": "next start",
910
"deps:update": "pnpm dlx npm-check-updates --configFileName .ncurc.yml -u --deep --mergeConfig && pnpm install"
1011
},
@@ -21,7 +22,9 @@
2122
"dependencies": {
2223
"@heroicons/react": "^2.1.1",
2324
"@vercel/analytics": "^1.2.2",
25+
"asciinema-player": "^3.7.0",
2426
"next": "^14.1.3",
27+
"next-sitemap": "^4.2.3",
2528
"nextra": "latest",
2629
"nextra-theme-docs": "latest",
2730
"react": "^18.2.0",

docs/pages/_app.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Analytics } from '@vercel/analytics/react'
22
import type { AppProps } from 'next/app'
33
import type { ReactElement } from 'react'
4-
54
import '../style.css'
65

76
function Nextra({ Component, pageProps }: AppProps): ReactElement {

docs/pages/console-commands/database-commands.mdx

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import {Callout} from "nextra-theme-docs";
22
import {OptionTable} from "../../components/env-table";
3+
import Image from 'next/image';
34

45
# Database Commands
56

6-
The following commands are available for managing the database.
7+
Database commands provides tooling to manage and inspect your databases.
78

89
### Command Reference Table
910

@@ -34,3 +35,39 @@ export const commands = [
3435
}))}
3536
columns={columns}
3637
/>
38+
39+
### Listing Databases
40+
41+
`cycle:db:list`
42+
43+
This command provides a comprehensive list of all databases, along with their tables and the count of records in each table.
44+
45+
#### Usage
46+
47+
```bash
48+
php artisan cycle:db:list
49+
```
50+
51+
#### Example
52+
53+
<Image src="/images/command.cycle-db-list.png" alt="Listing Databases" width={1882} height={1016} />
54+
55+
### Describing Table Schema
56+
57+
`cycle:db:table`
58+
59+
To get detailed information about the schema of a specific table, use the cycle:db:table command. This includes column names, types, and other relevant metadata.
60+
61+
#### Usage
62+
63+
```bash
64+
php artisan cycle:db:table your_table_name
65+
```
66+
67+
#### Options
68+
69+
`--d|database`: The name of the database to use. If not provided, the default database will be used.
70+
71+
#### Example
72+
73+
<Image src="/images/command.cycle-db-table.png" alt="Listing Table Contents" width={1882} height={1016} />

docs/pages/console-commands/migration-commands.mdx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {Callout} from "nextra-theme-docs";
22
import {OptionTable} from "../../components/env-table";
3+
import AsciinemaPlayer from "../../components/asciinema-player/player";
34

45
# Migration Commands
56

@@ -65,7 +66,27 @@ php artisan cycle:migrate
6566

6667
#### Options
6768

68-
`--one`: Executes only the first pending migration, allowing for more granular control over the migration process.
69+
- `--one`: Executes only the first pending migration, allowing for more granular control over the migration process.
70+
71+
#### Example
72+
73+
Recording shows the visualization of applying migrations to the database.
74+
75+
<br/>
76+
77+
<AsciinemaPlayer
78+
src="https://asciinema.org/a/sRNJPTQZTHxRoiGVAqxKvR48K.cast"
79+
options={{
80+
idleTimeLimit: 2,
81+
preload: true,
82+
loop: 0,
83+
speed: 1.0,
84+
theme: 'monokai',
85+
rows: 28,
86+
cols: 120,
87+
poster: "npt:0:03"
88+
}}
89+
/>
6990

7091
### Replaying Migrations
7192

@@ -81,7 +102,7 @@ php artisan cycle:migrate:replay
81102

82103
#### Options
83104

84-
`--all`: Replays all migrations, effectively refreshing your entire database schema.
105+
- `--all`: Replays all migrations, effectively refreshing your entire database schema.
85106

86107

87108
### Rolling Back Migrations
@@ -98,7 +119,7 @@ php artisan cycle:migrate:rollback
98119

99120
#### Options
100121

101-
`--all`: Rolls back all migrations, allowing you to revert your database schema to its initial state.
122+
- `--all`: Rolls back all migrations, allowing you to revert your database schema to its initial state.
102123

103124

104125
### Checking Migration Status
@@ -131,4 +152,4 @@ php artisan cycle:migrate:fresh
131152

132153
#### Options
133154

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

docs/pages/console-commands/orm-commands.mdx

Lines changed: 104 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import {Callout} from "nextra-theme-docs";
22
import {OptionTable} from "../../components/env-table";
3+
import AsciinemaPlayer from "../../components/asciinema-player/player";
34

45
# ORM Commands
56

6-
The following commands are available for managing the ORM.
7+
ORM commands facilitate the management of the Object-Relational Mapping layer, allowing for the initialization and updating of schemas, migration generation, schema visualization, and direct synchronization with the database.
78

89
### Command Reference Table
910

@@ -36,3 +37,105 @@ export const commands = [
3637
}))}
3738
columns={columns}
3839
/>
40+
41+
### Initializing or Updating ORM Schema
42+
43+
`cycle:orm`
44+
45+
This command initializes or updates the Cycle ORM schema by analyzing the database structure and annotated classes.
46+
47+
#### Usage
48+
49+
```bash
50+
php artisan cycle:orm
51+
```
52+
53+
### Generating ORM Schema Migrations
54+
55+
`cycle:orm:migrate`
56+
57+
Use this command to generate migrations based on the current ORM schema. It's a crucial step for evolving the database schema in a controlled manner.
58+
59+
#### Usage
60+
61+
```bash
62+
php artisan cycle:orm:migrate
63+
```
64+
65+
#### Options
66+
67+
- `--r|run` - Automatically run generated migration.
68+
- `--s|split` - Split migration into multiple files (one per table).
69+
70+
#### Example
71+
72+
Recording shows migration file generation on existing Domain Entities and their relationships.
73+
74+
<br/>
75+
76+
<AsciinemaPlayer
77+
src="https://asciinema.org/a/Q7uli4kvEkbbzqt4LBLNlCCkE.cast"
78+
options={{
79+
idleTimeLimit: 2,
80+
preload: true,
81+
loop: 0,
82+
speed: 1.0,
83+
theme: 'monokai',
84+
rows: 28,
85+
cols: 120,
86+
poster: "npt:0:04"
87+
}}
88+
/>
89+
90+
### Displaying ORM Schema
91+
92+
`cycle:orm:render`
93+
94+
To visualize the current ORM schema directly in your console, use the `cycle:orm:render` command. This can help with understanding the structure and relationships defined in your ORM.
95+
96+
#### Usage
97+
98+
```bash
99+
php artisan cycle:orm:render
100+
```
101+
102+
#### Options
103+
104+
- `--nc|no-color` - Display output without colors.
105+
- `--p|php` - Display output as PHP code.
106+
107+
#### Example
108+
109+
Recording shows the visualization of the ORM schema in the console for existing `App/Entities/Post` entity.
110+
111+
<br/>
112+
113+
<AsciinemaPlayer
114+
src="https://asciinema.org/a/0ZTAlr5EWbVlll86A4EKm35N1.cast"
115+
options={{
116+
idleTimeLimit: 2,
117+
preload: true,
118+
loop: 0,
119+
speed: 1.0,
120+
theme: 'monokai',
121+
rows: 28,
122+
cols: 120,
123+
poster: "npt:0:03"
124+
}}
125+
/>
126+
127+
### Synchronizing ORM Schema with Database
128+
129+
`cycle:orm:sync`
130+
131+
This command directly synchronizes the Cycle ORM schema with the database. It bypasses the migration system and applies changes directly, which can be risky.
132+
133+
#### Usage
134+
135+
```bash
136+
php artisan cycle:orm:sync
137+
```
138+
139+
<Callout type="warning" emoji="⚠️">
140+
Be cautious when using the `cycle:orm:sync` command, as it directly alters the database schema and can potentially lead to data loss.
141+
</Callout>

0 commit comments

Comments
 (0)