Skip to content
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

feat(core): add support for community remote cache. #28170

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/generated/devkit/NxJsonConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`
Expand Down
13 changes: 13 additions & 0 deletions docs/generated/devkit/Workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`
Expand Down
1 change: 1 addition & 0 deletions packages/nx/src/adapter/compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const allowedWorkspaceExtensions = [
'neverConnectToCloud',
'sync',
'enableDbCache',
'communityCache',
] as const;

if (!patched) {
Expand Down
5 changes: 5 additions & 0 deletions packages/nx/src/config/nx-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@ export interface NxJsonConfiguration<T = '*' | string[]> {
* Enable the new experimental db based cache
*/
enableDbCache?: boolean;

/**
* community support for custom cache
*/
communityCache?: string;
}

export type PluginConfiguration = string | ExpandedPluginConfiguration;
Expand Down
7 changes: 4 additions & 3 deletions packages/nx/src/tasks-runner/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export class DbCache {
}
} else {
return (
(await this.getCustomCache(nxJson.communityCache)) ??
(await this.getPowerpackS3Cache()) ??
(await this.getPowerpackSharedCache()) ??
null
Expand All @@ -160,14 +161,14 @@ export class DbCache {
}

private getPowerpackS3Cache(): Promise<RemoteCacheV2 | null> {
return this.getPowerpackCache('@nx/powerpack-s3-cache');
return this.getCustomCache('@nx/powerpack-s3-cache');
}

private getPowerpackSharedCache(): Promise<RemoteCacheV2 | null> {
return this.getPowerpackCache('@nx/powerpack-shared-fs-cache');
return this.getCustomCache('@nx/powerpack-shared-fs-cache');
}

private async getPowerpackCache(pkg: string): Promise<RemoteCacheV2 | null> {
private async getCustomCache(pkg: string): Promise<RemoteCacheV2 | null> {
let getRemoteCache = null;
try {
getRemoteCache = (await import(this.resolvePackage(pkg))).getRemoteCache;
Expand Down