@r_masseater/fu4 0.3.2 → 0.3.4
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/{source-CzBgefky.mjs → app-BkrdDFcT.mjs} +195 -380
- package/dist/app-BkrdDFcT.mjs.map +1 -0
- package/dist/cli-D-hr3xCD.mjs +114 -0
- package/dist/cli-D-hr3xCD.mjs.map +1 -0
- package/dist/cli.mjs +1 -1
- package/dist/index.mjs +2 -2
- package/dist/presets.mjs +1 -1
- package/dist/source-CLFOyvUG.mjs +258 -0
- package/dist/source-CLFOyvUG.mjs.map +1 -0
- package/package.json +23 -6
- package/dist/app-WhjBftlQ.mjs +0 -204
- package/dist/app-WhjBftlQ.mjs.map +0 -1
- package/dist/cli-DtDQ1hoa.mjs +0 -21
- package/dist/cli-DtDQ1hoa.mjs.map +0 -1
- package/dist/source-CzBgefky.mjs.map +0 -1
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { n as sourceOf, o as baseName, r as sourceView } from "./source-CLFOyvUG.mjs";
|
|
1
2
|
import { createRequire } from "node:module";
|
|
2
|
-
import { Array as Array$1, Boolean,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { Argument, Command } from "effect/cli";
|
|
6
|
-
import { resolveConfigFromFile } from "vite-plus";
|
|
3
|
+
import { Array as Array$1, Boolean, Effect, Function, Match, Option, Order, Predicate, Record, Schema, String as String$1, pipe } from "effect";
|
|
4
|
+
// src/app/format.ts
|
|
5
|
+
const format = (diagnostic) => `${diagnostic.path}:${String(diagnostic.line)}:${String(diagnostic.column)}: ${diagnostic.message} [${diagnostic.rule}]`;
|
|
7
6
|
// ../lint-host/src/entities/rule/model/setting.ts
|
|
8
7
|
const NO_OPTIONS = {};
|
|
9
8
|
const settingOf = (entry) => Match.value(entry).pipe(Match.when(Match.string, (severity) => ({
|
|
@@ -17,40 +16,6 @@ const settingOf = (entry) => Match.value(entry).pipe(Match.when(Match.string, (s
|
|
|
17
16
|
const abiOf = (platform) => Match.value(platform).pipe(Match.when("linux", () => "-gnu"), Match.when("win32", () => "-msvc"), Match.orElse(() => ""));
|
|
18
17
|
const platformTarget = `${process.platform}-${process.arch}${abiOf(process.platform)}`;
|
|
19
18
|
const addonFileOf = (binary) => `${binary}.${platformTarget}.node`;
|
|
20
|
-
// ../lint-host/src/features/build-addon/model/build.ts
|
|
21
|
-
const taggedError$1 = Schema.TaggedError;
|
|
22
|
-
var AddonBuildFailed = class extends taggedError$1()("AddonBuildFailed", { message: Schema.String }) {};
|
|
23
|
-
const LIBRARY = {
|
|
24
|
-
linux: (name) => `lib${name}.so`,
|
|
25
|
-
darwin: (name) => `lib${name}.dylib`,
|
|
26
|
-
win32: (name) => `${name}.dll`
|
|
27
|
-
};
|
|
28
|
-
const SUCCESS = 0;
|
|
29
|
-
const cargo = Effect.fn("cargo")(function* cargo(crate, workspace) {
|
|
30
|
-
const exitCode = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).exitCode(ChildProcess.make("cargo", [
|
|
31
|
-
"build",
|
|
32
|
-
"--release",
|
|
33
|
-
"--locked",
|
|
34
|
-
"-p",
|
|
35
|
-
crate
|
|
36
|
-
], {
|
|
37
|
-
cwd: workspace,
|
|
38
|
-
stdout: "inherit",
|
|
39
|
-
stderr: "inherit"
|
|
40
|
-
}));
|
|
41
|
-
const failure = AddonBuildFailed.make({ message: `cargo exited with ${String(exitCode)}` });
|
|
42
|
-
yield* Effect.when(Effect.fail(failure), Effect.sync(() => Number(exitCode) !== SUCCESS));
|
|
43
|
-
});
|
|
44
|
-
Effect.fn("buildAddon")(function* build(options) {
|
|
45
|
-
const fileSystem = yield* FileSystem.FileSystem;
|
|
46
|
-
const path = yield* Path.Path;
|
|
47
|
-
const library = yield* Effect.fromOption(Record.get(LIBRARY, process.platform)).pipe(Effect.mapError(() => AddonBuildFailed.make({ message: `no native build for ${process.platform}` })));
|
|
48
|
-
yield* cargo(options.crate, options.workspaceDir);
|
|
49
|
-
const output = path.join(options.packageDir, "native");
|
|
50
|
-
yield* fileSystem.makeDirectory(output, { recursive: true });
|
|
51
|
-
const built = library(String$1.replaceAll("-", "_")(options.crate));
|
|
52
|
-
yield* fileSystem.copyFile(path.join(options.workspaceDir, "target", "release", built), path.join(output, addonFileOf(options.binary)));
|
|
53
|
-
});
|
|
54
19
|
// ../lint-host/src/features/load-addon/model/load.ts
|
|
55
20
|
const loadAddon = ({ packageName, binary, from, isAddon, failWith }) => {
|
|
56
21
|
const requireFrom = createRequire(from);
|
|
@@ -67,99 +32,6 @@ const callAddon = ({ addon, name, files, call, failWith }) => addon.pipe(Effect.
|
|
|
67
32
|
// ../lint-host/src/features/load-addon/model/guard.ts
|
|
68
33
|
const hasFunction = (value) => (name) => Predicate.hasProperty(value, name) && Predicate.isFunction(value[name]);
|
|
69
34
|
const exposes = (names) => (value) => pipe(names, Array$1.every(hasFunction(value)));
|
|
70
|
-
// ../lint-host/src/shared/lib/fail.ts
|
|
71
|
-
const taggedError = Schema.TaggedError;
|
|
72
|
-
var NotUtf8Error = class extends taggedError()("NotUtf8Error", { path: Schema.String }) {};
|
|
73
|
-
// ../lint-host/src/features/run-cli/model/cli.ts
|
|
74
|
-
const CONFIG_FILES = [
|
|
75
|
-
"vite.config.ts",
|
|
76
|
-
"vite.config.mts",
|
|
77
|
-
"vite.config.js",
|
|
78
|
-
"vite.config.mjs"
|
|
79
|
-
];
|
|
80
|
-
const FAILED = 1;
|
|
81
|
-
const DATA_FIRST_ARITY$1 = 2;
|
|
82
|
-
const STRICT_UTF8 = new TextDecoder("utf-8", { fatal: true });
|
|
83
|
-
const readSectionIn = (source, root) => Effect.gen(function* readConfig() {
|
|
84
|
-
const fileSystem = yield* FileSystem.FileSystem;
|
|
85
|
-
const path = yield* Path.Path;
|
|
86
|
-
const found = yield* pipe(CONFIG_FILES, Array$1.map((name) => path.join(root, name)), Effect.filter((file) => fileSystem.exists(file).pipe(Effect.orElseSucceed(() => false))));
|
|
87
|
-
const loaded = yield* Option.match(Array$1.head(found), {
|
|
88
|
-
onNone: () => Effect.succeed({}),
|
|
89
|
-
onSome: (file) => Effect.tryPromise({
|
|
90
|
-
try: () => resolveConfigFromFile(file),
|
|
91
|
-
catch: source.failWith(`could not load ${file}`)
|
|
92
|
-
})
|
|
93
|
-
});
|
|
94
|
-
return source.section(loaded);
|
|
95
|
-
}).pipe(Effect.withSpan(`${source.name}.config`));
|
|
96
|
-
Function.dual(DATA_FIRST_ARITY$1, readSectionIn);
|
|
97
|
-
const trackedFiles = (root, pathspecs) => Effect.gen(function* listFiles() {
|
|
98
|
-
const output = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).string(ChildProcess.make("git", [
|
|
99
|
-
"ls-files",
|
|
100
|
-
"-co",
|
|
101
|
-
"--exclude-standard",
|
|
102
|
-
"-z",
|
|
103
|
-
"--",
|
|
104
|
-
...pathspecs
|
|
105
|
-
], { cwd: root }));
|
|
106
|
-
return pipe(String$1.split(output, "\0"), Array$1.filter(String$1.isNonEmpty));
|
|
107
|
-
});
|
|
108
|
-
const requestOf = (config, patterns) => Array$1.match(patterns, {
|
|
109
|
-
onEmpty: () => ({ config }),
|
|
110
|
-
onNonEmpty: (given) => ({
|
|
111
|
-
config,
|
|
112
|
-
patterns: given
|
|
113
|
-
})
|
|
114
|
-
});
|
|
115
|
-
const hasError = (found) => pipe(found, Array$1.some(({ severity }) => severity === "error"));
|
|
116
|
-
const failWhen = (failed) => Effect.when(Effect.sync(() => {
|
|
117
|
-
process.exitCode = FAILED;
|
|
118
|
-
}), Effect.succeed(failed)).pipe(Effect.asVoid);
|
|
119
|
-
const printAll = (found, format) => Array$1.match(found, {
|
|
120
|
-
onEmpty: () => Effect.void,
|
|
121
|
-
onNonEmpty: (all) => Console.log(pipe(all, Array$1.map(format), Array$1.join("\n")))
|
|
122
|
-
});
|
|
123
|
-
const readerIn = (root, failWith) => Effect.gen(function* reader() {
|
|
124
|
-
const fileSystem = yield* FileSystem.FileSystem;
|
|
125
|
-
const path = yield* Path.Path;
|
|
126
|
-
return (file) => fileSystem.readFile(path.resolve(root, file)).pipe(Effect.mapError(failWith(`could not read ${file}`)), Effect.flatMap((bytes) => Effect.try({
|
|
127
|
-
try: () => STRICT_UTF8.decode(bytes),
|
|
128
|
-
catch: () => NotUtf8Error.make({ path: file })
|
|
129
|
-
})));
|
|
130
|
-
});
|
|
131
|
-
const mainOf = (cli, patterns) => Effect.gen(function* main() {
|
|
132
|
-
const root = process.cwd();
|
|
133
|
-
const config = yield* readSectionIn(cli, root);
|
|
134
|
-
const pathspecs = cli.pathspecs(requestOf(config, patterns));
|
|
135
|
-
const { files, projectFiles } = yield* Effect.all({
|
|
136
|
-
files: trackedFiles(root, pathspecs).pipe(Effect.withSpan(`${cli.name}.files`)),
|
|
137
|
-
projectFiles: trackedFiles(root, []).pipe(Effect.withSpan(`${cli.name}.project`))
|
|
138
|
-
}, { concurrency: "unbounded" });
|
|
139
|
-
const read = yield* readerIn(root, cli.failWith);
|
|
140
|
-
const found = yield* cli.lint({
|
|
141
|
-
root,
|
|
142
|
-
files,
|
|
143
|
-
projectFiles,
|
|
144
|
-
config,
|
|
145
|
-
read
|
|
146
|
-
});
|
|
147
|
-
yield* printAll(found, cli.format);
|
|
148
|
-
yield* failWhen(hasError(found));
|
|
149
|
-
});
|
|
150
|
-
const variadicOf = ({ name, description }) => Argument.String(name).pipe(Argument.withDescription(description), Argument.variadic());
|
|
151
|
-
const pathspecArgument = () => variadicOf({
|
|
152
|
-
name: "pathspec",
|
|
153
|
-
description: "Git pathspecs of the files to lint, in place of the configured ones"
|
|
154
|
-
});
|
|
155
|
-
const runCli = (cli) => {
|
|
156
|
-
const command = Command.make(cli.name, { pathspecs: pathspecArgument() }, ({ pathspecs }) => mainOf(cli, pathspecs)).pipe(Command.withDescription(cli.description));
|
|
157
|
-
runMain(cli.name)(Command.run(command, { version: cli.version }));
|
|
158
|
-
};
|
|
159
|
-
Function.dual(2, (value, build) => Option.match(value, {
|
|
160
|
-
onNone: () => ({}),
|
|
161
|
-
onSome: build
|
|
162
|
-
}));
|
|
163
35
|
// ../lint-host/src/shared/lib/trace.ts
|
|
164
36
|
const SAMPLED = "01";
|
|
165
37
|
const NOT_SAMPLED = "00";
|
|
@@ -182,27 +54,6 @@ const mergedLayers = (layers) => ({
|
|
|
182
54
|
ignores: pipe(layers, Array$1.flatMap((layer) => layer.ignores ?? [])),
|
|
183
55
|
overrides: pipe(layers, Array$1.flatMap((layer) => layer.overrides ?? []))
|
|
184
56
|
});
|
|
185
|
-
const EMPTY$1 = 0;
|
|
186
|
-
const LENGTH = 1;
|
|
187
|
-
const aligned = (buffer) => Option.match(Option.liftPredicate(buffer, ({ byteOffset }) => byteOffset % 4 === EMPTY$1), {
|
|
188
|
-
onNone: () => Uint8Array.from(buffer),
|
|
189
|
-
onSome: (value) => value
|
|
190
|
-
});
|
|
191
|
-
const wordAt = (words) => (index) => words[index] ?? EMPTY$1;
|
|
192
|
-
const fieldsOf = (header) => (fields) => pipe(fields, Record.map((index) => wordAt(header)(index)));
|
|
193
|
-
const wordsOf = (buffer) => (at, count) => new Uint32Array(buffer.buffer, buffer.byteOffset + at * 4, count);
|
|
194
|
-
const spanText = (words) => (blob, encoding) => (spansAt, unit) => {
|
|
195
|
-
const decoder = new TextDecoder(encoding);
|
|
196
|
-
const cache = /* @__PURE__ */ new Map();
|
|
197
|
-
const read = (index) => {
|
|
198
|
-
const at = spansAt + index * 2;
|
|
199
|
-
const offset = wordAt(words)(at) * unit;
|
|
200
|
-
const value = decoder.decode(blob.subarray(offset, offset + wordAt(words)(at + LENGTH) * unit));
|
|
201
|
-
cache.set(index, value);
|
|
202
|
-
return value;
|
|
203
|
-
};
|
|
204
|
-
return (index) => Option.getOrElse(Option.fromNullishOr(cache.get(index)), () => read(index));
|
|
205
|
-
};
|
|
206
57
|
// ../lint-host/src/shared/lib/diagnostic.ts
|
|
207
58
|
const notUtf8 = (tool) => (path) => ({
|
|
208
59
|
path,
|
|
@@ -225,13 +76,14 @@ const pathspecsOf = ({ defaults, unowned = [] }) => ({ config, patterns = [] })
|
|
|
225
76
|
...unowned,
|
|
226
77
|
...pipe(config.ignores ?? [], Array$1.map((glob) => `:(glob,exclude)${glob}`))
|
|
227
78
|
];
|
|
228
|
-
// src/entities/rule/model/
|
|
229
|
-
const
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
79
|
+
// src/entities/rule/model/extend.ts
|
|
80
|
+
const flattenConfig = (config) => {
|
|
81
|
+
const layers = layersOf(config);
|
|
82
|
+
return {
|
|
83
|
+
...mergedLayers(layers),
|
|
84
|
+
settings: mergedRecords(pipe(layers, Array$1.map((layer) => layer.settings)))
|
|
85
|
+
};
|
|
86
|
+
};
|
|
235
87
|
// ../../node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js
|
|
236
88
|
const balanced = (a, b, str) => {
|
|
237
89
|
const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
|
|
@@ -2345,232 +2197,195 @@ const selects = (patterns) => {
|
|
|
2345
2197
|
const excluded = pipe(patterns, Array$1.filter(isNegated), Array$1.map(withoutNegation), matcher);
|
|
2346
2198
|
return (path) => included(path) && !excluded(path);
|
|
2347
2199
|
};
|
|
2348
|
-
// src/
|
|
2349
|
-
const
|
|
2350
|
-
"workflow",
|
|
2351
|
-
"action",
|
|
2352
|
-
"dependabot",
|
|
2353
|
-
"pre-commit"
|
|
2354
|
-
];
|
|
2355
|
-
// src/shared/native/source.ts
|
|
2356
|
-
const EMPTY = 0;
|
|
2200
|
+
// src/entities/rule/model/resolve.ts
|
|
2201
|
+
const SEPARATOR = "/";
|
|
2357
2202
|
const START = 0;
|
|
2358
|
-
const
|
|
2359
|
-
const
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
semanticRoot: 2,
|
|
2363
|
-
concreteCount: 3,
|
|
2364
|
-
concreteRoot: 4,
|
|
2365
|
-
childCount: 5,
|
|
2366
|
-
errorCount: 6,
|
|
2367
|
-
stringCount: 7
|
|
2368
|
-
};
|
|
2369
|
-
const SEMANTIC = {
|
|
2370
|
-
kind: 0,
|
|
2371
|
-
tag: 1,
|
|
2372
|
-
value: 2,
|
|
2373
|
-
style: 3,
|
|
2374
|
-
line: 4,
|
|
2375
|
-
column: 5,
|
|
2376
|
-
childStart: 6,
|
|
2377
|
-
childCount: 7
|
|
2378
|
-
};
|
|
2379
|
-
const CONCRETE = {
|
|
2380
|
-
kind: 0,
|
|
2381
|
-
flags: 1,
|
|
2382
|
-
start: 2,
|
|
2383
|
-
end: 3,
|
|
2384
|
-
field: 4,
|
|
2385
|
-
parent: 5,
|
|
2386
|
-
childStart: 6,
|
|
2387
|
-
childCount: 7
|
|
2388
|
-
};
|
|
2389
|
-
const FLAG = {
|
|
2390
|
-
named: 1,
|
|
2391
|
-
error: 2,
|
|
2392
|
-
missing: 4,
|
|
2393
|
-
extra: 8
|
|
2394
|
-
};
|
|
2395
|
-
const UTF16 = "utf-16le";
|
|
2396
|
-
const rootOf = (value) => Option.liftPredicate(value, (id) => id !== NONE);
|
|
2397
|
-
const layoutOf = (header) => {
|
|
2398
|
-
const fields = fieldsOf(header)(HEADER);
|
|
2399
|
-
const { semanticCount, concreteCount, errorCount } = fields;
|
|
2400
|
-
const semanticAt = 8;
|
|
2401
|
-
const concreteAt = semanticAt + semanticCount * 8;
|
|
2402
|
-
const childAt = concreteAt + concreteCount * 8;
|
|
2403
|
-
const errorAt = childAt + fields.childCount;
|
|
2404
|
-
const spanAt = errorAt + errorCount * 3;
|
|
2405
|
-
return {
|
|
2406
|
-
semanticCount,
|
|
2407
|
-
concreteCount,
|
|
2408
|
-
errorCount,
|
|
2409
|
-
semanticAt,
|
|
2410
|
-
concreteAt,
|
|
2411
|
-
childAt,
|
|
2412
|
-
errorAt,
|
|
2413
|
-
spanAt,
|
|
2414
|
-
blobAt: (spanAt + fields.stringCount * 2) * 4
|
|
2415
|
-
};
|
|
2416
|
-
};
|
|
2417
|
-
const sourceView = (raw) => {
|
|
2418
|
-
const buffer = aligned(raw);
|
|
2419
|
-
const header = wordsOf(buffer)(START, 8);
|
|
2420
|
-
const layout = layoutOf(header);
|
|
2421
|
-
const words = wordsOf(buffer)(START, layout.blobAt / 4);
|
|
2422
|
-
const stringAt = spanText(words)(buffer.subarray(layout.blobAt), UTF16)(layout.spanAt, 2);
|
|
2423
|
-
return {
|
|
2424
|
-
semanticCount: layout.semanticCount,
|
|
2425
|
-
semanticRoot: rootOf(wordAt(header)(HEADER.semanticRoot)),
|
|
2426
|
-
concreteCount: layout.concreteCount,
|
|
2427
|
-
concreteRoot: rootOf(wordAt(header)(HEADER.concreteRoot)),
|
|
2428
|
-
errorCount: layout.errorCount,
|
|
2429
|
-
semantic: (id, field) => wordAt(words)(layout.semanticAt + id * 8 + field),
|
|
2430
|
-
concrete: (id, field) => wordAt(words)(layout.concreteAt + id * 8 + field),
|
|
2431
|
-
child: (index) => wordAt(words)(layout.childAt + index),
|
|
2432
|
-
error: (index, field) => wordAt(words)(layout.errorAt + index * 3 + field),
|
|
2433
|
-
stringAt,
|
|
2434
|
-
text: stringAt(EMPTY)
|
|
2435
|
-
};
|
|
2436
|
-
};
|
|
2437
|
-
// src/entities/source/model/source.ts
|
|
2438
|
-
const FIRST = 1;
|
|
2439
|
-
const FIRST_LINE = 0;
|
|
2440
|
-
const HALF = 2;
|
|
2441
|
-
const BIT = 2;
|
|
2442
|
-
const SET = 1;
|
|
2443
|
-
const ERROR_FIELD = {
|
|
2444
|
-
line: 0,
|
|
2445
|
-
column: 1,
|
|
2446
|
-
message: 2
|
|
2447
|
-
};
|
|
2448
|
-
const LINE_BREAK = /\r\n|\r|\n/u;
|
|
2449
|
-
const NEWLINES = /\n/gu;
|
|
2450
|
-
const KINDS = [
|
|
2451
|
-
"scalar",
|
|
2452
|
-
"sequence",
|
|
2453
|
-
"mapping",
|
|
2454
|
-
"alias"
|
|
2455
|
-
];
|
|
2456
|
-
const STYLES = [
|
|
2457
|
-
"plain",
|
|
2458
|
-
"single-quoted",
|
|
2459
|
-
"double-quoted",
|
|
2460
|
-
"literal",
|
|
2461
|
-
"folded"
|
|
2462
|
-
];
|
|
2463
|
-
const pick = (values, index, fallback) => pipe(Array$1.get(values, index), Option.getOrElse(() => fallback));
|
|
2464
|
-
const lazy = (make) => {
|
|
2465
|
-
let made = Option.none();
|
|
2466
|
-
return () => pipe(made, Option.getOrElse(() => {
|
|
2467
|
-
const value = make();
|
|
2468
|
-
made = Option.some(value);
|
|
2469
|
-
return value;
|
|
2470
|
-
}));
|
|
2471
|
-
};
|
|
2472
|
-
const memo = (make) => {
|
|
2473
|
-
const made = /* @__PURE__ */ new Map();
|
|
2474
|
-
return (id) => made.getOrInsertComputed(id, () => make(id));
|
|
2475
|
-
};
|
|
2476
|
-
const times = (count, make) => Array.from({ length: count }, (_empty, index) => make(index));
|
|
2477
|
-
const childrenOf = (view, at) => (start, count) => times(count, (offset) => at(view.child(start + offset)));
|
|
2478
|
-
const yamlTree = (view) => {
|
|
2479
|
-
const at = memo((id) => {
|
|
2480
|
-
const field = (name) => view.semantic(id, SEMANTIC[name]);
|
|
2481
|
-
const children = lazy(() => childrenOf(view, at)(field("childStart"), field("childCount")));
|
|
2482
|
-
return {
|
|
2483
|
-
id,
|
|
2484
|
-
kind: pick(KINDS, field("kind"), "scalar"),
|
|
2485
|
-
tag: view.stringAt(field("tag")),
|
|
2486
|
-
value: view.stringAt(field("value")),
|
|
2487
|
-
style: pick(STYLES, field("style"), "plain"),
|
|
2488
|
-
line: field("line"),
|
|
2489
|
-
column: field("column"),
|
|
2490
|
-
get children() {
|
|
2491
|
-
return children();
|
|
2492
|
-
}
|
|
2493
|
-
};
|
|
2494
|
-
});
|
|
2495
|
-
return at;
|
|
2496
|
-
};
|
|
2497
|
-
const hasFlag = (flags, flag) => Math.floor(flags / flag) % BIT === SET;
|
|
2498
|
-
const present = (index) => Option.liftPredicate(index, (value) => value !== NONE);
|
|
2499
|
-
const syntaxNode = (view, at) => (id) => {
|
|
2500
|
-
const field = (name) => view.concrete(id, CONCRETE[name]);
|
|
2501
|
-
const flags = field("flags");
|
|
2502
|
-
const start = field("start");
|
|
2503
|
-
const end = field("end");
|
|
2504
|
-
const children = lazy(() => childrenOf(view, at)(field("childStart"), field("childCount")));
|
|
2505
|
-
return {
|
|
2203
|
+
const enabled = ([id, entry]) => {
|
|
2204
|
+
const { severity, options } = settingOf(entry);
|
|
2205
|
+
if (severity === "off") return [];
|
|
2206
|
+
return [{
|
|
2506
2207
|
id,
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2208
|
+
severity,
|
|
2209
|
+
options
|
|
2210
|
+
}];
|
|
2211
|
+
};
|
|
2212
|
+
const applies = (path) => (override) => selects(override.files)(path);
|
|
2213
|
+
const isIgnored = (config) => (path) => matcher(config.ignores ?? [])(path);
|
|
2214
|
+
const entriesFor = (config) => (path) => {
|
|
2215
|
+
const merged = { ...config.rules };
|
|
2216
|
+
for (const override of pipe(config.overrides ?? [], Array$1.filter(applies(path)))) Object.assign(merged, override.rules);
|
|
2217
|
+
return merged;
|
|
2218
|
+
};
|
|
2219
|
+
const ruleOf = (config) => (id) => pipe(String$1.indexOf(SEPARATOR)(id), Option.flatMap((at) => pipe(Record.get(config.plugins ?? {}, String$1.slice(START, at)(id)), Option.flatMap((plugin) => Record.get(plugin.rules, String$1.slice(at + 1)(id))))));
|
|
2220
|
+
const activate = (config) => (entry) => pipe(ruleOf(config)(entry.id), Option.map((rule) => ({
|
|
2221
|
+
...entry,
|
|
2222
|
+
rule
|
|
2223
|
+
})), Option.toArray);
|
|
2224
|
+
const activeRules = (config) => (path) => pipe(Record.toEntries(entriesFor(config)(path)), Array$1.flatMap(enabled), Array$1.flatMap(activate(config)));
|
|
2225
|
+
// src/entities/source/model/kind.ts
|
|
2226
|
+
const WORKFLOWS = ".github/workflows/";
|
|
2227
|
+
const YAML = /\.ya?ml$/u;
|
|
2228
|
+
const ACTION = /^action\.ya?ml$/u;
|
|
2229
|
+
const DEPENDABOT = /^\.github\/dependabot\.ya?ml$/u;
|
|
2230
|
+
const PRE_COMMIT = /^\.pre-commit-(?:config|hooks)\.yaml$/u;
|
|
2231
|
+
const kindOf = (path) => {
|
|
2232
|
+
if (DEPENDABOT.test(path)) return Option.some("dependabot");
|
|
2233
|
+
if (PRE_COMMIT.test(path)) return Option.some("pre-commit");
|
|
2234
|
+
if (ACTION.test(baseName(path))) return Option.some("action");
|
|
2235
|
+
if (String$1.includes(WORKFLOWS)(path) && YAML.test(path)) return Option.some("workflow");
|
|
2236
|
+
return Option.none();
|
|
2237
|
+
};
|
|
2238
|
+
// src/shared/lib/errors.ts
|
|
2239
|
+
const taggedError = Schema.TaggedError;
|
|
2240
|
+
var Fu4Error = class extends taggedError()("Fu4Error", { message: Schema.String }) {};
|
|
2241
|
+
const failedWith = (message) => (cause) => Fu4Error.make({ message: `${message}: ${String(cause)}` });
|
|
2242
|
+
// src/shared/native/index.ts
|
|
2243
|
+
const isNative = exposes([
|
|
2244
|
+
"parsePaths",
|
|
2245
|
+
"parseText",
|
|
2246
|
+
"parseScript",
|
|
2247
|
+
"readText",
|
|
2248
|
+
"pathExists",
|
|
2249
|
+
"flushTelemetry"
|
|
2250
|
+
]);
|
|
2251
|
+
const native = loadAddon({
|
|
2252
|
+
packageName: "@r_masseater/fu4",
|
|
2253
|
+
binary: "fu4",
|
|
2254
|
+
from: import.meta.url,
|
|
2255
|
+
isAddon: isNative,
|
|
2256
|
+
failWith: failedWith
|
|
2257
|
+
});
|
|
2258
|
+
// src/features/run-rules/model/order.ts
|
|
2259
|
+
const byPosition = Order.combineAll([
|
|
2260
|
+
Order.mapInput(Order.String, (found) => found.path),
|
|
2261
|
+
Order.mapInput(Order.Number, (found) => found.line),
|
|
2262
|
+
Order.mapInput(Order.Number, (found) => found.column),
|
|
2263
|
+
Order.mapInput(Order.String, (found) => found.message)
|
|
2264
|
+
]);
|
|
2265
|
+
const same = (left, right) => left.path === right.path && left.line === right.line && left.column === right.column && left.message === right.message && left.rule === right.rule;
|
|
2266
|
+
const ordered = (found) => Array$1.dedupeWith(Array$1.sort(found, byPosition), same);
|
|
2267
|
+
// src/features/run-rules/model/run.ts
|
|
2268
|
+
const CONCURRENT$1 = { concurrency: "unbounded" };
|
|
2269
|
+
const appliesTo = (kind) => ({ rule }) => pipe(rule.meta.kinds ?? ["workflow"], Array$1.some((each) => each === kind));
|
|
2270
|
+
const diagnosticOf = (input, active) => ({ rule, ...report }) => ({
|
|
2271
|
+
path: input.path,
|
|
2272
|
+
...report,
|
|
2273
|
+
rule: rule ?? active.id,
|
|
2274
|
+
severity: active.severity
|
|
2275
|
+
});
|
|
2276
|
+
const checked = (active, context) => Effect.suspend(() => {
|
|
2277
|
+
const result = active.rule.check(context);
|
|
2278
|
+
if (Effect.isEffect(result)) return result;
|
|
2279
|
+
return Effect.void;
|
|
2280
|
+
});
|
|
2281
|
+
const runRule = (input) => (active) => {
|
|
2282
|
+
const reports = [];
|
|
2283
|
+
const context = {
|
|
2284
|
+
filename: input.path,
|
|
2285
|
+
kind: input.kind,
|
|
2286
|
+
source: input.source,
|
|
2287
|
+
options: active.options,
|
|
2288
|
+
settings: input.settings,
|
|
2289
|
+
project: input.project,
|
|
2290
|
+
parseScript: input.parseScript,
|
|
2291
|
+
report: (report) => {
|
|
2292
|
+
reports.push(report);
|
|
2526
2293
|
}
|
|
2527
2294
|
};
|
|
2528
|
-
}
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
};
|
|
2533
|
-
const
|
|
2534
|
-
const
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
const
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
const line = lineAt(starts, offset);
|
|
2548
|
-
return {
|
|
2549
|
-
line: line + FIRST,
|
|
2550
|
-
column: offset - (starts[line] ?? FIRST_LINE) + FIRST
|
|
2551
|
-
};
|
|
2295
|
+
return checked(active, context).pipe(Effect.catchCause((cause) => cause.pipe(failedWith(`fu4 rule ${active.id} failed on ${input.path}`), Effect.fail)), Effect.map(() => pipe(reports, Array$1.map(diagnosticOf(input, active)))), Effect.withSpan("fu4.rule", { attributes: {
|
|
2296
|
+
"fu4.rule.id": active.id,
|
|
2297
|
+
"code.file.path": input.path
|
|
2298
|
+
} }));
|
|
2299
|
+
};
|
|
2300
|
+
const runFile = Effect.fn("fu4.runFile")(function* runFile(input) {
|
|
2301
|
+
const active = pipe(input.rules, Array$1.filter(appliesTo(input.kind)));
|
|
2302
|
+
const results = yield* Effect.forEach(active, runRule(input), CONCURRENT$1);
|
|
2303
|
+
return Array$1.flatten(results);
|
|
2304
|
+
});
|
|
2305
|
+
// src/app/lint.ts
|
|
2306
|
+
const CONCURRENT = { concurrency: "unbounded" };
|
|
2307
|
+
const projectOf = (root, addon) => {
|
|
2308
|
+
const parsed = /* @__PURE__ */ new Map();
|
|
2309
|
+
const read = (file) => Option.fromNullishOr(addon.readText(root, file));
|
|
2310
|
+
const parse = (file) => {
|
|
2311
|
+
const source = pipe(read(file), Option.map((text) => sourceOf(sourceView(addon.parseText(text)))));
|
|
2312
|
+
parsed.set(file, source);
|
|
2313
|
+
return source;
|
|
2552
2314
|
};
|
|
2553
|
-
};
|
|
2554
|
-
const errorsOf = (view) => times(view.errorCount, (index) => ({
|
|
2555
|
-
line: view.error(index, ERROR_FIELD.line),
|
|
2556
|
-
column: view.error(index, ERROR_FIELD.column),
|
|
2557
|
-
message: view.stringAt(view.error(index, ERROR_FIELD.message))
|
|
2558
|
-
}));
|
|
2559
|
-
const sourceOf = (view) => {
|
|
2560
|
-
const yaml = yamlTree(view);
|
|
2561
|
-
const syntax = syntaxTree(view);
|
|
2562
|
-
const lines = lazy(() => String$1.split(LINE_BREAK)(view.text));
|
|
2563
2315
|
return {
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
get lines() {
|
|
2569
|
-
return lines();
|
|
2570
|
-
},
|
|
2571
|
-
positionOf: positionIn(view.text)
|
|
2316
|
+
root,
|
|
2317
|
+
exists: (file) => addon.pathExists(root, file),
|
|
2318
|
+
read,
|
|
2319
|
+
parse: (file) => Option.getOrElse(Option.fromNullishOr(parsed.get(file)), () => parse(file))
|
|
2572
2320
|
};
|
|
2573
2321
|
};
|
|
2574
|
-
|
|
2322
|
+
const scriptParser = (addon) => (language, text) => sourceOf(sourceView(addon.parseScript(language, text)));
|
|
2323
|
+
const targetsOf = (config, files) => pipe(files, Array$1.filter((file) => Option.isSome(kindOf(file)) && !isIgnored(config)(file)));
|
|
2324
|
+
const parsedFiles = Effect.fn("fu4.parse")(function* parsedFiles(root, targets) {
|
|
2325
|
+
const parent = yield* traceparent;
|
|
2326
|
+
return yield* callAddon({
|
|
2327
|
+
addon: native,
|
|
2328
|
+
name: "fu4",
|
|
2329
|
+
files: targets.length,
|
|
2330
|
+
call: (loaded) => loaded.parsePaths(root, targets, { traceparent: Option.getOrUndefined(parent) }),
|
|
2331
|
+
failWith: failedWith
|
|
2332
|
+
});
|
|
2333
|
+
});
|
|
2334
|
+
const lint = Effect.fn("fu4.lint")(function* lint(input) {
|
|
2335
|
+
const config = flattenConfig(input.config ?? {});
|
|
2336
|
+
const addon = yield* native;
|
|
2337
|
+
const parsed = yield* parsedFiles(input.root, targetsOf(config, input.files));
|
|
2338
|
+
const project = projectOf(input.root, addon);
|
|
2339
|
+
const lintOne = (file) => Option.match(Option.fromUndefinedOr(file.source), {
|
|
2340
|
+
onNone: () => Effect.succeed([notUtf8("fu4")(file.path)]),
|
|
2341
|
+
onSome: (source) => runFile({
|
|
2342
|
+
path: file.path,
|
|
2343
|
+
kind: Option.getOrThrow(kindOf(file.path)),
|
|
2344
|
+
source: sourceOf(sourceView(source)),
|
|
2345
|
+
rules: activeRules(config)(file.path),
|
|
2346
|
+
settings: config.settings ?? {},
|
|
2347
|
+
project,
|
|
2348
|
+
parseScript: scriptParser(addon)
|
|
2349
|
+
})
|
|
2350
|
+
});
|
|
2351
|
+
const results = yield* Effect.forEach(parsed, lintOne, CONCURRENT);
|
|
2352
|
+
return ordered(Array$1.flatten(results));
|
|
2353
|
+
});
|
|
2354
|
+
const kindFor = (input) => pipe(Option.fromNullishOr(input.kind), Option.orElse(() => kindOf(input.path)), Option.getOrElse(() => "workflow"));
|
|
2355
|
+
const lintText = Effect.fn("fu4.lintText")(function* lintText(input) {
|
|
2356
|
+
const config = flattenConfig(input.config ?? {});
|
|
2357
|
+
const addon = yield* native;
|
|
2358
|
+
const source = sourceOf(sourceView(addon.parseText(input.text)));
|
|
2359
|
+
const results = yield* runFile({
|
|
2360
|
+
path: input.path,
|
|
2361
|
+
kind: kindFor(input),
|
|
2362
|
+
source,
|
|
2363
|
+
rules: activeRules(config)(input.path),
|
|
2364
|
+
settings: config.settings ?? {},
|
|
2365
|
+
project: projectOf(input.root, addon),
|
|
2366
|
+
parseScript: scriptParser(addon)
|
|
2367
|
+
});
|
|
2368
|
+
return ordered(results);
|
|
2369
|
+
});
|
|
2370
|
+
// src/app/section.ts
|
|
2371
|
+
const fu4Section = sectionOf({
|
|
2372
|
+
name: "fu4",
|
|
2373
|
+
prepare: flattenConfig,
|
|
2374
|
+
fallback: {}
|
|
2375
|
+
});
|
|
2376
|
+
const workflowPathspecs = pathspecsOf({
|
|
2377
|
+
defaults: [
|
|
2378
|
+
".github/workflows/*.yml",
|
|
2379
|
+
".github/workflows/*.yaml",
|
|
2380
|
+
":(glob)**/action.yml",
|
|
2381
|
+
":(glob)**/action.yaml",
|
|
2382
|
+
".github/dependabot.yml",
|
|
2383
|
+
".github/dependabot.yaml",
|
|
2384
|
+
".pre-commit-config.yaml",
|
|
2385
|
+
".pre-commit-hooks.yaml"
|
|
2386
|
+
],
|
|
2387
|
+
unowned: [":(exclude,attr:linguist-vendored)", ":(exclude,attr:linguist-generated)"]
|
|
2388
|
+
});
|
|
2389
|
+
export { Fu4Error as a, lintText as i, workflowPathspecs as n, failedWith as o, lint as r, format as s, fu4Section as t };
|
|
2575
2390
|
|
|
2576
|
-
//# sourceMappingURL=
|
|
2391
|
+
//# sourceMappingURL=app-BkrdDFcT.mjs.map
|