fix(core): update to the async version of getting powerpack information (#29088)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

The deprecated sync API for getting powerpack license information is
used.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

The new async API for getting powerpack license information is used if
it is available. If not, it uses the sync API.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
This commit is contained in:
Jason Jean 2024-11-26 20:10:00 -05:00 committed by GitHub
parent 1ea7bb43e1
commit b018b94096
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 309 additions and 302 deletions

View File

@ -79,9 +79,9 @@
"@nx/js": "20.2.0-beta.3",
"@nx/next": "20.2.0-beta.3",
"@nx/playwright": "20.2.0-beta.3",
"@nx/powerpack-conformance": "1.1.0-beta.5",
"@nx/powerpack-enterprise-cloud": "1.1.0-beta.5",
"@nx/powerpack-license": "1.1.0-beta.5",
"@nx/powerpack-conformance": "1.1.0-beta.6",
"@nx/powerpack-enterprise-cloud": "1.1.0-beta.6",
"@nx/powerpack-license": "1.1.0-beta.6",
"@nx/react": "20.2.0-beta.3",
"@nx/storybook": "20.2.0-beta.3",
"@nx/vite": "20.2.0-beta.3",

View File

@ -106,11 +106,13 @@ export async function reportHandler() {
`Licensed to ${powerpackLicense.organizationName} for ${
powerpackLicense.seatCount
} user${powerpackLicense.seatCount > 1 ? 's' : ''} in ${
powerpackLicense.workspaceCount
powerpackLicense.workspaceCount === 9999
? 'an unlimited number of'
: powerpackLicense.workspaceCount
} workspace${
powerpackLicense.workspaceCount > 1 ? 's' : ''
} until ${new Date(
powerpackLicense.expiresAt * 1000
(powerpackLicense.realExpiresAt ?? powerpackLicense.expiresAt) * 1000
).toLocaleDateString()}`
);
bodyLines.push('');

View File

@ -19,10 +19,15 @@ export async function printPowerpackLicense() {
export async function getPowerpackLicenseInformation() {
try {
const { getPowerpackLicenseInformation } = (await import(
const {
getPowerpackLicenseInformation,
getPowerpackLicenseInformationAsync,
} = (await import(
'@nx/powerpack-license'
)) as typeof import('@nx/powerpack-license');
return getPowerpackLicenseInformation(workspaceRoot);
return (
getPowerpackLicenseInformationAsync ?? getPowerpackLicenseInformation
)(workspaceRoot);
} catch (e) {
if ('code' in e && e.code === 'MODULE_NOT_FOUND') {
throw new NxPowerpackNotInstalledError(e);

590
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff