@usegraft/content-migrations 0.1.1 → 0.2.0
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 +45 -0
- package/package.json +18 -5
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# @usegraft/content-migrations
|
|
2
|
+
|
|
3
|
+
> Codemod-style transforms for authored content when the schema changes.
|
|
4
|
+
|
|
5
|
+
Part of [Graft](https://github.com/AndersonDesign1/graft), a CMS built so an AI agent is the primary operator.
|
|
6
|
+
|
|
7
|
+
## Why
|
|
8
|
+
|
|
9
|
+
Content lives in files that git owns. When you add a required field or rename one, a hosted CMS would migrate rows behind your back. Here the files are the truth, so the migration rewrites the files and you review the diff.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm i @usegraft/content-migrations
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Write one
|
|
18
|
+
|
|
19
|
+
Migrations live in `migrations/<seq>-<name>.ts`.
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
// migrations/0001-pages-description.ts
|
|
23
|
+
import { defineContentMigration } from "@usegraft/content-migrations";
|
|
24
|
+
|
|
25
|
+
export default defineContentMigration({
|
|
26
|
+
collection: "pages",
|
|
27
|
+
migrate: (doc) => ({
|
|
28
|
+
...doc,
|
|
29
|
+
data: { ...doc.data, description: doc.data.description ?? doc.data.title },
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Run it
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
graft migrate # preview the diff
|
|
38
|
+
graft migrate --apply # write the files
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Applied migrations are recorded in `migrations_applied`, with the git SHA of the checkout at apply time.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
MIT. [Repository](https://github.com/AndersonDesign1/graft) · [Changelog](https://github.com/AndersonDesign1/graft/blob/feat/core/packages/content-migrations/CHANGELOG.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usegraft/content-migrations",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Codemod-style transforms for authored content when the schema changes.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"agent",
|
|
7
|
+
"ai",
|
|
8
|
+
"cms",
|
|
9
|
+
"codemod",
|
|
10
|
+
"content",
|
|
11
|
+
"graft",
|
|
12
|
+
"headless-cms",
|
|
13
|
+
"mcp",
|
|
14
|
+
"migrations",
|
|
15
|
+
"typescript"
|
|
16
|
+
],
|
|
17
|
+
"homepage": "https://github.com/AndersonDesign1/graft#readme",
|
|
4
18
|
"license": "MIT",
|
|
5
19
|
"repository": {
|
|
6
20
|
"type": "git",
|
|
@@ -24,8 +38,8 @@
|
|
|
24
38
|
"access": "public"
|
|
25
39
|
},
|
|
26
40
|
"dependencies": {
|
|
27
|
-
"@usegraft/contracts": "0.
|
|
28
|
-
"@usegraft/core": "0.
|
|
41
|
+
"@usegraft/contracts": "0.2.0",
|
|
42
|
+
"@usegraft/core": "0.2.0",
|
|
29
43
|
"gray-matter": "^4.0.3"
|
|
30
44
|
},
|
|
31
45
|
"engines": {
|
|
@@ -35,7 +49,6 @@
|
|
|
35
49
|
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
36
50
|
"dev": "tsup src/index.ts --format esm --watch",
|
|
37
51
|
"typecheck": "tsc --noEmit",
|
|
38
|
-
"test": "vitest run --passWithNoTests"
|
|
39
|
-
"lint": "oxlint ."
|
|
52
|
+
"test": "vitest run --passWithNoTests"
|
|
40
53
|
}
|
|
41
54
|
}
|