### Run StudioCMS Migration and Development Server Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/start-here/getting-started.mdx Execute these commands during initial setup or after schema updates to prepare the database and start the local development environment. ```shell ``` -------------------------------- ### Install Turso CLI Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/how-it-works/cli.mdx Displays usage information for the Turso CLI installer. ```log Usage: getTurso [options] Turso CLI Installer Options: -h, --help display help for command ``` -------------------------------- ### Install @studiocms/blog Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/package-catalog/studiocms-plugins/studiocms-blog.mdx Use the package manager to add the blog plugin to your project. ```bash npx studiocms add @studiocms/blog ``` -------------------------------- ### Install CFetch automatically Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/ecosystem/packages/cfetch.mdx Use the Astro CLI to automatically install the integration. ```bash npx astro add @studiocms/cfetch ``` -------------------------------- ### Configure dbStartPage Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/config-reference/index.mdx Controls the injection of the database initialization page during first-time setup. ```ts export default defineStudioCMSConfig({ dbStartPage: true, // DEFAULT - This injects a start page to setup your DB data. }) ``` -------------------------------- ### Setup Kysely Client Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/ecosystem/packages/kysely.mdx Initialize the database client using the LibSQL driver and Effect-ts configuration. ```ts import { getDBClientLive } from '@withstudiocms/kysely'; import type { StudioCMSDatabaseSchema } from '@withstudiocms/sdk/tables'; import { libsqlDriver } from '@withstudiocms/kysely/drivers/libsql'; import { ConfigProvider, Effect } from 'studiocms/effect'; export const getDbClient = Effect.gen(function* () { // Setup the LibSQL driver with a database URL from config const dialect = yield* libsqlDriver.pipe( Effect.withConfigProvider( ConfigProvider.fromJson({ CMS_LIBSQL_URL: 'file:./test.db', }) ) ); // Return the Kysely DB client with Effect helpers return yield* getDBClientLive(dialect); }); ``` -------------------------------- ### Install @studiocms/markdoc Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/package-catalog/studiocms-plugins/studiocms-markdoc.mdx Use the package manager command to add the integration to your project. ```bash npx studiocms add @studiocms/markdoc ``` -------------------------------- ### Install @studiocms/devapps via Astro CLI Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/package-catalog/studiocms-plugins/studiocms-devapps.mdx Use the Astro CLI to automatically install and configure the package. ```bash npx astro add @studiocms/devapps ``` -------------------------------- ### Install @studiocms/devapps manually Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/package-catalog/studiocms-plugins/studiocms-devapps.mdx Install the package via package manager and manually add it to the astro.config.mjs file. ```bash npm install @studiocms/devapps ``` ```ts import { defineConfig } from 'astro/config'; import studiocms from 'studiocms'; import devApps from '@studiocms/devapps'; export default defineConfig({ site: "https://example.com", integrations: [ studiocms(), // REQUIRED devApps(), ], }); ``` -------------------------------- ### Install @studiocms/md Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/package-catalog/studiocms-plugins/studiocms-md.mdx Use the package manager command to add the plugin to your project. ```bash npx studio-cms add @studiocms/md ``` -------------------------------- ### Start Docker Container Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/guides/database/sqld-server.mdx Launch the libSQL server container using Docker Compose. ```sh docker compose up -d ``` -------------------------------- ### Install @studiocms/mdx Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/package-catalog/studiocms-plugins/studiocms-mdx.mdx Use the package manager command to add the MDX plugin to your project. ```bash npx studiocms add @studiocms/mdx ``` -------------------------------- ### Install CFetch manually Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/ecosystem/packages/cfetch.mdx Install the package manually using your preferred package manager. ```bash npm install @studiocms/cfetch ``` -------------------------------- ### Install @studiocms/wysiwyg Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/package-catalog/studiocms-plugins/studiocms-wysiwyg.mdx Use the StudioCMS CLI to add the WYSIWYG plugin to your project. ```bash npx studiocms add @studiocms/wysiwyg ``` -------------------------------- ### Install StudioCMS Blog Plugin Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/start-here/getting-started.mdx Install the official blog plugin to quickly add a frontend to your StudioCMS project. ```shell ``` -------------------------------- ### Install peer dependencies Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/ecosystem/packages/cfetch.mdx Ensure the Effect library is installed as a peer dependency. ```bash npm install effect ``` -------------------------------- ### Start Astro Development Server Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/start-here/getting-started.mdx Use this command to launch the local development server for your Astro project. ```shell ``` -------------------------------- ### Setup Markdown Processor Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/ecosystem/packages/markdown-remark.mdx Initialize the processor using createMarkdownProcessor and export a render function for processing markdown strings. ```ts import { createMarkdownProcessor } from '@studiocms/markdown-remark/core'; import type { MarkdownProcessorRenderOptions } from '@studiocms/markdown-remark/types'; const processor = await createMarkdownProcessor({ /* * Your Options here * same as https://docs.astro.build/en/reference/configuration-reference/#markdown-options */ }); export async function render( content: string, options?: MarkdownProcessorRenderOptions ) { const result = await processor.render(content, options); return { html: result.astroHTML, meta: result.metadata, }; } ``` -------------------------------- ### Install @studiocms/html Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/package-catalog/studiocms-plugins/studiocms-html.mdx Use the package manager to add the HTML plugin to your StudioCMS project. ```bash npx studiocms add @studiocms/html ``` -------------------------------- ### Migrate database client dependencies Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/guides/upgrade/version-guides/0-1-0.mdx Commands to remove the deprecated libsql client and install the new kysely-turso package. ```bash ``` ```bash ``` -------------------------------- ### Install Cloudinary Plugin Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/package-catalog/studiocms-plugins/studiocms-cloudinary-js.mdx Use the StudioCMS CLI to add the Cloudinary image service package to your project. ```bash npx studiocms@latest add @studiocms/cloudinary-image-service ``` -------------------------------- ### Create a Custom StudioCMS Plugin Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/plugins/index.mdx Example implementation of a plugin using definePlugin, including an Astro Integration for custom logic. ```ts import { definePlugin } from 'studiocms/plugins'; import { AstroIntegration } from 'astro'; // Define the options for the plugin and integration interface Options { foo: string; } // Define the Astro integration const myIntegration = (options: Options): AstroIntegration => ({ name: 'my-astro-integration', hooks: { "astro:config:setup": () => { console.log('Hello from my Astro Integration!'); } } }); // Define the StudioCMS Plugin export const myPlugin = (options: Options) => definePlugin({ identifier: 'my-plugin', name: 'My Plugin', hooks: { 'studiocms:astro-config': ({ addIntegrations }) => { addIntegrations(myIntegration(options)) // Optional, but recommended } } }); ``` -------------------------------- ### cFetchText Interface and Usage Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/ecosystem/packages/cfetch.mdx Interface and example for fetching text data using Promises. ```ts const cFetchText: ( url: string | URL, options?: RequestInit | undefined, cacheConfig?: CFetchConfig | undefined ) => Promise> ``` ```ts import { cFetchText } from "c:fetch" const effect = await cFetchText( 'https://example.com', { method: "GET" } ); /* Return type: CachedResponse */ ``` -------------------------------- ### Get a user by ID using withCodec Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/ecosystem/packages/kysely.mdx Demonstrates retrieving a user record by ID using the withCodec helper with defined encoder and decoder schemas. ```ts import { getDBClientLive } from '@withstudiocms/kysely'; import type { StudioCMSDatabaseSchema } from '@withstudiocms/sdk/tables'; import { libsqlDriver } from '@withstudiocms/kysely/drivers/libsql'; import { ConfigProvider, Effect } from 'studiocms/effect'; export const getDbClient = Effect.gen(function* () { // Setup the LibSQL driver with a database URL from config const dialect = yield* libsqlDriver.pipe( Effect.withConfigProvider( ConfigProvider.fromJson({ CMS_LIBSQL_URL: 'file:./test.db', }) ) ); // Return the Kysely DB client with Effect helpers return yield* getDBClientLive(dialect); }); // ---cut--- import { Schema } from 'studiocms/effect'; import { StudioCMSUsersTable } from '@withstudiocms/sdk/tables'; export const insertUser = Effect.gen(function* () { const { withCodec } = yield* getDbClient; const getUserById = withCodec({ encoder: Schema.String, decoder: Schema.UndefinedOr(StudioCMSUsersTable.Select), callbackFn: (db, id) => db((client) => client.selectFrom('StudioCMSUsersTable') .selectAll() .where('id', '=', id) .executeTakeFirst() ), }); const user = yield* getUserById('some-user-id'); // ^? console.log('User by ID:', user); }); ``` -------------------------------- ### Navigate to Project Directory Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/start-here/getting-started.mdx Command to enter the newly created project folder. ```bash cd my-project ``` -------------------------------- ### Initialize StudioCMS project Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/how-it-works/cli.mdx Displays usage information for the project initialization command. ```log Usage: studiocms init [options] Initialize the StudioCMS project after new installation. Options: -d, --dry-run Dry run mode --skip-banners Skip all banners --debug Enable debug mode -h, --help Display help for command ``` -------------------------------- ### View CLI Help and Options Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/how-it-works/cli.mdx Displays the available commands and global options for the create-studiocms CLI. ```log Usage: create-studiocms [options] [command] Options: -V, --version Output the current version of the CLI Toolkit. -h, --help display help for command --color force color output --no-color disable color output Commands: get-turso Get the latest version of Turso. help Show help for command interactive* Start the interactive CLI. * Indicates the default command that is run when calling this CLI. ``` -------------------------------- ### Initialize and Run StudioCMS Project Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/index.mdx Use these commands to scaffold a new StudioCMS project and launch the local development server. ```sh # Create a new Astro project pnpm create studiocms@latest # Start the development server cd my-studiocms-project pnpm dev ``` -------------------------------- ### Insert a new user using withCodec Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/ecosystem/packages/kysely.mdx Demonstrates initializing a database client and using the withCodec helper to insert a new user record into the StudioCMSUsersTable. ```ts import { getDBClientLive } from '@withstudiocms/kysely'; import type { StudioCMSDatabaseSchema } from '@withstudiocms/sdk/tables'; import { libsqlDriver } from '@withstudiocms/kysely/drivers/libsql'; import { ConfigProvider, Effect } from 'studiocms/effect'; export const getDbClient = Effect.gen(function* () { // Setup the LibSQL driver with a database URL from config const dialect = yield* libsqlDriver.pipe( Effect.withConfigProvider( ConfigProvider.fromJson({ CMS_LIBSQL_URL: 'file:./test.db', }) ) ); // Return the Kysely DB client with Effect helpers return yield* getDBClientLive(dialect); }); // ---cut--- import { Schema } from 'studiocms/effect'; import { StudioCMSUsersTable } from '@withstudiocms/sdk/tables'; export const insertUser = Effect.gen(function* () { const { withCodec } = yield* getDbClient; const insertNewUser = withCodec({ encoder: StudioCMSUsersTable.Insert, decoder: StudioCMSUsersTable.Select, callbackFn: (db, newUser) => db((client) => client .insertInto('StudioCMSUsersTable') .values(newUser) .returningAll() .executeTakeFirstOrThrow() ), }); const data = { username: 'codec_user', email: 'codec_user@example.com', password: null, avatar: null, emailVerified: false, name: 'user', notifications: '', url: null, id: crypto.randomUUID(), updatedAt: new Date().toISOString(), createdAt: new Date().toISOString(), }; const insertedUser = yield* insertNewUser(data); // ^? console.log('Inserted user with codec:', insertedUser); }); ``` -------------------------------- ### Basic SDK Usage with Effect and JS Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/how-it-works/sdk.mdx Demonstrates how to interact with the SDK using the Effect pattern or the direct JS wrapper. ```ts /// // ---cut--- import { SDKCore, SDKCoreJs, runSDK } from 'studiocms:sdk'; import { Effect } from 'studiocms/effect'; // Create the Usable Effect const pagesEffect = Effect.gen(function* () { const sdk = yield* SDKCore; // then do something with the SDK return yield* sdk.GET.pages() }); // Convert the Effect into a JS/TS "program" const pagesResult1 = await runSDK(pagesEffect); // Just run the SDKCoreJS with the runSDK wrapper! const pagesResult2 = await runSDK(SDKCoreJs.GET.pages()); ``` -------------------------------- ### cFetch Interface and Usage Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/ecosystem/packages/cfetch.mdx Interface and example for the generic Promise-based fetch function. ```ts const cFetch: ( url: string | URL, parser: (response: Response) => Promise, options?: RequestInit | undefined, cacheConfig?: CFetchConfig | undefined ) => Promise> ``` ```ts import { cFetch } from "c:fetch" const effect = await cFetch<{ foo: string; bar: number; }>( 'https://api.example.com/data', (res) => res.json(), { method: "GET" } ); /* Return type: CachedResponse<{ foo: string; bar: number; }> */ ``` -------------------------------- ### cFetchEffect Interface and Usage Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/ecosystem/packages/cfetch.mdx Interface and example for the generic Effect-based fetch function. ```ts const cFetchEffect: ( url: string | URL, parser: (response: Response) => Promise, options?: RequestInit | undefined, cacheConfig?: CFetchConfig | undefined ) => Effect.Effect, FetchError, never> ``` ```ts import { cFetchEffect, Duration } from "c:fetch" const effect = cFetchEffect<{ foo: string; bar: number; }>( 'https://api.example.com/data', (res) => res.json(), { method: "GET" }, { ttl: Duration.hours(1), tags: ['example'], key: "api-data-fetch", verbose: false } ); /* Return type: Effect.Effect, FetchError, never> */ ``` -------------------------------- ### cFetchBlob Interface and Usage Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/ecosystem/packages/cfetch.mdx Interface and example for fetching Blob data using Promises. ```ts const cFetchBlob: ( url: string | URL, options?: RequestInit | undefined, cacheConfig?: CFetchConfig | undefined ) => Promise> ``` ```ts import { cFetchBlob } from "c:fetch" const effect = await cFetchBlob( 'https://example.com/image.png', { method: "GET" } ); /* Return type: CachedResponse */ ``` -------------------------------- ### cFetchJson Interface and Usage Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/ecosystem/packages/cfetch.mdx Interface and example for fetching JSON data using Promises. ```ts const cFetchJson: ( url: string | URL, options?: RequestInit | undefined, cacheConfig?: CFetchConfig | undefined ) => Promise> ``` ```ts import { cFetchJson } from "c:fetch" const effect = await cFetchJson<{ foo: string; bar: number; }>( 'https://api.example.com/data', { method: "GET" } ); /* Return type: CachedResponse<{ foo: string; bar: number; }> */ ``` -------------------------------- ### View studiocms CLI help Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/how-it-works/cli.mdx Displays the available options and commands for the main StudioCMS utility CLI. ```log Usage: studiocms [options] [command] Options: -V, --version Output the current version of the CLI Toolkit. -h, --help display help for command COMMANDS - add Add StudioCMS plugin(s) to your project - crypto Crypto Utilities for StudioCMS Security - get-turso Install the Turso CLI - init Initialize the StudioCMS project after new installation. - users Utilities for Tweaking Users in StudioCMS - migrate Manage database migrations for StudioCMS. ``` -------------------------------- ### cFetchEffectBlob Interface and Usage Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/ecosystem/packages/cfetch.mdx Interface and example for fetching Blob data using Effects. ```ts const cFetchEffectBlob: ( url: string | URL, options?: RequestInit | undefined, cacheConfig?: CFetchConfig | undefined ) => Effect.Effect, FetchError, never> ``` ```ts import { cFetchEffectBlob } from "c:fetch" const effect = cFetchEffectBlob( 'https://example.com/image.png', { method: "GET" } ); /* Return type: Effect.Effect, FetchError, never> */ ``` -------------------------------- ### cFetchEffectText Interface and Usage Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/ecosystem/packages/cfetch.mdx Interface and example for fetching text data using Effects. ```ts const cFetchEffectText: ( url: string | URL, options?: RequestInit | undefined, cacheConfig?: CFetchConfig | undefined ) => Effect.Effect, FetchError, never> ``` ```ts import { cFetchEffectText } from "c:fetch" const effect = cFetchEffectText( 'https://example.com', { method: "GET" } ); /* Return type: Effect.Effect, FetchError, never> */ ``` -------------------------------- ### cFetchEffectJson Interface and Usage Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/ecosystem/packages/cfetch.mdx Interface and example for fetching JSON data using Effects. ```ts const cFetchEffectJson: ( url: string | URL, options?: RequestInit | undefined, cacheConfig?: CFetchConfig | undefined ) => Effect.Effect, FetchError, never> ``` ```ts import { cFetchEffectJson } from "c:fetch" const effect = cFetchEffectJson<{ foo: string; bar: number; }>( 'https://api.example.com/data', { method: "GET" } ); /* Return type: Effect.Effect, FetchError, never> */ ``` -------------------------------- ### Enable Demo Mode Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/config-reference/features.mdx Configures demo mode with specific credentials for site access. ```ts import { defineStudioCMSConfig } from 'studiocms/config'; // ---cut--- export default defineStudioCMSConfig({ features: { developerConfig: { demoMode: { username: 'foo', password: 'bar' } } } }) ``` -------------------------------- ### Interactive CLI Command Options Source: https://github.com/withstudiocms/docs/blob/main/src/content/docs/en/how-it-works/cli.mdx Lists the specific flags available when running the interactive project creation command. ```log Usage: create-studiocms interactive [options] Start the interactive CLI. Powered by [clack](https://clack.cc). This command will open an interactive CLI prompt to guide you through the process of creating a new StudioCMS(or StudioCMS Ecosystem package) project using one of the available templates. Options: -t, --template