@ts-for-gir/cli 4.0.0-beta.26 → 4.0.0-beta.27
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/bin/ts-for-gir-dev.js +43 -0
- package/bin/ts-for-gir.js +20034 -31
- package/package.json +17 -13
- package/src/module-loader/file-finder.ts +3 -1
- package/src/start.ts +0 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CLI Wrapper for TypeScript Execution
|
|
5
|
+
*
|
|
6
|
+
* This wrapper is required to execute our CLI tool with the necessary Node.js parameters.
|
|
7
|
+
* Due to "type": "module" specified in package.json, Node.js only accepts .js files
|
|
8
|
+
* and rejects .ts or .sh files directly. This wrapper bridges that gap by:
|
|
9
|
+
*
|
|
10
|
+
* 1. Providing a .js entry point that Node.js can execute
|
|
11
|
+
* 2. Spawning the actual TypeScript file with experimental Node.js flags
|
|
12
|
+
* 3. Enabling TypeScript execution without compilation step
|
|
13
|
+
*
|
|
14
|
+
* The experimental flags used:
|
|
15
|
+
* - --experimental-specifier-resolution=node: Enables Node.js-style module resolution
|
|
16
|
+
* - --experimental-strip-types: Strips TypeScript types during execution
|
|
17
|
+
* - --experimental-transform-types: Transforms TypeScript syntax to JavaScript
|
|
18
|
+
* - --no-warnings: Suppresses experimental feature warnings
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { spawn } from 'node:child_process';
|
|
22
|
+
import { fileURLToPath } from 'node:url';
|
|
23
|
+
import { dirname, resolve } from 'node:path';
|
|
24
|
+
|
|
25
|
+
// Get the current file's directory in ES module context
|
|
26
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
27
|
+
const __dirname = dirname(__filename);
|
|
28
|
+
|
|
29
|
+
// Resolve the path to the actual TypeScript CLI entry point
|
|
30
|
+
const tsPath = resolve(__dirname, '../src/start.ts');
|
|
31
|
+
|
|
32
|
+
// Configure Node.js arguments for TypeScript execution
|
|
33
|
+
const nodeArgs = [
|
|
34
|
+
'--experimental-specifier-resolution=node',
|
|
35
|
+
'--experimental-strip-types',
|
|
36
|
+
'--experimental-transform-types',
|
|
37
|
+
'--no-warnings',
|
|
38
|
+
tsPath,
|
|
39
|
+
...process.argv.slice(2), // Forward all CLI arguments to the TypeScript file
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
// Spawn the Node.js process with TypeScript support and inherit stdio
|
|
43
|
+
spawn('node', nodeArgs, { stdio: 'inherit' });
|