Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add attw CLI option to treat problems as non-errors #3316

Merged
merged 2 commits into from
Apr 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 41 additions & 3 deletions examples/publish-ci/are-the-types-wrong/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from '@arethetypeswrong/core'
import React from 'react'
import { render, Text, Box, Static } from 'ink'
import yargs from 'yargs/yargs'

const allResolutionKinds: ResolutionKind[] = [
'node10',
Expand Down Expand Up @@ -232,7 +233,18 @@ function ChecksTable(props: { checks?: Checks }) {
)
}

;(async function main() {
const { argv } = yargs(process.argv).option('nonErrorProblems', {
alias: 'n',
type: 'array',
description: 'Do not treat these problems as errors for CLI exit codes',
choices: Object.keys(problemShortDescriptions) as ProblemKind[],
})

interface CLIOptions {
nonErrorProblems?: ProblemKind[]
}

;(async function main({ nonErrorProblems = [] }: CLIOptions) {
const analysis = await checkTgz(rtkPackageTgzBytes)

const checks: Checks = {
Expand Down Expand Up @@ -263,6 +275,32 @@ function ChecksTable(props: { checks?: Checks }) {
</Static>
)

const exitCode = checks.problems?.length ?? 0
const { problems = [] } = checks

console.log('\n\nProblem results:')

if (nonErrorProblems.length) {
console.log(
'Treating these problem categories as non-errors: ',
nonErrorProblems
)
}

const filteredProblems = problems.filter(
(p) => !nonErrorProblems.includes(p.kind)
)

if (filteredProblems.length) {
console.error(
'Remaining problems: ',
filteredProblems.map((p) => p.kind)
)
} else {
console.log('No errors found!')
}

const exitCode = filteredProblems.length
process.exit(exitCode)
})()
})({
nonErrorProblems: argv.nonErrorProblems as ProblemKind[],
})
3 changes: 2 additions & 1 deletion examples/publish-ci/are-the-types-wrong/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"@arethetypeswrong/core": "^0.0.4",
"@types/react": "^18.0.28",
"shelljs": "^0.8.5",
"tsx": "^3.12.5"
"tsx": "^3.12.5",
"yargs": "^17.7.1"
},
"resolutions": {
"@arethetypeswrong/core@^0.0.4": "patch:@arethetypeswrong/core@npm%3A0.0.4#./.yarn/patches/@arethetypeswrong-core-npm-0.0.4-edb717a66b.patch"
Expand Down
102 changes: 100 additions & 2 deletions examples/publish-ci/are-the-types-wrong/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,15 @@ __metadata:
languageName: node
linkType: hard

"ansi-styles@npm:^4.0.0":
version: 4.3.0
resolution: "ansi-styles@npm:4.3.0"
dependencies:
color-convert: ^2.0.1
checksum: 513b44c3b2105dd14cc42a19271e80f386466c4be574bccf60b627432f9198571ebf4ab1e4c3ba17347658f4ee1711c163d574248c0c1cdc2d5917a0ad582ec4
languageName: node
linkType: hard

"ansi-styles@npm:^6.0.0, ansi-styles@npm:^6.1.0":
version: 6.2.1
resolution: "ansi-styles@npm:6.2.1"
Expand Down Expand Up @@ -421,6 +430,7 @@ __metadata:
react: ^18.2.0
shelljs: ^0.8.5
tsx: ^3.12.5
yargs: ^17.7.1
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -554,6 +564,17 @@ __metadata:
languageName: node
linkType: hard

"cliui@npm:^8.0.1":
version: 8.0.1
resolution: "cliui@npm:8.0.1"
dependencies:
string-width: ^4.2.0
strip-ansi: ^6.0.1
wrap-ansi: ^7.0.0
checksum: 79648b3b0045f2e285b76fb2e24e207c6db44323581e421c3acbd0e86454cba1b37aea976ab50195a49e7384b871e6dfb2247ad7dec53c02454ac6497394cb56
languageName: node
linkType: hard

"code-excerpt@npm:^4.0.0":
version: 4.0.0
resolution: "code-excerpt@npm:4.0.0"
Expand All @@ -563,6 +584,22 @@ __metadata:
languageName: node
linkType: hard

"color-convert@npm:^2.0.1":
version: 2.0.1
resolution: "color-convert@npm:2.0.1"
dependencies:
color-name: ~1.1.4
checksum: 79e6bdb9fd479a205c71d89574fccfb22bd9053bd98c6c4d870d65c132e5e904e6034978e55b43d69fcaa7433af2016ee203ce76eeba9cfa554b373e7f7db336
languageName: node
linkType: hard

"color-name@npm:~1.1.4":
version: 1.1.4
resolution: "color-name@npm:1.1.4"
checksum: b0445859521eb4021cd0fb0cc1a75cecf67fceecae89b63f62b201cca8d345baf8b952c966862a9d9a2632987d4f6581f0ec8d957dfacece86f0a7919316f610
languageName: node
linkType: hard

"color-support@npm:^1.1.3":
version: 1.1.3
resolution: "color-support@npm:1.1.3"
Expand Down Expand Up @@ -747,6 +784,13 @@ __metadata:
languageName: node
linkType: hard

"escalade@npm:^3.1.1":
version: 3.1.1
resolution: "escalade@npm:3.1.1"
checksum: a3e2a99f07acb74b3ad4989c48ca0c3140f69f923e56d0cba0526240ee470b91010f9d39001f2a4a313841d237ede70a729e92125191ba5d21e74b106800b133
languageName: node
linkType: hard

"escape-string-regexp@npm:^2.0.0":
version: 2.0.0
resolution: "escape-string-regexp@npm:2.0.0"
Expand Down Expand Up @@ -828,6 +872,13 @@ __metadata:
languageName: node
linkType: hard

"get-caller-file@npm:^2.0.5":
version: 2.0.5
resolution: "get-caller-file@npm:2.0.5"
checksum: b9769a836d2a98c3ee734a88ba712e62703f1df31b94b784762c433c27a386dd6029ff55c2a920c392e33657d80191edbf18c61487e198844844516f843496b9
languageName: node
linkType: hard

"get-tsconfig@npm:^4.4.0":
version: 4.4.0
resolution: "get-tsconfig@npm:4.4.0"
Expand Down Expand Up @@ -1476,6 +1527,13 @@ __metadata:
languageName: node
linkType: hard

"require-directory@npm:^2.1.1":
version: 2.1.1
resolution: "require-directory@npm:2.1.1"
checksum: fb47e70bf0001fdeabdc0429d431863e9475e7e43ea5f94ad86503d918423c1543361cc5166d713eaa7029dd7a3d34775af04764bebff99ef413111a5af18c80
languageName: node
linkType: hard

"reselect@npm:^4.1.7":
version: 4.1.7
resolution: "reselect@npm:4.1.7"
Expand Down Expand Up @@ -1671,7 +1729,7 @@ __metadata:
languageName: node
linkType: hard

"string-width@npm:^1.0.2 || 2 || 3 || 4, string-width@npm:^4.2.3":
"string-width@npm:^1.0.2 || 2 || 3 || 4, string-width@npm:^4.1.0, string-width@npm:^4.2.0, string-width@npm:^4.2.3":
version: 4.2.3
resolution: "string-width@npm:4.2.3"
dependencies:
Expand Down Expand Up @@ -1702,7 +1760,7 @@ __metadata:
languageName: node
linkType: hard

"strip-ansi@npm:^6.0.1":
"strip-ansi@npm:^6.0.0, strip-ansi@npm:^6.0.1":
version: 6.0.1
resolution: "strip-ansi@npm:6.0.1"
dependencies:
Expand Down Expand Up @@ -1870,6 +1928,17 @@ __metadata:
languageName: node
linkType: hard

"wrap-ansi@npm:^7.0.0":
version: 7.0.0
resolution: "wrap-ansi@npm:7.0.0"
dependencies:
ansi-styles: ^4.0.0
string-width: ^4.1.0
strip-ansi: ^6.0.0
checksum: a790b846fd4505de962ba728a21aaeda189b8ee1c7568ca5e817d85930e06ef8d1689d49dbf0e881e8ef84436af3a88bc49115c2e2788d841ff1b8b5b51a608b
languageName: node
linkType: hard

"wrap-ansi@npm:^8.1.0":
version: 8.1.0
resolution: "wrap-ansi@npm:8.1.0"
Expand Down Expand Up @@ -1903,13 +1972,42 @@ __metadata:
languageName: node
linkType: hard

"y18n@npm:^5.0.5":
version: 5.0.8
resolution: "y18n@npm:5.0.8"
checksum: 54f0fb95621ee60898a38c572c515659e51cc9d9f787fb109cef6fde4befbe1c4602dc999d30110feee37456ad0f1660fa2edcfde6a9a740f86a290999550d30
languageName: node
linkType: hard

"yallist@npm:^4.0.0":
version: 4.0.0
resolution: "yallist@npm:4.0.0"
checksum: 343617202af32df2a15a3be36a5a8c0c8545208f3d3dfbc6bb7c3e3b7e8c6f8e7485432e4f3b88da3031a6e20afa7c711eded32ddfb122896ac5d914e75848d5
languageName: node
linkType: hard

"yargs-parser@npm:^21.1.1":
version: 21.1.1
resolution: "yargs-parser@npm:21.1.1"
checksum: ed2d96a616a9e3e1cc7d204c62ecc61f7aaab633dcbfab2c6df50f7f87b393993fe6640d017759fe112d0cb1e0119f2b4150a87305cc873fd90831c6a58ccf1c
languageName: node
linkType: hard

"yargs@npm:^17.7.1":
version: 17.7.1
resolution: "yargs@npm:17.7.1"
dependencies:
cliui: ^8.0.1
escalade: ^3.1.1
get-caller-file: ^2.0.5
require-directory: ^2.1.1
string-width: ^4.2.3
y18n: ^5.0.5
yargs-parser: ^21.1.1
checksum: 3d8a43c336a4942bc68080768664aca85c7bd406f018bad362fd255c41c8f4e650277f42fd65d543fce99e084124ddafee7bbfc1a5c6a8fda4cec78609dcf8d4
languageName: node
linkType: hard

"yoga-layout-prebuilt@npm:^1.9.6":
version: 1.10.0
resolution: "yoga-layout-prebuilt@npm:1.10.0"
Expand Down