Skip to content

Commit 8aabefd

Browse files
humanbirdlarbish
andauthored
fix(preview): skip collections without source in preview template (#3771)
Co-authored-by: Baptiste Leproux <leproux.baptiste@gmail.com>
1 parent ea196c5 commit 8aabefd

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/utils/templates.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,12 @@ export const previewTemplate = (collections: ResolvedCollection[], gitInfo: GitI
206206
filename: moduleTemplates.preview,
207207
getContents: ({ options }: { options: { collections: ResolvedCollection[] } }) => {
208208
const collectionsMeta = options.collections.reduce((acc, collection) => {
209+
// Only include non remote collections and collections with at least one local source (remove `info` collection)
210+
const localSources = collection.source?.filter(source => !source.repository) ?? []
211+
if (localSources.length === 0) {
212+
return acc
213+
}
214+
209215
const schemaWithCollectionName = {
210216
...collection.extendedSchema,
211217
definitions: {
@@ -216,8 +222,7 @@ export const previewTemplate = (collections: ResolvedCollection[], gitInfo: GitI
216222
name: collection.name,
217223
pascalName: pascalCase(collection.name),
218224
tableName: collection.tableName,
219-
// Remove source from collection meta if it's a remote collection
220-
source: collection.source?.filter(source => source.repository ? undefined : collection.source) || [],
225+
source: localSources,
221226
type: collection.type,
222227
fields: collection.fields,
223228
schema: schemaWithCollectionName,

0 commit comments

Comments
 (0)