knip 0.0.0-graph.3 → 0.0.0-node-types.0

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.
Files changed (214) hide show
  1. package/README.md +7 -915
  2. package/bin/knip.js +2 -0
  3. package/dist/ConfigurationChief.d.ts +14 -6
  4. package/dist/ConfigurationChief.js +104 -70
  5. package/dist/ConfigurationValidator.d.ts +553 -321
  6. package/dist/ConfigurationValidator.js +7 -1
  7. package/dist/DependencyDeputy.d.ts +4 -1
  8. package/dist/DependencyDeputy.js +13 -11
  9. package/dist/PrincipalFactory.d.ts +5 -2
  10. package/dist/PrincipalFactory.js +11 -7
  11. package/dist/ProjectPrincipal.d.ts +18 -15
  12. package/dist/ProjectPrincipal.js +43 -25
  13. package/dist/WorkspaceWorker.d.ts +9 -7
  14. package/dist/WorkspaceWorker.js +45 -63
  15. package/dist/binaries/bash-parser.js +1 -1
  16. package/dist/binaries/index.js +12 -3
  17. package/dist/binaries/resolvers/c8.js +2 -1
  18. package/dist/binaries/resolvers/dotenv.js +2 -1
  19. package/dist/binaries/resolvers/fallback.js +4 -2
  20. package/dist/binaries/resolvers/index.d.ts +1 -0
  21. package/dist/binaries/resolvers/index.js +1 -0
  22. package/dist/binaries/resolvers/node.js +1 -1
  23. package/dist/binaries/resolvers/nodemon.js +2 -1
  24. package/dist/binaries/resolvers/npx.js +2 -1
  25. package/dist/binaries/resolvers/nx.js +1 -1
  26. package/dist/binaries/resolvers/pnpm.js +1 -1
  27. package/dist/binaries/resolvers/rollup.js +2 -1
  28. package/dist/binaries/resolvers/tsx.d.ts +2 -0
  29. package/dist/binaries/resolvers/tsx.js +6 -0
  30. package/dist/binaries/resolvers/yarn.js +1 -1
  31. package/dist/binaries/util.d.ts +0 -3
  32. package/dist/binaries/util.js +1 -3
  33. package/dist/cli.d.ts +0 -1
  34. package/dist/cli.js +10 -9
  35. package/dist/constants.d.ts +0 -1
  36. package/dist/constants.js +5 -4
  37. package/dist/index.js +101 -65
  38. package/dist/manifest/index.js +8 -4
  39. package/dist/plugins/_template/index.js +15 -3
  40. package/dist/plugins/_template/types.d.ts +1 -0
  41. package/dist/plugins/angular/index.js +11 -11
  42. package/dist/plugins/astro/index.d.ts +7 -0
  43. package/dist/plugins/astro/index.js +19 -0
  44. package/dist/plugins/ava/index.d.ts +1 -1
  45. package/dist/plugins/ava/index.js +28 -7
  46. package/dist/plugins/ava/types.d.ts +5 -1
  47. package/dist/plugins/babel/helpers.d.ts +1 -2
  48. package/dist/plugins/babel/helpers.js +28 -20
  49. package/dist/plugins/babel/index.js +17 -14
  50. package/dist/plugins/capacitor/index.js +7 -3
  51. package/dist/plugins/changesets/index.js +10 -6
  52. package/dist/plugins/commitizen/index.d.ts +1 -0
  53. package/dist/plugins/commitizen/index.js +8 -4
  54. package/dist/plugins/commitizen/types.d.ts +1 -1
  55. package/dist/plugins/commitlint/index.js +7 -3
  56. package/dist/plugins/cspell/index.js +7 -3
  57. package/dist/plugins/cspell/types.d.ts +1 -1
  58. package/dist/plugins/cypress/index.d.ts +3 -1
  59. package/dist/plugins/cypress/index.js +17 -4
  60. package/dist/plugins/drizzle/index.js +5 -7
  61. package/dist/plugins/eslint/fallback.js +6 -1
  62. package/dist/plugins/eslint/helpers.d.ts +4 -11
  63. package/dist/plugins/eslint/helpers.js +24 -26
  64. package/dist/plugins/eslint/index.d.ts +1 -1
  65. package/dist/plugins/eslint/index.js +14 -4
  66. package/dist/plugins/gatsby/index.js +11 -5
  67. package/dist/plugins/github-actions/index.d.ts +1 -1
  68. package/dist/plugins/github-actions/index.js +7 -4
  69. package/dist/plugins/graphql-codegen/index.d.ts +7 -0
  70. package/dist/plugins/graphql-codegen/index.js +46 -0
  71. package/dist/plugins/graphql-codegen/types.d.ts +25 -0
  72. package/dist/plugins/graphql-codegen/types.js +3 -0
  73. package/dist/plugins/husky/index.js +9 -4
  74. package/dist/plugins/index.d.ts +4 -0
  75. package/dist/plugins/index.js +4 -0
  76. package/dist/plugins/jest/index.d.ts +1 -1
  77. package/dist/plugins/jest/index.js +21 -12
  78. package/dist/plugins/jest/types.d.ts +3 -0
  79. package/dist/plugins/lefthook/index.js +12 -8
  80. package/dist/plugins/lint-staged/index.d.ts +1 -0
  81. package/dist/plugins/lint-staged/index.js +10 -7
  82. package/dist/plugins/markdownlint/index.js +7 -4
  83. package/dist/plugins/mocha/index.d.ts +1 -0
  84. package/dist/plugins/mocha/index.js +12 -7
  85. package/dist/plugins/mocha/types.d.ts +4 -0
  86. package/dist/plugins/mocha/types.js +1 -0
  87. package/dist/plugins/next/index.d.ts +2 -1
  88. package/dist/plugins/next/index.js +7 -0
  89. package/dist/plugins/node-test-runner/index.d.ts +6 -0
  90. package/dist/plugins/node-test-runner/index.js +19 -0
  91. package/dist/plugins/npm-package-json-lint/index.d.ts +1 -0
  92. package/dist/plugins/npm-package-json-lint/index.js +8 -4
  93. package/dist/plugins/nx/index.js +13 -10
  94. package/dist/plugins/nyc/index.js +6 -3
  95. package/dist/plugins/nyc/types.d.ts +3 -0
  96. package/dist/plugins/nyc/types.js +1 -0
  97. package/dist/plugins/playwright/index.d.ts +5 -1
  98. package/dist/plugins/playwright/index.js +25 -2
  99. package/dist/plugins/playwright-ct/index.d.ts +3 -1
  100. package/dist/plugins/playwright-ct/index.js +18 -2
  101. package/dist/plugins/postcss/index.js +12 -9
  102. package/dist/plugins/prettier/index.js +11 -6
  103. package/dist/plugins/prettier/types.d.ts +8 -0
  104. package/dist/plugins/prettier/types.js +1 -0
  105. package/dist/plugins/release-it/index.d.ts +1 -0
  106. package/dist/plugins/release-it/index.js +14 -10
  107. package/dist/plugins/remark/index.d.ts +1 -0
  108. package/dist/plugins/remark/index.js +20 -4
  109. package/dist/plugins/remark/types.d.ts +3 -0
  110. package/dist/plugins/remark/types.js +1 -0
  111. package/dist/plugins/remix/index.d.ts +2 -1
  112. package/dist/plugins/remix/index.js +9 -0
  113. package/dist/plugins/rollup/index.d.ts +2 -1
  114. package/dist/plugins/rollup/index.js +8 -1
  115. package/dist/plugins/semantic-release/index.d.ts +1 -0
  116. package/dist/plugins/semantic-release/index.js +10 -4
  117. package/dist/plugins/semantic-release/types.d.ts +1 -1
  118. package/dist/plugins/sentry/index.d.ts +2 -1
  119. package/dist/plugins/sentry/index.js +7 -0
  120. package/dist/plugins/storybook/index.js +28 -10
  121. package/dist/plugins/storybook/types.d.ts +7 -0
  122. package/dist/plugins/stryker/index.js +13 -9
  123. package/dist/plugins/stylelint/index.js +8 -5
  124. package/dist/plugins/svelte/index.d.ts +2 -1
  125. package/dist/plugins/svelte/index.js +6 -0
  126. package/dist/plugins/tsup/index.d.ts +6 -0
  127. package/dist/plugins/tsup/index.js +23 -0
  128. package/dist/plugins/tsup/types.d.ts +7 -0
  129. package/dist/plugins/tsup/types.js +1 -0
  130. package/dist/plugins/typedoc/index.d.ts +1 -0
  131. package/dist/plugins/typedoc/index.js +8 -4
  132. package/dist/plugins/typedoc/types.d.ts +1 -1
  133. package/dist/plugins/typescript/index.js +16 -11
  134. package/dist/plugins/vite/index.js +7 -5
  135. package/dist/plugins/vitest/helpers.d.ts +2 -2
  136. package/dist/plugins/vitest/index.d.ts +4 -4
  137. package/dist/plugins/vitest/index.js +55 -26
  138. package/dist/plugins/vitest/types.d.ts +23 -2
  139. package/dist/plugins/webpack/index.js +31 -19
  140. package/dist/plugins/webpack/types.d.ts +2 -1
  141. package/dist/reporters/codeowners.js +2 -2
  142. package/dist/reporters/json.js +14 -9
  143. package/dist/reporters/symbols.js +3 -2
  144. package/dist/reporters/util.d.ts +8 -2
  145. package/dist/reporters/util.js +7 -1
  146. package/dist/types/cli.d.ts +1 -1
  147. package/dist/types/config.d.ts +9 -4
  148. package/dist/types/exports.d.ts +1 -0
  149. package/dist/types/imports.d.ts +6 -0
  150. package/dist/types/issues.d.ts +11 -1
  151. package/dist/types/package-json.d.ts +41 -0
  152. package/dist/types/package-json.js +1 -0
  153. package/dist/types/plugins.d.ts +5 -7
  154. package/dist/types/util.d.ts +16 -0
  155. package/dist/types/util.js +1 -0
  156. package/dist/types/workspace.d.ts +4 -1
  157. package/dist/typescript/SourceFile.d.ts +5 -0
  158. package/dist/typescript/SourceFileManager.js +3 -3
  159. package/dist/typescript/ast-helpers.d.ts +7 -14
  160. package/dist/typescript/ast-helpers.js +11 -9
  161. package/dist/typescript/createHosts.d.ts +1 -0
  162. package/dist/typescript/createHosts.js +1 -1
  163. package/dist/typescript/getImportsAndExports.d.ts +7 -5
  164. package/dist/typescript/getImportsAndExports.js +35 -18
  165. package/dist/typescript/resolveModuleNames.d.ts +1 -1
  166. package/dist/typescript/resolveModuleNames.js +38 -12
  167. package/dist/typescript/visitors/exports/exportDeclaration.js +14 -1
  168. package/dist/typescript/visitors/exports/exportKeyword.js +5 -2
  169. package/dist/typescript/visitors/exports/moduleExportsAccessExpression.js +29 -21
  170. package/dist/typescript/visitors/imports/importCall.js +1 -1
  171. package/dist/typescript/visitors/imports/importDeclaration.js +3 -3
  172. package/dist/typescript/visitors/imports/importEqualsDeclaration.js +1 -1
  173. package/dist/typescript/visitors/imports/jsDocType.js +37 -5
  174. package/dist/typescript/visitors/imports/propertyAccessCall.js +1 -1
  175. package/dist/typescript/visitors/imports/reExportDeclaration.js +8 -3
  176. package/dist/typescript/visitors/imports/requireCall.js +5 -5
  177. package/dist/util/array.d.ts +3 -1
  178. package/dist/util/cli-arguments.d.ts +3 -2
  179. package/dist/util/cli-arguments.js +6 -6
  180. package/dist/util/compilers.d.ts +122 -80
  181. package/dist/util/debug.d.ts +3 -3
  182. package/dist/util/debug.js +12 -18
  183. package/dist/util/fs.d.ts +2 -0
  184. package/dist/util/fs.js +22 -3
  185. package/dist/util/get-included-issue-types.js +14 -18
  186. package/dist/util/git.js +1 -1
  187. package/dist/util/glob.js +1 -1
  188. package/dist/util/loader.d.ts +2 -0
  189. package/dist/util/loader.js +23 -3
  190. package/dist/util/modules.d.ts +7 -1
  191. package/dist/util/modules.js +20 -10
  192. package/dist/util/object.d.ts +1 -0
  193. package/dist/util/object.js +3 -0
  194. package/dist/util/parse-args.d.ts +3 -0
  195. package/dist/util/parse-args.js +8 -0
  196. package/dist/util/path.d.ts +1 -0
  197. package/dist/util/path.js +5 -3
  198. package/dist/util/plugin.d.ts +4 -3
  199. package/dist/util/plugin.js +11 -4
  200. package/dist/util/protocols.d.ts +9 -0
  201. package/dist/util/protocols.js +9 -0
  202. package/dist/util/register.d.ts +2 -1
  203. package/dist/util/register.js +9 -13
  204. package/dist/util/require.js +7 -5
  205. package/dist/util/tsconfig-loader.js +2 -1
  206. package/dist/util/unwrap-function.d.ts +1 -0
  207. package/dist/util/unwrap-function.js +13 -0
  208. package/dist/version.d.ts +1 -1
  209. package/dist/version.js +1 -1
  210. package/package.json +86 -85
  211. package/schema-jsonc.json +11 -0
  212. package/schema.json +27 -3
  213. package/dist/plugins/vite/types.d.ts +0 -4
  214. /package/dist/plugins/{vite → jest}/types.js +0 -0
