@r_masseater/fu4 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +113 -30
- package/dist/app-KgCbMsJa.mjs +632 -0
- package/dist/app-KgCbMsJa.mjs.map +1 -0
- package/dist/cli-CfFhh0Tu.mjs +15 -0
- package/dist/cli-CfFhh0Tu.mjs.map +1 -0
- package/dist/cli.mjs +3 -12
- package/dist/cli.mjs.map +1 -1
- package/dist/index-DFaQsB5x.d.mts +114 -0
- package/dist/index.d.mts +20 -7
- package/dist/index.mjs +3 -1
- package/dist/presets.d.mts +662 -0
- package/dist/presets.mjs +42796 -0
- package/dist/presets.mjs.map +1 -0
- package/dist/types-CsheTVso.mjs +2131 -0
- package/dist/types-CsheTVso.mjs.map +1 -0
- package/dist/vite.d.mts +1 -1
- package/package.json +30 -21
- package/skills/apply-fu4-presets/SKILL.md +62 -0
- package/skills/lint-workflows/SKILL.md +31 -43
- package/dist/app-D0TgXIa0.mjs +0 -211
- package/dist/app-D0TgXIa0.mjs.map +0 -1
- package/dist/types-DywsX0Gn.d.mts +0 -34
package/package.json
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@r_masseater/fu4",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "The engine of a GitHub Actions linter: Rust parses workflows and TypeScript rules from its presets subpath check them, configured from vite.config.ts.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"actionlint",
|
|
7
7
|
"github-actions",
|
|
8
8
|
"lint",
|
|
9
|
+
"shellcheck",
|
|
9
10
|
"tanstack-intent",
|
|
10
|
-
"vite-plus"
|
|
11
|
+
"vite-plus",
|
|
12
|
+
"zizmor"
|
|
11
13
|
],
|
|
12
|
-
"homepage": "https://github.com/masseater/
|
|
14
|
+
"homepage": "https://github.com/masseater/ecosystems/tree/main/libs/fu4#readme",
|
|
13
15
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/masseater/
|
|
16
|
+
"url": "https://github.com/masseater/ecosystems/issues"
|
|
15
17
|
},
|
|
16
18
|
"license": "MIT",
|
|
17
19
|
"repository": {
|
|
18
20
|
"type": "git",
|
|
19
|
-
"url": "git+https://github.com/masseater/
|
|
21
|
+
"url": "git+https://github.com/masseater/ecosystems.git",
|
|
20
22
|
"directory": "libs/fu4"
|
|
21
23
|
},
|
|
22
24
|
"bin": {
|
|
@@ -26,9 +28,11 @@
|
|
|
26
28
|
"LICENSE",
|
|
27
29
|
"dist",
|
|
28
30
|
"logo.svg",
|
|
31
|
+
"skills/apply-fu4-presets",
|
|
29
32
|
"skills/lint-workflows"
|
|
30
33
|
],
|
|
31
34
|
"type": "module",
|
|
35
|
+
"sideEffects": false,
|
|
32
36
|
"imports": {
|
|
33
37
|
"#/*": "./src/*"
|
|
34
38
|
},
|
|
@@ -37,6 +41,10 @@
|
|
|
37
41
|
"types": "./dist/index.d.mts",
|
|
38
42
|
"default": "./dist/index.mjs"
|
|
39
43
|
},
|
|
44
|
+
"./presets": {
|
|
45
|
+
"types": "./dist/presets.d.mts",
|
|
46
|
+
"default": "./dist/presets.mjs"
|
|
47
|
+
},
|
|
40
48
|
"./vite": {
|
|
41
49
|
"types": "./dist/vite.d.mts",
|
|
42
50
|
"default": "./dist/vite.mjs"
|
|
@@ -48,35 +56,36 @@
|
|
|
48
56
|
"provenance": true
|
|
49
57
|
},
|
|
50
58
|
"dependencies": {
|
|
51
|
-
"@effect/platform-node": "4.1.
|
|
59
|
+
"@effect/platform-node": "^4.1.5"
|
|
52
60
|
},
|
|
53
61
|
"devDependencies": {
|
|
54
62
|
"@masseater.dev/lint-host": "0.0.0",
|
|
55
|
-
"@
|
|
63
|
+
"@masseater.dev/path-kit": "0.0.0",
|
|
64
|
+
"@r_masseater/vitest-otlp": "0.2.2",
|
|
56
65
|
"@types/hast": "3.0.5",
|
|
57
66
|
"@types/mdast": "4.0.4",
|
|
58
67
|
"@types/node": "26.6.6",
|
|
59
|
-
"effect": "4.1.
|
|
60
|
-
"hast-util-from-html": "
|
|
61
|
-
"hast-util-select": "
|
|
62
|
-
"
|
|
63
|
-
"liquidjs": "^10.30.1",
|
|
68
|
+
"effect": "4.1.5",
|
|
69
|
+
"hast-util-from-html": "2.1.0",
|
|
70
|
+
"hast-util-select": "6.0.5",
|
|
71
|
+
"liquidjs": "10.30.1",
|
|
64
72
|
"mdast-util-to-string": "4.0.0",
|
|
73
|
+
"minimatch": "11.0.9",
|
|
65
74
|
"remark-gfm": "4.0.1",
|
|
66
75
|
"remark-parse": "11.0.0",
|
|
67
76
|
"unified": "11.0.5",
|
|
68
|
-
"unist-util-visit": "
|
|
69
|
-
"vite": "npm:@voidzero-dev/vite-plus-core@8.3.
|
|
70
|
-
"vite-plus": "1.
|
|
77
|
+
"unist-util-visit": "5.2.0",
|
|
78
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@8.3.8001",
|
|
79
|
+
"vite-plus": "1.8.0",
|
|
71
80
|
"yaml": "2.9.1"
|
|
72
81
|
},
|
|
73
82
|
"peerDependencies": {
|
|
74
|
-
"effect": "^4.1.
|
|
83
|
+
"effect": "^4.1.0",
|
|
75
84
|
"vite": "*",
|
|
76
|
-
"vite-plus": ">=1.
|
|
85
|
+
"vite-plus": ">=1.8.0"
|
|
77
86
|
},
|
|
78
87
|
"engines": {
|
|
79
|
-
"node": ">=26"
|
|
88
|
+
"node": ">=26.13.1"
|
|
80
89
|
},
|
|
81
90
|
"native": {
|
|
82
91
|
"binary": "fu4",
|
|
@@ -86,8 +95,8 @@
|
|
|
86
95
|
]
|
|
87
96
|
},
|
|
88
97
|
"optionalDependencies": {
|
|
89
|
-
"@r_masseater/fu4-linux-x64-gnu": "0.
|
|
90
|
-
"@r_masseater/fu4-win32-x64-msvc": "0.
|
|
98
|
+
"@r_masseater/fu4-linux-x64-gnu": "0.3.0",
|
|
99
|
+
"@r_masseater/fu4-win32-x64-msvc": "0.3.0"
|
|
91
100
|
},
|
|
92
101
|
"scripts": {}
|
|
93
102
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: apply-fu4-presets
|
|
3
|
+
description: >
|
|
4
|
+
Use when choosing which @r_masseater/fu4/presets presets a repository's fu4 config extends,
|
|
5
|
+
setting their options, or fixing what their actionlint/ and zizmor/ rules report on GitHub
|
|
6
|
+
Actions workflows, actions, Dependabot and pre-commit configs.
|
|
7
|
+
metadata:
|
|
8
|
+
type: core
|
|
9
|
+
library: "@r_masseater/fu4"
|
|
10
|
+
library_version: 0.1.0
|
|
11
|
+
sources:
|
|
12
|
+
- src/app/presets.ts
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# apply-fu4-presets
|
|
16
|
+
|
|
17
|
+
Each preset returns a fu4 config that loads one plugin and turns its rules on as errors. A config
|
|
18
|
+
lists the presets it wants in `extends`; its own `rules` and `overrides` come after them and win.
|
|
19
|
+
|
|
20
|
+
## Setup
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import "@r_masseater/fu4/vite";
|
|
24
|
+
import { actionlint, zizmor } from "@r_masseater/fu4/presets";
|
|
25
|
+
import { defineConfig } from "vite-plus";
|
|
26
|
+
|
|
27
|
+
export default defineConfig({
|
|
28
|
+
fu4: {
|
|
29
|
+
extends: [
|
|
30
|
+
actionlint({
|
|
31
|
+
"self-hosted-runner": { labels: ["gpu"] },
|
|
32
|
+
"config-variables": ["DEPLOY_TARGET"],
|
|
33
|
+
}),
|
|
34
|
+
zizmor({ concerns: ["injection", "supply-chain"], persona: "regular", minSeverity: "low" }),
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Presets
|
|
41
|
+
|
|
42
|
+
- `actionlint(options)` turns on `actionlint/*`: what actionlint reports, with the same messages
|
|
43
|
+
and positions, and its shellcheck checks of `run:` scripts. It takes the options of
|
|
44
|
+
actionlint's `actionlint.yaml`: `self-hosted-runner.labels` and `config-variables`. Leave
|
|
45
|
+
`config-variables` out to accept any `vars.*` name; an empty list rejects every name.
|
|
46
|
+
- `zizmor(options)` turns on `zizmor/*`: zizmor's audits with its findings and positions.
|
|
47
|
+
`concerns` picks `injection`, `supply-chain`, `references`, `credentials`, `workflow` and
|
|
48
|
+
`config`; all by default. `persona`, `minSeverity` and `minConfidence` work as in zizmor.
|
|
49
|
+
`rules` is the `rules` section of a zizmor config. `online: false` skips the audits that query
|
|
50
|
+
GitHub, and `githubHost` points them at GitHub Enterprise Server.
|
|
51
|
+
- `recommended()` extends both with their defaults.
|
|
52
|
+
|
|
53
|
+
The audits that query GitHub read a token from `ZIZMOR_GITHUB_TOKEN`, `GH_TOKEN` or
|
|
54
|
+
`GITHUB_TOKEN` and are skipped without one.
|
|
55
|
+
|
|
56
|
+
## Fixing reports
|
|
57
|
+
|
|
58
|
+
The rule name in brackets names the tool it comes from. A zizmor message ends with a link to
|
|
59
|
+
zizmor's documentation for that audit; for an `actionlint/` rule, read actionlint's
|
|
60
|
+
documentation for the check. Fix the workflow first. A `# zizmor: ignore[audit]` comment on the
|
|
61
|
+
line silences one zizmor finding. Turn a rule off in `overrides` only for files you have decided
|
|
62
|
+
to accept, and keep the globs narrow.
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
name: lint-workflows
|
|
3
3
|
description: >
|
|
4
4
|
Use when setting up @r_masseater/fu4 in vite.config.ts, running it on GitHub Actions
|
|
5
|
-
workflows, actions or
|
|
6
|
-
|
|
7
|
-
security audits, and the CLI.
|
|
5
|
+
workflows, actions, Dependabot or pre-commit configs, or writing a rule or plugin for it.
|
|
6
|
+
Covers extends, rules, settings, overrides, ignores, the CLI and the rule API.
|
|
8
7
|
metadata:
|
|
9
8
|
type: core
|
|
10
9
|
library: "@r_masseater/fu4"
|
|
@@ -16,11 +15,9 @@ sources:
|
|
|
16
15
|
|
|
17
16
|
# lint-workflows
|
|
18
17
|
|
|
19
|
-
fu4 is a GitHub Actions
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
It also runs zizmor's security audits on workflows, `action.yml` files, the Dependabot config
|
|
23
|
-
and pre-commit configs, so zizmor does not need to be installed either.
|
|
18
|
+
fu4 is the engine of a GitHub Actions linter. Rust parses each file once; TypeScript rules read
|
|
19
|
+
the parsed trees without copying them. fu4 has no rules of its own, so a config without plugins
|
|
20
|
+
reports nothing. The official rules are in `@r_masseater/fu4/presets`.
|
|
24
21
|
|
|
25
22
|
## Setup
|
|
26
23
|
|
|
@@ -30,53 +27,44 @@ vp add -D @r_masseater/fu4
|
|
|
30
27
|
|
|
31
28
|
```ts
|
|
32
29
|
import "@r_masseater/fu4/vite";
|
|
30
|
+
import { recommended } from "@r_masseater/fu4/presets";
|
|
33
31
|
import { defineConfig } from "vite-plus";
|
|
34
32
|
|
|
35
33
|
export default defineConfig({
|
|
36
34
|
fu4: {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
".github/workflows/
|
|
41
|
-
|
|
42
|
-
ignores: [".github/workflows/
|
|
43
|
-
audit: {
|
|
44
|
-
persona: "regular",
|
|
45
|
-
minSeverity: "low",
|
|
46
|
-
rules: { "template-injection": { disable: true } },
|
|
47
|
-
},
|
|
35
|
+
extends: [recommended()],
|
|
36
|
+
rules: { "zizmor/stale-action-refs": "warn" },
|
|
37
|
+
overrides: [
|
|
38
|
+
{ files: [".github/workflows/vendored-*.yml"], rules: { "actionlint/shellcheck": "off" } },
|
|
39
|
+
],
|
|
40
|
+
ignores: [".github/workflows/generated-*.yml"],
|
|
48
41
|
},
|
|
49
42
|
});
|
|
50
43
|
```
|
|
51
44
|
|
|
52
|
-
- `
|
|
53
|
-
- `
|
|
54
|
-
|
|
55
|
-
- `
|
|
56
|
-
|
|
57
|
-
- `ignores` lists globs of workflows the CLI does not lint.
|
|
58
|
-
- `audit.rules` is the `rules` section of a zizmor config: `disable`, `ignore`,
|
|
59
|
-
`severity` and each audit's `config`.
|
|
60
|
-
- `audit.persona` is `regular` (the default), `pedantic` or `auditor`; the latter two add
|
|
61
|
-
findings zizmor hides by default. `audit.minSeverity` and `audit.minConfidence` drop findings
|
|
62
|
-
below a level.
|
|
63
|
-
- Audits that query GitHub (impostor commits, ref confusion, known vulnerable actions and
|
|
64
|
-
others) run when `GH_TOKEN` is set. `audit.online: false` skips them, and `audit.githubHost`
|
|
65
|
-
points them at GitHub Enterprise.
|
|
45
|
+
- `extends` lists configs to start from. The config's own keys come after them and win.
|
|
46
|
+
- `rules` sets a rule to `"error"`, `"warn"` or `"off"`, or to `[severity, options]`.
|
|
47
|
+
- `settings` holds values every rule can read, keyed by plugin name.
|
|
48
|
+
- `overrides` gives `files` globs their own `rules`.
|
|
49
|
+
- `ignores` lists globs of files the CLI does not lint.
|
|
66
50
|
|
|
67
51
|
## Running
|
|
68
52
|
|
|
69
53
|
Run `fu4` in the repository root. It lints the workflows git tracks or would add under
|
|
70
|
-
`.github/workflows`,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
54
|
+
`.github/workflows`, the `action.yml` files, `.github/dependabot.yml` and the pre-commit configs at
|
|
55
|
+
the root, prints `path:line:column: message [rule]`, and exits with 1 when it reports anything.
|
|
56
|
+
Pass pathspecs to lint other files: `fu4 'ci/**/*.yml'`. From code, `lint({ root, files, config })`
|
|
57
|
+
returns the diagnostics as an Effect.
|
|
74
58
|
|
|
75
|
-
|
|
59
|
+
## Writing rules
|
|
76
60
|
|
|
77
|
-
|
|
61
|
+
Define a rule with `defineRule({ meta, check })` and register it in a plugin with
|
|
62
|
+
`definePlugin({ rules })`. Put the plugin under `plugins` and turn its rules on in `rules`.
|
|
78
63
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
check
|
|
82
|
-
and
|
|
64
|
+
- `meta.kinds` lists the inputs the rule reads: `workflow` (the default), `action`, `dependabot`
|
|
65
|
+
or `pre-commit`.
|
|
66
|
+
- `check(context)` reads `context.source` (the YAML tree, the tree-sitter tree and the lines),
|
|
67
|
+
`context.options`, `context.settings` and `context.project`, which reads other files of the
|
|
68
|
+
repository. It may return an Effect.
|
|
69
|
+
- `context.parseScript(language, text)` parses a `run:` script as `bash` or `powershell`.
|
|
70
|
+
- `context.report({ message, line, column })` reports a finding.
|
package/dist/app-D0TgXIa0.mjs
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
import { Array, Boolean, Config, Console, Effect, FileSystem, Function, Layer, Match, Option, Order, Path, Predicate, Record, Redacted, Schema, String as String$1, pipe } from "effect";
|
|
3
|
-
import { NodeServices } from "@effect/platform-node";
|
|
4
|
-
import { runMain } from "@effect/platform-node/NodeRuntime";
|
|
5
|
-
import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
6
|
-
import { FetchHttpClient } from "effect/http";
|
|
7
|
-
import { Otlp, OtlpSerialization } from "effect/observability";
|
|
8
|
-
import { resolveConfigFromFile } from "vite-plus";
|
|
9
|
-
// src/app/format.ts
|
|
10
|
-
const format = (diagnostic) => `${diagnostic.path}:${String(diagnostic.line)}:${String(diagnostic.column)}: ${diagnostic.message} [${diagnostic.rule}]`;
|
|
11
|
-
// ../lint-host/src/shared/lib/target.ts
|
|
12
|
-
const abiOf = (platform) => Match.value(platform).pipe(Match.when("linux", () => "-gnu"), Match.when("win32", () => "-msvc"), Match.orElse(() => ""));
|
|
13
|
-
const platformTarget = `${process.platform}-${process.arch}${abiOf(process.platform)}`;
|
|
14
|
-
const addonFileOf = (binary) => `${binary}.${platformTarget}.node`;
|
|
15
|
-
// ../lint-host/src/features/build-addon/model/build.ts
|
|
16
|
-
const taggedError$1 = Schema.TaggedError;
|
|
17
|
-
var AddonBuildFailed = class extends taggedError$1()("AddonBuildFailed", { message: Schema.String }) {};
|
|
18
|
-
const LIBRARY = {
|
|
19
|
-
linux: (name) => `lib${name}.so`,
|
|
20
|
-
darwin: (name) => `lib${name}.dylib`,
|
|
21
|
-
win32: (name) => `${name}.dll`
|
|
22
|
-
};
|
|
23
|
-
const SUCCESS = 0;
|
|
24
|
-
const cargo = Effect.fn("cargo")(function* cargo(crate, workspace) {
|
|
25
|
-
const exitCode = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).exitCode(ChildProcess.make("cargo", [
|
|
26
|
-
"build",
|
|
27
|
-
"--release",
|
|
28
|
-
"--locked",
|
|
29
|
-
"-p",
|
|
30
|
-
crate
|
|
31
|
-
], {
|
|
32
|
-
cwd: workspace,
|
|
33
|
-
stdout: "inherit",
|
|
34
|
-
stderr: "inherit"
|
|
35
|
-
}));
|
|
36
|
-
const failure = AddonBuildFailed.make({ message: `cargo exited with ${String(exitCode)}` });
|
|
37
|
-
yield* Effect.when(Effect.fail(failure), Effect.sync(() => Number(exitCode) !== SUCCESS));
|
|
38
|
-
});
|
|
39
|
-
Effect.fn("buildAddon")(function* build(options) {
|
|
40
|
-
const fileSystem = yield* FileSystem.FileSystem;
|
|
41
|
-
const path = yield* Path.Path;
|
|
42
|
-
const library = yield* Effect.fromOption(Record.get(LIBRARY, process.platform)).pipe(Effect.mapError(() => AddonBuildFailed.make({ message: `no native build for ${process.platform}` })));
|
|
43
|
-
yield* cargo(options.crate, options.workspaceDir);
|
|
44
|
-
const output = path.join(options.packageDir, "native");
|
|
45
|
-
yield* fileSystem.makeDirectory(output, { recursive: true });
|
|
46
|
-
const built = library(String$1.replaceAll("-", "_")(options.crate));
|
|
47
|
-
yield* fileSystem.copyFile(path.join(options.workspaceDir, "target", "release", built), path.join(output, addonFileOf(options.binary)));
|
|
48
|
-
});
|
|
49
|
-
// ../lint-host/src/features/load-addon/model/load.ts
|
|
50
|
-
const loadAddon = ({ packageName, binary, from, isAddon, failWith }) => {
|
|
51
|
-
const requireFrom = createRequire(from);
|
|
52
|
-
const loadFrom = (specifier) => Effect.try({
|
|
53
|
-
try: () => requireFrom(specifier),
|
|
54
|
-
catch: failWith(`could not load ${specifier}`)
|
|
55
|
-
});
|
|
56
|
-
return loadFrom(`${packageName}-${platformTarget}`).pipe(Effect.catchCause(() => loadFrom(`${packageName}/native/${addonFileOf(binary)}`)), Effect.filterOrFail(isAddon, (found) => failWith(`no ${binary} addon for ${platformTarget}`)(found)));
|
|
57
|
-
};
|
|
58
|
-
const callAddon = ({ addon, name, files, call, failWith }) => addon.pipe(Effect.flatMap((loaded) => Effect.try({
|
|
59
|
-
try: () => call(loaded),
|
|
60
|
-
catch: failWith(`${name} could not lint`)
|
|
61
|
-
}).pipe(Effect.tap(() => Effect.promise(() => loaded.flushTelemetry())))), Effect.withSpan(`${name}.native`, { attributes: { [`${name}.files`]: files } }));
|
|
62
|
-
// ../lint-host/src/features/run-cli/model/cli.ts
|
|
63
|
-
const CONFIG_FILES = [
|
|
64
|
-
"vite.config.ts",
|
|
65
|
-
"vite.config.mts",
|
|
66
|
-
"vite.config.js",
|
|
67
|
-
"vite.config.mjs"
|
|
68
|
-
];
|
|
69
|
-
const FAILED = 1;
|
|
70
|
-
const ARGUMENTS_START = 2;
|
|
71
|
-
const configOf = (cli, root) => Effect.gen(function* readConfig() {
|
|
72
|
-
const fileSystem = yield* FileSystem.FileSystem;
|
|
73
|
-
const path = yield* Path.Path;
|
|
74
|
-
const found = yield* pipe(CONFIG_FILES, Array.map((name) => path.join(root, name)), Effect.filter((file) => fileSystem.exists(file).pipe(Effect.orElseSucceed(() => false))));
|
|
75
|
-
const loaded = yield* Option.match(Array.head(found), {
|
|
76
|
-
onNone: () => Effect.succeed({}),
|
|
77
|
-
onSome: (file) => Effect.tryPromise({
|
|
78
|
-
try: () => resolveConfigFromFile(file),
|
|
79
|
-
catch: cli.failWith(`could not load ${file}`)
|
|
80
|
-
})
|
|
81
|
-
});
|
|
82
|
-
return cli.section(loaded);
|
|
83
|
-
}).pipe(Effect.withSpan(`${cli.name}.config`));
|
|
84
|
-
const trackedFiles = (root, pathspecs) => Effect.gen(function* listFiles() {
|
|
85
|
-
const output = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).string(ChildProcess.make("git", [
|
|
86
|
-
"ls-files",
|
|
87
|
-
"-co",
|
|
88
|
-
"--exclude-standard",
|
|
89
|
-
"-z",
|
|
90
|
-
"--",
|
|
91
|
-
...pathspecs
|
|
92
|
-
], { cwd: root }));
|
|
93
|
-
return pipe(String$1.split(output, "\0"), Array.filter(String$1.isNonEmpty));
|
|
94
|
-
});
|
|
95
|
-
const requestOf = (config, patterns) => Array.match(patterns, {
|
|
96
|
-
onEmpty: () => ({ config }),
|
|
97
|
-
onNonEmpty: (given) => ({
|
|
98
|
-
config,
|
|
99
|
-
patterns: given
|
|
100
|
-
})
|
|
101
|
-
});
|
|
102
|
-
const hasError = (found) => pipe(found, Array.some(({ severity }) => severity === "error"));
|
|
103
|
-
const mainOf = (cli) => Effect.gen(function* main() {
|
|
104
|
-
const root = process.cwd();
|
|
105
|
-
const config = yield* configOf(cli, root);
|
|
106
|
-
const patterns = process.argv.slice(ARGUMENTS_START);
|
|
107
|
-
const files = yield* trackedFiles(root, cli.pathspecs(requestOf(config, patterns))).pipe(Effect.withSpan(`${cli.name}.files`));
|
|
108
|
-
const projectFiles = yield* trackedFiles(root, []).pipe(Effect.withSpan(`${cli.name}.project`));
|
|
109
|
-
const found = yield* cli.lint({
|
|
110
|
-
root,
|
|
111
|
-
files,
|
|
112
|
-
projectFiles,
|
|
113
|
-
config
|
|
114
|
-
});
|
|
115
|
-
yield* Array.match(found, {
|
|
116
|
-
onEmpty: () => Effect.void,
|
|
117
|
-
onNonEmpty: (all) => Console.log(pipe(all, Array.map(cli.format), Array.join("\n")))
|
|
118
|
-
});
|
|
119
|
-
yield* Effect.when(Effect.sync(() => {
|
|
120
|
-
process.exitCode = FAILED;
|
|
121
|
-
}), Effect.sync(() => hasError(found)));
|
|
122
|
-
});
|
|
123
|
-
const runCli = (cli) => {
|
|
124
|
-
const services = Otlp.layerFromConfig({ resource: { serviceName: cli.name } }).pipe(Layer.provide(OtlpSerialization.layerJson), Layer.provide(FetchHttpClient.layer), Layer.provideMerge(NodeServices.layer));
|
|
125
|
-
runMain(mainOf(cli).pipe(Effect.provide(services)));
|
|
126
|
-
};
|
|
127
|
-
const present = Function.dual(2, (value, build) => Option.match(value, {
|
|
128
|
-
onNone: () => ({}),
|
|
129
|
-
onSome: build
|
|
130
|
-
}));
|
|
131
|
-
// ../lint-host/src/shared/lib/trace.ts
|
|
132
|
-
const SAMPLED = "01";
|
|
133
|
-
const NOT_SAMPLED = "00";
|
|
134
|
-
const flagsOf = (sampled) => Boolean.match(sampled, {
|
|
135
|
-
onFalse: () => NOT_SAMPLED,
|
|
136
|
-
onTrue: () => SAMPLED
|
|
137
|
-
});
|
|
138
|
-
const traceparent = Effect.currentSpan.pipe(Effect.map((span) => `00-${span.traceId}-${span.spanId}-${flagsOf(span.sampled)}`), Effect.option);
|
|
139
|
-
const byPosition = Order.combine(Order.mapInput(Order.String, (found) => found.path), Order.mapInput(Order.Number, (found) => found.line));
|
|
140
|
-
const sortByPosition = (found) => Array.sort(found, byPosition);
|
|
141
|
-
// src/shared/lib/errors.ts
|
|
142
|
-
const taggedError = Schema.TaggedError;
|
|
143
|
-
var Fu4Error = class extends taggedError()("Fu4Error", { message: Schema.String }) {};
|
|
144
|
-
const failedWith = (message) => (cause) => Fu4Error.make({ message: `${message}: ${String(cause)}` });
|
|
145
|
-
// src/shared/native/index.ts
|
|
146
|
-
const isNative = (value) => Predicate.hasProperty(value, "lintPaths") && Predicate.isFunction(value.lintPaths) && Predicate.hasProperty(value, "flushTelemetry") && Predicate.isFunction(value.flushTelemetry);
|
|
147
|
-
const native = loadAddon({
|
|
148
|
-
packageName: "@r_masseater/fu4",
|
|
149
|
-
binary: "fu4",
|
|
150
|
-
from: import.meta.url,
|
|
151
|
-
isAddon: isNative,
|
|
152
|
-
failWith: failedWith
|
|
153
|
-
});
|
|
154
|
-
// src/app/lint.ts
|
|
155
|
-
const diagnosticsOf = (result) => pipe(result.diagnostics, Array.map((diagnostic) => ({
|
|
156
|
-
path: result.path,
|
|
157
|
-
line: diagnostic.line,
|
|
158
|
-
column: diagnostic.column,
|
|
159
|
-
rule: diagnostic.kind,
|
|
160
|
-
message: diagnostic.message,
|
|
161
|
-
severity: "error"
|
|
162
|
-
})));
|
|
163
|
-
const githubToken = Config.option(Config.Redacted("GH_TOKEN")).pipe(Effect.map(Option.filter((token) => Redacted.value(token) !== "")), Effect.orDie);
|
|
164
|
-
const auditOptions = Effect.fn("fu4.auditOptions")(function* auditOptions(config = {}) {
|
|
165
|
-
const { online = true, ...rest } = config;
|
|
166
|
-
if (!online) return rest;
|
|
167
|
-
const token = yield* githubToken;
|
|
168
|
-
return {
|
|
169
|
-
...rest,
|
|
170
|
-
...present(token, (value) => ({ githubToken: Redacted.value(value) }))
|
|
171
|
-
};
|
|
172
|
-
});
|
|
173
|
-
const lint = Effect.fn("fu4.lint")(function* lint(input) {
|
|
174
|
-
const parent = yield* traceparent;
|
|
175
|
-
const config = input.config ?? {};
|
|
176
|
-
const options = {
|
|
177
|
-
config,
|
|
178
|
-
audit: yield* auditOptions(config.audit),
|
|
179
|
-
...present(parent, (value) => ({ traceparent: value }))
|
|
180
|
-
};
|
|
181
|
-
const results = yield* callAddon({
|
|
182
|
-
addon: native,
|
|
183
|
-
name: "fu4",
|
|
184
|
-
files: input.files.length,
|
|
185
|
-
call: (addon) => addon.lintPaths(input.root, input.files, options),
|
|
186
|
-
failWith: failedWith
|
|
187
|
-
});
|
|
188
|
-
return sortByPosition(pipe(results, Array.flatMap(diagnosticsOf)));
|
|
189
|
-
});
|
|
190
|
-
// src/app/section.ts
|
|
191
|
-
const WORKFLOWS = [
|
|
192
|
-
".github/workflows/*.yml",
|
|
193
|
-
".github/workflows/*.yaml",
|
|
194
|
-
":(glob)**/action.yml",
|
|
195
|
-
":(glob)**/action.yaml",
|
|
196
|
-
".github/dependabot.yml",
|
|
197
|
-
".github/dependabot.yaml",
|
|
198
|
-
".pre-commit-config.yaml",
|
|
199
|
-
".pre-commit-hooks.yaml"
|
|
200
|
-
];
|
|
201
|
-
const NOT_OWNED = [":(exclude,attr:linguist-vendored)", ":(exclude,attr:linguist-generated)"];
|
|
202
|
-
const hasSection = (value) => Predicate.hasProperty(value, "fu4") && Predicate.isObject(value.fu4);
|
|
203
|
-
const fu4Section = (config) => pipe(Option.liftPredicate(config, hasSection), Option.map((value) => value.fu4), Option.getOrElse(() => ({})));
|
|
204
|
-
const workflowPathspecs = ({ config, patterns = WORKFLOWS }) => [
|
|
205
|
-
...patterns,
|
|
206
|
-
...NOT_OWNED,
|
|
207
|
-
...pipe(config.ignores ?? [], Array.map((glob) => `:(glob,exclude)${glob}`))
|
|
208
|
-
];
|
|
209
|
-
export { failedWith as a, Fu4Error as i, workflowPathspecs as n, runCli as o, lint as r, format as s, fu4Section as t };
|
|
210
|
-
|
|
211
|
-
//# sourceMappingURL=app-D0TgXIa0.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-D0TgXIa0.mjs","names":["taggedError","Rec","Str","Arr","Str","Fn","Bool","Arr","Arr","Arr"],"sources":["../src/app/format.ts","../../lint-host/src/shared/lib/target.ts","../../lint-host/src/features/build-addon/model/build.ts","../../lint-host/src/features/load-addon/model/load.ts","../../lint-host/src/features/run-cli/model/cli.ts","../../lint-host/src/shared/lib/present.ts","../../lint-host/src/shared/lib/trace.ts","../src/shared/lib/errors.ts","../src/shared/native/index.ts","../src/app/lint.ts","../src/app/section.ts"],"sourcesContent":["import type { Diagnostic } from \"#/shared/config/index.ts\";\n\nexport const format = (diagnostic: Diagnostic): string =>\n `${diagnostic.path}:${String(diagnostic.line)}:${String(diagnostic.column)}: ${diagnostic.message} [${diagnostic.rule}]`;\n","import { Match } from \"effect\";\n\nconst abiOf = (platform: string): string =>\n Match.value(platform).pipe(\n Match.when(\"linux\", () => \"-gnu\"),\n Match.when(\"win32\", () => \"-msvc\"),\n Match.orElse(() => \"\"),\n );\n\nexport const platformTarget = `${process.platform}-${process.arch}${abiOf(process.platform)}`;\n\nexport const addonFileOf = (binary: string): string => `${binary}.${platformTarget}.node`;\n","import { NodeServices } from \"@effect/platform-node\";\nimport { runMain } from \"@effect/platform-node/NodeRuntime\";\nimport { Effect, FileSystem, Path, Record as Rec, Schema, String as Str } from \"effect\";\nimport { ChildProcess, ChildProcessSpawner } from \"effect/process\";\n\nimport { addonFileOf } from \"#/shared/lib/target.ts\";\n\nconst taggedError = Schema.TaggedError;\n\nclass AddonBuildFailed extends taggedError<AddonBuildFailed, { readonly brand: unique symbol }>()(\n \"AddonBuildFailed\",\n { message: Schema.String },\n) {}\n\nconst LIBRARY: Readonly<Record<string, (name: string) => string>> = {\n linux: (name) => `lib${name}.so`,\n darwin: (name) => `lib${name}.dylib`,\n win32: (name) => `${name}.dll`,\n};\n\nconst SUCCESS = 0;\n\nexport interface AddonBuild {\n readonly crate: string;\n readonly binary: string;\n readonly packageDir: string;\n readonly workspaceDir: string;\n}\n\nconst cargo = Effect.fn(\"cargo\")(function* cargo(crate: string, workspace: string) {\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n const exitCode = yield* spawner.exitCode(\n ChildProcess.make(\"cargo\", [\"build\", \"--release\", \"--locked\", \"-p\", crate], {\n cwd: workspace,\n stdout: \"inherit\",\n stderr: \"inherit\",\n }),\n );\n const failure = AddonBuildFailed.make({ message: `cargo exited with ${String(exitCode)}` });\n yield* Effect.when(\n Effect.fail(failure),\n Effect.sync(() => Number(exitCode) !== SUCCESS),\n );\n});\n\nconst build = Effect.fn(\"buildAddon\")(function* build(options: AddonBuild) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const library = yield* Effect.fromOption(Rec.get(LIBRARY, process.platform)).pipe(\n Effect.mapError(() =>\n AddonBuildFailed.make({ message: `no native build for ${process.platform}` }),\n ),\n );\n yield* cargo(options.crate, options.workspaceDir);\n const output = path.join(options.packageDir, \"native\");\n yield* fileSystem.makeDirectory(output, { recursive: true });\n const built = library(Str.replaceAll(\"-\", \"_\")(options.crate));\n yield* fileSystem.copyFile(\n path.join(options.workspaceDir, \"target\", \"release\", built),\n path.join(output, addonFileOf(options.binary)),\n );\n});\n\nexport const buildAddon = (options: AddonBuild): void => {\n runMain(build(options).pipe(Effect.provide(NodeServices.layer)));\n};\n","import { createRequire } from \"node:module\";\n\nimport { Effect } from \"effect\";\n\nimport type { FailWith } from \"#/shared/lib/fail.ts\";\nimport { addonFileOf, platformTarget } from \"#/shared/lib/target.ts\";\n\nexport interface AddonSource<Addon, Failure> {\n readonly packageName: string;\n readonly binary: string;\n readonly from: string;\n readonly isAddon: (value: unknown) => value is Addon;\n readonly failWith: FailWith<Failure>;\n}\n\nexport const loadAddon = <Addon, Failure>({\n packageName,\n binary,\n from,\n isAddon,\n failWith,\n}: AddonSource<Addon, Failure>): Effect.Effect<Addon, Failure> => {\n const requireFrom = createRequire(from);\n const loadFrom = (specifier: string): Effect.Effect<unknown, Failure> =>\n Effect.try({\n try: (): unknown => requireFrom(specifier),\n catch: failWith(`could not load ${specifier}`),\n });\n return loadFrom(`${packageName}-${platformTarget}`).pipe(\n Effect.catchCause(() => loadFrom(`${packageName}/native/${addonFileOf(binary)}`)),\n Effect.filterOrFail(isAddon, (found) =>\n failWith(`no ${binary} addon for ${platformTarget}`)(found),\n ),\n );\n};\n\nexport interface Telemetered {\n readonly flushTelemetry: () => Promise<void>;\n}\n\nexport interface AddonCall<Addon extends Telemetered, Result, Failure> {\n readonly addon: Effect.Effect<Addon, Failure>;\n readonly name: string;\n readonly files: number;\n readonly call: (addon: Addon) => Result;\n readonly failWith: FailWith<Failure>;\n}\n\nexport const callAddon = <Addon extends Telemetered, Result, Failure>({\n addon,\n name,\n files,\n call,\n failWith,\n}: AddonCall<Addon, Result, Failure>): Effect.Effect<Result, Failure> =>\n addon.pipe(\n Effect.flatMap((loaded) =>\n Effect.try({ try: () => call(loaded), catch: failWith(`${name} could not lint`) }).pipe(\n Effect.tap(() => Effect.promise(() => loaded.flushTelemetry())),\n ),\n ),\n Effect.withSpan(`${name}.native`, { attributes: { [`${name}.files`]: files } }),\n );\n","import { NodeServices } from \"@effect/platform-node\";\nimport { runMain } from \"@effect/platform-node/NodeRuntime\";\nimport {\n Array as Arr,\n Console,\n Effect,\n FileSystem,\n Layer,\n Option,\n Path,\n String as Str,\n pipe,\n} from \"effect\";\nimport { FetchHttpClient } from \"effect/http\";\nimport { Otlp, OtlpSerialization } from \"effect/observability\";\nimport type { PlatformError } from \"effect/PlatformError\";\nimport { ChildProcess, ChildProcessSpawner } from \"effect/process\";\nimport { resolveConfigFromFile } from \"vite-plus\";\n\nimport type { FailWith } from \"#/shared/lib/fail.ts\";\n\nconst CONFIG_FILES = [\"vite.config.ts\", \"vite.config.mts\", \"vite.config.js\", \"vite.config.mjs\"];\nconst FAILED = 1;\nconst ARGUMENTS_START = 2;\n\nexport interface Reported {\n readonly severity: string;\n}\n\nexport interface LintCall<Config> {\n readonly root: string;\n readonly files: readonly string[];\n readonly projectFiles: readonly string[];\n readonly config: Config;\n}\n\nexport interface PathspecRequest<Config> {\n readonly config: Config;\n readonly patterns?: readonly string[];\n}\n\nexport interface Cli<Config, Found extends Reported, Failure> {\n readonly name: string;\n readonly section: (config: unknown) => Config;\n readonly pathspecs: (request: PathspecRequest<Config>) => readonly string[];\n readonly lint: (call: LintCall<Config>) => Effect.Effect<readonly Found[], Failure>;\n readonly format: (found: Found) => string;\n readonly failWith: FailWith<Failure>;\n}\n\nconst configOf = <Config, Found extends Reported, Failure>(\n cli: Cli<Config, Found, Failure>,\n root: string,\n): Effect.Effect<Config, Failure, FileSystem.FileSystem | Path.Path> =>\n Effect.gen(function* readConfig() {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const found = yield* pipe(\n CONFIG_FILES,\n Arr.map((name) => path.join(root, name)),\n Effect.filter((file) => fileSystem.exists(file).pipe(Effect.orElseSucceed(() => false))),\n );\n const loaded = yield* Option.match(Arr.head(found), {\n onNone: () => Effect.succeed<unknown>({}),\n onSome: (file) =>\n Effect.tryPromise({\n try: () => resolveConfigFromFile(file),\n catch: cli.failWith(`could not load ${file}`),\n }),\n });\n return cli.section(loaded);\n }).pipe(Effect.withSpan(`${cli.name}.config`));\n\nconst trackedFiles = (\n root: string,\n pathspecs: readonly string[],\n): Effect.Effect<readonly string[], PlatformError, ChildProcessSpawner.ChildProcessSpawner> =>\n Effect.gen(function* listFiles() {\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n const output = yield* spawner.string(\n ChildProcess.make(\n \"git\",\n [\"ls-files\", \"-co\", \"--exclude-standard\", \"-z\", \"--\", ...pathspecs],\n { cwd: root },\n ),\n );\n return pipe(Str.split(output, \"\\0\"), Arr.filter(Str.isNonEmpty));\n });\n\nconst requestOf = <Config>(config: Config, patterns: readonly string[]): PathspecRequest<Config> =>\n Arr.match(patterns, {\n onEmpty: () => ({ config }),\n onNonEmpty: (given) => ({ config, patterns: given }),\n });\n\nconst hasError = (found: readonly Reported[]): boolean =>\n pipe(\n found,\n Arr.some(({ severity }) => severity === \"error\"),\n );\n\nconst mainOf = <Config, Found extends Reported, Failure>(\n cli: Cli<Config, Found, Failure>,\n): Effect.Effect<\n void,\n Failure | PlatformError,\n FileSystem.FileSystem | Path.Path | ChildProcessSpawner.ChildProcessSpawner\n> =>\n Effect.gen(function* main() {\n const root = process.cwd();\n const config = yield* configOf(cli, root);\n const patterns = process.argv.slice(ARGUMENTS_START);\n const files = yield* trackedFiles(root, cli.pathspecs(requestOf(config, patterns))).pipe(\n Effect.withSpan(`${cli.name}.files`),\n );\n const projectFiles = yield* trackedFiles(root, []).pipe(Effect.withSpan(`${cli.name}.project`));\n const found = yield* cli.lint({ root, files, projectFiles, config });\n yield* Arr.match(found, {\n onEmpty: () => Effect.void,\n onNonEmpty: (all) => Console.log(pipe(all, Arr.map(cli.format), Arr.join(\"\\n\"))),\n });\n yield* Effect.when(\n Effect.sync(() => {\n process.exitCode = FAILED;\n }),\n Effect.sync(() => hasError(found)),\n );\n });\n\nexport const runCli = <Config, Found extends Reported, Failure>(\n cli: Cli<Config, Found, Failure>,\n): void => {\n const services = Otlp.layerFromConfig({ resource: { serviceName: cli.name } }).pipe(\n Layer.provide(OtlpSerialization.layerJson),\n Layer.provide(FetchHttpClient.layer),\n Layer.provideMerge(NodeServices.layer),\n );\n runMain(mainOf(cli).pipe(Effect.provide(services)));\n};\n","import { Function as Fn, Option } from \"effect\";\n\nconst DATA_FIRST_ARITY = 2;\n\nexport const present: {\n <Value, Fields extends object>(\n build: (value: Value) => Fields,\n ): (value: Option.Option<Value>) => Partial<Fields>;\n <Value, Fields extends object>(\n value: Option.Option<Value>,\n build: (value: Value) => Fields,\n ): Partial<Fields>;\n} = Fn.dual(\n DATA_FIRST_ARITY,\n <Value, Fields extends object>(\n value: Option.Option<Value>,\n build: (value: Value) => Fields,\n ): Partial<Fields> => Option.match(value, { onNone: (): Partial<Fields> => ({}), onSome: build }),\n);\n","import { Array as Arr, Boolean as Bool, Effect, Order } from \"effect\";\nimport type { Option } from \"effect\";\n\nconst SAMPLED = \"01\";\nconst NOT_SAMPLED = \"00\";\n\nexport interface Positioned {\n readonly path: string;\n readonly line: number;\n}\n\nconst flagsOf = (sampled: boolean): string =>\n Bool.match(sampled, { onFalse: () => NOT_SAMPLED, onTrue: () => SAMPLED });\n\nexport const traceparent: Effect.Effect<Option.Option<string>> = Effect.currentSpan.pipe(\n Effect.map((span) => `00-${span.traceId}-${span.spanId}-${flagsOf(span.sampled)}`),\n Effect.option,\n);\n\nconst byPosition: Order.Order<Positioned> = Order.combine(\n Order.mapInput(Order.String, (found: Positioned) => found.path),\n Order.mapInput(Order.Number, (found: Positioned) => found.line),\n);\n\nexport const sortByPosition = <Found extends Positioned>(found: readonly Found[]): Found[] =>\n Arr.sort(found, byPosition);\n","import { Schema } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class Fu4Error extends taggedError<Fu4Error, { readonly brand: unique symbol }>()(\n \"Fu4Error\",\n {\n message: Schema.String,\n },\n) {}\n\nexport const failedWith =\n (message: string) =>\n (cause: unknown): Fu4Error =>\n Fu4Error.make({ message: `${message}: ${String(cause)}` });\n","import { loadAddon } from \"@masseater.dev/lint-host\";\nimport { Predicate } from \"effect\";\nimport type { Effect } from \"effect\";\n\nimport type { AuditConfig, Fu4Config } from \"#/shared/config/index.ts\";\nimport { failedWith } from \"#/shared/lib/errors.ts\";\nimport type { Fu4Error } from \"#/shared/lib/errors.ts\";\n\nexport interface NativeDiagnostic {\n readonly line: number;\n readonly column: number;\n readonly message: string;\n readonly kind: string;\n}\n\nexport interface NativeResult {\n readonly path: string;\n readonly diagnostics: readonly NativeDiagnostic[];\n}\n\nexport interface NativeAuditOptions extends Omit<AuditConfig, \"online\"> {\n readonly githubToken?: string;\n}\n\nexport interface NativeOptions {\n readonly config?: Fu4Config;\n readonly audit?: NativeAuditOptions;\n readonly traceparent?: string;\n}\n\nexport interface Native {\n readonly lintPaths: (\n root: string,\n paths: readonly string[],\n options: NativeOptions,\n ) => readonly NativeResult[];\n readonly flushTelemetry: () => Promise<void>;\n}\n\nconst isNative = (value: unknown): value is Native =>\n Predicate.hasProperty(value, \"lintPaths\") &&\n Predicate.isFunction(value.lintPaths) &&\n Predicate.hasProperty(value, \"flushTelemetry\") &&\n Predicate.isFunction(value.flushTelemetry);\n\nexport const native: Effect.Effect<Native, Fu4Error> = loadAddon({\n packageName: \"@r_masseater/fu4\",\n binary: \"fu4\",\n from: import.meta.url,\n isAddon: isNative,\n failWith: failedWith,\n});\n","import { callAddon, present, sortByPosition, traceparent } from \"@masseater.dev/lint-host\";\nimport { Array as Arr, Config, Effect, Option, Redacted, pipe } from \"effect\";\n\nimport type { AuditConfig, Diagnostic, Fu4Config } from \"#/shared/config/index.ts\";\nimport { failedWith } from \"#/shared/lib/errors.ts\";\nimport { native } from \"#/shared/native/index.ts\";\nimport type { NativeAuditOptions, NativeOptions, NativeResult } from \"#/shared/native/index.ts\";\n\nexport interface LintInput {\n readonly root: string;\n readonly files: readonly string[];\n readonly config?: Fu4Config;\n}\n\nconst diagnosticsOf = (result: NativeResult): readonly Diagnostic[] =>\n pipe(\n result.diagnostics,\n Arr.map((diagnostic): Diagnostic => ({\n path: result.path,\n line: diagnostic.line,\n column: diagnostic.column,\n rule: diagnostic.kind,\n message: diagnostic.message,\n severity: \"error\",\n })),\n );\n\nconst githubToken = Config.option(Config.Redacted(\"GH_TOKEN\")).pipe(\n Effect.map(Option.filter((token) => Redacted.value(token) !== \"\")),\n Effect.orDie,\n);\n\nconst auditOptions = Effect.fn(\"fu4.auditOptions\")(function* auditOptions(\n config: AuditConfig = {},\n) {\n const { online = true, ...rest } = config;\n if (!online) {\n return rest;\n }\n const token = yield* githubToken;\n return {\n ...rest,\n ...present(token, (value) => ({ githubToken: Redacted.value(value) })),\n } satisfies NativeAuditOptions;\n});\n\nexport const lint = Effect.fn(\"fu4.lint\")(function* lint(input: LintInput) {\n const parent = yield* traceparent;\n const config = input.config ?? {};\n const options: NativeOptions = {\n config,\n audit: yield* auditOptions(config.audit),\n ...present(parent, (value) => ({ traceparent: value })),\n };\n const results = yield* callAddon({\n addon: native,\n name: \"fu4\",\n files: input.files.length,\n call: (addon) => addon.lintPaths(input.root, input.files, options),\n failWith: failedWith,\n });\n return sortByPosition(pipe(results, Arr.flatMap(diagnosticsOf)));\n});\n","import { Array as Arr, Option, Predicate, pipe } from \"effect\";\n\nimport type { Fu4Config } from \"#/shared/config/index.ts\";\n\nconst WORKFLOWS = [\n \".github/workflows/*.yml\",\n \".github/workflows/*.yaml\",\n \":(glob)**/action.yml\",\n \":(glob)**/action.yaml\",\n \".github/dependabot.yml\",\n \".github/dependabot.yaml\",\n \".pre-commit-config.yaml\",\n \".pre-commit-hooks.yaml\",\n];\n\nconst NOT_OWNED = [\":(exclude,attr:linguist-vendored)\", \":(exclude,attr:linguist-generated)\"];\n\nconst hasSection = (value: unknown): value is { readonly fu4: Fu4Config } =>\n Predicate.hasProperty(value, \"fu4\") && Predicate.isObject(value.fu4);\n\nexport const fu4Section = (config: unknown): Fu4Config =>\n pipe(\n Option.liftPredicate(config, hasSection),\n Option.map((value) => value.fu4),\n Option.getOrElse((): Fu4Config => ({})),\n );\n\nexport interface PathspecInput {\n readonly config: Fu4Config;\n readonly patterns?: readonly string[];\n}\n\nexport const workflowPathspecs = ({\n config,\n patterns = WORKFLOWS,\n}: PathspecInput): readonly string[] => [\n ...patterns,\n ...NOT_OWNED,\n ...pipe(\n config.ignores ?? [],\n Arr.map((glob) => `:(glob,exclude)${glob}`),\n ),\n];\n"],"mappings":";;;;;;;;;AAEA,MAAa,UAAU,eACrB,GAAG,WAAW,KAAK,GAAG,OAAO,WAAW,IAAI,EAAE,GAAG,OAAO,WAAW,MAAM,EAAE,IAAI,WAAW,QAAQ,IAAI,WAAW,KAAK;;ACDxH,MAAM,SAAS,aACb,MAAM,MAAM,QAAQ,CAAC,CAAC,KACpB,MAAM,KAAK,eAAe,MAAM,GAChC,MAAM,KAAK,eAAe,OAAO,GACjC,MAAM,aAAa,EAAE,CACvB;AAEF,MAAa,iBAAiB,GAAG,QAAQ,SAAS,GAAG,QAAQ,OAAO,MAAM,QAAQ,QAAQ;AAE1F,MAAa,eAAe,WAA2B,GAAG,OAAO,GAAG,eAAe;;ACJnF,MAAMA,gBAAc,OAAO;AAE3B,IAAM,mBAAN,cAA+BA,cAAiE,CAAC,CAC/F,oBACA,EAAE,SAAS,OAAO,OAAO,CAC3B,CAAC,CAAC,CAAC;AAEH,MAAM,UAA8D;CAClE,QAAQ,SAAS,MAAM,KAAK;CAC5B,SAAS,SAAS,MAAM,KAAK;CAC7B,QAAQ,SAAS,GAAG,KAAK;AAC3B;AAEA,MAAM,UAAU;AAShB,MAAM,QAAQ,OAAO,GAAG,OAAO,CAAC,CAAC,UAAU,MAAM,OAAe,WAAmB;CAEjF,MAAM,WAAW,QAAO,OADD,oBAAoB,oBAAA,CACX,SAC9B,aAAa,KAAK,SAAS;EAAC;EAAS;EAAa;EAAY;EAAM;CAAK,GAAG;EAC1E,KAAK;EACL,QAAQ;EACR,QAAQ;CACV,CA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M,cAAc,UAClB,UAAU,YAAY,OAAO,KAAK,KAAK,UAAU,SAAS,MAAM,GAAG;AAErE,MAAa,cAAc,WACzB,KACE,OAAO,cAAc,QAAQ,UAAU,GACvC,OAAO,KAAK,UAAU,MAAM,GAAG,GAC/B,OAAO,iBAA4B,CAAC,EAAE,CACxC;AAOF,MAAa,qBAAqB,EAChC,QACA,WAAW,gBAC2B;CACtC,GAAG;CACH,GAAG;CACH,GAAG,KACD,OAAO,WAAW,CAAC,GACnBC,MAAI,KAAK,SAAS,kBAAkB,MAAM,CAC5C;AACF"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
interface PathConfig {
|
|
2
|
-
readonly ignore?: readonly string[];
|
|
3
|
-
}
|
|
4
|
-
interface SelfHostedRunner {
|
|
5
|
-
readonly labels?: readonly string[];
|
|
6
|
-
}
|
|
7
|
-
type Persona = "regular" | "pedantic" | "auditor";
|
|
8
|
-
type Severity = "informational" | "low" | "medium" | "high";
|
|
9
|
-
type Confidence = Exclude<Severity, "informational">;
|
|
10
|
-
interface AuditConfig {
|
|
11
|
-
readonly rules?: Readonly<Record<string, unknown>>;
|
|
12
|
-
readonly persona?: Persona;
|
|
13
|
-
readonly minSeverity?: Severity;
|
|
14
|
-
readonly minConfidence?: Confidence;
|
|
15
|
-
readonly githubHost?: string;
|
|
16
|
-
readonly online?: boolean;
|
|
17
|
-
}
|
|
18
|
-
interface Fu4Config {
|
|
19
|
-
readonly audit?: AuditConfig;
|
|
20
|
-
readonly selfHostedRunner?: SelfHostedRunner;
|
|
21
|
-
readonly configVariables?: readonly string[] | null;
|
|
22
|
-
readonly paths?: Readonly<Record<string, PathConfig>>;
|
|
23
|
-
readonly ignores?: readonly string[];
|
|
24
|
-
}
|
|
25
|
-
interface Diagnostic {
|
|
26
|
-
readonly path: string;
|
|
27
|
-
readonly line: number;
|
|
28
|
-
readonly column: number;
|
|
29
|
-
readonly rule: string;
|
|
30
|
-
readonly message: string;
|
|
31
|
-
readonly severity: "error";
|
|
32
|
-
}
|
|
33
|
-
export { PathConfig as a, Severity as c, Fu4Config as i, Confidence as n, Persona as o, Diagnostic as r, SelfHostedRunner as s, AuditConfig as t };
|
|
34
|
-
//# sourceMappingURL=types-DywsX0Gn.d.mts.map
|