@shivaedev/quality 0.57.0 → 0.57.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/CHANGELOG.md +7 -0
- package/dist/adapters/executable.d.ts +3 -0
- package/dist/adapters/executable.d.ts.map +1 -0
- package/dist/adapters/executable.js +14 -0
- package/dist/adapters/executable.js.map +1 -0
- package/dist/baseline/cleanupMergeFiles.d.ts.map +1 -1
- package/dist/baseline/cleanupMergeFiles.js +3 -2
- package/dist/baseline/cleanupMergeFiles.js.map +1 -1
- package/dist/baseline/shards.d.ts.map +1 -1
- package/dist/baseline/shards.js +4 -2
- package/dist/baseline/shards.js.map +1 -1
- package/dist/biome/recommendedRules.d.ts.map +1 -1
- package/dist/biome/recommendedRules.js +3 -2
- package/dist/biome/recommendedRules.js.map +1 -1
- package/dist/biome/report.d.ts.map +1 -1
- package/dist/biome/report.js +3 -2
- package/dist/biome/report.js.map +1 -1
- package/dist/cli/baseline.d.ts.map +1 -1
- package/dist/cli/baseline.js +3 -2
- package/dist/cli/baseline.js.map +1 -1
- package/dist/cli/fix.d.ts.map +1 -1
- package/dist/cli/fix.js +3 -2
- package/dist/cli/fix.js.map +1 -1
- package/dist/cli/fixRule.d.ts.map +1 -1
- package/dist/cli/fixRule.js +3 -2
- package/dist/cli/fixRule.js.map +1 -1
- package/dist/cli/lint.d.ts.map +1 -1
- package/dist/cli/lint.js +2 -2
- package/dist/cli/lint.js.map +1 -1
- package/dist/cli/migrateBaseline.d.ts.map +1 -1
- package/dist/cli/migrateBaseline.js +3 -2
- package/dist/cli/migrateBaseline.js.map +1 -1
- package/dist/cli/migrateExceptions.d.ts.map +1 -1
- package/dist/cli/migrateExceptions.js +3 -2
- package/dist/cli/migrateExceptions.js.map +1 -1
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/load.js +3 -2
- package/dist/config/load.js.map +1 -1
- package/dist/engine/session.d.ts.map +1 -1
- package/dist/engine/session.js +3 -2
- package/dist/engine/session.js.map +1 -1
- package/dist/hooks/install.d.ts.map +1 -1
- package/dist/hooks/install.js +4 -2
- package/dist/hooks/install.js.map +1 -1
- package/dist/hooks/location.d.ts.map +1 -1
- package/dist/hooks/location.js +3 -2
- package/dist/hooks/location.js.map +1 -1
- package/dist/hooks/preCommit.d.ts.map +1 -1
- package/dist/hooks/preCommit.js +3 -2
- package/dist/hooks/preCommit.js.map +1 -1
- package/dist/hooks/setup.d.ts.map +1 -1
- package/dist/hooks/setup.js +3 -2
- package/dist/hooks/setup.js.map +1 -1
- package/dist/hooks/status.d.ts.map +1 -1
- package/dist/hooks/status.js +5 -15
- package/dist/hooks/status.js.map +1 -1
- package/dist/hooks/uninstall.d.ts.map +1 -1
- package/dist/hooks/uninstall.js +3 -2
- package/dist/hooks/uninstall.js.map +1 -1
- package/dist/inventory/filesystem.d.ts.map +1 -1
- package/dist/inventory/filesystem.js +3 -2
- package/dist/inventory/filesystem.js.map +1 -1
- package/dist/inventory/shadcnFolders.d.ts.map +1 -1
- package/dist/inventory/shadcnFolders.js +4 -2
- package/dist/inventory/shadcnFolders.js.map +1 -1
- package/dist/inventory/trackedPaths.d.ts.map +1 -1
- package/dist/inventory/trackedPaths.js +4 -2
- package/dist/inventory/trackedPaths.js.map +1 -1
- package/dist/rules/imports/manifest.d.ts.map +1 -1
- package/dist/rules/imports/manifest.js +9 -6
- package/dist/rules/imports/manifest.js.map +1 -1
- package/dist/rules/suppressions/noIgnoreDeprecations.d.ts.map +1 -1
- package/dist/rules/suppressions/noIgnoreDeprecations.js +3 -2
- package/dist/rules/suppressions/noIgnoreDeprecations.js.map +1 -1
- package/dist/testing/adapters/assertThat.d.ts +5 -0
- package/dist/testing/adapters/assertThat.d.ts.map +1 -0
- package/dist/testing/adapters/assertThat.js +9 -0
- package/dist/testing/adapters/assertThat.js.map +1 -0
- package/package.json +5 -4
- package/src/adapters/executable.ts +14 -0
- package/src/baseline/cleanupMergeFiles.ts +4 -2
- package/src/baseline/shards.ts +6 -2
- package/src/biome/recommendedRules.ts +4 -2
- package/src/biome/report.ts +4 -2
- package/src/cli/baseline.ts +4 -2
- package/src/cli/fix.ts +4 -2
- package/src/cli/fixRule.ts +4 -2
- package/src/cli/lint.ts +3 -2
- package/src/cli/migrateBaseline.ts +4 -2
- package/src/cli/migrateExceptions.ts +4 -2
- package/src/config/load.ts +4 -2
- package/src/engine/session.ts +4 -2
- package/src/hooks/install.ts +6 -2
- package/src/hooks/location.ts +4 -2
- package/src/hooks/preCommit.ts +4 -2
- package/src/hooks/setup.ts +4 -2
- package/src/hooks/status.ts +7 -15
- package/src/hooks/uninstall.ts +4 -2
- package/src/inventory/filesystem.ts +4 -2
- package/src/inventory/shadcnFolders.ts +6 -2
- package/src/inventory/trackedPaths.ts +6 -2
- package/src/rules/imports/manifest.ts +14 -8
- package/src/rules/suppressions/noIgnoreDeprecations.ts +4 -2
- package/src/testing/adapters/assertThat.ts +12 -0
package/src/biome/report.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Effect, Schema } from "effect";
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Effect, Path, Schema } from "effect";
|
|
3
3
|
import { type BiomeRun, runBiome } from "#adapters/biome/run.ts";
|
|
4
4
|
import type { ExceptionDeclaration } from "#exceptions/declaration.ts";
|
|
5
5
|
import { SetupFailure } from "#failure.ts";
|
|
@@ -65,6 +65,8 @@ export const biomeReport = Effect.fn("Biome.biomeReport")(function* (
|
|
|
65
65
|
exceptions: readonly ExceptionDeclaration[] = [],
|
|
66
66
|
files: readonly string[] = ["."],
|
|
67
67
|
) {
|
|
68
|
+
const { relative, sep } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
69
|
+
|
|
68
70
|
const [report, tracked] = yield* Effect.all([reportFor(root, args, files, exceptions), ignoredTrackedPaths(root)], {
|
|
69
71
|
concurrency: "unbounded",
|
|
70
72
|
});
|
package/src/cli/baseline.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Console, Effect, type FileSystem } from "effect";
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Console, Effect, type FileSystem, Path } from "effect";
|
|
3
3
|
import type { BaselineEntry } from "#baseline/format.ts";
|
|
4
4
|
import { saveShards } from "#baseline/shards.ts";
|
|
5
5
|
import { adopt, type Pruned, prune, type Scope } from "#baseline/update.ts";
|
|
@@ -26,6 +26,8 @@ export const writeBaseline = Effect.fn("Cli.writeBaseline")(function* (
|
|
|
26
26
|
files: readonly string[],
|
|
27
27
|
firstAdoption = false,
|
|
28
28
|
): Effect.fn.Return<void, SetupFailure, RuleServices> {
|
|
29
|
+
const { relative, resolve } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
30
|
+
|
|
29
31
|
const session = yield* openSession(cwd, config);
|
|
30
32
|
const existing = session.baseline.files.size === 0 ? undefined : session.baseline.entries;
|
|
31
33
|
if (firstAdoption && (rules.length === 0 || rules.some((rule) => registrable(session.config, rule)))) {
|
package/src/cli/fix.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Console, Effect, FileSystem } from "effect";
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Console, Effect, FileSystem, Path } from "effect";
|
|
3
3
|
import { biomeReport } from "#biome/report.ts";
|
|
4
4
|
import { changedRanges } from "#cli/changedRanges.ts";
|
|
5
5
|
import { loadConfig } from "#config/load.ts";
|
|
@@ -19,6 +19,8 @@ function isBinary(bytes: Uint8Array): boolean {
|
|
|
19
19
|
|
|
20
20
|
export function snapshotOf(root: string): Effect.Effect<ReadonlyMap<string, string>, SetupFailure, RuleServices> {
|
|
21
21
|
return Effect.gen(function* () {
|
|
22
|
+
const { relative } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
23
|
+
|
|
22
24
|
const fs = yield* FileSystem.FileSystem;
|
|
23
25
|
const decoder = new TextDecoder();
|
|
24
26
|
const paths = yield* walk(root);
|
package/src/cli/fixRule.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Console, Effect, FileSystem } from "effect";
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Console, Effect, FileSystem, Path } from "effect";
|
|
3
3
|
import { fixJsxConditionals } from "#adapters/fixJsxConditionals.ts";
|
|
4
4
|
import { loadConfig } from "#config/load.ts";
|
|
5
5
|
import { scan } from "#engine/session.ts";
|
|
@@ -16,6 +16,8 @@ export const fixRule = Effect.fn("Cli.fixRule")(function* (
|
|
|
16
16
|
configPath: string | undefined,
|
|
17
17
|
rules: readonly string[],
|
|
18
18
|
): Effect.fn.Return<void, SetupFailure | GateFailed, RuleServices> {
|
|
19
|
+
const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
20
|
+
|
|
19
21
|
const config = yield* loadConfig(cwd, configPath);
|
|
20
22
|
for (const rule of rules) {
|
|
21
23
|
if (rule !== "react/jsx-conditionals") {
|
package/src/cli/lint.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { relative } from "node:path";
|
|
2
1
|
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
|
|
3
2
|
import * as NodePath from "@effect/platform-node/NodePath";
|
|
4
|
-
import { Console, Effect } from "effect";
|
|
3
|
+
import { Console, Effect, Path } from "effect";
|
|
5
4
|
import { withHeavyLock } from "@shivaedev/heavy-lock/withHeavyLock.ts";
|
|
6
5
|
import { looseStagedEntries } from "#baseline/looseStagedEntries.ts";
|
|
7
6
|
import { evaluate, passes } from "#engine/evaluate.ts";
|
|
@@ -13,6 +12,8 @@ import type { RuleServices } from "#rule.ts";
|
|
|
13
12
|
|
|
14
13
|
export const lint = Effect.fn("Cli.lint")(
|
|
15
14
|
function* (cwd: string, config: string | undefined, staged = false): Effect.fn.Return<void, SetupFailure | GateFailed, RuleServices> {
|
|
15
|
+
const { relative } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
16
|
+
|
|
16
17
|
const session = yield* openSession(cwd, config);
|
|
17
18
|
const evaluated = evaluate(session.violations, session.registry, session.baseline.entries, session.config);
|
|
18
19
|
const loose = staged ? yield* looseStagedEntries(session) : [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Console, Effect, FileSystem } from "effect";
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Console, Effect, FileSystem, Path } from "effect";
|
|
3
3
|
import { decodeBaseline } from "#baseline/format.ts";
|
|
4
4
|
import { convertLegacy, decodeLegacyBaseline, LEGACY_BASELINE } from "#baseline/legacy.ts";
|
|
5
5
|
import { saveShards, shardPaths } from "#baseline/shards.ts";
|
|
@@ -16,6 +16,8 @@ export const migrateBaseline = Effect.fn("Cli.migrateBaseline")(function* (
|
|
|
16
16
|
configPath: string | undefined,
|
|
17
17
|
from: string | undefined,
|
|
18
18
|
): Effect.fn.Return<void, SetupFailure, RuleServices> {
|
|
19
|
+
const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
20
|
+
|
|
19
21
|
const config = yield* loadConfig(cwd, configPath);
|
|
20
22
|
const source = from ?? LEGACY_BASELINE;
|
|
21
23
|
const paths = yield* shardPaths(config).pipe(Effect.mapError((error) => new SetupFailure({ cause: error, message: error.message })));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Console, Effect, FileSystem } from "effect";
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Console, Effect, FileSystem, Path } from "effect";
|
|
3
3
|
import { loadConfig } from "#config/load.ts";
|
|
4
4
|
import { validOrFail } from "#decoded.ts";
|
|
5
5
|
import { readInput } from "#engine/baselineFile.ts";
|
|
@@ -38,6 +38,8 @@ export const migrateExceptions = Effect.fnUntraced(function* (
|
|
|
38
38
|
configPath: string | undefined,
|
|
39
39
|
from: string | undefined,
|
|
40
40
|
): Effect.fn.Return<void, SetupFailure, FileSystem.FileSystem> {
|
|
41
|
+
const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
42
|
+
|
|
41
43
|
const config = yield* loadConfig(cwd, configPath);
|
|
42
44
|
const registryPath = from ?? config.registry;
|
|
43
45
|
const raw = yield* readInput(config.root, registryPath);
|
package/src/config/load.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Effect, type FileSystem, Schema } from "effect";
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Effect, type FileSystem, Path, Schema } from "effect";
|
|
3
3
|
import { readConfig } from "#adapters/readConfig.ts";
|
|
4
4
|
import { validOrFail } from "#decoded.ts";
|
|
5
5
|
import type { ExceptionDeclaration } from "#exceptions/declaration.ts";
|
|
@@ -46,6 +46,8 @@ export const loadConfig = Effect.fn("Config.loadConfig")(function* (
|
|
|
46
46
|
cwd: string,
|
|
47
47
|
path: string | undefined,
|
|
48
48
|
): Effect.fn.Return<ResolvedConfig, SetupFailure, FileSystem.FileSystem> {
|
|
49
|
+
const { dirname } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
50
|
+
|
|
49
51
|
const { file, loaded } = yield* readConfig(cwd, path);
|
|
50
52
|
const config = yield* validOrFail(file, yield* Effect.promise(() => decodeConfig(loaded)));
|
|
51
53
|
const rules = yield* validOrFail(file, yield* resolveRules(config));
|
package/src/engine/session.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Effect, type Scope } from "effect";
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Effect, Path, type Scope } from "effect";
|
|
3
3
|
import { setManifestFiles } from "#adapters/manifestInventory.ts";
|
|
4
4
|
import { manifestReader } from "#adapters/manifestReader.ts";
|
|
5
5
|
import { loadConfig, type ResolvedConfig } from "#config/load.ts";
|
|
@@ -31,6 +31,8 @@ function setup<TValue, TRequirements>(effect: Effect.Effect<TValue, Error, TRequ
|
|
|
31
31
|
export const scan = Effect.fn("Engine.scan")(function* (
|
|
32
32
|
config: ResolvedConfig,
|
|
33
33
|
): Effect.fn.Return<Pick<Session, "inventory" | "staleRegistry" | "violations">, SetupFailure, RuleServices | Scope.Scope> {
|
|
34
|
+
const { relative } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
35
|
+
|
|
34
36
|
const inventory = yield* setup(collectInventory(config.root, config));
|
|
35
37
|
const readText = yield* manifestReader(config.root);
|
|
36
38
|
setManifestFiles(readText, inventory.manifestFiles);
|
package/src/hooks/install.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Console, Effect, FileSystem } from "effect";
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Console, Effect, FileSystem, Path } from "effect";
|
|
3
3
|
import { CONFIG_FILE } from "#config/constants.ts";
|
|
4
4
|
import { loadConfig } from "#config/load.ts";
|
|
5
5
|
import { SetupFailure } from "#failure.ts";
|
|
@@ -28,6 +28,8 @@ const realPath = Effect.fnUntraced(function* (path: string) {
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
const write = Effect.fnUntraced(function* (file: string, text: string) {
|
|
31
|
+
const { dirname } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
32
|
+
|
|
31
33
|
const fs = yield* FileSystem.FileSystem;
|
|
32
34
|
yield* fs.makeDirectory(dirname(file), { recursive: true }).pipe(
|
|
33
35
|
Effect.andThen(fs.writeFileString(file, text)),
|
|
@@ -37,6 +39,8 @@ const write = Effect.fnUntraced(function* (file: string, text: string) {
|
|
|
37
39
|
});
|
|
38
40
|
|
|
39
41
|
export const installHook = Effect.fn("Hooks.installHook")(function* (install: HookInstall) {
|
|
42
|
+
const { basename, dirname, join, relative } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
43
|
+
|
|
40
44
|
const config = yield* loadConfig(install.cwd, install.config);
|
|
41
45
|
const location = yield* hookLocation(config.root);
|
|
42
46
|
const root = yield* realPath(config.root);
|
package/src/hooks/location.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Effect } from "effect";
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Effect, Path } from "effect";
|
|
3
3
|
import { SetupFailure } from "#failure.ts";
|
|
4
4
|
import { run } from "#git/command.ts";
|
|
5
5
|
|
|
@@ -11,6 +11,8 @@ export interface HookLocation {
|
|
|
11
11
|
|
|
12
12
|
// Hooks live in the common git directory, which every worktree of the repository shares.
|
|
13
13
|
export const hookLocation = Effect.fn("Hooks.hookLocation")(function* (cwd: string) {
|
|
14
|
+
const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
15
|
+
|
|
14
16
|
const paths = yield* run(cwd, ["rev-parse", "--path-format=absolute", "--show-toplevel", "--git-common-dir"]);
|
|
15
17
|
const [toplevel, common] = paths.stdout.trim().split("\n");
|
|
16
18
|
if (paths.code !== 0 || toplevel === undefined || common === undefined) {
|
package/src/hooks/preCommit.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Console, Effect } from "effect";
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Console, Effect, Path } from "effect";
|
|
3
3
|
import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
4
4
|
import { readPackageManifest } from "#adapters/manifestInventory.ts";
|
|
5
5
|
import { manifestReader } from "#adapters/manifestReader.ts";
|
|
@@ -11,6 +11,8 @@ const COMMIT_AGAIN =
|
|
|
11
11
|
"help: fix what the output above reports, then commit again; `quality hooks pre-commit` repeats these checks without committing.";
|
|
12
12
|
|
|
13
13
|
const commitScripts = Effect.fnUntraced(function* (root: string) {
|
|
14
|
+
const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
15
|
+
|
|
14
16
|
const file = join(root, "package.json");
|
|
15
17
|
const readText = yield* manifestReader(root);
|
|
16
18
|
const manifest = yield* Effect.tryPromise({
|
package/src/hooks/setup.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Effect, FileSystem } from "effect";
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Effect, FileSystem, Path } from "effect";
|
|
3
3
|
import { type HookInstall, installHook } from "./install.ts";
|
|
4
4
|
|
|
5
5
|
export const setupHook = Effect.fn("Hooks.setupHook")(function* (options: Omit<HookInstall, "force">) {
|
|
6
|
+
const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
7
|
+
|
|
6
8
|
const fs = yield* FileSystem.FileSystem;
|
|
7
9
|
if (yield* fs.exists(join(options.cwd, ".git"))) {
|
|
8
10
|
yield* installHook({ ...options, force: false });
|
package/src/hooks/status.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Console, Effect } from "effect";
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Console, Effect, Path } from "effect";
|
|
3
|
+
import { executable } from "#adapters/executable.ts";
|
|
5
4
|
import { GateFailed, SetupFailure } from "#failure.ts";
|
|
6
5
|
import { gitOrFail } from "#git/command.ts";
|
|
7
6
|
import { readOptionalText } from "#inventory/filesystem.ts";
|
|
@@ -9,18 +8,9 @@ import { forwardingPath, globalHooksPath } from "./forwarding.ts";
|
|
|
9
8
|
import { type HookLocation, hookLocation } from "./location.ts";
|
|
10
9
|
import { isHookShim } from "./shim.ts";
|
|
11
10
|
|
|
12
|
-
function executable(file: string) {
|
|
13
|
-
return Effect.promise(async () => {
|
|
14
|
-
try {
|
|
15
|
-
await access(file, constants.X_OK);
|
|
16
|
-
return await realpath(file);
|
|
17
|
-
} catch {
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
11
|
export const globalHookStatus = Effect.fn("Hooks.globalHookStatus")(function* (location: HookLocation) {
|
|
12
|
+
const { resolve } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
13
|
+
|
|
24
14
|
const path = yield* globalHooksPath(location.toplevel);
|
|
25
15
|
const hook = resolve(location.toplevel, path, "pre-commit");
|
|
26
16
|
const target = path === "" ? undefined : yield* executable(hook);
|
|
@@ -33,6 +23,8 @@ export const globalHookStatus = Effect.fn("Hooks.globalHookStatus")(function* (l
|
|
|
33
23
|
});
|
|
34
24
|
|
|
35
25
|
export const hookStatus = Effect.fn("Hooks.hookStatus")(function* (cwd: string) {
|
|
26
|
+
const { dirname, resolve } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
27
|
+
|
|
36
28
|
const location = yield* hookLocation(cwd);
|
|
37
29
|
const path = (yield* gitOrFail(cwd, ["rev-parse", "--path-format=absolute", "--git-path", "hooks/pre-commit"])).trim();
|
|
38
30
|
const text = yield* readOptionalText(path).pipe(Effect.mapError((error) => new SetupFailure({ cause: error, message: error.message })));
|
package/src/hooks/uninstall.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Console, Effect, FileSystem } from "effect";
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Console, Effect, FileSystem, Path } from "effect";
|
|
3
3
|
import { SetupFailure } from "#failure.ts";
|
|
4
4
|
import { gitOrFail, run } from "#git/command.ts";
|
|
5
5
|
import { readOptionalText } from "#inventory/filesystem.ts";
|
|
@@ -8,6 +8,8 @@ import { hookLocation } from "./location.ts";
|
|
|
8
8
|
import { isHookShim } from "./shim.ts";
|
|
9
9
|
|
|
10
10
|
export const uninstallHook = Effect.fn("Hooks.uninstallHook")(function* (cwd: string) {
|
|
11
|
+
const { dirname } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
12
|
+
|
|
11
13
|
const fs = yield* FileSystem.FileSystem;
|
|
12
14
|
const { file } = yield* hookLocation(cwd);
|
|
13
15
|
const existing = yield* Effect.mapError(readOptionalText(file), (failure) => new SetupFailure({ cause: failure, message: failure.message }));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Data, Effect, FileSystem } from "effect";
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Data, Effect, FileSystem, Path } from "effect";
|
|
3
3
|
import type { PlatformError } from "effect/PlatformError";
|
|
4
4
|
|
|
5
5
|
export class FilesystemFailure extends Data.TaggedError("FilesystemFailure")<{
|
|
@@ -41,6 +41,8 @@ export const writeText = Effect.fn("Inventory.writeText")(function* (
|
|
|
41
41
|
path: string,
|
|
42
42
|
text: string,
|
|
43
43
|
): Effect.fn.Return<void, FilesystemFailure, FileSystem.FileSystem> {
|
|
44
|
+
const { dirname } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
45
|
+
|
|
44
46
|
const fs = yield* FileSystem.FileSystem;
|
|
45
47
|
const written = Effect.andThen(fs.makeDirectory(dirname(path), { recursive: true }), fs.writeFileString(path, text));
|
|
46
48
|
return yield* Effect.mapError(written, (error) => new FilesystemFailure({ message: `cannot write ${path}: ${error.message}`, path }));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Effect, Schema } from "effect";
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Effect, Path, Schema } from "effect";
|
|
3
3
|
import type { SetupFailure } from "#failure.ts";
|
|
4
4
|
import type { RuleServices } from "#rule.ts";
|
|
5
5
|
import { FilesystemFailure, readRequiredText } from "./filesystem.ts";
|
|
@@ -12,9 +12,13 @@ const Components = Schema.fromJsonString(Schema.Struct({ aliases: Schema.Struct(
|
|
|
12
12
|
export const shadcnFolders = Effect.fn("Inventory.shadcnFolders")(function* (
|
|
13
13
|
root: string,
|
|
14
14
|
): Effect.fn.Return<readonly string[], FilesystemFailure | SetupFailure, RuleServices> {
|
|
15
|
+
const { basename } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
16
|
+
|
|
15
17
|
const paths = (yield* walk(root)).filter((path) => basename(path) === "components.json");
|
|
16
18
|
return yield* Effect.forEach(paths, (path) =>
|
|
17
19
|
Effect.gen(function* () {
|
|
20
|
+
const { dirname, relative } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
21
|
+
|
|
18
22
|
const text = yield* readRequiredText(path);
|
|
19
23
|
return yield* Effect.try({
|
|
20
24
|
catch: (cause) => new FilesystemFailure({ message: `cannot resolve ${path}: ${String(cause)}`, path }),
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Effect } from "effect";
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Effect, Path } from "effect";
|
|
3
3
|
import { SetupFailure } from "#failure.ts";
|
|
4
4
|
import { run } from "#git/command.ts";
|
|
5
5
|
|
|
6
6
|
const listedPaths = Effect.fn("Inventory.listedPaths")(function* (directory: string, options: readonly string[], path = ".") {
|
|
7
|
+
const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
8
|
+
|
|
7
9
|
const result = yield* run(directory, ["ls-files", "-z", ...options, "--", path]);
|
|
8
10
|
if (result.code !== 0) {
|
|
9
11
|
if (result.stderr.includes("not a git repository")) {
|
|
@@ -26,6 +28,8 @@ export const ignoredTrackedPaths = Effect.fn("Inventory.ignoredTrackedPaths")(fu
|
|
|
26
28
|
});
|
|
27
29
|
|
|
28
30
|
export const ignoredPaths = Effect.fn("Inventory.ignoredPaths")(function* (directory: string) {
|
|
31
|
+
const { resolve } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
32
|
+
|
|
29
33
|
const paths = yield* listedPaths(directory, ["--others", "--ignored", "--exclude-standard", "--directory"]);
|
|
30
34
|
return paths?.map((path) => resolve(path));
|
|
31
35
|
});
|
|
@@ -33,26 +33,26 @@ interface ManifestDependencies {
|
|
|
33
33
|
readonly shipped: ReadonlySet<string>;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
const manifestDependencies = Effect.fn("Imports.manifestDependencies")(function* (
|
|
37
37
|
inputs: RuleInputs,
|
|
38
38
|
owner: WorkspacePackage,
|
|
39
39
|
graph: ImportGraph,
|
|
40
40
|
workspace: ReadonlyMap<string, string>,
|
|
41
|
-
):
|
|
41
|
+
): Effect.fn.Return<ManifestDependencies> {
|
|
42
42
|
const path = posix.join(owner.directory, "package.json");
|
|
43
|
-
const manifest =
|
|
43
|
+
const manifest = yield* Effect.promise(() => readPackageManifest(inputs.readText, path));
|
|
44
44
|
if (manifest === undefined) {
|
|
45
|
-
|
|
45
|
+
return yield* Effect.die(new Error("the manifest is missing"));
|
|
46
46
|
}
|
|
47
47
|
return {
|
|
48
48
|
...bundleInputs(graph, owner, manifest, (candidate) => developmentFile(owner, candidate)),
|
|
49
49
|
application: isApplication(manifest),
|
|
50
50
|
development: new Set(dependencyNames(manifest, "devDependencies")),
|
|
51
|
-
entryPoints:
|
|
51
|
+
entryPoints: yield* Effect.promise(() => entryPointsOf(inputs, owner.directory, manifest, workspace)),
|
|
52
52
|
private: Reflect.get(manifest, "private") === true,
|
|
53
53
|
shipped: new Set(SHIPPED_FIELDS.flatMap((field) => dependencyNames(manifest, field))),
|
|
54
54
|
};
|
|
55
|
-
}
|
|
55
|
+
});
|
|
56
56
|
|
|
57
57
|
function developmentFile(owner: WorkspacePackage, path: string): boolean {
|
|
58
58
|
return isTestCode(path) || isTooling(owner.directory, path);
|
|
@@ -93,8 +93,14 @@ export const importsManifest = defineRule({
|
|
|
93
93
|
const owners = [...graph.packages, ...(root === undefined ? [] : [root])];
|
|
94
94
|
const workspace = new Map(graph.packages.map((owner) => [owner.name, owner.directory]));
|
|
95
95
|
const policies = new Map(
|
|
96
|
-
yield* Effect.
|
|
97
|
-
|
|
96
|
+
yield* Effect.forEach(
|
|
97
|
+
owners,
|
|
98
|
+
(owner) =>
|
|
99
|
+
Effect.map(manifestDependencies(inputs, owner, graph, workspace), (policy): readonly [WorkspacePackage, ManifestDependencies] => [
|
|
100
|
+
owner,
|
|
101
|
+
policy,
|
|
102
|
+
]),
|
|
103
|
+
{ concurrency: "unbounded" },
|
|
98
104
|
),
|
|
99
105
|
);
|
|
100
106
|
const runtime = new Set([...policies.values()].flatMap((policy) => [...policy.runtime]));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Effect } from "effect";
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Effect, Path } from "effect";
|
|
3
3
|
import { readRequiredText } from "#inventory/filesystem.ts";
|
|
4
4
|
import { posix } from "#inventory/ignoreScope.ts";
|
|
5
5
|
import { walk } from "#inventory/walk.ts";
|
|
@@ -19,6 +19,8 @@ function settingIn(path: string, text: string): readonly Finding[] {
|
|
|
19
19
|
export const noIgnoreDeprecations = defineRule({
|
|
20
20
|
check: ({ root }) =>
|
|
21
21
|
Effect.gen(function* () {
|
|
22
|
+
const { join, relative } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
23
|
+
|
|
22
24
|
const paths = yield* walk(root);
|
|
23
25
|
const configs = paths.map((path) => posix(relative(root, path))).filter((path) => path.endsWith(".json"));
|
|
24
26
|
const findings = yield* Effect.forEach(configs.toSorted(), (path) =>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { type Assertion, type ExpectStatic, expect } from "vitest";
|
|
3
|
+
|
|
4
|
+
export function assertThat<TValue>(value: TValue, check: (actual: Assertion<void, TValue>, matchers: ExpectStatic) => void): Effect.Effect<void> {
|
|
5
|
+
return Effect.sync(() => check(expect(value), expect));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function withMatchers<TValue, TError, TServices>(
|
|
9
|
+
check: (matchers: ExpectStatic) => Effect.Effect<TValue, TError, TServices>,
|
|
10
|
+
): Effect.Effect<TValue, TError, TServices> {
|
|
11
|
+
return Effect.suspend(() => check(expect));
|
|
12
|
+
}
|