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
(build-tools): Add command to update types #17427
(build-tools): Add command to update types #17427
Conversation
669b8d2
to
375b9c8
Compare
375b9c8
to
6ebec4b
Compare
build-tools/packages/build-cli/src/commands/updates/packageTypes.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-cli/src/commands/updates/packageTypes.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-cli/src/commands/updates/packageTypes.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-cli/src/commands/updates/packageTypes.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-cli/src/commands/updates/packageTypes.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-cli/src/commands/updates/packageTypes.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-cli/src/commands/updates/packageTypes.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-cli/src/commands/updates/packageTypes.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-cli/src/commands/updates/packageTypes.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-cli/src/commands/updates/packageTypes.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think about how to test this. If you factor out the main code into functions that accept a Package, then you can write tests that check that the properties are set correctly by the functions, for example.
build-tools/packages/build-cli/src/commands/updates/packageTypes.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-cli/src/commands/updates/packageTypes.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-cli/src/commands/updates/packageTypes.ts
Outdated
Show resolved
Hide resolved
21b9219
to
6a1e16b
Compare
6a1e16b
to
f3ea649
Compare
build-tools/packages/build-cli/src/commands/setReleaseTagForPublishing.ts
Outdated
Show resolved
Hide resolved
fa2c031
to
046d11e
Compare
046d11e
to
4ec49c6
Compare
build-tools/packages/build-cli/src/commands/release/setDtsTypes.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-cli/src/commands/release/setDtsTypes.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-cli/src/commands/release/setDtsTypes.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-cli/src/commands/release/setDtsTypes.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-cli/src/commands/release/setDtsTypes.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-cli/src/commands/release/setDtsTypes.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-cli/src/commands/release/setDtsTypes.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-cli/src/commands/release/setDtsTypes.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-cli/src/commands/release/setDtsTypes.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-cli/src/commands/release/setDtsTypes.ts
Outdated
Show resolved
Hide resolved
a9cf5a9
to
e3f8bc8
Compare
e3f8bc8
to
849b71a
Compare
|
| packagesNotUpdated: string[]; | ||
| } | ||
|
|
||
| const knownDtsKinds = ["alpha", "beta", "public", "untrimmed"] as const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you should refer to these as dtsTypes. Multiple .d.ts files being involved here is really an implementation detail of how this system you are making works with API-extractor.
I think it would make more sense to name thins (like this command, and this list) after "releaseTags" and link https://api-extractor.com/pages/tsdoc/doc_comment_syntax/#release-tags for additional docs.
Naming the command something like "selectReleaseTagToPublish" would be much more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"release" is a very overloaded term. I don't want to use it for this purpose. This work is explicitly about types only. Nothing related to what we release when, what version the release will have, etc. This tool only changes the types between "flavors" of the types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also has nothing to do with "publishing," so I don't think setReleaseTagToPublish is a good choice either. Maybe setPackageTypesField?
build-tools/packages/build-cli/src/commands/release/setDtsTypes.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-cli/src/commands/release/setDtsTypes.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-cli/src/commands/release/setDtsTypes.ts
Outdated
Show resolved
Hide resolved
| type DtsKind = typeof knownDtsKinds[number]; | ||
|
|
||
| function isDtsKind(str: string | undefined): str is DtsKind { | ||
| return str === undefined ? false : knownDtsKinds.includes(str as any); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this as any cast needed? Might need to explicitly type knownDtsKinds as string[]?
build-tools/packages/build-cli/src/commands/release/setDtsTypes.ts
Outdated
Show resolved
Hide resolved
b437ba0
to
5a9e974
Compare
4d8e46b
to
2c5d51b
Compare
9823f13
to
db6323e
Compare
db6323e
to
6a22c32
Compare
This new flub command will be used to update the
package.jsontypesto point to the alpha/beta release as required.This command first verifies the presence of an
api-extractor.jsonfile and subsequently examines its rollup configurations. If these configurations are present, it proceeds to update thepackage.json's types/typingsfield based on predefined conditions and flags.The updated package.json is serialized while retaining its original formatting and then written back to the file.
flub release setPackageTypesField -g client --types alpha --jsonflub release setPackageTypesField -g client --types beta --jsonflub release setPackageTypesField -g client --types public --jsonflub release setPackageTypesField -g client --types untrimmed --jsonAB#5535