syncpack 14.0.0-alpha.1 → 14.0.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # syncpack
2
2
 
3
3
  <p align="center">
4
- <img src="https://jamiemason.github.io/syncpack/logo.svg" width="200" height="179" alt="">
4
+ <img src="https://jamiemason.github.io/syncpack/logo.svg" width="134" height="120" alt="">
5
5
  <br>Consistent dependency versions in large JavaScript Monorepos.
6
6
  <br><a href="https://jamiemason.github.io/syncpack">https://jamiemason.github.io/syncpack</a>
7
7
  </p>
@@ -9,46 +9,93 @@
9
9
  ## Installation
10
10
 
11
11
  ```bash
12
- npm install --save-dev syncpack
12
+ npm install --save-dev syncpack@alpha
13
13
  ```
14
14
 
15
15
  ## Commands
16
16
 
17
- ### [fix-mismatches](https://jamiemason.github.io/syncpack/command/fix-mismatches)
17
+ > All command line options can be combined to target packages and dependencies in multiple ways.
18
18
 
19
- Ensure that multiple packages requiring the same dependency define the same version, so that every package requires eg. `react@16.4.2`, instead of a combination of `react@16.4.2`, `react@0.15.9`, and `react@16.0.0`.
20
-
21
- ### [format](https://jamiemason.github.io/syncpack/command/format)
22
-
23
- Organise package.json files according to a conventional format, where fields appear in a predictable order and nested fields are ordered alphabetically. Shorthand properties are used where available, such as the `"repository"` and `"bugs"` fields.
19
+ ### [lint](https://jamiemason.github.io/syncpack/command/lint) and [fix](https://jamiemason.github.io/syncpack/command/fix)
24
20
 
25
- ### [lint](https://jamiemason.github.io/syncpack/command/lint)
26
-
27
- Lint all versions and ranges and exit with 0 or 1 based on whether all files match your Syncpack configuration file.
28
-
29
- ### [lint-semver-ranges](https://jamiemason.github.io/syncpack/command/lint-semver-ranges)
30
-
31
- Check whether dependency versions used within "dependencies", "devDependencies", etc follow a consistent format.
21
+ Ensure that multiple packages requiring the same dependency define the same version, so that every package requires eg. `react@16.4.2`, instead of a combination of `react@16.4.2`, `react@0.15.9`, and `react@16.0.0`.
32
22
 
33
- ### [list](https://jamiemason.github.io/syncpack/command/list)
23
+ #### Examples
34
24
 
35
- List all dependencies required by your packages.
25
+ ```bash
26
+ # Find every issue in "dependencies" or "devDependencies"
27
+ syncpack lint --dependency-types prod,dev
28
+ # Look for issues in dependencies containing "react" in the name
29
+ syncpack lint --dependencies '**react**'
30
+ # Autofix the above issues
31
+ syncpack fix --dependencies '**react**'
32
+ # Find issues everywhere except "peerDependencies"
33
+ syncpack lint --dependency-types '!peer'
34
+ # Only look for issues where an exact version is used
35
+ syncpack lint --specifier-types exact
36
+ # Only look for issues where an exact version is specified
37
+ syncpack lint --specifier-types exact
38
+ # Sort dependencies by how many times they are used
39
+ syncpack lint --sort count
40
+ # Show a lot more detail about the issues
41
+ syncpack lint --show hints,ignored,instances,statuses
42
+ # See more examples
43
+ syncpack lint --help
44
+ syncpack fix --help
45
+ # See a short summary of options
46
+ syncpack lint -h
47
+ syncpack fix -h
48
+ ```
36
49
 
37
- ### [list-mismatches](https://jamiemason.github.io/syncpack/command/list-mismatches)
50
+ ### [update](https://jamiemason.github.io/syncpack/command/update)
38
51
 
