Skip to content

Commit

Permalink
feat(core): add support for community remote caching
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan-Hall committed Nov 24, 2024
1 parent 93daca5 commit d660dbd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
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',
'useLegacyCache',
'remoteCache',
] 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 @@ -520,6 +520,11 @@ export interface NxJsonConfiguration<T = '*' | string[]> {
* Use the legacy file system cache instead of the db cache
*/
useLegacyCache?: boolean;

/**
* community support for custom cache
*/
remoteCache?: 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 @@ -156,6 +156,7 @@ export class DbCache {
}
} else {
return (
(await this.getCustomCache(nxJson.remoteCache)) ??
(await this.getPowerpackS3Cache()) ??
(await this.getPowerpackSharedCache()) ??
null
Expand All @@ -164,14 +165,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 d660dbd

Please sign in to comment.