@r_masseater/vite-plus-adopt 0.24.4 → 0.25.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/dist/cli.mjs +18 -13
- package/dist/cli.mjs.map +1 -1
- package/dist/index.mjs +13 -1
- package/dist/index.mjs.map +1 -0
- package/dist/{vpa-tyPVfXod.mjs → run-checks-RwkrfT5c.mjs} +30 -32
- package/dist/run-checks-RwkrfT5c.mjs.map +1 -0
- package/package.json +3 -3
- package/dist/vpa-tyPVfXod.mjs.map +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as
|
|
3
|
-
import { Effect,
|
|
2
|
+
import { a as stagedSecrets, c as runCi, d as checkPushedRefs, i as lintMessageText, l as version, r as lintMessageFile, s as prepare, t as runAllChecks } from "./run-checks-RwkrfT5c.mjs";
|
|
3
|
+
import { Effect, Option, Path } from "effect";
|
|
4
|
+
import { hookFlags } from "@r_masseater/masseater-utils/hook-flags";
|
|
4
5
|
import { runMain } from "@r_masseater/masseater-utils/node-main";
|
|
5
|
-
|
|
6
|
-
/** @internal */
|
|
7
|
-
const runCli = (program) => {
|
|
8
|
-
runMain("vpa")(program);
|
|
9
|
-
};
|
|
6
|
+
import { Command } from "effect/cli";
|
|
10
7
|
// src/app/cli.ts
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
const switched = (on, hook) => Option.liftPredicate(hook, () => on);
|
|
9
|
+
const hookOf = (input) => Option.firstSomeOf([
|
|
10
|
+
switched(input.prepare, prepare),
|
|
11
|
+
switched(input.staged, stagedSecrets),
|
|
12
|
+
switched(input.prePush, checkPushedRefs),
|
|
13
|
+
input.commitMsg.pipe(Option.map(lintMessageFile)),
|
|
14
|
+
input.message.pipe(Option.map(lintMessageText))
|
|
15
|
+
]).pipe(Option.getOrElse(() => runAllChecks));
|
|
16
|
+
const inRepository = Effect.fn("inRepository")(function* inRepository(hook) {
|
|
17
|
+
return yield* hook((yield* Path.Path).resolve("."));
|
|
18
|
+
});
|
|
19
|
+
const ci = Command.make("ci", {}, () => inRepository(runCi)).pipe(Command.withDescription("Puts the shared setup action into every job and workflow that runs vp, and drops the hand-written Actions caches"));
|
|
20
|
+
const vpa = Command.make("vpa", hookFlags, (input) => inRepository(hookOf(input))).pipe(Command.withDescription("Runs every check configured in vite.config.ts"), Command.withSubcommands([ci]));
|
|
21
|
+
runMain("vpa")(Command.run(vpa, { version }));
|
|
17
22
|
export {};
|
|
18
23
|
|
|
19
24
|
//# sourceMappingURL=cli.mjs.map
|
package/dist/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","names":[],"sources":["../src/app/
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":["manifest.version"],"sources":["../src/app/cli.ts"],"sourcesContent":["import { hookFlags } from \"@r_masseater/masseater-utils/hook-flags\";\nimport { runMain } from \"@r_masseater/masseater-utils/node-main\";\nimport manifest from \"@r_masseater/vite-plus-adopt/package.json\" with { type: \"json\" };\nimport { Effect, Option, Path } from \"effect\";\nimport { Command } from \"effect/cli\";\n\nimport { checkPushedRefs } from \"#/features/check-pushed-refs/index.ts\";\nimport { runCi } from \"#/features/sync-ci/index.ts\";\n\nimport { lintMessageFile, lintMessageText, stagedSecrets } from \"./hooks.ts\";\nimport { prepare } from \"./prepare.ts\";\nimport { runAllChecks } from \"./run-checks.ts\";\n\ninterface HookInput {\n readonly prepare: boolean;\n readonly staged: boolean;\n readonly prePush: boolean;\n readonly commitMsg: Option.Option<string>;\n readonly message: Option.Option<string>;\n}\n\ntype Hook = typeof runAllChecks;\n\nconst switched = (on: boolean, hook: Hook): Option.Option<Hook> =>\n Option.liftPredicate(hook, () => on);\n\nconst hookOf = (input: HookInput): Hook =>\n Option.firstSomeOf([\n switched(input.prepare, prepare),\n switched(input.staged, stagedSecrets),\n switched(input.prePush, checkPushedRefs),\n input.commitMsg.pipe(Option.map(lintMessageFile)),\n input.message.pipe(Option.map(lintMessageText)),\n ]).pipe(Option.getOrElse((): Hook => runAllChecks));\n\nconst inRepository = Effect.fn(\"inRepository\")(function* inRepository(hook: Hook) {\n const path = yield* Path.Path;\n return yield* hook(path.resolve(\".\"));\n});\n\nconst ci = Command.make(\"ci\", {}, () => inRepository(runCi)).pipe(\n Command.withDescription(\n \"Puts the shared setup action into every job and workflow that runs vp, and drops the hand-written Actions caches\",\n ),\n);\n\nconst vpa = Command.make(\"vpa\", hookFlags, (input) => inRepository(hookOf(input))).pipe(\n Command.withDescription(\"Runs every check configured in vite.config.ts\"),\n Command.withSubcommands([ci]),\n);\n\nrunMain(\"vpa\")(Command.run(vpa, { version: manifest.version }));\n"],"mappings":";;;;;;;AAuBA,MAAM,YAAY,IAAa,SAC7B,OAAO,cAAc,YAAY,EAAE;AAErC,MAAM,UAAU,UACd,OAAO,YAAY;CACjB,SAAS,MAAM,SAAS,OAAO;CAC/B,SAAS,MAAM,QAAQ,aAAa;CACpC,SAAS,MAAM,SAAS,eAAe;CACvC,MAAM,UAAU,KAAK,OAAO,IAAI,eAAe,CAAC;CAChD,MAAM,QAAQ,KAAK,OAAO,IAAI,eAAe,CAAC;AAChD,CAAC,CAAC,CAAC,KAAK,OAAO,gBAAsB,YAAY,CAAC;AAEpD,MAAM,eAAe,OAAO,GAAG,cAAc,CAAC,CAAC,UAAU,aAAa,MAAY;CAEhF,OAAO,OAAO,MAAK,OADC,KAAK,KAAA,CACD,QAAQ,GAAG,CAAC;AACtC,CAAC;AAED,MAAM,KAAK,QAAQ,KAAK,MAAM,CAAC,SAAS,aAAa,KAAK,CAAC,CAAC,CAAC,KAC3D,QAAQ,gBACN,kHACF,CACF;AAEA,MAAM,MAAM,QAAQ,KAAK,OAAO,YAAY,UAAU,aAAa,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,KACjF,QAAQ,gBAAgB,+CAA+C,GACvE,QAAQ,gBAAgB,CAAC,EAAE,CAAC,CAC9B;AAEA,QAAQ,KAAK,CAAC,CAAC,QAAQ,IAAI,KAAK,EAAWA,QAAiB,CAAC,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { f as loadViteConfig, n as HOOKS, o as usage, p as VpToolsError, t as runAllChecks, u as findCiDrift } from "./run-checks-RwkrfT5c.mjs";
|
|
2
|
+
import { Array, Function, Option, Record, pipe } from "effect";
|
|
3
|
+
/** @internal */
|
|
4
|
+
const runVpa = Function.dual(2, (root, args) => pipe(args, Array.match({
|
|
5
|
+
onEmpty: () => runAllChecks(root),
|
|
6
|
+
onNonEmpty: ([flag, ...rest]) => pipe(Record.get(HOOKS, flag), Option.match({
|
|
7
|
+
onNone: () => usage,
|
|
8
|
+
onSome: (hook) => hook(root, rest)
|
|
9
|
+
}))
|
|
10
|
+
})));
|
|
11
|
+
export { VpToolsError, findCiDrift, loadViteConfig, runVpa };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["Fn","Arr","Rec"],"sources":["../src/app/vpa.ts"],"sourcesContent":["import { Option, Array as Arr, Record as Rec, pipe, Function as Fn } from \"effect\";\n\nimport type { CommandEffect } from \"#/shared/lib/command.ts\";\n\nimport { HOOKS, usage } from \"./hooks.ts\";\nimport { runAllChecks } from \"./run-checks.ts\";\n\nconst DATA_FIRST_ARITY = 2;\n\n/** @internal */\nexport const runVpa: {\n (args: readonly string[]): (root: string) => CommandEffect;\n (root: string, args: readonly string[]): CommandEffect;\n} = Fn.dual(DATA_FIRST_ARITY, (root: string, args: readonly string[]): CommandEffect =>\n pipe(\n args,\n Arr.match({\n onEmpty: () => runAllChecks(root),\n onNonEmpty: ([flag, ...rest]) =>\n pipe(\n Rec.get(HOOKS, flag),\n Option.match({ onNone: () => usage, onSome: (hook) => hook(root, rest) }),\n ),\n }),\n ),\n);\n"],"mappings":";;;AAUA,MAAa,SAGTA,SAAG,KAAK,IAAmB,MAAc,SAC3C,KACE,MACAC,MAAI,MAAM;CACR,eAAe,aAAa,IAAI;CAChC,aAAa,CAAC,MAAM,GAAG,UACrB,KACEC,OAAI,IAAI,OAAO,IAAI,GACnB,OAAO,MAAM;EAAE,cAAc;EAAO,SAAS,SAAS,KAAK,MAAM,IAAI;CAAE,CAAC,CAC1E;AACJ,CAAC,CACH,CACF"}
|
|
@@ -126,9 +126,9 @@ const withSection = Function.dual(2, (key, run) => (context) => pipe(Option.from
|
|
|
126
126
|
onSome: (section) => Effect.asSome(run(section, context))
|
|
127
127
|
})));
|
|
128
128
|
// src/shared/lib/git.ts
|
|
129
|
-
const DATA_FIRST_ARITY$
|
|
129
|
+
const DATA_FIRST_ARITY$6 = 2;
|
|
130
130
|
/** @internal */
|
|
131
|
-
const listGitFiles = Function.dual(DATA_FIRST_ARITY$
|
|
131
|
+
const listGitFiles = Function.dual(DATA_FIRST_ARITY$6, (root, pathspecs) => Effect.gen(function* list() {
|
|
132
132
|
const output = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).string(ChildProcess.make("git", [
|
|
133
133
|
"-c",
|
|
134
134
|
"core.quotePath=false",
|
|
@@ -142,7 +142,7 @@ const listGitFiles = Function.dual(DATA_FIRST_ARITY$7, (root, pathspecs) => Effe
|
|
|
142
142
|
return pipe(String$1.split(output, "\0"), Array.filter(String$1.isNonEmpty));
|
|
143
143
|
}));
|
|
144
144
|
/** @internal */
|
|
145
|
-
const listCommitMessages = Function.dual(DATA_FIRST_ARITY$
|
|
145
|
+
const listCommitMessages = Function.dual(DATA_FIRST_ARITY$6, (root, range) => Effect.gen(function* messages() {
|
|
146
146
|
const output = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).string(ChildProcess.make("git", [
|
|
147
147
|
"log",
|
|
148
148
|
"-z",
|
|
@@ -327,7 +327,7 @@ const textlintCheck = withSection("textlint", (config, { root }) => {
|
|
|
327
327
|
/** @internal */
|
|
328
328
|
const commitlintCheck = withSection("commitlint", (config, { root, range }) => listCommitMessages(root, range).pipe(Effect.flatMap((messages) => lintCommitMessages(config, root, messages))));
|
|
329
329
|
// src/features/scan-secrets/model/secret-checks.ts
|
|
330
|
-
const DATA_FIRST_ARITY$
|
|
330
|
+
const DATA_FIRST_ARITY$5 = 2;
|
|
331
331
|
const SUCCESS$1 = 0;
|
|
332
332
|
const RANGE = "..";
|
|
333
333
|
const HEAD = "HEAD";
|
|
@@ -378,7 +378,7 @@ const scan = (config, root, source) => Effect.gen(function* scanSource() {
|
|
|
378
378
|
/** @internal */
|
|
379
379
|
const h56mCheck = withSection("h56m", (config, { root, range }) => lacksHistory(root).pipe(Effect.flatMap((partial) => scan(config, root, sourceOf(partial, range)))));
|
|
380
380
|
/** @internal */
|
|
381
|
-
const scanStagedSecrets = Function.dual(DATA_FIRST_ARITY$
|
|
381
|
+
const scanStagedSecrets = Function.dual(DATA_FIRST_ARITY$5, (config, root) => scan(config, root, { type: "staged" }));
|
|
382
382
|
/** @internal */
|
|
383
383
|
const writeTo = Function.dual(2, (sink, text) => Effect.gen(function* write() {
|
|
384
384
|
const stdio = yield* Stdio.Stdio;
|
|
@@ -891,7 +891,7 @@ const syncCi = (root) => planned(root).pipe(Effect.flatMap(({ changes }) => Effe
|
|
|
891
891
|
})));
|
|
892
892
|
// package.json
|
|
893
893
|
var name = "@r_masseater/vite-plus-adopt";
|
|
894
|
-
var version = "0.
|
|
894
|
+
var version = "0.25.0";
|
|
895
895
|
// src/features/sync-ci/model/installed-version.ts
|
|
896
896
|
const RANGE_PREFIX = /^[\^~]/u;
|
|
897
897
|
const pnpm$1 = attempt("pnpm");
|
|
@@ -1458,7 +1458,7 @@ const unpackArchive = (target) => (bytes) => placeAtomically(target, (staging) =
|
|
|
1458
1458
|
}));
|
|
1459
1459
|
// src/features/install-tools/model/install-one.ts
|
|
1460
1460
|
const SHORT_HASH = 12;
|
|
1461
|
-
const DATA_FIRST_ARITY$
|
|
1461
|
+
const DATA_FIRST_ARITY$2 = 3;
|
|
1462
1462
|
const START = 0;
|
|
1463
1463
|
const SEPARATOR$1 = "/";
|
|
1464
1464
|
const directoryFor = (cache, { name, version, platform }, sha256) => Effect.gen(function* directory() {
|
|
@@ -1472,7 +1472,7 @@ const alreadyInstalled = (cache, planned, locked) => Effect.gen(function* lookup
|
|
|
1472
1472
|
return Option.liftPredicate(directory, () => present);
|
|
1473
1473
|
});
|
|
1474
1474
|
/** @internal */
|
|
1475
|
-
const installOne = Function.dual(DATA_FIRST_ARITY$
|
|
1475
|
+
const installOne = Function.dual(DATA_FIRST_ARITY$2, (cache, lock, planned) => Effect.gen(function* install() {
|
|
1476
1476
|
const locked = Record.get(lock, planned.url);
|
|
1477
1477
|
const cached = yield* alreadyInstalled(cache, planned, locked);
|
|
1478
1478
|
if (Option.isSome(cached)) return {
|
|
@@ -1527,7 +1527,7 @@ const writeLock = (root) => (lock) => Effect.gen(function* write() {
|
|
|
1527
1527
|
// src/features/install-tools/model/plan.ts
|
|
1528
1528
|
const SEPARATOR = "/";
|
|
1529
1529
|
const PLACEHOLDER = "{version}";
|
|
1530
|
-
const DATA_FIRST_ARITY$
|
|
1530
|
+
const DATA_FIRST_ARITY$1 = 2;
|
|
1531
1531
|
const withVersion = (version) => (template) => String$1.replaceAll(PLACEHOLDER, version)(template);
|
|
1532
1532
|
const defaultBase = (name) => Option.liftPredicate(`https://github.com/${name}/releases/download/v${PLACEHOLDER}`, () => String$1.includes(SEPARATOR)(name));
|
|
1533
1533
|
const binsOf = (name, bin) => Option.getOrElse(Option.fromNullishOr(bin), () => [pipe(String$1.split(SEPARATOR)(name), Array.last, Option.getOrElse(() => name))]);
|
|
@@ -1546,7 +1546,7 @@ const planOne = (platform) => ([name, source]) => {
|
|
|
1546
1546
|
});
|
|
1547
1547
|
};
|
|
1548
1548
|
/** @internal */
|
|
1549
|
-
const planTools = Function.dual(DATA_FIRST_ARITY$
|
|
1549
|
+
const planTools = Function.dual(DATA_FIRST_ARITY$1, (section, platform) => pipe(Record.toEntries(section), Effect.forEach(planOne(platform), { concurrency: 1 }), Effect.map(Array.getSomes)));
|
|
1550
1550
|
// src/features/install-tools/model/section.ts
|
|
1551
1551
|
const DISABLED = [
|
|
1552
1552
|
"false",
|
|
@@ -1622,24 +1622,30 @@ const USAGE = pipe([
|
|
|
1622
1622
|
], Array.join("\n"));
|
|
1623
1623
|
/** @internal */
|
|
1624
1624
|
const usage = Effect.fail(checksFailed(USAGE));
|
|
1625
|
+
/** @internal */
|
|
1625
1626
|
const stagedSecrets = (root) => loadSection(root, "h56m").pipe(Effect.flatMap((config) => scanStagedSecrets(config, root)), Effect.flatMap(finish));
|
|
1626
|
-
const lintMessage = (toMessage) => (root
|
|
1627
|
+
const lintMessage = (toMessage) => (argument) => (root) => Effect.gen(function* lintGiven() {
|
|
1628
|
+
const message = yield* toMessage(argument);
|
|
1629
|
+
const config = yield* loadSection(root, "commitlint");
|
|
1630
|
+
const report = yield* lintCommitMessages(config, root, [message]);
|
|
1631
|
+
return yield* finish(report);
|
|
1632
|
+
});
|
|
1633
|
+
const readMessage = (file) => FileSystem.FileSystem.pipe(Effect.flatMap((fs) => fs.readFileString(file)));
|
|
1634
|
+
/** @internal */
|
|
1635
|
+
const lintMessageFile = lintMessage(readMessage);
|
|
1636
|
+
/** @internal */
|
|
1637
|
+
const lintMessageText = lintMessage(Effect.succeed);
|
|
1638
|
+
const withArgument = (hook) => (root, rest) => pipe(Array.head(rest), Option.match({
|
|
1627
1639
|
onNone: () => usage,
|
|
1628
|
-
onSome: (argument) =>
|
|
1629
|
-
const message = yield* toMessage(argument);
|
|
1630
|
-
const config = yield* loadSection(root, "commitlint");
|
|
1631
|
-
const report = yield* lintCommitMessages(config, root, [message]);
|
|
1632
|
-
return yield* finish(report);
|
|
1633
|
-
})
|
|
1640
|
+
onSome: (argument) => hook(argument)(root)
|
|
1634
1641
|
}));
|
|
1635
|
-
const readMessage = (file) => FileSystem.FileSystem.pipe(Effect.flatMap((fs) => fs.readFileString(file)));
|
|
1636
1642
|
/** @internal */
|
|
1637
1643
|
const HOOKS = {
|
|
1638
1644
|
ci: runCi,
|
|
1639
1645
|
"--prepare": prepare,
|
|
1640
1646
|
"--staged": stagedSecrets,
|
|
1641
|
-
"--commit-msg":
|
|
1642
|
-
"--message":
|
|
1647
|
+
"--commit-msg": withArgument(lintMessageFile),
|
|
1648
|
+
"--message": withArgument(lintMessageText),
|
|
1643
1649
|
"--pre-push": checkPushedRefs
|
|
1644
1650
|
};
|
|
1645
1651
|
// src/shared/lib/workspace.ts
|
|
@@ -1672,7 +1678,7 @@ const listDependencies = (root) => Effect.gen(function* list() {
|
|
|
1672
1678
|
return pipe(Array.sort(listed, byFile), Array.flatMap(({ dependencies }) => dependencies));
|
|
1673
1679
|
});
|
|
1674
1680
|
// src/features/check-repository/model/dependency-rules.ts
|
|
1675
|
-
const DATA_FIRST_ARITY
|
|
1681
|
+
const DATA_FIRST_ARITY = 2;
|
|
1676
1682
|
const SINGLE = 1;
|
|
1677
1683
|
const bannedBy = (dependencies) => ([reason, globs]) => {
|
|
1678
1684
|
const isBanned = (name) => pipe(globs, Array.some((glob) => minimatch(name, glob)));
|
|
@@ -1717,7 +1723,7 @@ const comparedDependencies = (rules, dependencies) => {
|
|
|
1717
1723
|
const isExact = inWorkspaces(exactGlobs(rules));
|
|
1718
1724
|
return pipe(dependencies, Array.filter(({ specifier }) => !String$1.startsWith("workspace:")(specifier)), Array.filter(Predicate.not(isExact)));
|
|
1719
1725
|
};
|
|
1720
|
-
const checkDependencies = Function.dual(DATA_FIRST_ARITY
|
|
1726
|
+
const checkDependencies = Function.dual(DATA_FIRST_ARITY, (rules, dependencies) => [
|
|
1721
1727
|
...bannedProblems(rules, dependencies),
|
|
1722
1728
|
...exactProblems(rules, dependencies),
|
|
1723
1729
|
...versionProblems(rules, comparedDependencies(rules, dependencies))
|
|
@@ -1883,14 +1889,6 @@ const runAllChecks = (root) => Effect.gen(function* all() {
|
|
|
1883
1889
|
onNonEmpty: (failed) => Effect.fail(checksFailed(`Failed: ${Array.join(failed, ", ")}`))
|
|
1884
1890
|
}));
|
|
1885
1891
|
});
|
|
1886
|
-
|
|
1887
|
-
const runVpa = Function.dual(2, (root, args) => pipe(args, Array.match({
|
|
1888
|
-
onEmpty: () => runAllChecks(root),
|
|
1889
|
-
onNonEmpty: ([flag, ...rest]) => pipe(Record.get(HOOKS, flag), Option.match({
|
|
1890
|
-
onNone: () => usage,
|
|
1891
|
-
onSome: (hook) => hook(root, rest)
|
|
1892
|
-
}))
|
|
1893
|
-
})));
|
|
1894
|
-
export { VpToolsError as i, findCiDrift as n, loadViteConfig as r, runVpa as t };
|
|
1892
|
+
export { stagedSecrets as a, runCi as c, checkPushedRefs as d, loadViteConfig as f, lintMessageText as i, version as l, HOOKS as n, usage as o, VpToolsError as p, lintMessageFile as r, prepare as s, runAllChecks as t, findCiDrift as u };
|
|
1895
1893
|
|
|
1896
|
-
//# sourceMappingURL=
|
|
1894
|
+
//# sourceMappingURL=run-checks-RwkrfT5c.mjs.map
|