Skip to content

Commit

Permalink
fix(core): update to the async version of getting powerpack informati…
Browse files Browse the repository at this point in the history
…on (#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 #
  • Loading branch information
FrozenPandaz authored Nov 27, 2024
1 parent 1ea7bb4 commit b018b94
Show file tree
Hide file tree
Showing 4 changed files with 274 additions and 267 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 4 additions & 2 deletions packages/nx/src/command-line/report/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('');
Expand Down
9 changes: 7 additions & 2 deletions packages/nx/src/utils/powerpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit b018b94

Please sign in to comment.