Skip to content

Commit bd7573e

Browse files
committed
feat(config): add updateGroups to set registry update policies
Closes #244
1 parent 7e30187 commit bd7573e

31 files changed

Lines changed: 1007 additions & 290 deletions

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ syncpack update --target latest
9595
syncpack update --target minor
9696
# Only update patch versions (1.2.x)
9797
syncpack update --target patch
98+
# Pick which updates to apply through an interactive prompt
99+
syncpack update --interactive
100+
# Interactively pick from patch updates only
101+
syncpack update --interactive --target patch
102+
# Interactively pick which @aws-sdk packages to update
103+
syncpack update --interactive --dependencies '@aws-sdk/**'
98104
# Check for outdated dependencies in one package
99105
syncpack update --check --source 'packages/pingu/package.json'
100106
# Update dependencies and devDependencies in the whole monorepo
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
#[derive(Debug)]
1+
#[cfg(test)]
2+
#[path = "update_target_test.rs"]
3+
mod update_target_test;
4+
5+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
26
pub enum UpdateTarget {
37
/// "*.*.*"
48
Latest,
@@ -7,3 +11,16 @@ pub enum UpdateTarget {
711
/// "1.2.*"
812
Patch,
913
}
14+
15+
impl UpdateTarget {
16+
/// Return the stricter of two `UpdateTarget`s. `Patch` < `Minor` < `Latest`
17+
/// in strictness, so `Patch` always wins, then `Minor`, then `Latest`.
18+
pub fn stricter(self, other: Self) -> Self {
19+
use UpdateTarget::*;
20+
match (self, other) {
21+
(Patch, _) | (_, Patch) => Patch,
22+
(Minor, _) | (_, Minor) => Minor,
23+
_ => Latest,
24+
}
25+
}
26+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use super::UpdateTarget;
2+
3+
#[test]
4+
fn stricter_covers_all_nine_pairs() {
5+
use UpdateTarget::*;
6+
assert_eq!(Latest.stricter(Latest), Latest);
7+
assert_eq!(Latest.stricter(Minor), Minor);
8+
assert_eq!(Latest.stricter(Patch), Patch);
9+
assert_eq!(Minor.stricter(Latest), Minor);
10+
assert_eq!(Minor.stricter(Minor), Minor);
11+
assert_eq!(Minor.stricter(Patch), Patch);
12+
assert_eq!(Patch.stricter(Latest), Patch);
13+
assert_eq!(Patch.stricter(Minor), Patch);
14+
assert_eq!(Patch.stricter(Patch), Patch);
15+
}

npm/syncpack.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export interface RcFile {
2525
minimumReleaseAge?: number;
2626
/** @see https://syncpack.dev/semver-groups */
2727
semverGroups?: SemverGroup.Any[];
28+
/** @see https://syncpack.dev/update-groups */
29+
updateGroups?: UpdateGroup.Any[];
2830
/** @see https://syncpack.dev/config/sort-az */
2931
sortAz?: string[];
3032
/** @see https://syncpack.dev/config/sort-exports */
@@ -92,6 +94,18 @@ namespace SemverGroup {
9294
export type Any = Ignored | WithRange;
9395
}
9496

97+
namespace UpdateGroup {
98+
export interface Ignored extends GroupSelector {
99+
/** @see https://syncpack.dev/update-groups/ignored/#isignored */
100+
isIgnored: true;
101+
}
102+
export interface Targeted extends GroupSelector {
103+
/** @see https://syncpack.dev/update-groups/targeted/#target */
104+
target: 'patch' | 'minor' | 'latest';
105+
}
106+
export type Any = Ignored | Targeted;
107+
}
108+
95109
namespace VersionGroup {
96110
export interface Banned extends GroupSelector {
97111
/** @see https://syncpack.dev/version-groups/banned/#isbanned */

pnpm-lock.yaml

Lines changed: 95 additions & 171 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/astro.config.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ export default defineConfig({
100100
label: 'Semver Groups',
101101
items: [{ autogenerate: { directory: 'semver-groups' } }],
102102
},
103+
{
104+
label: 'Update Groups',
105+
badge: 'New',
106+
items: [{ autogenerate: { directory: 'update-groups' } }],
107+
},
103108
{
104109
label: 'Configuration File',
105110
items: [
@@ -118,6 +123,7 @@ export default defineConfig({
118123
'config/sort-packages',
119124
'config/source',
120125
'config/strict',
126+
{ label: 'updateGroups', link: '/update-groups/', badge: 'New' },
121127
{ label: 'versionGroups', link: '/version-groups/' },
122128
],
123129
},

site/remark-plugins/link-aliases.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export function linkAliases() {
2222
CONFIG_SORT_PACKAGES: '/config/sort-packages/',
2323
CONFIG_SOURCE: '/config/source/',
2424
CONFIG_SYNCPACKRC: '/config/syncpackrc/',
25+
CONFIG_UPDATE_GROUPS: '/update-groups/',
2526
CONFIG_VERSION_GROUPS: '/version-groups/',
2627

2728
GUIDE_PEER_DEPENDENCIES: '/guide/peer-dependencies/',
@@ -44,6 +45,7 @@ export function linkAliases() {
4445
TERM_SPECIFIER: '/glossary/#specifier',
4546
TERM_SPECIFIER_TYPE: '/glossary/#specifier-type',
4647
TERM_STATUS_CODE: '/glossary/#status-code',
48+
TERM_UPDATE_GROUP: '/glossary/#update-group',
4749
TERM_VERSION_GROUP: '/glossary/#version-group',
4850
TERM_WORKSPACE: '/glossary/#workspace',
4951

@@ -80,6 +82,9 @@ export function linkAliases() {
8082

8183
STATUS_SAME_MINOR_MISMATCH: '/status/same-minor-mismatch',
8284

85+
UPDATE_GROUP_IGNORED: '/update-groups/ignored/',
86+
UPDATE_GROUP_TARGETED: '/update-groups/targeted/',
87+
8388
VERSION_GROUP_BANNED: '/version-groups/banned/',
8489
VERSION_GROUP_CATALOG: '/version-groups/catalog/',
8590
VERSION_GROUP_HIGHEST_SEMVER: '/version-groups/highest-semver/',

site/src/_partials/option/target.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Code } from "astro:components";
22

3-
Limit updates to only those within the given semver portion.
3+
Limit updates to only those within the given semver portion. For per-dependency control, see [updateGroups](CONFIG_UPDATE_GROUPS) — when both apply to the same instance, the stricter of the two wins.
44

55
<Code
66
code={`

site/src/_partials/tips/custom-types.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ import { Aside } from "@astrojs/starlight/components";
55
[`customTypes`](CONFIG_CUSTOM_TYPES).
66
- pnpm and bun catalog names are auto-registered as dependency types.
77

8-
See the [Dependency Types](REF_DEPENDENCY_TYPES) guide for the list of possible values.
8+
See the [Dependency Types](REF_DEPENDENCY_TYPES) guide for the list of possible values.
9+
910
</Aside>

site/src/content/docs/command/update.mdx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import SourceOption from "@partials/option/source.mdx";
2323
import SpecifierTypesOption from "@partials/option/specifier-types.mdx";
2424
import TargetOption from "@partials/option/target.mdx";
2525

26-
Update dependencies in your monorepo to newer versions from the npm registry. Checks for available updates and modifies package.json files — and `pnpm-workspace.yaml` catalog entries when present — to use them. Unlike `fix` which synchronises versions across packages, `update` fetches the latest published versions. Use `--target` to control update strategy (latest, minor, patch). Versions newer than [minimumReleaseAge](CONFIG_MINIMUM_RELEASE_AGE) are excluded by default to reduce supply chain attack risk.
26+
Update dependencies in your monorepo to newer versions from the npm registry. Checks for available updates and modifies package.json files — and `pnpm-workspace.yaml` catalog entries when present — to use them. Unlike `fix` which synchronises versions across packages, `update` fetches the latest published versions. Use `--target` to control update strategy (latest, minor, patch), or define [updateGroups](CONFIG_UPDATE_GROUPS) for per-dependency control. Versions newer than [minimumReleaseAge](CONFIG_MINIMUM_RELEASE_AGE) are excluded by default to reduce supply chain attack risk.
2727

2828
## Examples
2929

@@ -34,6 +34,12 @@ syncpack update --target latest
3434
syncpack update --target minor
3535
# Only update patch versions (1.2.x)
3636
syncpack update --target patch
37+
# Pick which updates to apply through an interactive prompt
38+
syncpack update --interactive
39+
# Interactively pick from patch updates only
40+
syncpack update --interactive --target patch
41+
# Interactively pick which @aws-sdk packages to update
42+
syncpack update --interactive --dependencies '@aws-sdk/**'
3743
# Check for outdated dependencies in one package
3844
syncpack update --check --source 'packages/pingu/package.json'
3945
# Update dependencies and devDependencies in the whole monorepo

0 commit comments

Comments
 (0)