diff --git a/docs/generated/devkit/NxJsonConfiguration.md b/docs/generated/devkit/NxJsonConfiguration.md index 93d50df8a539fe..d1f6f4f1981154 100644 --- a/docs/generated/devkit/NxJsonConfiguration.md +++ b/docs/generated/devkit/NxJsonConfiguration.md @@ -21,6 +21,7 @@ Nx.json configuration - [affected](../../devkit/documents/NxJsonConfiguration#affected): NxAffectedConfig - [cacheDirectory](../../devkit/documents/NxJsonConfiguration#cachedirectory): string - [cli](../../devkit/documents/NxJsonConfiguration#cli): Object +- [communityCache](../../devkit/documents/NxJsonConfiguration#communitycache): string - [defaultBase](../../devkit/documents/NxJsonConfiguration#defaultbase): string - [defaultProject](../../devkit/documents/NxJsonConfiguration#defaultproject): string - [enableDbCache](../../devkit/documents/NxJsonConfiguration#enabledbcache): boolean @@ -82,6 +83,14 @@ Default generator collection. It is used when no collection is provided. --- +### communityCache + +• `Optional` **communityCache**: `string` + +community support for custom cache + +--- + ### defaultBase • `Optional` **defaultBase**: `string` diff --git a/docs/generated/devkit/Workspace.md b/docs/generated/devkit/Workspace.md index 1778f5ba0af7d2..1455a253e4b35f 100644 --- a/docs/generated/devkit/Workspace.md +++ b/docs/generated/devkit/Workspace.md @@ -19,6 +19,7 @@ use ProjectsConfigurations or NxJsonConfiguration - [affected](../../devkit/documents/Workspace#affected): NxAffectedConfig - [cacheDirectory](../../devkit/documents/Workspace#cachedirectory): string - [cli](../../devkit/documents/Workspace#cli): Object +- [communityCache](../../devkit/documents/Workspace#communitycache): string - [defaultBase](../../devkit/documents/Workspace#defaultbase): string - [defaultProject](../../devkit/documents/Workspace#defaultproject): string - [enableDbCache](../../devkit/documents/Workspace#enabledbcache): boolean @@ -94,6 +95,18 @@ Default generator collection. It is used when no collection is provided. --- +### communityCache + +• `Optional` **communityCache**: `string` + +community support for custom cache + +#### Inherited from + +[NxJsonConfiguration](../../devkit/documents/NxJsonConfiguration).[communityCache](../../devkit/documents/NxJsonConfiguration#communitycache) + +--- + ### defaultBase • `Optional` **defaultBase**: `string` diff --git a/packages/nx/src/adapter/compat.ts b/packages/nx/src/adapter/compat.ts index f24befda7e90a2..929ee4a464c7e5 100644 --- a/packages/nx/src/adapter/compat.ts +++ b/packages/nx/src/adapter/compat.ts @@ -81,6 +81,7 @@ export const allowedWorkspaceExtensions = [ 'neverConnectToCloud', 'sync', 'enableDbCache', + 'communityCache', ] as const; if (!patched) { diff --git a/packages/nx/src/config/nx-json.ts b/packages/nx/src/config/nx-json.ts index 4848d417d817d9..0d85a1e20debc2 100644 --- a/packages/nx/src/config/nx-json.ts +++ b/packages/nx/src/config/nx-json.ts @@ -519,6 +519,11 @@ export interface NxJsonConfiguration { * Enable the new experimental db based cache */ enableDbCache?: boolean; + + /** + * community support for custom cache + */ + communityCache?: string; } export type PluginConfiguration = string | ExpandedPluginConfiguration; diff --git a/packages/nx/src/tasks-runner/cache.ts b/packages/nx/src/tasks-runner/cache.ts index 10aa833d9bf868..72fdd87fa06374 100644 --- a/packages/nx/src/tasks-runner/cache.ts +++ b/packages/nx/src/tasks-runner/cache.ts @@ -152,6 +152,7 @@ export class DbCache { } } else { return ( + (await this.getCustomCache(nxJson.communityCache)) ?? (await this.getPowerpackS3Cache()) ?? (await this.getPowerpackSharedCache()) ?? null @@ -160,14 +161,14 @@ export class DbCache { } private getPowerpackS3Cache(): Promise { - return this.getPowerpackCache('@nx/powerpack-s3-cache'); + return this.getCustomCache('@nx/powerpack-s3-cache'); } private getPowerpackSharedCache(): Promise { - return this.getPowerpackCache('@nx/powerpack-shared-fs-cache'); + return this.getCustomCache('@nx/powerpack-shared-fs-cache'); } - private async getPowerpackCache(pkg: string): Promise { + private async getCustomCache(pkg: string): Promise { let getRemoteCache = null; try { getRemoteCache = (await import(this.resolvePackage(pkg))).getRemoteCache;