spfn 0.2.0-beta.3 → 0.2.0-beta.30
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/spfn.js +46 -4
- package/dist/index.js +1120 -449
- package/dist/templates/lib/api-client.ts +65 -34
- package/dist/templates/server/router.ts +0 -14
- package/package.json +3 -3
package/bin/spfn.js
CHANGED
|
@@ -1,10 +1,52 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* SPFN CLI Entry Point
|
|
5
|
+
*
|
|
6
|
+
* Re-spawns with --import tsx when .ts schema loading is needed.
|
|
7
|
+
* This avoids ERR_REQUIRE_CYCLE_MODULE on Node.js 22+ where
|
|
8
|
+
* tsx.register() causes CJS/ESM interop cycles.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const TSX_FLAG = '--import';
|
|
12
|
+
const TSX_MODULE = 'tsx';
|
|
13
|
+
|
|
14
|
+
// Already running with tsx loader — just run
|
|
15
|
+
if (process.execArgv.some(arg => arg.includes(TSX_MODULE)))
|
|
16
|
+
{
|
|
17
|
+
import('../dist/index.js').then(({ run }) => run()).catch(abort);
|
|
18
|
+
}
|
|
19
|
+
else
|
|
20
|
+
{
|
|
21
|
+
// Try to re-spawn with --import tsx for .ts schema support
|
|
22
|
+
tryRelaunchWithTsx().catch(() =>
|
|
23
|
+
{
|
|
24
|
+
// tsx not available — run without it
|
|
25
|
+
import('../dist/index.js').then(({ run }) => run()).catch(abort);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function tryRelaunchWithTsx()
|
|
4
30
|
{
|
|
5
|
-
|
|
6
|
-
|
|
31
|
+
// Verify tsx is resolvable
|
|
32
|
+
await import('tsx/esm/api');
|
|
33
|
+
|
|
34
|
+
const { spawn } = await import('child_process');
|
|
35
|
+
const child = spawn(
|
|
36
|
+
process.execPath,
|
|
37
|
+
[TSX_FLAG, TSX_MODULE, ...process.execArgv, process.argv[1], ...process.argv.slice(2)],
|
|
38
|
+
{ stdio: 'inherit' },
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
child.on('close', (code) => process.exit(code ?? 0));
|
|
42
|
+
child.on('error', () =>
|
|
43
|
+
{
|
|
44
|
+
import('../dist/index.js').then(({ run }) => run()).catch(abort);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function abort(error)
|
|
7
49
|
{
|
|
8
50
|
console.error('Error:', error);
|
|
9
51
|
process.exit(1);
|
|
10
|
-
}
|
|
52
|
+
}
|