(addOnsBase)
| 106 | } |
| 107 | |
| 108 | function scanCatalogDirectory(addOnsBase) { |
| 109 | if (!existsSync(addOnsBase)) { |
| 110 | return [] |
| 111 | } |
| 112 | |
| 113 | const addOns = [] |
| 114 | |
| 115 | for (const entry of readdirSync(addOnsBase, { withFileTypes: true })) { |
| 116 | if (!entry.isDirectory()) { |
| 117 | continue |
| 118 | } |
| 119 | |
| 120 | const addOnDir = join(addOnsBase, entry.name) |
| 121 | const info = readJson(join(addOnDir, 'info.json')) |
| 122 | |
| 123 | let packageAdditions = {} |
| 124 | let packageTemplate |
| 125 | const packageJsonPath = join(addOnDir, 'package.json') |
| 126 | const packageTemplatePath = join(addOnDir, 'package.json.ejs') |
| 127 | if (existsSync(packageJsonPath)) { |
| 128 | packageAdditions = readJson(packageJsonPath) |
| 129 | } else if (existsSync(packageTemplatePath)) { |
| 130 | packageTemplate = readFileSync(packageTemplatePath, 'utf8') |
| 131 | registerTemplate(packageTemplate) |
| 132 | } |
| 133 | |
| 134 | let readme |
| 135 | let readmeIsEjs = false |
| 136 | const readmePath = join(addOnDir, 'README.md') |
| 137 | const readmeTemplatePath = join(addOnDir, 'README.md.ejs') |
| 138 | if (existsSync(readmePath)) { |
| 139 | readme = readFileSync(readmePath, 'utf8') |
| 140 | } else if (existsSync(readmeTemplatePath)) { |
| 141 | readme = readFileSync(readmeTemplatePath, 'utf8') |
| 142 | registerTemplate(readme) |
| 143 | readmeIsEjs = true |
| 144 | } |
| 145 | |
| 146 | let smallLogo |
| 147 | const smallLogoPath = join(addOnDir, 'small-logo.svg') |
| 148 | if (existsSync(smallLogoPath)) { |
| 149 | smallLogo = readFileSync(smallLogoPath, 'utf8') |
| 150 | } |
| 151 | |
| 152 | addOns.push({ |
| 153 | ...info, |
| 154 | id: entry.name, |
| 155 | version: info.version ?? '0.0.0', |
| 156 | packageAdditions, |
| 157 | packageTemplate, |
| 158 | readme, |
| 159 | readmeIsEjs, |
| 160 | files: findFilesRecursively(join(addOnDir, 'assets')), |
| 161 | deletedFiles: info.deletedFiles ?? [], |
| 162 | smallLogo, |
| 163 | }) |
| 164 | } |
| 165 |
no test coverage detected