@milkenjoyer/toolchain 0.0.0-stage → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ export { t as default } from "./effect-plugin-ByuWwyB8.mjs";
@@ -0,0 +1,4 @@
1
+ export declare const patchCommand = "effect-tsgo patch --oxlint";
2
+ export declare const effectTsgoPlugin = "effecttsgo";
3
+ export declare const enforcedTsgoRules: ReadonlyArray<string>;
4
+ export declare const effectTsgoRules: Readonly<Record<string, "error">>;
@@ -0,0 +1,23 @@
1
+ import * as Arr from "effect/Array";
2
+ import * as R from "effect/Record";
3
+ import { presets } from "@effect/tsgo/oxlint-presets";
4
+ import * as Order from "effect/Order";
5
+ import * as Struct from "effect/Struct";
6
+ // src/effect-tsgo.ts
7
+ const patchCommand = "effect-tsgo patch --oxlint";
8
+ const effectTsgoPlugin = "effecttsgo";
9
+ const beyondRecommended = [
10
+ "effecttsgo/any-unknown-in-error-context",
11
+ "effecttsgo/crypto-random-uuid-in-effect",
12
+ "effecttsgo/effect-try-without-catch",
13
+ "effecttsgo/global-date-in-effect",
14
+ "effecttsgo/global-fetch-in-effect",
15
+ "effecttsgo/global-json-in-effect",
16
+ "effecttsgo/global-random-in-effect",
17
+ "effecttsgo/global-timers-in-effect",
18
+ "effecttsgo/missing-effect-service-dependency",
19
+ "effecttsgo/unsafe-effect-type-assertion"
20
+ ];
21
+ const enforcedTsgoRules = Arr.sort(Arr.dedupe([...Struct.keys(presets.recommended.rules ?? {}), ...beyondRecommended]), Order.String);
22
+ const effectTsgoRules = R.fromEntries(Arr.map(enforcedTsgoRules, (rule) => [rule, "error"]));
23
+ export { effectTsgoPlugin, effectTsgoRules, enforcedTsgoRules, patchCommand };
@@ -0,0 +1,6 @@
1
+ export type Exception = {
2
+ readonly files: ReadonlyArray<string>;
3
+ readonly rules: ReadonlyArray<string>;
4
+ readonly issue: string;
5
+ };
6
+ export declare const exceptions: ReadonlyArray<Exception>;
@@ -0,0 +1,3 @@
1
+ // src/exceptions.ts
2
+ const exceptions = [];
3
+ export { exceptions };
package/dist/fmt.d.mts ADDED
@@ -0,0 +1,5 @@
1
+ import { OxfmtConfig } from "vite-plus/fmt";
2
+ export type FmtOptions = {
3
+ readonly ignores?: ReadonlyArray<string>;
4
+ };
5
+ export declare const fmt: ({ ignores }?: FmtOptions) => OxfmtConfig;
package/dist/fmt.mjs ADDED
@@ -0,0 +1,8 @@
1
+ import ultraciteFmt from "ultracite/oxfmt";
2
+ // src/fmt.ts
3
+ const { ignorePatterns: coreIgnores = [] } = ultraciteFmt;
4
+ const fmt = ({ ignores = [] } = {}) => ({
5
+ ...ultraciteFmt,
6
+ ignorePatterns: [...coreIgnores, ...ignores]
7
+ });
8
+ export { fmt };
@@ -0,0 +1,26 @@
1
+ import { Packuments } from "./compatible.mjs";
2
+ import { Exception } from "./exceptions.mjs";
3
+ import { Catalog } from "./versions.mjs";
4
+ import { OxlintConfig } from "vite-plus/lint";
5
+ type Ranges = Readonly<Record<string, string>>;
6
+ export declare const manifestRanges: (text: string) => ReadonlyArray<readonly [string, Ranges]>;
7
+ export declare const isFoldkitViteInput: (file: string) => boolean;
8
+ export declare const foldkitViteFindings: (files: ReadonlyArray<readonly [string, string]>) => ReadonlyArray<string>;
9
+ export declare const exactFindings: {
10
+ (text: string): (file: string) => ReadonlyArray<string>;
11
+ (file: string, text: string): ReadonlyArray<string>;
12
+ };
13
+ export declare const pinFindings: {
14
+ (text: string, rootCatalog?: Ranges): (file: string) => ReadonlyArray<string>;
15
+ (file: string, text: string, rootCatalog?: Ranges): ReadonlyArray<string>;
16
+ };
17
+ export declare const ruleFindings: {
18
+ (list?: ReadonlyArray<Exception>): (config: OxlintConfig) => ReadonlyArray<string>;
19
+ (config: OxlintConfig, list?: ReadonlyArray<Exception>): ReadonlyArray<string>;
20
+ };
21
+ export declare const exceptionFindings: (list?: ReadonlyArray<Exception>) => ReadonlyArray<string>;
22
+ export declare const tagFindings: {
23
+ (registry: Packuments): (current: Catalog) => ReadonlyArray<string>;
24
+ (current: Catalog, registry: Packuments): ReadonlyArray<string>;
25
+ };
26
+ export {};
package/dist/guard.mjs ADDED
@@ -0,0 +1,141 @@
1
+ import { latestOf, onLatestLine, otherTags } from "./compatible.mjs";
2
+ import { enforcedTsgoRules } from "./effect-tsgo.mjs";
3
+ import { exceptions } from "./exceptions.mjs";
4
+ import { birbprophetRules, effectRules, foldkitPreset } from "./lint.mjs";
5
+ import { lead, versionOf } from "./versions.mjs";
6
+ import * as Arr from "effect/Array";
7
+ import { dual } from "effect/Function";
8
+ import * as HashSet from "effect/HashSet";
9
+ import * as Option from "effect/Option";
10
+ import * as R from "effect/Record";
11
+ import * as Schema from "effect/Schema";
12
+ import * as Str from "effect/String";
13
+ import * as Effect from "effect/Effect";
14
+ import * as Result from "effect/Result";
15
+ // src/guard.ts
16
+ const Versions = Schema.Record(Schema.String, Schema.String).pipe(Schema.withDecodingDefaultKey(Effect.succeed({})));
17
+ const Catalogs = Schema.Record(Schema.String, Schema.Record(Schema.String, Schema.String)).pipe(Schema.withDecodingDefaultKey(Effect.succeed({})));
18
+ const WorkspaceList = Schema.Array(Schema.String);
19
+ const WorkspaceCatalogs = Schema.Struct({
20
+ catalog: Versions,
21
+ catalogs: Catalogs
22
+ });
23
+ const Manifest = Schema.fromJsonString(Schema.Struct({
24
+ dependencies: Versions,
25
+ devDependencies: Versions,
26
+ peerDependencies: Versions,
27
+ optionalDependencies: Versions,
28
+ overrides: Versions,
29
+ resolutions: Versions,
30
+ catalog: Versions,
31
+ catalogs: Catalogs,
32
+ workspaces: Schema.optionalKey(Schema.Union([WorkspaceList, WorkspaceCatalogs]))
33
+ }));
34
+ const named = (prefix, catalogs) => Arr.map(R.toEntries(catalogs), ([name, ranges]) => [`${prefix}.${name}`, ranges]);
35
+ const manifestRanges = (text) => {
36
+ const decoded = Schema.decodeResult(Manifest)(text);
37
+ if (Result.isFailure(decoded)) throw decoded.failure;
38
+ const manifest = decoded.success;
39
+ const workspaces = Schema.is(WorkspaceCatalogs)(manifest.workspaces) ? manifest.workspaces : {
40
+ catalog: {},
41
+ catalogs: {}
42
+ };
43
+ return [
44
+ ["dependencies", manifest.dependencies],
45
+ ["devDependencies", manifest.devDependencies],
46
+ ["peerDependencies", manifest.peerDependencies],
47
+ ["optionalDependencies", manifest.optionalDependencies],
48
+ ["overrides", manifest.overrides],
49
+ ["resolutions", manifest.resolutions],
50
+ ["catalog", manifest.catalog],
51
+ ["workspaces.catalog", workspaces.catalog],
52
+ ...named("catalogs", manifest.catalogs),
53
+ ...named("workspaces.catalogs", workspaces.catalogs)
54
+ ];
55
+ };
56
+ const SEMVER = String.raw`\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?`;
57
+ const EXACT = new RegExp(String.raw`^(?:npm:(?:@[\w.-]+\/)?[\w.-]+@)?${SEMVER}$`, "u");
58
+ const REFERENCE = /^(?:catalog:[\w.-]*|workspace:\*)$/u;
59
+ const DEPENDENCY_FIELDS = HashSet.fromIterable([
60
+ "dependencies",
61
+ "devDependencies",
62
+ "peerDependencies",
63
+ "optionalDependencies"
64
+ ]);
65
+ const VITE_CONFIG = /(?:^|\/)vite\.config\.[cm]?[jt]s$/u;
66
+ const MANIFEST = /(?:^|\/)package\.json$/u;
67
+ const VITE_PLUGIN = /["'`]@foldkit\/vite-plugin["'`]/u;
68
+ const folderOf = (file) => Str.slice(0, Str.lastIndexOf("/")(file).pipe(Option.getOrElse(() => -1)) + 1)(file);
69
+ const isFoldkitViteInput = (file) => MANIFEST.test(file) || VITE_CONFIG.test(file);
70
+ const foldkitViteFindings = (files) => {
71
+ const foldkitFolders = HashSet.fromIterable(Arr.flatMap(files, ([file, text]) => MANIFEST.test(file) && Arr.some(manifestRanges(text), ([field, ranges]) => HashSet.has(DEPENDENCY_FIELDS, field) && R.has(ranges, "foldkit")) ? [folderOf(file)] : []));
72
+ return Arr.flatMap(files, ([config, source]) => VITE_CONFIG.test(config) && HashSet.has(foldkitFolders, folderOf(config)) && !VITE_PLUGIN.test(source) ? [`${config} builds a foldkit package without @foldkit/vite-plugin, so view identity isn't stamped and keyed patching breaks`] : []);
73
+ };
74
+ const exactFindings = dual(2, (file, text) => Arr.flatMap(manifestRanges(text), ([field, ranges]) => Arr.flatMap(R.toEntries(ranges), ([name, version]) => EXACT.test(version) || REFERENCE.test(version) ? [] : [`${file} ${field} ${name}: ${version} is not an exact version`])));
75
+ const pinFindings = dual((args) => Schema.is(Schema.String)(args[1]), (file, text, rootCatalog = {}) => Arr.flatMap(manifestRanges(text), ([field, ranges]) => Arr.flatMap(R.toEntries(ranges), ([name, written]) => Option.match(versionOf(name), {
76
+ onNone: () => [],
77
+ onSome: (pinnedVersion) => {
78
+ const actual = written === "catalog:" ? Option.getOrElse(R.get(rootCatalog, name), () => written) : written;
79
+ return actual === pinnedVersion || Str.startsWith("workspace:")(written) ? [] : [`${file} ${field} ${name}: ${actual} is not the toolchain catalog's ${pinnedVersion}`];
80
+ }
81
+ }))));
82
+ const severityOf = (setting) => String(Schema.is(Schema.Array(Schema.Unknown))(setting) ? setting[0] : setting);
83
+ const atError = (setting) => [
84
+ "error",
85
+ "deny",
86
+ "2"
87
+ ].includes(severityOf(setting));
88
+ const settingOf = (rules, rule) => Option.fromNullishOr(rules?.[rule]);
89
+ const guarded = [
90
+ ...R.keys(R.filter(foldkitPreset.rules, (setting) => setting === "error")),
91
+ ...R.keys(effectRules),
92
+ ...R.keys(birbprophetRules),
93
+ ...enforcedTsgoRules
94
+ ];
95
+ const presetScopes = Arr.map(foldkitPreset.overrides, ({ files, rules }) => ({
96
+ files,
97
+ rules: R.keys(R.filter(rules, (setting) => setting === "off"))
98
+ }));
99
+ const scopedGuards = Arr.map(foldkitPreset.overrides, ({ files, excludeFiles = [], rules }) => ({
100
+ files,
101
+ excludeFiles,
102
+ rules: R.keys(R.filter(rules, (setting) => setting === "error"))
103
+ }));
104
+ const guardedInOverrides = Arr.dedupe([...guarded, ...Arr.flatMap(scopedGuards, ({ rules }) => rules)]);
105
+ const sameFiles = (files, other) => files.length === other.length && Arr.every(files, (file) => other.includes(file));
106
+ const excepted = (override, rule, list) => Arr.some([...presetScopes, ...list], (exception) => exception.rules.includes(rule) && sameFiles(override.files, exception.files));
107
+ const scopeFindings = (overrides) => Arr.flatMap(scopedGuards, ({ files, excludeFiles, rules }) => Arr.flatMap(rules, (rule) => Arr.some(overrides, (override) => sameFiles(override.files, files) && sameFiles(override.excludeFiles ?? [], excludeFiles) && Option.exists(settingOf(override.rules, rule), atError)) ? [] : [`${rule} is not at error for ${Arr.join(files, ", ")}`]));
108
+ const overrideFindings = (where, overrides, list) => Arr.flatMap(overrides, (override) => Arr.flatMap(guardedInOverrides, (rule) => Option.match(settingOf(override.rules, rule), {
109
+ onNone: () => [],
110
+ onSome: (setting) => atError(setting) || excepted(override, rule, list) ? [] : [`${where} override for ${Arr.join(override.files, ", ")} sets ${rule} to ${severityOf(setting)} outside a named-file exception`]
111
+ })));
112
+ const inheritedFindings = (where, { extends: extendedConfigs = [] }) => Arr.flatMap(extendedConfigs, ({ overrides = [], ...extended }, index) => {
113
+ const path = `${where}extends[${index}]`;
114
+ return [...overrideFindings(path, overrides, []), ...inheritedFindings(`${path}.`, extended)];
115
+ });
116
+ const ruleFindings = dual((args) => args[0] !== void 0 && !Schema.is(Schema.Array(Schema.Unknown))(args[0]), ({ overrides = [], ...config }, list = exceptions) => [
117
+ ...Arr.flatMap(guarded, (rule) => Option.match(settingOf(config.rules, rule), {
118
+ onNone: () => [`${rule} is not set`],
119
+ onSome: (setting) => atError(setting) ? [] : [`${rule} is ${severityOf(setting)}`]
120
+ })),
121
+ ...overrideFindings("the config's", overrides, list),
122
+ ...scopeFindings(overrides),
123
+ ...inheritedFindings("", config)
124
+ ]);
125
+ const GLOB = /[*?[\]{}!]/u;
126
+ const ISSUE = /^https:\/\/github\.com\/[\w.-]+\/[\w.-]+\/issues\/\d+$/u;
127
+ const exceptionFindings = (list = exceptions) => Arr.flatMap(list, (exception, index) => [
128
+ ...Arr.isReadonlyArrayEmpty(exception.files) ? [`exception ${index} names no file`] : [],
129
+ ...Arr.flatMap(exception.files, (file) => GLOB.test(file) ? [`exception ${index} names ${file}, a pattern rather than a file`] : []),
130
+ ...Arr.isReadonlyArrayEmpty(exception.rules) ? [`exception ${index} names no rule`] : [],
131
+ ...ISSUE.test(exception.issue) ? [] : [`exception ${index} has no issue link: ${exception.issue}`]
132
+ ]);
133
+ const familyTagFindings = (registry, family) => Option.match(latestOf(registry, family), {
134
+ onNone: () => [`${lead(family)} has no latest tag in the registry record`],
135
+ onSome: (latest) => family.version === latest ? [] : Option.match(Arr.findFirst(otherTags(registry, family), ([, version]) => version === family.version), {
136
+ onSome: ([tag]) => [`${family.name} ${family.version} comes from the ${tag} tag`],
137
+ onNone: () => onLatestLine(family.version, latest) ? [] : [`${family.name} ${family.version} is not on npm's latest line (${latest})`]
138
+ })
139
+ });
140
+ const tagFindings = dual(2, (current, registry) => Arr.flatMap(current.families, (family) => familyTagFindings(registry, family)));
141
+ export { exactFindings, exceptionFindings, foldkitViteFindings, isFoldkitViteInput, manifestRanges, pinFindings, ruleFindings, tagFindings };
@@ -0,0 +1,16 @@
1
+ import * as Schema from "effect/Schema";
2
+ import * as Effect from "effect/Effect";
3
+ import { FileSystem } from "effect/FileSystem";
4
+ import { Path } from "effect/Path";
5
+ export declare const worktreePrePush = "#!/bin/sh\nif ! root=$(git rev-parse --show-toplevel); then\n printf '%s\\n' 'pre-push: could not determine the invoking worktree root' >&2\n exit 1\nfi\nif [ ! -f \"$root/node_modules/.bin/vp\" ] || [ ! -x \"$root/node_modules/.bin/vp\" ]; then\n printf '%s\\n' \"pre-push: missing or nonexecutable $root/node_modules/.bin/vp\" >&2\n exit 1\nfi\nif [ ! -f \"$root/.vite-hooks/pre-push\" ]; then\n printf '%s\\n' \"pre-push: missing $root/.vite-hooks/pre-push\" >&2\n exit 1\nfi\nif ! git -C \"$root\" ls-files --error-unmatch .vite-hooks/pre-push >/dev/null 2>&1; then\n printf '%s\\n' \"pre-push: untracked $root/.vite-hooks/pre-push\" >&2\n exit 1\nfi\nexport PATH=\"$root/node_modules/.bin:$PATH\"\nexec /bin/sh -e \"$root/.vite-hooks/pre-push\" \"$@\"\n";
6
+ declare const Setup_base: Schema.Class<Setup, Schema.TaggedStruct<"Setup", {
7
+ readonly message: Schema.String;
8
+ }>, import("effect/Cause").YieldableError & {
9
+ readonly brand: unique symbol;
10
+ }>;
11
+ declare class Setup extends Setup_base {}
12
+ export declare const configurePrePush: (args_0: {
13
+ readonly cwd: string;
14
+ readonly agent: boolean;
15
+ }) => Effect.Effect<void, import("effect/PlatformError").PlatformError | Setup, import("effect/process/ChildProcessSpawner").ChildProcessSpawner | FileSystem | Path>;
16
+ export {};
package/dist/hooks.mjs ADDED
@@ -0,0 +1,137 @@
1
+ import * as Arr from "effect/Array";
2
+ import * as Schema from "effect/Schema";
3
+ import * as Str from "effect/String";
4
+ import * as Effect from "effect/Effect";
5
+ import { FileSystem } from "effect/FileSystem";
6
+ import { Path } from "effect/Path";
7
+ import { ChildProcess } from "effect/process";
8
+ import * as Stream from "effect/Stream";
9
+ // src/hooks.ts
10
+ const worktreePrePush = `#!/bin/sh
11
+ if ! root=$(git rev-parse --show-toplevel); then
12
+ printf '%s\\n' 'pre-push: could not determine the invoking worktree root' >&2
13
+ exit 1
14
+ fi
15
+ if [ ! -f "$root/node_modules/.bin/vp" ] || [ ! -x "$root/node_modules/.bin/vp" ]; then
16
+ printf '%s\\n' "pre-push: missing or nonexecutable $root/node_modules/.bin/vp" >&2
17
+ exit 1
18
+ fi
19
+ if [ ! -f "$root/.vite-hooks/pre-push" ]; then
20
+ printf '%s\\n' "pre-push: missing $root/.vite-hooks/pre-push" >&2
21
+ exit 1
22
+ fi
23
+ if ! git -C "$root" ls-files --error-unmatch .vite-hooks/pre-push >/dev/null 2>&1; then
24
+ printf '%s\\n' "pre-push: untracked $root/.vite-hooks/pre-push" >&2
25
+ exit 1
26
+ fi
27
+ export PATH="$root/node_modules/.bin:$PATH"
28
+ exec /bin/sh -e "$root/.vite-hooks/pre-push" "$@"
29
+ `;
30
+ var Setup = class extends Schema.TaggedError()("Setup", { message: Schema.String }) {};
31
+ const execute = Effect.fn("Hooks.execute")(function* (command) {
32
+ const child = yield* command;
33
+ const [code, stdout, stderr] = yield* Effect.all([
34
+ child.exitCode,
35
+ child.stdout.pipe(Stream.decodeText, Stream.mkString),
36
+ child.stderr.pipe(Stream.decodeText, Stream.mkString)
37
+ ], { concurrency: "unbounded" });
38
+ if (Number(code) !== 0) return yield* Setup.make({ message: `${command.command} ${Arr.join(Arr.map(command.args, String), " ")} exited ${code}: ${stdout}${stderr}` });
39
+ return {
40
+ stdout,
41
+ stderr
42
+ };
43
+ });
44
+ const git = Effect.fn("Hooks.git")(function* (cwd, args) {
45
+ return yield* execute(ChildProcess.make("git", args, {
46
+ cwd,
47
+ stdin: "ignore"
48
+ }));
49
+ });
50
+ const localVp = Effect.fn("Hooks.localVp")(function* (root, args) {
51
+ return yield* execute(ChildProcess.make(`${root}/node_modules/.bin/vp`, args, {
52
+ cwd: root,
53
+ stdin: "ignore"
54
+ }));
55
+ });
56
+ const requireFile = Effect.fn("Hooks.requireFile")(function* (file) {
57
+ const stat = yield* (yield* FileSystem).stat(file);
58
+ if (stat.type !== "File") return yield* Setup.make({ message: `Required pre-push setup file is not a file: ${file}` });
59
+ return stat;
60
+ });
61
+ const requireExecutable = Effect.fn("Hooks.requireExecutable")(function* (file) {
62
+ const stat = yield* requireFile(file);
63
+ if (!Arr.some([
64
+ 64,
65
+ 8,
66
+ 1
67
+ ], (permission) => Math.floor(stat.mode / permission) % 2 === 1)) return yield* Setup.make({ message: `Required pre-push setup file is not executable: ${file}` });
68
+ return stat;
69
+ });
70
+ const installPrePush = Effect.fn("Hooks.installPrePush")(function* (root) {
71
+ const fs = yield* FileSystem;
72
+ const path = yield* Path;
73
+ const generated = path.join(root, ".vite-hooks", "_");
74
+ yield* requireFile(path.join(generated, "h"));
75
+ const dispatcher = path.join(generated, "pre-push");
76
+ yield* requireFile(dispatcher);
77
+ yield* git(root, [
78
+ "config",
79
+ "--local",
80
+ "core.hooksPath",
81
+ generated
82
+ ]);
83
+ yield* fs.writeFileString(dispatcher, worktreePrePush);
84
+ yield* fs.chmod(dispatcher, 493);
85
+ });
86
+ const verifyActivePrePush = Effect.fn("Hooks.verifyActivePrePush")(function* (root) {
87
+ const fs = yield* FileSystem;
88
+ const path = yield* Path;
89
+ const active = yield* git(root, [
90
+ "rev-parse",
91
+ "--path-format=absolute",
92
+ "--git-path",
93
+ "hooks"
94
+ ]);
95
+ const activeHook = path.join(Str.trim(active.stdout), "pre-push");
96
+ const bytes = yield* fs.readFile(activeHook);
97
+ const expected = new TextEncoder().encode(worktreePrePush);
98
+ if (bytes.length !== expected.length || bytes.some((byte, index) => byte !== expected[index])) return yield* Setup.make({ message: `Active pre-push has wrong bytes: ${activeHook}` });
99
+ return yield* requireExecutable(activeHook).pipe(Effect.asVoid);
100
+ });
101
+ const configurePrePush = Effect.fn("Hooks.configurePrePush")(function* ({ cwd, agent }) {
102
+ const path = yield* Path;
103
+ const rootResult = yield* git(cwd, ["rev-parse", "--show-toplevel"]);
104
+ const root = Str.trim(rootResult.stdout);
105
+ const vp = path.join(root, "node_modules", ".bin", "vp");
106
+ yield* requireExecutable(vp);
107
+ const tracked = path.join(root, ".vite-hooks", "pre-push");
108
+ yield* requireFile(tracked);
109
+ yield* git(root, [
110
+ "ls-files",
111
+ "--error-unmatch",
112
+ ".vite-hooks/pre-push"
113
+ ]);
114
+ yield* localVp(root, [
115
+ "config",
116
+ "--hooks",
117
+ agent ? "--agent" : "--no-agent"
118
+ ]);
119
+ const active = yield* git(root, [
120
+ "rev-parse",
121
+ "--path-format=absolute",
122
+ "--git-path",
123
+ "hooks"
124
+ ]);
125
+ const generated = path.join(root, ".vite-hooks", "_");
126
+ const disabled = yield* git(root, [
127
+ "config",
128
+ "--type=bool",
129
+ "--default=false",
130
+ "--get",
131
+ "vp.hooks.disabled"
132
+ ]);
133
+ if (Str.trim(disabled.stdout) === "true") return yield* Setup.make({ message: "Native pre-push setup has hooks disabled" });
134
+ if (Str.trim(active.stdout) === generated) yield* installPrePush(root);
135
+ return yield* verifyActivePrePush(root);
136
+ }, Effect.scoped);
137
+ export { configurePrePush, worktreePrePush };
@@ -0,0 +1 @@
1
+ export declare const packageName = "@milkenjoyer/toolchain";
package/dist/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ // src/index.ts
2
+ const packageName = "@milkenjoyer/toolchain";
3
+ export { packageName };
@@ -0,0 +1,7 @@
1
+ import { KnipConfiguration } from "knip";
2
+ export type KnipOptions = {
3
+ readonly entry?: ReadonlyArray<string>;
4
+ readonly ignoreDependencies?: ReadonlyArray<string>;
5
+ readonly workspaces?: KnipConfiguration["workspaces"];
6
+ };
7
+ export declare const knip: ({ entry, ignoreDependencies, workspaces }?: KnipOptions) => KnipConfiguration;
package/dist/knip.mjs ADDED
@@ -0,0 +1,15 @@
1
+ // src/knip.ts
2
+ const baseEntry = [
3
+ "*.run.ts",
4
+ "scripts/*.ts",
5
+ "tests/fixtures/**/*.ts"
6
+ ];
7
+ const toolchainPlugins = ["@effect/language-service", "@foldkit/oxlint-plugin"];
8
+ const knip = ({ entry = [], ignoreDependencies = [], workspaces = {} } = {}) => ({
9
+ ignoreDependencies: [...toolchainPlugins, ...ignoreDependencies],
10
+ workspaces: {
11
+ ".": { entry: [...baseEntry, ...entry] },
12
+ ...workspaces
13
+ }
14
+ });
15
+ export { knip };
@@ -0,0 +1,23 @@
1
+ import { OxlintConfig } from "vite-plus/lint";
2
+ export type LintOptions = {
3
+ readonly ignores?: ReadonlyArray<string>;
4
+ };
5
+ export declare const foldkitPreset: {
6
+ readonly jsPlugins: readonly {
7
+ readonly name: string;
8
+ readonly specifier: string;
9
+ }[];
10
+ readonly rules: {
11
+ readonly [x: string]: "error" | "off";
12
+ };
13
+ readonly overrides: readonly {
14
+ readonly files: string[];
15
+ readonly excludeFiles?: string[];
16
+ readonly rules: {
17
+ readonly [x: string]: "error" | "off";
18
+ };
19
+ }[];
20
+ };
21
+ export declare const effectRules: Record<string, "error">;
22
+ export declare const birbprophetRules: Record<string, "error">;
23
+ export declare const lint: ({ ignores }?: LintOptions) => OxlintConfig;
package/dist/lint.mjs ADDED
@@ -0,0 +1,96 @@
1
+ import { t as plugin } from "./effect-plugin-ByuWwyB8.mjs";
2
+ import { effectTsgoPlugin, effectTsgoRules } from "./effect-tsgo.mjs";
3
+ import { exceptions } from "./exceptions.mjs";
4
+ import { t as plugin$1 } from "./plugin-C3DDlAbr.mjs";
5
+ import { staticRules } from "./rules.mjs";
6
+ import * as Arr from "effect/Array";
7
+ import * as Option from "effect/Option";
8
+ import * as R from "effect/Record";
9
+ import * as Schema from "effect/Schema";
10
+ import * as Str from "effect/String";
11
+ import foldkitRecommended from "@foldkit/oxlint-plugin/recommended.json" with { type: "json" };
12
+ import ultraciteCore from "ultracite/oxlint/core";
13
+ // src/lint.ts
14
+ const plugins = [
15
+ "typescript",
16
+ "import",
17
+ "promise",
18
+ "unicorn",
19
+ "oxc",
20
+ "eslint",
21
+ "node",
22
+ "vitest",
23
+ effectTsgoPlugin
24
+ ];
25
+ const categories = {
26
+ correctness: "error",
27
+ suspicious: "error",
28
+ pedantic: "off",
29
+ perf: "off",
30
+ style: "off",
31
+ restriction: "off",
32
+ nursery: "off"
33
+ };
34
+ const PresetRules = Schema.Record(Schema.String, Schema.Literals(["error", "off"]));
35
+ const Globs = Schema.mutable(Schema.Array(Schema.String));
36
+ const FoldkitPreset = Schema.Struct({
37
+ jsPlugins: Schema.Array(Schema.Struct({
38
+ name: Schema.String,
39
+ specifier: Schema.String
40
+ })),
41
+ rules: PresetRules,
42
+ overrides: Schema.Array(Schema.Struct({
43
+ files: Globs,
44
+ excludeFiles: Schema.optionalKey(Globs),
45
+ rules: PresetRules
46
+ }))
47
+ });
48
+ const foldkitPreset = Schema.decodeUnknownSync(FoldkitPreset)(foldkitRecommended);
49
+ const atError = (prefix, rules) => R.fromEntries(Arr.map(rules, (rule) => [`${prefix}/${rule}`, "error"]));
50
+ const effectRules = atError(plugin.meta.name, R.keys(plugin.rules));
51
+ const birbprophetRules = atError(plugin$1.meta.name, R.keys(plugin$1.rules));
52
+ const { ignorePatterns: coreIgnores = [] } = ultraciteCore;
53
+ const resolved = (specifier) => decodeURIComponent(new URL(import.meta.resolve(specifier)).pathname);
54
+ const ownExtension = Str.slice(Str.lastIndexOf(".")(import.meta.filename).pipe(Option.getOrElse(() => -1)))(import.meta.filename);
55
+ const sibling = (module) => resolved(`./${module}${ownExtension}`);
56
+ const exceptionTier = (exception) => ({
57
+ files: [...exception.files],
58
+ rules: R.fromEntries(Arr.map(exception.rules, (rule) => [rule, "off"]))
59
+ });
60
+ const lint = ({ ignores = [] } = {}) => ({
61
+ plugins,
62
+ categories,
63
+ jsPlugins: [
64
+ {
65
+ name: "vite-plus",
66
+ specifier: resolved("vite-plus/oxlint-plugin")
67
+ },
68
+ ...Arr.map(foldkitPreset.jsPlugins, ({ name, specifier }) => ({
69
+ name,
70
+ specifier: resolved(specifier)
71
+ })),
72
+ {
73
+ name: plugin.meta.name,
74
+ specifier: sibling("effect-plugin")
75
+ },
76
+ {
77
+ name: plugin$1.meta.name,
78
+ specifier: sibling("plugin")
79
+ }
80
+ ],
81
+ options: {
82
+ typeAware: true,
83
+ typeCheck: true
84
+ },
85
+ rules: {
86
+ ...foldkitPreset.rules,
87
+ ...staticRules,
88
+ "vite-plus/prefer-vite-plus-imports": "error",
89
+ ...effectRules,
90
+ ...birbprophetRules,
91
+ ...effectTsgoRules
92
+ },
93
+ overrides: [...foldkitPreset.overrides, ...Arr.map(exceptions, exceptionTier)],
94
+ ignorePatterns: [...coreIgnores, ...ignores]
95
+ });
96
+ export { birbprophetRules, effectRules, foldkitPreset, lint };