### Install Project Dependencies with Yarn Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/condo/docs/quick-start.md This command installs all the necessary project dependencies and links yarn workspaces. It ensures that all packages and their interdependencies are correctly set up for development. Requires Yarn to be installed globally. ```shell yarn ``` -------------------------------- ### Setup and Run Dev Portal API (Shell) Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/dev-portal-api/README.md This snippet outlines the steps to set up the environment, configure the database, install dependencies, and run the dev-portal-api using Docker Compose and Yarn workspaces. It includes creating a .env file, starting PostgreSQL and Redis, creating the database, installing packages, generating migrations, applying migrations, and finally starting the development server. ```shell # create .env file! cat > .env << ENDOFFILE DATABASE_URL=postgresql://postgres:postgres@127.0.0.1/dev-portal-api NODE_ENV=development DISABLE_LOGGING=true COOKIE_SECRET=random SERVER_URL=http://localhost:4016 ENDOFFILE # up database on default port docker-compose up -d postgresdb redis # create database if not exists docker exec condo_postgresdb_1 bash -c "su postgres -c \"createdb ${DATABASE_NAME}\"" # install dependencies and link yarn workspaces yarn # create first migration! yarn workspace @app/dev-portal-api makemigrations # migrate! yarn workspace @app/dev-portal-api migrate # run dev server! yarn workspace @app/dev-portal-api dev ``` -------------------------------- ### Install Open Condo Migrator Globally Source: https://github.com/open-condo-software/open-condo-platform/blob/main/docs/migration.md Installs the Open Condo migrator tool globally using npm. This is the simplest way to get started if you don't need to build from source. ```bash npm i -g @open-condo/migrator ``` -------------------------------- ### Initialize Project Environment and Run Application Source: https://github.com/open-condo-software/open-condo-platform/blob/main/packages/codegen/templates/app00/README.md This snippet sets up the project's environment variables, creates a .env file with development and production configurations, starts the PostgreSQL and Redis databases using Docker Compose, creates the project database, installs dependencies, builds the Docker image, prepares the application, and finally runs the development server. ```bash export DATABASE_NAME="{{ name }}" export SERVICE_LOCAL_PORT='3001' # create .env file! cat > .env << ENDOFFILE DATABASE_URL=postgresql://postgres:postgres@127.0.0.1/${DATABASE_NAME} NODE_ENV=development DISABLE_LOGGING=true COOKIE_SECRET=random SERVER_URL=http://localhost:${SERVICE_LOCAL_PORT} TESTS_FAKE_CLIENT_MODE=true # production docker deploy envs! DOCKER_FILE_INSTALL_COMMAND=python3 -m pip install 'psycopg2-binary>=2.8.5' && python3 -m pip install 'Django>=3.0.6' DOCKER_FILE_BUILD_COMMAND=echo yarn workspace @app/{{ name }} build DOCKER_COMPOSE_APP_IMAGE_TAG={{ name }} DOCKER_COMPOSE_START_APP_COMMAND=yarn workspace @app/{{ name }} start DOCKER_COMPOSE_DATABASE_URL=postgresql://postgres:postgres@postgresdb/main DOCKER_COMPOSE_COOKIE_SECRET=random DOCKER_COMPOSE_SERVER_URL=http://localhost:3003 ENDOFFILE # up database on default port docker-compose up -d postgresdb redis # create database if not exists docker exec condo_postgresdb_1 bash -c "su postgres -c \"createdb ${DATABASE_NAME}\"" # install dependencies and link yarn workspaces yarn # build first image! bash ./bin/warm-docker-cache docker-compose build # prepare the application using the prepare script node ./bin/prepare.js # run dev server! yarn workspace @app/{{ name }} dev ``` -------------------------------- ### Setup and Run Miniapp Development Environment Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/miniapp/README.md This snippet details the steps to set up the local development environment for the miniapp. It includes creating a .env file with necessary configurations, starting PostgreSQL and Redis databases using Docker Compose, creating the database if it doesn't exist, installing Node.js dependencies, building the Docker image, preparing the application, and finally starting the development server. ```bash export DATABASE_NAME="miniapp" export SERVICE_LOCAL_PORT='3001' # create .env file! cat > .env << ENDOFFILE DATABASE_URL=postgresql://postgres:postgres@127.0.0.1/${DATABASE_NAME} NODE_ENV=development DISABLE_LOGGING=true COOKIE_SECRET=random SERVER_URL=http://localhost:${SERVICE_LOCAL_PORT} TESTS_FAKE_CLIENT_MODE=true # production docker deploy envs! DOCKER_FILE_INSTALL_COMMAND=python3 -m pip install 'psycopg2-binary>=2.8.5' && python3 -m pip install 'Django>=3.0.6' DOCKER_FILE_BUILD_COMMAND=echo yarn workspace @app/miniapp build DOCKER_COMPOSE_APP_IMAGE_TAG=miniapp DOCKER_COMPOSE_START_APP_COMMAND=yarn workspace @app/miniapp start DOCKER_COMPOSE_DATABASE_URL=postgresql://postgres:postgres@postgresdb/main DOCKER_COMPOSE_COOKIE_SECRET=random DOCKER_COMPOSE_SERVER_URL=http://localhost:3003 ENDOFFILE # up database on default port docker-compose up -d postgresdb redis # create database if not exists docker exec condo_postgresdb_1 bash -c "su postgres -c \"createdb ${DATABASE_NAME}\"" # install dependencies and link yarn workspaces yarn # build first image! bash ./bin/warm-docker-cache docker-compose build # prepare the application using the prepare script node ./bin/prepare.js # run dev server! yarn workspace @app/miniapp dev ``` -------------------------------- ### Install Prerequisites for macOS Users Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/condo/docs/quick-start.md This script installs essential tools for macOS developers, including Homebrew, Node Version Manager (nvm), a specific Node.js version, and Yarn. It ensures the development environment is correctly set up by managing Node.js versions and installing global packages. ```shell brew install nvm nvm install v14.16.0 nvm alias default v14.16.0 node --version npm --version npm install -g yarn ``` -------------------------------- ### Start PostgreSQL and Redis Docker Containers Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/condo/docs/quick-start.md This command starts the PostgreSQL and Redis services in detached mode using Docker Compose. It's crucial for applications that rely on these databases for data storage and caching. Ensure Docker and Docker Compose are installed and configured. ```shell docker-compose up -d postgresdb redis ``` -------------------------------- ### Build Docker Images Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/condo/docs/quick-start.md This sequence of commands first warms the Docker cache by running a script and then builds the application's Docker image using Docker Compose. This prepares the application's environment for deployment or local execution within a container. Assumes Docker and Docker Compose are installed. ```shell bash ./bin/warm-docker-cache docker-compose build ``` -------------------------------- ### Initialize Husky Git Hooks Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/condo/docs/quick-start.md This command initializes Husky, a tool for managing git hooks, in your project. It helps automate tasks before or after git operations, ensuring code quality and consistency. No specific inputs or outputs are required, and it assumes you have npx installed. ```shell npx @husky/init ``` -------------------------------- ### Redis Migration Command Example Source: https://github.com/open-condo-software/open-condo-platform/blob/main/docs/migration.md Example command to initiate Redis Shake synchronization after configuring `shake.toml`. This command is used to start the data replication process. ```bash ./redis-shake shake.toml ``` -------------------------------- ### Address Service Quick Start and Environment Setup Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/address-service/README.md This snippet details the steps to set up and run the address-service locally. It includes setting environment variables, configuring the `.env` file for different providers and database connections, and launching the service using Docker Compose. It also covers initial dependency installation, database migrations, and building the Docker image. ```shell export DATABASE_NAME="address-service" export SERVICE_LOCAL_PORT='3001' # create .env file! cat > .env << ENDOFFILE PROVIDER=dadata DATABASE_URL=postgresql://postgres:postgres@127.0.0.1/${DATABASE_NAME} NODE_ENV=development DISABLE_LOGGING=true COOKIE_SECRET=random SERVER_URL=http://localhost:${SERVICE_LOCAL_PORT} TESTS_FAKE_CLIENT_MODE=true # production docker deploy envs! DOCKER_FILE_INSTALL_COMMAND=python3 -m pip install 'psycopg2-binary>=2.8.5' && python3 -m pip install 'Django>=3.0.6' DOCKER_FILE_BUILD_COMMAND=echo yarn workspace @app/address-service build DOCKER_COMPOSE_APP_IMAGE_TAG=address-service DOCKER_COMPOSE_START_APP_COMMAND=yarn workspace @app/address-service start DOCKER_COMPOSE_DATABASE_URL=postgresql://postgres:postgres@postgresdb/main DOCKER_COMPOSE_COOKIE_SECRET=random DOCKER_COMPOSE_SERVER_URL=http://localhost:3003 # for OIDC auth (login into admin interface) OIDC_CONFIG='{"serverUrl":"insert condo url", "clientId":"", "clientSecret":""}' # Config for dadata suggestions api DADATA_SUGGESTIONS='{"url": "https://suggestions.dadata.ru/suggestions/api/4_1/rs", "token": ""}' ENDOFFILE # up database on default port docker-compose up -d postgresdb redis # create database if not exists docker exec condo-postgresdb-1 bash -c "su postgres -c \"createdb ${DATABASE_NAME}\"" # install dependencies and link yarn workspaces yarn # build first image! bash ./bin/warm-docker-cache docker-compose build # create first migration! docker-compose run app yarn workspace @app/address-service makemigrations # migrate! docker-compose run app yarn workspace @app/address-service migrate # run dev server! yarn workspace @app/address-service dev ``` -------------------------------- ### Install kmigrator Dependencies Source: https://github.com/open-condo-software/open-condo-platform/blob/main/docs/develop.md Installs necessary Python packages for the database migration process. This includes Django and psycopg2-binary for PostgreSQL interaction. ```bash # install dependencies python3 -m pip install django python3 -m pip install psycopg2-binary ``` -------------------------------- ### App Root Component Setup with Apollo, Intl, and Auth Source: https://github.com/open-condo-software/open-condo-platform/blob/main/packages/next/README.md Demonstrates how to wrap the main application component (MyApp) with HOCs for Apollo client integration, internationalization, and authentication. This setup ensures these functionalities are available throughout the application. It requires installing `@open-condo/next/apollo`, `@open-condo/next/auth`, and `@open-condo/next/intl`. ```javascript import React from 'react' import { withApollo } from '@open-condo/next/apollo' import { withAuth } from '@open-condo/next/auth' import { withIntl } from '@open-condo/next/intl' const MyApp = ({ Component, pageProps }) => { return () } export default withApollo({ ssr: true })(withIntl({ ssr: true, messagesImporter: (locale) => import(`../lang/${locale}/${locale}`) })(withAuth({ ssr: false })(MyApp))) ``` -------------------------------- ### Start Condo App in Development Mode Source: https://github.com/open-condo-software/open-condo-platform/blob/main/README.md Starts the Open Condo application locally in development mode. This command should be run after all setup and preparation steps are complete. ```bash yarn workspace @app/condo dev ``` -------------------------------- ### Install Semgrep via Pip Source: https://github.com/open-condo-software/open-condo-platform/blob/main/docs/develop.md Installs the Semgrep static analysis tool using Python's pip package installer. This is an alternative method for installing Semgrep. ```shell python3 -m pip install semgrep ``` -------------------------------- ### KV Client Usage with Key Prefixes (TypeScript) Source: https://github.com/open-condo-software/open-condo-platform/blob/main/docs/migration.md Demonstrates how to use the `getKVClient` to interact with the Key-Value store. The client automatically prefixes keys based on the application's package name, ensuring data isolation in shared databases or clusters. This example shows setting and getting values, illustrating the automatic key prefixing behavior. ```typescript const { getKVClient } = require('@open-condo/keystone/kv') const kv = getKVClient() await kv.set('key:subkey', 'value1') // will be stored as “condo:key:subkey” in db const value = await kv.get('key:subkey') // value1 ``` ```typescript const { getKVClient } = require('@open-condo/keystone/kv') const kv = getKVClient() await kv.set('key:subkey', 'value2') // will be stored as “miniapp:key:subkey” in db const value = await kv.get('key:subkey') // value2 ``` -------------------------------- ### Apply Database Migrations Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/condo/docs/quick-start.md This command applies the pending database migrations to the application's database, ensuring the database schema is up-to-date. It executes the `migrate` command within the Condominium workspace inside a Docker container. Requires Docker and Yarn. ```shell docker-compose run app yarn workspace @app/condo migrate ``` -------------------------------- ### Build and Install Local Open Condo Migrator Source: https://github.com/open-condo-software/open-condo-platform/blob/main/docs/migration.md Builds the Open Condo migrator tool from the local repository. This process involves installing monorepo dependencies, building the migrator workspace, and then running yarn again to place the built package into the monorepo's node_modules. ```bash yarn yarn workspace @open-condo/migrator build yarn ``` -------------------------------- ### Install k6 on Linux using APT Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/condo/k6/README.md Installs the k6 performance testing tool on Debian-based Linux systems using the APT package manager. This involves adding the k6 repository and then installing the package. ```bash sudo gpg -k sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69 echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list sudo apt-get update sudo apt-get install k6 ``` -------------------------------- ### Manage PostgreSQL Schema Migrations Source: https://github.com/open-condo-software/open-condo-platform/blob/main/packages/codegen/templates/app00/README.md This section provides commands for managing PostgreSQL database schema migrations. It includes creating new migration scripts, applying pending migrations to the database, and rolling back the last applied migration. ```bash # create migration script at migrations/20201212124723-00xx_name.js docker-compose run app yarn workspace @app/{{ name }} makemigrations # migrate current DB to new schema docker-compose run app yarn workspace @app/{{ name }} migrate # if you needed to rollback applyed migration docker-compose run app yarn workspace @app/{{ name }} kmigrator down ``` -------------------------------- ### Start Databases with Docker Compose Source: https://github.com/open-condo-software/open-condo-platform/blob/main/README.md Starts the PostgreSQL and Redis databases using Docker Compose. This is a prerequisite for running the Open Condo platform locally. ```bash docker compose up -d postgresdb redis ``` -------------------------------- ### Install Semgrep via Homebrew Source: https://github.com/open-condo-software/open-condo-platform/blob/main/docs/develop.md Installs the Semgrep static analysis tool using the Homebrew package manager. Semgrep helps identify vulnerable code patterns. ```shell brew install semgrep ``` -------------------------------- ### Install Node.js Dependencies with Yarn Source: https://github.com/open-condo-software/open-condo-platform/blob/main/README.md Installs all project dependencies using Yarn. This command should be run after cloning the repository. ```bash yarn install ``` -------------------------------- ### Install Python Dependencies with Pip Source: https://github.com/open-condo-software/open-condo-platform/blob/main/README.md Installs necessary Python packages for database migrations, including Django and psycopg2-binary. ```bash pip install Django psycopg2-binary ``` -------------------------------- ### Add Package to All Apps (Monorepo) Source: https://github.com/open-condo-software/open-condo-platform/blob/main/docs/develop.md Installs a specified package to all applications within the monorepo. The '-W' flag indicates a workspace-wide installation. ```bash yarn add -W # Example: yarn add react react-dom -W ``` -------------------------------- ### Install Turbo CLI Globally Source: https://github.com/open-condo-software/open-condo-platform/blob/main/README.md Installs the Turbo build system CLI globally. This is recommended if the 'turbo' command is not found after running 'yarn install'. ```bash npm i -g turbo@^2 ``` -------------------------------- ### Install All Packages with NPM Source: https://github.com/open-condo-software/open-condo-platform/blob/main/packages/miniapp-utils/README.md Installs the `@open-condo/miniapp-utils` package along with its core peer dependencies (React, ReactDOM, Apollo Client) using NPM. This is the recommended approach for projects needing the full suite of utilities. ```bash npm i @open-condo/miniapp-utils react react-dom @apollo/client ``` -------------------------------- ### Declare Environment Variables for Development Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/condo/docs/quick-start.md This command creates and populates a `.env` file with essential environment variables for local development. It configures database connection, Node.js environment, logging, session secrets, server URL, and Docker-specific build and run commands. The content is piped into the `.env` file. ```shell cat > .env << ENDOFFILE DATABASE_URL=postgresql://postgres:postgres@127.0.0.1/main NODE_ENV=development DISABLE_LOGGING=true COOKIE_SECRET=random SERVER_URL=http://localhost:3000 TESTS_FAKE_CLIENT_MODE=true # production docker deploy envs! DOCKER_FILE_INSTALL_COMMAND="python3 -m pip install 'psycopg2-binary>=2.8.5' && python3 -m pip install 'Django>=3.0.6'" DOCKER_FILE_BUILD_COMMAND="echo yarn workspace @app/condo build" DOCKER_COMPOSE_APP_IMAGE_TAG=condo DOCKER_COMPOSE_START_APP_COMMAND="yarn workspace @app/condo start" DOCKER_COMPOSE_START_WORKER_COMMAND="yarn workspace @app/condo worker" DOCKER_COMPOSE_MIGRATION_COMMAND="yarn workspace @app/condo migrate" DOCKER_COMPOSE_DATABASE_URL=postgresql://postgres:postgres@postgresdb/main DOCKER_COMPOSE_COOKIE_SECRET=random DOCKER_COMPOSE_SERVER_URL=http://localhost:3003 ENDOFFILE ``` -------------------------------- ### Install All Packages with Yarn Source: https://github.com/open-condo-software/open-condo-platform/blob/main/packages/miniapp-utils/README.md Installs the `@open-condo/miniapp-utils` package along with its core peer dependencies (React, ReactDOM, Apollo Client) using Yarn. This command is equivalent to the NPM installation but uses Yarn's package management system. ```bash yarn add @open-condo/miniapp-utils react react-dom @apollo/client ``` -------------------------------- ### Add Package to Specific App (Monorepo) Source: https://github.com/open-condo-software/open-condo-platform/blob/main/docs/develop.md Installs a specified package to a particular application workspace. Replace `` with the app's directory name (e.g., 'web'). ```bash yarn workspace @app/ add # Example: yarn workspace @app/web add react react-dom ``` -------------------------------- ### Install @open-condo/migrator Package (Local Usage) Source: https://github.com/open-condo-software/open-condo-platform/blob/main/packages/migrator/README.md Installs the @open-condo/migrator package as a development dependency in your project. This allows for direct execution of the CLI commands after installation. ```bash yarn add -D @open-condo/migrator ``` -------------------------------- ### Install @open-condo/ui with npm Source: https://github.com/open-condo-software/open-condo-platform/blob/main/packages/ui/README.md Installs the @open-condo/ui package using npm. This is the primary method for adding the library to your project if you use npm as your package manager. ```bash npm i @open-condo/ui ``` -------------------------------- ### Dokku Server Setup and Configuration Source: https://github.com/open-condo-software/open-condo-platform/blob/main/docs/deploy.md This script installs necessary Dokku plugins for Let's Encrypt, PostgreSQL, and Redis. It also sets global Dokku configuration for Let's Encrypt email and adds a cron job for certificate renewal. ```shell script # Prepare dokku dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres dokku plugin:install https://github.com/dokku/dokku-redis.git redis dokku config:set --global DOKKU_LETSENCRYPT_EMAIL=contact@8iq.dev dokku letsencrypt:cron-job --add ``` -------------------------------- ### Generate TypeScript GraphQL Types Source: https://github.com/open-condo-software/open-condo-platform/blob/main/packages/codegen/templates/app00/README.md This command generates a './schema.d.ts' file containing all GraphQL types for the project, ensuring type safety between the GraphQL schema and the TypeScript code. ```bash # create ./schema.d.ts file with all GQL types yarn workspace @app/{{ name }} maketypes ``` -------------------------------- ### Example DATABASE_URL Configuration (dotenv) Source: https://github.com/open-condo-software/open-condo-platform/blob/main/packages/keystone/databaseAdapters/BalancingReplicaKnexAdapter/README.md This shows an example of how the `DATABASE_URL` environment variable would be formatted in a .env file, using the custom protocol and a JSON stringified object of named databases. ```dotenv DATABASE_URL=custom:{"main":"****://****:postgres@127.0.0.1:5432/main","replica":"****://****:postgres@127.0.0.1:5433/replica"} ``` -------------------------------- ### Install k6 on macOS using Homebrew Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/condo/k6/README.md Installs the k6 performance testing tool on macOS using the Homebrew package manager. This is a prerequisite for running performance tests natively on macOS. ```bash brew install k6 ``` -------------------------------- ### Install @open-condo/bridge with npm or yarn Source: https://github.com/open-condo-software/open-condo-platform/blob/main/packages/bridge/README.md Instructions for installing the @open-condo/bridge package using either npm or yarn package managers. This is the initial step before integrating the library into your project. ```bash npm i @open-condo/bridge ``` ```bash yarn add @open-condo/bridge ``` -------------------------------- ### Install Condo Bridge using package managers Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/dev-portal-web/docs/bridge/about.en.mdx Instructions for installing the Condo Bridge library using npm, yarn, or pnpm. This is the first step to integrate the library into your project. ```bash npm i @open-condo/bridge ``` ```bash yarn add @open-condo/bridge ``` ```bash pnpm i @open-condo/bridge ``` -------------------------------- ### Install @open-condo/webhooks Package Source: https://github.com/open-condo-software/open-condo-platform/blob/main/packages/webhooks/README.md Installs the webhooks extension to a Keystone5 app using yarn. This is the first step to integrating webhook functionality. ```bash yarn add @open-condo/webhooks ``` -------------------------------- ### Install @open-condo/apollo with NPM Source: https://github.com/open-condo-software/open-condo-platform/blob/main/packages/apollo/README.md Installs the @open-condo/apollo package along with its peer dependencies (react, react-dom, @apollo/client) using the npm package manager. ```bash npm i @open-condo/apollo react react-dom @apollo/client ``` -------------------------------- ### Install Open Condo UI with npm, yarn, or pnpm Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/dev-portal-web/docs/ui/about.en.mdx Installs the Open Condo UI library using different package managers. Choose the command corresponding to your preferred package manager. ```bash npm i @open-condo/ui ``` ```bash yarn add @open-condo/ui ``` ```bash pnpm i @open-condo/ui ``` -------------------------------- ### Install @open-condo/icons with yarn Source: https://github.com/open-condo-software/open-condo-platform/blob/main/packages/icons/README.md This snippet demonstrates how to install the @open-condo/icons package using yarn, an alternative package manager. This command achieves the same result as the npm installation, adding the icon library to your project's dependencies. ```bash yarn add @open-condo/icons ``` -------------------------------- ### Install @open-condo/apollo with Yarn Source: https://github.com/open-condo-software/open-condo-platform/blob/main/packages/apollo/README.md Installs the @open-condo/apollo package along with its peer dependencies (react, react-dom, @apollo/client) using the yarn package manager. ```bash yarn add @open-condo/apollo react react-dom @apollo/client ``` -------------------------------- ### Install @open-condo/tsconfig with npm Source: https://github.com/open-condo-software/open-condo-platform/blob/main/packages/tsconfig/README.md Installs the @open-condo/tsconfig package using npm. This is the primary method for adding the package as a dependency to your project. ```bash npm i @open-condo/tsconfig ``` -------------------------------- ### Install Git Pre-commit Hooks with Husky Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/condo/docs/development/local-setup.md This command installs the necessary pre-commit hooks managed by Husky into your local Git repository. Running this command ensures that code quality checks and other defined hooks are executed automatically before each commit, helping to maintain code standards. ```shell yarn run prepare ``` -------------------------------- ### Run k6 tests with native package Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/condo/k6/README.md Executes k6 performance tests using a locally installed k6 package. It requires setting environment variables for BASE_URL, AUTH_EMAIL, and AUTH_PASSWORD, and then running webpack before the k6 test. ```bash export BASE_URL=http://localhost:3000 export AUTH_EMAIL=user@example.com export AUTH_PASSWORD=secret_example yarn --cwd . webpack && k6 run ``` -------------------------------- ### Start PostgreSQL Docker Container Source: https://github.com/open-condo-software/open-condo-platform/blob/main/docs/db-upgrade.md This command starts the PostgreSQL Docker container, typically after it has been stopped or if it needs to be newly created. It ensures the database service is available. ```bash docker compose up -d postgresdb ``` -------------------------------- ### Example DATABASE_POOLS Configuration (dotenv) Source: https://github.com/open-condo-software/open-condo-platform/blob/main/packages/keystone/databaseAdapters/BalancingReplicaKnexAdapter/README.md This shows an example of the `DATABASE_POOLS` environment variable formatted in a .env file. It uses a JSON stringified object to define pools, specifying which databases belong to each pool and their writability. ```dotenv DATABASE_POOLS='{"main":{"databases":["main"],"writable":true},"replicas":{"databases":["replica"],"writable":false}}' ``` -------------------------------- ### Run @open-condo/migrator CLI (Local & Remote - No Install) Source: https://github.com/open-condo-software/open-condo-platform/blob/main/packages/migrator/README.md Executes the @open-condo/migrator CLI tool. This command can be run locally after building or remotely without prior installation. It displays the help menu for available commands. ```bash npx @open-condo/migrator --help ``` -------------------------------- ### Condo Bridge API: supports method example Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/dev-portal-web/docs/bridge/about.en.mdx Example of using the `bridge.supports` method to check if a specific method is available in the runtime environment before attempting to send an event. This helps in creating more robust applications. ```typescript // Checking if event is available if (bridge.supports('CondoWebAppResizeWindow')) { // Then sending actual event bridge.send('CondoWebAppResizeWindow', { height: document.body.scrollHeight }) } ``` -------------------------------- ### Prepare Local App Environment Source: https://github.com/open-condo-software/open-condo-platform/blob/main/README.md Prepares the local application environment by copying .env files, creating databases, setting ports, and running application-specific preparation scripts. This is for local development only. ```bash node bin/prepare -f condo ``` -------------------------------- ### Setup and Schema Creation for Open-Condo Platform Source: https://github.com/open-condo-software/open-condo-platform/blob/main/packages/codegen/README.md This snippet demonstrates the process of setting up a new application within the Open-Condo platform, creating schemas for user and friend data, generating types, and managing database migrations. It includes commands for creating a new app, defining schema fields, generating TypeScript types, and applying or reverting migrations. ```bash export APP=name7 yarn createapp ${APP} yarn workspace @app/${APP} createschema user.User "name:Text; email:Text; password?:Password; isAdmin:Checkbox; manager?:Relationship:User:SET_NULL; isMan:Select:man,woman" yarn workspace @app/${APP} createschema user.Friend "name:Text; friend1:Relationship:User:SET_NULL" yarn workspace @app/${APP} maketypes yarn workspace @app/${APP} makemigrations yarn workspace @app/${APP} createservice User.UpdateFriendsService --type queries|mutations yarn workspace @app/${APP} migrate yarn workspace @app/${APP} migrate:down ``` -------------------------------- ### Build Condo Dependencies Source: https://github.com/open-condo-software/open-condo-platform/blob/main/README.md Builds the internal `@open-condo` packages located in the `./packages` directory. This step is required before launching the main application. ```bash yarn workspace @app/condo build:deps ``` -------------------------------- ### GET /CondoWebAppGetActiveProgressBars Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/dev-portal-web/docs/bridge/methods/notifications/get-active-progress-bars.en.mdx Retrieves all active progress bar notifications that have not been closed by the user. It is recommended to call this method every time the mini-app is started to keep tasks in sync. ```APIDOC ## GET /CondoWebAppGetActiveProgressBars ### Description Retrieves all active progress bar notifications that have not been closed by the user. It is recommended to call this method every time the mini-app is started to keep tasks in sync. ### Method GET ### Endpoint /CondoWebAppGetActiveProgressBars ### Parameters This method takes no parameters. ### Request Example ```typescript jsx import bridge from '@open-condo/bridge' bridge.send('CondoWebAppGetActiveProgressBars').then((data) => { console.log(data.bars) }) ``` ### Response #### Success Response (200) - **bars** (array) - An array containing active progress bar objects. - **id** (string) - The unique identifier for the progress bar. - **message** (string) - The main message for the progress bar. - **description** (string) - Additional description for the progress bar. - **progress** (number) - The current progress value (0-100). - **externalTaskId** (string) - The identifier of the external task associated with the progress bar. #### Response Example ```json { "bars": [ { "id": "9e4dd15a-aec6-4d81-90e3-fab58deac8c0", "message": "Uploading some data", "description": "Please keep the page open", "progress": 0, "externalTaskId": "de74da8d-207a-4a25-bf52-5bce25efe860" }, { "id": "30cc8153-2d71-4be5-98dd-f2eae4cbfc82", "message": "Uploading some data", "description": "Please keep the page open", "progress": 0, "externalTaskId": "2179294d-f77e-4d54-9bac-94094f94adcc" } ] } ``` ``` -------------------------------- ### Redis Data Version Update Command Source: https://github.com/open-condo-software/open-condo-platform/blob/main/docs/migration.md Command to update the data version in the original Redis database after synchronization has started. This acts as a guard to ensure proper data flow during migration. ```redis SET data_version 2 ``` -------------------------------- ### Get Authenticated User Details (cURL) Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/dev-portal-web/docs/api/examples/auth.en.mdx This cURL command demonstrates how to query for the details of the currently authenticated user using a bearer token. It sends a JSON payload with the query to the API endpoint. This is a command-line example. ```bash curl 'https://condo.d.doma.ai/admin/api' -H 'Authorization: Bearer XnwCETJ2-0bcG1l-gQgFHs8973izf9Gz.26mZWez8e3j0l43HUB8noqxWtfMLwnkQ6IitR9z2v0o' -H 'Content-Type: application/json' --data-raw '{"variables":{},"query":"query { authenticatedUser { id name avatar { publicUrl __typename } phone email isAdmin __typename }}"}' ``` -------------------------------- ### RedisShake Configuration for Migration Source: https://github.com/open-condo-software/open-condo-platform/blob/main/docs/migration.md A TOML configuration example for RedisShake, a tool used for data migration and transformation. This configuration is part of the minimal downtime migration strategy, facilitating real-time replication with key prefix additions. ```toml # Configuration for RedisShake (example structure) # Ensure to replace placeholders and adjust settings as per RedisShake documentation [source] host = "your_source_redis_host" port = 6379 password = "your_source_password" [target] host = "your_target_redis_host" port = 6379 password = "your_target_password" [filter] key_prefix_add = "new_prefix_" # Other relevant filters and options can be added here ``` -------------------------------- ### Drop Database and Reapply All Migrations Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/condo/docs/migrations.md This command sequence completely resets the database by stopping services, restarting the PostgreSQL and Redis databases, and then reapplying all pending migrations. It's useful for a fresh start or after significant schema changes. Ensure `docker-compose` is configured correctly for your environment. ```bash docker-compose down && docker-compose up -d postgresdb redis && docker-compose run app yarn workspace @app/condo makemigrations && docker-compose run app yarn workspace @app/condo migrate ``` -------------------------------- ### Manage PostgreSQL Schema Migrations Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/miniapp/README.md This snippet demonstrates how to manage PostgreSQL database schema migrations for the miniapp. It covers creating new migration scripts, applying pending migrations to the database, and rolling back the last applied migration. ```bash # create migration script at migrations/20201212124723-00xx_name.js docker-compose run app yarn workspace @app/miniapp makemigrations # migrate current DB to new schema docker-compose run app yarn workspace @app/miniapp migrate # if you needed to rollback applyed migration docker-compose run app yarn workspace @app/miniapp kmigrator down ``` -------------------------------- ### Get Help for Createservice Utility Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/condo/docs/utils/createservice.md Displays help information for the 'createservice' utility, detailing its usage and options. This is useful for understanding how to structure commands for generating new services. ```shell yarn workspace @app/${APP} createservice --help ``` -------------------------------- ### Example JWT Payload for x-proxy-signature Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/dev-portal-web/docs/api/proxying.en.mdx An example illustrating the content of the JWT payload used for creating the `x-proxy-signature`. This example includes specific values for a proxy ID, user IP, timestamp, HTTP method, and request path. ```json { "x-proxy-id": "my-proxy-123", "x-proxy-ip": "1.2.3.4", "x-proxy-timestamp": "1756633489141", "method": "POST", "url": "/admin/api" } ``` -------------------------------- ### Build and Run Open Conda Platform in Production Mode Source: https://github.com/open-condo-software/open-condo-platform/blob/main/README.md Executes the build command for the Open Conda Platform and then starts the application in production mode. The application will be accessible via a web browser. Users can configure the port by modifying the `apps/condo/.env` file. ```bash yarn workspace @app/condo build yarn workspace @app/condo start ``` -------------------------------- ### Basic Condo Bridge Usage Examples (JS and HTML) Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/dev-portal-web/docs/bridge/about.en.mdx Demonstrates basic usage of the Condo Bridge library. It shows how to send events with and without arguments, and how to handle responses using Promises. Includes examples for both direct JavaScript integration and usage within an HTML script tag. ```typescript import bridge from '@open-condo/bridge' // Send event bridge.send('') // Send event with args bridge.send('', { someArg: 'some value' }) // Send event and process response bridge.send('', { someArg: 'some value' }) .then((response) => { // successful state processing }).catch((error) => { // error processing }) ``` ```html ``` -------------------------------- ### Q Object Examples for Query Conditions Source: https://github.com/open-condo-software/open-condo-platform/blob/main/docs/kmigrator.md This section provides various examples of using Q objects to construct complex query conditions. It demonstrates lookups for greater than, less than, exact matches, null checks, case-insensitive comparisons, list containment, date ranges, and regular expression matching, along with their corresponding SQL equivalents. ```javascript // Greater than or equal to Q(age__gte=18) // Greater than Q(age__gt=18) // Less than Q(age__lt=18) // StartAt less than finishAt Q(startAt__lt=models.F("finishAt")) // Exact match Q(id__exact=14) // IS NULL check Q(id__exact=None) // Case-insensitive exact match Q(name__iexact='beatles blog') // Combined checks (IS NULL or LIKE) Q(name__iexact=None) & Q(sname__iexact='beatles blog') // Combined checks (LIKE or IS NULL) Q(name__iexact=None) | Q(sname__iexact='beatles blog') // Case-sensitive containment Q(headline__contains='Lennon') // Case-insensitive containment Q(headline__icontains='Lennon') // In a list Q(id__in=[1, 3, 4]) // In a string (character by character) Q(headline__in='abc') // Date range (inclusive) Q(pub_date__range=(date(2005, 1, 1), date(2005, 3, 31))) // Date part greater than Q(pub_time__date__gt=date(2005, 1, 1)) // Year exact match Q(pub_date__year=2005) // Time exact match Q(pub_date__time=time(14, 30)) // Case-insensitive regex match Q(title__iregex=r'^(An?|The) +') // Not NULL check Q(phone__isnull=False) ``` -------------------------------- ### Install @open-condo/ui Package Source: https://github.com/open-condo-software/open-condo-platform/blob/main/apps/dev-portal-web/docs/mdx.en.mdx This snippet shows how to add the @open-condo/ui package to your project using yarn. It's a basic command-line operation. ```bash yarn add @open-condo/ui ``` -------------------------------- ### Email Subject Translation String Example Source: https://github.com/open-condo-software/open-condo-platform/blob/main/docs/localization.md Example of a JSON translation string for an email subject, including dynamic placeholders for message metadata. ```json { ... "notification.messages.TICKET_ASSIGNEE_CONNECTED.email.subject": "You were assigned as responsible of ticket #{data.ticketNumber}", ... ``` -------------------------------- ### Install @open-condo/tsconfig with yarn Source: https://github.com/open-condo-software/open-condo-platform/blob/main/packages/tsconfig/README.md Installs the @open-condo/tsconfig package using yarn. This provides an alternative package management method for integrating the configuration into your project. ```bash yarn add @open-condo/tsconfig ``` -------------------------------- ### Excel Column Header Translation String Example Source: https://github.com/open-condo-software/open-condo-platform/blob/main/docs/localization.md Example of JSON translation strings for column headers in exported Excel files, using the 'excelExport.headers' format. ```json { ... "excelExport.headers.payments.date": "Date", "excelExport.headers.payments.account": "Account", "excelExport.headers.payments.address": "Address", "excelExport.headers.payments.unitName": "Unit name", "excelExport.headers.payments.type": "Type", "excelExport.headers.payments.transaction": "Transaction", "excelExport.headers.payments.amount": "Amount", "excelExport.headers.contacts.name": "Name", "excelExport.headers.contacts.address": "Address", "excelExport.headers.contacts.unitName": "Unit name", "excelExport.headers.contacts.phone": "Phone", "excelExport.headers.contacts.email": "Email", ... ``` -------------------------------- ### Excel Sheet Name Translation String Example Source: https://github.com/open-condo-software/open-condo-platform/blob/main/docs/localization.md Example of a JSON translation string for naming sheets in exported Excel files, following the 'excelExport.sheetNames' convention. ```json { ... "excelExport.sheetNames.buildings": "Buildings", "excelExport.sheetNames.tickets": "Tickets", ... ``` -------------------------------- ### Create and Configure Dokku Application Source: https://github.com/open-condo-software/open-condo-platform/blob/main/docs/deploy.md This script creates a new application on the Dokku server, links it with PostgreSQL and Redis services, and sets various configuration variables for the application's runtime environment, including Node.js settings, URLs, and secrets. ```shell script # CREATE DOKKU APPLICATION ON DOKKU SERVER SIDE export APP=node5 export APP_VERSION=v5 export DOCKER_IMAGE=apps:condo export START_WEB_COMMAND='yarn workspace @app/condo start' export START_WORKER_COMMAND='yarn workspace @app/condo worker' dokku apps:create ${APP} POSTGRES_IMAGE='postgres' POSTGRES_IMAGE_VERSION='13.2' dokku postgres:create ${APP} dokku postgres:link ${APP} ${APP} REDIS_IMAGE='redis' REDIS_IMAGE_VERSION='6.2' dokku redis:create ${APP} dokku redis:link ${APP} ${APP} dokku config:set --no-restart ${APP} NODE_ENV=production dokku config:set --no-restart ${APP} SERVER_URL=https://${APP}.dev.doma.ai dokku config:set --no-restart ${APP} START_WEB_COMMAND="${START_WEB_COMMAND}" dokku config:set --no-restart ${APP} START_WORKER_COMMAND="${START_WORKER_COMMAND}" dokku config:set --no-restart ${APP} COOKIE_SECRET=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) dokku checks:disable ${APP} dokku proxy:ports-set ${APP} http:80:5000 dokku nginx:set ${APP} hsts false dokku nginx:set ${APP} hsts-include-subdomains false docker tag ${DOCKER_IMAGE} dokku/${APP}:${APP_VERSION} dokku tags:deploy ${APP} ${APP_VERSION} docker exec -it -u root ${APP}.web.1 yarn workspace @app/CODDI migrate dokku letsencrypt ${APP} ``` -------------------------------- ### Push Notification Title Translation String Example Source: https://github.com/open-condo-software/open-condo-platform/blob/main/docs/localization.md Example of a JSON translation string for a push notification title, similar to email subjects with dynamic placeholders. ```json { ... "notification.messages.TICKET_ASSIGNEE_CONNECTED.push.title": "You were assigned as responsible of ticket #{data.ticketNumber}", ... ```