Skip to content

Commit

Permalink
chore(workspace-plguin): update cypress-component configuration to ha…
Browse files Browse the repository at this point in the history
…ve typeRoots
  • Loading branch information
mainframev committed Nov 1, 2024
1 parent a7cd52a commit aa9540f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions":{
"isolatedModules":false,
"types":["node", "cypress", "cypress-real-events"],
"typeRoots":["<%= options.rootOffset %>node_modules", "<%= options.rootOffset %>node_modules/@types"],
"lib":["ES2019", "dom"]
},
"include":["**/*.cy.ts", "**/*.cy.tsx"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ describe(`cypress-component-configuration`, () => {
"ES2019",
"dom",
],
"typeRoots": Array [
"../node_modules",
"../node_modules/@types",
],
"types": Array [
"node",
"cypress",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Tree, formatFiles, names, joinPathFragments } from '@nx/devkit';
import { Tree, formatFiles, names, joinPathFragments, offsetFromRoot } from '@nx/devkit';

import { getProjectConfig, printUserLogs, UserLog } from '../../utils';

Expand All @@ -22,7 +22,7 @@ export default async function (tree: Tree, schema: CypressComponentConfiguration
return;
}

addFiles(tree, normalizedOptions);
addFiles(tree, { ...normalizedOptions, rootOffset: offsetFromRoot(tree.root) });

await formatFiles(tree);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import { PackageJson, TsConfig } from '../../../types';
import { getProjectConfig } from '../../../utils';
import { uniqueArray } from './utils';

type Options = ReturnType<typeof getProjectConfig>;
type Options = ReturnType<typeof getProjectConfig> & { rootOffset: string };

export function addFiles(tree: Tree, options: Options) {
generateFiles(tree, joinPathFragments(__dirname, '../files'), options.projectConfig.root, { tmpl: '' });
generateFiles(tree, joinPathFragments(__dirname, '../files'), options.projectConfig.root, {
tmpl: '',
options,
});

updateJson(tree, options.paths.tsconfig.main, (json: TsConfig) => {
json.references?.push({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ describe('migrate-converged-pkg generator', () => {
isolatedModules: false,
lib: ['ES2019', 'dom'],
types: ['node', 'cypress', 'cypress-real-events'],
typeRoots: ['../node_modules', '../node_modules/@types'],
},
include: ['**/*.cy.ts', '**/*.cy.tsx'],
});
Expand Down

0 comments on commit aa9540f

Please sign in to comment.