syncpack 12.1.0 → 12.3.0
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 +5 -5
- package/dist/bin-fix-mismatches/index.js +2 -0
- package/dist/bin-format/format.d.ts +2 -0
- package/dist/bin-format/format.js +66 -36
- package/dist/bin-lint/lint.js +40 -1
- package/dist/bin-lint-semver-ranges/index.js +2 -0
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +2 -2
- package/dist/bin-list/index.js +2 -0
- package/dist/bin-list/list.js +2 -2
- package/dist/bin-list-mismatches/index.js +2 -0
- package/dist/bin-list-mismatches/list-mismatches.js +10 -10
- package/dist/bin-prompt/index.js +2 -0
- package/dist/bin-set-semver-ranges/index.js +2 -0
- package/dist/bin-update/effects.js +6 -6
- package/dist/bin-update/index.js +2 -0
- package/dist/bin-update/update.js +3 -3
- package/dist/config/get-filter.js +2 -1
- package/dist/config/get-indent.js +2 -1
- package/dist/config/get-sort-az.js +4 -11
- package/dist/config/get-sort-exports.d.ts +2 -0
- package/dist/config/get-sort-exports.js +12 -0
- package/dist/config/get-sort-first.js +4 -2
- package/dist/config/types.d.ts +25 -2
- package/dist/constants.d.ts +62 -23
- package/dist/constants.js +52 -32
- package/dist/get-instances/instance.d.ts +2 -1
- package/dist/get-instances/instance.js +4 -3
- package/dist/guards/can-add-to-group.js +14 -7
- package/dist/io/to-json.d.ts +9 -0
- package/dist/io/to-json.js +33 -0
- package/dist/io/write-if-changed.d.ts +0 -6
- package/dist/io/write-if-changed.js +3 -31
- package/dist/option.d.ts +1 -0
- package/dist/option.js +4 -0
- package/dist/schema.json +160 -12
- package/dist/semver-group/create-semver-groups.js +6 -0
- package/dist/semver-group/with-range.d.ts +1 -1
- package/dist/semver-group/with-range.js +3 -3
- package/dist/specifier/alias.d.ts +2 -0
- package/dist/specifier/alias.js +3 -1
- package/dist/specifier/base.d.ts +4 -2
- package/dist/specifier/base.js +3 -1
- package/dist/specifier/delete.d.ts +4 -2
- package/dist/specifier/delete.js +3 -1
- package/dist/specifier/{version.d.ts → exact.d.ts} +3 -1
- package/dist/specifier/{version.js → exact.js} +6 -4
- package/dist/specifier/file.d.ts +2 -0
- package/dist/specifier/file.js +3 -1
- package/dist/specifier/hosted-git.d.ts +2 -0
- package/dist/specifier/hosted-git.js +3 -1
- package/dist/specifier/index.d.ts +5 -3
- package/dist/specifier/index.js +7 -3
- package/dist/specifier/latest.d.ts +19 -0
- package/dist/specifier/latest.js +24 -0
- package/dist/specifier/range.d.ts +2 -1
- package/dist/specifier/range.js +3 -2
- package/dist/specifier/tag.d.ts +2 -0
- package/dist/specifier/tag.js +3 -1
- package/dist/specifier/unsupported.d.ts +2 -0
- package/dist/specifier/unsupported.js +3 -1
- package/dist/specifier/url.d.ts +2 -0
- package/dist/specifier/url.js +3 -1
- package/dist/specifier/workspace-protocol.d.ts +2 -0
- package/dist/specifier/workspace-protocol.js +3 -1
- package/dist/version-group/create-version-groups.js +11 -0
- package/dist/version-group/pinned.js +1 -1
- package/dist/version-group/same-range.js +5 -5
- package/dist/version-group/snapped-to.js +5 -5
- package/dist/version-group/standard.js +9 -9
- package/package.json +6 -6
package/dist/config/types.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { CUSTOM_TYPES } from '../constants';
|
|
2
|
+
import type { Specifier } from '../specifier';
|
|
1
3
|
/**
|
|
2
4
|
* Aliases for semver range formats supported by syncpack
|
|
3
5
|
*
|
|
@@ -18,11 +20,15 @@
|
|
|
18
20
|
* @default ""
|
|
19
21
|
*/
|
|
20
22
|
export type SemverRange = '' | '*' | '>' | '>=' | '.x' | '<' | '<=' | '^' | '~' | 'workspace:';
|
|
23
|
+
type DefaultDependencyType = keyof typeof CUSTOM_TYPES;
|
|
24
|
+
export type DependencyType = DefaultDependencyType | `!${DefaultDependencyType}` | (string & {});
|
|
25
|
+
export type SpecifierType = Specifier.Any['name'] | `!${Specifier.Any['name']}` | (string & {});
|
|
21
26
|
export interface GroupConfig {
|
|
22
27
|
dependencies?: string[];
|
|
23
|
-
dependencyTypes?:
|
|
28
|
+
dependencyTypes?: DependencyType[];
|
|
24
29
|
label?: string;
|
|
25
30
|
packages?: string[];
|
|
31
|
+
specifierTypes?: SpecifierType[];
|
|
26
32
|
}
|
|
27
33
|
export declare namespace SemverGroupConfig {
|
|
28
34
|
interface Disabled extends GroupConfig {
|
|
@@ -85,25 +91,42 @@ export interface CliConfig {
|
|
|
85
91
|
readonly filter: string;
|
|
86
92
|
readonly indent: string;
|
|
87
93
|
readonly source: string[];
|
|
94
|
+
readonly specs: string;
|
|
88
95
|
readonly types: string;
|
|
89
96
|
}
|
|
90
97
|
export interface RcConfig {
|
|
91
98
|
/** @see https://jamiemason.github.io/syncpack/config/custom-types */
|
|
92
99
|
customTypes: Record<string, CustomTypeConfig.Any>;
|
|
93
100
|
/** @see https://jamiemason.github.io/syncpack/config/dependency-types */
|
|
94
|
-
dependencyTypes:
|
|
101
|
+
dependencyTypes: DependencyType[];
|
|
95
102
|
/** @see https://jamiemason.github.io/syncpack/config/filter */
|
|
96
103
|
filter: string;
|
|
104
|
+
/** @see https://jamiemason.github.io/syncpack/config/format-bugs */
|
|
105
|
+
formatBugs: boolean;
|
|
106
|
+
/** @see https://jamiemason.github.io/syncpack/config/format-repository */
|
|
107
|
+
formatRepository: boolean;
|
|
97
108
|
/** @see https://jamiemason.github.io/syncpack/config/indent */
|
|
98
109
|
indent: string;
|
|
110
|
+
/** @see https://jamiemason.github.io/syncpack/config/lint-formatting */
|
|
111
|
+
lintFormatting: boolean;
|
|
112
|
+
/** @see https://jamiemason.github.io/syncpack/config/lint-semver-ranges */
|
|
113
|
+
lintSemverRanges: boolean;
|
|
114
|
+
/** @see https://jamiemason.github.io/syncpack/config/lint-versions */
|
|
115
|
+
lintVersions: boolean;
|
|
99
116
|
/** @see https://jamiemason.github.io/syncpack/config/semver-groups */
|
|
100
117
|
semverGroups: SemverGroupConfig.Any[];
|
|
101
118
|
/** @see https://jamiemason.github.io/syncpack/config/sort-az */
|
|
102
119
|
sortAz: string[];
|
|
120
|
+
/** @see https://jamiemason.github.io/syncpack/config/sort-exports */
|
|
121
|
+
sortExports: string[];
|
|
103
122
|
/** @see https://jamiemason.github.io/syncpack/config/sort-first */
|
|
104
123
|
sortFirst: string[];
|
|
124
|
+
/** @see https://jamiemason.github.io/syncpack/config/sort-packages */
|
|
125
|
+
sortPackages: boolean;
|
|
105
126
|
/** @see https://jamiemason.github.io/syncpack/config/source */
|
|
106
127
|
source: string[];
|
|
128
|
+
/** @see https://jamiemason.github.io/syncpack/config/specifier-types */
|
|
129
|
+
specifierTypes: SpecifierType[];
|
|
107
130
|
/** @see https://jamiemason.github.io/syncpack/config/version-groups */
|
|
108
131
|
versionGroups: VersionGroupConfig.Any[];
|
|
109
132
|
}
|
package/dist/constants.d.ts
CHANGED
|
@@ -24,44 +24,83 @@ export declare const RANGE: {
|
|
|
24
24
|
readonly WORKSPACE: "workspace:";
|
|
25
25
|
};
|
|
26
26
|
export declare const INTERNAL_TYPES: readonly ["dev", "local", "overrides", "peer", "pnpmOverrides", "prod", "resolutions"];
|
|
27
|
+
export declare const CUSTOM_TYPES: {
|
|
28
|
+
readonly dev: {
|
|
29
|
+
readonly strategy: "versionsByName";
|
|
30
|
+
readonly path: "devDependencies";
|
|
31
|
+
};
|
|
32
|
+
readonly local: {
|
|
33
|
+
readonly strategy: "name~version";
|
|
34
|
+
readonly namePath: "name";
|
|
35
|
+
readonly path: "version";
|
|
36
|
+
};
|
|
37
|
+
readonly overrides: {
|
|
38
|
+
readonly strategy: "versionsByName";
|
|
39
|
+
readonly path: "overrides";
|
|
40
|
+
};
|
|
41
|
+
readonly peer: {
|
|
42
|
+
readonly strategy: "versionsByName";
|
|
43
|
+
readonly path: "peerDependencies";
|
|
44
|
+
};
|
|
45
|
+
readonly pnpmOverrides: {
|
|
46
|
+
readonly strategy: "versionsByName";
|
|
47
|
+
readonly path: "pnpm.overrides";
|
|
48
|
+
};
|
|
49
|
+
readonly prod: {
|
|
50
|
+
readonly strategy: "versionsByName";
|
|
51
|
+
readonly path: "dependencies";
|
|
52
|
+
};
|
|
53
|
+
readonly resolutions: {
|
|
54
|
+
readonly strategy: "versionsByName";
|
|
55
|
+
readonly path: "resolutions";
|
|
56
|
+
};
|
|
57
|
+
};
|
|
27
58
|
export declare const DEFAULT_CONFIG: {
|
|
28
59
|
customTypes: {
|
|
29
|
-
dev: {
|
|
30
|
-
strategy: "versionsByName";
|
|
31
|
-
path:
|
|
60
|
+
readonly dev: {
|
|
61
|
+
readonly strategy: "versionsByName";
|
|
62
|
+
readonly path: "devDependencies";
|
|
32
63
|
};
|
|
33
|
-
local: {
|
|
34
|
-
strategy: "name~version";
|
|
35
|
-
namePath:
|
|
36
|
-
path:
|
|
64
|
+
readonly local: {
|
|
65
|
+
readonly strategy: "name~version";
|
|
66
|
+
readonly namePath: "name";
|
|
67
|
+
readonly path: "version";
|
|
37
68
|
};
|
|
38
|
-
overrides: {
|
|
39
|
-
strategy: "versionsByName";
|
|
40
|
-
path:
|
|
69
|
+
readonly overrides: {
|
|
70
|
+
readonly strategy: "versionsByName";
|
|
71
|
+
readonly path: "overrides";
|
|
41
72
|
};
|
|
42
|
-
peer: {
|
|
43
|
-
strategy: "versionsByName";
|
|
44
|
-
path:
|
|
73
|
+
readonly peer: {
|
|
74
|
+
readonly strategy: "versionsByName";
|
|
75
|
+
readonly path: "peerDependencies";
|
|
45
76
|
};
|
|
46
|
-
pnpmOverrides: {
|
|
47
|
-
strategy: "versionsByName";
|
|
48
|
-
path:
|
|
77
|
+
readonly pnpmOverrides: {
|
|
78
|
+
readonly strategy: "versionsByName";
|
|
79
|
+
readonly path: "pnpm.overrides";
|
|
49
80
|
};
|
|
50
|
-
prod: {
|
|
51
|
-
strategy: "versionsByName";
|
|
52
|
-
path:
|
|
81
|
+
readonly prod: {
|
|
82
|
+
readonly strategy: "versionsByName";
|
|
83
|
+
readonly path: "dependencies";
|
|
53
84
|
};
|
|
54
|
-
resolutions: {
|
|
55
|
-
strategy: "versionsByName";
|
|
56
|
-
path:
|
|
85
|
+
readonly resolutions: {
|
|
86
|
+
readonly strategy: "versionsByName";
|
|
87
|
+
readonly path: "resolutions";
|
|
57
88
|
};
|
|
58
89
|
};
|
|
59
|
-
dependencyTypes:
|
|
90
|
+
dependencyTypes: "**"[];
|
|
60
91
|
filter: string;
|
|
92
|
+
formatBugs: true;
|
|
93
|
+
formatRepository: true;
|
|
61
94
|
indent: string;
|
|
95
|
+
lintFormatting: true;
|
|
96
|
+
lintSemverRanges: true;
|
|
97
|
+
lintVersions: true;
|
|
62
98
|
semverGroups: never[];
|
|
63
99
|
sortAz: string[];
|
|
100
|
+
sortExports: string[];
|
|
64
101
|
sortFirst: string[];
|
|
102
|
+
sortPackages: true;
|
|
65
103
|
source: string[];
|
|
104
|
+
specifierTypes: "**"[];
|
|
66
105
|
versionGroups: never[];
|
|
67
106
|
};
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_CONFIG = exports.INTERNAL_TYPES = exports.RANGE = exports.ICON = exports.CWD = void 0;
|
|
3
|
+
exports.DEFAULT_CONFIG = exports.CUSTOM_TYPES = exports.INTERNAL_TYPES = exports.RANGE = exports.ICON = exports.CWD = void 0;
|
|
4
4
|
/** Single source of truth, intended to aid testing or to override */
|
|
5
5
|
exports.CWD = process.env.MOCK_CWD || process.cwd();
|
|
6
6
|
/** Single source of truth for icons used in output */
|
|
@@ -35,43 +35,50 @@ exports.INTERNAL_TYPES = [
|
|
|
35
35
|
'prod',
|
|
36
36
|
'resolutions',
|
|
37
37
|
];
|
|
38
|
-
exports.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
path: 'pnpm.overrides',
|
|
60
|
-
},
|
|
61
|
-
prod: {
|
|
62
|
-
strategy: 'versionsByName',
|
|
63
|
-
path: 'dependencies',
|
|
64
|
-
},
|
|
65
|
-
resolutions: {
|
|
66
|
-
strategy: 'versionsByName',
|
|
67
|
-
path: 'resolutions',
|
|
68
|
-
},
|
|
38
|
+
exports.CUSTOM_TYPES = {
|
|
39
|
+
dev: {
|
|
40
|
+
strategy: 'versionsByName',
|
|
41
|
+
path: 'devDependencies',
|
|
42
|
+
},
|
|
43
|
+
local: {
|
|
44
|
+
strategy: 'name~version',
|
|
45
|
+
namePath: 'name',
|
|
46
|
+
path: 'version',
|
|
47
|
+
},
|
|
48
|
+
overrides: {
|
|
49
|
+
strategy: 'versionsByName',
|
|
50
|
+
path: 'overrides',
|
|
51
|
+
},
|
|
52
|
+
peer: {
|
|
53
|
+
strategy: 'versionsByName',
|
|
54
|
+
path: 'peerDependencies',
|
|
55
|
+
},
|
|
56
|
+
pnpmOverrides: {
|
|
57
|
+
strategy: 'versionsByName',
|
|
58
|
+
path: 'pnpm.overrides',
|
|
69
59
|
},
|
|
60
|
+
prod: {
|
|
61
|
+
strategy: 'versionsByName',
|
|
62
|
+
path: 'dependencies',
|
|
63
|
+
},
|
|
64
|
+
resolutions: {
|
|
65
|
+
strategy: 'versionsByName',
|
|
66
|
+
path: 'resolutions',
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
exports.DEFAULT_CONFIG = {
|
|
70
|
+
customTypes: exports.CUSTOM_TYPES,
|
|
70
71
|
dependencyTypes: ['**'],
|
|
71
72
|
filter: '.',
|
|
73
|
+
formatBugs: true,
|
|
74
|
+
formatRepository: true,
|
|
72
75
|
indent: ' ',
|
|
76
|
+
lintFormatting: true,
|
|
77
|
+
lintSemverRanges: true,
|
|
78
|
+
lintVersions: true,
|
|
73
79
|
semverGroups: [],
|
|
74
80
|
sortAz: [
|
|
81
|
+
'bin',
|
|
75
82
|
'contributors',
|
|
76
83
|
'dependencies',
|
|
77
84
|
'devDependencies',
|
|
@@ -80,7 +87,20 @@ exports.DEFAULT_CONFIG = {
|
|
|
80
87
|
'resolutions',
|
|
81
88
|
'scripts',
|
|
82
89
|
],
|
|
90
|
+
sortExports: [
|
|
91
|
+
'types',
|
|
92
|
+
'node-addons',
|
|
93
|
+
'node',
|
|
94
|
+
'browser',
|
|
95
|
+
'import',
|
|
96
|
+
'require',
|
|
97
|
+
'development',
|
|
98
|
+
'production',
|
|
99
|
+
'default',
|
|
100
|
+
],
|
|
83
101
|
sortFirst: ['name', 'description', 'version', 'author'],
|
|
102
|
+
sortPackages: true,
|
|
84
103
|
source: ['package.json', 'packages/*/package.json'],
|
|
104
|
+
specifierTypes: ['**'],
|
|
85
105
|
versionGroups: [],
|
|
86
106
|
};
|
|
@@ -2,6 +2,7 @@ import type { Effect } from 'effect';
|
|
|
2
2
|
import type { Strategy } from '../config/get-custom-types';
|
|
3
3
|
import type { PackageJsonFile } from '../get-package-json-files/package-json-file';
|
|
4
4
|
import type { SemverGroup } from '../semver-group';
|
|
5
|
+
import { Specifier } from '../specifier';
|
|
5
6
|
import type { VersionGroup } from '../version-group';
|
|
6
7
|
import type { Delete } from '../version-group/lib/delete';
|
|
7
8
|
export declare class Instance {
|
|
@@ -10,7 +11,7 @@ export declare class Instance {
|
|
|
10
11
|
/** The .name property of the package.json file of this instance */
|
|
11
12
|
pkgName: string;
|
|
12
13
|
/** The specifier as it is on disk before being fixed */
|
|
13
|
-
rawSpecifier:
|
|
14
|
+
rawSpecifier: Specifier.Any;
|
|
14
15
|
/** The package this dependency is installed in this specific time */
|
|
15
16
|
packageJsonFile: PackageJsonFile;
|
|
16
17
|
/** Locates where in the file this dependency is installed */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Instance = void 0;
|
|
4
|
+
const specifier_1 = require("../specifier");
|
|
4
5
|
class Instance {
|
|
5
6
|
/** The name of this dependency */
|
|
6
7
|
name;
|
|
@@ -19,16 +20,16 @@ class Instance {
|
|
|
19
20
|
constructor(name, rawSpecifier, packageJsonFile, strategy) {
|
|
20
21
|
this.name = name;
|
|
21
22
|
this.pkgName = packageJsonFile.jsonFile.contents.name || 'PACKAGE_JSON_HAS_NO_NAME';
|
|
22
|
-
this.rawSpecifier = rawSpecifier;
|
|
23
23
|
this.packageJsonFile = packageJsonFile;
|
|
24
24
|
this.strategy = strategy;
|
|
25
25
|
this.semverGroup = null;
|
|
26
26
|
this.versionGroup = null;
|
|
27
|
+
this.rawSpecifier = specifier_1.Specifier.create(this, rawSpecifier);
|
|
27
28
|
}
|
|
28
29
|
/** Mutate the package.json file in memory with the latest version specifier */
|
|
29
30
|
write(rawSpecifier) {
|
|
30
|
-
this.rawSpecifier = rawSpecifier;
|
|
31
|
-
return this.strategy.write(this.packageJsonFile, [this.name, this.rawSpecifier]);
|
|
31
|
+
this.rawSpecifier = specifier_1.Specifier.create(this, rawSpecifier);
|
|
32
|
+
return this.strategy.write(this.packageJsonFile, [this.name, this.rawSpecifier.raw]);
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
exports.Instance = Instance;
|
|
@@ -4,11 +4,12 @@ exports.canAddToGroup = void 0;
|
|
|
4
4
|
const minimatch_1 = require("minimatch");
|
|
5
5
|
const is_non_empty_array_1 = require("tightrope/guard/is-non-empty-array");
|
|
6
6
|
function canAddToGroup(packageJsonFilesByName, group, instance) {
|
|
7
|
-
const { dependencies, dependencyTypes, packages } = group.config;
|
|
7
|
+
const { dependencies, dependencyTypes, packages, specifierTypes } = group.config;
|
|
8
8
|
return (group.canAdd(instance) &&
|
|
9
9
|
matchesDependencyTypes(dependencyTypes, instance) &&
|
|
10
10
|
matchesPackages(packages, instance) &&
|
|
11
|
-
matchesDependencies(packageJsonFilesByName, group, dependencies, instance)
|
|
11
|
+
matchesDependencies(packageJsonFilesByName, group, dependencies, instance) &&
|
|
12
|
+
matchesSpecifierTypes(specifierTypes, instance));
|
|
12
13
|
}
|
|
13
14
|
exports.canAddToGroup = canAddToGroup;
|
|
14
15
|
function matchesDependencies(packageJsonFilesByName, group, dependencies, instance) {
|
|
@@ -28,14 +29,20 @@ function matchesPackages(packages, instance) {
|
|
|
28
29
|
return packages.some((pattern) => (0, minimatch_1.minimatch)(instance.pkgName, pattern));
|
|
29
30
|
}
|
|
30
31
|
function matchesDependencyTypes(dependencyTypes, instance) {
|
|
32
|
+
return matchesKnownList(dependencyTypes, instance.strategy.name);
|
|
33
|
+
}
|
|
34
|
+
function matchesSpecifierTypes(specifierTypes, instance) {
|
|
35
|
+
return matchesKnownList(specifierTypes, instance.rawSpecifier.name);
|
|
36
|
+
}
|
|
37
|
+
function matchesKnownList(values, value) {
|
|
31
38
|
// matches if not defined
|
|
32
|
-
if (!(0, is_non_empty_array_1.isNonEmptyArray)(
|
|
39
|
+
if (!(0, is_non_empty_array_1.isNonEmptyArray)(values))
|
|
33
40
|
return true;
|
|
34
|
-
if (
|
|
41
|
+
if (values.join('') === '**')
|
|
35
42
|
return true;
|
|
36
43
|
const negative = [];
|
|
37
44
|
const positive = [];
|
|
38
|
-
|
|
45
|
+
values.forEach((name) => {
|
|
39
46
|
if (name.startsWith('!')) {
|
|
40
47
|
negative.push(name.replace('!', ''));
|
|
41
48
|
}
|
|
@@ -43,7 +50,7 @@ function matchesDependencyTypes(dependencyTypes, instance) {
|
|
|
43
50
|
positive.push(name);
|
|
44
51
|
}
|
|
45
52
|
});
|
|
46
|
-
if ((0, is_non_empty_array_1.isNonEmptyArray)(negative) && !negative.includes(
|
|
53
|
+
if ((0, is_non_empty_array_1.isNonEmptyArray)(negative) && !negative.includes(value))
|
|
47
54
|
return true;
|
|
48
|
-
return (0, is_non_empty_array_1.isNonEmptyArray)(positive) && positive.includes(
|
|
55
|
+
return (0, is_non_empty_array_1.isNonEmptyArray)(positive) && positive.includes(value);
|
|
49
56
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Ctx } from '../get-context';
|
|
2
|
+
import type { PackageJsonFile } from '../get-package-json-files/package-json-file';
|
|
3
|
+
type Ending = '\n' | '\r' | '\r\n' | string;
|
|
4
|
+
export declare const newlines: {
|
|
5
|
+
detect(source: string): Ending;
|
|
6
|
+
fix(source: string, lineEnding: Ending): string;
|
|
7
|
+
};
|
|
8
|
+
export declare function toJson(ctx: Ctx, file: PackageJsonFile): string;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toJson = exports.newlines = void 0;
|
|
4
|
+
const os_1 = require("os");
|
|
5
|
+
const get_indent_1 = require("../config/get-indent");
|
|
6
|
+
const CR = '\r';
|
|
7
|
+
const CRLF = '\r\n';
|
|
8
|
+
const LF = '\n';
|
|
9
|
+
exports.newlines = {
|
|
10
|
+
detect(source) {
|
|
11
|
+
const cr = source.split(CR).length;
|
|
12
|
+
const lf = source.split(LF).length;
|
|
13
|
+
const crlf = source.split(CRLF).length;
|
|
14
|
+
if (cr + lf === 0)
|
|
15
|
+
return os_1.EOL;
|
|
16
|
+
if (crlf === cr && crlf === lf)
|
|
17
|
+
return CRLF;
|
|
18
|
+
if (cr > lf)
|
|
19
|
+
return CR;
|
|
20
|
+
return LF;
|
|
21
|
+
},
|
|
22
|
+
fix(source, lineEnding) {
|
|
23
|
+
return source.replace(/\r\n|\n|\r/g, lineEnding);
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
function toJson(ctx, file) {
|
|
27
|
+
const contents = file.jsonFile.contents;
|
|
28
|
+
const indent = (0, get_indent_1.getIndent)(ctx.config);
|
|
29
|
+
const EOL = exports.newlines.detect(file.jsonFile.json);
|
|
30
|
+
const source = `${JSON.stringify(contents, null, indent)}${EOL}`;
|
|
31
|
+
return exports.newlines.fix(source, EOL);
|
|
32
|
+
}
|
|
33
|
+
exports.toJson = toJson;
|
|
@@ -3,9 +3,3 @@ import type { Io } from '.';
|
|
|
3
3
|
import type { Ctx } from '../get-context';
|
|
4
4
|
import type { WriteFileError } from './write-file-sync';
|
|
5
5
|
export declare function writeIfChanged(ctx: Ctx): Effect.Effect<Io, WriteFileError, Ctx>;
|
|
6
|
-
type Ending = '\n' | '\r' | '\r\n' | string;
|
|
7
|
-
export declare const newlines: {
|
|
8
|
-
detect(source: string): Ending;
|
|
9
|
-
fix(source: string, lineEnding: Ending): string;
|
|
10
|
-
};
|
|
11
|
-
export {};
|
|
@@ -3,43 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.writeIfChanged = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const effect_1 = require("effect");
|
|
9
|
-
const os_1 = require("os");
|
|
10
|
-
const get_indent_1 = require("../config/get-indent");
|
|
11
9
|
const constants_1 = require("../constants");
|
|
10
|
+
const to_json_1 = require("./to-json");
|
|
12
11
|
const write_file_sync_1 = require("./write-file-sync");
|
|
13
12
|
function writeIfChanged(ctx) {
|
|
14
|
-
return (0, effect_1.pipe)(effect_1.Effect.all(ctx.packageJsonFiles.map((file) => (0, effect_1.pipe)(effect_1.Effect.Do, effect_1.Effect.bind('nextJson', () => toJson(file)), effect_1.Effect.bind('hasChanged', ({ nextJson }) => effect_1.Effect.succeed(file.jsonFile.json !== nextJson)), effect_1.Effect.flatMap(({ hasChanged, nextJson }) => hasChanged
|
|
13
|
+
return (0, effect_1.pipe)(effect_1.Effect.all(ctx.packageJsonFiles.map((file) => (0, effect_1.pipe)(effect_1.Effect.Do, effect_1.Effect.bind('nextJson', () => effect_1.Effect.succeed((0, to_json_1.toJson)(ctx, file))), effect_1.Effect.bind('hasChanged', ({ nextJson }) => effect_1.Effect.succeed(file.jsonFile.json !== nextJson)), effect_1.Effect.flatMap(({ hasChanged, nextJson }) => hasChanged
|
|
15
14
|
? (0, effect_1.pipe)((0, write_file_sync_1.writeFileSync)(file.jsonFile.filePath, nextJson), effect_1.Effect.flatMap(() => effect_1.Effect.logInfo((0, chalk_1.default) `{green ${constants_1.ICON.tick}} ${file.jsonFile.shortPath}`)))
|
|
16
15
|
: effect_1.Effect.logInfo((0, chalk_1.default) `{dim ${constants_1.ICON.skip} ${file.jsonFile.shortPath}}`))))), effect_1.Effect.map(() => ctx));
|
|
17
|
-
function toJson(file) {
|
|
18
|
-
const contents = file.jsonFile.contents;
|
|
19
|
-
const indent = (0, get_indent_1.getIndent)(ctx.config);
|
|
20
|
-
const EOL = exports.newlines.detect(file.jsonFile.json);
|
|
21
|
-
const source = `${JSON.stringify(contents, null, indent)}${EOL}`;
|
|
22
|
-
return effect_1.Effect.succeed(exports.newlines.fix(source, EOL));
|
|
23
|
-
}
|
|
24
16
|
}
|
|
25
17
|
exports.writeIfChanged = writeIfChanged;
|
|
26
|
-
const CR = '\r';
|
|
27
|
-
const CRLF = '\r\n';
|
|
28
|
-
const LF = '\n';
|
|
29
|
-
exports.newlines = {
|
|
30
|
-
detect(source) {
|
|
31
|
-
const cr = source.split(CR).length;
|
|
32
|
-
const lf = source.split(LF).length;
|
|
33
|
-
const crlf = source.split(CRLF).length;
|
|
34
|
-
if (cr + lf === 0)
|
|
35
|
-
return os_1.EOL;
|
|
36
|
-
if (crlf === cr && crlf === lf)
|
|
37
|
-
return CRLF;
|
|
38
|
-
if (cr > lf)
|
|
39
|
-
return CR;
|
|
40
|
-
return LF;
|
|
41
|
-
},
|
|
42
|
-
fix(source, lineEnding) {
|
|
43
|
-
return source.replace(/\r\n|\n|\r/g, lineEnding);
|
|
44
|
-
},
|
|
45
|
-
};
|
package/dist/option.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export declare const option: {
|
|
|
3
3
|
readonly filter: readonly ["-f, --filter [pattern]", string];
|
|
4
4
|
readonly indent: readonly ["-i, --indent [value]", `override indentation. defaults to "${string}"`];
|
|
5
5
|
readonly source: readonly ["-s, --source [pattern]", "glob pattern for package.json files to read from", typeof collect, string[]];
|
|
6
|
+
readonly specs: readonly ["-s, --specs <names>", string];
|
|
6
7
|
readonly types: readonly ["-t, --types <names>", string];
|
|
7
8
|
};
|
|
8
9
|
declare function collect(value: string, previous: string[]): string[];
|
package/dist/option.js
CHANGED
|
@@ -19,6 +19,10 @@ exports.option = {
|
|
|
19
19
|
collect,
|
|
20
20
|
[],
|
|
21
21
|
],
|
|
22
|
+
specs: [
|
|
23
|
+
'-s, --specs <names>',
|
|
24
|
+
(0, chalk_1.default) `only include dependencies whose version specifier match these types (eg. {yellow specs=latest,range,workspace-protocol})`,
|
|
25
|
+
],
|
|
22
26
|
types: [
|
|
23
27
|
'-t, --types <names>',
|
|
24
28
|
(0, chalk_1.default) `only include dependencies matching these types (eg. {yellow types=dev,prod,myCustomType})`,
|