@r_masseater/vite-plus-adopt 0.24.3 → 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 CHANGED
@@ -1,19 +1,24 @@
1
1
  #!/usr/bin/env node
2
- import { t as runVpa } from "./vpa-D_tLqq4j.mjs";
3
- import { Effect, Path, Stdio } from "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
- // src/app/run-cli.ts
6
- /** @internal */
7
- const runCli = (program) => {
8
- runMain("vpa")(program);
9
- };
6
+ import { Command } from "effect/cli";
10
7
  // src/app/cli.ts
11
- runCli(Effect.gen(function* main() {
12
- const stdio = yield* Stdio.Stdio;
13
- const path = yield* Path.Path;
14
- const args = yield* stdio.args;
15
- return yield* runVpa(path.resolve("."), args);
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/run-cli.ts","../src/app/cli.ts"],"sourcesContent":["import { runMain } from \"@r_masseater/masseater-utils/node-main\";\nimport type { Effect } from \"effect\";\n\nimport type { CommandServices } from \"#/shared/lib/command.ts\";\n\n/** @internal */\nexport const runCli = <Failure>(program: Effect.Effect<void, Failure, CommandServices>): void => {\n runMain(\"vpa\")(program);\n};\n","import { Effect, Path, Stdio } from \"effect\";\n\nimport { runCli } from \"./run-cli.ts\";\nimport { runVpa } from \"./vpa.ts\";\n\nrunCli(\n Effect.gen(function* main() {\n const stdio = yield* Stdio.Stdio;\n const path = yield* Path.Path;\n const args = yield* stdio.args;\n return yield* runVpa(path.resolve(\".\"), args);\n }),\n);\n"],"mappings":";;;;;;AAMA,MAAa,UAAmB,YAAiE;CAC/F,QAAQ,KAAK,CAAC,CAAC,OAAO;AACxB;;ACHA,OACE,OAAO,IAAI,UAAU,OAAO;CAC1B,MAAM,QAAQ,OAAO,MAAM;CAC3B,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,OAAO,OAAO,MAAM;CAC1B,OAAO,OAAO,OAAO,KAAK,QAAQ,GAAG,GAAG,IAAI;AAC9C,CAAC,CACH"}
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
- export { i as VpToolsError, n as findCiDrift, r as loadViteConfig, t as runVpa } from "./vpa-D_tLqq4j.mjs";
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$7 = 2;
129
+ const DATA_FIRST_ARITY$6 = 2;
130
130
  /** @internal */
131
- const listGitFiles = Function.dual(DATA_FIRST_ARITY$7, (root, pathspecs) => Effect.gen(function* list() {
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$7, (root, range) => Effect.gen(function* messages() {
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$6 = 2;
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$6, (config, root) => scan(config, root, { type: "staged" }));
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.24.3";
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");
@@ -1117,11 +1117,14 @@ const below = (directory) => (path) => pipe(Option.liftPredicate(path, () => Str
1117
1117
  // src/shared/lib/http.ts
1118
1118
  const RETRY_DELAY = "1 second";
1119
1119
  const RETRIES = 4;
1120
+ const EXPIRED_SIGNED_URL = 618;
1121
+ const signedUrlExpired = (error) => pipe(Option.fromUndefinedOr(error.response), Option.exists(({ status }) => status === EXPIRED_SIGNED_URL));
1120
1122
  /** @internal */
1121
1123
  const fetchBytes = (request) => Effect.gen(function* fetchArchive() {
1122
1124
  const body = yield* (yield* (yield* HttpClient.HttpClient).pipe(HttpClient.filterStatusOk, HttpClient.retryTransient({
1123
1125
  schedule: Schedule.exponential(RETRY_DELAY),
1124
- times: RETRIES
1126
+ times: RETRIES,
1127
+ while: signedUrlExpired
1125
1128
  })).execute(request)).arrayBuffer;
1126
1129
  return new Uint8Array(body);
1127
1130
  });
@@ -1455,7 +1458,7 @@ const unpackArchive = (target) => (bytes) => placeAtomically(target, (staging) =
1455
1458
  }));
1456
1459
  // src/features/install-tools/model/install-one.ts
1457
1460
  const SHORT_HASH = 12;
1458
- const DATA_FIRST_ARITY$3 = 3;
1461
+ const DATA_FIRST_ARITY$2 = 3;
1459
1462
  const START = 0;
1460
1463
  const SEPARATOR$1 = "/";
1461
1464
  const directoryFor = (cache, { name, version, platform }, sha256) => Effect.gen(function* directory() {
@@ -1469,7 +1472,7 @@ const alreadyInstalled = (cache, planned, locked) => Effect.gen(function* lookup
1469
1472
  return Option.liftPredicate(directory, () => present);
1470
1473
  });
1471
1474
  /** @internal */
1472
- const installOne = Function.dual(DATA_FIRST_ARITY$3, (cache, lock, planned) => Effect.gen(function* install() {
1475
+ const installOne = Function.dual(DATA_FIRST_ARITY$2, (cache, lock, planned) => Effect.gen(function* install() {
1473
1476
  const locked = Record.get(lock, planned.url);
1474
1477
  const cached = yield* alreadyInstalled(cache, planned, locked);
1475
1478
  if (Option.isSome(cached)) return {
@@ -1524,7 +1527,7 @@ const writeLock = (root) => (lock) => Effect.gen(function* write() {
1524
1527
  // src/features/install-tools/model/plan.ts
1525
1528
  const SEPARATOR = "/";
1526
1529
  const PLACEHOLDER = "{version}";
1527
- const DATA_FIRST_ARITY$2 = 2;
1530
+ const DATA_FIRST_ARITY$1 = 2;
1528
1531
  const withVersion = (version) => (template) => String$1.replaceAll(PLACEHOLDER, version)(template);
1529
1532
  const defaultBase = (name) => Option.liftPredicate(`https://github.com/${name}/releases/download/v${PLACEHOLDER}`, () => String$1.includes(SEPARATOR)(name));
1530
1533
  const binsOf = (name, bin) => Option.getOrElse(Option.fromNullishOr(bin), () => [pipe(String$1.split(SEPARATOR)(name), Array.last, Option.getOrElse(() => name))]);
@@ -1543,7 +1546,7 @@ const planOne = (platform) => ([name, source]) => {
1543
1546
  });
1544
1547
  };
1545
1548
  /** @internal */
1546
- const planTools = Function.dual(DATA_FIRST_ARITY$2, (section, platform) => pipe(Record.toEntries(section), Effect.forEach(planOne(platform), { concurrency: 1 }), Effect.map(Array.getSomes)));
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)));
1547
1550
  // src/features/install-tools/model/section.ts
1548
1551
  const DISABLED = [
1549
1552
  "false",
@@ -1619,24 +1622,30 @@ const USAGE = pipe([
1619
1622
  ], Array.join("\n"));
1620
1623
  /** @internal */
1621
1624
  const usage = Effect.fail(checksFailed(USAGE));
1625
+ /** @internal */
1622
1626
  const stagedSecrets = (root) => loadSection(root, "h56m").pipe(Effect.flatMap((config) => scanStagedSecrets(config, root)), Effect.flatMap(finish));
1623
- const lintMessage = (toMessage) => (root, rest) => pipe(Array.head(rest), Option.match({
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({
1624
1639
  onNone: () => usage,
1625
- onSome: (argument) => Effect.gen(function* lintGiven() {
1626
- const message = yield* toMessage(argument);
1627
- const config = yield* loadSection(root, "commitlint");
1628
- const report = yield* lintCommitMessages(config, root, [message]);
1629
- return yield* finish(report);
1630
- })
1640
+ onSome: (argument) => hook(argument)(root)
1631
1641
  }));
1632
- const readMessage = (file) => FileSystem.FileSystem.pipe(Effect.flatMap((fs) => fs.readFileString(file)));
1633
1642
  /** @internal */
1634
1643
  const HOOKS = {
1635
1644
  ci: runCi,
1636
1645
  "--prepare": prepare,
1637
1646
  "--staged": stagedSecrets,
1638
- "--commit-msg": lintMessage(readMessage),
1639
- "--message": lintMessage(Effect.succeed),
1647
+ "--commit-msg": withArgument(lintMessageFile),
1648
+ "--message": withArgument(lintMessageText),
1640
1649
  "--pre-push": checkPushedRefs
1641
1650
  };
1642
1651
  // src/shared/lib/workspace.ts
@@ -1669,7 +1678,7 @@ const listDependencies = (root) => Effect.gen(function* list() {
1669
1678
  return pipe(Array.sort(listed, byFile), Array.flatMap(({ dependencies }) => dependencies));
1670
1679
  });
1671
1680
  // src/features/check-repository/model/dependency-rules.ts
1672
- const DATA_FIRST_ARITY$1 = 2;
1681
+ const DATA_FIRST_ARITY = 2;
1673
1682
  const SINGLE = 1;
1674
1683
  const bannedBy = (dependencies) => ([reason, globs]) => {
1675
1684
  const isBanned = (name) => pipe(globs, Array.some((glob) => minimatch(name, glob)));
@@ -1714,7 +1723,7 @@ const comparedDependencies = (rules, dependencies) => {
1714
1723
  const isExact = inWorkspaces(exactGlobs(rules));
1715
1724
  return pipe(dependencies, Array.filter(({ specifier }) => !String$1.startsWith("workspace:")(specifier)), Array.filter(Predicate.not(isExact)));
1716
1725
  };
1717
- const checkDependencies = Function.dual(DATA_FIRST_ARITY$1, (rules, dependencies) => [
1726
+ const checkDependencies = Function.dual(DATA_FIRST_ARITY, (rules, dependencies) => [
1718
1727
  ...bannedProblems(rules, dependencies),
1719
1728
  ...exactProblems(rules, dependencies),
1720
1729
  ...versionProblems(rules, comparedDependencies(rules, dependencies))
@@ -1880,14 +1889,6 @@ const runAllChecks = (root) => Effect.gen(function* all() {
1880
1889
  onNonEmpty: (failed) => Effect.fail(checksFailed(`Failed: ${Array.join(failed, ", ")}`))
1881
1890
  }));
1882
1891
  });
1883
- /** @internal */
1884
- const runVpa = Function.dual(2, (root, args) => pipe(args, Array.match({
1885
- onEmpty: () => runAllChecks(root),
1886
- onNonEmpty: ([flag, ...rest]) => pipe(Record.get(HOOKS, flag), Option.match({
1887
- onNone: () => usage,
1888
- onSome: (hook) => hook(root, rest)
1889
- }))
1890
- })));
1891
- 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 };
1892
1893
 
1893
- //# sourceMappingURL=vpa-D_tLqq4j.mjs.map
1894
+ //# sourceMappingURL=run-checks-RwkrfT5c.mjs.map