Skip to content

Commit

Permalink
fix(storybook): do not set cacheableOperations if not previously set (n…
Browse files Browse the repository at this point in the history
  • Loading branch information
leosvelperez committed Mar 27, 2024
1 parent 3532161 commit 590c7ae
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -488,11 +488,14 @@ export function addStorybookToNamedInputs(tree: Tree) {
}
}

export function addStorybookToTargetDefaults(tree: Tree) {
export function addStorybookToTargetDefaults(tree: Tree, setCache = true) {
const nxJson = readNxJson(tree);

nxJson.targetDefaults ??= {};
nxJson.targetDefaults['build-storybook'] ??= {};
if (setCache) {
nxJson.targetDefaults['build-storybook'].cache ??= true;
}
nxJson.targetDefaults['build-storybook'].inputs ??= [
'default',
nxJson.namedInputs && 'production' in nxJson.namedInputs
Expand Down Expand Up @@ -630,25 +633,20 @@ export function getTsConfigPath(
}

export function addBuildStorybookToCacheableOperations(tree: Tree) {
updateJson(tree, 'nx.json', (json) => ({
...json,
tasksRunnerOptions: {
...(json.tasksRunnerOptions ?? {}),
default: {
...(json.tasksRunnerOptions?.default ?? {}),
options: {
...(json.tasksRunnerOptions?.default?.options ?? {}),
cacheableOperations: Array.from(
new Set([
...(json.tasksRunnerOptions?.default?.options
?.cacheableOperations ?? []),
'build-storybook',
])
),
},
},
},
}));
const nxJson = readNxJson(tree);

if (
nxJson.tasksRunnerOptions?.default?.options?.cacheableOperations &&
!nxJson.tasksRunnerOptions.default.options.cacheableOperations.includes(
'build-storybook'
)
) {
nxJson.tasksRunnerOptions.default.options.cacheableOperations.push(
'build-storybook'
);

updateNxJson(tree, nxJson);
}
}

export function projectIsRootProjectInStandaloneWorkspace(projectRoot: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ export default async function (tree: Tree) {
);

addStorybookToNamedInputs(tree);
addStorybookToTargetDefaults(tree);
addStorybookToTargetDefaults(tree, false);
await formatFiles(tree);
}

0 comments on commit 590c7ae

Please sign in to comment.