Update mutations and readme files in scripts (#67)

This commit is contained in:
Hakan Shehu
2025-06-15 12:52:24 +02:00
committed by GitHub
parent 9294600c61
commit ee6b749c60
4 changed files with 103 additions and 24 deletions

View File

@@ -23,19 +23,40 @@ By consolidating emojis from [Emoji Mart](https://github.com/missive/emoji-mart)
3. **Process & Generate**
- Initializes or updates an `emojis.db` SQLite database in `src/emojis/`.
The script creates two database files and an SVG sprite:
**Full Database (`emojis.db`)**:
- Initializes or updates an `emojis.db` SQLite database in `../assets/emojis/`.
- Creates (or reuses) the following tables:
- **categories** (stores category info like name, display order, etc.)
- **emojis** (stores each emojis core data, such as code, name, tags, emoticons, etc.)
- **emoji_svgs** (stores each emoji skins SVG image as a BLOB)
- **emojis** (stores each emoji's core data, such as code, name, tags, emoticons, etc.)
- **emoji_svgs** (stores each emoji skin's SVG image as a BLOB)
- **emoji_search** (FTS table for search queries across emoji names, tags, etc.)
- Stores each emoji skin's SVG data as a BLOB in the `emoji_svgs` table.
**Minimal Database (`emojis.min.db`)**:
- Creates a lightweight version of the database without storing SVG data as BLOBs.
- Contains the same tables as the full database, except:
- **emoji_skins** (references emoji skins without storing SVG data)
- No `emoji_svgs` table (SVG data is available via the sprite instead)
- Used in web app for emoji listing and search, because of some browser limitations on using the full database.
**SVG Sprite (`emojis.svg`)**:
- Generates a comprehensive SVG sprite containing all emoji skins as symbols.
- Each emoji skin is accessible via its unique skin ID as a symbol reference.
- Used in web app for emoji rendering, because of some browser limitations on using the full database.
**Additional Processing**:
- Merges any existing data so as not to overwrite or lose previously assigned IDs. This ensures emojis already in use retain consistent IDs in the Colanode app.
- Stores each emoji skins SVG data as a BLOB in a separate `emoji_svgs` table.
- Maintains a full-text search (`emoji_search`) table for easy querying by name or tags.
4. **Cleanup**
- Removes the temporary working directory once processing is complete.
- Leaves you with a fully updated `emojis.db` containing all the emoji data and SVG images.
- Leaves you with updated `emojis.db`, `emojis.min.db`, and `emojis.svg` files containing all the emoji data and assets.
## Usage
@@ -51,11 +72,15 @@ By consolidating emojis from [Emoji Mart](https://github.com/missive/emoji-mart)
npm run generate:emojis
```
Once the script completes, youll have a fresh `emojis.db` file that contains all relevant emoji metadata (IDs, categories, tags, etc.) and their corresponding SVG assets.
Once the script completes, you'll have:
- A full `emojis.db` file with all emoji metadata and SVG data as BLOBs
- A minimal `emojis.min.db` file with metadata only (no SVG BLOBs)
- An `emojis.svg` sprite file containing all emoji graphics as symbols
## Notes on Licensing
While **Colanode** is open source under its own [license terms](../../../LICENSE) (in the root of the monorepo), the emojis retrieved from **Emoji Mart** and **Twemoji** are subject to their respective licenses. Please review their repositories for details:
- [missive/emoji-mart](https://github.com/missive/emoji-mart)
- [jdecked/twemoji (originally Twitters Twemoji)](https://github.com/jdecked/twemoji)
- [jdecked/twemoji (originally Twitter's Twemoji)](https://github.com/jdecked/twemoji)

View File

@@ -8,8 +8,8 @@ By consolidating icons from [Remix Icon](https://github.com/Remix-Design/RemixIc
1. **Download Required Repositories**
- **Remix Icon** (from GitHub tag `v4.6.0`): Provides an extensive set of general-purpose icons, each organized into categories (e.g., System,” “User Interface, etc.).
- **Simple Icons** (from GitHub tag `v14.3.0`): Provides icons for popular brands, making it easy to visually represent external services or technologies.
- **Remix Icon** (from GitHub tag `v4.6.0`): Provides an extensive set of general-purpose icons, each organized into categories (e.g., "System," "User Interface," etc.).
- **Simple Icons** (from GitHub tag `v14.13.0`): Provides icons for popular brands, making it easy to visually represent external services or technologies.
2. **Extract & Organize Files**
The script:
@@ -21,21 +21,40 @@ By consolidating icons from [Remix Icon](https://github.com/Remix-Design/RemixIc
3. **Process & Generate**
- Initializes or updates an `icons.db` SQLite database in `src/icons/`.
- Merges any existing metadata so that icons already in use keep their same IDs.
The script creates two database files and an SVG sprite:
**Full Database (`icons.db`)**:
- Initializes or updates an `icons.db` SQLite database in `../assets/icons/`.
- Creates (or reuses) the following tables:
- **categories** (stores category info like name, display order, etc.)
- **icons** (stores each icons core data, such as code, name, tags, etc.)
- **icon_svgs** (stores each icons SVG image as a BLOB)
- **icons** (stores each icon's core data, such as code, name, tags, etc.)
- **icon_svgs** (stores each icon's SVG image as a BLOB)
- **icon_search** (FTS table for search queries across icon names, tags, etc.)
- Organizes icons into categories (e.g., “System” categories from Remix Icon and a “Logos” category for all Simple Icons).
- Stores each icon's SVG data as a BLOB in the `icon_svgs` table.
**Minimal Database (`icons.min.db`)**:
- Creates a lightweight version of the database without storing SVG data as BLOBs.
- Contains the same tables as the full database, except:
- No `icon_svgs` table (SVG data is available via the sprite instead)
- Used in web app for icon listing and search, because of some browser limitations on using the full database.
**SVG Sprite (`icons.svg`)**:
- Generates a comprehensive SVG sprite containing all icons as symbols.
- Each icon is accessible via its unique icon ID as a symbol reference.
- Used in web app for icon rendering, because of some browser limitations on using the full database.
**Additional Processing**:
- Organizes icons into categories (e.g., "System" categories from Remix Icon and a "Logos" category for all Simple Icons).
- Merges any existing data so as not to overwrite or lose previously assigned IDs. This ensures icons already in use retain consistent IDs in the Colanode app.
- Stores each icons SVG data as a BLOB in a separate `icon_svgs` table.
- Maintains a full-text search (`icon_search`) table for easy querying by name or tags.
4. **Clean Up**
- Removes temporary files and directories once all icons have been inserted into the database.
- Leaves you with a fully updated `icons.db` containing all icons and their metadata.
- Leaves you with updated `icons.db`, `icons.min.db`, and `icons.svg` files containing all icon data and assets.
## Usage
@@ -51,7 +70,11 @@ By consolidating icons from [Remix Icon](https://github.com/Remix-Design/RemixIc
npm run generate:icons
```
Once the script completes, youll have a fresh `icons.db` file that contains all relevant icon metadata (IDs, categories, tags, etc.) and their corresponding SVG assets.
Once the script completes, you'll have:
- A full `icons.db` file with all icon metadata and SVG data as BLOBs
- A minimal `icons.min.db` file with metadata only (no SVG BLOBs)
- An `icons.svg` sprite file containing all icon graphics as symbols
## Notes on Licensing

View File

@@ -1,17 +1,47 @@
# Colanode postinstall script
This directory contains the **postinstall script** that automatically copies and updates emoji and icon SQLite databases within the **Colanode** desktop application after each dependency installation. It ensures that the latest emojis and icons are always present in the `apps/desktop/assets` folder without requiring manual intervention.
This directory contains the **postinstall script** that automatically copies and distributes emoji and icon assets to the appropriate **Colanode** applications after each dependency installation. It ensures that the latest emojis, icons, fonts, and images are always present in both the desktop and web applications without requiring manual intervention.
The primary purpose of this script is to maintain updated emojis and icons in the desktop application (and potentially other future apps) without committing thousands of individual files to version control. Given that there are roughly 3,500 emoji files and 4,800 icon files, storing them directly in the apps repository would significantly bloat the codebase and produce large diffs whenever assets are updated or reorganized. Instead, these assets are stored in respective SQLite database files in the `scripts` directory and automatically extracted into the desktop apps `assets` folder during dependency installation. This ensures that all necessary emojis and icons are available for both development and production builds, while also preventing the repository from becoming unwieldy. The `apps/desktop/assets/emojis.db` and `apps/desktop/assets/icons.db` directories are therefore ignored by Git.
## What It Does
For more information about how these emojis or icons are generated and zipped, check:
The script copies different types of assets to different Colanode apps based on their specific needs:
**Desktop Application (`apps/desktop/assets/`)**:
- **Full databases**: `emojis.db` and `icons.db` (with SVG BLOBs) for offline capability
- **SVG sprites**: `emojis.svg` and `icons.svg` for efficient rendering
- **Fonts**: Custom fonts like `neotrax.otf`
- **Images**: Application logos and icons in various formats (.png, .ico, .icns)
**Web Application (`apps/web/public/assets/`)**:
- **Minimal databases**: `emojis.min.db` and `icons.min.db` (renamed to `emojis.db` and `icons.db`) without SVG BLOBs for faster loading
- **SVG sprites**: `emojis.svg` and `icons.svg` for rendering (since SVG data isn't in the minimal databases)
- **Fonts**: Custom fonts like `neotrax.otf`
- **Images**: Web-specific logo files in PNG format
## Why This Approach?
The primary purpose of this script is to maintain updated assets across applications without committing thousands of individual files to version control. Given that there are roughly 3,500 emoji files and 4,800 icon files, storing them directly in each app's repository would significantly bloat the codebase and produce large diffs whenever assets are updated.
**Key Benefits**:
- **Desktop apps** get full databases with embedded SVG data for offline functionality
- **Web apps** get minimal databases + separate SVG sprites for optimal loading performance and browser compatibility
- **Version control** remains clean by avoiding thousands of individual asset files
- **Consistent updates** across all applications when assets are regenerated
- **Flexible deployment** strategies for different application types
The asset directories (`apps/desktop/assets/` and `apps/web/public/assets/`) are therefore ignored by Git, as they are automatically populated during the build process.
For more information about how these assets are generated, check:
- [Emoji generation script](../emojis)
- [Icon generation script](../icons)
## Usage
While its normally triggered by the monorepos `postinstall` hook, you can manually invoke it if youd like:
While it's normally triggered by the monorepo's `postinstall` hook, you can manually invoke it if you'd like:
```bash
node --no-warnings --loader ts-node/esm scripts/src/postinstall/index.ts

View File

@@ -1,3 +1,5 @@
import { faker } from '@faker-js/faker';
import {
Block,
generateId,
@@ -26,7 +28,6 @@ import {
recordModel,
} from '@colanode/core';
import { encodeState, YDoc } from '@colanode/crdt';
import { faker } from '@faker-js/faker';
import { User } from './types';
@@ -881,7 +882,7 @@ export class NodeGenerator {
return {
id: generateId(IdType.Mutation),
type: 'create_node',
type: 'node.create',
data: data,
createdAt: new Date().toISOString(),
};
@@ -906,7 +907,7 @@ export class NodeGenerator {
return {
id: generateId(IdType.Mutation),
type: 'update_document',
type: 'document.update',
data: data,
createdAt: new Date().toISOString(),
};