forked from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: simplify and split models/definition/filters files (#30)
* feat: split universal editor files * feat: reorganise to reduce the number of files again * feat: rename files to partials * feat: add husky pre-commit hook * feat: run build:json when any model changes * fix: glob pattern to blocks * fix: rename file to follow partials pattern * fix: def include, add columns filter * fix: explicitly set the model id for default content * fix: rename _component.json to _name.json * fix: use name instead of label * docs: update documentation
- Loading branch information
Showing
21 changed files
with
975 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ LICENSE | |
package.json | ||
package-lock.json | ||
test/* | ||
_* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node .husky/pre-commit.mjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { exec } from "node:child_process"; | ||
|
||
const run = (cmd) => new Promise((resolve, reject) => exec( | ||
cmd, | ||
(error, stdout, stderr) => { | ||
if (error) reject(); | ||
if (stderr) reject(stderr); | ||
resolve(stdout); | ||
} | ||
)); | ||
|
||
const changeset = await run('git diff --cached --name-only --diff-filter=ACMR'); | ||
const modifiedFiles = changeset.split('\n').filter(Boolean); | ||
|
||
// check if there are any model files staged | ||
const modifledPartials = modifiedFiles.filter((file) => file.match(/(^|\/)_.*.json/)); | ||
if (modifledPartials.length > 0) { | ||
const output = await run('npm run build:json --silent'); | ||
console.log(output); | ||
await run('git add .'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{ | ||
"definitions": [ | ||
{ | ||
"title": "Cards", | ||
"id": "cards", | ||
"plugins": { | ||
"xwalk": { | ||
"page": { | ||
"resourceType": "core/franklin/components/block/v1/block", | ||
"template": { | ||
"name": "Cards", | ||
"filter": "cards" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"title": "Card", | ||
"id": "card", | ||
"plugins": { | ||
"xwalk": { | ||
"page": { | ||
"resourceType": "core/franklin/components/block/v1/block/item", | ||
"template": { | ||
"name": "Card", | ||
"model": "card" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"models": [ | ||
{ | ||
"id": "card", | ||
"fields": [ | ||
{ | ||
"component": "reference", | ||
"valueType": "string", | ||
"name": "image", | ||
"label": "Image", | ||
"multi": false | ||
}, | ||
{ | ||
"component": "richtext", | ||
"name": "text", | ||
"value": "", | ||
"label": "Text", | ||
"valueType": "string" | ||
} | ||
] | ||
} | ||
], | ||
"filters": [ | ||
{ | ||
"id": "cards", | ||
"components": [ | ||
"card" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"definitions": [ | ||
{ | ||
"title": "Columns", | ||
"id": "columns", | ||
"plugins": { | ||
"xwalk": { | ||
"page": { | ||
"resourceType": "core/franklin/components/columns/v1/columns", | ||
"template": { | ||
"columns": "2", | ||
"rows": "1" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"models": [ | ||
{ | ||
"id": "columns", | ||
"fields": [ | ||
{ | ||
"component": "text", | ||
"valueType": "number", | ||
"name": "columns", | ||
"value": "", | ||
"label": "Columns" | ||
}, | ||
{ | ||
"component": "text", | ||
"valueType": "number", | ||
"name": "rows", | ||
"value": "", | ||
"label": "Rows" | ||
} | ||
] | ||
} | ||
], | ||
"filters": [ | ||
{ | ||
"id": "columns", | ||
"components": [ | ||
"column" | ||
] | ||
}, | ||
{ | ||
"id": "column", | ||
"components": [ | ||
"text", | ||
"image", | ||
"button", | ||
"title" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"definitions": [ | ||
{ | ||
"title": "Fragment", | ||
"id": "fragment", | ||
"plugins": { | ||
"xwalk": { | ||
"page": { | ||
"resourceType": "core/franklin/components/block/v1/block", | ||
"template": { | ||
"name": "Fragment", | ||
"model": "fragment" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"models": [ | ||
{ | ||
"id": "fragment", | ||
"fields": [ | ||
{ | ||
"component": "aem-content", | ||
"name": "reference", | ||
"label": "Reference" | ||
} | ||
] | ||
} | ||
], | ||
"filters": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"definitions": [ | ||
{ | ||
"title": "Hero", | ||
"id": "hero", | ||
"plugins": { | ||
"xwalk": { | ||
"page": { | ||
"resourceType": "core/franklin/components/block/v1/block", | ||
"template": { | ||
"name": "Hero", | ||
"model": "hero" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"models": [ | ||
{ | ||
"id": "hero", | ||
"fields": [ | ||
{ | ||
"component": "reference", | ||
"valueType": "string", | ||
"name": "image", | ||
"label": "Image", | ||
"multi": false | ||
}, | ||
{ | ||
"component": "text", | ||
"valueType": "string", | ||
"name": "imageAlt", | ||
"label": "Alt", | ||
"value": "" | ||
}, | ||
{ | ||
"component": "richtext", | ||
"name": "text", | ||
"value": "", | ||
"label": "Text", | ||
"valueType": "string" | ||
} | ||
] | ||
} | ||
], | ||
"filters": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.