Skip to content

Commit 6a2f567

Browse files
authored
Update generate-readme script (#3037)
* Rework generate-readmes * Remove docs script from all packages (just applied monorepolint) * Revert @monorepolint/cli to pick up an older yargs * Add missed glob dependencies * one more missed glob dependency * Another missed dependency, not sure why these are only showing up on CI * Remove glob from packages, keep it at the root instead
1 parent 6d9a78e commit 6a2f567

File tree

121 files changed

+299
-596
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+299
-596
lines changed

.monorepolint.config.mjs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
// @ts-check
22
import * as path from "node:path";
3-
import { glob } from "glob";
4-
import * as fs from "node:fs";
3+
import { existsSync } from "node:fs";
4+
import * as fs from "node:fs/promises";
55
import {
66
alphabeticalDependencies,
77
alphabeticalScripts,
88
packageOrder,
99
packageEntry,
1010
packageScript,
1111
requireDependency,
12+
REMOVE,
1213
} from "@monorepolint/rules";
1314

1415
const TS_PACKAGES = []; // projects that use typescript to build
@@ -21,30 +22,34 @@ const TSTYCHE_PACKAGES = []; // projects that use tstyche for type tests.
2122
const BENCH_PACKAGES = []; // projects that have benchmarks
2223

2324
// iterate all the packages and figure out what buckets everything falls into
24-
const __dirname = new URL(".", import.meta.url).pathname;
25-
glob.sync(path.join(__dirname, "packages", "turf-*")).forEach((pk) => {
25+
const packagesPath = path.join(process.cwd(), "packages");
26+
for (const pk of await fs.readdir(packagesPath)) {
27+
if (pk === "turf") {
28+
continue;
29+
}
30+
2631
const name = JSON.parse(
27-
fs.readFileSync(path.join(pk, "package.json"), "utf8")
32+
await fs.readFile(path.join(packagesPath, pk, "package.json"), "utf8")
2833
).name;
2934

30-
if (fs.existsSync(path.join(pk, "index.ts"))) {
35+
if (existsSync(path.join(packagesPath, pk, "index.ts"))) {
3136
TS_PACKAGES.push(name);
3237
} else {
3338
JS_PACKAGES.push(name);
3439
}
3540

36-
if (fs.existsSync(path.join(pk, "test.js"))) {
41+
if (existsSync(path.join(pk, "test.js"))) {
3742
TAPE_PACKAGES.push(name);
3843
}
3944

40-
if (fs.existsSync(path.join(pk, "types.ts"))) {
45+
if (existsSync(path.join(packagesPath, pk, "types.ts"))) {
4146
TYPES_PACKAGES.push(name);
4247
}
4348

44-
if (fs.existsSync(path.join(pk, "test/types.tst.ts"))) {
49+
if (existsSync(path.join(packagesPath, pk, "test/types.tst.ts"))) {
4550
TSTYCHE_PACKAGES.push(name);
4651
}
47-
});
52+
}
4853

4954
const TS_TAPE_PACKAGES = TAPE_PACKAGES.filter(
5055
(pkg) => -1 !== TS_PACKAGES.indexOf(pkg)
@@ -175,7 +180,7 @@ export default {
175180
packageScript({
176181
options: {
177182
scripts: {
178-
docs: "tsx ../../scripts/generate-readmes.ts",
183+
docs: REMOVE,
179184
test: "pnpm run /test:.*/",
180185
},
181186
},
@@ -234,6 +239,7 @@ export default {
234239
options: {
235240
devDependencies: {
236241
benchmark: "^2.1.4",
242+
glob: REMOVE,
237243
tape: "^5.9.0",
238244
tsup: "^8.4.0",
239245
tsx: "^4.19.4",

docs/CONTRIBUTING.md

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -140,25 +140,13 @@ Should you want to generate new README files manually, use `pnpm run docs`:
140140

141141
### Documentation - Examples
142142

143-
**Build docs for only `@turf/center`**
144-
145-
```bash
146-
$ cd ./turf/packages/turf-center
147-
$ pnpm run docs
148-
149-
> @turf/center@5.0.4 docs /Users/mac/Github/turf/packages/turf-center
150-
> node ../../scripts/generate-readmes
151-
152-
Building Docs: @turf/center
153-
```
154-
155143
**Builds docs for all packages**
156144

157145
```bash
158146
$ cd ./turf
159147
$ pnpm run docs
160148
> @ docs /Users/mac/Github/turf
161-
> tsx ./scripts/generate-readmes
149+
> node ./scripts/generate-readmes.mts
162150

163151
Building Docs: @turf/along
164152
Building Docs: @turf/area
@@ -171,6 +159,8 @@ Building Docs: @turf/boolean-clockwise
171159
....
172160
```
173161

162+
Note: This should be automatically executed with a pre-commit hook when necessary
163+
174164
### Public website
175165

176166
The [turfjs.org](https://turfjs.org/) website is managed in a [separate repo](https://github.com/Turfjs/turf-www) with its own [contributing guide](https://github.com/Turfjs/turf-www/blob/master/CONTRIBUTING.md).

package.json

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"private": true,
33
"funding": "https://opencollective.com/turf",
44
"scripts": {
5-
"docs": "tsx ./scripts/generate-readmes.ts",
5+
"docs": "node ./scripts/generate-readmes.mts",
66
"lint": "pnpm run /lint:.*/",
77
"lint:docs": "documentation lint packages/turf-*/index.js",
88
"lint:escheck-cjs": "es-check es8 packages/*/dist/cjs/index.cjs packages/turf/turf.min.js",
@@ -23,7 +23,7 @@
2323
"eslint --fix"
2424
],
2525
"packages/*/index.{js,ts}": [
26-
"pnpm tsx ./scripts/generate-readmes",
26+
"node ./scripts/generate-readmes.mts",
2727
"git add ./packages/*/README.md"
2828
],
2929
"*": "prettier --write --ignore-unknown"
@@ -32,10 +32,10 @@
3232
"devDependencies": {
3333
"@eslint/eslintrc": "^3.3.1",
3434
"@eslint/js": "^9.31.0",
35-
"@monorepolint/cli": "0.5.0",
36-
"@monorepolint/config": "0.5.0",
37-
"@monorepolint/core": "0.5.0",
38-
"@monorepolint/rules": "0.5.0",
35+
"@monorepolint/cli": "0.6.0-alpha.5",
36+
"@monorepolint/config": "0.6.0-alpha.6",
37+
"@monorepolint/core": "0.6.0-alpha.6",
38+
"@monorepolint/rules": "0.6.0-alpha.6",
3939
"@types/node": "22.15.3",
4040
"acorn": "^8.14.1",
4141
"camelcase": "^8.0.0",
@@ -48,7 +48,6 @@
4848
"eslint-config-prettier": "^10.1.8",
4949
"eslint-plugin-prettier": "^5.5.3",
5050
"esm": "^3.2.25",
51-
"fs-extra": "^11.3.0",
5251
"glob": "^11.1.0",
5352
"globals": "^16.0.0",
5453
"husky": "^9.1.7",
@@ -59,9 +58,8 @@
5958
"prettier": "^3.5.3",
6059
"progress": "^2.0.3",
6160
"tsup": "^8.4.0",
62-
"tsx": "^4.19.4",
6361
"typescript": "^5.8.3",
6462
"typescript-eslint": "^8.38.0",
65-
"yamljs": "^0.3.0"
63+
"yaml": "^2.8.2"
6664
}
6765
}

packages/turf-along/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
"scripts": {
4848
"bench": "tsx bench.ts",
4949
"build": "tsup --config ../../tsup.config.ts",
50-
"docs": "tsx ../../scripts/generate-readmes.ts",
5150
"test": "pnpm run /test:.*/",
5251
"test:tape": "tsx test.ts"
5352
},

packages/turf-angle/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
"scripts": {
4848
"bench": "tsx bench.ts",
4949
"build": "tsup --config ../../tsup.config.ts",
50-
"docs": "tsx ../../scripts/generate-readmes.ts",
5150
"test": "pnpm run /test:.*/",
5251
"test:tape": "tsx test.ts"
5352
},
@@ -58,7 +57,6 @@
5857
"@types/benchmark": "^2.1.5",
5958
"@types/tape": "^5.8.1",
6059
"benchmark": "^2.1.4",
61-
"glob": "^11.1.0",
6260
"load-json-file": "^7.0.1",
6361
"tape": "^5.9.0",
6462
"tsup": "^8.4.0",

packages/turf-area/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
"scripts": {
4747
"bench": "tsx bench.ts",
4848
"build": "tsup --config ../../tsup.config.ts",
49-
"docs": "tsx ../../scripts/generate-readmes.ts",
5049
"test": "pnpm run /test:.*/",
5150
"test:tape": "tsx test.ts"
5251
},

packages/turf-bbox-clip/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
"scripts": {
5353
"bench": "tsx bench.ts",
5454
"build": "tsup --config ../../tsup.config.ts",
55-
"docs": "tsx ../../scripts/generate-readmes.ts",
5655
"test": "pnpm run /test:.*/",
5756
"test:tape": "tsx test.ts"
5857
},

packages/turf-bbox-polygon/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
"scripts": {
4848
"bench": "tsx bench.ts",
4949
"build": "tsup --config ../../tsup.config.ts",
50-
"docs": "tsx ../../scripts/generate-readmes.ts",
5150
"test": "pnpm run /test:.*/",
5251
"test:tape": "tsx test.ts"
5352
},

packages/turf-bbox/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
"scripts": {
4949
"bench": "tsx bench.ts",
5050
"build": "tsup --config ../../tsup.config.ts",
51-
"docs": "tsx ../../scripts/generate-readmes.ts",
5251
"test": "pnpm run /test:.*/",
5352
"test:tape": "tsx test.ts"
5453
},

packages/turf-bearing/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
"scripts": {
4545
"bench": "tsx bench.ts",
4646
"build": "tsup --config ../../tsup.config.ts",
47-
"docs": "tsx ../../scripts/generate-readmes.ts",
4847
"test": "pnpm run /test:.*/",
4948
"test:tape": "tsx test.ts"
5049
},

0 commit comments

Comments
 (0)