Skip to content

Commit

Permalink
(chore) Move @fluentui/react-components to react-components subfolder (
Browse files Browse the repository at this point in the history
  • Loading branch information
TristanWatanabe authored Apr 26, 2022
1 parent 0469953 commit 00d9679
Show file tree
Hide file tree
Showing 84 changed files with 109 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .codesandbox/ci.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"buildCommand": "build:codesandbox",
"packages": ["packages/react", "packages/react-components"],
"packages": ["packages/react", "packages/react-components/react-components"],
"sandboxes": ["x5u3t", "spnyu"],
"node": "12"
}
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ packages/react-button @microsoft/cxe-red @khmakoto
packages/react-card @microsoft/cxe-prg
packages/react-checkbox @microsoft/cxe-red @khmakoto
packages/react-combobox @microsoft/cxe-coastal @smhigley
packages/react-components @microsoft/fluentui-react
packages/react-components/react-components @microsoft/fluentui-react
packages/react-dialog @microsoft/cxe-prg
packages/react-divider @microsoft/cxe-coastal
packages/react-focus @microsoft/cxe-red @khmakoto
Expand Down
17 changes: 15 additions & 2 deletions apps/public-docsite-v9/.storybook/main.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,27 @@ const path = require('path');
function getVnextStories() {
/** @type {Record<string,unknown>} */
const packageJson = JSON.parse(
fs.readFileSync(path.resolve(__dirname, '../../../packages/react-components/package.json'), 'utf-8'),
fs.readFileSync(
path.resolve(__dirname, '../../../packages/react-components/react-components/package.json'),
'utf-8',
),
);

const dependencies = /** @type {Record<string,string>} */ (packageJson.dependencies);

return Object.keys({ ...dependencies, '@fluentui/react-components': '' })
.filter(pkgName => pkgName.startsWith('@fluentui/'))
.map(pkgName => '../../../packages/' + pkgName.replace('@fluentui/', '') + '/src/**/*.stories.@(ts|tsx|mdx)');
.map(pkgName => {
const name = pkgName.replace('@fluentui/', '');
const storiesGlob = '/src/**/*.stories.@(ts|tsx|mdx)';

//TODO: simplify once all v9 packages have been moved to the new react-components subfolder.
if (fs.existsSync(`../../packages/${name}/package.json`)) {
return `../../../packages/${name}${storiesGlob}`;
} else {
return `../../../packages/react-components/${name}${storiesGlob}`;
}
});
}

exports.getVnextStories = getVnextStories;
4 changes: 2 additions & 2 deletions apps/public-docsite-v9/.storybook/main.utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ describe(`main utils`, () => {
const actual = utils.getVnextStories();

const expected = [
expect.stringContaining('../../react-'),
expect.stringContaining('../../../packages/react-'),
expect.stringContaining('/src/**/*.stories.@(ts|tsx|mdx)'),
];

expect(actual).toEqual(expect.arrayContaining(expected));

const first = actual[0];
expect(first.startsWith('../../react-')).toBeTruthy();
expect(first.startsWith('../../../packages/react-')).toBeTruthy();
expect(first.endsWith('/src/**/*.stories.@(ts|tsx|mdx)')).toBeTruthy();
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "react-components: Move to new common folder",
"packageName": "@fluentui/react-components",
"email": "tristan.watanabe@gmail.com",
"dependentChangeType": "none"
}
10 changes: 9 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"packages": ["apps/*", "packages/*", "scripts", "packages/fluentui/*", "tools", "typings"],
"packages": [
"apps/*",
"packages/*",
"packages/react-components/*",
"scripts",
"packages/fluentui/*",
"tools",
"typings"
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "0.0.0"
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@
"apps/*",
"packages/*",
"packages/fluentui/*",
"packages/react-components/*",
"scripts",
"tools",
"typings"
Expand Down Expand Up @@ -300,6 +301,7 @@
"package.json",
"apps/*/package.json",
"packages/!(web-components)/package.json",
"packages/react-components/*/package.json",
"packages/fluentui/*/package.json",
"scripts/package.json"
],
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,21 @@
{
"files": "**/index.ts",
"rules": {
"@rnx-kit/no-export-all": ["error", { "expand": "all" }],
"@rnx-kit/no-export-all": [
"error",
{
"expand": "all"
}
],
"@fluentui/ban-imports": [
"error",
{
"pathRegex": ".*",
"names": [{ "regex": "Commons$" }],
"names": [
{
"regex": "Commons$"
}
],
"message": "Commons types should not be exported from @fluentui/react-components"
}
]
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const rootMain = require('../../../.storybook/main');
const rootMain = require('../../../../.storybook/main');
const utils = require('./main.utils');

module.exports = /** @type {Omit<import('../../../.storybook/main'), 'typescript'|'babel'>} */ ({
module.exports = /** @type {Omit<import('../../../../.storybook/main'), 'typescript'|'babel'>} */ ({
...rootMain,
stories: [
...rootMain.stories,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,18 @@ function getVnextStories() {

return Object.keys(dependencies)
.filter(pkgName => pkgName.startsWith('@fluentui/'))
.map(pkgName => '../../' + pkgName.replace('@fluentui/', '') + '/src/**/*.stories.@(ts|tsx|mdx)');
.map(pkgName => {
const name = pkgName.replace('@fluentui/', '');
const storiesGlob = '/src/**/*.stories.@(ts|tsx|mdx)';
const pkgUnmigratedPath = `../../${name}`;
const pkgMigratedPath = `../${name}`;
//TODO: simplify once all v9 packages have been moved to the new react-components subfolder.
if (fs.existsSync(pkgUnmigratedPath + '/package.json')) {
return `../${pkgUnmigratedPath}${storiesGlob}`;
} else {
return `../${pkgMigratedPath}${storiesGlob}`;
}
});
}

exports.getVnextStories = getVnextStories;
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ describe(`main utils`, () => {
describe(`#getVnextStories`, () => {
it(`should generate storybook stories string array of glob based on package.json#dependencies field`, () => {
const actual = utils.getVnextStories();

const expected = [
expect.stringContaining('../../react-'),
expect.stringContaining('../../../react-'),
expect.stringContaining('/src/**/*.stories.@(ts|tsx|mdx)'),
];

expect(actual).toEqual(expect.arrayContaining(expected));

const first = actual[0];
expect(first.startsWith('../../react-')).toBeTruthy();
expect(first.startsWith('../../../react-')).toBeTruthy();
expect(first.endsWith('/src/**/*.stories.@(ts|tsx|mdx)')).toBeTruthy();
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as rootPreview from '../../../.storybook/preview';
import * as rootPreview from '../../../../.storybook/preview';

/** @type {typeof rootPreview.parameters} */
export const parameters = {
Expand Down
File renamed without changes.
Loading

0 comments on commit 00d9679

Please sign in to comment.