Skip to content

Commit

Permalink
feat(workspace-plugin): make split-lib-in-two add compat tag if invok…
Browse files Browse the repository at this point in the history
…ed on compat kind of project
  • Loading branch information
Hotell committed Apr 23, 2024
1 parent e89441c commit e3ba234
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 4 deletions.
53 changes: 50 additions & 3 deletions tools/workspace-plugin/src/generators/react-library/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,26 @@ describe('react-library generator', () => {
"
`);

expect(readJson(tree, `${stories.root}/.eslintrc.json`)).toMatchInlineSnapshot(`
Object {
"extends": Array [
"plugin:@fluentui/eslint-plugin/react",
],
"root": true,
"rules": Object {
"import/no-extraneous-dependencies": Array [
"error",
Object {
"packageDir": Array [
".",
"../../../../",
],
},
],
},
}
`);

// global updates

const expectedPathAlias = {
Expand All @@ -246,9 +266,12 @@ describe('react-library generator', () => {
setup(tree);

await generator(tree, { name: 'react-one', owner: '@org/chosen-one', kind: 'compat' });
const config = readProjectConfiguration(tree, '@proj/react-one-compat');
const library = readProjectConfiguration(tree, '@proj/react-one-compat');
const stories = readProjectConfiguration(tree, '@proj/react-one-compat-stories');

expect(tree.children(config.root)).toMatchInlineSnapshot(`
// library

expect(tree.children(library.root)).toMatchInlineSnapshot(`
Array [
"project.json",
".babelrc.json",
Expand All @@ -268,13 +291,37 @@ describe('react-library generator', () => {
"tsconfig.spec.json",
]
`);
expect(config).toEqual(
expect(library).toEqual(
expect.objectContaining({
root: 'packages/react-components/react-one-compat/library',
sourceRoot: 'packages/react-components/react-one-compat/library/src',
tags: ['platform:web', 'vNext', 'compat'],
}),
);

// stories

expect(tree.children(stories.root)).toMatchInlineSnapshot(`
Array [
"src",
".storybook",
"README.md",
"just.config.ts",
".eslintrc.json",
"tsconfig.json",
"tsconfig.lib.json",
"package.json",
"project.json",
]
`);

expect(stories).toEqual(
expect.objectContaining({
root: 'packages/react-components/react-one-compat/stories',
sourceRoot: 'packages/react-components/react-one-compat/stories/src',
tags: ['vNext', 'platform:web', 'compat', 'type:stories'],
}),
);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,12 @@ function makeStoriesLibrary(tree: Tree, options: Options, logger: typeof output)
root: newProjectRoot,
sourceRoot: newProjectSourceRoot,
name: `${options.projectConfig.name}-stories`,
tags: ['vNext', 'platform:web', 'type:stories'],
tags: [
'vNext',
'platform:web',
options.projectConfig.tags?.includes('compat') ? 'compat' : null,
'type:stories',
].filter(Boolean) as string[],
});

updateJson(tree, '/tsconfig.base.json', (json: TsConfig) => {
Expand Down

0 comments on commit e3ba234

Please sign in to comment.