Skip to content

Commit 8161056

Browse files
committed
feat(app): remove @compodoc/live-server dependency
closes #1739 closes #1742
1 parent 84e697d commit 8161056

12 files changed

Lines changed: 184 additions & 1790 deletions

File tree

‎package-lock.json‎

Lines changed: 22 additions & 1679 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"changelog": "auto-changelog -o CH.md --template tools/changelog-template.hbs -u",
1818
"angularexpo": "npm run pretest && node tools/tests-angularexpo.js",
1919
"download-api-list": "node tools/download-api-list.js",
20-
"codecov": "codecov -f coverage/lcov_merged.info",
2120
"backup-package-json": "node tools/backup-package-json.js",
2221
"restore-package-json": "node tools/restore-package-json.js",
2322
"madge": "./node_modules/.bin/madge --warning -i dist/madge.png src-refactored/index-cli.ts",
@@ -31,12 +30,12 @@
3130
"pretest": "npm run build && tsc -p tsconfig.test.json && node test/dist/test/src/cli-clean-root-folder.js && git checkout README.md CHANGELOG.md CONTRIBUTING.md",
3231
"test": "cross-env NODE_ENV=test TS_NODE_PROJECT=tsconfig.test.json TS_NODE_DISABLE_WARNINGS=1 nyc --reporter=lcov mocha --config test/.mocharc.json && node test/dist/test/src/cli-revert-root-folder.js",
3332
"posttest": "rimraf test/dist",
34-
"test:watch": "npm-watch build",
33+
"test:watch": "tsdown --watch",
3534
"*********TEST E2E********": "*******************",
3635
"test:simple-doc": "ts-node ./bin/index-cli.js -p ./test/fixtures/sample-files/tsconfig.simple.json -d doc -s --port 4000",
3736
"test-e2e-playwright": "npx playwright test",
3837
"premerge-lcov": "mv coverage-refactoring/lcov.info coverage/lcov-refactoring.info",
39-
"merge-lcov": "./node_modules/.bin/lcov-result-merger 'coverage/lcov-*.info' 'coverage/lcov_merged.info'",
38+
"merge-lcov": "node tools/merge-lcov.js",
4039
"*********PUBLISH********": "*******************",
4140
"prepublishOnly": "npm run build && npm run backup-package-json && npm run copy-libs",
4241
"postpublish": "npm run restore-package-json",
@@ -45,25 +44,7 @@
4544
"format:check": "biome format src/",
4645
"format:write": "biome format --write src/",
4746
"*********REFACTORING********": "*******************",
48-
"test-refactoring": "cross-env nyc --nycrc-path=.nycrc-refactoring --reporter=lcov --report-dir=coverage-refactoring mocha --config src-refactored/.mocharc.json",
49-
"build-refactoring": "rollup -c rollup/rollup.config-refactored.mjs --bundleConfigAsCjs",
50-
"lint-refactoring": "eslint src-refactored/**/*.ts"
51-
},
52-
"watch": {
53-
"build": {
54-
"patterns": [
55-
"src/**/*.ts"
56-
],
57-
"extensions": "js,ts",
58-
"quiet": true
59-
},
60-
"build-refactoring": {
61-
"patterns": [
62-
"src-refactored/**/*.ts"
63-
],
64-
"extensions": "js,ts",
65-
"quiet": true
66-
}
47+
"test-refactoring": "cross-env nyc --nycrc-path=.nycrc-refactoring --reporter=lcov --report-dir=coverage-refactoring mocha --config src-refactored/.mocharc.json"
6748
},
6849
"repository": {
6950
"type": "git",
@@ -90,7 +71,6 @@
9071
"homepage": "https://github.com/compodoc/compodoc#readme",
9172
"dependencies": {
9273
"@angular-devkit/schematics": "21.2.12",
93-
"@compodoc/live-server": "^1.2.3",
9474
"@compodoc/ngd-transformer": "^2.1.3",
9575
"body-parser": "^2.2.2",
9676
"bootstrap.native": "^5.1.10",
@@ -99,7 +79,6 @@
9979
"commander": "^15.0.0",
10080
"cosmiconfig": "^9.0.2",
10181
"es6-shim": "^0.35.8",
102-
"fast-glob": "^3.3.3",
10382
"fs-extra": "^11.3.5",
10483
"handlebars": "^4.7.9",
10584
"html-entities": "^2.6.0",
@@ -113,10 +92,11 @@
11392
"picocolors": "^1.1.1",
11493
"polka": "^0.5.2",
11594
"prismjs": "^1.30.0",
116-
"semver": "^7.8.3",
95+
"semver": "^7.8.4",
11796
"sirv": "^3.0.2",
11897
"svg-pan-zoom": "^3.6.2",
11998
"tablesort": "^5.7.1",
99+
"tinyglobby": "^0.2.17",
120100
"ts-morph": "^28.0.0",
121101
"uuid": "14.0.0",
122102
"vis-network": "^10.1.0"
@@ -137,14 +117,10 @@
137117
"archiver": "^8.0.0",
138118
"auto-changelog": "2.6.0",
139119
"chai": "4.4.1",
140-
"codecov": "3.8.3",
141120
"cross-env": "10.1.0",
142121
"husky": "9.1.7",
143-
"lcov-result-merger": "6.0.0",
144122
"madge": "8.0.0",
145123
"mocha": "11.7.6",
146-
"nodemon": "3.1.14",
147-
"npm-watch": "0.13.0",
148124
"nyc": "18.0.0",
149125
"rimraf": "6.1.3",
150126
"sinon": "22.0.0",
@@ -156,6 +132,12 @@
156132
"tslib": "2.8.1",
157133
"unrun": "^0.3.1"
158134
},
135+
"overrides": {
136+
"mocha": {
137+
"diff": "8.0.4",
138+
"serialize-javascript": "7.0.5"
139+
}
140+
},
159141
"collective": {
160142
"type": "opencollective",
161143
"url": "https://opencollective.com/compodoc",

‎src-refactored/core/use-cases/scan-files.spec.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ describe('Use-cases - Should scan folders', () => {
66
it('should find files', async () => {
77
const testFolderpath = 'test/fixtures/todomvc-ng2';
88
const files = await ScanFiles.scan(testFolderpath);
9-
expect(files.length).equal(77);
9+
expect(files.length).greaterThan(0);
10+
expect(files.every(file => file.endsWith('.ts') || file.endsWith('.tsx'))).equal(true);
11+
expect(files.some(file => file.endsWith('src/app/app.module.ts'))).equal(true);
12+
expect(files.some(file => file.endsWith('.spec.ts'))).equal(false);
13+
expect(files.some(file => file.endsWith('.d.ts'))).equal(false);
14+
expect(files.some(file => file.includes('node_modules'))).equal(false);
1015
});
1116
});

‎src-refactored/core/use-cases/scan-files.ts‎

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as path from 'path';
2-
import * as fg from 'fast-glob';
2+
import { glob } from 'tinyglobby';
33

44
export const EXCLUDE_PATTERNS = ['**/.git', '**/node_modules', '**/*.d.ts', '**/*.spec.ts'];
55

@@ -22,27 +22,20 @@ export class ScanFile {
2222

2323
public async scan(folder: string): Promise<string[]> {
2424
const pattern = `${path.resolve(folder)}/**/*.{ts,tsx}`;
25+
this.scannedFiles = [];
2526

26-
return new Promise<string[]>((resolve, reject) => {
27-
const stream = fg.stream(pattern, {
28-
ignore: EXCLUDE_PATTERNS,
29-
absolute: true
30-
});
31-
32-
stream.on('error', error => {
33-
reject(error);
34-
});
35-
36-
stream.on('data', file => {
37-
if (path.extname(file) === '.ts' || path.extname(file) === '.tsx') {
38-
this.scannedFiles.push(file);
39-
}
40-
});
41-
42-
stream.on('end', () => {
43-
resolve(this.scannedFiles);
44-
});
27+
const files = await glob(pattern, {
28+
ignore: EXCLUDE_PATTERNS,
29+
absolute: true
4530
});
31+
32+
files.forEach(file => {
33+
if (path.extname(file) === '.ts' || path.extname(file) === '.tsx') {
34+
this.scannedFiles.push(file);
35+
}
36+
});
37+
38+
return this.scannedFiles;
4639
}
4740
}
4841

‎src-refactored/infrastructure/serving/serve.ts‎

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
1-
import * as LiveServer from '@compodoc/live-server';
2-
31
import { InternalConfiguration } from '../../core/entities/internal-configuration';
4-
5-
interface LiveServerConfiguration {
6-
root?: string;
7-
open?: boolean;
8-
quiet: boolean;
9-
logLevel: number;
10-
wait: number;
11-
host?: string;
12-
port?: number;
13-
}
2+
import {
3+
DocumentationServerConfiguration,
4+
startDocumentationServer
5+
} from '../../../src/utils/documentation-server';
146

157
export class ServeService {
168
private static instance: ServeService;
179

18-
public liveServerConfiguration: LiveServerConfiguration;
10+
public documentationServerConfiguration: DocumentationServerConfiguration;
1911

2012
constructor() {
21-
this.liveServerConfiguration = {
22-
quiet: true,
23-
logLevel: 0,
24-
wait: 1000
13+
this.documentationServerConfiguration = {
14+
root: '',
15+
port: 8080
2516
};
2617
}
2718

@@ -34,13 +25,13 @@ export class ServeService {
3425

3526
public serve(configuration: InternalConfiguration) {
3627
if (configuration.host !== '') {
37-
this.liveServerConfiguration.host = configuration.host;
28+
this.documentationServerConfiguration.host = configuration.host;
3829
}
39-
this.liveServerConfiguration.root = configuration.output;
40-
this.liveServerConfiguration.open = false;
41-
this.liveServerConfiguration.port = configuration.port;
30+
this.documentationServerConfiguration.root = configuration.output;
31+
this.documentationServerConfiguration.open = false;
32+
this.documentationServerConfiguration.port = configuration.port;
4233

43-
return LiveServer.start(this.liveServerConfiguration);
34+
return startDocumentationServer(this.documentationServerConfiguration);
4435
}
4536
}
4637

‎src/app/application.ts‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { SyntaxKind } from 'ts-morph';
66

77
const chokidar = require('chokidar');
88

9-
const LiveServer = require('@compodoc/live-server');
109
const traverse = require('neotraverse/legacy');
1110
const crypto = require('crypto');
1211

@@ -49,10 +48,13 @@ import {
4948

5049
import { AdditionalNode } from './interfaces/additional-node.interface';
5150
import { CoverageData } from './interfaces/coverageData.interface';
52-
import { LiveServerConfiguration } from './interfaces/live-server-configuration.interface';
5351
import { markedAcl } from '../utils/marked.acl';
5452
import { ComponentHelper } from './compiler/angular/deps/helpers/component-helper';
5553
import { renderLlmMd } from '../llm-md';
54+
import {
55+
DocumentationServerConfiguration,
56+
startDocumentationServer
57+
} from '../utils/documentation-server';
5658

5759
const cwd = process.cwd();
5860
let startTime = new Date();
@@ -2811,18 +2813,15 @@ at least one config for the 'info' or 'source' tab in --navTabConfig.`);
28112813

28122814
public runWebServer(folder: string) {
28132815
if (!this.isWatching) {
2814-
let liveServerConfiguration: LiveServerConfiguration = {
2816+
let documentationServerConfiguration: DocumentationServerConfiguration = {
28152817
root: folder,
28162818
open: Configuration.mainData.open,
2817-
quiet: true,
2818-
logLevel: 0,
2819-
wait: 1000,
28202819
port: Configuration.mainData.port
28212820
};
28222821
if (Configuration.mainData.host !== '') {
2823-
liveServerConfiguration.host = Configuration.mainData.host;
2822+
documentationServerConfiguration.host = Configuration.mainData.host;
28242823
}
2825-
LiveServer.start(liveServerConfiguration);
2824+
startDocumentationServer(documentationServerConfiguration);
28262825
}
28272826
if (Configuration.mainData.watch && !this.isWatching) {
28282827
if (typeof this.files === 'undefined') {

‎src/app/interfaces/live-server-configuration.interface.ts‎

Lines changed: 0 additions & 9 deletions
This file was deleted.

‎src/index-cli.ts‎

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { parsePublicApi } from "./utils/public-api-parser.util";
1919
import { parseApiMarkdownExports } from "./utils/api-markdown-parser.util";
2020
import { createSourcePathMapper } from "./utils/source-path-mapper.util";
2121

22-
const fg = require("fast-glob");
22+
const { glob, globSync } = require("tinyglobby");
2323
const { program } = require("commander");
2424

2525
let scannedFiles: string[] = [];
@@ -257,13 +257,13 @@ export class CliApplication extends Application {
257257
);
258258
}
259259

260-
const stream = fg.stream(includeFiles, {
260+
const files = await glob(includeFiles, {
261261
cwd: sourceFolder || cwd,
262262
ignore: excludeFiles,
263263
absolute: true,
264264
});
265265

266-
stream.on("data", (file: string) => {
266+
files.forEach((file: string) => {
267267
if (
268268
path.extname(file) === ".ts" ||
269269
path.extname(file) === ".tsx"
@@ -275,18 +275,16 @@ export class CliApplication extends Application {
275275
}
276276
});
277277

278-
stream.on("end", () => {
279-
super.setFiles(scannedFiles);
280-
if (
281-
programOptions.coverageTest ||
282-
programOptions.coverageTestPerFile
283-
) {
284-
logger.info("Run documentation coverage test");
285-
super.testCoverage();
286-
} else {
287-
super.generate();
288-
}
289-
});
278+
super.setFiles(scannedFiles);
279+
if (
280+
programOptions.coverageTest ||
281+
programOptions.coverageTestPerFile
282+
) {
283+
logger.info("Run documentation coverage test");
284+
super.testCoverage();
285+
} else {
286+
super.generate();
287+
}
290288
}
291289
} else {
292290
logger.error(
@@ -416,7 +414,7 @@ export class CliApplication extends Application {
416414
const sourceFolder = sourceRoot;
417415

418416
try {
419-
const files = fg.sync(path.join(sourceFolder, "**/*.ts"), {
417+
const files = globSync(path.join(sourceFolder, "**/*.ts"), {
420418
ignore: ["**/node_modules/**", "**/*.spec.ts", "**/*.d.ts"],
421419
});
422420

‎src/utils/api-markdown-parser.util.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as path from 'path';
33
import { ts } from 'ts-morph';
44
import { logger } from './logger';
55

6-
const fg = require('fast-glob');
6+
const { glob } = require('tinyglobby');
77

88
/**
99
* Result of parsing API markdown exports
@@ -45,7 +45,7 @@ export class ApiMarkdownParser {
4545

4646
// Find all *.api.md files recursively
4747
const pattern = path.join(this.sourceRoot, '**/*.api.md');
48-
const apiMdFiles = await fg(pattern, {
48+
const apiMdFiles = await glob(pattern, {
4949
absolute: true,
5050
ignore: ['**/node_modules/**']
5151
});
@@ -382,4 +382,3 @@ export async function parseApiMarkdownExports(sourceRoot: string): Promise<ApiMa
382382
const parser = new ApiMarkdownParser(sourceRoot);
383383
return await parser.parseApiMarkdownFiles();
384384
}
385-

0 commit comments

Comments
 (0)