@yearofthedan/warp 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +9 -8
  2. package/dist/analysis/imports.d.ts +3 -1
  3. package/dist/analysis/imports.js +5 -1
  4. package/dist/analysis/typescript.js +2 -1
  5. package/dist/app/check.js +2 -1
  6. package/dist/app/checkModel.js +1 -1
  7. package/dist/app/load.js +12 -12
  8. package/dist/builtins/advice.d.ts +8 -0
  9. package/dist/builtins/advice.js +42 -0
  10. package/dist/builtins/dependency-direction/dependencyDirection.js +32 -15
  11. package/dist/builtins/index.js +2 -0
  12. package/dist/builtins/module-externals/moduleExternals.js +10 -9
  13. package/dist/builtins/no-cross-module-reexport/noCrossModuleReexport.js +16 -5
  14. package/dist/builtins/place.js +5 -3
  15. package/dist/builtins/unresolved-import/unresolvedImport.d.ts +2 -0
  16. package/dist/builtins/unresolved-import/unresolvedImport.js +15 -0
  17. package/dist/builtins/unused-declaration/declarations.js +1 -1
  18. package/dist/builtins/unused-declaration/empty.js +16 -9
  19. package/dist/builtins/unused-declaration/grants.js +8 -11
  20. package/dist/builtins/unused-declaration/surfaces.js +11 -19
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.js +1 -1
  23. package/dist/model/archetype/builder.d.ts +11 -11
  24. package/dist/model/archetype/builder.js +14 -21
  25. package/dist/model/archetype/data.d.ts +19 -13
  26. package/dist/model/archetype/draft.d.ts +2 -9
  27. package/dist/model/archetype/draft.js +48 -59
  28. package/dist/model/archetype/fixes.d.ts +37 -0
  29. package/dist/model/archetype/fixes.js +234 -0
  30. package/dist/model/archetype/reach.js +34 -80
  31. package/dist/model/archetype/references.d.ts +1 -1
  32. package/dist/model/archetype/references.js +13 -28
  33. package/dist/model/archetype/requirements.js +3 -6
  34. package/dist/model/archetype/resolve.d.ts +2 -3
  35. package/dist/model/archetype/resolve.js +85 -67
  36. package/dist/model/archetype/rulesets.js +0 -7
  37. package/dist/model/archetype/settings.js +4 -19
  38. package/dist/model/facts.d.ts +6 -0
  39. package/dist/reporters/model.js +8 -9
  40. package/package.json +1 -1
