Conversation
✅ Deploy Preview for luthor canceled.
|
Co-authored-by: exaby73 <50555895+exaby73@users.noreply.github.com>
|
@copilot README for # dpk
[](https://pub.dev/packages/dpk)
[](https://opensource.org/licenses/MIT)
An alternative package manager for Dart that enhances the standard `dart pub` commands with extra features like script running and dependency patching. `dpk` acts as a wrapper around the standard Dart tooling, allowing you to use the commands you are already familiar with.
## Features
- **Familiar Commands**: Implements `get`, `add`, `remove`, `upgrade`, and `downgrade` commands that mirror `dart pub`.
- **Script Runner**: Define and run custom scripts from your `dpk.yaml` file using `dpk run`.
- **Dependency Patching**: A powerful feature to manage and apply patches to your dependencies, ideal for monorepos or when you need to test a fix before a package is updated.
## Installation
Install `dpk` globally using the following command:
```bash
dart install dpkFor Dart versions before 3.10, use: dart pub global activate dpkSetupA minimal dpk project requires two files:
name: my_package
environment:
sdk: ^3.8.0
version: ^X.Y.ZThe Usage
Managing Dependencies
Running ScriptsYou can define custom scripts in a
version: ^X.Y.Z # Required: dpk version constraint
scripts:
analyze: dart analyze
test: dart testRun a script using dpk run analyzeScript HooksScripts can have Example with hooks: scripts:
# Get command hooks (works with built-in dpk get command)
pre:get: echo "Starting dependency resolution..."
post:get: echo "Dependencies resolved!"
# Build command hooks
pre:build: dart run build_runner clean
build: dart run build_runner build -d
post:build: echo "Build completed successfully"
# Watch command can inherit build hooks
watch:
runHooksFrom: build
command: dart run build_runner watch -dWhen you run
Note: Hooks work for any script you define, as well as built-in dpk commands like Environment VariablesYou can set environment variables for scripts using the scripts:
build:
command: dart compile exe bin/main.dart -o build/app
env:
DART_VM_OPTIONS: '-Denv=production'
LOG_LEVEL: verboseInjected Environment Variablesdpk automatically injects the following environment variables into scripts:
Example using scripts:
check-root:
command: echo "Workspace root is $DPK_ROOT"
runInPackages:
- 'packages/*'Patching DependenciesThe
1. Initialize PatchingFirst, initialize the patching environment. This will create a dpk patch initThis command must be run after fetching dependencies with Important: Make sure to exclude the
analyzer:
exclude:
- pub_packages/**Excluding 2. Modify Your DependenciesNavigate into the 3. Generate PatchesOnce you have made your changes, generate patch files: dpk patch generateThis command compares the modified dependency code against the initial state and creates 4. Apply PatchesTo apply existing patches to your dependencies (e.g., after a fresh dpk patch applyThis command will apply all Note: If you haven't run Configuration (
|
| Variable | Description |
|---|---|
DPK_PACKAGE_PATH |
Relative path to the package from workspace root |
DPK_PACKAGE_NAME |
The package name from pubspec.yaml |
DPK_PACKAGE_VERSION |
The package version from pubspec.yaml |
Example with template variables:
catalog:
repository: https://github.com/user/repo/tree/main/DPK_PACKAGE_PATH
documentation: https://pub.dev/documentation/DPK_PACKAGE_NAME/DPK_PACKAGE_VERSION/When you run dpk get in a workspace with a catalog, dpk automatically updates each package's pubspec.yaml with the catalog configuration, replacing template variables with package-specific values.
Advanced Features
Workspace Support
dpk automatically detects workspace configurations by looking for a workspace field in parent pubspec.yaml files. This enables:
- Running scripts across multiple packages with
runInPackages - Sharing dependencies and configuration via catalog
- Consistent versioning across the workspace
Automatic Workspace Detection
dpk searches up the directory tree to find workspace roots, allowing you to run commands from any subdirectory within a workspace.
Complex Script Chaining
Scripts can be chained and share hooks using runHooksFrom:
scripts:
ci:
command: echo "Running CI"
runHooksFrom: test # Inherits pre:test and post:test
pre:test: dart analyze
post:test: dart format --set-exit-if-changed .Troubleshooting
Common Issues
- "dpk.yaml not found": A
dpk.yamlfile is required in your project root (or workspace root for monorepos) - "'version' is required in dpk.yaml": Add a
versionfield with a semver constraint (e.g.,version: ^X.Y.Z) - "dpk version X.X.X does not satisfy required version constraint": Update dpk with
dart install dpk(Dart 3.10+) ordart pub global activate dpk - Patches not applying: Ensure you've run
dpk patch initfirst and that the patches directory exists - Workspace not detected: Check that parent directories have a valid
pubspec.yamlwith aworkspacefield - Environment variables not substituting: Verify the variable is exported in your shell environment
- Scripts not found: Ensure
dpk.yamlis in the project root
_Action steps to install `dpk`_
```yaml
- name: Install dpk
shell: bash
run: dart install dpk
- name: Add Dart bin to PATH
shell: bash
run: echo "$HOME/.local/state/Dart/install/bin" >> $GITHUB_PATH
Co-authored-by: exaby73 <50555895+exaby73@users.noreply.github.com>
Updated the copilot instructions with the correct information:
Changes in commit f04807e. |
Co-authored-by: exaby73 <50555895+exaby73@users.noreply.github.com>
Adds
.github/copilot-instructions.mdto guide AI-assisted development in the Luthor validation library.Contents
luthorandluthor_generatorpackagesdart install dpkfor Dart 3.10+, PATH setup instructions, and commands for format, analyze, test, and code generation patterns./docs, including setup, development, build, and preview commandsExample validation pattern documented:
Provides sufficient context for Copilot to understand project conventions, maintain consistency, and follow established patterns when suggesting code.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.