[internal] Add license report scripts (#2751)

This PR adds scripts that allow us to generate reports on our
dependencies.

### Change Type

- [x] `internal` — Any other changes that don't affect the published
package[^2]
This commit is contained in:
Steve Ruiz 2024-04-01 14:36:40 +01:00 committed by GitHub
parent fba2b0d076
commit 3df866a86f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 291 additions and 6 deletions

2
.gitignore vendored
View file

@ -93,3 +93,5 @@ apps/docs/content/gen
.wrangler
/vercel.json
license-report-prod.html
license-report.html

View file

@ -96,6 +96,7 @@
"jest": "30.0.0-alpha.2",
"json5": "^2.2.3",
"lazyrepo": "0.0.0-alpha.27",
"license-report": "^6.5.0",
"lint-staged": ">=10",
"prettier": "^3.0.3",
"prettier-plugin-organize-imports": "^3.2.3",

62
scripts/license-report.ts Normal file
View file

@ -0,0 +1,62 @@
// For all package.jsons found in the monorepo, generate a license report
// by running the `license-report --output=html` script in each package.
import { execPromise } from '@auto-it/core'
import { execSync } from 'child_process'
import { writeFileSync } from 'fs'
// Use `yarn workspace list` to get all the packages in the monorepo
async function main() {
const devOnly = process.argv.includes('--dev')
const prodOnly = process.argv.includes('--prod')
const htmlTables: { title: string; content: string }[] = []
const workspaceList = execSync('yarn workspaces list', {
encoding: 'utf-8',
})
const lines = workspaceList.split('\n')
lines.pop() // remove // Done
for (let i = 0; i < lines.length; i++) {
const location = lines[i].split(': ')[1]
try {
console.log('running license-report in', location)
const report = await execPromise(
`yarn license-report --package=${location}/package.json --department.value=tldraw --relatedTo.label=Package --relatedTo.value=${location} --output=html --only=${devOnly ? 'dev' : prodOnly ? 'prod' : 'dev,prod,peer,opt'}`
)
// Extract the <table> contents from the report
const table = report.match(/<tbody>.*<\/tbody>/gs)
if (!table) {
console.error('Error extracting table from license-report result.')
process.exit(1)
}
htmlTables.push({ title: location, content: table[0] })
} catch (e) {
console.error(`Error running license-report in ${location}, ${e}`)
}
}
const html = `
<html>
<body>
<table><thead><tr><th class="string">department</th><th class="string">related to</th><th class="string">name</th><th class="string">license period</th><th class="string">material / not material</th><th class="string">license type</th><th class="string">link</th><th class="string">remote version</th><th class="string">installed version</th><th class="string">defined version</th><th class="string">author</th></tr></thead><tbody>
${htmlTables.reduce((acc, { content }) => {
acc += content + '<tr></tr>'
return acc
}, '')}
</tbody></table>
</body>
</html>
`
writeFileSync(
prodOnly
? 'license-report-prod.html'
: devOnly
? 'license-report-dev.html'
: 'license-report.html',
html
)
}
main()

230
yarn.lock
View file

@ -4059,6 +4059,13 @@ __metadata:
languageName: node
linkType: hard
"@kessler/tableify@npm:^1.0.2":
version: 1.0.2
resolution: "@kessler/tableify@npm:1.0.2"
checksum: 705d5218559bcbcde2a3a7908f42f0738f92a4d703d687e4a1f716fd9215e8bee5a326d8181b9f3e783fb3713a7bee65bdbe3cf0ef339cb3e51ec5fa6a2bf467
languageName: node
linkType: hard
"@lezer/common@npm:^1.0.0, @lezer/common@npm:^1.0.2, @lezer/common@npm:^1.1.0, @lezer/common@npm:^1.2.0":
version: 1.2.1
resolution: "@lezer/common@npm:1.2.1"
@ -6430,6 +6437,13 @@ __metadata:
languageName: node
linkType: hard
"@sindresorhus/is@npm:^5.2.0":
version: 5.6.0
resolution: "@sindresorhus/is@npm:5.6.0"
checksum: b077c325acec98e30f7d86df158aaba2e7af2acb9bb6a00fda4b91578539fbff4ecebe9b934e24fec0e6950de3089d89d79ec02d9062476b20ce185be0e01bd6
languageName: node
linkType: hard
"@sindresorhus/slugify@npm:^2.2.0":
version: 2.2.1
resolution: "@sindresorhus/slugify@npm:2.2.1"
@ -7300,6 +7314,15 @@ __metadata:
languageName: node
linkType: hard
"@szmarczak/http-timer@npm:^5.0.1":
version: 5.0.1
resolution: "@szmarczak/http-timer@npm:5.0.1"
dependencies:
defer-to-connect: "npm:^2.0.1"
checksum: fc9cb993e808806692e4a3337c90ece0ec00c89f4b67e3652a356b89730da98bc824273a6d67ca84d5f33cd85f317dcd5ce39d8cc0a2f060145a608a7cb8ce92
languageName: node
linkType: hard
"@testing-library/dom@npm:^9.0.0":
version: 9.3.4
resolution: "@testing-library/dom@npm:9.3.4"
@ -7521,6 +7544,7 @@ __metadata:
jest: "npm:30.0.0-alpha.2"
json5: "npm:^2.2.3"
lazyrepo: "npm:0.0.0-alpha.27"
license-report: "npm:^6.5.0"
lint-staged: "npm:>=10"
prettier: "npm:^3.0.3"
prettier-plugin-organize-imports: "npm:^3.2.3"
@ -8028,7 +8052,7 @@ __metadata:
languageName: node
linkType: hard
"@types/http-cache-semantics@npm:*":
"@types/http-cache-semantics@npm:*, @types/http-cache-semantics@npm:^4.0.2":
version: 4.0.4
resolution: "@types/http-cache-semantics@npm:4.0.4"
checksum: a59566cff646025a5de396d6b3f44a39ab6a74f2ed8150692e0f31cc52f3661a68b04afe3166ebe0d566bd3259cb18522f46e949576d5204781cd6452b7fe0c5
@ -10398,6 +10422,28 @@ __metadata:
languageName: node
linkType: hard
"cacheable-lookup@npm:^7.0.0":
version: 7.0.0
resolution: "cacheable-lookup@npm:7.0.0"
checksum: 69ea78cd9f16ad38120372e71ba98b64acecd95bbcbcdad811f857dc192bad81ace021f8def012ce19178583db8d46afd1a00b3e8c88527e978e049edbc23252
languageName: node
linkType: hard
"cacheable-request@npm:^10.2.8":
version: 10.2.14
resolution: "cacheable-request@npm:10.2.14"
dependencies:
"@types/http-cache-semantics": "npm:^4.0.2"
get-stream: "npm:^6.0.1"
http-cache-semantics: "npm:^4.1.1"
keyv: "npm:^4.5.3"
mimic-response: "npm:^4.0.0"
normalize-url: "npm:^8.0.0"
responselike: "npm:^3.0.0"
checksum: 102f454ac68eb66f99a709c5cf65e90ed89f1b9269752578d5a08590b3986c3ea47a5d9dff208fe7b65855a29da129a2f23321b88490106898e0ba70b807c912
languageName: node
linkType: hard
"cacheable-request@npm:^7.0.2":
version: 7.0.4
resolution: "cacheable-request@npm:7.0.4"
@ -11547,7 +11593,7 @@ __metadata:
languageName: node
linkType: hard
"defer-to-connect@npm:^2.0.0":
"defer-to-connect@npm:^2.0.0, defer-to-connect@npm:^2.0.1":
version: 2.0.1
resolution: "defer-to-connect@npm:2.0.1"
checksum: 8a9b50d2f25446c0bfefb55a48e90afd58f85b21bcf78e9207cd7b804354f6409032a1705c2491686e202e64fc05f147aa5aa45f9aa82627563f045937f5791b
@ -12120,6 +12166,13 @@ __metadata:
languageName: node
linkType: hard
"eol@npm:^0.9.1":
version: 0.9.1
resolution: "eol@npm:0.9.1"
checksum: 9d3fd93bb2bb5c69c7fe8dfb97b62213ed95857a2e90f5db3110415993e8a989d87fb011755ce22fdb92ca36fbe4e111b395a6f4ce00b9b51d3f00f19c2acf52
languageName: node
linkType: hard
"err-code@npm:^2.0.2":
version: 2.0.3
resolution: "err-code@npm:2.0.3"
@ -14053,6 +14106,13 @@ __metadata:
languageName: node
linkType: hard
"form-data-encoder@npm:^2.1.2":
version: 2.1.4
resolution: "form-data-encoder@npm:2.1.4"
checksum: 3778e7db3c21457296e6fdbc4200642a6c01e8be9297256e845ee275f9ddaecb5f49bfb0364690ad216898c114ec59bf85f01ec823a70670b8067273415d62f6
languageName: node
linkType: hard
"form-data@npm:^4.0.0":
version: 4.0.0
resolution: "form-data@npm:4.0.0"
@ -14421,6 +14481,13 @@ __metadata:
languageName: node
linkType: hard
"get-stdin@npm:^5.0.1":
version: 5.0.1
resolution: "get-stdin@npm:5.0.1"
checksum: f9784638ad3e68a0a8bdc031aedf0fca749843cd134956fbd4f3bbac17c359e0fb9210343fcbed72ee79fb19d8e4c49b7a6e742cc5d44e94ac1405e9371d4b3e
languageName: node
linkType: hard
"get-stream@npm:^5.1.0":
version: 5.2.0
resolution: "get-stream@npm:5.2.0"
@ -14430,7 +14497,7 @@ __metadata:
languageName: node
linkType: hard
"get-stream@npm:^6.0.0":
"get-stream@npm:^6.0.0, get-stream@npm:^6.0.1":
version: 6.0.1
resolution: "get-stream@npm:6.0.1"
checksum: 781266d29725f35c59f1d214aedc92b0ae855800a980800e2923b3fbc4e56b3cb6e462c42e09a1cf1a00c64e056a78fa407cbe06c7c92b7e5cd49b4b85c2a497
@ -14728,6 +14795,25 @@ __metadata:
languageName: node
linkType: hard
"got@npm:^13.0.0":
version: 13.0.0
resolution: "got@npm:13.0.0"
dependencies:
"@sindresorhus/is": "npm:^5.2.0"
"@szmarczak/http-timer": "npm:^5.0.1"
cacheable-lookup: "npm:^7.0.0"
cacheable-request: "npm:^10.2.8"
decompress-response: "npm:^6.0.0"
form-data-encoder: "npm:^2.1.2"
get-stream: "npm:^6.0.1"
http2-wrapper: "npm:^2.1.10"
lowercase-keys: "npm:^3.0.0"
p-cancelable: "npm:^3.0.0"
responselike: "npm:^3.0.0"
checksum: 35ac9fe37daca3d0a4f90305d8e64626268ef5a42584f5bcb42eea3cb9bbeb691cf9041d5ea72133a7295d1291684789a3148ff89a95f3d3ce3d0ebb6fb2f680
languageName: node
linkType: hard
"gpt-3-encoder@npm:1.1.4":
version: 1.1.4
resolution: "gpt-3-encoder@npm:1.1.4"
@ -15261,6 +15347,16 @@ __metadata:
languageName: node
linkType: hard
"http2-wrapper@npm:^2.1.10":
version: 2.2.1
resolution: "http2-wrapper@npm:2.2.1"
dependencies:
quick-lru: "npm:^5.1.1"
resolve-alpn: "npm:^1.2.0"
checksum: e7a5ac6548318e83fc0399cd832cdff6bbf902b165d211cad47a56ee732922e0aa1107246dd884b12532a1c4649d27c4d44f2480911c65202e93c90bde8fa29d
languageName: node
linkType: hard
"https-proxy-agent@npm:5, https-proxy-agent@npm:^5.0.0, https-proxy-agent@npm:^5.0.1":
version: 5.0.1
resolution: "https-proxy-agent@npm:5.0.1"
@ -17241,6 +17337,25 @@ __metadata:
languageName: node
linkType: hard
"license-report@npm:^6.5.0":
version: 6.5.0
resolution: "license-report@npm:6.5.0"
dependencies:
"@kessler/tableify": "npm:^1.0.2"
debug: "npm:^4.3.4"
eol: "npm:^0.9.1"
got: "npm:^13.0.0"
rc: "npm:^1.2.8"
semver: "npm:^7.5.4"
tablemark: "npm:^3.0.0"
text-table: "npm:^0.2.0"
visit-values: "npm:^2.0.0"
bin:
license-report: index.js
checksum: 6475e00363924d2fac5712f9866272cfb930834ad4469bc4454fc108a24212a51c2dd49911c61000fef2a848527d3eb37a6b380e4b22865c12d9b4c3ade95d11
languageName: node
linkType: hard
"lie@npm:3.1.1":
version: 3.1.1
resolution: "lie@npm:3.1.1"
@ -17571,6 +17686,15 @@ __metadata:
languageName: node
linkType: hard
"lower-case@npm:^2.0.2":
version: 2.0.2
resolution: "lower-case@npm:2.0.2"
dependencies:
tslib: "npm:^2.0.3"
checksum: 83a0a5f159ad7614bee8bf976b96275f3954335a84fad2696927f609ddae902802c4f3312d86668722e668bef41400254807e1d3a7f2e8c3eede79691aa1f010
languageName: node
linkType: hard
"lowercase-keys@npm:^2.0.0":
version: 2.0.0
resolution: "lowercase-keys@npm:2.0.0"
@ -17578,6 +17702,13 @@ __metadata:
languageName: node
linkType: hard
"lowercase-keys@npm:^3.0.0":
version: 3.0.0
resolution: "lowercase-keys@npm:3.0.0"
checksum: 67a3f81409af969bc0c4ca0e76cd7d16adb1e25aa1c197229587eaf8671275c8c067cd421795dbca4c81be0098e4c426a086a05e30de8a9c587b7a13c0c7ccc5
languageName: node
linkType: hard
"lowlight@npm:^3.0.0":
version: 3.1.0
resolution: "lowlight@npm:3.1.0"
@ -18804,6 +18935,13 @@ __metadata:
languageName: node
linkType: hard
"mimic-response@npm:^4.0.0":
version: 4.0.0
resolution: "mimic-response@npm:4.0.0"
checksum: 33b804cc961efe206efdb1fca6a22540decdcfce6c14eb5c0c50e5ae9022267ab22ce8f5568b1f7247ba67500fe20d523d81e0e9f009b321ccd9d472e78d1850
languageName: node
linkType: hard
"min-indent@npm:^1.0.0":
version: 1.0.1
resolution: "min-indent@npm:1.0.1"
@ -19301,6 +19439,16 @@ __metadata:
languageName: node
linkType: hard
"no-case@npm:^3.0.4":
version: 3.0.4
resolution: "no-case@npm:3.0.4"
dependencies:
lower-case: "npm:^2.0.2"
tslib: "npm:^2.0.3"
checksum: 0b2ebc113dfcf737d48dde49cfebf3ad2d82a8c3188e7100c6f375e30eafbef9e9124aadc3becef237b042fd5eb0aad2fd78669c20972d045bbe7fea8ba0be5c
languageName: node
linkType: hard
"node-abi@npm:^3.3.0":
version: 3.54.0
resolution: "node-abi@npm:3.54.0"
@ -19480,6 +19628,13 @@ __metadata:
languageName: node
linkType: hard
"normalize-url@npm:^8.0.0":
version: 8.0.1
resolution: "normalize-url@npm:8.0.1"
checksum: ae392037584fc5935b663ae4af475351930a1fc39e107956cfac44f42d5127eec2d77d9b7b12ded4696ca78103bafac5b6206a0ea8673c7bffecbe13544fcc5a
languageName: node
linkType: hard
"npm-run-path@npm:^4.0.1":
version: 4.0.1
resolution: "npm-run-path@npm:4.0.1"
@ -19837,6 +19992,13 @@ __metadata:
languageName: node
linkType: hard
"p-cancelable@npm:^3.0.0":
version: 3.0.0
resolution: "p-cancelable@npm:3.0.0"
checksum: a5eab7cf5ac5de83222a014eccdbfde65ecfb22005ee9bc242041f0b4441e07fac7629432c82f48868aa0f8413fe0df6c6067c16f76bf9217cd8dc651923c93d
languageName: node
linkType: hard
"p-limit@npm:^1.1.0":
version: 1.3.0
resolution: "p-limit@npm:1.3.0"
@ -21647,7 +21809,7 @@ __metadata:
languageName: node
linkType: hard
"resolve-alpn@npm:^1.0.0":
"resolve-alpn@npm:^1.0.0, resolve-alpn@npm:^1.2.0":
version: 1.2.1
resolution: "resolve-alpn@npm:1.2.1"
checksum: 744e87888f0b6fa0b256ab454ca0b9c0b80808715e2ef1f3672773665c92a941f6181194e30ccae4a8cd0adbe0d955d3f133102636d2ee0cca0119fec0bc9aec
@ -21790,6 +21952,15 @@ __metadata:
languageName: node
linkType: hard
"responselike@npm:^3.0.0":
version: 3.0.0
resolution: "responselike@npm:3.0.0"
dependencies:
lowercase-keys: "npm:^3.0.0"
checksum: e0cc9be30df4f415d6d83cdede3c5c887cd4a73e7cc1708bcaab1d50a28d15acb68460ac5b02bcc55a42f3d493729c8856427dcf6e57e6e128ad05cba4cfb95e
languageName: node
linkType: hard
"restore-cursor@npm:^3.1.0":
version: 3.1.0
resolution: "restore-cursor@npm:3.1.0"
@ -22182,6 +22353,17 @@ __metadata:
languageName: node
linkType: hard
"sentence-case@npm:^3.0.4":
version: 3.0.4
resolution: "sentence-case@npm:3.0.4"
dependencies:
no-case: "npm:^3.0.4"
tslib: "npm:^2.0.3"
upper-case-first: "npm:^2.0.2"
checksum: 3cfe6c0143e649132365695706702d7f729f484fa7b25f43435876efe7af2478243eefb052bacbcce10babf9319fd6b5b6bc59b94c80a1c819bcbb40651465d5
languageName: node
linkType: hard
"serialize-javascript@npm:6.0.0":
version: 6.0.0
resolution: "serialize-javascript@npm:6.0.0"
@ -22555,6 +22737,18 @@ __metadata:
languageName: node
linkType: hard
"split-text-to-chunks@npm:^1.0.0":
version: 1.0.0
resolution: "split-text-to-chunks@npm:1.0.0"
dependencies:
get-stdin: "npm:^5.0.1"
minimist: "npm:^1.2.0"
bin:
wordwrap: cli.js
checksum: 944a2defff4eccf193216177b284bd8d3da0d83391827d89efa4250d4c0a0729e63fecfc0cf56fa2c50acba2b8017753b332b13d0aebdb9fb5c1c2164a943ce5
languageName: node
linkType: hard
"sprintf-js@npm:~1.0.2":
version: 1.0.3
resolution: "sprintf-js@npm:1.0.3"
@ -23132,6 +23326,16 @@ __metadata:
languageName: node
linkType: hard
"tablemark@npm:^3.0.0":
version: 3.0.0
resolution: "tablemark@npm:3.0.0"
dependencies:
sentence-case: "npm:^3.0.4"
split-text-to-chunks: "npm:^1.0.0"
checksum: 1e819d7e1ad268743543778b5a1aec559113bf91098e220997fddccd207fd779d8ab216ff86d2180bb780841a23ef3f84f59bbc493d41cd5badff1246a04a8de
languageName: node
linkType: hard
"tapable@npm:^2.1.1, tapable@npm:^2.2.0":
version: 2.2.1
resolution: "tapable@npm:2.2.1"
@ -23717,7 +23921,7 @@ __metadata:
languageName: node
linkType: hard
"tslib@npm:^2, tslib@npm:^2.0.0, tslib@npm:^2.0.1, tslib@npm:^2.1.0, tslib@npm:^2.2.0, tslib@npm:^2.3.1, tslib@npm:^2.4.0, tslib@npm:^2.5.0, tslib@npm:^2.6.1, tslib@npm:^2.6.2":
"tslib@npm:^2, tslib@npm:^2.0.0, tslib@npm:^2.0.1, tslib@npm:^2.0.3, tslib@npm:^2.1.0, tslib@npm:^2.2.0, tslib@npm:^2.3.1, tslib@npm:^2.4.0, tslib@npm:^2.5.0, tslib@npm:^2.6.1, tslib@npm:^2.6.2":
version: 2.6.2
resolution: "tslib@npm:2.6.2"
checksum: bd26c22d36736513980091a1e356378e8b662ded04204453d353a7f34a4c21ed0afc59b5f90719d4ba756e581a162ecbf93118dc9c6be5acf70aa309188166ca
@ -24336,6 +24540,15 @@ __metadata:
languageName: node
linkType: hard
"upper-case-first@npm:^2.0.2":
version: 2.0.2
resolution: "upper-case-first@npm:2.0.2"
dependencies:
tslib: "npm:^2.0.3"
checksum: 4487db4701effe3b54ced4b3e4aa4d9ab06c548f97244d04aafb642eedf96a76d5a03cf5f38f10f415531d5792d1ac6e1b50f2a76984dc6964ad530f12876409
languageName: node
linkType: hard
"uri-js@npm:^4.2.2":
version: 4.4.1
resolution: "uri-js@npm:4.4.1"
@ -24674,6 +24887,13 @@ __metadata:
languageName: node
linkType: hard
"visit-values@npm:^2.0.0":
version: 2.0.0
resolution: "visit-values@npm:2.0.0"
checksum: 9422c453864c363a93421f94342ce7c53fbd3e52b7dcd1f4df63c45e2ac1a71332047f1153fbdad2d9544867fa835f4029e2dca9415ee58437513fdb64895618
languageName: node
linkType: hard
"vite-node@npm:^0.28.5":
version: 0.28.5
resolution: "vite-node@npm:0.28.5"