@vernikr/size-report 2.4.0 → 2.5.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.
@@ -1,93 +1,87 @@
1
- # Шаблоны для подключаемого проекта
1
+ # Templates for a project wiring the tool in
2
2
 
3
- Два файла, которые проект берёт как есть: настройки, проходящие проверку самого
4
- инструмента, и описание проверки в CI. Ставятся они вместе с пакетом, поэтому
5
- лежат в его поставке (`files` в `package.json`) и стерегутся проверкой
6
- `test/templates.test.js`: черновик обязан быть валидным, а команды описания —
7
- существовать в инструменте.
3
+ Two files a project takes as they are: settings that pass the tool's own check, and a description of the CI
4
+ check. They are installed together with the package, which is why they travel in its delivery (`files` in
5
+ `package.json`) and are guarded by `test/templates.test.js`: the draft has to be valid, and the commands of
6
+ the description have to exist in the tool.
8
7
 
9
- | Файл | Куда | Что делать |
8
+ | File | Where | What to do |
10
9
  |---|---|---|
11
- | `size-report.config.json` | `size-table.config.json` в корне проекта | **Поправить колонки** и, если нужно, остальное |
12
- | `ci.yml` | `.github/workflows/size-report.yml` | Ничего: файл работает как есть |
10
+ | `size-report.config.json` | `size-table.config.json` in the project root | **Fix the columns** and, if needed, the rest |
11
+ | `ci.yml` | `.github/workflows/size-report.yml` | Nothing: the file works as it is |
13
12
 
14
- Отчёт в проекте появляется без ручной работы: после установки пакета и первого
15
- запуска инструмент сам ставит хуки `post-commit`/`post-merge`, и `docs/` с
16
- `size-report.html` создаётся первым же коммитом. Снять автоматику — `size
17
- uninstall-hook`, выключить, не снимая, — `"hooks": {"enabled": false}`.
13
+ The report appears in the project without manual work: after the package is installed and the tool runs for
14
+ the first time, it installs the hooks `post-commit`/`post-merge` itself, and `docs/size-report.html` is
15
+ created by the very first commit. To take the automation away — `size uninstall-hook`; to switch it off
16
+ without removing it — `"hooks": {"enabled": false}`.
18
17
 
19
- ## Настройки
18
+ ## Settings
20
19
 
21
- **Файл настроек заводить не нужно.** Без него инструмент выводит профиль из самого
22
- проекта: колонками каждый отслеживаемый файл, который можно измерить (отчёт тогда
23
- описывает проект целиком, а не несколько самых крупных его файлов), журналом —
24
- первый знакомый (`WORKLOG.md`,
25
- `CHANGELOG.md`, …), файлом отчёта `docs/`, если каталог есть, командой починки
26
- объявленный скрипт `sizes`, ссылкой на коммит адрес `origin`. О том, что настройки
27
- выведены, инструмент говорит строкой, а закрепляет их файлом `size --init`: дальше
28
- это обычные настройки, которые правят руками.
20
+ **A settings file is not needed.** Without one the tool derives the profile from the project itself: the
21
+ columns are every tracked file that can be measured (the report then describes the project as a whole rather
22
+ than a few of its largest files), the journal is the first familiar one (`WORKLOG.md`, `CHANGELOG.md`, …),
23
+ the report file is `docs/size-report.html`, the fix command is the declared `sizes` script, and the commit
24
+ link comes from the `origin` address. That the settings were derived the tool says in a line, and it pins
25
+ them to a file with `size --init`: from then on they are ordinary settings, edited by hand.
29
26
 
