From dbfa028b6f307e1625d67eb022f75ed881dd4b4f Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 5 Nov 2025 17:29:10 +0000 Subject: [PATCH 1/2] feat: Add comprehensive documentation for plugin-devkit Co-authored-by: chris --- REPOSITORY_FEATURES.md | 387 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 387 insertions(+) create mode 100644 REPOSITORY_FEATURES.md diff --git a/REPOSITORY_FEATURES.md b/REPOSITORY_FEATURES.md new file mode 100644 index 0000000..a35fea5 --- /dev/null +++ b/REPOSITORY_FEATURES.md @@ -0,0 +1,387 @@ +# Plugin Devkit Repository - Comprehensive Feature Analysis + +## Overview + +**plugin-devkit** is a Shopify CLI plugin (v1.0.8) developed by Archetype Themes Limited Partnership. It's a TypeScript-based CLI tool built with oclif that enhances Shopify theme development with a component-driven architecture. The plugin enables developers to build modular, reusable Liquid components for Shopify themes. + +## Project Structure + +### Technology Stack +- **Language**: TypeScript (ES2022 target, Node16 modules) +- **CLI Framework**: oclif (@oclif/core v4) +- **Build System**: TypeScript compiler +- **Package Manager**: npm +- **Node.js Version**: v18.12.0+ + +### Key Dependencies +- `@oclif/core`: CLI framework +- `chokidar`: File watching +- `deepmerge`: Object merging +- `fs-extra`: File system operations +- `glob`: File pattern matching +- `jsonc`: JSON with comments support +- `parse-imports`: JavaScript import parsing +- `smol-toml`: TOML parsing + +### Architecture +- Commands organized under `src/commands/theme/` +- Shared utilities in `src/utilities/` +- Base command class for common functionality +- Argument and flag definitions centralized + +## Core Features + +### 1. Component Management System + +#### Component Collection Structure +Components are organized in a collection directory with: +- `components/` - Contains component folders +- Each component folder contains: + - `*.liquid` - Main component file (same name as folder) + - `snippets/` - Related snippet files + - `assets/` - Component assets (JS, CSS) + - `setup/` - Setup files (settings_schema.json, settings_data.json, etc.) +- `scripts/` - Global JavaScript files +- `package.json` - Collection metadata + +#### Component Node System +The plugin uses a `LiquidNode` data structure to track: +- **Type**: `component`, `snippet`, `asset`, `entry`, `setup` +- **Dependencies**: Snippets referenced via `render`, `include`, `inject` +- **Assets**: JavaScript files referenced via `asset_url` filter or ES6 imports +- **Body**: File content for analysis +- **Theme Folder**: Target location (`assets`, `snippets`, `layout`, `sections`, `templates`, `blocks`) + +### 2. Commands + +#### Component Commands (`shopify theme component`) + +##### `map` - Generate Component Manifest +- **Purpose**: Creates/updates `component.manifest.json` file +- **Features**: + - Maps component files (snippets and assets) to their source collection + - Tracks component collection version and commit hash + - Supports component selection (single, comma-separated, or `*` for all) + - Handles conflicts and overrides with warnings + - Recursively processes component dependencies + - Flags: + - `--ignore-conflicts` (`-f`): Ignore conflicts when mapping + - `--ignore-overrides` (`-o`): Ignore overrides when mapping + - `--collection-name` (`-n`): Override collection name + - `--collection-version` (`-v`): Override collection version + +##### `copy` - Copy Component Files +- **Purpose**: Copies rendered component files into theme directory +- **Features**: + - Copies snippets and assets from collection to theme + - Validates manifest exists and version matches + - Only copies files belonging to current collection + - Updates files only if changed + +##### `clean` - Remove Unused Files +- **Purpose**: Removes component files not in manifest +- **Features**: + - Scans theme directory for snippets and assets + - Removes files not listed in `component.manifest.json` + - Prevents orphaned component files + - Supports quiet mode (`-q`) + +##### `install` - Complete Installation +- **Purpose**: Runs full component installation workflow +- **Features**: + - Executes in sequence: `map` → `copy` → `clean` → `generate import-map` + - One-command setup for components + - Supports component selector + +##### `dev` - Development Environment +- **Purpose**: Creates sandboxed development environment +- **Features**: + - Removes existing `.dev` directory + - Clones/fetches theme from GitHub or local directory + - Copies component files and setup files + - Integrates with `shopify theme dev` for preview + - File watching with chokidar for auto-sync + - Flags: + - `--theme-dir` (`-t`): Theme directory (default: GitHub Explorer theme) + - `--setup-files` (`-s`): Copy setup files (default: true) + - `--watch` (`-w`): Watch for changes (default: true) + - `--preview` (`-y`): Sync to theme directory (default: true) + - `--generate-import-map` (`-i`): Generate import map + - `--generate-template-map` (`-m`): Generate template map + - Theme dev flags: `--host`, `--port`, `--live-reload`, `--store`, `--theme`, `--password`, `--store-password`, `--environment` + +#### Generate Commands (`shopify theme generate`) + +##### `import-map` - Generate JavaScript Import Map +- **Purpose**: Creates `snippets/head.import-map.liquid` for ES6 module imports +- **Features**: + - Scans `assets/` directory for `.js` files + - Creates import map with Shopify `asset_url` filter + - Supports both `.js` and `.min.js` extensions + - Generates `