@tramvai/cli 2.64.0 → 2.66.0
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.
- package/README.md +46 -38
- package/lib/api/analyze/providers/shared.js +1 -1
- package/lib/api/analyze/providers/shared.js.map +1 -1
- package/lib/api/benchmark/index.d.ts +1 -1
- package/lib/api/build/child-app.js +3 -2
- package/lib/api/build/child-app.js.map +1 -1
- package/lib/api/build/module.js +1 -2
- package/lib/api/build/module.js.map +1 -1
- package/lib/api/build/providers/shared.js +1 -1
- package/lib/api/build/providers/shared.js.map +1 -1
- package/lib/api/index.d.ts +6 -2
- package/lib/api/index.js +3 -3
- package/lib/api/index.js.map +1 -1
- package/lib/api/shared/types/withConfig.d.ts +3 -2
- package/lib/api/start/providers/application/server.js +11 -18
- package/lib/api/start/providers/application/server.js.map +1 -1
- package/lib/api/start/providers/application/shared.js +17 -25
- package/lib/api/start/providers/application/shared.js.map +1 -1
- package/lib/api/start/providers/child-app/shared.js +19 -25
- package/lib/api/start/providers/child-app/shared.js.map +1 -1
- package/lib/api/start/providers/module/shared.js +18 -24
- package/lib/api/start/providers/module/shared.js.map +1 -1
- package/lib/api/start/utils/banner.js +3 -2
- package/lib/api/start/utils/banner.js.map +1 -1
- package/lib/api/start/utils/listenServer.js +3 -2
- package/lib/api/start/utils/listenServer.js.map +1 -1
- package/lib/api/start/utils/tips/tips.js +10 -8
- package/lib/api/start/utils/tips/tips.js.map +1 -1
- package/lib/api/start-prod/providers/application.js +6 -5
- package/lib/api/start-prod/providers/application.js.map +1 -1
- package/lib/api/start-prod/providers/child-app.js +3 -2
- package/lib/api/start-prod/providers/child-app.js.map +1 -1
- package/lib/api/start-prod/providers/shared.js +5 -13
- package/lib/api/start-prod/providers/shared.js.map +1 -1
- package/lib/builder/webpack/devServer/client.js +18 -15
- package/lib/builder/webpack/devServer/client.js.map +1 -1
- package/lib/builder/webpack/devServer/notifier.d.ts +2 -2
- package/lib/builder/webpack/devServer/notifier.js +3 -3
- package/lib/builder/webpack/devServer/notifier.js.map +1 -1
- package/lib/builder/webpack/devServer/pool/process/pool.js +3 -2
- package/lib/builder/webpack/devServer/pool/process/pool.js.map +1 -1
- package/lib/builder/webpack/devServer/pool/thread/pool.js +7 -0
- package/lib/builder/webpack/devServer/pool/thread/pool.js.map +1 -1
- package/lib/builder/webpack/devServer/server.js +7 -2
- package/lib/builder/webpack/devServer/server.js.map +1 -1
- package/lib/builder/webpack/providers/analyze/shared.js +3 -3
- package/lib/builder/webpack/providers/analyze/shared.js.map +1 -1
- package/lib/builder/webpack/providers/build/application/server.js.map +1 -1
- package/lib/builder/webpack/providers/build/client.js +3 -3
- package/lib/builder/webpack/providers/build/client.js.map +1 -1
- package/lib/builder/webpack/providers/build/server.js +1 -1
- package/lib/builder/webpack/providers/build/server.js.map +1 -1
- package/lib/builder/webpack/tokens.d.ts +313 -3
- package/lib/builder/webpack/tokens.js.map +1 -1
- package/lib/builder/webpack/utils/copyBuildFile.d.ts +2 -1
- package/lib/builder/webpack/utils/copyBuildFile.js +2 -3
- package/lib/builder/webpack/utils/copyBuildFile.js.map +1 -1
- package/lib/builder/webpack/utils/copyStatsJsonFile.d.ts +2 -1
- package/lib/builder/webpack/utils/copyStatsJsonFile.js +1 -1
- package/lib/builder/webpack/utils/copyStatsJsonFile.js.map +1 -1
- package/lib/cli/CLI.d.ts +2 -2
- package/lib/cli/CLI.js +2 -2
- package/lib/cli/CLI.js.map +1 -1
- package/lib/cli/index.js.map +1 -1
- package/lib/commands/analyze/command.d.ts +1 -1
- package/lib/commands/analyze/command.js.map +1 -1
- package/lib/commands/benchmark/command.d.ts +1 -1
- package/lib/commands/benchmark/command.js.map +1 -1
- package/lib/commands/build/command.d.ts +1 -1
- package/lib/commands/build/command.js.map +1 -1
- package/lib/commands/new/new.js +0 -1
- package/lib/commands/new/new.js.map +1 -1
- package/lib/commands/new/questions/packageManager.d.ts +1 -1
- package/lib/commands/new/questions/packageManager.js.map +1 -1
- package/lib/commands/new/questions/template.d.ts +1 -1
- package/lib/commands/new/questions/template.js.map +1 -1
- package/lib/commands/new/questions/testingFramework.d.ts +1 -1
- package/lib/commands/new/questions/testingFramework.js.map +1 -1
- package/lib/commands/new/questions/type.d.ts +1 -1
- package/lib/commands/new/questions/type.js.map +1 -1
- package/lib/commands/new/steps/initializationGit.d.ts +1 -1
- package/lib/commands/new/steps/initializationGit.js.map +1 -1
- package/lib/commands/start/command.d.ts +1 -1
- package/lib/commands/start/command.js.map +1 -1
- package/lib/commands/start-prod/command.d.ts +1 -1
- package/lib/commands/start-prod/command.js.map +1 -1
- package/lib/commands/static/application.js +4 -4
- package/lib/commands/static/application.js.map +1 -1
- package/lib/commands/static/command.d.ts +1 -1
- package/lib/commands/static/command.js.map +1 -1
- package/lib/commands/static/generate.js +2 -2
- package/lib/commands/static/generate.js.map +1 -1
- package/lib/commands/static/server.d.ts +2 -1
- package/lib/commands/static/server.js +1 -1
- package/lib/commands/static/server.js.map +1 -1
- package/lib/commands/static/staticServer.d.ts +2 -1
- package/lib/commands/static/staticServer.js +1 -1
- package/lib/commands/static/staticServer.js.map +1 -1
- package/lib/commands/update/updatePackageJson.js +3 -0
- package/lib/commands/update/updatePackageJson.js.map +1 -1
- package/lib/config/configManager.d.ts +15 -73
- package/lib/config/configManager.js +64 -92
- package/lib/config/configManager.js.map +1 -1
- package/lib/config/showConfig.d.ts +1 -1
- package/lib/config/showConfig.js +1 -1
- package/lib/config/showConfig.js.map +1 -1
- package/lib/config/validate.d.ts +5 -4
- package/lib/config/validate.js +2 -9
- package/lib/config/validate.js.map +1 -1
- package/lib/di/tokens/config.d.ts +106 -1
- package/lib/di/tokens/config.js.map +1 -1
- package/lib/external/config.d.ts +2 -2
- package/lib/library/babel/index.js +1 -0
- package/lib/library/babel/index.js.map +1 -1
- package/lib/library/swc/index.js +1 -1
- package/lib/library/swc/index.js.map +1 -1
- package/lib/library/webpack/application/client/common.js +6 -4
- package/lib/library/webpack/application/client/common.js.map +1 -1
- package/lib/library/webpack/application/client/dev.js +9 -8
- package/lib/library/webpack/application/client/dev.js.map +1 -1
- package/lib/library/webpack/application/client/prod/optimization/splitChunks.js +40 -39
- package/lib/library/webpack/application/client/prod/optimization/splitChunks.js.map +1 -1
- package/lib/library/webpack/application/client/prod.js +3 -4
- package/lib/library/webpack/application/client/prod.js.map +1 -1
- package/lib/library/webpack/application/server/common.js +5 -5
- package/lib/library/webpack/application/server/common.js.map +1 -1
- package/lib/library/webpack/application/server/dev.js +3 -6
- package/lib/library/webpack/application/server/dev.js.map +1 -1
- package/lib/library/webpack/application/server/prod.js +3 -4
- package/lib/library/webpack/application/server/prod.js.map +1 -1
- package/lib/library/webpack/blocks/apiResolve.js +1 -1
- package/lib/library/webpack/blocks/apiResolve.js.map +1 -1
- package/lib/library/webpack/blocks/configResolve.js +2 -2
- package/lib/library/webpack/blocks/configResolve.js.map +1 -1
- package/lib/library/webpack/blocks/configToEnv.js +5 -2
- package/lib/library/webpack/blocks/configToEnv.js.map +1 -1
- package/lib/library/webpack/blocks/css.d.ts +3 -1
- package/lib/library/webpack/blocks/css.js +17 -6
- package/lib/library/webpack/blocks/css.js.map +1 -1
- package/lib/library/webpack/blocks/extractCssPlugin.d.ts +4 -3
- package/lib/library/webpack/blocks/extractCssPlugin.js +4 -6
- package/lib/library/webpack/blocks/extractCssPlugin.js.map +1 -1
- package/lib/library/webpack/blocks/filesClient.d.ts +3 -2
- package/lib/library/webpack/blocks/filesClient.js +7 -7
- package/lib/library/webpack/blocks/filesClient.js.map +1 -1
- package/lib/library/webpack/blocks/filesServer.d.ts +2 -1
- package/lib/library/webpack/blocks/filesServer.js +3 -3
- package/lib/library/webpack/blocks/filesServer.js.map +1 -1
- package/lib/library/webpack/blocks/js.d.ts +2 -1
- package/lib/library/webpack/blocks/js.js +1 -1
- package/lib/library/webpack/blocks/js.js.map +1 -1
- package/lib/library/webpack/blocks/nodeClient.d.ts +2 -1
- package/lib/library/webpack/blocks/nodeClient.js +2 -2
- package/lib/library/webpack/blocks/nodeClient.js.map +1 -1
- package/lib/library/webpack/blocks/optimize.d.ts +2 -1
- package/lib/library/webpack/blocks/optimize.js +3 -3
- package/lib/library/webpack/blocks/optimize.js.map +1 -1
- package/lib/library/webpack/blocks/pagesResolve.js +1 -1
- package/lib/library/webpack/blocks/pagesResolve.js.map +1 -1
- package/lib/library/webpack/blocks/postcssAssets.d.ts +2 -1
- package/lib/library/webpack/blocks/postcssAssets.js +2 -2
- package/lib/library/webpack/blocks/postcssAssets.js.map +1 -1
- package/lib/library/webpack/blocks/serverInline.d.ts +2 -1
- package/lib/library/webpack/blocks/serverInline.js.map +1 -1
- package/lib/library/webpack/blocks/ts.d.ts +2 -1
- package/lib/library/webpack/blocks/ts.js.map +1 -1
- package/lib/library/webpack/child-app/client/common.d.ts +2 -2
- package/lib/library/webpack/child-app/client/common.js +1 -1
- package/lib/library/webpack/child-app/client/common.js.map +1 -1
- package/lib/library/webpack/child-app/client/dev.d.ts +2 -2
- package/lib/library/webpack/child-app/client/dev.js +6 -5
- package/lib/library/webpack/child-app/client/dev.js.map +1 -1
- package/lib/library/webpack/child-app/client/prod.d.ts +2 -2
- package/lib/library/webpack/child-app/client/prod.js.map +1 -1
- package/lib/library/webpack/child-app/common.d.ts +2 -2
- package/lib/library/webpack/child-app/common.js.map +1 -1
- package/lib/library/webpack/child-app/server/common.d.ts +2 -2
- package/lib/library/webpack/child-app/server/common.js +1 -1
- package/lib/library/webpack/child-app/server/common.js.map +1 -1
- package/lib/library/webpack/child-app/server/dev.d.ts +2 -2
- package/lib/library/webpack/child-app/server/dev.js.map +1 -1
- package/lib/library/webpack/child-app/server/prod.d.ts +2 -2
- package/lib/library/webpack/child-app/server/prod.js.map +1 -1
- package/lib/library/webpack/common/client/prod.d.ts +2 -1
- package/lib/library/webpack/common/client/prod.js +4 -5
- package/lib/library/webpack/common/client/prod.js.map +1 -1
- package/lib/library/webpack/common/main.d.ts +2 -1
- package/lib/library/webpack/common/main.js +3 -3
- package/lib/library/webpack/common/main.js.map +1 -1
- package/lib/library/webpack/common/server/prod.d.ts +2 -1
- package/lib/library/webpack/common/server/prod.js +4 -5
- package/lib/library/webpack/common/server/prod.js.map +1 -1
- package/lib/library/webpack/index.js +1 -2
- package/lib/library/webpack/index.js.map +1 -1
- package/lib/library/webpack/loaders/image-loader/index.d.ts +2 -1
- package/lib/library/webpack/loaders/image-loader/index.js.map +1 -1
- package/lib/library/webpack/loaders/pagesResolve.d.ts +10 -1
- package/lib/library/webpack/loaders/pagesResolve.js +4 -3
- package/lib/library/webpack/loaders/pagesResolve.js.map +1 -1
- package/lib/library/webpack/loaders/replaceContent.d.ts +6 -1
- package/lib/library/webpack/loaders/replaceContent.js +4 -3
- package/lib/library/webpack/loaders/replaceContent.js.map +1 -1
- package/lib/library/webpack/module/client/common.js +1 -1
- package/lib/library/webpack/module/client/common.js.map +1 -1
- package/lib/library/webpack/module/externals.d.ts +1 -1
- package/lib/library/webpack/module/externals.js.map +1 -1
- package/lib/library/webpack/module/resolveExternal.d.ts +1 -1
- package/lib/library/webpack/module/resolveExternal.js.map +1 -1
- package/lib/library/webpack/module/server/common.js +1 -1
- package/lib/library/webpack/module/server/common.js.map +1 -1
- package/lib/library/webpack/plugins/LazyModuleInitialization.d.ts +2 -2
- package/lib/library/webpack/plugins/LazyModuleInitialization.js +1 -0
- package/lib/library/webpack/plugins/LazyModuleInitialization.js.map +1 -1
- package/lib/library/webpack/plugins/WebpackBar/utils/index.d.ts +7 -7
- package/lib/library/webpack/plugins/WebpackBar/utils/index.js.map +1 -1
- package/lib/library/webpack/plugins/WebpackBar/utils/webpack.d.ts +2 -2
- package/lib/library/webpack/plugins/WebpackBar/utils/webpack.js.map +1 -1
- package/lib/library/webpack/types/webpack.d.ts +2 -2
- package/lib/library/webpack/utils/files.d.ts +4 -3
- package/lib/library/webpack/utils/files.js +2 -2
- package/lib/library/webpack/utils/files.js.map +1 -1
- package/lib/library/webpack/utils/transpiler.d.ts +3 -2
- package/lib/library/webpack/utils/transpiler.js +2 -2
- package/lib/library/webpack/utils/transpiler.js.map +1 -1
- package/lib/library/webpack/utils/workersPool.d.ts +3 -6
- package/lib/library/webpack/utils/workersPool.js +1 -1
- package/lib/library/webpack/utils/workersPool.js.map +1 -1
- package/lib/models/config.d.ts +2 -3
- package/lib/models/config.js +32 -3
- package/lib/models/config.js.map +1 -1
- package/lib/schema/ConfigSchema.d.ts +13 -4
- package/lib/schema/autogeneratedSchema.json +1808 -2074
- package/lib/typings/configEntry/application.d.ts +81 -86
- package/lib/typings/configEntry/child-app.d.ts +10 -29
- package/lib/typings/configEntry/cli.d.ts +254 -0
- package/lib/typings/configEntry/{CheckAsyncTsConfig.js → cli.js} +1 -1
- package/lib/typings/configEntry/cli.js.map +1 -0
- package/lib/typings/configEntry/common.d.ts +16 -276
- package/lib/typings/configEntry/common.js +15 -0
- package/lib/typings/configEntry/common.js.map +1 -1
- package/lib/typings/configEntry/module.d.ts +10 -29
- package/lib/typings/configEntry/package.d.ts +2 -1
- package/lib/ui/commander.js +1 -1
- package/lib/ui/commander.js.map +1 -1
- package/lib/utils/applyTemplate.js.map +1 -1
- package/lib/utils/detectPortSync.d.ts +1 -0
- package/lib/utils/detectPortSync.js +10 -0
- package/lib/utils/detectPortSync.js.map +1 -0
- package/lib/utils/safeRequire.js +5 -1
- package/lib/utils/safeRequire.js.map +1 -1
- package/lib/utils/webpackBuild.d.ts +2 -1
- package/lib/utils/webpackBuild.js +3 -3
- package/lib/utils/webpackBuild.js.map +1 -1
- package/package.json +14 -9
- package/schema.json +1802 -2068
- package/src/api/analyze/providers/shared.ts +3 -2
- package/src/api/benchmark/__integration__/__fixtures__/tramvai.json +1 -8
- package/src/api/benchmark/index.ts +1 -1
- package/src/api/build/__integration__/__fixtures__/app/App.tsx +0 -1
- package/src/api/build/__integration__/__fixtures__/app/index.tsx +14 -8
- package/src/api/build/__integration__/__fixtures__/app/server.tsx +0 -1
- package/src/api/build/__integration__/__fixtures__/tramvai.json +1 -10
- package/src/api/build/__integration__/build.test.ts +4 -13
- package/src/api/build/child-app.ts +4 -4
- package/src/api/build/module.ts +2 -4
- package/src/api/build/providers/shared.ts +2 -2
- package/src/api/index.ts +6 -2
- package/src/api/shared/types/withConfig.ts +5 -6
- package/src/api/start/__integration__/__fixtures__/app/index.tsx +11 -7
- package/src/api/start/__integration__/__fixtures__/tramvai.json +6 -17
- package/src/api/start/__integration__/start.test.ts +38 -13
- package/src/api/start/providers/application/server.ts +14 -23
- package/src/api/start/providers/application/shared.ts +26 -52
- package/src/api/start/providers/child-app/shared.ts +23 -46
- package/src/api/start/providers/module/shared.ts +24 -47
- package/src/api/start/utils/banner.ts +3 -2
- package/src/api/start/utils/listenServer.ts +2 -1
- package/src/api/start/utils/tips/tips.ts +11 -8
- package/src/api/start-prod/providers/application.ts +19 -19
- package/src/api/start-prod/providers/child-app.ts +7 -8
- package/src/api/start-prod/providers/shared.ts +6 -20
- package/src/builder/webpack/devServer/client.ts +22 -15
- package/src/builder/webpack/devServer/notifier.ts +6 -6
- package/src/builder/webpack/devServer/pool/process/pool.ts +3 -3
- package/src/builder/webpack/devServer/pool/thread/pool.ts +7 -0
- package/src/builder/webpack/devServer/server.ts +13 -6
- package/src/builder/webpack/providers/analyze/shared.ts +3 -2
- package/src/builder/webpack/providers/build/application/server.ts +5 -1
- package/src/builder/webpack/providers/build/client.ts +2 -2
- package/src/builder/webpack/providers/build/server.ts +1 -1
- package/src/builder/webpack/tokens.ts +4 -3
- package/src/builder/webpack/utils/copyBuildFile.ts +4 -5
- package/src/builder/webpack/utils/copyStatsJsonFile.ts +5 -2
- package/src/cli/CLI.ts +6 -6
- package/src/cli/index.ts +1 -1
- package/src/commands/analyze/command.ts +1 -1
- package/src/commands/benchmark/command.ts +1 -1
- package/src/commands/build/command.ts +2 -2
- package/src/commands/new/new.ts +0 -1
- package/src/commands/new/questions/packageManager.ts +1 -1
- package/src/commands/new/questions/template.ts +1 -1
- package/src/commands/new/questions/testingFramework.ts +1 -1
- package/src/commands/new/questions/type.ts +1 -1
- package/src/commands/new/steps/initializationGit.ts +1 -1
- package/src/commands/new/templates/app/monorepo/tramvai.json.hbs +6 -32
- package/src/commands/new/templates/app/multirepo/tramvai.json.hbs +6 -23
- package/src/commands/new/templates/child-app/monorepo/tramvai.json.hbs +3 -18
- package/src/commands/new/templates/child-app/multirepo/tramvai.json.hbs +3 -9
- package/src/commands/start/command.ts +2 -2
- package/src/commands/start-prod/command.ts +2 -2
- package/src/commands/static/application.ts +5 -14
- package/src/commands/static/command.ts +1 -1
- package/src/commands/static/generate.ts +2 -2
- package/src/commands/static/server.ts +5 -2
- package/src/commands/static/staticServer.ts +6 -3
- package/src/commands/update/updatePackageJson.ts +6 -2
- package/src/config/configManager.spec.ts +49 -0
- package/src/config/configManager.ts +129 -197
- package/src/config/showConfig.ts +2 -2
- package/src/config/validate.ts +14 -25
- package/src/di/tokens/config.ts +2 -1
- package/src/library/babel/index.ts +1 -0
- package/src/library/swc/__integration__/swc.build.test.ts +3 -21
- package/src/library/swc/__integration__/swc.start.test.ts +3 -21
- package/src/library/swc/index.ts +1 -1
- package/src/library/webpack/application/client/common.ts +7 -7
- package/src/library/webpack/application/client/dev.ts +9 -9
- package/src/library/webpack/application/client/prod/optimization/splitChunks.ts +43 -44
- package/src/library/webpack/application/client/prod.ts +3 -5
- package/src/library/webpack/application/server/common.ts +5 -8
- package/src/library/webpack/application/server/dev.ts +5 -6
- package/src/library/webpack/application/server/prod.ts +3 -9
- package/src/library/webpack/blocks/apiResolve.ts +1 -1
- package/src/library/webpack/blocks/configResolve.ts +2 -2
- package/src/library/webpack/blocks/configToEnv.ts +5 -2
- package/src/library/webpack/blocks/css.ts +26 -17
- package/src/library/webpack/blocks/extractCssPlugin.ts +11 -10
- package/src/library/webpack/blocks/filesClient.ts +52 -50
- package/src/library/webpack/blocks/filesServer.ts +4 -3
- package/src/library/webpack/blocks/js.ts +3 -2
- package/src/library/webpack/blocks/nodeClient.ts +4 -3
- package/src/library/webpack/blocks/optimize.ts +5 -6
- package/src/library/webpack/blocks/pagesResolve.ts +1 -1
- package/src/library/webpack/blocks/postcssAssets.ts +6 -7
- package/src/library/webpack/blocks/serverInline.ts +2 -1
- package/src/library/webpack/blocks/ts.ts +2 -1
- package/src/library/webpack/child-app/client/common.ts +3 -3
- package/src/library/webpack/child-app/client/dev.ts +8 -8
- package/src/library/webpack/child-app/client/prod.ts +2 -2
- package/src/library/webpack/child-app/common.ts +2 -2
- package/src/library/webpack/child-app/server/common.ts +3 -3
- package/src/library/webpack/child-app/server/dev.ts +2 -2
- package/src/library/webpack/child-app/server/prod.ts +2 -2
- package/src/library/webpack/common/client/prod.ts +10 -6
- package/src/library/webpack/common/main.ts +9 -4
- package/src/library/webpack/common/server/prod.ts +10 -6
- package/src/library/webpack/index.ts +2 -3
- package/src/library/webpack/loaders/image-loader/index.ts +2 -1
- package/src/library/webpack/loaders/pagesResolve.ts +17 -5
- package/src/library/webpack/loaders/replaceContent.ts +11 -2
- package/src/library/webpack/module/client/common.ts +1 -1
- package/src/library/webpack/module/externals.ts +1 -1
- package/src/library/webpack/module/resolveExternal.ts +1 -1
- package/src/library/webpack/module/server/common.ts +1 -1
- package/src/library/webpack/plugins/LazyModuleInitialization.ts +6 -1
- package/src/library/webpack/plugins/WebpackBar/utils/index.ts +8 -8
- package/src/library/webpack/plugins/WebpackBar/utils/webpack.ts +1 -1
- package/src/library/webpack/types/webpack.ts +2 -2
- package/src/library/webpack/utils/files.ts +4 -3
- package/src/library/webpack/utils/transpiler.ts +6 -11
- package/src/library/webpack/utils/workersPool.ts +6 -9
- package/src/models/config.spec.ts +352 -0
- package/src/models/config.ts +41 -9
- package/src/schema/ConfigSchema.ts +15 -4
- package/src/schema/autogeneratedSchema.json +1808 -2074
- package/src/schema/tramvai.spec.ts +89 -184
- package/src/typings/configEntry/application.ts +85 -87
- package/src/typings/configEntry/child-app.ts +10 -30
- package/src/typings/configEntry/cli.ts +271 -0
- package/src/typings/configEntry/common.ts +26 -278
- package/src/typings/configEntry/module.ts +11 -30
- package/src/typings/configEntry/package.ts +3 -1
- package/src/ui/commander.ts +1 -1
- package/src/utils/applyTemplate.ts +2 -2
- package/src/utils/detectPortSync.ts +7 -0
- package/src/utils/safeRequire.ts +6 -1
- package/src/utils/webpackBuild.ts +4 -3
- package/lib/library/webpack/plugins/DedupePlugin/DedupePlugin.d.ts +0 -37
- package/lib/library/webpack/plugins/DedupePlugin/DedupePlugin.js +0 -241
- package/lib/library/webpack/plugins/DedupePlugin/DedupePlugin.js.map +0 -1
- package/lib/library/webpack/plugins/DedupePlugin/index.d.ts +0 -1
- package/lib/library/webpack/plugins/DedupePlugin/index.js +0 -6
- package/lib/library/webpack/plugins/DedupePlugin/index.js.map +0 -1
- package/lib/typings/configEntry/CheckAsyncTsConfig.d.ts +0 -13
- package/lib/typings/configEntry/CheckAsyncTsConfig.js.map +0 -1
- package/src/library/webpack/plugins/DedupePlugin/DedupePlugin.spec.ts +0 -95
- package/src/library/webpack/plugins/DedupePlugin/DedupePlugin.ts +0 -307
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-1/index.js +0 -3
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-1/node_modules/package-dep/index.js +0 -1
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-1/node_modules/package-dep/package.json +0 -7
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-1/package.json +0 -7
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-2/index.js +0 -3
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-2/node_modules/package-dep/index.js +0 -1
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-2/node_modules/package-dep/package.json +0 -7
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-2/package.json +0 -7
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-3/index.js +0 -3
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-3/node_modules/package-dep/index.js +0 -1
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-3/node_modules/package-dep/package.json +0 -7
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-3/package.json +0 -7
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-dep/index.js +0 -1
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-dep/package.json +0 -7
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-1/index.js +0 -3
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-1/node_modules/package-esm-dep/index.js +0 -1
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-1/node_modules/package-esm-dep/package.json +0 -8
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-1/package.json +0 -8
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-2/index.js +0 -3
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-2/node_modules/package-esm-dep/index.js +0 -1
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-2/node_modules/package-esm-dep/package.json +0 -8
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-2/package.json +0 -8
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/package-lock.json +0 -0
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/package.json +0 -14
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/src/index.js +0 -9
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/tramvai.json +0 -67
- package/src/library/webpack/plugins/DedupePlugin/__integration__/DedupePlugin.test.ts +0 -90
- package/src/library/webpack/plugins/DedupePlugin/index.ts +0 -1
- package/src/typings/configEntry/CheckAsyncTsConfig.ts +0 -15
|
@@ -5,13 +5,14 @@ import {
|
|
|
5
5
|
COMMAND_PARAMETERS_TOKEN,
|
|
6
6
|
CONFIG_ENTRY_TOKEN,
|
|
7
7
|
} from '../../../di/tokens';
|
|
8
|
-
import {
|
|
8
|
+
import { createConfigManager } from '../../../config/configManager';
|
|
9
|
+
import type { CliConfigEntry } from '../../../typings/configEntry/cli';
|
|
9
10
|
|
|
10
11
|
export const sharedProviders: readonly Provider[] = [
|
|
11
12
|
provide({
|
|
12
13
|
provide: CONFIG_MANAGER_TOKEN,
|
|
13
14
|
useFactory: ({ configEntry, parameters }) => {
|
|
14
|
-
return
|
|
15
|
+
return createConfigManager(configEntry as CliConfigEntry, {
|
|
15
16
|
...parameters,
|
|
16
17
|
env: 'production',
|
|
17
18
|
buildType: 'client',
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import ReactDOM from 'react-dom';
|
|
3
2
|
import App from './App';
|
|
4
3
|
|
|
@@ -9,12 +8,19 @@ const bundlesMap = {
|
|
|
9
8
|
third: () => import('./bundles/third'),
|
|
10
9
|
};
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (url.searchParams.has('bundle')) {
|
|
15
|
-
bundlesMap[url.searchParams.get('bundle')]().then(({ default: name }) =>
|
|
16
|
-
console.log(`loaded bundle ${name}`)
|
|
17
|
-
);
|
|
11
|
+
if (typeof window === 'undefined') {
|
|
12
|
+
require('./server.tsx')
|
|
18
13
|
}
|
|
19
14
|
|
|
20
|
-
|
|
15
|
+
if (typeof window !== 'undefined') {
|
|
16
|
+
const url = new URL(window.location.href);
|
|
17
|
+
|
|
18
|
+
if (url.searchParams.has('bundle')) {
|
|
19
|
+
bundlesMap[url.searchParams.get('bundle')]().then(({ default: name }) =>
|
|
20
|
+
console.log(`loaded bundle ${name}`)
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
ReactDOM.hydrate(<App />, document.getElementById('root'));
|
|
25
|
+
|
|
26
|
+
}
|
|
@@ -5,16 +5,7 @@
|
|
|
5
5
|
"name": "app",
|
|
6
6
|
"root": "app",
|
|
7
7
|
"type": "application",
|
|
8
|
-
"
|
|
9
|
-
"build": {
|
|
10
|
-
"options": {
|
|
11
|
-
"server": "app/server.tsx"
|
|
12
|
-
},
|
|
13
|
-
"configurations": {
|
|
14
|
-
"modern": false
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
8
|
+
"modern": false
|
|
18
9
|
},
|
|
19
10
|
"module": {
|
|
20
11
|
"name": "module",
|
|
@@ -55,19 +55,10 @@ describe('@tramvai/cli build command', () => {
|
|
|
55
55
|
name: 'app',
|
|
56
56
|
type: 'application',
|
|
57
57
|
root: resolve(FIXTURES_DIR, 'app'),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
configurations: {
|
|
64
|
-
modern: false,
|
|
65
|
-
definePlugin: {
|
|
66
|
-
dev: {
|
|
67
|
-
IS_REACT_APP: true,
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
},
|
|
58
|
+
modern: false,
|
|
59
|
+
define: {
|
|
60
|
+
development: {
|
|
61
|
+
IS_REACT_APP: 'true',
|
|
71
62
|
},
|
|
72
63
|
},
|
|
73
64
|
},
|
|
@@ -2,13 +2,11 @@ import type { Container } from '@tinkoff/dippy';
|
|
|
2
2
|
import type { Result } from './index';
|
|
3
3
|
import { sharedProviders } from './providers/shared';
|
|
4
4
|
import { registerProviders } from '../../utils/di';
|
|
5
|
-
import { ABSTRACT_BUILDER_FACTORY_TOKEN
|
|
5
|
+
import { ABSTRACT_BUILDER_FACTORY_TOKEN } from '../../di/tokens';
|
|
6
6
|
|
|
7
7
|
export const buildChildApp = async (di: Container): Result => {
|
|
8
8
|
registerProviders(di, sharedProviders);
|
|
9
9
|
|
|
10
|
-
const configManager = di.get(CONFIG_MANAGER_TOKEN);
|
|
11
|
-
|
|
12
10
|
const builderFactory = di.get(ABSTRACT_BUILDER_FACTORY_TOKEN);
|
|
13
11
|
const builder = await builderFactory.createBuilder('webpack', {
|
|
14
12
|
options: {
|
|
@@ -18,7 +16,9 @@ export const buildChildApp = async (di: Container): Result => {
|
|
|
18
16
|
});
|
|
19
17
|
|
|
20
18
|
const builderBuild = await builder.build({
|
|
21
|
-
|
|
19
|
+
// child-app either should be built for legacy code always
|
|
20
|
+
// or should be smart loaded depending on browser capabilities
|
|
21
|
+
modern: false,
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
return {
|
package/src/api/build/module.ts
CHANGED
|
@@ -2,13 +2,11 @@ import type { Container } from '@tinkoff/dippy';
|
|
|
2
2
|
import type { Result } from './index';
|
|
3
3
|
import { sharedProviders } from './providers/shared';
|
|
4
4
|
import { registerProviders } from '../../utils/di';
|
|
5
|
-
import { ABSTRACT_BUILDER_FACTORY_TOKEN
|
|
5
|
+
import { ABSTRACT_BUILDER_FACTORY_TOKEN } from '../../di/tokens';
|
|
6
6
|
|
|
7
7
|
export const buildModule = async (di: Container): Result => {
|
|
8
8
|
registerProviders(di, [...sharedProviders]);
|
|
9
9
|
|
|
10
|
-
const configManager = di.get(CONFIG_MANAGER_TOKEN);
|
|
11
|
-
|
|
12
10
|
const builderFactory = di.get(ABSTRACT_BUILDER_FACTORY_TOKEN);
|
|
13
11
|
const builder = await builderFactory.createBuilder('webpack', {
|
|
14
12
|
options: {
|
|
@@ -18,7 +16,7 @@ export const buildModule = async (di: Container): Result => {
|
|
|
18
16
|
});
|
|
19
17
|
|
|
20
18
|
const builderBuild = await builder.build({
|
|
21
|
-
modern:
|
|
19
|
+
modern: false,
|
|
22
20
|
});
|
|
23
21
|
|
|
24
22
|
return {
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
COMMAND_PARAMETERS_TOKEN,
|
|
5
5
|
CONFIG_ENTRY_TOKEN,
|
|
6
6
|
} from '../../../di/tokens';
|
|
7
|
-
import {
|
|
7
|
+
import { createConfigManager } from '../../../config/configManager';
|
|
8
8
|
import type { ApplicationConfigEntry } from '../../../typings/configEntry/application';
|
|
9
9
|
import type { Params } from '../index';
|
|
10
10
|
|
|
@@ -18,7 +18,7 @@ export const sharedProviders: readonly Provider[] = [
|
|
|
18
18
|
configEntry: ApplicationConfigEntry;
|
|
19
19
|
parameters: Params;
|
|
20
20
|
}) => {
|
|
21
|
-
return
|
|
21
|
+
return createConfigManager(configEntry, {
|
|
22
22
|
...parameters,
|
|
23
23
|
env: 'production',
|
|
24
24
|
buildType: 'client',
|
package/src/api/index.ts
CHANGED
|
@@ -14,12 +14,16 @@ import type { AnalyzeCommand } from './analyze';
|
|
|
14
14
|
import type { StartProdCommand } from './start-prod';
|
|
15
15
|
|
|
16
16
|
export * from '../di/tokens';
|
|
17
|
-
export { ConfigManager } from '../config/configManager';
|
|
17
|
+
export { ConfigManager, createConfigManager } from '../config/configManager';
|
|
18
|
+
export { CliConfigEntry } from '../typings/configEntry/cli';
|
|
19
|
+
export { ApplicationConfigEntry } from '../typings/configEntry/application';
|
|
20
|
+
export { ChildAppConfigEntry } from '../typings/configEntry/child-app';
|
|
21
|
+
export { ConvertToSchema } from '../schema/ConfigSchema';
|
|
18
22
|
export { ConfigManager as ConfigManagerValidator } from '../models/config';
|
|
19
23
|
export { getTramvaiConfig } from '../utils/getTramvaiConfig';
|
|
20
24
|
export { syncJsonFile } from '../utils/syncJsonFile';
|
|
21
25
|
export { babelConfigFactory } from '../library/babel';
|
|
22
|
-
export {
|
|
26
|
+
export { filesClientWebpackRulesFactory } from '../library/webpack/blocks/filesClient';
|
|
23
27
|
export { cssWebpackRulesFactory } from '../library/webpack/blocks/css';
|
|
24
28
|
export { lessWebpackRulesFactory } from '../library/webpack/blocks/less';
|
|
25
29
|
export { postcssAssetsWebpackRulesFactory } from '../library/webpack/blocks/postcssAssets';
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
+
import type { WithRootDir } from './withRootDir';
|
|
1
2
|
import type { ApplicationConfigEntry } from '../../../typings/configEntry/application';
|
|
2
3
|
import type { ModuleConfigEntry } from '../../../typings/configEntry/module';
|
|
3
|
-
import type { WithRootDir } from './withRootDir';
|
|
4
4
|
import type { PackageConfigEntry } from '../../../typings/configEntry/package';
|
|
5
5
|
import type { ChildAppConfigEntry } from '../../../typings/configEntry/child-app';
|
|
6
|
+
import type { ConvertToSchema } from '../../../schema/ConfigSchema';
|
|
6
7
|
|
|
7
8
|
export type WithConfig<T> = WithRootDir<T> &
|
|
8
9
|
(
|
|
9
10
|
| { target: string }
|
|
10
11
|
| {
|
|
11
|
-
config:
|
|
12
|
-
|
|
|
13
|
-
|
|
14
|
-
| PackageConfigEntry
|
|
15
|
-
| ChildAppConfigEntry;
|
|
12
|
+
config: ConvertToSchema<
|
|
13
|
+
ApplicationConfigEntry | ModuleConfigEntry | PackageConfigEntry | ChildAppConfigEntry
|
|
14
|
+
>;
|
|
16
15
|
}
|
|
17
16
|
);
|
|
@@ -8,12 +8,16 @@ const bundlesMap = {
|
|
|
8
8
|
third: () => import('./bundles/third'),
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
if (typeof window === 'undefined') {
|
|
12
|
+
require('./server')
|
|
13
|
+
} else {
|
|
14
|
+
const url = new URL(window.location.href);
|
|
12
15
|
|
|
13
|
-
if (url.searchParams.has('bundle')) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
16
|
+
if (url.searchParams.has('bundle')) {
|
|
17
|
+
bundlesMap[
|
|
18
|
+
url.searchParams.get('bundle') as keyof typeof bundlesMap
|
|
19
|
+
]().then(({ default: name }: { default: string }) => console.log(`loaded bundle ${name}`));
|
|
20
|
+
}
|
|
18
21
|
|
|
19
|
-
ReactDOM.hydrate(<App />, document.getElementById('root'));
|
|
22
|
+
ReactDOM.hydrate(<App />, document.getElementById('root'));
|
|
23
|
+
}
|
|
@@ -5,23 +5,12 @@
|
|
|
5
5
|
"name": "app",
|
|
6
6
|
"root": "app",
|
|
7
7
|
"type": "application",
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"configurations": {
|
|
15
|
-
"fileSystemPages": {
|
|
16
|
-
"enable": true
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"serve": {
|
|
21
|
-
"configurations": {
|
|
22
|
-
"hotRefresh": true
|
|
23
|
-
}
|
|
24
|
-
}
|
|
8
|
+
"serverApiDir": "app/api",
|
|
9
|
+
"fileSystemPages": {
|
|
10
|
+
"enabled": true
|
|
11
|
+
},
|
|
12
|
+
"hotRefresh": {
|
|
13
|
+
"enabled": true
|
|
25
14
|
}
|
|
26
15
|
},
|
|
27
16
|
"module": {
|
|
@@ -6,7 +6,10 @@ import type { PromiseType } from 'utility-types';
|
|
|
6
6
|
import { getPort } from '@tramvai/internal-test-utils/utils/getPort';
|
|
7
7
|
import { getServerUrl } from '@tramvai/test-integration';
|
|
8
8
|
import { initPlaywright } from '@tramvai/test-pw';
|
|
9
|
+
import { createServer } from '../utils/createServer';
|
|
10
|
+
import { listenServer } from '../utils/listenServer';
|
|
9
11
|
import { getListeningPort } from '../utils/getListeningPort';
|
|
12
|
+
import { stopServer } from '../utils/stopServer';
|
|
10
13
|
|
|
11
14
|
const FIXTURES_DIR = resolve(__dirname, '__fixtures__');
|
|
12
15
|
|
|
@@ -93,9 +96,7 @@ describe('@tramvai/cli start command', () => {
|
|
|
93
96
|
port: serverPort,
|
|
94
97
|
staticPort: staticServerPort,
|
|
95
98
|
type: 'application',
|
|
96
|
-
|
|
97
|
-
name: 'app',
|
|
98
|
-
}),
|
|
99
|
+
name: 'app',
|
|
99
100
|
});
|
|
100
101
|
|
|
101
102
|
const { body: browserslistConfig } = await request
|
|
@@ -136,8 +137,6 @@ describe('@tramvai/cli start command', () => {
|
|
|
136
137
|
|
|
137
138
|
await page.goto(serverUrl);
|
|
138
139
|
|
|
139
|
-
console.log(await page.$eval('body', (node) => node.innerHTML));
|
|
140
|
-
|
|
141
140
|
expect(
|
|
142
141
|
await page.$eval('#cmp', (node) => (node as HTMLElement).innerText)
|
|
143
142
|
).toMatchInlineSnapshot(`"Cmp test: start"`);
|
|
@@ -173,13 +172,6 @@ describe('@tramvai/cli start command', () => {
|
|
|
173
172
|
name: 'app',
|
|
174
173
|
type: 'application',
|
|
175
174
|
root,
|
|
176
|
-
commands: {
|
|
177
|
-
build: {
|
|
178
|
-
options: {
|
|
179
|
-
server: resolve(root, 'server.tsx'),
|
|
180
|
-
},
|
|
181
|
-
},
|
|
182
|
-
},
|
|
183
175
|
},
|
|
184
176
|
});
|
|
185
177
|
|
|
@@ -267,6 +259,39 @@ describe('@tramvai/cli start command', () => {
|
|
|
267
259
|
|
|
268
260
|
return close();
|
|
269
261
|
});
|
|
262
|
+
|
|
263
|
+
it('should start the app on the next available port, if default port is busy', async () => {
|
|
264
|
+
const testServerStub = createServer();
|
|
265
|
+
const testStaticServerStub = createServer();
|
|
266
|
+
|
|
267
|
+
// To avoid situation when two subsequent calls
|
|
268
|
+
// of the `detectPortSync` return the same free port.
|
|
269
|
+
await listenServer(testServerStub, '0.0.0.0', getPort() + 50);
|
|
270
|
+
await listenServer(testStaticServerStub, '0.0.0.0', getPort());
|
|
271
|
+
|
|
272
|
+
const { server, staticServer, close } = await start({
|
|
273
|
+
rootDir: FIXTURES_DIR,
|
|
274
|
+
target: 'app',
|
|
275
|
+
resolveSymlinks: false,
|
|
276
|
+
port: getListeningPort(testServerStub),
|
|
277
|
+
staticPort: getListeningPort(testStaticServerStub),
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const testServer = supertestByPort(getListeningPort(server));
|
|
281
|
+
const testStatic = supertestByPort(getListeningPort(staticServer));
|
|
282
|
+
|
|
283
|
+
expect(server?.address()).toMatchObject({
|
|
284
|
+
port: expect.any(Number),
|
|
285
|
+
});
|
|
286
|
+
expect(staticServer?.address()).toMatchObject({
|
|
287
|
+
port: expect.any(Number),
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
await testServer.get('/').expect(200);
|
|
291
|
+
await testStatic.get('/').expect(404);
|
|
292
|
+
|
|
293
|
+
return Promise.all([close(), stopServer(testServerStub), stopServer(testStaticServerStub)]);
|
|
294
|
+
});
|
|
270
295
|
});
|
|
271
296
|
|
|
272
297
|
describe('module', () => {
|
|
@@ -288,7 +313,7 @@ describe('@tramvai/cli start command', () => {
|
|
|
288
313
|
});
|
|
289
314
|
|
|
290
315
|
it('should start module by specific config', async () => {
|
|
291
|
-
const staticServerPort =
|
|
316
|
+
const staticServerPort = getPort();
|
|
292
317
|
|
|
293
318
|
const { staticServer, close } = await start({
|
|
294
319
|
config: {
|
|
@@ -1,45 +1,36 @@
|
|
|
1
1
|
import type { Provider } from '@tinkoff/dippy';
|
|
2
|
+
import { provide } from '@tinkoff/dippy';
|
|
3
|
+
|
|
2
4
|
import { INIT_HANDLER_TOKEN, CLOSE_HANDLER_TOKEN } from '../../tokens';
|
|
3
|
-
import {
|
|
5
|
+
import { CONFIG_MANAGER_TOKEN, SERVER_TOKEN } from '../../../../di/tokens';
|
|
4
6
|
import { stopServer } from '../../utils/stopServer';
|
|
5
7
|
import { createServer } from '../../utils/createServer';
|
|
6
8
|
import { listenServer } from '../../utils/listenServer';
|
|
7
|
-
import type { Params } from '../../index';
|
|
8
9
|
|
|
9
10
|
export const serverProviders: readonly Provider[] = [
|
|
10
|
-
{
|
|
11
|
+
provide({
|
|
11
12
|
provide: SERVER_TOKEN,
|
|
12
13
|
useFactory: createServer,
|
|
13
|
-
},
|
|
14
|
-
{
|
|
14
|
+
}),
|
|
15
|
+
provide({
|
|
15
16
|
provide: INIT_HANDLER_TOKEN,
|
|
16
17
|
multi: true,
|
|
17
|
-
useFactory: ({ server,
|
|
18
|
+
useFactory: ({ server, configManager }) => {
|
|
18
19
|
return async function staticServerListen() {
|
|
19
|
-
const { host
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
await listenServer(server, host, port);
|
|
23
|
-
} catch (error) {
|
|
24
|
-
if ((error as any).code === 'EADDRINUSE') {
|
|
25
|
-
throw new Error(
|
|
26
|
-
`Address '${host}:${port}' in use, either release this port or use options --port --host`
|
|
27
|
-
);
|
|
28
|
-
}
|
|
20
|
+
const { host, port } = configManager;
|
|
29
21
|
|
|
30
|
-
|
|
31
|
-
}
|
|
22
|
+
await listenServer(server, host, port);
|
|
32
23
|
};
|
|
33
24
|
},
|
|
34
25
|
deps: {
|
|
35
26
|
server: SERVER_TOKEN,
|
|
36
|
-
|
|
27
|
+
configManager: CONFIG_MANAGER_TOKEN,
|
|
37
28
|
},
|
|
38
|
-
},
|
|
39
|
-
{
|
|
29
|
+
}),
|
|
30
|
+
provide({
|
|
40
31
|
provide: CLOSE_HANDLER_TOKEN,
|
|
41
32
|
multi: true,
|
|
42
|
-
useFactory: ({ server }
|
|
33
|
+
useFactory: ({ server }) => {
|
|
43
34
|
return () => {
|
|
44
35
|
return stopServer(server);
|
|
45
36
|
};
|
|
@@ -47,5 +38,5 @@ export const serverProviders: readonly Provider[] = [
|
|
|
47
38
|
deps: {
|
|
48
39
|
server: SERVER_TOKEN,
|
|
49
40
|
},
|
|
50
|
-
},
|
|
41
|
+
}),
|
|
51
42
|
] as const;
|
|
@@ -1,88 +1,62 @@
|
|
|
1
1
|
import type { Provider } from '@tinkoff/dippy';
|
|
2
|
+
import { provide } from '@tinkoff/dippy';
|
|
3
|
+
|
|
2
4
|
import { CLOSE_HANDLER_TOKEN, INIT_HANDLER_TOKEN } from '../../tokens';
|
|
3
5
|
import {
|
|
4
6
|
CONFIG_MANAGER_TOKEN,
|
|
5
7
|
CONFIG_ENTRY_TOKEN,
|
|
6
8
|
COMMAND_PARAMETERS_TOKEN,
|
|
7
|
-
SERVER_TOKEN,
|
|
8
9
|
STATIC_SERVER_TOKEN,
|
|
9
10
|
} from '../../../../di/tokens';
|
|
10
11
|
import { stopServer } from '../../utils/stopServer';
|
|
11
12
|
import type { ApplicationConfigEntry } from '../../../../typings/configEntry/application';
|
|
12
|
-
import
|
|
13
|
-
|
|
13
|
+
import {
|
|
14
|
+
createConfigManager,
|
|
15
|
+
DEFAULT_PORT,
|
|
16
|
+
DEFAULT_STATIC_PORT,
|
|
17
|
+
} from '../../../../config/configManager';
|
|
14
18
|
import { createServer } from '../../utils/createServer';
|
|
15
19
|
import { listenServer } from '../../utils/listenServer';
|
|
16
|
-
import {
|
|
20
|
+
import { detectPortSync } from '../../../../utils/detectPortSync';
|
|
17
21
|
|
|
18
22
|
export const sharedProviders: readonly Provider[] = [
|
|
19
|
-
{
|
|
23
|
+
provide({
|
|
20
24
|
provide: CONFIG_MANAGER_TOKEN,
|
|
21
|
-
useFactory: ({
|
|
22
|
-
configEntry,
|
|
23
|
-
parameters,
|
|
24
|
-
server,
|
|
25
|
-
staticServer,
|
|
26
|
-
}: {
|
|
27
|
-
configEntry: ApplicationConfigEntry;
|
|
28
|
-
parameters: Params;
|
|
29
|
-
server: typeof SERVER_TOKEN;
|
|
30
|
-
staticServer: typeof STATIC_SERVER_TOKEN;
|
|
31
|
-
}) => {
|
|
32
|
-
return new ConfigManager(configEntry, {
|
|
25
|
+
useFactory: ({ configEntry, parameters }) =>
|
|
26
|
+
createConfigManager(configEntry as ApplicationConfigEntry, {
|
|
33
27
|
...parameters,
|
|
34
28
|
env: 'development',
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
39
|
-
},
|
|
29
|
+
port: detectPortSync(parameters.port ?? DEFAULT_PORT),
|
|
30
|
+
staticPort: detectPortSync(parameters.staticPort ?? DEFAULT_STATIC_PORT),
|
|
31
|
+
}),
|
|
40
32
|
deps: {
|
|
41
33
|
configEntry: CONFIG_ENTRY_TOKEN,
|
|
42
34
|
parameters: COMMAND_PARAMETERS_TOKEN,
|
|
43
|
-
staticServer: STATIC_SERVER_TOKEN,
|
|
44
|
-
server: { token: SERVER_TOKEN, optional: true },
|
|
45
35
|
},
|
|
46
|
-
},
|
|
47
|
-
{
|
|
36
|
+
}),
|
|
37
|
+
provide({
|
|
48
38
|
provide: STATIC_SERVER_TOKEN,
|
|
49
39
|
useFactory: createServer,
|
|
50
|
-
},
|
|
51
|
-
{
|
|
40
|
+
}),
|
|
41
|
+
provide({
|
|
52
42
|
provide: INIT_HANDLER_TOKEN,
|
|
53
43
|
multi: true,
|
|
54
|
-
useFactory: ({
|
|
55
|
-
staticServer,
|
|
56
|
-
parameters,
|
|
57
|
-
}: {
|
|
58
|
-
staticServer: typeof STATIC_SERVER_TOKEN;
|
|
59
|
-
parameters: Params;
|
|
60
|
-
}) => {
|
|
44
|
+
useFactory: ({ configManager, staticServer }) => {
|
|
61
45
|
return async function staticServerListen() {
|
|
62
|
-
const { staticHost
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
await listenServer(staticServer, staticHost.replace('localhost', '0.0.0.0'), staticPort);
|
|
66
|
-
} catch (error) {
|
|
67
|
-
if ((error as any).code === 'EADDRINUSE') {
|
|
68
|
-
throw new Error(
|
|
69
|
-
`Address '${staticHost}:${staticPort}' in use, either release this port or use options --staticPort --staticHost`
|
|
70
|
-
);
|
|
71
|
-
}
|
|
46
|
+
const { staticHost, staticPort } = configManager;
|
|
72
47
|
|
|
73
|
-
|
|
74
|
-
}
|
|
48
|
+
await listenServer(staticServer, staticHost.replace('localhost', '0.0.0.0'), staticPort);
|
|
75
49
|
};
|
|
76
50
|
},
|
|
77
51
|
deps: {
|
|
78
52
|
staticServer: STATIC_SERVER_TOKEN,
|
|
79
|
-
|
|
53
|
+
configManager: CONFIG_MANAGER_TOKEN,
|
|
80
54
|
},
|
|
81
|
-
},
|
|
82
|
-
{
|
|
55
|
+
}),
|
|
56
|
+
provide({
|
|
83
57
|
provide: CLOSE_HANDLER_TOKEN,
|
|
84
58
|
multi: true,
|
|
85
|
-
useFactory: ({ staticServer }
|
|
59
|
+
useFactory: ({ staticServer }) => {
|
|
86
60
|
return () => {
|
|
87
61
|
return stopServer(staticServer);
|
|
88
62
|
};
|
|
@@ -90,5 +64,5 @@ export const sharedProviders: readonly Provider[] = [
|
|
|
90
64
|
deps: {
|
|
91
65
|
staticServer: STATIC_SERVER_TOKEN,
|
|
92
66
|
},
|
|
93
|
-
},
|
|
67
|
+
}),
|
|
94
68
|
] as const;
|