@openpkg-ts/extract 0.23.2 → 0.24.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/bin/tspec.js CHANGED
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- extract
4
- } from "../shared/chunk-8898fs2f.js";
3
+ detectTsRuntime,
4
+ extract,
5
+ resolveCompiledPath
6
+ } from "../shared/chunk-bh378f7b.js";
5
7
 
6
8
  // src/cli/spec.ts
7
9
  import * as fs from "node:fs";
@@ -430,6 +432,26 @@ function createProgram() {
430
432
  console.warn(` Consider: tspec src/index.ts
431
433
  `);
432
434
  }
435
+ if (options.runtime) {
436
+ const resolvedEntry = path.resolve(entryFile);
437
+ const baseDir = path.dirname(resolvedEntry);
438
+ const isTs = /\.tsx?$/.test(resolvedEntry);
439
+ if (isTs) {
440
+ const compiledPath = resolveCompiledPath(resolvedEntry, baseDir);
441
+ const tsRuntime = detectTsRuntime();
442
+ if (!compiledPath && !tsRuntime) {
443
+ console.error(`✗ Runtime schema extraction requires compiled JavaScript files.`);
444
+ console.error(` No .js files found for ${path.basename(entryFile)}.
445
+ `);
446
+ console.error(` Solutions:`);
447
+ console.error(` 1. Build the project first: npm run build`);
448
+ console.error(` 2. Install a TS runtime: bun, tsx, or ts-node`);
449
+ console.error(` 3. Use Node 22+ for native TypeScript support`);
450
+ console.error(` 4. Remove --runtime flag for static extraction only`);
451
+ process.exit(1);
452
+ }
453
+ }
454
+ }
433
455
  const spin = spinner("Extracting...");
434
456
  const result = await extract({
435
457
  entryFile: path.resolve(entryFile),