diff --git a/.changeset/cool-dolls-trade.md b/.changeset/cool-dolls-trade.md new file mode 100644 index 00000000..12fd3318 --- /dev/null +++ b/.changeset/cool-dolls-trade.md @@ -0,0 +1,5 @@ +--- +'arui-scripts': patch +--- + +Убрана ненужная проверка на наличие файлов, необходимых для сборки. Эта проверка и так будет сделана вебпаком, поэтому сммысла от доп проверки на нашем уровне - нет diff --git a/packages/arui-scripts/src/commands/util/check-required-files.ts b/packages/arui-scripts/src/commands/util/check-required-files.ts deleted file mode 100644 index 2363c8e9..00000000 --- a/packages/arui-scripts/src/commands/util/check-required-files.ts +++ /dev/null @@ -1,86 +0,0 @@ -import fs from 'fs'; -import path from 'path'; - -import chalk from 'chalk'; - -import configs from '../../configs/app-configs'; - -const extensions = ['ts', 'tsx', 'js', 'jsx']; - -function entryPointToArray( - entryPoint: string | string[] | Record, -): string[] { - if (typeof entryPoint === 'string') { - return [entryPoint]; - } - if (Array.isArray(entryPoint)) { - return entryPoint; - } - - return Object.keys(entryPoint).reduce((result, name) => { - const entry = entryPointToArray(entryPoint[name]); - - return [...result, ...entry]; - }, [] as string[]); -} - -const files = [ - ...entryPointToArray(configs.serverEntry), - ...entryPointToArray(configs.clientEntry), - ...(Array.isArray(configs.clientPolyfillsEntry) - ? configs.clientPolyfillsEntry - : [configs.clientPolyfillsEntry]), -]; - -function checkFileWithExtensions(filePath: string, extensions: string[]) { - if (extensions.some((ext) => filePath.endsWith(`.${ext}`))) { - try { - fs.accessSync(filePath); - - return true; - } catch (err) { - // empty error - } - } - - for (let i = 0; i < extensions.length; i++) { - try { - fs.accessSync(`${filePath}.${extensions[i]}`); - - return true; - } catch (err) { - // emprty error - } - } - - return false; -} - -function checkRequiredFiles() { - const unavailableFilePaths: string[] = files.filter(Boolean).reduce((result, filePath) => { - if (filePath && !checkFileWithExtensions(filePath, extensions)) { - result.push(filePath); - } - - return result; - }, [] as string[]); - - if (unavailableFilePaths.length !== 0) { - console.log(chalk.red('Could not find required files.')); - const extensionsString = extensions.join(','); - - unavailableFilePaths.forEach((filePath) => { - const dirName = path.dirname(filePath); - const fileName = path.basename(filePath); - - console.log(chalk.red(' Name: ') + chalk.cyan(`${fileName}.{${extensionsString}}`)); - console.log(chalk.red(' Searched in: ') + chalk.cyan(dirName)); - }); - - return false; - } - - return true; -} - -export default checkRequiredFiles; diff --git a/packages/arui-scripts/src/commands/util/run-compilers.ts b/packages/arui-scripts/src/commands/util/run-compilers.ts index 9f198668..95e22e2a 100644 --- a/packages/arui-scripts/src/commands/util/run-compilers.ts +++ b/packages/arui-scripts/src/commands/util/run-compilers.ts @@ -2,15 +2,9 @@ import { spawn } from 'child_process'; import fs from 'fs-extra'; -import configs from '../../configs/app-configs'; - -import checkRequiredFiles from './check-required-files'; +import { configs } from '../../configs/app-configs'; export function runCompilers(pathToCompilers: Array) { - if (!checkRequiredFiles()) { - process.exit(1); - } - if (fs.pathExistsSync(configs.serverOutputPath)) { fs.removeSync(configs.serverOutputPath); }