@lucasacoutinho/archer 0.2.1 → 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 +144 -387
- package/dist/analyzer/Analyzer.d.ts +17 -0
- package/dist/analyzer/Analyzer.d.ts.map +1 -0
- package/dist/analyzer/Analyzer.js +15 -0
- package/dist/analyzer/Analyzer.js.map +1 -0
- package/dist/analyzer/bindings.d.ts +26 -0
- package/dist/analyzer/bindings.d.ts.map +1 -0
- package/dist/analyzer/bindings.js +61 -0
- package/dist/analyzer/bindings.js.map +1 -0
- package/dist/analyzer/errors.d.ts +34 -0
- package/dist/analyzer/errors.d.ts.map +1 -0
- package/dist/analyzer/errors.js +20 -0
- package/dist/analyzer/errors.js.map +1 -0
- package/dist/analyzer/graph-file.d.ts +13 -0
- package/dist/analyzer/graph-file.d.ts.map +1 -0
- package/dist/analyzer/graph-file.js +22 -0
- package/dist/analyzer/graph-file.js.map +1 -0
- package/dist/analyzer/paths.d.ts +12 -0
- package/dist/analyzer/paths.d.ts.map +1 -0
- package/dist/analyzer/paths.js +26 -0
- package/dist/analyzer/paths.js.map +1 -0
- package/dist/analyzer/server-exit.d.ts +19 -0
- package/dist/analyzer/server-exit.d.ts.map +1 -0
- package/dist/analyzer/server-exit.js +70 -0
- package/dist/analyzer/server-exit.js.map +1 -0
- package/dist/analyzer/source.d.ts +29 -0
- package/dist/analyzer/source.d.ts.map +1 -0
- package/dist/analyzer/source.js +58 -0
- package/dist/analyzer/source.js.map +1 -0
- package/dist/analyzer/syntax.d.ts +29 -0
- package/dist/analyzer/syntax.d.ts.map +1 -0
- package/dist/analyzer/syntax.js +226 -0
- package/dist/analyzer/syntax.js.map +1 -0
- package/dist/analyzer/targets.d.ts +26 -0
- package/dist/analyzer/targets.d.ts.map +1 -0
- package/dist/analyzer/targets.js +84 -0
- package/dist/analyzer/targets.js.map +1 -0
- package/dist/analyzer/typescript.d.ts +5 -0
- package/dist/analyzer/typescript.d.ts.map +1 -0
- package/dist/analyzer/typescript.js +221 -0
- package/dist/analyzer/typescript.js.map +1 -0
- package/dist/analyzer/workspace.d.ts +24 -0
- package/dist/analyzer/workspace.d.ts.map +1 -0
- package/dist/analyzer/workspace.js +9 -0
- package/dist/analyzer/workspace.js.map +1 -0
- package/dist/cli/explain.d.ts +3 -0
- package/dist/cli/explain.d.ts.map +1 -0
- package/dist/cli/explain.js +21 -0
- package/dist/cli/explain.js.map +1 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +159 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/config/input.d.ts +59 -0
- package/dist/config/input.d.ts.map +1 -0
- package/dist/config/input.js +115 -0
- package/dist/config/input.js.map +1 -0
- package/dist/config/rules.d.ts +94 -0
- package/dist/config/rules.d.ts.map +1 -0
- package/dist/config/rules.js +130 -0
- package/dist/config/rules.js.map +1 -0
- package/dist/core/baseline.d.ts +16 -0
- package/dist/core/baseline.d.ts.map +1 -0
- package/dist/core/baseline.js +25 -0
- package/dist/core/baseline.js.map +1 -0
- package/dist/core/check.d.ts +16 -0
- package/dist/core/check.d.ts.map +1 -0
- package/dist/core/check.js +271 -0
- package/dist/core/check.js.map +1 -0
- package/dist/core/config.d.ts +72 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +78 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/fingerprint.d.ts +54 -0
- package/dist/core/fingerprint.d.ts.map +1 -0
- package/dist/core/fingerprint.js +182 -0
- package/dist/core/fingerprint.js.map +1 -0
- package/dist/core/keys.d.ts +10 -0
- package/dist/core/keys.d.ts.map +1 -0
- package/dist/core/keys.js +16 -0
- package/dist/core/keys.js.map +1 -0
- package/dist/core/lower.d.ts +13 -0
- package/dist/core/lower.d.ts.map +1 -0
- package/dist/core/lower.js +82 -0
- package/dist/core/lower.js.map +1 -0
- package/dist/core/model.d.ts +155 -0
- package/dist/core/model.d.ts.map +1 -0
- package/dist/core/model.js +116 -0
- package/dist/core/model.js.map +1 -0
- package/dist/core/pattern.d.ts +13 -0
- package/dist/core/pattern.d.ts.map +1 -0
- package/dist/core/pattern.js +29 -0
- package/dist/core/pattern.js.map +1 -0
- package/dist/core/reach.d.ts +10 -0
- package/dist/core/reach.d.ts.map +1 -0
- package/dist/core/reach.js +81 -0
- package/dist/core/reach.js.map +1 -0
- package/dist/core/rule.d.ts +200 -0
- package/dist/core/rule.d.ts.map +1 -0
- package/dist/core/rule.js +162 -0
- package/dist/core/rule.js.map +1 -0
- package/dist/core/selector.d.ts +7 -0
- package/dist/core/selector.d.ts.map +1 -0
- package/dist/core/selector.js +27 -0
- package/dist/core/selector.js.map +1 -0
- package/dist/core/structural.d.ts +10 -0
- package/dist/core/structural.d.ts.map +1 -0
- package/dist/core/structural.js +24 -0
- package/dist/core/structural.js.map +1 -0
- package/dist/core/text.d.ts +26 -0
- package/dist/core/text.d.ts.map +1 -0
- package/dist/core/text.js +144 -0
- package/dist/core/text.js.map +1 -0
- package/dist/effect.d.ts +19 -0
- package/dist/effect.d.ts.map +1 -0
- package/dist/effect.js +21 -0
- package/dist/effect.js.map +1 -0
- package/dist/index.d.ts +24 -44
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +59 -52
- package/dist/index.js.map +1 -0
- package/dist/report/agent.d.ts +3 -0
- package/dist/report/agent.d.ts.map +1 -0
- package/dist/report/agent.js +35 -0
- package/dist/report/agent.js.map +1 -0
- package/dist/report/dot.d.ts +4 -0
- package/dist/report/dot.d.ts.map +1 -0
- package/dist/report/dot.js +15 -0
- package/dist/report/dot.js.map +1 -0
- package/dist/report/github.d.ts +3 -0
- package/dist/report/github.d.ts.map +1 -0
- package/dist/report/github.js +18 -0
- package/dist/report/github.js.map +1 -0
- package/dist/report/json.d.ts +3 -0
- package/dist/report/json.d.ts.map +1 -0
- package/dist/report/json.js +4 -0
- package/dist/report/json.js.map +1 -0
- package/dist/report/message.d.ts +20 -0
- package/dist/report/message.d.ts.map +1 -0
- package/dist/report/message.js +73 -0
- package/dist/report/message.js.map +1 -0
- package/dist/report/pretty.d.ts +8 -0
- package/dist/report/pretty.d.ts.map +1 -0
- package/dist/report/pretty.js +89 -0
- package/dist/report/pretty.js.map +1 -0
- package/dist/report/render.d.ts +9 -0
- package/dist/report/render.d.ts.map +1 -0
- package/dist/report/render.js +10 -0
- package/dist/report/render.js.map +1 -0
- package/dist/report/report.d.ts +44 -0
- package/dist/report/report.d.ts.map +1 -0
- package/dist/report/report.js +49 -0
- package/dist/report/report.js.map +1 -0
- package/dist/report/sarif.d.ts +3 -0
- package/dist/report/sarif.d.ts.map +1 -0
- package/dist/report/sarif.js +68 -0
- package/dist/report/sarif.js.map +1 -0
- package/dist/run.d.ts +49 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +87 -0
- package/dist/run.js.map +1 -0
- package/dist/shell/baseline-file.d.ts +20 -0
- package/dist/shell/baseline-file.d.ts.map +1 -0
- package/dist/shell/baseline-file.js +46 -0
- package/dist/shell/baseline-file.js.map +1 -0
- package/dist/shell/load-config.d.ts +19 -0
- package/dist/shell/load-config.d.ts.map +1 -0
- package/dist/shell/load-config.js +39 -0
- package/dist/shell/load-config.js.map +1 -0
- package/package.json +29 -177
- package/skills/archer/SKILL.md +127 -45
- package/skills/archer/agents/openai.yaml +2 -2
- package/skills/archer/references/rules.md +267 -54
- package/dist/bun/plugin.cjs +0 -85
- package/dist/bun/plugin.d.cts +0 -7
- package/dist/bun/plugin.d.ts +0 -7
- package/dist/bun/plugin.js +0 -11
- package/dist/bun.cjs +0 -2238
- package/dist/bun.d.cts +0 -13
- package/dist/bun.d.ts +0 -13
- package/dist/bun.js +0 -28
- package/dist/chunk-2AKMBLHG.js +0 -2165
- package/dist/chunk-67YEOTXP.js +0 -25
- package/dist/chunk-IDVLHNL2.js +0 -46
- package/dist/chunk-ZZ6TR4PO.js +0 -201
- package/dist/cli.js +0 -2643
- package/dist/index.cjs +0 -2484
- package/dist/index.d.cts +0 -45
- package/dist/jest/plugin.cjs +0 -85
- package/dist/jest/plugin.d.cts +0 -7
- package/dist/jest/plugin.d.ts +0 -7
- package/dist/jest/plugin.js +0 -11
- package/dist/jest.cjs +0 -2237
- package/dist/jest.d.cts +0 -13
- package/dist/jest.d.ts +0 -13
- package/dist/jest.js +0 -27
- package/dist/matchers-Cqnbsyxe.d.cts +0 -11
- package/dist/matchers-Cqnbsyxe.d.ts +0 -11
- package/dist/node.cjs +0 -2237
- package/dist/node.d.cts +0 -13
- package/dist/node.d.ts +0 -13
- package/dist/node.js +0 -27
- package/dist/reporters-BbAXMpuW.d.cts +0 -6
- package/dist/reporters-xh-HQneS.d.ts +0 -6
- package/dist/suite-BwnPDCvU.d.cts +0 -337
- package/dist/suite-BwnPDCvU.d.ts +0 -337
- package/dist/vitest/plugin.cjs +0 -85
- package/dist/vitest/plugin.d.cts +0 -7
- package/dist/vitest/plugin.d.ts +0 -7
- package/dist/vitest/plugin.js +0 -11
- package/dist/vitest.cjs +0 -2531
- package/dist/vitest.d.cts +0 -37
- package/dist/vitest.d.ts +0 -37
- package/dist/vitest.js +0 -139
package/dist/vitest.d.cts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { TestOptions } from 'vitest';
|
|
2
|
-
import { R as ReporterName } from './reporters-BbAXMpuW.cjs';
|
|
3
|
-
import { A as ArcherOptions, a as ArchitectureSuite } from './suite-BwnPDCvU.cjs';
|
|
4
|
-
export { S as Selector } from './suite-BwnPDCvU.cjs';
|
|
5
|
-
|
|
6
|
-
interface ArchitectureCheckOptions {
|
|
7
|
-
readonly baseline?: string;
|
|
8
|
-
readonly config?: string;
|
|
9
|
-
readonly cwd?: string;
|
|
10
|
-
readonly failOnWarnings?: boolean;
|
|
11
|
-
readonly output?: string;
|
|
12
|
-
readonly reporter?: ReporterName;
|
|
13
|
-
readonly updateBaseline?: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface ArchTestOptions extends ArcherOptions {
|
|
17
|
-
readonly test?: TestOptions;
|
|
18
|
-
}
|
|
19
|
-
interface ArcherVitestOptions extends Omit<ArchitectureCheckOptions, 'cwd' | 'updateBaseline'> {
|
|
20
|
-
}
|
|
21
|
-
interface ArcherVitestPlugin {
|
|
22
|
-
readonly enforce: 'pre';
|
|
23
|
-
readonly name: 'archer:architecture-check';
|
|
24
|
-
readonly configResolved: (config: {
|
|
25
|
-
readonly root: string;
|
|
26
|
-
}) => Promise<void>;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Runs Archer once while Vitest resolves its Vite configuration.
|
|
30
|
-
*/
|
|
31
|
-
declare function archer(options?: ArcherVitestOptions): ArcherVitestPlugin;
|
|
32
|
-
/**
|
|
33
|
-
* Registers an architecture test in Vitest and returns its rule builder.
|
|
34
|
-
*/
|
|
35
|
-
declare function arch(name: string, options?: ArchTestOptions): ArchitectureSuite;
|
|
36
|
-
|
|
37
|
-
export { type ArchTestOptions, ArcherOptions, type ArcherVitestOptions, type ArcherVitestPlugin, arch, archer };
|
package/dist/vitest.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { TestOptions } from 'vitest';
|
|
2
|
-
import { R as ReporterName } from './reporters-xh-HQneS.js';
|
|
3
|
-
import { A as ArcherOptions, a as ArchitectureSuite } from './suite-BwnPDCvU.js';
|
|
4
|
-
export { S as Selector } from './suite-BwnPDCvU.js';
|
|
5
|
-
|
|
6
|
-
interface ArchitectureCheckOptions {
|
|
7
|
-
readonly baseline?: string;
|
|
8
|
-
readonly config?: string;
|
|
9
|
-
readonly cwd?: string;
|
|
10
|
-
readonly failOnWarnings?: boolean;
|
|
11
|
-
readonly output?: string;
|
|
12
|
-
readonly reporter?: ReporterName;
|
|
13
|
-
readonly updateBaseline?: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface ArchTestOptions extends ArcherOptions {
|
|
17
|
-
readonly test?: TestOptions;
|
|
18
|
-
}
|
|
19
|
-
interface ArcherVitestOptions extends Omit<ArchitectureCheckOptions, 'cwd' | 'updateBaseline'> {
|
|
20
|
-
}
|
|
21
|
-
interface ArcherVitestPlugin {
|
|
22
|
-
readonly enforce: 'pre';
|
|
23
|
-
readonly name: 'archer:architecture-check';
|
|
24
|
-
readonly configResolved: (config: {
|
|
25
|
-
readonly root: string;
|
|
26
|
-
}) => Promise<void>;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Runs Archer once while Vitest resolves its Vite configuration.
|
|
30
|
-
*/
|
|
31
|
-
declare function archer(options?: ArcherVitestOptions): ArcherVitestPlugin;
|
|
32
|
-
/**
|
|
33
|
-
* Registers an architecture test in Vitest and returns its rule builder.
|
|
34
|
-
*/
|
|
35
|
-
declare function arch(name: string, options?: ArchTestOptions): ArchitectureSuite;
|
|
36
|
-
|
|
37
|
-
export { type ArchTestOptions, ArcherOptions, type ArcherVitestOptions, type ArcherVitestPlugin, arch, archer };
|
package/dist/vitest.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
applyBaseline,
|
|
3
|
-
createBaseline,
|
|
4
|
-
readBaseline,
|
|
5
|
-
report,
|
|
6
|
-
writeBaseline
|
|
7
|
-
} from "./chunk-ZZ6TR4PO.js";
|
|
8
|
-
import {
|
|
9
|
-
ArchitectureSuite,
|
|
10
|
-
analyze
|
|
11
|
-
} from "./chunk-2AKMBLHG.js";
|
|
12
|
-
import {
|
|
13
|
-
ArchitectureError
|
|
14
|
-
} from "./chunk-IDVLHNL2.js";
|
|
15
|
-
|
|
16
|
-
// src/adapters/vitest/index.ts
|
|
17
|
-
import { test } from "vitest";
|
|
18
|
-
|
|
19
|
-
// src/application/check.ts
|
|
20
|
-
import { existsSync } from "fs";
|
|
21
|
-
import { mkdir, writeFile } from "fs/promises";
|
|
22
|
-
import path from "path";
|
|
23
|
-
import { createJiti } from "jiti";
|
|
24
|
-
var CONFIG_NAMES = [
|
|
25
|
-
"archer.config.ts",
|
|
26
|
-
"archer.config.mts",
|
|
27
|
-
"archer.config.cts",
|
|
28
|
-
"archer.config.js",
|
|
29
|
-
"archer.config.mjs",
|
|
30
|
-
"archer.config.cjs"
|
|
31
|
-
];
|
|
32
|
-
var REPORTERS = /* @__PURE__ */ new Set([
|
|
33
|
-
"agent",
|
|
34
|
-
"dot",
|
|
35
|
-
"github",
|
|
36
|
-
"json",
|
|
37
|
-
"llm",
|
|
38
|
-
"pretty",
|
|
39
|
-
"sarif"
|
|
40
|
-
]);
|
|
41
|
-
function findConfig(cwd, explicit) {
|
|
42
|
-
if (explicit !== void 0) {
|
|
43
|
-
const resolved = path.resolve(cwd, explicit);
|
|
44
|
-
if (!existsSync(resolved)) throw new Error(`Archer config not found: ${resolved}`);
|
|
45
|
-
return resolved;
|
|
46
|
-
}
|
|
47
|
-
for (const name of CONFIG_NAMES) {
|
|
48
|
-
const candidate = path.join(cwd, name);
|
|
49
|
-
if (existsSync(candidate)) return candidate;
|
|
50
|
-
}
|
|
51
|
-
throw new Error(`No Archer config found in ${cwd}. Run 'archer init' to create one.`);
|
|
52
|
-
}
|
|
53
|
-
async function loadConfig(fileName) {
|
|
54
|
-
const jiti = createJiti(fileName, { moduleCache: false });
|
|
55
|
-
const config = await jiti.import(fileName, { default: true });
|
|
56
|
-
if (typeof config !== "object" || config === null || !("rules" in config) || typeof config.rules !== "function") {
|
|
57
|
-
throw new TypeError(`Archer config '${fileName}' must export defineConfig({ rules() {} }).`);
|
|
58
|
-
}
|
|
59
|
-
return config;
|
|
60
|
-
}
|
|
61
|
-
async function writeReport(fileName, content) {
|
|
62
|
-
await mkdir(path.dirname(fileName), { recursive: true });
|
|
63
|
-
await writeFile(fileName, `${content}
|
|
64
|
-
`, "utf8");
|
|
65
|
-
}
|
|
66
|
-
async function checkArchitecture(options = {}) {
|
|
67
|
-
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
68
|
-
const configPath = findConfig(cwd, options.config);
|
|
69
|
-
const config = await loadConfig(configPath);
|
|
70
|
-
if (config.reporter !== void 0 && !REPORTERS.has(config.reporter)) {
|
|
71
|
-
throw new TypeError(`Unknown reporter '${config.reporter}' in ${configPath}.`);
|
|
72
|
-
}
|
|
73
|
-
const configDirectory = path.dirname(configPath);
|
|
74
|
-
const root = path.resolve(configDirectory, config.root ?? ".");
|
|
75
|
-
const suite = new ArchitectureSuite({ ...config, root });
|
|
76
|
-
await config.rules(suite);
|
|
77
|
-
const graph = await analyze({ ...config, root });
|
|
78
|
-
const originalResult = await suite.check(graph);
|
|
79
|
-
const configuredBaseline = options.baseline ?? config.baseline;
|
|
80
|
-
const baselinePath = path.resolve(configDirectory, configuredBaseline ?? ".archer-baseline.json");
|
|
81
|
-
const updateBaseline = options.updateBaseline ?? false;
|
|
82
|
-
if (updateBaseline) await writeBaseline(baselinePath, createBaseline(originalResult));
|
|
83
|
-
if (!updateBaseline && configuredBaseline !== void 0 && !existsSync(baselinePath)) {
|
|
84
|
-
throw new Error(`Archer baseline not found: ${baselinePath}`);
|
|
85
|
-
}
|
|
86
|
-
const result = !updateBaseline && existsSync(baselinePath) ? applyBaseline(originalResult, await readBaseline(baselinePath)) : originalResult;
|
|
87
|
-
const reporter = options.reporter ?? config.reporter ?? "pretty";
|
|
88
|
-
const content = report(reporter, result, graph);
|
|
89
|
-
const configuredOutput = options.output ?? config.output;
|
|
90
|
-
const outputPath = configuredOutput === void 0 ? void 0 : path.resolve(configDirectory, configuredOutput);
|
|
91
|
-
if (outputPath !== void 0) await writeReport(outputPath, content);
|
|
92
|
-
return {
|
|
93
|
-
baselinePath,
|
|
94
|
-
code: result.ok && (!(options.failOnWarnings ?? false) || result.warnings === 0) ? 0 : 1,
|
|
95
|
-
content,
|
|
96
|
-
graph,
|
|
97
|
-
...outputPath === void 0 ? {} : { outputPath },
|
|
98
|
-
result,
|
|
99
|
-
updatedBaseline: updateBaseline
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// src/adapters/vitest/index.ts
|
|
104
|
-
var ArcherVitestError = class extends Error {
|
|
105
|
-
constructor(message) {
|
|
106
|
-
super(message);
|
|
107
|
-
this.name = "ArcherVitestError";
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
function archer(options = {}) {
|
|
111
|
-
let execution;
|
|
112
|
-
return {
|
|
113
|
-
enforce: "pre",
|
|
114
|
-
name: "archer:architecture-check",
|
|
115
|
-
configResolved(config) {
|
|
116
|
-
execution ??= checkArchitecture({ ...options, cwd: config.root }).then((result) => {
|
|
117
|
-
if (result.code !== 0) throw new ArcherVitestError(result.content);
|
|
118
|
-
if (result.outputPath === void 0) process.stdout.write(`${result.content}
|
|
119
|
-
`);
|
|
120
|
-
});
|
|
121
|
-
return execution;
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
function arch(name, options = {}) {
|
|
126
|
-
const { test: testOptions, ...archerOptions } = options;
|
|
127
|
-
const suite = new ArchitectureSuite(archerOptions);
|
|
128
|
-
test(name, testOptions ?? {}, async () => {
|
|
129
|
-
const result = await suite.check();
|
|
130
|
-
if (!result.ok) {
|
|
131
|
-
throw new ArchitectureError(result);
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
return suite;
|
|
135
|
-
}
|
|
136
|
-
export {
|
|
137
|
-
arch,
|
|
138
|
-
archer
|
|
139
|
-
};
|