You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: add package.json config source and priority system documentation
- Add "Project Configuration (package.json)" section to configuration.md
- Document allowed fields: shortCode, clientId, mrtProject, mrtOrigin, accountManagerHost
- Explain security rationale for excluding sensitive fields
- Update resolution priority list to include package.json as lowest priority
- Document numeric priority system in extending.md
- Add priority table showing ranges (< 0, 0, 1-999, 1000)
- Add example showing how to set priority on custom ConfigSource
Copy file name to clipboardExpand all lines: docs/guide/configuration.md
+43-5Lines changed: 43 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -148,18 +148,56 @@ For multi-instance configurations, each config object also supports:
148
148
|`name`| Instance name for selection with `-i`/`--instance`|
149
149
|`active`| Set to `true` to use this config by default |
150
150
151
+
## Project Configuration (package.json)
152
+
153
+
You can store project-level defaults in your `package.json` file under the `b2c` key. This is useful for settings that are shared across your entire project and safe to commit to version control.
154
+
155
+
```json
156
+
{
157
+
"name": "my-storefront",
158
+
"version": "1.0.0",
159
+
"b2c": {
160
+
"shortCode": "abc123",
161
+
"clientId": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
162
+
"mrtProject": "my-project",
163
+
"accountManagerHost": "account.demandware.com"
164
+
}
165
+
}
166
+
```
167
+
168
+
### Allowed Fields
169
+
170
+
Only non-sensitive, project-level fields can be configured in `package.json`:
171
+
172
+
| Field | Description |
173
+
|-------|-------------|
174
+
|`shortCode`| SCAPI short code |
175
+
|`clientId`| OAuth client ID (for implicit login discovery) |
176
+
|`mrtProject`| MRT project slug |
177
+
|`mrtOrigin`| MRT API origin URL override |
178
+
|`accountManagerHost`| Account Manager hostname for OAuth |
179
+
180
+
::: warning Security Note
181
+
Sensitive fields like `hostname`, `password`, `clientSecret`, `username`, and `mrtApiKey` are intentionally **not** supported in `package.json`. These should be configured via `dw.json` (which should be in `.gitignore`), environment variables, or secure credential stores.
182
+
:::
183
+
184
+
::: tip Lowest Priority
185
+
`package.json` has the lowest priority of all configuration sources. Values from `dw.json`, environment variables, or CLI flags will always override `package.json` settings. This makes it ideal for project defaults that can be overridden per-environment.
186
+
:::
187
+
151
188
### Resolution Priority
152
189
153
190
Configuration is resolved with the following precedence (highest to lowest):
154
191
155
192
1.**CLI flags and environment variables** - Explicit values always take priority
156
-
2.**Plugin sources (high priority)** - Custom sources with `priority: 'before'`
157
-
3.**dw.json** - Project configuration file
158
-
4.**~/.mobify** - Home directory file (for MRT API key only)
159
-
5.**Plugin sources (low priority)** - Custom sources with `priority: 'after'`
Plugins can add custom configuration sources like secret managers or environment-specific files. See [Extending the CLI](./extending) for details.
200
+
Plugins can add custom configuration sources like secret managers or environment-specific files. Plugins can use numeric priorities for fine-grained control over ordering. See [Extending the CLI](./extending) for details.
Copy file name to clipboardExpand all lines: docs/guide/extending.md
+33-4Lines changed: 33 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,19 +58,48 @@ This hook is called during command initialization, after CLI flags are parsed bu
58
58
| Property | Type | Description |
59
59
|----------|------|-------------|
60
60
|`sources`|`ConfigSource[]`| Config sources to add to resolution |
61
-
|`priority`|`'before' \| 'after'`| Where to insert relative to defaults (default: `'after'`) |
61
+
|`priority`|`'before' \| 'after' \| number`| Priority for sources (see below). Default: `'after'`|
62
+
63
+
::: tip Numeric Priorities
64
+
String values map to numeric priorities: `'before'` → -1, `'after'` → 10. You can also use any numeric value directly for fine-grained control. Lower numbers = higher priority.
65
+
:::
62
66
63
67
### Priority Ordering
64
68
69
+
Configuration sources use a numeric priority system where **lower numbers = higher priority**:
OAuth credentials (`clientId`/`clientSecret`) and Basic auth credentials (`username`/`password`) are treated as atomic groups. If any field in a group is already set by a higher-priority source, all fields in that group from your source will be ignored. Ensure your source provides complete credential pairs, or that higher-priority sources don't partially define the same credentials.
0 commit comments