Skip to content

Commit

Permalink
Merge branch 'next' into norbert/cpc
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelangen committed Jun 10, 2024
2 parents 74cfb9c + 2cbf3a7 commit 9bf5336
Show file tree
Hide file tree
Showing 32 changed files with 435 additions and 564 deletions.
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,8 @@ jobs:
name: Install dependencies
command: yarn install --no-immutable
working_directory: test-storybooks/portable-stories-kitchen-sink/<< parameters.directory >>
environment:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
- run:
name: Run Jest tests
command: yarn jest
Expand Down
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ yarn build --watch react core-server api addon-docs
yarn task --task dev --template <your template> --start-from=publish
```

### Making code changes when working on Angular-specific code

If you are working on Angular-specific code, you will need to append `--prod` to the above mentioned commands to ensure that the Angular compiler is able to pick up the changes appropriately and doesn't fail. This will build all the packages in production mode.

```sh
yarn task --prod
```

```bash
cd code
yarn build --prod --watch angular core-server api addon-docs
```

## Contributing to Storybook

For further advice on how to contribute, please refer to our [NEW contributing guide on the Storybook website](https://storybook.js.org/docs/contribute).
4 changes: 2 additions & 2 deletions code/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@
"@types/compression": "^1.7.0",
"@types/detect-port": "^1.3.0",
"@types/diff": "^5.0.9",
"@types/doctrine": "^0.0.3",
"@types/ejs": "^3.1.1",
"@types/find-cache-dir": "^5.0.0",
"@types/fs-extra": "^11.0.1",
Expand Down Expand Up @@ -317,6 +316,7 @@
"chai": "^4.4.1",
"chalk": "^5.3.0",
"cli-table3": "^0.6.1",
"comment-parser": "^1.4.1",
"compression": "^1.7.4",
"copy-to-clipboard": "^3.3.1",
"cross-spawn": "^7.0.3",
Expand All @@ -326,7 +326,6 @@
"detect-package-manager": "^3.0.2",
"detect-port": "^1.3.0",
"diff": "^5.2.0",
"doctrine": "^3.0.0",
"downshift": "^9.0.4",
"ejs": "^3.1.10",
"esbuild": "^0.18.0 || ^0.19.0 || ^0.20.0",
Expand All @@ -344,6 +343,7 @@
"globby": "^14.0.1",
"handlebars": "^4.7.7",
"js-yaml": "^4.1.0",
"jsdoc-type-pratt-parser": "^4.0.0",
"lazy-universal-dotenv": "^4.0.0",
"lodash": "^4.17.21",
"markdown-to-jsx": "^7.4.5",
Expand Down
124 changes: 62 additions & 62 deletions code/core/src/common/utils/__tests__/normalize-stories.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,172 +42,172 @@ const options = {

describe('normalizeStoriesEntry', () => {
it('direct file path', () => {
const specifier = normalizeStoriesEntry('../path/to/file.stories.mdx', options);
const specifier = normalizeStoriesEntry('../path/to/file.stories.jsx', options);
expect(specifier).toMatchInlineSnapshot(`
{
"titlePrefix": "",
"directory": "./path/to",
"files": "file.stories.mdx",
"files": "file.stories.jsx",
"importPathMatcher": {}
}
`);

expect(specifier.importPathMatcher).toMatchPaths(['./path/to/file.stories.mdx']);
expect(specifier.importPathMatcher).toMatchPaths(['./path/to/file.stories.jsx']);
expect(specifier.importPathMatcher).not.toMatchPaths([
'./path/to/file.stories.js',
'./file.stories.mdx',
'../file.stories.mdx',
'./file.stories.jsx',
'../file.stories.jsx',
]);
});

it('story in config dir', () => {
const specifier = normalizeStoriesEntry('./file.stories.mdx', options);
const specifier = normalizeStoriesEntry('./file.stories.jsx', options);
expect(specifier).toMatchInlineSnapshot(`
{
"titlePrefix": "",
"directory": "./.storybook",
"files": "file.stories.mdx",
"files": "file.stories.jsx",
"importPathMatcher": {}
}
`);

expect(specifier.importPathMatcher).toMatchPaths(['./.storybook/file.stories.mdx']);
expect(specifier.importPathMatcher).toMatchPaths(['./.storybook/file.stories.jsx']);
expect(specifier.importPathMatcher).not.toMatchPaths([
'.storybook/file.stories.mdx',
'./file.stories.mdx',
'../file.stories.mdx',
'.storybook/file.stories.jsx',
'./file.stories.jsx',
'../file.stories.jsx',
]);
});

it('non-recursive files glob', () => {
const specifier = normalizeStoriesEntry('../*/*.stories.mdx', options);
const specifier = normalizeStoriesEntry('../*/*.stories.jsx', options);
expect(specifier).toMatchInlineSnapshot(`
{
"titlePrefix": "",
"directory": ".",
"files": "*/*.stories.mdx",
"files": "*/*.stories.jsx",
"importPathMatcher": {}
}
`);

expect(specifier.importPathMatcher).toMatchPaths([
'./path/file.stories.mdx',
'./second-path/file.stories.mdx',
'./path/file.stories.jsx',
'./second-path/file.stories.jsx',
]);
expect(specifier.importPathMatcher).not.toMatchPaths([
'./path/file.stories.js',
'./path/to/file.stories.mdx',
'./file.stories.mdx',
'../file.stories.mdx',
'./path/to/file.stories.jsx',
'./file.stories.jsx',
'../file.stories.jsx',
]);
});

it('double non-recursive directory/files glob', () => {
const specifier = normalizeStoriesEntry('../*/*/*.stories.mdx', options);
const specifier = normalizeStoriesEntry('../*/*/*.stories.jsx', options);
expect(specifier).toMatchInlineSnapshot(`
{
"titlePrefix": "",
"directory": ".",
"files": "*/*/*.stories.mdx",
"files": "*/*/*.stories.jsx",
"importPathMatcher": {}
}
`);

expect(specifier.importPathMatcher).toMatchPaths([
'./path/to/file.stories.mdx',
'./second-path/to/file.stories.mdx',
'./path/to/file.stories.jsx',
'./second-path/to/file.stories.jsx',
]);
expect(specifier.importPathMatcher).not.toMatchPaths([
'./file.stories.mdx',
'./path/file.stories.mdx',
'./path/to/third/file.stories.mdx',
'./file.stories.jsx',
'./path/file.stories.jsx',
'./path/to/third/file.stories.jsx',
'./path/to/file.stories.js',
'../file.stories.mdx',
'../file.stories.jsx',
]);
});

it('directory/files glob', () => {
const specifier = normalizeStoriesEntry('../**/*.stories.mdx', options);
const specifier = normalizeStoriesEntry('../**/*.stories.jsx', options);
expect(specifier).toMatchInlineSnapshot(`
{
"titlePrefix": "",
"directory": ".",
"files": "**/*.stories.mdx",
"files": "**/*.stories.jsx",
"importPathMatcher": {}
}
`);
expect(specifier.importPathMatcher).toMatchPaths([
'./file.stories.mdx',
'./path/file.stories.mdx',
'./path/to/file.stories.mdx',
'./path/to/third/file.stories.mdx',
'./file.stories.jsx',
'./path/file.stories.jsx',
'./path/to/file.stories.jsx',
'./path/to/third/file.stories.jsx',
]);
expect(specifier.importPathMatcher).not.toMatchPaths([
'./file.stories.js',
'../file.stories.mdx',
'../file.stories.jsx',
]);
});

it('double stars glob', () => {
const specifier = normalizeStoriesEntry('../**/foo/**/*.stories.mdx', options);
const specifier = normalizeStoriesEntry('../**/foo/**/*.stories.jsx', options);
expect(specifier).toMatchInlineSnapshot(`
{
"titlePrefix": "",
"directory": ".",
"files": "**/foo/**/*.stories.mdx",
"files": "**/foo/**/*.stories.jsx",
"importPathMatcher": {}
}
`);

expect(specifier.importPathMatcher).toMatchPaths([
'./foo/file.stories.mdx',
'./path/to/foo/file.stories.mdx',
'./path/to/foo/third/fourth/file.stories.mdx',
'./foo/file.stories.jsx',
'./path/to/foo/file.stories.jsx',
'./path/to/foo/third/fourth/file.stories.jsx',
]);
expect(specifier.importPathMatcher).not.toMatchPaths([
'./file.stories.mdx',
'./file.stories.jsx',
'./file.stories.js',
'../file.stories.mdx',
'../file.stories.jsx',
]);
});

it('intermediate directory glob', () => {
const specifier = normalizeStoriesEntry('../**/foo/*.stories.mdx', options);
const specifier = normalizeStoriesEntry('../**/foo/*.stories.jsx', options);
expect(specifier).toMatchInlineSnapshot(`
{
"titlePrefix": "",
"directory": ".",
"files": "**/foo/*.stories.mdx",
"files": "**/foo/*.stories.jsx",
"importPathMatcher": {}
}
`);

expect(specifier.importPathMatcher).toMatchPaths([
'./path/to/foo/file.stories.mdx',
'./foo/file.stories.mdx',
'./path/to/foo/file.stories.jsx',
'./foo/file.stories.jsx',
]);
expect(specifier.importPathMatcher).not.toMatchPaths([
'./file.stories.mdx',
'./file.stories.jsx',
'./file.stories.js',
'./path/to/foo/third/fourth/file.stories.mdx',
'../file.stories.mdx',
'./path/to/foo/third/fourth/file.stories.jsx',
'../file.stories.jsx',
]);
});

it('directory outside of working dir', () => {
const specifier = normalizeStoriesEntry('../../src/*.stories.mdx', options);
const specifier = normalizeStoriesEntry('../../src/*.stories.jsx', options);
expect(specifier).toMatchInlineSnapshot(`
{
"titlePrefix": "",
"directory": "../src",
"files": "*.stories.mdx",
"files": "*.stories.jsx",
"importPathMatcher": {}
}
`);

expect(specifier.importPathMatcher).toMatchPaths(['../src/file.stories.mdx']);
expect(specifier.importPathMatcher).toMatchPaths(['../src/file.stories.jsx']);
expect(specifier.importPathMatcher).not.toMatchPaths([
'./src/file.stories.mdx',
'./src/file.stories.jsx',
'../src/file.stories.js',
]);
});
Expand Down Expand Up @@ -237,11 +237,11 @@ describe('normalizeStoriesEntry', () => {
});

it('directory/files specifier', () => {
const specifier = normalizeStoriesEntry({ directory: '..', files: '*.stories.mdx' }, options);
const specifier = normalizeStoriesEntry({ directory: '..', files: '*.stories.jsx' }, options);
expect(specifier).toMatchInlineSnapshot(`
{
"titlePrefix": "",
"files": "*.stories.mdx",
"files": "*.stories.jsx",
"directory": ".",
"importPathMatcher": {}
}
Expand All @@ -262,39 +262,39 @@ describe('normalizeStoriesEntry', () => {

it('directory/titlePrefix/files specifier', () => {
const specifier = normalizeStoriesEntry(
{ directory: '..', titlePrefix: 'atoms', files: '*.stories.mdx' },
{ directory: '..', titlePrefix: 'atoms', files: '*.stories.jsx' },
options
);
expect(specifier).toMatchInlineSnapshot(`
{
"titlePrefix": "atoms",
"files": "*.stories.mdx",
"files": "*.stories.jsx",
"directory": ".",
"importPathMatcher": {}
}
`);
});

it('globs with negation', () => {
const specifier = normalizeStoriesEntry('../!(negation)/*.stories.mdx', options);
const specifier = normalizeStoriesEntry('../!(negation)/*.stories.jsx', options);
expect(specifier).toMatchInlineSnapshot(`
{
"titlePrefix": "",
"directory": ".",
"files": "!(negation)/*.stories.mdx",
"files": "!(negation)/*.stories.jsx",
"importPathMatcher": {}
}
`);

expect(specifier.importPathMatcher).toMatchPaths([
'./path/file.stories.mdx',
'./second-path/file.stories.mdx',
'./path/file.stories.jsx',
'./second-path/file.stories.jsx',
]);
expect(specifier.importPathMatcher).not.toMatchPaths([
'./path/file.stories.js',
'./path/to/file.stories.mdx',
'./file.stories.mdx',
'../file.stories.mdx',
'./path/to/file.stories.jsx',
'./file.stories.jsx',
'../file.stories.jsx',
]);
});
});
Expand Down
Loading

0 comments on commit 9bf5336

Please sign in to comment.