mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 01:47:13 +00:00 
			
		
		
		
	Revert breaking change & adapt the feature behavior
This commit is contained in:
		
							parent
							
								
									0b15df5850
								
							
						
					
					
						commit
						489e422f60
					
				| @ -4,8 +4,8 @@ const tsUtils = require('@strapi/typescript-utils'); | ||||
| 
 | ||||
| const strapi = require('../../../../index'); | ||||
| 
 | ||||
| module.exports = async ({ debug, silent }) => { | ||||
|   if (debug && silent) { | ||||
| module.exports = async ({ debug, silent, verbose, outDir }) => { | ||||
|   if ((debug || verbose) && silent) { | ||||
|     console.error('Flags conflict: both silent and debug mode are enabled, exiting...'); | ||||
|     process.exit(1); | ||||
|   } | ||||
| @ -16,7 +16,12 @@ module.exports = async ({ debug, silent }) => { | ||||
|   await tsUtils.generators.generate({ | ||||
|     strapi: app, | ||||
|     pwd: appContext.appDir, | ||||
|     logger: { silent, debug }, | ||||
|     rootDir: outDir ?? undefined, | ||||
|     logger: { | ||||
|       silent, | ||||
|       // TODO V5: verbose is deprecated and should be removed
 | ||||
|       debug: debug || verbose, | ||||
|     }, | ||||
|     artefacts: { contentTypes: true, components: true }, | ||||
|   }); | ||||
| 
 | ||||
|  | ||||
| @ -10,7 +10,12 @@ module.exports = ({ command }) => { | ||||
|   command | ||||
|     .command('ts:generate-types') | ||||
|     .description(`Generate TypeScript typings for your schemas`) | ||||
|     .option('--verbose', `[DEPRECATED] The verbose option has been replaced by debug`, false) | ||||
|     .option('-d, --debug', `Run the generation with debug messages`, false) | ||||
|     .option('-s, --silent', `Run the generation silently, without any output`, false) | ||||
|     .option( | ||||
|       '-o, --out-dir <outDir>', | ||||
|       'Specify a relative root directory in which the definitions will be generated. Changing this value might break types exposed by Strapi that relies on generated types.' | ||||
|     ) | ||||
|     .action(getLocalScript('ts/generate-types')); | ||||
| }; | ||||
|  | ||||
| @ -2,6 +2,7 @@ | ||||
| 
 | ||||
| const path = require('path'); | ||||
| 
 | ||||
| const REGISTRIES_OUT_DIR = path.join('types', 'shared', 'registries'); | ||||
| const TYPES_ROOT_DIR = 'types'; | ||||
| const REGISTRIES_OUT_DIR = path.join('shared', 'registries'); | ||||
| 
 | ||||
| module.exports = { REGISTRIES_OUT_DIR }; | ||||
| module.exports = { REGISTRIES_OUT_DIR, TYPES_ROOT_DIR }; | ||||
|  | ||||
| @ -3,7 +3,7 @@ | ||||
| const path = require('path'); | ||||
| const chalk = require('chalk'); | ||||
| 
 | ||||
| const { REGISTRIES_OUT_DIR } = require('./constants'); | ||||
| const { TYPES_ROOT_DIR, REGISTRIES_OUT_DIR } = require('./constants'); | ||||
| const { saveDefinitionToFileSystem, createLogger, timer } = require('./utils'); | ||||
| const generateContentTypesDefinitions = require('./content-types'); | ||||
| const generateComponentsDefinitions = require('./components'); | ||||
| @ -37,12 +37,12 @@ const GENERATORS = { | ||||
|  * @param {GenerateConfig} [config] | ||||
|  */ | ||||
| const generate = async (config = {}) => { | ||||
|   const { pwd, strapi, artefacts = {}, logger: loggerConfig } = config; | ||||
|   const { pwd, rootDir = TYPES_ROOT_DIR, strapi, artefacts = {}, logger: loggerConfig } = config; | ||||
|   const reports = {}; | ||||
|   const logger = createLogger(loggerConfig); | ||||
|   const psTimer = timer().start(); | ||||
| 
 | ||||
|   const registryPwd = path.join(pwd, REGISTRIES_OUT_DIR); | ||||
|   const registryPwd = path.join(pwd, rootDir, REGISTRIES_OUT_DIR); | ||||
|   const generatorConfig = { strapi, pwd: registryPwd, logger }; | ||||
| 
 | ||||
|   const returnWithMessage = () => { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Convly
						Convly