@onderwijsin/directus-seeder-hook 0.0.0-stage → 1.0.1
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/CHANGELOG.md +33 -0
- package/LICENSE +21 -0
- package/README.md +656 -2
- package/dist/index.js +1 -0
- package/package.json +82 -3
- package/seeder-config.schema.json +1100 -0
- package/seeder.config.example.json +29 -0
package/README.md
CHANGED
|
@@ -1,3 +1,657 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @onderwijsin/directus-seeder-hook
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Seed Directus system records and configured application collections from JSON. Extract current data
|
|
4
|
+
manually during development, or enable automatic extraction independently for either scope. Imports
|
|
5
|
+
are explicit CLI commands: the hook never seeds at startup or applies schema.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm add @onderwijsin/directus-seeder-hook
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Requires Directus `>=12.0.0 <13.0.0`, Node.js `>=24.10.0`, and a trusted, non-sandboxed Directus
|
|
14
|
+
installation. Restart Directus after installation. For containers, install the package in the
|
|
15
|
+
runtime image or include its built extension directory; see
|
|
16
|
+
[including extensions](https://directus.com/docs/self-hosting/including-extensions). Installations
|
|
17
|
+
allowing only sandboxed extensions cannot load this hook.
|
|
18
|
+
|
|
19
|
+
The Directus process needs database and storage access, readable seed JSON and import assets, and
|
|
20
|
+
writable extraction and temporary directories. Mount persistent paths yourself. Seeder operations
|
|
21
|
+
use Directus services with administrator permissions, independently of a caller's API token.
|
|
22
|
+
|
|
23
|
+
## Commands and options
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npx directus seed config
|
|
27
|
+
npx directus seed system --mode insert-missing
|
|
28
|
+
npx directus seed system --mode insert-update --include directus_roles directus_permissions --yes
|
|
29
|
+
# Requires core.collections in SEEDER_CONFIG_PATH
|
|
30
|
+
npx directus seed core --include categories --yes
|
|
31
|
+
DEPLOYMENT_ENV=development npx directus seed extract --scope both --json-only
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Run imports after database bootstrap and schema setup. In Directus containers without `npx`, invoke
|
|
35
|
+
the installed CLI directly:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
docker compose exec directus node /directus/cli.js seed system --mode insert-missing
|
|
39
|
+
docker compose exec -e DEPLOYMENT_ENV=development directus node /directus/cli.js seed extract
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
| Option | Import: `seed system` / `seed core` | Export: `seed extract` |
|
|
43
|
+
| -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
|
|
44
|
+
| `-m, --mode <mode>` | Override all collection modes with exact `insert-missing`, `insert-update`, or `full-idempotent`. Omitted: use each effective `operationMode`. | — |
|
|
45
|
+
| `--full-reset` | Bypass management boundaries; every selected collection with a seed file must resolve to `full-idempotent`. | — |
|
|
46
|
+
| `-i, --include <collections...>` | Select collections. | Select JSON output. |
|
|
47
|
+
| `-e, --exclude <collections...>` | Exclude collections. | Exclude JSON output. |
|
|
48
|
+
| `-f, --force`, `-y, --yes` | Skip confirmation prompts, but retain the full-idempotent environment gate. | — |
|
|
49
|
+
| `--scope <scope>` | — | Exact `system` (default), `core`, or `both`. |
|
|
50
|
+
| `--skip-clean` | — | Preserve other output; selected files are still overwritten. |
|
|
51
|
+
| `--json-only` | — | Skip binary reads, downloads, and cleanup. |
|
|
52
|
+
| `-a, --assets` | — | Enable system binaries even with `SEEDER_JSON_ONLY=true`. Conflicts with `--json-only`. |
|
|
53
|
+
| `-h, --help` | Show help. | Show help. |
|
|
54
|
+
|
|
55
|
+
CLI collection names are separate space-delimited arguments. Each CLI list replaces its matching
|
|
56
|
+
environment list; exclusions win. Selection preserves configured order, and `both` processes system
|
|
57
|
+
then core. Neither command accepts a positional seed path; use environment paths. For manual
|
|
58
|
+
extraction, selection narrows JSON output only: **cleanup and binary export are not narrowed by
|
|
59
|
+
include/exclude**. Core always handles JSON only, including with `--assets`.
|
|
60
|
+
|
|
61
|
+
### Inspect collection configuration
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
npx directus seed config --defaults
|
|
65
|
+
npx directus seed config --collection directus_roles
|
|
66
|
+
npx directus seed config --collection articles
|
|
67
|
+
LOG_LEVEL=silent npx directus seed config | jq '.system.order'
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`seed config` prints effective collection settings, including resolved modes and management, as JSON
|
|
71
|
+
with two-space indentation and one final newline. Output always has `system` and `core`, each with
|
|
72
|
+
`order` and `collections`. It ignores import/extraction selection. `--collection` narrows both
|
|
73
|
+
scopes to that name, leaving the other empty; an unknown name exits 1. The command accepts no mode,
|
|
74
|
+
include, exclude, or scope option. Directus startup can also log to stdout; use `LOG_LEVEL=silent`
|
|
75
|
+
when piping JSON. Inspection errors go to stderr and exit 1.
|
|
76
|
+
|
|
77
|
+
`--defaults` bypasses the consumer file, even if missing or invalid, and shows built-in system
|
|
78
|
+
settings and an empty core scope. Startup environment validation still applies. Normal inspection
|
|
79
|
+
validates the configured file without falling back to defaults.
|
|
80
|
+
|
|
81
|
+
Inspection is read-only: no seeds, manifests, relation sources, database/schema access, services,
|
|
82
|
+
cache clearing, locks, or output files. It needs no destructive opt-in and works in every deployment
|
|
83
|
+
environment. It shows configured settings, not live schema compatibility; verify the target schema
|
|
84
|
+
and management inputs before importing.
|
|
85
|
+
|
|
86
|
+
## Configuration reference
|
|
87
|
+
|
|
88
|
+
[Directus casts environment values](https://directus.com/docs/configuration/intro) before the hook
|
|
89
|
+
validates them once at startup. Booleans must arrive as booleans; numeric `0`/`1` are not booleans.
|
|
90
|
+
Integer options require numbers without coercion or truncation. Invalid values fail startup even
|
|
91
|
+
when unused or overridden by CLI. `SEEDER_ENABLED=false` skips registration and remaining
|
|
92
|
+
validation. Environment changes require a restart.
|
|
93
|
+
|
|
94
|
+
| Variable | Default | Accepted value and effect |
|
|
95
|
+
| ------------------------------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
96
|
+
| `SEEDER_ENABLED` | `true` | Master switch; boolean `false` or string `false` disables all registration. |
|
|
97
|
+
| `DEPLOYMENT_ENV` | Unset | Untrimmed string. Only exact `development` enables manual/automatic extraction; also controls system import transformations below. |
|
|
98
|
+
| `SEEDER_CONFIG_PATH` | Unset | Nonblank, trimmed path to consumer JSON; relative to the Directus working directory. No file discovery. |
|
|
99
|
+
| `SEEDER_SCOPE` | `system` | Only `system`, case-insensitive without trimming. Choose core via `seed core` or extraction `--scope`. |
|
|
100
|
+
| `SEEDER_INCLUDE` | `[]` | One nonblank string or an array; trimmed names. Empty array selects all available collections. |
|
|
101
|
+
| `SEEDER_EXCLUDE` | `[]` | Same list forms; empty array excludes none. Exclusions win. |
|
|
102
|
+
| `SEEDER_CONTINUE_ON_ERROR` | `false` | Continue with later collections after an import mutation failure. Either value exits 1 for failed mutations; preflight and extraction errors still fail. |
|
|
103
|
+
| `SEEDER_BATCH_SIZE` | `50` | Positive integer batch size. |
|
|
104
|
+
| `SEEDER_ENABLE_FULL_IDEMPOTENT` | `false` | Required for full-idempotent import, including with `--yes` or `--force`. |
|
|
105
|
+
| `SEEDER_JSON_ONLY` | `false` | Disable system binary extraction/cleanup; manual `--assets` overrides it. Does not affect file import. |
|
|
106
|
+
| `SEEDER_AUTO_EXTRACT_SYSTEM` | `false` | Enable automatic system extraction in development. |
|
|
107
|
+
| `SEEDER_AUTO_EXTRACT_CORE` | `false` | Independently enable automatic configured core extraction in development. |
|
|
108
|
+
| `SEEDER_AUTO_EXTRACT_INCLUDE` | Unset | Optional nonempty list of supported system/configured core names. Overrides general filters and skips cleanup for auto-extract only. |
|
|
109
|
+
| `SEEDER_JSON_INDENT` | `tab` | Exact `tab` or `space`, without trimming; manual and automatic extraction. |
|
|
110
|
+
| `SEEDER_JSON_INDENT_SIZE` | `2` | Integer `1`–`10`; used with `space`, validated even with `tab`. |
|
|
111
|
+
| `SEEDER_SEEDS_DIR` | `/directus/seeds` | Nonblank, trimmed seeds root; scope JSON/history lives under `system/` or `core/`. |
|
|
112
|
+
| `SEEDER_ASSETS_DIR` | `/directus/seeds/system/assets` | Nonblank, trimmed system asset path, independent of the seeds root. Changing the root never relocates assets. |
|
|
113
|
+
| `DEFAULT_EMAIL` | `admin@example.com` | String replacing the email of matching root-user seeds. |
|
|
114
|
+
| `DEFAULT_PASSWORD` | `p4ssw0rd!` | String replacing matching root-user passwords. Supply a deployment-specific secret. |
|
|
115
|
+
| `STORAGE_LOCATIONS` | `['local']` | Directus storage locations: one nonblank string or a nonempty array, trimmed. File imports retain seeded `storage`, otherwise use the first location. Storage drivers must already be configured. |
|
|
116
|
+
|
|
117
|
+
Lists accept singular values or Directus-cast arrays and normalize to arrays. For example,
|
|
118
|
+
`SEEDER_INCLUDE=directus_roles,directus_users` selects two names, while
|
|
119
|
+
`SEEDER_INCLUDE=string:directus_roles,directus_users` is one literal entry: the hook does not split
|
|
120
|
+
strings itself. `SEEDER_INCLUDE=json:[]` selects all; `SEEDER_EXCLUDE=json:[]` excludes none. Blank
|
|
121
|
+
entries and nonstrings fail. The automatic allowlist is case-sensitive and rejects empty values,
|
|
122
|
+
empty arrays, and unknown names, even for a disabled scope. Omit it to use general filters.
|
|
123
|
+
`STORAGE_LOCATIONS=json:[]` is invalid.
|
|
124
|
+
|
|
125
|
+
Credential strings retain whitespace and explicitly empty values. In a standalone Directus `.env`,
|
|
126
|
+
use `string:` for numeric or boolean-like secrets, for example `DEFAULT_PASSWORD=string:123456`. If
|
|
127
|
+
deployment tooling already adds that prefix, supply the plain secret to that tooling.
|
|
128
|
+
|
|
129
|
+
Standard Directus `LOG_LEVEL=debug` or `trace` helps diagnose runs. CLI confirmations are also
|
|
130
|
+
skipped for non-TTY stdin/stdout or any nonempty raw process value of `CI`,
|
|
131
|
+
`CONTINUOUS_INTEGRATION`, `BUILD_NUMBER`, or `GITHUB_ACTIONS`, including the string `false`.
|
|
132
|
+
|
|
133
|
+
A minimal development setup:
|
|
134
|
+
|
|
135
|
+
```dotenv
|
|
136
|
+
DEPLOYMENT_ENV=development
|
|
137
|
+
SEEDER_SEEDS_DIR=/directus/seeds
|
|
138
|
+
SEEDER_ASSETS_DIR=/directus/seeds/system/assets
|
|
139
|
+
SEEDER_JSON_ONLY=true
|
|
140
|
+
SEEDER_AUTO_EXTRACT_SYSTEM=false
|
|
141
|
+
SEEDER_AUTO_EXTRACT_CORE=false
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Consumer JSON configuration
|
|
145
|
+
|
|
146
|
+
The package ships `seeder.config.example.json` and `seeder-config.schema.json`. Copy the example
|
|
147
|
+
outside managed output directories and set the runtime path:
|
|
148
|
+
|
|
149
|
+
```sh
|
|
150
|
+
cp node_modules/@onderwijsin/directus-seeder-hook/seeder.config.example.json ./seeder.config.json
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
```dotenv
|
|
154
|
+
SEEDER_CONFIG_PATH=./seeder.config.json
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
For example:
|
|
158
|
+
|
|
159
|
+
```json
|
|
160
|
+
{
|
|
161
|
+
"$schema": "./node_modules/@onderwijsin/directus-seeder-hook/seeder-config.schema.json",
|
|
162
|
+
"system": {
|
|
163
|
+
"collections": {
|
|
164
|
+
"directus_presets": { "management": { "type": "id-range", "max": 50000 } }
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
"core": {
|
|
168
|
+
"collections": {
|
|
169
|
+
"categories": { "operationMode": "insert-update" },
|
|
170
|
+
"articles": {
|
|
171
|
+
"operationMode": "full-idempotent",
|
|
172
|
+
"management": { "type": "manifest" },
|
|
173
|
+
"fields": ["id", "title", "category"]
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
"order": ["categories"]
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Mount the config separately in containers and use its container path. Copying it to the host alone
|
|
182
|
+
does not expose it to Directus. For editors without a local npm installation, copy the shipped
|
|
183
|
+
schema beside the config and use `"$schema": "./seeder-config.schema.json"`; keep it aligned with
|
|
184
|
+
the installed version. The schema is also exported as
|
|
185
|
+
`@onderwijsin/directus-seeder-hook/seeder-config.schema.json` for tooling. No TypeScript loader or
|
|
186
|
+
additional consumer dependency is required.
|
|
187
|
+
|
|
188
|
+
Top-level keys are optional string `$schema`/`$comment` metadata and optional `system`/`core`.
|
|
189
|
+
Metadata is ignored at runtime. `system` accepts optional `collections` and `order`; `{}` retains
|
|
190
|
+
all built-ins. `core` requires `collections` and accepts optional `order`. Unknown properties or
|
|
191
|
+
unsupported names fail validation, even for excluded collections.
|
|
192
|
+
|
|
193
|
+
| Collection property | Contract |
|
|
194
|
+
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
195
|
+
| `operationMode` | Exact `insert-missing`, `insert-update`, or `full-idempotent`. Optional system override; required for every core declaration, even with a CLI mode override. |
|
|
196
|
+
| `fields` | Array of field names, or `null` for all fields. Omitted: system projection below; core `['*']`. Explicit core arrays must include the actual primary key or `'*'`. |
|
|
197
|
+
| `filter` | Directus extraction filter, or `null` to clear it. Does not constrain import deletes. |
|
|
198
|
+
| `sort` | Array of sort strings, or `null` to clear it. |
|
|
199
|
+
| `deep` | Directus deep-query object, or `null` to clear it. |
|
|
200
|
+
| `management` | ID range, direct relation, or manifest object described below. `null` removes a boundary; omission preserves the system default. |
|
|
201
|
+
|
|
202
|
+
Overrides replace whole properties, without recursive merging. Include every desired field when
|
|
203
|
+
replacing `fields`; `["id", "name"]` drops other built-in fields. Replacing the presets filter also
|
|
204
|
+
removes its `user = null` rule unless you include it. Setting roles `management: null` keeps its
|
|
205
|
+
full-idempotent mode but makes synchronization whole-collection. Inspect defaults before overriding:
|
|
206
|
+
|
|
207
|
+
```sh
|
|
208
|
+
npx directus seed config --defaults --collection directus_roles
|
|
209
|
+
npx directus seed config --collection directus_roles
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Each scope's `order` is a unique-name priority prefix, followed by remaining built-ins (system) or
|
|
213
|
+
JSON declarations (core). Unknown or duplicate names fail. System overrides/order do not select
|
|
214
|
+
collections or add new system collections. Core declarations define the available application
|
|
215
|
+
collections; names start with a letter or underscore, followed by letters, digits, or underscores.
|
|
216
|
+
The `directus_` prefix and `__proto__` are rejected. Core inherits no system defaults or
|
|
217
|
+
transformations. Consumers own schema, dependency order, and existing related records; file foreign
|
|
218
|
+
keys remain scalar references, with binaries managed separately through system functionality.
|
|
219
|
+
|
|
220
|
+
See [query parameters](https://directus.com/docs/guides/connect/query-parameters) and
|
|
221
|
+
[filter rules](https://directus.com/docs/guides/connect/filter-rules). Query shapes are validated
|
|
222
|
+
before cleanup, but Directus validates actual fields/relations during reads. Combine comparisons on
|
|
223
|
+
one field as separate objects in `_and`; multiple operators in a single predicate are rejected.
|
|
224
|
+
|
|
225
|
+
Configured missing, unreadable, malformed, or invalid files abort before import mutations or
|
|
226
|
+
extraction cleanup, without fallback. Imports, manual exports, and normal inspection reread the file
|
|
227
|
+
on each invocation; auto-extract captures it at hook registration and needs a restart to reload.
|
|
228
|
+
|
|
229
|
+
## Seed files and supported collections
|
|
230
|
+
|
|
231
|
+
Store one JSON array per collection under `<SEEDER_SEEDS_DIR>/<scope>/<collection>.json`:
|
|
232
|
+
|
|
233
|
+
```text
|
|
234
|
+
/directus/seeds/
|
|
235
|
+
├── system/
|
|
236
|
+
│ ├── directus_roles.json
|
|
237
|
+
│ ├── directus_roles.managed-ids.json
|
|
238
|
+
│ └── assets/
|
|
239
|
+
│ └── <filename_disk>
|
|
240
|
+
└── core/
|
|
241
|
+
├── categories.json
|
|
242
|
+
├── articles.json
|
|
243
|
+
└── articles.managed-ids.json
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Root-level JSON/history is ignored; there is no flat-layout fallback or migration. Assets use the
|
|
247
|
+
independent `SEEDER_ASSETS_DIR`. System seeds use stable `id` values and scalar foreign-key IDs:
|
|
248
|
+
|
|
249
|
+
```json
|
|
250
|
+
[{ "id": "2a7d5e56-ba21-4fe5-b18e-f0d7147c7ae0", "name": "Editor", "icon": "edit" }]
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Built-in modes and management:
|
|
254
|
+
|
|
255
|
+
| Collections | `operationMode` | `management` |
|
|
256
|
+
| ---------------------------------------------------------------------------------------------------------------- | ----------------- | ------------------------------------------------------------------------------ |
|
|
257
|
+
| `directus_policies`, `directus_roles`, `directus_users`, `directus_access`, `directus_folders`, `directus_files` | `full-idempotent` | `{ "type": "manifest" }` |
|
|
258
|
+
| `directus_presets`, `directus_settings` | `insert-update` | None |
|
|
259
|
+
| `directus_permissions` | `full-idempotent` | `{ "type": "relation", "field": "policy", "collection": "directus_policies" }` |
|
|
260
|
+
| `directus_dashboards`, `directus_panels`, `directus_flows`, `directus_operations`, `directus_translations` | `full-idempotent` | None |
|
|
261
|
+
|
|
262
|
+
The following table also defines the built-in processing order and extraction defaults. Imported
|
|
263
|
+
JSON may contain additional Directus fields. Presets have no default ID cap; the configuration
|
|
264
|
+
example adds one for that consumer only.
|
|
265
|
+
|
|
266
|
+
| Collection, in processing order | Extracted fields and filter |
|
|
267
|
+
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
268
|
+
| `directus_policies` | `id`, `name`, `icon`, `description`, `ip_access`, `enforce_tfa`, `admin_access`, `app_access` |
|
|
269
|
+
| `directus_roles` | `id`, `name`, `icon`, `description`, `parent` |
|
|
270
|
+
| `directus_users` | `id`, `avatar`, `first_name`, `last_name`, `title`, `description`, `email`, `status`, `provider`, `role`, `email_notifications`, `tags`, `language` |
|
|
271
|
+
| `directus_access` | `id`, `policy`, `role`, `sort`, `user` |
|
|
272
|
+
| `directus_presets` | `id`, `bookmark`, `user`, `role`, `collection`, `search`, `layout`, `layout_query`, `layout_options`, `refresh_interval`, `filter`, `icon`, `color`; only `user = null`, without an ID cap, sorted by `-role`, then `id`. |
|
|
273
|
+
| `directus_permissions` | `id`, `collection`, `action`, `permissions`, `validation`, `presets`, `fields`, `policy` |
|
|
274
|
+
| `directus_folders` | `id`, `name`, `parent`, `type`; sorted by `-parent`. |
|
|
275
|
+
| `directus_files` | `id`, `filename_disk`, `filename_download`, `description`, `title`, `type`, `folder` |
|
|
276
|
+
| `directus_dashboards` | `id`, `name`, `note`, `icon`, `color` |
|
|
277
|
+
| `directus_panels` | `id`, `dashboard`, `name`, `icon`, `color`, `show_header`, `note`, `type`, `position_x`, `position_y`, `width`, `height`, `options` |
|
|
278
|
+
| `directus_flows` | `id`, `name`, `icon`, `color`, `description`, `status`, `trigger`, `accountability`, `options`, `operation`, `folder` |
|
|
279
|
+
| `directus_operations` | `id`, `name`, `key`, `type`, `position_x`, `position_y`, `options`, `resolve`, `reject`, `flow`; ordered by operation references where possible, with warnings for cycles. |
|
|
280
|
+
| `directus_settings` | All fields except `license_key` and `license_token`. |
|
|
281
|
+
| `directus_translations` | `id`, `language`, `key`, `value`; sorted by `key`, then `language`. |
|
|
282
|
+
|
|
283
|
+
Other system collections, including `directus_extensions`, and schema are outside system scope.
|
|
284
|
+
Declare application collections under `core.collections`.
|
|
285
|
+
|
|
286
|
+
Extraction always omits `directus_users.password`, including with explicit `fields` overrides,
|
|
287
|
+
wildcards, or `fields: null`. Directus conceals existing passwords, so they cannot be recovered by
|
|
288
|
+
extraction. Output can still contain secrets in settings, Flow options, or custom fields; these
|
|
289
|
+
omissions are not general secret redaction. Review output before sharing or committing it. Seeder
|
|
290
|
+
output is not a complete database/storage backup.
|
|
291
|
+
|
|
292
|
+
### Primary keys and input preflight
|
|
293
|
+
|
|
294
|
+
Import requires the selected scope directory to exist and be a directory; flat root files do not
|
|
295
|
+
satisfy this requirement. Extraction creates selected scope directories. An existing scope directory
|
|
296
|
+
with no selected seed files is a successful no-op with a warning and no database work or cache
|
|
297
|
+
clearing. Only supported direct child seed files count; nested/unsupported files are ignored.
|
|
298
|
+
|
|
299
|
+
Selection happens before preflight. Before any selected collection is mutated, required input and
|
|
300
|
+
transformations are validated, including Flow filter metadata, relation sources, and manifests where
|
|
301
|
+
applicable. Invalid required input aborts the entire import even with continuation enabled.
|
|
302
|
+
Unselected files are ignored unless needed as Flow metadata or a relation source.
|
|
303
|
+
|
|
304
|
+
- A missing target file (ENOENT only) skips its collection in every mode, including deletes.
|
|
305
|
+
- Valid `[]` is intentional empty data: insert modes do nothing; full-idempotent deletes within
|
|
306
|
+
management, or the whole selected collection without a boundary.
|
|
307
|
+
- Invalid JSON, a non-array root, empty/whitespace-only files, and other read errors exit 1 with
|
|
308
|
+
file context. Missing data is never silently converted to `[]`.
|
|
309
|
+
|
|
310
|
+
Core resolves the actual live schema primary key, including names other than `id`. Every imported
|
|
311
|
+
row requires a unique schema-compatible key: canonical lowercase UUID, nonempty string, safe
|
|
312
|
+
`integer` number, or canonical decimal `bigInteger` string, without coercion. Big-integer keys
|
|
313
|
+
retain their string representation, including small IDs such as `"2"` and values beyond JavaScript's
|
|
314
|
+
safe integer range such as `"9007199254740993"`. Decimal strings allow `0` or an optional minus sign
|
|
315
|
+
followed by digits without leading zeroes; numbers, `+2`, `02`, `-0`, whitespace, fractions, and
|
|
316
|
+
exponents are rejected for big-integer keys. PostgreSQL roundtrips are verified; other databases
|
|
317
|
+
require Directus and its driver to return bigint strings as well. Missing/duplicate/invalid keys,
|
|
318
|
+
missing collections, alias or missing keys, and unsupported key types fail before mutations in every
|
|
319
|
+
mode, including full reset. Explicit extraction `fields` must contain that key or `'*'`; `[]` fails.
|
|
320
|
+
Omitted/null fields use `['*']`. The Seeder never inserts a key into an explicit projection.
|
|
321
|
+
|
|
322
|
+
**Integer primary key `0`**
|
|
323
|
+
|
|
324
|
+
The Seeder currently does not support records with an integer primary key of `0` due to limitations
|
|
325
|
+
in Directus' `ItemsService`. This is intentionally not worked around by the Seeder.
|
|
326
|
+
|
|
327
|
+
For further context and Directus' rationale for not addressing this edge case, see
|
|
328
|
+
[issue #28318](https://github.com/directus/directus/issues/28318) and
|
|
329
|
+
[PR #28319](https://github.com/directus/directus/pull/28319).
|
|
330
|
+
|
|
331
|
+
### System transformations and compatibility
|
|
332
|
+
|
|
333
|
+
For ordinary users, explicit seed `password` values are passed to Directus when creating or updating
|
|
334
|
+
records according to the selected mode. Use an explicit password for local development users that
|
|
335
|
+
need to log in immediately. Omitting `password` leaves an existing user's password unchanged;
|
|
336
|
+
`insert-missing` never updates existing users. Any supplied `password` consisting solely of one or
|
|
337
|
+
more asterisks (`*`, `**`, etc.) is rejected during input preflight, before any selected collection
|
|
338
|
+
mutates, even with `SEEDER_CONTINUE_ON_ERROR=true`. This validation also applies to root-user seed
|
|
339
|
+
input before the environment overrides below.
|
|
340
|
+
|
|
341
|
+
Matching root-user seeds always receive `DEFAULT_EMAIL` and `DEFAULT_PASSWORD`, including when the
|
|
342
|
+
JSON omits `password`: this existing transformation supplies an effective seed password. Their
|
|
343
|
+
status is `active` only in exact `development`, otherwise `suspended`. Matching is case-insensitive:
|
|
344
|
+
title exactly `super user`, or first name `admin` and last name `developer` or `user`. This is not a
|
|
345
|
+
permission check and does not create a missing seed user. Update modes overwrite the matching target
|
|
346
|
+
values.
|
|
347
|
+
|
|
348
|
+
Explicit policy `enforce_tfa: true` remains true. Exact `production` additionally enforces TFA for
|
|
349
|
+
policies with `admin_access: true` or `app_access: true`; otherwise enforcement is false.
|
|
350
|
+
|
|
351
|
+
Outside exact `development`, flows with `[dev]` in their name (case-insensitive) and their seeded
|
|
352
|
+
operations are filtered out. Operations read an existing `directus_flows.json` as filter metadata
|
|
353
|
+
even when Flows are unselected; invalid metadata aborts preflight, a missing file supplies no IDs,
|
|
354
|
+
and reading it does not import it. In development an unselected Flow file is ignored.
|
|
355
|
+
|
|
356
|
+
Operations are supplied as reference-free rows followed by reference updates in the same collection
|
|
357
|
+
input. Reference restoration can be skipped in insert-missing or fail during import: this is not a
|
|
358
|
+
guaranteed transactional two-pass import. Verify Flow links afterward. Extraction orders operations
|
|
359
|
+
by references where possible and warns about cycles.
|
|
360
|
+
|
|
361
|
+
When the target lacks `directus_folders.type` or `directus_flows.folder`, extraction omits only
|
|
362
|
+
those absent fields from inherited default projections. Explicit `fields` arrays pass unchanged;
|
|
363
|
+
selecting missing fields still fails. Other overrides retain this adaptation. Import preflight
|
|
364
|
+
removes only `type: "files"` and `folder: null` for older schemas; other supplied values fail with
|
|
365
|
+
file/row/field context before any mutation. With those fields present, values are retained; omitted
|
|
366
|
+
fields follow normal Directus create/update semantics.
|
|
367
|
+
|
|
368
|
+
## Seeding safety and management
|
|
369
|
+
|
|
370
|
+
| Mode | Effect |
|
|
371
|
+
| ----------------- | ----------------------------------------------------------------------------------------------------- |
|
|
372
|
+
| `insert-missing` | Create records whose primary keys do not exist. |
|
|
373
|
+
| `insert-update` | Create missing records and update existing records. |
|
|
374
|
+
| `full-idempotent` | Also delete target records absent from seeds, within management or the whole collection if unbounded. |
|
|
375
|
+
|
|
376
|
+
Effective mode precedence is explicit CLI `--mode`, then each collection's configured/built-in
|
|
377
|
+
`operationMode`. Only selected collections with present seed files participate in safety prompts and
|
|
378
|
+
the destructive gate. Full-idempotent requires `SEEDER_ENABLE_FULL_IDEMPOTENT=true`; interactive
|
|
379
|
+
runs require exact `DELETE`. Otherwise insert-update prompts yes/no, default no. Prompt bypasses are
|
|
380
|
+
listed above; cancellation exits 0. Back up and review the target before destructive import.
|
|
381
|
+
|
|
382
|
+
```sh
|
|
383
|
+
SEEDER_ENABLE_FULL_IDEMPOTENT=true npx directus seed system --include directus_roles --yes
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
Stable keys are necessary for repeatability. Core always requires them; unbounded system import
|
|
387
|
+
retains batch-dependent handling of ID-less rows, unsuitable for synchronization.
|
|
388
|
+
|
|
389
|
+
Management applies only to full-idempotent import; insert modes do not read sources/manifests, and
|
|
390
|
+
CLI mode overrides preserve configured boundaries. Preflight validates all required boundaries
|
|
391
|
+
before any selected collection mutates. **Extraction filters and omitted fields do not protect
|
|
392
|
+
managed records from deletion.** A filtered export or environment transformation can omit records
|
|
393
|
+
that full-idempotent later deletes.
|
|
394
|
+
|
|
395
|
+
### System role deletion
|
|
396
|
+
|
|
397
|
+
Full-idempotent system imports delete selected roles through Directus's `RolesService`. The Seeder
|
|
398
|
+
keeps the configured order for reads and upserts and waits to delete roles until selected
|
|
399
|
+
`directus_users` and `directus_access` with seed files have completed successfully. If either
|
|
400
|
+
collection fails, the Seeder skips the pending role deletions even with
|
|
401
|
+
`SEEDER_CONTINUE_ON_ERROR=true`. A skipped pending deletion or an error from Directus makes the
|
|
402
|
+
import exit 1. Earlier successful writes can remain.
|
|
403
|
+
|
|
404
|
+
Management limits the roles selected for deletion. Directus detaches child roles, suspends users
|
|
405
|
+
assigned to the deleted roles and clears their role, and handles related records such as role-linked
|
|
406
|
+
presets and policy assignments. These effects can reach records outside the Seeder's management and
|
|
407
|
+
collection selection. Directus still refuses to remove the last active administrator, including
|
|
408
|
+
during `--full-reset`. Seed the replacement admin's user and access changes in the same import when
|
|
409
|
+
retiring a role used by the last active administrator.
|
|
410
|
+
|
|
411
|
+
### ID-range management
|
|
412
|
+
|
|
413
|
+
```json
|
|
414
|
+
{ "management": { "type": "id-range", "min": 1, "max": 50000 } }
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
`min` is inclusive, `max` exclusive; at least one is required and `min < max` when both are present.
|
|
418
|
+
Bounds must be safe-integer numbers; unknown properties/types, null, fractional, unsafe, or empty
|
|
419
|
+
bounds fail configuration validation regardless of mode. Bounded full-idempotent seed IDs must be
|
|
420
|
+
explicit safe integer numbers or canonical decimal bigint strings within the range. Comparisons are
|
|
421
|
+
exact even for bigint IDs outside JavaScript's safe integer range; bounds remain safe-integer
|
|
422
|
+
numbers. Core range extraction/import also requires an integer or big-integer schema primary key.
|
|
423
|
+
|
|
424
|
+
Full-idempotent preserves out-of-range rows; `[]` deletes only in-range rows. Extraction ANDs the
|
|
425
|
+
range with its query filter, but deletion uses only the range. For example, the presets
|
|
426
|
+
`user = null` filter can omit personal presets inside the range without protecting them from later
|
|
427
|
+
deletion.
|
|
428
|
+
|
|
429
|
+
### Manifest management
|
|
430
|
+
|
|
431
|
+
```json
|
|
432
|
+
{ "management": { "type": "manifest" } }
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
History lives beside seeds at `<seeds-root>/<scope>/<collection>.managed-ids.json`, as a plain ID
|
|
436
|
+
array. Extraction queries current data independently of existing seeds/history and unions exported
|
|
437
|
+
IDs into that manifest, deduplicated and sorted lexically for strings or numerically for numbers.
|
|
438
|
+
IDs must match the live primary-key type: lowercase UUID, nonempty string, safe integer number, or
|
|
439
|
+
canonical decimal bigint string. Bigint IDs remain strings in history; other string keys retain
|
|
440
|
+
case. Include the primary key in extracted fields.
|
|
441
|
+
|
|
442
|
+
A missing manifest is created on extraction. Empty exports write ordinary seed `[]` while keeping
|
|
443
|
+
history. Only extracted collections update history. Invalid/unreadable existing manifests fail and
|
|
444
|
+
are never overwritten; replacement is atomic, but the whole export has no rollback. Cleanup
|
|
445
|
+
preserves all `*.managed-ids.json` files.
|
|
446
|
+
|
|
447
|
+
Full-idempotent import requires every seed ID to belong to a valid manifest and leaves it unchanged.
|
|
448
|
+
Missing, unreadable, invalid history or out-of-set/missing seed IDs abort preflight. A missing
|
|
449
|
+
target seed file skips its manifest. Empty history plus empty seeds does no collection
|
|
450
|
+
reads/mutations; nonempty seeds against empty history fail. Empty seeds with history delete only
|
|
451
|
+
historical IDs.
|
|
452
|
+
|
|
453
|
+
For history A/B, seeds A, and target A/B/C, import synchronizes A, deletes B, and preserves C.
|
|
454
|
+
Narrowing an export can leave historical IDs absent from seeds but still eligible for deletion. To
|
|
455
|
+
relinquish management, review remaining target rows and remove those IDs from history and seeds; a
|
|
456
|
+
later export of them adds them again. Manifests contain IDs only, without timestamps or statuses.
|
|
457
|
+
|
|
458
|
+
### Relation management
|
|
459
|
+
|
|
460
|
+
```json
|
|
461
|
+
{
|
|
462
|
+
"management": { "type": "relation", "field": "policy", "collection": "directus_policies" }
|
|
463
|
+
}
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
One direct scalar many-to-one foreign key defines membership through the raw source file
|
|
467
|
+
`<seeds-root>/<scope>/<source-collection>.json`. The example manages permissions linked to policy
|
|
468
|
+
IDs in `system/directus_policies.json`, even when Policies are not selected for import. System
|
|
469
|
+
sources must be supported system collections; core sources need not be separately declared or
|
|
470
|
+
selected. The relation must target the source's actual schema primary key with compatible scalar
|
|
471
|
+
types. Paths, aliases, compound relationships, and nested relation objects are unsupported.
|
|
472
|
+
|
|
473
|
+
Required sources must be readable valid arrays with explicit unique schema-compatible keys. Source
|
|
474
|
+
filters, management, and transformations do not narrow raw membership; management is not recursive.
|
|
475
|
+
Target rows need explicit primary keys and a non-null scalar foreign key belonging to that set.
|
|
476
|
+
Lowercase UUIDs, exact nonempty string keys, safe integer numbers, and canonical decimal bigint
|
|
477
|
+
strings are validated. For mixed integer/bigInteger relations, source membership is represented in
|
|
478
|
+
the foreign key's type: a bigint FK uses strings, an integer FK uses safe numbers. Seed payloads
|
|
479
|
+
retain their values; unrepresentable source IDs fail preflight. An existing target seed-ID collision
|
|
480
|
+
outside membership aborts instead of moving that row into it.
|
|
481
|
+
|
|
482
|
+
A missing/invalid source fails preflight rather than implying an empty/unbounded set. Source `[]`
|
|
483
|
+
with target `[]` does no target reads/mutations; nonempty target seeds fail. Target `[]` with a
|
|
484
|
+
nonempty source deletes only rows currently linked to its IDs. Missing target files skip work.
|
|
485
|
+
|
|
486
|
+
With the policy already present in Directus and its ID in `system/directus_policies.json`, clear its
|
|
487
|
+
permissions by writing `[]` to `system/directus_permissions.json` and running:
|
|
488
|
+
|
|
489
|
+
```sh
|
|
490
|
+
SEEDER_ENABLE_FULL_IDEMPOTENT=true npx directus seed system --include directus_permissions --yes
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
Relation management keeps no ownership history. To relinquish a source ID, retain it while importing
|
|
494
|
+
target `[]`, verify the clear, then remove it. Review parent deletion/database cascades separately.
|
|
495
|
+
Extraction does not read relation-source seeds or inherit their queries; configure each collection's
|
|
496
|
+
query explicitly and review exported target membership before importing.
|
|
497
|
+
|
|
498
|
+
### Full reset
|
|
499
|
+
|
|
500
|
+
```sh
|
|
501
|
+
SEEDER_ENABLE_FULL_IDEMPOTENT=true npx directus seed system --mode full-idempotent --full-reset --include directus_roles --yes
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
`--full-reset` bypasses all management boundaries for this import and reads no management sources or
|
|
505
|
+
manifests. Every selected collection with a seed file must resolve to full-idempotent. Selection,
|
|
506
|
+
other input preflight, environment opt-in, and prompts still apply. Empty seeds clear the entire
|
|
507
|
+
selected collection, including unmanaged records; missing files still skip it. Configuration/history
|
|
508
|
+
remain unchanged. This synchronizes records; it does not reset schema or reinsert every record.
|
|
509
|
+
|
|
510
|
+
### Failure handling
|
|
511
|
+
|
|
512
|
+
There is no extension-wide transaction or rollback. Preflight checks required inputs,
|
|
513
|
+
transformations, and managed IDs, not complete record schemas or binary availability. Database/asset
|
|
514
|
+
failures can leave earlier mutations or uploads intact. Every mutation failure exits 1. By default
|
|
515
|
+
it stops at the failed collection; continuation skips the rest of that collection and attempts later
|
|
516
|
+
ones, still exiting 1. Counts can omit partial progress in a failed batch.
|
|
517
|
+
|
|
518
|
+
After collection processing, imports attempt to clear the Directus system cache even after partial
|
|
519
|
+
failure. Cache failure also exits 1 and may leave stale state. Fix the cause, inspect target data,
|
|
520
|
+
and rerun deliberately. Fully successful runs and valid no-ops exit 0.
|
|
521
|
+
|
|
522
|
+
## Extraction, assets, and automatic behavior
|
|
523
|
+
|
|
524
|
+
Extraction reads current Directus data using each collection's query, without existing seed files.
|
|
525
|
+
ID ranges additionally filter exports; relation management is import-only, and manifests retain
|
|
526
|
+
exported-ID history without filtering the query. Selected files are overwritten even for empty
|
|
527
|
+
results (`[]` plus one newline), including with `--skip-clean` or selective auto-extract.
|
|
528
|
+
|
|
529
|
+
JSON uses tabs by default, or `SEEDER_JSON_INDENT=space` with width `1`–`10`, and exactly one final
|
|
530
|
+
newline. The same input produces the same serialization. No project formatter is invoked.
|
|
531
|
+
|
|
532
|
+
### Cleanup and output paths
|
|
533
|
+
|
|
534
|
+
Manual extraction cleans first unless `--skip-clean`. Automatic extraction cleans only
|
|
535
|
+
event-triggered scopes when its allowlist is unset; an explicit allowlist skips cleanup.
|
|
536
|
+
|
|
537
|
+
- Each participating scope loses direct regular `.json` files except `*.managed-ids.json`, including
|
|
538
|
+
unselected seed JSON. Non-JSON files, nested directories, and symlinks remain.
|
|
539
|
+
- With system binaries enabled, the assets directory loses **all direct regular files**, even for an
|
|
540
|
+
empty `directus_files` collection.
|
|
541
|
+
- Cleanup never recurses, follows symlinks, clears the seeds root as a whole, or touches an
|
|
542
|
+
unselected scope. Include/exclude does not narrow cleanup.
|
|
543
|
+
|
|
544
|
+
Use dedicated output directories: hand-created and uncommitted matching files are deleted too. Keep
|
|
545
|
+
configuration/schema files outside them. Before deletion, extraction rejects filesystem roots,
|
|
546
|
+
symlinked directories/ancestors, and assets equal to or containing the effective JSON directory,
|
|
547
|
+
even in JSON-only mode. System binary extraction also rejects assets equal to or containing the core
|
|
548
|
+
directory. Assets may be nested within system output or live separately.
|
|
549
|
+
|
|
550
|
+
Read errors fail instead of writing empty results. Cleanup or previous writes may already have
|
|
551
|
+
happened; extraction has no whole-run rollback. Inspect partial JSON/manifests/assets, fix the
|
|
552
|
+
cause, and rerun with the intended cleanup policy before using the export.
|
|
553
|
+
|
|
554
|
+
### Assets
|
|
555
|
+
|
|
556
|
+
Core never reads, downloads, or cleans binaries. System JSON-only mode also preserves every binary
|
|
557
|
+
while still exporting `directus_files.json` when selected. Manual `--assets` overrides environment
|
|
558
|
+
JSON-only; it cannot be combined with `--json-only`.
|
|
559
|
+
|
|
560
|
+
Binary export queries **all** `directus_files`, regardless of JSON selection, fields, filters, or
|
|
561
|
+
management. It buffers each asset in memory and writes it under `filename_disk`. Download failures
|
|
562
|
+
fail the run. File import reads those local binaries and uploads through Directus `FilesService`,
|
|
563
|
+
preserving supplied IDs; updates re-upload too. Missing binaries/`filename_disk` cause errors.
|
|
564
|
+
JSON-only controls extraction only; the hook does not provision storage.
|
|
565
|
+
|
|
566
|
+
```sh
|
|
567
|
+
# Clean system JSON and export all binaries (default)
|
|
568
|
+
DEPLOYMENT_ENV=development npx directus seed extract
|
|
569
|
+
# Refresh selected JSON while preserving other output and every binary
|
|
570
|
+
DEPLOYMENT_ENV=development npx directus seed extract --json-only --skip-clean --include directus_roles
|
|
571
|
+
# Clean/export core only; leave system JSON and assets untouched
|
|
572
|
+
DEPLOYMENT_ENV=development npx directus seed extract --scope core
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
### Automatic extraction
|
|
576
|
+
|
|
577
|
+
Require exact `DEPLOYMENT_ENV=development` and enable `SEEDER_AUTO_EXTRACT_SYSTEM`,
|
|
578
|
+
`SEEDER_AUTO_EXTRACT_CORE`, or both. Core needs configured collections. Selected CRUD actions share
|
|
579
|
+
a 15-second debounce; further events extend it. Changed scopes run sequentially under the shared
|
|
580
|
+
bulk lock, each refreshing all its selected collections in configured order. Core-only events leave
|
|
581
|
+
system JSON/assets untouched. Enabling auto-extract does not extract or import at startup.
|
|
582
|
+
|
|
583
|
+
Automatic extraction hooks are not registered in Seeder CLI processes (`seed system`, `seed core`,
|
|
584
|
+
`seed extract`, or `seed config`).
|
|
585
|
+
|
|
586
|
+
On `server.stop` or a received `extensions.unload` event, pending automatic extraction is canceled
|
|
587
|
+
and new events no longer schedule work; an extraction already running may finish. Unload cleanup
|
|
588
|
+
requires a Directus version containing
|
|
589
|
+
[the upstream fix](https://github.com/directus/directus/pull/28421). Older versions unregister hook
|
|
590
|
+
listeners before emitting that event, so reload/disable cleanup is not guaranteed there.
|
|
591
|
+
|
|
592
|
+
Automatic failures are logged per scope; other changed scopes are still attempted. There is no
|
|
593
|
+
automatic retry. Inspect partial output, fix the cause, and trigger a new event or extract manually.
|
|
594
|
+
|
|
595
|
+
System events use names such as `roles.create/update/delete`; core uses
|
|
596
|
+
`<collection>.items.create/update/delete`. See
|
|
597
|
+
[Directus event hooks](https://directus.com/docs/guides/extensions/api-extensions/hooks).
|
|
598
|
+
`users.update` with only `last_page` or an empty payload is ignored. File uploads may not emit
|
|
599
|
+
monitored events; use manual extraction when needed.
|
|
600
|
+
|
|
601
|
+
| Selection | Triggers and output | Cleanup and binaries |
|
|
602
|
+
| --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
603
|
+
| Allowlist unset | General include/exclude in enabled scopes; only changed scopes run. | Clean changed scope JSON; system honors `SEEDER_JSON_ONLY` and can export/clean all assets. |
|
|
604
|
+
| `SEEDER_AUTO_EXTRACT_INCLUDE` set | Only listed supported system/configured core names in enabled scopes; overrides both general filters. Each changed scope refreshes its listed collections. | No cleanup. System is forced JSON-only unless `directus_files` is listed; even then binaries require `SEEDER_JSON_ONLY=false` and still export all files. |
|
|
605
|
+
|
|
606
|
+
For example, with `articles` declared:
|
|
607
|
+
|
|
608
|
+
```dotenv
|
|
609
|
+
DEPLOYMENT_ENV=development
|
|
610
|
+
SEEDER_AUTO_EXTRACT_SYSTEM=true
|
|
611
|
+
SEEDER_AUTO_EXTRACT_CORE=true
|
|
612
|
+
SEEDER_AUTO_EXTRACT_INCLUDE=directus_roles,articles
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
Both switches default to false. Omit the allowlist for general filters; blank/empty/unknown names
|
|
616
|
+
fail, including for disabled scopes. Manual commands ignore the automatic allowlist. Selective runs
|
|
617
|
+
retain stale JSON/binaries from previous selections, removed records, or renamed files. Review them
|
|
618
|
+
before import; use a deliberate clean manual export for a fresh snapshot. Debouncing is not
|
|
619
|
+
incremental extraction: repeated system changes can re-export large binaries with substantial I/O.
|
|
620
|
+
|
|
621
|
+
### Coordination and troubleshooting
|
|
622
|
+
|
|
623
|
+
Commands and auto-extract share `directus-lock-bulk-operation.flag` in the process temporary
|
|
624
|
+
directory. Active contention fails manual commands before work; automatic work skips without retry.
|
|
625
|
+
Flags expire after five minutes without renewal. Cleanup releases only the acquired owner's flag,
|
|
626
|
+
including process-exit cleanup on prompt cancellation.
|
|
627
|
+
|
|
628
|
+
This is local filesystem coordination, not a distributed lock or overlap guarantee: expiration and
|
|
629
|
+
non-atomic checks/removal can allow overlap, and separate temporary filesystems do not coordinate.
|
|
630
|
+
Run commands sequentially and stop extraction writers during deployment seeding. After interruption,
|
|
631
|
+
inspect active operations before removing stale flags or retrying; partial data/output may remain.
|
|
632
|
+
|
|
633
|
+
For missing commands, check installation, loading, and `SEEDER_ENABLED`; missing extraction also
|
|
634
|
+
requires exact development. For auto-extract, check scope switches, selection, debounce, and bulk
|
|
635
|
+
flags. For failed runs, inspect exit status, Directus logs (`debug`/`trace`), directory permissions,
|
|
636
|
+
required inputs/assets, and storage configuration before accepting or retrying results.
|
|
637
|
+
|
|
638
|
+
### Consumer formatting
|
|
639
|
+
|
|
640
|
+
If project formatting is needed, wrap manual extraction and your installed formatter in a project
|
|
641
|
+
script, for example with Oxfmt:
|
|
642
|
+
|
|
643
|
+
```json
|
|
644
|
+
{
|
|
645
|
+
"scripts": {
|
|
646
|
+
"seed:extract": "DEPLOYMENT_ENV=development SEEDER_SEEDS_DIR=./seeds SEEDER_ASSETS_DIR=./seeds/system/assets directus seed extract && oxfmt 'seeds/system/*.json'"
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
The consumer owns formatter dependencies/configuration and environment syntax. `&&` runs formatting
|
|
652
|
+
only after extraction succeeds and propagates formatter errors. For containers, bind-mount output
|
|
653
|
+
and run formatting where its tooling is installed. Auto-extract does not invoke this script.
|
|
654
|
+
|
|
655
|
+
## License
|
|
656
|
+
|
|
657
|
+
MIT. See `LICENSE` in the installed package.
|