@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.
- package/README.md +28 -2
- package/dist/compatible.d.mts +91 -0
- package/dist/compatible.mjs +160 -0
- package/dist/effect-plugin-ByuWwyB8.mjs +3505 -0
- package/dist/effect-plugin.d.mts +3967 -0
- package/dist/effect-plugin.mjs +1 -0
- package/dist/effect-tsgo.d.mts +4 -0
- package/dist/effect-tsgo.mjs +23 -0
- package/dist/exceptions.d.mts +6 -0
- package/dist/exceptions.mjs +3 -0
- package/dist/fmt.d.mts +5 -0
- package/dist/fmt.mjs +8 -0
- package/dist/guard.d.mts +26 -0
- package/dist/guard.mjs +141 -0
- package/dist/hooks.d.mts +16 -0
- package/dist/hooks.mjs +137 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +3 -0
- package/dist/knip.d.mts +7 -0
- package/dist/knip.mjs +15 -0
- package/dist/lint.d.mts +23 -0
- package/dist/lint.mjs +96 -0
- package/dist/plugin-C3DDlAbr.mjs +268 -0
- package/dist/plugin.d.mts +8 -0
- package/dist/plugin.mjs +1 -0
- package/dist/rules.d.mts +106 -0
- package/dist/rules.mjs +112 -0
- package/dist/versions.d.mts +46 -0
- package/dist/versions.mjs +142 -0
- package/licenses/anti-slop.txt +21 -0
- package/licenses/oxlint-plugin-effect.txt +21 -0
- package/node-version +1 -0
- package/package.json +105 -4
- package/renovate.json +77 -0
- package/tsconfig.base.json +34 -0
- package/vscode/extensions.json +3 -0
- package/vscode/settings.json +6 -0
package/README.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Configure pre-push hooks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A shared absolute Git hooks path must dispatch through the invoking worktree. `@milkenjoyer/toolchain/hooks` supplies `configurePrePush` to run native Vite+ setup and install that dispatcher as one operation.
|
|
4
|
+
|
|
5
|
+
Create the composition entrypoint `scripts/composition/configure-hooks.ts` and replace the existing `vp config` prepare step with `bun scripts/composition/configure-hooks.ts`. Keep the other prepare steps in their current order.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { NodeRuntime, NodeServices } from "@effect/platform-node";
|
|
9
|
+
import { configurePrePush } from "@milkenjoyer/toolchain/hooks";
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
|
+
|
|
12
|
+
if (import.meta.main) {
|
|
13
|
+
NodeRuntime.runMain(
|
|
14
|
+
configurePrePush({ cwd: process.cwd(), agent: true }).pipe(
|
|
15
|
+
Effect.provide(NodeServices.layer)
|
|
16
|
+
)
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Call `NodeRuntime.runMain` directly inside the entrypoint guard. For VibeBattler, the prepare command is `effect-tsgo patch --oxlint && bun scripts/composition/configure-hooks.ts && vp run @vibebattler/plugin#build`.
|
|
22
|
+
|
|
23
|
+
Use `agent: false` where the old command used `--no-agent`. The product moves its package pin to the released toolchain version. It imports the shared implementation rather than copying it.
|
|
24
|
+
|
|
25
|
+
The program runs the local `vp config --hooks`, retains an absolute shared hooks path, replaces only the generated `.vite-hooks/_/pre-push`, and verifies the active Git dispatcher before returning success. Native `h`, other hook stubs and the tracked `.vite-hooks/pre-push` checks retain their behavior. The dispatcher requires the invoking worktree's executable `node_modules/.bin/vp` and tracked `.vite-hooks/pre-push`. It preserves stdin, arguments, cwd and the check's exit status.
|
|
26
|
+
|
|
27
|
+
Use this same prepare entrypoint for regeneration. A bare native `vp config` or `vp hooks enable` restores the upstream stub. The supported setup entrypoint regenerates and reinstalls the corrected stub together. A worktree whose shared active dispatcher belongs to another checkout cannot silently repair that checkout. Setup must reject a stale shared dispatcher until the parent updates the primary through the reviewed deployment.
|
|
28
|
+
|
|
29
|
+
Before deployment, save the active generated stub's bytes and executable mode. Compare the replacement with the released `worktreePrePush` export. Rollback restores those saved bytes and mode. The old stub reintroduces the diagnosed executable/config mismatch, so keep affected worktree pushes held after rollback.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Catalog, Family } from "./versions.mjs";
|
|
2
|
+
import * as Data from "effect/Data";
|
|
3
|
+
import * as Option from "effect/Option";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
5
|
+
export declare const VersionManifest: Schema.Struct<{
|
|
6
|
+
readonly dependencies: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
7
|
+
readonly peerDependencies: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
8
|
+
readonly bundledVersions: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
9
|
+
}>;
|
|
10
|
+
export type VersionManifest = typeof VersionManifest.Type;
|
|
11
|
+
export declare const Packument: Schema.Struct<{
|
|
12
|
+
readonly "dist-tags": Schema.$Record<Schema.String, Schema.String>;
|
|
13
|
+
readonly versions: Schema.$Record<Schema.String, Schema.Struct<{
|
|
14
|
+
readonly dependencies: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
15
|
+
readonly peerDependencies: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
16
|
+
readonly bundledVersions: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
17
|
+
}>>;
|
|
18
|
+
}>;
|
|
19
|
+
export type Packument = typeof Packument.Type;
|
|
20
|
+
export declare const Packuments: Schema.$Record<Schema.String, Schema.Struct<{
|
|
21
|
+
readonly "dist-tags": Schema.$Record<Schema.String, Schema.String>;
|
|
22
|
+
readonly versions: Schema.$Record<Schema.String, Schema.Struct<{
|
|
23
|
+
readonly dependencies: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
24
|
+
readonly peerDependencies: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
25
|
+
readonly bundledVersions: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
26
|
+
}>>;
|
|
27
|
+
}>>;
|
|
28
|
+
export type Packuments = typeof Packuments.Type;
|
|
29
|
+
type UnmetFields = {
|
|
30
|
+
readonly name: string;
|
|
31
|
+
readonly version: string;
|
|
32
|
+
readonly needs: string;
|
|
33
|
+
readonly range: string;
|
|
34
|
+
readonly actual: string;
|
|
35
|
+
};
|
|
36
|
+
export type Conflict = Data.TaggedEnum<{
|
|
37
|
+
Unpublished: {
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly version: string;
|
|
40
|
+
};
|
|
41
|
+
Unmet: UnmetFields;
|
|
42
|
+
}>;
|
|
43
|
+
export declare const Conflict: Data.TaggedEnum.Constructor<{
|
|
44
|
+
readonly _tag: "Unmet";
|
|
45
|
+
readonly name: string;
|
|
46
|
+
readonly version: string;
|
|
47
|
+
readonly needs: string;
|
|
48
|
+
readonly range: string;
|
|
49
|
+
readonly actual: string;
|
|
50
|
+
} | {
|
|
51
|
+
readonly _tag: "Unpublished";
|
|
52
|
+
readonly name: string;
|
|
53
|
+
readonly version: string;
|
|
54
|
+
}>;
|
|
55
|
+
export type Solution = {
|
|
56
|
+
readonly resolved: boolean;
|
|
57
|
+
readonly catalog: Catalog;
|
|
58
|
+
readonly latest: Readonly<Record<string, string>>;
|
|
59
|
+
readonly blockers: Readonly<Record<string, string>>;
|
|
60
|
+
readonly conflicts: ReadonlyArray<Conflict>;
|
|
61
|
+
};
|
|
62
|
+
export declare const latestOf: {
|
|
63
|
+
(family: Family): (registry: Packuments) => Option.Option<string>;
|
|
64
|
+
(registry: Packuments, family: Family): Option.Option<string>;
|
|
65
|
+
};
|
|
66
|
+
export declare const otherTags: {
|
|
67
|
+
(family: Family): (registry: Packuments) => ReadonlyArray<readonly [string, string]>;
|
|
68
|
+
(registry: Packuments, family: Family): ReadonlyArray<readonly [string, string]>;
|
|
69
|
+
};
|
|
70
|
+
export declare const aliasTarget: (alias: string) => Option.Option<readonly [string, string]>;
|
|
71
|
+
export declare const fixedRange: {
|
|
72
|
+
(family: Family, name: string): (registry: Packuments) => Option.Option<string>;
|
|
73
|
+
(registry: Packuments, family: Family, name: string): Option.Option<string>;
|
|
74
|
+
};
|
|
75
|
+
export declare const conflicts: {
|
|
76
|
+
(registry: Packuments): (current: Catalog) => ReadonlyArray<Conflict>;
|
|
77
|
+
(current: Catalog, registry: Packuments): ReadonlyArray<Conflict>;
|
|
78
|
+
};
|
|
79
|
+
export declare const onLatestLine: {
|
|
80
|
+
(latest: string): (version: string) => boolean;
|
|
81
|
+
(version: string, latest: string): boolean;
|
|
82
|
+
};
|
|
83
|
+
export declare const describeConflict: {
|
|
84
|
+
(current: Catalog): (conflict: Conflict) => string;
|
|
85
|
+
(conflict: Conflict, current: Catalog): string;
|
|
86
|
+
};
|
|
87
|
+
export declare const solve: {
|
|
88
|
+
(start?: Catalog): (registry: Packuments) => Solution;
|
|
89
|
+
(registry: Packuments, start?: Catalog): Solution;
|
|
90
|
+
};
|
|
91
|
+
export {};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { catalog, familyNamed, familyOf, fixedBy, fixedOf, lead, ownerOf, versionOf } from "./versions.mjs";
|
|
2
|
+
import * as Arr from "effect/Array";
|
|
3
|
+
import * as Data from "effect/Data";
|
|
4
|
+
import { dual } from "effect/Function";
|
|
5
|
+
import * as HashSet from "effect/HashSet";
|
|
6
|
+
import * as Match from "effect/Match";
|
|
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 semver from "semver";
|
|
12
|
+
// src/compatible.ts
|
|
13
|
+
const Ranges = Schema.optionalKey(Schema.Record(Schema.String, Schema.String));
|
|
14
|
+
const VersionManifest = Schema.Struct({
|
|
15
|
+
dependencies: Ranges,
|
|
16
|
+
peerDependencies: Ranges,
|
|
17
|
+
bundledVersions: Ranges
|
|
18
|
+
});
|
|
19
|
+
const Packument = Schema.Struct({
|
|
20
|
+
"dist-tags": Schema.Record(Schema.String, Schema.String),
|
|
21
|
+
versions: Schema.Record(Schema.String, VersionManifest)
|
|
22
|
+
});
|
|
23
|
+
const Packuments = Schema.Record(Schema.String, Packument);
|
|
24
|
+
const Conflict = Data.taggedEnum();
|
|
25
|
+
const ALIAS = /^npm:(?<target>(?:@[^/@]+\/)?[^@]+)@(?<version>.+)$/u;
|
|
26
|
+
const manifestOf = (registry, name, version) => Option.flatMap(R.get(registry, name), (packument) => R.get(packument.versions, version));
|
|
27
|
+
const latestOf = dual(2, (registry, family) => Option.flatMap(R.get(registry, lead(family)), (packument) => R.get(packument["dist-tags"], "latest")));
|
|
28
|
+
const otherTags = dual(2, (registry, family) => Arr.flatMap(family.packages, (name) => Option.match(R.get(registry, name), {
|
|
29
|
+
onNone: () => [],
|
|
30
|
+
onSome: (packument) => Arr.filter(R.toEntries(packument["dist-tags"]), ([tag]) => tag !== "latest")
|
|
31
|
+
})));
|
|
32
|
+
const aliasTarget = (alias) => Option.flatMap(Option.fromNullishOr(ALIAS.exec(alias)?.groups), (groups) => Option.all([Option.fromNullishOr(groups.target), Option.fromNullishOr(groups.version)]));
|
|
33
|
+
const fixedRange = dual(3, (registry, family, name) => Option.flatMap(manifestOf(registry, lead(family), family.version), ({ dependencies = {} }) => R.get(dependencies, name)));
|
|
34
|
+
const anchored = (start, name) => Option.exists(ownerOf(name, start), (owner) => Arr.isReadonlyArrayNonEmpty(fixedBy(owner.name, start)));
|
|
35
|
+
const requirements = (start, name, manifest) => {
|
|
36
|
+
const { dependencies = {}, peerDependencies = {} } = manifest;
|
|
37
|
+
return [...anchored(start, name) ? R.toEntries(dependencies) : [], ...R.toEntries(peerDependencies)];
|
|
38
|
+
};
|
|
39
|
+
const holds = (registry, needs, actual, range) => Option.match(aliasTarget(actual), {
|
|
40
|
+
onNone: () => semver.validRange(range) !== null && semver.satisfies(actual, Str.replace(/^=/u, "")(range)),
|
|
41
|
+
onSome: ([target, version]) => range === actual || Option.exists(Option.flatMap(manifestOf(registry, target, version), ({ bundledVersions = {} }) => R.get(bundledVersions, needs)), (bundled) => semver.satisfies(bundled, range))
|
|
42
|
+
});
|
|
43
|
+
const conflictsForManifest = (registry, start, lookup, family, name, manifest) => Arr.flatMap(requirements(start, name, manifest), ([needs, range]) => Option.match(lookup(needs), {
|
|
44
|
+
onNone: () => [],
|
|
45
|
+
onSome: (actual) => holds(registry, needs, actual, range) ? [] : [Conflict.Unmet({
|
|
46
|
+
name,
|
|
47
|
+
version: family.version,
|
|
48
|
+
needs,
|
|
49
|
+
range,
|
|
50
|
+
actual
|
|
51
|
+
})]
|
|
52
|
+
}));
|
|
53
|
+
const memberConflicts = (registry, start, lookup, family, name) => Option.match(manifestOf(registry, name, family.version), {
|
|
54
|
+
onNone: () => R.has(registry, name) ? [Conflict.Unpublished({
|
|
55
|
+
name,
|
|
56
|
+
version: family.version
|
|
57
|
+
})] : [],
|
|
58
|
+
onSome: (manifest) => conflictsForManifest(registry, start, lookup, family, name, manifest)
|
|
59
|
+
});
|
|
60
|
+
const conflictsAmong = (registry, start, picked, lookup) => Arr.flatMap(picked, (family) => Arr.flatMap(family.packages, (name) => memberConflicts(registry, start, lookup, family, name)));
|
|
61
|
+
const conflicts = dual(2, (current, registry) => conflictsAmong(registry, current, current.families, (name) => versionOf(name, current)));
|
|
62
|
+
const fixedVersion = (registry, family, entry) => Option.match(fixedRange(registry, family, entry.name), {
|
|
63
|
+
onNone: () => entry,
|
|
64
|
+
onSome: (range) => ({
|
|
65
|
+
...entry,
|
|
66
|
+
version: Str.replace(/^=/u, "")(range)
|
|
67
|
+
})
|
|
68
|
+
});
|
|
69
|
+
const onLatestLine = dual(2, (version, latest) => semver.lte(version, latest) && (semver.prerelease(latest) !== null || semver.prerelease(version) === null));
|
|
70
|
+
const published = (registry, family) => Option.match(R.get(registry, lead(family)), {
|
|
71
|
+
onNone: () => [],
|
|
72
|
+
onSome: (packument) => R.keys(packument.versions)
|
|
73
|
+
});
|
|
74
|
+
const rises = (family, latest, tagged, version) => semver.valid(version) !== null && semver.gt(version, family.version) && onLatestLine(version, latest) && (version === latest || !HashSet.has(tagged, version));
|
|
75
|
+
const ladder = (registry, family) => {
|
|
76
|
+
const tagged = HashSet.fromIterable(Arr.map(otherTags(registry, family), ([, version]) => version));
|
|
77
|
+
const above = Option.match(latestOf(registry, family), {
|
|
78
|
+
onNone: () => [],
|
|
79
|
+
onSome: (latest) => Arr.filter(published(registry, family), (version) => rises(family, latest, tagged, version) && Arr.every(family.packages, (name) => !R.has(registry, name) || Option.isSome(manifestOf(registry, name, version))))
|
|
80
|
+
});
|
|
81
|
+
return [...Arr.sort(above, semver.rcompare), family.version];
|
|
82
|
+
};
|
|
83
|
+
const assemble = (registry, start, picked) => ({
|
|
84
|
+
families: picked,
|
|
85
|
+
fixed: Arr.flatMap(start.fixed, (entry) => Arr.fromOption(Option.map(familyNamed(entry.by, {
|
|
86
|
+
...start,
|
|
87
|
+
families: picked
|
|
88
|
+
}), (family) => fixedVersion(registry, family, entry))))
|
|
89
|
+
});
|
|
90
|
+
const pickedVersion = (registry, start, picked, name) => {
|
|
91
|
+
const owner = ownerOf(name, start);
|
|
92
|
+
if (Option.isNone(owner)) return Option.none();
|
|
93
|
+
const chosen = familyNamed(owner.value.name, {
|
|
94
|
+
...start,
|
|
95
|
+
families: picked
|
|
96
|
+
});
|
|
97
|
+
if (Option.isNone(chosen)) return Option.none();
|
|
98
|
+
if (Option.isSome(familyOf(name, start))) return Option.some(chosen.value.version);
|
|
99
|
+
return Option.map(fixedOf(name, start), (entry) => fixedVersion(registry, chosen.value, entry).version);
|
|
100
|
+
};
|
|
101
|
+
const search = (registry, start, rungs, picked) => Arr.matchLeft(rungs, {
|
|
102
|
+
onEmpty: () => Option.some(picked),
|
|
103
|
+
onNonEmpty: ([family, versions], rest) => Arr.findFirst(versions, (version) => {
|
|
104
|
+
const next = [...picked, {
|
|
105
|
+
...family,
|
|
106
|
+
version
|
|
107
|
+
}];
|
|
108
|
+
return Arr.isReadonlyArrayEmpty(conflictsAmong(registry, start, next, (name) => pickedVersion(registry, start, next, name))) ? search(registry, start, rest, next) : Option.none();
|
|
109
|
+
})
|
|
110
|
+
});
|
|
111
|
+
const describeConflict = dual(2, (conflict, current) => Match.value(conflict).pipe(Match.tag("Unpublished", ({ name, version }) => `${name} ${version} is not published`), Match.tag("Unmet", ({ name, version, needs, range, actual }) => {
|
|
112
|
+
return `${name} ${version} needs ${needs} ${range}, and the set has ${needs} ${actual}${Option.match(fixedOf(needs, current), {
|
|
113
|
+
onNone: () => "",
|
|
114
|
+
onSome: (entry) => `, which ${entry.by} fixes`
|
|
115
|
+
})}`;
|
|
116
|
+
}), Match.exhaustive));
|
|
117
|
+
const involves = (conflict, family, current) => family.packages.includes(conflict.name) || Match.value(conflict).pipe(Match.tag("Unmet", ({ needs }) => Option.exists(ownerOf(needs, current), (owner) => owner.name === family.name)), Match.orElse(() => false));
|
|
118
|
+
const familyBlocker = (registry, solved, family, latest) => {
|
|
119
|
+
const families = Arr.map(solved.families, (entry) => entry.name === family.name ? {
|
|
120
|
+
...entry,
|
|
121
|
+
version: latest
|
|
122
|
+
} : entry);
|
|
123
|
+
const trial = assemble(registry, solved, families);
|
|
124
|
+
const relevant = Arr.filter(conflicts(trial, registry), (conflict) => involves(conflict, family, trial));
|
|
125
|
+
return Arr.match(relevant, {
|
|
126
|
+
onEmpty: () => {
|
|
127
|
+
if (ladder(registry, family).includes(latest)) return `no compatible set includes ${family.name} ${latest}`;
|
|
128
|
+
return `${family.name} ${latest} is below the catalog or not published for every package in its family`;
|
|
129
|
+
},
|
|
130
|
+
onNonEmpty: ([first]) => describeConflict(first, trial)
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
const blockersOf = (registry, solved, latest) => R.fromEntries(Arr.flatMap(solved.families, (family) => Option.match(R.get(latest, family.name), {
|
|
134
|
+
onNone: () => [],
|
|
135
|
+
onSome: (version) => version === family.version ? [] : [[family.name, familyBlocker(registry, solved, family, version)]]
|
|
136
|
+
})));
|
|
137
|
+
const solve = dual((args) => Schema.is(Packuments)(args[0]), (registry, start = catalog) => {
|
|
138
|
+
const latest = R.fromEntries(Arr.flatMap(start.families, (family) => Arr.fromOption(Option.map(latestOf(registry, family), (version) => [family.name, version]))));
|
|
139
|
+
const rungs = Arr.map(start.families, (family) => [family, ladder(registry, family)]);
|
|
140
|
+
return Option.match(search(registry, start, rungs, []), {
|
|
141
|
+
onNone: () => ({
|
|
142
|
+
resolved: false,
|
|
143
|
+
catalog: start,
|
|
144
|
+
latest,
|
|
145
|
+
blockers: {},
|
|
146
|
+
conflicts: conflicts(start, registry)
|
|
147
|
+
}),
|
|
148
|
+
onSome: (picked) => {
|
|
149
|
+
const solved = assemble(registry, start, picked);
|
|
150
|
+
return {
|
|
151
|
+
resolved: true,
|
|
152
|
+
catalog: solved,
|
|
153
|
+
latest,
|
|
154
|
+
blockers: blockersOf(registry, solved, latest),
|
|
155
|
+
conflicts: []
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
export { Conflict, Packument, Packuments, VersionManifest, aliasTarget, conflicts, describeConflict, fixedRange, latestOf, onLatestLine, otherTags, solve };
|