Skip to content

Commit bd9d5ba

Browse files
committed
improve package management system docs
1 parent 652d22d commit bd9d5ba

1 file changed

Lines changed: 74 additions & 4 deletions

File tree

docs/src/content/docs/configuration/packages.mdx

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,38 @@ Based on detection, cigen runs the appropriate command:
261261
| `python` | Pipfile.lock | `pipenv install --deploy` |
262262
| `go` | go.mod | `go mod download` |
263263

264+
## How Default Configuration Works
265+
266+
Cigen includes production-ready package manager definitions that are compiled into the binary. These defaults are organized as separate YAML files for maintainability:
267+
268+
```
269+
src/packages/config_templates/
270+
├── package_managers/
271+
│ ├── node.yml
272+
│ ├── ruby.yml
273+
│ ├── python.yml
274+
│ ├── go.yml
275+
│ ├── rust.yml
276+
│ ├── java.yml
277+
│ └── dotnet.yml
278+
└── version_sources/
279+
├── node.yml
280+
├── ruby.yml
281+
├── bundler.yml
282+
├── python.yml
283+
├── go.yml
284+
├── rustc.yml
285+
├── cargo.yml
286+
├── java.yml
287+
└── dotnet.yml
288+
```
289+
290+
When you define `package_managers` or `version_sources` in your `.cigen/cigen.yml`, your configuration intelligently merges with these defaults:
291+
292+
- **Override**: Completely replace a built-in definition
293+
- **Extend**: Add new package managers alongside built-ins
294+
- **Inherit**: Use built-in defaults when no custom config is provided
295+
264296
## Customizing Package Managers
265297

266298
### Overriding Built-in Definitions
@@ -289,6 +321,30 @@ package_managers:
289321
title="Custom package manager commands"
290322
/>
291323

324+
### Customizing Version Sources
325+
326+
You can also customize how versions are detected for cache keys:
327+
328+
<Code
329+
code={`# .cigen/cigen.yml
330+
version_sources:
331+
node:
332+
- file: .nvmrc
333+
- file: .node-version
334+
- file: package.json
335+
pattern: '"engines":\\s*{\\s*"node":\\s*"([^"]+)"'
336+
- command: node --version
337+
parse_version: true
338+
339+
# Add custom version source
340+
custom_tool:
341+
- file: .custom-version
342+
- command: custom-tool --version
343+
parse_version: false # Don't parse, use raw output`}
344+
lang="yaml"
345+
title="Custom version sources"
346+
/>
347+
292348
### Adding New Package Managers
293349

294350
Define completely new package managers:
@@ -431,14 +487,28 @@ jobs:
431487
If the wrong package manager is used:
432488

433489
1. **Ensure lock file exists** and is committed
434-
2. **Check working directory** is correct
435-
3. **Explicitly specify** if needed:
490+
2. **Check detection order** in the built-in definitions - earlier rules take precedence
491+
3. **Override detection rules** if needed:
436492
```yaml
437-
packages:
493+
package_managers:
438494
node:
439-
manager: pnpm # Force specific manager
495+
detect:
496+
- name: pnpm # Force pnpm to be checked first
497+
lockfile: pnpm-lock.yaml
498+
command: pnpm install --frozen-lockfile
499+
- name: npm
500+
lockfile: package-lock.json
501+
command: npm ci
440502
```
441503

504+
### Custom Package Manager Not Working
505+
506+
If your custom package manager configuration isn't being used:
507+
508+
1. **Check YAML syntax** - invalid YAML will be ignored
509+
2. **Verify field names** match the schema (`detect`, `checksum_sources`, `cache_paths`, etc.)
510+
3. **Test with `cigen validate`** to catch configuration errors early
511+
442512
### Deduplication Not Happening
443513

444514
If jobs aren't sharing installation:

0 commit comments

Comments
 (0)