@@ -1,30 +1,33 @@
1
1
  import { compact } from '../../util/array.js';
2
2
  import { timerify } from '../../util/Performance.js';
3
3
  import { hasDependency, load } from '../../util/plugin.js';
4
- import { resolvePresetName, resolvePluginName, api } from './helpers.js';
4
+ import { resolveName, api } from './helpers.js';
5
5
  export const NAME = 'Babel';
6
6
  export const ENABLERS = [/^@babel\//];
7
7
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
8
8
  export const CONFIG_FILE_PATTERNS = [
9
- 'babel.config.json',
10
- 'babel.config.js',
11
- '.babelrc.json',
12
- '.babelrc.js',
9
+ 'babel.config.{json,js,cjs,mjs,cts}',
10
+ '.babelrc.{json,js,cjs,mjs,cts}',
13
11
  '.babelrc',
14
12
  'package.json',
15
13
  ];
16
- const getItemName = (value) => typeof value === 'string' ? [value] : Array.isArray(value) ? [value[0]] : [];
14
+ const getName = (value) => typeof value === 'string' ? [value] : Array.isArray(value) ? [value[0]] : [];
17
15
  export const getDependenciesFromConfig = (config) => {
18
- const presets = config.presets?.flatMap(getItemName).map(resolvePresetName) ?? [];
19
- const plugins = config.plugins?.flatMap(getItemName).map(resolvePluginName) ?? [];
16
+ const presets = config.presets?.flatMap(getName).map(name => resolveName(name, 'preset')) ?? [];
17
+ const plugins = config.plugins?.flatMap(getName).map(name => resolveName(name, 'plugin')) ?? [];
20
18
  const nested = config.env ? Object.values(config.env).flatMap(getDependenciesFromConfig) : [];
21
19
  return compact([...presets, ...plugins, ...nested]);
22
20
  };
23
- const findBabelDependencies = async (configFilePath, { manifest }) => {
24
- let config = configFilePath.endsWith('package.json') ? manifest.babel : await load(configFilePath);
25
- if (typeof config === 'function') {
26
- config = config(api);
27
- }
28
- return config ? getDependenciesFromConfig(config) : [];
21
+ const findBabelDependencies = async (configFilePath, { manifest, isProduction }) => {
22
+ if (isProduction)
23
+ return [];
24
+ let localConfig = configFilePath.endsWith('package.json')
25
+ ? manifest.babel
26
+ : await load(configFilePath);
27
+ if (typeof localConfig === 'function')
28
+ localConfig = localConfig(api);
29
+ if (!localConfig)
30
+ return [];
31
+ return getDependenciesFromConfig(localConfig);
29
32
  };
30
33
  export const findDependencies = timerify(findBabelDependencies);
@@ -4,8 +4,12 @@ export const NAME = 'Capacitor';
4
4
  export const ENABLERS = [/^@capacitor\//];
5
5
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
6
6
  export const CONFIG_FILE_PATTERNS = ['capacitor.config.ts'];
7
- const findCapacitorDependencies = async (configFilePath) => {
8
- const config = await load(configFilePath);
9
- return config.includePlugins ?? [];
7
+ const findCapacitorDependencies = async (configFilePath, { isProduction }) => {
8
+ if (isProduction)
9
+ return [];
10
+ const localConfig = await load(configFilePath);
11
+ if (!localConfig)
12
+ return [];
13
+ return localConfig.includePlugins ?? [];
10
14
  };
11
15
  export const findDependencies = timerify(findCapacitorDependencies);
@@ -4,12 +4,16 @@ export const NAME = 'Changesets';
4
4
  export const ENABLERS = ['@changesets/cli'];
5
5
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
6
6
  export const CONFIG_FILE_PATTERNS = ['.changeset/config.json'];
7
- const findChangesetsDependencies = async (configFilePath) => {
8
- const config = await load(configFilePath);
9
- return Array.isArray(config.changelog)
10
- ? [config.changelog[0]]
11
- : typeof config.changelog === 'string'
12
- ? [config.changelog]
7
+ const findChangesetsDependencies = async (configFilePath, { isProduction }) => {
8
+ if (isProduction)
9
+ return [];
10
+ const localConfig = await load(configFilePath);
11
+ if (!localConfig)
12
+ return [];
13
+ return Array.isArray(localConfig.changelog)
14
+ ? [localConfig.changelog[0]]
15
+ : typeof localConfig.changelog === 'string'
16
+ ? [localConfig.changelog]
13
17
  : [];
14
18
  };
15
19
  export const findDependencies = timerify(findChangesetsDependencies);
@@ -1,6 +1,7 @@
1
1
  import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
2
  export declare const NAME = "Commitizen";
3
3
  export declare const ENABLERS: string[];
4
+ export declare const PACKAGE_JSON_PATH = "config.commitizen";
4
5
  export declare const isEnabled: IsPluginEnabledCallback;
5
6
  export declare const CONFIG_FILE_PATTERNS: string[];
6
7
  export declare const findDependencies: GenericPluginCallback;
@@ -2,13 +2,17 @@ import { timerify } from '../../util/Performance.js';
2
2
  import { hasDependency, load } from '../../util/plugin.js';
3
3
  export const NAME = 'Commitizen';
4
4
  export const ENABLERS = ['commitizen'];
5
+ export const PACKAGE_JSON_PATH = 'config.commitizen';
5
6
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
6
7
  export const CONFIG_FILE_PATTERNS = ['.czrc', '.cz.json', 'package.json'];
7
- const findPluginDependencies = async (configFilePath, { manifest }) => {
8
- const config = configFilePath.endsWith('package.json')
8
+ const findPluginDependencies = async (configFilePath, { manifest, isProduction }) => {
9
+ if (isProduction)
10
+ return [];
11
+ const localConfig = configFilePath.endsWith('package.json')
9
12
  ? manifest.config?.commitizen
10
13
  : await load(configFilePath);
11
- const path = config?.path;
12
- return path === undefined ? [] : [path];
14
+ if (!localConfig)
15
+ return [];
16
+ return localConfig.path ? [localConfig.path] : [];
13
17
  };
14
18
  export const findDependencies = timerify(findPluginDependencies);
@@ -1,3 +1,3 @@
1
- export type PluginConfig = {
1
+ export type CommitizenConfig = {
2
2
  path?: string;
3
3
  };
@@ -9,10 +9,14 @@ export const CONFIG_FILE_PATTERNS = [
9
9
  'commitlint.config.{js,cjs,ts,cts}',
10
10
  'package.json',
11
11
  ];
12
- const findCommitLintDependencies = async (configFilePath, { manifest }) => {
13
- const config = configFilePath.endsWith('package.json')
12
+ const findCommitLintDependencies = async (configFilePath, { manifest, isProduction }) => {
13
+ if (isProduction)
14
+ return [];
15
+ const localConfig = configFilePath.endsWith('package.json')
14
16
  ? manifest.commitlint
15
17
  : await load(configFilePath);
16
- return config?.extends ? [config.extends].flat() : [];
18
+ if (!localConfig)
19
+ return [];
20
+ return localConfig.extends ? [localConfig.extends].flat() : [];
17
21
  };
18
22
  export const findDependencies = timerify(findCommitLintDependencies);
@@ -9,9 +9,13 @@ export const CONFIG_FILE_PATTERNS = [
9
9
  '.c{s,S}pell.json',
10
10
  'cSpell.json',
11
11
  ];
12
- const findCspellDependencies = async (configFilePath) => {
13
- const config = await load(configFilePath);
14
- const imports = config?.import ?? [];
12
+ const findCspellDependencies = async (configFilePath, { isProduction }) => {
13
+ if (isProduction)
14
+ return [];
15
+ const localConfig = await load(configFilePath);
16
+ if (!localConfig)
17
+ return [];
18
+ const imports = localConfig.import ?? [];
15
19
  return imports;
16
20
  };
17
21
  export const findDependencies = timerify(findCspellDependencies);
@@ -1,3 +1,3 @@
1
- export type PluginConfig = {
1
+ export type CSpellConfig = {
2
2
  import?: string[];
3
3
  };
@@ -1,5 +1,7 @@
1
- import type { IsPluginEnabledCallback } from '../../types/plugins.js';
1
+ import type { GenericPluginCallback, IsPluginEnabledCallback } from '../../types/plugins.js';
2
2
  export declare const NAME = "Cypress";
3
3
  export declare const ENABLERS: string[];
4
4
  export declare const isEnabled: IsPluginEnabledCallback;
5
+ export declare const CONFIG_FILE_PATTERNS: string[];
5
6
  export declare const ENTRY_FILE_PATTERNS: string[];
7
+ export declare const findDependencies: GenericPluginCallback;
@@ -1,10 +1,23 @@
1
- import { hasDependency } from '../../util/plugin.js';
1
+ import { load, hasDependency } from '../../util/plugin.js';
2
+ import { toEntryPattern } from '../../util/protocols.js';
2
3
  export const NAME = 'Cypress';
3
4
  export const ENABLERS = ['cypress'];
4
5
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
5
- export const ENTRY_FILE_PATTERNS = [
6
- 'cypress.config.{js,ts,mjs,cjs}',
6
+ export const CONFIG_FILE_PATTERNS = ['cypress.config.{js,ts,mjs,cjs}'];
7
+ const TEST_FILE_PATTERNS = ['cypress/e2e/**/*.cy.{js,jsx,ts,tsx}'];
8
+ const SUPPORT_FILE_PATTERNS = [
7
9
  'cypress/support/e2e.{js,jsx,ts,tsx}',
8
- 'cypress/e2e/**/*.cy.{js,jsx,ts,tsx}',
9
10
  'cypress/plugins/index.js',
10
11
  ];
12
+ export const ENTRY_FILE_PATTERNS = [...TEST_FILE_PATTERNS, ...SUPPORT_FILE_PATTERNS];
13
+ export const findDependencies = async (configFilePath, options) => {
14
+ const { config } = options;
15
+ const localConfig = await load(configFilePath);
16
+ if (!localConfig)
17
+ return [];
18
+ if (config.entry)
19
+ return config.entry.map(toEntryPattern);
20
+ const patterns = [localConfig.e2e?.specPattern ?? [], localConfig.component?.specPattern ?? []].flat();
21
+ const entryPatterns = (patterns.length > 0 ? patterns : TEST_FILE_PATTERNS).map(toEntryPattern);
22
+ return [...entryPatterns, ...SUPPORT_FILE_PATTERNS.map(toEntryPattern)];
23
+ };
@@ -1,16 +1,14 @@
1
- import { _glob } from '../../util/glob.js';
2
1
  import { timerify } from '../../util/Performance.js';
3
2
  import { hasDependency, load } from '../../util/plugin.js';
3
+ import { toProductionEntryPattern } from '../../util/protocols.js';
4
4
  export const NAME = 'Drizzle';
5
5
  export const ENABLERS = ['drizzle-kit'];
6
6
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
7
7
  export const CONFIG_FILE_PATTERNS = ['drizzle.config.{ts,js,json}'];
8
- const findDrizzleDependencies = async (configFilePath, { cwd }) => {
9
- const config = await load(configFilePath);
10
- if (!config || !config.schema)
8
+ const findDrizzleDependencies = async (configFilePath) => {
9
+ const localConfig = await load(configFilePath);
10
+ if (!localConfig?.schema)
11
11
  return [];
12
- const patterns = Array.isArray(config.schema) ? config.schema : [config.schema];
13
- const paths = await _glob({ cwd, patterns });
14
- return paths;
12
+ return [localConfig.schema].flat().map(toProductionEntryPattern);
15
13
  };
16
14
  export const findDependencies = timerify(findDrizzleDependencies);
@@ -1,5 +1,6 @@
1
1
  import createJITI from 'jiti';
2
2
  import transform from 'jiti/dist/babel.js';
3
+ import { FAKE_PATH } from '../../util/loader.js';
3
4
  import { timerify } from '../../util/Performance.js';
4
5
  const rushstackMatch = /require\(("|')@rushstack\/(eslint-config\/patch|eslint-patch)\/modern-module-resolution("|')\)/;
5
6
  const jiti = createJITI(process.cwd(), {
@@ -9,5 +10,9 @@ const jiti = createJITI(process.cwd(), {
9
10
  return transform(opts);
10
11
  },
11
12
  });
12
- const load = (configFilePath) => jiti(configFilePath);
13
+ const load = (configFilePath) => {
14
+ if (configFilePath === FAKE_PATH)
15
+ return;
16
+ return jiti(configFilePath);
17
+ };
13
18
  export const fallback = timerify(load);
@@ -1,14 +1,7 @@
1
- /// <reference types="npmcli__package-json" />
2
- import type { ESLintConfig } from './types.js';
3
- import type { PackageJson } from '@npmcli/package-json';
4
- type Manifest = PackageJson & {
5
- eslintConfig?: ESLintConfig;
6
- };
7
- type GetDependenciesDeep = (configFilePath: string, dependencies: Set<string>, options: {
1
+ import type { PackageJsonWithPlugins } from '../../types/package-json.js';
2
+ type GetDependenciesDeep = (configFilePath: string, options: {
8
3
  cwd: string;
9
- manifest: Manifest;
10
- }) => Promise<Set<string>>;
4
+ manifest: PackageJsonWithPlugins;
5
+ }, dependencies?: Set<string>) => Promise<Set<string>>;
11
6
  export declare const getDependenciesDeep: GetDependenciesDeep;
12
- export declare const resolvePluginSpecifier: (specifier: string) => string;
13
- export declare const resolveExtendSpecifier: (specifier: string) => string | undefined;
14
7
  export {};
@@ -1,47 +1,43 @@
1
1
  import { compact } from '../../util/array.js';
2
+ import { getPackageNameFromModuleSpecifier } from '../../util/modules.js';
2
3
  import { isInternal, dirname, toAbsolute } from '../../util/path.js';
3
4
  import { load } from '../../util/plugin.js';
4
5
  import { _resolve } from '../../util/require.js';
6
+ import { getDependenciesFromConfig } from '../babel/index.js';
5
7
  import { fallback } from './fallback.js';
8
+ import { PACKAGE_JSON_PATH } from './index.js';
6
9
  const getDependencies = (config) => {
7
10
  const extendsSpecifiers = config.extends ? [config.extends].flat().map(resolveExtendSpecifier) : [];
8
11
  if (extendsSpecifiers.some(specifier => specifier?.startsWith('eslint-plugin-prettier')))
9
12
  extendsSpecifiers.push('eslint-config-prettier');
10
13
  const plugins = config.plugins ? config.plugins.map(resolvePluginSpecifier) : [];
11
14
  const parser = config.parser;
12
- const extraPlugins = config.parserOptions?.babelOptions?.plugins ?? [];
13
- const extraParsers = config.parserOptions?.babelOptions?.presets ?? [];
15
+ const babelDependencies = config.parserOptions?.babelOptions
16
+ ? getDependenciesFromConfig(config.parserOptions.babelOptions)
17
+ : [];
14
18
  const settings = config.settings ? getDependenciesFromSettings(config.settings) : [];
15
19
  const overrides = config.overrides ? [config.overrides].flat().flatMap(getDependencies) : [];
16
- return compact([
17
- ...extendsSpecifiers,
18
- ...plugins,
19
- ...extraPlugins,
20
- parser,
21
- ...extraParsers,
22
- ...settings,
23
- ...overrides,
24
- ]);
20
+ return compact([...extendsSpecifiers, ...plugins, parser, ...babelDependencies, ...settings, ...overrides]);
25
21
  };
26
- export const getDependenciesDeep = async (configFilePath, dependencies = new Set(), options) => {
22
+ export const getDependenciesDeep = async (configFilePath, options, dependencies = new Set()) => {
27
23
  const addAll = (deps) => deps.forEach(dependency => dependencies.add(dependency));
28
- const config = configFilePath.endsWith('package.json')
29
- ? options.manifest.eslintConfig
24
+ const localConfig = configFilePath.endsWith('package.json')
25
+ ? options.manifest[PACKAGE_JSON_PATH]
30
26
  : /(\.(jsonc?|ya?ml)|rc)$/.test(configFilePath)
31
27
  ? await load(configFilePath)
32
28
  : await fallback(configFilePath);
33
- if (config) {
34
- if (config.extends) {
35
- for (const extend of [config.extends].flat()) {
29
+ if (localConfig) {
30
+ if (localConfig.extends) {
31
+ for (const extend of [localConfig.extends].flat()) {
36
32
  if (isInternal(extend)) {
37
33
  const filePath = toAbsolute(extend, dirname(configFilePath));
38
34
  const extendConfigFilePath = _resolve(filePath);
39
35
  dependencies.add(extendConfigFilePath);
40
- addAll(await getDependenciesDeep(extendConfigFilePath, dependencies, options));
36
+ addAll(await getDependenciesDeep(extendConfigFilePath, options, dependencies));
41
37
  }
42
38
  }
43
39
  }
44
- addAll(getDependencies(config));
40
+ addAll(getDependencies(localConfig));
45
41
  }
46
42
  return dependencies;
47
43
  };
@@ -53,15 +49,17 @@ const resolveSpecifier = (namespace, rawSpecifier) => {
53
49
  const specifier = rawSpecifier.replace(/(^plugin:|:.+$)/, '');
54
50
  if (isQualifiedSpecifier(specifier))
55
51
  return specifier;
56
- if (!specifier.startsWith('@'))
57
- return `${namespace}-${specifier}`;
52
+ if (!specifier.startsWith('@')) {
53
+ const id = rawSpecifier.startsWith('plugin:') ? getPackageNameFromModuleSpecifier(specifier) : specifier;
54
+ return `${namespace}-${id}`;
55
+ }
58
56
  const [scope, name, ...rest] = specifier.split('/');
59
57
  if (rawSpecifier.startsWith('plugin:') && rest.length === 0)
60
- return [scope, namespace, name].join('/');
58
+ return [scope, namespace].join('/');
61
59
  return [scope, name ? `${namespace}-${name}` : namespace, ...rest].join('/');
62
60
  };
63
- export const resolvePluginSpecifier = (specifier) => resolveSpecifier('eslint-plugin', specifier);
64
- export const resolveExtendSpecifier = (specifier) => {
61
+ const resolvePluginSpecifier = (specifier) => resolveSpecifier('eslint-plugin', specifier);
62
+ const resolveExtendSpecifier = (specifier) => {
65
63
  if (isInternal(specifier))
66
64
  return;
67
65
  if (/^next(\/.+)?$/.test(specifier))
@@ -70,7 +68,7 @@ export const resolveExtendSpecifier = (specifier) => {
70
68
  return resolveSpecifier(namespace, specifier);
71
69
  };
72
70
  const getDependenciesFromSettings = (settings = {}) => {
73
- return compact(Object.entries(settings).flatMap(([settingKey, settings]) => {
71
+ return Object.entries(settings).flatMap(([settingKey, settings]) => {
74
72
  if (settingKey === 'import/resolver') {
75
73
  return (typeof settings === 'string' ? [settings] : Object.keys(settings))
76
74
  .filter(key => key !== 'node')
@@ -79,5 +77,5 @@ const getDependenciesFromSettings = (settings = {}) => {
79
77
  if (settingKey === 'import/parsers') {
80
78
  return typeof settings === 'string' ? [settings] : Object.keys(settings);
81
79
  }
82
- }));
80
+ });
83
81
  };
@@ -1,7 +1,7 @@
1
1
  import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
2
  export declare const NAME = "ESLint";
3
3
  export declare const ENABLERS: string[];
4
+ export declare const PACKAGE_JSON_PATH = "eslintConfig";
4
5
  export declare const isEnabled: IsPluginEnabledCallback;
5
6
  export declare const CONFIG_FILE_PATTERNS: string[];
6
- export declare const ENTRY_FILE_PATTERNS: string[];
7
7
  export declare const findDependencies: GenericPluginCallback;
@@ -3,13 +3,23 @@ import { hasDependency } from '../../util/plugin.js';
3
3
  import { getDependenciesDeep } from './helpers.js';
4
4
  export const NAME = 'ESLint';
5
5
  export const ENABLERS = ['eslint'];
6
+ export const PACKAGE_JSON_PATH = 'eslintConfig';
6
7
  export const isEnabled = ({ dependencies, manifest, config }) => hasDependency(dependencies, ENABLERS) ||
7
8
  'eslint' in config ||
8
9
  Boolean(manifest.name && /(^eslint-config|\/eslint-config)/.test(manifest.name));
9
- export const CONFIG_FILE_PATTERNS = ['.eslintrc', '.eslintrc.{js,json,cjs}', '.eslintrc.{yml,yaml}', 'package.json'];
10
- export const ENTRY_FILE_PATTERNS = ['eslint.config.js'];
11
- const findESLintDependencies = async (configFilePath, { cwd, manifest }) => {
12
- const dependencies = await getDependenciesDeep(configFilePath, new Set(), { cwd, manifest });
10
+ export const CONFIG_FILE_PATTERNS = [
11
+ 'eslint.config.js',
12
+ '.eslintrc',
13
+ '.eslintrc.{js,json,cjs}',
14
+ '.eslintrc.{yml,yaml}',
15
+ 'package.json',
16
+ ];
17
+ const findESLintDependencies = async (configFilePath, { cwd, manifest, isProduction }) => {
18
+ if (isProduction)
19
+ return [];
20
+ if (configFilePath.endsWith('eslint.config.js'))
21
+ return [];
22
+ const dependencies = await getDependenciesDeep(configFilePath, { cwd, manifest });
13
23
  return Array.from(dependencies);
14
24
  };
15
25
  export const findDependencies = timerify(findESLintDependencies);
@@ -1,25 +1,31 @@
1
1
  import { timerify } from '../../util/Performance.js';
2
2
  import { hasDependency, load } from '../../util/plugin.js';
3
+ import { toProductionEntryPattern } from '../../util/protocols.js';
3
4
  export const NAME = 'Gatsby';
4
5
  export const ENABLERS = ['gatsby', 'gatsby-cli'];
5
6
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
6
- export const CONFIG_FILE_PATTERNS = ['gatsby-{config,node}.{js,jsx,ts,tsx}'];
7
+ export const CONFIG_FILE_PATTERNS = ['gatsby-{config,node}.{js,jsx,ts,tsx}', 'plugins/**/gatsby-node.{js,jsx,ts,tsx}'];
7
8
  export const PRODUCTION_ENTRY_FILE_PATTERNS = [
8
9
  'gatsby-{browser,ssr}.{js,jsx,ts,tsx}',
9
10
  'src/api/**/*.{js,ts}',
10
11
  'src/pages/**/*.{js,jsx,ts,tsx}',
11
12
  'src/templates/**/*.{js,jsx,ts,tsx}',
12
13
  'src/html.{js,jsx,ts,tsx}',
14
+ 'plugins/**/gatsby-{browser,ssr}.{js,jsx,ts,tsx}',
13
15
  ];
14
- const findGatsbyDependencies = async (configFilePath) => {
15
- const config = await load(configFilePath);
16
+ const findGatsbyDependencies = async (configFilePath, options) => {
17
+ const { isProduction, config } = options;
18
+ const localConfig = await load(configFilePath);
19
+ const entryPatterns = (config.entry ?? PRODUCTION_ENTRY_FILE_PATTERNS).map(toProductionEntryPattern);
20
+ if (isProduction || !localConfig)
21
+ return entryPatterns;
16
22
  if (/gatsby-config/.test(configFilePath)) {
17
- return config.plugins.map(plugin => (typeof plugin === 'string' ? plugin : plugin.resolve));
23
+ return localConfig.plugins.map(plugin => (typeof plugin === 'string' ? plugin : plugin.resolve));
18
24
  }
19
25
  if (/gatsby-node/.test(configFilePath)) {
20
26
  const plugins = new Set();
21
27
  const actions = { setBabelPlugin: plugin => plugins.add(plugin.name) };
22
- const _config = config;
28
+ const _config = localConfig;
23
29
  if (typeof _config.onCreateBabelConfig === 'function') {
24
30
  _config.onCreateBabelConfig({ actions });
25
31
  }
@@ -1,6 +1,6 @@
1
1
  import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
2
  export declare const NAME = "GitHub Actions";
3
- export declare const ENABLERS = "This plugin is enabled when a `.yml` file is found in the `.github/workflows` folder.";
3
+ export declare const ENABLERS = "This plugin is enabled when a `.yml` or `.yaml` file is found in the `.github/workflows` folder.";
4
4
  export declare const isEnabled: IsPluginEnabledCallback;
5
5
  export declare const CONFIG_FILE_PATTERNS: string[];
6
6
  export declare const findDependencies: GenericPluginCallback;
@@ -4,10 +4,13 @@ import { getValuesByKeyDeep } from '../../util/object.js';
4
4
  import { timerify } from '../../util/Performance.js';
5
5
  import { load } from '../../util/plugin.js';
6
6
  export const NAME = 'GitHub Actions';
7
- export const ENABLERS = 'This plugin is enabled when a `.yml` file is found in the `.github/workflows` folder.';
8
- export const isEnabled = async ({ cwd }) => Boolean(await _firstGlob({ cwd, patterns: ['.github/workflows/*.yml'] }));
9
- export const CONFIG_FILE_PATTERNS = ['.github/workflows/*.yml', '.github/**/action.{yml,yaml}'];
10
- const findGithubActionsDependencies = async (configFilePath, { cwd, manifest }) => {
7
+ export const ENABLERS = 'This plugin is enabled when a `.yml` or `.yaml` file is found in the `.github/workflows` folder.';
8
+ export const isEnabled = async ({ cwd }) => Boolean(await _firstGlob({ cwd, patterns: ['.github/workflows/*.{yml,yaml}'] }));
9
+ export const CONFIG_FILE_PATTERNS = ['.github/workflows/*.{yml,yaml}', '.github/**/action.{yml,yaml}'];
10
+ const findGithubActionsDependencies = async (configFilePath, options) => {
11
+ const { cwd, manifest, isProduction } = options;
12
+ if (isProduction)
13
+ return [];
11
14
  const config = await load(configFilePath);
12
15
  if (!config)
13
16
  return [];
@@ -0,0 +1,7 @@
1
+ import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
+ export declare const NAME = "GraphQL Codegen";
3
+ export declare const ENABLERS: RegExp[];
4
+ export declare const PACKAGE_JSON_PATH = "codegen";
5
+ export declare const isEnabled: IsPluginEnabledCallback;
6
+ export declare const CONFIG_FILE_PATTERNS: string[];
7
+ export declare const findDependencies: GenericPluginCallback;
@@ -0,0 +1,46 @@
1
+ import { isInternal } from '../../util/path.js';
2
+ import { timerify } from '../../util/Performance.js';
3
+ import { hasDependency, load } from '../../util/plugin.js';
4
+ import { toEntryPattern } from '../../util/protocols.js';
5
+ import { isConfigurationOutput } from './types.js';
6
+ export const NAME = 'GraphQL Codegen';
7
+ export const ENABLERS = [/^@graphql-codegen\//];
8
+ export const PACKAGE_JSON_PATH = 'codegen';
9
+ export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
10
+ export const CONFIG_FILE_PATTERNS = [
11
+ 'codegen.{json,yml,yaml,js,ts,mjs,cts}',
12
+ '.codegenrc.{json,yml,yaml,js,ts}',
13
+ 'codegen.config.js',
14
+ 'package.json',
15
+ ];
16
+ const findPluginDependencies = async (configFilePath, options) => {
17
+ const { manifest, isProduction } = options;
18
+ if (isProduction)
19
+ return [];
20
+ const localConfig = configFilePath.endsWith('package.json')
21
+ ? manifest[PACKAGE_JSON_PATH]
22
+ : await load(configFilePath);
23
+ if (!localConfig)
24
+ return [];
25
+ const generateSet = Object.values(localConfig.generates);
26
+ const configurationOutput = generateSet.filter(isConfigurationOutput);
27
+ const presets = configurationOutput
28
+ .map(configOutput => (configOutput.preset ? configOutput.preset : undefined))
29
+ .filter((preset) => typeof preset === 'string')
30
+ .map(presetName => `@graphql-codegen/${presetName}${presetName.endsWith('-preset') ? '' : '-preset'}`);
31
+ const flatPlugins = generateSet
32
+ .filter((config) => !isConfigurationOutput(config))
33
+ .flatMap(item => Object.keys(item))
34
+ .map(plugin => `@graphql-codegen/${plugin}`);
35
+ const nestedPlugins = configurationOutput
36
+ .flatMap(configOutput => (configOutput.plugins ? configOutput.plugins : []))
37
+ .flatMap(plugin => {
38
+ if (typeof plugin !== 'string')
39
+ return [];
40
+ if (isInternal(plugin))
41
+ return [toEntryPattern(plugin)];
42
+ return [`@graphql-codegen/${plugin}`];
43
+ });
44
+ return [...presets, ...flatPlugins, ...nestedPlugins];
45
+ };
46
+ export const findDependencies = timerify(findPluginDependencies);
@@ -0,0 +1,25 @@
1
+ type PluginConfig<T = unknown> = {
2
+ [key: string]: T;
3
+ };
4
+ export interface ConfiguredPlugin {
5
+ [name: string]: PluginConfig;
6
+ }
7
+ type NamedPlugin = string;
8
+ type OutputConfig = NamedPlugin | ConfiguredPlugin;
9
+ type PresetNamesBase = 'client' | 'near-operation-file' | 'gql-tag-operations' | 'graphql-modules' | 'import-types';
10
+ export type PresetNames = `${PresetNamesBase}-preset` | PresetNamesBase;
11
+ type OutputPreset = {
12
+ buildGeneratesSection: (options: unknown) => Promise<unknown>;
13
+ prepareDocuments?: (outputFilePath: string, outputSpecificDocuments: unknown) => Promise<unknown>;
14
+ };
15
+ export declare function isConfigurationOutput(config: ConfiguredOutput | ConfiguredPlugin[]): config is ConfiguredOutput;
16
+ interface ConfiguredOutput {
17
+ plugins?: OutputConfig[];
18
+ preset?: PresetNames | OutputPreset;
19
+ }
20
+ export interface GraphqlCodegenTypes {
21
+ generates: {
22
+ [outputPath: string]: ConfiguredOutput | ConfiguredPlugin[];
23
+ };
24
+ }
25
+ export {};
@@ -0,0 +1,3 @@
1
+ export function isConfigurationOutput(config) {
2
+ return 'preset' in config || 'plugins' in config;
3
+ }
@@ -1,15 +1,20 @@
1
- import { readFileSync } from 'fs';
2
1
  import { _getDependenciesFromScripts } from '../../binaries/index.js';
3
2
  import { getGitHookPaths } from '../../util/git.js';
3
+ import { FAKE_PATH } from '../../util/loader.js';
4
4
  import { timerify } from '../../util/Performance.js';
5
- import { hasDependency } from '../../util/plugin.js';
5
+ import { hasDependency, loadFile } from '../../util/plugin.js';
6
6
  export const NAME = 'husky';
7
7
  export const ENABLERS = ['husky'];
8
8
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
9
9
  const gitHookPaths = getGitHookPaths('.husky');
10
10
  export const CONFIG_FILE_PATTERNS = [...gitHookPaths];
11
- const findHuskyDependencies = async (configFilePath, { cwd, manifest }) => {
12
- const script = readFileSync(configFilePath);
11
+ const findHuskyDependencies = async (configFilePath, options) => {
12
+ const { cwd, manifest, isProduction } = options;
13
+ if (isProduction || configFilePath === FAKE_PATH)
14
+ return [];
15
+ const script = await loadFile(configFilePath);
16
+ if (!script)
17
+ return [];
13
18
  return _getDependenciesFromScripts(String(script), {
14
19
  cwd,
15
20
  manifest,
@@ -1,4 +1,5 @@
1
1
  export * as angular from './angular/index.js';
2
+ export * as astro from './astro/index.js';
2
3
  export * as ava from './ava/index.js';
3
4
  export * as babel from './babel/index.js';
4
5
  export * as capacitor from './capacitor/index.js';
@@ -11,6 +12,7 @@ export * as drizzle from './drizzle/index.js';
11
12
  export * as eslint from './eslint/index.js';
12
13
  export * as gatsby from './gatsby/index.js';
13
14
  export * as githubActions from './github-actions/index.js';
15
+ export * as graphqlCodegen from './graphql-codegen/index.js';
14
16
  export * as husky from './husky/index.js';
15
17
  export * as jest from './jest/index.js';
16
18
  export * as lefthook from './lefthook/index.js';
@@ -18,6 +20,7 @@ export * as lintStaged from './lint-staged/index.js';
18
20
  export * as markdownlint from './markdownlint/index.js';
19
21
  export * as mocha from './mocha/index.js';
20
22
  export * as next from './next/index.js';
23
+ export * as nodeTestRunner from './node-test-runner/index.js';
21
24
  export * as npmPackageJsonLint from './npm-package-json-lint/index.js';
22
25
  export * as nx from './nx/index.js';
23
26
  export * as nyc from './nyc/index.js';
@@ -36,6 +39,7 @@ export * as stryker from './stryker/index.js';
36
39
  export * as stylelint from './stylelint/index.js';
37
40
  export * as svelte from './svelte/index.js';
38
41
  export * as tailwind from './tailwind/index.js';
42
+ export * as tsup from './tsup/index.js';
39
43
  export * as typedoc from './typedoc/index.js';
40
44
  export * as typescript from './typescript/index.js';
41
45
  export * as vite from './vite/index.js';