blocks-dusted 0.1.0 → 0.1.2
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 +967 -3
- package/package.json +40 -40
- package/src/commands/add.js +143 -45
- package/src/commands/list.js +2 -2
- package/src/installers/checkRequirements.js +1 -0
- package/src/installers/copyTemplateFiles.js +23 -2
- package/src/installers/patchPayloadConfigCollections.js +92 -0
- package/src/installers/writeInstalledBlockReadme.js +17 -4
- package/src/registry/listTemplates.js +16 -7
- package/src/registry/loadTemplateManifest.js +20 -11
- package/src/registry/validateTemplateManifest.js +6 -5
- package/src/utils/paths.js +7 -0
- package/templates/blocks/DD-BookCall/Component.tsx +535 -573
- package/templates/blocks/DD-CardTemplate01/Component.tsx +45 -49
- package/templates/blocks/DD-Carousel-A/Component.tsx +249 -266
- package/templates/blocks/DD-Carousel-B/Component.tsx +403 -432
- package/templates/blocks/DD-ComparisonTable/Component.tsx +256 -272
- package/templates/blocks/DD-Contact/Component.tsx +434 -439
- package/templates/blocks/DD-Contact/config.ts +8 -3
- package/templates/blocks/DD-FeatCat/Component.tsx +302 -361
- package/templates/blocks/DD-FeatCat/config.ts +201 -204
- package/templates/blocks/DD-FeatStrip/Component.tsx +171 -201
- package/templates/blocks/DD-Hero/Component.tsx +297 -317
- package/templates/blocks/DD-HorizontalScroll/Component.tsx +244 -303
- package/templates/blocks/DD-MasonaryMedia/Component.tsx +202 -228
- package/templates/blocks/DD-MasonaryMedia/config.ts +13 -14
- package/templates/blocks/DD-Pricing/Component.tsx +372 -380
- package/templates/blocks/DD-Process/Component.tsx +149 -155
- package/templates/blocks/DD-Section/Component.tsx +266 -327
- package/templates/blocks/DD-Services/Component.tsx +176 -188
- package/templates/blocks/DD-ShowcaseGrid/Component.tsx +307 -317
- package/templates/blocks/DD-Slider-A/Component.tsx +237 -252
- package/templates/blocks/DD-StackCards/Component.tsx +137 -160
- package/templates/blocks/DD-Team/Component.tsx +247 -265
- package/templates/blocks/DD-TechStack/Component.tsx +57 -72
- package/templates/blocks/DD-Testimonials/Component.tsx +147 -147
- package/templates/blocks/DD-Testimonials/config.ts +66 -66
- package/templates/blocks/DD-Work/Component.tsx +315 -328
- package/templates/blocks/DD-Work-B/Component.tsx +294 -320
- package/templates/collections/Testimonials/README.md +11 -0
- package/templates/collections/Testimonials/Testimonials.ts +161 -0
- package/templates/collections/Testimonials/manifest.json +55 -0
- package/templates/components/RichText/README.md +13 -0
- package/templates/components/RichText/converter/componentConverter/blocks.tsx +43 -0
- package/templates/components/RichText/converter/componentConverter/types.ts +11 -0
- package/templates/components/RichText/converter/index.tsx +18 -0
- package/templates/components/RichText/converter/internalLinks.tsx +45 -0
- package/templates/components/RichText/converter/textConverter.tsx +27 -0
- package/templates/components/RichText/index.tsx +35 -0
- package/templates/components/RichText/manifest.json +80 -0
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises'
|
|
2
2
|
import { join } from 'node:path'
|
|
3
|
-
import {
|
|
3
|
+
import { templateDirectories } from '../utils/paths.js'
|
|
4
4
|
import { isSafeTemplateName } from '../utils/strings.js'
|
|
5
5
|
|
|
6
6
|
export async function loadTemplateManifest(templateName) {
|
|
7
7
|
if (!isSafeTemplateName(templateName)) throw new Error(`Invalid template name: ${templateName}`)
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
const manifestPath = join(templateDirectory, 'manifest.json')
|
|
9
|
+
const misses = []
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
for (const directory of templateDirectories) {
|
|
12
|
+
const templateDirectory = join(directory.path, templateName)
|
|
13
|
+
const manifestPath = join(templateDirectory, 'manifest.json')
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
const manifest = JSON.parse(await readFile(manifestPath, 'utf8'))
|
|
17
|
+
return { manifest, manifestPath, templateDirectory }
|
|
18
|
+
} catch (error) {
|
|
19
|
+
if (error.code === 'ENOENT') {
|
|
20
|
+
misses.push(manifestPath)
|
|
21
|
+
continue
|
|
22
|
+
}
|
|
23
|
+
if (error instanceof SyntaxError) throw new Error(`Invalid JSON in ${manifestPath}: ${error.message}`)
|
|
24
|
+
throw error
|
|
25
|
+
}
|
|
19
26
|
}
|
|
20
|
-
|
|
27
|
+
|
|
28
|
+
throw new Error(`Template not found: ${templateName}`)
|
|
29
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const REQUIRED_STRINGS = ['name', 'type', 'slug', 'version']
|
|
2
|
+
const TEMPLATE_TYPES = new Set(['block', 'component', 'collection'])
|
|
2
3
|
const OPTIONAL_ARRAYS = [
|
|
3
4
|
'files',
|
|
4
5
|
'requiredProjectFiles',
|
|
@@ -14,13 +15,13 @@ const OPTIONAL_ARRAYS = [
|
|
|
14
15
|
export function validateTemplateManifest(manifest) {
|
|
15
16
|
const errors = []
|
|
16
17
|
if (!manifest || typeof manifest !== 'object' || Array.isArray(manifest)) {
|
|
17
|
-
throw new Error('
|
|
18
|
+
throw new Error('Template manifest must be a JSON object.')
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
for (const key of REQUIRED_STRINGS) {
|
|
21
22
|
if (typeof manifest[key] !== 'string' || manifest[key].trim() === '') errors.push(`${key} must be a non-empty string`)
|
|
22
23
|
}
|
|
23
|
-
if (manifest.type
|
|
24
|
+
if (!TEMPLATE_TYPES.has(manifest.type)) errors.push('type must be one of: block, component, collection')
|
|
24
25
|
if (manifest.label !== undefined && typeof manifest.label !== 'string') errors.push('label must be a string when present')
|
|
25
26
|
if (manifest.sourceName !== undefined && typeof manifest.sourceName !== 'string') errors.push('sourceName must be a string when present')
|
|
26
27
|
if (manifest.portableName !== undefined && typeof manifest.portableName !== 'string') errors.push('portableName must be a string when present')
|
|
@@ -33,7 +34,7 @@ export function validateTemplateManifest(manifest) {
|
|
|
33
34
|
if (!Array.isArray(manifest.files)) errors.push('files must be an array')
|
|
34
35
|
if (manifest.source !== undefined && (!manifest.source || typeof manifest.source !== 'object' || Array.isArray(manifest.source))) errors.push('source must be an object when present')
|
|
35
36
|
if (manifest.patchTargets !== undefined && (!manifest.patchTargets || typeof manifest.patchTargets !== 'object' || Array.isArray(manifest.patchTargets))) errors.push('patchTargets must be an object when present')
|
|
36
|
-
for (const key of ['collectionRegistration', 'renderBlocksRegistration', 'renderBlocksBehavior', 'pageRouteIntegration']) {
|
|
37
|
+
for (const key of ['collectionRegistration', 'renderBlocksRegistration', 'renderBlocksBehavior', 'pageRouteIntegration', 'payloadConfigRegistration']) {
|
|
37
38
|
if (manifest[key] !== undefined && (!manifest[key] || typeof manifest[key] !== 'object' || Array.isArray(manifest[key]))) errors.push(`${key} must be an object when present`)
|
|
38
39
|
}
|
|
39
40
|
|
|
@@ -64,6 +65,6 @@ export function validateTemplateManifest(manifest) {
|
|
|
64
65
|
})
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
if (errors.length > 0) throw new Error(`Invalid
|
|
68
|
+
if (errors.length > 0) throw new Error(`Invalid template manifest:\n- ${errors.join('\n- ')}`)
|
|
68
69
|
return manifest
|
|
69
|
-
}
|
|
70
|
+
}
|
package/src/utils/paths.js
CHANGED
|
@@ -5,3 +5,10 @@ const currentDirectory = dirname(fileURLToPath(import.meta.url))
|
|
|
5
5
|
export const packageRoot = resolve(currentDirectory, '..', '..')
|
|
6
6
|
export const templatesDirectory = resolve(packageRoot, 'templates')
|
|
7
7
|
export const blocksDirectory = resolve(templatesDirectory, 'blocks')
|
|
8
|
+
export const componentsDirectory = resolve(templatesDirectory, 'components')
|
|
9
|
+
export const collectionsDirectory = resolve(templatesDirectory, 'collections')
|
|
10
|
+
export const templateDirectories = [
|
|
11
|
+
{ type: 'block', path: blocksDirectory },
|
|
12
|
+
{ type: 'component', path: componentsDirectory },
|
|
13
|
+
{ type: 'collection', path: collectionsDirectory },
|
|
14
|
+
]
|