39
- List dependencies which are required by multiple packages, where the version is not the same across every package.
52
+ Update packages to the latest versions from the npm registry, wherever they are in your monorepo.<br/>Semver range preferences are preserved when updating.
40
53
 
41
- ### [prompt](https://jamiemason.github.io/syncpack/command/prompt)
54
+ #### Examples
42
55
 
43
- Displays a series of prompts to fix mismatches which syncpack cannot fix automatically.
56
+ ```bash
57
+ # Accept any update in latest (x.x.x)
58
+ syncpack update --target latest
59
+ # Only update minor versions (1.x.x)
60
+ syncpack update --target minor
61
+ # Only update patch versions (1.2.x)
62
+ syncpack update --target patch
63
+ # Check for outdated dependencies in one package
64
+ syncpack update --check --source 'packages/pingu/package.json'
65
+ # Update dependencies and devDependencies in the whole monorepo
66
+ syncpack update --dependency-types dev,prod
67
+ # Only update dependencies with a semver range specifier (^, ~, etc.)
68
+ syncpack update --specifier-types range
69
+ # Update dependencies where name exactly matches 'react'
70
+ syncpack update --dependencies 'react'
71
+ # Update dependencies where name contains 'react'
72
+ syncpack update --dependencies '**react**'
73
+ # Update dependencies with the '@aws-sdk' scope
74
+ syncpack update --dependencies '@aws-sdk/**'
75
+ # See more examples
76
+ syncpack update --help
77
+ # See a short summary of options
78
+ syncpack update -h
79
+ ```
44
80
 
45
- ### [set-semver-ranges](https://jamiemason.github.io/syncpack/command/set-semver-ranges)
81
+ ### [format](https://jamiemason.github.io/syncpack/command/format)
46
82
 
47
- Ensure dependency versions used within `"dependencies"`, `"devDependencies"` etc follow a consistent format.
83
+ Organise package.json files according to a conventional format, where fields appear in a predictable order and nested fields are ordered alphabetically. Shorthand properties are used where available, such as the `"repository"` and `"bugs"` fields.
48
84
 
49
- ### [update](https://jamiemason.github.io/syncpack/command/update)
85
+ #### Examples
50
86
 
51
- Interactively update packages to the latest versions from the npm registry, wherever they are in your monorepo. You can update every dependency, just dev/peer/prod dependencies, just packages which match a name filter, and more.
87
+ ```bash
88
+ # Fix every formatting issue in the monorepo
89
+ syncpack format
90
+ # List all formatting issues in the monorepo
91
+ syncpack format --check
92
+ # Check the formatting of one package
93
+ syncpack format --check --source 'packages/pingu/package.json'
94
+ # See more examples
95
+ syncpack format --help
96
+ # See a short summary of options
97
+ syncpack format -h
98
+ ```
52
99
 
53
100
  ## Badges
54
101
 
package/index.cjs ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawnSync } = require('node:child_process');
4
+
5
+ const args = process.argv.slice(2);
6
+ const arch = process.arch;
7
+ const [os, extension] = ['win32', 'cygwin'].includes(process.platform)
8
+ ? ['windows', '.exe']
9
+ : [process.platform, ''];
10
+ const optionalDep = `syncpack-${os}-${arch}`;
11
+ const pkgSpecifier = `${optionalDep}/bin/syncpack${extension}`;
12
+ const pathToBinary = require.resolve(pkgSpecifier);
13
+
14
+ process.exit(
15
+ spawnSync(pathToBinary, args, {
16
+ cwd: process.cwd(),
17
+ stdio: ['ignore', 'inherit', 'inherit'],
18
+ env: {
19
+ ...process.env,
20
+ COSMICONFIG_REQUIRE_PATH: require.resolve('cosmiconfig'),
21
+ RUST_BACKTRACE: 'full',
22
+ },
23
+ }).status || 0,
24
+ );
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "syncpack",
3
3
  "description": "Consistent dependency versions in large JavaScript Monorepos",
