@codedrifters/configulator 0.0.269 → 0.0.271

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, path4) {
26534
+ const parts = path4.split(".");
26535
26535
  let current = obj;
26536
26536
  for (const part of parts) {
26537
26537
  if (current == null || typeof current !== "object") {
@@ -26757,20 +26757,20 @@ var ClaudeRenderer = class _ClaudeRenderer {
26757
26757
  obj.excludedCommands = [...sandbox.excludedCommands];
26758
26758
  }
26759
26759
  if (sandbox.filesystem) {
26760
- const fs = {};
26760
+ const fs2 = {};
26761
26761
  if (sandbox.filesystem.allowRead?.length) {
26762
- fs.allowRead = [...sandbox.filesystem.allowRead];
26762
+ fs2.allowRead = [...sandbox.filesystem.allowRead];
26763
26763
  }
26764
26764
  if (sandbox.filesystem.denyRead?.length) {
26765
- fs.denyRead = [...sandbox.filesystem.denyRead];
26765
+ fs2.denyRead = [...sandbox.filesystem.denyRead];
26766
26766
  }
26767
26767
  if (sandbox.filesystem.allowWrite?.length) {
26768
- fs.allowWrite = [...sandbox.filesystem.allowWrite];
26768
+ fs2.allowWrite = [...sandbox.filesystem.allowWrite];
26769
26769
  }
26770
26770
  if (sandbox.filesystem.denyWrite?.length) {
26771
- fs.denyWrite = [...sandbox.filesystem.denyWrite];
26771
+ fs2.denyWrite = [...sandbox.filesystem.denyWrite];
26772
26772
  }
26773
- if (Object.keys(fs).length > 0) obj.filesystem = fs;
26773
+ if (Object.keys(fs2).length > 0) obj.filesystem = fs2;
26774
26774
  }
26775
26775
  if (sandbox.network) {
26776
26776
  const net = {};
@@ -28515,6 +28515,343 @@ var AwsDeploymentTarget = class _AwsDeploymentTarget extends Component12 {
28515
28515
  }
28516
28516
  };
28517
28517
 
28518
+ // src/docs-sync/reference-extraction/extraction.ts
28519
+ import * as fs from "fs";
28520
+ import * as path2 from "path";
28521
+ import { fromMarkdown } from "mdast-util-from-markdown";
28522
+ var DEFAULT_DOCS_ROOT = "docs/src/content/docs";
28523
+ var DEFAULT_SYMBOL_PATTERN = /^(?:[a-z][a-zA-Z0-9]*|[A-Z][a-zA-Z0-9]*|[A-Z][A-Z0-9_]*)$/;
28524
+ function extractDocReferences(options = {}) {
28525
+ const docsRoot = path2.resolve(options.docsRoot ?? DEFAULT_DOCS_ROOT);
28526
+ const symbolPattern = options.symbolPattern ?? DEFAULT_SYMBOL_PATTERN;
28527
+ const knownSymbols = new Set(options.knownSymbols ?? []);
28528
+ if (!fs.existsSync(docsRoot)) {
28529
+ return [];
28530
+ }
28531
+ const records = [];
28532
+ for (const absolutePath of walkMarkdownFiles(docsRoot)) {
28533
+ const docPath = toPosix(path2.relative(docsRoot, absolutePath));
28534
+ const source = fs.readFileSync(absolutePath, "utf-8");
28535
+ const tree = fromMarkdown(stripYamlFrontmatter(source));
28536
+ collectInlineCode(tree, (symbol, position) => {
28537
+ if (!symbolPattern.test(symbol)) {
28538
+ return;
28539
+ }
28540
+ records.push({
28541
+ docPath,
28542
+ line: position.line,
28543
+ column: position.column,
28544
+ symbol,
28545
+ isKnown: knownSymbols.has(symbol)
28546
+ });
28547
+ });
28548
+ }
28549
+ records.sort((a, b) => {
28550
+ if (a.docPath !== b.docPath) {
28551
+ return a.docPath.localeCompare(b.docPath);
28552
+ }
28553
+ if (a.line !== b.line) {
28554
+ return a.line - b.line;
28555
+ }
28556
+ if (a.column !== b.column) {
28557
+ return a.column - b.column;
28558
+ }
28559
+ return a.symbol.localeCompare(b.symbol);
28560
+ });
28561
+ return records;
28562
+ }
28563
+ function walkMarkdownFiles(root) {
28564
+ const out = [];
28565
+ const stack = [root];
28566
+ while (stack.length > 0) {
28567
+ const dir = stack.pop();
28568
+ let entries;
28569
+ try {
28570
+ entries = fs.readdirSync(dir, { withFileTypes: true });
28571
+ } catch {
28572
+ continue;
28573
+ }
28574
+ for (const entry of entries) {
28575
+ const full = path2.join(dir, entry.name);
28576
+ if (entry.isDirectory()) {
28577
+ stack.push(full);
28578
+ } else if (entry.isFile() && full.toLowerCase().endsWith(".md")) {
28579
+ out.push(full);
28580
+ }
28581
+ }
28582
+ }
28583
+ out.sort();
28584
+ return out;
28585
+ }
28586
+ function collectInlineCode(tree, visit) {
28587
+ walk(tree);
28588
+ function walk(node) {
28589
+ if (node.type === "inlineCode") {
28590
+ const start = node.position?.start;
28591
+ if (!start) {
28592
+ return;
28593
+ }
28594
+ visit(node.value, { line: start.line, column: start.column });
28595
+ return;
28596
+ }
28597
+ if (node.type === "code" || node.type === "html") {
28598
+ return;
28599
+ }
28600
+ const parent = node;
28601
+ if (Array.isArray(parent.children)) {
28602
+ for (const child of parent.children) {
28603
+ walk(child);
28604
+ }
28605
+ }
28606
+ }
28607
+ }
28608
+ function toPosix(p) {
28609
+ return p.split(path2.sep).join("/");
28610
+ }
28611
+ function stripYamlFrontmatter(source) {
28612
+ if (!source.startsWith("---")) {
28613
+ return source;
28614
+ }
28615
+ const lines = source.split("\n");
28616
+ if (lines[0] !== "---") {
28617
+ return source;
28618
+ }
28619
+ let endIndex = -1;
28620
+ for (let i = 1; i < lines.length; i++) {
28621
+ if (lines[i] === "---") {
28622
+ endIndex = i;
28623
+ break;
28624
+ }
28625
+ }
28626
+ if (endIndex < 0) {
28627
+ return source;
28628
+ }
28629
+ for (let i = 0; i <= endIndex; i++) {
28630
+ lines[i] = "";
28631
+ }
28632
+ return lines.join("\n");
28633
+ }
28634
+
28635
+ // src/docs-sync/tsdoc-coverage/coverage.ts
28636
+ import * as path3 from "path";
28637
+ import { TSDocParser } from "@microsoft/tsdoc";
28638
+ import * as ts from "typescript";
28639
+ var TsDocCoverageKind = {
28640
+ Class: "Class",
28641
+ Interface: "Interface",
28642
+ TypeAlias: "TypeAlias",
28643
+ Enum: "Enum",
28644
+ Function: "Function",
28645
+ Variable: "Variable",
28646
+ Module: "Module",
28647
+ Default: "Default",
28648
+ Other: "Other"
28649
+ };
28650
+ var DEFAULT_THIN_SUMMARY_WORD_THRESHOLD = 4;
28651
+ var DEFAULT_ENTRY_POINT = "src/index.ts";
28652
+ function analyzeTsDocCoverage(options) {
28653
+ const resolvedOptions = typeof options === "string" ? { packageRoot: options } : options;
28654
+ const packageRoot = path3.resolve(resolvedOptions.packageRoot);
28655
+ const entryPoint = path3.resolve(
28656
+ packageRoot,
28657
+ resolvedOptions.entryPoint ?? DEFAULT_ENTRY_POINT
28658
+ );
28659
+ const thinThreshold = resolvedOptions.thinSummaryWordThreshold ?? DEFAULT_THIN_SUMMARY_WORD_THRESHOLD;
28660
+ const compilerOptions = resolveCompilerOptions(
28661
+ packageRoot,
28662
+ resolvedOptions.tsconfigPath
28663
+ );
28664
+ const program = ts.createProgram({
28665
+ rootNames: [entryPoint],
28666
+ options: compilerOptions
28667
+ });
28668
+ const checker = program.getTypeChecker();
28669
+ const entrySource = program.getSourceFile(entryPoint);
28670
+ if (!entrySource) {
28671
+ throw new Error(
28672
+ `analyzeTsDocCoverage: entry point not found in program: ${entryPoint}`
28673
+ );
28674
+ }
28675
+ const moduleSymbol = checker.getSymbolAtLocation(entrySource);
28676
+ if (!moduleSymbol) {
28677
+ return [];
28678
+ }
28679
+ const tsdocParser = new TSDocParser();
28680
+ const records = [];
28681
+ for (const exportSymbol of checker.getExportsOfModule(moduleSymbol)) {
28682
+ const resolved = resolveAlias(exportSymbol, checker);
28683
+ const declaration = pickPrimaryDeclaration(resolved);
28684
+ if (!declaration) {
28685
+ continue;
28686
+ }
28687
+ const kind = classifyDeclaration(declaration);
28688
+ const location = resolveLocation(declaration);
28689
+ const tsdoc = parseTsDocFor(declaration, tsdocParser);
28690
+ const summaryWordCount = tsdoc ? countSummaryWords(tsdoc) : 0;
28691
+ const hasSummary = summaryWordCount > 0;
28692
+ const hasThinSummary = hasSummary && summaryWordCount <= thinThreshold;
28693
+ const hasParams = tsdoc ? hasBlockTag(tsdoc, "@param") : false;
28694
+ const hasReturns = tsdoc ? hasBlockTag(tsdoc, "@returns") || hasBlockTag(tsdoc, "@return") : false;
28695
+ records.push({
28696
+ symbol: exportSymbol.getName(),
28697
+ kind,
28698
+ location,
28699
+ hasSummary,
28700
+ hasThinSummary,
28701
+ hasParams,
28702
+ hasReturns
28703
+ });
28704
+ }
28705
+ records.sort((a, b) => {
28706
+ if (a.location.file !== b.location.file) {
28707
+ return a.location.file.localeCompare(b.location.file);
28708
+ }
28709
+ if (a.location.line !== b.location.line) {
28710
+ return a.location.line - b.location.line;
28711
+ }
28712
+ return a.symbol.localeCompare(b.symbol);
28713
+ });
28714
+ return records;
28715
+ }
28716
+ function resolveCompilerOptions(packageRoot, tsconfigPath) {
28717
+ if (tsconfigPath) {
28718
+ const absoluteTsconfig = path3.resolve(packageRoot, tsconfigPath);
28719
+ const configFile = ts.readConfigFile(absoluteTsconfig, ts.sys.readFile);
28720
+ if (configFile.error) {
28721
+ throw new Error(
28722
+ `analyzeTsDocCoverage: failed to read tsconfig at ${absoluteTsconfig}: ${ts.flattenDiagnosticMessageText(configFile.error.messageText, "\n")}`
28723
+ );
28724
+ }
28725
+ const parsed = ts.parseJsonConfigFileContent(
28726
+ configFile.config,
28727
+ ts.sys,
28728
+ path3.dirname(absoluteTsconfig)
28729
+ );
28730
+ return { ...parsed.options, noEmit: true };
28731
+ }
28732
+ return {
28733
+ target: ts.ScriptTarget.ESNext,
28734
+ module: ts.ModuleKind.NodeNext,
28735
+ moduleResolution: ts.ModuleResolutionKind.NodeNext,
28736
+ allowJs: false,
28737
+ declaration: false,
28738
+ noEmit: true,
28739
+ skipLibCheck: true,
28740
+ strict: false,
28741
+ esModuleInterop: true,
28742
+ resolveJsonModule: true
28743
+ };
28744
+ }
28745
+ function resolveAlias(symbol, checker) {
28746
+ let current = symbol;
28747
+ for (let i = 0; i < 32; i++) {
28748
+ if (!isAlias(current)) {
28749
+ return current;
28750
+ }
28751
+ const next = checker.getAliasedSymbol(current);
28752
+ if (!next || next === current) {
28753
+ return current;
28754
+ }
28755
+ current = next;
28756
+ }
28757
+ return current;
28758
+ }
28759
+ function isAlias(symbol) {
28760
+ return (symbol.flags & ts.SymbolFlags.Alias) !== 0;
28761
+ }
28762
+ function pickPrimaryDeclaration(symbol) {
28763
+ const declarations = symbol.getDeclarations();
28764
+ if (!declarations || declarations.length === 0) {
28765
+ return void 0;
28766
+ }
28767
+ const concrete = declarations.find(
28768
+ (d) => !ts.isExportSpecifier(d) && !ts.isExportAssignment(d) && !ts.isExportDeclaration(d)
28769
+ );
28770
+ return concrete ?? declarations[0];
28771
+ }
28772
+ function classifyDeclaration(declaration) {
28773
+ if (ts.isClassDeclaration(declaration)) {
28774
+ return TsDocCoverageKind.Class;
28775
+ }
28776
+ if (ts.isInterfaceDeclaration(declaration)) {
28777
+ return TsDocCoverageKind.Interface;
28778
+ }
28779
+ if (ts.isTypeAliasDeclaration(declaration)) {
28780
+ return TsDocCoverageKind.TypeAlias;
28781
+ }
28782
+ if (ts.isEnumDeclaration(declaration)) {
28783
+ return TsDocCoverageKind.Enum;
28784
+ }
28785
+ if (ts.isFunctionDeclaration(declaration) || ts.isMethodDeclaration(declaration)) {
28786
+ return TsDocCoverageKind.Function;
28787
+ }
28788
+ if (ts.isVariableDeclaration(declaration) || ts.isVariableStatement(declaration)) {
28789
+ return TsDocCoverageKind.Variable;
28790
+ }
28791
+ if (ts.isModuleDeclaration(declaration)) {
28792
+ return TsDocCoverageKind.Module;
28793
+ }
28794
+ if (ts.isExportAssignment(declaration)) {
28795
+ return TsDocCoverageKind.Default;
28796
+ }
28797
+ return TsDocCoverageKind.Other;
28798
+ }
28799
+ function resolveLocation(declaration) {
28800
+ const target = ts.isVariableDeclaration(declaration) ? declaration.parent.parent ?? declaration : declaration;
28801
+ const source = target.getSourceFile();
28802
+ const { line } = source.getLineAndCharacterOfPosition(target.getStart());
28803
+ return { file: source.fileName, line: line + 1 };
28804
+ }
28805
+ function parseTsDocFor(declaration, parser) {
28806
+ const target = ts.isVariableDeclaration(declaration) ? declaration.parent.parent ?? declaration : declaration;
28807
+ const sourceText = target.getSourceFile().getFullText();
28808
+ const ranges = ts.getLeadingCommentRanges(sourceText, target.getFullStart());
28809
+ if (!ranges || ranges.length === 0) {
28810
+ return void 0;
28811
+ }
28812
+ for (let i = ranges.length - 1; i >= 0; i--) {
28813
+ const range = ranges[i];
28814
+ if (range.kind !== ts.SyntaxKind.MultiLineCommentTrivia) {
28815
+ continue;
28816
+ }
28817
+ const text = sourceText.slice(range.pos, range.end);
28818
+ if (!text.startsWith("/**")) {
28819
+ continue;
28820
+ }
28821
+ const parsed = parser.parseString(text);
28822
+ return parsed.docComment;
28823
+ }
28824
+ return void 0;
28825
+ }
28826
+ function countSummaryWords(doc) {
28827
+ let words = 0;
28828
+ doc.summarySection.nodes.forEach((node) => {
28829
+ words += countWordsInNode(node);
28830
+ });
28831
+ return words;
28832
+ }
28833
+ function countWordsInNode(node) {
28834
+ const anyNode = node;
28835
+ if (anyNode.kind === "PlainText" && typeof anyNode.text === "string") {
28836
+ return anyNode.text.split(/\s+/).filter((token) => token.trim().length > 0).length;
28837
+ }
28838
+ let words = 0;
28839
+ const children = anyNode.getChildNodes?.() ?? [];
28840
+ for (const child of children) {
28841
+ words += countWordsInNode(child);
28842
+ }
28843
+ return words;
28844
+ }
28845
+ function hasBlockTag(doc, tagName) {
28846
+ if (tagName === "@param") {
28847
+ return doc.params.count > 0;
28848
+ }
28849
+ if (tagName === "@returns" || tagName === "@return") {
28850
+ return doc.returnsBlock !== void 0;
28851
+ }
28852
+ return doc.customBlocks.some((block) => block.blockTag.tagName === tagName);
28853
+ }
28854
+
28518
28855
  // src/latest-eligible-version.ts
28519
28856
  var NPM_REGISTRY = "https://registry.npmjs.org";
28520
28857
  function isPrerelease(version) {
@@ -28696,14 +29033,14 @@ var LAYOUT_ROOT_BY_PROJECT_TYPE = {
28696
29033
  };
28697
29034
  function validateMonorepoLayout(root) {
28698
29035
  const violations = [];
28699
- const rootOutdir = toPosix(root.outdir);
29036
+ const rootOutdir = toPosix2(root.outdir);
28700
29037
  for (const sub of root.subprojects) {
28701
29038
  const className = sub.constructor.name;
28702
29039
  const expectedRoot = expectedRootFor(sub, className);
28703
29040
  if (expectedRoot === void 0) {
28704
29041
  continue;
28705
29042
  }
28706
- const relOutdir = relativeOutdir(rootOutdir, toPosix(sub.outdir));
29043
+ const relOutdir = relativeOutdir(rootOutdir, toPosix2(sub.outdir));
28707
29044
  if (!outdirMatchesRoot(relOutdir, expectedRoot)) {
28708
29045
  violations.push({
28709
29046
  projectName: sub.name,
@@ -28762,7 +29099,7 @@ function outdirMatchesRoot(relOutdir, expectedRoot) {
28762
29099
  }
28763
29100
  return segments.length >= 2;
28764
29101
  }
28765
- function toPosix(p) {
29102
+ function toPosix2(p) {
28766
29103
  return p.replace(/\\/g, "/");
28767
29104
  }
28768
29105
  function relativeOutdir(rootOutdir, subOutdir) {
@@ -28851,8 +29188,8 @@ var ResetTask = class _ResetTask extends Component14 {
28851
29188
  const resetTask = this.project.tasks.addTask(this.taskName, {
28852
29189
  description: "Delete build artifacts specified by pathsToRemove option, or artifactsDirectory if pathsToRemove is empty"
28853
29190
  });
28854
- this.pathsToRemove.forEach((path2) => {
28855
- resetTask.exec(`[ -e "${path2}" ] && rm -rf ${path2} || true`);
29191
+ this.pathsToRemove.forEach((path4) => {
29192
+ resetTask.exec(`[ -e "${path4}" ] && rm -rf ${path4} || true`);
28856
29193
  });
28857
29194
  const rootHasTurbo = TurboRepo.of(this.project.root) !== void 0;
28858
29195
  const isSubproject = this.project !== this.project.root;
@@ -30749,7 +31086,7 @@ export const collections = {
30749
31086
  `;
30750
31087
 
30751
31088
  // src/typescript/typescript-config.ts
30752
- import { relative as relative4 } from "path";
31089
+ import { relative as relative5 } from "path";
30753
31090
  import { Component as Component19 } from "projen";
30754
31091
  import { ensureRelativePathStartsWithDot } from "projen/lib/util/path";
30755
31092
  var TypeScriptConfig = class extends Component19 {
@@ -30768,7 +31105,7 @@ var TypeScriptConfig = class extends Component19 {
30768
31105
  ...tsPaths,
30769
31106
  [dep.name]: [
30770
31107
  ensureRelativePathStartsWithDot(
30771
- relative4(project.outdir, subproject.outdir)
31108
+ relative5(project.outdir, subproject.outdir)
30772
31109
  )
30773
31110
  ]
30774
31111
  };
@@ -30873,6 +31210,7 @@ export {
30873
31210
  STARLIGHT_ROLE,
30874
31211
  StarlightProject,
30875
31212
  TestRunner,
31213
+ TsDocCoverageKind,
30876
31214
  TurboRepo,
30877
31215
  TurboRepoTask,
30878
31216
  TypeScriptConfig,
@@ -30887,6 +31225,7 @@ export {
30887
31225
  addBuildCompleteJob,
30888
31226
  addSyncLabelsWorkflow,
30889
31227
  agendaBundle,
31228
+ analyzeTsDocCoverage,
30890
31229
  awsCdkBundle,
30891
31230
  baseBundle,
30892
31231
  bcmWriterBundle,
@@ -30917,6 +31256,7 @@ export {
30917
31256
  customerProfileBundle,
30918
31257
  docsSyncBundle,
30919
31258
  extractApiProcedure,
31259
+ extractDocReferences,
30920
31260
  formatLayoutViolation,
30921
31261
  formatStarlightSingletonViolation,
30922
31262
  getLatestEligibleVersion,