spfn 0.2.0-beta.46 → 0.2.0-beta.47
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
CHANGED
|
@@ -755,7 +755,7 @@ var init_deployment_config = __esm({
|
|
|
755
755
|
|
|
756
756
|
// src/utils/version.ts
|
|
757
757
|
function getCliVersion() {
|
|
758
|
-
return "0.2.0-beta.
|
|
758
|
+
return "0.2.0-beta.47";
|
|
759
759
|
}
|
|
760
760
|
function getTagFromVersion(version) {
|
|
761
761
|
const match = version.match(/-([a-z]+)\./i);
|
|
@@ -36,88 +36,23 @@ export const envSchema = defineEnvSchema({
|
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
* Type-safe Environment
|
|
39
|
+
* Type-safe Environment Variables
|
|
40
40
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
41
|
+
* Variables are lazily validated on access — if a required variable is
|
|
42
|
+
* missing or invalid, an error is thrown at the first access point.
|
|
43
|
+
* This is timing-safe with dotenv loading.
|
|
43
44
|
*
|
|
44
45
|
* @example
|
|
45
46
|
* ```typescript
|
|
46
47
|
* import env from '@/server/config/env.config';
|
|
47
48
|
*
|
|
48
|
-
*
|
|
49
|
-
* const
|
|
50
|
-
*
|
|
51
|
-
* // Get optional variable (returns undefined if missing)
|
|
52
|
-
* const redisUrl = env.get('REDIS_URL');
|
|
53
|
-
*
|
|
54
|
-
* // Get with default value
|
|
55
|
-
* const port = env.get('PORT') ?? 8790;
|
|
49
|
+
* const dbUrl = env.DATABASE_URL; // throws if required and missing
|
|
50
|
+
* const port = env.PORT ?? 8790; // optional with fallback
|
|
56
51
|
* ```
|
|
57
|
-
*/
|
|
58
|
-
export const env = createEnvRegistry(envSchema);
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Validate Environment Variables
|
|
62
52
|
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* or if there are configuration errors.
|
|
53
|
+
* For explicit upfront validation (e.g. in a CLI script), call
|
|
54
|
+
* `createEnvRegistry(envSchema).validateAll()` to get `{ errors, warnings }`.
|
|
66
55
|
*/
|
|
67
|
-
|
|
68
|
-
{
|
|
69
|
-
const validation = env.validate();
|
|
70
|
-
|
|
71
|
-
// Critical errors (missing required variables)
|
|
72
|
-
if (!validation.valid)
|
|
73
|
-
{
|
|
74
|
-
console.error('\n❌ Environment Validation Failed\n');
|
|
75
|
-
console.error('The following required environment variables are missing or invalid:\n');
|
|
76
|
-
|
|
77
|
-
validation.errors.forEach((error) =>
|
|
78
|
-
{
|
|
79
|
-
console.error(` • ${error.key}`);
|
|
80
|
-
console.error(` ${error.message}`);
|
|
81
|
-
|
|
82
|
-
if (error.suggestion)
|
|
83
|
-
{
|
|
84
|
-
console.error(` 💡 ${error.suggestion}`);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
console.error('');
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
console.error('Please check your .env files and ensure all required variables are set.');
|
|
91
|
-
console.error('See .env.example for reference.\n');
|
|
92
|
-
|
|
93
|
-
process.exit(1);
|
|
94
|
-
}
|
|
56
|
+
export const env = createEnvRegistry(envSchema).validate();
|
|
95
57
|
|
|
96
|
-
// Non-critical warnings
|
|
97
|
-
if (validation.warnings.length > 0)
|
|
98
|
-
{
|
|
99
|
-
console.warn('\n⚠️ Environment Warnings:\n');
|
|
100
|
-
|
|
101
|
-
validation.warnings.forEach((warning) =>
|
|
102
|
-
{
|
|
103
|
-
console.warn(` • ${warning.key}: ${warning.message}`);
|
|
104
|
-
|
|
105
|
-
if (warning.suggestion)
|
|
106
|
-
{
|
|
107
|
-
console.warn(` 💡 ${warning.suggestion}`);
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
console.warn('');
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Export the registry as default
|
|
117
|
-
*
|
|
118
|
-
* Import this in your application to access environment variables:
|
|
119
|
-
* ```typescript
|
|
120
|
-
* import env from '@/server/config/env.config';
|
|
121
|
-
* ```
|
|
122
|
-
*/
|
|
123
58
|
export default env;
|
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.47",
|
|
4
4
|
"description": "Superfunction CLI - Add SPFN to your Next.js project",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"concurrently": "^9.2.1",
|
|
79
79
|
"tsx": "^4.20.6",
|
|
80
80
|
"typescript": "^5.3.3",
|
|
81
|
-
"@spfn/core": "0.2.0-beta.
|
|
81
|
+
"@spfn/core": "0.2.0-beta.48"
|
|
82
82
|
},
|
|
83
83
|
"scripts": {
|
|
84
84
|
"build": "tsup && node scripts/copy-templates.js",
|