30
- Этот образец для другого случая: хочется начать с правленого файла или посмотреть
31
- все ключи сразу. **Колонки в нём пример**, а не список ваших файлов: в шаблоне стоят
32
- `README.md` и `package.json`, потому что они есть почти в любом проекте, и с ними
33
- первый отчёт соберётся сразу. Свои колонки у `size --init` (он берёт их из вашего
34
- дерева и истории; доки в него входят): либо взять его файл целиком и перенести из
35
- шаблона ключи, которых там нет, либо скопировать шаблон и вписать колонки руками.
36
- Отсюда же растёт ожидаемое: колонки примерные, поэтому `size check` скажет, что
37
- README и журнал колонкой не отслеживаются, — так и задумано.
27
+ This sample is for another case: starting from an edited file, or seeing all the keys at once. **Its columns
28
+ are an example** rather than a list of your files: the template holds `README.md` and `package.json` because
29
+ nearly any project has them, and with them the first report is assembled at once. Your own columns come from
30
+ `size --init` (it takes them from your tree and history; documentation is included): either take its file
31
+ whole and carry over the keys the template has and it does not, or copy the template and write the columns in
32
+ by hand. The expectation grows from the same place: the columns are examples, so `size check` will name the
33
+ paths that are not columns the project's own sources and its journal — and that is deliberate.
38
34
 
39
- Что стоит знать про значения шаблона:
35
+ What is worth knowing about the template's values:
40
36
 
41
- - `metrics: ["raw", "min", "tok"]` — три измерения отчёта. `min` считается
42
- настоящим минификатором (`minify.engine: "esbuild"`), а `tok` словарём
43
- `o200k_base`. Оба едут необязательными зависимостями пакета и ставятся обычной
44
- установкой; если их нет (установка без необязательных зависимостей, платформа
45
- без них), инструмент работает, но честно говорит, что числа получены другим
46
- счётом, и отдаёт **код 4** — это не ошибка настройки, а названное приближение.
47
- - `fixCommand` — команда, которую цитирует подпись отчёта и отказы. В шаблоне это
48
- `node node_modules/@vernikr/size-report/bin/size.js --write` — путь к
49
- установленному пакету внутри проекта. **Имени пакета как команды здесь быть не
50
- может:** `npx <имя>` в проекте без установленного пакета уходит в реестр и тянет
51
- пакет по сети, то есть совет, который должен выручать, зависит от доступа к
52
- реестру и от того, что там лежит. Если в проекте есть свой
53
- скрипт, например `pnpm run sizes`, впишите его: подпись отчёта будет вести
54
- к нему.
55
- - `journal: null` ссылок на разделы журнала не будет. Если в проекте есть
56
- `WORKLOG.md` или `CHANGELOG.md`, поставьте объект с `path`, `url`, `pattern`
57
- именно этот объект выводит `size --init`, когда журнал в проекте есть.
58
- - `paths` внутри колонки псевдонимы одного файла: если файл переименовывали,
59
- перечислите и старое имя, и новое, и колонка не разорвётся.
60
- - `output: "docs/size-report.html"` файл отчёта (он один: самодостаточная страница со всеми числами, фильтрами и ссылкой); каталог инструмент создаст сам. Хук обновления ставится сам — скриптом установки (npm, yarn) или первым запуском (pnpm 10 не исполняет скрипты зависимостей, если не разрешить `pnpm.onlyBuiltDependencies`), и после каждого коммита отчёт пересобирается. Первый отчёт остаётся неотслеживаемым, пока вы не добавите его в git; дальше он обновляется коммитами сам.
37
+ - `metrics: ["raw", "min", "tok"]` — the report's three measurements. `min` is counted by the real minifier
38
+ (`minify.engine: "esbuild"`) and `tok` by the `o200k_base` dictionary. Both travel as optional
39
+ dependencies of the package and are installed by an ordinary installation; without them (an installation
40
+ without the optional dependencies, a platform that has none) the tool still works, but says honestly that
41
+ the numbers were counted another way, and returns **code 4** that is a named approximation rather than
42
+ an error of the settings.
43
+ - `fixCommand` — the command the report's signature and the refusals quote. In the template it is
44
+ `node node_modules/@vernikr/size-report/bin/size.js --write` — the path to the installed package inside
45
+ the project. **The package name as a command cannot stand here:** `npx <name>` in a project without the
46
+ installed package goes to the registry and pulls the package over the network, so the advice that is meant
47
+ to help would depend on access to the registry and on what lies there. If the project has a script of its
48
+ own `pnpm run sizes`, say write it in: the report's signature will lead to it.
49
+ - `journal: null` there will be no references to journal sections. If the project has `WORKLOG.md` or
50
+ `CHANGELOG.md`, put an object with `path`, `url` and `pattern`: that very object is what `size --init`
51
+ derives when the project has a journal.
52
+ - `paths` inside a column are aliases of one file: if the file was renamed, list both the old name and the
53
+ new one, and the column will not break apart.
54
+ - `output: "docs/size-report.html"` the report file (there is one of it: a self-contained page with all the
55
+ numbers, the filters and the link); the tool creates the directory itself. The updating hook is installed by
56
+ itselfby the install script (npm, yarn) or by the first run (pnpm 10 does not run dependency scripts
57
+ unless `pnpm.onlyBuiltDependencies` allows it) — and the report is rebuilt after every commit. The first
58
+ report stays untracked until you add it to git; from then on it updates itself by commits.
61
59
 