4
- "version": "14.0.0-alpha.1",
4
+ "version": "14.0.0-alpha.11",
5
5
  "author": "Jamie Mason <jamie@foldleft.io> (https://github.com/JamieMason)",
6
6
  "bugs": "https://github.com/JamieMason/syncpack/issues",
7
7
  "contributors": [
@@ -14,6 +14,7 @@
14
14
  "Aparajita Fishman (https://github.com/aparajita)",
15
15
  "Artur Wierzbicki (https://github.com/ArturWierzbicki)",
16
16
  "Chase Holdren (https://github.com/chaseholdren)",
17
+ "Chase Tamnoon (https://github.com/chase-tamnoon)",
17
18
  "Daniel Silva (https://github.com/dsilvasc)",
18
19
  "Elchin Valiyev (https://github.com/evaliyev)",
19
20
  "Gabriel Pereira Woitechen (https://github.com/wtchnm)",
@@ -29,12 +30,13 @@
29
30
  "Michał Warać (https://github.com/auto200)",
30
31
  "Nick Saunders (https://github.com/nsaunders)",
31
32
  "Siraj (https://github.com/Syhner)",
33
+ "Steve Beaugé (https://github.com/stevebeauge)",
32
34
  "Stuart Knightley (https://github.com/Stuk)",
33
35
  "Tom Fletcher (https://github.com/tom-fletcher)"
34
36
  ],
35
37
  "dependencies": {
36
- "cosmiconfig": "9.0.0",
37
- "typescript": "5.6.3"
38
+ "cosmiconfig": "^9.0.0",
39
+ "typescript": "^5.7.3"
38
40
  },
39
41
  "engines": {
40
42
  "node": ">=14.17.0"
@@ -64,15 +66,15 @@
64
66
  "license": "MIT",
65
67
  "repository": "JamieMason/syncpack",
66
68
  "bin": {
67
- "syncpack": "./index.js"
69
+ "syncpack": "./index.cjs"
68
70
  },
69
71
  "optionalDependencies": {
70
- "syncpack-linux-x64": "14.0.0-alpha.1",
71
- "syncpack-linux-arm64": "14.0.0-alpha.1",
72
- "syncpack-darwin-x64": "14.0.0-alpha.1",
73
- "syncpack-darwin-arm64": "14.0.0-alpha.1",
74
- "syncpack-windows-x64": "14.0.0-alpha.1",
75
- "syncpack-windows-arm64": "14.0.0-alpha.1"
72
+ "syncpack-linux-x64": "14.0.0-alpha.11",
73
+ "syncpack-linux-arm64": "14.0.0-alpha.11",
74
+ "syncpack-darwin-x64": "14.0.0-alpha.11",
75
+ "syncpack-darwin-arm64": "14.0.0-alpha.11",
76
+ "syncpack-windows-x64": "14.0.0-alpha.11",
77
+ "syncpack-windows-arm64": "14.0.0-alpha.11"
76
78
  },
77
79
  "types": "./syncpack.d.ts"
78
80
  }
package/schema.json CHANGED
@@ -99,6 +99,88 @@
99
99
  ],
100
100
  "type": "object"
101
101
  },
