Skip to content

Commit

Permalink
feat(compodoc): add compodoc to cachable operations
Browse files Browse the repository at this point in the history
resolves #6
  • Loading branch information
twittwer committed May 1, 2020
1 parent 7c7db14 commit 81ce308
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
24 changes: 24 additions & 0 deletions libs/compodoc/src/schematics/ng-add/ng-add-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,27 @@ export function moveToDevDependencies(packageName: string): Rule {
return packageJson;
});
}

export function addCacheableOperation(operation: string): Rule {
return updateJsonInTree('nx.json', nxJson => {
if (
!nxJson.tasksRunnerOptions?.default?.runner ||
!Array.isArray(
nxJson.tasksRunnerOptions?.default?.options?.cacheableOperations,
)
) {
return nxJson;
}

const isAlreadyCached = nxJson.tasksRunnerOptions.default.options.cacheableOperations.includes(
operation,
);
if (!isAlreadyCached) {
nxJson.tasksRunnerOptions.default.options.cacheableOperations.push(
operation,
);
}

return nxJson;
});
}
8 changes: 6 additions & 2 deletions libs/compodoc/src/schematics/ng-add/schematic.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { chain, Rule } from '@angular-devkit/schematics';
import { installDependencies, moveToDevDependencies } from './ng-add-utils';
import {
addCacheableOperation,
installDependencies,
moveToDevDependencies,
} from './ng-add-utils';

// TODO: Evaluate the best option for plugin dependency on compodoc
// - defined a wildcard version (`*`)
Expand All @@ -15,6 +19,6 @@ export default function(): Rule {
},
}),
moveToDevDependencies('@twittwer/compodoc'), // is eventually added to the dependencies by the ng-add command
// TODO: add `compodoc` to `cacheableOperations` in `nx.json`
addCacheableOperation('compodoc'),
]);
}

0 comments on commit 81ce308

Please sign in to comment.