sounding 0.0.2 → 0.0.3

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/README.md CHANGED
@@ -28,8 +28,9 @@ Sounding also owns its own built-in world engine, so the same package can:
28
28
  - capture outgoing mail by wrapping `sails.helpers.mail.send` and storing normalized messages in `sails.sounding.mailbox`
29
29
 
30
30
  The default configuration story is intentionally calm:
31
- - Sounding disables its hook automatically when Sails runs in `production`
32
- - set `sounding.enableInProduction = true` only for controlled production-like environments such as staging
31
+ - Sounding only enables its hook in the environments listed under `sounding.environments`
32
+ - the default is `['test']`, so non-test boot paths stay dark unless you opt in explicitly
33
+ - if you intentionally need Sounding in another environment, add that environment name to the list
33
34
  - auth conventions auto-detect `User`/`userId` and `Creator`/`creatorId`, with `sounding.auth` available for overrides
34
35
  - Sounding manages a temporary `sails-sqlite` datastore by default
35
36
  - managed SQLite artifacts live under `.tmp/db`
@@ -37,6 +38,16 @@ The default configuration story is intentionally calm:
37
38
  - browser projects start with `desktop`
38
39
  - `inherit` remains available when an app already has a serious test datastore story
39
40
 
41
+ For example:
42
+
43
+ ```js
44
+ module.exports.sounding = {
45
+ environments: ['test'],
46
+ }
47
+ ```
48
+
49
+ If you intentionally want Sounding during another boot path, widen the list explicitly, for example `['test', 'console']` or `['test', 'production']`.
50
+
40
51
  This repository starts with docs-driven product research and the first hook/runtime scaffolding for that vision.
41
52
 
42
53
  See `RESEARCH.md`.
package/index.js CHANGED
@@ -14,12 +14,22 @@ const { createExpect } = require('./lib/create-expect')
14
14
  const { createTestApi } = require('./lib/create-test-api')
15
15
  const { getDefaultConfig } = require('./lib/default-config')
16
16
 
17
- function isProductionEnvironment(sails) {
18
- return (sails.config?.environment || process.env.NODE_ENV) === 'production'
17
+ function getCurrentEnvironment(sails) {
18
+ return sails.config?.environment || process.env.NODE_ENV
19
+ }
20
+
21
+ function getEnabledEnvironments(sails) {
22
+ const configured = sails.config?.sounding?.environments
23
+
24
+ if (Array.isArray(configured)) {
25
+ return configured
26
+ }
27
+
28
+ return getDefaultConfig().environments
19
29
  }
20
30
 
21
31
  function shouldEnableHook(sails) {
22
- return sails.config?.sounding?.enableInProduction === true || !isProductionEnvironment(sails)
32
+ return getEnabledEnvironments(sails).includes(getCurrentEnvironment(sails))
23
33
  }
24
34
 
25
35
  function soundingHook(sails) {
@@ -27,6 +37,7 @@ function soundingHook(sails) {
27
37
 
28
38
  return {
29
39
  defaults: {
40
+ // Hook defaults live under `sails.config.sounding`.
30
41
  sounding: getDefaultConfig(),
31
42
  },
32
43
 
@@ -1,5 +1,7 @@
1
1
  const DEFAULT_CONFIG = Object.freeze({
2
- enableInProduction: false,
2
+ // Sails environments where the Sounding hook should boot.
3
+ // Keep this test-only by default so non-test processes stay dark.
4
+ environments: ['test'],
3
5
  app: {
4
6
  path: '.',
5
7
  environment: 'test',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sounding",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Testing framework for Sails applications and The Boring JavaScript Stack.",
5
5
  "main": "index.js",
6
6
  "license": "MIT",