@tramvai/cli 5.50.0 → 5.53.78
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/__migrations__/d2023-02-01b-tramvai-config-refactoring.js +78 -80
- package/__migrations__/d2025-04-11b-tramvai-config-remove-modern.js +13 -0
- package/bin/spawn.js +69 -3
- package/lib/api/analyze/index.d.ts +0 -1
- package/lib/api/analyze/index.d.ts.map +1 -1
- package/lib/api/analyze/index.js +2 -2
- package/lib/api/analyze/index.js.map +1 -1
- package/lib/api/build/application.d.ts.map +1 -1
- package/lib/api/build/application.js +2 -5
- package/lib/api/build/application.js.map +1 -1
- package/lib/api/build/child-app.d.ts.map +1 -1
- package/lib/api/build/child-app.js +1 -5
- package/lib/api/build/child-app.js.map +1 -1
- package/lib/api/build/index.d.ts +0 -2
- package/lib/api/build/index.d.ts.map +1 -1
- package/lib/api/build/index.js.map +1 -1
- package/lib/api/build/module.d.ts.map +1 -1
- package/lib/api/build/module.js +1 -3
- package/lib/api/build/module.js.map +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +0 -4
- package/lib/api/index.js.map +1 -1
- package/lib/api/start/index.d.ts +0 -1
- package/lib/api/start/index.d.ts.map +1 -1
- package/lib/api/start/index.js.map +1 -1
- package/lib/api/start/utils/banner.d.ts.map +1 -1
- package/lib/api/start/utils/banner.js +0 -1
- package/lib/api/start/utils/banner.js.map +1 -1
- package/lib/api/start/utils/tips/tips.d.ts.map +1 -1
- package/lib/api/start/utils/tips/tips.js +0 -8
- package/lib/api/start/utils/tips/tips.js.map +1 -1
- package/lib/builder/webpack/devServer/pool/process/pool.d.ts.map +1 -1
- package/lib/builder/webpack/devServer/pool/process/pool.js +0 -2
- package/lib/builder/webpack/devServer/pool/process/pool.js.map +1 -1
- package/lib/builder/webpack/devServer/server.d.ts.map +1 -1
- package/lib/builder/webpack/devServer/server.js +4 -0
- package/lib/builder/webpack/devServer/server.js.map +1 -1
- package/lib/builder/webpack/index.d.ts.map +1 -1
- package/lib/builder/webpack/index.js +3 -5
- package/lib/builder/webpack/index.js.map +1 -1
- package/lib/builder/webpack/providers/build/client.d.ts.map +1 -1
- package/lib/builder/webpack/providers/build/client.js +0 -1
- package/lib/builder/webpack/providers/build/client.js.map +1 -1
- package/lib/builder/webpack/providers/build/clientShared.d.ts.map +1 -1
- package/lib/builder/webpack/providers/build/clientShared.js +4 -6
- package/lib/builder/webpack/providers/build/clientShared.js.map +1 -1
- package/lib/builder/webpack/providers/client.d.ts.map +1 -1
- package/lib/builder/webpack/providers/client.js +0 -13
- package/lib/builder/webpack/providers/client.js.map +1 -1
- package/lib/builder/webpack/providers/shared.d.ts.map +1 -1
- package/lib/builder/webpack/providers/shared.js +2 -8
- package/lib/builder/webpack/providers/shared.js.map +1 -1
- package/lib/builder/webpack/tokens.d.ts +4 -139
- package/lib/builder/webpack/tokens.d.ts.map +1 -1
- package/lib/builder/webpack/tokens.js +1 -4
- package/lib/builder/webpack/tokens.js.map +1 -1
- package/lib/builder/webpack/utils/copyStatsJsonFile.d.ts.map +1 -1
- package/lib/builder/webpack/utils/copyStatsJsonFile.js +0 -11
- package/lib/builder/webpack/utils/copyStatsJsonFile.js.map +1 -1
- package/lib/cli/CLI.d.ts +2 -2
- package/lib/cli/CLI.d.ts.map +1 -1
- package/lib/cli/CLI.js +2 -2
- package/lib/cli/CLI.js.map +1 -1
- package/lib/cli/index.d.ts.map +1 -1
- package/lib/cli/index.js +28 -7
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/runCLI.d.ts +3 -0
- package/lib/cli/runCLI.d.ts.map +1 -1
- package/lib/cli/runCLI.js +18 -6
- package/lib/cli/runCLI.js.map +1 -1
- package/lib/commands/build/command.d.ts +1 -1
- package/lib/commands/build/command.d.ts.map +1 -1
- package/lib/commands/build/command.js +41 -13
- package/lib/commands/build/command.js.map +1 -1
- package/lib/commands/createApp.d.ts.map +1 -1
- package/lib/commands/createApp.js +0 -1
- package/lib/commands/createApp.js.map +1 -1
- package/lib/commands/new/new.d.ts.map +1 -1
- package/lib/commands/new/new.js +28 -3
- package/lib/commands/new/new.js.map +1 -1
- package/lib/commands/start/command.d.ts +1 -1
- package/lib/commands/start/command.d.ts.map +1 -1
- package/lib/commands/start/command.js +39 -7
- package/lib/commands/start/command.js.map +1 -1
- package/lib/commands/start/start.d.ts +1 -1
- package/lib/commands/start/start.d.ts.map +1 -1
- package/lib/commands/start/start.js +2 -1
- package/lib/commands/start/start.js.map +1 -1
- package/lib/commands/static/application.d.ts.map +1 -1
- package/lib/commands/static/application.js +0 -1
- package/lib/commands/static/application.js.map +1 -1
- package/lib/commands/update/command.d.ts +6 -1
- package/lib/commands/update/command.d.ts.map +1 -1
- package/lib/commands/update/command.js +8 -1
- package/lib/commands/update/command.js.map +1 -1
- package/lib/commands/update/dependantLibs.d.ts +2 -1
- package/lib/commands/update/dependantLibs.d.ts.map +1 -1
- package/lib/commands/update/dependantLibs.js +17 -4
- package/lib/commands/update/dependantLibs.js.map +1 -1
- package/lib/commands/update/update.d.ts +2 -1
- package/lib/commands/update/update.d.ts.map +1 -1
- package/lib/commands/update/update.js +6 -6
- package/lib/commands/update/update.js.map +1 -1
- package/lib/commands/update/updatePackageJson.d.ts +1 -1
- package/lib/commands/update/updatePackageJson.d.ts.map +1 -1
- package/lib/commands/update/updatePackageJson.js +10 -14
- package/lib/commands/update/updatePackageJson.js.map +1 -1
- package/lib/config/configManager.d.ts +0 -1
- package/lib/config/configManager.d.ts.map +1 -1
- package/lib/config/configManager.js +2 -17
- package/lib/config/configManager.js.map +1 -1
- package/lib/config/validate.d.ts.map +1 -1
- package/lib/config/validate.js +8 -1
- package/lib/config/validate.js.map +1 -1
- package/lib/di/providers/index.d.ts +0 -1
- package/lib/di/providers/index.d.ts.map +1 -1
- package/lib/di/providers/index.js +0 -1
- package/lib/di/providers/index.js.map +1 -1
- package/lib/di/tokens/config.d.ts +2 -0
- package/lib/di/tokens/config.d.ts.map +1 -1
- package/lib/di/tokens/index.d.ts +0 -1
- package/lib/di/tokens/index.d.ts.map +1 -1
- package/lib/di/tokens/index.js +0 -1
- package/lib/di/tokens/index.js.map +1 -1
- package/lib/library/babel/index.d.ts +0 -44
- package/lib/library/babel/index.d.ts.map +1 -1
- package/lib/library/babel/index.js +6 -13
- 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/typescript/index.d.ts +0 -23
- package/lib/library/typescript/index.d.ts.map +1 -1
- package/lib/library/typescript/index.js +1 -2
- package/lib/library/typescript/index.js.map +1 -1
- package/lib/library/webpack/application/client/common.d.ts.map +1 -1
- package/lib/library/webpack/application/client/common.js +40 -6
- package/lib/library/webpack/application/client/common.js.map +1 -1
- package/lib/library/webpack/application/client/dev.js +2 -2
- package/lib/library/webpack/application/client/dev.js.map +1 -1
- package/lib/library/webpack/application/client/prod.d.ts.map +1 -1
- package/lib/library/webpack/application/client/prod.js +1 -2
- package/lib/library/webpack/application/client/prod.js.map +1 -1
- package/lib/library/webpack/application/common.js +1 -1
- package/lib/library/webpack/application/common.js.map +1 -1
- package/lib/library/webpack/application/server/common.js +1 -1
- package/lib/library/webpack/application/server/common.js.map +1 -1
- package/lib/library/webpack/application/server/dev.js +1 -1
- package/lib/library/webpack/application/server/dev.js.map +1 -1
- package/lib/library/webpack/application/server/prod.js +1 -1
- package/lib/library/webpack/application/server/prod.js.map +1 -1
- package/lib/library/webpack/blocks/css.d.ts.map +1 -1
- package/lib/library/webpack/blocks/css.js +15 -11
- package/lib/library/webpack/blocks/css.js.map +1 -1
- package/lib/library/webpack/blocks/optimize.js +2 -2
- package/lib/library/webpack/blocks/optimize.js.map +1 -1
- package/lib/library/webpack/blocks/pwa/client.d.ts.map +1 -1
- package/lib/library/webpack/blocks/pwa/client.js +2 -5
- package/lib/library/webpack/blocks/pwa/client.js.map +1 -1
- package/lib/library/webpack/blocks/pwa/shared.d.ts.map +1 -1
- package/lib/library/webpack/blocks/pwa/shared.js +2 -3
- package/lib/library/webpack/blocks/pwa/shared.js.map +1 -1
- package/lib/library/webpack/blocks/resolve.js +2 -2
- package/lib/library/webpack/blocks/resolve.js.map +1 -1
- package/lib/library/webpack/blocks/serverInline.d.ts.map +1 -1
- package/lib/library/webpack/blocks/serverInline.js +1 -2
- package/lib/library/webpack/blocks/serverInline.js.map +1 -1
- package/lib/library/webpack/blocks/sourcemaps.d.ts +1 -1
- package/lib/library/webpack/blocks/sourcemaps.d.ts.map +1 -1
- package/lib/library/webpack/blocks/sourcemaps.js +4 -2
- package/lib/library/webpack/blocks/sourcemaps.js.map +1 -1
- package/lib/library/webpack/child-app/client/common.d.ts.map +1 -1
- package/lib/library/webpack/child-app/client/common.js +8 -3
- package/lib/library/webpack/child-app/client/common.js.map +1 -1
- package/lib/library/webpack/child-app/client/dev.d.ts.map +1 -1
- package/lib/library/webpack/child-app/client/dev.js +5 -1
- package/lib/library/webpack/child-app/client/dev.js.map +1 -1
- package/lib/library/webpack/child-app/client/prod.d.ts.map +1 -1
- package/lib/library/webpack/child-app/client/prod.js +4 -0
- package/lib/library/webpack/child-app/client/prod.js.map +1 -1
- package/lib/library/webpack/child-app/common.d.ts.map +1 -1
- package/lib/library/webpack/child-app/common.js +1 -5
- package/lib/library/webpack/child-app/common.js.map +1 -1
- package/lib/library/webpack/child-app/server/dev.d.ts.map +1 -1
- package/lib/library/webpack/child-app/server/dev.js +4 -0
- package/lib/library/webpack/child-app/server/dev.js.map +1 -1
- package/lib/library/webpack/child-app/server/prod.d.ts.map +1 -1
- package/lib/library/webpack/child-app/server/prod.js +4 -0
- package/lib/library/webpack/child-app/server/prod.js.map +1 -1
- package/lib/library/webpack/common/client/prod.js +1 -1
- package/lib/library/webpack/common/client/prod.js.map +1 -1
- package/lib/library/webpack/common/main.d.ts.map +1 -1
- package/lib/library/webpack/common/main.js +1 -2
- package/lib/library/webpack/common/main.js.map +1 -1
- package/lib/library/webpack/constants/stats.d.ts.map +1 -1
- package/lib/library/webpack/constants/stats.js +2 -0
- package/lib/library/webpack/constants/stats.js.map +1 -1
- package/lib/library/webpack/loaders/image-loader/getImageMiniatureURL.js +1 -1
- package/lib/library/webpack/loaders/image-loader/getImageMiniatureURL.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.js +1 -1
- package/lib/library/webpack/module/externals.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/AssetsIntegritiesPlugin.d.ts +8 -0
- package/lib/library/webpack/plugins/AssetsIntegritiesPlugin.d.ts.map +1 -0
- package/lib/library/webpack/plugins/AssetsIntegritiesPlugin.js +29 -0
- package/lib/library/webpack/plugins/AssetsIntegritiesPlugin.js.map +1 -0
- package/lib/library/webpack/plugins/PurifyStatsPlugin.d.ts +15 -0
- package/lib/library/webpack/plugins/PurifyStatsPlugin.d.ts.map +1 -0
- package/lib/library/webpack/plugins/PurifyStatsPlugin.js +47 -0
- package/lib/library/webpack/plugins/PurifyStatsPlugin.js.map +1 -0
- package/lib/library/webpack/plugins/RuntimePathPlugin.d.ts.map +1 -1
- package/lib/library/webpack/plugins/RuntimePathPlugin.js +7 -3
- package/lib/library/webpack/plugins/RuntimePathPlugin.js.map +1 -1
- package/lib/library/webpack/utils/transpiler.d.ts +0 -1
- package/lib/library/webpack/utils/transpiler.d.ts.map +1 -1
- package/lib/library/webpack/utils/transpiler.js +1 -5
- package/lib/library/webpack/utils/transpiler.js.map +1 -1
- package/lib/models/analytics/analytics.d.ts +156 -0
- package/lib/models/analytics/analytics.d.ts.map +1 -0
- package/lib/models/analytics/analytics.js +259 -0
- package/lib/models/analytics/analytics.js.map +1 -0
- package/lib/models/analytics/analytics.worker.d.ts +5 -0
- package/lib/models/analytics/analytics.worker.d.ts.map +1 -0
- package/lib/models/analytics/analytics.worker.js +87 -0
- package/lib/models/analytics/analytics.worker.js.map +1 -0
- package/lib/models/analytics/utils.d.ts +15 -0
- package/lib/models/analytics/utils.d.ts.map +1 -0
- package/lib/models/analytics/utils.js +85 -0
- package/lib/models/analytics/utils.js.map +1 -0
- package/lib/models/command.d.ts.map +1 -1
- package/lib/models/command.js +1 -7
- package/lib/models/command.js.map +1 -1
- package/lib/models/context.d.ts +4 -4
- package/lib/models/context.d.ts.map +1 -1
- package/lib/models/context.js +3 -2
- package/lib/models/context.js.map +1 -1
- package/lib/models/logger.d.ts +1 -0
- package/lib/models/logger.d.ts.map +1 -1
- package/lib/models/logger.js +2 -1
- package/lib/models/logger.js.map +1 -1
- package/lib/models/task.d.ts.map +1 -1
- package/lib/models/task.js +1 -7
- package/lib/models/task.js.map +1 -1
- package/lib/schema/autogeneratedSchema.json +161 -20
- package/lib/schema/topLevelSchema.d.ts +14 -0
- package/lib/schema/topLevelSchema.d.ts.map +1 -1
- package/lib/schema/topLevelSchema.js +14 -0
- package/lib/schema/topLevelSchema.js.map +1 -1
- package/lib/typings/build/Builder.d.ts +2 -6
- package/lib/typings/build/Builder.d.ts.map +1 -1
- package/lib/typings/configEntry/application.d.ts +10 -5
- package/lib/typings/configEntry/application.d.ts.map +1 -1
- package/lib/typings/configEntry/cli.d.ts +13 -0
- package/lib/typings/configEntry/cli.d.ts.map +1 -1
- package/lib/typings/projectType.d.ts +5 -0
- package/lib/typings/projectType.d.ts.map +1 -1
- package/lib/typings/target.d.ts +1 -1
- package/lib/typings/target.d.ts.map +1 -1
- package/lib/utils/commands/dependencies/findTramvaiVersion.d.ts +1 -1
- package/lib/utils/commands/dependencies/findTramvaiVersion.d.ts.map +1 -1
- package/lib/utils/commands/dependencies/findTramvaiVersion.js +4 -11
- package/lib/utils/commands/dependencies/findTramvaiVersion.js.map +1 -1
- package/lib/utils/commands/dependencies/getLatestPackageVersion.d.ts +1 -1
- package/lib/utils/commands/dependencies/getLatestPackageVersion.d.ts.map +1 -1
- package/lib/utils/commands/dependencies/getLatestPackageVersion.js +7 -3
- package/lib/utils/commands/dependencies/getLatestPackageVersion.js.map +1 -1
- package/lib/utils/cpu-profile.d.ts +3 -0
- package/lib/utils/cpu-profile.d.ts.map +1 -1
- package/lib/utils/cpu-profile.js +8 -3
- package/lib/utils/cpu-profile.js.map +1 -1
- package/lib/utils/errors.d.ts +7 -0
- package/lib/utils/errors.d.ts.map +1 -0
- package/lib/utils/errors.js +43 -0
- package/lib/utils/errors.js.map +1 -0
- package/lib/utils/memoryUsage.d.ts +20 -0
- package/lib/utils/memoryUsage.d.ts.map +1 -0
- package/lib/utils/memoryUsage.js +51 -0
- package/lib/utils/memoryUsage.js.map +1 -0
- package/lib/utils/safeRequire.d.ts +1 -1
- package/lib/utils/safeRequire.d.ts.map +1 -1
- package/lib/utils/safeRequire.js +13 -3
- package/lib/utils/safeRequire.js.map +1 -1
- package/package.json +13 -15
- package/schema.json +175 -20
- package/src/api/analyze/index.ts +2 -3
- package/src/api/benchmark/__integration__/__fixtures__/tramvai.json +3 -0
- package/src/api/build/__integration__/__fixtures__/tramvai.json +4 -2
- package/src/api/build/__integration__/build.test.ts +0 -1
- package/src/api/build/application.ts +2 -5
- package/src/api/build/child-app.ts +1 -5
- package/src/api/build/index.ts +0 -2
- package/src/api/build/module.ts +1 -3
- package/src/api/index.ts +1 -10
- package/src/api/start/__integration__/__fixtures__/app/server.tsx +1 -0
- package/src/api/start/__integration__/__fixtures__/package.json +0 -3
- package/src/api/start/__integration__/__fixtures__/tramvai.json +3 -0
- package/src/api/start/__integration__/start.test.ts +2 -1
- package/src/api/start/index.ts +0 -1
- package/src/api/start/utils/banner.ts +0 -1
- package/src/api/start/utils/tips/tips.ts +0 -9
- package/src/builder/webpack/devServer/pool/process/pool.ts +0 -2
- package/src/builder/webpack/devServer/server.ts +5 -0
- package/src/builder/webpack/index.ts +3 -5
- package/src/builder/webpack/providers/build/client.ts +0 -1
- package/src/builder/webpack/providers/build/clientShared.ts +5 -11
- package/src/builder/webpack/providers/client.ts +1 -19
- package/src/builder/webpack/providers/shared.ts +2 -9
- package/src/builder/webpack/tokens.ts +0 -9
- package/src/builder/webpack/utils/copyStatsJsonFile.ts +0 -17
- package/src/cli/CLI.ts +6 -4
- package/src/cli/index.ts +33 -8
- package/src/cli/runCLI.ts +26 -5
- package/src/commands/build/command.ts +45 -13
- package/src/commands/createApp.ts +0 -2
- package/src/commands/new/new.ts +39 -7
- package/src/commands/new/templates/packageManagerConfig/yarnPackageManagerConfig/_yarnrc.yml.hbs +9 -0
- package/src/commands/new/templates/shared/_gitignore.hbs +10 -0
- package/src/commands/new/templates/shared/package.json.hbs +5 -1
- package/src/commands/start/command.ts +42 -7
- package/src/commands/start/start.ts +7 -1
- package/src/commands/static/application.ts +0 -1
- package/src/commands/update/command.ts +9 -1
- package/src/commands/update/dependantLibs.ts +23 -8
- package/src/commands/update/update.ts +7 -6
- package/src/commands/update/updatePackageJson.spec.ts +66 -3
- package/src/commands/update/updatePackageJson.ts +28 -16
- package/src/config/__integration__/__fixtures__/relative/src/index.ts +0 -0
- package/src/config/__integration__/__fixtures__/relative/src/polyfill.ts +0 -0
- package/src/config/__integration__/validate.test.ts +94 -0
- package/src/config/configManager.ts +2 -19
- package/src/config/validate.ts +8 -1
- package/src/di/providers/index.ts +0 -1
- package/src/di/tokens/index.ts +0 -1
- package/src/library/babel/index.ts +8 -14
- package/src/library/babel/plugins/__snapshots__/create-token-pure.spec.ts.snap +6 -6
- package/src/library/babel/plugins/__snapshots__/fill-declare-action-name.spec.ts.snap +24 -26
- package/src/library/babel/plugins/__snapshots__/provider-stack.spec.ts.snap +40 -59
- package/src/library/babel/plugins/lazy-component/lazy-component.spec.ts +0 -1
- package/src/library/babel/plugins/lazy-component/legacy-universal-replace.spec.ts +0 -1
- package/src/library/swc/__integration__/__snapshots__/swc.build.test.ts.snap +15 -208
- package/src/library/swc/__integration__/__snapshots__/swc.start.test.ts.snap +7 -10
- package/src/library/swc/__integration__/swc.build.test.ts +1 -13
- package/src/library/swc/__integration__/swc.start.test.ts +3 -0
- package/src/library/swc/index.ts +1 -1
- package/src/library/typescript/index.ts +1 -3
- package/src/library/webpack/application/client/common.ts +63 -6
- package/src/library/webpack/application/client/dev.ts +2 -2
- package/src/library/webpack/application/client/prod.ts +1 -2
- package/src/library/webpack/application/common.ts +1 -1
- package/src/library/webpack/application/server/common.ts +1 -1
- package/src/library/webpack/application/server/dev.ts +1 -1
- package/src/library/webpack/application/server/prod.ts +1 -1
- package/src/library/webpack/blocks/css.ts +17 -11
- package/src/library/webpack/blocks/optimize.ts +2 -2
- package/src/library/webpack/blocks/pwa/client.ts +1 -6
- package/src/library/webpack/blocks/pwa/shared.ts +1 -3
- package/src/library/webpack/blocks/resolve.ts +2 -2
- package/src/library/webpack/blocks/serverInline.ts +1 -2
- package/src/library/webpack/blocks/sourcemaps.ts +4 -2
- package/src/library/webpack/child-app/client/common.ts +9 -3
- package/src/library/webpack/child-app/client/dev.ts +6 -1
- package/src/library/webpack/child-app/client/prod.ts +5 -0
- package/src/library/webpack/child-app/common.ts +1 -7
- package/src/library/webpack/child-app/server/dev.ts +5 -0
- package/src/library/webpack/child-app/server/prod.ts +5 -0
- package/src/library/webpack/common/client/prod.ts +1 -1
- package/src/library/webpack/common/main.ts +1 -5
- package/src/library/webpack/constants/stats.ts +2 -0
- package/src/library/webpack/loaders/image-loader/getImageMiniatureURL.ts +1 -1
- package/src/library/webpack/module/client/common.ts +1 -1
- package/src/library/webpack/module/externals.ts +1 -1
- package/src/library/webpack/module/server/common.ts +1 -1
- package/src/library/webpack/plugins/AssetsIntegritiesPlugin.ts +34 -0
- package/src/library/webpack/plugins/PurifyStatsPlugin.ts +57 -0
- package/src/library/webpack/plugins/RuntimePathPlugin.ts +8 -3
- package/src/library/webpack/utils/polyfills/__integration__/__snapshots__/condition.test.ts.snap +16 -16
- package/src/library/webpack/utils/transpiler.ts +1 -5
- package/src/models/analytics/analytics.ts +488 -0
- package/src/models/analytics/analytics.worker.ts +102 -0
- package/src/models/analytics/utils.ts +122 -0
- package/src/models/command.ts +1 -8
- package/src/models/config.spec.ts +6 -2
- package/src/models/context.ts +4 -5
- package/src/models/logger.ts +2 -0
- package/src/models/task.ts +1 -7
- package/src/schema/autogeneratedSchema.json +161 -20
- package/src/schema/topLevelSchema.js +14 -0
- package/src/schema/tramvai.spec.ts +3 -1
- package/src/typings/build/Builder.ts +3 -8
- package/src/typings/configEntry/application.ts +11 -6
- package/src/typings/configEntry/cli.ts +14 -0
- package/src/typings/projectType.ts +5 -0
- package/src/typings/target.ts +1 -1
- package/src/utils/commands/dependencies/findTramvaiVersion.ts +5 -12
- package/src/utils/commands/dependencies/getLatestPackageVersion.ts +11 -3
- package/src/utils/cpu-profile.ts +14 -3
- package/src/utils/errors.ts +39 -0
- package/src/utils/memoryUsage.ts +58 -0
- package/src/utils/safeRequire.spec.ts +36 -0
- package/src/utils/safeRequire.ts +12 -3
- package/lib/builder/webpack/providers/build/clientModern.d.ts +0 -3
- package/lib/builder/webpack/providers/build/clientModern.d.ts.map +0 -1
- package/lib/builder/webpack/providers/build/clientModern.js +0 -60
- package/lib/builder/webpack/providers/build/clientModern.js.map +0 -1
- package/lib/di/providers/analytics.d.ts +0 -3
- package/lib/di/providers/analytics.d.ts.map +0 -1
- package/lib/di/providers/analytics.js +0 -20
- package/lib/di/providers/analytics.js.map +0 -1
- package/lib/di/tokens/analytics.d.ts +0 -14
- package/lib/di/tokens/analytics.d.ts.map +0 -1
- package/lib/di/tokens/analytics.js +0 -8
- package/lib/di/tokens/analytics.js.map +0 -1
- package/lib/models/analytics.d.ts +0 -31
- package/lib/models/analytics.d.ts.map +0 -1
- package/lib/models/analytics.js +0 -79
- package/lib/models/analytics.js.map +0 -1
- package/src/builder/webpack/providers/build/clientModern.ts +0 -64
- package/src/di/providers/analytics.ts +0 -22
- package/src/di/tokens/analytics.ts +0 -8
- package/src/models/analytics.ts +0 -116
- /package/src/commands/new/templates/{shared → packageManagerConfig/defaultPackageManagerConfig}/_npmrc.hbs +0 -0
|
@@ -7,6 +7,7 @@ import type { BuildCommand as BuildCommandType } from '../../api/build';
|
|
|
7
7
|
import { checkPwaDependencies } from '../../validators/commands/checkPwaDependencies';
|
|
8
8
|
import { checkSwcDependencies } from '../../validators/commands/checkSwcDependencies';
|
|
9
9
|
import { checkReactCompilerDependencies } from '../../validators/commands/checkReactCompilerDependencies';
|
|
10
|
+
import { getFeaturesProperties, getProjectProperties } from '../../models/analytics/utils';
|
|
10
11
|
|
|
11
12
|
export type Params = Parameters<BuildCommandType>[0] & {
|
|
12
13
|
target: string;
|
|
@@ -59,17 +60,6 @@ class BuildCommand extends CLICommand<Params> {
|
|
|
59
60
|
transformer: (value: string) => value !== 'false',
|
|
60
61
|
description: 'Enable/disable persistent file cache for used cli builder',
|
|
61
62
|
},
|
|
62
|
-
{
|
|
63
|
-
name: '--modern',
|
|
64
|
-
value: '[modern]',
|
|
65
|
-
description: 'modern compilation code with es2015+',
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
name: '--onlyModern',
|
|
69
|
-
value: '[onlyModern]',
|
|
70
|
-
transformer: (value: string) => value !== 'false',
|
|
71
|
-
description: 'Emit only modern build from client compilation',
|
|
72
|
-
},
|
|
73
63
|
{
|
|
74
64
|
name: '--verboseWebpack',
|
|
75
65
|
value: '[verboseWebpack]',
|
|
@@ -89,9 +79,51 @@ class BuildCommand extends CLICommand<Params> {
|
|
|
89
79
|
checkReactCompilerDependencies,
|
|
90
80
|
];
|
|
91
81
|
|
|
92
|
-
action(parameters: Params) {
|
|
82
|
+
async action(parameters: Params) {
|
|
83
|
+
const start = Date.now();
|
|
84
|
+
|
|
85
|
+
await this.context.analytics.send({
|
|
86
|
+
event: 'cli:command:start',
|
|
87
|
+
message: '@tramvai/cli production build started',
|
|
88
|
+
level: 'INFO',
|
|
89
|
+
command: 'build',
|
|
90
|
+
parameters,
|
|
91
|
+
project: getProjectProperties({ parameters, configManager: this.context.config }),
|
|
92
|
+
features: getFeaturesProperties({ parameters, configManager: this.context.config }),
|
|
93
|
+
});
|
|
94
|
+
|
|
93
95
|
// used require for lazy code execution
|
|
94
|
-
return require('./build')
|
|
96
|
+
return require('./build')
|
|
97
|
+
.default(this.context, parameters)
|
|
98
|
+
.then(async (result) => {
|
|
99
|
+
await this.context.analytics.send({
|
|
100
|
+
event: 'cli:command:end',
|
|
101
|
+
message: '@tramvai/cli production build finished',
|
|
102
|
+
level: 'INFO',
|
|
103
|
+
command: 'build',
|
|
104
|
+
parameters,
|
|
105
|
+
duration: Date.now() - start,
|
|
106
|
+
project: getProjectProperties({ parameters, configManager: this.context.config }),
|
|
107
|
+
memoryUsage: this.context.analytics.memoryMonitor.read(),
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
return result;
|
|
111
|
+
})
|
|
112
|
+
.catch(async (error) => {
|
|
113
|
+
await this.context.analytics.send({
|
|
114
|
+
event: 'cli:command:error',
|
|
115
|
+
message: '@tramvai/cli production build failed',
|
|
116
|
+
level: 'ERROR',
|
|
117
|
+
command: 'build',
|
|
118
|
+
parameters,
|
|
119
|
+
duration: Date.now() - start,
|
|
120
|
+
error,
|
|
121
|
+
project: getProjectProperties({ parameters, configManager: this.context.config }),
|
|
122
|
+
memoryUsage: this.context.analytics.memoryMonitor.read(),
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
throw error;
|
|
126
|
+
});
|
|
95
127
|
}
|
|
96
128
|
}
|
|
97
129
|
|
|
@@ -2,7 +2,6 @@ import type { Provider } from '@tinkoff/dippy';
|
|
|
2
2
|
import { createChildContainer } from '@tinkoff/dippy';
|
|
3
3
|
import { initRootContainer } from '../di/root';
|
|
4
4
|
import {
|
|
5
|
-
analyticsProviders,
|
|
6
5
|
builderProviders,
|
|
7
6
|
commandsProviders,
|
|
8
7
|
configProviders,
|
|
@@ -20,7 +19,6 @@ export const createApp = ({
|
|
|
20
19
|
providers: Provider[];
|
|
21
20
|
}): typeof COMMAND_RUNNER_TOKEN => {
|
|
22
21
|
const rootContainer = initRootContainer([
|
|
23
|
-
...analyticsProviders,
|
|
24
22
|
...stdProviders,
|
|
25
23
|
...configProviders,
|
|
26
24
|
...commandsProviders,
|
package/src/commands/new/new.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
+
import { command } from 'execa';
|
|
3
4
|
import inquirer from 'inquirer';
|
|
4
5
|
import { packageManagerFactory } from '@tinkoff/package-manager-wrapper';
|
|
5
6
|
import type { Context } from '../../models/context';
|
|
@@ -21,7 +22,22 @@ import { typeQuestion } from './questions/type';
|
|
|
21
22
|
// ts не копирует файлы, так что шаблона не будет в lib директории =(
|
|
22
23
|
const getPathToTemplate = (type: Type, template: Templates) =>
|
|
23
24
|
path.resolve(__dirname, '../../../src/commands/new/templates', type, template);
|
|
24
|
-
const
|
|
25
|
+
const getPathToPackageManagerConfig = (packageManager: PackageManagers) => {
|
|
26
|
+
if (packageManager === 'yarn') {
|
|
27
|
+
return path.resolve(
|
|
28
|
+
__dirname,
|
|
29
|
+
'../../../src/commands/new/templates/packageManagerConfig/yarnPackageManagerConfig'
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return path.resolve(
|
|
34
|
+
__dirname,
|
|
35
|
+
'../../../src/commands/new/templates/packageManagerConfig/defaultPackageManagerConfig'
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
const getPathToShared = () => {
|
|
39
|
+
return path.resolve(__dirname, '../../../src/commands/new/templates/shared');
|
|
40
|
+
};
|
|
25
41
|
const getPathToBlock = (type: Type) =>
|
|
26
42
|
path.resolve(__dirname, '../../../src/commands/new/templates', type, 'block');
|
|
27
43
|
const getPathToMonorepoBlock = () =>
|
|
@@ -29,6 +45,7 @@ const getPathToMonorepoBlock = () =>
|
|
|
29
45
|
const getPathToTestingFramework = (type: Type, testingFramework: TestingFrameworks) =>
|
|
30
46
|
path.resolve(__dirname, '../../../src/commands/new/templates', type, 'testing', testingFramework);
|
|
31
47
|
|
|
48
|
+
// eslint-disable-next-line max-statements
|
|
32
49
|
export default async function createNew(context: Context, params: Params): Promise<CommandResult> {
|
|
33
50
|
const {
|
|
34
51
|
name: inputName,
|
|
@@ -64,24 +81,31 @@ export default async function createNew(context: Context, params: Params): Promi
|
|
|
64
81
|
|
|
65
82
|
const templateDir = getPathToTemplate(type, template);
|
|
66
83
|
const sharedDir = getPathToShared();
|
|
84
|
+
const packageManagerConfigDif = getPathToPackageManagerConfig(packageManager);
|
|
67
85
|
const blockDir = getPathToBlock(type);
|
|
68
86
|
const isMonorepo = template === 'monorepo';
|
|
87
|
+
|
|
88
|
+
const isYarn = packageManager === 'yarn';
|
|
89
|
+
|
|
69
90
|
const baseDir = type === 'app' ? 'apps' : 'child-apps';
|
|
91
|
+
const rootDir = path.resolve(process.cwd(), directoryName);
|
|
70
92
|
const blockDirectoryName = {
|
|
71
93
|
monorepo: path.join(baseDir, name),
|
|
72
94
|
multirepo: 'src',
|
|
73
95
|
}[template];
|
|
74
96
|
|
|
75
97
|
const templateData = {
|
|
98
|
+
isMonorepo,
|
|
76
99
|
configEntry,
|
|
77
100
|
isJest: testingFramework === 'jest',
|
|
78
101
|
isNpm: packageManager === 'npm',
|
|
79
|
-
isYarn
|
|
102
|
+
isYarn,
|
|
80
103
|
workspaceBaseDir: isMonorepo ? baseDir : undefined,
|
|
81
104
|
};
|
|
82
105
|
|
|
83
106
|
await renderTemplate(templateDir, directoryName, templateData);
|
|
84
107
|
await renderTemplate(sharedDir, directoryName, templateData);
|
|
108
|
+
await renderTemplate(packageManagerConfigDif, directoryName, templateData);
|
|
85
109
|
await renderTemplate(blockDir, path.join(directoryName, blockDirectoryName), templateData);
|
|
86
110
|
if (template === 'monorepo') {
|
|
87
111
|
const monorepoBlockDir = getPathToMonorepoBlock();
|
|
@@ -100,15 +124,23 @@ export default async function createNew(context: Context, params: Params): Promi
|
|
|
100
124
|
templateData
|
|
101
125
|
);
|
|
102
126
|
}
|
|
103
|
-
|
|
104
127
|
await initializationGit(directoryName);
|
|
128
|
+
|
|
129
|
+
if (isYarn) {
|
|
130
|
+
await command('yarn set version berry', {
|
|
131
|
+
env: {
|
|
132
|
+
YARN_HTTP_PROXY: process.env.HTTP_PROXY,
|
|
133
|
+
YARN_HTTPS_PROXY: process.env.HTTPS_PROXY,
|
|
134
|
+
},
|
|
135
|
+
cwd: rootDir,
|
|
136
|
+
stdio: 'inherit',
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
105
140
|
await installDependencies({
|
|
106
141
|
localDir: directoryName,
|
|
107
142
|
type,
|
|
108
|
-
packageManager: packageManagerFactory(
|
|
109
|
-
{ rootDir: path.resolve(process.cwd(), directoryName) },
|
|
110
|
-
packageManager
|
|
111
|
-
),
|
|
143
|
+
packageManager: packageManagerFactory({ rootDir }, packageManager),
|
|
112
144
|
testingFramework,
|
|
113
145
|
workspace: isMonorepo ? blockDirectoryName : undefined,
|
|
114
146
|
});
|
|
@@ -7,6 +7,7 @@ import type { StartCommand as StartCommandType } from '../../api/start';
|
|
|
7
7
|
import { checkPwaDependencies } from '../../validators/commands/checkPwaDependencies';
|
|
8
8
|
import { checkSwcDependencies } from '../../validators/commands/checkSwcDependencies';
|
|
9
9
|
import { checkReactCompilerDependencies } from '../../validators/commands/checkReactCompilerDependencies';
|
|
10
|
+
import { getFeaturesProperties, getProjectProperties } from '../../models/analytics/utils';
|
|
10
11
|
|
|
11
12
|
export type Params = Parameters<StartCommandType>[0] & {
|
|
12
13
|
target: string;
|
|
@@ -61,11 +62,6 @@ export class StartCommand extends CLICommand<Params> {
|
|
|
61
62
|
value: '[profile]',
|
|
62
63
|
description: 'report statistic how much time execute loaders and plugins',
|
|
63
64
|
},
|
|
64
|
-
{
|
|
65
|
-
name: '--modern',
|
|
66
|
-
value: '[modern]',
|
|
67
|
-
description: 'modern compilation code with es2015+',
|
|
68
|
-
},
|
|
69
65
|
{
|
|
70
66
|
name: '--sm, --sourceMap',
|
|
71
67
|
value: '[sourceMap]',
|
|
@@ -142,8 +138,47 @@ export class StartCommand extends CLICommand<Params> {
|
|
|
142
138
|
checkReactCompilerDependencies,
|
|
143
139
|
];
|
|
144
140
|
|
|
145
|
-
action(parameters) {
|
|
141
|
+
async action(parameters) {
|
|
142
|
+
const start = Date.now();
|
|
143
|
+
|
|
144
|
+
await this.context.analytics.send({
|
|
145
|
+
event: 'cli:command:start',
|
|
146
|
+
message: '@tramvai/cli development build started',
|
|
147
|
+
level: 'INFO',
|
|
148
|
+
command: 'start',
|
|
149
|
+
parameters,
|
|
150
|
+
project: getProjectProperties({ parameters, configManager: this.context.config }),
|
|
151
|
+
features: getFeaturesProperties({ parameters, configManager: this.context.config }),
|
|
152
|
+
});
|
|
153
|
+
|
|
146
154
|
// used require for lazy code execution
|
|
147
|
-
return require('./start')
|
|
155
|
+
return require('./start')
|
|
156
|
+
.default(this.context, parameters, async () => {
|
|
157
|
+
await this.context.analytics.send({
|
|
158
|
+
event: 'cli:command:end',
|
|
159
|
+
message: '@tramvai/cli development build finished',
|
|
160
|
+
level: 'INFO',
|
|
161
|
+
command: 'start',
|
|
162
|
+
parameters,
|
|
163
|
+
duration: Date.now() - start,
|
|
164
|
+
project: getProjectProperties({ parameters, configManager: this.context.config }),
|
|
165
|
+
memoryUsage: this.context.analytics.memoryMonitor.read(),
|
|
166
|
+
});
|
|
167
|
+
})
|
|
168
|
+
.catch(async (error) => {
|
|
169
|
+
await this.context.analytics.send({
|
|
170
|
+
event: 'cli:command:error',
|
|
171
|
+
message: '@tramvai/cli development build failed',
|
|
172
|
+
level: 'ERROR',
|
|
173
|
+
command: 'start',
|
|
174
|
+
parameters,
|
|
175
|
+
duration: Date.now() - start,
|
|
176
|
+
error,
|
|
177
|
+
project: getProjectProperties({ parameters, configManager: this.context.config }),
|
|
178
|
+
memoryUsage: this.context.analytics.memoryMonitor.read(),
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
throw error;
|
|
182
|
+
});
|
|
148
183
|
}
|
|
149
184
|
}
|
|
@@ -3,13 +3,19 @@ import type { CommandResult } from '../../models/command';
|
|
|
3
3
|
|
|
4
4
|
import { app } from '../index';
|
|
5
5
|
|
|
6
|
-
export default async (
|
|
6
|
+
export default async (
|
|
7
|
+
context: Context,
|
|
8
|
+
parameters,
|
|
9
|
+
finishedBuildCallback: Function
|
|
10
|
+
): Promise<CommandResult | any> => {
|
|
7
11
|
const { staticServer } = await app.run('start', {
|
|
8
12
|
...parameters,
|
|
9
13
|
// игнорируем ошибку т.к. сборка не обязательно правильная при запуске, но при виде ошибки разработчик сможет поправить и не понадобится перезапускать с нуля
|
|
10
14
|
strictErrorHandle: false,
|
|
11
15
|
});
|
|
12
16
|
|
|
17
|
+
await finishedBuildCallback();
|
|
18
|
+
|
|
13
19
|
await new Promise((resolve) => {
|
|
14
20
|
staticServer.on('close', resolve);
|
|
15
21
|
});
|
|
@@ -10,7 +10,15 @@ class UpdateCommand extends CLICommand {
|
|
|
10
10
|
|
|
11
11
|
command = `update [to]`;
|
|
12
12
|
|
|
13
|
-
options = [
|
|
13
|
+
options = [
|
|
14
|
+
{
|
|
15
|
+
name: '-t, --tag',
|
|
16
|
+
value: '[tag]',
|
|
17
|
+
transformer: (value: string) => value !== 'false',
|
|
18
|
+
description:
|
|
19
|
+
'Install target version as is - useful for dist tags like prerelease / stable-v5.x.x/ custom tags',
|
|
20
|
+
},
|
|
21
|
+
];
|
|
14
22
|
|
|
15
23
|
alias = 'u';
|
|
16
24
|
|
|
@@ -1,25 +1,40 @@
|
|
|
1
1
|
import getLatestPackageVersion from 'latest-version';
|
|
2
2
|
import getPackageInfo from 'package-json';
|
|
3
|
+
import type { Ora } from 'ora';
|
|
3
4
|
import { DEPENDANT_LIBS_MAP } from '../../utils/tramvaiVersions';
|
|
4
5
|
|
|
5
6
|
export const getLibPackageVersion = async (
|
|
6
7
|
name: string,
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
version: string,
|
|
9
|
+
resolvedVersion: string,
|
|
10
|
+
spinner: Ora
|
|
9
11
|
): Promise<string | undefined> => {
|
|
10
12
|
const unifiedModule = DEPENDANT_LIBS_MAP.get(name);
|
|
11
13
|
|
|
12
14
|
if (!unifiedModule) {
|
|
13
|
-
|
|
15
|
+
try {
|
|
16
|
+
return await getLatestPackageVersion(name, { version });
|
|
17
|
+
} catch (e) {
|
|
18
|
+
// clear the spinner to be able to log info that should be preserved in the output
|
|
19
|
+
// the idea borrowed from [here](https://github.com/sindresorhus/ora/issues/120)
|
|
20
|
+
spinner.clear();
|
|
21
|
+
|
|
22
|
+
console.warn(`⚠️ cannot resolve proper version for the "${name}" package,
|
|
23
|
+
You have to update this package by yourself.`);
|
|
24
|
+
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
14
27
|
}
|
|
15
28
|
|
|
16
|
-
const { dependencies } = await getPackageInfo(unifiedModule, { version:
|
|
29
|
+
const { dependencies } = await getPackageInfo(unifiedModule, { version: resolvedVersion });
|
|
17
30
|
|
|
18
31
|
if (!dependencies[name]) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
32
|
+
// clear the spinner to be able to log info that should be preserved in the output
|
|
33
|
+
// the idea borrowed from [here](https://github.com/sindresorhus/ora/issues/120)
|
|
34
|
+
spinner.clear();
|
|
35
|
+
|
|
36
|
+
console.warn(`⚠️ cannot resolve proper version for the "${name}" package,
|
|
37
|
+
You have to update this package by yourself.`);
|
|
23
38
|
|
|
24
39
|
return;
|
|
25
40
|
}
|
|
@@ -9,13 +9,14 @@ import { findTramvaiVersion } from '../../utils/commands/dependencies/findTramva
|
|
|
9
9
|
|
|
10
10
|
export type Params = {
|
|
11
11
|
to: string;
|
|
12
|
+
tag?: boolean;
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
export default async (
|
|
15
16
|
context: Context,
|
|
16
|
-
{ to: version = 'latest' }: Params
|
|
17
|
+
{ to: version = 'latest', tag }: Params
|
|
17
18
|
): Promise<CommandResult> => {
|
|
18
|
-
const
|
|
19
|
+
const resolvedVersion = tag ? version : await getLatestPackageVersion('@tramvai/cli', version);
|
|
19
20
|
const currentVersion = await findTramvaiVersion();
|
|
20
21
|
|
|
21
22
|
if (!currentVersion) {
|
|
@@ -24,7 +25,7 @@ export default async (
|
|
|
24
25
|
);
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
if (currentVersion === version) {
|
|
28
|
+
if (currentVersion === version || currentVersion === resolvedVersion) {
|
|
28
29
|
throw new Error(
|
|
29
30
|
'The installed version is equal to the current version, no update is required.'
|
|
30
31
|
);
|
|
@@ -33,18 +34,18 @@ export default async (
|
|
|
33
34
|
context.logger.event({
|
|
34
35
|
type: 'info',
|
|
35
36
|
event: 'resolving-version',
|
|
36
|
-
message: `
|
|
37
|
+
message: `Next tramvai version resolved to ${tag ? 'tag' : 'version'} "${resolvedVersion}", current version is "${currentVersion}"`,
|
|
37
38
|
});
|
|
38
39
|
|
|
39
40
|
if (context.packageManager.workspaces) {
|
|
40
41
|
await Promise.all(
|
|
41
42
|
context.packageManager.workspaces.map((directory) =>
|
|
42
|
-
updatePackageJson(
|
|
43
|
+
updatePackageJson(version, resolvedVersion, currentVersion, tag, directory)
|
|
43
44
|
)
|
|
44
45
|
);
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
await updatePackageJson(
|
|
48
|
+
await updatePackageJson(version, resolvedVersion, currentVersion, tag);
|
|
48
49
|
|
|
49
50
|
context.logger.event({
|
|
50
51
|
type: 'info',
|
|
@@ -76,7 +76,7 @@ it('should update tramvai deps to latest versions', async () => {
|
|
|
76
76
|
return {};
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
await updatePackageJson(LATEST_TRAMVAI_VERSION, CURRENT_TRAMVAI_VERSION);
|
|
79
|
+
await updatePackageJson(LATEST_TRAMVAI_VERSION, LATEST_TRAMVAI_VERSION, CURRENT_TRAMVAI_VERSION);
|
|
80
80
|
|
|
81
81
|
// eslint-disable-next-line jest/no-interpolation-in-snapshots
|
|
82
82
|
expect(mockFsWrite.mock.calls[0]).toMatchInlineSnapshot(`
|
|
@@ -100,7 +100,7 @@ it('should update tramvai deps to latest versions', async () => {
|
|
|
100
100
|
`);
|
|
101
101
|
});
|
|
102
102
|
|
|
103
|
-
it('prerelease should be used for dependant libs', async () => {
|
|
103
|
+
it('prerelease should be resolved and used for dependant libs', async () => {
|
|
104
104
|
mockPackageJson = {
|
|
105
105
|
dependencies: {
|
|
106
106
|
'@tramvai/core': CURRENT_TRAMVAI_VERSION,
|
|
@@ -138,7 +138,7 @@ it('prerelease should be used for dependant libs', async () => {
|
|
|
138
138
|
return {};
|
|
139
139
|
});
|
|
140
140
|
|
|
141
|
-
await updatePackageJson(LATEST_TRAMVAI_VERSION, CURRENT_TRAMVAI_VERSION
|
|
141
|
+
await updatePackageJson('prerelease', LATEST_TRAMVAI_VERSION, CURRENT_TRAMVAI_VERSION);
|
|
142
142
|
|
|
143
143
|
// eslint-disable-next-line jest/no-interpolation-in-snapshots
|
|
144
144
|
expect(mockFsWrite.mock.calls[0]).toMatchInlineSnapshot(`
|
|
@@ -162,3 +162,66 @@ it('prerelease should be used for dependant libs', async () => {
|
|
|
162
162
|
]
|
|
163
163
|
`);
|
|
164
164
|
});
|
|
165
|
+
|
|
166
|
+
it('dist tag should be used for dependant libs', async () => {
|
|
167
|
+
mockPackageJson = {
|
|
168
|
+
dependencies: {
|
|
169
|
+
'@tramvai/core': CURRENT_TRAMVAI_VERSION,
|
|
170
|
+
'@tramvai/module-common': CURRENT_TRAMVAI_VERSION,
|
|
171
|
+
'@tinkoff/router': '^0.2.3',
|
|
172
|
+
'@tinkoff/url': '0.3.2',
|
|
173
|
+
'@tinkoff/pack-polyfills': '1.0.0',
|
|
174
|
+
},
|
|
175
|
+
devDependencies: {
|
|
176
|
+
'@tramvai/cli': CURRENT_TRAMVAI_VERSION,
|
|
177
|
+
},
|
|
178
|
+
peerDependencies: {
|
|
179
|
+
'@tinkoff/dippy': '0.7.10',
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
mockPackageInfoDependencies.mockImplementation((dep: string) => {
|
|
184
|
+
switch (dep) {
|
|
185
|
+
case '@tramvai/core':
|
|
186
|
+
return { '@tinkoff/dippy': '0.7.44', '@tinkoff/utils': '^2.1.0' };
|
|
187
|
+
case '@tramvai/module-common':
|
|
188
|
+
return {
|
|
189
|
+
'@tinkoff/error': '0.6.1',
|
|
190
|
+
'@tinkoff/url': '0.4.1',
|
|
191
|
+
};
|
|
192
|
+
case '@tramvai/cli':
|
|
193
|
+
return {};
|
|
194
|
+
case '@tramvai/module-router':
|
|
195
|
+
return {
|
|
196
|
+
'@tinkoff/router': '0.4.3',
|
|
197
|
+
'@tinkoff/url': '0.4.1',
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return {};
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
await updatePackageJson('prerelease', 'prerelease', CURRENT_TRAMVAI_VERSION, true);
|
|
205
|
+
|
|
206
|
+
// eslint-disable-next-line jest/no-interpolation-in-snapshots
|
|
207
|
+
expect(mockFsWrite.mock.calls[0]).toMatchInlineSnapshot(`
|
|
208
|
+
[
|
|
209
|
+
"${packageJsonPath}",
|
|
210
|
+
"{
|
|
211
|
+
"dependencies": {
|
|
212
|
+
"@tramvai/core": "prerelease",
|
|
213
|
+
"@tramvai/module-common": "prerelease",
|
|
214
|
+
"@tinkoff/router": "prerelease",
|
|
215
|
+
"@tinkoff/url": "prerelease",
|
|
216
|
+
"@tinkoff/pack-polyfills": "prerelease"
|
|
217
|
+
},
|
|
218
|
+
"devDependencies": {
|
|
219
|
+
"@tramvai/cli": "prerelease"
|
|
220
|
+
},
|
|
221
|
+
"peerDependencies": {
|
|
222
|
+
"@tinkoff/dippy": "prerelease"
|
|
223
|
+
}
|
|
224
|
+
}",
|
|
225
|
+
]
|
|
226
|
+
`);
|
|
227
|
+
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { parse, minVersion } from 'semver';
|
|
2
1
|
import fs from 'fs';
|
|
3
2
|
import pMap from 'p-map';
|
|
4
3
|
import type { Ora } from 'ora';
|
|
@@ -8,17 +7,12 @@ import { packageHasVersion } from '../../utils/commands/dependencies/packageHasV
|
|
|
8
7
|
import { getLibPackageVersion } from './dependantLibs';
|
|
9
8
|
import { isDependantLib, isUnifiedVersion } from '../../utils/tramvaiVersions';
|
|
10
9
|
|
|
11
|
-
const getVersionFromDep = (dep?: string) => {
|
|
12
|
-
if (dep) {
|
|
13
|
-
return parse(dep)?.version || minVersion(dep)?.version;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
|
|
17
10
|
const updateDependencies = (
|
|
18
11
|
dependencies: Record<string, string> = {},
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
version: string,
|
|
13
|
+
resolvedVersion: string,
|
|
21
14
|
currentVersion: string,
|
|
15
|
+
tag: boolean,
|
|
22
16
|
spinner: Ora
|
|
23
17
|
) => {
|
|
24
18
|
return pMap<string, void>(
|
|
@@ -26,10 +20,12 @@ const updateDependencies = (
|
|
|
26
20
|
async (dep) => {
|
|
27
21
|
let nextVersion: string | undefined;
|
|
28
22
|
|
|
29
|
-
if (isUnifiedVersion(dep) &&
|
|
30
|
-
nextVersion =
|
|
23
|
+
if (isUnifiedVersion(dep) && dependencies[dep] === currentVersion) {
|
|
24
|
+
nextVersion = resolvedVersion;
|
|
31
25
|
} else if (isDependantLib(dep)) {
|
|
32
|
-
const libVersion =
|
|
26
|
+
const libVersion = tag
|
|
27
|
+
? resolvedVersion
|
|
28
|
+
: await getLibPackageVersion(dep, version, resolvedVersion, spinner);
|
|
33
29
|
nextVersion = libVersion;
|
|
34
30
|
}
|
|
35
31
|
|
|
@@ -64,8 +60,9 @@ const updateDependencies = (
|
|
|
64
60
|
|
|
65
61
|
export const updatePackageJson = async (
|
|
66
62
|
version: string,
|
|
63
|
+
resolvedVersion: string,
|
|
67
64
|
currentVersion: string,
|
|
68
|
-
|
|
65
|
+
tag?: boolean,
|
|
69
66
|
path = '.'
|
|
70
67
|
) => {
|
|
71
68
|
const packageJsonPath = resolve(path, 'package.json');
|
|
@@ -75,13 +72,28 @@ export const updatePackageJson = async (
|
|
|
75
72
|
const spinner = ora(`Updating package.json versions`).start();
|
|
76
73
|
|
|
77
74
|
try {
|
|
78
|
-
await updateDependencies(
|
|
79
|
-
|
|
75
|
+
await updateDependencies(
|
|
76
|
+
content.dependencies,
|
|
77
|
+
version,
|
|
78
|
+
resolvedVersion,
|
|
79
|
+
currentVersion,
|
|
80
|
+
tag,
|
|
81
|
+
spinner
|
|
82
|
+
);
|
|
83
|
+
await updateDependencies(
|
|
84
|
+
content.devDependencies,
|
|
85
|
+
version,
|
|
86
|
+
resolvedVersion,
|
|
87
|
+
currentVersion,
|
|
88
|
+
tag,
|
|
89
|
+
spinner
|
|
90
|
+
);
|
|
80
91
|
await updateDependencies(
|
|
81
92
|
content.peerDependencies,
|
|
82
93
|
version,
|
|
83
|
-
|
|
94
|
+
resolvedVersion,
|
|
84
95
|
currentVersion,
|
|
96
|
+
tag,
|
|
85
97
|
spinner
|
|
86
98
|
);
|
|
87
99
|
|
|
File without changes
|
|
File without changes
|