spfn 0.2.0-beta.9 → 0.3.0-beta.2
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/LICENSE +1 -1
- package/README.md +626 -204
- package/bin/spfn.js +53 -4
- package/dist/index.js +4183 -2281
- package/dist/templates/.dockerignore +1 -0
- package/dist/templates/Dockerfile +1 -1
- package/dist/templates/README.md +94 -0
- package/dist/templates/lib/api-client.ts +1 -1
- package/dist/templates/modes/full/src/app/auth/callback/page.tsx +1 -0
- package/dist/templates/modes/full/src/app/login/page.tsx +68 -0
- package/dist/templates/modes/full/src/i18n/catalogs.ts +16 -0
- package/dist/templates/modes/full/src/i18n/server.ts +9 -0
- package/dist/templates/modes/full/src/server/config/env.config.ts +23 -0
- package/dist/templates/modes/full/src/server/mcp.ts +75 -0
- package/dist/templates/modes/full/src/server/router.ts +32 -0
- package/dist/templates/modes/full/src/server/routes/examples.ts +94 -0
- package/dist/templates/modes/full/src/server/routes/health.ts +9 -0
- package/dist/templates/modes/full/src/server/routes/root.ts +15 -0
- package/dist/templates/modes/full/src/server/server.config.ts +14 -0
- package/dist/templates/server/config/env.config.ts +10 -75
- package/dist/templates/server/entities/config.ts +1 -1
- package/dist/templates/server/entities/example.entity.ts +1 -1
- package/dist/templates/server/repositories/example.repository.ts +1 -1
- package/dist/templates/server/router.ts +2 -3
- package/dist/templates/server/routes/examples.ts +2 -12
- package/dist/templates/server/routes/health.ts +1 -1
- package/dist/templates/server/routes/root.ts +1 -2
- package/dist/templates/server/server.config.ts +2 -2
- package/dist/templates/vercel/npmrc +4 -0
- package/dist/templates/vercel/route.ts +53 -0
- package/dist/templates/vercel/vercel.json +6 -0
- package/package.json +35 -23
- package/dist/commands/generate/templates/contract.template +0 -58
- package/dist/commands/generate/templates/entity.template +0 -28
- package/dist/commands/generate/templates/init-migration.template +0 -3
- package/dist/commands/generate/templates/repository.template +0 -56
- package/dist/commands/generate/templates/route.template +0 -65
- package/dist/commands/generate/templates/schema.template +0 -13
- package/dist/templates/Dockerfile.optimized +0 -67
- package/dist/templates/config/index.ts +0 -22
- package/dist/templates/config/schema.ts +0 -42
package/bin/spfn.js
CHANGED
|
@@ -1,10 +1,59 @@
|
|
|
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
|
+
// Resolve tsx to an absolute URL from THIS package's location. A bare
|
|
32
|
+
// '--import tsx' is resolved by Node against the child's CWD, so running
|
|
33
|
+
// outside a project (no node_modules/tsx up the tree) crashes the child
|
|
34
|
+
// with ERR_MODULE_NOT_FOUND even though the guard import above succeeds
|
|
35
|
+
// (it resolves package-relative). Resolving here also doubles as the
|
|
36
|
+
// availability check — a throw falls back to running without tsx.
|
|
37
|
+
const { createRequire } = await import('module');
|
|
38
|
+
const { pathToFileURL } = await import('url');
|
|
39
|
+
const tsxUrl = pathToFileURL(createRequire(import.meta.url).resolve(TSX_MODULE)).href;
|
|
40
|
+
|
|
41
|
+
const { spawn } = await import('child_process');
|
|
42
|
+
const child = spawn(
|
|
43
|
+
process.execPath,
|
|
44
|
+
[TSX_FLAG, tsxUrl, ...process.execArgv, process.argv[1], ...process.argv.slice(2)],
|
|
45
|
+
{ stdio: 'inherit' },
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
child.on('close', (code) => process.exit(code ?? 0));
|
|
49
|
+
child.on('error', () =>
|
|
50
|
+
{
|
|
51
|
+
import('../dist/index.js').then(({ run }) => run()).catch(abort);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function abort(error)
|
|
7
56
|
{
|
|
8
57
|
console.error('Error:', error);
|
|
9
58
|
process.exit(1);
|
|
10
|
-
}
|
|
59
|
+
}
|