62
- ## Проверка в CI
60
+ ## The check in CI
63
61
 
64
- Скопируйте `ci.yml` в `.github/workflows/size-report.yml` — правок он не требует,
65
- если проект на `pnpm`. Что он делает и почему именно так, написано в его
66
- комментариях; коротко: собирает таблицу заново и сверяет с файлом на диске,
67
- а затем снимает данные отчёта дважды обычно и в среде, где настроек git нет
68
- вовсе (`GIT_CONFIG_GLOBAL=/dev/null`), и сравнивает снимки побайтово. Второе и
69
- есть проверка того, что числа не зависят от машины.
62
+ Copy `ci.yml` to `.github/workflows/size-report.yml` — it needs no edits if the project is on `pnpm`. What it
63
+ does and why exactly so is written in its comments; in short: it assembles the table again and compares it
64
+ with the file on disk, then takes the report's data twice — usually and in an environment with no git
65
+ settings at all (`GIT_CONFIG_GLOBAL=/dev/null`) and compares the snapshots byte for byte. The second one is
66
+ the check that the numbers do not depend on the machine.
70
67
 
71
- Своих секретов описание не требует и не должно: пакет ставится из публичного
72
- репозитория, а pnpm тянет его архив по HTTPS ни ключа, ни токена ни установке,
73
- ни самой проверке не нужно. Если проект уйдёт на приватный registry или на свою
74
- копию пакета, шаг с ключом придётся добавить самому: заводить его в шаблоне за
75
- проект инструмент не должен.
68
+ It needs no secrets of its own, and must not: the package is installed from a public repository, and pnpm
69
+ pulls its archive over HTTPS neither the installation nor the check itself needs a key or a token. Should
70
+ the project move to a private registry or to a copy of the package of its own, the key step will have to be
71
+ added by hand: bringing it into the template on the project's behalf is not the tool's business.
76
72
 
77
- Для `npm` и `yarn` в файле сказано, какие две строки заменить.
73
+ For `npm` and `yarn` the file itself says what to replace.
78
74
 