@@ -19,7 +19,7 @@ export interface Package {
19
19
  export interface Shape {
20
20
  readonly [shapeBrand]: 'dir' | 'files';
21
21
  }
22
- export interface Selector<K extends 'dir' | 'files' = 'dir' | 'files'> {
22
+ export interface Selector<K extends 'dir' | 'files' | 'mirror' = 'dir' | 'files'> {
23
23
  readonly [selectorBrand]: K;
24
24
  }
25
25
  export interface Self {
@@ -52,7 +52,7 @@ export interface UsingContext {
52
52
  export type Using<P> = readonly (Reference | Package)[] | ((m: P, context: UsingContext) => readonly (Reference | Package)[]);
53
53
  type Surfaces = Record<string, Reference | readonly Reference[]>;
54
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;
55
+ type NewName<K extends string, C> = K extends keyof C ? `module '${K}' is already declared` : K;
56
56
  type With<C, K extends string, T> = C & {
57
57
  readonly [k in K]: T;
58
58
  };
@@ -63,7 +63,11 @@ export interface Modules<C, H> {
63
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
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
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
+ testModule<const K extends string>(name: NewName<K, C>, selector: Selector<'files' | 'dir' | 'mirror'>, archetype?: Archetype<undefined, {}, C, {}>): Modules<With<C, K, Reference>, With<H, K, ModuleHandle>>;
66
67
  }
68
+ export type TestUsing<C, R> = readonly (Reference | Package)[] | ((m: C, context: {
69
+ readonly required: R;
70
+ }) => readonly (Reference | Package)[]);
67
71
  export interface ContainsContext<R> {
68
72
  required: R;
69
73
  self: Self;
@@ -83,8 +87,7 @@ export interface ArchetypeMethods<N extends string | undefined, C, H, R, E, P> e
83
87
  entry(entry: Selector<'files'>): ArchetypeBuilder<N, C, H, R, {}, P>;
84
88
  provides(provides: (s: C) => Record<string, Reference>): ArchetypeBuilder<N, C, H, R, E, P>;
85
89
  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>;
90
+ testUsing(using: TestUsing<C, R>): ArchetypeBuilder<N, C, H, R, E, P>;
88
91
  using<P2 = any>(using: Using<P2>): ArchetypeBuilder<N, C, H, R, E, P2>;
89
92
  }
90
93
  export interface Ruleset {
@@ -96,7 +99,6 @@ export interface Ruleset {
96
99
  export interface WarpConfig {
97
100
  root: Archetype<string, any, any, any>;
98
101
  tsconfig?: string | readonly string[];
99
- tests?: Selector<'files'>;
100
102
  plugins?: Record<string, unknown>;
101
103
  rulesets?: Record<string, Ruleset>;
102
104
  }
@@ -113,7 +115,7 @@ export type RecordedRef = {
113
115
  pattern: string;
114
116
  };
115
117
  export interface RecordedSelector {
116
- kind: 'dir' | 'files';
118
+ kind: 'dir' | 'files' | 'mirror';
117
119
  patterns: readonly unknown[];
118
120
  }
119
121
  export interface RecordedModule {
@@ -121,6 +123,7 @@ export interface RecordedModule {
121
123
  selector: unknown;
122
124
  archetype?: unknown;
123
125
  extra: readonly unknown[];
126
+ test?: true;
124
127
  }
125
128
  export interface RecordedDefinition {
126
129
  name: unknown;
@@ -131,11 +134,7 @@ export interface RecordedDefinition {
131
134
  entry?: unknown;
132
135
  provides?: unknown;
133
136
  description?: unknown;
134
- tests?: {
135
- locator?: unknown;
136
- layer?: unknown;
137
- extra: readonly unknown[];
138
- };
137
+ testUsing?: unknown;
139
138
  }
140
139
  export interface RecordedArchetype {
141
140
  definition: RecordedDefinition;
@@ -177,6 +176,7 @@ export declare function dir(): Shape;
177
176
  export declare function dir(...paths: [string, ...string[]]): Selector<'dir'>;
178
177
  export declare function files(): Shape;
179
178
  export declare function files(...patterns: [string, ...string[]]): Selector<'files'>;
179
+ export declare const mirror: (from: string, to: string) => Selector<'mirror'>;
180
180
  export declare const pkg: (pattern: string) => Package;
181
181
  export declare const defineConfig: <const C extends WarpConfig>(config: C) => C;
182
182
  export declare const ruleset: () => Ruleset;
@@ -16,28 +16,24 @@ export const self = Object.freeze(record('self', true));
16
16
  const modules = (entries) => ({
17
17
  ...record('modules', entries),
18
18
  module: (name, selector, archetype, ...extra) => modules([...entries, { name, selector, archetype, extra }]),
19
+ testModule: (name, selector, archetype, ...extra) => modules([...entries, { name, selector, archetype, extra, test: true }]),
19
20
  });
20
21
  export const inlineName = (holder, module) => `${holder}.${module}`;
21
- const handles = (holder, entries, tests) => ({
22
- ...Object.fromEntries((Array.isArray(entries) ? entries : [])
23
- .filter((entry) => typeof entry.name === 'string')
24
- .map((entry) => {
25
- const handle = record('handle', { archetype: holder, module: entry.name });
26
- const anonymous = recordedAs(entry.archetype, 'archetype')?.definition;
27
- const nested = anonymous && anonymous.name === undefined
28
- ? {
29
- modules: handles(inlineName(String(holder), entry.name), anonymous.modules, anonymous.tests),
30
- }
31
- : {};
32
- return [entry.name, Object.freeze({ ...handle, ...nested })];
33
- })),
34
- ...(tests === undefined ? {} : { tests: Object.freeze(record('handle', { archetype: holder, module: 'tests' })) }),
35
- });
22
+ const handles = (holder, entries) => Object.fromEntries((Array.isArray(entries) ? entries : [])
23
+ .filter((entry) => typeof entry.name === 'string')
24
+ .map((entry) => {
25
+ const handle = record('handle', { archetype: holder, module: entry.name });
26
+ const anonymous = recordedAs(entry.archetype, 'archetype')?.definition;
27
+ const nested = anonymous && anonymous.name === undefined && !entry.test
28
+ ? { modules: handles(inlineName(String(holder), entry.name), anonymous.modules) }
29
+ : {};
30
+ return [entry.name, Object.freeze({ ...handle, ...nested })];
31
+ }));
36
32
  const builder = (state) => {
37
33
  const { definition } = state;
38
34
  const define = (field) => (value) => builder({ ...state, definition: { ...definition, [field]: value } });
39
35
  return {
40
- modules: handles(definition.name, definition.modules, definition.tests),
36
+ modules: handles(definition.name, definition.modules),
41
37
  name: definition.name,
42
38
  ...record('archetype', state),
43
39
  identify: define('identify'),
@@ -47,11 +43,7 @@ const builder = (state) => {
47
43
  entry: define('entry'),
48
44
  provides: define('provides'),
49
45
  description: define('description'),
50
- tests: (first, ...rest) => {
51
- const located = recordedAs(first, 'selector') !== undefined;
52
- const [layer, ...extra] = located ? rest : [first, ...rest];
53
- return define('tests')({ ...(located ? { locator: first } : {}), layer, extra });
54
- },
46
+ testUsing: define('testUsing'),
55
47
  using: (using) => builder({ ...state, using }),
56
48
  };
57
49
  };
@@ -70,6 +62,7 @@ export function dir(...paths) {
70
62
  export function files(...patterns) {
71
63
  return selector('files', patterns);
72
64
  }
65
+ export const mirror = (from, to) => Object.freeze(record('selector', { kind: 'mirror', patterns: [from, to] }));
73
66
  export const pkg = (pattern) => ref({ kind: 'package', pattern });
74
67
  export const defineConfig = (config) => config;
75
68
  const rulesetOf = (state) => ({
@@ -24,17 +24,14 @@ export type ExposesData = {
24
24
  kind: 'surfaces';
25
25
  surfaces: Record<string, RefData[]>;
26
26
  };
27
- export interface LocatorData {
27
+ export type LocatorData = {
28
28
  kind: 'dir' | 'files';
29
29
  patterns: string[];
30
- }
31
- export interface TestLayerData {
32
- locator?: LocatorData;
33
- modules: FilesModuleData[];
34
- using: RefData[];
35
- exposes?: ExposesData;
36
- rules?: RuleSettingsData;
37
- }
30
+ } | {
31
+ kind: 'mirror';
32
+ from: string;
33
+ to: string;
34
+ };
38
35
  export interface FilesModuleData {
39
36
  kind: 'files';
40
37
  name: string;
@@ -43,7 +40,6 @@ export interface FilesModuleData {
43
40
  exposes?: Exclude<ExposesData, {
44
41
  kind: 'surfaces';
45
42
  }>;
46
- tests?: TestLayerData;
47
43
  rules?: RuleSettingsData;
48
44
  description?: string;
49
45
  }
@@ -56,7 +52,18 @@ export interface DirModuleData {
56
52
  rules?: RuleSettingsData;
57
53
  description?: string;
58
54
  }
59
- export type ModuleData = FilesModuleData | DirModuleData;
55
+ export interface TestModuleData {
56
+ kind: 'test';
57
+ name: string;
58
+ locator: LocatorData;
59
+ using: RefData[];
60
+ exposes?: Exclude<ExposesData, {
61
+ kind: 'surfaces';
62
+ }>;
63
+ rules?: RuleSettingsData;
64
+ description?: string;
65
+ }
66
+ export type ModuleData = FilesModuleData | DirModuleData | TestModuleData;
60
67
  export type RequirementData = {
61
68
  kind: 'archetype';
62
69
  archetype: string;
@@ -79,7 +86,7 @@ export interface ArchetypeData {
79
86
  modules: ModuleData[];
80
87
  exposes?: ExposesData;
81
88
  provides: Record<string, ModuleRefData>;
82
- tests?: TestLayerData;
89
+ testUsing?: RefData[];
83
90
  rules?: RuleSettingsData;
84
91
  }
85
92
  export interface ConfigData {
@@ -87,6 +94,5 @@ export interface ConfigData {
87
94
  root: string;
88
95
  archetypes: Record<string, ArchetypeData>;
89
96
  tsconfig: string[];
90
- tests?: string[];
91
97
  rules?: RuleSettingsData;
92
98
  }
@@ -1,16 +1,9 @@
1
1
  import { type RecordedDefinition } from './builder.ts';
2
- import type { ArchetypeData, LocatorData, ModuleData } from './data.ts';
2
+ import type { ArchetypeData, ModuleData } from './data.ts';
3
3
  import { type Fail } from './shared.ts';
4
- export interface DraftTests {
5
- locator?: LocatorData;
6
- modules: DraftModule[];
7
- using: unknown[];
8
- exposes?: DraftExposes;
9
- }
10
4
  export interface DraftModule {
11
5
  data: ModuleData;
12
6
  using: unknown[];
13
- tests?: DraftTests;
14
7
  }
15
8
  export type DraftExposes = {
16
9
  kind: 'all';
@@ -27,7 +20,7 @@ export interface Draft {
27
20
  modules: DraftModule[];
28
21
  exposes?: DraftExposes;
29
22
  provides: Record<string, unknown>;
30
- tests?: DraftTests;
23
+ testUsing: unknown[];
31
24
  }
32
25
  export interface Collected extends RecordedDefinition {
33
26
  inline?: true;
@@ -21,7 +21,7 @@ const named = (value) => {
21
21
  return definition && definition.name !== undefined ? [definition] : [];
22
22
  };
23
23
  const reached = (definition) => [
24
- ...entriesOf(definition.modules).flatMap((entry) => named(entry.archetype)),
24
+ ...entriesOf(definition.modules).flatMap((entry) => (entry.test ? [] : named(entry.archetype))),
25
25
  ...Object.values(isRecord(definition.requires) ? definition.requires : {}).flatMap(named),
26
26
  ...inlineArchetypes(definition),
27
27
  ];
@@ -43,7 +43,8 @@ const inlineArchetypes = (holder) => isName(holder.name)
43
43
  ]
44
44
  : [])
45
45
  : [];
46
- const isInline = (entry) => (entry.archetype === undefined || anonymousOf(entry) !== undefined) &&
46
+ const isInline = (entry) => !entry.test &&
47
+ (entry.archetype === undefined || anonymousOf(entry) !== undefined) &&
47
48
  recordedAs(entry.selector, 'selector')?.kind === 'dir';
48
49
  const entriesOf = (modules) => (Array.isArray(modules) ? modules : []);
49
50
  const callback = (value) => (typeof value === 'function' ? value(moduleRefs()) : undefined);
@@ -56,7 +57,7 @@ export const draft = (name, state, fail) => {
56
57
  const provides = state.provides === undefined ? {} : callback(state.provides);
57
58
  if (!isRecord(provides))
58
59
  fail(`${name}.provides: expected a callback returning modules by name, (m) => ({ strings: m.strings })`);
59
- const tests = testsOf(name, state.tests, 'dir', fail);
60
+ const testUsing = usingOf(`${name}.testUsing`, state.testUsing, fail);
60
61
  return {
61
62
  data: {
62
63
  name,
@@ -70,52 +71,9 @@ export const draft = (name, state, fail) => {
70
71
  modules,
71
72
  ...(exposes ? { exposes } : {}),
72
73
  provides: isRecord(provides) ? provides : {},
73
- ...(tests ? { tests } : {}),
74
+ testUsing,
74
75
  };
75
76
  };
76
- const testsOf = (where, value, kind, fail) => {
77
- if (value === undefined)
78
- return undefined;
79
- if (value.extra.length > 0)
80
- fail(`${where}.tests: takes a locator and an archetype, .tests(dir('e2e'), using([...]))`);
81
- const locator = value.locator === undefined ? undefined : selectorOf(`${where}.tests`, value.locator, fail);
82
- const recorded = value.layer === undefined ? undefined : recordedAs(value.layer, 'archetype');
83
- if (value.layer !== undefined && recorded?.definition.name !== undefined)
84
- fail(`${where}.tests: a test layer is an archetype of its own: contains(...), using(...) or exposes(...)`);
85
- const layer = recorded?.definition.name === undefined ? recorded?.definition : undefined;
86
- if (layer)
87
- checkLayer(`${where}.tests`, layer, fail);
88
- const modules = layer
89
- ? draftModules(`${where}.tests`, layer.modules, fail).map((module) => testModule(where, module, fail))
90
- : [];
91
- if (kind === 'files' && modules.length > 0)
92
- fail(`${where}.tests: a files module's tests hold no modules; give them to its folder's archetype`);
93
- if (kind === 'files' && !locator)
94
- fail(`${where}.tests: a files module names where its tests are, .tests(files('*.logic.test.ts'))`);
95
- const exposes = exposesOf(`${where}.tests.exposes`, layer?.exposes, true, fail);
96
- return {
97
- ...(locator ? { locator } : {}),
98
- modules,
99
- using: usingOf(`${where}.tests`, recorded?.using, fail),
100
- ...(exposes ? { exposes } : {}),
101
- };
102
- };
103
- const checkLayer = (where, layer, fail) => {
104
- for (const field of ['identify', 'provides', 'tests', 'entry'])
105
- if (layer[field] !== undefined)
106
- fail(`${where}.${field}: a test layer holds test modules, its using and what it exposes`);
107
- if (isRecord(layer.requires) && Object.keys(layer.requires).length > 0)
108
- fail(`${where}.requires: a test layer sees what its holder requires`);
109
- };
110
- const testModule = (where, module, fail) => {
111
- const at = `${where}.tests.${module.data.name}`;
112
- if (module.data.kind !== 'files')
113
- fail(`${at}: a test module is a files module, files('*.dsl.ts')`);
114
- if (module.using.length > 0)
115
- fail(`${at}: a test module sees what its layer sees; give the layer .using()`);
116
- const data = module.data;
117
- return { ...module, data: { ...data, exposes: data.exposes ?? { kind: 'all' } } };
118
- };
119
77
  const surfaceOf = (name, state, fail) => {
120
78
  if (state.entry === undefined)
121
79
  return exposesOf(`${name}.exposes`, state.exposes, true, fail);
@@ -167,8 +125,8 @@ const draftModule = (archetype, entry, fail) => {
167
125
  if (!isName(name) || name.includes('.'))
168
126
  fail(`${archetype}: a module's name is a non-empty string without dots, not ${JSON.stringify(name)}`);
169
127
  const where = `${archetype}.${String(name)}`;
170
- if (name === 'tests')
171
- fail(`${where}: tests names a module's test layer; give the module another name`);
128
+ if (entry.test)
129
+ return draftTestModule(archetype, entry, where, fail);
172
130
  const { kind, patterns } = selectorOf(where, entry.selector, fail);
173
131
  if (entry.extra.length > 0)
174
132
  fail(`${where}: .module() takes a name, a selector and an archetype`);
@@ -185,13 +143,41 @@ const draftModule = (archetype, entry, fail) => {
185
143
  if (named !== undefined)
186
144
  fail(`${where}: an archetype makes a folder module; use dir(...), not files(...)`);
187
145
  const exposes = exposesOf(`${where}.exposes`, anonymous?.exposes, false, fail);
188
- const tests = testsOf(where, anonymous?.tests, 'files', fail);
146
+ return { data: { kind, ...common, patterns, ...(exposes ? { exposes } : {}) }, using };
147
+ };
148
+ const draftTestModule = (holder, entry, where, fail) => {
149
+ const locator = locatorOf(where, entry.selector, fail);
150
+ if (entry.extra.length > 0)
151
+ fail(`${where}: .testModule() takes a name, a selector and an archetype`);
152
+ const { named, anonymous, using } = archetypeOf(where, holder, entry.archetype, fail);
153
+ if (named !== undefined)
154
+ fail(`${where}: a test module's archetype is its own: using(...), exposes(...) or description(...)`);
155
+ if (anonymous)
156
+ checkAnonymous(where, 'test', anonymous, fail);
157
+ const exposes = exposesOf(`${where}.exposes`, anonymous?.exposes, false, fail);
158
+ const description = anonymous?.description;
189
159
  return {
190
- data: { kind, ...common, patterns, ...(exposes ? { exposes } : {}) },
160
+ data: {
161
+ kind: 'test',
162
+ name: entry.name,
163
+ locator,
164
+ using: [],
165
+ ...(exposes ? { exposes } : {}),
166
+ ...(description === undefined ? {} : { description }),
167
+ },
191
168
  using,
192
- ...(tests ? { tests } : {}),
193
169
  };
194
170
  };
171
+ const locatorOf = (where, value, fail) => {
172
+ const selector = recordedAs(value, 'selector');
173
+ if (selector?.kind !== 'mirror')
174
+ return selectorOf(where, value, fail, 'test');
175
+ const [from, to] = selector.patterns;
176
+ if (!isMirrorPath(from) || !isMirrorPath(to))
177
+ fail(`${where}: mirror() takes two folder paths without placeholders, mirror('src', 'test')`);
178
+ return { kind: 'mirror', from: String(from), to: String(to) };
179
+ };
180
+ const isMirrorPath = (path) => isName(path) && !path.includes('{') && isDirPath(path);
195
181
  const archetypeOf = (where, holder, value, fail) => {
196
182
  if (value === undefined)
197
183
  return { using: [] };
@@ -202,7 +188,7 @@ const archetypeOf = (where, holder, value, fail) => {
202
188
  fail(`${where}: expected an archetype, such as component, using(...) or exposes(all())`);
203
189
  return { using: [] };
204
190
  }
205
- const using = usingOf(where, recorded.using, fail);
191
+ const using = usingOf(`${where}.using`, recorded.using, fail);
206
192
  const { definition } = recorded;
207
193
  return definition.name === undefined ? { anonymous: definition, using } : { named: definition.name, using };
208
194
  };
@@ -216,15 +202,18 @@ const checkAnonymous = (where, kind, definition, fail) => {
216
202
  const hasModules = Array.isArray(definition.modules) && definition.modules.length > 0;
217
203
  const folderOnly = [
218
204
  ...(hasModules ? ['contains'] : []),
219
- ...['identify', 'provides', 'entry'].filter((field) => definition[field] !== undefined),
205
+ ...['identify', 'provides', 'entry', 'testUsing'].filter((field) => definition[field] !== undefined),
220
206
  ];
221
207
  for (const field of folderOnly)
222
- fail(`${where}.${field}: a files module has no modules; use dir(...) for ${field}`);
208
+ fail(kind === 'test'
209
+ ? `${where}.${field}: a test module holds test code; its archetype takes using(...), exposes(...) and description(...)`
210
+ : `${where}.${field}: a files module has no modules; use dir(...) for ${field}`);
223
211
  };
224
- const selectorOf = (where, value, fail) => {
212
+ const selectorOf = (where, value, fail, of = 'module') => {
225
213
  const selector = recordedAs(value, 'selector');
226
- if (!selector) {
227
- fail(`${where}: expected a selector, files('*.ts') or dir('src/ui')`);
214
+ if (!selector || selector.kind === 'mirror') {
215
+ const shapes = of === 'test' ? "files('*.test.ts'), dir('e2e') or mirror('src', 'test')" : "files('*.ts') or dir('src/ui')";
216
+ fail(`${where}: expected a selector, ${shapes}`);
228
217
  return { kind: 'files', patterns: [] };
229
218
  }
230
219
  const patterns = selector.patterns;
@@ -238,7 +227,7 @@ const usingOf = (where, value, fail) => {
238
227
  const using = typeof value === 'function' ? value(moduleRefs(), { required: requiredRefs() }) : (value ?? []);
239
228
  if (Array.isArray(using))
240
229
  return using;
241
- fail(`${where}.using: expected a list of references, or a callback returning one`);
230
+ fail(`${where}: expected a list of references, or a callback returning one`);
242
231
  return [];
243
232
  };
244
233
  const checkDirPaths = (where, paths, fail) => {
@@ -0,0 +1,37 @@
1
+ import type { ConfigData, RefData } from './data.ts';
2
+ import type { Model, ModuleView } from './resolve.ts';
3
+ export interface Site {
4
+ label: string;
5
+ holder: ModuleView;
6
+ add(config: ConfigData, ref: RefData): ConfigData;
7
+ visible: ReadonlySet<string>;
8
+ self?: string;
9
+ tests: boolean;
10
+ }
11
+ export type Fix = {
12
+ kind: 'using';
13
+ site: string;
14
+ ref: RefData;
15
+ } | {
16
+ kind: 'declare';
17
+ archetype: string;
18
+ module: string;
19
+ above: string;
20
+ } | {
21
+ kind: 'require';
22
+ archetype: string;
23
+ name: string;
24
+ provider: string;
25
+ module: string;
26
+ } | {
27
+ kind: 'expose';
28
+ archetype: string;
29
+ ref: RefData;
30
+ } | {
31
+ kind: 'expose-file';
32
+ archetype: string;
33
+ pattern: string;
34
+ };
35
+ export declare const namedArchetype: (config: ConfigData, name: string) => string;
36
+ export declare const sitesOf: (config: ConfigData, model: Model, file: string) => Site[];
37
+ export declare const fixesFor: (config: ConfigData, model: Model, from: string, to: string) => Fix[] | undefined;