@forge-ts/cli 0.14.0 → 0.16.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/dist/chunk-CNINN7IQ.js +28 -0
- package/dist/chunk-CNINN7IQ.js.map +1 -0
- package/dist/chunk-DV33Y4E2.js +333 -0
- package/dist/chunk-DV33Y4E2.js.map +1 -0
- package/dist/chunk-ZFFY4AQX.js +73 -0
- package/dist/chunk-ZFFY4AQX.js.map +1 -0
- package/dist/forge-logger-RTOBEKWH.js +10 -0
- package/dist/forge-logger-RTOBEKWH.js.map +1 -0
- package/dist/index.d.ts +292 -28
- package/dist/index.js +644 -184
- package/dist/index.js.map +1 -1
- package/dist/init-project-5AWZ2LAI.js +14 -0
- package/dist/init-project-5AWZ2LAI.js.map +1 -0
- package/dist/output-OSCHMPOX.js +10 -0
- package/dist/output-OSCHMPOX.js.map +1 -0
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as citty from 'citty';
|
|
2
2
|
import { AuditEvent, BypassRecord } from '@forge-ts/core';
|
|
3
3
|
import { SSGTarget } from '@forge-ts/gen';
|
|
4
|
+
import * as consola from 'consola';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Central output layer for forge-ts CLI.
|
|
@@ -578,6 +579,134 @@ declare const docsDevCommand: citty.CommandDef<{
|
|
|
578
579
|
};
|
|
579
580
|
}>;
|
|
580
581
|
|
|
582
|
+
/**
|
|
583
|
+
* Status of a single doctor check.
|
|
584
|
+
* @public
|
|
585
|
+
*/
|
|
586
|
+
type DoctorCheckStatus = "pass" | "warn" | "error" | "info";
|
|
587
|
+
/**
|
|
588
|
+
* Result of a single doctor check.
|
|
589
|
+
*
|
|
590
|
+
* @public
|
|
591
|
+
*/
|
|
592
|
+
interface DoctorCheckResult {
|
|
593
|
+
/** Name of the check. */
|
|
594
|
+
name: string;
|
|
595
|
+
/** Status of the check. */
|
|
596
|
+
status: DoctorCheckStatus;
|
|
597
|
+
/** Human-readable message. */
|
|
598
|
+
message: string;
|
|
599
|
+
/** Whether this issue can be auto-fixed with --fix. */
|
|
600
|
+
fixable: boolean;
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Result of the `doctor` command.
|
|
604
|
+
*
|
|
605
|
+
* @example
|
|
606
|
+
* ```typescript
|
|
607
|
+
* import { runDoctor } from "@forge-ts/cli/commands/doctor";
|
|
608
|
+
* const output = await runDoctor({ cwd: process.cwd() });
|
|
609
|
+
* console.log(output.data.summary.passed); // number of passed checks
|
|
610
|
+
* ```
|
|
611
|
+
* @public
|
|
612
|
+
*/
|
|
613
|
+
interface DoctorResult {
|
|
614
|
+
/** Whether all checks passed without errors. */
|
|
615
|
+
success: boolean;
|
|
616
|
+
/** Individual check results. */
|
|
617
|
+
checks: DoctorCheckResult[];
|
|
618
|
+
/** Summary counts. */
|
|
619
|
+
summary: {
|
|
620
|
+
passed: number;
|
|
621
|
+
warnings: number;
|
|
622
|
+
errors: number;
|
|
623
|
+
info: number;
|
|
624
|
+
};
|
|
625
|
+
/** Files that were fixed (only populated when --fix is used). */
|
|
626
|
+
fixed: string[];
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Arguments for the `doctor` command.
|
|
630
|
+
* @internal
|
|
631
|
+
*/
|
|
632
|
+
interface DoctorArgs {
|
|
633
|
+
/** Project root directory (default: cwd). */
|
|
634
|
+
cwd?: string;
|
|
635
|
+
/** Auto-fix resolvable issues. */
|
|
636
|
+
fix?: boolean;
|
|
637
|
+
/** MVI verbosity level for structured output. */
|
|
638
|
+
mvi?: string;
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Runs the doctor integrity check flow.
|
|
642
|
+
*
|
|
643
|
+
* Checks:
|
|
644
|
+
* 1. forge-ts.config.ts — exists and loadable
|
|
645
|
+
* 2. tsdoc.json — exists and extends @forge-ts/core/tsdoc-preset
|
|
646
|
+
* 3. @forge-ts/core — installed in node_modules
|
|
647
|
+
* 4. TypeScript — installed
|
|
648
|
+
* 5. tsconfig.json — exists and has strict mode
|
|
649
|
+
* 6. biome.json — exists (informational)
|
|
650
|
+
* 7. .forge-lock.json — exists, valid, matches config
|
|
651
|
+
* 8. .forge-audit.jsonl — exists and event count
|
|
652
|
+
* 9. .forge-bypass.json — exists and active bypasses
|
|
653
|
+
* 10. Git hooks — forge-ts check in pre-commit
|
|
654
|
+
*
|
|
655
|
+
* @param args - CLI arguments for the doctor command.
|
|
656
|
+
* @returns A typed `CommandOutput<DoctorResult>`.
|
|
657
|
+
* @example
|
|
658
|
+
* ```typescript
|
|
659
|
+
* import { runDoctor } from "@forge-ts/cli/commands/doctor";
|
|
660
|
+
* const output = await runDoctor({ cwd: process.cwd(), fix: false });
|
|
661
|
+
* console.log(output.data.summary); // { passed: 7, warnings: 2, errors: 1, info: 0 }
|
|
662
|
+
* ```
|
|
663
|
+
* @public
|
|
664
|
+
*/
|
|
665
|
+
declare function runDoctor(args: DoctorArgs): Promise<CommandOutput<DoctorResult>>;
|
|
666
|
+
/**
|
|
667
|
+
* Citty command definition for `forge-ts doctor`.
|
|
668
|
+
*
|
|
669
|
+
* Performs project integrity checks and optionally auto-fixes
|
|
670
|
+
* resolvable issues with `--fix`.
|
|
671
|
+
*
|
|
672
|
+
* @example
|
|
673
|
+
* ```typescript
|
|
674
|
+
* import { doctorCommand } from "@forge-ts/cli/commands/doctor";
|
|
675
|
+
* // Registered as a top-level subcommand of `forge-ts`
|
|
676
|
+
* ```
|
|
677
|
+
* @public
|
|
678
|
+
*/
|
|
679
|
+
declare const doctorCommand: citty.CommandDef<{
|
|
680
|
+
readonly cwd: {
|
|
681
|
+
readonly type: "string";
|
|
682
|
+
readonly description: "Project root directory";
|
|
683
|
+
};
|
|
684
|
+
readonly fix: {
|
|
685
|
+
readonly type: "boolean";
|
|
686
|
+
readonly description: "Auto-fix resolvable issues";
|
|
687
|
+
readonly default: false;
|
|
688
|
+
};
|
|
689
|
+
readonly json: {
|
|
690
|
+
readonly type: "boolean";
|
|
691
|
+
readonly description: "Output as LAFS JSON envelope";
|
|
692
|
+
readonly default: false;
|
|
693
|
+
};
|
|
694
|
+
readonly human: {
|
|
695
|
+
readonly type: "boolean";
|
|
696
|
+
readonly description: "Output as formatted text";
|
|
697
|
+
readonly default: false;
|
|
698
|
+
};
|
|
699
|
+
readonly quiet: {
|
|
700
|
+
readonly type: "boolean";
|
|
701
|
+
readonly description: "Suppress non-essential output";
|
|
702
|
+
readonly default: false;
|
|
703
|
+
};
|
|
704
|
+
readonly mvi: {
|
|
705
|
+
readonly type: "string";
|
|
706
|
+
readonly description: "MVI verbosity level: minimal, standard, full";
|
|
707
|
+
};
|
|
708
|
+
}>;
|
|
709
|
+
|
|
581
710
|
/**
|
|
582
711
|
* Result of the `init docs` command.
|
|
583
712
|
*
|
|
@@ -766,6 +895,123 @@ declare const initHooksCommand: citty.CommandDef<{
|
|
|
766
895
|
};
|
|
767
896
|
}>;
|
|
768
897
|
|
|
898
|
+
/**
|
|
899
|
+
* Detected project environment from Step 1 of the init flow.
|
|
900
|
+
*
|
|
901
|
+
* @public
|
|
902
|
+
*/
|
|
903
|
+
interface InitProjectEnvironment {
|
|
904
|
+
/** Whether package.json exists. */
|
|
905
|
+
packageJsonExists: boolean;
|
|
906
|
+
/** Whether tsconfig.json exists. */
|
|
907
|
+
tsconfigExists: boolean;
|
|
908
|
+
/** Whether biome.json or biome.jsonc exists. */
|
|
909
|
+
biomeDetected: boolean;
|
|
910
|
+
/** TypeScript version from dependencies, or null if not found. */
|
|
911
|
+
typescriptVersion: string | null;
|
|
912
|
+
/** Detected hook manager. */
|
|
913
|
+
hookManager: "husky" | "lefthook" | "none";
|
|
914
|
+
/** Whether the project is a monorepo. */
|
|
915
|
+
monorepo: boolean;
|
|
916
|
+
/** Monorepo type if detected. */
|
|
917
|
+
monorepoType: "pnpm" | "npm/yarn" | null;
|
|
918
|
+
}
|
|
919
|
+
/**
|
|
920
|
+
* Result of the `init` (project setup) command.
|
|
921
|
+
*
|
|
922
|
+
* @example
|
|
923
|
+
* ```typescript
|
|
924
|
+
* import { runInitProject } from "@forge-ts/cli/commands/init-project";
|
|
925
|
+
* const output = await runInitProject({ cwd: process.cwd() });
|
|
926
|
+
* console.log(output.data.created); // list of created files
|
|
927
|
+
* ```
|
|
928
|
+
* @public
|
|
929
|
+
*/
|
|
930
|
+
interface InitProjectResult {
|
|
931
|
+
/** Whether the init succeeded. */
|
|
932
|
+
success: boolean;
|
|
933
|
+
/** Files that were created. */
|
|
934
|
+
created: string[];
|
|
935
|
+
/** Files that already existed and were skipped. */
|
|
936
|
+
skipped: string[];
|
|
937
|
+
/** Warning messages collected during init. */
|
|
938
|
+
warnings: string[];
|
|
939
|
+
/** Detected project environment. */
|
|
940
|
+
environment: InitProjectEnvironment;
|
|
941
|
+
/** Next steps for the user. */
|
|
942
|
+
nextSteps: string[];
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* Arguments for the `init` (project setup) command.
|
|
946
|
+
* @internal
|
|
947
|
+
*/
|
|
948
|
+
interface InitProjectArgs {
|
|
949
|
+
/** Project root directory (default: cwd). */
|
|
950
|
+
cwd?: string;
|
|
951
|
+
/** MVI verbosity level for structured output. */
|
|
952
|
+
mvi?: string;
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* Runs the full project init flow.
|
|
956
|
+
*
|
|
957
|
+
* Steps:
|
|
958
|
+
* 1. Detect project environment
|
|
959
|
+
* 2. Write forge-ts.config.ts (if not exists)
|
|
960
|
+
* 3. Write tsdoc.json (if not exists)
|
|
961
|
+
* 4. Validate tsconfig.json strictness
|
|
962
|
+
* 5. Validate package.json
|
|
963
|
+
* 6. Report summary
|
|
964
|
+
*
|
|
965
|
+
* @param args - CLI arguments for the init command.
|
|
966
|
+
* @returns A typed `CommandOutput<InitProjectResult>`.
|
|
967
|
+
* @example
|
|
968
|
+
* ```typescript
|
|
969
|
+
* import { runInitProject } from "@forge-ts/cli/commands/init-project";
|
|
970
|
+
* const output = await runInitProject({ cwd: process.cwd() });
|
|
971
|
+
* console.log(output.data.created); // ["forge-ts.config.ts", "tsdoc.json"]
|
|
972
|
+
* ```
|
|
973
|
+
* @public
|
|
974
|
+
*/
|
|
975
|
+
declare function runInitProject(args: InitProjectArgs): Promise<CommandOutput<InitProjectResult>>;
|
|
976
|
+
/**
|
|
977
|
+
* Citty command definition for `forge-ts init` (bare — full project setup).
|
|
978
|
+
*
|
|
979
|
+
* Detects the project environment, writes default configuration files,
|
|
980
|
+
* validates tsconfig/package.json, and reports a summary.
|
|
981
|
+
*
|
|
982
|
+
* @example
|
|
983
|
+
* ```typescript
|
|
984
|
+
* import { initProjectCommand } from "@forge-ts/cli/commands/init-project";
|
|
985
|
+
* // Registered as the default handler for `forge-ts init`
|
|
986
|
+
* ```
|
|
987
|
+
* @public
|
|
988
|
+
*/
|
|
989
|
+
declare const initProjectCommand: citty.CommandDef<{
|
|
990
|
+
readonly cwd: {
|
|
991
|
+
readonly type: "string";
|
|
992
|
+
readonly description: "Project root directory";
|
|
993
|
+
};
|
|
994
|
+
readonly json: {
|
|
995
|
+
readonly type: "boolean";
|
|
996
|
+
readonly description: "Output as LAFS JSON envelope";
|
|
997
|
+
readonly default: false;
|
|
998
|
+
};
|
|
999
|
+
readonly human: {
|
|
1000
|
+
readonly type: "boolean";
|
|
1001
|
+
readonly description: "Output as formatted text";
|
|
1002
|
+
readonly default: false;
|
|
1003
|
+
};
|
|
1004
|
+
readonly quiet: {
|
|
1005
|
+
readonly type: "boolean";
|
|
1006
|
+
readonly description: "Suppress non-essential output";
|
|
1007
|
+
readonly default: false;
|
|
1008
|
+
};
|
|
1009
|
+
readonly mvi: {
|
|
1010
|
+
readonly type: "string";
|
|
1011
|
+
readonly description: "MVI verbosity level: minimal, standard, full";
|
|
1012
|
+
};
|
|
1013
|
+
}>;
|
|
1014
|
+
|
|
769
1015
|
/**
|
|
770
1016
|
* Typed result for the `lock` command.
|
|
771
1017
|
* @public
|
|
@@ -1087,45 +1333,63 @@ declare const unlockCommand: citty.CommandDef<{
|
|
|
1087
1333
|
}>;
|
|
1088
1334
|
|
|
1089
1335
|
/**
|
|
1090
|
-
*
|
|
1336
|
+
* Forge-ts branded logger built on consola from the UnJS ecosystem.
|
|
1091
1337
|
*
|
|
1092
|
-
*
|
|
1338
|
+
* Provides a singleton logger instance (`forgeLogger`) and a configuration
|
|
1339
|
+
* function (`configureLogger`) that respects CLI flags (`--quiet`, `--json`,
|
|
1340
|
+
* `--verbose`) and TTY detection.
|
|
1093
1341
|
*
|
|
1094
1342
|
* @packageDocumentation
|
|
1095
1343
|
* @internal
|
|
1096
1344
|
*/
|
|
1097
1345
|
/**
|
|
1098
|
-
*
|
|
1346
|
+
* Pre-configured consola instance branded for forge-ts.
|
|
1347
|
+
*
|
|
1348
|
+
* @example
|
|
1349
|
+
* ```typescript
|
|
1350
|
+
* import { forgeLogger } from "./forge-logger.js";
|
|
1351
|
+
* forgeLogger.info("Checking 42 files...");
|
|
1352
|
+
* forgeLogger.success("All checks passed");
|
|
1353
|
+
* forgeLogger.warn("Deprecated import detected");
|
|
1354
|
+
* forgeLogger.error("Build failed");
|
|
1355
|
+
* forgeLogger.debug("Resolved config from forge-ts.config.ts");
|
|
1356
|
+
* ```
|
|
1099
1357
|
* @internal
|
|
1100
1358
|
*/
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
/**
|
|
1109
|
-
|
|
1110
|
-
/**
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
* @param detail - Description of what was produced.
|
|
1115
|
-
* @param duration - Optional wall-clock time in milliseconds.
|
|
1116
|
-
*/
|
|
1117
|
-
step(label: string, detail: string, duration?: number): void;
|
|
1359
|
+
declare const forgeLogger: consola.ConsolaInstance;
|
|
1360
|
+
/**
|
|
1361
|
+
* Options for configuring the forge-ts logger at CLI startup.
|
|
1362
|
+
*
|
|
1363
|
+
* @internal
|
|
1364
|
+
*/
|
|
1365
|
+
interface ForgeLoggerOptions {
|
|
1366
|
+
/** Suppress all consola output (--quiet flag). */
|
|
1367
|
+
quiet?: boolean;
|
|
1368
|
+
/** JSON output mode (--json flag). LAFS handles JSON; suppress consola. */
|
|
1369
|
+
json?: boolean;
|
|
1370
|
+
/** Enable debug-level output (--verbose flag). */
|
|
1371
|
+
verbose?: boolean;
|
|
1118
1372
|
}
|
|
1119
1373
|
/**
|
|
1120
|
-
*
|
|
1374
|
+
* Configures the global {@link forgeLogger} based on CLI flags.
|
|
1375
|
+
*
|
|
1376
|
+
* Call this once at the start of a command's `run()` handler to align
|
|
1377
|
+
* consola's output level with the user's intent:
|
|
1378
|
+
*
|
|
1379
|
+
* - `quiet` or `json` sets level to 0 (silent) so only LAFS output appears.
|
|
1380
|
+
* - `verbose` sets level to 4 (debug) for maximum detail.
|
|
1381
|
+
* - Default level is 3 (info) which covers info, warn, error, and success.
|
|
1121
1382
|
*
|
|
1122
|
-
* @param options -
|
|
1123
|
-
*
|
|
1124
|
-
* @
|
|
1383
|
+
* @param options - Flag-driven configuration.
|
|
1384
|
+
*
|
|
1385
|
+
* @example
|
|
1386
|
+
* ```typescript
|
|
1387
|
+
* import { configureLogger, forgeLogger } from "./forge-logger.js";
|
|
1388
|
+
* configureLogger({ quiet: args.quiet, json: args.json, verbose: args.verbose });
|
|
1389
|
+
* forgeLogger.info("This respects the configured level");
|
|
1390
|
+
* ```
|
|
1125
1391
|
* @internal
|
|
1126
1392
|
*/
|
|
1127
|
-
declare function
|
|
1128
|
-
colors?: boolean;
|
|
1129
|
-
}): Logger;
|
|
1393
|
+
declare function configureLogger(options: ForgeLoggerOptions): void;
|
|
1130
1394
|
|
|
1131
|
-
export { type AuditResult, type BuildResult, type BuildStep, type BypassCreateResult, type BypassStatusResult, type CheckFileError, type CheckFileGroup, type CheckFileWarning, type CheckPage, type CheckResult, type CheckRuleCount, type CheckTriage, type CommandOutput, type ForgeCliError, type ForgeCliWarning, type HookManager, type InitDocsResult, type InitHooksResult, type
|
|
1395
|
+
export { type AuditResult, type BuildResult, type BuildStep, type BypassCreateResult, type BypassStatusResult, type CheckFileError, type CheckFileGroup, type CheckFileWarning, type CheckPage, type CheckResult, type CheckRuleCount, type CheckTriage, type CommandOutput, type DoctorCheckResult, type DoctorCheckStatus, type DoctorResult, type ForgeCliError, type ForgeCliWarning, type ForgeLoggerOptions, type HookManager, type InitDocsResult, type InitHooksResult, type InitProjectEnvironment, type InitProjectResult, type LockResult, type OutputFlags, type PrepublishResult, type TestFailure, type TestResult, type UnlockResult, auditCommand, buildCommand, bypassCommand, checkCommand, configureLogger, docsDevCommand, doctorCommand, emitResult, forgeLogger, initDocsCommand, initHooksCommand, initProjectCommand, lockCommand, prepublishCommand, resolveExitCode, runBypassCreate, runBypassStatus, runDocsDev, runDoctor, runInitHooks, runInitProject, runLock, runPrepublish, runUnlock, testCommand, unlockCommand };
|