79
- Проверки полноты (`pnpm exec size check`) в шаблоне намеренно нет: она требует,
80
- чтобы **каждый** путь истории был колонкой или исключением, а колонки в шаблоне
81
- примерные, и на проекте, где они ещё не подобраны, такая проверка была бы красной
82
- не по делу. Когда колонки обрисуют проект, добавьте шаг сами: `check` назовёт
83
- пути, которые колонкой не отслеживаются, и коммиты, которые их завели; те, что
84
- считать не нужно, вписываются в `skip` тот же список делает путь и исключением.
85
- Про один коммит отвечает `pnpm exec size explain <sha>`.
75
+ There is deliberately no completeness check (`pnpm exec size check`) in the template: it demands that
76
+ **every** path of the history be a column or an exception, while the template's columns are examples — and in
77
+ a project whose columns are not chosen yet such a check would be red for no reason. Once the columns describe
78
+ the project, add the step yourself: `check` names the paths a column does not track and the commits that
79
+ introduced them; those that need not be counted go to `skip` — the same list makes a path an exception as
80
+ well. About a single commit `pnpm exec size explain <sha>` answers.
86
81
 
87
- ## Чего в шаблонах нет
82
+ ## What the templates do not have
88
83
 
89
- Блока для файлов агентов проекта (`AGENTS.md` и подобных) здесь нет намеренно:
90
- требования такого файла не просят, а выдумывать формат чужого репозитория
91
- инструмент не должен. Что агенту нужно знать, он возьмёт из `size --help` и
92
- `size --data` команды и данные описаны в `README.md` пакета, раздел
93
- «Для ИИ-агента».
84
+ A block for the project's own agent files (`AGENTS.md` and the like) is deliberately absent here: the
85
+ requirements do not ask for such a file, and inventing the format of someone else's repository is not
86
+ something the tool should do. What an agent needs to know it will take from `size --help` and `size --data` —
87
+ the commands and the data are described in the package's `README.md`, section "For an AI agent".
package/templates/ci.yml CHANGED
@@ -1,31 +1,31 @@
1
- # Проверка объёма для проекта, подключившего @vernikr/size-report.
2
- # Положите файл в .github/workflows/size-report.yml — правок он не требует.
1
+ # Checking the size for a project that has installed @vernikr/size-report.
2
+ # Put the file in .github/workflows/size-report.yml — it needs no edits.
3
3
  #
4
- # Что проверяется и почему так:
5
- # * отчёт на диске сходится с историей git — это его числа (отчёт один:
6
- # самодостаточная страница `size-report.html`);
7
- # * тот же снимок чисел, снятый в среде, где настроек git нет вовсе,
8
- # совпадает побайтово: вывод инструмента не должен зависеть от того, что
9
- # настроено на машине (BLOCKERS.md §B1, §B2).
4
+ # What is checked, and why it is done this way:
5
+ # * the report on disk agrees with the git history these are its numbers (the report is one:
6
+ # the self-contained page `size-report.html`);
7
+ # * the same snapshot of numbers, taken in an environment where there are no git settings at all,
8
+ # is byte-identical: the output of the tool must not depend on what is
9
+ # configured on the machine (BLOCKERS.md §B1, §B2).
10
10
  #
11
- # Секретов шаблон не требует и не может потребовать: пакет ставится из
12
- # публичного репозитория, а pnpm тянет его архив с codeload.github.com по HTTPS —
13
- # ни ключа, ни токена установке не нужно (проверено установкой в окружении без
14
- # настроек git и без помощника учётных данных; README пакета, §1). Если проект
15
- # уйдёт на приватный registry, шаг с ключом придётся добавить самому.
11
+ # The template requires no secrets and cannot require any: the package comes from
12
+ # a public repository, and pnpm pulls its archive from codeload.github.com over HTTPS —
13
+ # the install needs neither a key nor a token (proved by an install in an environment without
14
+ # git settings and without a credential helper; the package's README, §1). If the project
15
+ # moves to a private registry, the step with a key is yours to add.
16
16
  #
