@openpkg-ts/cli 0.3.1 → 0.4.1

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.
Files changed (2) hide show
  1. package/dist/bin/openpkg.js +29 -15
  2. package/package.json +3 -3
@@ -11,7 +11,7 @@ import { Command as Command10 } from "commander";
11
11
  // package.json
12
12
  var package_default = {
13
13
  name: "@openpkg-ts/cli",
14
- version: "0.3.0",
14
+ version: "0.4.1",
15
15
  description: "CLI for OpenPkg TypeScript API extraction and documentation generation",
16
16
  homepage: "https://github.com/ryanwaits/openpkg-ts#readme",
17
17
  repository: {
@@ -34,8 +34,8 @@ var package_default = {
34
34
  test: "bun test"
35
35
  },
36
36
  dependencies: {
37
- "@openpkg-ts/adapters": "^0.3.0",
38
- "@openpkg-ts/sdk": "^0.31.0",
37
+ "@openpkg-ts/adapters": "^0.3.1",
38
+ "@openpkg-ts/sdk": "^0.32.0",
39
39
  commander: "^14.0.0"
40
40
  },
41
41
  devDependencies: {
@@ -309,7 +309,7 @@ function getExtension(format) {
309
309
  return ".md";
310
310
  }
311
311
  }
312
- function renderExport(docs, exportId, format) {
312
+ function renderExport(docs, exportId, format, collapseUnionThreshold) {
313
313
  const exp = docs.getExport(exportId);
314
314
  if (!exp)
315
315
  throw new Error(`Export not found: ${exportId}`);
@@ -319,21 +319,26 @@ function renderExport(docs, exportId, format) {
319
319
  case "html":
320
320
  return docs.toHTML({ export: exportId });
321
321
  default:
322
- return docs.toMarkdown({ export: exportId, frontmatter: true, codeSignatures: true });
322
+ return docs.toMarkdown({
323
+ export: exportId,
324
+ frontmatter: true,
325
+ codeSignatures: true,
326
+ collapseUnionThreshold
327
+ });
323
328
  }
324
329
  }
325
- function renderFull(docs, format) {
330
+ function renderFull(docs, format, collapseUnionThreshold) {
326
331
  switch (format) {
327
332
  case "json":
328
333
  return JSON.stringify(docs.toJSON(), null, 2);
329
334
  case "html":
330
335
  return docs.toHTML();
331
336
  default:
332
- return docs.toMarkdown({ frontmatter: true, codeSignatures: true });
337
+ return docs.toMarkdown({ frontmatter: true, codeSignatures: true, collapseUnionThreshold });
333
338
  }
334
339
  }
335
340
  function createDocsCommand() {
336
- return new Command5("docs").description("Generate documentation from OpenPkg spec").argument("<spec>", "Path to openpkg.json spec file (use - for stdin)").option("-o, --output <path>", "Output file or directory (default: stdout)").option("-f, --format <format>", "Output format: md, json, html (default: md)", "md").option("--split", "Output one file per export (requires --output as directory)").option("-e, --export <name>", "Generate docs for a single export by name").option("-a, --adapter <name>", "Use adapter for generation (default: raw)").action(async (specPath, options) => {
341
+ return new Command5("docs").description("Generate documentation from OpenPkg spec").argument("<spec>", "Path to openpkg.json spec file (use - for stdin)").option("-o, --output <path>", "Output file or directory (default: stdout)").option("-f, --format <format>", "Output format: md, json, html (default: md)", "md").option("--split", "Output one file per export (requires --output as directory)").option("-e, --export <name>", "Generate docs for a single export by name").option("-a, --adapter <name>", "Use adapter for generation (default: raw)").option("--collapse-unions <n>", "Collapse unions with more than N members (default: no collapse)").action(async (specPath, options) => {
337
342
  const format = options.format || "md";
338
343
  try {
339
344
  if (options.adapter && options.adapter !== "raw") {
@@ -384,6 +389,7 @@ function createDocsCommand() {
384
389
  }
385
390
  docs = createDocs(specFile);
386
391
  }
392
+ const collapseUnionThreshold = options.collapseUnions ? parseInt(options.collapseUnions, 10) : undefined;
387
393
  if (options.export) {
388
394
  const exports = docs.getAllExports();
389
395
  const exp = exports.find((e) => e.name === options.export);
@@ -391,7 +397,7 @@ function createDocsCommand() {
391
397
  console.error(JSON.stringify({ error: `Export not found: ${options.export}` }));
392
398
  process.exit(1);
393
399
  }
394
- const output2 = renderExport(docs, exp.id, format);
400
+ const output2 = renderExport(docs, exp.id, format, collapseUnionThreshold);
395
401
  if (options.output && options.output !== "-") {
396
402
  const outputPath = path5.resolve(options.output);
397
403
  fs5.writeFileSync(outputPath, output2);
@@ -414,13 +420,13 @@ function createDocsCommand() {
414
420
  for (const exp of exports) {
415
421
  const filename = `${exp.name}${getExtension(format)}`;
416
422
  const filePath = path5.join(outDir, filename);
417
- const content = renderExport(docs, exp.id, format);
423
+ const content = renderExport(docs, exp.id, format, collapseUnionThreshold);
418
424
  fs5.writeFileSync(filePath, content);
419
425
  }
420
426
  console.error(`Wrote ${exports.length} files to ${outDir}`);
421
427
  return;
422
428
  }
423
- const output = renderFull(docs, format);
429
+ const output = renderFull(docs, format, collapseUnionThreshold);
424
430
  if (options.output && options.output !== "-") {
425
431
  const outputPath = path5.resolve(options.output);
426
432
  fs5.writeFileSync(outputPath, output);
@@ -471,7 +477,7 @@ function validateKinds(kinds) {
471
477
  return kinds;
472
478
  }
473
479
  function createFilterCommand() {
474
- return new Command6("filter").description("Filter an OpenPkg spec by various criteria").argument("<spec>", "Path to spec file (JSON)").option("--kind <kinds>", "Filter by kinds (comma-separated)").option("--name <names>", "Filter by exact names (comma-separated)").option("--id <ids>", "Filter by IDs (comma-separated)").option("--tag <tags>", "Filter by tags (comma-separated)").option("--deprecated", "Only deprecated exports").option("--no-deprecated", "Exclude deprecated exports").option("--has-description", "Only exports with descriptions").option("--missing-description", "Only exports without descriptions").option("--search <term>", "Search name/description (case-insensitive)").option("--module <path>", "Filter by source file path (contains)").option("-o, --output <file>", "Output file (default: stdout)").option("--summary", "Only output matched/total counts").option("--quiet", "Output raw spec only (no wrapper)").action(async (specPath, options) => {
480
+ return new Command6("filter").description("Filter an OpenPkg spec by various criteria").argument("<spec>", "Path to spec file (JSON)").option("--kind <kinds>", "Filter by kinds (comma-separated)").option("--name <names>", "Filter by exact names (comma-separated)").option("--id <ids>", "Filter by IDs (comma-separated)").option("--tag <tags>", "Filter by tags (comma-separated)").option("--deprecated", "Only deprecated exports").option("--no-deprecated", "Exclude deprecated exports").option("--has-description", "Only exports with descriptions").option("--missing-description", "Only exports without descriptions").option("--search <term>", "Search name/description (case-insensitive)").option("--search-members", "Also search member names/descriptions").option("--search-docs", "Also search param/return descriptions and examples").option("--module <path>", "Filter by source file path (contains)").option("-o, --output <file>", "Output file (default: stdout)").option("--summary", "Only output matched/total counts").option("--quiet", "Output raw spec only (no wrapper)").action(async (specPath, options) => {
475
481
  try {
476
482
  const spec = loadSpec5(specPath);
477
483
  const criteria = {};
@@ -494,6 +500,10 @@ function createFilterCommand() {
494
500
  criteria.hasDescription = false;
495
501
  if (options.search)
496
502
  criteria.search = options.search;
503
+ if (options.searchMembers)
504
+ criteria.searchMembers = true;
505
+ if (options.searchDocs)
506
+ criteria.searchDocs = true;
497
507
  if (options.module)
498
508
  criteria.module = options.module;
499
509
  const result = filterSpec(spec, criteria);
@@ -569,7 +579,7 @@ function formatDiagnostics(diagnostics) {
569
579
  }));
570
580
  }
571
581
  function createSnapshotCommand() {
572
- return new Command8("snapshot").description("Generate full OpenPkg spec from TypeScript entry point").argument("<entry>", "Entry point file path").option("-o, --output <file>", "Output file (default: openpkg.json, use - for stdout)", "openpkg.json").option("--max-depth <n>", "Max type depth (default: 4)", "4").option("--skip-resolve", "Skip external type resolution").option("--runtime", "Enable Standard Schema runtime extraction").option("--only <exports>", "Filter exports (comma-separated, wildcards supported)").option("--ignore <exports>", "Ignore exports (comma-separated, wildcards supported)").option("--verify", "Exit 1 if any exports fail").action(async (entry, options) => {
582
+ return new Command8("snapshot").description("Generate full OpenPkg spec from TypeScript entry point").argument("<entry>", "Entry point file path").option("-o, --output <file>", "Output file (default: openpkg.json, use - for stdout)", "openpkg.json").option("--max-depth <n>", "Max type depth (default: 4)", "4").option("--skip-resolve", "Skip external type resolution").option("--runtime", "Enable Standard Schema runtime extraction").option("--only <exports>", "Filter exports (comma-separated, wildcards supported)").option("--ignore <exports>", "Ignore exports (comma-separated, wildcards supported)").option("--verify", "Exit 1 if any exports fail").option("--verbose", "Show detailed output including skipped exports").option("--include-private", "Include private/protected class members").action(async (entry, options) => {
573
583
  const entryFile = path8.resolve(entry);
574
584
  const extractOptions = {
575
585
  entryFile,
@@ -577,7 +587,8 @@ function createSnapshotCommand() {
577
587
  resolveExternalTypes: !options.skipResolve,
578
588
  schemaExtraction: options.runtime ? "hybrid" : "static",
579
589
  only: parseFilter(options.only),
580
- ignore: parseFilter(options.ignore)
590
+ ignore: parseFilter(options.ignore),
591
+ includePrivate: options.includePrivate
581
592
  };
582
593
  try {
583
594
  const result = await extractSpec(extractOptions);
@@ -590,7 +601,10 @@ function createSnapshotCommand() {
590
601
  discovered: result.verification.discovered,
591
602
  extracted: result.verification.extracted,
592
603
  skipped: result.verification.skipped,
593
- failed: result.verification.failed
604
+ failed: result.verification.failed,
605
+ ...options.verbose && result.verification.details.skipped.length > 0 && {
606
+ skippedDetails: result.verification.details.skipped
607
+ }
594
608
  }
595
609
  },
596
610
  ...result.runtimeSchemas && {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpkg-ts/cli",
3
- "version": "0.3.1",
3
+ "version": "0.4.1",
4
4
  "description": "CLI for OpenPkg TypeScript API extraction and documentation generation",
5
5
  "homepage": "https://github.com/ryanwaits/openpkg-ts#readme",
6
6
  "repository": {
@@ -23,8 +23,8 @@
23
23
  "test": "bun test"
24
24
  },
25
25
  "dependencies": {
26
- "@openpkg-ts/adapters": "^0.3.0",
27
- "@openpkg-ts/sdk": "^0.31.0",
26
+ "@openpkg-ts/adapters": "^0.3.1",
27
+ "@openpkg-ts/sdk": "^0.32.0",
28
28
  "commander": "^14.0.0"
29
29
  },
30
30
  "devDependencies": {