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.
Files changed (50) hide show
  1. package/README.md +967 -3
  2. package/package.json +40 -40
  3. package/src/commands/add.js +143 -45
  4. package/src/commands/list.js +2 -2
  5. package/src/installers/checkRequirements.js +1 -0
  6. package/src/installers/copyTemplateFiles.js +23 -2
  7. package/src/installers/patchPayloadConfigCollections.js +92 -0
  8. package/src/installers/writeInstalledBlockReadme.js +17 -4
  9. package/src/registry/listTemplates.js +16 -7
  10. package/src/registry/loadTemplateManifest.js +20 -11
  11. package/src/registry/validateTemplateManifest.js +6 -5
  12. package/src/utils/paths.js +7 -0
  13. package/templates/blocks/DD-BookCall/Component.tsx +535 -573
  14. package/templates/blocks/DD-CardTemplate01/Component.tsx +45 -49
  15. package/templates/blocks/DD-Carousel-A/Component.tsx +249 -266
  16. package/templates/blocks/DD-Carousel-B/Component.tsx +403 -432
  17. package/templates/blocks/DD-ComparisonTable/Component.tsx +256 -272
  18. package/templates/blocks/DD-Contact/Component.tsx +434 -439
  19. package/templates/blocks/DD-Contact/config.ts +8 -3
  20. package/templates/blocks/DD-FeatCat/Component.tsx +302 -361
  21. package/templates/blocks/DD-FeatCat/config.ts +201 -204
  22. package/templates/blocks/DD-FeatStrip/Component.tsx +171 -201
  23. package/templates/blocks/DD-Hero/Component.tsx +297 -317
  24. package/templates/blocks/DD-HorizontalScroll/Component.tsx +244 -303
  25. package/templates/blocks/DD-MasonaryMedia/Component.tsx +202 -228
  26. package/templates/blocks/DD-MasonaryMedia/config.ts +13 -14
  27. package/templates/blocks/DD-Pricing/Component.tsx +372 -380
  28. package/templates/blocks/DD-Process/Component.tsx +149 -155
  29. package/templates/blocks/DD-Section/Component.tsx +266 -327
  30. package/templates/blocks/DD-Services/Component.tsx +176 -188
  31. package/templates/blocks/DD-ShowcaseGrid/Component.tsx +307 -317
  32. package/templates/blocks/DD-Slider-A/Component.tsx +237 -252
  33. package/templates/blocks/DD-StackCards/Component.tsx +137 -160
  34. package/templates/blocks/DD-Team/Component.tsx +247 -265
  35. package/templates/blocks/DD-TechStack/Component.tsx +57 -72
  36. package/templates/blocks/DD-Testimonials/Component.tsx +147 -147
  37. package/templates/blocks/DD-Testimonials/config.ts +66 -66
  38. package/templates/blocks/DD-Work/Component.tsx +315 -328
  39. package/templates/blocks/DD-Work-B/Component.tsx +294 -320
  40. package/templates/collections/Testimonials/README.md +11 -0
  41. package/templates/collections/Testimonials/Testimonials.ts +161 -0
  42. package/templates/collections/Testimonials/manifest.json +55 -0
  43. package/templates/components/RichText/README.md +13 -0
  44. package/templates/components/RichText/converter/componentConverter/blocks.tsx +43 -0
  45. package/templates/components/RichText/converter/componentConverter/types.ts +11 -0
  46. package/templates/components/RichText/converter/index.tsx +18 -0
  47. package/templates/components/RichText/converter/internalLinks.tsx +45 -0
  48. package/templates/components/RichText/converter/textConverter.tsx +27 -0
  49. package/templates/components/RichText/index.tsx +35 -0
  50. 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 { blocksDirectory } from '../utils/paths.js'
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 templateDirectory = join(blocksDirectory, templateName)
10
- const manifestPath = join(templateDirectory, 'manifest.json')
9
+ const misses = []
11
10
 
12
- try {
13
- const manifest = JSON.parse(await readFile(manifestPath, 'utf8'))
14
- return { manifest, manifestPath, templateDirectory }
15
- } catch (error) {
16
- if (error.code === 'ENOENT') throw new Error(`Template not found: ${templateName}`)
17
- if (error instanceof SyntaxError) throw new Error(`Invalid JSON in ${manifestPath}: ${error.message}`)
18
- throw error
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('Block manifest must be a JSON object.')
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 !== 'block') errors.push('type must be "block"')
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 block manifest:\n- ${errors.join('\n- ')}`)
68
+ if (errors.length > 0) throw new Error(`Invalid template manifest:\n- ${errors.join('\n- ')}`)
68
69
  return manifest
69
- }
70
+ }
@@ -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
+ ]