fix(core): several powerpack fixes (#28088)
<!-- 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 --> * There is no flag in `nx.json` to enable the db cache * Typings for powerpack are `any` * Powerpack errors are not shown in `nx report` * 9999 workspaces show up when user purchases unlimited license * There is no indication from caching that license has expired. ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> * There is an `enableDbCache` flag for `nx.json`. It'll probably be changed soon. * Typings for powerpack come from the powerpack packages * Powerpack errors are shown in nx report * "an unlimited number of workspaces" shows up when user purchases unlimited license * There is an indication when licenses expire. ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
This commit is contained in:
parent
fd99bae238
commit
4081901b8d
@ -23,6 +23,7 @@ Nx.json configuration
|
|||||||
- [cli](../../devkit/documents/NxJsonConfiguration#cli): Object
|
- [cli](../../devkit/documents/NxJsonConfiguration#cli): Object
|
||||||
- [defaultBase](../../devkit/documents/NxJsonConfiguration#defaultbase): string
|
- [defaultBase](../../devkit/documents/NxJsonConfiguration#defaultbase): string
|
||||||
- [defaultProject](../../devkit/documents/NxJsonConfiguration#defaultproject): string
|
- [defaultProject](../../devkit/documents/NxJsonConfiguration#defaultproject): string
|
||||||
|
- [enableDbCache](../../devkit/documents/NxJsonConfiguration#enabledbcache): boolean
|
||||||
- [extends](../../devkit/documents/NxJsonConfiguration#extends): string
|
- [extends](../../devkit/documents/NxJsonConfiguration#extends): string
|
||||||
- [generators](../../devkit/documents/NxJsonConfiguration#generators): Object
|
- [generators](../../devkit/documents/NxJsonConfiguration#generators): Object
|
||||||
- [implicitDependencies](../../devkit/documents/NxJsonConfiguration#implicitdependencies): ImplicitDependencyEntry<T>
|
- [implicitDependencies](../../devkit/documents/NxJsonConfiguration#implicitdependencies): ImplicitDependencyEntry<T>
|
||||||
@ -98,6 +99,14 @@ will be used. Convenient for small workspaces with one main application.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
### enableDbCache
|
||||||
|
|
||||||
|
• `Optional` **enableDbCache**: `boolean`
|
||||||
|
|
||||||
|
Enable the new experimental db based cache
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### extends
|
### extends
|
||||||
|
|
||||||
• `Optional` **extends**: `string`
|
• `Optional` **extends**: `string`
|
||||||
|
|||||||
@ -21,6 +21,7 @@ use ProjectsConfigurations or NxJsonConfiguration
|
|||||||
- [cli](../../devkit/documents/Workspace#cli): Object
|
- [cli](../../devkit/documents/Workspace#cli): Object
|
||||||
- [defaultBase](../../devkit/documents/Workspace#defaultbase): string
|
- [defaultBase](../../devkit/documents/Workspace#defaultbase): string
|
||||||
- [defaultProject](../../devkit/documents/Workspace#defaultproject): string
|
- [defaultProject](../../devkit/documents/Workspace#defaultproject): string
|
||||||
|
- [enableDbCache](../../devkit/documents/Workspace#enabledbcache): boolean
|
||||||
- [extends](../../devkit/documents/Workspace#extends): string
|
- [extends](../../devkit/documents/Workspace#extends): string
|
||||||
- [generators](../../devkit/documents/Workspace#generators): Object
|
- [generators](../../devkit/documents/Workspace#generators): Object
|
||||||
- [implicitDependencies](../../devkit/documents/Workspace#implicitdependencies): ImplicitDependencyEntry<string[] | "\*">
|
- [implicitDependencies](../../devkit/documents/Workspace#implicitdependencies): ImplicitDependencyEntry<string[] | "\*">
|
||||||
@ -118,6 +119,18 @@ will be used. Convenient for small workspaces with one main application.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
### enableDbCache
|
||||||
|
|
||||||
|
• `Optional` **enableDbCache**: `boolean`
|
||||||
|
|
||||||
|
Enable the new experimental db based cache
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[NxJsonConfiguration](../../devkit/documents/NxJsonConfiguration).[enableDbCache](../../devkit/documents/NxJsonConfiguration#enabledbcache)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### extends
|
### extends
|
||||||
|
|
||||||
• `Optional` **extends**: `string`
|
• `Optional` **extends**: `string`
|
||||||
|
|||||||
@ -79,6 +79,9 @@
|
|||||||
"@nx/js": "19.8.0-beta.2",
|
"@nx/js": "19.8.0-beta.2",
|
||||||
"@nx/next": "19.8.0-beta.2",
|
"@nx/next": "19.8.0-beta.2",
|
||||||
"@nx/playwright": "19.8.0-beta.2",
|
"@nx/playwright": "19.8.0-beta.2",
|
||||||
|
"@nx/powerpack-license": "0.0.2-alpha.4",
|
||||||
|
"@nx/powerpack-s3-cache": "0.0.2-alpha.4",
|
||||||
|
"@nx/powerpack-shared-fs-cache": "0.0.2-alpha.4",
|
||||||
"@nx/react": "19.8.0-beta.2",
|
"@nx/react": "19.8.0-beta.2",
|
||||||
"@nx/storybook": "19.8.0-beta.2",
|
"@nx/storybook": "19.8.0-beta.2",
|
||||||
"@nx/vite": "19.8.0-beta.2",
|
"@nx/vite": "19.8.0-beta.2",
|
||||||
|
|||||||
@ -111,7 +111,8 @@
|
|||||||
"@nx/nx-linux-arm64-musl",
|
"@nx/nx-linux-arm64-musl",
|
||||||
"@nx/nx-linux-arm-gnueabihf",
|
"@nx/nx-linux-arm-gnueabihf",
|
||||||
"@nx/nx-win32-arm64-msvc",
|
"@nx/nx-win32-arm64-msvc",
|
||||||
"@nx/nx-freebsd-x64"
|
"@nx/nx-freebsd-x64",
|
||||||
|
"@nx/powerpack-license"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -80,6 +80,7 @@ export const allowedWorkspaceExtensions = [
|
|||||||
'useInferencePlugins',
|
'useInferencePlugins',
|
||||||
'neverConnectToCloud',
|
'neverConnectToCloud',
|
||||||
'sync',
|
'sync',
|
||||||
|
'enableDbCache',
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
if (!patched) {
|
if (!patched) {
|
||||||
|
|||||||
@ -23,7 +23,11 @@ import { getNxRequirePaths } from '../../utils/installation-directory';
|
|||||||
import { NxJsonConfiguration, readNxJson } from '../../config/nx-json';
|
import { NxJsonConfiguration, readNxJson } from '../../config/nx-json';
|
||||||
import { ProjectGraph } from '../../config/project-graph';
|
import { ProjectGraph } from '../../config/project-graph';
|
||||||
import { ProjectGraphError } from '../../project-graph/error-types';
|
import { ProjectGraphError } from '../../project-graph/error-types';
|
||||||
import { getPowerpackLicenseInformation } from '../../utils/powerpack';
|
import {
|
||||||
|
getPowerpackLicenseInformation,
|
||||||
|
NxPowerpackNotInstalledError,
|
||||||
|
} from '../../utils/powerpack';
|
||||||
|
import type { PowerpackLicense } from '@nx/powerpack-license';
|
||||||
|
|
||||||
const nxPackageJson = readJsonFile<typeof import('../../../package.json')>(
|
const nxPackageJson = readJsonFile<typeof import('../../../package.json')>(
|
||||||
join(__dirname, '../../../package.json')
|
join(__dirname, '../../../package.json')
|
||||||
@ -61,6 +65,7 @@ export async function reportHandler() {
|
|||||||
pm,
|
pm,
|
||||||
pmVersion,
|
pmVersion,
|
||||||
powerpackLicense,
|
powerpackLicense,
|
||||||
|
powerpackError,
|
||||||
localPlugins,
|
localPlugins,
|
||||||
powerpackPlugins,
|
powerpackPlugins,
|
||||||
communityPlugins,
|
communityPlugins,
|
||||||
@ -93,6 +98,7 @@ export async function reportHandler() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (powerpackLicense) {
|
if (powerpackLicense) {
|
||||||
|
bodyLines.push('');
|
||||||
bodyLines.push(LINE_SEPARATOR);
|
bodyLines.push(LINE_SEPARATOR);
|
||||||
bodyLines.push(chalk.green('Nx Powerpack'));
|
bodyLines.push(chalk.green('Nx Powerpack'));
|
||||||
|
|
||||||
@ -122,6 +128,13 @@ export async function reportHandler() {
|
|||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
bodyLines.push('');
|
||||||
|
} else if (powerpackError) {
|
||||||
|
bodyLines.push('');
|
||||||
|
bodyLines.push(chalk.red('Nx Powerpack'));
|
||||||
|
bodyLines.push(LINE_SEPARATOR);
|
||||||
|
bodyLines.push(powerpackError.message);
|
||||||
|
bodyLines.push('');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (registeredPlugins.length) {
|
if (registeredPlugins.length) {
|
||||||
@ -183,8 +196,8 @@ export async function reportHandler() {
|
|||||||
export interface ReportData {
|
export interface ReportData {
|
||||||
pm: PackageManager;
|
pm: PackageManager;
|
||||||
pmVersion: string;
|
pmVersion: string;
|
||||||
// TODO(@FrozenPandaz): Provide the right type here.
|
powerpackLicense: PowerpackLicense | null;
|
||||||
powerpackLicense: any | null;
|
powerpackError: Error | null;
|
||||||
powerpackPlugins: PackageJson[];
|
powerpackPlugins: PackageJson[];
|
||||||
localPlugins: string[];
|
localPlugins: string[];
|
||||||
communityPlugins: PackageJson[];
|
communityPlugins: PackageJson[];
|
||||||
@ -234,13 +247,19 @@ export async function getReportData(): Promise<ReportData> {
|
|||||||
const native = isNativeAvailable();
|
const native = isNativeAvailable();
|
||||||
|
|
||||||
let powerpackLicense = null;
|
let powerpackLicense = null;
|
||||||
|
let powerpackError = null;
|
||||||
try {
|
try {
|
||||||
powerpackLicense = await getPowerpackLicenseInformation();
|
powerpackLicense = await getPowerpackLicenseInformation();
|
||||||
} catch {}
|
} catch (e) {
|
||||||
|
if (!(e instanceof NxPowerpackNotInstalledError)) {
|
||||||
|
powerpackError = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pm,
|
pm,
|
||||||
powerpackLicense,
|
powerpackLicense,
|
||||||
|
powerpackError,
|
||||||
powerpackPlugins,
|
powerpackPlugins,
|
||||||
pmVersion,
|
pmVersion,
|
||||||
localPlugins,
|
localPlugins,
|
||||||
|
|||||||
@ -514,6 +514,11 @@ export interface NxJsonConfiguration<T = '*' | string[]> {
|
|||||||
* Configuration for the `nx sync` command.
|
* Configuration for the `nx sync` command.
|
||||||
*/
|
*/
|
||||||
sync?: NxSyncConfiguration;
|
sync?: NxSyncConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable the new experimental db based cache
|
||||||
|
*/
|
||||||
|
enableDbCache?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PluginConfiguration = string | ExpandedPluginConfiguration;
|
export type PluginConfiguration = string | ExpandedPluginConfiguration;
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import { machineId } from 'node-machine-id';
|
|||||||
import { NxCache, CachedResult as NativeCacheResult } from '../native';
|
import { NxCache, CachedResult as NativeCacheResult } from '../native';
|
||||||
import { getDbConnection } from '../utils/db-connection';
|
import { getDbConnection } from '../utils/db-connection';
|
||||||
import { isNxCloudUsed } from '../utils/nx-cloud-utils';
|
import { isNxCloudUsed } from '../utils/nx-cloud-utils';
|
||||||
import { readNxJson } from '../config/nx-json';
|
import { NxJsonConfiguration, readNxJson } from '../config/nx-json';
|
||||||
import { verifyOrUpdateNxCloudClient } from '../nx-cloud/update-manager';
|
import { verifyOrUpdateNxCloudClient } from '../nx-cloud/update-manager';
|
||||||
import { getCloudOptions } from '../nx-cloud/utilities/get-cloud-options';
|
import { getCloudOptions } from '../nx-cloud/utilities/get-cloud-options';
|
||||||
import { isCI } from '../utils/is-ci';
|
import { isCI } from '../utils/is-ci';
|
||||||
@ -28,9 +28,12 @@ export type CachedResult = {
|
|||||||
};
|
};
|
||||||
export type TaskWithCachedResult = { task: Task; cachedResult: CachedResult };
|
export type TaskWithCachedResult = { task: Task; cachedResult: CachedResult };
|
||||||
|
|
||||||
export function getCache(options: DefaultTasksRunnerOptions) {
|
export function getCache(
|
||||||
|
nxJson: NxJsonConfiguration,
|
||||||
|
options: DefaultTasksRunnerOptions
|
||||||
|
) {
|
||||||
return process.env.NX_DISABLE_DB !== 'true' &&
|
return process.env.NX_DISABLE_DB !== 'true' &&
|
||||||
process.env.NX_DB_CACHE === 'true'
|
(nxJson.enableDbCache === true || process.env.NX_DB_CACHE === 'true')
|
||||||
? new DbCache({
|
? new DbCache({
|
||||||
// Remove this in Nx 21
|
// Remove this in Nx 21
|
||||||
nxCloudRemoteCache: isNxCloudUsed(readNxJson())
|
nxCloudRemoteCache: isNxCloudUsed(readNxJson())
|
||||||
@ -155,26 +158,22 @@ export class DbCache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getPowerpackS3Cache(): Promise<RemoteCacheV2 | null> {
|
private getPowerpackS3Cache(): Promise<RemoteCacheV2 | null> {
|
||||||
try {
|
return this.getPowerpackCache('@nx/powerpack-s3-cache');
|
||||||
const { getRemoteCache } = await import(
|
|
||||||
this.resolvePackage('@nx/powerpack-s3-cache')
|
|
||||||
);
|
|
||||||
return getRemoteCache();
|
|
||||||
} catch {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getPowerpackSharedCache(): Promise<RemoteCacheV2 | null> {
|
private getPowerpackSharedCache(): Promise<RemoteCacheV2 | null> {
|
||||||
|
return this.getPowerpackCache('@nx/powerpack-shared-fs-cache');
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getPowerpackCache(pkg: string): Promise<RemoteCacheV2 | null> {
|
||||||
|
let getRemoteCache = null;
|
||||||
try {
|
try {
|
||||||
const { getRemoteCache } = await import(
|
getRemoteCache = (await import(this.resolvePackage(pkg))).getRemoteCache;
|
||||||
this.resolvePackage('@nx/powerpack-shared-fs-cache')
|
|
||||||
);
|
|
||||||
return getRemoteCache();
|
|
||||||
} catch {
|
} catch {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
return getRemoteCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
private resolvePackage(pkg: string) {
|
private resolvePackage(pkg: string) {
|
||||||
|
|||||||
@ -134,6 +134,7 @@ async function runAllTasks(
|
|||||||
context.initiatingProject,
|
context.initiatingProject,
|
||||||
context.projectGraph,
|
context.projectGraph,
|
||||||
context.taskGraph,
|
context.taskGraph,
|
||||||
|
context.nxJson,
|
||||||
options,
|
options,
|
||||||
context.nxArgs?.nxBail,
|
context.nxArgs?.nxBail,
|
||||||
context.daemon,
|
context.daemon,
|
||||||
|
|||||||
@ -31,9 +31,10 @@ import {
|
|||||||
import { workspaceRoot } from '../utils/workspace-root';
|
import { workspaceRoot } from '../utils/workspace-root';
|
||||||
import { output } from '../utils/output';
|
import { output } from '../utils/output';
|
||||||
import { combineOptionsForExecutor } from '../utils/params';
|
import { combineOptionsForExecutor } from '../utils/params';
|
||||||
|
import { NxJsonConfiguration } from '../config/nx-json';
|
||||||
|
|
||||||
export class TaskOrchestrator {
|
export class TaskOrchestrator {
|
||||||
private cache = getCache(this.options);
|
private cache = getCache(this.nxJson, this.options);
|
||||||
private forkedProcessTaskRunner = new ForkedProcessTaskRunner(this.options);
|
private forkedProcessTaskRunner = new ForkedProcessTaskRunner(this.options);
|
||||||
|
|
||||||
private tasksSchedule = new TasksSchedule(
|
private tasksSchedule = new TasksSchedule(
|
||||||
@ -68,6 +69,7 @@ export class TaskOrchestrator {
|
|||||||
private readonly initiatingProject: string | undefined,
|
private readonly initiatingProject: string | undefined,
|
||||||
private readonly projectGraph: ProjectGraph,
|
private readonly projectGraph: ProjectGraph,
|
||||||
private readonly taskGraph: TaskGraph,
|
private readonly taskGraph: TaskGraph,
|
||||||
|
private readonly nxJson: NxJsonConfiguration,
|
||||||
private readonly options: DefaultTasksRunnerOptions,
|
private readonly options: DefaultTasksRunnerOptions,
|
||||||
private readonly bail: boolean,
|
private readonly bail: boolean,
|
||||||
private readonly daemon: DaemonClient,
|
private readonly daemon: DaemonClient,
|
||||||
|
|||||||
@ -10,7 +10,9 @@ export async function printPowerpackLicense() {
|
|||||||
logger.log(
|
logger.log(
|
||||||
`Nx Powerpack Licensed to ${organizationName} for ${seatCount} user${
|
`Nx Powerpack Licensed to ${organizationName} for ${seatCount} user${
|
||||||
seatCount > 1 ? '' : 's'
|
seatCount > 1 ? '' : 's'
|
||||||
} in ${workspaceCount} workspace${workspaceCount > 1 ? '' : 's'}`
|
} in ${
|
||||||
|
workspaceCount === 9999 ? 'an unlimited number of' : workspaceCount
|
||||||
|
} workspace${workspaceCount > 1 ? '' : 's'}`
|
||||||
);
|
);
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
@ -18,14 +20,11 @@ export async function printPowerpackLicense() {
|
|||||||
export async function getPowerpackLicenseInformation() {
|
export async function getPowerpackLicenseInformation() {
|
||||||
try {
|
try {
|
||||||
const { getPowerpackLicenseInformation } = (await import(
|
const { getPowerpackLicenseInformation } = (await import(
|
||||||
// @ts-ignore
|
|
||||||
'@nx/powerpack-license'
|
'@nx/powerpack-license'
|
||||||
// TODO(@FrozenPandaz): Provide the right type here.
|
)) as typeof import('@nx/powerpack-license');
|
||||||
)) as any;
|
|
||||||
// )) as typeof import('@nx/powerpack-license');
|
|
||||||
return getPowerpackLicenseInformation(workspaceRoot);
|
return getPowerpackLicenseInformation(workspaceRoot);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if ('code' in e && e.code === 'ERR_MODULE_NOT_FOUND') {
|
if ('code' in e && e.code === 'MODULE_NOT_FOUND') {
|
||||||
throw new NxPowerpackNotInstalledError(e);
|
throw new NxPowerpackNotInstalledError(e);
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
|
|||||||
1485
pnpm-lock.yaml
generated
1485
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user