spfn 0.2.0-beta.5 → 0.2.0-beta.7
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/index.js +39 -26
- package/dist/templates/lib/api-client.ts +0 -2
- package/dist/templates/server/router.ts +0 -14
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -531,20 +531,20 @@ async function setupApiProxy(cwd, includeAuth) {
|
|
|
531
531
|
const routeContent = `/**
|
|
532
532
|
* SPFN RPC Proxy
|
|
533
533
|
*
|
|
534
|
-
* Resolves routeName to actual HTTP method and path from
|
|
534
|
+
* Resolves routeName to actual HTTP method and path from routeMap,
|
|
535
535
|
* then forwards requests to SPFN API server with automatic:
|
|
536
536
|
* - Cookie forwarding
|
|
537
537
|
* - Interceptor execution
|
|
538
538
|
* - Header manipulation
|
|
539
539
|
*
|
|
540
|
-
* Note:
|
|
541
|
-
*
|
|
540
|
+
* Note: Uses generated route-map to avoid loading server code in Next.js process.
|
|
541
|
+
* Run \`spfn codegen run\` if route-map.ts is missing.
|
|
542
542
|
*/
|
|
543
543
|
|
|
544
|
-
${authImport}import {
|
|
544
|
+
${authImport}import { routeMap } from '@/generated/route-map';
|
|
545
545
|
import { createRpcProxy } from '@spfn/core/nextjs/server';
|
|
546
546
|
|
|
547
|
-
export const { GET, POST } = createRpcProxy({
|
|
547
|
+
export const { GET, POST } = createRpcProxy({ routeMap });
|
|
548
548
|
`;
|
|
549
549
|
writeFileSync2(rpcRoutePath, routeContent);
|
|
550
550
|
const relativePath = rpcRoutePath.replace(cwd + "/", "");
|
|
@@ -741,6 +741,23 @@ var init_deployment_config = __esm({
|
|
|
741
741
|
}
|
|
742
742
|
});
|
|
743
743
|
|
|
744
|
+
// src/utils/version.ts
|
|
745
|
+
function getCliVersion() {
|
|
746
|
+
return "0.2.0-beta.7";
|
|
747
|
+
}
|
|
748
|
+
function getTagFromVersion(version) {
|
|
749
|
+
const match = version.match(/-([a-z]+)\./i);
|
|
750
|
+
return match ? match[1] : "latest";
|
|
751
|
+
}
|
|
752
|
+
function getSpfnTag() {
|
|
753
|
+
return getTagFromVersion(getCliVersion());
|
|
754
|
+
}
|
|
755
|
+
var init_version = __esm({
|
|
756
|
+
"src/utils/version.ts"() {
|
|
757
|
+
"use strict";
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
|
|
744
761
|
// src/commands/init/steps/package.ts
|
|
745
762
|
import ora3 from "ora";
|
|
746
763
|
import { execa as execa2 } from "execa";
|
|
@@ -750,13 +767,14 @@ async function setupPackageJson(cwd, packageJsonPath, packageJson, packageManage
|
|
|
750
767
|
packageJson.dependencies = packageJson.dependencies || {};
|
|
751
768
|
packageJson.devDependencies = packageJson.devDependencies || {};
|
|
752
769
|
packageJson.scripts = packageJson.scripts || {};
|
|
753
|
-
|
|
770
|
+
const spfnTag = getSpfnTag();
|
|
771
|
+
packageJson.dependencies["@spfn/core"] = spfnTag;
|
|
754
772
|
packageJson.dependencies["@sinclair/typebox"] = "^0.34.0";
|
|
755
773
|
packageJson.dependencies["drizzle-typebox"] = "^0.1.0";
|
|
756
|
-
packageJson.dependencies["spfn"] =
|
|
774
|
+
packageJson.dependencies["spfn"] = spfnTag;
|
|
757
775
|
packageJson.dependencies["concurrently"] = "^9.2.1";
|
|
758
776
|
if (includeAuth) {
|
|
759
|
-
packageJson.dependencies["@spfn/auth"] =
|
|
777
|
+
packageJson.dependencies["@spfn/auth"] = spfnTag;
|
|
760
778
|
}
|
|
761
779
|
packageJson.devDependencies["@types/node"] = "^20.11.0";
|
|
762
780
|
packageJson.devDependencies["tsx"] = "^4.20.6";
|
|
@@ -793,6 +811,7 @@ var init_package = __esm({
|
|
|
793
811
|
"src/commands/init/steps/package.ts"() {
|
|
794
812
|
"use strict";
|
|
795
813
|
init_logger();
|
|
814
|
+
init_version();
|
|
796
815
|
({ writeFileSync: writeFileSync4 } = fse6);
|
|
797
816
|
}
|
|
798
817
|
});
|
|
@@ -830,26 +849,17 @@ SPFN_API_URL=http://localhost:8790
|
|
|
830
849
|
* SPFN Codegen Configuration
|
|
831
850
|
*
|
|
832
851
|
* Configure code generators here. Generators run during \`spfn dev\` and \`spfn codegen run\`.
|
|
833
|
-
*
|
|
834
|
-
* Example: Custom generator
|
|
835
|
-
* @example
|
|
836
|
-
* const myGenerator = defineGenerator({
|
|
837
|
-
* name: 'my-package:generator',
|
|
838
|
-
* enabled: true,
|
|
839
|
-
* // ... generator-specific options
|
|
840
|
-
* });
|
|
841
|
-
*
|
|
842
|
-
* Example: File-based generator
|
|
843
|
-
* @example
|
|
844
|
-
* const customGen = defineGenerator({
|
|
845
|
-
* path: './src/generators/my-generator.ts',
|
|
846
|
-
* });
|
|
847
852
|
*/
|
|
848
853
|
|
|
849
854
|
export default defineConfig({
|
|
850
855
|
generators: [
|
|
851
|
-
//
|
|
852
|
-
//
|
|
856
|
+
// Route map generator - generates routeName \u2192 {method, path} mappings
|
|
857
|
+
// Used by RPC proxy to resolve routes without importing server code
|
|
858
|
+
defineGenerator({
|
|
859
|
+
name: '@spfn/core:route-map',
|
|
860
|
+
routerPath: './src/server/router.ts',
|
|
861
|
+
outputPath: './src/generated/route-map.ts',
|
|
862
|
+
}),
|
|
853
863
|
]
|
|
854
864
|
});
|
|
855
865
|
`;
|
|
@@ -1277,7 +1287,9 @@ catch (error)
|
|
|
1277
1287
|
const pm = detectPackageManager(cwd);
|
|
1278
1288
|
if (options.serverOnly || !hasNext) {
|
|
1279
1289
|
const watchMode2 = options.watch === true;
|
|
1280
|
-
|
|
1290
|
+
const host = options.host ?? process.env.HOST ?? "localhost";
|
|
1291
|
+
const port = options.port ?? process.env.PORT ?? "4000";
|
|
1292
|
+
logger.info(`Starting SPFN Server on http://${host}:${port}${watchMode2 ? " (watch mode)" : ""}
|
|
1281
1293
|
`);
|
|
1282
1294
|
let serverProcess2 = null;
|
|
1283
1295
|
let watcherProcess2 = null;
|
|
@@ -4714,8 +4726,9 @@ async function validateEnvVars(options) {
|
|
|
4714
4726
|
envCommand.command("validate").description("Validate environment variables against schema (for CI/CD)").option("-p, --packages <packages...>", "Packages to validate", ["@spfn/core"]).option("-s, --strict", "Exit on any error (including load failures)").action(validateEnvVars);
|
|
4715
4727
|
|
|
4716
4728
|
// src/index.ts
|
|
4729
|
+
init_version();
|
|
4717
4730
|
var program = new Command13();
|
|
4718
|
-
program.name("spfn").description("SPFN CLI - The Missing Backend for Next.js").version(
|
|
4731
|
+
program.name("spfn").description("SPFN CLI - The Missing Backend for Next.js").version(getCliVersion());
|
|
4719
4732
|
program.addCommand(createCommand);
|
|
4720
4733
|
program.addCommand(initCommand);
|
|
4721
4734
|
program.addCommand(addCommand);
|
|
@@ -8,7 +8,6 @@ import { createApi } from '@spfn/core/nextjs';
|
|
|
8
8
|
import { errorRegistry } from "@spfn/core/errors";
|
|
9
9
|
|
|
10
10
|
import type { AppRouter } from '@/server/router';
|
|
11
|
-
import { appMetadata } from "@/server/router.metadata";
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Pre-configured type-safe API client
|
|
@@ -43,7 +42,6 @@ import { appMetadata } from "@/server/router.metadata";
|
|
|
43
42
|
* - Route Handlers
|
|
44
43
|
*/
|
|
45
44
|
export const api = createApi<AppRouter>({
|
|
46
|
-
metadata: { ...appMetadata },
|
|
47
45
|
errorRegistry: errorRegistry,
|
|
48
46
|
debug: true
|
|
49
47
|
});
|
|
@@ -12,9 +12,6 @@ import { listExamples, getExample, createExample, updateExample, deleteExample }
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Main application router
|
|
15
|
-
*
|
|
16
|
-
* defineRouter extracts metadata automatically.
|
|
17
|
-
* Use codegen to generate router.metadata.ts for client-side usage.
|
|
18
15
|
*/
|
|
19
16
|
export const appRouter = defineRouter({
|
|
20
17
|
getRoot,
|
|
@@ -28,16 +25,5 @@ export const appRouter = defineRouter({
|
|
|
28
25
|
|
|
29
26
|
/**
|
|
30
27
|
* Router type for client usage
|
|
31
|
-
*
|
|
32
|
-
* Usage:
|
|
33
|
-
* ```typescript
|
|
34
|
-
* import type { AppRouter } from '@/server/router';
|
|
35
|
-
* import { appMetadata } from '@/server/router.metadata'; // Generated by codegen
|
|
36
|
-
*
|
|
37
|
-
* const api = createApi<AppRouter>({
|
|
38
|
-
* baseUrl: '/api/actions',
|
|
39
|
-
* metadata: appMetadata // Only method/path, no server code!
|
|
40
|
-
* });
|
|
41
|
-
* ```
|
|
42
28
|
*/
|
|
43
29
|
export type AppRouter = typeof appRouter;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spfn",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.7",
|
|
4
4
|
"description": "Superfunction CLI - Add SPFN to your Next.js project",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"postgres": "^3.4.0",
|
|
68
68
|
"prompts": "^2.4.2",
|
|
69
69
|
"tsup": "^8.5.0",
|
|
70
|
-
"@spfn/core": "0.2.0-beta.
|
|
70
|
+
"@spfn/core": "0.2.0-beta.9"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@types/fs-extra": "^11.0.4",
|