Skip to content

Commit 09c6f5f

Browse files
committed
refactor(@angular-devkit/build-angular): remove dependency on text-table
Removes `text-table` from dependencies
1 parent dbd3984 commit 09c6f5f

File tree

5 files changed

+42
-23
lines changed

5 files changed

+42
-23
lines changed

package.json

-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@
113113
"@types/semver": "^7.3.12",
114114
"@types/shelljs": "^0.8.11",
115115
"@types/tar": "^6.1.2",
116-
"@types/text-table": "^0.2.1",
117116
"@types/watchpack": "^2.4.4",
118117
"@types/yargs": "^17.0.20",
119118
"@types/yargs-parser": "^21.0.0",
@@ -204,7 +203,6 @@
204203
"symbol-observable": "4.0.0",
205204
"tar": "^6.1.6",
206205
"terser": "5.27.0",
207-
"text-table": "0.2.0",
208206
"tree-kill": "1.2.2",
209207
"ts-node": "^10.9.1",
210208
"tslib": "2.6.2",

packages/angular_devkit/build_angular/BUILD.bazel

-2
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ ts_library(
159159
"@npm//@types/node",
160160
"@npm//@types/picomatch",
161161
"@npm//@types/semver",
162-
"@npm//@types/text-table",
163162
"@npm//@types/watchpack",
164163
"@npm//@vitejs/plugin-basic-ssl",
165164
"@npm//@web/test-runner",
@@ -203,7 +202,6 @@ ts_library(
203202
"@npm//source-map-loader",
204203
"@npm//source-map-support",
205204
"@npm//terser",
206-
"@npm//text-table",
207205
"@npm//tree-kill",
208206
"@npm//tslib",
209207
"@npm//typescript",

packages/angular_devkit/build_angular/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"source-map-loader": "5.0.0",
6060
"source-map-support": "0.5.21",
6161
"terser": "5.27.0",
62-
"text-table": "0.2.0",
6362
"tree-kill": "1.2.2",
6463
"tslib": "2.6.2",
6564
"undici": "6.4.0",

packages/angular_devkit/build_angular/src/tools/webpack/utils/stats.ts

+41-9
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88

99
import { WebpackLoggingCallback } from '@angular-devkit/build-webpack';
1010
import { logging, tags } from '@angular-devkit/core';
11-
import assert from 'assert';
12-
import * as path from 'path';
13-
import textTable from 'text-table';
11+
import assert from 'node:assert';
12+
import * as path from 'node:path';
1413
import { Configuration, StatsCompilation } from 'webpack';
1514
import { Schema as BrowserBuilderOptions } from '../../../builders/browser/schema';
1615
import { normalizeOptimization } from '../../../utils';
@@ -88,7 +87,6 @@ export function generateBuildStatsTable(
8887
const r = (x: string) => (colors ? ansiColors.redBright(x) : x);
8988
const y = (x: string) => (colors ? ansiColors.yellowBright(x) : x);
9089
const bold = (x: string) => (colors ? ansiColors.bold(x) : x);
91-
const dim = (x: string) => (colors ? ansiColors.dim(x) : x);
9290

9391
const getSizeColor = (name: string, file?: string, defaultColor = c) => {
9492
const severity = budgets.get(name) || (file && budgets.get(file));
@@ -216,11 +214,45 @@ export function generateBuildStatsTable(
216214
bundleInfo.push(['Lazy Chunk Files', ...baseTitles].map(bold), ...changedLazyChunksStats);
217215
}
218216

219-
return textTable(bundleInfo, {
220-
hsep: dim(' | '),
221-
stringLength: (s) => removeColor(s).length,
222-
align: tableAlign,
223-
});
217+
return generateTableText(bundleInfo, colors);
218+
}
219+
220+
function generateTableText(bundleInfo: (string | number)[][], colors: boolean): string {
221+
const longest: number[] = [];
222+
for (const item of bundleInfo) {
223+
for (let i = 0; i < item.length; i++) {
224+
if (item[i] === undefined) {
225+
continue;
226+
}
227+
228+
const currentItem = item[i].toString();
229+
const currentLongest = (longest[i] ??= 0);
230+
const currentItemLength = removeColor(currentItem).length;
231+
if (currentLongest < currentItemLength) {
232+
longest[i] = currentItemLength;
233+
}
234+
}
235+
}
236+
237+
const seperator = colors ? ansiColors.dim(' | ') : ' | ';
238+
const outputTable: string[] = [];
239+
for (const item of bundleInfo) {
240+
for (let i = 0; i < longest.length; i++) {
241+
if (item[i] === undefined) {
242+
continue;
243+
}
244+
245+
const currentItem = item[i].toString();
246+
const currentItemLength = removeColor(currentItem).length;
247+
const stringPad = ' '.repeat(longest[i] - currentItemLength);
248+
// Last item is right aligned, thus we add the padding at the start.
249+
item[i] = longest.length === i + 1 ? stringPad + currentItem : currentItem + stringPad;
250+
}
251+
252+
outputTable.push(item.join(seperator));
253+
}
254+
255+
return outputTable.join('\n');
224256
}
225257

226258
function generateBuildStats(hash: string, time: number, colors: boolean): string {

yarn.lock

+1-9
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@
131131
tslib "^2.3.0"
132132

133133
"@angular/bazel@https://github.com/angular/bazel-builds.git#a0e463179c1d15995508827d977565031b9ba8fb":
134-
version "17.2.0-next.0+sha-c043128"
135-
uid a0e463179c1d15995508827d977565031b9ba8fb
134+
version "17.2.0-next.0"
136135
resolved "https://github.com/angular/bazel-builds.git#a0e463179c1d15995508827d977565031b9ba8fb"
137136
dependencies:
138137
"@microsoft/api-extractor" "^7.24.2"
@@ -149,7 +148,6 @@
149148

150149
"@angular/build-tooling@https://github.com/angular/dev-infra-private-build-tooling-builds.git#103b5c2cf1be1d62b292d3c0a447b0f6918f0770":
151150
version "0.0.0-10788de8a2999c84bc16a132dfe1a0a9bc934604"
152-
uid "103b5c2cf1be1d62b292d3c0a447b0f6918f0770"
153151
resolved "https://github.com/angular/dev-infra-private-build-tooling-builds.git#103b5c2cf1be1d62b292d3c0a447b0f6918f0770"
154152
dependencies:
155153
"@angular-devkit/build-angular" "17.2.0-next.0"
@@ -317,7 +315,6 @@
317315

318316
"@angular/ng-dev@https://github.com/angular/dev-infra-private-ng-dev-builds.git#21604aaadd15167ee2be0d89622b7009a13cdac7":
319317
version "0.0.0-10788de8a2999c84bc16a132dfe1a0a9bc934604"
320-
uid "21604aaadd15167ee2be0d89622b7009a13cdac7"
321318
resolved "https://github.com/angular/dev-infra-private-ng-dev-builds.git#21604aaadd15167ee2be0d89622b7009a13cdac7"
322319
dependencies:
323320
"@yarnpkg/lockfile" "^1.1.0"
@@ -3961,11 +3958,6 @@
39613958
"@types/node" "*"
39623959
minipass "^4.0.0"
39633960

3964-
"@types/text-table@^0.2.1":
3965-
version "0.2.5"
3966-
resolved "https://registry.yarnpkg.com/@types/text-table/-/text-table-0.2.5.tgz#f9c609b81c943e9fc8d73ef82ad2f2a78be5f53b"
3967-
integrity sha512-hcZhlNvMkQG/k1vcZ6yHOl6WAYftQ2MLfTHcYRZ2xYZFD8tGVnE3qFV0lj1smQeDSR7/yY0PyuUalauf33bJeA==
3968-
39693961
"@types/through@*":
39703962
version "0.0.33"
39713963
resolved "https://registry.yarnpkg.com/@types/through/-/through-0.0.33.tgz#14ebf599320e1c7851e7d598149af183c6b9ea56"

0 commit comments

Comments
 (0)