@yearofthedan/warp 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +72 -2
- package/dist/analysis/complexity.d.ts +4 -0
- package/dist/analysis/complexity.js +84 -0
- package/dist/analysis/folders.d.ts +2 -0
- package/dist/analysis/folders.js +15 -0
- package/dist/analysis/imports.d.ts +13 -0
- package/dist/analysis/imports.js +135 -0
- package/dist/analysis/members.d.ts +4 -0
- package/dist/analysis/members.js +190 -0
- package/dist/analysis/source.d.ts +13 -0
- package/dist/analysis/source.js +29 -0
- package/dist/analysis/specifiers.d.ts +2 -0
- package/dist/analysis/specifiers.js +6 -0
- package/dist/analysis/typescript.d.ts +2 -0
- package/dist/analysis/typescript.js +105 -0
- package/dist/app/check.d.ts +23 -0
- package/dist/app/check.js +15 -0
- package/dist/app/checkModel.d.ts +5 -0
- package/dist/app/checkModel.js +30 -0
- package/dist/app/diff.d.ts +25 -0
- package/dist/app/diff.js +53 -0
- package/dist/app/facts.d.ts +7 -0
- package/dist/app/facts.js +55 -0
- package/dist/app/load.d.ts +13 -0
- package/dist/app/load.js +76 -0
- package/dist/app/ports.d.ts +41 -0
- package/dist/app/ports.js +1 -0
- package/dist/app/unclassified.d.ts +5 -0
- package/dist/app/unclassified.js +13 -0
- package/dist/builtins/cognitive-complexity/cognitiveComplexity.d.ts +6 -0
- package/dist/builtins/cognitive-complexity/cognitiveComplexity.js +26 -0
- package/dist/builtins/components.d.ts +2 -0
- package/dist/builtins/components.js +20 -0
- package/dist/builtins/dependency-direction/dependencyDirection.d.ts +2 -0
- package/dist/builtins/dependency-direction/dependencyDirection.js +68 -0
- package/dist/builtins/file-cohesion/fileCohesion.d.ts +6 -0
- package/dist/builtins/file-cohesion/fileCohesion.js +30 -0
- package/dist/builtins/function-cohesion/functionCohesion.d.ts +6 -0
- package/dist/builtins/function-cohesion/functionCohesion.js +30 -0
- package/dist/builtins/index.d.ts +4 -0
- package/dist/builtins/index.js +30 -0
- package/dist/builtins/loops.d.ts +25 -0
- package/dist/builtins/loops.js +64 -0
- package/dist/builtins/module-cycle/moduleCycle.d.ts +3 -0
- package/dist/builtins/module-cycle/moduleCycle.js +61 -0
- package/dist/builtins/module-externals/moduleExternals.d.ts +2 -0
- package/dist/builtins/module-externals/moduleExternals.js +41 -0
- package/dist/builtins/no-cross-module-reexport/noCrossModuleReexport.d.ts +2 -0
- package/dist/builtins/no-cross-module-reexport/noCrossModuleReexport.js +47 -0
- package/dist/builtins/no-cycle/noCycle.d.ts +3 -0
- package/dist/builtins/no-cycle/noCycle.js +39 -0
- package/dist/builtins/no-double-export/noDoubleExport.d.ts +2 -0
- package/dist/builtins/no-double-export/noDoubleExport.js +38 -0
- package/dist/builtins/packages.d.ts +2 -0
- package/dist/builtins/packages.js +5 -0
- package/dist/builtins/place.d.ts +2 -0
- package/dist/builtins/place.js +6 -0
- package/dist/builtins/shared.d.ts +10 -0
- package/dist/builtins/shared.js +13 -0
- package/dist/builtins/unused-declaration/declarations.d.ts +32 -0
- package/dist/builtins/unused-declaration/declarations.js +26 -0
- package/dist/builtins/unused-declaration/empty.d.ts +3 -0
- package/dist/builtins/unused-declaration/empty.js +22 -0
- package/dist/builtins/unused-declaration/grants.d.ts +3 -0
- package/dist/builtins/unused-declaration/grants.js +48 -0
- package/dist/builtins/unused-declaration/surfaces.d.ts +3 -0
- package/dist/builtins/unused-declaration/surfaces.js +57 -0
- package/dist/builtins/unused-declaration/unusedDeclaration.d.ts +2 -0
- package/dist/builtins/unused-declaration/unusedDeclaration.js +14 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +168 -0
- package/dist/config/loadConfig.d.ts +7 -0
- package/dist/config/loadConfig.js +53 -0
- package/dist/config/toolDigest.d.ts +1 -0
- package/dist/config/toolDigest.js +16 -0
- package/dist/git/cache.d.ts +3 -0
- package/dist/git/cache.js +41 -0
- package/dist/git/repository.d.ts +3 -0
- package/dist/git/repository.js +76 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +4 -0
- package/dist/model/archetype/builder.d.ts +183 -0
- package/dist/model/archetype/builder.js +85 -0
- package/dist/model/archetype/data.d.ts +92 -0
- package/dist/model/archetype/data.js +1 -0
- package/dist/model/archetype/draft.d.ts +37 -0
- package/dist/model/archetype/draft.js +275 -0
- package/dist/model/archetype/reach.d.ts +35 -0
- package/dist/model/archetype/reach.js +209 -0
- package/dist/model/archetype/references.d.ts +13 -0
- package/dist/model/archetype/references.js +166 -0
- package/dist/model/archetype/requirements.d.ts +5 -0
- package/dist/model/archetype/requirements.js +69 -0
- package/dist/model/archetype/resolve.d.ts +30 -0
- package/dist/model/archetype/resolve.js +315 -0
- package/dist/model/archetype/rulesets.d.ts +4 -0
- package/dist/model/archetype/rulesets.js +115 -0
- package/dist/model/archetype/settings.d.ts +21 -0
- package/dist/model/archetype/settings.js +64 -0
- package/dist/model/archetype/shared.d.ts +5 -0
- package/dist/model/archetype/shared.js +4 -0
- package/dist/model/configError.d.ts +3 -0
- package/dist/model/configError.js +3 -0
- package/dist/model/facts.d.ts +57 -0
- package/dist/model/facts.js +1 -0
- package/dist/reporters/agent.d.ts +4 -0
- package/dist/reporters/agent.js +24 -0
- package/dist/reporters/claudeHook.d.ts +2 -0
- package/dist/reporters/claudeHook.js +10 -0
- package/dist/reporters/index.d.ts +2 -0
- package/dist/reporters/index.js +9 -0
- package/dist/reporters/json.d.ts +2 -0
- package/dist/reporters/json.js +4 -0
- package/dist/reporters/model.d.ts +4 -0
- package/dist/reporters/model.js +60 -0
- package/dist/reporters/omp.d.ts +2 -0
- package/dist/reporters/omp.js +6 -0
- package/dist/reporters/reporter.d.ts +22 -0
- package/dist/reporters/reporter.js +5 -0
- package/dist/reporters/sarif.d.ts +2 -0
- package/dist/reporters/sarif.js +44 -0
- package/dist/reporters/text.d.ts +8 -0
- package/dist/reporters/text.js +39 -0
- package/dist/rules/diff.d.ts +10 -0
- package/dist/rules/diff.js +31 -0
- package/dist/rules/registry.d.ts +5 -0
- package/dist/rules/registry.js +33 -0
- package/dist/rules/rule.d.ts +59 -0
- package/dist/rules/rule.js +18 -0
- package/package.json +43 -4
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { childrenNamed, instancesOf, named, unused, within } from './declarations.js';
|
|
2
|
+
export const unusedSurfaces = (context) => {
|
|
3
|
+
const edges = context.project.files.flatMap((file) => file.imports.map((edge) => ({ from: file.path, to: edge.via ?? edge.to })));
|
|
4
|
+
return declared(context)
|
|
5
|
+
.filter((declaration) => declaration.holders.some((holder) => context.atModule(holder).on))
|
|
6
|
+
.filter((declaration) => !declaration.holders.some((holder) => reached(context, edges, holder, declaration.files(holder))))
|
|
7
|
+
.map(({ declaredIn, layer, exposes, holders }) => {
|
|
8
|
+
const modules = holders.map((holder) => holder.id);
|
|
9
|
+
const importers = layer === 'test' ? 'no test outside' : 'nothing outside';
|
|
10
|
+
return unused(context.config, `${declaredIn}:${exposes}`, `${declaredIn} ${exposes}, but ${importers} ${holders.map(named).join(', ')} imports it. Remove it, or use the module where it is needed.`, { kind: 'surface', declaredIn, layer, exposes, modules });
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
const reached = (context, edges, holder, files) => edges.some(({ from, to }) => files.has(to) && !within(context.model.moduleOf(from), holder));
|
|
14
|
+
const declared = (context) => Object.values(context.config.archetypes).flatMap((archetype) => {
|
|
15
|
+
const instances = instancesOf(context, archetype.name).filter((instance) => instance !== context.model.root);
|
|
16
|
+
const own = archetype.exposes ? production(context, archetype.name, archetype.exposes, instances) : [];
|
|
17
|
+
const modules = archetype.modules.flatMap((module) => {
|
|
18
|
+
const holders = childrenNamed(context, instances, module.name);
|
|
19
|
+
return module.kind === 'files' && module.exposes
|
|
20
|
+
? production(context, `${archetype.name}.${module.name}`, module.exposes, holders)
|
|
21
|
+
: [];
|
|
22
|
+
});
|
|
23
|
+
const tests = archetype.tests?.exposes ? test(`${archetype.name}.tests`, archetype.tests.exposes, instances) : [];
|
|
24
|
+
return [...own, ...modules, ...tests];
|
|
25
|
+
});
|
|
26
|
+
const production = (context, declaredIn, exposes, holders) => {
|
|
27
|
+
const layer = 'production';
|
|
28
|
+
if (exposes.kind !== 'surfaces')
|
|
29
|
+
return [
|
|
30
|
+
{ declaredIn, layer, exposes: whole(exposes), holders, files: (holder) => context.verdicts.surface(holder) },
|
|
31
|
+
];
|
|
32
|
+
return Object.keys(exposes.surfaces).map((name) => ({
|
|
33
|
+
declaredIn,
|
|
34
|
+
layer,
|
|
35
|
+
exposes: `exposes ${name}`,
|
|
36
|
+
holders,
|
|
37
|
+
files: (holder) => context.verdicts.surface(holder, name),
|
|
38
|
+
}));
|
|
39
|
+
};
|
|
40
|
+
const test = (declaredIn, exposes, holders) => {
|
|
41
|
+
const layer = 'test';
|
|
42
|
+
const filesOf = (holder, names) => new Set(holder.children
|
|
43
|
+
.filter((child) => child.test && (names === undefined || names.has(child.name)))
|
|
44
|
+
.flatMap((child) => child.files));
|
|
45
|
+
if (exposes.kind !== 'surfaces')
|
|
46
|
+
return [{ declaredIn, layer, exposes: whole(exposes), holders, files: (holder) => filesOf(holder) }];
|
|
47
|
+
return Object.entries(exposes.surfaces).map(([name, refs]) => {
|
|
48
|
+
const names = new Set(refs.flatMap((ref) => (ref.kind === 'module' ? [`tests.${ref.module}`] : [])));
|
|
49
|
+
return { declaredIn, layer, exposes: `exposes ${name}`, holders, files: (holder) => filesOf(holder, names) };
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
const whole = (exposes) => {
|
|
53
|
+
if (exposes.kind === 'all')
|
|
54
|
+
return 'exposes(all())';
|
|
55
|
+
const selector = `files(${exposes.patterns.map((pattern) => `'${pattern}'`).join(', ')})`;
|
|
56
|
+
return exposes.entry ? `.entry(${selector})` : `exposes(${selector})`;
|
|
57
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { noOptions } from '../../rules/rule.js';
|
|
2
|
+
import { holding, id } from './declarations.js';
|
|
3
|
+
import { emptyModules } from './empty.js';
|
|
4
|
+
import { unusedGrants } from './grants.js';
|
|
5
|
+
import { unusedSurfaces } from './surfaces.js';
|
|
6
|
+
export const unusedDeclaration = {
|
|
7
|
+
id,
|
|
8
|
+
scope: 'project',
|
|
9
|
+
parseOptions: noOptions,
|
|
10
|
+
check: (project) => {
|
|
11
|
+
const context = { ...project, held: holding(project) };
|
|
12
|
+
return [...unusedGrants(context), ...unusedSurfaces(context), ...emptyModules(context)];
|
|
13
|
+
},
|
|
14
|
+
};
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync, realpathSync } from 'node:fs';
|
|
3
|
+
import { basename, dirname, resolve } from 'node:path';
|
|
4
|
+
import { parseArgs } from 'node:util';
|
|
5
|
+
import { diskFolders } from './analysis/folders.js';
|
|
6
|
+
import { typescriptAnalyzer } from './analysis/typescript.js';
|
|
7
|
+
import { modelProject, projectCheck } from './app/check.js';
|
|
8
|
+
import { factsStore } from './app/facts.js';
|
|
9
|
+
import { diffProject, parseRange } from './app/diff.js';
|
|
10
|
+
import { builtinRegistry, unclassifiedDocs } from './builtins/index.js';
|
|
11
|
+
import { findConfig, loadConfig } from './config/loadConfig.js';
|
|
12
|
+
import { toolDigest } from './config/toolDigest.js';
|
|
13
|
+
import { gitDirCache } from './git/cache.js';
|
|
14
|
+
import { gitRepository, projectPathOf } from './git/repository.js';
|
|
15
|
+
import { rulesOf } from './model/archetype/settings.js';
|
|
16
|
+
import { loadConfigData } from './app/load.js';
|
|
17
|
+
import { ConfigError } from './model/configError.js';
|
|
18
|
+
import { reporters } from './reporters/index.js';
|
|
19
|
+
import { modelJson, modelText } from './reporters/model.js';
|
|
20
|
+
import { actionable } from './reporters/reporter.js';
|
|
21
|
+
const usage = `usage:
|
|
22
|
+
warp check [--config <file>] [--ruleset <name>] [--reporter <name>] [--fail]
|
|
23
|
+
warp diff <base>[..<head> | ...<head>] [--since-last-run] [--config <file>] [--ruleset <name>] [--reporter <name>] [--fail]
|
|
24
|
+
warp model [--config <file>] [--ruleset <name>] [--rules] [--json]
|
|
25
|
+
|
|
26
|
+
check reports every finding in the working tree.
|
|
27
|
+
diff reports findings that are new or worse at <head> than at <base>. Without <head>, compares the working tree.
|
|
28
|
+
<base>...<head> compares from where <head> left <base>, as git does.
|
|
29
|
+
With --since-last-run, compares the working tree with the last such run, or with <base> if there is none.
|
|
30
|
+
model prints the modules the config finds, and which module each file is in.
|
|
31
|
+
|
|
32
|
+
--config path to the config file (default: the first of warp.config.ts, .mts, .js, .mjs)
|
|
33
|
+
--ruleset one of the config's rulesets (default: the one named default, if any)
|
|
34
|
+
--reporter ${[...reporters.keys()].join(', ')} (default: text)
|
|
35
|
+
--since-last-run with diff, compare with the last diff run that had this flag
|
|
36
|
+
--fail exit 1 when there are findings (check) or new or worse findings (diff)
|
|
37
|
+
--rules with model, list each module's rule settings that differ from the defaults
|
|
38
|
+
--json print the model as JSON, with every module's resolved rule settings`;
|
|
39
|
+
const adaptersAt = (root) => {
|
|
40
|
+
const adapters = { analyzer: typescriptAnalyzer, foldersAt: diskFolders };
|
|
41
|
+
try {
|
|
42
|
+
return { ...adapters, facts: factsStore(gitDirCache(root), toolDigest(), gitRepository(root).projectPath()) };
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return adapters;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const main = async (argv) => {
|
|
49
|
+
const { values, positionals } = parseArgs({
|
|
50
|
+
args: argv,
|
|
51
|
+
allowPositionals: true,
|
|
52
|
+
options: {
|
|
53
|
+
config: { type: 'string' },
|
|
54
|
+
ruleset: { type: 'string' },
|
|
55
|
+
rules: { type: 'boolean', default: false },
|
|
56
|
+
reporter: { type: 'string', default: 'text' },
|
|
57
|
+
fail: { type: 'boolean', default: false },
|
|
58
|
+
'since-last-run': { type: 'boolean', default: false },
|
|
59
|
+
json: { type: 'boolean', default: false },
|
|
60
|
+
help: { type: 'boolean', short: 'h', default: false },
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
const [command, ...args] = positionals;
|
|
64
|
+
if (values.help)
|
|
65
|
+
return help(0);
|
|
66
|
+
if (command === 'check' && args.length === 0)
|
|
67
|
+
return run(values, (root, project) => ({ mode: 'check', findings: project.check(root) }));
|
|
68
|
+
if (command === 'diff' && args.length === 1)
|
|
69
|
+
return run(values, (root, project, digest) => ({
|
|
70
|
+
mode: 'diff',
|
|
71
|
+
delta: delta(args[0], root, project, digest, values['since-last-run']),
|
|
72
|
+
}));
|
|
73
|
+
if (command === 'model' && args.length === 0)
|
|
74
|
+
return printModel(values);
|
|
75
|
+
return help(2);
|
|
76
|
+
};
|
|
77
|
+
const help = (code) => {
|
|
78
|
+
(code === 0 ? console.log : console.error)(usage);
|
|
79
|
+
return code;
|
|
80
|
+
};
|
|
81
|
+
const resolveConfig = async (options) => {
|
|
82
|
+
const configFile = realpathSync(options.config ? resolve(options.config) : findConfig(process.cwd()));
|
|
83
|
+
const root = dirname(configFile);
|
|
84
|
+
const { raw, digest } = await loadConfig(configFile);
|
|
85
|
+
const builtins = [...builtinRegistry.values()];
|
|
86
|
+
const { config, rules, warnings } = loadConfigData(raw, {
|
|
87
|
+
builtins,
|
|
88
|
+
ruleset: options.ruleset,
|
|
89
|
+
file: basename(configFile),
|
|
90
|
+
});
|
|
91
|
+
for (const warning of warnings)
|
|
92
|
+
console.error(`warp config: ${warning}`);
|
|
93
|
+
return { root, config, rules, digest };
|
|
94
|
+
};
|
|
95
|
+
const checkOf = ({ root, config, rules }) => projectCheck(adaptersAt(root), config, { rules, unclassifiedDocs });
|
|
96
|
+
const run = async (options, produce) => {
|
|
97
|
+
const reporter = reporters.get(options.reporter);
|
|
98
|
+
if (!reporter)
|
|
99
|
+
throw new Error(`no reporter called ${options.reporter}: use one of ${[...reporters.keys()].join(', ')}`);
|
|
100
|
+
try {
|
|
101
|
+
const resolved = await resolveConfig(options);
|
|
102
|
+
const report = produce(resolved.root, checkOf(resolved), resolved.digest);
|
|
103
|
+
const output = reporter.render(report, { toolVersion: version(), projectPath: projectPathOf(resolved.root) });
|
|
104
|
+
if (output)
|
|
105
|
+
console.log(output);
|
|
106
|
+
if (reporter.renderFailure)
|
|
107
|
+
forgetFailure();
|
|
108
|
+
return options.fail && actionable(report).length > 0 ? 1 : 0;
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
const code = failed(error, reporter.failureExitCode);
|
|
112
|
+
const problem = describe(error);
|
|
113
|
+
if (!reporter.renderFailure || !isNewFailure(problem))
|
|
114
|
+
return code;
|
|
115
|
+
console.log(reporter.renderFailure(problem));
|
|
116
|
+
return 0;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const failureKey = () => `${toolDigest()}-failure`;
|
|
120
|
+
const failureCache = () => {
|
|
121
|
+
try {
|
|
122
|
+
return gitDirCache(process.cwd());
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
const isNewFailure = (problem) => {
|
|
129
|
+
const cache = failureCache();
|
|
130
|
+
if (cache?.get(failureKey()) === problem)
|
|
131
|
+
return false;
|
|
132
|
+
cache?.set(failureKey(), problem);
|
|
133
|
+
return true;
|
|
134
|
+
};
|
|
135
|
+
const forgetFailure = () => {
|
|
136
|
+
const cache = failureCache();
|
|
137
|
+
if (cache?.get(failureKey()) !== undefined)
|
|
138
|
+
cache.prune((key) => key !== failureKey());
|
|
139
|
+
};
|
|
140
|
+
const printModel = async (options) => {
|
|
141
|
+
try {
|
|
142
|
+
const { root, config, rules } = await resolveConfig(options);
|
|
143
|
+
const { model } = modelProject(adaptersAt(root), root, config);
|
|
144
|
+
const settings = rulesOf(config, model, rules);
|
|
145
|
+
console.log(options.json ? modelJson(model, settings) : modelText(model, options.rules ? settings : undefined));
|
|
146
|
+
return 0;
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
return failed(error);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
const delta = (range, root, project, configDigest, sinceLastRun) => diffProject({ range: parseRange(range), root, project, configDigest, toolDigest: toolDigest(), sinceLastRun }, { repository: gitRepository(root), cache: gitDirCache(root) });
|
|
153
|
+
const version = () => JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
|
|
154
|
+
const describe = (error) => error instanceof ConfigError
|
|
155
|
+
? `warp config: ${error.message}`
|
|
156
|
+
: error instanceof Error
|
|
157
|
+
? error.message
|
|
158
|
+
: String(error);
|
|
159
|
+
const failed = (error, exitCode = 2) => {
|
|
160
|
+
console.error(describe(error));
|
|
161
|
+
return exitCode;
|
|
162
|
+
};
|
|
163
|
+
try {
|
|
164
|
+
process.exitCode = await main(process.argv.slice(2));
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
process.exitCode = failed(error);
|
|
168
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx, extraExtensions, ignoreCase) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
if (extraExtensions) {
|
|
4
|
+
for (var extension in extraExtensions) {
|
|
5
|
+
var suffix = path.slice(-extension.length);
|
|
6
|
+
if (suffix === extension || ignoreCase && suffix.toLowerCase() === extension.toLowerCase()) {
|
|
7
|
+
var output = extraExtensions[extension];
|
|
8
|
+
return output === extension ? path : path.slice(0, -extension.length) + output;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
13
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return path;
|
|
17
|
+
};
|
|
18
|
+
import { createHash } from 'node:crypto';
|
|
19
|
+
import { existsSync } from 'node:fs';
|
|
20
|
+
import { registerHooks } from 'node:module';
|
|
21
|
+
import { join } from 'node:path';
|
|
22
|
+
import { pathToFileURL } from 'node:url';
|
|
23
|
+
import { ConfigError } from '../model/configError.js';
|
|
24
|
+
export const configNames = ['warp.config.ts', 'warp.config.mts', 'warp.config.js', 'warp.config.mjs'];
|
|
25
|
+
export const findConfig = (dir) => {
|
|
26
|
+
const found = configNames.map((name) => join(dir, name)).find((file) => existsSync(file));
|
|
27
|
+
if (!found)
|
|
28
|
+
throw new ConfigError(`no config in ${dir}: add one of ${configNames.join(', ')}`);
|
|
29
|
+
return found;
|
|
30
|
+
};
|
|
31
|
+
const entry = new URL(import.meta.url.endsWith('.ts') ? '../index.ts' : '../index.js', import.meta.url).href;
|
|
32
|
+
const ownFiles = new URL('../../', import.meta.url).href;
|
|
33
|
+
export const loadConfig = async (file) => {
|
|
34
|
+
const digest = createHash('sha256');
|
|
35
|
+
const hooks = registerHooks({
|
|
36
|
+
resolve: (specifier, context, nextResolve) => specifier === '@yearofthedan/warp' ? { url: entry, shortCircuit: true } : nextResolve(specifier, context),
|
|
37
|
+
load: (url, context, nextLoad) => {
|
|
38
|
+
const loaded = nextLoad(url, context);
|
|
39
|
+
if (url.startsWith('file:') && !url.startsWith(ownFiles))
|
|
40
|
+
digest.update(url).update(String(loaded.source ?? ''));
|
|
41
|
+
return loaded;
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
try {
|
|
45
|
+
const module = await import(__rewriteRelativeImportExtension(pathToFileURL(file).href));
|
|
46
|
+
if (module.default === undefined)
|
|
47
|
+
throw new ConfigError(`${file}: expected the config as its default export`);
|
|
48
|
+
return { raw: module.default, digest: digest.digest('hex') };
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
hooks.deregister();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const toolDigest: () => string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { readdirSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
const sourceDir = fileURLToPath(new URL('../', import.meta.url));
|
|
7
|
+
const code = /(?<!\.test)\.(ts|js)$/;
|
|
8
|
+
export const toolDigest = () => {
|
|
9
|
+
const digest = createHash('sha256').update(createRequire(import.meta.url)('typescript/package.json').version);
|
|
10
|
+
const files = readdirSync(sourceDir, { recursive: true, encoding: 'utf8' })
|
|
11
|
+
.filter((file) => code.test(file))
|
|
12
|
+
.sort();
|
|
13
|
+
for (const file of files)
|
|
14
|
+
digest.update(file).update(readFileSync(join(sourceDir, file)));
|
|
15
|
+
return digest.digest('hex').slice(0, 16);
|
|
16
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { mkdirSync, readdirSync, readFileSync, renameSync, rmSync, statSync, utimesSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { join, resolve } from 'node:path';
|
|
4
|
+
export const maxAgeMs = 30 * 24 * 60 * 60 * 1000;
|
|
5
|
+
export const gitDirCache = (projectRoot, now = Date.now) => {
|
|
6
|
+
const gitDir = execFileSync('git', ['rev-parse', '--git-common-dir'], { cwd: projectRoot, encoding: 'utf8' }).trim();
|
|
7
|
+
const dir = join(resolve(projectRoot, gitDir), 'warp-cache');
|
|
8
|
+
const file = (key) => join(dir, `${key}.json`);
|
|
9
|
+
const touch = (key) => {
|
|
10
|
+
const time = new Date(now());
|
|
11
|
+
utimesSync(file(key), time, time);
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
get(key) {
|
|
15
|
+
try {
|
|
16
|
+
const value = JSON.parse(readFileSync(file(key), 'utf8'));
|
|
17
|
+
touch(key);
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
set(key, value) {
|
|
25
|
+
mkdirSync(dir, { recursive: true });
|
|
26
|
+
const partial = `${file(key)}.${process.pid}`;
|
|
27
|
+
writeFileSync(partial, JSON.stringify(value));
|
|
28
|
+
renameSync(partial, file(key));
|
|
29
|
+
touch(key);
|
|
30
|
+
},
|
|
31
|
+
prune(keep) {
|
|
32
|
+
for (const name of readdirSync(dir)) {
|
|
33
|
+
if (!name.endsWith('.json'))
|
|
34
|
+
continue;
|
|
35
|
+
const path = join(dir, name);
|
|
36
|
+
if (!keep(name.slice(0, -'.json'.length)) || now() - statSync(path).mtimeMs > maxAgeMs)
|
|
37
|
+
rmSync(path, { force: true });
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { existsSync, mkdtempSync, realpathSync, rmSync, symlinkSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join, relative, sep } from 'node:path';
|
|
5
|
+
export const gitRepository = (projectRoot) => {
|
|
6
|
+
const git = (...args) => execFileSync('git', args, { cwd: projectRoot, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim();
|
|
7
|
+
const top = realpathSync(git('rev-parse', '--show-toplevel'));
|
|
8
|
+
const project = realpathSync(projectRoot);
|
|
9
|
+
const projectPath = relative(top, project).split(sep).join('/');
|
|
10
|
+
return {
|
|
11
|
+
projectPath: () => projectPath,
|
|
12
|
+
commit: (ref) => git('rev-parse', '--verify', `${ref}^{commit}`),
|
|
13
|
+
mergeBase: (a, b) => git('merge-base', a, b),
|
|
14
|
+
changedLines: (base, head) => changedLines(git, base, head),
|
|
15
|
+
checkout(commit, requiredFile) {
|
|
16
|
+
const scratch = mkdtempSync(join(tmpdir(), 'warp-'));
|
|
17
|
+
const dir = join(scratch, 'tree');
|
|
18
|
+
const dispose = () => rmSync(scratch, { recursive: true, force: true });
|
|
19
|
+
try {
|
|
20
|
+
exportTree(top, commit, scratch, dir);
|
|
21
|
+
const root = join(dir, projectPath);
|
|
22
|
+
if (!existsSync(join(root, requiredFile)))
|
|
23
|
+
return { dispose };
|
|
24
|
+
for (const from of new Set([project, top])) {
|
|
25
|
+
const modules = join(from, 'node_modules');
|
|
26
|
+
const to = join(dir, relative(top, from), 'node_modules');
|
|
27
|
+
if (existsSync(modules) && !existsSync(to))
|
|
28
|
+
symlinkSync(modules, to, 'dir');
|
|
29
|
+
}
|
|
30
|
+
return { projectRoot: root, dispose };
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
dispose();
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
const exportTree = (cwd, commit, scratch, dir) => {
|
|
40
|
+
const env = { ...process.env, GIT_INDEX_FILE: join(scratch, 'index'), GIT_LFS_SKIP_SMUDGE: '1' };
|
|
41
|
+
const git = (...args) => execFileSync('git', args, { cwd, env, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
42
|
+
git('read-tree', commit);
|
|
43
|
+
git('checkout-index', '--all', `--prefix=${dir}${sep}`);
|
|
44
|
+
};
|
|
45
|
+
export const projectPathOf = (projectRoot) => {
|
|
46
|
+
try {
|
|
47
|
+
return gitRepository(projectRoot).projectPath();
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return '';
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const changedLines = (git, base, head) => {
|
|
54
|
+
const range = head === undefined ? [base] : [base, head];
|
|
55
|
+
const patch = git('diff', '--unified=0', '--no-color', '--no-ext-diff', '--src-prefix=a/', '--dst-prefix=b/', '--relative', ...range, '--', '.');
|
|
56
|
+
const untracked = head === undefined ? git('ls-files', '--others', '--exclude-standard', '--', '.').split('\n') : [];
|
|
57
|
+
return [
|
|
58
|
+
...addedLines(patch),
|
|
59
|
+
...untracked.filter(Boolean).map((file) => ({ file, from: 1, to: Number.POSITIVE_INFINITY })),
|
|
60
|
+
];
|
|
61
|
+
};
|
|
62
|
+
const addedLines = (patch) => {
|
|
63
|
+
const lines = [];
|
|
64
|
+
let file;
|
|
65
|
+
for (const line of patch.split('\n')) {
|
|
66
|
+
if (line.startsWith('+++ '))
|
|
67
|
+
file = line === '+++ /dev/null' ? undefined : line.slice('+++ b/'.length);
|
|
68
|
+
const hunk = /^@@ -\S+ \+(\d+)(?:,(\d+))? @@/.exec(line);
|
|
69
|
+
if (!hunk || file === undefined)
|
|
70
|
+
continue;
|
|
71
|
+
const [from, count] = [Number(hunk[1]), Number(hunk[2] ?? 1)];
|
|
72
|
+
if (count > 0)
|
|
73
|
+
lines.push({ file, from, to: from + count - 1 });
|
|
74
|
+
}
|
|
75
|
+
return lines;
|
|
76
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { all, archetype, contains, defineConfig, dir, exposes, files, pkg, ruleset, using, type ModuleHandle, type Selector, type Ruleset, type RuleSettings, type WarpConfig, type All, type Archetype, type Exposed, type Using, type UsingContext, type Package, type Reference, type Shape, } from './model/archetype/builder.ts';
|
|
2
|
+
export { loadConfigData, type LoadedConfigData } from './app/load.ts';
|
|
3
|
+
export type * from './model/archetype/data.ts';
|
|
4
|
+
export type { Complexity, FunctionFacts, ImportEdge, FileFacts, Member, MemberGraph, MemberKind, } from './model/facts.ts';
|
|
5
|
+
export type { Model, ModuleView } from './model/archetype/resolve.ts';
|
|
6
|
+
export type { Grant, Refusal, Verdict, Verdicts } from './model/archetype/reach.ts';
|
|
7
|
+
export { ConfigError } from './model/configError.ts';
|
|
8
|
+
export { type Finding, type FileContext, type FileRule, type Plugin, type ProjectContext, type ProjectRule, type Rule, type Setting, wholeNumberOptions, } from './rules/rule.ts';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { all, archetype, contains, defineConfig, dir, exposes, files, pkg, ruleset, using, } from './model/archetype/builder.js';
|
|
2
|
+
export { loadConfigData } from './app/load.js';
|
|
3
|
+
export { ConfigError } from './model/configError.js';
|
|
4
|
+
export { wholeNumberOptions, } from './rules/rule.js';
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import type { IdentifyData } from './data.ts';
|
|
2
|
+
declare const referenceBrand: unique symbol;
|
|
3
|
+
declare const packageBrand: unique symbol;
|
|
4
|
+
declare const shapeBrand: unique symbol;
|
|
5
|
+
declare const selectorBrand: unique symbol;
|
|
6
|
+
declare const selfBrand: unique symbol;
|
|
7
|
+
declare const exposesType: unique symbol;
|
|
8
|
+
declare const usingType: unique symbol;
|
|
9
|
+
declare const modulesType: unique symbol;
|
|
10
|
+
declare const allBrand: unique symbol;
|
|
11
|
+
declare const handleBrand: unique symbol;
|
|
12
|
+
declare const rulesetBrand: unique symbol;
|
|
13
|
+
export interface Reference {
|
|
14
|
+
readonly [referenceBrand]: true;
|
|
15
|
+
}
|
|
16
|
+
export interface Package {
|
|
17
|
+
readonly [packageBrand]: true;
|
|
18
|
+
}
|
|
19
|
+
export interface Shape {
|
|
20
|
+
readonly [shapeBrand]: 'dir' | 'files';
|
|
21
|
+
}
|
|
22
|
+
export interface Selector<K extends 'dir' | 'files' = 'dir' | 'files'> {
|
|
23
|
+
readonly [selectorBrand]: K;
|
|
24
|
+
}
|
|
25
|
+
export interface Self {
|
|
26
|
+
readonly [selfBrand]: true;
|
|
27
|
+
}
|
|
28
|
+
export interface ModuleHandle {
|
|
29
|
+
readonly [handleBrand]: true;
|
|
30
|
+
}
|
|
31
|
+
export type RuleSettings = 'off' | Record<string, boolean | object>;
|
|
32
|
+
export interface All {
|
|
33
|
+
readonly [allBrand]: true;
|
|
34
|
+
}
|
|
35
|
+
export interface Archetype<N extends string | undefined = string, E = unknown, P = unknown, H = unknown> {
|
|
36
|
+
readonly name: N;
|
|
37
|
+
readonly [exposesType]?: E;
|
|
38
|
+
readonly [usingType]?: (s: P) => void;
|
|
39
|
+
readonly [modulesType]?: H;
|
|
40
|
+
}
|
|
41
|
+
export type AnyArchetype = Archetype<any, any, any, any>;
|
|
42
|
+
export type SurfaceRefs<E> = Reference & {
|
|
43
|
+
readonly [K in keyof E]: Reference;
|
|
44
|
+
};
|
|
45
|
+
type AnySurface = Reference & {
|
|
46
|
+
readonly [surface: string]: Reference;
|
|
47
|
+
};
|
|
48
|
+
type RequiredRef<A> = A extends Archetype<string, infer E> ? SurfaceRefs<E> : Reference;
|
|
49
|
+
export interface UsingContext {
|
|
50
|
+
readonly required: Readonly<Record<string, AnySurface>>;
|
|
51
|
+
}
|
|
52
|
+
export type Using<P> = readonly (Reference | Package)[] | ((m: P, context: UsingContext) => readonly (Reference | Package)[]);
|
|
53
|
+
type Surfaces = Record<string, Reference | readonly Reference[]>;
|
|
54
|
+
export type Exposed = All | Selector<'files'>;
|
|
55
|
+
type NewName<K extends string, C> = K extends 'tests' ? 'tests names the test layer' : K extends keyof C ? `module '${K}' is already declared` : K;
|
|
56
|
+
type With<C, K extends string, T> = C & {
|
|
57
|
+
readonly [k in K]: T;
|
|
58
|
+
};
|
|
59
|
+
type HandleOf<N, H> = N extends string ? ModuleHandle : {} extends H ? ModuleHandle : ModuleHandle & {
|
|
60
|
+
readonly modules: H;
|
|
61
|
+
};
|
|
62
|
+
export interface Modules<C, H> {
|
|
63
|
+
module<const K extends string>(name: NewName<K, C>, selector: Selector<'files'>, archetype?: Archetype<undefined, {}, C, {}>): Modules<With<C, K, Reference>, With<H, K, ModuleHandle>>;
|
|
64
|
+
module<const K extends string>(name: NewName<K, C>, selector: Selector<'dir'>, archetype: Self): Modules<With<C, K, AnySurface>, With<H, K, ModuleHandle>>;
|
|
65
|
+
module<const K extends string, N extends string | undefined = undefined, E = {}, H2 = {}>(name: NewName<K, C>, selector: Selector<'dir'>, archetype?: Archetype<N, E, C, H2>): Modules<With<C, K, SurfaceRefs<E>>, With<H, K, HandleOf<N, H2>>>;
|
|
66
|
+
}
|
|
67
|
+
export interface ContainsContext<R> {
|
|
68
|
+
required: R;
|
|
69
|
+
self: Self;
|
|
70
|
+
}
|
|
71
|
+
export type Identify = IdentifyData;
|
|
72
|
+
export type ArchetypeBuilder<N extends string | undefined, C, H, R, E, P = unknown> = ArchetypeMethods<N, C, H, R, E, P> & {
|
|
73
|
+
readonly modules: H;
|
|
74
|
+
};
|
|
75
|
+
export interface ArchetypeMethods<N extends string | undefined, C, H, R, E, P> extends Archetype<N, E, P, H> {
|
|
76
|
+
identify(identify: Identify): ArchetypeBuilder<N, C, H, R, E, P>;
|
|
77
|
+
requires<const R2 extends Record<string, AnyArchetype | Shape>>(requires: R2): ArchetypeBuilder<N, C, H, {
|
|
78
|
+
readonly [K in keyof R2]: RequiredRef<R2[K]>;
|
|
79
|
+
}, E, P>;
|
|
80
|
+
contains<C2, H2>(modules: (m: Modules<{}, {}>, context: ContainsContext<R>) => Modules<C2, H2>): ArchetypeBuilder<N, C2, H2, R, E, P>;
|
|
81
|
+
exposes<const E2 extends Surfaces>(exposes: (s: C) => E2): ArchetypeBuilder<N, C, H, R, E2, P>;
|
|
82
|
+
exposes(exposes: Exposed): ArchetypeBuilder<N, C, H, R, {}, P>;
|
|
83
|
+
entry(entry: Selector<'files'>): ArchetypeBuilder<N, C, H, R, {}, P>;
|
|
84
|
+
provides(provides: (s: C) => Record<string, Reference>): ArchetypeBuilder<N, C, H, R, E, P>;
|
|
85
|
+
description(description: string): ArchetypeBuilder<N, C, H, R, E, P>;
|
|
86
|
+
tests(layer: Archetype<undefined, any, C, any>): ArchetypeBuilder<N, C, With<H, 'tests', ModuleHandle>, R, E, P>;
|
|
87
|
+
tests(locator: Selector, layer?: Archetype<undefined, any, C, any>): ArchetypeBuilder<N, C, With<H, 'tests', ModuleHandle>, R, E, P>;
|
|
88
|
+
using<P2 = any>(using: Using<P2>): ArchetypeBuilder<N, C, H, R, E, P2>;
|
|
89
|
+
}
|
|
90
|
+
export interface Ruleset {
|
|
91
|
+
readonly [rulesetBrand]: true;
|
|
92
|
+
rules(settings: RuleSettings): Ruleset;
|
|
93
|
+
on(target: Archetype<string, any, any, any> | ModuleHandle, settings: RuleSettings): Ruleset;
|
|
94
|
+
extends(base: Ruleset): Ruleset;
|
|
95
|
+
}
|
|
96
|
+
export interface WarpConfig {
|
|
97
|
+
root: Archetype<string, any, any, any>;
|
|
98
|
+
tsconfig?: string | readonly string[];
|
|
99
|
+
tests?: Selector<'files'>;
|
|
100
|
+
plugins?: Record<string, unknown>;
|
|
101
|
+
rulesets?: Record<string, Ruleset>;
|
|
102
|
+
}
|
|
103
|
+
export type RecordedRef = {
|
|
104
|
+
kind: 'module';
|
|
105
|
+
module: string;
|
|
106
|
+
surface?: string;
|
|
107
|
+
} | {
|
|
108
|
+
kind: 'required';
|
|
109
|
+
name: string;
|
|
110
|
+
surface?: string;
|
|
111
|
+
} | {
|
|
112
|
+
kind: 'package';
|
|
113
|
+
pattern: string;
|
|
114
|
+
};
|
|
115
|
+
export interface RecordedSelector {
|
|
116
|
+
kind: 'dir' | 'files';
|
|
117
|
+
patterns: readonly unknown[];
|
|
118
|
+
}
|
|
119
|
+
export interface RecordedModule {
|
|
120
|
+
name: unknown;
|
|
121
|
+
selector: unknown;
|
|
122
|
+
archetype?: unknown;
|
|
123
|
+
extra: readonly unknown[];
|
|
124
|
+
}
|
|
125
|
+
export interface RecordedDefinition {
|
|
126
|
+
name: unknown;
|
|
127
|
+
identify?: unknown;
|
|
128
|
+
requires: unknown;
|
|
129
|
+
modules: unknown;
|
|
130
|
+
exposes?: unknown;
|
|
131
|
+
entry?: unknown;
|
|
132
|
+
provides?: unknown;
|
|
133
|
+
description?: unknown;
|
|
134
|
+
tests?: {
|
|
135
|
+
locator?: unknown;
|
|
136
|
+
layer?: unknown;
|
|
137
|
+
extra: readonly unknown[];
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
export interface RecordedArchetype {
|
|
141
|
+
definition: RecordedDefinition;
|
|
142
|
+
using?: unknown;
|
|
143
|
+
}
|
|
144
|
+
export interface RecordedRuleset {
|
|
145
|
+
base?: unknown;
|
|
146
|
+
entries: readonly {
|
|
147
|
+
target?: unknown;
|
|
148
|
+
settings: unknown;
|
|
149
|
+
}[];
|
|
150
|
+
}
|
|
151
|
+
interface Recorded {
|
|
152
|
+
ref: RecordedRef;
|
|
153
|
+
self: true;
|
|
154
|
+
all: true;
|
|
155
|
+
shape: 'dir' | 'files';
|
|
156
|
+
selector: RecordedSelector;
|
|
157
|
+
modules: readonly RecordedModule[];
|
|
158
|
+
archetype: RecordedArchetype;
|
|
159
|
+
handle: {
|
|
160
|
+
archetype: unknown;
|
|
161
|
+
module: unknown;
|
|
162
|
+
};
|
|
163
|
+
ruleset: RecordedRuleset;
|
|
164
|
+
}
|
|
165
|
+
export declare const recordedAs: <T extends keyof Recorded>(value: unknown, type: T) => Recorded[T] | undefined;
|
|
166
|
+
export declare const moduleRefs: () => unknown;
|
|
167
|
+
export declare const requiredRefs: () => unknown;
|
|
168
|
+
export declare const self: Self;
|
|
169
|
+
export declare const inlineName: (holder: string, module: string) => string;
|
|
170
|
+
export declare function archetype(): ArchetypeBuilder<undefined, {}, {}, {}, {}>;
|
|
171
|
+
export declare function archetype<const N extends string>(name: N): ArchetypeBuilder<N, {}, {}, {}, {}>;
|
|
172
|
+
export declare const using: <P = any>(using: Using<P>) => ArchetypeBuilder<undefined, {}, {}, {}, {}, P>;
|
|
173
|
+
export declare const exposes: (exposes: Exposed) => ArchetypeBuilder<undefined, {}, {}, {}, {}>;
|
|
174
|
+
export declare const contains: <C2, H2>(modules: (m: Modules<{}, {}>, context: ContainsContext<{}>) => Modules<C2, H2>) => ArchetypeBuilder<undefined, C2, H2, {}, {}>;
|
|
175
|
+
export declare const all: () => All;
|
|
176
|
+
export declare function dir(): Shape;
|
|
177
|
+
export declare function dir(...paths: [string, ...string[]]): Selector<'dir'>;
|
|
178
|
+
export declare function files(): Shape;
|
|
179
|
+
export declare function files(...patterns: [string, ...string[]]): Selector<'files'>;
|
|
180
|
+
export declare const pkg: (pattern: string) => Package;
|
|
181
|
+
export declare const defineConfig: <const C extends WarpConfig>(config: C) => C;
|
|
182
|
+
export declare const ruleset: () => Ruleset;
|
|
183
|
+
export {};
|