@r_masseater/vite-plus-adopt 0.15.0 → 0.17.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/README.md +5 -0
- package/dist/cli.mjs +4 -15
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +13 -2
- package/dist/index.mjs +1 -1
- package/dist/{vpa-B16TImrg.mjs → vpa-mR96ZDOS.mjs} +450 -25
- package/dist/vpa-mR96ZDOS.mjs.map +1 -0
- package/package.json +4 -4
- package/dist/vpa-B16TImrg.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -42,6 +42,7 @@ export default defineConfig({
|
|
|
42
42
|
|
|
43
43
|
`import type {} from "@r_masseater/vite-plus-adopt"` types the keys vpa reads (`commitlint`, `dependencyRules`, `fallow`, `h56m`, `skills`, `textlint` and `tools`) on `defineConfig`.
|
|
44
44
|
textlint checks the Markdown files Git tracks. To check other files too, list their globs (`files`) and the settings for them in `textlint.sources`. `presets` work there as well.
|
|
45
|
+
`filterModules` takes textlint filter rules as modules, such as `{ comments: commentsFilter }`, and `filters: { comments: true }` turns one on, so the repository does not have to install them for textlint to find them. With `reportUnusedDirectives: true`, a `textlint-disable` comment that hides no message is an error. The check lints a file with a disable comment a second time without the filters.
|
|
45
46
|
|
|
46
47
|
Write the Git hooks like this.
|
|
47
48
|
|
|
@@ -120,6 +121,10 @@ export default defineConfig({
|
|
|
120
121
|
|
|
121
122
|
The Renovate preset updates `version` of each GitHub key and of `dotnet`. A new version has no entry in `vpa-lock.json` yet, so `vpa --prepare` records it.
|
|
122
123
|
|
|
124
|
+
## GitHub Actions caches
|
|
125
|
+
|
|
126
|
+
`vpa ci` puts the shared `setup` action of [typescript-template](https://github.com/masseater/typescript-template) into every job that runs `vp`, and removes what that action replaces: hand-written `actions/cache` steps for the pnpm store, the pnpm metadata, the vpa tools and msch, the `voidzero-dev/setup-vp` step and the `vp install --frozen-lockfile` step. Comments and formatting around the edited steps stay. It pins every template action and workflow to one commit, and calls `maintain-caches.yml` from `.github/workflows/cache.yml`, which saves the pnpm store on the default branch and deletes cache entries that it no longer needs. A local action in `.github/actions/` that wraps the shared one keeps its extra steps, and `vpa ci` forwards the inputs `cache`, `save` and `session-path` that it declares. Run it again after a new `vpa` version to move the pins. The library entry exports `findCiDrift(root)`, which lists the files `vpa ci` would change and the files whose template pins differ.
|
|
127
|
+
|
|
123
128
|
## Replacement for @arethetypeswrong/core
|
|
124
129
|
|
|
125
130
|
`@r_masseater/vite-plus-adopt/attw` provides the same API as [@arethetypeswrong/core][attw] 0.18.5, on TypeScript 7.1 alone.
|
package/dist/cli.mjs
CHANGED
|
@@ -1,22 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { t as runVpa } from "./vpa-mR96ZDOS.mjs";
|
|
3
|
+
import { Effect, Path, Stdio } from "effect";
|
|
4
|
+
import { runMain } from "@r_masseater/node-main";
|
|
5
5
|
// src/app/run-cli.ts
|
|
6
|
-
const reportFailure = (cause) => {
|
|
7
|
-
const message = pipe(Cause.findErrorOption(cause), Option.filter(Schema.is(VpToolsError)), Option.match({
|
|
8
|
-
onNone: () => Cause.pretty(cause),
|
|
9
|
-
onSome: (error) => error.message
|
|
10
|
-
}));
|
|
11
|
-
return writeTo("stderr", `${message}\n`);
|
|
12
|
-
};
|
|
13
6
|
/** @internal */
|
|
14
7
|
const runCli = (program) => {
|
|
15
|
-
|
|
16
|
-
serviceName: "vpa",
|
|
17
|
-
services: Layer.empty,
|
|
18
|
-
onFailure: reportFailure
|
|
19
|
-
})(program);
|
|
8
|
+
runMain("vpa")(program);
|
|
20
9
|
};
|
|
21
10
|
// src/app/cli.ts
|
|
22
11
|
runCli(Effect.gen(function* main() {
|
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 {
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":[],"sources":["../src/app/run-cli.ts","../src/app/cli.ts"],"sourcesContent":["import { runMain } from \"@r_masseater/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"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect, FileSystem, Path, PlatformError, Schema, Stdio } from "effect";
|
|
2
2
|
import { ChildProcessSpawner } from "effect/process";
|
|
3
3
|
import { TextlintRcConfig } from "@textlint/config-loader";
|
|
4
|
-
import { TextlintKernelRule } from "@textlint/kernel";
|
|
4
|
+
import { TextlintKernelFilterRule, TextlintKernelRule } from "@textlint/kernel";
|
|
5
5
|
import { H56mConfig } from "@r_masseater/h56m";
|
|
6
6
|
import { UserConfig } from "@commitlint/types";
|
|
7
7
|
declare const VpToolsError_base: Schema.Class<VpToolsError, Schema.TaggedStruct<"VpToolsError", {
|
|
@@ -41,6 +41,8 @@ interface TextlintSource extends TextlintRcConfig {
|
|
|
41
41
|
interface TextlintConfig extends TextlintRcConfig {
|
|
42
42
|
readonly ignores?: readonly string[];
|
|
43
43
|
readonly presets?: Readonly<Record<string, TextlintPreset>>;
|
|
44
|
+
readonly filterModules?: Readonly<Record<string, TextlintKernelFilterRule["rule"]>>;
|
|
45
|
+
readonly reportUnusedDirectives?: boolean;
|
|
44
46
|
readonly sources?: readonly TextlintSource[];
|
|
45
47
|
}
|
|
46
48
|
type FallowConfig = Readonly<Record<string, unknown>>;
|
|
@@ -83,5 +85,14 @@ export declare const runVpa: {
|
|
|
83
85
|
(args: readonly string[]): (root: string) => CommandEffect;
|
|
84
86
|
(root: string, args: readonly string[]): CommandEffect;
|
|
85
87
|
};
|
|
86
|
-
|
|
88
|
+
/** @internal */
|
|
89
|
+
interface CiDrift {
|
|
90
|
+
readonly file: string;
|
|
91
|
+
readonly reason: "setup" | "ref";
|
|
92
|
+
}
|
|
93
|
+
/** @internal */
|
|
94
|
+
type Services = FileSystem.FileSystem | Path.Path;
|
|
95
|
+
/** @internal */
|
|
96
|
+
export declare const findCiDrift: (root: string) => Effect.Effect<readonly CiDrift[], never, Services>;
|
|
97
|
+
export type { CiDrift, CommitlintConfig, DependencyRules, FallowConfig, SkillsSection, TextlintConfig, ToolSections };
|
|
87
98
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { i as VpToolsError, r as loadViteConfig, t as runVpa } from "./vpa-
|
|
1
|
+
export { i as VpToolsError, n as findCiDrift, r as loadViteConfig, t as runVpa } from "./vpa-mR96ZDOS.mjs";
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { n as toJson } from "./json-QtVKpodH.mjs";
|
|
2
|
-
import { Array, Boolean as Boolean$1, Config, Context, Effect, Exit, FileSystem, Function, Layer, Option, Order, Path, Predicate, Record, Redacted, Schedule, Schema, Stdio, Stream, String as String$1, pipe } from "effect";
|
|
2
|
+
import { Array, Boolean as Boolean$1, Config, Context, Effect, Exit, FileSystem, Function, Layer, Match, Number, Option, Order, Path, Predicate, Record, Redacted, Schedule, Schema, Stdio, Stream, String as String$1, pipe } from "effect";
|
|
3
3
|
import { resolveConfigFromFile } from "vite-plus";
|
|
4
4
|
import format from "@commitlint/format";
|
|
5
5
|
import lint from "@commitlint/lint";
|
|
6
6
|
import load from "@commitlint/load";
|
|
7
7
|
import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
8
|
+
import { createLinter, loadLinterFormatter } from "textlint";
|
|
8
9
|
import { loadPackagesFromRawConfig } from "@textlint/config-loader";
|
|
9
10
|
import { TextlintKernelDescriptor } from "@textlint/kernel";
|
|
10
|
-
import { createLinter, loadLinterFormatter } from "textlint";
|
|
11
11
|
import { loadBuiltinPlugins } from "textlint/lib/src/loader/TextlintrcLoader.js";
|
|
12
12
|
import { normalizeTextlintPresetSubRuleKey } from "@textlint/utils";
|
|
13
13
|
import { format as format$1, makeDetector } from "@r_masseater/h56m";
|
|
14
|
+
import { isMap, isPair, isScalar, isSeq, parse, parseDocument, visit } from "yaml";
|
|
14
15
|
import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/http";
|
|
15
16
|
import { minimatch } from "minimatch";
|
|
16
|
-
import { parse } from "yaml";
|
|
17
17
|
import { Tar } from "effect/encoding";
|
|
18
18
|
import { findWorkspaceProjectsNoCheck } from "@pnpm/workspace.projects-reader";
|
|
19
19
|
import { readWorkspaceManifest } from "@pnpm/workspace.workspace-manifest-reader";
|
|
@@ -143,44 +143,136 @@ const presetRulesOf = (config) => {
|
|
|
143
143
|
}));
|
|
144
144
|
};
|
|
145
145
|
/** @internal */
|
|
146
|
+
const filterRulesOf = ({ config, wrap }) => {
|
|
147
|
+
const settings = config.filters ?? {};
|
|
148
|
+
return pipe(Record.toEntries(config.filterModules ?? {}), Array.filter(([name]) => Boolean(settings[name])), Array.map(([name, rule]) => ({
|
|
149
|
+
ruleId: name,
|
|
150
|
+
rule: wrap(rule),
|
|
151
|
+
options: pipe(Record.get(settings, name), Option.filter(isRuleOptions), Option.getOrElse(() => true))
|
|
152
|
+
})));
|
|
153
|
+
};
|
|
154
|
+
/** @internal */
|
|
146
155
|
const rawConfigOf = (config) => {
|
|
147
|
-
const { ignores: _ignores, presets = {}, sources: _sources, ...rawConfig } = config;
|
|
156
|
+
const { ignores: _ignores, presets = {}, filterModules = {}, reportUnusedDirectives: _report, sources: _sources, ...rawConfig } = config;
|
|
148
157
|
return {
|
|
149
158
|
...rawConfig,
|
|
150
|
-
rules: pipe(rawConfig.rules ?? {}, Record.filter((_setting, name) => !Record.has(presets, name)))
|
|
159
|
+
rules: pipe(rawConfig.rules ?? {}, Record.filter((_setting, name) => !Record.has(presets, name))),
|
|
160
|
+
filters: pipe(rawConfig.filters ?? {}, Record.filter((_setting, name) => !Record.has(filterModules, name)))
|
|
151
161
|
};
|
|
152
162
|
};
|
|
153
|
-
// src/features/check-text/model/textlint.ts
|
|
154
|
-
|
|
155
|
-
const descriptorOf = (
|
|
156
|
-
|
|
163
|
+
// src/features/check-text/model/textlint-descriptor.ts
|
|
164
|
+
/** @internal */
|
|
165
|
+
const descriptorOf = ({ root, config, wrap }) => Effect.gen(function* descriptor() {
|
|
166
|
+
const path = yield* Path.Path;
|
|
167
|
+
const loaded = yield* attempt("textlint")(() => loadPackagesFromRawConfig({
|
|
168
|
+
rawConfig: rawConfigOf(config),
|
|
169
|
+
node_moduleDir: path.join(root, "node_modules")
|
|
170
|
+
}));
|
|
171
|
+
if (!loaded.ok) return yield* toolFailed("textlint")(loaded.error.message);
|
|
157
172
|
const { rules, filterRules, plugins } = loaded.config;
|
|
158
|
-
|
|
173
|
+
const builtIn = yield* attempt("textlint")(loadBuiltinPlugins);
|
|
174
|
+
return new TextlintKernelDescriptor({
|
|
159
175
|
rules: [...rules, ...presetRulesOf(config)],
|
|
160
|
-
filterRules,
|
|
176
|
+
filterRules: [...filterRules, ...filterRulesOf({
|
|
177
|
+
config,
|
|
178
|
+
wrap
|
|
179
|
+
})],
|
|
161
180
|
plugins: [...builtIn.plugin.toKernelPluginsFormat(), ...plugins],
|
|
162
181
|
configBaseDir: root
|
|
163
|
-
})
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
// src/features/check-text/model/unused-directives.ts
|
|
185
|
+
const WILDCARD = "*";
|
|
186
|
+
const FIRST$2 = 1;
|
|
187
|
+
const START$2 = 0;
|
|
188
|
+
const positionOf = (text, index) => {
|
|
189
|
+
const before = pipe(text, String$1.slice(START$2, index), String$1.split("\n"));
|
|
190
|
+
return {
|
|
191
|
+
line: before.length,
|
|
192
|
+
column: pipe(Array.last(before), Option.getOrElse(() => ""), String$1.length) + FIRST$2
|
|
193
|
+
};
|
|
164
194
|
};
|
|
195
|
+
const ruleIdOf = (optional) => Match.value(optional["ruleId"]).pipe(Match.when(Match.string, (ruleId) => ruleId), Match.orElse(() => WILDCARD));
|
|
196
|
+
const delegating = (context, shouldIgnore) => ({
|
|
197
|
+
id: context.id,
|
|
198
|
+
Syntax: context.Syntax,
|
|
199
|
+
severity: context.severity,
|
|
200
|
+
RuleError: context.RuleError,
|
|
201
|
+
locator: context.locator,
|
|
202
|
+
getFilePath: () => context.getFilePath(),
|
|
203
|
+
getSource: (...args) => context.getSource(...args),
|
|
204
|
+
getConfigBaseDir: () => context.getConfigBaseDir(),
|
|
205
|
+
shouldIgnore
|
|
206
|
+
});
|
|
207
|
+
const recording = () => {
|
|
208
|
+
const found = [];
|
|
209
|
+
return {
|
|
210
|
+
wrap: (reporter) => (context, options) => reporter(delegating(context, (range, optional) => {
|
|
211
|
+
const file = pipe(Option.fromNullishOr(context.getFilePath()), Option.getOrElse(() => ""));
|
|
212
|
+
found.push({
|
|
213
|
+
file,
|
|
214
|
+
range,
|
|
215
|
+
ruleId: ruleIdOf(optional),
|
|
216
|
+
...positionOf(context.getSource(), range[START$2])
|
|
217
|
+
});
|
|
218
|
+
context.shouldIgnore(range, optional);
|
|
219
|
+
}), options),
|
|
220
|
+
ignored: () => found
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
const suppresses = (ignored, message) => {
|
|
224
|
+
const [start, end] = ignored.range;
|
|
225
|
+
const [from, to] = message.range;
|
|
226
|
+
return start <= from && to <= end && (ignored.ruleId === WILDCARD || ignored.ruleId === message.ruleId);
|
|
227
|
+
};
|
|
228
|
+
const unusedMessage = (ignored) => Match.value(ignored.ruleId).pipe(Match.when(WILDCARD, () => "This textlint-disable comment hides no message."), Match.orElse((ruleId) => `This textlint-disable comment hides no message of ${ruleId}.`));
|
|
229
|
+
const unusedIn = ({ unfiltered, ignored }) => pipe(ignored, Array.filter((entry) => !pipe(unfiltered, Array.filter((result) => result.filePath === entry.file), Array.flatMap((result) => result.messages), Array.some((message) => suppresses(entry, message)))), Array.map(({ file, line, column, ...entry }) => ({
|
|
230
|
+
file,
|
|
231
|
+
line,
|
|
232
|
+
column,
|
|
233
|
+
message: unusedMessage({
|
|
234
|
+
file,
|
|
235
|
+
line,
|
|
236
|
+
column,
|
|
237
|
+
...entry
|
|
238
|
+
})
|
|
239
|
+
})));
|
|
240
|
+
const filesWithDirectives = (ignored) => pipe(ignored, Array.map(({ file }) => file), Array.dedupe);
|
|
241
|
+
const formatUnused = (unused) => pipe(unused, Array.map(({ file, line, column, message }) => `${file}\n ${String(line)}:${String(column)} error ${message} unused-directive`), Array.join("\n\n"));
|
|
242
|
+
// src/features/check-text/model/textlint.ts
|
|
243
|
+
const DATA_FIRST_ARITY_3 = 3;
|
|
244
|
+
const unusedOf = (config, descriptor, recorder) => {
|
|
245
|
+
const ignored = recorder.ignored();
|
|
246
|
+
if (config.reportUnusedDirectives !== true || Array.isReadonlyArrayEmpty(ignored)) return Effect.succeed([]);
|
|
247
|
+
const bare = descriptor.shallowMerge({ filterRules: [] });
|
|
248
|
+
return attempt("textlint")(() => createLinter({ descriptor: bare }).lintFiles([...filesWithDirectives(ignored)])).pipe(Effect.map((unfiltered) => unusedIn({
|
|
249
|
+
unfiltered,
|
|
250
|
+
ignored
|
|
251
|
+
})));
|
|
252
|
+
};
|
|
253
|
+
const wrapperOf = (config, recorder) => pipe(Option.liftPredicate(recorder.wrap, () => config.reportUnusedDirectives === true), Option.getOrElse(() => Function.identity));
|
|
254
|
+
const reportOf = (formatted, results, unused) => ({
|
|
255
|
+
valid: Array.isReadonlyArrayEmpty(unused) && pipe(results, Array.every((result) => Array.isArrayEmpty(result.messages))),
|
|
256
|
+
output: pipe([formatted, formatUnused(unused)], Array.filter(String$1.isNonEmpty), Array.join("\n"))
|
|
257
|
+
});
|
|
165
258
|
/** @internal */
|
|
166
259
|
const lintTexts = Function.dual(DATA_FIRST_ARITY_3, (config, root, files) => Effect.gen(function* lint() {
|
|
167
260
|
const path = yield* Path.Path;
|
|
168
261
|
yield* attempt("textlint")(() => import("vite-plus/register"));
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
262
|
+
const recorder = recording();
|
|
263
|
+
const descriptor = yield* descriptorOf({
|
|
264
|
+
root,
|
|
265
|
+
config,
|
|
266
|
+
wrap: wrapperOf(config, recorder)
|
|
267
|
+
});
|
|
174
268
|
const absolute = pipe(files, Array.map((file) => path.join(root, file)));
|
|
175
269
|
const results = yield* attempt("textlint")(() => createLinter({ descriptor }).lintFiles([...absolute]));
|
|
270
|
+
const unused = yield* unusedOf(config, descriptor, recorder);
|
|
176
271
|
const formatter = yield* attempt("textlint")(() => loadLinterFormatter({
|
|
177
272
|
formatterName: "stylish",
|
|
178
273
|
color: false
|
|
179
274
|
}));
|
|
180
|
-
return
|
|
181
|
-
valid: pipe(results, Array.every((result) => Array.isArrayEmpty(result.messages))),
|
|
182
|
-
output: formatter.format(results)
|
|
183
|
-
};
|
|
275
|
+
return reportOf(formatter.format(results), results, unused);
|
|
184
276
|
}));
|
|
185
277
|
// src/features/check-text/model/text-checks.ts
|
|
186
278
|
const MARKDOWN = "*.md";
|
|
@@ -194,10 +286,12 @@ const mergeReports = (reports) => ({
|
|
|
194
286
|
/** @internal */
|
|
195
287
|
const textlintCheck = withSection("textlint", (config, { root }) => {
|
|
196
288
|
const markdown = markdownFiles(root, config.ignores).pipe(Effect.flatMap((files) => lintTexts(config, root, files)));
|
|
197
|
-
const presets =
|
|
289
|
+
const { presets = {}, filterModules = {}, reportUnusedDirectives = false } = config;
|
|
198
290
|
const sources = pipe(config.sources ?? [], Array.map(({ files, ...source }) => Effect.flatMap(sourceFiles(root, files), (listed) => lintTexts({
|
|
199
291
|
...source,
|
|
200
|
-
presets
|
|
292
|
+
presets,
|
|
293
|
+
filterModules,
|
|
294
|
+
reportUnusedDirectives
|
|
201
295
|
}, root, listed))));
|
|
202
296
|
return Effect.all([markdown, ...sources], { concurrency: 1 }).pipe(Effect.map(mergeReports));
|
|
203
297
|
});
|
|
@@ -267,6 +361,335 @@ const finish = (report) => {
|
|
|
267
361
|
if (report.output === "") return Effect.void;
|
|
268
362
|
return writeTo("stdout", `${report.output}\n`);
|
|
269
363
|
};
|
|
364
|
+
// src/features/sync-ci/model/template.ts
|
|
365
|
+
const TEMPLATE_REF = "a841e00930f7f6c21b8eb7249a429f1c16f53356";
|
|
366
|
+
const TEMPLATE = "masseater/typescript-template/.github";
|
|
367
|
+
const SETUP_ACTION = `${TEMPLATE}/actions/setup`;
|
|
368
|
+
const MAINTAIN_WORKFLOW = `${TEMPLATE}/workflows/maintain-caches.yml`;
|
|
369
|
+
const TEMPLATE_USE = new RegExp(String.raw`^${TEMPLATE}/(?:actions|workflows)/[^@]+@`, "u");
|
|
370
|
+
const pinned = (path) => `${path}@${TEMPLATE_REF}`;
|
|
371
|
+
const CACHE_WORKFLOW = "cache.yml";
|
|
372
|
+
const DEFAULT_BRANCH_ONLY = "github.ref == format('refs/heads/{0}', github.event.repository.default_branch)";
|
|
373
|
+
const REGISTRY_ACCESS = `\${{ secrets.TAKUMI_GUARD_TOKEN }}`;
|
|
374
|
+
const CACHE_WORKFLOW_SOURCE = Array.join([
|
|
375
|
+
"name: cache",
|
|
376
|
+
"",
|
|
377
|
+
"on:",
|
|
378
|
+
" schedule:",
|
|
379
|
+
" - cron: \"47 * * * *\"",
|
|
380
|
+
" workflow_dispatch:",
|
|
381
|
+
"",
|
|
382
|
+
"permissions: {}",
|
|
383
|
+
"",
|
|
384
|
+
"jobs:",
|
|
385
|
+
" caches:",
|
|
386
|
+
` if: ${DEFAULT_BRANCH_ONLY}`,
|
|
387
|
+
" permissions:",
|
|
388
|
+
" actions: write",
|
|
389
|
+
" contents: read",
|
|
390
|
+
` uses: ${pinned(MAINTAIN_WORKFLOW)}`,
|
|
391
|
+
" secrets:",
|
|
392
|
+
` TAKUMI_GUARD_TOKEN: ${REGISTRY_ACCESS}`,
|
|
393
|
+
""
|
|
394
|
+
], "\n");
|
|
395
|
+
const PINNED_USE = new RegExp(String.raw`(?<use>${TEMPLATE}/(?:actions|workflows)/[^@\s]+)@(?<ref>[0-9a-f]{40})`, "gu");
|
|
396
|
+
const refsIn = (source) => pipe(source, String$1.matchAll(PINNED_USE), Array.fromIterable, Array.flatMap(({ groups }) => pipe(Option.fromNullishOr(groups), Option.flatMap(Record.get("ref")), Option.toArray)));
|
|
397
|
+
const withoutRefs = (source) => pipe(source, String$1.replaceAll(PINNED_USE, "$<use>"));
|
|
398
|
+
// src/features/sync-ci/model/yaml-nodes.ts
|
|
399
|
+
const EMPTY = "";
|
|
400
|
+
const ByStartDescending = Order.mapInput(Order.flip(Number.Order), ({ start }) => start);
|
|
401
|
+
const NEWLINE = "\n";
|
|
402
|
+
const FIRST$1 = 0;
|
|
403
|
+
const NEXT$1 = 1;
|
|
404
|
+
const RANGE_END = 2;
|
|
405
|
+
/** @internal */
|
|
406
|
+
const scalarText = (node) => pipe(Option.liftPredicate(node, isScalar), Option.map(({ value }) => value), Option.filter(Predicate.isString), Option.getOrElse(() => EMPTY));
|
|
407
|
+
/** @internal */
|
|
408
|
+
const fieldOf = (key) => (node) => pipe(Option.liftPredicate(node, isMap), Option.map((map) => scalarText(map.get(key, true))), Option.getOrElse(() => EMPTY));
|
|
409
|
+
/** @internal */
|
|
410
|
+
const usesOf = fieldOf("uses");
|
|
411
|
+
/** @internal */
|
|
412
|
+
const lineStart = ({ source, offset }) => pipe(source, String$1.slice(FIRST$1, offset), String$1.lastIndexOf(NEWLINE), Option.map((index) => index + NEXT$1), Option.getOrElse(() => FIRST$1));
|
|
413
|
+
/** @internal */
|
|
414
|
+
const startOf = (node) => pipe(Option.liftPredicate(node, isMap), Option.flatMapNullishOr(({ range }) => range), Option.map(([start]) => start));
|
|
415
|
+
/** @internal */
|
|
416
|
+
const endOf = (node) => pipe(Option.liftPredicate(node, isMap), Option.flatMapNullishOr(({ range }) => range), Option.map((range) => range[RANGE_END]));
|
|
417
|
+
const insertAt = (text) => ({ start, end, text: insert }) => pipe(text, String$1.slice(FIRST$1, start)) + insert + pipe(text, String$1.slice(end));
|
|
418
|
+
/** @internal */
|
|
419
|
+
const applyEdits = ({ source, edits }) => pipe(Array.sort(edits, ByStartDescending), Array.match({
|
|
420
|
+
onEmpty: () => source,
|
|
421
|
+
onNonEmpty: ([edit, ...rest]) => applyEdits({
|
|
422
|
+
source: insertAt(source)(edit),
|
|
423
|
+
edits: rest
|
|
424
|
+
})
|
|
425
|
+
}));
|
|
426
|
+
/** @internal */
|
|
427
|
+
const itemsOf = (node) => pipe(Option.liftPredicate(node, isSeq), Option.map(({ items }) => items), Option.getOrElse(() => []));
|
|
428
|
+
// src/features/sync-ci/model/cache-workflow.ts
|
|
429
|
+
const INDENT$1 = " ";
|
|
430
|
+
const CALL = "caches";
|
|
431
|
+
const jobText = (jobs) => pipe([
|
|
432
|
+
"",
|
|
433
|
+
`${INDENT$1}${CALL}:`,
|
|
434
|
+
`${INDENT$1}${INDENT$1}needs: [${pipe(jobs, Array.join(", "))}]`,
|
|
435
|
+
`${INDENT$1}${INDENT$1}if: always() && ${DEFAULT_BRANCH_ONLY}`,
|
|
436
|
+
`${INDENT$1}${INDENT$1}permissions:`,
|
|
437
|
+
`${INDENT$1}${INDENT$1}${INDENT$1}actions: write`,
|
|
438
|
+
`${INDENT$1}${INDENT$1}${INDENT$1}contents: read`,
|
|
439
|
+
`${INDENT$1}${INDENT$1}uses: ${pinned(MAINTAIN_WORKFLOW)}`,
|
|
440
|
+
`${INDENT$1}${INDENT$1}secrets:`,
|
|
441
|
+
`${INDENT$1}${INDENT$1}${INDENT$1}TAKUMI_GUARD_TOKEN: ${REGISTRY_ACCESS}`
|
|
442
|
+
], Array.map((line) => `${line}\n`), Array.join(""));
|
|
443
|
+
/** @internal */
|
|
444
|
+
const addMaintainJob = ({ source, jobs, telemetryNeeds }) => pipe(Option.liftPredicate(parseDocument(source).get("jobs", true), isMap), Option.flatMap(endOf), Option.match({
|
|
445
|
+
onNone: () => source,
|
|
446
|
+
onSome: (at) => applyEdits({
|
|
447
|
+
source,
|
|
448
|
+
edits: [{
|
|
449
|
+
start: at,
|
|
450
|
+
end: at,
|
|
451
|
+
text: jobText(jobs)
|
|
452
|
+
}, ...pipe(telemetryNeeds, Array.map((start) => ({
|
|
453
|
+
start,
|
|
454
|
+
end: start,
|
|
455
|
+
text: `, ${CALL}`
|
|
456
|
+
})))]
|
|
457
|
+
})
|
|
458
|
+
}));
|
|
459
|
+
// src/features/sync-ci/model/rewrite-steps.ts
|
|
460
|
+
const CACHE_USE = /^actions\/cache(?:\/(?:restore|save))?@/u;
|
|
461
|
+
const SETUP_VP_USE = "voidzero-dev/setup-vp@";
|
|
462
|
+
const CHECKOUT_USE = "actions/checkout@";
|
|
463
|
+
const LOCAL_USE = /^(?:\$|\.)\/\.github\/actions\/(?<name>[^/@\s]+)$/u;
|
|
464
|
+
const MANAGED_PATH = /\.cache\/pnpm|vpa\/tools|\.cache\/msch|store-path/u;
|
|
465
|
+
const MANAGED_RUN = /npm\.flatt\.tech|vp install --frozen-lockfile|pnpm store (?:path|prune)|\.cache\/pnpm\/v/u;
|
|
466
|
+
const VP_COMMAND = /(?:^|[\s;&|(])vpx?\s/u;
|
|
467
|
+
const FORWARDED_INPUTS = [
|
|
468
|
+
"cache",
|
|
469
|
+
"save",
|
|
470
|
+
"session-path"
|
|
471
|
+
];
|
|
472
|
+
const INDENT = " ";
|
|
473
|
+
const FIRST = 0;
|
|
474
|
+
const runOf = fieldOf("run");
|
|
475
|
+
const pathOf = (step) => pipe(Option.liftPredicate(step, isMap), Option.map((map) => scalarText(map.getIn(["with", "path"], true))), Option.getOrElse(() => ""));
|
|
476
|
+
const isManaged = (step) => pipe(usesOf(step), String$1.startsWith(SETUP_VP_USE)) || CACHE_USE.test(usesOf(step)) && MANAGED_PATH.test(pathOf(step)) || MANAGED_RUN.test(runOf(step));
|
|
477
|
+
const localAction = (step) => pipe(LOCAL_USE.exec(usesOf(step)), Option.fromNullishOr, Option.flatMapNullishOr(({ groups }) => groups), Option.flatMap(Record.get("name")));
|
|
478
|
+
const isSetup = (localSetups) => (step) => pipe(usesOf(step), String$1.startsWith(`masseater/typescript-template/.github/actions/setup@`)) || pipe(localAction(step), Option.exists((name) => localSetups.has(name)));
|
|
479
|
+
const runsVp = (step) => pipe(usesOf(step), String$1.startsWith(`masseater/typescript-template/.github/actions/verify@`)) || VP_COMMAND.test(runOf(step));
|
|
480
|
+
const forwardedLines = (inputs, pad) => pipe(FORWARDED_INPUTS, Array.filter((name) => pipe(inputs, Array.contains(name))), Array.map((name) => `${pad}${INDENT}${name}: \${{ inputs.${name} }}`), Array.match({
|
|
481
|
+
onEmpty: () => [],
|
|
482
|
+
onNonEmpty: (lines) => [`${pad}with:`, ...lines]
|
|
483
|
+
}));
|
|
484
|
+
const prefixOf = (source, step) => pipe(startOf(step), Option.map((start) => pipe(source, String$1.slice(lineStart({
|
|
485
|
+
source,
|
|
486
|
+
offset: start
|
|
487
|
+
}), start))), Option.getOrElse(() => ""));
|
|
488
|
+
const setupText = ({ source, inputs }, sample) => {
|
|
489
|
+
const prefix = prefixOf(source, sample);
|
|
490
|
+
const pad = pipe(" ", String$1.repeat(prefix.length));
|
|
491
|
+
return pipe([`${prefix}uses: ${pinned(SETUP_ACTION)}`, ...forwardedLines(inputs, pad)], Array.map((line) => `${line}\n`), Array.join(""));
|
|
492
|
+
};
|
|
493
|
+
const removal = (source, step) => Option.zipWith(startOf(step), endOf(step), (start, end) => ({
|
|
494
|
+
start: lineStart({
|
|
495
|
+
source,
|
|
496
|
+
offset: start
|
|
497
|
+
}),
|
|
498
|
+
end,
|
|
499
|
+
text: ""
|
|
500
|
+
}));
|
|
501
|
+
const replacement = (rewrite, step) => Option.map(removal(rewrite.source, step), (edit) => ({
|
|
502
|
+
...edit,
|
|
503
|
+
text: setupText(rewrite, step)
|
|
504
|
+
}));
|
|
505
|
+
const insertion = (rewrite, items) => {
|
|
506
|
+
const offset = pipe(items, Array.findFirst((step) => pipe(usesOf(step), String$1.startsWith(CHECKOUT_USE))), Option.flatMap(endOf), Option.orElse(() => pipe(Array.head(items), Option.flatMap(startOf), Option.map((start) => lineStart({
|
|
507
|
+
source: rewrite.source,
|
|
508
|
+
offset: start
|
|
509
|
+
})))));
|
|
510
|
+
return Option.zipWith(offset, Array.head(items), (at, head) => ({
|
|
511
|
+
start: at,
|
|
512
|
+
end: at,
|
|
513
|
+
text: setupText(rewrite, head)
|
|
514
|
+
}));
|
|
515
|
+
};
|
|
516
|
+
const managedEdits = (rewrite, items) => {
|
|
517
|
+
const hasSetup = pipe(items, Array.some(isSetup(rewrite.localSetups)));
|
|
518
|
+
return pipe(items, Array.filter(isManaged), Array.map((step, index) => {
|
|
519
|
+
if (index === FIRST && !hasSetup) return replacement(rewrite, step);
|
|
520
|
+
return removal(rewrite.source, step);
|
|
521
|
+
}), Array.getSomes);
|
|
522
|
+
};
|
|
523
|
+
/** @internal */
|
|
524
|
+
const stepEdits = (rewrite) => {
|
|
525
|
+
if (!isSeq(rewrite.steps)) return [];
|
|
526
|
+
const items = rewrite.steps.items;
|
|
527
|
+
if (pipe(items, Array.some(isManaged))) return managedEdits(rewrite, items);
|
|
528
|
+
const needsSetup = pipe(items, Array.some(runsVp));
|
|
529
|
+
const hasSetup = pipe(items, Array.some(isSetup(rewrite.localSetups)));
|
|
530
|
+
if (needsSetup && !hasSetup) return pipe(insertion(rewrite, items), Option.toArray);
|
|
531
|
+
return [];
|
|
532
|
+
};
|
|
533
|
+
// src/features/sync-ci/model/rewrite-document.ts
|
|
534
|
+
const AFTER_REF = /@.*$/u;
|
|
535
|
+
const CLOSING_BRACKET = 1;
|
|
536
|
+
const TELEMETRY_USE = /\/actions\/ci-telemetry@/u;
|
|
537
|
+
const pinEdits = (document, source) => {
|
|
538
|
+
const found = [];
|
|
539
|
+
visit(document, { Pair: (_key, pair) => {
|
|
540
|
+
if (isPair(pair) && scalarText(pair.key) === "uses" && isScalar(pair.value) && TEMPLATE_USE.test(scalarText(pair.value))) pipe(Option.fromNullishOr(pair.value.range), Option.map(([start, end]) => ({
|
|
541
|
+
start,
|
|
542
|
+
end,
|
|
543
|
+
text: pipe(source, String$1.slice(start, end), String$1.replace(AFTER_REF, `@${TEMPLATE_REF}`))
|
|
544
|
+
})), Option.map((edit) => found.push(edit)));
|
|
545
|
+
} });
|
|
546
|
+
return found;
|
|
547
|
+
};
|
|
548
|
+
const tableAt = (document, path) => pipe(Option.liftPredicate(document.getIn(path, true), isMap), Option.map(({ items }) => pipe(items, Array.map(({ key, value }) => [scalarText(key), value]))), Option.getOrElse(() => []));
|
|
549
|
+
const jobsOf = (document) => pipe(tableAt(document, ["jobs"]), Array.map(([, job]) => job), Array.filter(isMap));
|
|
550
|
+
const stepsOf = (job) => pipe(Option.liftPredicate(job, isMap), Option.map((map) => itemsOf(map.get("steps", true))), Option.getOrElse(() => []));
|
|
551
|
+
const actionSteps = (document) => {
|
|
552
|
+
const steps = document.getIn(["runs", "steps"], true);
|
|
553
|
+
return itemsOf(steps);
|
|
554
|
+
};
|
|
555
|
+
const allSteps = (document) => pipe(jobsOf(document), Array.flatMap(stepsOf), Array.appendAll(actionSteps(document)));
|
|
556
|
+
const includesSetup = (document) => pipe(allSteps(document), Array.some((step) => pipe(usesOf(step), String$1.startsWith(`${SETUP_ACTION}@`))));
|
|
557
|
+
const callsMaintain = (document) => pipe(jobsOf(document), Array.some((job) => pipe(usesOf(job), String$1.startsWith(`${MAINTAIN_WORKFLOW}@`))));
|
|
558
|
+
const reportsTelemetry = (job) => pipe(stepsOf(job), Array.some((step) => TELEMETRY_USE.test(usesOf(step))));
|
|
559
|
+
const telemetryNeedsAt = (document) => pipe(jobsOf(document), Array.filter(reportsTelemetry), Array.flatMap((job) => pipe(Option.liftPredicate(job.getIn(["needs"], true), isSeq), Option.filter(({ flow }) => flow === true), Option.flatMap(({ range }) => Option.fromNullishOr(range)), Option.map(([, valueEnd]) => valueEnd - CLOSING_BRACKET), Option.toArray)));
|
|
560
|
+
const inputNames = (document) => pipe(tableAt(document, ["inputs"]), Array.map(([name]) => name));
|
|
561
|
+
/** @internal */
|
|
562
|
+
const rewriteDocument = ({ source, localSetups }) => {
|
|
563
|
+
const document = parseDocument(source);
|
|
564
|
+
const inputs = inputNames(document);
|
|
565
|
+
const edits = pipe([...pipe(jobsOf(document), Array.map((job) => job.get("steps", true))), document.getIn(["runs", "steps"], true)], Array.flatMap((steps) => stepEdits({
|
|
566
|
+
steps,
|
|
567
|
+
source,
|
|
568
|
+
localSetups,
|
|
569
|
+
inputs
|
|
570
|
+
})), Array.appendAll(pinEdits(document, source)));
|
|
571
|
+
const rewritten = applyEdits({
|
|
572
|
+
source,
|
|
573
|
+
edits
|
|
574
|
+
});
|
|
575
|
+
const result = parseDocument(rewritten);
|
|
576
|
+
return {
|
|
577
|
+
source: rewritten,
|
|
578
|
+
includesSetup: includesSetup(result),
|
|
579
|
+
callsMaintain: callsMaintain(result),
|
|
580
|
+
telemetryNeeds: telemetryNeedsAt(result),
|
|
581
|
+
jobs: pipe(tableAt(result, ["jobs"]), Array.filter(([, job]) => !reportsTelemetry(job)), Array.map(([name]) => name))
|
|
582
|
+
};
|
|
583
|
+
};
|
|
584
|
+
// src/features/sync-ci/model/sync-ci.ts
|
|
585
|
+
const WORKFLOWS = ".github/workflows";
|
|
586
|
+
const ACTIONS = ".github/actions";
|
|
587
|
+
const YAML_FILE = /\.ya?ml$/u;
|
|
588
|
+
const ACTION_FILES = ["action.yml", "action.yaml"];
|
|
589
|
+
const SEQUENTIAL = { concurrency: 1 };
|
|
590
|
+
const SINGLE_REF = 1;
|
|
591
|
+
const entriesOf = (directory) => FileSystem.FileSystem.pipe(Effect.flatMap((fs) => fs.readDirectory(directory)), Effect.map((entries) => Array.sort(entries, String$1.Order)), Effect.orElseSucceed(() => []));
|
|
592
|
+
const readSource = (file, name) => FileSystem.FileSystem.pipe(Effect.flatMap((fs) => fs.readFileString(file)), Effect.map((source) => ({
|
|
593
|
+
file,
|
|
594
|
+
name,
|
|
595
|
+
source
|
|
596
|
+
})), Effect.orDie);
|
|
597
|
+
const workflowSources = (root) => Effect.gen(function* readWorkflows() {
|
|
598
|
+
const path = yield* Path.Path;
|
|
599
|
+
const directory = path.join(root, WORKFLOWS);
|
|
600
|
+
const entries = yield* entriesOf(directory);
|
|
601
|
+
return yield* Effect.forEach(pipe(entries, Array.filter((entry) => YAML_FILE.test(entry))), (entry) => readSource(path.join(directory, entry), entry), SEQUENTIAL);
|
|
602
|
+
});
|
|
603
|
+
const actionFile = (directory, name) => Effect.gen(function* findActionFile() {
|
|
604
|
+
const fs = yield* FileSystem.FileSystem;
|
|
605
|
+
const path = yield* Path.Path;
|
|
606
|
+
const found = yield* Effect.findFirst(pipe(ACTION_FILES, Array.map((file) => path.join(directory, name, file))), (candidate) => fs.exists(candidate).pipe(Effect.orElseSucceed(() => false)));
|
|
607
|
+
return yield* Option.match(found, {
|
|
608
|
+
onNone: () => Effect.succeedNone,
|
|
609
|
+
onSome: (file) => readSource(file, name).pipe(Effect.asSome)
|
|
610
|
+
});
|
|
611
|
+
});
|
|
612
|
+
const actionSources = (root) => Effect.gen(function* readActions() {
|
|
613
|
+
const directory = (yield* Path.Path).join(root, ACTIONS);
|
|
614
|
+
const names = yield* entriesOf(directory);
|
|
615
|
+
const found = yield* Effect.forEach(names, (name) => actionFile(directory, name), SEQUENTIAL);
|
|
616
|
+
return Array.getSomes(found);
|
|
617
|
+
});
|
|
618
|
+
const settle = (actions, known) => {
|
|
619
|
+
const next = new Set(pipe(actions, Array.filter(({ source }) => rewriteDocument({
|
|
620
|
+
source,
|
|
621
|
+
localSetups: known
|
|
622
|
+
}).includesSetup), Array.map(({ name }) => name)));
|
|
623
|
+
if (next.size === known.size) return known;
|
|
624
|
+
return settle(actions, next);
|
|
625
|
+
};
|
|
626
|
+
const rewriteAll = (sources, localSetups) => pipe(sources, Array.map((found) => ({
|
|
627
|
+
...found,
|
|
628
|
+
rewritten: rewriteDocument({
|
|
629
|
+
source: found.source,
|
|
630
|
+
localSetups
|
|
631
|
+
})
|
|
632
|
+
})));
|
|
633
|
+
const cacheWorkflow = (root, workflows) => Effect.gen(function* planCacheWorkflow() {
|
|
634
|
+
const path = yield* Path.Path;
|
|
635
|
+
if (pipe(workflows, Array.some(({ rewritten }) => rewritten.callsMaintain))) return [];
|
|
636
|
+
return [pipe(workflows, Array.findFirst(({ name }) => name === CACHE_WORKFLOW), Option.match({
|
|
637
|
+
onNone: () => ({
|
|
638
|
+
file: path.join(root, WORKFLOWS, CACHE_WORKFLOW),
|
|
639
|
+
previous: "",
|
|
640
|
+
source: CACHE_WORKFLOW_SOURCE
|
|
641
|
+
}),
|
|
642
|
+
onSome: ({ file, rewritten, source }) => ({
|
|
643
|
+
file,
|
|
644
|
+
previous: source,
|
|
645
|
+
source: addMaintainJob({
|
|
646
|
+
source: rewritten.source,
|
|
647
|
+
jobs: rewritten.jobs,
|
|
648
|
+
telemetryNeeds: rewritten.telemetryNeeds
|
|
649
|
+
})
|
|
650
|
+
})
|
|
651
|
+
}))];
|
|
652
|
+
});
|
|
653
|
+
const write = (root, { file, source }) => Effect.gen(function* writeChanged() {
|
|
654
|
+
const fs = yield* FileSystem.FileSystem;
|
|
655
|
+
const path = yield* Path.Path;
|
|
656
|
+
yield* fs.writeFileString(file, source);
|
|
657
|
+
yield* writeTo("stdout", `Updated ${path.relative(root, file)}\n`);
|
|
658
|
+
});
|
|
659
|
+
const planned = (root) => Effect.gen(function* plan() {
|
|
660
|
+
const workflows = yield* workflowSources(root);
|
|
661
|
+
const actions = yield* actionSources(root);
|
|
662
|
+
const localSetups = settle(actions, /* @__PURE__ */ new Set());
|
|
663
|
+
const rewrittenWorkflows = rewriteAll(workflows, localSetups);
|
|
664
|
+
const created = yield* cacheWorkflow(root, rewrittenWorkflows);
|
|
665
|
+
return {
|
|
666
|
+
changes: pipe([...rewriteAll(actions, localSetups), ...rewrittenWorkflows], Array.filter(({ rewritten, source }) => rewritten.source !== source), Array.map(({ file, rewritten, source }) => ({
|
|
667
|
+
file,
|
|
668
|
+
previous: source,
|
|
669
|
+
source: rewritten.source
|
|
670
|
+
})), Array.filter(({ file }) => !pipe(created, Array.some((change) => change.file === file))), Array.appendAll(created)),
|
|
671
|
+
sources: [...actions, ...workflows]
|
|
672
|
+
};
|
|
673
|
+
});
|
|
674
|
+
const refDrift = (sources) => {
|
|
675
|
+
const pinned = pipe(sources, Array.filter(({ source }) => !Array.isReadonlyArrayEmpty(refsIn(source))));
|
|
676
|
+
if (new Set(pipe(pinned, Array.flatMap(({ source }) => refsIn(source)))).size <= SINGLE_REF) return [];
|
|
677
|
+
return pipe(pinned, Array.map(({ file }) => ({
|
|
678
|
+
file,
|
|
679
|
+
reason: "ref"
|
|
680
|
+
})));
|
|
681
|
+
};
|
|
682
|
+
const setupDrift = (changes) => pipe(changes, Array.filter(({ previous, source }) => withoutRefs(previous) !== withoutRefs(source)), Array.map(({ file }) => ({
|
|
683
|
+
file,
|
|
684
|
+
reason: "setup"
|
|
685
|
+
})));
|
|
686
|
+
/** @internal */
|
|
687
|
+
const findCiDrift = (root) => planned(root).pipe(Effect.map(({ changes, sources }) => [...setupDrift(changes), ...refDrift(sources)]));
|
|
688
|
+
/** @internal */
|
|
689
|
+
const syncCi = (root) => planned(root).pipe(Effect.flatMap(({ changes }) => Effect.forEach(changes, (change) => write(root, change), {
|
|
690
|
+
...SEQUENTIAL,
|
|
691
|
+
discard: true
|
|
692
|
+
})));
|
|
270
693
|
// src/shared/config/skills.ts
|
|
271
694
|
const Repository = Schema.String.check(Schema.isPattern(/^[\w-][\w.-]*\/[\w.-]+$/u));
|
|
272
695
|
const LocalDirectory = Schema.String.check(Schema.isPattern(/^\.\/[\w.-]+(?:\/[\w.-]+)*$/u));
|
|
@@ -1218,6 +1641,7 @@ const runAllChecks = (root) => Effect.gen(function* all() {
|
|
|
1218
1641
|
const DATA_FIRST_ARITY = 2;
|
|
1219
1642
|
const USAGE = pipe([
|
|
1220
1643
|
"Usage: vpa run every check configured in vite.config.ts",
|
|
1644
|
+
" vpa ci put the shared setup action into every job and workflow that runs vp, and drop the hand-written Actions caches",
|
|
1221
1645
|
" vpa --prepare install the skills and tools in vite.config.ts (prepare)",
|
|
1222
1646
|
" vpa --staged scan the staged changes for secrets (pre-commit)",
|
|
1223
1647
|
" vpa --commit-msg <file> lint a commit message (commit-msg)",
|
|
@@ -1236,6 +1660,7 @@ const lintMessage = (toMessage) => (root, rest) => pipe(Array.head(rest), Option
|
|
|
1236
1660
|
}));
|
|
1237
1661
|
const readMessage = (file) => FileSystem.FileSystem.pipe(Effect.flatMap((fs) => fs.readFileString(file)));
|
|
1238
1662
|
const HOOKS = {
|
|
1663
|
+
ci: syncCi,
|
|
1239
1664
|
"--prepare": prepare,
|
|
1240
1665
|
"--staged": stagedSecrets,
|
|
1241
1666
|
"--commit-msg": lintMessage(readMessage),
|
|
@@ -1249,6 +1674,6 @@ const runVpa = Function.dual(DATA_FIRST_ARITY, (root, args) => pipe(args, Array.
|
|
|
1249
1674
|
onSome: (hook) => hook(root, rest)
|
|
1250
1675
|
}))
|
|
1251
1676
|
})));
|
|
1252
|
-
export { VpToolsError as i,
|
|
1677
|
+
export { VpToolsError as i, findCiDrift as n, loadViteConfig as r, runVpa as t };
|
|
1253
1678
|
|
|
1254
|
-
//# sourceMappingURL=vpa-
|
|
1679
|
+
//# sourceMappingURL=vpa-mR96ZDOS.mjs.map
|