diff --git a/package.json b/package.json index 6c8457b09b30..8434e0bcd739 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,6 @@ "@types/semver": "^7.3.12", "@types/shelljs": "^0.8.11", "@types/tar": "^6.1.2", - "@types/text-table": "^0.2.1", "@types/watchpack": "^2.4.4", "@types/yargs": "^17.0.20", "@types/yargs-parser": "^21.0.0", @@ -204,7 +203,6 @@ "symbol-observable": "4.0.0", "tar": "^6.1.6", "terser": "5.27.0", - "text-table": "0.2.0", "tree-kill": "1.2.2", "ts-node": "^10.9.1", "tslib": "2.6.2", diff --git a/packages/angular_devkit/build_angular/BUILD.bazel b/packages/angular_devkit/build_angular/BUILD.bazel index 93f1471225a5..2ad2e04f93f5 100644 --- a/packages/angular_devkit/build_angular/BUILD.bazel +++ b/packages/angular_devkit/build_angular/BUILD.bazel @@ -159,7 +159,6 @@ ts_library( "@npm//@types/node", "@npm//@types/picomatch", "@npm//@types/semver", - "@npm//@types/text-table", "@npm//@types/watchpack", "@npm//@vitejs/plugin-basic-ssl", "@npm//@web/test-runner", @@ -203,7 +202,6 @@ ts_library( "@npm//source-map-loader", "@npm//source-map-support", "@npm//terser", - "@npm//text-table", "@npm//tree-kill", "@npm//tslib", "@npm//typescript", diff --git a/packages/angular_devkit/build_angular/package.json b/packages/angular_devkit/build_angular/package.json index 9064e7534611..3084ddbb6937 100644 --- a/packages/angular_devkit/build_angular/package.json +++ b/packages/angular_devkit/build_angular/package.json @@ -59,7 +59,6 @@ "source-map-loader": "5.0.0", "source-map-support": "0.5.21", "terser": "5.27.0", - "text-table": "0.2.0", "tree-kill": "1.2.2", "tslib": "2.6.2", "undici": "6.4.0", diff --git a/packages/angular_devkit/build_angular/src/tools/webpack/utils/stats.ts b/packages/angular_devkit/build_angular/src/tools/webpack/utils/stats.ts index afb310e231a8..2a7d506712ec 100644 --- a/packages/angular_devkit/build_angular/src/tools/webpack/utils/stats.ts +++ b/packages/angular_devkit/build_angular/src/tools/webpack/utils/stats.ts @@ -8,9 +8,8 @@ import { WebpackLoggingCallback } from '@angular-devkit/build-webpack'; import { logging, tags } from '@angular-devkit/core'; -import assert from 'assert'; -import * as path from 'path'; -import textTable from 'text-table'; +import assert from 'node:assert'; +import * as path from 'node:path'; import { Configuration, StatsCompilation } from 'webpack'; import { Schema as BrowserBuilderOptions } from '../../../builders/browser/schema'; import { normalizeOptimization } from '../../../utils'; @@ -88,7 +87,6 @@ export function generateBuildStatsTable( const r = (x: string) => (colors ? ansiColors.redBright(x) : x); const y = (x: string) => (colors ? ansiColors.yellowBright(x) : x); const bold = (x: string) => (colors ? ansiColors.bold(x) : x); - const dim = (x: string) => (colors ? ansiColors.dim(x) : x); const getSizeColor = (name: string, file?: string, defaultColor = c) => { const severity = budgets.get(name) || (file && budgets.get(file)); @@ -216,11 +214,45 @@ export function generateBuildStatsTable( bundleInfo.push(['Lazy Chunk Files', ...baseTitles].map(bold), ...changedLazyChunksStats); } - return textTable(bundleInfo, { - hsep: dim(' | '), - stringLength: (s) => removeColor(s).length, - align: tableAlign, - }); + return generateTableText(bundleInfo, colors); +} + +function generateTableText(bundleInfo: (string | number)[][], colors: boolean): string { + const longest: number[] = []; + for (const item of bundleInfo) { + for (let i = 0; i < item.length; i++) { + if (item[i] === undefined) { + continue; + } + + const currentItem = item[i].toString(); + const currentLongest = (longest[i] ??= 0); + const currentItemLength = removeColor(currentItem).length; + if (currentLongest < currentItemLength) { + longest[i] = currentItemLength; + } + } + } + + const seperator = colors ? ansiColors.dim(' | ') : ' | '; + const outputTable: string[] = []; + for (const item of bundleInfo) { + for (let i = 0; i < longest.length; i++) { + if (item[i] === undefined) { + continue; + } + + const currentItem = item[i].toString(); + const currentItemLength = removeColor(currentItem).length; + const stringPad = ' '.repeat(longest[i] - currentItemLength); + // Last item is right aligned, thus we add the padding at the start. + item[i] = longest.length === i + 1 ? stringPad + currentItem : currentItem + stringPad; + } + + outputTable.push(item.join(seperator)); + } + + return outputTable.join('\n'); } function generateBuildStats(hash: string, time: number, colors: boolean): string { diff --git a/yarn.lock b/yarn.lock index 0e4023b1e4e0..3238ba97aa6b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -131,8 +131,7 @@ tslib "^2.3.0" "@angular/bazel@https://github.com/angular/bazel-builds.git#a0e463179c1d15995508827d977565031b9ba8fb": - version "17.2.0-next.0+sha-c043128" - uid a0e463179c1d15995508827d977565031b9ba8fb + version "17.2.0-next.0" resolved "https://github.com/angular/bazel-builds.git#a0e463179c1d15995508827d977565031b9ba8fb" dependencies: "@microsoft/api-extractor" "^7.24.2" @@ -149,7 +148,6 @@ "@angular/build-tooling@https://github.com/angular/dev-infra-private-build-tooling-builds.git#103b5c2cf1be1d62b292d3c0a447b0f6918f0770": version "0.0.0-10788de8a2999c84bc16a132dfe1a0a9bc934604" - uid "103b5c2cf1be1d62b292d3c0a447b0f6918f0770" resolved "https://github.com/angular/dev-infra-private-build-tooling-builds.git#103b5c2cf1be1d62b292d3c0a447b0f6918f0770" dependencies: "@angular-devkit/build-angular" "17.2.0-next.0" @@ -317,7 +315,6 @@ "@angular/ng-dev@https://github.com/angular/dev-infra-private-ng-dev-builds.git#21604aaadd15167ee2be0d89622b7009a13cdac7": version "0.0.0-10788de8a2999c84bc16a132dfe1a0a9bc934604" - uid "21604aaadd15167ee2be0d89622b7009a13cdac7" resolved "https://github.com/angular/dev-infra-private-ng-dev-builds.git#21604aaadd15167ee2be0d89622b7009a13cdac7" dependencies: "@yarnpkg/lockfile" "^1.1.0" @@ -3961,11 +3958,6 @@ "@types/node" "*" minipass "^4.0.0" -"@types/text-table@^0.2.1": - version "0.2.5" - resolved "https://registry.yarnpkg.com/@types/text-table/-/text-table-0.2.5.tgz#f9c609b81c943e9fc8d73ef82ad2f2a78be5f53b" - integrity sha512-hcZhlNvMkQG/k1vcZ6yHOl6WAYftQ2MLfTHcYRZ2xYZFD8tGVnE3qFV0lj1smQeDSR7/yY0PyuUalauf33bJeA== - "@types/through@*": version "0.0.33" resolved "https://registry.yarnpkg.com/@types/through/-/through-0.0.33.tgz#14ebf599320e1c7851e7d598149af183c6b9ea56"