Skip to content

Commit f35c486

Browse files
committed
feat(core): refactor and general improvements
Closes #140 When linting semver ranges, warn on non-semver versions but don't error Closes #139 Handle !negated globs Closes #132 Show more detailed information about errors and warnings Closes #111 Throw when config is invalid, instead of defaulting
1 parent 2801b67 commit f35c486

File tree

200 files changed

+5005
-3711
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+5005
-3711
lines changed

.eslintrc.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ module.exports = {
3737
},
3838
],
3939
'@typescript-eslint/no-var-requires': 'off',
40-
'@typescript-eslint/consistent-type-imports': [
41-
'error',
42-
{ prefer: 'type-imports' },
43-
],
40+
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
4441
},
4542
};

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"arrowParens": "always",
3-
"printWidth": 80,
3+
"printWidth": 100,
44
"proseWrap": "always",
55
"quoteProps": "consistent",
66
"singleQuote": true,

.syncpackrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ const config = {
1313
packages: ['**'],
1414
pinVersion: '4.1.2',
1515
},
16+
{
17+
dependencies: ['globby'],
18+
packages: ['**'],
19+
pinVersion: '11.1.0',
20+
},
1621
],
1722
};
1823

.vscode/tasks.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
"version": "2.0.0",
33
"tasks": [
44
{
5-
"args": [
6-
"${workspaceFolder}/${relativeFileDirname}/${fileBasenameNoExtension}.spec.ts"
7-
],
5+
"args": ["${workspaceFolder}/${relativeFileDirname}/${fileBasenameNoExtension}.spec.ts"],
86
"command": "scripts/upsert-test.sh",
97
"group": "test",
108
"label": "Upsert test for current file",

jest.config.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,21 @@ module.exports = {
44
'src/**/*.ts',
55
'!src/bin.ts',
66
'!src/bin*/index.ts',
7-
'!src/lib/effects.ts',
87
'!src/lib/log.ts',
98
'!src/option.ts',
109
],
1110
coverageReporters: ['html', 'lcov'],
1211
coverageThreshold: {
1312
global: {
1413
branches: 80,
15-
functions: 95,
16-
lines: 95,
17-
statements: 95,
14+
functions: 90,
15+
lines: 90,
16+
statements: 90,
1817
},
1918
},
2019
moduleFileExtensions: ['ts', 'js'],
2120
setupFiles: ['<rootDir>/test/jest.setup.ts'],
22-
testMatch: [
23-
'<rootDir>/src/**/*.spec.ts',
24-
'<rootDir>/test/scenarios/**/*.spec.ts',
25-
],
21+
testMatch: ['<rootDir>/src/**/*.spec.ts', '<rootDir>/test/scenarios/**/*.spec.ts'],
2622
transform: {
2723
'^.+\\.ts$': ['ts-jest', { isolatedModules: true }],
2824
},

package.json

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,30 @@
3030
"Tom Fletcher (https://github.com/tom-fletcher)"
3131
],
3232
"dependencies": {
33+
"@effect/data": "0.12.5",
34+
"@effect/io": "0.26.0",
35+
"@effect/match": "0.24.4",
3336
"chalk": "4.1.2",
34-
"commander": "10.0.1",
35-
"cosmiconfig": "8.1.3",
37+
"commander": "11.0.0",
38+
"cosmiconfig": "8.2.0",
3639
"enquirer": "2.3.6",
3740
"fs-extra": "11.1.1",
38-
"glob": "10.2.6",
41+
"globby": "11.1.0",
3942
"minimatch": "9.0.1",
4043
"read-yaml-file": "2.1.0",
41-
"semver": "7.5.1",
44+
"semver": "7.5.2",
4245
"tightrope": "0.1.0",
4346
"ts-toolbelt": "9.6.0"
4447
},
4548
"devDependencies": {
4649
"@tsconfig/node14": "1.0.3",
4750
"@types/fs-extra": "11.0.1",
48-
"@types/glob": "8.1.0",
4951
"@types/jest": "29.5.2",
5052
"@types/node": "14.18.36",
5153
"@types/semver": "7.5.0",
52-
"@typescript-eslint/eslint-plugin": "5.59.8",
53-
"@typescript-eslint/parser": "5.59.8",
54-
"eslint": "8.42.0",
54+
"@typescript-eslint/eslint-plugin": "5.59.11",
55+
"@typescript-eslint/parser": "5.59.11",
56+
"eslint": "8.43.0",
5557
"eslint-plugin-import": "2.27.5",
5658
"eslint-plugin-jest": "27.2.1",
5759
"expect-more-jest": "5.5.0",
@@ -94,16 +96,19 @@
9496
"repository": "JamieMason/syncpack",
9597
"resolutions": {
9698
"chalk": "4.1.2",
99+
"globby": "11.1.0",
97100
"string-width": "<5.0.0",
98101
"strip-ansi": "<7.0.0",
99102
"wrap-ansi": "<8.0.0"
100103
},
101104
"scripts": {
102-
"build": "rm -rf ./dist && tsc --project .",
105+
"build": "rm -rf ./dist && tsc --project tsconfig.build.json",
103106
"format": "yarn format:lint && yarn format:source",
104107
"format:lint": "yarn lint --fix",
105108
"format:source": "prettier --write .",
106-
"lint": "eslint --ext .ts .",
109+
"lint": "yarn lint:ts && yarn lint:eslint",
110+
"lint:eslint": "eslint --ext .ts .",
111+
"lint:ts": "tsc --noEmit --project tsconfig.json",
107112
"prepack": "yarn build",
108113
"test": "jest src test"
109114
},

site/docs/config-file.mdx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,18 @@ id: config-file
33
title: Configuration File
44
---
55

6-
Creating a configuration file is optional, syncpack will search up the directory
7-
tree in the following places:
6+
Creating a configuration file is optional, syncpack will search up the directory tree in the
7+
following places:
88

99
- a `syncpack` property in `package.json`
1010
- a `.syncpackrc` file in JSON or YAML format
11-
- a `.syncpackrc.json`, `.syncpackrc.yaml`, `.syncpackrc.yml`, `.syncpackrc.js`,
12-
or `.syncpackrc.cjs` file
13-
- a `syncpack.config.js` or `syncpack.config.cjs` CommonJS module exporting an
14-
object
11+
- a `.syncpackrc.json`, `.syncpackrc.yaml`, `.syncpackrc.yml`, `.syncpackrc.js`, or
12+
`.syncpackrc.cjs` file
13+
- a `syncpack.config.js` or `syncpack.config.cjs` CommonJS module exporting an object
1514
- a `config.syncpack` property in `package.json`
1615

17-
If you want to specify a path to a configuration file, overriding the discovered
18-
configuration file (if present), you can use the [`--config`](./config-file.mdx)
19-
option.
16+
If you want to specify a path to a configuration file, overriding the discovered configuration file
17+
(if present), you can use the [`--config`](./config-file.mdx) option.
2018

2119
## Default Configuration
2220

@@ -53,8 +51,8 @@ option.
5351

5452
## TypeScript IntelliSense
5553

56-
If you want intellisense for the configuration file, you can annotate your
57-
javascript config files with the following:
54+
If you want intellisense for the configuration file, you can annotate your javascript config files
55+
with the following:
5856

5957
:::caution
6058

site/docs/config/custom-types.mdx

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,14 @@ import Pills from '@site/src/components/pill';
99

1010
<Pills optional />
1111

12-
Extend syncpack to find and fix versions in your packages which are not
13-
available by default. Custom types behave like any other dependency, so can be
14-
included in [versionGroups](./version-groups.mdx) or
15-
[semverGroups](./semver-groups.mdx) etc.
12+
Extend syncpack to find and fix versions in your packages which are not available by default. Custom
13+
types behave like any other dependency, so can be included in [versionGroups](./version-groups.mdx)
14+
or [semverGroups](./semver-groups.mdx) etc.
1615

1716
The example below adds support for synchronising versions found in:
1817

19-
1. The
20-
[`engines`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#engines)
21-
object.
22-
1. The [`packageManager`](https://nodejs.org/api/packages.html#packagemanager)
23-
string.
18+
1. The [`engines`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#engines) object.
19+
1. The [`packageManager`](https://nodejs.org/api/packages.html#packagemanager) string.
2420

2521
```json title=".syncpackrc"
2622
{
@@ -48,27 +44,26 @@ Syncpack config files also support
4844

4945
<Pills required />
5046

51-
The key of each custom type is its name, this can be used in the following
52-
places to toggle when it is enabled:
47+
The key of each custom type is its name, this can be used in the following places to toggle when it
48+
is enabled:
5349

54-
1. [`--types`](../option/types.mdx) and
55-
[`dependencyTypes`](./dependency-types.mdx).
50+
1. [`--types`](../option/types.mdx) and [`dependencyTypes`](./dependency-types.mdx).
5651
1. [`versionGroup.dependencyTypes`](./version-groups.mdx#dependencytypes)
5752
1. [`semverGroup.dependencyTypes`](./semver-groups.mdx#dependencytypes)
5853

5954
## customTypes\[name\].path
6055

6156
<Pills required />
6257

63-
Where the version can be found in each package.json file, such as `engines`,
64-
`packageManager` or `some.nested.property`.
58+
Where the version can be found in each package.json file, such as `engines`, `packageManager` or
59+
`some.nested.property`.
6560

6661
## customTypes\[name\].strategy
6762

6863
<Pills required />
6964

70-
A strategy defines how syncpack needs to read and write dependency names and
71-
versions, there are 3 to choose from:
65+
A strategy defines how syncpack needs to read and write dependency names and versions, there are 3
66+
to choose from:
7267

7368
| Name | Example |
7469
| ---------------- | -------------------------------------- |

site/docs/config/dependency-types.mdx

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@ import Pills from '@site/src/components/pill';
1010

1111
<Pills optional />
1212

13-
All of the [default dependency types](#default-dependency-types) are enabled by
14-
default, but can be reduced to a smaller list via the `dependencyTypes` property
15-
of your config file.
13+
All of the [default dependency types](#default-dependency-types) are enabled by default, but can be
14+
reduced to a smaller list via the `dependencyTypes` property of your config file.
1615

1716
In this example, only dependencies found in the
18-
[`dependencies`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#dependencies)
19-
and
17+
[`dependencies`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#dependencies) and
2018
[`devDependencies`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#devDependencies)
2119
properties of package.json files will be inspected by syncpack:
2220

@@ -35,17 +33,16 @@ Syncpack config files also support
3533

3634
:::tip
3735

38-
The [default dependency types](#default-dependency-types) can be extended with
39-
your own [`customTypes`](./custom-types.mdx), so you can find and fix versions
40-
found in other parts of your package.json files.
36+
The [default dependency types](#default-dependency-types) can be extended with your own
37+
[`customTypes`](./custom-types.mdx), so you can find and fix versions found in other parts of your
38+
package.json files.
4139

4240
:::
4341

4442
:::info
4543

46-
Your `dependencyTypes` configuration in your [config file](../config-file.mdx)
47-
can be overridden on an ad hoc basis using the [`--types`](../option/types.mdx)
48-
option.
44+
Your `dependencyTypes` configuration in your [config file](../config-file.mdx) can be overridden on
45+
an ad hoc basis using the [`--types`](../option/types.mdx) option.
4946

5047
:::
5148

@@ -56,9 +53,8 @@ option.
5653
## The `workspace` type
5754

5855
This option synchronises the versions of your dependencies with the
59-
[`version`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#version)
60-
properties of the package.json files developed in your own local
61-
workspace/project, when they relate to eachother.
56+
[`version`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#version) properties of the
57+
package.json files developed in your own local workspace/project, when they relate to eachother.
6258

6359
Take this example, `@your-repo/fetch` is developed in your repo:
6460

@@ -83,5 +79,5 @@ and another package developed in your repo depends on it:
8379
}
8480
```
8581

86-
When `workspace` is enabled, syncpack will fix `@your-repo/ui` so it depends on
87-
version `1.0.2` of `@your-repo/fetch`.
82+
When `workspace` is enabled, syncpack will fix `@your-repo/ui` so it depends on version `1.0.2` of
83+
`@your-repo/fetch`.

site/docs/config/filter.mdx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@ import Pills from '@site/src/components/pill';
99

1010
<Pills optional />
1111

12-
A string which will be passed to `new RegExp()` to match against package names
13-
that should be included.
12+
A string which will be passed to `new RegExp()` to match against package names that should be
13+
included.
1414

1515
:::danger
1616

17-
`filter` was originally intended as a convenience to be used from the command
18-
line to filter the output of `syncpack list`, **it is not recommended to add
19-
this to your config file to manage your project more generally**.
17+
`filter` was originally intended as a convenience to be used from the command line to filter the
18+
output of `syncpack list`, **it is not recommended to add this to your config file to manage your
19+
project more generally**.
2020

21-
Instead use [`versionGroups`](./version-groups.mdx) and/or
22-
[`semverGroups`](./semver-groups.mdx).
21+
Instead use [`versionGroups`](./version-groups.mdx) and/or [`semverGroups`](./semver-groups.mdx).
2322

2423
:::

0 commit comments

Comments
 (0)