react-cosmos 6.0.0-alpha.6 → 6.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -50,6 +50,12 @@
50
50
  "type": "string",
51
51
  "minLength": 1
52
52
  },
53
+ "ignore": {
54
+ "description": "Patterns for ignoring fixture and decorator files (eg. [\"**/dist/**\"]]).",
55
+ "type": "array",
56
+ "items": { "type": "string", "minLength": 1 },
57
+ "uniqueItems": true
58
+ },
53
59
  "watchDirs": {
54
60
  "description": "Directories where the Cosmos server watches for fixture files changes while running. [default: [\".\"]]",
55
61
  "type": "array",
@@ -14,6 +14,7 @@ export function createCosmosConfig(rootDir, cosmosConfigInput = {}) {
14
14
  hostname: getHostname(cosmosConfigInput),
15
15
  https: getHttps(cosmosConfigInput),
16
16
  httpsOptions: getHttpsOptions(cosmosConfigInput, rootDir),
17
+ ignore: getIgnore(cosmosConfigInput),
17
18
  port: getPort(cosmosConfigInput),
18
19
  plugins: getPlugins(cosmosConfigInput, rootDir),
19
20
  publicUrl: getPublicUrl(cosmosConfigInput),
@@ -46,6 +47,9 @@ function getHttpsOptions(cosmosConfigInput, rootDir) {
46
47
  }
47
48
  return null;
48
49
  }
50
+ function getIgnore({ ignore = [] }) {
51
+ return ['**/node_modules/**', ...ignore];
52
+ }
49
53
  function getPublicUrl({ publicUrl = '/' }) {
50
54
  return publicUrl;
51
55
  }
@@ -12,6 +12,7 @@ export type CosmosConfig = {
12
12
  hostname: null | string;
13
13
  https: boolean;
14
14
  httpsOptions: null | HttpsOptions;
15
+ ignore: string[];
15
16
  port: number;
16
17
  plugins: string[];
17
18
  publicUrl: string;
@@ -2,10 +2,11 @@ type FindUserModulePathsArgs = {
2
2
  rootDir: string;
3
3
  fixturesDir: string;
4
4
  fixtureFileSuffix: string;
5
+ ignore: string[];
5
6
  };
6
7
  type UserModulePaths = {
7
8
  fixturePaths: string[];
8
9
  decoratorPaths: string[];
9
10
  };
10
- export declare function findUserModulePaths({ rootDir, fixturesDir, fixtureFileSuffix, }: FindUserModulePathsArgs): UserModulePaths;
11
+ export declare function findUserModulePaths({ rootDir, fixturesDir, fixtureFileSuffix, ignore, }: FindUserModulePathsArgs): UserModulePaths;
11
12
  export {};
@@ -1,11 +1,11 @@
1
1
  import glob from 'glob';
2
2
  import micromatch from 'micromatch';
3
- import { getDecoratorPatterns, getFixturePatterns, getIgnorePatterns, } from './shared.js';
4
- export function findUserModulePaths({ rootDir, fixturesDir, fixtureFileSuffix, }) {
3
+ import { getDecoratorPatterns, getFixturePatterns } from './shared.js';
4
+ export function findUserModulePaths({ rootDir, fixturesDir, fixtureFileSuffix, ignore, }) {
5
5
  const paths = glob.sync('**/*', {
6
6
  cwd: rootDir,
7
7
  absolute: true,
8
- ignore: getIgnorePatterns(),
8
+ ignore,
9
9
  });
10
10
  const fixturePatterns = getFixturePatterns(fixturesDir, fixtureFileSuffix);
11
11
  const fixturePaths = getMatchingPaths(paths, fixturePatterns);
@@ -1,16 +1,16 @@
1
1
  import { watch } from 'chokidar';
2
2
  import { debounce } from 'lodash-es';
3
- import { getDecoratorPatterns, getFixturePatterns, getIgnorePatterns, } from './shared.js';
3
+ import { getDecoratorPatterns, getFixturePatterns } from './shared.js';
4
4
  const DEBOUNCE_INTERVAL = 50;
5
5
  export async function startFixtureWatcher(cosmosConfig, event, callback) {
6
- const { fixturesDir, fixtureFileSuffix } = cosmosConfig;
6
+ const { fixturesDir, fixtureFileSuffix, ignore } = cosmosConfig;
7
7
  const FILE_PATTERNS = [
8
8
  ...getFixturePatterns(fixturesDir, fixtureFileSuffix),
9
9
  ...getDecoratorPatterns(),
10
10
  ];
11
11
  return new Promise(resolve => {
12
12
  const watcher = watch(FILE_PATTERNS, {
13
- ignored: getIgnorePatterns(),
13
+ ignored: ignore,
14
14
  ignoreInitial: true,
15
15
  cwd: cosmosConfig.rootDir,
16
16
  })
@@ -1,11 +1,12 @@
1
1
  import { findUserModulePaths } from './findUserModulePaths.js';
2
2
  import { userDepsTemplate } from './userDepsTemplate.js';
3
3
  export function generateUserDepsModule({ cosmosConfig, rendererConfig, relativeToDir, }) {
4
- const { rootDir, fixturesDir, fixtureFileSuffix, globalImports } = cosmosConfig;
4
+ const { rootDir, fixturesDir, fixtureFileSuffix, globalImports, ignore } = cosmosConfig;
5
5
  const { fixturePaths, decoratorPaths } = findUserModulePaths({
6
6
  rootDir,
7
7
  fixturesDir,
8
8
  fixtureFileSuffix,
9
+ ignore,
9
10
  });
10
11
  return userDepsTemplate({
11
12
  globalImports,
@@ -4,5 +4,5 @@ type UserModules = {
4
4
  fixtures: ReactFixtureExports;
5
5
  decorators: ReactDecorators;
6
6
  };
7
- export declare function getUserModules({ rootDir, fixturesDir, fixtureFileSuffix, }: CosmosConfig): UserModules;
7
+ export declare function getUserModules({ rootDir, fixturesDir, fixtureFileSuffix, ignore, }: CosmosConfig): UserModules;
8
8
  export {};
@@ -1,11 +1,12 @@
1
1
  import path from 'path';
2
2
  import { slash } from '../utils/slash.js';
3
3
  import { findUserModulePaths } from './findUserModulePaths.js';
4
- export function getUserModules({ rootDir, fixturesDir, fixtureFileSuffix, }) {
4
+ export function getUserModules({ rootDir, fixturesDir, fixtureFileSuffix, ignore, }) {
5
5
  const { fixturePaths, decoratorPaths } = findUserModulePaths({
6
6
  rootDir,
7
7
  fixturesDir,
8
8
  fixtureFileSuffix,
9
+ ignore,
9
10
  });
10
11
  return {
11
12
  fixtures: getDefaultExports(fixturePaths, rootDir),
@@ -3,4 +3,3 @@ export type Json = string | number | boolean | null | {
3
3
  } | Json[];
4
4
  export declare function getFixturePatterns(fixturesDir: string, fixtureFileSuffix: string): string[];
5
5
  export declare function getDecoratorPatterns(): string[];
6
- export declare function getIgnorePatterns(): string[];
@@ -5,7 +5,6 @@ const FIXTURE_PATTERNS = [
5
5
  '**/*.<fixtureFileSuffix>.{js,jsx,ts,tsx}',
6
6
  ];
7
7
  const DECORATOR_PATTERNS = ['**/cosmos.decorator.{js,jsx,ts,tsx}'];
8
- const IGNORE_PATTERNS = ['**/node_modules/**'];
9
8
  export function getFixturePatterns(fixturesDir, fixtureFileSuffix) {
10
9
  return FIXTURE_PATTERNS.map(pattern => replaceKeys(pattern, {
11
10
  '<fixturesDir>': fixturesDir,
@@ -15,6 +14,3 @@ export function getFixturePatterns(fixturesDir, fixtureFileSuffix) {
15
14
  export function getDecoratorPatterns() {
16
15
  return DECORATOR_PATTERNS;
17
16
  }
18
- export function getIgnorePatterns() {
19
- return IGNORE_PATTERNS;
20
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-cosmos",
3
- "version": "6.0.0-alpha.6",
3
+ "version": "6.0.0-alpha.7",
4
4
  "description": "Sandbox for developing and testing UI components in isolation",
5
5
  "repository": "https://github.com/react-cosmos/react-cosmos/tree/main/packages/react-cosmos",
6
6
  "license": "MIT",
@@ -18,7 +18,7 @@
18
18
  "pem": "^1.14.6",
19
19
  "pkg-up": "^4.0.0",
20
20
  "react-cosmos-core": "^6.0.0-alpha.6",
21
- "react-cosmos-ui": "^6.0.0-alpha.6",
21
+ "react-cosmos-ui": "^6.0.0-alpha.7",
22
22
  "ws": "^8.12.1",
23
23
  "yargs": "^17.7.1"
24
24
  },
@@ -27,5 +27,5 @@
27
27
  "cosmos-export": "./bin/cosmos-export.js",
28
28
  "cosmos-native": "./bin/cosmos-native.js"
29
29
  },
30
- "gitHead": "e901d3a46ee43a24b6279395e6718c9521088b60"
30
+ "gitHead": "f4702e164485966e21a8b3ec4cac8377914ee3dc"
31
31
  }