syncpack 13.0.1 → 14.0.0-alpha.2
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 +0 -3
- package/index.js +48 -0
- package/package.json +16 -73
- package/schema.json +917 -0
- package/syncpack.d.ts +122 -0
- package/LICENSE +0 -20
- package/dist/bin-fix-mismatches/fix-mismatches.d.ts +0 -16
- package/dist/bin-fix-mismatches/fix-mismatches.js +0 -115
- package/dist/bin-fix-mismatches/index.d.ts +0 -2
- package/dist/bin-fix-mismatches/index.js +0 -33
- package/dist/bin-format/format.d.ts +0 -13
- package/dist/bin-format/format.js +0 -92
- package/dist/bin-format/index.d.ts +0 -2
- package/dist/bin-format/index.js +0 -28
- package/dist/bin-lint/index.d.ts +0 -2
- package/dist/bin-lint/index.js +0 -17
- package/dist/bin-lint/lint.d.ts +0 -11
- package/dist/bin-lint/lint.js +0 -52
- package/dist/bin-lint-semver-ranges/index.d.ts +0 -2
- package/dist/bin-lint-semver-ranges/index.js +0 -30
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.d.ts +0 -16
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +0 -92
- package/dist/bin-list/index.d.ts +0 -2
- package/dist/bin-list/index.js +0 -27
- package/dist/bin-list/list.d.ts +0 -14
- package/dist/bin-list/list.js +0 -151
- package/dist/bin-list-mismatches/index.d.ts +0 -2
- package/dist/bin-list-mismatches/index.js +0 -29
- package/dist/bin-list-mismatches/list-mismatches.d.ts +0 -18
- package/dist/bin-list-mismatches/list-mismatches.js +0 -224
- package/dist/bin-prompt/index.d.ts +0 -2
- package/dist/bin-prompt/index.js +0 -29
- package/dist/bin-prompt/prompt.d.ts +0 -11
- package/dist/bin-prompt/prompt.js +0 -95
- package/dist/bin-set-semver-ranges/index.d.ts +0 -2
- package/dist/bin-set-semver-ranges/index.js +0 -32
- package/dist/bin-set-semver-ranges/set-semver-ranges.d.ts +0 -11
- package/dist/bin-set-semver-ranges/set-semver-ranges.js +0 -61
- package/dist/bin-update/effects.d.ts +0 -52
- package/dist/bin-update/effects.js +0 -282
- package/dist/bin-update/index.d.ts +0 -2
- package/dist/bin-update/index.js +0 -24
- package/dist/bin-update/update.d.ts +0 -6
- package/dist/bin-update/update.js +0 -59
- package/dist/bin.d.ts +0 -2
- package/dist/bin.js +0 -37
- package/dist/config/get-custom-types.d.ts +0 -19
- package/dist/config/get-custom-types.js +0 -57
- package/dist/config/get-enabled-types.d.ts +0 -17
- package/dist/config/get-enabled-types.js +0 -109
- package/dist/config/get-filter.d.ts +0 -2
- package/dist/config/get-filter.js +0 -10
- package/dist/config/get-indent.d.ts +0 -2
- package/dist/config/get-indent.js +0 -9
- package/dist/config/get-sort-az.d.ts +0 -2
- package/dist/config/get-sort-az.js +0 -8
- package/dist/config/get-sort-exports.d.ts +0 -2
- package/dist/config/get-sort-exports.js +0 -9
- package/dist/config/get-sort-first.d.ts +0 -2
- package/dist/config/get-sort-first.js +0 -8
- package/dist/config/get-source.d.ts +0 -2
- package/dist/config/get-source.js +0 -8
- package/dist/config/tag.d.ts +0 -3
- package/dist/config/tag.js +0 -2
- package/dist/config/types.d.ts +0 -134
- package/dist/config/types.js +0 -1
- package/dist/constants.d.ts +0 -106
- package/dist/constants.js +0 -103
- package/dist/error-handlers/default-error-handlers.d.ts +0 -25
- package/dist/error-handlers/default-error-handlers.js +0 -80
- package/dist/get-context/index.d.ts +0 -23
- package/dist/get-context/index.js +0 -18
- package/dist/get-context/lib/key-by.d.ts +0 -6
- package/dist/get-context/lib/key-by.js +0 -12
- package/dist/get-instances/index.d.ts +0 -14
- package/dist/get-instances/index.js +0 -42
- package/dist/get-instances/instance.d.ts +0 -26
- package/dist/get-instances/instance.js +0 -35
- package/dist/get-package-json-files/get-file-paths.d.ts +0 -21
- package/dist/get-package-json-files/get-file-paths.js +0 -22
- package/dist/get-package-json-files/get-patterns/get-lerna-patterns.d.ts +0 -3
- package/dist/get-package-json-files/get-patterns/get-lerna-patterns.js +0 -12
- package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.d.ts +0 -3
- package/dist/get-package-json-files/get-patterns/get-pnpm-patterns.js +0 -14
- package/dist/get-package-json-files/get-patterns/get-yarn-patterns.d.ts +0 -3
- package/dist/get-package-json-files/get-patterns/get-yarn-patterns.js +0 -16
- package/dist/get-package-json-files/get-patterns/index.d.ts +0 -8
- package/dist/get-package-json-files/get-patterns/index.js +0 -23
- package/dist/get-package-json-files/index.d.ts +0 -10
- package/dist/get-package-json-files/index.js +0 -8
- package/dist/get-package-json-files/package-json-file.d.ts +0 -54
- package/dist/get-package-json-files/package-json-file.js +0 -44
- package/dist/guards/can-add-to-group.d.ts +0 -5
- package/dist/guards/can-add-to-group.js +0 -58
- package/dist/guards/is-semver.d.ts +0 -2
- package/dist/guards/is-semver.js +0 -15
- package/dist/guards/is-valid-semver-range.d.ts +0 -3
- package/dist/guards/is-valid-semver-range.js +0 -14
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -1
- package/dist/io/ask-for-choice.d.ts +0 -14
- package/dist/io/ask-for-choice.js +0 -17
- package/dist/io/ask-for-input.d.ts +0 -13
- package/dist/io/ask-for-input.js +0 -14
- package/dist/io/exit-if-invalid.d.ts +0 -4
- package/dist/io/exit-if-invalid.js +0 -9
- package/dist/io/glob-sync.d.ts +0 -11
- package/dist/io/glob-sync.js +0 -14
- package/dist/io/index.d.ts +0 -27
- package/dist/io/index.js +0 -26
- package/dist/io/read-config-file.d.ts +0 -7
- package/dist/io/read-config-file.js +0 -24
- package/dist/io/read-file-sync.d.ts +0 -12
- package/dist/io/read-file-sync.js +0 -9
- package/dist/io/read-json-file-sync.d.ts +0 -31
- package/dist/io/read-json-file-sync.js +0 -23
- package/dist/io/read-yaml-file-sync.d.ts +0 -12
- package/dist/io/read-yaml-file-sync.js +0 -9
- package/dist/io/to-formatted-json.d.ts +0 -9
- package/dist/io/to-formatted-json.js +0 -32
- package/dist/io/write-file-sync.d.ts +0 -12
- package/dist/io/write-file-sync.js +0 -10
- package/dist/io/write-if-changed.d.ts +0 -5
- package/dist/io/write-if-changed.js +0 -9
- package/dist/lib/format-repository-url.d.ts +0 -1
- package/dist/lib/format-repository-url.js +0 -40
- package/dist/lib/get-group-header.d.ts +0 -10
- package/dist/lib/get-group-header.js +0 -25
- package/dist/lib/get.d.ts +0 -11
- package/dist/lib/get.js +0 -44
- package/dist/lib/pad-start.d.ts +0 -1
- package/dist/lib/pad-start.js +0 -3
- package/dist/lib/ring-buffer.d.ts +0 -10
- package/dist/lib/ring-buffer.js +0 -20
- package/dist/lib/set-semver-range.d.ts +0 -3
- package/dist/lib/set-semver-range.js +0 -24
- package/dist/lib/show-help-on-error.d.ts +0 -2
- package/dist/lib/show-help-on-error.js +0 -32
- package/dist/lib/sort-by-name.d.ts +0 -5
- package/dist/lib/sort-by-name.js +0 -9
- package/dist/lib/with-logger.d.ts +0 -2
- package/dist/lib/with-logger.js +0 -28
- package/dist/option.d.ts +0 -10
- package/dist/option.js +0 -30
- package/dist/report.d.ts +0 -131
- package/dist/report.js +0 -129
- package/dist/schema.json +0 -614
- package/dist/semver-group/create-semver-groups.d.ts +0 -4
- package/dist/semver-group/create-semver-groups.js +0 -83
- package/dist/semver-group/disabled.d.ts +0 -26
- package/dist/semver-group/disabled.js +0 -28
- package/dist/semver-group/filtered-out.d.ts +0 -27
- package/dist/semver-group/filtered-out.js +0 -34
- package/dist/semver-group/ignored.d.ts +0 -22
- package/dist/semver-group/ignored.js +0 -24
- package/dist/semver-group/index.d.ts +0 -20
- package/dist/semver-group/index.js +0 -7
- package/dist/semver-group/with-range.d.ts +0 -22
- package/dist/semver-group/with-range.js +0 -45
- package/dist/specifier/alias.d.ts +0 -17
- package/dist/specifier/alias.js +0 -21
- package/dist/specifier/base.d.ts +0 -41
- package/dist/specifier/base.js +0 -54
- package/dist/specifier/delete.d.ts +0 -17
- package/dist/specifier/delete.js +0 -16
- package/dist/specifier/exact.d.ts +0 -20
- package/dist/specifier/exact.js +0 -21
- package/dist/specifier/file.d.ts +0 -8
- package/dist/specifier/file.js +0 -7
- package/dist/specifier/hosted-git.d.ts +0 -15
- package/dist/specifier/hosted-git.js +0 -24
- package/dist/specifier/index.d.ts +0 -28
- package/dist/specifier/index.js +0 -75
- package/dist/specifier/latest.d.ts +0 -19
- package/dist/specifier/latest.js +0 -20
- package/dist/specifier/lib/non-semver-error.d.ts +0 -11
- package/dist/specifier/lib/non-semver-error.js +0 -6
- package/dist/specifier/lib/parse-specifier.d.ts +0 -14
- package/dist/specifier/lib/parse-specifier.js +0 -18
- package/dist/specifier/lib/specific-registry-result.d.ts +0 -9
- package/dist/specifier/lib/specific-registry-result.js +0 -1
- package/dist/specifier/range.d.ts +0 -19
- package/dist/specifier/range.js +0 -20
- package/dist/specifier/tag.d.ts +0 -11
- package/dist/specifier/tag.js +0 -10
- package/dist/specifier/unsupported.d.ts +0 -7
- package/dist/specifier/unsupported.js +0 -7
- package/dist/specifier/url.d.ts +0 -8
- package/dist/specifier/url.js +0 -7
- package/dist/specifier/workspace-protocol.d.ts +0 -19
- package/dist/specifier/workspace-protocol.js +0 -35
- package/dist/strategy/lib/get-non-empty-string-prop.d.ts +0 -3
- package/dist/strategy/lib/get-non-empty-string-prop.js +0 -7
- package/dist/strategy/name-and-version-props.d.ts +0 -12
- package/dist/strategy/name-and-version-props.js +0 -60
- package/dist/strategy/named-version-string.d.ts +0 -11
- package/dist/strategy/named-version-string.js +0 -52
- package/dist/strategy/unnamed-version-string.d.ts +0 -11
- package/dist/strategy/unnamed-version-string.js +0 -45
- package/dist/strategy/versions-by-name.d.ts +0 -11
- package/dist/strategy/versions-by-name.js +0 -27
- package/dist/version-group/banned.d.ts +0 -17
- package/dist/version-group/banned.js +0 -26
- package/dist/version-group/create-version-groups.d.ts +0 -4
- package/dist/version-group/create-version-groups.js +0 -118
- package/dist/version-group/filtered-out.d.ts +0 -19
- package/dist/version-group/filtered-out.js +0 -30
- package/dist/version-group/ignored.d.ts +0 -17
- package/dist/version-group/ignored.js +0 -23
- package/dist/version-group/index.d.ts +0 -26
- package/dist/version-group/index.js +0 -7
- package/dist/version-group/lib/clean.d.ts +0 -2
- package/dist/version-group/lib/clean.js +0 -6
- package/dist/version-group/lib/delete.d.ts +0 -2
- package/dist/version-group/lib/delete.js +0 -1
- package/dist/version-group/lib/get-highest-version.d.ts +0 -6
- package/dist/version-group/lib/get-highest-version.js +0 -8
- package/dist/version-group/lib/get-lowest-version.d.ts +0 -6
- package/dist/version-group/lib/get-lowest-version.js +0 -8
- package/dist/version-group/lib/get-preferred-version.d.ts +0 -5
- package/dist/version-group/lib/get-preferred-version.js +0 -53
- package/dist/version-group/lib/get-range-score.d.ts +0 -2
- package/dist/version-group/lib/get-range-score.js +0 -20
- package/dist/version-group/lib/group-by.d.ts +0 -5
- package/dist/version-group/lib/group-by.js +0 -11
- package/dist/version-group/pinned.d.ts +0 -17
- package/dist/version-group/pinned.js +0 -26
- package/dist/version-group/same-range.d.ts +0 -19
- package/dist/version-group/same-range.js +0 -96
- package/dist/version-group/snapped-to.d.ts +0 -17
- package/dist/version-group/snapped-to.js +0 -71
- package/dist/version-group/standard.d.ts +0 -18
- package/dist/version-group/standard.js +0 -119
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Effect, pipe } from 'effect';
|
|
2
|
-
import { applyEdits, modify } from 'jsonc-parser';
|
|
3
|
-
import { Instance } from '../get-instances/instance.js';
|
|
4
|
-
export class PackageJsonFile {
|
|
5
|
-
/** resolved configuration */
|
|
6
|
-
config;
|
|
7
|
-
/** ensure only one set of instances is ever created and shared */
|
|
8
|
-
_instances;
|
|
9
|
-
/** the wrapped package.json file */
|
|
10
|
-
jsonFile;
|
|
11
|
-
/** the .name property from the package.json file */
|
|
12
|
-
name;
|
|
13
|
-
/** the next package.json file contents after modification, with formatting preserved */
|
|
14
|
-
nextJson;
|
|
15
|
-
constructor(jsonFile, config) {
|
|
16
|
-
this._instances = null;
|
|
17
|
-
this.config = config;
|
|
18
|
-
this.jsonFile = jsonFile;
|
|
19
|
-
this.name = jsonFile.contents.name;
|
|
20
|
-
this.nextJson = jsonFile.json;
|
|
21
|
-
}
|
|
22
|
-
getInstances(enabledTypes) {
|
|
23
|
-
if (!this._instances) {
|
|
24
|
-
return pipe(Effect.all(enabledTypes.map(strategy => pipe(strategy.read(this), Effect.map(entries => entries.map(([name, rawSpecifier]) => new Instance(name, rawSpecifier, this, strategy)))))), Effect.map(array => array.flat()), Effect.tapBoth({
|
|
25
|
-
onSuccess: instances => Effect.logDebug(`found ${instances.length} instances in <${this.jsonFile.shortPath}>`),
|
|
26
|
-
onFailure: () => Effect.logError(`failed to get instances from <${this.jsonFile.shortPath}>`),
|
|
27
|
-
}), Effect.catchAll(() => Effect.succeed([])), Effect.tap(instances => Effect.sync(() => {
|
|
28
|
-
this._instances = instances;
|
|
29
|
-
})));
|
|
30
|
-
}
|
|
31
|
-
return Effect.succeed(this._instances);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Apply an edit to the raw JSON string which will be written to disk. This string preserves the
|
|
35
|
-
* original formatting of the file.
|
|
36
|
-
*/
|
|
37
|
-
applyEdit(fullPath, value) {
|
|
38
|
-
const edits = modify(this.nextJson, fullPath.map(parseNumericStrings), value, {});
|
|
39
|
-
this.nextJson = applyEdits(this.nextJson, edits);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function parseNumericStrings(key) {
|
|
43
|
-
return /[^0-9]/.test(key) ? key : Number(key);
|
|
44
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Ctx } from '../get-context/index.js';
|
|
2
|
-
import type { Instance } from '../get-instances/instance.js';
|
|
3
|
-
import type { SemverGroup } from '../semver-group/index.js';
|
|
4
|
-
import type { VersionGroup } from '../version-group/index.js';
|
|
5
|
-
export declare function canAddToGroup(packageJsonFilesByName: Ctx['packageJsonFilesByName'], group: SemverGroup.Any | VersionGroup.Any, instance: Instance): boolean;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { minimatch } from 'minimatch';
|
|
2
|
-
import { isNonEmptyArray } from 'tightrope/guard/is-non-empty-array.js';
|
|
3
|
-
export function canAddToGroup(packageJsonFilesByName, group, instance) {
|
|
4
|
-
const { dependencies, dependencyTypes, packages, specifierTypes } = group.config;
|
|
5
|
-
return (group.canAdd(instance) &&
|
|
6
|
-
matchesDependencyTypes(dependencyTypes, instance) &&
|
|
7
|
-
matchesPackages(packages, instance) &&
|
|
8
|
-
matchesDependencies(packageJsonFilesByName, group, dependencies, instance) &&
|
|
9
|
-
matchesSpecifierTypes(specifierTypes, instance));
|
|
10
|
-
}
|
|
11
|
-
function matchesDependencies(packageJsonFilesByName, group, dependencies, instance) {
|
|
12
|
-
// matches if not defined
|
|
13
|
-
if (!isNonEmptyArray(dependencies)) {
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
return dependencies.some(pattern => (pattern === '$LOCAL' &&
|
|
17
|
-
instance.name in packageJsonFilesByName &&
|
|
18
|
-
((group.groupType === 'versionGroup' &&
|
|
19
|
-
instance.versionGroup === null) ||
|
|
20
|
-
(group.groupType === 'semverGroup' &&
|
|
21
|
-
instance.semverGroup === null))) ||
|
|
22
|
-
minimatch(instance.name, pattern));
|
|
23
|
-
}
|
|
24
|
-
function matchesPackages(packages, instance) {
|
|
25
|
-
return matchesKnownList(packages, instance.pkgName);
|
|
26
|
-
}
|
|
27
|
-
function matchesDependencyTypes(dependencyTypes, instance) {
|
|
28
|
-
return matchesKnownList(dependencyTypes, instance.strategy.name);
|
|
29
|
-
}
|
|
30
|
-
function matchesSpecifierTypes(specifierTypes, instance) {
|
|
31
|
-
return matchesKnownList(specifierTypes, instance.rawSpecifier.name);
|
|
32
|
-
}
|
|
33
|
-
function matchesKnownList(values, value) {
|
|
34
|
-
// matches if not defined
|
|
35
|
-
if (!isNonEmptyArray(values)) {
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
if (values.join('') === '**') {
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
const negative = [];
|
|
42
|
-
const positive = [];
|
|
43
|
-
values.forEach(name => {
|
|
44
|
-
if (name.startsWith('!')) {
|
|
45
|
-
negative.push(name.replace('!', ''));
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
positive.push(name);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
if (isNonEmptyArray(negative) && !someMinimatch(value, negative)) {
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
return isNonEmptyArray(positive) && someMinimatch(value, positive);
|
|
55
|
-
}
|
|
56
|
-
function someMinimatch(value, patterns) {
|
|
57
|
-
return patterns.some(pattern => minimatch(value, pattern));
|
|
58
|
-
}
|
package/dist/guards/is-semver.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { isString } from 'tightrope/guard/is-string.js';
|
|
2
|
-
/** @deprecated migrate to make better use of npm-package-arg */
|
|
3
|
-
export function isSemver(version) {
|
|
4
|
-
const range = '(~|\\^|>=|>|<=|<)?';
|
|
5
|
-
const ints = '[0-9]+';
|
|
6
|
-
const intsOrX = '([0-9]+|x)';
|
|
7
|
-
const dot = '\\.';
|
|
8
|
-
const major = new RegExp(`^${range}${ints}$`);
|
|
9
|
-
const minor = new RegExp(`^${range}${ints}${dot}${intsOrX}$`);
|
|
10
|
-
const patch = new RegExp(`^${range}${ints}${dot}${intsOrX}${dot}${intsOrX}$`);
|
|
11
|
-
return (isString(version) &&
|
|
12
|
-
(version.search(major) !== -1 ||
|
|
13
|
-
version.search(minor) !== -1 ||
|
|
14
|
-
version.search(patch) !== -1));
|
|
15
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { RANGE } from '../constants.js';
|
|
2
|
-
/** @deprecated migrate to make better use of npm-package-arg */
|
|
3
|
-
export function isValidSemverRange(value) {
|
|
4
|
-
return (value === RANGE.ANY ||
|
|
5
|
-
value === RANGE.EXACT ||
|
|
6
|
-
value === RANGE.GT ||
|
|
7
|
-
value === RANGE.GTE ||
|
|
8
|
-
value === RANGE.LOOSE ||
|
|
9
|
-
value === RANGE.LT ||
|
|
10
|
-
value === RANGE.LTE ||
|
|
11
|
-
value === RANGE.MINOR ||
|
|
12
|
-
value === RANGE.PATCH ||
|
|
13
|
-
value === RANGE.WORKSPACE);
|
|
14
|
-
}
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Effect } from 'effect';
|
|
2
|
-
import type { Io } from './index.js';
|
|
3
|
-
declare const AskForChoiceError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => Readonly<A> & {
|
|
4
|
-
readonly _tag: "AskForChoiceError";
|
|
5
|
-
};
|
|
6
|
-
declare class AskForChoiceError extends AskForChoiceError_base<{
|
|
7
|
-
readonly error: string;
|
|
8
|
-
}> {
|
|
9
|
-
}
|
|
10
|
-
export declare function askForChoice(opts: {
|
|
11
|
-
message: string;
|
|
12
|
-
choices: string[];
|
|
13
|
-
}): Effect.Effect<string, AskForChoiceError, Io>;
|
|
14
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Data, Effect, pipe } from 'effect';
|
|
2
|
-
import { IoTag } from './index.js';
|
|
3
|
-
class AskForChoiceError extends Data.TaggedClass('AskForChoiceError') {
|
|
4
|
-
}
|
|
5
|
-
export function askForChoice(opts) {
|
|
6
|
-
return pipe(IoTag, Effect.flatMap(io => Effect.tryPromise({
|
|
7
|
-
try: () => io.enquirer
|
|
8
|
-
.prompt({
|
|
9
|
-
type: 'select',
|
|
10
|
-
name: 'choice',
|
|
11
|
-
message: opts.message,
|
|
12
|
-
choices: opts.choices,
|
|
13
|
-
})
|
|
14
|
-
.then(res => res.choice),
|
|
15
|
-
catch: err => new AskForChoiceError({ error: String(err) }),
|
|
16
|
-
})));
|
|
17
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Effect } from 'effect';
|
|
2
|
-
import type { Io } from './index.js';
|
|
3
|
-
declare const AskForInputError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => Readonly<A> & {
|
|
4
|
-
readonly _tag: "AskForInputError";
|
|
5
|
-
};
|
|
6
|
-
declare class AskForInputError extends AskForInputError_base<{
|
|
7
|
-
readonly error: string;
|
|
8
|
-
}> {
|
|
9
|
-
}
|
|
10
|
-
export declare function askForInput(opts: {
|
|
11
|
-
message: string;
|
|
12
|
-
}): Effect.Effect<string, AskForInputError, Io>;
|
|
13
|
-
export {};
|
package/dist/io/ask-for-input.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Data, Effect, pipe } from 'effect';
|
|
2
|
-
import { IoTag } from './index.js';
|
|
3
|
-
class AskForInputError extends Data.TaggedClass('AskForInputError') {
|
|
4
|
-
}
|
|
5
|
-
export function askForInput(opts) {
|
|
6
|
-
return pipe(IoTag, Effect.flatMap(io => Effect.tryPromise({
|
|
7
|
-
try: () => io.enquirer.prompt({
|
|
8
|
-
name: 'version',
|
|
9
|
-
type: 'input',
|
|
10
|
-
message: opts.message,
|
|
11
|
-
}),
|
|
12
|
-
catch: err => new AskForInputError({ error: String(err) }),
|
|
13
|
-
})));
|
|
14
|
-
}
|
package/dist/io/glob-sync.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Effect } from 'effect';
|
|
2
|
-
import type { Io } from './index.js';
|
|
3
|
-
declare const GlobError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => Readonly<A> & {
|
|
4
|
-
readonly _tag: "GlobError";
|
|
5
|
-
};
|
|
6
|
-
export declare class GlobError extends GlobError_base<{
|
|
7
|
-
readonly error: string;
|
|
8
|
-
}> {
|
|
9
|
-
}
|
|
10
|
-
export declare function globSync(io: Io, patterns: string[]): Effect.Effect<string[], GlobError>;
|
|
11
|
-
export {};
|
package/dist/io/glob-sync.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Data, Effect } from 'effect';
|
|
2
|
-
export class GlobError extends Data.TaggedClass('GlobError') {
|
|
3
|
-
}
|
|
4
|
-
export function globSync(io, patterns) {
|
|
5
|
-
return Effect.try({
|
|
6
|
-
try: () => io.globby.sync(patterns, {
|
|
7
|
-
absolute: true,
|
|
8
|
-
cwd: io.process.cwd(),
|
|
9
|
-
fs: io.fs,
|
|
10
|
-
ignore: ['**/node_modules/**'],
|
|
11
|
-
}),
|
|
12
|
-
catch: err => new GlobError({ error: String(err) }),
|
|
13
|
-
});
|
|
14
|
-
}
|
package/dist/io/index.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import { cosmiconfig } from 'cosmiconfig';
|
|
3
|
-
import { Context } from 'effect';
|
|
4
|
-
import enquirer from 'enquirer';
|
|
5
|
-
import { globbySync } from 'globby';
|
|
6
|
-
import { sync as readYamlFileSync } from 'read-yaml-file';
|
|
7
|
-
export interface Io {
|
|
8
|
-
cosmiconfig: {
|
|
9
|
-
cosmiconfig: typeof cosmiconfig;
|
|
10
|
-
};
|
|
11
|
-
enquirer: {
|
|
12
|
-
prompt: typeof enquirer.prompt<any>;
|
|
13
|
-
};
|
|
14
|
-
fs: typeof fs;
|
|
15
|
-
globby: {
|
|
16
|
-
sync: typeof globbySync;
|
|
17
|
-
};
|
|
18
|
-
process: {
|
|
19
|
-
cwd: typeof process.cwd;
|
|
20
|
-
exit: typeof process.exit;
|
|
21
|
-
};
|
|
22
|
-
readYamlFile: {
|
|
23
|
-
sync: typeof readYamlFileSync<any>;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export declare const IoTag: Context.Tag<Io, Io>;
|
|
27
|
-
export declare const io: Io;
|
package/dist/io/index.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import { cosmiconfig } from 'cosmiconfig';
|
|
3
|
-
import { Context } from 'effect';
|
|
4
|
-
import enquirer from 'enquirer';
|
|
5
|
-
import { globbySync } from 'globby';
|
|
6
|
-
import { sync as readYamlFileSync } from 'read-yaml-file';
|
|
7
|
-
export const IoTag = Context.GenericTag('@services/IoTag');
|
|
8
|
-
export const io = {
|
|
9
|
-
cosmiconfig: {
|
|
10
|
-
cosmiconfig,
|
|
11
|
-
},
|
|
12
|
-
enquirer: {
|
|
13
|
-
prompt: enquirer.prompt,
|
|
14
|
-
},
|
|
15
|
-
fs: fs,
|
|
16
|
-
globby: {
|
|
17
|
-
sync: globbySync,
|
|
18
|
-
},
|
|
19
|
-
process: {
|
|
20
|
-
cwd: process.cwd,
|
|
21
|
-
exit: process.exit,
|
|
22
|
-
},
|
|
23
|
-
readYamlFile: {
|
|
24
|
-
sync: readYamlFileSync,
|
|
25
|
-
},
|
|
26
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Effect } from 'effect';
|
|
2
|
-
import type { O } from 'ts-toolbelt';
|
|
3
|
-
import type { RcConfig } from '../config/types.js';
|
|
4
|
-
import type { Io } from './index.js';
|
|
5
|
-
type UnverifiedRcConfig = O.Partial<RcConfig, 'deep'>;
|
|
6
|
-
export declare function readConfigFile(io: Io, configPath?: string): Effect.Effect<UnverifiedRcConfig>;
|
|
7
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
2
|
-
import { Effect, Option, pipe } from 'effect';
|
|
3
|
-
import { isNonEmptyObject } from 'tightrope/guard/is-non-empty-object.js';
|
|
4
|
-
import { readJsonFileSync } from './read-json-file-sync.js';
|
|
5
|
-
const getOptionOfNonEmptyObject = Option.liftPredicate((isNonEmptyObject));
|
|
6
|
-
export function readConfigFile(io, configPath) {
|
|
7
|
-
return pipe(Effect.try(() => io.cosmiconfig.cosmiconfig('syncpack')), Effect.flatMap(client => Effect.tryPromise(() => configPath ? client.load(configPath) : client.search())), Effect.flatMap(result => result !== null
|
|
8
|
-
? getValueFromCosmiconfig(result)
|
|
9
|
-
: findConfigInPackageJson(io)), Effect.tap(config => Effect.logDebug(`config file found: ${JSON.stringify(config)}`)), Effect.tapError(() => Effect.logDebug('no config file found, will use defaults')), Effect.catchAll(() => Effect.succeed({})));
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Look for a .config.syncpack property in the root package.json.
|
|
13
|
-
* @see https://github.com/JamieMason/syncpack/issues/86
|
|
14
|
-
*/
|
|
15
|
-
function findConfigInPackageJson(io) {
|
|
16
|
-
return pipe(Effect.Do, Effect.bind('rcPath', () => Effect.succeed(join(io.process.cwd(), 'package.json'))), Effect.bind('packageJson', ({ rcPath }) => readJsonFileSync(io, rcPath)), Effect.bind('config', ({ packageJson }) => Effect.try(() => packageJson.contents?.config?.syncpack)), Effect.flatMap(({ config }) => getOptionOfNonEmptyObject(config)), Effect.tapBoth({
|
|
17
|
-
onSuccess: () => Effect.logDebug('config found in <package.json>.config.syncpack'),
|
|
18
|
-
onFailure: () => Effect.logDebug('config not found in <package.json>.config.syncpack'),
|
|
19
|
-
}));
|
|
20
|
-
}
|
|
21
|
-
/** Extract the value from a successful search by cosmiconfig */
|
|
22
|
-
function getValueFromCosmiconfig(result) {
|
|
23
|
-
return pipe(Effect.succeed(result), Effect.tap(result => Effect.logDebug(`cosmiconfig found ${result.filepath}`)), Effect.flatMap(result => getOptionOfNonEmptyObject(result.config)));
|
|
24
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Effect } from 'effect';
|
|
2
|
-
import type { Io } from './index.js';
|
|
3
|
-
declare const ReadFileError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => Readonly<A> & {
|
|
4
|
-
readonly _tag: "ReadFileError";
|
|
5
|
-
};
|
|
6
|
-
export declare class ReadFileError extends ReadFileError_base<{
|
|
7
|
-
readonly filePath: string;
|
|
8
|
-
readonly error: string;
|
|
9
|
-
}> {
|
|
10
|
-
}
|
|
11
|
-
export declare function readFileSync(io: Io, filePath: string): Effect.Effect<string, ReadFileError>;
|
|
12
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Data, Effect } from 'effect';
|
|
2
|
-
export class ReadFileError extends Data.TaggedClass('ReadFileError') {
|
|
3
|
-
}
|
|
4
|
-
export function readFileSync(io, filePath) {
|
|
5
|
-
return Effect.try({
|
|
6
|
-
try: () => io.fs.readFileSync(filePath, { encoding: 'utf8' }),
|
|
7
|
-
catch: err => new ReadFileError({ filePath, error: String(err) }),
|
|
8
|
-
});
|
|
9
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Effect } from 'effect';
|
|
2
|
-
import { type ParseError } from 'jsonc-parser';
|
|
3
|
-
import type { Io } from './index.js';
|
|
4
|
-
import type { ReadFileError } from './read-file-sync.js';
|
|
5
|
-
declare const JsonParseError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => Readonly<A> & {
|
|
6
|
-
readonly _tag: "JsonParseError";
|
|
7
|
-
};
|
|
8
|
-
export declare class JsonParseError extends JsonParseError_base<{
|
|
9
|
-
readonly errors: ParseError[];
|
|
10
|
-
readonly filePath: string;
|
|
11
|
-
readonly json: string;
|
|
12
|
-
}> {
|
|
13
|
-
}
|
|
14
|
-
declare const JsonFile_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => Readonly<A> & {
|
|
15
|
-
readonly _tag: "JsonFile";
|
|
16
|
-
};
|
|
17
|
-
export declare class JsonFile<T> extends JsonFile_base<{
|
|
18
|
-
/** absolute path on disk to the directory of this file */
|
|
19
|
-
readonly dirPath: string;
|
|
20
|
-
/** absolute path on disk to this file */
|
|
21
|
-
readonly filePath: string;
|
|
22
|
-
/** relative path on disk to this file */
|
|
23
|
-
readonly shortPath: string;
|
|
24
|
-
/** parsed JSON contents of the file */
|
|
25
|
-
contents: T;
|
|
26
|
-
/** raw file contents of the file */
|
|
27
|
-
readonly json: string;
|
|
28
|
-
}> {
|
|
29
|
-
}
|
|
30
|
-
export declare function readJsonFileSync<T>(io: Io, filePath: string): Effect.Effect<JsonFile<T>, ReadFileError | JsonParseError>;
|
|
31
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { dirname, relative } from 'node:path';
|
|
2
|
-
import { Data, Effect, pipe } from 'effect';
|
|
3
|
-
import { parse } from 'jsonc-parser';
|
|
4
|
-
import { readFileSync } from './read-file-sync.js';
|
|
5
|
-
export class JsonParseError extends Data.TaggedClass('JsonParseError') {
|
|
6
|
-
}
|
|
7
|
-
export class JsonFile extends Data.TaggedClass('JsonFile') {
|
|
8
|
-
}
|
|
9
|
-
export function readJsonFileSync(io, filePath) {
|
|
10
|
-
return pipe(Effect.Do, Effect.bind('json', () => readFileSync(io, filePath)), Effect.bind('contents', ({ json }) => {
|
|
11
|
-
const errors = [];
|
|
12
|
-
const data = parse(json, errors);
|
|
13
|
-
return errors.length === 0
|
|
14
|
-
? Effect.succeed(data)
|
|
15
|
-
: Effect.fail(new JsonParseError({ errors, filePath, json }));
|
|
16
|
-
}), Effect.map(({ contents, json }) => new JsonFile({
|
|
17
|
-
contents,
|
|
18
|
-
dirPath: dirname(filePath),
|
|
19
|
-
filePath,
|
|
20
|
-
json,
|
|
21
|
-
shortPath: relative(io.process.cwd(), filePath),
|
|
22
|
-
})));
|
|
23
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Effect } from 'effect';
|
|
2
|
-
import type { Io } from './index.js';
|
|
3
|
-
declare const ReadYamlFileError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => Readonly<A> & {
|
|
4
|
-
readonly _tag: "ReadYamlFileError";
|
|
5
|
-
};
|
|
6
|
-
declare class ReadYamlFileError extends ReadYamlFileError_base<{
|
|
7
|
-
readonly filePath: string;
|
|
8
|
-
readonly error: string;
|
|
9
|
-
}> {
|
|
10
|
-
}
|
|
11
|
-
export declare function readYamlFileSync<T = unknown>(io: Io, filePath: string): Effect.Effect<T, ReadYamlFileError>;
|
|
12
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Data, Effect } from 'effect';
|
|
2
|
-
class ReadYamlFileError extends Data.TaggedClass('ReadYamlFileError') {
|
|
3
|
-
}
|
|
4
|
-
export function readYamlFileSync(io, filePath) {
|
|
5
|
-
return Effect.try({
|
|
6
|
-
try: () => io.readYamlFile.sync(filePath),
|
|
7
|
-
catch: err => new ReadYamlFileError({ filePath, error: String(err) }),
|
|
8
|
-
});
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Ctx } from '../get-context/index.js';
|
|
2
|
-
import type { PackageJsonFile } from '../get-package-json-files/package-json-file.js';
|
|
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 toFormattedJson(ctx: Ctx, file: PackageJsonFile): string;
|
|
9
|
-
export {};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { EOL } from 'node:os';
|
|
2
|
-
import { getIndent } from '../config/get-indent.js';
|
|
3
|
-
const CR = '\r';
|
|
4
|
-
const CRLF = '\r\n';
|
|
5
|
-
const LF = '\n';
|
|
6
|
-
export const newlines = {
|
|
7
|
-
detect(source) {
|
|
8
|
-
const cr = source.split(CR).length;
|
|
9
|
-
const lf = source.split(LF).length;
|
|
10
|
-
const crlf = source.split(CRLF).length;
|
|
11
|
-
if (cr + lf === 0) {
|
|
12
|
-
return EOL;
|
|
13
|
-
}
|
|
14
|
-
if (crlf === cr && crlf === lf) {
|
|
15
|
-
return CRLF;
|
|
16
|
-
}
|
|
17
|
-
if (cr > lf) {
|
|
18
|
-
return CR;
|
|
19
|
-
}
|
|
20
|
-
return LF;
|
|
21
|
-
},
|
|
22
|
-
fix(source, lineEnding) {
|
|
23
|
-
return source.replace(/\r\n|\n|\r/g, lineEnding);
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
export function toFormattedJson(ctx, file) {
|
|
27
|
-
const contents = file.jsonFile.contents;
|
|
28
|
-
const indent = getIndent(ctx.config);
|
|
29
|
-
const eol = newlines.detect(file.jsonFile.json);
|
|
30
|
-
const source = `${JSON.stringify(contents, null, indent)}${eol}`;
|
|
31
|
-
return newlines.fix(source, eol);
|
|
32
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Effect } from 'effect';
|
|
2
|
-
import type { Io } from './index.js';
|
|
3
|
-
declare const WriteFileError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => Readonly<A> & {
|
|
4
|
-
readonly _tag: "WriteFileError";
|
|
5
|
-
};
|
|
6
|
-
export declare class WriteFileError extends WriteFileError_base<{
|
|
7
|
-
readonly filePath: string;
|
|
8
|
-
readonly error: string;
|
|
9
|
-
}> {
|
|
10
|
-
}
|
|
11
|
-
export declare function writeFileSync(filePath: string, contents: string): Effect.Effect<void, WriteFileError, Io>;
|
|
12
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Data, Effect, pipe } from 'effect';
|
|
2
|
-
import { IoTag } from './index.js';
|
|
3
|
-
export class WriteFileError extends Data.TaggedClass('WriteFileError') {
|
|
4
|
-
}
|
|
5
|
-
export function writeFileSync(filePath, contents) {
|
|
6
|
-
return pipe(IoTag, Effect.flatMap(io => Effect.try({
|
|
7
|
-
try: () => io.fs.writeFileSync(filePath, contents),
|
|
8
|
-
catch: err => new WriteFileError({ filePath, error: String(err) }),
|
|
9
|
-
})));
|
|
10
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Effect } from 'effect';
|
|
2
|
-
import type { Ctx } from '../get-context/index.js';
|
|
3
|
-
import type { Io } from './index.js';
|
|
4
|
-
import type { WriteFileError } from './write-file-sync.js';
|
|
5
|
-
export declare function writeIfChanged(ctx: Ctx): Effect.Effect<Ctx, WriteFileError, Io>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk-template';
|
|
2
|
-
import { Effect, pipe } from 'effect';
|
|
3
|
-
import { ICON } from '../constants.js';
|
|
4
|
-
import { writeFileSync } from './write-file-sync.js';
|
|
5
|
-
export function writeIfChanged(ctx) {
|
|
6
|
-
return pipe(Effect.all(ctx.packageJsonFiles.map((file) => file.jsonFile.json !== file.nextJson
|
|
7
|
-
? pipe(writeFileSync(file.jsonFile.filePath, file.nextJson), Effect.flatMap(() => Effect.logInfo(chalk `{green ${ICON.tick}} ${file.jsonFile.shortPath}`)))
|
|
8
|
-
: Effect.logInfo(chalk `{dim ${ICON.skip} ${file.jsonFile.shortPath}}`))), Effect.map(() => ctx));
|
|
9
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function formatRepositoryUrl(input: string | undefined): string | undefined;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export function formatRepositoryUrl(input) {
|
|
2
|
-
if (!input) {
|
|
3
|
-
return undefined;
|
|
4
|
-
}
|
|
5
|
-
const extractedUrl = input.match(/https?:\/\/[^\s]+/)?.[0];
|
|
6
|
-
if (extractedUrl) {
|
|
7
|
-
const withoutSuffix = removeSuffix(extractedUrl);
|
|
8
|
-
return withoutSuffix;
|
|
9
|
-
}
|
|
10
|
-
const isSshProtocol = input.startsWith('git@');
|
|
11
|
-
if (isSshProtocol) {
|
|
12
|
-
const withoutAffix = removeSuffix(removePrefix(input, 'git@'));
|
|
13
|
-
const [origin, path] = withoutAffix.split(':');
|
|
14
|
-
if (!(origin && path)) {
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
return `https://${origin}/${path}`;
|
|
18
|
-
}
|
|
19
|
-
const isShortcut = input.split('/').length === 2;
|
|
20
|
-
if (isShortcut) {
|
|
21
|
-
return `https://github.com/${input}`;
|
|
22
|
-
}
|
|
23
|
-
const isGitProtocol = input.startsWith('git://');
|
|
24
|
-
if (isGitProtocol) {
|
|
25
|
-
const withoutAffix = removeSuffix(removePrefix(input));
|
|
26
|
-
return `https://${withoutAffix}`;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function removeSuffix(url, suffix = '.git') {
|
|
30
|
-
if (url.endsWith(suffix)) {
|
|
31
|
-
return url.slice(0, url.length - suffix.length);
|
|
32
|
-
}
|
|
33
|
-
return url;
|
|
34
|
-
}
|
|
35
|
-
function removePrefix(url, prefix = 'git://') {
|
|
36
|
-
if (url.startsWith(prefix)) {
|
|
37
|
-
return url.slice(prefix.length, url.length);
|
|
38
|
-
}
|
|
39
|
-
return url;
|
|
40
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { SemverGroup } from '../semver-group/index.js';
|
|
2
|
-
import type { VersionGroup } from '../version-group/index.js';
|
|
3
|
-
export declare function getSemverGroupHeader(input: {
|
|
4
|
-
group: SemverGroup.Any;
|
|
5
|
-
index: number;
|
|
6
|
-
}): string;
|
|
7
|
-
export declare function getVersionGroupHeader(input: {
|
|
8
|
-
group: VersionGroup.Any;
|
|
9
|
-
index: number;
|
|
10
|
-
}): string;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
export function getSemverGroupHeader(input) {
|
|
3
|
-
return getGroupHeader(input.group.config.label || `Semver Group ${input.index + 1}`);
|
|
4
|
-
}
|
|
5
|
-
export function getVersionGroupHeader(input) {
|
|
6
|
-
return getGroupHeader(input.group.config.label || `Version Group ${input.index + 1}`);
|
|
7
|
-
}
|
|
8
|
-
function getGroupHeader(label) {
|
|
9
|
-
const trimmed = label.trim();
|
|
10
|
-
const hasNewLines = trimmed.search(/[\r\n]/) !== -1;
|
|
11
|
-
const header = hasNewLines
|
|
12
|
-
? formatMultiLine(trimmed)
|
|
13
|
-
: formatSingleLine(trimmed);
|
|
14
|
-
return chalk.blue(header);
|
|
15
|
-
}
|
|
16
|
-
function formatSingleLine(label) {
|
|
17
|
-
const leftSide = `= ${label} `;
|
|
18
|
-
const dividerWidth = 80 - leftSide.length;
|
|
19
|
-
const rightSide = dividerWidth > 0 ? '='.repeat(dividerWidth) : '';
|
|
20
|
-
return `${leftSide}${rightSide}`;
|
|
21
|
-
}
|
|
22
|
-
function formatMultiLine(label) {
|
|
23
|
-
const reindented = label.replace(/^\s+/gm, ' ');
|
|
24
|
-
return `= ${reindented}`;
|
|
25
|
-
}
|