mirror of
https://github.com/callstack/agent-device.git
synced 2026-09-14 20:06:34 +08:00
c0fc822e80
Evaluated knip (webpro-nl/knip) against the fallow setup already in the
repo, cleaned up everything it surfaced, then removed knip again: measured
head-to-head on the same tree, fallow is a strict superset once two
switches it already supports are flipped.
Dead code removed:
- `daemon/artifact-materialization.ts` (224 lines) had no production
caller, only its own test. Removing it exposed that
`downloadArtifactToTempDir` and the whole URL-fetch-with-redirects path
in `artifact-download.ts` were reachable only through it — the live
upload paths use the incoming-request helpers instead. That file goes
348 -> 123 lines. `readZipEntries` then fell out of `artifact-archive.ts`.
- Dead test-helper exports: 12 unused re-exports and 6 needlessly-exported
mocks in `session-test-harness.ts`, dead barrel entries in
`__tests__/test-utils/index.ts`, plus `withMockedXcrun`, `matchesSchema`,
`IOS_FRAME`, `IOS_TAB_FRAME`, `snapshotWithOffscreenContent`.
- `androidSnapshotHelperOutput` was duplicated byte-for-byte in
`provider-scenarios/android-world.ts`; it now imports the shared copy.
- 8 unreferenced type aliases, and 17 redundant type re-export lines in
`client/client-types.ts`. The published `.d.ts` is byte-identical before
and after all 19 files: those types already reach consumers through
`contracts/*` via `CommandResult<...>`, so this is not an API change.
Tooling:
- `.fallowrc.json` gains `includeEntryExports`,
`ignoreExportsUsedInFile: {type, interface}` and `unused-types: warn`.
That combination is what made the findings above visible; the previous
config was quiet mainly because of its own suppression list.
- Dropped 2 now-obsolete `ignoreExports` suppressions, added 3 documented
ones (published `sdk/*` surface, tool-config `default` exports, and the
`AssertTrue<...>` totality guards that exist only to satisfy
`noUnusedLocals`).
`unused-types` stays at `warn`: 72 pre-existing type re-export lines across
27 files remain, tracked separately. Every other fallow detector is at zero.
43 lines
1.7 KiB
TypeScript
43 lines
1.7 KiB
TypeScript
import {
|
|
listDescriptorCatalogEntries,
|
|
type DescriptorCatalogRecord,
|
|
type DescriptorCliCommandName,
|
|
type DescriptorCommandNameForCatalogGroup,
|
|
} from './core/command-descriptor/registry.ts';
|
|
import type { CommandCatalogGroup } from './core/command-descriptor/types.ts';
|
|
|
|
export const PUBLIC_COMMANDS = deriveCommandCatalog('public');
|
|
export const INTERNAL_COMMANDS = deriveCommandCatalog('internal');
|
|
const LOCAL_CLI_COMMANDS = deriveCommandCatalog('local-cli');
|
|
|
|
export const SPECIAL_CLI_COMMANDS = {
|
|
help: 'help',
|
|
} as const;
|
|
|
|
export type InternalCommandName = DescriptorCommandNameForCatalogGroup<'internal'>;
|
|
export type LocalCliCommandName = DescriptorCommandNameForCatalogGroup<'local-cli'>;
|
|
export type SpecialCliCommandName =
|
|
(typeof SPECIAL_CLI_COMMANDS)[keyof typeof SPECIAL_CLI_COMMANDS];
|
|
export type CliCommandName = DescriptorCliCommandName;
|
|
export type KnownCliCommandName = CliCommandName | InternalCommandName | SpecialCliCommandName;
|
|
|
|
export function listCliCommandNames(): CliCommandName[] {
|
|
return [...Object.values(PUBLIC_COMMANDS), ...Object.values(LOCAL_CLI_COMMANDS)].sort();
|
|
}
|
|
|
|
export function isKnownCliCommandName(command: string): command is KnownCliCommandName {
|
|
if ((Object.values(SPECIAL_CLI_COMMANDS) as readonly string[]).includes(command)) return true;
|
|
if ((Object.values(INTERNAL_COMMANDS) as readonly string[]).includes(command)) return true;
|
|
return (listCliCommandNames() as readonly string[]).includes(command);
|
|
}
|
|
|
|
function deriveCommandCatalog<Group extends CommandCatalogGroup>(
|
|
group: Group,
|
|
): DescriptorCatalogRecord<Group> {
|
|
const result: Record<string, string> = {};
|
|
for (const [key, name] of listDescriptorCatalogEntries(group)) {
|
|
result[key] = name;
|
|
}
|
|
return result as DescriptorCatalogRecord<Group>;
|
|
}
|