Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"launchdarkly-migration",
"openfeature-migration",
"flag-debt",
"flag-cleanup",
"feature-toggle",
"tech-debt",
"static-analysis",
"codemod",
"cli",
Expand All @@ -32,7 +35,7 @@
"migration-tool",
"developer-tools"
],
"author": "flaglint",
"author": "flaglint (https://flaglint.dev)",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
5 changes: 2 additions & 3 deletions src/commands/audit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import chalk from "chalk";
import { scan } from "../scanner/index.js";
import { LocalFileSource } from "../scanner/local-source.js";
import { buildAuditReport } from "../auditor/index.js";
import { validateDirectory, loadConfigOrExit, EXCLUDE_TEST_PATTERNS, createSpinner, stderrInfo } from "./shared.js";
import { validateDirectory, loadConfigOrExit, EXCLUDE_TEST_PATTERNS, startSpinner, stderrInfo } from "./shared.js";
import {
formatAuditJson,
formatAuditMarkdown,
Expand Down Expand Up @@ -96,8 +96,7 @@ Examples:
: config;

const format = options.format as AuditFormat;
const spinner = createSpinner(`Auditing ${dir}...`).start();
process.once("SIGINT", () => { spinner.stop(); process.exit(130); });
const spinner = startSpinner(`Auditing ${dir}...`);
let lastSpinnerUpdate = 0;

let scanResult;
Expand Down
5 changes: 2 additions & 3 deletions src/commands/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { LocalFileSource } from "../scanner/local-source.js";
import { analyze, formatMigrationReport } from "../migrator/index.js";
import { formatDryRunDiff } from "../migrator/dry-run.js";
import { applyMigration, ApplyError } from "../migrator/apply.js";
import { validateDirectory, loadConfigOrExit, EXCLUDE_TEST_PATTERNS, createSpinner, stderrInfo } from "./shared.js";
import { validateDirectory, loadConfigOrExit, EXCLUDE_TEST_PATTERNS, startSpinner, stderrInfo } from "./shared.js";

export function registerMigrateCommand(program: Command): void {
program
Expand Down Expand Up @@ -57,8 +57,7 @@ Examples:
? { ...config, exclude: [...config.exclude, ...EXCLUDE_TEST_PATTERNS] }
: config;

const spinner = createSpinner(`Scanning ${dir}...`).start();
process.once("SIGINT", () => { spinner.stop(); process.exit(130); });
const spinner = startSpinner(`Scanning ${dir}...`);

// Single source used for scan, dry-run, and apply.
const source = new LocalFileSource(dir);
Expand Down
5 changes: 2 additions & 3 deletions src/commands/scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { formatReport } from "../reporter/index.js";
import { formatDuration } from "./utils/format-duration.js";
import type { ReportFormat, ReporterOptions } from "../types.js";
import { isStale } from "../types.js";
import { validateDirectory, loadConfigOrExit, EXCLUDE_TEST_PATTERNS, createSpinner, stderrInfo, isVerbose } from "./shared.js";
import { validateDirectory, loadConfigOrExit, EXCLUDE_TEST_PATTERNS, startSpinner, stderrInfo, isVerbose } from "./shared.js";

const VALID_FORMATS: ReportFormat[] = ["json", "markdown", "html", "sarif"];

Expand Down Expand Up @@ -52,8 +52,7 @@ Examples:
: config;

const format = options.format as ReporterOptions["format"];
const spinner = createSpinner(`Scanning ${dir}...`).start();
process.once("SIGINT", () => { spinner.stop(); process.exit(130); });
const spinner = startSpinner(`Scanning ${dir}...`);
let lastSpinnerUpdate = 0;

let result;
Expand Down
11 changes: 10 additions & 1 deletion src/commands/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@ export function stderrInfo(msg: string): void {

/** Creates an ora spinner that is silenced in quiet mode. */
export function createSpinner(text: string): Ora {
const spinner = ora({ text, isSilent: _quiet });
return ora({ text, isSilent: _quiet });
}

/**
* Starts a spinner and wires SIGINT → stop + exit 130.
* Centralises the identical setup block that every scan command needs.
*/
export function startSpinner(text: string): Ora {
const spinner = createSpinner(text).start();
process.once("SIGINT", () => { spinner.stop(); process.exit(130); });
return spinner;
}

Expand Down
5 changes: 2 additions & 3 deletions src/commands/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
formatValidationSarif,
} from "../validator/index.js";
import { readBaseline, findNewFingerprints, BaselineError } from "../baseline.js";
import { validateDirectory, loadConfigOrExit, createSpinner, stderrInfo } from "./shared.js";
import { validateDirectory, loadConfigOrExit, startSpinner, stderrInfo } from "./shared.js";

const VALID_VALIDATE_FORMATS = ["text", "sarif"] as const;
type ValidateFormat = (typeof VALID_VALIDATE_FORMATS)[number];
Expand Down Expand Up @@ -88,8 +88,7 @@ Examples:
await validateDirectory(dir);
const config = await loadConfigOrExit(options.config);

const spinner = createSpinner(`Scanning ${dir}...`).start();
process.once("SIGINT", () => { spinner.stop(); process.exit(130); });
const spinner = startSpinner(`Scanning ${dir}...`);

const source = new LocalFileSource(dir);

Expand Down
1 change: 0 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const FlagLintConfigSchema = z.object({
// Governs which vendor SDK the scanner targets.
// Only "launchdarkly" is wired; other values are rejected with a clear error.
provider: z.string().default("launchdarkly"),
// TODO v0.3: replace minFileCount with real date-based staleness via git log
minFileCount: z.number().int().min(0).default(0),
wrappers: z
.array(
Expand Down
5 changes: 3 additions & 2 deletions src/scanner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ const LD_FLAG_KEY_METHODS = new Set([
]);

// Client methods that enumerate all flags — no flag key, use '*'.
// TODO: bulk inventory calls must not be auto-migrated as normal single-flag
// evaluations; they need a separate manual-review migration path.
// Bulk calls are flagged safelyAutomatable: false in the migrator (manualReviewReason: "bulk-inventory-call").
const LD_ALL_FLAGS_METHODS = new Set(["allFlags", "allFlagsState"]);
const LD_DETAIL_METHODS = new Set([
"variationDetail",
Expand Down Expand Up @@ -678,6 +677,8 @@ export async function scan(
return { ...detectUsages(ast, code, file, config.wrappers), warning: null };
}

// 50 concurrent file reads — balanced for I/O-bound work on most codebases.
// AST parsing is CPU-bound; raising this on large monorepos may not help.
const limit = pLimit(50);

const results = await Promise.all(
Expand Down
Loading