Skip to content

Commit

Permalink
Go public
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Sep 26, 2023
1 parent 8e83198 commit 51adaa3
Show file tree
Hide file tree
Showing 18 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/writing-a-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ usually they depend on `devDependencies`. However, some plugins target productio
Here's an example from the latter:

```ts
export const PRODUCTION_ENTRY_FILE_PATTERNS = [
/** @public */
const PRODUCTION_ENTRY_FILE_PATTERNS = [
'app/root.tsx',
'app/entry.{client,server}.{js,jsx,ts,tsx}',
'app/routes/**/*.{js,ts,tsx}',
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/_template/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ export const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDepen

export const CONFIG_FILE_PATTERNS = [];

/** @public */
export const ENTRY_FILE_PATTERNS = [];

/** @public */
export const PRODUCTION_ENTRY_FILE_PATTERNS = [];

export const PROJECT_FILE_PATTERNS = [];
Expand Down
1 change: 1 addition & 0 deletions src/plugins/ava/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDepen

export const CONFIG_FILE_PATTERNS = ['ava.config.{js,cjs,mjs}', 'package.json'];

/** @public */
export const ENTRY_FILE_PATTERNS = [
`test.{js,cjs,mjs}`,
`{src,source}/test.{js,cjs,mjs}`,
Expand Down
1 change: 1 addition & 0 deletions src/plugins/cypress/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const ENABLERS = ['cypress'];

export const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDependency(dependencies, ENABLERS);

/** @public */
export const ENTRY_FILE_PATTERNS = [
'cypress.config.{js,ts,mjs,cjs}',
'cypress/support/e2e.{js,jsx,ts,tsx}',
Expand Down
1 change: 1 addition & 0 deletions src/plugins/eslint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const CONFIG_FILE_PATTERNS = ['.eslintrc', '.eslintrc.{js,json,cjs}', '.e

// New: https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new
// We can handle eslint.config.js just like other source code (as dependencies are imported)
/** @public */
export const ENTRY_FILE_PATTERNS = ['eslint.config.js'];

// Note: shareable configs should use `peerDependencies` for plugins
Expand Down
1 change: 1 addition & 0 deletions src/plugins/gatsby/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDepen

export const CONFIG_FILE_PATTERNS = ['gatsby-{config,node}.{js,jsx,ts,tsx}'];

/** @public */
export const PRODUCTION_ENTRY_FILE_PATTERNS = [
'gatsby-{browser,ssr}.{js,jsx,ts,tsx}',
'src/api/**/*.{js,ts}',
Expand Down
1 change: 1 addition & 0 deletions src/plugins/jest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const isEnabled: IsPluginEnabledCallback = ({ dependencies, manifest }) =

export const CONFIG_FILE_PATTERNS = ['jest.config.{js,ts,mjs,cjs,json}', 'package.json'];

/** @public */
export const ENTRY_FILE_PATTERNS = ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'];

const resolveExtensibleConfig = async (configFilePath: string) => {
Expand Down
1 change: 1 addition & 0 deletions src/plugins/mocha/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDepen

export const CONFIG_FILE_PATTERNS = ['.mocharc.{js,cjs,json,jsonc,yml,yaml}', 'package.json'];

/** @public */
export const ENTRY_FILE_PATTERNS = ['**/test/*.{js,cjs,mjs}'];

const findMochaDependencies: GenericPluginCallback = async (configFilePath, { manifest, isProduction }) => {
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/next/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const ENABLERS = ['next'];

export const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDependency(dependencies, ENABLERS);

/** @public */
export const ENTRY_FILE_PATTERNS = ['next.config.{js,ts,cjs,mjs}'];

const productionEntryFilePatternsWithoutSrc = [
Expand All @@ -24,6 +25,7 @@ const productionEntryFilePatternsWithoutSrc = [
'pages/**/*.{js,jsx,ts,tsx}',
];

/** @public */
export const PRODUCTION_ENTRY_FILE_PATTERNS = [
...productionEntryFilePatternsWithoutSrc,
...productionEntryFilePatternsWithoutSrc.map(pattern => `src/${pattern}`),
Expand Down
1 change: 1 addition & 0 deletions src/plugins/node-test-runner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const isEnabled: IsPluginEnabledCallback = ({ manifest }) => {
return Boolean(manifest.scripts?.test && /node.+--test/.test(manifest.scripts?.test));
};

/** @public */
export const ENTRY_FILE_PATTERNS = [
'**/test.{js,cjs,mjs}',
'**/test-*.{js,cjs,mjs}',
Expand Down
1 change: 1 addition & 0 deletions src/plugins/playwright-ct/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDepen

export const CONFIG_FILE_PATTERNS = ['playwright-ct.config.{js,ts}', 'playwright/index.{js,ts,jsx,tsx}'];

/** @public */
export const ENTRY_FILE_PATTERNS = ['**/*.@(spec|test).?(c|m)[jt]s?(x)'];

const findPlaywrightCTDependencies: GenericPluginCallback = async configFilePath => {
Expand Down
1 change: 1 addition & 0 deletions src/plugins/playwright/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const ENABLERS = ['@playwright/test'];

export const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDependency(dependencies, ENABLERS);

/** @public */
export const ENTRY_FILE_PATTERNS = ['**/*.@(spec|test).?(c|m)[jt]s?(x)'];

export const CONFIG_FILE_PATTERNS = ['playwright.config.{js,ts}'];
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/remix/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ export const ENABLERS = [/^@remix-run\//];

export const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDependency(dependencies, ENABLERS);

/** @public */
export const ENTRY_FILE_PATTERNS = ['remix.config.js', 'remix.init/index.js'];

/** @public */
export const PRODUCTION_ENTRY_FILE_PATTERNS = [
'app/root.tsx',
'app/entry.{client,server}.{js,jsx,ts,tsx}',
Expand Down
1 change: 1 addition & 0 deletions src/plugins/rollup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const ENABLERS = ['rollup'];

export const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDependency(dependencies, ENABLERS);

/** @public */
export const ENTRY_FILE_PATTERNS = ['rollup.config.{js,mjs,ts}'];

const findRollupDependencies: GenericPluginCallback = async () => {
Expand Down
1 change: 1 addition & 0 deletions src/plugins/sentry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const ENABLERS = [/^@sentry\//];

export const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDependency(dependencies, ENABLERS);

/** @public */
export const ENTRY_FILE_PATTERNS = ['sentry.{client,server,edge}.config.{js,ts}'];

const findSentryDependencies: GenericPluginCallback = async () => {
Expand Down
1 change: 1 addition & 0 deletions src/plugins/storybook/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDepen

export const CONFIG_FILE_PATTERNS = ['.storybook/{main,manager,test-runner}.{js,ts}'];

/** @public */
export const ENTRY_FILE_PATTERNS = ['.storybook/preview.{js,jsx,ts,tsx}', '**/*.stories.{js,jsx,ts,tsx}'];

export const PROJECT_FILE_PATTERNS = ['.storybook/**/*.{js,jsx,ts,tsx}'];
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/svelte/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ export const ENABLERS = ['svelte'];

export const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDependency(dependencies, ENABLERS);

/** @public */
export const ENTRY_FILE_PATTERNS = ['svelte.config.js', 'vite.config.ts'];

/** @public */
export const PRODUCTION_ENTRY_FILE_PATTERNS = [
'src/routes/**/+{page,server,page.server,error,layout,layout.server}{,@*}.{js,ts,svelte}',
];
Expand Down
1 change: 1 addition & 0 deletions src/plugins/vitest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDepen

export const CONFIG_FILE_PATTERNS = ['vitest.config.ts', 'vitest.{workspace,projects}.{ts,js,json}'];

/** @public */
export const ENTRY_FILE_PATTERNS = ['**/*.{test,spec}.?(c|m)[jt]s?(x)'];

export const findVitestDeps = (config: VitestConfig, options: GenericPluginCallbackOptions) => {
Expand Down

0 comments on commit 51adaa3

Please sign in to comment.