@strapi/typescript-utils 5.0.0-rc.9 → 5.0.1

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.
@@ -5,6 +5,11 @@ const { factory } = require('typescript');
5
5
  const { models } = require('../common');
6
6
  const { emitDefinitions, format, generateSharedExtensionDefinition } = require('../utils');
7
7
 
8
+ const NO_COMPONENT_PLACEHOLDER_COMMENT = `/*
9
+ * The app doesn't have any components yet.
10
+ */
11
+ `;
12
+
8
13
  /**
9
14
  * Generate type definitions for Strapi Components
10
15
  *
@@ -23,6 +28,12 @@ const generateComponentsDefinitions = async (options = {}) => {
23
28
  definition: models.schema.generateSchemaDefinition(contentType),
24
29
  }));
25
30
 
31
+ options.logger.debug(`Found ${componentsDefinitions.length} components.`);
32
+
33
+ if (componentsDefinitions.length === 0) {
34
+ return { output: NO_COMPONENT_PLACEHOLDER_COMMENT, stats: {} };
35
+ }
36
+
26
37
  const formattedSchemasDefinitions = componentsDefinitions.reduce((acc, def) => {
27
38
  acc.push(
28
39
  // Definition
@@ -5,6 +5,11 @@ const { factory } = require('typescript');
5
5
  const { models } = require('../common');
6
6
  const { emitDefinitions, format, generateSharedExtensionDefinition } = require('../utils');
7
7
 
8
+ const NO_CONTENT_TYPE_PLACEHOLDER_COMMENT = `/*
9
+ * The app doesn't have any content-types yet.
10
+ */
11
+ `;
12
+
8
13
  /**
9
14
  * Generate type definitions for Strapi Content-Types
10
15
  *
@@ -23,6 +28,12 @@ const generateContentTypesDefinitions = async (options = {}) => {
23
28
  definition: models.schema.generateSchemaDefinition(contentType),
24
29
  }));
25
30
 
31
+ options.logger.debug(`Found ${contentTypesDefinitions.length} content-types.`);
32
+
33
+ if (contentTypesDefinitions.length === 0) {
34
+ return { output: NO_CONTENT_TYPE_PLACEHOLDER_COMMENT, stats: {} };
35
+ }
36
+
26
37
  const formattedSchemasDefinitions = contentTypesDefinitions.reduce((acc, def) => {
27
38
  acc.push(
28
39
  // Definition
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/typescript-utils",
3
- "version": "5.0.0-rc.9",
3
+ "version": "5.0.1",
4
4
  "description": "Typescript support for Strapi",
5
5
  "keywords": [
6
6
  "strapi",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "chalk": "4.1.2",
39
- "cli-table3": "0.6.2",
39
+ "cli-table3": "0.6.5",
40
40
  "fs-extra": "11.2.0",
41
41
  "lodash": "4.17.21",
42
42
  "prettier": "3.2.5",
@@ -49,5 +49,5 @@
49
49
  "node": ">=18.0.0 <=20.x.x",
50
50
  "npm": ">=6.0.0"
51
51
  },
52
- "gitHead": "e281ba8e37693c2fc24795be4df4f2ed516063fc"
52
+ "gitHead": "99323ff7d720a309ae03d2fa50b232a25cf57116"
53
53
  }