knip 5.33.2 → 5.34.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.
- package/dist/ConfigurationChief.d.ts +27 -27
- package/dist/ConfigurationChief.js +20 -36
- package/dist/ConfigurationValidator.d.ts +392 -0
- package/dist/ConfigurationValidator.js +7 -0
- package/dist/DependencyDeputy.js +5 -2
- package/dist/PrincipalFactory.d.ts +3 -20
- package/dist/PrincipalFactory.js +4 -4
- package/dist/ProjectPrincipal.d.ts +2 -5
- package/dist/ProjectPrincipal.js +0 -5
- package/dist/WorkspaceWorker.d.ts +15 -13
- package/dist/WorkspaceWorker.js +144 -105
- package/dist/binaries/bash-parser.d.ts +3 -2
- package/dist/binaries/bash-parser.js +33 -22
- package/dist/binaries/fallback.d.ts +2 -0
- package/dist/binaries/fallback.js +12 -0
- package/dist/binaries/index.d.ts +2 -2
- package/dist/binaries/index.js +15 -26
- package/dist/binaries/package-manager/bun.d.ts +2 -0
- package/dist/binaries/{resolvers → package-manager}/bun.js +6 -4
- package/dist/binaries/package-manager/index.d.ts +8 -0
- package/dist/binaries/package-manager/index.js +12 -0
- package/dist/binaries/{resolvers → package-manager}/node.d.ts +0 -2
- package/dist/binaries/package-manager/node.js +5 -0
- package/dist/binaries/package-manager/npm.d.ts +2 -0
- package/dist/binaries/package-manager/npm.js +8 -0
- package/dist/binaries/package-manager/npx.d.ts +2 -0
- package/dist/binaries/{resolvers → package-manager}/npx.js +6 -6
- package/dist/binaries/package-manager/pnpm.d.ts +2 -0
- package/dist/binaries/{resolvers → package-manager}/pnpm.js +6 -3
- package/dist/binaries/package-manager/yarn.d.ts +2 -0
- package/dist/binaries/{resolvers → package-manager}/yarn.js +9 -7
- package/dist/binaries/plugins.d.ts +2 -0
- package/dist/binaries/plugins.js +61 -0
- package/dist/binaries/util.d.ts +0 -2
- package/dist/binaries/util.js +0 -25
- package/dist/compilers/index.d.ts +70 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +2 -1
- package/dist/index.js +74 -46
- package/dist/manifest/helpers.d.ts +1 -5
- package/dist/manifest/helpers.js +8 -7
- package/dist/plugins/_template/index.d.ts +2 -2
- package/dist/plugins/_template/index.js +4 -3
- package/dist/plugins/angular/index.d.ts +1 -1
- package/dist/plugins/angular/index.js +13 -10
- package/dist/plugins/astro/index.d.ts +1 -1
- package/dist/plugins/astro/index.js +6 -5
- package/dist/plugins/ava/index.d.ts +1 -1
- package/dist/plugins/ava/index.js +4 -5
- package/dist/plugins/babel/helpers.js +1 -1
- package/dist/plugins/babel/index.d.ts +3 -2
- package/dist/plugins/babel/index.js +4 -3
- package/dist/plugins/c8/index.d.ts +10 -0
- package/dist/plugins/c8/index.js +11 -0
- package/dist/plugins/capacitor/index.d.ts +1 -1
- package/dist/plugins/capacitor/index.js +5 -4
- package/dist/plugins/changesets/index.d.ts +1 -1
- package/dist/plugins/changesets/index.js +4 -3
- package/dist/plugins/commitizen/index.d.ts +1 -1
- package/dist/plugins/commitizen/index.js +3 -2
- package/dist/plugins/commitlint/index.d.ts +1 -1
- package/dist/plugins/commitlint/index.js +4 -2
- package/dist/plugins/cspell/index.d.ts +1 -1
- package/dist/plugins/cspell/index.js +3 -2
- package/dist/plugins/cucumber/index.d.ts +2 -2
- package/dist/plugins/cucumber/index.js +4 -4
- package/dist/plugins/cypress/helpers.d.ts +1 -1
- package/dist/plugins/cypress/helpers.js +3 -4
- package/dist/plugins/cypress/index.d.ts +1 -1
- package/dist/plugins/cypress/index.js +6 -5
- package/dist/plugins/dotenv/index.d.ts +8 -0
- package/dist/plugins/dotenv/index.js +9 -0
- package/dist/plugins/drizzle/index.d.ts +1 -1
- package/dist/plugins/drizzle/index.js +3 -3
- package/dist/plugins/eleventy/index.d.ts +1 -1
- package/dist/plugins/eleventy/index.js +6 -6
- package/dist/plugins/eslint/helpers.d.ts +4 -5
- package/dist/plugins/eslint/helpers.js +10 -32
- package/dist/plugins/eslint/index.d.ts +1 -1
- package/dist/plugins/eslint/index.js +3 -6
- package/dist/plugins/gatsby/index.d.ts +1 -1
- package/dist/plugins/gatsby/index.js +6 -3
- package/dist/plugins/github-actions/index.d.ts +1 -1
- package/dist/plugins/github-actions/index.js +23 -7
- package/dist/plugins/graphql-codegen/index.d.ts +1 -1
- package/dist/plugins/graphql-codegen/index.js +7 -7
- package/dist/plugins/husky/index.d.ts +1 -1
- package/dist/plugins/husky/index.js +4 -3
- package/dist/plugins/index.d.ts +685 -77
- package/dist/plugins/index.js +170 -77
- package/dist/plugins/jest/index.d.ts +1 -1
- package/dist/plugins/jest/index.js +22 -24
- package/dist/plugins/ladle/index.d.ts +2 -2
- package/dist/plugins/ladle/index.js +4 -4
- package/dist/plugins/lefthook/index.d.ts +1 -1
- package/dist/plugins/lefthook/index.js +18 -14
- package/dist/plugins/lint-staged/index.d.ts +1 -1
- package/dist/plugins/lint-staged/index.js +6 -5
- package/dist/plugins/linthtml/index.d.ts +1 -1
- package/dist/plugins/linthtml/index.js +6 -8
- package/dist/plugins/lockfile-lint/index.d.ts +2 -2
- package/dist/plugins/lockfile-lint/index.js +2 -1
- package/dist/plugins/lost-pixel/index.d.ts +2 -2
- package/dist/plugins/lost-pixel/index.js +1 -1
- package/dist/plugins/markdownlint/index.d.ts +1 -1
- package/dist/plugins/markdownlint/index.js +3 -2
- package/dist/plugins/mocha/index.d.ts +4 -1
- package/dist/plugins/mocha/index.js +8 -4
- package/dist/plugins/moonrepo/index.d.ts +2 -2
- package/dist/plugins/moonrepo/index.js +4 -4
- package/dist/plugins/msw/index.d.ts +1 -1
- package/dist/plugins/msw/index.js +4 -4
- package/dist/plugins/nest/index.d.ts +2 -2
- package/dist/plugins/nest/index.js +4 -3
- package/dist/plugins/netlify/index.d.ts +1 -1
- package/dist/plugins/netlify/index.js +6 -6
- package/dist/plugins/next/index.d.ts +1 -1
- package/dist/plugins/next/index.js +1 -1
- package/dist/plugins/node/index.d.ts +8 -0
- package/dist/plugins/node/index.js +9 -0
- package/dist/plugins/node-test-runner/index.d.ts +1 -1
- package/dist/plugins/nodemon/index.d.ts +10 -0
- package/dist/plugins/nodemon/index.js +11 -0
- package/dist/plugins/npm-package-json-lint/index.d.ts +1 -1
- package/dist/plugins/npm-package-json-lint/index.js +4 -2
- package/dist/plugins/nuxt/index.d.ts +1 -1
- package/dist/plugins/nuxt/index.js +4 -4
- package/dist/plugins/nx/index.d.ts +5 -1
- package/dist/plugins/nx/index.js +10 -8
- package/dist/plugins/nyc/index.d.ts +1 -1
- package/dist/plugins/nyc/index.js +3 -2
- package/dist/plugins/oclif/index.d.ts +2 -2
- package/dist/plugins/oclif/index.js +3 -2
- package/dist/plugins/playwright/index.d.ts +13 -1
- package/dist/plugins/playwright/index.js +13 -6
- package/dist/plugins/playwright-ct/index.d.ts +9 -3
- package/dist/plugins/playwright-ct/index.js +3 -2
- package/dist/plugins/playwright-test/index.d.ts +13 -0
- package/dist/plugins/playwright-test/index.js +16 -0
- package/dist/plugins/postcss/index.d.ts +1 -1
- package/dist/plugins/postcss/index.js +5 -2
- package/dist/plugins/preconstruct/index.d.ts +1 -1
- package/dist/plugins/preconstruct/index.js +3 -3
- package/dist/plugins/prettier/index.d.ts +1 -1
- package/dist/plugins/prettier/index.js +5 -5
- package/dist/plugins/react-cosmos/index.d.ts +2 -2
- package/dist/plugins/react-cosmos/index.js +5 -6
- package/dist/plugins/release-it/index.d.ts +1 -1
- package/dist/plugins/release-it/index.js +4 -3
- package/dist/plugins/remark/index.d.ts +1 -1
- package/dist/plugins/remark/index.js +3 -2
- package/dist/plugins/remix/index.d.ts +1 -1
- package/dist/plugins/remix/index.js +1 -1
- package/dist/plugins/rollup/index.d.ts +3 -1
- package/dist/plugins/rollup/index.js +8 -1
- package/dist/plugins/rsbuild/index.d.ts +2 -2
- package/dist/plugins/rsbuild/index.js +1 -1
- package/dist/plugins/rspack/index.d.ts +2 -2
- package/dist/plugins/rspack/index.js +4 -8
- package/dist/plugins/semantic-release/index.d.ts +1 -1
- package/dist/plugins/semantic-release/index.js +4 -2
- package/dist/plugins/sentry/index.d.ts +1 -1
- package/dist/plugins/sentry/index.js +1 -1
- package/dist/plugins/simple-git-hooks/index.d.ts +2 -2
- package/dist/plugins/simple-git-hooks/index.js +5 -5
- package/dist/plugins/size-limit/index.d.ts +2 -2
- package/dist/plugins/size-limit/index.js +2 -1
- package/dist/plugins/storybook/index.d.ts +1 -1
- package/dist/plugins/storybook/index.js +5 -5
- package/dist/plugins/stryker/index.d.ts +1 -1
- package/dist/plugins/stryker/index.js +3 -2
- package/dist/plugins/stylelint/index.d.ts +1 -1
- package/dist/plugins/stylelint/index.js +4 -3
- package/dist/plugins/svelte/index.d.ts +1 -1
- package/dist/plugins/svelte/index.js +1 -1
- package/dist/plugins/syncpack/index.d.ts +2 -3
- package/dist/plugins/syncpack/index.js +2 -4
- package/dist/plugins/tailwind/index.d.ts +1 -1
- package/dist/plugins/tailwind/index.js +1 -1
- package/dist/plugins/travis/index.d.ts +1 -1
- package/dist/plugins/travis/index.js +3 -4
- package/dist/plugins/ts-node/index.d.ts +15 -0
- package/dist/plugins/ts-node/index.js +12 -0
- package/dist/plugins/tsup/index.d.ts +4 -1
- package/dist/plugins/tsup/index.js +7 -3
- package/dist/plugins/tsx/index.d.ts +9 -0
- package/dist/plugins/tsx/index.js +10 -0
- package/dist/plugins/typedoc/index.d.ts +4 -1
- package/dist/plugins/typedoc/index.js +10 -3
- package/dist/plugins/typedoc/types.d.ts +1 -0
- package/dist/plugins/typescript/index.d.ts +11 -2
- package/dist/plugins/typescript/index.js +19 -34
- package/dist/plugins/unbuild/index.d.ts +1 -1
- package/dist/plugins/unbuild/index.js +3 -3
- package/dist/plugins/unocss/index.d.ts +2 -2
- package/dist/plugins/unocss/index.js +2 -1
- package/dist/plugins/vercel-og/index.d.ts +1 -1
- package/dist/plugins/vercel-og/index.js +1 -1
- package/dist/plugins/vike/index.d.ts +2 -2
- package/dist/plugins/vike/index.js +1 -1
- package/dist/plugins/vite/index.d.ts +3 -3
- package/dist/plugins/vite/index.js +2 -2
- package/dist/plugins/vitest/index.d.ts +4 -1
- package/dist/plugins/vitest/index.js +31 -20
- package/dist/plugins/vue/index.d.ts +1 -1
- package/dist/plugins/vue/index.js +10 -10
- package/dist/plugins/webdriver-io/index.d.ts +1 -1
- package/dist/plugins/webdriver-io/index.js +3 -2
- package/dist/plugins/webpack/index.d.ts +3 -5
- package/dist/plugins/webpack/index.js +18 -19
- package/dist/plugins/wireit/index.d.ts +1 -1
- package/dist/plugins/wireit/index.js +2 -2
- package/dist/plugins/wrangler/index.d.ts +1 -1
- package/dist/plugins/wrangler/index.js +3 -2
- package/dist/plugins/xo/index.d.ts +2 -2
- package/dist/plugins/xo/index.js +4 -4
- package/dist/plugins/yorkie/index.d.ts +1 -1
- package/dist/plugins/yorkie/index.js +6 -5
- package/dist/plugins.d.ts +7 -4
- package/dist/plugins.js +17 -10
- package/dist/reporters/symbols.js +1 -1
- package/dist/types/PluginNames.d.ts +2 -0
- package/dist/types/PluginNames.js +86 -0
- package/dist/types/args.d.ts +14 -0
- package/dist/types/config.d.ts +84 -21
- package/dist/types/package-json.d.ts +10 -0
- package/dist/types/project.d.ts +18 -0
- package/dist/typescript/ast-helpers.d.ts +1 -1
- package/dist/typescript/ast-helpers.js +5 -1
- package/dist/typescript/find-internal-references.d.ts +1 -1
- package/dist/typescript/find-internal-references.js +12 -10
- package/dist/typescript/get-imports-and-exports.d.ts +1 -11
- package/dist/typescript/get-imports-and-exports.js +19 -14
- package/dist/typescript/visitors/dynamic-imports/importCall.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/importType.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/index.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/jsDocType.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/requireCall.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/resolveCall.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportAssignment.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportKeyword.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportKeyword.js +2 -0
- package/dist/typescript/visitors/exports/exportsAccessExpression.d.ts +1 -1
- package/dist/typescript/visitors/exports/index.d.ts +1 -1
- package/dist/typescript/visitors/exports/moduleExportsAccessExpression.d.ts +1 -1
- package/dist/typescript/visitors/imports/importDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/imports/importEqualsDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/imports/index.d.ts +1 -1
- package/dist/typescript/visitors/imports/reExportDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/index.d.ts +1 -1
- package/dist/typescript/visitors/scripts/bun.d.ts +1 -1
- package/dist/typescript/visitors/scripts/execa.d.ts +1 -1
- package/dist/typescript/visitors/scripts/index.d.ts +1 -1
- package/dist/typescript/visitors/scripts/zx.d.ts +1 -1
- package/dist/util/create-workspace-graph.d.ts +1 -1
- package/dist/util/create-workspace-graph.js +7 -7
- package/dist/util/debug.d.ts +2 -2
- package/dist/util/debug.js +1 -1
- package/dist/util/glob.js +2 -2
- package/dist/util/{handle-dependency.d.ts → handle-referenced-dependency.d.ts} +2 -1
- package/dist/util/handle-referenced-dependency.js +82 -0
- package/dist/util/input.d.ts +37 -0
- package/dist/util/input.js +36 -0
- package/dist/util/map-workspaces.d.ts +5 -2
- package/dist/util/map-workspaces.js +6 -6
- package/dist/util/modules.d.ts +1 -0
- package/dist/util/modules.js +4 -3
- package/dist/util/object.d.ts +1 -0
- package/dist/util/object.js +19 -0
- package/dist/util/plugin-config.d.ts +24 -0
- package/dist/util/plugin-config.js +32 -0
- package/dist/util/plugin.d.ts +3 -31
- package/dist/util/plugin.js +9 -54
- package/dist/util/regex.js +3 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -10
- package/schema.json +28 -0
- package/dist/binaries/resolvers/bun.d.ts +0 -2
- package/dist/binaries/resolvers/c8.d.ts +0 -2
- package/dist/binaries/resolvers/c8.js +0 -11
- package/dist/binaries/resolvers/dotenv.d.ts +0 -2
- package/dist/binaries/resolvers/dotenv.js +0 -7
- package/dist/binaries/resolvers/fallback.d.ts +0 -2
- package/dist/binaries/resolvers/fallback.js +0 -26
- package/dist/binaries/resolvers/index.d.ts +0 -15
- package/dist/binaries/resolvers/index.js +0 -26
- package/dist/binaries/resolvers/node.js +0 -11
- package/dist/binaries/resolvers/nodemon.d.ts +0 -2
- package/dist/binaries/resolvers/nodemon.js +0 -16
- package/dist/binaries/resolvers/npx.d.ts +0 -2
- package/dist/binaries/resolvers/nx.d.ts +0 -2
- package/dist/binaries/resolvers/nx.js +0 -9
- package/dist/binaries/resolvers/pnpm.d.ts +0 -2
- package/dist/binaries/resolvers/rollup.d.ts +0 -2
- package/dist/binaries/resolvers/rollup.js +0 -12
- package/dist/binaries/resolvers/ts-node.d.ts +0 -2
- package/dist/binaries/resolvers/ts-node.js +0 -16
- package/dist/binaries/resolvers/tsx.d.ts +0 -2
- package/dist/binaries/resolvers/tsx.js +0 -6
- package/dist/binaries/resolvers/yarn.d.ts +0 -2
- package/dist/binaries/types.d.ts +0 -11
- package/dist/types/plugins.d.ts +0 -42
- package/dist/util/handle-dependency.js +0 -63
- package/dist/util/protocols.d.ts +0 -9
- package/dist/util/protocols.js +0 -9
- /package/dist/{binaries/types.js → types/args.js} +0 -0
- /package/dist/types/{plugins.js → project.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type ts from 'typescript';
|
|
2
|
+
import type { GetImportsAndExportsOptions } from '../../types/config.js';
|
|
2
3
|
import type { ExportNode } from '../../types/exports.js';
|
|
3
4
|
import type { ImportNode } from '../../types/imports.js';
|
|
4
|
-
import type { GetImportsAndExportsOptions } from '../get-imports-and-exports.js';
|
|
5
5
|
type FileCondition = (sourceFile: ts.SourceFile) => boolean;
|
|
6
6
|
type VisitorFactory<T> = (fileCondition: FileCondition, fn: Visitor<T>) => VisitorCondition<T>;
|
|
7
7
|
type VisitorCondition<T> = (sourceFile: ts.SourceFile) => Visitor<T>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../../types/config.js").GetImportsAndExportsOptions) => string | string[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../../types/config.js").GetImportsAndExportsOptions) => string | string[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("../../../types/config.js").GetImportsAndExportsOptions) => string | string[] | undefined)[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("../../../types/config.js").GetImportsAndExportsOptions) => string | string[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -4,5 +4,5 @@ interface Package {
|
|
|
4
4
|
dir: string;
|
|
5
5
|
}
|
|
6
6
|
export type WorkspaceGraph = Record<string, Set<string>>;
|
|
7
|
-
export declare function createWorkspaceGraph(cwd: string, wsNames: string[], wsPkgNames: Set<string>,
|
|
7
|
+
export declare function createWorkspaceGraph(cwd: string, wsNames: string[], wsPkgNames: Set<string>, wsPackages: Map<string, Package>): WorkspaceGraph;
|
|
8
8
|
export {};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { join } from './path.js';
|
|
2
2
|
const types = ['peerDependencies', 'devDependencies', 'optionalDependencies', 'dependencies'];
|
|
3
|
-
export function createWorkspaceGraph(cwd, wsNames, wsPkgNames,
|
|
3
|
+
export function createWorkspaceGraph(cwd, wsNames, wsPkgNames, wsPackages) {
|
|
4
4
|
const graph = {};
|
|
5
|
-
const getWorkspaceDirs = (pkg) => {
|
|
5
|
+
const getWorkspaceDirs = (pkg, name) => {
|
|
6
6
|
const dirs = new Set();
|
|
7
7
|
for (const type of types) {
|
|
8
8
|
if (pkg.manifest[type]) {
|
|
9
9
|
for (const pkgName in pkg.manifest[type]) {
|
|
10
10
|
if (wsPkgNames.has(pkgName)) {
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
13
|
-
dirs.add(
|
|
11
|
+
const wsPackage = wsPackages.get(name);
|
|
12
|
+
if (wsPackage)
|
|
13
|
+
dirs.add(wsPackage.dir);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -18,9 +18,9 @@ export function createWorkspaceGraph(cwd, wsNames, wsPkgNames, byPkgName, byName
|
|
|
18
18
|
return dirs;
|
|
19
19
|
};
|
|
20
20
|
for (const name of wsNames) {
|
|
21
|
-
const pkg =
|
|
21
|
+
const pkg = wsPackages.get(name);
|
|
22
22
|
if (pkg)
|
|
23
|
-
graph[join(cwd, name)] = getWorkspaceDirs(pkg);
|
|
23
|
+
graph[join(cwd, name)] = getWorkspaceDirs(pkg, name);
|
|
24
24
|
}
|
|
25
25
|
return graph;
|
|
26
26
|
}
|
package/dist/util/debug.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const inspect: (obj: unknown) => void;
|
|
2
2
|
export declare const debugLog: (context: string, message: string) => void;
|
|
3
|
-
export declare const debugLogObject: (context: string, name: string, obj: unknown | (() => unknown)) => void;
|
|
4
|
-
export declare const debugLogArray: (context: string | [string, string], message: string, elements: string[] | Set<string>) => void;
|
|
3
|
+
export declare const debugLogObject: (context: string | [string, string], name: string, obj: unknown | (() => unknown)) => void;
|
|
4
|
+
export declare const debugLogArray: (context: string | [string, string], message: string, elements: string[] | Set<string> | (() => string[] | Set<string>)) => void;
|
package/dist/util/debug.js
CHANGED
|
@@ -23,7 +23,7 @@ export const debugLogObject = IS_DEBUG_ENABLED
|
|
|
23
23
|
: noop;
|
|
24
24
|
export const debugLogArray = IS_DEBUG_ENABLED
|
|
25
25
|
? (context, message, elements) => {
|
|
26
|
-
const collection = Array.from(elements);
|
|
26
|
+
const collection = Array.from(typeof elements === 'function' ? elements() : elements);
|
|
27
27
|
console.debug(`${ctx(context)} ${message} (${collection.length})`);
|
|
28
28
|
logArray(collection);
|
|
29
29
|
}
|
package/dist/util/glob.js
CHANGED
|
@@ -3,10 +3,10 @@ import { GLOBAL_IGNORE_PATTERNS } from '../constants.js';
|
|
|
3
3
|
import { timerify } from './Performance.js';
|
|
4
4
|
import { compact } from './array.js';
|
|
5
5
|
import { globby } from './glob-core.js';
|
|
6
|
-
import { join, relative } from './path.js';
|
|
6
|
+
import { isAbsolute, join, relative } from './path.js';
|
|
7
7
|
const prependDirToPatterns = (cwd, dir, patterns) => {
|
|
8
8
|
const relativePath = relative(cwd, dir);
|
|
9
|
-
const prepend = (pattern) => prependDirToPattern(relativePath, pattern);
|
|
9
|
+
const prepend = (pattern) => isAbsolute(pattern.replace(/^!/, '')) ? pattern : prependDirToPattern(relativePath, pattern);
|
|
10
10
|
return compact([patterns].flat().map(prepend).map(removeProductionSuffix)).sort(negatedLast);
|
|
11
11
|
};
|
|
12
12
|
const removeProductionSuffix = (pattern) => pattern.replace(/!$/, '');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ConfigurationChief, Workspace } from '../ConfigurationChief.js';
|
|
2
2
|
import type { DependencyDeputy } from '../DependencyDeputy.js';
|
|
3
3
|
import type { IssueCollector } from '../IssueCollector.js';
|
|
4
|
-
|
|
4
|
+
import { type Input } from './input.js';
|
|
5
|
+
export declare const getReferencedDependencyHandler: (collector: IssueCollector, deputy: DependencyDeputy, chief: ConfigurationChief, isGitIgnored: (s: string) => boolean) => (input: Input, workspace: Workspace) => string | undefined;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { IGNORED_RUNTIME_DEPENDENCIES } from '../constants.js';
|
|
2
|
+
import { debugLog } from './debug.js';
|
|
3
|
+
import { toDebugString } from './input.js';
|
|
4
|
+
import { fromBinary, isBinary, isConfigPattern, isDeferResolveEntry, isDependency } from './input.js';
|
|
5
|
+
import { getPackageNameFromSpecifier } from './modules.js';
|
|
6
|
+
import { dirname, isAbsolute, isInternal, join } from './path.js';
|
|
7
|
+
import { _resolveSync } from './resolve.js';
|
|
8
|
+
export const getReferencedDependencyHandler = (collector, deputy, chief, isGitIgnored) => (input, workspace) => {
|
|
9
|
+
const { specifier, containingFilePath } = input;
|
|
10
|
+
if (!containingFilePath || IGNORED_RUNTIME_DEPENDENCIES.has(specifier))
|
|
11
|
+
return;
|
|
12
|
+
if (isBinary(input)) {
|
|
13
|
+
const binaryName = fromBinary(input);
|
|
14
|
+
const ws = (input.dir && chief.findWorkspaceByFilePath(`${input.dir}/`)) || workspace;
|
|
15
|
+
const isHandled = deputy.maybeAddReferencedBinary(ws, binaryName);
|
|
16
|
+
if (isHandled)
|
|
17
|
+
return;
|
|
18
|
+
collector.addIssue({
|
|
19
|
+
type: 'binaries',
|
|
20
|
+
filePath: containingFilePath,
|
|
21
|
+
workspace: workspace.name,
|
|
22
|
+
symbol: binaryName,
|
|
23
|
+
});
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const packageName = getPackageNameFromSpecifier(specifier);
|
|
27
|
+
if (packageName) {
|
|
28
|
+
const isWorkspace = chief.workspacesByPkgName.has(packageName);
|
|
29
|
+
const specifierWorkspace = chief.findWorkspaceByFilePath(containingFilePath) ?? workspace;
|
|
30
|
+
if (specifierWorkspace) {
|
|
31
|
+
const isHandled = deputy.maybeAddReferencedExternalDependency(specifierWorkspace, packageName);
|
|
32
|
+
if (isWorkspace || isDependency(input)) {
|
|
33
|
+
if (!isHandled) {
|
|
34
|
+
if ((deputy.isProduction && input.production) || !deputy.isProduction) {
|
|
35
|
+
collector.addIssue({
|
|
36
|
+
type: 'unlisted',
|
|
37
|
+
filePath: containingFilePath,
|
|
38
|
+
workspace: specifierWorkspace.name,
|
|
39
|
+
symbol: specifier,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const ref = _resolveSync(specifier, dirname(containingFilePath));
|
|
45
|
+
if (ref && !isGitIgnored(ref))
|
|
46
|
+
return ref;
|
|
47
|
+
}
|
|
48
|
+
if (isHandled)
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (!isConfigPattern(input) && deputy.isProduction && !input.production) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const baseDir = input.dir ?? dirname(containingFilePath);
|
|
56
|
+
const filePath = isAbsolute(specifier) ? specifier : join(baseDir, specifier);
|
|
57
|
+
const resolvedFilePath = _resolveSync(filePath, baseDir);
|
|
58
|
+
if (resolvedFilePath && isInternal(resolvedFilePath)) {
|
|
59
|
+
return isGitIgnored(resolvedFilePath) ? undefined : resolvedFilePath;
|
|
60
|
+
}
|
|
61
|
+
if (!isInternal(filePath)) {
|
|
62
|
+
collector.addIssue({
|
|
63
|
+
type: 'unlisted',
|
|
64
|
+
filePath: containingFilePath,
|
|
65
|
+
workspace: workspace.name,
|
|
66
|
+
symbol: packageName ?? specifier,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
else if (!isGitIgnored(filePath)) {
|
|
70
|
+
if (!isDeferResolveEntry(input) && !isConfigPattern(input)) {
|
|
71
|
+
collector.addIssue({
|
|
72
|
+
type: 'unresolved',
|
|
73
|
+
filePath: containingFilePath,
|
|
74
|
+
workspace: workspace.name,
|
|
75
|
+
symbol: specifier,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
debugLog(workspace.name, `Unable to resolve ${toDebugString(input)}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { PluginName } from '../types/PluginNames.js';
|
|
2
|
+
type InputType = 'binary' | 'entry' | 'config' | 'dependency' | 'deferResolve' | 'deferResolveEntry';
|
|
3
|
+
export interface Input {
|
|
4
|
+
type: InputType;
|
|
5
|
+
specifier: string;
|
|
6
|
+
production?: boolean;
|
|
7
|
+
dir?: string;
|
|
8
|
+
containingFilePath?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ConfigInput extends Input {
|
|
11
|
+
type: 'config';
|
|
12
|
+
containingFilePath: string;
|
|
13
|
+
pluginName: PluginName;
|
|
14
|
+
}
|
|
15
|
+
type Options = {
|
|
16
|
+
production?: boolean;
|
|
17
|
+
dir?: string;
|
|
18
|
+
containingFilePath?: string;
|
|
19
|
+
};
|
|
20
|
+
export declare const fromBinary: (input: Input) => string;
|
|
21
|
+
export declare const toBinary: (specifier: string, options?: Options) => Input;
|
|
22
|
+
export declare const isBinary: (input: Input) => boolean;
|
|
23
|
+
export declare const toEntry: (specifier: string) => Input;
|
|
24
|
+
export declare const isEntry: (input: Input) => boolean;
|
|
25
|
+
export declare const toProductionEntry: (specifier: string, options?: Options) => Input;
|
|
26
|
+
export declare const isProductionEntry: (input: Input) => boolean;
|
|
27
|
+
export declare const toConfig: (pluginName: PluginName, specifier: string, containingFilePath: string) => ConfigInput;
|
|
28
|
+
export declare const isConfigPattern: (input: Input) => input is ConfigInput;
|
|
29
|
+
export declare const toDependency: (specifier: string) => Input;
|
|
30
|
+
export declare const isDependency: (input: Input) => boolean;
|
|
31
|
+
export declare const toProductionDependency: (specifier: string) => Input;
|
|
32
|
+
export declare const toDevDependency: (specifier: string) => Input;
|
|
33
|
+
export declare const toDeferResolve: (specifier: string) => Input;
|
|
34
|
+
export declare const toDeferResolveEntry: (specifier: string) => Input;
|
|
35
|
+
export declare const isDeferResolveEntry: (input: Input) => boolean;
|
|
36
|
+
export declare const toDebugString: (input: Input) => string;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { toRelative } from './path.js';
|
|
2
|
+
export const fromBinary = (input) => input.specifier;
|
|
3
|
+
export const toBinary = (specifier, options = {}) => ({
|
|
4
|
+
type: 'binary',
|
|
5
|
+
specifier,
|
|
6
|
+
...options,
|
|
7
|
+
});
|
|
8
|
+
export const isBinary = (input) => input.type === 'binary';
|
|
9
|
+
export const toEntry = (specifier) => ({ type: 'entry', specifier });
|
|
10
|
+
export const isEntry = (input) => input.type === 'entry' && !input.production;
|
|
11
|
+
export const toProductionEntry = (specifier, options = {}) => ({
|
|
12
|
+
type: 'entry',
|
|
13
|
+
specifier,
|
|
14
|
+
production: true,
|
|
15
|
+
...options,
|
|
16
|
+
});
|
|
17
|
+
export const isProductionEntry = (input) => input.type === 'entry' && input.production === true;
|
|
18
|
+
export const toConfig = (pluginName, specifier, containingFilePath) => ({
|
|
19
|
+
type: 'config',
|
|
20
|
+
specifier,
|
|
21
|
+
pluginName,
|
|
22
|
+
containingFilePath,
|
|
23
|
+
});
|
|
24
|
+
export const isConfigPattern = (input) => input.type === 'config';
|
|
25
|
+
export const toDependency = (specifier) => ({ type: 'dependency', specifier });
|
|
26
|
+
export const isDependency = (input) => input.type === 'dependency';
|
|
27
|
+
export const toProductionDependency = (specifier) => ({
|
|
28
|
+
type: 'dependency',
|
|
29
|
+
specifier,
|
|
30
|
+
production: true,
|
|
31
|
+
});
|
|
32
|
+
export const toDevDependency = (specifier) => ({ type: 'dependency', specifier });
|
|
33
|
+
export const toDeferResolve = (specifier) => ({ type: 'deferResolve', specifier });
|
|
34
|
+
export const toDeferResolveEntry = (specifier) => ({ type: 'deferResolveEntry', specifier });
|
|
35
|
+
export const isDeferResolveEntry = (input) => input.type === 'deferResolveEntry';
|
|
36
|
+
export const toDebugString = (input) => `${input.type}:${input.specifier} ${input.containingFilePath ? `(${toRelative(input.containingFilePath)})` : ''}`;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import type { Package } from '../
|
|
2
|
-
|
|
1
|
+
import type { Package } from '../types/package-json.js';
|
|
2
|
+
type Packages = Map<string, Package>;
|
|
3
|
+
type WorkspacePkgNames = Set<string>;
|
|
4
|
+
export default function mapWorkspaces(cwd: string, workspaces: string[]): Promise<[Packages, WorkspacePkgNames]>;
|
|
5
|
+
export {};
|
|
@@ -7,10 +7,10 @@ import { join } from './path.js';
|
|
|
7
7
|
import { _require } from './require.js';
|
|
8
8
|
export default async function mapWorkspaces(cwd, workspaces) {
|
|
9
9
|
const [negatedPatterns, patterns] = partition(workspaces, p => p.match(/^!/));
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const packages = new Map();
|
|
11
|
+
const wsPkgNames = new Set();
|
|
12
12
|
if (patterns.length === 0 && negatedPatterns.length === 0)
|
|
13
|
-
return [
|
|
13
|
+
return [packages, wsPkgNames];
|
|
14
14
|
const matches = await fg.glob(patterns, {
|
|
15
15
|
cwd,
|
|
16
16
|
onlyDirectories: true,
|
|
@@ -23,9 +23,9 @@ export default async function mapWorkspaces(cwd, workspaces) {
|
|
|
23
23
|
const manifest = _require(filePath);
|
|
24
24
|
const pkgName = getPackageName(manifest, dir);
|
|
25
25
|
const pkg = { dir, name, pkgName, manifest };
|
|
26
|
-
|
|
26
|
+
packages.set(name, pkg);
|
|
27
27
|
if (pkgName)
|
|
28
|
-
|
|
28
|
+
wsPkgNames.add(pkgName);
|
|
29
29
|
else
|
|
30
30
|
throw new ConfigurationError(`Missing package name in ${filePath}`);
|
|
31
31
|
}
|
|
@@ -36,5 +36,5 @@ export default async function mapWorkspaces(cwd, workspaces) {
|
|
|
36
36
|
throw error;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
return [
|
|
39
|
+
return [packages, wsPkgNames];
|
|
40
40
|
}
|
package/dist/util/modules.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const getPackageNameFromModuleSpecifier: (moduleSpecifier: string) => string | undefined;
|
|
2
2
|
export declare const getPackageNameFromFilePath: (value: string) => string;
|
|
3
|
+
export declare const getPackageNameFromSpecifier: (specifier: string) => string | undefined;
|
|
3
4
|
export declare const isStartsLikePackageName: (specifier: string) => boolean;
|
|
4
5
|
export declare const isDefinitelyTyped: (packageName: string) => boolean;
|
|
5
6
|
export declare const getDefinitelyTypedFor: (packageName: string) => string;
|
package/dist/util/modules.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isBuiltin } from 'node:module';
|
|
2
|
-
import { DT_SCOPE } from '../constants.js';
|
|
3
|
-
import { isAbsolute, toPosix } from './path.js';
|
|
2
|
+
import { DT_SCOPE, PROTOCOL_VIRTUAL } from '../constants.js';
|
|
3
|
+
import { isAbsolute, isInNodeModules, toPosix } from './path.js';
|
|
4
4
|
export const getPackageNameFromModuleSpecifier = (moduleSpecifier) => {
|
|
5
5
|
if (!isStartsLikePackageName(moduleSpecifier))
|
|
6
6
|
return;
|
|
@@ -14,6 +14,7 @@ export const getPackageNameFromFilePath = (value) => {
|
|
|
14
14
|
return match[match.length - 1];
|
|
15
15
|
return value;
|
|
16
16
|
};
|
|
17
|
+
export const getPackageNameFromSpecifier = (specifier) => isInNodeModules(specifier) ? getPackageNameFromFilePath(specifier) : getPackageNameFromModuleSpecifier(specifier);
|
|
17
18
|
export const isStartsLikePackageName = (specifier) => /^(@[a-z0-9._]|[a-z0-9])/.test(specifier);
|
|
18
19
|
export const isDefinitelyTyped = (packageName) => packageName.startsWith(`${DT_SCOPE}/`);
|
|
19
20
|
export const getDefinitelyTypedFor = (packageName) => {
|
|
@@ -36,7 +37,7 @@ export const sanitizeSpecifier = (specifier) => {
|
|
|
36
37
|
return specifier;
|
|
37
38
|
if (isAbsolute(specifier))
|
|
38
39
|
return specifier;
|
|
39
|
-
if (specifier.startsWith(
|
|
40
|
+
if (specifier.startsWith(PROTOCOL_VIRTUAL))
|
|
40
41
|
return specifier;
|
|
41
42
|
return specifier.replace(matchDirectives, '$2');
|
|
42
43
|
};
|
package/dist/util/object.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const getValuesByKeyDeep: (obj: any, key: string) => unknown[];
|
|
2
|
+
export declare const findByKeyDeep: <T>(obj: any, key: string) => T[];
|
|
2
3
|
export declare const getStringValues: (obj: any) => string[];
|
|
3
4
|
export declare const getKeysByValue: <T>(obj: T, value: unknown) => (keyof T)[];
|
|
4
5
|
export declare const get: <T>(obj: T, path: string) => any;
|
package/dist/util/object.js
CHANGED
|
@@ -13,6 +13,25 @@ export const getValuesByKeyDeep = (obj, key) => {
|
|
|
13
13
|
}
|
|
14
14
|
return objects;
|
|
15
15
|
};
|
|
16
|
+
export const findByKeyDeep = (obj, key) => {
|
|
17
|
+
const objects = [];
|
|
18
|
+
if (obj && typeof obj === 'object') {
|
|
19
|
+
if (key in obj) {
|
|
20
|
+
objects.push(obj);
|
|
21
|
+
}
|
|
22
|
+
for (const value of Object.values(obj)) {
|
|
23
|
+
if (Array.isArray(value)) {
|
|
24
|
+
for (const item of value) {
|
|
25
|
+
objects.push(...findByKeyDeep(item, key));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else if (typeof value === 'object') {
|
|
29
|
+
objects.push(...findByKeyDeep(value, key));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return objects;
|
|
34
|
+
};
|
|
16
35
|
export const getStringValues = (obj) => {
|
|
17
36
|
if (typeof obj === 'string')
|
|
18
37
|
return [obj];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const toCosmiconfig: (moduleName: string, options?: {
|
|
2
|
+
rcPrefix?: string;
|
|
3
|
+
rcSuffix?: string;
|
|
4
|
+
configDir?: boolean;
|
|
5
|
+
configFiles?: boolean;
|
|
6
|
+
configFilesAllExtensions?: boolean;
|
|
7
|
+
additionalExtensions?: string[];
|
|
8
|
+
}) => string[];
|
|
9
|
+
export declare const toLilconfig: (moduleName: string, options?: {
|
|
10
|
+
rcPrefix?: string;
|
|
11
|
+
rcSuffix?: string;
|
|
12
|
+
configDir?: boolean;
|
|
13
|
+
configFiles?: boolean;
|
|
14
|
+
configFilesAllExtensions?: boolean;
|
|
15
|
+
additionalExtensions?: string[];
|
|
16
|
+
}) => string[];
|
|
17
|
+
export declare const toUnconfig: (moduleName: string, options?: {
|
|
18
|
+
rcPrefix?: string;
|
|
19
|
+
rcSuffix?: string;
|
|
20
|
+
configDir?: boolean;
|
|
21
|
+
configFiles?: boolean;
|
|
22
|
+
configFilesAllExtensions?: boolean;
|
|
23
|
+
additionalExtensions?: string[];
|
|
24
|
+
}) => string[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const toConfigMap = (defaultExtensions, builderConfig) => (moduleName, options) => {
|
|
2
|
+
const config = {
|
|
3
|
+
rcPrefix: '.',
|
|
4
|
+
rcSuffix: 'rc',
|
|
5
|
+
configDir: true,
|
|
6
|
+
configFiles: true,
|
|
7
|
+
configFilesAllExtensions: false,
|
|
8
|
+
additionalExtensions: [],
|
|
9
|
+
...builderConfig,
|
|
10
|
+
...options,
|
|
11
|
+
};
|
|
12
|
+
const { rcPrefix, rcSuffix } = config;
|
|
13
|
+
const jsTypeExtensions = ['js', 'ts', 'cjs', 'mjs', 'cts', 'mts'];
|
|
14
|
+
const extensions = [...defaultExtensions, ...config.additionalExtensions];
|
|
15
|
+
const baseFiles = [
|
|
16
|
+
`${rcPrefix}${moduleName}${rcSuffix}`,
|
|
17
|
+
...(config.configDir ? [`.config/${moduleName}${rcSuffix}`] : []),
|
|
18
|
+
];
|
|
19
|
+
const rcFiles = `${rcPrefix}${moduleName}${rcSuffix}.{${extensions.join(',')}}`;
|
|
20
|
+
const configExtensions = extensions.filter(ext => config.configFilesAllExtensions || jsTypeExtensions.includes(ext));
|
|
21
|
+
const configFiles = config.configFiles ? [`${moduleName}.config.{${configExtensions.join(',')}}`] : [];
|
|
22
|
+
const configDirFiles = config.configDir ? [`.config/${moduleName}${rcSuffix}.{${extensions.join(',')}}`] : [];
|
|
23
|
+
return [...baseFiles, rcFiles, ...configFiles, ...configDirFiles];
|
|
24
|
+
};
|
|
25
|
+
export const toCosmiconfig = toConfigMap(['json', 'yaml', 'yml', 'js', 'ts', 'cjs', 'mjs'], { configDir: true });
|
|
26
|
+
export const toLilconfig = toConfigMap(['json', 'js', 'cjs', 'mjs'], { configDir: true });
|
|
27
|
+
export const toUnconfig = toConfigMap(['json', 'ts', 'mts', 'cts', 'js', 'mjs', 'cjs'], {
|
|
28
|
+
configDir: false,
|
|
29
|
+
rcPrefix: '',
|
|
30
|
+
rcSuffix: '',
|
|
31
|
+
configFiles: false,
|
|
32
|
+
});
|
package/dist/util/plugin.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
export { _getDependenciesFromScripts as getDependenciesFromScripts } from '../binaries/index.js';
|
|
2
1
|
export { _loadJSON as loadJSON } from './fs.js';
|
|
3
2
|
export { _load as load } from './loader.js';
|
|
4
|
-
|
|
5
|
-
import type
|
|
6
|
-
import type { Plugin, PluginOptions } from '../types/plugins.js';
|
|
7
|
-
export declare const toCamelCase: (name: string) => string;
|
|
3
|
+
import type { Plugin, PluginOptions, RawPluginConfiguration } from '../types/config.js';
|
|
4
|
+
import { type Input } from './input.js';
|
|
8
5
|
export declare const hasDependency: (dependencies: Set<string>, values: (string | RegExp)[]) => boolean;
|
|
9
6
|
export declare const normalizePluginConfig: (pluginConfig: RawPluginConfiguration) => boolean | {
|
|
10
7
|
config: string[] | null;
|
|
@@ -12,29 +9,4 @@ export declare const normalizePluginConfig: (pluginConfig: RawPluginConfiguratio
|
|
|
12
9
|
project: string[] | null;
|
|
13
10
|
};
|
|
14
11
|
export declare const loadConfigForPlugin: (configFilePath: string, plugin: Plugin, options: PluginOptions, pluginName: string) => Promise<any>;
|
|
15
|
-
export declare const getFinalEntryPaths: (plugin: Plugin, options: PluginOptions, configEntryPaths:
|
|
16
|
-
export declare const toCosmiconfig: (moduleName: string, options?: {
|
|
17
|
-
rcPrefix?: string;
|
|
18
|
-
rcSuffix?: string;
|
|
19
|
-
configDir?: boolean;
|
|
20
|
-
configFiles?: boolean;
|
|
21
|
-
configFilesAllExtensions?: boolean;
|
|
22
|
-
additionalExtensions?: string[];
|
|
23
|
-
}) => string[];
|
|
24
|
-
export declare const toLilconfig: (moduleName: string, options?: {
|
|
25
|
-
rcPrefix?: string;
|
|
26
|
-
rcSuffix?: string;
|
|
27
|
-
configDir?: boolean;
|
|
28
|
-
configFiles?: boolean;
|
|
29
|
-
configFilesAllExtensions?: boolean;
|
|
30
|
-
additionalExtensions?: string[];
|
|
31
|
-
}) => string[];
|
|
32
|
-
export declare const toUnconfig: (moduleName: string, options?: {
|
|
33
|
-
rcPrefix?: string;
|
|
34
|
-
rcSuffix?: string;
|
|
35
|
-
configDir?: boolean;
|
|
36
|
-
configFiles?: boolean;
|
|
37
|
-
configFilesAllExtensions?: boolean;
|
|
38
|
-
additionalExtensions?: string[];
|
|
39
|
-
}) => string[];
|
|
40
|
-
export declare const resolveEntry: (options: PluginOptions, specifier: string, rootDir?: string) => string;
|
|
12
|
+
export declare const getFinalEntryPaths: (plugin: Plugin, options: PluginOptions, configEntryPaths: Input[]) => Input[];
|
package/dist/util/plugin.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
export { _getDependenciesFromScripts as getDependenciesFromScripts } from '../binaries/index.js';
|
|
2
1
|
export { _loadJSON as loadJSON } from './fs.js';
|
|
3
2
|
export { _load as load } from './loader.js';
|
|
4
|
-
export { _resolveSync as resolve } from './resolve.js';
|
|
5
3
|
import { arrayify } from './array.js';
|
|
4
|
+
import { toEntry, toProductionEntry } from './input.js';
|
|
6
5
|
import { _load as load } from './loader.js';
|
|
7
6
|
import { get } from './object.js';
|
|
8
|
-
import { basename
|
|
9
|
-
import { toEntryPattern, toProductionEntryPattern } from './protocols.js';
|
|
10
|
-
import { _resolveSync } from './resolve.js';
|
|
11
|
-
export const toCamelCase = (name) => name.toLowerCase().replace(/(-[a-z])/g, group => group.toUpperCase().replace('-', ''));
|
|
7
|
+
import { basename } from './path.js';
|
|
12
8
|
export const hasDependency = (dependencies, values) => values.some(value => {
|
|
13
9
|
if (typeof value === 'string') {
|
|
14
10
|
return dependencies.has(value);
|
|
@@ -50,52 +46,11 @@ export const loadConfigForPlugin = async (configFilePath, plugin, options, plugi
|
|
|
50
46
|
export const getFinalEntryPaths = (plugin, options, configEntryPaths) => {
|
|
51
47
|
const { config, isProduction } = options;
|
|
52
48
|
if (plugin.title === 'Storybook')
|
|
53
|
-
return [...(config.entry ?? []).map(
|
|
54
|
-
const toEntryPathProtocol = isProduction && plugin.production && plugin.production.length > 0 ?
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
};
|
|
61
|
-
const toConfigMap = (defaultExtensions, builderConfig) => (moduleName, options) => {
|
|
62
|
-
const config = {
|
|
63
|
-
rcPrefix: '.',
|
|
64
|
-
rcSuffix: 'rc',
|
|
65
|
-
configDir: true,
|
|
66
|
-
configFiles: true,
|
|
67
|
-
configFilesAllExtensions: false,
|
|
68
|
-
additionalExtensions: [],
|
|
69
|
-
...builderConfig,
|
|
70
|
-
...options,
|
|
71
|
-
};
|
|
72
|
-
const { rcPrefix, rcSuffix } = config;
|
|
73
|
-
const jsTypeExtensions = ['js', 'ts', 'cjs', 'mjs', 'cts', 'mts'];
|
|
74
|
-
const extensions = [...defaultExtensions, ...config.additionalExtensions];
|
|
75
|
-
const baseFiles = [
|
|
76
|
-
`${rcPrefix}${moduleName}${rcSuffix}`,
|
|
77
|
-
...(config.configDir ? [`.config/${moduleName}${rcSuffix}`] : []),
|
|
78
|
-
];
|
|
79
|
-
const rcFiles = `${rcPrefix}${moduleName}${rcSuffix}.{${extensions.join(',')}}`;
|
|
80
|
-
const configExtensions = extensions.filter(ext => config.configFilesAllExtensions || jsTypeExtensions.includes(ext));
|
|
81
|
-
const configFiles = config.configFiles ? [`${moduleName}.config.{${configExtensions.join(',')}}`] : [];
|
|
82
|
-
const configDirFiles = config.configDir ? [`.config/${moduleName}${rcSuffix}.{${extensions.join(',')}}`] : [];
|
|
83
|
-
return [...baseFiles, rcFiles, ...configFiles, ...configDirFiles];
|
|
84
|
-
};
|
|
85
|
-
export const toCosmiconfig = toConfigMap(['json', 'yaml', 'yml', 'js', 'ts', 'cjs', 'mjs'], { configDir: true });
|
|
86
|
-
export const toLilconfig = toConfigMap(['json', 'js', 'cjs', 'mjs'], { configDir: true });
|
|
87
|
-
export const toUnconfig = toConfigMap(['json', 'ts', 'mts', 'cts', 'js', 'mjs', 'cjs'], {
|
|
88
|
-
configDir: false,
|
|
89
|
-
rcPrefix: '',
|
|
90
|
-
rcSuffix: '',
|
|
91
|
-
configFiles: false,
|
|
92
|
-
});
|
|
93
|
-
export const resolveEntry = (options, specifier, rootDir = '.') => {
|
|
94
|
-
const { configFileDir } = options;
|
|
95
|
-
const resolvedPath = isAbsolute(specifier)
|
|
96
|
-
? specifier
|
|
97
|
-
: _resolveSync(join(configFileDir, rootDir, specifier), join(configFileDir, rootDir));
|
|
98
|
-
if (resolvedPath)
|
|
99
|
-
return toEntryPattern(relative(configFileDir, resolvedPath));
|
|
100
|
-
return specifier;
|
|
49
|
+
return [...(config.entry ?? []).map(toEntry), ...configEntryPaths];
|
|
50
|
+
const toEntryPathProtocol = isProduction && plugin.production && plugin.production.length > 0 ? toProductionEntry : toEntry;
|
|
51
|
+
if (config.entry)
|
|
52
|
+
return config.entry.map(id => toEntryPathProtocol(id));
|
|
53
|
+
if (configEntryPaths.length > 0)
|
|
54
|
+
return configEntryPaths;
|
|
55
|
+
return [...(plugin.entry ?? []).map(toEntry), ...(plugin.production ?? []).map(id => toProductionEntry(id))];
|
|
101
56
|
};
|
package/dist/util/regex.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
1
|
+
const isRegexLikeMatch = /[*+\\(|{^$]/;
|
|
2
|
+
const isRegexLike = (value) => isRegexLikeMatch.test(value);
|
|
3
|
+
export const toRegexOrString = (value) => typeof value === 'string' && isRegexLike(value) ? new RegExp(value) : value;
|
|
3
4
|
export const findMatch = (haystack, needle) => haystack?.find(n => (typeof n === 'string' ? n === needle : n.test(needle)));
|
|
4
5
|
const idCharMatch = /[a-zA-Z0-9$_]/;
|
|
5
6
|
export const isIdChar = (text) => idCharMatch.test(text);
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.
|
|
1
|
+
export declare const version = "5.34.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.
|
|
1
|
+
export const version = '5.34.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.34.0",
|
|
4
4
|
"description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
|
|
5
5
|
"homepage": "https://knip.dev",
|
|
6
6
|
"repository": {
|
|
@@ -35,10 +35,6 @@
|
|
|
35
35
|
},
|
|
36
36
|
"type": "module",
|
|
37
37
|
"types": "./dist/index.d.ts",
|
|
38
|
-
"imports": {
|
|
39
|
-
"#p/*.ts": "./src/*.ts",
|
|
40
|
-
"#p/*.js": "./dist/*.js"
|
|
41
|
-
},
|
|
42
38
|
"scripts": {
|
|
43
39
|
"knip": "node ./dist/cli.js --directory ../..",
|
|
44
40
|
"knip:production": "node ./dist/cli.js --directory ../.. --production --strict",
|
|
@@ -52,7 +48,8 @@
|
|
|
52
48
|
"qa": "bun lint && bun run build && bun knip && bun knip:production && bun run test",
|
|
53
49
|
"release": "release-it",
|
|
54
50
|
"create-plugin": "bun ./scripts/create-new-plugin.ts",
|
|
55
|
-
"postcreate-plugin": "biome format --write schema.json schema-jsonc.json src/ConfigurationValidator.ts"
|
|
51
|
+
"postcreate-plugin": "biome format --write schema.json schema-jsonc.json src/ConfigurationValidator.ts",
|
|
52
|
+
"generate-plugin-types": "bun ./scripts/generate-plugin-types.ts"
|
|
56
53
|
},
|
|
57
54
|
"files": [
|
|
58
55
|
"dist",
|
|
@@ -85,15 +82,15 @@
|
|
|
85
82
|
"devDependencies": {
|
|
86
83
|
"@jest/types": "^29.6.3",
|
|
87
84
|
"@release-it/bumper": "^6.0.1",
|
|
88
|
-
"@types/bun": "^1.1.
|
|
85
|
+
"@types/bun": "^1.1.11",
|
|
89
86
|
"@types/js-yaml": "^4.0.9",
|
|
90
87
|
"@types/minimist": "^1.2.5",
|
|
91
88
|
"@types/picomatch": "3.0.1",
|
|
92
89
|
"@types/webpack": "^5.28.5",
|
|
93
|
-
"@wdio/types": "^9.1.
|
|
90
|
+
"@wdio/types": "^9.1.3",
|
|
94
91
|
"glob": "^10.4.2",
|
|
95
|
-
"release-it": "^17.
|
|
96
|
-
"type-fest": "^4.
|
|
92
|
+
"release-it": "^17.10.0",
|
|
93
|
+
"type-fest": "^4.26.1",
|
|
97
94
|
"typescript": "^5.5.2"
|
|
98
95
|
},
|
|
99
96
|
"engines": {
|