@dcaldeira/tooling 0.1.0 → 0.2.1

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 (49) hide show
  1. package/README.md +34 -34
  2. package/checks/a11y.mjs +206 -206
  3. package/checks/architecture.mjs +137 -137
  4. package/checks/audit.mjs +121 -121
  5. package/checks/bundle.mjs +128 -126
  6. package/checks/dependencies.mjs +277 -277
  7. package/checks/duplication.mjs +135 -0
  8. package/checks/lint-scss.mjs +363 -349
  9. package/checks/package.mjs +30 -30
  10. package/checks/playwright-summary.mjs +53 -53
  11. package/checks/sass.mjs +67 -67
  12. package/checks/scan-secrets.mjs +58 -58
  13. package/checks/shared.mjs +86 -86
  14. package/checks/translations.mjs +55 -55
  15. package/checks/visual-compare.mjs +148 -148
  16. package/checks/visual-report-html.mjs +470 -470
  17. package/checks/visual-report.mjs +13 -13
  18. package/config.schema.json +999 -927
  19. package/configs/eslint.mjs +27 -27
  20. package/configs/knip.json +11 -11
  21. package/configs/playwright.mjs +15 -15
  22. package/configs/vitest.mjs +16 -16
  23. package/package.json +105 -105
  24. package/release/finalize.mjs +65 -65
  25. package/release/github.mjs +64 -64
  26. package/release/prepare.mjs +30 -30
  27. package/runner/browsers.mjs +73 -73
  28. package/runner/cache.mjs +121 -121
  29. package/runner/ci-plan.mjs +54 -54
  30. package/runner/cli.mjs +250 -248
  31. package/runner/config.mjs +148 -148
  32. package/runner/docs-install.mjs +93 -93
  33. package/runner/execute.mjs +298 -286
  34. package/runner/generate.mjs +122 -122
  35. package/runner/git.mjs +122 -122
  36. package/runner/graph.mjs +250 -243
  37. package/runner/insights.mjs +313 -313
  38. package/runner/provision.mjs +53 -53
  39. package/runner/repo-standard.mjs +104 -0
  40. package/runner/report.mjs +35 -35
  41. package/runner/serve-static.mjs +76 -76
  42. package/runner/setup.mjs +241 -237
  43. package/runner/summary.mjs +112 -112
  44. package/runner/watch.mjs +82 -82
  45. package/templates/ci.yml +25 -25
  46. package/templates/dependabot-merge.yml +13 -13
  47. package/templates/dependabot.yml +26 -26
  48. package/templates/pre-push +13 -13
  49. package/templates/release.yml +23 -23
