Merge pull request #16516 from strapi/ts-support-2/automatic-type-generation

This commit is contained in:
Jean-Sébastien Herbaux 2023-05-02 09:45:07 +02:00 committed by GitHub
commit cd5e791448
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -106,12 +106,30 @@ const primaryProcess = async ({ distDir, appDir, build, isTSProject, watchAdmin,
cluster.fork();
};
const workerProcess = ({ appDir, distDir, watchAdmin, polling, isTSProject }) => {
const strapiInstance = strapi({
const workerProcess = async ({ appDir, distDir, watchAdmin, polling, isTSProject }) => {
const strapiInstance = await strapi({
distDir,
autoReload: true,
serveAdminPanel: !watchAdmin,
});
}).load();
/**
* TypeScript automatic type generation upon dev server restart
* Its implementation, configuration and behavior can change in future releases
* @experimental
*/
const shouldGenerateTypeScriptTypes = strapiInstance.config.get('typescript.autogenerate', false);
if (shouldGenerateTypeScriptTypes) {
// This is run in an uncaught promise on purpose so that it doesn't block Strapi startup
// NOTE: We should probably add some configuration options to manage the file structure output or the verbosity level
tsUtils.generators.generateSchemasDefinitions({
strapi: strapiInstance,
outDir: appDir,
verbose: false,
silent: true,
});
}
const adminWatchIgnoreFiles = strapiInstance.config.get('admin.watchIgnoreFiles', []);
watchFileChanges({
@ -179,6 +197,7 @@ function watchFileChanges({ appDir, strapiInstance, watchIgnoreFiles, polling })
'**/*.db*',
'**/exports/**',
'**/dist/**',
'**/*.d.ts',
...watchIgnoreFiles,
],
});