ng-checkup 0.1.0 → 0.3.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.
- package/README.md +255 -59
- package/dist/baseline.d.ts +72 -0
- package/dist/baseline.js +82 -0
- package/dist/baseline.js.map +1 -0
- package/dist/checks/change-detection.js +5 -0
- package/dist/checks/change-detection.js.map +1 -1
- package/dist/checks/circular-deps.js +3 -0
- package/dist/checks/circular-deps.js.map +1 -1
- package/dist/checks/components.js +5 -0
- package/dist/checks/components.js.map +1 -1
- package/dist/checks/deprecated-apis.js +5 -0
- package/dist/checks/deprecated-apis.js.map +1 -1
- package/dist/checks/state.js +5 -0
- package/dist/checks/state.js.map +1 -1
- package/dist/checks/testing.js +3 -0
- package/dist/checks/testing.js.map +1 -1
- package/dist/checks/type-safety.js +26 -6
- package/dist/checks/type-safety.js.map +1 -1
- package/dist/checks/version.js +5 -0
- package/dist/checks/version.js.map +1 -1
- package/dist/cli.d.ts +69 -12
- package/dist/cli.js +246 -45
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +49 -0
- package/dist/config.js +98 -0
- package/dist/config.js.map +1 -0
- package/dist/files.d.ts +5 -1
- package/dist/files.js +10 -4
- package/dist/files.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +92 -0
- package/dist/init.js +239 -0
- package/dist/init.js.map +1 -0
- package/dist/report/html.js +24 -0
- package/dist/report/html.js.map +1 -1
- package/dist/report/markdown.js +14 -0
- package/dist/report/markdown.js.map +1 -1
- package/dist/report/terminal.js +21 -0
- package/dist/report/terminal.js.map +1 -1
- package/dist/types.d.ts +23 -0
- package/dist/workspace.d.ts +6 -0
- package/dist/workspace.js +1 -0
- package/dist/workspace.js.map +1 -1
- package/package.json +10 -3
- package/schematics/collection.json +10 -0
- package/schematics/ng-add/index.cjs +65 -0
- package/schematics/ng-add/schema.json +29 -0
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { existsSync, mkdirSync, realpathSync, statSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import { dirname, extname, resolve } from 'node:path';
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, realpathSync, statSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { dirname, extname, join, resolve } from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { parseArgs } from 'node:util';
|
|
6
|
+
import { BASELINE_FILE, baselineIncreases, compareWithBaseline, createBaseline, readBaseline, serializeBaseline } from './baseline.js';
|
|
7
|
+
import { loadConfig } from './config.js';
|
|
6
8
|
import { runCheckup, TOOL } from './index.js';
|
|
9
|
+
import { planInit } from './init.js';
|
|
7
10
|
import { renderHtml } from './report/html.js';
|
|
8
11
|
import { renderMarkdown } from './report/markdown.js';
|
|
9
12
|
import { renderTerminal } from './report/terminal.js';
|
|
10
13
|
const HELP = `Usage: ng-checkup [path] [options]
|
|
14
|
+
ng-checkup init [path] [init options]
|
|
15
|
+
ng-checkup baseline [path] [--force]
|
|
11
16
|
|
|
12
17
|
A one-minute modernization report for an Angular codebase. Reads the code,
|
|
13
18
|
never changes it, and sends nothing anywhere except one npm registry lookup
|
|
@@ -21,25 +26,38 @@ Options:
|
|
|
21
26
|
.html, .md or .json. Repeatable.
|
|
22
27
|
--json Print the report as JSON to stdout instead of the summary
|
|
23
28
|
-v, --verbose Print every finding with its files
|
|
24
|
-
--fail-on <grade> Exit with code 1 if any area is graded <grade> or worse
|
|
25
|
-
poor or fair
|
|
29
|
+
--fail-on <grade> Exit with code 1 if any area is graded <grade> or worse
|
|
30
|
+
(poor or fair), or with regression if a measure is
|
|
31
|
+
worse than the baseline (for CI)
|
|
26
32
|
--max-examples <n> Example files listed per finding (default 5)
|
|
27
33
|
--offline Do not look up the latest Angular version online
|
|
34
|
+
--config <file> Config file (default: ng-checkup.config.json in the root)
|
|
28
35
|
--no-color Plain output (also off when NO_COLOR is set or not a TTY)
|
|
29
36
|
-h, --help Show this help
|
|
30
37
|
--version Show the version
|
|
31
38
|
|
|
39
|
+
Init options (ng-checkup init):
|
|
40
|
+
--ci <provider> auto (default), github, gitlab or none
|
|
41
|
+
--dry-run Show what would change without writing anything
|
|
42
|
+
--force Replace an existing "checkup" script
|
|
43
|
+
|
|
44
|
+
Baseline options (ng-checkup baseline):
|
|
45
|
+
--force Accept measures that went up since the last baseline
|
|
46
|
+
|
|
32
47
|
Examples:
|
|
33
48
|
npx ng-checkup
|
|
34
49
|
npx ng-checkup ../my-app --report checkup.html
|
|
35
|
-
npx ng-checkup --fail-on poor --report checkup.md
|
|
50
|
+
npx ng-checkup --fail-on poor --report checkup.md
|
|
51
|
+
npx ng-checkup init
|
|
52
|
+
npx ng-checkup baseline && npx ng-checkup --fail-on regression`;
|
|
36
53
|
/** Grades in order of how bad they are, for `--fail-on`. */
|
|
37
54
|
const SEVERITY_ORDER = ['good', 'fair', 'poor'];
|
|
38
55
|
/**
|
|
39
|
-
* Parses `argv` (without the node and script entries)
|
|
40
|
-
* whose message is meant for the user on anything invalid,
|
|
41
|
-
* prints with the hint to `--help`. Returns `'help'` or
|
|
42
|
-
* two flags so `main` can print and exit before doing
|
|
56
|
+
* Parses `argv` (without the node and script entries) of a checkup run.
|
|
57
|
+
* Throws an `Error` whose message is meant for the user on anything invalid,
|
|
58
|
+
* which `main` prints with the hint to `--help`. Returns `'help'` or
|
|
59
|
+
* `'version'` for those two flags so `main` can print and exit before doing
|
|
60
|
+
* any work.
|
|
43
61
|
*/
|
|
44
62
|
export function parseCliArguments(argv, environment = process.env, isTty = Boolean(process.stdout.isTTY)) {
|
|
45
63
|
const { values, positionals } = parseArgs({
|
|
@@ -52,6 +70,7 @@ export function parseCliArguments(argv, environment = process.env, isTty = Boole
|
|
|
52
70
|
'fail-on': { type: 'string' },
|
|
53
71
|
'max-examples': { type: 'string' },
|
|
54
72
|
offline: { type: 'boolean' },
|
|
73
|
+
config: { type: 'string' },
|
|
55
74
|
'no-color': { type: 'boolean' },
|
|
56
75
|
help: { type: 'boolean', short: 'h' },
|
|
57
76
|
version: { type: 'boolean' },
|
|
@@ -61,22 +80,19 @@ export function parseCliArguments(argv, environment = process.env, isTty = Boole
|
|
|
61
80
|
return 'help';
|
|
62
81
|
if (values.version)
|
|
63
82
|
return 'version';
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
throw new Error(`Not a directory: ${root}`);
|
|
69
|
-
const reports = values.report ?? [];
|
|
70
|
-
for (const report of reports) {
|
|
71
|
-
if (!['.html', '.htm', '.md', '.json'].includes(extname(report).toLowerCase()))
|
|
72
|
-
throw new Error(`Unknown report format for ${report}: use .html, .md or .json`);
|
|
73
|
-
}
|
|
83
|
+
const root = parseRoot(positionals);
|
|
84
|
+
const reports = (values.report ?? []).map((report) => resolve(report));
|
|
85
|
+
for (const report of reports)
|
|
86
|
+
assertReportFormat(report);
|
|
74
87
|
const failOn = values['fail-on'];
|
|
75
|
-
if (failOn !== undefined && failOn !== 'fair' && failOn !== 'poor')
|
|
76
|
-
throw new Error(`--fail-on takes poor or
|
|
77
|
-
|
|
78
|
-
if (
|
|
79
|
-
|
|
88
|
+
if (failOn !== undefined && failOn !== 'fair' && failOn !== 'poor' && failOn !== 'regression')
|
|
89
|
+
throw new Error(`--fail-on takes poor, fair or regression, got ${failOn}`);
|
|
90
|
+
let maxExamples;
|
|
91
|
+
if (values['max-examples'] !== undefined) {
|
|
92
|
+
maxExamples = Number(values['max-examples']);
|
|
93
|
+
if (!Number.isInteger(maxExamples) || maxExamples < 0)
|
|
94
|
+
throw new Error(`--max-examples takes a whole number, got ${values['max-examples']}`);
|
|
95
|
+
}
|
|
80
96
|
return {
|
|
81
97
|
root,
|
|
82
98
|
reports,
|
|
@@ -86,8 +102,70 @@ export function parseCliArguments(argv, environment = process.env, isTty = Boole
|
|
|
86
102
|
maxExamples,
|
|
87
103
|
offline: values.offline ?? false,
|
|
88
104
|
color: !values['no-color'] && environment['NO_COLOR'] === undefined && isTty,
|
|
105
|
+
config: values.config,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/** Parses the arguments after `init`. Same error contract as `parseCliArguments`. */
|
|
109
|
+
export function parseInitArguments(argv) {
|
|
110
|
+
const { values, positionals } = parseArgs({
|
|
111
|
+
args: argv,
|
|
112
|
+
allowPositionals: true,
|
|
113
|
+
options: {
|
|
114
|
+
ci: { type: 'string' },
|
|
115
|
+
'dry-run': { type: 'boolean' },
|
|
116
|
+
force: { type: 'boolean' },
|
|
117
|
+
help: { type: 'boolean', short: 'h' },
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
if (values.help)
|
|
121
|
+
return 'help';
|
|
122
|
+
const ci = values.ci ?? 'auto';
|
|
123
|
+
if (!['auto', 'github', 'gitlab', 'none'].includes(ci))
|
|
124
|
+
throw new Error(`--ci takes auto, github, gitlab or none, got ${ci}`);
|
|
125
|
+
return { root: parseRoot(positionals), ci: ci, dryRun: values['dry-run'] ?? false, force: values.force ?? false };
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Lays the command line over the config file: every flag that was given
|
|
129
|
+
* wins, the config fills the rest, and the built-in defaults come last.
|
|
130
|
+
* Config reports resolve against the config file's directory, command-line
|
|
131
|
+
* ones were already resolved against the working directory, which is what a
|
|
132
|
+
* user typing a path expects.
|
|
133
|
+
*/
|
|
134
|
+
export function resolveSettings(args, config, configDirectory) {
|
|
135
|
+
return {
|
|
136
|
+
reports: args.reports.length > 0 ? args.reports : (config.reports ?? []).map((report) => resolve(configDirectory, report)),
|
|
137
|
+
failOn: args.failOn ?? config.failOn,
|
|
138
|
+
maxExamples: args.maxExamples ?? config.maxExamples ?? 5,
|
|
139
|
+
offline: args.offline || (config.offline ?? false),
|
|
140
|
+
ignore: config.ignore,
|
|
141
|
+
baselinePath: config.baseline ? resolve(configDirectory, config.baseline) : join(args.root, BASELINE_FILE),
|
|
89
142
|
};
|
|
90
143
|
}
|
|
144
|
+
/** Parses the arguments after `baseline`. */
|
|
145
|
+
export function parseBaselineArguments(argv) {
|
|
146
|
+
const { values, positionals } = parseArgs({
|
|
147
|
+
args: argv,
|
|
148
|
+
allowPositionals: true,
|
|
149
|
+
options: { force: { type: 'boolean' }, config: { type: 'string' }, help: { type: 'boolean', short: 'h' } },
|
|
150
|
+
});
|
|
151
|
+
if (values.help)
|
|
152
|
+
return 'help';
|
|
153
|
+
return { root: parseRoot(positionals), force: values.force ?? false, config: values.config };
|
|
154
|
+
}
|
|
155
|
+
/** The single optional path argument, checked to be a directory. */
|
|
156
|
+
function parseRoot(positionals) {
|
|
157
|
+
if (positionals.length > 1)
|
|
158
|
+
throw new Error(`Expected one path, got ${positionals.length}: ${positionals.join(' ')}`);
|
|
159
|
+
const root = resolve(positionals[0] ?? '.');
|
|
160
|
+
if (!existsSync(root) || !statSync(root).isDirectory())
|
|
161
|
+
throw new Error(`Not a directory: ${root}`);
|
|
162
|
+
return root;
|
|
163
|
+
}
|
|
164
|
+
/** Rejects a report path whose extension names no format. */
|
|
165
|
+
function assertReportFormat(path) {
|
|
166
|
+
if (!['.html', '.htm', '.md', '.json'].includes(extname(path).toLowerCase()))
|
|
167
|
+
throw new Error(`Unknown report format for ${path}: use .html, .md or .json`);
|
|
168
|
+
}
|
|
91
169
|
/** Renders a report in the format its file extension names. */
|
|
92
170
|
export function renderForFile(report, path) {
|
|
93
171
|
const extension = extname(path).toLowerCase();
|
|
@@ -98,36 +176,90 @@ export function renderForFile(report, path) {
|
|
|
98
176
|
return renderHtml(report);
|
|
99
177
|
}
|
|
100
178
|
/**
|
|
101
|
-
* True when some area is graded `failOn` or worse
|
|
102
|
-
*
|
|
179
|
+
* True when some area is graded `failOn` or worse, or, for `regression`,
|
|
180
|
+
* when the report's baseline comparison holds a regression. `info` never
|
|
181
|
+
* fails a run: it means the area could not be measured, not that it is bad.
|
|
103
182
|
*/
|
|
104
183
|
export function shouldFail(report, failOn) {
|
|
105
184
|
if (!failOn)
|
|
106
185
|
return false;
|
|
186
|
+
if (failOn === 'regression')
|
|
187
|
+
return (report.baseline?.regressions.length ?? 0) > 0;
|
|
107
188
|
const threshold = SEVERITY_ORDER.indexOf(failOn);
|
|
108
189
|
return report.checks.some((check) => check.grade !== 'info' && SEVERITY_ORDER.indexOf(check.grade) >= threshold);
|
|
109
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* Runs `ng-checkup init`: plans against the real file system, then writes
|
|
193
|
+
* the changes unless `dryRun`. Returns the plan so the caller can print it.
|
|
194
|
+
*/
|
|
195
|
+
export async function runInit(args) {
|
|
196
|
+
// The first baseline is today's code, measured offline: no measure depends
|
|
197
|
+
// on the registry. Skipped when one exists, which the planner keeps anyway.
|
|
198
|
+
const baselinePath = join(args.root, BASELINE_FILE);
|
|
199
|
+
const baseline = existsSync(baselinePath) ? undefined : serializeBaseline(createBaseline(await runCheckup(args.root, { offline: true })));
|
|
200
|
+
const plan = planInit({
|
|
201
|
+
read: (path) => {
|
|
202
|
+
const absolute = join(args.root, path);
|
|
203
|
+
return existsSync(absolute) && statSync(absolute).isFile() ? readFileSync(absolute, 'utf8') : undefined;
|
|
204
|
+
},
|
|
205
|
+
exists: (path) => existsSync(join(args.root, path)),
|
|
206
|
+
}, { ci: args.ci, force: args.force, version: TOOL.version, baseline });
|
|
207
|
+
if (!args.dryRun) {
|
|
208
|
+
for (const change of plan.changes) {
|
|
209
|
+
const target = join(args.root, change.path);
|
|
210
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
211
|
+
writeFileSync(target, change.content);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return plan;
|
|
215
|
+
}
|
|
216
|
+
/** The text `ng-checkup init` prints: what changed, what was left alone, what to run next. */
|
|
217
|
+
export function describeInitPlan(plan, dryRun) {
|
|
218
|
+
const lines = [];
|
|
219
|
+
if (plan.changes.length === 0) {
|
|
220
|
+
lines.push('Nothing to set up: ng-checkup is already configured here.');
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
lines.push(dryRun ? 'ng-checkup init would make these changes (dry run, nothing written):' : 'ng-checkup is set up:');
|
|
224
|
+
for (const change of plan.changes)
|
|
225
|
+
lines.push(` ${change.action === 'create' ? 'create' : 'update'} ${change.path.padEnd(36)} ${change.summary}`);
|
|
226
|
+
}
|
|
227
|
+
for (const note of plan.notes)
|
|
228
|
+
lines.push('', note);
|
|
229
|
+
if (!dryRun) {
|
|
230
|
+
lines.push('', 'Next:');
|
|
231
|
+
plan.nextSteps.forEach((step, index) => lines.push(` ${index + 1}. ${step}`));
|
|
232
|
+
}
|
|
233
|
+
return lines.join('\n');
|
|
234
|
+
}
|
|
110
235
|
/** Entry point. Exit codes: 0 done, 1 `--fail-on` tripped, 2 usage or runtime error. */
|
|
111
|
-
async function main() {
|
|
236
|
+
async function main(argv) {
|
|
237
|
+
if (argv[0] === 'init')
|
|
238
|
+
return mainInit(argv.slice(1));
|
|
239
|
+
if (argv[0] === 'baseline')
|
|
240
|
+
return mainBaseline(argv.slice(1));
|
|
112
241
|
let parsed;
|
|
242
|
+
let settings;
|
|
243
|
+
let baseline;
|
|
113
244
|
try {
|
|
114
|
-
parsed = parseCliArguments(
|
|
245
|
+
parsed = parseCliArguments(argv);
|
|
246
|
+
if (parsed === 'help' || parsed === 'version') {
|
|
247
|
+
process.stdout.write(`${parsed === 'help' ? HELP : TOOL.version}\n`);
|
|
248
|
+
return 0;
|
|
249
|
+
}
|
|
250
|
+
const { config, directory } = loadConfig(parsed.root, parsed.config);
|
|
251
|
+
settings = resolveSettings(parsed, config, directory);
|
|
252
|
+
baseline = readBaseline(settings.baselinePath);
|
|
253
|
+
if (settings.failOn === 'regression' && !baseline)
|
|
254
|
+
throw new Error(`--fail-on regression needs a baseline, and there is none at ${settings.baselinePath}. Create it with: ng-checkup baseline`);
|
|
115
255
|
}
|
|
116
256
|
catch (error) {
|
|
117
|
-
|
|
118
|
-
return 2;
|
|
119
|
-
}
|
|
120
|
-
if (parsed === 'help') {
|
|
121
|
-
process.stdout.write(`${HELP}\n`);
|
|
122
|
-
return 0;
|
|
257
|
+
return usageError(error);
|
|
123
258
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const report = await runCheckup(parsed.root, { offline: parsed.offline, maxExamples: parsed.maxExamples });
|
|
129
|
-
for (const path of parsed.reports) {
|
|
130
|
-
const target = resolve(path);
|
|
259
|
+
const report = await runCheckup(parsed.root, { offline: settings.offline, maxExamples: settings.maxExamples, ignore: settings.ignore });
|
|
260
|
+
if (baseline)
|
|
261
|
+
report.baseline = compareWithBaseline(report, baseline, settings.baselinePath);
|
|
262
|
+
for (const target of settings.reports) {
|
|
131
263
|
mkdirSync(dirname(target), { recursive: true });
|
|
132
264
|
writeFileSync(target, renderForFile(report, target));
|
|
133
265
|
}
|
|
@@ -136,10 +268,79 @@ async function main() {
|
|
|
136
268
|
}
|
|
137
269
|
else {
|
|
138
270
|
process.stdout.write(`${renderTerminal(report, { color: parsed.color, verbose: parsed.verbose })}\n`);
|
|
139
|
-
for (const
|
|
140
|
-
process.stdout.write(`Report written to ${
|
|
271
|
+
for (const target of settings.reports)
|
|
272
|
+
process.stdout.write(`Report written to ${target}\n`);
|
|
141
273
|
}
|
|
142
|
-
return shouldFail(report,
|
|
274
|
+
return shouldFail(report, settings.failOn) ? 1 : 0;
|
|
275
|
+
}
|
|
276
|
+
/** `ng-checkup init`. */
|
|
277
|
+
async function mainInit(argv) {
|
|
278
|
+
try {
|
|
279
|
+
const parsed = parseInitArguments(argv);
|
|
280
|
+
if (parsed === 'help') {
|
|
281
|
+
process.stdout.write(`${HELP}\n`);
|
|
282
|
+
return 0;
|
|
283
|
+
}
|
|
284
|
+
const plan = await runInit(parsed);
|
|
285
|
+
process.stdout.write(`${describeInitPlan(plan, parsed.dryRun)}\n`);
|
|
286
|
+
return 0;
|
|
287
|
+
}
|
|
288
|
+
catch (error) {
|
|
289
|
+
return usageError(error);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* `ng-checkup baseline`: records the current measures. Updating may only
|
|
294
|
+
* lower numbers; a measure that went up is refused unless `--force`, so a
|
|
295
|
+
* regression cannot be waved through by re-running the command.
|
|
296
|
+
*/
|
|
297
|
+
async function mainBaseline(argv) {
|
|
298
|
+
try {
|
|
299
|
+
const parsed = parseBaselineArguments(argv);
|
|
300
|
+
if (parsed === 'help') {
|
|
301
|
+
process.stdout.write(`${HELP}\n`);
|
|
302
|
+
return 0;
|
|
303
|
+
}
|
|
304
|
+
const written = await writeBaseline(parsed);
|
|
305
|
+
process.stdout.write(`${written}\n`);
|
|
306
|
+
return 0;
|
|
307
|
+
}
|
|
308
|
+
catch (error) {
|
|
309
|
+
return usageError(error);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Runs the analysis and writes the baseline. Returns the message to print.
|
|
314
|
+
* Offline on purpose: no measure depends on the latest Angular version.
|
|
315
|
+
*
|
|
316
|
+
* @throws When a measure went up and `force` is not set, listing each one.
|
|
317
|
+
*/
|
|
318
|
+
export async function writeBaseline(args) {
|
|
319
|
+
const { config, directory } = loadConfig(args.root, args.config);
|
|
320
|
+
const path = config.baseline ? resolve(directory, config.baseline) : join(args.root, BASELINE_FILE);
|
|
321
|
+
const previous = readBaseline(path);
|
|
322
|
+
const report = await runCheckup(args.root, { offline: true, ignore: config.ignore });
|
|
323
|
+
const next = createBaseline(report);
|
|
324
|
+
const increases = baselineIncreases(previous, next);
|
|
325
|
+
if (increases.length > 0 && !args.force) {
|
|
326
|
+
throw new Error(`these measures went up since the last baseline, which only ever goes down:\n${increases.map((entry) => ` ${entry.key}: ${entry.before} -> ${entry.after}`).join('\n')}\nFix them, or accept the new numbers with: ng-checkup baseline --force`);
|
|
327
|
+
}
|
|
328
|
+
writeFileSync(path, serializeBaseline(next));
|
|
329
|
+
const lowered = previous ? Object.entries(next.measures).filter(([key, value]) => previous.measures[key] !== undefined && value < previous.measures[key]) : [];
|
|
330
|
+
const lines = [`Baseline ${previous ? 'updated' : 'written'}: ${path} (${Object.keys(next.measures).length} measures)`];
|
|
331
|
+
for (const [key, value] of lowered)
|
|
332
|
+
lines.push(` lowered ${key}: ${previous.measures[key]} -> ${value}`);
|
|
333
|
+
if (increases.length > 0)
|
|
334
|
+
for (const entry of increases)
|
|
335
|
+
lines.push(` raised (--force) ${entry.key}: ${entry.before} -> ${entry.after}`);
|
|
336
|
+
if (!previous)
|
|
337
|
+
lines.push('Commit it, then run ng-checkup --fail-on regression in CI: it fails only when a number gets worse.');
|
|
338
|
+
return lines.join('\n');
|
|
339
|
+
}
|
|
340
|
+
/** Prints a user-facing error with the hint to `--help` and returns exit code 2. */
|
|
341
|
+
function usageError(error) {
|
|
342
|
+
process.stderr.write(`ng-checkup: ${error instanceof Error ? error.message : String(error)}\nRun ng-checkup --help for usage.\n`);
|
|
343
|
+
return 2;
|
|
143
344
|
}
|
|
144
345
|
/**
|
|
145
346
|
* True when this file is the process entry point. Compared through
|
|
@@ -156,7 +357,7 @@ function isEntryPoint() {
|
|
|
156
357
|
}
|
|
157
358
|
}
|
|
158
359
|
if (isEntryPoint()) {
|
|
159
|
-
main().then((code) => {
|
|
360
|
+
main(process.argv.slice(2)).then((code) => {
|
|
160
361
|
process.exitCode = code;
|
|
161
362
|
}, (error) => {
|
|
162
363
|
process.stderr.write(`ng-checkup failed: ${error instanceof Error ? (error.stack ?? error.message) : String(error)}\n`);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACvF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACtD,OAA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AE,EAAE;QACP,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAC1B,CAAC,EACD,CAAC,KAAc,EAAE,EAAE;QACjB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACxH,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** The file `ng-checkup` reads from the analysed root when no `--config` is given. */
|
|
2
|
+
export declare const CONFIG_FILE = "ng-checkup.config.json";
|
|
3
|
+
/**
|
|
4
|
+
* What `ng-checkup.config.json` may set. Every key is optional and every one
|
|
5
|
+
* has a command-line flag that overrides it, so a config file only ever
|
|
6
|
+
* supplies defaults: a developer running `npx ng-checkup --report x.md` gets
|
|
7
|
+
* exactly that, whatever the file says.
|
|
8
|
+
*/
|
|
9
|
+
export interface CheckupConfig {
|
|
10
|
+
/** Report files to write, relative to the config file's directory. */
|
|
11
|
+
reports?: string[];
|
|
12
|
+
/** As `--fail-on`. `regression` fails only when a measure is worse than the baseline. */
|
|
13
|
+
failOn?: 'fair' | 'poor' | 'regression';
|
|
14
|
+
/** As `--max-examples`. */
|
|
15
|
+
maxExamples?: number;
|
|
16
|
+
/** As `--offline`. */
|
|
17
|
+
offline?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Paths left out of the analysis, relative to the root: `src/legacy`,
|
|
20
|
+
* `**\/generated`, `apps/*\/e2e`. A pattern matches a file or a directory and
|
|
21
|
+
* everything below it; `*` stops at `/`, `**` does not.
|
|
22
|
+
*/
|
|
23
|
+
ignore?: string[];
|
|
24
|
+
/** The baseline file, relative to the config file. Defaults to `ng-checkup.baseline.json` in the root. */
|
|
25
|
+
baseline?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Reads and validates the config file.
|
|
29
|
+
*
|
|
30
|
+
* @param explicitPath A path given with `--config`. It must exist; the default
|
|
31
|
+
* file may be absent, which simply means no config.
|
|
32
|
+
* @returns The parsed config and the directory its relative paths resolve
|
|
33
|
+
* against, or an empty config when there is no file.
|
|
34
|
+
* @throws An `Error` whose message is meant for the user on malformed JSON,
|
|
35
|
+
* an unknown key or a value of the wrong type. A typo such as `failon`
|
|
36
|
+
* fails loudly instead of being silently ignored, which would leave CI
|
|
37
|
+
* passing on a threshold nobody set.
|
|
38
|
+
*/
|
|
39
|
+
export declare function loadConfig(root: string, explicitPath?: string): {
|
|
40
|
+
config: CheckupConfig;
|
|
41
|
+
directory: string;
|
|
42
|
+
path?: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Compiles `ignore` patterns into one predicate over report paths (relative
|
|
46
|
+
* to the root, `/`-separated). Undefined when there are no patterns, so the
|
|
47
|
+
* file walk can skip the check entirely.
|
|
48
|
+
*/
|
|
49
|
+
export declare function ignoreMatcher(patterns: string[] | undefined): ((relativePath: string) => boolean) | undefined;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { extname, join, resolve } from 'node:path';
|
|
3
|
+
/** The file `ng-checkup` reads from the analysed root when no `--config` is given. */
|
|
4
|
+
export const CONFIG_FILE = 'ng-checkup.config.json';
|
|
5
|
+
/** Keys the file may contain. `$schema` is accepted so editors can attach one later. */
|
|
6
|
+
const KNOWN_KEYS = new Set(['$schema', 'reports', 'failOn', 'maxExamples', 'offline', 'ignore', 'baseline']);
|
|
7
|
+
/**
|
|
8
|
+
* Reads and validates the config file.
|
|
9
|
+
*
|
|
10
|
+
* @param explicitPath A path given with `--config`. It must exist; the default
|
|
11
|
+
* file may be absent, which simply means no config.
|
|
12
|
+
* @returns The parsed config and the directory its relative paths resolve
|
|
13
|
+
* against, or an empty config when there is no file.
|
|
14
|
+
* @throws An `Error` whose message is meant for the user on malformed JSON,
|
|
15
|
+
* an unknown key or a value of the wrong type. A typo such as `failon`
|
|
16
|
+
* fails loudly instead of being silently ignored, which would leave CI
|
|
17
|
+
* passing on a threshold nobody set.
|
|
18
|
+
*/
|
|
19
|
+
export function loadConfig(root, explicitPath) {
|
|
20
|
+
const path = explicitPath ? resolve(explicitPath) : join(root, CONFIG_FILE);
|
|
21
|
+
if (!existsSync(path)) {
|
|
22
|
+
if (explicitPath)
|
|
23
|
+
throw new Error(`Config file not found: ${path}`);
|
|
24
|
+
return { config: {}, directory: root };
|
|
25
|
+
}
|
|
26
|
+
let raw;
|
|
27
|
+
try {
|
|
28
|
+
raw = JSON.parse(readFileSync(path, 'utf8'));
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
throw new Error(`${path} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
32
|
+
}
|
|
33
|
+
if (typeof raw !== 'object' || raw === null || Array.isArray(raw))
|
|
34
|
+
throw new Error(`${path} must contain a JSON object`);
|
|
35
|
+
const record = raw;
|
|
36
|
+
const unknown = Object.keys(record).filter((key) => !KNOWN_KEYS.has(key));
|
|
37
|
+
if (unknown.length > 0)
|
|
38
|
+
throw new Error(`${path}: unknown ${unknown.length === 1 ? 'key' : 'keys'} ${unknown.join(', ')}. Allowed: ${[...KNOWN_KEYS].filter((key) => key !== '$schema').join(', ')}`);
|
|
39
|
+
const config = {};
|
|
40
|
+
if (record['reports'] !== undefined) {
|
|
41
|
+
const reports = record['reports'];
|
|
42
|
+
if (!Array.isArray(reports) || !reports.every((entry) => typeof entry === 'string'))
|
|
43
|
+
throw new Error(`${path}: reports must be an array of file names`);
|
|
44
|
+
for (const report of reports) {
|
|
45
|
+
if (!['.html', '.htm', '.md', '.json'].includes(extname(report).toLowerCase()))
|
|
46
|
+
throw new Error(`${path}: unknown report format for ${report}, use .html, .md or .json`);
|
|
47
|
+
}
|
|
48
|
+
config.reports = reports;
|
|
49
|
+
}
|
|
50
|
+
if (record['failOn'] !== undefined) {
|
|
51
|
+
if (record['failOn'] !== 'fair' && record['failOn'] !== 'poor' && record['failOn'] !== 'regression')
|
|
52
|
+
throw new Error(`${path}: failOn must be "poor", "fair" or "regression"`);
|
|
53
|
+
config.failOn = record['failOn'];
|
|
54
|
+
}
|
|
55
|
+
if (record['maxExamples'] !== undefined) {
|
|
56
|
+
const value = record['maxExamples'];
|
|
57
|
+
if (typeof value !== 'number' || !Number.isInteger(value) || value < 0)
|
|
58
|
+
throw new Error(`${path}: maxExamples must be a whole number`);
|
|
59
|
+
config.maxExamples = value;
|
|
60
|
+
}
|
|
61
|
+
if (record['offline'] !== undefined) {
|
|
62
|
+
if (typeof record['offline'] !== 'boolean')
|
|
63
|
+
throw new Error(`${path}: offline must be true or false`);
|
|
64
|
+
config.offline = record['offline'];
|
|
65
|
+
}
|
|
66
|
+
if (record['ignore'] !== undefined) {
|
|
67
|
+
const ignore = record['ignore'];
|
|
68
|
+
if (!Array.isArray(ignore) || !ignore.every((entry) => typeof entry === 'string'))
|
|
69
|
+
throw new Error(`${path}: ignore must be an array of paths`);
|
|
70
|
+
config.ignore = ignore;
|
|
71
|
+
}
|
|
72
|
+
if (record['baseline'] !== undefined) {
|
|
73
|
+
if (typeof record['baseline'] !== 'string' || record['baseline'].trim() === '')
|
|
74
|
+
throw new Error(`${path}: baseline must be a file path`);
|
|
75
|
+
config.baseline = record['baseline'];
|
|
76
|
+
}
|
|
77
|
+
return { config, directory: resolve(path, '..'), path };
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Compiles `ignore` patterns into one predicate over report paths (relative
|
|
81
|
+
* to the root, `/`-separated). Undefined when there are no patterns, so the
|
|
82
|
+
* file walk can skip the check entirely.
|
|
83
|
+
*/
|
|
84
|
+
export function ignoreMatcher(patterns) {
|
|
85
|
+
const cleaned = (patterns ?? []).map((pattern) => pattern.trim().replace(/^\.\//, '').replace(/\/+$/, '')).filter(Boolean);
|
|
86
|
+
if (cleaned.length === 0)
|
|
87
|
+
return undefined;
|
|
88
|
+
const expressions = cleaned.map((pattern) => {
|
|
89
|
+
const source = pattern
|
|
90
|
+
.split(/(\*\*\/?|\*|\?)/)
|
|
91
|
+
.map((part) => (part === '**/' ? '(?:.*/)?' : part === '**' ? '.*' : part === '*' ? '[^/]*' : part === '?' ? '[^/]' : part.replace(/[.+^${}()|[\]\\]/g, '\\$&')))
|
|
92
|
+
.join('');
|
|
93
|
+
// A pattern matches the path itself or anything below it.
|
|
94
|
+
return new RegExp(`^${source}(?:/.*)?$`);
|
|
95
|
+
});
|
|
96
|
+
return (relativePath) => expressions.some((expression) => expression.test(relativePath));
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD,sFAAsF;AACtF,MAAM,CAAC,MAAM,WAAW,GAAG,wBAAwB,CAAC;AA2BpD,wFAAwF;AACxF,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;AAE7G;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,YAAqB;IAC5D,MAAM,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAC5E,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAA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sorted, which keeps report output stable between runs on the
|
|
15
15
|
* same tree. An unreadable directory is skipped rather than failing the run,
|
|
16
16
|
* since a permissions problem in one corner says nothing about the code.
|
|
17
|
+
*
|
|
18
|
+
* @param isIgnored The config file's `ignore` patterns as a predicate over
|
|
19
|
+
* report paths. An ignored directory is not descended into at all, which is
|
|
20
|
+
* what makes ignoring a large generated folder cheap.
|
|
17
21
|
*/
|
|
18
|
-
export declare function collectFiles(root: string): CollectedFiles;
|
|
22
|
+
export declare function collectFiles(root: string, isIgnored?: (relativePath: string) => boolean): CollectedFiles;
|
|
19
23
|
/**
|
|
20
24
|
* The form every report uses for a path: relative to the analysed root, with
|
|
21
25
|
* `/` separators on every platform, so a report generated on Windows reads the
|
package/dist/files.js
CHANGED
|
@@ -22,10 +22,14 @@ const MAX_FILE_BYTES = 1_000_000;
|
|
|
22
22
|
* The result is sorted, which keeps report output stable between runs on the
|
|
23
23
|
* same tree. An unreadable directory is skipped rather than failing the run,
|
|
24
24
|
* since a permissions problem in one corner says nothing about the code.
|
|
25
|
+
*
|
|
26
|
+
* @param isIgnored The config file's `ignore` patterns as a predicate over
|
|
27
|
+
* report paths. An ignored directory is not descended into at all, which is
|
|
28
|
+
* what makes ignoring a large generated folder cheap.
|
|
25
29
|
*/
|
|
26
|
-
export function collectFiles(root) {
|
|
30
|
+
export function collectFiles(root, isIgnored) {
|
|
27
31
|
const result = { typescript: [], html: [], projectJsons: [] };
|
|
28
|
-
walk(root, result);
|
|
32
|
+
walk(root, root, result, isIgnored);
|
|
29
33
|
result.typescript.sort();
|
|
30
34
|
result.html.sort();
|
|
31
35
|
result.projectJsons.sort();
|
|
@@ -34,7 +38,7 @@ export function collectFiles(root) {
|
|
|
34
38
|
/**
|
|
35
39
|
* The recursive half of `collectFiles`. Mutates `into`.
|
|
36
40
|
*/
|
|
37
|
-
function walk(directory, into) {
|
|
41
|
+
function walk(root, directory, into, isIgnored) {
|
|
38
42
|
let entries;
|
|
39
43
|
try {
|
|
40
44
|
entries = readdirSync(directory, { withFileTypes: true });
|
|
@@ -44,10 +48,12 @@ function walk(directory, into) {
|
|
|
44
48
|
}
|
|
45
49
|
for (const entry of entries) {
|
|
46
50
|
const path = join(directory, entry.name);
|
|
51
|
+
if (isIgnored?.(toReportPath(root, path)))
|
|
52
|
+
continue;
|
|
47
53
|
if (entry.isDirectory()) {
|
|
48
54
|
if (entry.name.startsWith('.') || SKIPPED_DIRECTORIES.has(entry.name))
|
|
49
55
|
continue;
|
|
50
|
-
walk(path, into);
|
|
56
|
+
walk(root, path, into, isIgnored);
|
|
51
57
|
continue;
|
|
52
58
|
}
|
|
53
59
|
if (!entry.isFile())
|