@stacksjs/defaults 0.70.59 → 0.70.61

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/defaults",
3
3
  "type": "module",
4
- "version": "0.70.59",
4
+ "version": "0.70.61",
5
5
  "description": "Default Stacks scaffold resources (views, layouts, components, preloader) — shipped so apps consuming the framework from node_modules get the same fallback resources a vendored checkout provides. Source of truth: storage/framework/defaults.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -44,11 +44,20 @@ if (!skipPreloader) {
44
44
  const productionCommands = ['cloud:remove', 'cloud:rm', 'cloud:destroy', 'cloud:cleanup', 'cloud:clean-up', 'undeploy']
45
45
  const isProductionCommand = productionCommands.includes(args[0])
46
46
 
47
- // Handle deploy command which can have an optional env argument: `deploy [env]`
47
+ // Handle deploy command: the env may be positional (`deploy staging`) or a
48
+ // flag (`deploy --staging`). CI deploys use the flag form, so detecting only
49
+ // the positional arg left APP_ENV wrong and loaded the wrong .env file.
48
50
  const isDeployCommand = args[0] === 'deploy'
49
51
  if (isDeployCommand) {
50
- // Check if second arg is an environment (not a flag starting with -)
51
- const deployEnv = args[1] && !args[1].startsWith('-') ? args[1] : 'production'
52
+ const flagEnv = args.includes('--production') || args.includes('--prod')
53
+ ? 'production'
54
+ : args.includes('--staging')
55
+ ? 'staging'
56
+ : args.includes('--development') || args.includes('--dev')
57
+ ? 'development'
58
+ : undefined
59
+ const positionalEnv = args[1] && !args[1].startsWith('-') ? args[1] : undefined
60
+ const deployEnv = flagEnv ?? positionalEnv ?? 'production'
52
61
  process.env.APP_ENV = deployEnv
53
62
  process.env.NODE_ENV = deployEnv
54
63
  }
@@ -71,7 +80,12 @@ if (!skipPreloader) {
71
80
  // process.env.SOME_SECRET directly (e.g. deploy-time credentials like
72
81
  // HCLOUD_TOKEN/PORKBUN_API_KEY) with no error — it just looks like a
73
82
  // bogus/expired credential downstream.
74
- autoLoadEnv({ quiet: true, keysFile: '.env.keys' })
83
+ // Pass the resolved env so autoLoadEnv reads `.env.<env>` with the matching
84
+ // `DOTENV_PRIVATE_KEY_<ENV>` (it defaults to `development` otherwise), and
85
+ // overload so this decrypted pass overrides the still-encrypted values the
86
+ // earlier `@stacksjs/env/plugin.js` bunfig preload seeds into process.env
87
+ // (loadEnv won't overwrite already-set vars without it).
88
+ autoLoadEnv({ quiet: true, keysFile: '.env.keys', env: process.env.APP_ENV, overload: true })
75
89
  }
76
90
 
77
91
  // stx template engine plugin