102
+ "DependencyGroup": {
103
+ "additionalProperties": false,
104
+ "properties": {
105
+ "aliasName": {
106
+ "see": "https://jamiemason.github.io/syncpack/config/dependency-groups/#aliasname",
107
+ "type": "string"
108
+ },
109
+ "dependencies": {
110
+ "items": {
111
+ "type": "string"
112
+ },
113
+ "see": "https://jamiemason.github.io/syncpack/config/dependency-groups/#dependencies",
114
+ "type": "array"
115
+ },
116
+ "dependencyTypes": {
117
+ "items": {
118
+ "anyOf": [
119
+ {
120
+ "type": "string"
121
+ },
122
+ {
123
+ "enum": [
124
+ "dev",
125
+ "local",
126
+ "overrides",
127
+ "peer",
128
+ "pnpmOverrides",
129
+ "prod",
130
+ "resolutions"
131
+ ],
132
+ "type": "string"
133
+ }
134
+ ]
135
+ },
136
+ "see": "https://jamiemason.github.io/syncpack/config/dependency-groups/#dependencytypes",
137
+ "type": "array"
138
+ },
139
+ "packages": {
140
+ "items": {
141
+ "type": "string"
142
+ },
143
+ "see": "https://jamiemason.github.io/syncpack/config/dependency-groups/#packages",
144
+ "type": "array"
145
+ },
146
+ "specifierTypes": {
147
+ "items": {
148
+ "anyOf": [
149
+ {
150
+ "type": "string"
151
+ },
152
+ {
153
+ "enum": [
154
+ "alias",
155
+ "exact",
156
+ "file",
157
+ "git",
158
+ "latest",
159
+ "major",
160
+ "minor",
161
+ "missing",
162
+ "range",
163
+ "range-complex",
164
+ "range-major",
165
+ "range-minor",
166
+ "tag",
167
+ "unsupported",
168
+ "url",
169
+ "workspace-protocol"
170
+ ],
171
+ "type": "string"
172
+ }
173
+ ]
174
+ },
175
+ "see": "https://jamiemason.github.io/syncpack/config/dependency-groups/#specifiertypes",
176
+ "type": "array"
177
+ }
178
+ },
179
+ "required": [
180
+ "aliasName"
181
+ ],
182
+ "type": "object"
183
+ },
102
184
  "RcFile": {
103
185
  "additionalProperties": false,
104
186
  "properties": {
@@ -113,6 +195,13 @@
113
195
  "see": "https://jamiemason.github.io/syncpack/config/custom-types",
114
196
  "type": "object"
115
197
  },
198
+ "dependencyGroups": {
199
+ "items": {
200
+ "$ref": "#/definitions/DependencyGroup"
201
+ },
202
+ "see": "https://jamiemason.github.io/syncpack/config/dependency-groups",
203
+ "type": "array"
204
+ },
116
205
  "formatBugs": {
117
206
  "see": "https://jamiemason.github.io/syncpack/config/format-bugs",
118
207
  "type": "boolean"
package/syncpack.d.ts CHANGED
@@ -2,7 +2,11 @@ export interface RcFile {
2
2
  /** @see https://jamiemason.github.io/syncpack/integrations/json-schema */
3
3
  $schema?: string;
4
4
  /** @see https://jamiemason.github.io/syncpack/config/custom-types */
5
- customTypes?: Record<string, CustomType.Any>;
5
+ customTypes?: {
6
+ [name: string]: CustomType.Any;
7
+ };
8
+ /** @see https://jamiemason.github.io/syncpack/config/dependency-groups */
9
+ dependencyGroups?: DependencyGroup[];
6
10
  /** @see https://jamiemason.github.io/syncpack/config/format-bugs */
7
11
  formatBugs?: boolean;
8
12
  /** @see https://jamiemason.github.io/syncpack/config/format-repository */
@@ -36,7 +40,7 @@ export interface RcFile {
36
40
  /** @deprecated */
37
41
  specifierTypes?: never;
38
42
  }
39
- export interface DependencyGroup {
43
+ export interface GroupSelector {
40
44
  /** @see https://jamiemason.github.io/syncpack/config/version-groups/standard/#dependencies */
41
45
  dependencies?: string[];
42
46
  /** @see https://jamiemason.github.io/syncpack/config/version-groups/standard/#dependencytypes */
@@ -48,41 +52,53 @@ export interface DependencyGroup {
48
52
  /** @see https://jamiemason.github.io/syncpack/config/version-groups/standard/#specifiertypes */
49
53
  specifierTypes?: SpecifierType[];
50
54
  }
55
+ export interface DependencyGroup {
56
+ /** @see https://jamiemason.github.io/syncpack/config/dependency-groups/#aliasname */
57
+ aliasName: string;
58
+ /** @see https://jamiemason.github.io/syncpack/config/dependency-groups/#dependencies */
59
+ dependencies?: string[];
60
+ /** @see https://jamiemason.github.io/syncpack/config/dependency-groups/#dependencytypes */
61
+ dependencyTypes?: DependencyType[];
62
+ /** @see https://jamiemason.github.io/syncpack/config/dependency-groups/#packages */
63
+ packages?: string[];
64
+ /** @see https://jamiemason.github.io/syncpack/config/dependency-groups/#specifiertypes */
65
+ specifierTypes?: SpecifierType[];
66
+ }
51
67
  declare namespace SemverGroup {
52
- interface Ignored extends DependencyGroup {
68
+ interface Ignored extends GroupSelector {
53
69
  /** @see https://jamiemason.github.io/syncpack/config/semver-groups/ignored/#isignored */
54
70
  isIgnored: true;
55
71
  }
56
- interface WithRange extends DependencyGroup {
72
+ interface WithRange extends GroupSelector {
57
73
  /** @see https://jamiemason.github.io/syncpack/config/semver-groups/with-range/#range */
58
74
  range: SemverRange;
59
75
  }
60
76
  type Any = Ignored | WithRange;
61
77
  }
62
78
  declare namespace VersionGroup {
63
- interface Banned extends DependencyGroup {
79
+ interface Banned extends GroupSelector {
64
80
  /** @see https://jamiemason.github.io/syncpack/config/version-groups/banned/#isbanned */
65
81
  isBanned: true;
66
82
  }
67
- interface Ignored extends DependencyGroup {
83
+ interface Ignored extends GroupSelector {
68
84
  /** @see https://jamiemason.github.io/syncpack/config/version-groups/ignored/#isignored */
69
85
  isIgnored: true;
70
86
  }
71
- interface Pinned extends DependencyGroup {
87
+ interface Pinned extends GroupSelector {
72
88
  /** @see https://jamiemason.github.io/syncpack/config/version-groups/pinned/#pinversion */
73
89
  pinVersion: string;
74
90
  }
75
- interface SnappedTo extends DependencyGroup {
91
+ interface SnappedTo extends GroupSelector {
76
92
  /** @see https://jamiemason.github.io/syncpack/config/version-groups/snapped-to/#snapto */
77
93
  snapTo: string[];
78
94
  }
79
- interface SameRange extends DependencyGroup {
95
+ interface SameRange extends GroupSelector {
80
96
  /** @see https://jamiemason.github.io/syncpack/config/version-groups/same-range/#policy */
81
- policy: "sameRange";
97
+ policy: 'sameRange';
82
98
  }
83
- interface Standard extends DependencyGroup {
99
+ interface Standard extends GroupSelector {
84
100
  /** @see https://jamiemason.github.io/syncpack/config/version-groups/lowest-version/#preferversion */
85
- preferVersion?: "highestSemver" | "lowestSemver";
101
+ preferVersion?: 'highestSemver' | 'lowestSemver';
86
102
  }
87
103
  type Any = Banned | Ignored | Pinned | SameRange | SnappedTo | Standard;
88
104
  }
@@ -93,30 +109,30 @@ declare namespace CustomType {
93
109
  /** @see https://jamiemason.github.io/syncpack/config/custom-types/#name */
94
110
  path: string;
95
111
  /** @see https://jamiemason.github.io/syncpack/config/custom-types/#namestrategy */
96
- strategy: "name~version";
112
+ strategy: 'name~version';
97
113
  }
98
114
  interface NamedVersionString {
99
115
  /** @see https://jamiemason.github.io/syncpack/config/custom-types/#name */
100
116
  path: string;
101
117
  /** @see https://jamiemason.github.io/syncpack/config/custom-types/#namestrategy */
102
- strategy: "name@version";
118
+ strategy: 'name@version';
103
119
  }
104
120
  interface UnnamedVersionString {
105
121
  /** @see https://jamiemason.github.io/syncpack/config/custom-types/#name */
106
122
  path: string;
107
123
  /** @see https://jamiemason.github.io/syncpack/config/custom-types/#namestrategy */
108
- strategy: "version";
124
+ strategy: 'version';
109
125
  }
110
126
  interface VersionsByName {
111
127
  /** @see https://jamiemason.github.io/syncpack/config/custom-types/#name */
112
128
  path: string;
113
129
  /** @see https://jamiemason.github.io/syncpack/config/custom-types/#namestrategy */
114
- strategy: "versionsByName";
130
+ strategy: 'versionsByName';
115
131
  }
116
132
  type Any = NameAndVersionProps | NamedVersionString | UnnamedVersionString | VersionsByName;
117
133
  }
118
- type SemverRange = "" | "*" | ">" | ">=" | ".x" | "<" | "<=" | "^" | "~";
119
- type DependencyType = "dev" | "local" | "overrides" | "peer" | "pnpmOverrides" | "prod" | "resolutions" | AnyString;
120
- type SpecifierType = "alias" | "exact" | "file" | "git" | "latest" | "major" | "minor" | "missing" | "range" | "range-complex" | "range-major" | "range-minor" | "tag" | "unsupported" | "url" | "workspace-protocol" | AnyString;
134
+ type SemverRange = '' | '*' | '>' | '>=' | '.x' | '<' | '<=' | '^' | '~';
135
+ type DependencyType = 'dev' | 'local' | 'overrides' | 'peer' | 'pnpmOverrides' | 'prod' | 'resolutions' | AnyString;
136
+ type SpecifierType = 'alias' | 'exact' | 'file' | 'git' | 'latest' | 'major' | 'minor' | 'missing' | 'range' | 'range-complex' | 'range-major' | 'range-minor' | 'tag' | 'unsupported' | 'url' | 'workspace-protocol' | AnyString;
121
137
  type AnyString = string & {};
122
138
  export {};
package/index.js DELETED
@@ -1,48 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const { spawnSync } = require("child_process");
4
- const { cosmiconfig } = require("cosmiconfig");
5
-
6
- const args = process.argv.slice(2);
7
- const arch = process.arch;
8
- const [os, extension] = ["win32", "cygwin"].includes(process.platform)
9
- ? ["windows", ".exe"]
10
- : [process.platform, ""];
11
- const optionalDep = `syncpack-${os}-${arch}`;
12
- const pkgSpecifier = `${optionalDep}/bin/syncpack${extension}`;
13
-
14
- cosmiconfig("syncpack")
15
- .search()
16
- .then(({ config }) => (config ? JSON.stringify(config) : "{}"))
17
- .catch(() => "{}")
18
- .then((rcfileAsJson) => ({
19
- pathToBinary: require.resolve(pkgSpecifier),
20
- rcfileAsJson,
21
- }))
22
- .catch((err) => {
23
- panic(
24
- `expected optionalDependency "${optionalDep}" containing a Rust binary at "${pkgSpecifier}"`,
25
- err
26
- );
27
- })
28
- .then(({ pathToBinary, rcfileAsJson }) => {
29
- process.exit(
30
- spawnSync(pathToBinary, args, {
31
- input: rcfileAsJson,
32
- stdio: ["pipe", "inherit", "inherit"],
33
- }).status ?? 0
34
- );
35
- })
36
- .catch((err) => {
37
- panic("syncpack encountered an unknown error", err);
38
- });
39
-
40
- function panic(message, err) {
41
- console.error(
42
- "\x1b[31m%s\n%s\x1b[0m",
43
- `! ${message}`,
44
- " Please raise issue at https://github.com/JamieMason/syncpack/issues/new?template=bug_report.yaml",
45
- err
46
- );
47
- process.exit(1);
48
- }