spfn 0.2.0-beta.2 → 0.2.0-beta.4

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.
Files changed (2) hide show
  1. package/dist/index.js +65 -0
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -4640,6 +4640,71 @@ async function checkEnvFiles(options) {
4640
4640
  }
4641
4641
  envCommand.command("init").description("Generate .env template files from schema").option("-p, --package <package>", "Package name to read env schema from", "@spfn/core").option("-f, --force", "Overwrite existing files").action(initEnvFiles);
4642
4642
  envCommand.command("check").description("Check .env files against schema").option("-p, --package <package>", "Package name to read env schema from", "@spfn/core").action(checkEnvFiles);
4643
+ async function validateEnvVars(options) {
4644
+ const packages = options.packages || ["@spfn/core"];
4645
+ console.log(chalk26.blue.bold(`
4646
+ \u{1F50D} Validating environment variables
4647
+ `));
4648
+ const allErrors = [];
4649
+ const allWarnings = [];
4650
+ for (const packageName of packages) {
4651
+ try {
4652
+ console.log(chalk26.dim(` \u{1F4E6} ${packageName}`));
4653
+ const envSchema = await loadEnvSchema(packageName);
4654
+ const { createEnvRegistry } = await import("@spfn/core/env");
4655
+ const registry = createEnvRegistry(envSchema);
4656
+ const result = registry.validateAll();
4657
+ for (const error of result.errors) {
4658
+ allErrors.push({ ...error, package: packageName });
4659
+ }
4660
+ for (const warning of result.warnings) {
4661
+ allWarnings.push({ ...warning, package: packageName });
4662
+ }
4663
+ } catch (error) {
4664
+ if (error instanceof Error && error.message.includes("does not export envSchema")) {
4665
+ console.log(chalk26.dim(` \u23ED\uFE0F No envSchema exported, skipping`));
4666
+ continue;
4667
+ }
4668
+ console.error(chalk26.red(` \u274C Failed to load: ${error instanceof Error ? error.message : String(error)}`));
4669
+ if (options.strict) {
4670
+ process.exit(1);
4671
+ }
4672
+ }
4673
+ }
4674
+ console.log("");
4675
+ if (allErrors.length > 0) {
4676
+ console.log(chalk26.red.bold(`\u274C Validation Errors (${allErrors.length}):
4677
+ `));
4678
+ for (const error of allErrors) {
4679
+ console.log(` ${chalk26.red("\u2717")} ${chalk26.cyan(error.key)}`);
4680
+ console.log(` ${chalk26.dim(error.message)}`);
4681
+ console.log(` ${chalk26.dim(`from ${error.package}`)}`);
4682
+ console.log("");
4683
+ }
4684
+ }
4685
+ if (allWarnings.length > 0) {
4686
+ console.log(chalk26.yellow.bold(`\u26A0\uFE0F Warnings (${allWarnings.length}):
4687
+ `));
4688
+ for (const warning of allWarnings) {
4689
+ console.log(` ${chalk26.yellow("\u26A0")} ${chalk26.cyan(warning.key)}`);
4690
+ console.log(` ${chalk26.dim(warning.message)}`);
4691
+ console.log("");
4692
+ }
4693
+ }
4694
+ if (allErrors.length === 0 && allWarnings.length === 0) {
4695
+ console.log(chalk26.green.bold("\u2705 All environment variables are valid!\n"));
4696
+ } else if (allErrors.length === 0) {
4697
+ console.log(chalk26.green("\u2705 No errors found."));
4698
+ console.log(chalk26.yellow(`\u26A0\uFE0F ${allWarnings.length} warning(s) found.
4699
+ `));
4700
+ } else {
4701
+ console.log(chalk26.red(`
4702
+ \u274C Validation failed with ${allErrors.length} error(s)
4703
+ `));
4704
+ process.exit(1);
4705
+ }
4706
+ }
4707
+ 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);
4643
4708
 
4644
4709
  // src/index.ts
4645
4710
  var program = new Command13();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spfn",
3
- "version": "0.2.0-beta.2",
3
+ "version": "0.2.0-beta.4",
4
4
  "description": "Superfunction CLI - Add SPFN to your Next.js project",
5
5
  "type": "module",
6
6
  "bin": {
@@ -59,7 +59,7 @@
59
59
  "chokidar": "^4.0.3",
60
60
  "commander": "^11.1.0",
61
61
  "dotenv": "^17.2.3",
62
- "drizzle-orm": "^0.44.7",
62
+ "drizzle-orm": "^0.45.0",
63
63
  "execa": "^8.0.1",
64
64
  "fs-extra": "^11.2.0",
65
65
  "ora": "^7.0.1",
@@ -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.4"
70
+ "@spfn/core": "0.2.0-beta.5"
71
71
  },
72
72
  "devDependencies": {
73
73
  "@types/fs-extra": "^11.0.4",