@yearofthedan/warp 0.4.1 → 0.5.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 +5 -7
- package/dist/{analysis → adapters/analysis}/complexity.d.ts +1 -1
- package/dist/adapters/analysis/folders.d.ts +2 -0
- package/dist/{app/facts.d.ts → adapters/analysis/freshFacts.d.ts} +1 -2
- package/dist/{app/facts.js → adapters/analysis/freshFacts.js} +0 -10
- package/dist/{analysis → adapters/analysis}/imports.d.ts +2 -1
- package/dist/{analysis → adapters/analysis}/imports.js +52 -18
- package/dist/{analysis → adapters/analysis}/members.d.ts +1 -1
- package/dist/adapters/analysis/specifiers.d.ts +10 -0
- package/dist/adapters/analysis/specifiers.js +39 -0
- package/dist/adapters/analysis/typescript.d.ts +2 -0
- package/dist/{analysis → adapters/analysis}/typescript.js +10 -4
- package/dist/{config → adapters/config}/loadConfig.d.ts +2 -7
- package/dist/{config → adapters/config}/loadConfig.js +5 -4
- package/dist/{git → adapters/git}/cache.d.ts +1 -1
- package/dist/adapters/git/factsStore.d.ts +2 -0
- package/dist/adapters/git/factsStore.js +10 -0
- package/dist/{git → adapters/git}/repository.d.ts +1 -1
- package/dist/{config → adapters/git}/toolDigest.js +1 -1
- package/dist/{reporters → adapters/reporters}/model.d.ts +2 -2
- package/dist/{reporters → adapters/reporters}/reporter.d.ts +2 -2
- package/dist/{reporters → adapters/reporters}/text.d.ts +2 -2
- package/dist/app/check.d.ts +5 -6
- package/dist/app/check.js +3 -3
- package/dist/app/checkModel.d.ts +5 -5
- package/dist/app/checkModel.js +4 -5
- package/dist/app/configLines.d.ts +1 -1
- package/dist/app/diff.d.ts +1 -1
- package/dist/app/diff.js +1 -1
- package/dist/app/failures.d.ts +6 -0
- package/dist/app/failures.js +15 -0
- package/dist/app/load.d.ts +11 -5
- package/dist/app/load.js +22 -59
- package/dist/app/ports.d.ts +13 -3
- package/dist/builtins/advice.d.ts +4 -4
- package/dist/builtins/advice.js +1 -1
- package/dist/builtins/cognitive-complexity/{cognitiveComplexity.d.ts → rule.d.ts} +1 -1
- package/dist/builtins/cognitive-complexity/{cognitiveComplexity.js → rule.js} +1 -1
- package/dist/builtins/components.d.ts +1 -1
- package/dist/builtins/dependency-direction/rule.d.ts +2 -0
- package/dist/builtins/dependency-direction/{dependencyDirection.js → rule.js} +3 -3
- package/dist/builtins/file-cohesion/{fileCohesion.d.ts → rule.d.ts} +1 -1
- package/dist/builtins/file-cohesion/{fileCohesion.js → rule.js} +1 -1
- package/dist/builtins/function-cohesion/{functionCohesion.d.ts → rule.d.ts} +1 -1
- package/dist/builtins/function-cohesion/{functionCohesion.js → rule.js} +1 -1
- package/dist/builtins/index.d.ts +2 -2
- package/dist/builtins/index.js +18 -13
- package/dist/builtins/loops.d.ts +1 -1
- package/dist/builtins/loops.js +1 -1
- package/dist/builtins/module-cycle/{moduleCycle.d.ts → rule.d.ts} +1 -1
- package/dist/builtins/module-externals/rule.d.ts +2 -0
- package/dist/builtins/module-externals/{moduleExternals.js → rule.js} +3 -3
- package/dist/builtins/no-cross-module-reexport/rule.d.ts +2 -0
- package/dist/builtins/no-cross-module-reexport/{noCrossModuleReexport.js → rule.js} +1 -1
- package/dist/builtins/no-cycle/{noCycle.d.ts → rule.d.ts} +1 -1
- package/dist/builtins/no-double-export/rule.d.ts +2 -0
- package/dist/builtins/no-double-export/{noDoubleExport.js → rule.js} +1 -1
- package/dist/builtins/packages.d.ts +1 -1
- package/dist/builtins/place.d.ts +1 -1
- package/dist/builtins/shared.d.ts +1 -1
- package/dist/builtins/unclassified/rule.d.ts +2 -0
- package/dist/builtins/unclassified/rule.js +15 -0
- package/dist/builtins/unresolved-import/rule.d.ts +2 -0
- package/dist/builtins/unresolved-import/{unresolvedImport.js → rule.js} +1 -1
- package/dist/builtins/unused-declaration/declarations.d.ts +3 -3
- package/dist/builtins/unused-declaration/empty.d.ts +1 -1
- package/dist/builtins/unused-declaration/empty.js +1 -1
- package/dist/builtins/unused-declaration/grants.d.ts +1 -1
- package/dist/builtins/unused-declaration/grants.js +42 -10
- package/dist/builtins/unused-declaration/rule.d.ts +2 -0
- package/dist/builtins/unused-declaration/{unusedDeclaration.js → rule.js} +1 -1
- package/dist/builtins/unused-declaration/surfaces.d.ts +1 -1
- package/dist/builtins/unused-declaration/surfaces.js +1 -1
- package/dist/cli.js +34 -54
- package/dist/{model/archetype → domain/fixes}/fixes.d.ts +2 -2
- package/dist/{model/archetype → domain/fixes}/fixes.js +2 -6
- package/dist/domain/language/compile.d.ts +11 -0
- package/dist/domain/language/compile.js +58 -0
- package/dist/{model/archetype → domain/language}/references.d.ts +3 -6
- package/dist/{model/archetype → domain/language}/references.js +16 -21
- package/dist/{model/archetype → domain/language}/requirements.d.ts +3 -3
- package/dist/{model/archetype → domain/language}/requirements.js +2 -1
- package/dist/domain/language/rulesets.d.ts +10 -0
- package/dist/domain/language/rulesets.js +60 -0
- package/dist/{model/archetype/language.d.ts → domain/language/structure.d.ts} +4 -3
- package/dist/{model/archetype/language.js → domain/language/structure.js} +32 -12
- package/dist/{model/archetype → domain/model}/data.d.ts +9 -6
- package/dist/{model/archetype → domain/model}/reach.d.ts +1 -0
- package/dist/{model/archetype → domain/model}/reach.js +3 -7
- package/dist/{model/archetype → domain/model}/resolve.d.ts +2 -0
- package/dist/{model/archetype → domain/model}/resolve.js +6 -1
- package/dist/{model/archetype → domain/model}/settings.d.ts +0 -1
- package/dist/domain/model/settings.js +82 -0
- package/dist/domain/model/text.d.ts +4 -0
- package/dist/domain/model/text.js +13 -0
- package/dist/{rules → domain/rules}/registry.d.ts +1 -0
- package/dist/{rules → domain/rules}/registry.js +10 -0
- package/dist/{rules → domain/rules}/rule.d.ts +10 -4
- package/dist/index.d.ts +6 -6
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/analysis/folders.d.ts +0 -2
- package/dist/analysis/specifiers.d.ts +0 -2
- package/dist/analysis/specifiers.js +0 -6
- package/dist/analysis/typescript.d.ts +0 -2
- package/dist/app/unclassified.d.ts +0 -5
- package/dist/app/unclassified.js +0 -13
- package/dist/builtins/dependency-direction/dependencyDirection.d.ts +0 -2
- package/dist/builtins/module-externals/moduleExternals.d.ts +0 -2
- package/dist/builtins/no-cross-module-reexport/noCrossModuleReexport.d.ts +0 -2
- package/dist/builtins/no-double-export/noDoubleExport.d.ts +0 -2
- package/dist/builtins/unresolved-import/unresolvedImport.d.ts +0 -2
- package/dist/builtins/unused-declaration/unusedDeclaration.d.ts +0 -2
- package/dist/model/archetype/rulesets.d.ts +0 -5
- package/dist/model/archetype/rulesets.js +0 -139
- package/dist/model/archetype/settings.js +0 -54
- /package/dist/{analysis → adapters/analysis}/complexity.js +0 -0
- /package/dist/{analysis → adapters/analysis}/folders.js +0 -0
- /package/dist/{analysis → adapters/analysis}/members.js +0 -0
- /package/dist/{analysis → adapters/analysis}/source.d.ts +0 -0
- /package/dist/{analysis → adapters/analysis}/source.js +0 -0
- /package/dist/{git → adapters/git}/cache.js +0 -0
- /package/dist/{git → adapters/git}/repository.js +0 -0
- /package/dist/{config → adapters/git}/toolDigest.d.ts +0 -0
- /package/dist/{reporters → adapters/reporters}/agent.d.ts +0 -0
- /package/dist/{reporters → adapters/reporters}/agent.js +0 -0
- /package/dist/{reporters → adapters/reporters}/claudeHook.d.ts +0 -0
- /package/dist/{reporters → adapters/reporters}/claudeHook.js +0 -0
- /package/dist/{reporters → adapters/reporters}/index.d.ts +0 -0
- /package/dist/{reporters → adapters/reporters}/index.js +0 -0
- /package/dist/{reporters → adapters/reporters}/json.d.ts +0 -0
- /package/dist/{reporters → adapters/reporters}/json.js +0 -0
- /package/dist/{reporters → adapters/reporters}/model.js +0 -0
- /package/dist/{reporters → adapters/reporters}/omp.d.ts +0 -0
- /package/dist/{reporters → adapters/reporters}/omp.js +0 -0
- /package/dist/{reporters → adapters/reporters}/reporter.js +0 -0
- /package/dist/{reporters → adapters/reporters}/sarif.d.ts +0 -0
- /package/dist/{reporters → adapters/reporters}/sarif.js +0 -0
- /package/dist/{reporters → adapters/reporters}/text.js +0 -0
- /package/dist/builtins/module-cycle/{moduleCycle.js → rule.js} +0 -0
- /package/dist/builtins/no-cycle/{noCycle.js → rule.js} +0 -0
- /package/dist/{model → domain/facts}/facts.d.ts +0 -0
- /package/dist/{model → domain/facts}/facts.js +0 -0
- /package/dist/{model → domain/model}/configError.d.ts +0 -0
- /package/dist/{model → domain/model}/configError.js +0 -0
- /package/dist/{model/archetype → domain/model}/data.js +0 -0
- /package/dist/{model/archetype → domain/model}/shared.d.ts +0 -0
- /package/dist/{model/archetype → domain/model}/shared.js +0 -0
- /package/dist/{rules → domain/rules}/diff.d.ts +0 -0
- /package/dist/{rules → domain/rules}/diff.js +0 -0
- /package/dist/{rules → domain/rules}/rule.js +0 -0
package/dist/cli.js
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
3
|
-
import {
|
|
3
|
+
import { dirname, join, resolve } from 'node:path';
|
|
4
4
|
import { parseArgs } from 'node:util';
|
|
5
|
-
import { diskFolders } from './analysis/folders.js';
|
|
6
|
-
import { typescriptAnalyzer } from './analysis/typescript.js';
|
|
5
|
+
import { diskFolders } from './adapters/analysis/folders.js';
|
|
6
|
+
import { typescriptAnalyzer } from './adapters/analysis/typescript.js';
|
|
7
7
|
import { modelProject, projectCheck } from './app/check.js';
|
|
8
8
|
import { placeProblems } from './app/configLines.js';
|
|
9
|
-
import { factsStore } from './
|
|
9
|
+
import { factsStore } from './adapters/git/factsStore.js';
|
|
10
|
+
import { failures } from './app/failures.js';
|
|
10
11
|
import { diffProject, parseRange } from './app/diff.js';
|
|
11
|
-
import {
|
|
12
|
-
import { findConfig,
|
|
13
|
-
import { toolDigest } from './
|
|
14
|
-
import { gitDirCache } from './git/cache.js';
|
|
15
|
-
import { gitRepository, projectPathOf } from './git/repository.js';
|
|
16
|
-
import { anyRuleOn, rulesOf } from './model/
|
|
17
|
-
import { recommended } from './
|
|
18
|
-
import {
|
|
19
|
-
import { ConfigError } from './model/configError.js';
|
|
20
|
-
import { reporters } from './reporters/index.js';
|
|
21
|
-
import { modelJson, modelText } from './reporters/model.js';
|
|
22
|
-
import { actionable } from './reporters/reporter.js';
|
|
12
|
+
import { warp } from './builtins/index.js';
|
|
13
|
+
import { findConfig, yamlConfig } from './adapters/config/loadConfig.js';
|
|
14
|
+
import { toolDigest } from './adapters/git/toolDigest.js';
|
|
15
|
+
import { gitDirCache } from './adapters/git/cache.js';
|
|
16
|
+
import { gitRepository, projectPathOf } from './adapters/git/repository.js';
|
|
17
|
+
import { anyRuleOn, rulesOf } from './domain/model/settings.js';
|
|
18
|
+
import { recommended } from './domain/language/compile.js';
|
|
19
|
+
import { loadConfig } from './app/load.js';
|
|
20
|
+
import { ConfigError } from './domain/model/configError.js';
|
|
21
|
+
import { reporters } from './adapters/reporters/index.js';
|
|
22
|
+
import { modelJson, modelText } from './adapters/reporters/model.js';
|
|
23
|
+
import { actionable } from './adapters/reporters/reporter.js';
|
|
23
24
|
const usage = `usage:
|
|
24
|
-
warp check [--config <file>] [--
|
|
25
|
-
warp diff <base>[..<head> | ...<head>] [--since-last-run] [--config <file>] [--
|
|
26
|
-
warp model [--config <file>] [--
|
|
25
|
+
warp check [--config <file>] [--reporter <name>] [--fail]
|
|
26
|
+
warp diff <base>[..<head> | ...<head>] [--since-last-run] [--config <file>] [--reporter <name>] [--fail]
|
|
27
|
+
warp model [--config <file>] [--rules] [--json]
|
|
27
28
|
|
|
28
29
|
check reports every finding in the working tree.
|
|
29
30
|
diff reports findings that are new or worse at <head> than at <base>. Without <head>, compares the working tree.
|
|
@@ -32,16 +33,17 @@ diff reports findings that are new or worse at <head> than at <base>. Without
|
|
|
32
33
|
model prints the modules the config finds, and which module each file is in.
|
|
33
34
|
|
|
34
35
|
--config path to the config file (default: warp.yaml)
|
|
35
|
-
--ruleset one of the config's rulesets (default: the one named default, if any)
|
|
36
36
|
--reporter ${[...reporters.keys()].join(', ')} (default: text)
|
|
37
37
|
--since-last-run with diff, compare with the last diff run that had this flag
|
|
38
38
|
--fail exit 1 when there are findings (check) or new or worse findings (diff)
|
|
39
39
|
--rules with model, list each module's rule settings that differ from the defaults
|
|
40
40
|
--json print the model as JSON, with every module's resolved rule settings`;
|
|
41
|
+
let toolHash;
|
|
42
|
+
const tool = () => (toolHash ??= toolDigest());
|
|
41
43
|
const adaptersAt = (root) => {
|
|
42
44
|
const adapters = { analyzer: typescriptAnalyzer, foldersAt: diskFolders };
|
|
43
45
|
try {
|
|
44
|
-
return { ...adapters, facts: factsStore(gitDirCache(root),
|
|
46
|
+
return { ...adapters, facts: factsStore(gitDirCache(root), tool(), gitRepository(root).projectPath()) };
|
|
45
47
|
}
|
|
46
48
|
catch {
|
|
47
49
|
return adapters;
|
|
@@ -53,7 +55,6 @@ const main = async (argv) => {
|
|
|
53
55
|
allowPositionals: true,
|
|
54
56
|
options: {
|
|
55
57
|
config: { type: 'string' },
|
|
56
|
-
ruleset: { type: 'string' },
|
|
57
58
|
rules: { type: 'boolean', default: false },
|
|
58
59
|
reporter: { type: 'string', default: 'text' },
|
|
59
60
|
fail: { type: 'boolean', default: false },
|
|
@@ -83,22 +84,13 @@ const help = (code) => {
|
|
|
83
84
|
const resolveConfig = async (options) => {
|
|
84
85
|
const configFile = realpathSync(options.config ? resolve(options.config) : findConfig(process.cwd()));
|
|
85
86
|
const root = dirname(configFile);
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
for (const tsconfig of config.tsconfig.filter((path) => !existsSync(join(root, path))))
|
|
92
|
-
throw new ConfigError(`tsconfig: no ${tsconfig} beside ${file}; add it, or list the project's tsconfig files under tsconfig`);
|
|
93
|
-
return { root, config, rules, lines, digest };
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
if (error instanceof ConfigError)
|
|
97
|
-
throw new ConfigError(placeProblems(lines, file, error.message));
|
|
98
|
-
throw error;
|
|
99
|
-
}
|
|
87
|
+
const source = yamlConfig(configFile);
|
|
88
|
+
const loaded = await loadConfig(source, { builtins: warp });
|
|
89
|
+
for (const tsconfig of loaded.config.tsconfig.filter((path) => !existsSync(join(root, path))))
|
|
90
|
+
throw new ConfigError(placeProblems(loaded.lines, source.file, `tsconfig: no ${tsconfig} beside ${source.file}; add it, or list the project's tsconfig files under tsconfig`));
|
|
91
|
+
return { root, ...loaded };
|
|
100
92
|
};
|
|
101
|
-
const checkOf = ({ root, config, rules, lines }) => projectCheck(adaptersAt(root), config, { rules,
|
|
93
|
+
const checkOf = ({ root, config, rules, lines }) => projectCheck(adaptersAt(root), config, { rules, lines });
|
|
102
94
|
const run = async (options, produce) => {
|
|
103
95
|
const reporter = reporters.get(options.reporter);
|
|
104
96
|
if (!reporter)
|
|
@@ -112,13 +104,13 @@ const run = async (options, produce) => {
|
|
|
112
104
|
if (output)
|
|
113
105
|
console.log(output);
|
|
114
106
|
if (reporter.renderFailure)
|
|
115
|
-
|
|
107
|
+
lastFailure().forget();
|
|
116
108
|
return options.fail && actionable(report).length > 0 ? 1 : 0;
|
|
117
109
|
}
|
|
118
110
|
catch (error) {
|
|
119
111
|
const code = failed(error, reporter.failureExitCode);
|
|
120
112
|
const problem = describe(error);
|
|
121
|
-
if (!reporter.renderFailure || !
|
|
113
|
+
if (!reporter.renderFailure || !lastFailure().isNew(problem))
|
|
122
114
|
return code;
|
|
123
115
|
console.log(reporter.renderFailure(problem));
|
|
124
116
|
return 0;
|
|
@@ -134,8 +126,7 @@ const placed = ({ lines, config }, run) => {
|
|
|
134
126
|
throw error;
|
|
135
127
|
}
|
|
136
128
|
};
|
|
137
|
-
const nothingOn = (file) => `No rules are on, so nothing was checked. Turn some on in ${file}:
|
|
138
|
-
const failureKey = () => `${toolDigest()}-failure`;
|
|
129
|
+
const nothingOn = (file) => `No rules are on, so nothing was checked. Turn some on in ${file}: root: { ruleset: [${recommended}] }`;
|
|
139
130
|
const failureCache = () => {
|
|
140
131
|
try {
|
|
141
132
|
return gitDirCache(process.cwd());
|
|
@@ -144,18 +135,7 @@ const failureCache = () => {
|
|
|
144
135
|
return undefined;
|
|
145
136
|
}
|
|
146
137
|
};
|
|
147
|
-
const
|
|
148
|
-
const cache = failureCache();
|
|
149
|
-
if (cache?.get(failureKey()) === problem)
|
|
150
|
-
return false;
|
|
151
|
-
cache?.set(failureKey(), problem);
|
|
152
|
-
return true;
|
|
153
|
-
};
|
|
154
|
-
const forgetFailure = () => {
|
|
155
|
-
const cache = failureCache();
|
|
156
|
-
if (cache?.get(failureKey()) !== undefined)
|
|
157
|
-
cache.prune((key) => key !== failureKey());
|
|
158
|
-
};
|
|
138
|
+
const lastFailure = () => failures(failureCache(), tool());
|
|
159
139
|
const printModel = async (options) => {
|
|
160
140
|
try {
|
|
161
141
|
const resolved = await resolveConfig(options);
|
|
@@ -169,7 +149,7 @@ const printModel = async (options) => {
|
|
|
169
149
|
return failed(error);
|
|
170
150
|
}
|
|
171
151
|
};
|
|
172
|
-
const delta = (range, root, project, configDigest, sinceLastRun) => diffProject({ range: parseRange(range), root, project, configDigest, toolDigest:
|
|
152
|
+
const delta = (range, root, project, configDigest, sinceLastRun) => diffProject({ range: parseRange(range), root, project, configDigest, toolDigest: tool(), sinceLastRun }, { repository: gitRepository(root), cache: gitDirCache(root) });
|
|
173
153
|
const version = () => JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
|
|
174
154
|
const describe = (error) => error instanceof ConfigError
|
|
175
155
|
? `warp config: ${error.message}`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ConfigData, RefData } from '
|
|
2
|
-
import type
|
|
1
|
+
import type { ConfigData, RefData } from '../model/data.ts';
|
|
2
|
+
import { type Model, type ModuleView } from '../model/resolve.ts';
|
|
3
3
|
export interface Site {
|
|
4
4
|
label: string;
|
|
5
5
|
holder: ModuleView;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { instanceOf, verdicts } from '
|
|
2
|
-
|
|
3
|
-
for (let at = module.parent; at; at = at.parent)
|
|
4
|
-
yield at;
|
|
5
|
-
};
|
|
1
|
+
import { instanceOf, verdicts } from '../model/reach.js';
|
|
2
|
+
import { ancestors, subtree } from '../model/resolve.js';
|
|
6
3
|
const lineage = (module) => [module, ...ancestors(module)];
|
|
7
4
|
export const namedArchetype = (config, name) => config.archetypes[name].inline ? namedArchetype(config, name.slice(0, name.lastIndexOf('.'))) : name;
|
|
8
5
|
const withArchetype = (config, name, change) => ({
|
|
@@ -208,7 +205,6 @@ const exposeFilesModule = (search, config, hiddenBy) => {
|
|
|
208
205
|
})),
|
|
209
206
|
};
|
|
210
207
|
};
|
|
211
|
-
const subtree = (module) => [module, ...module.children.flatMap(subtree)];
|
|
212
208
|
const uses = (config, model, from, under) => {
|
|
213
209
|
const judge = verdicts(config, model);
|
|
214
210
|
const reached = subtree(from).flatMap((module) => module.files.slice(0, 1).flatMap((file) => (judge.reach(file) ?? []).flatMap((grant) => [...grant.files])));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ConfigData } from '../model/data.ts';
|
|
2
|
+
import { type Check } from './references.ts';
|
|
3
|
+
export { recommended } from './rulesets.ts';
|
|
4
|
+
export interface CompileOptions {
|
|
5
|
+
file?: string;
|
|
6
|
+
plugins?: readonly string[];
|
|
7
|
+
rulesets?: Readonly<Record<string, unknown>>;
|
|
8
|
+
ruleIds?: ReadonlySet<string> | undefined;
|
|
9
|
+
options?: Check['options'];
|
|
10
|
+
}
|
|
11
|
+
export declare const compileConfig: (raw: unknown, { file, plugins, rulesets, ruleIds, options }?: CompileOptions) => ConfigData;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ConfigError } from '../model/configError.js';
|
|
2
|
+
import { defined, isName, isRecord } from '../model/shared.js';
|
|
3
|
+
import { checkReferences, toRules } from './references.js';
|
|
4
|
+
import { checkInputs, markTests } from './requirements.js';
|
|
5
|
+
import { rulesets as namedRulesets } from './rulesets.js';
|
|
6
|
+
import { parseStructure } from './structure.js';
|
|
7
|
+
export { recommended } from './rulesets.js';
|
|
8
|
+
const keys = ['root', 'archetypes', 'rulesets', 'plugins', 'tsconfig'];
|
|
9
|
+
export const compileConfig = (raw, { file = 'warp.yaml', plugins = [], rulesets = {}, ruleIds, options = {} } = {}) => {
|
|
10
|
+
const errors = [];
|
|
11
|
+
const fail = (message) => {
|
|
12
|
+
if (!errors.includes(message))
|
|
13
|
+
errors.push(message);
|
|
14
|
+
};
|
|
15
|
+
const failed = () => {
|
|
16
|
+
if (errors.length > 0)
|
|
17
|
+
throw new ConfigError(errors.join('\n'));
|
|
18
|
+
};
|
|
19
|
+
if (!isRecord(raw))
|
|
20
|
+
throw new ConfigError(`${file}: expected a mapping, root: { modules: ... }`);
|
|
21
|
+
const unknownKeys = Object.keys(raw).filter((key) => !keys.includes(key));
|
|
22
|
+
for (const key of unknownKeys)
|
|
23
|
+
fail(`${key}: unknown key; a config takes ${keys.join(', ')}`);
|
|
24
|
+
checkPlugins(raw.plugins, plugins, fail);
|
|
25
|
+
const check = { fail, ruleIds, options };
|
|
26
|
+
const named = namedRulesets(raw.rulesets, rulesets, (value, at) => toRules(check, value, at), fail);
|
|
27
|
+
const structure = parseStructure(raw.root, raw.archetypes, fail, named.parse);
|
|
28
|
+
named.checkUsed();
|
|
29
|
+
failed();
|
|
30
|
+
checkReferences(structure.archetypes, structure.pending, fail);
|
|
31
|
+
markTests(structure.archetypes, fail);
|
|
32
|
+
checkInputs(structure.archetypes, structure.pending, fail);
|
|
33
|
+
const config = {
|
|
34
|
+
file,
|
|
35
|
+
root: structure.root,
|
|
36
|
+
archetypes: Object.fromEntries(Object.entries(structure.archetypes).map(([name, archetype]) => [name, archetypeData(archetype)])),
|
|
37
|
+
tsconfig: tsconfigs(raw.tsconfig, fail),
|
|
38
|
+
};
|
|
39
|
+
failed();
|
|
40
|
+
return config;
|
|
41
|
+
};
|
|
42
|
+
const archetypeData = (archetype) => defined({ ...archetype, modules: archetype.modules.map(defined) });
|
|
43
|
+
const checkPlugins = (declared, loaded, fail) => {
|
|
44
|
+
if (declared === undefined)
|
|
45
|
+
return;
|
|
46
|
+
if (!isRecord(declared) || !Object.values(declared).every(isName)) {
|
|
47
|
+
fail('plugins: expected plugin paths by namespace, { wt: ./rules/wt.ts }');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
for (const namespace of Object.keys(declared).filter((namespace) => !loaded.includes(namespace)))
|
|
51
|
+
fail(`plugins.${namespace}: not loaded; warp loads each plugin from its path before reading the config`);
|
|
52
|
+
};
|
|
53
|
+
const tsconfigs = (value, fail) => {
|
|
54
|
+
const paths = [value ?? 'tsconfig.json'].flat();
|
|
55
|
+
if (paths.length === 0 || !paths.every(isName))
|
|
56
|
+
fail('tsconfig: expected a path or a list of paths');
|
|
57
|
+
return paths;
|
|
58
|
+
};
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { type ArchetypeData, type ExposesData, type
|
|
2
|
-
import type { PendingRef } from './
|
|
3
|
-
import { type Fail } from '
|
|
1
|
+
import { type ArchetypeData, type ExposesData, type RuleSettingsData } from '../model/data.ts';
|
|
2
|
+
import type { PendingRef } from './structure.ts';
|
|
3
|
+
import { type Fail } from '../model/shared.ts';
|
|
4
4
|
export interface Check {
|
|
5
5
|
fail: Fail;
|
|
6
6
|
ruleIds?: ReadonlySet<string> | undefined;
|
|
7
7
|
options: Readonly<Record<string, (raw: Record<string, unknown>, at: string) => unknown>>;
|
|
8
8
|
}
|
|
9
|
-
export declare const packageText: (pattern: string) => string;
|
|
10
|
-
export declare const show: (ref: RefData) => string;
|
|
11
9
|
export declare const checkReferences: (archetypes: Record<string, ArchetypeData>, pending: readonly PendingRef[], fail: Fail) => void;
|
|
12
10
|
interface Surfaces {
|
|
13
11
|
exposes: ExposesData | undefined;
|
|
14
12
|
testExposes: readonly string[];
|
|
15
13
|
}
|
|
16
14
|
export declare const exposedProblem: (subject: string, { exposes, testExposes }: Surfaces, surface: string | undefined, tests: boolean) => string | undefined;
|
|
17
|
-
export declare const exposesText: (exposes: ExposesData | undefined) => string;
|
|
18
15
|
export declare const toRules: (check: Check, value: unknown, where: string) => RuleSettingsData | undefined;
|
|
19
16
|
export {};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { ConfigError } from '../configError.js';
|
|
2
|
-
import { isTestData } from '
|
|
3
|
-
import { isRecord, list } from '
|
|
4
|
-
|
|
5
|
-
export const show = (ref) => ref.kind === 'package'
|
|
6
|
-
? packageText(ref.pattern)
|
|
7
|
-
: `${ref.kind === 'module' && ref.top ? 'top.' : ''}${ref.kind === 'required' ? ref.name : ref.module}${ref.surface === undefined ? '' : `.${ref.surface}`}`;
|
|
1
|
+
import { ConfigError } from '../model/configError.js';
|
|
2
|
+
import { isTestData } from '../model/data.js';
|
|
3
|
+
import { isRecord, list } from '../model/shared.js';
|
|
4
|
+
import { exposesText, show } from '../model/text.js';
|
|
8
5
|
export const checkReferences = (archetypes, pending, fail) => {
|
|
9
6
|
for (const entry of pending) {
|
|
10
7
|
const problem = refProblem(archetypes, entry);
|
|
@@ -48,35 +45,33 @@ export const exposedProblem = (subject, { exposes, testExposes }, surface, tests
|
|
|
48
45
|
return `${subject} exposes ${list(named, 'nothing')}`;
|
|
49
46
|
return `${subject} exposes ${exposesText(exposes)}, not named surfaces`;
|
|
50
47
|
};
|
|
51
|
-
export const exposesText = (exposes) => {
|
|
52
|
-
if (exposes === undefined)
|
|
53
|
-
return 'nothing';
|
|
54
|
-
if (exposes.kind === 'all')
|
|
55
|
-
return 'all its files';
|
|
56
|
-
if (exposes.kind === 'files')
|
|
57
|
-
return `{ files: [${exposes.patterns.join(', ')}] }`;
|
|
58
|
-
return Object.keys(exposes.surfaces).join(', ');
|
|
59
|
-
};
|
|
60
48
|
export const toRules = (check, value, where) => {
|
|
61
|
-
if (value === undefined
|
|
62
|
-
return
|
|
49
|
+
if (value === undefined)
|
|
50
|
+
return undefined;
|
|
51
|
+
if (value === 'off')
|
|
52
|
+
return { '*': false };
|
|
63
53
|
if (!isRecord(value)) {
|
|
64
54
|
check.fail(`${where}: expected off or rule settings by id`);
|
|
65
55
|
return undefined;
|
|
66
56
|
}
|
|
67
|
-
return Object.fromEntries(Object.entries(value).
|
|
57
|
+
return Object.fromEntries(Object.entries(value).flatMap(([id, setting]) => {
|
|
58
|
+
const parsed = toSetting(check, id, setting, where);
|
|
59
|
+
return parsed === undefined ? [] : [[id, parsed]];
|
|
60
|
+
}));
|
|
68
61
|
};
|
|
69
62
|
const toSetting = (check, id, setting, where) => {
|
|
70
63
|
if (id !== '*' && check.ruleIds && !check.ruleIds.has(id))
|
|
71
64
|
check.fail(`${where}: no rule called ${id}`);
|
|
65
|
+
else if (id === '*' && setting !== 'off' && setting !== false)
|
|
66
|
+
check.fail(`${where}.*: expected off; turn rules on by name, or extend a ruleset such as warp:recommended`);
|
|
72
67
|
else if (setting === 'on' || setting === 'off')
|
|
73
68
|
return setting === 'on';
|
|
74
69
|
else if (typeof setting === 'boolean')
|
|
75
70
|
return setting;
|
|
76
|
-
else if (
|
|
71
|
+
else if (isRecord(setting))
|
|
77
72
|
return checkOptions(check, id, setting, where);
|
|
78
73
|
else
|
|
79
|
-
check.fail(`${where}.${id}: expected on, off
|
|
74
|
+
check.fail(`${where}.${id}: expected on, off or options`);
|
|
80
75
|
return undefined;
|
|
81
76
|
};
|
|
82
77
|
const checkOptions = (check, id, options, where) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ArchetypeData } from '
|
|
2
|
-
import type { PendingRef } from './
|
|
3
|
-
import type { Fail } from '
|
|
1
|
+
import type { ArchetypeData } from '../model/data.ts';
|
|
2
|
+
import type { PendingRef } from './structure.ts';
|
|
3
|
+
import type { Fail } from '../model/shared.ts';
|
|
4
4
|
export declare const markTests: (archetypes: Record<string, ArchetypeData>, fail: Fail) => void;
|
|
5
5
|
export declare const checkInputs: (archetypes: Record<string, ArchetypeData>, pending: readonly PendingRef[], fail: Fail) => void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { exposedProblem
|
|
1
|
+
import { exposedProblem } from './references.js';
|
|
2
|
+
import { show } from '../model/text.js';
|
|
2
3
|
const namedOf = (archetype) => archetype.split('.')[0];
|
|
3
4
|
const sitesOf = (archetypes) => Object.values(archetypes).flatMap((holder) => holder.modules
|
|
4
5
|
.filter((module) => module.kind === 'dir' && !archetypes[module.archetype]?.inline)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RuleSettingsData, RulesetData } from '../model/data.ts';
|
|
2
|
+
import { type Fail } from '../model/shared.ts';
|
|
3
|
+
export type ParseRules = (value: unknown, at: string) => RuleSettingsData | undefined;
|
|
4
|
+
export type ParseRuleset = (value: unknown, at: string) => RulesetData | undefined;
|
|
5
|
+
export interface Rulesets {
|
|
6
|
+
parse: ParseRuleset;
|
|
7
|
+
checkUsed(): void;
|
|
8
|
+
}
|
|
9
|
+
export declare const recommended = "warp:recommended";
|
|
10
|
+
export declare const rulesets: (named: unknown, shared: Readonly<Record<string, unknown>>, parseRules: ParseRules, fail: Fail) => Rulesets;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { isRecord, list } from '../model/shared.js';
|
|
2
|
+
export const recommended = 'warp:recommended';
|
|
3
|
+
const rulesetKeys = ['extends', 'rules'];
|
|
4
|
+
export const rulesets = (named, shared, parseRules, fail) => {
|
|
5
|
+
const state = {
|
|
6
|
+
local: localRulesets(named, fail),
|
|
7
|
+
shared,
|
|
8
|
+
parseRules,
|
|
9
|
+
fail,
|
|
10
|
+
extended: new Set(),
|
|
11
|
+
};
|
|
12
|
+
return {
|
|
13
|
+
parse: (value, at) => (value === undefined ? undefined : flatten(state, value, at, [])),
|
|
14
|
+
checkUsed: () => {
|
|
15
|
+
for (const name of [...state.local.keys()].filter((name) => !state.extended.has(name)))
|
|
16
|
+
fail(`rulesets.${name}: nothing extends it; a named ruleset applies through a ruleset's extends`);
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
const localRulesets = (value, fail) => {
|
|
21
|
+
if (value === undefined)
|
|
22
|
+
return new Map();
|
|
23
|
+
if (!isRecord(value)) {
|
|
24
|
+
fail('rulesets: expected rulesets by name, { strict: { rules: {...} } }');
|
|
25
|
+
return new Map();
|
|
26
|
+
}
|
|
27
|
+
for (const name of Object.keys(value).filter((name) => name.includes(':')))
|
|
28
|
+
fail(`rulesets.${name}: a name has no ':', which marks a plugin's ruleset`);
|
|
29
|
+
return new Map(Object.entries(value).filter(([name]) => !name.includes(':')));
|
|
30
|
+
};
|
|
31
|
+
const flatten = (state, value, at, seen) => {
|
|
32
|
+
const def = Array.isArray(value) ? { extends: value } : value === 'off' ? { rules: 'off' } : value;
|
|
33
|
+
if (!isRecord(def)) {
|
|
34
|
+
state.fail(`${at}: expected a ruleset, off, [${recommended}] or { extends: [${recommended}], rules: {...} }`);
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
for (const key of Object.keys(def).filter((key) => !rulesetKeys.includes(key)))
|
|
38
|
+
state.fail(`${at}: unknown key ${key}; a ruleset takes ${rulesetKeys.join(', ')}`);
|
|
39
|
+
const bases = [def.extends ?? []].flat().flatMap((base) => baseOf(state, base, `${at}.extends`, seen));
|
|
40
|
+
const own = state.parseRules(def.rules, `${at}.rules`);
|
|
41
|
+
return own ? [...bases, own] : bases;
|
|
42
|
+
};
|
|
43
|
+
const baseOf = (state, base, at, seen) => {
|
|
44
|
+
const local = typeof base === 'string' && state.local.has(base);
|
|
45
|
+
if (typeof base !== 'string' || !(local || Object.hasOwn(state.shared, base))) {
|
|
46
|
+
const known = [...Object.keys(state.shared), ...state.local.keys()];
|
|
47
|
+
state.fail(`${at}: '${String(base)}' is no ruleset; extend ${list(known, 'nothing')}`);
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
if (seen.includes(base)) {
|
|
51
|
+
state.fail(`${at}: ${[...seen, base].join(' extends ')}, a loop`);
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
state.extended.add(base);
|
|
55
|
+
return resolveNamed(state, base, local, seen);
|
|
56
|
+
};
|
|
57
|
+
const resolveNamed = (state, name, local, seen) => {
|
|
58
|
+
const def = local ? state.local.get(name) : state.shared[name];
|
|
59
|
+
return flatten(state, def, local ? `rulesets.${name}` : name, [...seen, name]);
|
|
60
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { ArchetypeData, RefData } from '
|
|
2
|
-
import { type Fail } from '
|
|
1
|
+
import type { ArchetypeData, RefData } from '../model/data.ts';
|
|
2
|
+
import { type Fail } from '../model/shared.ts';
|
|
3
|
+
import type { ParseRuleset } from './rulesets.ts';
|
|
3
4
|
export interface PendingRef {
|
|
4
5
|
ref: RefData;
|
|
5
6
|
where: string;
|
|
@@ -13,4 +14,4 @@ export interface Structure {
|
|
|
13
14
|
pending: PendingRef[];
|
|
14
15
|
}
|
|
15
16
|
export declare const rootName = "root";
|
|
16
|
-
export declare const parseStructure: (root: unknown, archetypes: unknown, fail: Fail) => Structure;
|
|
17
|
+
export declare const parseStructure: (root: unknown, archetypes: unknown, fail: Fail, ruleset: ParseRuleset) => Structure;
|
|
@@ -1,20 +1,31 @@
|
|
|
1
|
-
import { isName, isRecord, list } from '
|
|
1
|
+
import { isName, isRecord, list } from '../model/shared.js';
|
|
2
2
|
export const rootName = 'root';
|
|
3
|
-
const moduleKeys = [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const moduleKeys = [
|
|
4
|
+
'description',
|
|
5
|
+
'dir',
|
|
6
|
+
'files',
|
|
7
|
+
'entry',
|
|
8
|
+
'archetype',
|
|
9
|
+
'dependencies',
|
|
10
|
+
'exposes',
|
|
11
|
+
'modules',
|
|
12
|
+
'test',
|
|
13
|
+
'ruleset',
|
|
14
|
+
];
|
|
15
|
+
const archetypeKeys = ['description', 'marker', 'requires', 'entry', 'exposes', 'modules', 'test', 'ruleset'];
|
|
16
|
+
const rootKeys = ['description', 'modules', 'test', 'ruleset'];
|
|
17
|
+
const testKeys = ['requires', 'dependencies', 'provides', 'exposes', 'modules', 'ruleset'];
|
|
7
18
|
const kindOf = new Map([
|
|
8
19
|
[archetypeKeys, 'an archetype'],
|
|
9
20
|
[rootKeys, 'the root'],
|
|
10
21
|
[testKeys, 'a test block'],
|
|
11
22
|
]);
|
|
12
|
-
const testModuleKeys = ['description', 'dir', 'files', 'archetype', 'dependencies', 'exposes', 'modules'];
|
|
13
|
-
export const parseStructure = (root, archetypes, fail) => {
|
|
23
|
+
const testModuleKeys = ['description', 'dir', 'files', 'archetype', 'dependencies', 'exposes', 'modules', 'ruleset'];
|
|
24
|
+
export const parseStructure = (root, archetypes, fail, ruleset) => {
|
|
14
25
|
const defs = archetypes === undefined ? {} : isRecord(archetypes) ? archetypes : {};
|
|
15
26
|
if (archetypes !== undefined && !isRecord(archetypes))
|
|
16
27
|
fail('archetypes: expected archetypes by name');
|
|
17
|
-
const state = { defs, archetypes: {}, pending: [], fail };
|
|
28
|
+
const state = { defs, archetypes: {}, pending: [], fail, ruleset };
|
|
18
29
|
if (Object.hasOwn(defs, rootName))
|
|
19
30
|
fail(`archetypes.${rootName}: root is the repository; name the archetype otherwise`);
|
|
20
31
|
for (const [name, def] of Object.entries(defs)) {
|
|
@@ -63,6 +74,7 @@ const archetype = (state, name, def, options) => {
|
|
|
63
74
|
const data = options.parent ? inlineData(state, name, where, test) : namedData(state, name, def, test);
|
|
64
75
|
if (options.test)
|
|
65
76
|
data.test = true;
|
|
77
|
+
Object.assign(data, rulesetsAt(state, where, def.ruleset, test.ruleset));
|
|
66
78
|
const scope = {
|
|
67
79
|
archetype: name,
|
|
68
80
|
names: new Set([...Object.keys(modules), ...Object.keys(testModules), ...filesTestNames(modules)]),
|
|
@@ -98,6 +110,11 @@ const inlineData = (state, name, where, test) => {
|
|
|
98
110
|
state.fail(`${where}.test.requires: only an archetype requires; its modules see what it requires`);
|
|
99
111
|
return { name, inline: true, requires: [], modules: [] };
|
|
100
112
|
};
|
|
113
|
+
const rulesetsAt = (state, where, ruleset, testRuleset) => {
|
|
114
|
+
const own = state.ruleset(ruleset, `${where}.ruleset`);
|
|
115
|
+
const tests = state.ruleset(testRuleset, `${where}.test.ruleset`);
|
|
116
|
+
return { ...(own ? { ruleset: own } : {}), ...(tests ? { testRuleset: tests } : {}) };
|
|
117
|
+
};
|
|
101
118
|
const testBlock = (state, where, value) => {
|
|
102
119
|
if (value === undefined)
|
|
103
120
|
return {};
|
|
@@ -185,6 +202,7 @@ const testFiles = (state, scope, name, def, of) => {
|
|
|
185
202
|
...(of === undefined ? {} : { of }),
|
|
186
203
|
using: references(state, scope, `${where}.dependencies`, def.dependencies, true),
|
|
187
204
|
...(exposed && exposed.kind !== 'surfaces' ? { exposes: exposed } : {}),
|
|
205
|
+
...rulesetsAt(state, where, def.ruleset, undefined),
|
|
188
206
|
...description(state, where, def.description),
|
|
189
207
|
};
|
|
190
208
|
};
|
|
@@ -213,7 +231,7 @@ const instance = (state, scope, name, def, test) => {
|
|
|
213
231
|
state.fail(`${where}.${key}: ${named} defines what is inside; declare ${key} there`);
|
|
214
232
|
const own = bindings(state, scope, `${where}.dependencies`, def.dependencies, test);
|
|
215
233
|
const testBlock = isRecord(def.test) ? def.test : {};
|
|
216
|
-
for (const key of Object.keys(testBlock).filter((key) => key !== 'dependencies'))
|
|
234
|
+
for (const key of Object.keys(testBlock).filter((key) => key !== 'dependencies' && key !== 'ruleset'))
|
|
217
235
|
state.fail(`${where}.test.${key}: ${named} defines its test code; declare ${key} there`);
|
|
218
236
|
const tests = bindings(state, scope, `${where}.test.dependencies`, testBlock.dependencies, true);
|
|
219
237
|
return {
|
|
@@ -225,6 +243,7 @@ const instance = (state, scope, name, def, test) => {
|
|
|
225
243
|
using: Object.values(own),
|
|
226
244
|
...(Object.keys(own).length > 0 ? { inputs: own } : {}),
|
|
227
245
|
...(Object.keys(tests).length > 0 ? { testInputs: tests } : {}),
|
|
246
|
+
...rulesetsAt(state, where, def.ruleset, testBlock.ruleset),
|
|
228
247
|
...description(state, where, def.description),
|
|
229
248
|
};
|
|
230
249
|
};
|
|
@@ -249,17 +268,18 @@ const filesModule = (state, scope, name, def) => {
|
|
|
249
268
|
for (const key of ['modules', 'entry'].filter((key) => def[key] !== undefined))
|
|
250
269
|
state.fail(`${where}.${key}: a files module has no modules; use dir for a folder of them`);
|
|
251
270
|
const exposed = exposes(state, scope, `${where}.exposes`, def.exposes, undefined, false, false);
|
|
271
|
+
const test = isRecord(def.test) ? def.test : {};
|
|
252
272
|
const module = {
|
|
253
273
|
kind: 'files',
|
|
254
274
|
name,
|
|
255
275
|
patterns: patterns(state, `${where}.files`, def.files),
|
|
256
276
|
using: references(state, scope, `${where}.dependencies`, def.dependencies, false),
|
|
257
277
|
...(exposed && exposed.kind !== 'surfaces' ? { exposes: exposed } : {}),
|
|
278
|
+
...rulesetsAt(state, where, def.ruleset, test.ruleset),
|
|
258
279
|
...description(state, where, def.description),
|
|
259
280
|
};
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
state.fail(`${where}.test.${key}: a files module's test block holds its test modules only`);
|
|
281
|
+
for (const key of Object.keys(test).filter((key) => key !== 'modules' && key !== 'ruleset'))
|
|
282
|
+
state.fail(`${where}.test.${key}: a files module's test block holds its test modules and ruleset only`);
|
|
263
283
|
const tests = test.modules === undefined ? {} : record(state, `${where}.test.modules`, test.modules);
|
|
264
284
|
const lifted = Object.entries(tests).map(([inner, raw]) => {
|
|
265
285
|
const testDef = record(state, `${where}.test.modules.${inner}`, raw);
|
|
@@ -15,7 +15,8 @@ export interface PackageRefData {
|
|
|
15
15
|
pattern: string;
|
|
16
16
|
}
|
|
17
17
|
export type RefData = ModuleRefData | RequiredRefData | PackageRefData;
|
|
18
|
-
export type RuleSettingsData =
|
|
18
|
+
export type RuleSettingsData = Record<string, boolean | Record<string, unknown>>;
|
|
19
|
+
export type RulesetData = readonly RuleSettingsData[];
|
|
19
20
|
export type ExposesData = {
|
|
20
21
|
kind: 'all';
|
|
21
22
|
} | {
|
|
@@ -34,7 +35,8 @@ export interface FilesModuleData {
|
|
|
34
35
|
exposes?: Exclude<ExposesData, {
|
|
35
36
|
kind: 'surfaces';
|
|
36
37
|
}>;
|
|
37
|
-
|
|
38
|
+
ruleset?: RulesetData;
|
|
39
|
+
testRuleset?: RulesetData;
|
|
38
40
|
description?: string;
|
|
39
41
|
}
|
|
40
42
|
export interface DirModuleData {
|
|
@@ -46,7 +48,8 @@ export interface DirModuleData {
|
|
|
46
48
|
using: RefData[];
|
|
47
49
|
inputs?: Record<string, RefData>;
|
|
48
50
|
testInputs?: Record<string, RefData>;
|
|
49
|
-
|
|
51
|
+
ruleset?: RulesetData;
|
|
52
|
+
testRuleset?: RulesetData;
|
|
50
53
|
description?: string;
|
|
51
54
|
}
|
|
52
55
|
export interface TestModuleData {
|
|
@@ -58,7 +61,7 @@ export interface TestModuleData {
|
|
|
58
61
|
exposes?: Exclude<ExposesData, {
|
|
59
62
|
kind: 'surfaces';
|
|
60
63
|
}>;
|
|
61
|
-
|
|
64
|
+
ruleset?: RulesetData;
|
|
62
65
|
description?: string;
|
|
63
66
|
}
|
|
64
67
|
export type ModuleData = FilesModuleData | DirModuleData | TestModuleData;
|
|
@@ -78,12 +81,12 @@ export interface ArchetypeData {
|
|
|
78
81
|
exposes?: ExposesData;
|
|
79
82
|
testExposes?: Record<string, RefData[]>;
|
|
80
83
|
testUsing?: RefData[];
|
|
81
|
-
|
|
84
|
+
ruleset?: RulesetData;
|
|
85
|
+
testRuleset?: RulesetData;
|
|
82
86
|
}
|
|
83
87
|
export interface ConfigData {
|
|
84
88
|
file: string;
|
|
85
89
|
root: string;
|
|
86
90
|
archetypes: Record<string, ArchetypeData>;
|
|
87
91
|
tsconfig: string[];
|
|
88
|
-
rules?: RuleSettingsData;
|
|
89
92
|
}
|
|
@@ -28,6 +28,7 @@ export type Verdict = {
|
|
|
28
28
|
} & Refusal);
|
|
29
29
|
export interface Verdicts {
|
|
30
30
|
reach(file: string): readonly Grant[] | undefined;
|
|
31
|
+
grants(module: ModuleView, view?: View): readonly Grant[];
|
|
31
32
|
exposes(module: ModuleView): ExposesData | undefined;
|
|
32
33
|
surface(module: ModuleView, name?: string, view?: View): ReadonlySet<string>;
|
|
33
34
|
verdict(from: string, to: string): Verdict | undefined;
|