syncpack 12.4.0 → 14.0.0-alpha.1
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/index.js +48 -0
- package/package.json +17 -76
- 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 -110
- package/dist/bin-fix-mismatches/index.d.ts +0 -2
- package/dist/bin-fix-mismatches/index.js +0 -64
- package/dist/bin-format/format.d.ts +0 -13
- package/dist/bin-format/format.js +0 -90
- package/dist/bin-format/index.d.ts +0 -2
- package/dist/bin-format/index.js +0 -53
- package/dist/bin-lint/index.d.ts +0 -2
- package/dist/bin-lint/index.js +0 -38
- 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 -65
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.d.ts +0 -16
- package/dist/bin-lint-semver-ranges/lint-semver-ranges.js +0 -91
- package/dist/bin-list/index.d.ts +0 -2
- package/dist/bin-list/index.js +0 -57
- package/dist/bin-list/list.d.ts +0 -14
- package/dist/bin-list/list.js +0 -147
- package/dist/bin-list-mismatches/index.d.ts +0 -2
- package/dist/bin-list-mismatches/index.js +0 -59
- package/dist/bin-list-mismatches/list-mismatches.d.ts +0 -18
- package/dist/bin-list-mismatches/list-mismatches.js +0 -218
- package/dist/bin-prompt/index.d.ts +0 -2
- package/dist/bin-prompt/index.js +0 -61
- package/dist/bin-prompt/prompt.d.ts +0 -11
- package/dist/bin-prompt/prompt.js +0 -93
- package/dist/bin-set-semver-ranges/index.d.ts +0 -2
- package/dist/bin-set-semver-ranges/index.js +0 -69
- package/dist/bin-set-semver-ranges/set-semver-ranges.d.ts +0 -11
- package/dist/bin-set-semver-ranges/set-semver-ranges.js +0 -58
- package/dist/bin-update/effects.d.ts +0 -52
- package/dist/bin-update/effects.js +0 -267
- package/dist/bin-update/index.d.ts +0 -2
- package/dist/bin-update/index.js +0 -54
- 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 -50
- package/dist/config/get-enabled-types.d.ts +0 -17
- package/dist/config/get-enabled-types.js +0 -94
- 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 -8
- 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 -132
- 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 -31
- 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 -10
- 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 -47
- package/dist/get-package-json-files/package-json-file.js +0 -29
- package/dist/guards/can-add-to-group.d.ts +0 -5
- package/dist/guards/can-add-to-group.js +0 -52
- package/dist/guards/is-semver.d.ts +0 -2
- package/dist/guards/is-semver.js +0 -13
- 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 -22
- 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 -30
- package/dist/io/read-json-file-sync.js +0 -19
- 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-json.d.ts +0 -9
- package/dist/io/to-json.js +0 -29
- 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 -10
- package/dist/lib/format-repository-url.d.ts +0 -1
- package/dist/lib/format-repository-url.js +0 -37
- package/dist/lib/get-group-header.d.ts +0 -10
- package/dist/lib/get-group-header.js +0 -23
- package/dist/lib/get.d.ts +0 -11
- package/dist/lib/get.js +0 -36
- 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 -20
- 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 -29
- package/dist/option.d.ts +0 -10
- package/dist/option.js +0 -27
- package/dist/report.d.ts +0 -131
- package/dist/report.js +0 -129
- package/dist/schema.json +0 -544
- package/dist/semver-group/create-semver-groups.d.ts +0 -4
- package/dist/semver-group/create-semver-groups.js +0 -79
- 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 -20
- 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 -22
- package/dist/specifier/index.d.ts +0 -28
- package/dist/specifier/index.js +0 -63
- 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 -16
- 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 -34
- 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 -49
- 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 -25
- 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 -114
- 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 -44
- package/dist/version-group/lib/get-range-score.d.ts +0 -2
- package/dist/version-group/lib/get-range-score.js +0 -18
- 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 -69
- package/dist/version-group/standard.d.ts +0 -18
- package/dist/version-group/standard.js +0 -116
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Specifier } from '../specifier/index.js';
|
|
2
|
-
export class Instance {
|
|
3
|
-
/** The name of this dependency */
|
|
4
|
-
name;
|
|
5
|
-
/** The .name property of the package.json file of this instance */
|
|
6
|
-
pkgName;
|
|
7
|
-
/** The specifier as it is on disk before being fixed */
|
|
8
|
-
rawSpecifier;
|
|
9
|
-
/** The package this dependency is installed in this specific time */
|
|
10
|
-
packageJsonFile;
|
|
11
|
-
/** Locates where in the file this dependency is installed */
|
|
12
|
-
strategy;
|
|
13
|
-
/** The semver group this instance belongs to */
|
|
14
|
-
semverGroup;
|
|
15
|
-
/** The version group this instance belongs to */
|
|
16
|
-
versionGroup;
|
|
17
|
-
constructor(name, rawSpecifier, packageJsonFile, strategy) {
|
|
18
|
-
this.name = name;
|
|
19
|
-
this.pkgName = packageJsonFile.jsonFile.contents.name || 'PACKAGE_JSON_HAS_NO_NAME';
|
|
20
|
-
this.packageJsonFile = packageJsonFile;
|
|
21
|
-
this.strategy = strategy;
|
|
22
|
-
this.semverGroup = null;
|
|
23
|
-
this.versionGroup = null;
|
|
24
|
-
this.rawSpecifier = Specifier.create(this, rawSpecifier);
|
|
25
|
-
}
|
|
26
|
-
/** Mutate the package.json file in memory with the latest version specifier */
|
|
27
|
-
write(rawSpecifier) {
|
|
28
|
-
this.rawSpecifier = Specifier.create(this, rawSpecifier);
|
|
29
|
-
return this.strategy.write(this.packageJsonFile, [this.name, this.rawSpecifier.raw]);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Effect } from 'effect';
|
|
2
|
-
import type { Ctx } from '../get-context/index.js';
|
|
3
|
-
import type { GlobError } from '../io/glob-sync.js';
|
|
4
|
-
import type { Io } from '../io/index.js';
|
|
5
|
-
declare const NoSourcesFoundError_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: "NoSourcesFoundError";
|
|
7
|
-
};
|
|
8
|
-
export declare class NoSourcesFoundError extends NoSourcesFoundError_base<{
|
|
9
|
-
readonly CWD: string;
|
|
10
|
-
readonly patterns: string[];
|
|
11
|
-
}> {
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Using --source options and/or config files on disk from
|
|
15
|
-
* npm/pnpm/yarn/lerna, return an array of absolute paths to every package.json
|
|
16
|
-
* file the user is working with.
|
|
17
|
-
*
|
|
18
|
-
* @returns Array of absolute file paths to package.json files
|
|
19
|
-
*/
|
|
20
|
-
export declare function getFilePaths(io: Io, config: Ctx['config']): Effect.Effect<string[], GlobError | NoSourcesFoundError>;
|
|
21
|
-
export {};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Data, Effect, pipe } from 'effect';
|
|
2
|
-
import { uniq } from 'tightrope/array/uniq.js';
|
|
3
|
-
import { isNonEmptyArray } from 'tightrope/guard/is-non-empty-array.js';
|
|
4
|
-
import { globSync } from '../io/glob-sync.js';
|
|
5
|
-
import { getPatterns } from './get-patterns/index.js';
|
|
6
|
-
export class NoSourcesFoundError extends Data.TaggedClass('NoSourcesFoundError') {
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Using --source options and/or config files on disk from
|
|
10
|
-
* npm/pnpm/yarn/lerna, return an array of absolute paths to every package.json
|
|
11
|
-
* file the user is working with.
|
|
12
|
-
*
|
|
13
|
-
* @returns Array of absolute file paths to package.json files
|
|
14
|
-
*/
|
|
15
|
-
export function getFilePaths(io, config) {
|
|
16
|
-
return pipe(Effect.Do, Effect.bind('patterns', () => getPatterns(io, config)), Effect.bind('filePaths', ({ patterns }) => globSync(io, patterns)), Effect.bind('flatFilePaths', ({ filePaths }) => Effect.sync(() => uniq(filePaths.flat()))), Effect.flatMap(({ flatFilePaths, patterns }) => isNonEmptyArray(flatFilePaths)
|
|
17
|
-
? Effect.succeed(flatFilePaths)
|
|
18
|
-
: Effect.fail(new NoSourcesFoundError({
|
|
19
|
-
CWD: io.process.cwd(),
|
|
20
|
-
patterns,
|
|
21
|
-
}))));
|
|
22
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Effect, Option as O, pipe } from 'effect';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
import { isArrayOfStrings } from 'tightrope/guard/is-array-of-strings.js';
|
|
4
|
-
import { readJsonFileSync } from '../../io/read-json-file-sync.js';
|
|
5
|
-
export function getLernaPatterns(io) {
|
|
6
|
-
return pipe(readJsonFileSync(io, join(io.process.cwd(), 'lerna.json')), Effect.map((file) => isArrayOfStrings(file.contents.packages) ? O.some(file.contents.packages) : O.none()), Effect.catchTags({
|
|
7
|
-
ReadFileError: () => Effect.succeed(O.none()),
|
|
8
|
-
JsonParseError: () => Effect.succeed(O.none()),
|
|
9
|
-
}));
|
|
10
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Effect, Option as O, pipe } from 'effect';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
import { isArrayOfStrings } from 'tightrope/guard/is-array-of-strings.js';
|
|
4
|
-
import { readYamlFileSync } from '../../io/read-yaml-file-sync.js';
|
|
5
|
-
export function getPnpmPatterns(io) {
|
|
6
|
-
return pipe(
|
|
7
|
-
// packages:
|
|
8
|
-
// - "packages/**"
|
|
9
|
-
// - "components/**"
|
|
10
|
-
// - "!**/test/**"
|
|
11
|
-
readYamlFileSync(io, join(io.process.cwd(), 'pnpm-workspace.yaml')), Effect.map((file) => (isArrayOfStrings(file?.packages) ? O.some(file.packages) : O.none())), Effect.catchTags({
|
|
12
|
-
ReadYamlFileError: () => Effect.succeed(O.none()),
|
|
13
|
-
}));
|
|
14
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Effect, Option as O, pipe } from 'effect';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
import { isArrayOfStrings } from 'tightrope/guard/is-array-of-strings.js';
|
|
4
|
-
import { isNonEmptyObject } from 'tightrope/guard/is-non-empty-object.js';
|
|
5
|
-
import { readJsonFileSync } from '../../io/read-json-file-sync.js';
|
|
6
|
-
export function getYarnPatterns(io) {
|
|
7
|
-
return pipe(readJsonFileSync(io, join(io.process.cwd(), 'package.json')), Effect.map((file) => isNonEmptyObject(file.contents.workspaces) &&
|
|
8
|
-
isArrayOfStrings(file.contents.workspaces.packages)
|
|
9
|
-
? O.some(file.contents.workspaces.packages)
|
|
10
|
-
: isArrayOfStrings(file.contents.workspaces)
|
|
11
|
-
? O.some(file.contents.workspaces)
|
|
12
|
-
: O.none()), Effect.catchTags({
|
|
13
|
-
ReadFileError: () => Effect.succeed(O.none()),
|
|
14
|
-
JsonParseError: () => Effect.succeed(O.none()),
|
|
15
|
-
}));
|
|
16
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Effect } from 'effect';
|
|
2
|
-
import type { Ctx } from '../../get-context/index.js';
|
|
3
|
-
import type { Io } from '../../io/index.js';
|
|
4
|
-
/**
|
|
5
|
-
* Find every glob pattern which should be used to find package.json files for
|
|
6
|
-
* this monorepo.
|
|
7
|
-
*/
|
|
8
|
-
export declare function getPatterns(io: Io, config: Ctx['config']): Effect.Effect<string[]>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Effect, Option as O, pipe } from 'effect';
|
|
2
|
-
import { isArrayOfStrings } from 'tightrope/guard/is-array-of-strings.js';
|
|
3
|
-
import { getSource } from '../../config/get-source.js';
|
|
4
|
-
import { DEFAULT_CONFIG } from '../../constants.js';
|
|
5
|
-
import { getLernaPatterns } from './get-lerna-patterns.js';
|
|
6
|
-
import { getPnpmPatterns } from './get-pnpm-patterns.js';
|
|
7
|
-
import { getYarnPatterns } from './get-yarn-patterns.js';
|
|
8
|
-
/**
|
|
9
|
-
* Find every glob pattern which should be used to find package.json files for
|
|
10
|
-
* this monorepo.
|
|
11
|
-
*/
|
|
12
|
-
export function getPatterns(io, config) {
|
|
13
|
-
return pipe(getCliPatterns(), Effect.flatMap((opt) => (O.isSome(opt) ? Effect.succeed(opt) : getWorkspacePatterns())), Effect.map(O.map(limitToPackageJson)), Effect.map(O.getOrElse(() => [...DEFAULT_CONFIG.source])));
|
|
14
|
-
function getCliPatterns() {
|
|
15
|
-
return pipe(O.some(getSource(config)), O.filter(isArrayOfStrings), Effect.succeed);
|
|
16
|
-
}
|
|
17
|
-
function getWorkspacePatterns() {
|
|
18
|
-
return pipe(getYarnPatterns(io), Effect.flatMap((opt) => (O.isSome(opt) ? Effect.succeed(opt) : getPnpmPatterns(io))), Effect.flatMap((opt) => (O.isSome(opt) ? Effect.succeed(opt) : getLernaPatterns(io))), Effect.map(O.map((patterns) => ['package.json', ...patterns])));
|
|
19
|
-
}
|
|
20
|
-
function limitToPackageJson(patterns) {
|
|
21
|
-
return patterns.map((pattern) => pattern.includes('package.json') ? pattern : `${pattern}/package.json`);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Effect } from 'effect';
|
|
2
|
-
import type { Ctx } from '../get-context/index.js';
|
|
3
|
-
import type { GlobError } from '../io/glob-sync.js';
|
|
4
|
-
import type { Io } from '../io/index.js';
|
|
5
|
-
import type { ReadFileError } from '../io/read-file-sync.js';
|
|
6
|
-
import type { JsonParseError } from '../io/read-json-file-sync.js';
|
|
7
|
-
import type { NoSourcesFoundError } from './get-file-paths.js';
|
|
8
|
-
import { PackageJsonFile } from './package-json-file.js';
|
|
9
|
-
/** Create an API for every package.json file needed. */
|
|
10
|
-
export declare function getPackageJsonFiles(io: Io, config: Ctx['config']): Effect.Effect<PackageJsonFile[], NoSourcesFoundError | GlobError | ReadFileError | JsonParseError>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Effect, pipe } from 'effect';
|
|
2
|
-
import { readJsonFileSync } from '../io/read-json-file-sync.js';
|
|
3
|
-
import { getFilePaths } from './get-file-paths.js';
|
|
4
|
-
import { PackageJsonFile } from './package-json-file.js';
|
|
5
|
-
/** Create an API for every package.json file needed. */
|
|
6
|
-
export function getPackageJsonFiles(io, config) {
|
|
7
|
-
return pipe(getFilePaths(io, config), Effect.flatMap((filePaths) => Effect.all(filePaths.map((filePath) => readJsonFileSync(io, filePath)))), Effect.map((files) => files.map((file) => new PackageJsonFile(file, config))), Effect.tap((files) => Effect.logDebug(`${files.length} package.json files found`)));
|
|
8
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Effect } from 'effect';
|
|
2
|
-
import type { Strategy } from '../config/get-custom-types.js';
|
|
3
|
-
import type { Ctx } from '../get-context/index.js';
|
|
4
|
-
import { Instance } from '../get-instances/instance.js';
|
|
5
|
-
import type { RcFile } from '../index.js';
|
|
6
|
-
import type { JsonFile } from '../io/read-json-file-sync.js';
|
|
7
|
-
export type PackageJson = {
|
|
8
|
-
bugs?: {
|
|
9
|
-
url: string;
|
|
10
|
-
} | string;
|
|
11
|
-
config?: {
|
|
12
|
-
syncpack?: RcFile;
|
|
13
|
-
};
|
|
14
|
-
dependencies?: Record<string, string>;
|
|
15
|
-
description?: string;
|
|
16
|
-
devDependencies?: Record<string, string>;
|
|
17
|
-
keywords?: string[];
|
|
18
|
-
name?: string;
|
|
19
|
-
overrides?: Record<string, string>;
|
|
20
|
-
peerDependencies?: Record<string, string>;
|
|
21
|
-
pnpm?: {
|
|
22
|
-
overrides?: Record<string, string>;
|
|
23
|
-
};
|
|
24
|
-
repository?: {
|
|
25
|
-
directory?: string;
|
|
26
|
-
type: string;
|
|
27
|
-
url: string;
|
|
28
|
-
} | string;
|
|
29
|
-
resolutions?: Record<string, string>;
|
|
30
|
-
scripts?: Record<string, string>;
|
|
31
|
-
version?: string;
|
|
32
|
-
workspaces?: string[] | {
|
|
33
|
-
packages?: string[];
|
|
34
|
-
};
|
|
35
|
-
} & Record<string, Record<string, string | string[] | Record<string, string | string[]>> | string | string[] | undefined>;
|
|
36
|
-
export declare class PackageJsonFile {
|
|
37
|
-
/** resolved configuration */
|
|
38
|
-
readonly config: Ctx['config'];
|
|
39
|
-
/** ensure only one set of instances is ever created and shared */
|
|
40
|
-
private _instances;
|
|
41
|
-
/** the wrapped package.json file */
|
|
42
|
-
jsonFile: JsonFile<PackageJson>;
|
|
43
|
-
/** the .name property from the package.json file */
|
|
44
|
-
name: string | undefined;
|
|
45
|
-
constructor(jsonFile: JsonFile<PackageJson>, config: Ctx['config']);
|
|
46
|
-
getInstances(enabledTypes: Strategy.Any[]): Effect.Effect<Instance[]>;
|
|
47
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Effect, pipe } from 'effect';
|
|
2
|
-
import { Instance } from '../get-instances/instance.js';
|
|
3
|
-
export class PackageJsonFile {
|
|
4
|
-
/** resolved configuration */
|
|
5
|
-
config;
|
|
6
|
-
/** ensure only one set of instances is ever created and shared */
|
|
7
|
-
_instances;
|
|
8
|
-
/** the wrapped package.json file */
|
|
9
|
-
jsonFile;
|
|
10
|
-
/** the .name property from the package.json file */
|
|
11
|
-
name;
|
|
12
|
-
constructor(jsonFile, config) {
|
|
13
|
-
this._instances = null;
|
|
14
|
-
this.config = config;
|
|
15
|
-
this.jsonFile = jsonFile;
|
|
16
|
-
this.name = jsonFile.contents.name;
|
|
17
|
-
}
|
|
18
|
-
getInstances(enabledTypes) {
|
|
19
|
-
if (!this._instances) {
|
|
20
|
-
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({
|
|
21
|
-
onSuccess: (instances) => Effect.logDebug(`found ${instances.length} instances in <${this.jsonFile.shortPath}>`),
|
|
22
|
-
onFailure: () => Effect.logError(`failed to get instances from <${this.jsonFile.shortPath}>`),
|
|
23
|
-
}), Effect.catchAll(() => Effect.succeed([])), Effect.tap((instances) => Effect.sync(() => {
|
|
24
|
-
this._instances = instances;
|
|
25
|
-
})));
|
|
26
|
-
}
|
|
27
|
-
return Effect.succeed(this._instances);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -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,52 +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
|
-
return dependencies.some((pattern) => (pattern === '$LOCAL' &&
|
|
16
|
-
instance.name in packageJsonFilesByName &&
|
|
17
|
-
((group.groupType === 'versionGroup' && instance.versionGroup === null) ||
|
|
18
|
-
(group.groupType === 'semverGroup' && instance.semverGroup === null))) ||
|
|
19
|
-
minimatch(instance.name, pattern));
|
|
20
|
-
}
|
|
21
|
-
function matchesPackages(packages, instance) {
|
|
22
|
-
return matchesKnownList(packages, instance.pkgName);
|
|
23
|
-
}
|
|
24
|
-
function matchesDependencyTypes(dependencyTypes, instance) {
|
|
25
|
-
return matchesKnownList(dependencyTypes, instance.strategy.name);
|
|
26
|
-
}
|
|
27
|
-
function matchesSpecifierTypes(specifierTypes, instance) {
|
|
28
|
-
return matchesKnownList(specifierTypes, instance.rawSpecifier.name);
|
|
29
|
-
}
|
|
30
|
-
function matchesKnownList(values, value) {
|
|
31
|
-
// matches if not defined
|
|
32
|
-
if (!isNonEmptyArray(values))
|
|
33
|
-
return true;
|
|
34
|
-
if (values.join('') === '**')
|
|
35
|
-
return true;
|
|
36
|
-
const negative = [];
|
|
37
|
-
const positive = [];
|
|
38
|
-
values.forEach((name) => {
|
|
39
|
-
if (name.startsWith('!')) {
|
|
40
|
-
negative.push(name.replace('!', ''));
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
positive.push(name);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
if (isNonEmptyArray(negative) && !someMinimatch(value, negative))
|
|
47
|
-
return true;
|
|
48
|
-
return isNonEmptyArray(positive) && someMinimatch(value, positive);
|
|
49
|
-
}
|
|
50
|
-
function someMinimatch(value, patterns) {
|
|
51
|
-
return patterns.some((pattern) => minimatch(value, pattern));
|
|
52
|
-
}
|
package/dist/guards/is-semver.js
DELETED
|
@@ -1,13 +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 || version.search(minor) !== -1 || version.search(patch) !== -1));
|
|
13
|
-
}
|
|
@@ -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 { cosmiconfig } from 'cosmiconfig';
|
|
2
|
-
import { Context } from 'effect';
|
|
3
|
-
import enquirer from 'enquirer';
|
|
4
|
-
import fs from 'fs';
|
|
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 { cosmiconfig } from 'cosmiconfig';
|
|
2
|
-
import { Context } from 'effect';
|
|
3
|
-
import enquirer from 'enquirer';
|
|
4
|
-
import fs from 'fs';
|
|
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,22 +0,0 @@
|
|
|
1
|
-
import { Effect, Option, pipe } from 'effect';
|
|
2
|
-
import { join } from 'path';
|
|
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 ? getValueFromCosmiconfig(result) : 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({})));
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Look for a .config.syncpack property in the root package.json.
|
|
11
|
-
* @see https://github.com/JamieMason/syncpack/issues/86
|
|
12
|
-
*/
|
|
13
|
-
function findConfigInPackageJson(io) {
|
|
14
|
-
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({
|
|
15
|
-
onSuccess: () => Effect.logDebug('config found in <package.json>.config.syncpack'),
|
|
16
|
-
onFailure: () => Effect.logDebug('config not found in <package.json>.config.syncpack'),
|
|
17
|
-
}));
|
|
18
|
-
}
|
|
19
|
-
/** Extract the value from a successful search by cosmiconfig */
|
|
20
|
-
function getValueFromCosmiconfig(result) {
|
|
21
|
-
return pipe(Effect.succeed(result), Effect.tap((result) => Effect.logDebug(`cosmiconfig found ${result.filepath}`)), Effect.flatMap((result) => getOptionOfNonEmptyObject(result.config)));
|
|
22
|
-
}
|
|
@@ -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,30 +0,0 @@
|
|
|
1
|
-
import { Effect } from 'effect';
|
|
2
|
-
import type { Io } from './index.js';
|
|
3
|
-
import type { ReadFileError } from './read-file-sync.js';
|
|
4
|
-
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> & {
|
|
5
|
-
readonly _tag: "JsonParseError";
|
|
6
|
-
};
|
|
7
|
-
export declare class JsonParseError extends JsonParseError_base<{
|
|
8
|
-
readonly error: unknown;
|
|
9
|
-
readonly filePath: string;
|
|
10
|
-
readonly json: string;
|
|
11
|
-
}> {
|
|
12
|
-
}
|
|
13
|
-
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> & {
|
|
14
|
-
readonly _tag: "JsonFile";
|
|
15
|
-
};
|
|
16
|
-
export declare class JsonFile<T> extends JsonFile_base<{
|
|
17
|
-
/** absolute path on disk to the directory of this file */
|
|
18
|
-
readonly dirPath: string;
|
|
19
|
-
/** absolute path on disk to this file */
|
|
20
|
-
readonly filePath: string;
|
|
21
|
-
/** relative path on disk to this file */
|
|
22
|
-
readonly shortPath: string;
|
|
23
|
-
/** parsed JSON contents of the file */
|
|
24
|
-
contents: T;
|
|
25
|
-
/** raw file contents of the file */
|
|
26
|
-
readonly json: string;
|
|
27
|
-
}> {
|
|
28
|
-
}
|
|
29
|
-
export declare function readJsonFileSync<T>(io: Io, filePath: string): Effect.Effect<JsonFile<T>, ReadFileError | JsonParseError>;
|
|
30
|
-
export {};
|