Skip to content

Commit ccae1ac

Browse files
authored
fix: convert @apilink to @link on build (#383)
Related: apify/crawlee#2717
1 parent 19edcb0 commit ccae1ac

8 files changed

+160
-494
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"eslint-config-prettier": "^10.1.1",
8383
"fs-extra": "^11.2.0",
8484
"gen-esm-wrapper": "^1.1.3",
85+
"globby": "^14.1.0",
8586
"husky": "^9.1.7",
8687
"lerna": "^8.1.8",
8788
"lint-staged": "^15.2.8",

packages/apify/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"clean": "rimraf ./dist",
4949
"compile": "tsc -p tsconfig.build.json && gen-esm-wrapper ./dist/index.js ./dist/index.mjs",
5050
"copy": "tsx ../../scripts/copy.ts --readme=local",
51-
"fixApifyExport": "tsx ../../scripts/temp_fix_apify_exports.ts"
51+
"fixApifyExport": "node ../../scripts/temp_fix_apify_exports.mjs"
5252
},
5353
"publishConfig": {
5454
"access": "public"

scripts/temp_fix_apify_exports.mjs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { copyFileSync, readFileSync, writeFileSync } from 'node:fs';
2+
import { resolve } from 'node:path';
3+
4+
import { globby } from 'globby';
5+
6+
const cwd = resolve(process.cwd(), 'dist');
7+
const target = resolve(cwd, 'index.d.ts');
8+
const file = readFileSync(target).toString();
9+
10+
writeFileSync(
11+
target,
12+
file.replace(
13+
`export * from './exports';`,
14+
`// @ts-ignore\nexport * from './exports';`,
15+
),
16+
);
17+
18+
const files = await globby(`${cwd}/**/*.(d.ts|js)`);
19+
20+
// convert `@apilink` to `@link`
21+
for (const filepath of files) {
22+
const input = readFileSync(filepath, { encoding: 'utf8' }).split('\n');
23+
const output = [];
24+
let changed = false;
25+
26+
for (const line of input) {
27+
if (line.includes('@apilink')) {
28+
output.push(line.replaceAll('@apilink', '@link'));
29+
changed = true;
30+
} else {
31+
output.push(line);
32+
}
33+
}
34+
35+
if (changed === true) {
36+
console.log('Writing', filepath);
37+
writeFileSync(filepath, output.join('\n'));
38+
}
39+
}

scripts/temp_fix_apify_exports.ts

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

tools/build_readme.js

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

0 commit comments

Comments
 (0)