@stacksjs/config 0.75.81 → 0.75.82

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.
@@ -1,3 +1,4 @@
1
+ import { type FeatureName } from '@stacksjs/features/names';
1
2
  export declare function feature(name: string): boolean;
2
3
  /**
3
4
  * Force-enable a feature in the running process. Intended for tests and
@@ -18,5 +19,28 @@ export declare function resetFeature(name: string): void;
18
19
  * framework features plus any runtime overrides for ad-hoc flags.
19
20
  */
20
21
  export declare function listFeatures(): Record<string, boolean>;
21
- export type StacksFeature = | 'auth' | 'marketing' | 'cms' | 'commerce' | 'forms'
22
- | 'dashboard' | 'monitoring' | 'realtime' | 'queue';
22
+ /**
23
+ * Every name `feature()` answers for: the installable bundles, plus `auth`.
24
+ *
25
+ * Derived rather than restated. The bundles were spelled out here as well as in
26
+ * `@stacksjs/features`, and nothing related the two lists, so a feature added
27
+ * to one and not the other shipped silently - config-only meant no install
28
+ * command and no migration gating, features-only meant `canonicalFeatures()`
29
+ * no longer forced it on and generated artifacts stopped being a function of
30
+ * the source alone (stacksjs/stacks#2867, #2408).
31
+ *
32
+ * Imported from `@stacksjs/features/names`, not the package root: the root also
33
+ * carries the file and table manifests and reaches `node:fs` and
34
+ * `@stacksjs/path` for them, which costs about a millisecond on a path every
35
+ * process walks before anything else. The names module imports nothing.
36
+ *
37
+ * `auth` is added here and is not an installable bundle, which looks backwards
38
+ * until you read why: `config/auth.ts` ships in every app with `enabled: true`,
39
+ * so gating the auth routes on `feature('auth')` would mount `/login`,
40
+ * `/register`, `/generate-two-factor-secret`, `/logout-all` and `/auth/tokens`
41
+ * into every app currently running with `dashboard` off. Route selection is
42
+ * explicit instead, through `STACKS_DEFAULT_ROUTES` - see the rationale in
43
+ * `router/src/route-loader.ts` and `defaults/bootstrap.ts`. It is a name
44
+ * `feature()` knows, and nothing gates on it.
45
+ */
46
+ export type StacksFeature = FeatureName | 'auth';
package/dist/features.js CHANGED
@@ -1 +1 @@
1
- import{config}from"./runtime";const FEATURE_NAMES=["auth","marketing","cms","commerce","forms","dashboard","monitoring","realtime","queue"],FEATURE_DEFAULTS={dashboard:!0},overrides=new Map;function configFor(name){const raw=config[name];return raw&&typeof raw==="object"?raw:void 0}function canonicalFeatures(){return process.env.STACKS_CANONICAL_FEATURES==="1"}export function feature(name){if(overrides.has(name))return overrides.get(name);if(canonicalFeatures()&&FEATURE_NAMES.includes(name))return!0;const cfg=configFor(name);if(cfg){const enabledField=cfg.enabled;if(enabledField===!1)return!1;if(Array.isArray(cfg.env)&&cfg.env.length>0){const currentEnv=(config.app?.env??"").toString();if(!cfg.env.includes(currentEnv))return!1}if(enabledField!==void 0)return!!enabledField;return!0}return FEATURE_DEFAULTS[name]??!1}export function enableFeature(name){overrides.set(name,!0)}export function disableFeature(name){overrides.set(name,!1)}export function resetFeature(name){overrides.delete(name)}export function listFeatures(){const out={};for(const name of FEATURE_NAMES)out[name]=feature(name);for(const name of overrides.keys())out[name]=feature(name);return out}
1
+ import{FEATURE_NAMES as INSTALLABLE_FEATURES}from"@stacksjs/features/names";import{config}from"./runtime";const FEATURE_NAMES=[...INSTALLABLE_FEATURES,"auth"],FEATURE_DEFAULTS={dashboard:!0},overrides=new Map;function configFor(name){const raw=config[name];return raw&&typeof raw==="object"?raw:void 0}function canonicalFeatures(){return process.env.STACKS_CANONICAL_FEATURES==="1"}export function feature(name){if(overrides.has(name))return overrides.get(name);if(canonicalFeatures()&&FEATURE_NAMES.includes(name))return!0;const cfg=configFor(name);if(cfg){const enabledField=cfg.enabled;if(enabledField===!1)return!1;if(Array.isArray(cfg.env)&&cfg.env.length>0){const currentEnv=(config.app?.env??"").toString();if(!cfg.env.includes(currentEnv))return!1}if(enabledField!==void 0)return!!enabledField;return!0}return FEATURE_DEFAULTS[name]??!1}export function enableFeature(name){overrides.set(name,!0)}export function disableFeature(name){overrides.set(name,!1)}export function resetFeature(name){overrides.delete(name)}export function listFeatures(){const out={};for(const name of FEATURE_NAMES)out[name]=feature(name);for(const name of overrides.keys())out[name]=feature(name);return out}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/config",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.81",
5
+ "version": "0.75.82",
6
6
  "description": "The Stacks config helper methods.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -55,14 +55,15 @@
55
55
  "prepublishOnly": "bun run build"
56
56
  },
57
57
  "dependencies": {
58
- "@stacksjs/events": "0.75.81",
59
- "@stacksjs/path": "0.75.81",
60
- "@stacksjs/tunnel": "0.75.81",
58
+ "@stacksjs/events": "0.75.82",
59
+ "@stacksjs/features": "0.75.82",
60
+ "@stacksjs/path": "0.75.82",
61
+ "@stacksjs/tunnel": "0.75.82",
61
62
  "ts-pantry": "^0.11.69"
62
63
  },
63
64
  "devDependencies": {
64
- "@stacksjs/alias": "0.75.81",
65
- "@stacksjs/types": "0.75.81",
65
+ "@stacksjs/alias": "0.75.82",
66
+ "@stacksjs/types": "0.75.82",
66
67
  "better-dx": "^0.2.24"
67
68
  }
68
69
  }