mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 15:13:21 +00:00
Add Placeholders for Empty Artifacts in Type Generation (#21441)
This commit is contained in:
parent
c7b2b2abcc
commit
89197526ed
@ -5,6 +5,11 @@ const { factory } = require('typescript');
|
||||
const { models } = require('../common');
|
||||
const { emitDefinitions, format, generateSharedExtensionDefinition } = require('../utils');
|
||||
|
||||
const NO_COMPONENT_PLACEHOLDER_COMMENT = `/*
|
||||
* The app doesn't have any components yet.
|
||||
*/
|
||||
`;
|
||||
|
||||
/**
|
||||
* Generate type definitions for Strapi Components
|
||||
*
|
||||
@ -23,6 +28,12 @@ const generateComponentsDefinitions = async (options = {}) => {
|
||||
definition: models.schema.generateSchemaDefinition(contentType),
|
||||
}));
|
||||
|
||||
options.logger.debug(`Found ${componentsDefinitions.length} components.`);
|
||||
|
||||
if (componentsDefinitions.length === 0) {
|
||||
return { output: NO_COMPONENT_PLACEHOLDER_COMMENT, stats: {} };
|
||||
}
|
||||
|
||||
const formattedSchemasDefinitions = componentsDefinitions.reduce((acc, def) => {
|
||||
acc.push(
|
||||
// Definition
|
||||
|
||||
@ -5,6 +5,11 @@ const { factory } = require('typescript');
|
||||
const { models } = require('../common');
|
||||
const { emitDefinitions, format, generateSharedExtensionDefinition } = require('../utils');
|
||||
|
||||
const NO_CONTENT_TYPE_PLACEHOLDER_COMMENT = `/*
|
||||
* The app doesn't have any content-types yet.
|
||||
*/
|
||||
`;
|
||||
|
||||
/**
|
||||
* Generate type definitions for Strapi Content-Types
|
||||
*
|
||||
@ -23,6 +28,12 @@ const generateContentTypesDefinitions = async (options = {}) => {
|
||||
definition: models.schema.generateSchemaDefinition(contentType),
|
||||
}));
|
||||
|
||||
options.logger.debug(`Found ${contentTypesDefinitions.length} content-types.`);
|
||||
|
||||
if (contentTypesDefinitions.length === 0) {
|
||||
return { output: NO_CONTENT_TYPE_PLACEHOLDER_COMMENT, stats: {} };
|
||||
}
|
||||
|
||||
const formattedSchemasDefinitions = contentTypesDefinitions.reduce((acc, def) => {
|
||||
acc.push(
|
||||
// Definition
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user