@bymaksym/loadline 1.0.0 → 1.1.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.
Files changed (112) hide show
  1. package/README.md +211 -43
  2. package/dist/cli/cli/args.js +79 -128
  3. package/dist/cli/cli/gates.js +80 -14
  4. package/dist/cli/cli/main.js +164 -33
  5. package/dist/cli/cli/memory.js +40 -4
  6. package/dist/cli/cli/{declared.js → read/declared.js} +1 -1
  7. package/dist/cli/cli/read/locate.js +214 -0
  8. package/dist/cli/cli/{read-build.js → read/read-build.js} +149 -84
  9. package/dist/cli/cli/read/read-config.js +120 -0
  10. package/dist/cli/cli/{html-report.js → render/html-report.js} +14 -10
  11. package/dist/cli/cli/render/render-agent.js +114 -0
  12. package/dist/cli/cli/render/render-asked.js +104 -0
  13. package/dist/cli/cli/render/render-badge.js +140 -0
  14. package/dist/cli/cli/{render-json.js → render/render-json.js} +18 -5
  15. package/dist/cli/cli/{render-markdown.js → render/render-markdown.js} +5 -5
  16. package/dist/cli/cli/{render-pr.js → render/render-pr.js} +33 -13
  17. package/dist/cli/cli/{render-sarif.js → render/render-sarif.js} +8 -3
  18. package/dist/cli/cli/{render-text.js → render/render-text.js} +118 -111
  19. package/dist/cli/cli/render/terminal.js +55 -0
  20. package/dist/cli/cli/report.js +68 -27
  21. package/dist/cli/cli/self-check.js +19 -23
  22. package/dist/cli/cli/since-last.js +2 -2
  23. package/dist/cli/cli/text/text-errors.js +124 -0
  24. package/dist/cli/cli/text/text.js +343 -0
  25. package/dist/cli/cli/text/usage.js +240 -0
  26. package/dist/cli/src/app/core/analysis/analysis.js +63 -23
  27. package/dist/cli/src/app/core/analysis/{barrels.js → graph/barrels.js} +1 -1
  28. package/dist/cli/src/app/core/analysis/{blast.js → graph/blast.js} +56 -17
  29. package/dist/cli/src/app/core/analysis/{cycles.js → graph/cycles.js} +1 -1
  30. package/dist/cli/src/app/core/analysis/{importers.js → graph/importers.js} +1 -1
  31. package/dist/cli/src/app/core/analysis/{insights.js → graph/insights.js} +10 -4
  32. package/dist/cli/src/app/core/analysis/invariant.js +1 -1
  33. package/dist/cli/src/app/core/analysis/metafile.types.js +7 -1
  34. package/dist/cli/src/app/core/analysis/{delivery.js → screens/delivery.js} +1 -1
  35. package/dist/cli/src/app/core/analysis/{entries.js → screens/entries.js} +50 -9
  36. package/dist/cli/src/app/core/analysis/screens/marks.js +32 -0
  37. package/dist/cli/src/app/core/analysis/screens/route-files.js +116 -0
  38. package/dist/cli/src/app/core/analysis/{sourcemap.js → sourcemap/sourcemap.js} +106 -7
  39. package/dist/cli/src/app/core/analysis/{split-drift.js → sourcemap/split-drift.js} +1 -1
  40. package/dist/cli/src/app/core/analysis/tool.js +83 -0
  41. package/dist/cli/src/app/core/assets/assets.js +134 -15
  42. package/dist/cli/src/app/core/baseline/baseline.js +0 -0
  43. package/dist/cli/src/app/core/{intake → build-text}/index-html.js +168 -13
  44. package/dist/cli/src/app/core/build-text/route-table.js +178 -0
  45. package/dist/cli/src/app/core/build-text/tool-marks.js +54 -0
  46. package/dist/cli/src/app/core/caching/caching.js +121 -43
  47. package/dist/cli/src/app/core/caching/from-analysis.js +20 -4
  48. package/dist/cli/src/app/core/config/config-text.js +90 -0
  49. package/dist/cli/src/app/core/config/config-values.js +358 -0
  50. package/dist/cli/src/app/core/config/loadline-config.js +81 -16
  51. package/dist/cli/src/app/core/config/merge-config.js +98 -0
  52. package/dist/cli/src/app/core/deps/deps.js +104 -16
  53. package/dist/cli/src/app/core/export/summary.js +29 -5
  54. package/dist/cli/src/app/core/findings/actions.js +3 -1
  55. package/dist/cli/src/app/core/findings/{boot-single.js → bundle/boot-single.js} +3 -3
  56. package/dist/cli/src/app/core/findings/{dupes.js → bundle/dupes.js} +8 -5
  57. package/dist/cli/src/app/core/findings/{graph.js → bundle/graph.js} +30 -18
  58. package/dist/cli/src/app/core/findings/{own-in-boot.js → bundle/own-in-boot.js} +9 -5
  59. package/dist/cli/src/app/core/findings/{requests.js → bundle/requests.js} +3 -3
  60. package/dist/cli/src/app/core/findings/{shipped.js → bundle/shipped.js} +28 -14
  61. package/dist/cli/src/app/core/findings/compose.js +6 -1
  62. package/dist/cli/src/app/core/findings/effort.js +2 -0
  63. package/dist/cli/src/app/core/findings/finding.types.js +1 -0
  64. package/dist/cli/src/app/core/findings/findings.js +48 -19
  65. package/dist/cli/src/app/core/findings/{assets.js → folder/assets.js} +38 -14
  66. package/dist/cli/src/app/core/findings/{caching.js → folder/caching.js} +16 -9
  67. package/dist/cli/src/app/core/findings/{page.js → folder/page.js} +6 -2
  68. package/dist/cli/src/app/core/findings/{scan.js → folder/scan.js} +25 -11
  69. package/dist/cli/src/app/core/findings/kind-names.js +163 -0
  70. package/dist/cli/src/app/core/findings/{deps.js → supplied/deps.js} +13 -8
  71. package/dist/cli/src/app/core/findings/supplied/forbidden.js +71 -0
  72. package/dist/cli/src/app/core/findings/{situation.js → supplied/situation.js} +2 -2
  73. package/dist/cli/src/app/core/findings/text/causes.js +39 -0
  74. package/dist/cli/src/app/core/findings/{finding-html.js → text/finding-html.js} +8 -1
  75. package/dist/cli/src/app/core/findings/{finding-text.js → text/finding-text.js} +208 -77
  76. package/dist/cli/src/app/core/findings/text/tool-advice.js +97 -0
  77. package/dist/cli/src/app/core/format/format.utils.js +158 -11
  78. package/dist/cli/src/app/core/format/ownership.js +93 -0
  79. package/dist/cli/src/app/core/i18n/en.js +76 -17
  80. package/dist/cli/src/app/core/i18n/es.js +82 -22
  81. package/dist/cli/src/app/core/intake/bundle-graph.js +281 -43
  82. package/dist/cli/src/app/core/intake/dist-files.js +82 -14
  83. package/dist/cli/src/app/core/intake/embedded.js +11 -1
  84. package/dist/cli/src/app/core/intake/unreached.js +139 -0
  85. package/dist/cli/src/app/core/intake/webpack-modules.js +185 -0
  86. package/dist/cli/src/app/core/intake/webpack-stats.js +298 -0
  87. package/dist/cli/src/app/core/project/project-context.js +16 -4
  88. package/dist/cli/src/app/core/project/project-name.js +36 -0
  89. package/dist/cli/src/app/core/scan/scan.js +58 -19
  90. package/dist/cli/src/app/core/scan/secrets.js +23 -3
  91. package/dist/cli/src/app/core/situation/situation-text.js +23 -0
  92. package/dist/cli/src/app/core/situation/situation.js +6 -4
  93. package/dist/cli/src/app/core/timing/timing.js +5 -2
  94. package/dist/cli/src/app/core/whatif/defer.js +29 -4
  95. package/dist/cli/src/app/core/whatif/source-importers.js +58 -0
  96. package/dist/cli/src/app/core/whatif/why.js +102 -0
  97. package/docs/CONFIG-REFERENCE.md +230 -0
  98. package/docs/CONFIG.md +511 -0
  99. package/docs/HOW-IT-WORKS.md +286 -25
  100. package/loadline.html +24 -20
  101. package/loadline.schema.json +1209 -0
  102. package/package.json +35 -29
  103. package/dist/cli/cli/locate.js +0 -60
  104. package/dist/cli/cli/text.js +0 -215
  105. /package/dist/cli/cli/{read-build.types.js → read/read-build.types.js} +0 -0
  106. /package/dist/cli/cli/{render-json.types.js → render/render-json.types.js} +0 -0
  107. /package/dist/cli/cli/{text.types.js → text/text.types.js} +0 -0
  108. /package/dist/cli/src/app/core/analysis/{exclusive.js → graph/exclusive.js} +0 -0
  109. /package/dist/cli/src/app/core/analysis/{insights.types.js → graph/insights.types.js} +0 -0
  110. /package/dist/cli/src/app/core/analysis/{module-graph.js → graph/module-graph.js} +0 -0
  111. /package/dist/cli/src/app/core/analysis/{sourcemap.types.js → sourcemap/sourcemap.types.js} +0 -0
  112. /package/dist/cli/src/app/core/findings/{finding-plain.js → text/finding-plain.js} +0 -0
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ /**
3
+ * What `loadline.json` forbids, found in the build: one signal per rule that matches.
4
+ *
5
+ * Every other signal is this tool's opinion about a build. This one is the team's, written down in
6
+ * `forbidden`, and the tool only says where the rule is broken and which import breaks it. That is
7
+ * why it is high whatever the size: the team already decided it matters, and a 2 kB `moment` locale
8
+ * breaks "no moment" exactly as much as the whole library does.
9
+ *
10
+ * The key of each signal is the rule as written — `moment`, `src/app/admin/*` — rather than what it
11
+ * matched, so an acceptance names the same text the rule does.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.buildForbiddenFindings = void 0;
15
+ const format_utils_1 = require("../../format/format.utils");
16
+ const finding_html_1 = require("../text/finding-html");
17
+ const finding_text_1 = require("../text/finding-text");
18
+ /** Names listed on the card before "and N more": enough to recognise the rule, not a dump. */
19
+ const LISTED = 5;
20
+ const matches = (rule, module) => rule.package === undefined
21
+ ? !module.pkg && (0, format_utils_1.namedBy)(rule.path ?? '', module.path)
22
+ : !!module.pkg && (0, format_utils_1.matchesStars)(rule.package, module.pkg);
23
+ const buildForbiddenFindings = (analysis, rules, lang) => {
24
+ if (!rules || rules.length === 0) {
25
+ return [];
26
+ }
27
+ const insights = analysis.insights();
28
+ return rules.flatMap(rule => {
29
+ const inBoot = rule.in === 'bootstrap';
30
+ const hits = analysis.modules
31
+ .filter(module => matches(rule, module))
32
+ .map(module => ({
33
+ module,
34
+ bytes: module.places
35
+ .filter(place => !inBoot || place.zone === 'boot')
36
+ .reduce((sum, place) => sum + place.bytes, 0),
37
+ }))
38
+ .filter(hit => hit.bytes > 0)
39
+ .toSorted((a, b) => b.bytes - a.bytes);
40
+ const first = hits[0];
41
+ if (!first) {
42
+ return [];
43
+ }
44
+ const key = rule.package ?? rule.path ?? '';
45
+ const files = hits.map(hit => hit.module.path);
46
+ const bytes = hits.reduce((sum, hit) => sum + hit.bytes, 0);
47
+ const names = [...new Set(hits.map(hit => hit.module.pkg ?? hit.module.label))];
48
+ const chain = analysis.chainTo(first.module.path);
49
+ return [
50
+ {
51
+ severity: 'high',
52
+ target: { tab: 'search', key },
53
+ kind: 'forbidden',
54
+ size: bytes,
55
+ ...(inBoot && { saving: insights.exclusiveOf(files) }),
56
+ sources: files,
57
+ ...finding_text_1.TEXT[lang].forbidden({
58
+ rule: key,
59
+ ruleHtml: (0, finding_html_1.mono)((0, finding_html_1.escapeHtml)(key)),
60
+ inBoot,
61
+ why: (0, finding_html_1.escapeHtml)(rule.why),
62
+ size: (0, format_utils_1.formatBytes)(bytes),
63
+ names: names.slice(0, LISTED).map(name => (0, finding_html_1.mono)(name)),
64
+ more: Math.max(0, names.length - LISTED),
65
+ chain: chain && chain.length > 1 ? (0, finding_html_1.chainHtml)((0, format_utils_1.chainSteps)(chain)) : null,
66
+ }),
67
+ },
68
+ ];
69
+ });
70
+ };
71
+ exports.buildForbiddenFindings = buildForbiddenFindings;
@@ -22,8 +22,8 @@
22
22
  */
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.buildSituationFindings = void 0;
25
- const situation_1 = require("../situation/situation");
26
- const finding_text_1 = require("./finding-text");
25
+ const situation_1 = require("../../situation/situation");
26
+ const finding_text_1 = require("../text/finding-text");
27
27
  /**
28
28
  * Which signal being on the report makes which question worth asking.
29
29
  *
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ /**
3
+ * What a change against the baseline is made of, as the growth signals print it: "`xlsx` ≈+118 kB
4
+ * (new)". The delta alone answers "how much"; the question on a merge request is "what did I add".
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.screenCausesText = exports.bootCausesText = void 0;
8
+ const format_utils_1 = require("../../format/format.utils");
9
+ const finding_html_1 = require("./finding-html");
10
+ const finding_text_1 = require("./finding-text");
11
+ /** How many causes the bootstrap's growth names: the ones that explain it, not the whole tail. */
12
+ const BOOT_CAUSES_SHOWN = 5;
13
+ /**
14
+ * The same for each screen that grew. Lower, because that signal lists several screens in one
15
+ * sentence and each brings its own: three is enough to say where the growth is.
16
+ */
17
+ const SCREEN_CAUSES_SHOWN = 3;
18
+ /**
19
+ * One entry per cause: "`@microsoft/teams-js` ≈+19 kB (new)", "`src/app/rooms` ≈+2 kB (your code)".
20
+ * In the report's unit, with `≈` when that is an estimate.
21
+ */
22
+ const causesText = (causes, unit, lang, shown) => {
23
+ const text = finding_text_1.TEXT[lang];
24
+ const mark = unit.estimated ? '≈' : '';
25
+ return causes.slice(0, shown).map(cause => {
26
+ const notes = [text.bootCauseChange[cause.change], cause.own ? text.bootCauseOwn : ''].filter(Boolean);
27
+ const figure = `${mark}${(0, format_utils_1.formatDelta)(Math.round(cause.diff * unit.ratio))}`;
28
+ return `${(0, finding_html_1.mono)(cause.name)} ${figure}${notes.length > 0 ? ` (${notes.join(', ')})` : ''}`;
29
+ });
30
+ };
31
+ /** What the bootstrap's change is made of, as one line. Empty when nothing moved enough to name. */
32
+ const bootCausesText = (comparison, lang) => causesText(comparison.bootCauses, { ratio: comparison.causesRatio, estimated: comparison.causesEstimated }, lang, BOOT_CAUSES_SHOWN).join(' · ');
33
+ exports.bootCausesText = bootCausesText;
34
+ /**
35
+ * What one screen's change is made of, one entry per cause. Empty when either snapshot lacked the
36
+ * screen's breakdown, so the text claims none rather than an invented one.
37
+ */
38
+ const screenCausesText = (screen, lang) => causesText(screen.causes ?? [], { ratio: screen.causesRatio, estimated: screen.causesEstimated }, lang, SCREEN_CAUSES_SHOWN);
39
+ exports.screenCausesText = screenCausesText;
@@ -4,7 +4,7 @@
4
4
  * name or a version number set apart from the sentence is what makes it findable at a glance.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.fewNamed = exports.chainHtml = exports.mono = void 0;
7
+ exports.escapeHtml = exports.fewNamed = exports.chainHtml = exports.mono = void 0;
8
8
  /** A name as code: a file, a package, a configuration key. */
9
9
  const mono = (text) => `<span class="mono">${text}</span>`;
10
10
  exports.mono = mono;
@@ -24,3 +24,10 @@ const fewNamed = (items, more, max = 5) => {
24
24
  return items.length > max ? `${shown} ${more(items.length - max)}` : shown;
25
25
  };
26
26
  exports.fewNamed = fewNamed;
27
+ /**
28
+ * Text somebody wrote in `loadline.json`, made safe to put into a signal's HTML. Every other piece
29
+ * of a signal is written here or read from a build; this one is free text from a person, and a
30
+ * `<` in a reason would otherwise open a tag on the page and vanish from the terminal.
31
+ */
32
+ const escapeHtml = (text) => text.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('"', '&quot;');
33
+ exports.escapeHtml = escapeHtml;