@rtorcato/js-tooling 2.16.0 → 2.17.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.
|
@@ -596,6 +596,72 @@ async function checkCodeQL(dir) {
|
|
|
596
596
|
hint: 'Run `npx @rtorcato/js-tooling fix codeql` to scaffold CodeQL security scanning',
|
|
597
597
|
};
|
|
598
598
|
}
|
|
599
|
+
const TYPEDOC_CONFIGS = [
|
|
600
|
+
'typedoc.json',
|
|
601
|
+
'typedoc.config.js',
|
|
602
|
+
'typedoc.config.mjs',
|
|
603
|
+
'typedoc.config.cjs',
|
|
604
|
+
'typedoc.config.ts',
|
|
605
|
+
];
|
|
606
|
+
async function checkTypedoc(dir, pkg) {
|
|
607
|
+
if (pkg?.private === true) {
|
|
608
|
+
return {
|
|
609
|
+
check: 'TypeDoc',
|
|
610
|
+
status: 'ok',
|
|
611
|
+
detail: 'not applicable (package is private)',
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
let configFile = null;
|
|
615
|
+
let configContent = null;
|
|
616
|
+
for (const candidate of TYPEDOC_CONFIGS) {
|
|
617
|
+
const fp = path.join(dir, candidate);
|
|
618
|
+
if (await fs.pathExists(fp)) {
|
|
619
|
+
configFile = candidate;
|
|
620
|
+
try {
|
|
621
|
+
configContent = await fs.readFile(fp, 'utf-8');
|
|
622
|
+
}
|
|
623
|
+
catch {
|
|
624
|
+
configContent = '';
|
|
625
|
+
}
|
|
626
|
+
break;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
const deps = {
|
|
630
|
+
...(pkg?.dependencies ?? {}),
|
|
631
|
+
...(pkg?.devDependencies ?? {}),
|
|
632
|
+
};
|
|
633
|
+
const hasDep = !!deps['typedoc'];
|
|
634
|
+
const usesPreset = configContent ? /@rtorcato\/js-tooling\/typedoc/.test(configContent) : false;
|
|
635
|
+
if (configFile && usesPreset) {
|
|
636
|
+
return {
|
|
637
|
+
check: 'TypeDoc',
|
|
638
|
+
status: 'ok',
|
|
639
|
+
detail: `${configFile} extends the preset`,
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
if (configFile && !usesPreset) {
|
|
643
|
+
return {
|
|
644
|
+
check: 'TypeDoc',
|
|
645
|
+
status: 'drift',
|
|
646
|
+
detail: `${configFile} found but does not extend @rtorcato/js-tooling/typedoc`,
|
|
647
|
+
hint: 'Add `"extends": ["@rtorcato/js-tooling/typedoc"]` to typedoc.json',
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
if (hasDep && !configFile) {
|
|
651
|
+
return {
|
|
652
|
+
check: 'TypeDoc',
|
|
653
|
+
status: 'drift',
|
|
654
|
+
detail: 'typedoc installed but no typedoc.json found',
|
|
655
|
+
hint: 'Run `npx @rtorcato/js-tooling fix typedoc` to scaffold typedoc.json',
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
return {
|
|
659
|
+
check: 'TypeDoc',
|
|
660
|
+
status: 'optional-missing',
|
|
661
|
+
detail: 'TypeDoc not configured',
|
|
662
|
+
hint: 'Run `npx @rtorcato/js-tooling fix typedoc` to scaffold API docs generation',
|
|
663
|
+
};
|
|
664
|
+
}
|
|
599
665
|
function isPublishableLibrary(pkg) {
|
|
600
666
|
if (!pkg || pkg.private === true)
|
|
601
667
|
return false;
|
|
@@ -748,6 +814,7 @@ export async function runDoctor(dir) {
|
|
|
748
814
|
results.push(await checkCodeQL(targetDir));
|
|
749
815
|
results.push(await checkGitLabCI(targetDir));
|
|
750
816
|
results.push(await checkCodeowners(targetDir));
|
|
817
|
+
results.push(await checkTypedoc(targetDir, pkg));
|
|
751
818
|
results.push(await checkAreTheTypesWrong(targetDir, pkg));
|
|
752
819
|
results.push(await checkTreeshakeSetup(targetDir, pkg));
|
|
753
820
|
// Lockfile-driven demotion: if the lock records an intentional opt-out for a
|
package/dist/cli/commands/fix.js
CHANGED
|
@@ -13,6 +13,7 @@ import { composeVerifyScriptFromPkg } from '../generators/package-json.js';
|
|
|
13
13
|
import { generateCodeQLWorkflow, generateDependabotConfig, generateRenovateConfig, } from '../generators/security.js';
|
|
14
14
|
import { generateVitestConfig } from '../generators/testing.js';
|
|
15
15
|
import { generateTreeshakeCheck, inferSubpathsFromExports } from '../generators/treeshake.js';
|
|
16
|
+
import { generateTypedocConfig, generateTypedocWorkflow } from '../generators/typedoc.js';
|
|
16
17
|
import { copyPreset } from '../utils/copy-preset.js';
|
|
17
18
|
import { LOCKFILE_NAME, readLockfile, updateLockfileConfig, writeLockfile, } from '../utils/lockfile.js';
|
|
18
19
|
import { runDoctor } from './doctor.js';
|
|
@@ -359,6 +360,30 @@ const FIXERS = [
|
|
|
359
360
|
return { filesWritten: written };
|
|
360
361
|
},
|
|
361
362
|
},
|
|
363
|
+
{
|
|
364
|
+
target: 'typedoc',
|
|
365
|
+
description: 'Scaffold typedoc.json extending the preset + .github/workflows/docs.yml (GitHub Pages)',
|
|
366
|
+
appliesTo: ['TypeDoc'],
|
|
367
|
+
outputs: ['typedoc.json', '.github/workflows/docs.yml'],
|
|
368
|
+
riskLevel: 'safe-add',
|
|
369
|
+
canFixDrift: true,
|
|
370
|
+
async run({ targetDir, pkg }) {
|
|
371
|
+
await generateTypedocConfig(pkg, targetDir);
|
|
372
|
+
const workflow = await generateTypedocWorkflow(targetDir);
|
|
373
|
+
const pkgPath = path.join(targetDir, 'package.json');
|
|
374
|
+
const filesWritten = ['typedoc.json', workflow];
|
|
375
|
+
if (await fs.pathExists(pkgPath)) {
|
|
376
|
+
const pkgData = (await fs.readJson(pkgPath));
|
|
377
|
+
const scripts = pkgData.scripts ?? {};
|
|
378
|
+
if (!scripts.docs) {
|
|
379
|
+
pkgData.scripts = { ...scripts, docs: 'typedoc' };
|
|
380
|
+
await fs.writeJson(pkgPath, pkgData, { spaces: 2 });
|
|
381
|
+
filesWritten.push('package.json');
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return { filesWritten };
|
|
385
|
+
},
|
|
386
|
+
},
|
|
362
387
|
{
|
|
363
388
|
target: 'package-json',
|
|
364
389
|
description: 'Add @rtorcato/js-tooling to devDependencies',
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
const DOCS_WORKFLOW = `name: 📚 Docs
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
jobs:
|
|
8
|
+
docs:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
permissions:
|
|
11
|
+
contents: write
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- uses: pnpm/action-setup@v4
|
|
15
|
+
- uses: actions/setup-node@v4
|
|
16
|
+
with:
|
|
17
|
+
node-version: 22
|
|
18
|
+
cache: pnpm
|
|
19
|
+
- run: pnpm install --frozen-lockfile
|
|
20
|
+
- run: pnpm docs
|
|
21
|
+
- uses: peaceiris/actions-gh-pages@v4
|
|
22
|
+
with:
|
|
23
|
+
github_token: \${{ secrets.GITHUB_TOKEN }}
|
|
24
|
+
publish_dir: ./docs
|
|
25
|
+
`;
|
|
26
|
+
export async function generateTypedocConfig(pkg, targetDir) {
|
|
27
|
+
const name = pkg?.name ?? 'My Library';
|
|
28
|
+
const config = {
|
|
29
|
+
extends: ['@rtorcato/js-tooling/typedoc'],
|
|
30
|
+
entryPoints: ['./src/index.ts'],
|
|
31
|
+
name,
|
|
32
|
+
};
|
|
33
|
+
await fs.writeJson(path.join(targetDir, 'typedoc.json'), config, { spaces: 2 });
|
|
34
|
+
}
|
|
35
|
+
export async function generateTypedocWorkflow(targetDir) {
|
|
36
|
+
const workflowsDir = path.join(targetDir, '.github', 'workflows');
|
|
37
|
+
await fs.ensureDir(workflowsDir);
|
|
38
|
+
await fs.writeFile(path.join(workflowsDir, 'docs.yml'), DOCS_WORKFLOW);
|
|
39
|
+
return '.github/workflows/docs.yml';
|
|
40
|
+
}
|
package/dist/cli/index.js
CHANGED
|
@@ -148,6 +148,12 @@ const TOOL_CATALOG = [
|
|
|
148
148
|
exports: ['@rtorcato/js-tooling/tsup'],
|
|
149
149
|
fixTarget: null,
|
|
150
150
|
},
|
|
151
|
+
{
|
|
152
|
+
name: 'TypeDoc',
|
|
153
|
+
description: 'API documentation generation for TypeScript library projects',
|
|
154
|
+
exports: ['@rtorcato/js-tooling/typedoc'],
|
|
155
|
+
fixTarget: 'typedoc',
|
|
156
|
+
},
|
|
151
157
|
{
|
|
152
158
|
name: 'esbuild',
|
|
153
159
|
description: 'Fast JavaScript bundler configuration',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rtorcato/js-tooling",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.1",
|
|
4
4
|
"description": "JavaScript and TypeScript tooling for Node.js, React, Next.js, and Vitest.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"tooling/tests/ssr-safety.d.mts",
|
|
71
71
|
"tooling/tsup/index.ts",
|
|
72
72
|
"tooling/biome/biome.json",
|
|
73
|
+
"tooling/typedoc/typedoc.json",
|
|
73
74
|
"tooling/semantic-release/*.mjs",
|
|
74
75
|
"tooling/semantic-release/*.d.mts",
|
|
75
76
|
"README.md"
|
|
@@ -142,6 +143,7 @@
|
|
|
142
143
|
},
|
|
143
144
|
"./tsup": "./tooling/tsup/index.ts",
|
|
144
145
|
"./biome": "./tooling/biome/biome.json",
|
|
146
|
+
"./typedoc": "./tooling/typedoc/typedoc.json",
|
|
145
147
|
"./semantic-release": {
|
|
146
148
|
"types": "./tooling/semantic-release/index.d.mts",
|
|
147
149
|
"import": "./tooling/semantic-release/index.mjs"
|