@codedrifters/configulator 0.0.269 → 0.0.270

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/lib/index.mjs CHANGED
@@ -26530,8 +26530,8 @@ var FALLBACKS = {
26530
26530
  monorepoLayoutSeedBlock: ""
26531
26531
  };
26532
26532
  var TEMPLATE_RE = /\{\{(\w+(?:\.\w+)*)\}\}/g;
26533
- function getNestedValue(obj, path2) {
26534
- const parts = path2.split(".");
26533
+ function getNestedValue(obj, path3) {
26534
+ const parts = path3.split(".");
26535
26535
  let current = obj;
26536
26536
  for (const part of parts) {
26537
26537
  if (current == null || typeof current !== "object") {
@@ -28515,6 +28515,226 @@ var AwsDeploymentTarget = class _AwsDeploymentTarget extends Component12 {
28515
28515
  }
28516
28516
  };
28517
28517
 
28518
+ // src/docs-sync/tsdoc-coverage/coverage.ts
28519
+ import * as path2 from "path";
28520
+ import { TSDocParser } from "@microsoft/tsdoc";
28521
+ import * as ts from "typescript";
28522
+ var TsDocCoverageKind = {
28523
+ Class: "Class",
28524
+ Interface: "Interface",
28525
+ TypeAlias: "TypeAlias",
28526
+ Enum: "Enum",
28527
+ Function: "Function",
28528
+ Variable: "Variable",
28529
+ Module: "Module",
28530
+ Default: "Default",
28531
+ Other: "Other"
28532
+ };
28533
+ var DEFAULT_THIN_SUMMARY_WORD_THRESHOLD = 4;
28534
+ var DEFAULT_ENTRY_POINT = "src/index.ts";
28535
+ function analyzeTsDocCoverage(options) {
28536
+ const resolvedOptions = typeof options === "string" ? { packageRoot: options } : options;
28537
+ const packageRoot = path2.resolve(resolvedOptions.packageRoot);
28538
+ const entryPoint = path2.resolve(
28539
+ packageRoot,
28540
+ resolvedOptions.entryPoint ?? DEFAULT_ENTRY_POINT
28541
+ );
28542
+ const thinThreshold = resolvedOptions.thinSummaryWordThreshold ?? DEFAULT_THIN_SUMMARY_WORD_THRESHOLD;
28543
+ const compilerOptions = resolveCompilerOptions(
28544
+ packageRoot,
28545
+ resolvedOptions.tsconfigPath
28546
+ );
28547
+ const program = ts.createProgram({
28548
+ rootNames: [entryPoint],
28549
+ options: compilerOptions
28550
+ });
28551
+ const checker = program.getTypeChecker();
28552
+ const entrySource = program.getSourceFile(entryPoint);
28553
+ if (!entrySource) {
28554
+ throw new Error(
28555
+ `analyzeTsDocCoverage: entry point not found in program: ${entryPoint}`
28556
+ );
28557
+ }
28558
+ const moduleSymbol = checker.getSymbolAtLocation(entrySource);
28559
+ if (!moduleSymbol) {
28560
+ return [];
28561
+ }
28562
+ const tsdocParser = new TSDocParser();
28563
+ const records = [];
28564
+ for (const exportSymbol of checker.getExportsOfModule(moduleSymbol)) {
28565
+ const resolved = resolveAlias(exportSymbol, checker);
28566
+ const declaration = pickPrimaryDeclaration(resolved);
28567
+ if (!declaration) {
28568
+ continue;
28569
+ }
28570
+ const kind = classifyDeclaration(declaration);
28571
+ const location = resolveLocation(declaration);
28572
+ const tsdoc = parseTsDocFor(declaration, tsdocParser);
28573
+ const summaryWordCount = tsdoc ? countSummaryWords(tsdoc) : 0;
28574
+ const hasSummary = summaryWordCount > 0;
28575
+ const hasThinSummary = hasSummary && summaryWordCount <= thinThreshold;
28576
+ const hasParams = tsdoc ? hasBlockTag(tsdoc, "@param") : false;
28577
+ const hasReturns = tsdoc ? hasBlockTag(tsdoc, "@returns") || hasBlockTag(tsdoc, "@return") : false;
28578
+ records.push({
28579
+ symbol: exportSymbol.getName(),
28580
+ kind,
28581
+ location,
28582
+ hasSummary,
28583
+ hasThinSummary,
28584
+ hasParams,
28585
+ hasReturns
28586
+ });
28587
+ }
28588
+ records.sort((a, b) => {
28589
+ if (a.location.file !== b.location.file) {
28590
+ return a.location.file.localeCompare(b.location.file);
28591
+ }
28592
+ if (a.location.line !== b.location.line) {
28593
+ return a.location.line - b.location.line;
28594
+ }
28595
+ return a.symbol.localeCompare(b.symbol);
28596
+ });
28597
+ return records;
28598
+ }
28599
+ function resolveCompilerOptions(packageRoot, tsconfigPath) {
28600
+ if (tsconfigPath) {
28601
+ const absoluteTsconfig = path2.resolve(packageRoot, tsconfigPath);
28602
+ const configFile = ts.readConfigFile(absoluteTsconfig, ts.sys.readFile);
28603
+ if (configFile.error) {
28604
+ throw new Error(
28605
+ `analyzeTsDocCoverage: failed to read tsconfig at ${absoluteTsconfig}: ${ts.flattenDiagnosticMessageText(configFile.error.messageText, "\n")}`
28606
+ );
28607
+ }
28608
+ const parsed = ts.parseJsonConfigFileContent(
28609
+ configFile.config,
28610
+ ts.sys,
28611
+ path2.dirname(absoluteTsconfig)
28612
+ );
28613
+ return { ...parsed.options, noEmit: true };
28614
+ }
28615
+ return {
28616
+ target: ts.ScriptTarget.ESNext,
28617
+ module: ts.ModuleKind.NodeNext,
28618
+ moduleResolution: ts.ModuleResolutionKind.NodeNext,
28619
+ allowJs: false,
28620
+ declaration: false,
28621
+ noEmit: true,
28622
+ skipLibCheck: true,
28623
+ strict: false,
28624
+ esModuleInterop: true,
28625
+ resolveJsonModule: true
28626
+ };
28627
+ }
28628
+ function resolveAlias(symbol, checker) {
28629
+ let current = symbol;
28630
+ for (let i = 0; i < 32; i++) {
28631
+ if (!isAlias(current)) {
28632
+ return current;
28633
+ }
28634
+ const next = checker.getAliasedSymbol(current);
28635
+ if (!next || next === current) {
28636
+ return current;
28637
+ }
28638
+ current = next;
28639
+ }
28640
+ return current;
28641
+ }
28642
+ function isAlias(symbol) {
28643
+ return (symbol.flags & ts.SymbolFlags.Alias) !== 0;
28644
+ }
28645
+ function pickPrimaryDeclaration(symbol) {
28646
+ const declarations = symbol.getDeclarations();
28647
+ if (!declarations || declarations.length === 0) {
28648
+ return void 0;
28649
+ }
28650
+ const concrete = declarations.find(
28651
+ (d) => !ts.isExportSpecifier(d) && !ts.isExportAssignment(d) && !ts.isExportDeclaration(d)
28652
+ );
28653
+ return concrete ?? declarations[0];
28654
+ }
28655
+ function classifyDeclaration(declaration) {
28656
+ if (ts.isClassDeclaration(declaration)) {
28657
+ return TsDocCoverageKind.Class;
28658
+ }
28659
+ if (ts.isInterfaceDeclaration(declaration)) {
28660
+ return TsDocCoverageKind.Interface;
28661
+ }
28662
+ if (ts.isTypeAliasDeclaration(declaration)) {
28663
+ return TsDocCoverageKind.TypeAlias;
28664
+ }
28665
+ if (ts.isEnumDeclaration(declaration)) {
28666
+ return TsDocCoverageKind.Enum;
28667
+ }
28668
+ if (ts.isFunctionDeclaration(declaration) || ts.isMethodDeclaration(declaration)) {
28669
+ return TsDocCoverageKind.Function;
28670
+ }
28671
+ if (ts.isVariableDeclaration(declaration) || ts.isVariableStatement(declaration)) {
28672
+ return TsDocCoverageKind.Variable;
28673
+ }
28674
+ if (ts.isModuleDeclaration(declaration)) {
28675
+ return TsDocCoverageKind.Module;
28676
+ }
28677
+ if (ts.isExportAssignment(declaration)) {
28678
+ return TsDocCoverageKind.Default;
28679
+ }
28680
+ return TsDocCoverageKind.Other;
28681
+ }
28682
+ function resolveLocation(declaration) {
28683
+ const target = ts.isVariableDeclaration(declaration) ? declaration.parent.parent ?? declaration : declaration;
28684
+ const source = target.getSourceFile();
28685
+ const { line } = source.getLineAndCharacterOfPosition(target.getStart());
28686
+ return { file: source.fileName, line: line + 1 };
28687
+ }
28688
+ function parseTsDocFor(declaration, parser) {
28689
+ const target = ts.isVariableDeclaration(declaration) ? declaration.parent.parent ?? declaration : declaration;
28690
+ const sourceText = target.getSourceFile().getFullText();
28691
+ const ranges = ts.getLeadingCommentRanges(sourceText, target.getFullStart());
28692
+ if (!ranges || ranges.length === 0) {
28693
+ return void 0;
28694
+ }
28695
+ for (let i = ranges.length - 1; i >= 0; i--) {
28696
+ const range = ranges[i];
28697
+ if (range.kind !== ts.SyntaxKind.MultiLineCommentTrivia) {
28698
+ continue;
28699
+ }
28700
+ const text = sourceText.slice(range.pos, range.end);
28701
+ if (!text.startsWith("/**")) {
28702
+ continue;
28703
+ }
28704
+ const parsed = parser.parseString(text);
28705
+ return parsed.docComment;
28706
+ }
28707
+ return void 0;
28708
+ }
28709
+ function countSummaryWords(doc) {
28710
+ let words = 0;
28711
+ doc.summarySection.nodes.forEach((node) => {
28712
+ words += countWordsInNode(node);
28713
+ });
28714
+ return words;
28715
+ }
28716
+ function countWordsInNode(node) {
28717
+ const anyNode = node;
28718
+ if (anyNode.kind === "PlainText" && typeof anyNode.text === "string") {
28719
+ return anyNode.text.split(/\s+/).filter((token) => token.trim().length > 0).length;
28720
+ }
28721
+ let words = 0;
28722
+ const children = anyNode.getChildNodes?.() ?? [];
28723
+ for (const child of children) {
28724
+ words += countWordsInNode(child);
28725
+ }
28726
+ return words;
28727
+ }
28728
+ function hasBlockTag(doc, tagName) {
28729
+ if (tagName === "@param") {
28730
+ return doc.params.count > 0;
28731
+ }
28732
+ if (tagName === "@returns" || tagName === "@return") {
28733
+ return doc.returnsBlock !== void 0;
28734
+ }
28735
+ return doc.customBlocks.some((block) => block.blockTag.tagName === tagName);
28736
+ }
28737
+
28518
28738
  // src/latest-eligible-version.ts
28519
28739
  var NPM_REGISTRY = "https://registry.npmjs.org";
28520
28740
  function isPrerelease(version) {
@@ -28851,8 +29071,8 @@ var ResetTask = class _ResetTask extends Component14 {
28851
29071
  const resetTask = this.project.tasks.addTask(this.taskName, {
28852
29072
  description: "Delete build artifacts specified by pathsToRemove option, or artifactsDirectory if pathsToRemove is empty"
28853
29073
  });
28854
- this.pathsToRemove.forEach((path2) => {
28855
- resetTask.exec(`[ -e "${path2}" ] && rm -rf ${path2} || true`);
29074
+ this.pathsToRemove.forEach((path3) => {
29075
+ resetTask.exec(`[ -e "${path3}" ] && rm -rf ${path3} || true`);
28856
29076
  });
28857
29077
  const rootHasTurbo = TurboRepo.of(this.project.root) !== void 0;
28858
29078
  const isSubproject = this.project !== this.project.root;
@@ -30873,6 +31093,7 @@ export {
30873
31093
  STARLIGHT_ROLE,
30874
31094
  StarlightProject,
30875
31095
  TestRunner,
31096
+ TsDocCoverageKind,
30876
31097
  TurboRepo,
30877
31098
  TurboRepoTask,
30878
31099
  TypeScriptConfig,
@@ -30887,6 +31108,7 @@ export {
30887
31108
  addBuildCompleteJob,
30888
31109
  addSyncLabelsWorkflow,
30889
31110
  agendaBundle,
31111
+ analyzeTsDocCoverage,
30890
31112
  awsCdkBundle,
30891
31113
  baseBundle,
30892
31114
  bcmWriterBundle,