package/runner/config.mjs CHANGED
@@ -1,148 +1,148 @@
1
- import { readFileSync } from 'node:fs';
2
- import { isAbsolute, relative, resolve } from 'node:path';
3
-
4
- const schema = JSON.parse(readFileSync(new URL('../config.schema.json', import.meta.url), 'utf8'));
5
- export const defaults = {
6
- docs: ['docs/**', '**/*.md', '**/*.mdx'],
7
- styles: ['**/*.scss', '**/*.css'],
8
- translations: ['**/locales/*.json'],
9
- app: ['src/**'],
10
- database: [],
11
- functions: [],
12
- workflows: ['.github/workflows/**'],
13
- tooling: ['tooling.config.json', '*config*', 'scripts/**', '.githooks/**'],
14
- dependencies: ['**/package.json', '**/package-lock.json', '**/npm-shrinkwrap.json'],
15
- };
16
- export const inside = (root, path) => {
17
- const target = resolve(root, path);
18
- const rel = relative(root, target);
19
- if (rel === '..' || rel.startsWith('../') || rel.startsWith('..\\') || isAbsolute(rel))
20
- throw new Error(`Path outside repository: ${path}`);
21
- return target;
22
- };
23
-
24
- // Interpret the keywords used by our bundled schema without adding dependencies to the planner.
25
- function validate(value, rule, path) {
26
- const fail = (message) => {
27
- throw new Error(`${path}: ${message}`);
28
- };
29
- if (rule.oneOf) {
30
- let matches = 0;
31
- for (const option of rule.oneOf) {
32
- try {
33
- validate(value, option, path);
34
- matches++;
35
- } catch {}
36
- }
37
- if (matches !== 1) fail('must match exactly one allowed shape');
38
- }
39
- if ('const' in rule && value !== rule.const) fail(`must be ${rule.const}`);
40
- if (rule.enum && !rule.enum.includes(value)) fail(`must be one of ${rule.enum.join(', ')}`);
41
- if (rule.type) {
42
- const valid =
43
- rule.type === 'object'
44
- ? value !== null && typeof value === 'object' && !Array.isArray(value)
45
- : rule.type === 'array'
46
- ? Array.isArray(value)
47
- : rule.type === 'integer'
48
- ? Number.isInteger(value)
49
- : rule.type === 'number'
50
- ? typeof value === 'number' && Number.isFinite(value)
51
- : typeof value === rule.type;
52
- if (!valid) fail(`must be ${rule.type}`);
53
- }
54
- if (typeof value === 'string') {
55
- if (rule.minLength !== undefined && value.length < rule.minLength) fail('must not be empty');
56
- if (rule.pattern && !new RegExp(rule.pattern).test(value)) fail('invalid name');
57
- }
58
- if (typeof value === 'number') {
59
- if (rule.minimum !== undefined && value < rule.minimum) fail(`must be >= ${rule.minimum}`);
60
- if (rule.maximum !== undefined && value > rule.maximum) fail(`must be <= ${rule.maximum}`);
61
- if (rule.exclusiveMinimum !== undefined && value <= rule.exclusiveMinimum)
62
- fail(`must be > ${rule.exclusiveMinimum}`);
63
- }
64
- if (Array.isArray(value)) {
65
- if (rule.minItems !== undefined && value.length < rule.minItems) fail('too few items');
66
- if (rule.maxItems !== undefined && value.length > rule.maxItems) fail('too many items');
67
- value.forEach((item, i) => {
68
- const itemRule = rule.prefixItems?.[i] ?? rule.items;
69
- if (itemRule) validate(item, itemRule, `${path}[${i}]`);
70
- });
71
- } else if (value !== null && typeof value === 'object') {
72
- for (const key of rule.required ?? []) if (!Object.hasOwn(value, key)) fail(`missing ${key}`);
73
- for (const [key, child] of Object.entries(value)) {
74
- if (rule.propertyNames) validate(key, rule.propertyNames, `${path}.${key}`);
75
- const childRule = rule.properties?.[key];
76
- if (childRule) validate(child, childRule, `${path}.${key}`);
77
- else if (rule.additionalProperties === false) fail(`unknown key ${key}`);
78
- else if (rule.additionalProperties && typeof rule.additionalProperties === 'object')
79
- validate(child, rule.additionalProperties, `${path}.${key}`);
80
- }
81
- }
82
- }
83
-
84
- export function validateConfig(value) {
85
- validate(value, schema, 'config');
86
- const layers = value.architecture?.layers ?? [];
87
- if (new Set(layers.map((layer) => layer.name)).size !== layers.length)
88
- throw new Error('Architecture layer names must be unique');
89
- for (const layer of layers)
90
- for (const name of layer.allow)
91
- if (!layers.some((candidate) => candidate.name === name))
92
- throw new Error(`Unknown architecture layer: ${name}`);
93
- for (const route of value.a11y?.routes ?? [])
94
- for (const action of route.actions ?? [])
95
- if (['fill', 'press'].includes(action.type) && action.value === undefined)
96
- throw new Error(`Accessibility action ${action.type} requires value`);
97
- for (const url of [value.a11y?.baseURL, value.a11y?.server?.url].filter(Boolean))
98
- if (!['http:', 'https:'].includes(new URL(url).protocol))
99
- throw new Error('Accessibility URLs must use HTTP or HTTPS');
100
- for (const path of value.execution?.typeScriptBuildInfo ?? [])
101
- if (/[\r\n]/.test(path) || !path.endsWith('.tsbuildinfo'))
102
- throw new Error('TypeScript cache paths must be .tsbuildinfo patterns');
103
- for (const [id, check] of Object.entries(value.checks ?? {})) {
104
- if (check && check.devFiles && check.devCommand && !Array.isArray(check.devCommand))
105
- throw new Error(`Changed-file command ${id} must be an array`);
106
- }
107
- return value;
108
- }
109
-
110
- export function loadConfig(root, path = process.env.TOOLING_CONFIG_PATH ?? 'tooling.config.json') {
111
- const raw = readFileSync(inside(root, path), 'utf8');
112
- const config = validateConfig(JSON.parse(raw));
113
- const paths = [
114
- ...(config.inputs ?? []),
115
- ...(config.sass?.entrypoints ?? []),
116
- ...(config.sass?.include ?? []),
117
- ...(config.sass?.exclude ?? []),
118
- ...(config.sass?.importantExceptions ?? []),
119
- ...(config.sass?.source ? [config.sass.source] : []),
120
- ...(config.execution?.typeScriptBuildInfo ?? []),
121
- ...(config.architecture?.include ?? []),
122
- ...(config.architecture?.exclude ?? []),
123
- ...(config.architecture?.tsconfig ? [config.architecture.tsconfig] : []),
124
- ...(config.architecture?.modules ?? []).flatMap((module) => [module.root, ...module.public]),
125
- ...(config.architecture?.layers ?? []).flatMap((layer) => layer.paths),
126
- ...(config.dependencyConsistency?.manifests ?? []),
127
- ...(config.dependencyConsistency?.include ?? []),
128
- ...(config.dependencyConsistency?.exclude ?? []),
129
- ...[
130
- config.generators?.components,
131
- config.generators?.hooks,
132
- config.a11y?.storageState,
133
- config.a11y?.server?.cwd,
134
- ].filter(Boolean),
135
- ...(config.reporting?.unit ?? []),
136
- ...(config.reporting?.coverage ?? []),
137
- ...(config.reporting?.playwright ?? []),
138
- ...Object.values(config.workspaces ?? {}).flatMap((workspace) => workspace.paths),
139
- ...Object.values(config.checks ?? {})
140
- .filter(Boolean)
141
- .flatMap((check) => [
142
- ...(check.cwd !== undefined ? [check.cwd] : []),
143
- ...(typeof check.cache === 'object' ? check.cache.inputs : []),
144
- ]),
145
- ];
146
- paths.forEach((path) => inside(root, path));
147
- return { config, raw };
148
- }
1
+ import { readFileSync } from 'node:fs';
2
+ import { isAbsolute, relative, resolve } from 'node:path';
3
+
4
+ const schema = JSON.parse(readFileSync(new URL('../config.schema.json', import.meta.url), 'utf8'));
5
+ export const defaults = {
6
+ docs: ['docs/**', '**/*.md', '**/*.mdx'],
7
+ styles: ['**/*.scss', '**/*.css'],
8
+ translations: ['**/locales/*.json'],
9
+ app: ['src/**'],
10
+ database: [],
11
+ functions: [],
12
+ workflows: ['.github/workflows/**'],
13
+ tooling: ['tooling.config.json', '*config*', 'scripts/**', '.githooks/**'],
14
+ dependencies: ['**/package.json', '**/package-lock.json', '**/npm-shrinkwrap.json'],
15
+ };
16
+ export const inside = (root, path) => {
17
+ const target = resolve(root, path);
18
+ const rel = relative(root, target);
19
+ if (rel === '..' || rel.startsWith('../') || rel.startsWith('..\\') || isAbsolute(rel))
20
+ throw new Error(`Path outside repository: ${path}`);
21
+ return target;
22
+ };
23
+
24
+ // Interpret the keywords used by our bundled schema without adding dependencies to the planner.
25
+ function validate(value, rule, path) {
26
+ const fail = (message) => {
27
+ throw new Error(`${path}: ${message}`);
28
+ };
29
+ if (rule.oneOf) {
30
+ let matches = 0;
31
+ for (const option of rule.oneOf) {
32
+ try {
33
+ validate(value, option, path);
34
+ matches++;
35
+ } catch {}
36
+ }
37
+ if (matches !== 1) fail('must match exactly one allowed shape');
38
+ }
39
+ if ('const' in rule && value !== rule.const) fail(`must be ${rule.const}`);
40
+ if (rule.enum && !rule.enum.includes(value)) fail(`must be one of ${rule.enum.join(', ')}`);
41
+ if (rule.type) {
42
+ const valid =
43
+ rule.type === 'object'
44
+ ? value !== null && typeof value === 'object' && !Array.isArray(value)
45
+ : rule.type === 'array'
46
+ ? Array.isArray(value)
47
+ : rule.type === 'integer'
48
+ ? Number.isInteger(value)
49
+ : rule.type === 'number'
50
+ ? typeof value === 'number' && Number.isFinite(value)
51
+ : typeof value === rule.type;
52
+ if (!valid) fail(`must be ${rule.type}`);
53
+ }
54
+ if (typeof value === 'string') {
55
+ if (rule.minLength !== undefined && value.length < rule.minLength) fail('must not be empty');
56
+ if (rule.pattern && !new RegExp(rule.pattern).test(value)) fail('invalid name');
57
+ }
58
+ if (typeof value === 'number') {
59
+ if (rule.minimum !== undefined && value < rule.minimum) fail(`must be >= ${rule.minimum}`);
60
+ if (rule.maximum !== undefined && value > rule.maximum) fail(`must be <= ${rule.maximum}`);
61
+ if (rule.exclusiveMinimum !== undefined && value <= rule.exclusiveMinimum)
62
+ fail(`must be > ${rule.exclusiveMinimum}`);
63
+ }
64
+ if (Array.isArray(value)) {
65
+ if (rule.minItems !== undefined && value.length < rule.minItems) fail('too few items');
66
+ if (rule.maxItems !== undefined && value.length > rule.maxItems) fail('too many items');
67
+ value.forEach((item, i) => {
68
+ const itemRule = rule.prefixItems?.[i] ?? rule.items;
69
+ if (itemRule) validate(item, itemRule, `${path}[${i}]`);
70
+ });
71
+ } else if (value !== null && typeof value === 'object') {
72
+ for (const key of rule.required ?? []) if (!Object.hasOwn(value, key)) fail(`missing ${key}`);
73
+ for (const [key, child] of Object.entries(value)) {
74
+ if (rule.propertyNames) validate(key, rule.propertyNames, `${path}.${key}`);
75
+ const childRule = rule.properties?.[key];
76
+ if (childRule) validate(child, childRule, `${path}.${key}`);
77
+ else if (rule.additionalProperties === false) fail(`unknown key ${key}`);
78
+ else if (rule.additionalProperties && typeof rule.additionalProperties === 'object')
79
+ validate(child, rule.additionalProperties, `${path}.${key}`);
80
+ }
81
+ }
82
+ }
83
+
84
+ export function validateConfig(value) {
85
+ validate(value, schema, 'config');
86
+ const layers = value.architecture?.layers ?? [];
87
+ if (new Set(layers.map((layer) => layer.name)).size !== layers.length)
88
+ throw new Error('Architecture layer names must be unique');
89
+ for (const layer of layers)
90
+ for (const name of layer.allow)
91
+ if (!layers.some((candidate) => candidate.name === name))
92
+ throw new Error(`Unknown architecture layer: ${name}`);
93
+ for (const route of value.a11y?.routes ?? [])
94
+ for (const action of route.actions ?? [])
95
+ if (['fill', 'press'].includes(action.type) && action.value === undefined)
96
+ throw new Error(`Accessibility action ${action.type} requires value`);
97
+ for (const url of [value.a11y?.baseURL, value.a11y?.server?.url].filter(Boolean))
98
+ if (!['http:', 'https:'].includes(new URL(url).protocol))
99
+ throw new Error('Accessibility URLs must use HTTP or HTTPS');
100
+ for (const path of value.execution?.typeScriptBuildInfo ?? [])
101
+ if (/[\r\n]/.test(path) || !path.endsWith('.tsbuildinfo'))
102
+ throw new Error('TypeScript cache paths must be .tsbuildinfo patterns');
103
+ for (const [id, check] of Object.entries(value.checks ?? {})) {
104
+ if (check && check.devFiles && check.devCommand && !Array.isArray(check.devCommand))
105
+ throw new Error(`Changed-file command ${id} must be an array`);
106
+ }
107
+ return value;
108
+ }
109
+
110
+ export function loadConfig(root, path = process.env.TOOLING_CONFIG_PATH ?? 'tooling.config.json') {
111
+ const raw = readFileSync(inside(root, path), 'utf8');
112
+ const config = validateConfig(JSON.parse(raw));
113
+ const paths = [
114
+ ...(config.inputs ?? []),
115
+ ...(config.sass?.entrypoints ?? []),
116
+ ...(config.sass?.include ?? []),
117
+ ...(config.sass?.exclude ?? []),
118
+ ...(config.sass?.importantExceptions ?? []),
119
+ ...(config.sass?.source ? [config.sass.source] : []),
120
+ ...(config.execution?.typeScriptBuildInfo ?? []),
121
+ ...(config.architecture?.include ?? []),
122
+ ...(config.architecture?.exclude ?? []),
123
+ ...(config.architecture?.tsconfig ? [config.architecture.tsconfig] : []),
124
+ ...(config.architecture?.modules ?? []).flatMap((module) => [module.root, ...module.public]),
125
+ ...(config.architecture?.layers ?? []).flatMap((layer) => layer.paths),
126
+ ...(config.dependencyConsistency?.manifests ?? []),
127
+ ...(config.dependencyConsistency?.include ?? []),
128
+ ...(config.dependencyConsistency?.exclude ?? []),
129
+ ...[
130
+ config.generators?.components,
131
+ config.generators?.hooks,
132
+ config.a11y?.storageState,
133
+ config.a11y?.server?.cwd,
134
+ ].filter(Boolean),
135
+ ...(config.reporting?.unit ?? []),
136
+ ...(config.reporting?.coverage ?? []),
137
+ ...(config.reporting?.playwright ?? []),
138
+ ...Object.values(config.workspaces ?? {}).flatMap((workspace) => workspace.paths),
139
+ ...Object.values(config.checks ?? {})
140
+ .filter(Boolean)
141
+ .flatMap((check) => [
142
+ ...(check.cwd !== undefined ? [check.cwd] : []),
143
+ ...(typeof check.cache === 'object' ? check.cache.inputs : []),
144
+ ]),
145
+ ];
146
+ paths.forEach((path) => inside(root, path));
147
+ return { config, raw };
148
+ }
@@ -1,93 +1,93 @@
1
- import {
2
- existsSync,
3
- mkdirSync,
4
- readFileSync,
5
- writeFileSync,
6
- symlinkSync,
7
- appendFileSync,
8
- } from 'node:fs';
9
- import { dirname, join, resolve } from 'node:path';
10
- import { fileURLToPath, pathToFileURL } from 'node:url';
11
- import { invoke } from './execute.mjs';
12
-
13
- export function formatterLock(root, selection) {
14
- if (
15
- selection.groups.length !== 1 ||
16
- selection.groups[0] !== 'docs' ||
17
- selection.checks.length !== 1 ||
18
- selection.checks[0].id !== 'format' ||
19
- selection.checks[0].excluded ||
20
- selection.excluded.length ||
21
- selection.checks[0].cwd ||
22
- JSON.stringify(selection.checks[0].command) !== JSON.stringify(['prettier', '--check', '.'])
23
- )
24
- return null;
25
- const lock = JSON.parse(readFileSync(join(root, 'package-lock.json'), 'utf8'));
26
- const entry = lock.packages?.['node_modules/prettier'];
27
- if (
28
- !entry?.version ||
29
- !entry.integrity ||
30
- !entry.resolved ||
31
- entry.link ||
32
- Object.keys(entry.dependencies ?? {}).length ||
33
- Object.keys(entry.optionalDependencies ?? {}).length ||
34
- Object.keys(entry.peerDependencies ?? {}).length
35
- )
36
- return null;
37
- return {
38
- name: 'tooling-docs',
39
- version: '1.0.0',
40
- lockfileVersion: 3,
41
- requires: true,
42
- packages: {
43
- '': { name: 'tooling-docs', version: '1.0.0', devDependencies: { prettier: entry.version } },
44
- 'node_modules/prettier': { ...entry, dev: true, devOptional: undefined },
45
- },
46
- };
47
- }
48
-
49
- export async function installFormatter(root, lock) {
50
- const directory = join(root, '.tooling', 'formatter');
51
- mkdirSync(directory, { recursive: true });
52
- writeFileSync(
53
- join(directory, 'package.json'),
54
- JSON.stringify({
55
- name: lock.name,
56
- version: lock.version,
57
- private: true,
58
- devDependencies: lock.packages[''].devDependencies,
59
- }),
60
- );
61
- writeFileSync(join(directory, 'package-lock.json'), JSON.stringify(lock));
62
- const result = await invoke(['npm', 'ci', '--ignore-scripts', '--no-audit', '--no-fund'], root, {
63
- cwd: directory,
64
- });
65
- if (result.status !== 'passed') throw new Error('Formatter installation failed');
66
- const links = [
67
- [join(root, 'node_modules/prettier'), join(directory, 'node_modules/prettier')],
68
- [join(root, 'node_modules/@dcaldeira/tooling'), fileURLToPath(new URL('../', import.meta.url))],
69
- ];
70
- for (const [target, source] of links) {
71
- if (existsSync(target)) throw new Error(`Refusing to replace ${target}`);
72
- mkdirSync(dirname(target), { recursive: true });
73
- symlinkSync(source, target, process.platform === 'win32' ? 'junction' : 'dir');
74
- }
75
- }
76
-
77
- if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
78
- const root = process.cwd();
79
- const selection = JSON.parse(readFileSync(resolve(process.argv[2]), 'utf8'));
80
- const lock = formatterLock(root, selection);
81
- if (process.argv.includes('--plan')) {
82
- if (process.env.GITHUB_OUTPUT)
83
- appendFileSync(process.env.GITHUB_OUTPUT, `lightweight=${Boolean(lock)}\n`);
84
- console.log(
85
- lock
86
- ? 'Standalone formatter installation available'
87
- : 'Full dependency installation required',
88
- );
89
- } else {
90
- if (!lock) throw new Error('This plan requires the full project installation');
91
- await installFormatter(root, lock);
92
- }
93
- }
1
+ import {
2
+ existsSync,
3
+ mkdirSync,
4
+ readFileSync,
5
+ writeFileSync,
6
+ symlinkSync,
7
+ appendFileSync,
8
+ } from 'node:fs';
9
+ import { dirname, join, resolve } from 'node:path';
10
+ import { fileURLToPath, pathToFileURL } from 'node:url';
11
+ import { invoke } from './execute.mjs';
12
+
13
+ export function formatterLock(root, selection) {
14
+ if (
15
+ selection.groups.length !== 1 ||
16
+ selection.groups[0] !== 'docs' ||
17
+ selection.checks.length !== 1 ||
18
+ selection.checks[0].id !== 'format' ||
19
+ selection.checks[0].excluded ||
20
+ selection.excluded.length ||
21
+ selection.checks[0].cwd ||
22
+ JSON.stringify(selection.checks[0].command) !== JSON.stringify(['prettier', '--check', '.'])
23
+ )
24
+ return null;
25
+ const lock = JSON.parse(readFileSync(join(root, 'package-lock.json'), 'utf8'));
26
+ const entry = lock.packages?.['node_modules/prettier'];
27
+ if (
28
+ !entry?.version ||
29
+ !entry.integrity ||
30
+ !entry.resolved ||
31
+ entry.link ||
32
+ Object.keys(entry.dependencies ?? {}).length ||
33
+ Object.keys(entry.optionalDependencies ?? {}).length ||
34
+ Object.keys(entry.peerDependencies ?? {}).length
35
+ )
36
+ return null;
37
+ return {
38
+ name: 'tooling-docs',
39
+ version: '1.0.0',
40
+ lockfileVersion: 3,
41
+ requires: true,
42
+ packages: {
43
+ '': { name: 'tooling-docs', version: '1.0.0', devDependencies: { prettier: entry.version } },
44
+ 'node_modules/prettier': { ...entry, dev: true, devOptional: undefined },
45
+ },
46
+ };
47
+ }
48
+
49
+ export async function installFormatter(root, lock) {
50
+ const directory = join(root, '.tooling', 'formatter');
51
+ mkdirSync(directory, { recursive: true });
52
+ writeFileSync(
53
+ join(directory, 'package.json'),
54
+ JSON.stringify({
55
+ name: lock.name,
56
+ version: lock.version,
57
+ private: true,
58
+ devDependencies: lock.packages[''].devDependencies,
59
+ }),
60
+ );
61
+ writeFileSync(join(directory, 'package-lock.json'), JSON.stringify(lock));
62
+ const result = await invoke(['npm', 'ci', '--ignore-scripts', '--no-audit', '--no-fund'], root, {
63
+ cwd: directory,
64
+ });
65
+ if (result.status !== 'passed') throw new Error('Formatter installation failed');
66
+ const links = [
67
+ [join(root, 'node_modules/prettier'), join(directory, 'node_modules/prettier')],
68
+ [join(root, 'node_modules/@dcaldeira/tooling'), fileURLToPath(new URL('../', import.meta.url))],
69
+ ];
70
+ for (const [target, source] of links) {
71
+ if (existsSync(target)) throw new Error(`Refusing to replace ${target}`);
72
+ mkdirSync(dirname(target), { recursive: true });
73
+ symlinkSync(source, target, process.platform === 'win32' ? 'junction' : 'dir');
74
+ }
75
+ }
76
+
77
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
78
+ const root = process.cwd();
79
+ const selection = JSON.parse(readFileSync(resolve(process.argv[2]), 'utf8'));
80
+ const lock = formatterLock(root, selection);
81
+ if (process.argv.includes('--plan')) {
82
+ if (process.env.GITHUB_OUTPUT)
83
+ appendFileSync(process.env.GITHUB_OUTPUT, `lightweight=${Boolean(lock)}\n`);
84
+ console.log(
85
+ lock
86
+ ? 'Standalone formatter installation available'
87
+ : 'Full dependency installation required',
88
+ );
89
+ } else {
90
+ if (!lock) throw new Error('This plan requires the full project installation');
91
+ await installFormatter(root, lock);
92
+ }
93
+ }