17
- # Менеджер пакетов: ниже pnpm. Для npm — `npm ci` вместо `pnpm install`,
18
- # для yarn — `yarn --immutable`. Сама проверка всегда одна и та же команда
19
- # `size`: локальный бинарь, поставленный установкой пакета (`pnpm exec size` после
20
- # `pnpm install`, `npm exec size` после `npm ci`).
21
- # Имени пакета как команды здесь нет намеренно: `npx <имя>` в проекте без
22
- # установленного пакета уходит в реестр и тянет пакет оттуда по сети, тогда как
23
- # шаг проверки обязан работать на том, что поставлено установкой.
24
- # Нужен явный путь — `node node_modules/@vernikr/size-report/bin/size.js`.
17
+ # The package manager: pnpm below. For npm — `npm ci` instead of `pnpm install`,
18
+ # for yarn — `yarn --immutable`. The check itself is always the same command
19
+ # `size`: the local binary the install puts there (`pnpm exec size` after
20
+ # `pnpm install`, `npm exec size` after `npm ci`).
21
+ # The package name as a command is deliberately absent here: `npx <name>` in a project
22
+ # without the package installed goes to the registry and pulls it over the network, while
23
+ # the check step has to work on what the install put there.
24
+ # An explicit path is what is needed — `node node_modules/@vernikr/size-report/bin/size.js`.
25
25
  #
26
- # Отчёт не в git? Такое тоже задумано требованиями (отчёт выводимый артефакт):
27
- # тогда вместо шага «Отчёт совпадает с историей» поставьте сборку
28
- # `pnpm exec size --write` — и этот шаг будет проверять, что отчёт собирается.
26
+ # The report is not in git? The requirements foresee that too (the report is a derived artifact):
27
+ # then instead of the step «the report agrees with the history» put the build
28
+ # `pnpm exec size --write` — and that step will check that the report assembles.
29
29
 
30
30
  name: size-report
31
31
 
@@ -35,8 +35,8 @@ jobs:
35
35
  size:
36
36
  runs-on: ubuntu-latest
37
37
  steps:
38
- # История нужна целиком: отчёт строится по коммитам, и на обрезанном
39
- # клоне инструмент отказывается работать (код 3), а не пишет короткую.
38
+ # The whole history is needed: the report is built from the commits, and on a truncated
39
+ # clone the tool refuses to work (code 3) rather than writing a short one.
40
40
  - uses: actions/checkout@v7
41
41
  with:
42
42
  fetch-depth: 0
@@ -48,21 +48,21 @@ jobs:
48
48
  node-version: 22
49
49
  cache: pnpm
50
50
 
51
- - name: Установка
51
+ - name: Setup
52
52
  run: pnpm install --frozen-lockfile
53
53
 
54
- # Проверка та же команда `size` без ключей: она собирает отчёт заново
55
- # и сверяет с файлом на диске. Своего набора тестов потребителю не нужно.
56
- - name: Отчёт совпадает с историей
54
+ # The check is the same `size` command without flags: it assembles the report anew
55
+ # and compares it with the file on disk. A consumer needs no test set of its own.
56
+ - name: The report agrees with the history
57
57
  run: pnpm exec size
58
58
 
59
- - name: Снимок чисел контракта
59
+ - name: A snapshot of the contract numbers
60
60
  run: pnpm exec size --data > /tmp/size-report-data.json
61
61
 
62
- - name: Снимок чисел без настроек git на машине
62
+ - name: A snapshot of numbers without the machine's git settings
63
63
  run: pnpm exec size --data > /tmp/size-report-data-null.json
64
64
  env:
65
65
  GIT_CONFIG_GLOBAL: /dev/null
66
66
 
67
- - name: Числа не зависят от настроек машины
67
+ - name: The numbers do not depend on the machine's settings
68
68
  run: diff -u /tmp/size-report-data.json /tmp/size-report-data-null.json
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "output": "docs/size-report.html",
3
- "locale": "ru",
4
- "title": "Объём файлов по коммитам",
5
- "heading": "Объём файлов по коммитам",
3
+ "locale": "en",
4
+ "title": "File size by commit",
5
+ "heading": "File size by commit",
6
6
  "fixCommand": "node node_modules/@vernikr/size-report/bin/size.js --write",
7
7
  "metrics": [
8
8
  "raw",