Skip to content

Commit

Permalink
feat(core): add support for community cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan-Hall committed Sep 27, 2024
1 parent f221a41 commit 6fcb923
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
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

0 comments on commit 6fcb923

Please sign in to comment.