Skip to content

Commit

Permalink
bump docusaurus to v3.
Browse files Browse the repository at this point in the history
..

..

..
  • Loading branch information
igalklebanov committed Jun 22, 2024
1 parent e71bbc4 commit 23b35ca
Show file tree
Hide file tree
Showing 20 changed files with 14,765 additions and 11,927 deletions.
4 changes: 2 additions & 2 deletions site/docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { Summary } from './getting-started/Summary'
{() => (
<Dialects
packageManager={new URLSearchParams(document.location.search).get(
'package-manager'
'package-manager',
)}
packageManagersURL="#installation"
/>
Expand All @@ -42,7 +42,7 @@ import { Summary } from './getting-started/Summary'
dialect={new URLSearchParams(document.location.search).get('dialect')}
dialectsURL="#dialects"
packageManager={new URLSearchParams(document.location.search).get(
'package-manager'
'package-manager',
)}
packageManagersURL="#installation"
/>
Expand Down
1 change: 0 additions & 1 deletion site/docs/getting-started/Dialects.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import Admonition from '@theme/Admonition'
import CodeBlock from '@theme/CodeBlock'
import Heading from '@theme/Heading'
Expand Down
1 change: 0 additions & 1 deletion site/docs/getting-started/IUseADifferentDatabase.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import Link from '@docusaurus/Link'
import { PRETTY_DIALECT_NAMES, type PropsWithDialect } from './shared'

Expand Down
3 changes: 1 addition & 2 deletions site/docs/getting-started/IUseADifferentPackageManager.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import Link from '@docusaurus/Link'
import { PRETTY_PACKAGE_MANAGER_NAMES, type PackageManager } from './shared'

Expand All @@ -8,7 +7,7 @@ export interface IUseADifferentPackageManagerProps {
}

export function IUseADifferentPackageManager(
props: IUseADifferentPackageManagerProps
props: IUseADifferentPackageManagerProps,
) {
const packageManagerName =
PRETTY_PACKAGE_MANAGER_NAMES[props.packageManager || 'npm']
Expand Down
2 changes: 1 addition & 1 deletion site/docs/getting-started/Installation.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { type ReactNode } from 'react'
import type { ReactNode } from 'react'
import CodeBlock from '@theme/CodeBlock'
import Link from '@docusaurus/Link'
import Tabs from '@theme/Tabs'
Expand Down
14 changes: 7 additions & 7 deletions site/docs/getting-started/Instantiation.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React, { type ReactNode } from 'react'
import Admonition from '@theme/Admonition'
import CodeBlock from '@theme/CodeBlock'
import { IUseADifferentDatabase } from './IUseADifferentDatabase'
Expand All @@ -17,7 +16,7 @@ import {

function getNotSupportedCode(
dialect: Dialect,
packageManager: PackageManager
packageManager: PackageManager,
): string {
return `/* Kysely doesn't support ${PRETTY_DIALECT_NAMES[dialect]} + ${
PRETTY_PACKAGE_MANAGER_NAMES[packageManager || 'npm']
Expand All @@ -29,12 +28,13 @@ const dialect = /* instantiate the dialect here */`

function getDialectSpecificCodeSnippet(
dialect: Dialect,
packageManager: PackageManager
packageManager: PackageManager,
): string {
const driverNPMPackageName = getDriverNPMPackageNames(packageManager)[dialect]
const dialectClassName = DIALECT_CLASS_NAMES[dialect]
const poolClassName = 'Pool'
const poolClassImport = packageManager === 'deno' ? poolClassName : `{ ${poolClassName} }`
const poolClassImport =
packageManager === 'deno' ? poolClassName : `{ ${poolClassName} }`

if (dialect === 'postgresql') {
return `import ${poolClassImport} from '${driverNPMPackageName}'
Expand Down Expand Up @@ -123,14 +123,14 @@ export function Instantiation(
props: PropsWithDialect<{
packageManager: PackageManager | undefined
packageManagersURL: string
}>
}>,
) {
const dialect = props.dialect || 'postgresql'
const packageManager = props.packageManager || 'npm'

const dialectSpecificCodeSnippet = !isDialectSupported(
dialect,
packageManager
packageManager,
)
? getNotSupportedCode(dialect, packageManager)
: getDialectSpecificCodeSnippet(dialect, packageManager)
Expand Down Expand Up @@ -173,7 +173,7 @@ export const db = new Kysely<Database>({
connections at all, so there's no need to create a new instance for each
request.
</Admonition>
<Admonition type="caution" title="keeping secrets">
<Admonition type="warning" title="keeping secrets">
Use a secrets manager, environment variables (DO NOT commit `.env` files
to your repository), or a similar solution, to avoid hardcoding database
credentials in your code.
Expand Down
1 change: 0 additions & 1 deletion site/docs/getting-started/Querying.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import Admonition from '@theme/Admonition'
import CodeBlock from '@theme/CodeBlock'
import Link from '@docusaurus/Link'
Expand Down
1 change: 0 additions & 1 deletion site/docs/getting-started/Summary.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import Admonition from '@theme/Admonition'
import CodeBlock from '@theme/CodeBlock'
import Link from '@docusaurus/Link'
Expand Down
10 changes: 5 additions & 5 deletions site/docs/getting-started/_types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
Insertable,
JSONColumnType,
Selectable,
Updateable
Updateable,
} from 'kysely'

export interface Database {
Expand Down Expand Up @@ -51,10 +51,10 @@ export interface PersonTable {
// and the insert and update types are always `string` since you're
// always stringifying insert/update values.
metadata: JSONColumnType<{
login_at: string;
ip: string | null;
agent: string | null;
plan: 'free' | 'premium';
login_at: string
ip: string | null
agent: string | null
plan: 'free' | 'premium'
}>
}

Expand Down
14 changes: 7 additions & 7 deletions site/docs/getting-started/shared.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { type ReactNode } from 'react'
import type { ReactNode } from 'react'
import packageJson from '../../package.json'

export type Dialect = 'postgresql' | 'mysql' | 'sqlite' | 'mssql'
Expand All @@ -21,7 +21,7 @@ const PACKAGE_MANAGER_UNSUPPORTED_DIALECTS: Record<PackageManager, Dialect[]> =

export function isDialectSupported(
dialect: Dialect,
packageManager: PackageManager
packageManager: PackageManager,
): boolean {
return !PACKAGE_MANAGER_UNSUPPORTED_DIALECTS[packageManager].includes(dialect)
}
Expand All @@ -34,14 +34,14 @@ export const DIALECT_CLASS_NAMES = {
} as const satisfies Record<Dialect, string>

export const getDriverNPMPackageNames = (
packageManager: PackageManager = 'npm'
packageManager: PackageManager = 'npm',
) =>
({
postgresql: packageManager === 'deno' ? 'pg-pool' : 'pg',
mysql: 'mysql2',
mssql: 'tedious',
sqlite: 'better-sqlite3',
} as const satisfies Record<Dialect, string>)
}) as const satisfies Record<Dialect, string>

export const POOL_NPM_PACKAGE_NAMES = {
mssql: 'tarn',
Expand Down Expand Up @@ -79,7 +79,7 @@ export interface Command {
export function getBashCommand(
packageManager: PackageManager,
installedPackage: string,
additionalPackages?: string[]
additionalPackages?: string[],
): Command {
if (packageManager === 'deno') {
throw new Error('Deno has no bash command')
Expand All @@ -98,7 +98,7 @@ export function getBashCommand(
}

export function getDenoCommand(
additionalImports?: Record<string, string>
additionalImports?: Record<string, string>,
): Command {
return {
content: JSON.stringify(
Expand All @@ -109,7 +109,7 @@ export function getDenoCommand(
},
},
null,
2
2,
),
intro: (
<>
Expand Down
14 changes: 7 additions & 7 deletions site/docs/migrations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ Migrations can use the `Kysely.schema` module to modify the schema. Migrations c

## Execution order

Migrations will be run in the alpha-numeric order of your migration names. An excellent way to name your migrations is to prefix them with an ISO 8601 date string.
Migrations will be run in the alpha-numeric order of your migration names. An excellent way to name your migrations is to prefix them with an ISO 8601 date string.

By default, Kysely will also ensure this order matches the execution order of any previously executed migrations in your database. If the orders do not match (for example, a new migration was added alphabetically before a previously executed one), an error will be returned. This adds safety by always executing your migrations in the correct, alphanumeric order.
By default, Kysely will also ensure this order matches the execution order of any previously executed migrations in your database. If the orders do not match (for example, a new migration was added alphabetically before a previously executed one), an error will be returned. This adds safety by always executing your migrations in the correct, alphanumeric order.

There is also an `allowUnorderedMigrations` option. This option will allow new migrations to be run even if they are added alphabetically before ones that have already executed. Allowing unordered migrations works well in large teams where multiple team members may add migrations at the same time in parallel commits without knowing about the other migrations. Pending (unexecuted) migrations will be run in alpha-numeric order when migrating up. When migrating down, migrations will be undone in the opposite order in which they were executed (reverse sorted by execution timestamp).

Expand Down Expand Up @@ -61,7 +61,7 @@ export async function up(db: Kysely<any>): Promise<void> {
.addColumn('last_name', 'varchar')
.addColumn('gender', 'varchar(50)', (col) => col.notNull())
.addColumn('created_at', 'timestamp', (col) =>
col.defaultTo(sql`now()`).notNull()
col.defaultTo(sql`now()`).notNull(),
)
.execute()

Expand All @@ -70,7 +70,7 @@ export async function up(db: Kysely<any>): Promise<void> {
.addColumn('id', 'serial', (col) => col.primaryKey())
.addColumn('name', 'varchar', (col) => col.notNull().unique())
.addColumn('owner_id', 'integer', (col) =>
col.references('person.id').onDelete('cascade').notNull()
col.references('person.id').onDelete('cascade').notNull(),
)
.addColumn('species', 'varchar', (col) => col.notNull())
.execute()
Expand Down Expand Up @@ -101,7 +101,7 @@ export async function up(db: Kysely<any>): Promise<void> {
.addColumn('last_name', 'text')
.addColumn('gender', 'text', (col) => col.notNull())
.addColumn('created_at', 'text', (col) =>
col.defaultTo(sql`CURRENT_TIMESTAMP`).notNull()
col.defaultTo(sql`CURRENT_TIMESTAMP`).notNull(),
)
.execute()

Expand All @@ -110,7 +110,7 @@ export async function up(db: Kysely<any>): Promise<void> {
.addColumn('id', 'integer', (col) => col.primaryKey())
.addColumn('name', 'text', (col) => col.notNull().unique())
.addColumn('owner_id', 'integer', (col) =>
col.references('person.id').onDelete('cascade').notNull()
col.references('person.id').onDelete('cascade').notNull(),
)
.addColumn('species', 'text', (col) => col.notNull())
.execute()
Expand All @@ -130,7 +130,7 @@ export async function down(db: Kysely<any>): Promise<void> {

## CLI (optional)

Kysely offers a CLI you can use for migrations (and more). It can help you create and run migrations.
Kysely offers a CLI you can use for migrations (and more). It can help you create and run migrations.
It is not part of the core, and your mileage may vary.

For more information, visit https://github.com/kysely-org/kysely-ctl.
Expand Down
2 changes: 1 addition & 1 deletion site/docs/recipes/0006-expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ An [`Expression<T>`](https://kysely-org.github.io/kysely-apidoc/interfaces/Expre

## Expression builder

Expressions are usually built using an instance of [ExpressionBuilder<DB, TB>](https://kysely-org.github.io/kysely-apidoc/interfaces/ExpressionBuilder.html). `DB` is the same database type you give to `Kysely` when you create an instance. `TB` is the union of all table names that are visible in the context. For example `ExpressionBuilder<DB, 'person' | 'pet'>` means you can access `person` and `pet` tables and all their columns in the expression.
Expressions are usually built using an instance of [`ExpressionBuilder<DB, TB>`](https://kysely-org.github.io/kysely-apidoc/interfaces/ExpressionBuilder.html). `DB` is the same database type you give to `Kysely` when you create an instance. `TB` is the union of all table names that are visible in the context. For example `ExpressionBuilder<DB, 'person' | 'pet'>` means you can access `person` and `pet` tables and all their columns in the expression.

You can get an instance of the expression builder by using a callback:

Expand Down
5 changes: 3 additions & 2 deletions site/docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion

const lightCodeTheme = require('prism-react-renderer/themes/github')
const darkCodeTheme = require('prism-react-renderer/themes/dracula')
const { themes } = require('prism-react-renderer')
const lightCodeTheme = themes.github
const darkCodeTheme = themes.dracula

/** @type {import('@docusaurus/types').Config} */
const config = {
Expand Down
Loading

0 comments on commit 23b35ca

Please sign in to comment.