knip 2.0.0-beta.1 → 2.0.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/README.md +114 -64
- package/dist/binaries/resolvers/fallback.js +6 -5
- package/dist/binaries/resolvers/index.d.ts +1 -0
- package/dist/binaries/resolvers/index.js +1 -0
- package/dist/binaries/resolvers/node.d.ts +0 -1
- package/dist/binaries/resolvers/node.js +1 -15
- package/dist/binaries/resolvers/rollup.js +10 -0
- package/dist/binaries/resolvers/util.d.ts +2 -0
- package/dist/binaries/resolvers/util.js +15 -0
- package/dist/cli.js +0 -0
- package/dist/configuration-chief.js +3 -5
- package/dist/configuration-validator.d.ts +400 -8
- package/dist/configuration-validator.js +7 -0
- package/dist/plugins/eslint/helpers.js +9 -9
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/tailwind/index.d.ts +5 -0
- package/dist/plugins/tailwind/index.js +5 -0
- package/dist/project-principal.js +0 -2
- package/dist/types/ast.d.ts +1 -1
- package/dist/types/issues.d.ts +9 -1
- package/dist/types/issues.js +10 -1
- package/dist/typescript/ast-walker.js +17 -16
- package/dist/typescript/resolveModuleNames.js +0 -4
- package/dist/util/cli-arguments.d.ts +1 -2
- package/dist/util/cli-arguments.js +1 -3
- package/dist/util/compilers.d.ts +72 -2
- package/dist/util/performance.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/workspace-worker.d.ts +1 -1
- package/package.json +12 -10
- package/schema.json +4 -0
- package/dist/commonjs.test.d.ts +0 -1
- package/dist/commonjs.test.js +0 -29
- package/dist/compilers.test.d.ts +0 -1
- package/dist/compilers.test.js +0 -18
- package/dist/definitely-typed.test.d.ts +0 -1
- package/dist/definitely-typed.test.js +0 -35
- package/dist/dependencies.test.d.ts +0 -1
- package/dist/dependencies.test.js +0 -76
- package/dist/entry-js.test.d.ts +0 -1
- package/dist/entry-js.test.js +0 -38
- package/dist/exports.test.d.ts +0 -1
- package/dist/exports.test.js +0 -48
- package/dist/fixtures/binaries/dir/index.d.ts +0 -1
- package/dist/fixtures/binaries/dir/index.js +0 -1
- package/dist/fixtures/binaries/main.d.ts +0 -1
- package/dist/fixtures/binaries/main.js +0 -1
- package/dist/fixtures/binaries/require.d.ts +0 -1
- package/dist/fixtures/binaries/require.js +0 -1
- package/dist/fixtures/binaries/script.d.ts +0 -1
- package/dist/fixtures/binaries/script.js +0 -1
- package/dist/fixtures/commonjs/dir/mod.d.ts +0 -1
- package/dist/fixtures/commonjs/dir/mod.js +0 -5
- package/dist/fixtures/commonjs/dir/mod1.d.ts +0 -7
- package/dist/fixtures/commonjs/dir/mod1.js +0 -5
- package/dist/fixtures/commonjs/dir/mod2.d.ts +0 -4
- package/dist/fixtures/commonjs/dir/mod2.js +0 -4
- package/dist/fixtures/commonjs/dir/mod3.d.ts +0 -2
- package/dist/fixtures/commonjs/dir/mod3.js +0 -4
- package/dist/fixtures/commonjs/export-is.d.ts +0 -2
- package/dist/fixtures/commonjs/export-is.js +0 -2
- package/dist/fixtures/commonjs/index.d.ts +0 -1
- package/dist/fixtures/commonjs/index.js +0 -31
- package/dist/fixtures/commonjs/odd.d.ts +0 -1
- package/dist/fixtures/commonjs/odd.js +0 -7
- package/dist/fixtures/compilers/component.d.ts +0 -2
- package/dist/fixtures/compilers/component.jsx +0 -1
- package/dist/fixtures/compilers/index.d.ts +0 -1
- package/dist/fixtures/compilers/index.js +0 -1
- package/dist/fixtures/compilers/knip.d.ts +0 -0
- package/dist/fixtures/compilers/knip.js +0 -7
- package/dist/fixtures/definitely-typed/index.d.ts +0 -1
- package/dist/fixtures/definitely-typed/index.js +0 -1
- package/dist/fixtures/dependencies/entry.d.ts +0 -1
- package/dist/fixtures/dependencies/entry.js +0 -6
- package/dist/fixtures/dependencies/my-module.d.ts +0 -3
- package/dist/fixtures/dependencies/my-module.js +0 -6
- package/dist/fixtures/dependencies/unused-module.d.ts +0 -1
- package/dist/fixtures/dependencies/unused-module.js +0 -6
- package/dist/fixtures/entry-js/dangling.d.ts +0 -1
- package/dist/fixtures/entry-js/dangling.js +0 -1
- package/dist/fixtures/entry-js/index.d.ts +0 -1
- package/dist/fixtures/entry-js/index.js +0 -2
- package/dist/fixtures/entry-js/my-module.d.ts +0 -4
- package/dist/fixtures/entry-js/my-module.js +0 -6
- package/dist/fixtures/entry-js/my-namespace.d.ts +0 -5
- package/dist/fixtures/entry-js/my-namespace.js +0 -3
- package/dist/fixtures/exports/dangling.d.ts +0 -1
- package/dist/fixtures/exports/dangling.js +0 -1
- package/dist/fixtures/exports/default-arrow-function.d.ts +0 -2
- package/dist/fixtures/exports/default-arrow-function.js +0 -1
- package/dist/fixtures/exports/default-class.d.ts +0 -2
- package/dist/fixtures/exports/default-class.js +0 -2
- package/dist/fixtures/exports/default-function.d.ts +0 -1
- package/dist/fixtures/exports/default-function.js +0 -1
- package/dist/fixtures/exports/default-generator-function.d.ts +0 -1
- package/dist/fixtures/exports/default-generator-function.js +0 -1
- package/dist/fixtures/exports/default-named-class.d.ts +0 -2
- package/dist/fixtures/exports/default-named-class.js +0 -2
- package/dist/fixtures/exports/default-named-function.d.ts +0 -1
- package/dist/fixtures/exports/default-named-function.js +0 -1
- package/dist/fixtures/exports/default-named-generator-function.d.ts +0 -1
- package/dist/fixtures/exports/default-named-generator-function.js +0 -1
- package/dist/fixtures/exports/default.d.ts +0 -3
- package/dist/fixtures/exports/default.js +0 -2
- package/dist/fixtures/exports/dynamic-import.d.ts +0 -4
- package/dist/fixtures/exports/dynamic-import.js +0 -3
- package/dist/fixtures/exports/index.d.ts +0 -2
- package/dist/fixtures/exports/index.js +0 -6
- package/dist/fixtures/exports/my-module.d.ts +0 -5
- package/dist/fixtures/exports/my-module.js +0 -7
- package/dist/fixtures/exports/my-namespace.d.ts +0 -5
- package/dist/fixtures/exports/my-namespace.js +0 -3
- package/dist/fixtures/exports/named.d.ts +0 -11
- package/dist/fixtures/exports/named.js +0 -11
- package/dist/fixtures/exports/types.d.ts +0 -9
- package/dist/fixtures/exports/types.js +0 -3
- package/dist/fixtures/gitignore/packages/a/build/dist.d.ts +0 -2
- package/dist/fixtures/gitignore/packages/a/build/dist.js +0 -1
- package/dist/fixtures/gitignore/packages/a/dist.d.ts +0 -1
- package/dist/fixtures/gitignore/packages/a/dist.js +0 -1
- package/dist/fixtures/gitignore/packages/a/index.d.ts +0 -1
- package/dist/fixtures/gitignore/packages/a/index.js +0 -1
- package/dist/fixtures/imports/dir/import-b.d.ts +0 -2
- package/dist/fixtures/imports/dir/import-b.js +0 -1
- package/dist/fixtures/imports/dir/mod.d.ts +0 -1
- package/dist/fixtures/imports/dir/mod.js +0 -1
- package/dist/fixtures/imports/index.d.ts +0 -1
- package/dist/fixtures/imports/index.js +0 -35
- package/dist/fixtures/js-only/dangling.d.ts +0 -1
- package/dist/fixtures/js-only/dangling.js +0 -1
- package/dist/fixtures/js-only/index.d.ts +0 -1
- package/dist/fixtures/js-only/index.js +0 -2
- package/dist/fixtures/js-only/my-namespace.d.ts +0 -3
- package/dist/fixtures/js-only/my-namespace.js +0 -3
- package/dist/fixtures/jsdoc/index.d.ts +0 -4
- package/dist/fixtures/jsdoc/index.js +0 -8
- package/dist/fixtures/members/index.d.ts +0 -1
- package/dist/fixtures/members/index.js +0 -16
- package/dist/fixtures/members/members.d.ts +0 -23
- package/dist/fixtures/members/members.js +0 -38
- package/dist/fixtures/namespace/index.d.ts +0 -1
- package/dist/fixtures/namespace/index.js +0 -5
- package/dist/fixtures/namespace/namespace.d.ts +0 -3
- package/dist/fixtures/namespace/namespace.js +0 -3
- package/dist/fixtures/namespace/re-exported-module.d.ts +0 -2
- package/dist/fixtures/namespace/re-exported-module.js +0 -2
- package/dist/fixtures/pathless/src/dir/module-a.d.ts +0 -2
- package/dist/fixtures/pathless/src/dir/module-a.js +0 -1
- package/dist/fixtures/pathless/src/index.d.ts +0 -2
- package/dist/fixtures/pathless/src/index.js +0 -2
- package/dist/fixtures/pathless/src/same.d.ts +0 -2
- package/dist/fixtures/pathless/src/same.js +0 -1
- package/dist/fixtures/paths-knip-config/abc/main.d.ts +0 -0
- package/dist/fixtures/paths-knip-config/abc/main.js +0 -1
- package/dist/fixtures/paths-knip-config/index.d.ts +0 -1
- package/dist/fixtures/paths-knip-config/index.js +0 -1
- package/dist/fixtures/paths-knip-config/knip.d.ts +0 -3
- package/dist/fixtures/paths-knip-config/knip.js +0 -9
- package/dist/fixtures/paths-knip-config/lib/fn.d.ts +0 -2
- package/dist/fixtures/paths-knip-config/lib/fn.js +0 -1
- package/dist/fixtures/paths-knip-config/lib/index.d.ts +0 -2
- package/dist/fixtures/paths-knip-config/lib/index.js +0 -1
- package/dist/fixtures/paths-knip-config/my-module.d.ts +0 -2
- package/dist/fixtures/paths-knip-config/my-module.js +0 -1
- package/dist/fixtures/paths-knip-config-workspaces/index.d.ts +0 -1
- package/dist/fixtures/paths-knip-config-workspaces/index.js +0 -1
- package/dist/fixtures/paths-knip-config-workspaces/lib/fn.d.ts +0 -2
- package/dist/fixtures/paths-knip-config-workspaces/lib/fn.js +0 -1
- package/dist/fixtures/paths-knip-config-workspaces/lib/index.d.ts +0 -2
- package/dist/fixtures/paths-knip-config-workspaces/lib/index.js +0 -1
- package/dist/fixtures/paths-knip-config-workspaces/my-module.d.ts +0 -1
- package/dist/fixtures/paths-knip-config-workspaces/my-module.js +0 -1
- package/dist/fixtures/paths-knip-config-workspaces/ws/index.d.ts +0 -1
- package/dist/fixtures/paths-knip-config-workspaces/ws/index.js +0 -1
- package/dist/fixtures/paths-knip-config-workspaces/ws/lib/main.d.ts +0 -0
- package/dist/fixtures/paths-knip-config-workspaces/ws/lib/main.js +0 -1
- package/dist/fixtures/paths-knip-config-workspaces/ws/util/lang.d.ts +0 -2
- package/dist/fixtures/paths-knip-config-workspaces/ws/util/lang.js +0 -1
- package/dist/fixtures/peer-dependencies/index.d.ts +0 -1
- package/dist/fixtures/peer-dependencies/index.js +0 -1
- package/dist/fixtures/plugins/ava/ava.config.d.mts +0 -13
- package/dist/fixtures/plugins/ava/ava.config.mjs +0 -13
- package/dist/fixtures/plugins/babel/babel.config.d.ts +0 -14
- package/dist/fixtures/plugins/babel/babel.config.js +0 -47
- package/dist/fixtures/plugins/capacitor/capacitor.config.d.ts +0 -3
- package/dist/fixtures/plugins/capacitor/capacitor.config.js +0 -15
- package/dist/fixtures/plugins/commitlint/commitlint.config.d.ts +0 -2
- package/dist/fixtures/plugins/commitlint/commitlint.config.js +0 -2
- package/dist/fixtures/plugins/cypress/cypress/support/commands.d.ts +0 -1
- package/dist/fixtures/plugins/cypress/cypress/support/commands.js +0 -5
- package/dist/fixtures/plugins/cypress/cypress/support/e2e.d.ts +0 -2
- package/dist/fixtures/plugins/cypress/cypress/support/e2e.js +0 -2
- package/dist/fixtures/plugins/cypress/cypress.config.d.ts +0 -2
- package/dist/fixtures/plugins/cypress/cypress.config.js +0 -9
- package/dist/fixtures/plugins/eslint/eslint.config.d.ts +0 -7
- package/dist/fixtures/plugins/eslint/eslint.config.js +0 -11
- package/dist/fixtures/plugins/eslint/index.d.ts +0 -1
- package/dist/fixtures/plugins/eslint/index.js +0 -1
- package/dist/fixtures/plugins/gatsby/gatsby-config.d.ts +0 -17
- package/dist/fixtures/plugins/gatsby/gatsby-config.js +0 -40
- package/dist/fixtures/plugins/gatsby/gatsby-node.d.ts +0 -3
- package/dist/fixtures/plugins/gatsby/gatsby-node.js +0 -15
- package/dist/fixtures/plugins/github-actions/comment.d.ts +0 -0
- package/dist/fixtures/plugins/github-actions/comment.js +0 -1
- package/dist/fixtures/plugins/github-actions/scripts/check-dependencies.d.ts +0 -0
- package/dist/fixtures/plugins/github-actions/scripts/check-dependencies.js +0 -1
- package/dist/fixtures/plugins/jest/jest.config.d.ts +0 -2
- package/dist/fixtures/plugins/jest/jest.config.js +0 -7
- package/dist/fixtures/plugins/jest/jest.config.shared.d.ts +0 -2
- package/dist/fixtures/plugins/jest/jest.config.shared.js +0 -15
- package/dist/fixtures/plugins/jest/jest.setup.d.ts +0 -1
- package/dist/fixtures/plugins/jest/jest.setup.js +0 -1
- package/dist/fixtures/plugins/jest/jest.transform.d.ts +0 -1
- package/dist/fixtures/plugins/jest/jest.transform.js +0 -2
- package/dist/fixtures/plugins/lefthook/example.d.mts +0 -2
- package/dist/fixtures/plugins/lefthook/example.mjs +0 -1
- package/dist/fixtures/plugins/next/next.config.d.ts +0 -2
- package/dist/fixtures/plugins/next/next.config.js +0 -9
- package/dist/fixtures/plugins/next/pages/[[...route]].d.ts +0 -3
- package/dist/fixtures/plugins/next/pages/[[...route]].jsx +0 -3
- package/dist/fixtures/plugins/next/pages/page.d.ts +0 -3
- package/dist/fixtures/plugins/next/pages/page.jsx +0 -3
- package/dist/fixtures/plugins/playwright/playwright.config.d.ts +0 -3
- package/dist/fixtures/plugins/playwright/playwright.config.js +0 -10
- package/dist/fixtures/plugins/playwright/test/some.spec.d.ts +0 -1
- package/dist/fixtures/plugins/playwright/test/some.spec.js +0 -6
- package/dist/fixtures/plugins/postcss/postcss.config.d.ts +0 -1
- package/dist/fixtures/plugins/postcss/postcss.config.js +0 -4
- package/dist/fixtures/plugins/remix/app/entry.client.d.ts +0 -1
- package/dist/fixtures/plugins/remix/app/entry.client.jsx +0 -11
- package/dist/fixtures/plugins/remix/app/entry.server.jsx +0 -3
- package/dist/fixtures/plugins/remix/app/root.d.ts +0 -5
- package/dist/fixtures/plugins/remix/app/root.jsx +0 -31
- package/dist/fixtures/plugins/remix/app/routes/index.d.ts +0 -1
- package/dist/fixtures/plugins/remix/app/routes/index.jsx +0 -8
- package/dist/fixtures/plugins/remix/app/utils.d.ts +0 -1
- package/dist/fixtures/plugins/remix/app/utils.js +0 -1
- package/dist/fixtures/plugins/remix/remix.config.d.ts +0 -2
- package/dist/fixtures/plugins/remix/remix.config.js +0 -5
- package/dist/fixtures/plugins/remix/remix.init/index.d.ts +0 -4
- package/dist/fixtures/plugins/remix/remix.init/index.js +0 -4
- package/dist/fixtures/plugins/remix/server.d.ts +0 -0
- package/dist/fixtures/plugins/remix/server.js +0 -1
- package/dist/fixtures/plugins/rollup/rollup.config.d.ts +0 -16
- package/dist/fixtures/plugins/rollup/rollup.config.js +0 -26
- package/dist/fixtures/plugins/sentry/sentry.client.config.d.ts +0 -1
- package/dist/fixtures/plugins/sentry/sentry.client.config.js +0 -6
- package/dist/fixtures/plugins/sentry/sentry.server.config.d.ts +0 -1
- package/dist/fixtures/plugins/sentry/sentry.server.config.js +0 -1
- package/dist/fixtures/plugins/storybook/addon/register.d.ts +0 -0
- package/dist/fixtures/plugins/storybook/addon/register.js +0 -1
- package/dist/fixtures/plugins/storybook/main.d.ts +0 -10
- package/dist/fixtures/plugins/storybook/main.js +0 -38
- package/dist/fixtures/plugins/storybook/preview.d.ts +0 -13
- package/dist/fixtures/plugins/storybook/preview.js +0 -14
- package/dist/fixtures/plugins/stryker/stryker.conf.cjs +0 -6
- package/dist/fixtures/plugins/stryker/stryker.conf.d.cts +0 -3
- package/dist/fixtures/plugins/stryker/stryker.conf.d.mts +0 -6
- package/dist/fixtures/plugins/stryker/stryker.conf.mjs +0 -6
- package/dist/fixtures/plugins/svelte/knip.d.ts +0 -11
- package/dist/fixtures/plugins/svelte/knip.js +0 -10
- package/dist/fixtures/plugins/svelte/src/routes/+page.d.ts +0 -1
- package/dist/fixtures/plugins/svelte/src/routes/+page.js +0 -1
- package/dist/fixtures/plugins/svelte/svelte.config.d.ts +0 -2
- package/dist/fixtures/plugins/svelte/svelte.config.js +0 -9
- package/dist/fixtures/plugins/svelte/vite.config.d.ts +0 -2
- package/dist/fixtures/plugins/svelte/vite.config.js +0 -5
- package/dist/fixtures/plugins/vitest/test/basic.spec.d.ts +0 -1
- package/dist/fixtures/plugins/vitest/test/basic.spec.js +0 -8
- package/dist/fixtures/plugins/vitest/vite.config.d.ts +0 -2
- package/dist/fixtures/plugins/vitest/vite.config.js +0 -10
- package/dist/fixtures/plugins/vitest/vitest.config.d.ts +0 -2
- package/dist/fixtures/plugins/vitest/vitest.config.js +0 -10
- package/dist/fixtures/plugins/webpack/merge.d.ts +0 -2
- package/dist/fixtures/plugins/webpack/merge.js +0 -9
- package/dist/fixtures/plugins/webpack/src/app-dep.d.ts +0 -2
- package/dist/fixtures/plugins/webpack/src/app-dep.js +0 -1
- package/dist/fixtures/plugins/webpack/src/app.d.ts +0 -1
- package/dist/fixtures/plugins/webpack/src/app.js +0 -1
- package/dist/fixtures/plugins/webpack/src/entry.d.ts +0 -0
- package/dist/fixtures/plugins/webpack/src/entry.js +0 -1
- package/dist/fixtures/plugins/webpack/src/unused.d.ts +0 -0
- package/dist/fixtures/plugins/webpack/src/unused.js +0 -1
- package/dist/fixtures/plugins/webpack/src/vendor.d.ts +0 -0
- package/dist/fixtures/plugins/webpack/src/vendor.js +0 -1
- package/dist/fixtures/plugins/webpack/webpack.common.d.ts +0 -65
- package/dist/fixtures/plugins/webpack/webpack.common.js +0 -81
- package/dist/fixtures/plugins/webpack/webpack.config.d.ts +0 -2
- package/dist/fixtures/plugins/webpack/webpack.config.js +0 -4
- package/dist/fixtures/plugins/webpack/webpack.dev.d.ts +0 -2
- package/dist/fixtures/plugins/webpack/webpack.dev.js +0 -19
- package/dist/fixtures/plugins/webpack/webpack.prod.d.ts +0 -2
- package/dist/fixtures/plugins/webpack/webpack.prod.js +0 -16
- package/dist/fixtures/re-exports/barrel.d.ts +0 -1
- package/dist/fixtures/re-exports/barrel.js +0 -1
- package/dist/fixtures/re-exports/entry.d.ts +0 -1
- package/dist/fixtures/re-exports/entry.js +0 -2
- package/dist/fixtures/re-exports/my-module.d.ts +0 -4
- package/dist/fixtures/re-exports/my-module.js +0 -6
- package/dist/fixtures/react/App.d.ts +0 -1
- package/dist/fixtures/react/App.jsx +0 -7
- package/dist/fixtures/react/Component.d.ts +0 -1
- package/dist/fixtures/react/Component.jsx +0 -4
- package/dist/fixtures/self-reference/entry.d.ts +0 -1
- package/dist/fixtures/self-reference/entry.js +0 -8
- package/dist/fixtures/self-reference/lib/module.d.ts +0 -2
- package/dist/fixtures/self-reference/lib/module.js +0 -1
- package/dist/fixtures/self-reference/out/entry.d.ts +0 -1
- package/dist/fixtures/self-reference/out/entry.js +0 -11
- package/dist/fixtures/self-reference/out/lib/module.d.mts +0 -3
- package/dist/fixtures/self-reference/out/lib/module.mjs +0 -4
- package/dist/fixtures/self-reference-from-plugin/entry.d.ts +0 -0
- package/dist/fixtures/self-reference-from-plugin/entry.js +0 -2
- package/dist/fixtures/self-reference-from-plugin/file.d.ts +0 -2
- package/dist/fixtures/self-reference-from-plugin/file.js +0 -1
- package/dist/fixtures/tsconfig-paths/aliased-dir/a.d.ts +0 -1
- package/dist/fixtures/tsconfig-paths/aliased-dir/a.js +0 -1
- package/dist/fixtures/tsconfig-paths/index.d.ts +0 -1
- package/dist/fixtures/tsconfig-paths/index.js +0 -6
- package/dist/fixtures/tsconfig-paths/internal-package/index.d.ts +0 -2
- package/dist/fixtures/tsconfig-paths/internal-package/index.js +0 -2
- package/dist/fixtures/tsconfig-paths/unprefixed/module.d.ts +0 -2
- package/dist/fixtures/tsconfig-paths/unprefixed/module.js +0 -2
- package/dist/fixtures/tsconfig-paths-extends/src/cli.d.ts +0 -1
- package/dist/fixtures/tsconfig-paths-extends/src/cli.js +0 -3
- package/dist/fixtures/tsconfig-paths-extends/src/index.d.ts +0 -3
- package/dist/fixtures/tsconfig-paths-extends/src/index.js +0 -3
- package/dist/fixtures/tsconfig-paths-extends/src/lib/main.d.ts +0 -2
- package/dist/fixtures/tsconfig-paths-extends/src/lib/main.js +0 -1
- package/dist/fixtures/tsconfig-paths-extends/src/util/index.d.ts +0 -2
- package/dist/fixtures/tsconfig-paths-extends/src/util/index.js +0 -1
- package/dist/fixtures/tsconfig-paths-implicit/src/hello/world.d.ts +0 -1
- package/dist/fixtures/tsconfig-paths-implicit/src/hello/world.js +0 -1
- package/dist/fixtures/tsconfig-paths-implicit/src/index.d.ts +0 -1
- package/dist/fixtures/tsconfig-paths-implicit/src/index.js +0 -2
- package/dist/fixtures/workspaces/apps/a/index.d.ts +0 -1
- package/dist/fixtures/workspaces/apps/a/index.js +0 -6
- package/dist/fixtures/workspaces/apps/b/index.d.ts +0 -1
- package/dist/fixtures/workspaces/apps/b/index.js +0 -4
- package/dist/fixtures/workspaces/docs/dangling.d.ts +0 -1
- package/dist/fixtures/workspaces/docs/dangling.js +0 -1
- package/dist/fixtures/workspaces/packages/lib-a/index.d.ts +0 -4
- package/dist/fixtures/workspaces/packages/lib-a/index.js +0 -3
- package/dist/fixtures/workspaces/packages/lib-b/ignored/index.d.ts +0 -0
- package/dist/fixtures/workspaces/packages/lib-b/ignored/index.js +0 -1
- package/dist/fixtures/workspaces/packages/lib-b/index.d.ts +0 -3
- package/dist/fixtures/workspaces/packages/lib-b/index.js +0 -2
- package/dist/fixtures/workspaces-nested/level-1-1/index.d.ts +0 -1
- package/dist/fixtures/workspaces-nested/level-1-1/index.js +0 -1
- package/dist/fixtures/workspaces-nested/level-1-1/index.spec.d.ts +0 -1
- package/dist/fixtures/workspaces-nested/level-1-1/index.spec.js +0 -1
- package/dist/fixtures/workspaces-nested/level-1-1/level-1-2/index.d.ts +0 -1
- package/dist/fixtures/workspaces-nested/level-1-1/level-1-2/index.js +0 -1
- package/dist/fixtures/workspaces-nested/level-1-1/level-1-2/index.spec.d.ts +0 -1
- package/dist/fixtures/workspaces-nested/level-1-1/level-1-2/index.spec.js +0 -1
- package/dist/fixtures/workspaces-nested/level-1-1/level-1-2/level-1-3/index.d.ts +0 -1
- package/dist/fixtures/workspaces-nested/level-1-1/level-1-2/level-1-3/index.js +0 -1
- package/dist/fixtures/workspaces-nested/level-1-1/level-1-2/level-1-3/index.spec.d.ts +0 -1
- package/dist/fixtures/workspaces-nested/level-1-1/level-1-2/level-1-3/index.spec.js +0 -1
- package/dist/fixtures/workspaces-paths/packages/lib-a/src/dir/module-a.d.ts +0 -2
- package/dist/fixtures/workspaces-paths/packages/lib-a/src/dir/module-a.js +0 -1
- package/dist/fixtures/workspaces-paths/packages/lib-a/src/index.d.ts +0 -2
- package/dist/fixtures/workspaces-paths/packages/lib-a/src/index.js +0 -2
- package/dist/fixtures/workspaces-paths/packages/lib-a/src/same.d.ts +0 -2
- package/dist/fixtures/workspaces-paths/packages/lib-a/src/same.js +0 -1
- package/dist/fixtures/workspaces-paths/packages/lib-b/src/dir/module-b.d.ts +0 -2
- package/dist/fixtures/workspaces-paths/packages/lib-b/src/dir/module-b.js +0 -1
- package/dist/fixtures/workspaces-paths/packages/lib-b/src/index.d.ts +0 -2
- package/dist/fixtures/workspaces-paths/packages/lib-b/src/index.js +0 -2
- package/dist/fixtures/workspaces-paths/packages/lib-c/src/dir/module.d.ts +0 -2
- package/dist/fixtures/workspaces-paths/packages/lib-c/src/dir/module.js +0 -1
- package/dist/fixtures/workspaces-paths/packages/lib-c/src/index.d.ts +0 -2
- package/dist/fixtures/workspaces-paths/packages/lib-c/src/index.js +0 -2
- package/dist/fixtures/workspaces-paths/packages/lib-d/src/dir/module.d.ts +0 -2
- package/dist/fixtures/workspaces-paths/packages/lib-d/src/dir/module.js +0 -1
- package/dist/fixtures/workspaces-paths/packages/lib-d/src/index.d.ts +0 -2
- package/dist/fixtures/workspaces-paths/packages/lib-d/src/index.js +0 -2
- package/dist/fixtures/workspaces-paths/packages/lib-e/src/dir/module-e.d.ts +0 -2
- package/dist/fixtures/workspaces-paths/packages/lib-e/src/dir/module-e.js +0 -1
- package/dist/fixtures/workspaces-paths/packages/lib-e/src/index.d.ts +0 -2
- package/dist/fixtures/workspaces-paths/packages/lib-e/src/index.js +0 -2
- package/dist/fixtures/workspaces-pnpm/apps/a/index.d.ts +0 -1
- package/dist/fixtures/workspaces-pnpm/apps/a/index.js +0 -6
- package/dist/fixtures/workspaces-pnpm/apps/b/index.d.ts +0 -1
- package/dist/fixtures/workspaces-pnpm/apps/b/index.js +0 -4
- package/dist/fixtures/workspaces-pnpm/docs/dangling.d.ts +0 -1
- package/dist/fixtures/workspaces-pnpm/docs/dangling.js +0 -1
- package/dist/fixtures/workspaces-pnpm/packages/lib-a/index.d.ts +0 -4
- package/dist/fixtures/workspaces-pnpm/packages/lib-a/index.js +0 -3
- package/dist/fixtures/workspaces-pnpm/packages/lib-b/index.d.ts +0 -3
- package/dist/fixtures/workspaces-pnpm/packages/lib-b/index.js +0 -2
- package/dist/fixtures/workspaces-self-reference/packages/self-reference/entry.d.ts +0 -1
- package/dist/fixtures/workspaces-self-reference/packages/self-reference/entry.js +0 -4
- package/dist/fixtures/workspaces-self-reference/packages/self-reference-from-plugin/entry.d.ts +0 -0
- package/dist/fixtures/workspaces-self-reference/packages/self-reference-from-plugin/entry.js +0 -2
- package/dist/fixtures/workspaces-self-reference/packages/self-reference-from-plugin/file.d.ts +0 -2
- package/dist/fixtures/workspaces-self-reference/packages/self-reference-from-plugin/file.js +0 -1
- package/dist/fixtures/zero-config/exclude.d.ts +0 -1
- package/dist/fixtures/zero-config/exclude.js +0 -1
- package/dist/fixtures/zero-config/index.d.ts +0 -1
- package/dist/fixtures/zero-config/index.js +0 -2
- package/dist/fixtures/zero-config/my-module.d.ts +0 -4
- package/dist/fixtures/zero-config/my-module.js +0 -6
- package/dist/fixtures/zero-config/my-namespace.d.ts +0 -5
- package/dist/fixtures/zero-config/my-namespace.js +0 -3
- package/dist/gitignore.test.d.ts +0 -1
- package/dist/gitignore.test.js +0 -22
- package/dist/helpers/baseArguments.d.ts +0 -8
- package/dist/helpers/baseArguments.js +0 -8
- package/dist/helpers/baseCounters.d.ts +0 -17
- package/dist/helpers/baseCounters.js +0 -7
- package/dist/helpers/index.d.ts +0 -2
- package/dist/helpers/index.js +0 -4
- package/dist/imports.test.d.ts +0 -1
- package/dist/imports.test.js +0 -39
- package/dist/js-only.test.d.ts +0 -1
- package/dist/js-only.test.js +0 -26
- package/dist/jsdoc.test.d.ts +0 -1
- package/dist/jsdoc.test.js +0 -21
- package/dist/members.test.d.ts +0 -1
- package/dist/members.test.js +0 -28
- package/dist/namespace.test.d.ts +0 -1
- package/dist/namespace.test.js +0 -18
- package/dist/npm-scripts.test.d.ts +0 -1
- package/dist/npm-scripts.test.js +0 -78
- package/dist/pathless.test.d.ts +0 -1
- package/dist/pathless.test.js +0 -14
- package/dist/paths-knip-config-workspaces.test.d.ts +0 -1
- package/dist/paths-knip-config-workspaces.test.js +0 -18
- package/dist/paths-knip-config.test.d.ts +0 -1
- package/dist/paths-knip-config.test.js +0 -18
- package/dist/peer-dependencies.test.d.ts +0 -1
- package/dist/peer-dependencies.test.js +0 -20
- package/dist/plugins/_template.test.d.ts +0 -1
- package/dist/plugins/_template.test.js +0 -12
- package/dist/plugins/ava.test.d.ts +0 -1
- package/dist/plugins/ava.test.js +0 -18
- package/dist/plugins/babel.test.d.ts +0 -1
- package/dist/plugins/babel.test.js +0 -62
- package/dist/plugins/capacitor.test.d.ts +0 -1
- package/dist/plugins/capacitor.test.js +0 -31
- package/dist/plugins/changesets.test.d.ts +0 -1
- package/dist/plugins/changesets.test.js +0 -12
- package/dist/plugins/commitlint.test.d.ts +0 -1
- package/dist/plugins/commitlint.test.js +0 -22
- package/dist/plugins/cspell.test.d.ts +0 -1
- package/dist/plugins/cspell.test.js +0 -10
- package/dist/plugins/cypress.test.d.ts +0 -1
- package/dist/plugins/cypress.test.js +0 -23
- package/dist/plugins/eslint.test.d.ts +0 -1
- package/dist/plugins/eslint.test.js +0 -43
- package/dist/plugins/gatsby.test.d.ts +0 -1
- package/dist/plugins/gatsby.test.js +0 -31
- package/dist/plugins/github-actions.test.d.ts +0 -1
- package/dist/plugins/github-actions.test.js +0 -25
- package/dist/plugins/husky.test.d.ts +0 -1
- package/dist/plugins/husky.test.js +0 -32
- package/dist/plugins/jest.test.d.ts +0 -1
- package/dist/plugins/jest.test.js +0 -18
- package/dist/plugins/lefthook.test.d.ts +0 -1
- package/dist/plugins/lefthook.test.js +0 -16
- package/dist/plugins/lint-staged.test.d.ts +0 -1
- package/dist/plugins/lint-staged.test.js +0 -18
- package/dist/plugins/markdownlint.test.d.ts +0 -1
- package/dist/plugins/markdownlint.test.js +0 -12
- package/dist/plugins/mocha.test.d.ts +0 -1
- package/dist/plugins/mocha.test.js +0 -22
- package/dist/plugins/next.test.d.ts +0 -1
- package/dist/plugins/next.test.js +0 -24
- package/dist/plugins/npm-package-json-lint.test.d.ts +0 -1
- package/dist/plugins/npm-package-json-lint.test.js +0 -12
- package/dist/plugins/nx.test.d.ts +0 -1
- package/dist/plugins/nx.test.js +0 -15
- package/dist/plugins/nyc.test.d.ts +0 -1
- package/dist/plugins/nyc.test.js +0 -10
- package/dist/plugins/playwright.test.d.ts +0 -1
- package/dist/plugins/playwright.test.js +0 -20
- package/dist/plugins/postcss.test.d.ts +0 -1
- package/dist/plugins/postcss.test.js +0 -33
- package/dist/plugins/prettier.test.d.ts +0 -1
- package/dist/plugins/prettier.test.js +0 -10
- package/dist/plugins/release-it.test.d.ts +0 -1
- package/dist/plugins/release-it.test.js +0 -10
- package/dist/plugins/remark.test.d.ts +0 -1
- package/dist/plugins/remark.test.js +0 -12
- package/dist/plugins/remix.test.d.ts +0 -1
- package/dist/plugins/remix.test.js +0 -39
- package/dist/plugins/rollup.test.d.ts +0 -1
- package/dist/plugins/rollup.test.js +0 -24
- package/dist/plugins/semantic-release.test.d.ts +0 -1
- package/dist/plugins/semantic-release.test.js +0 -31
- package/dist/plugins/sentry.test.d.ts +0 -1
- package/dist/plugins/sentry.test.js +0 -14
- package/dist/plugins/storybook.test.d.ts +0 -1
- package/dist/plugins/storybook.test.js +0 -18
- package/dist/plugins/stryker.test.d.ts +0 -1
- package/dist/plugins/stryker.test.js +0 -44
- package/dist/plugins/svelte.test.d.ts +0 -1
- package/dist/plugins/svelte.test.js +0 -21
- package/dist/plugins/typedoc.test.d.ts +0 -1
- package/dist/plugins/typedoc.test.js +0 -14
- package/dist/plugins/vitest.test.d.ts +0 -1
- package/dist/plugins/vitest.test.js +0 -17
- package/dist/plugins/webpack.test.d.ts +0 -1
- package/dist/plugins/webpack.test.js +0 -56
- package/dist/re-exports.test.d.ts +0 -1
- package/dist/re-exports.test.js +0 -18
- package/dist/react.test.d.ts +0 -1
- package/dist/react.test.js +0 -19
- package/dist/self-reference-from-plugin.test.d.ts +0 -1
- package/dist/self-reference-from-plugin.test.js +0 -47
- package/dist/self-reference.test.d.ts +0 -1
- package/dist/self-reference.test.js +0 -46
- package/dist/source-lab.d.ts +0 -21
- package/dist/source-lab.js +0 -135
- package/dist/tsconfig-paths-extends.test.d.ts +0 -1
- package/dist/tsconfig-paths-extends.test.js +0 -18
- package/dist/tsconfig-paths-implicit.test.d.ts +0 -1
- package/dist/tsconfig-paths-implicit.test.js +0 -18
- package/dist/tsconfig-paths.test.d.ts +0 -1
- package/dist/tsconfig-paths.test.js +0 -26
- package/dist/util/binaries/bash-parser.d.ts +0 -6
- package/dist/util/binaries/bash-parser.js +0 -57
- package/dist/util/binaries/index.d.ts +0 -2
- package/dist/util/binaries/index.js +0 -27
- package/dist/util/binaries/resolvers/fallback.js +0 -14
- package/dist/util/binaries/resolvers/index.d.ts +0 -4
- package/dist/util/binaries/resolvers/index.js +0 -4
- package/dist/util/binaries/resolvers/node.d.ts +0 -3
- package/dist/util/binaries/resolvers/node.js +0 -20
- package/dist/util/binaries/resolvers/npx.d.ts +0 -2
- package/dist/util/binaries/resolvers/npx.js +0 -5
- package/dist/util/binaries/resolvers/pnpm.d.ts +0 -2
- package/dist/util/binaries/resolvers/pnpm.js +0 -45
- package/dist/util/binaries/resolvers/yarn.d.ts +0 -2
- package/dist/util/binaries/resolvers/yarn.js +0 -46
- package/dist/util/binaries/types.d.ts +0 -18
- package/dist/util/binaries/types.js +0 -1
- package/dist/util/find-import-specifiers.d.ts +0 -5
- package/dist/util/find-import-specifiers.js +0 -48
- package/dist/util/get-included-issue-types.test.d.ts +0 -1
- package/dist/util/get-included-issue-types.test.js +0 -70
- package/dist/util/getReferencesFromScripts.test.d.ts +0 -1
- package/dist/util/getReferencesFromScripts.test.js +0 -126
- package/dist/util/log.d.ts +0 -7
- package/dist/util/log.js +0 -21
- package/dist/util/members.d.ts +0 -3
- package/dist/util/members.js +0 -25
- package/dist/util/module.test.d.ts +0 -1
- package/dist/util/module.test.js +0 -12
- package/dist/util/os.d.ts +0 -1
- package/dist/util/os.js +0 -1
- package/dist/util/project.d.ts +0 -13
- package/dist/util/project.js +0 -48
- package/dist/util/resolve-included-issue-types.d.ts +0 -16
- package/dist/util/resolve-included-issue-types.js +0 -30
- package/dist/util/type.d.ts +0 -2
- package/dist/util/type.js +0 -9
- package/dist/util/workspace.test.d.ts +0 -1
- package/dist/util/workspace.test.js +0 -13
- package/dist/workspaces-nested.test.d.ts +0 -1
- package/dist/workspaces-nested.test.js +0 -44
- package/dist/workspaces-paths.test.d.ts +0 -1
- package/dist/workspaces-paths.test.js +0 -21
- package/dist/workspaces-pnpm.test.d.ts +0 -1
- package/dist/workspaces-pnpm.test.js +0 -21
- package/dist/workspaces.test.d.ts +0 -1
- package/dist/workspaces.test.js +0 -56
- package/dist/zero-config.test.d.ts +0 -1
- package/dist/zero-config.test.js +0 -37
- /package/dist/{util/binaries/resolvers/fallback.d.ts → binaries/resolvers/rollup.d.ts} +0 -0
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import parse from 'bash-parser';
|
|
2
|
-
import parseArgs from 'minimist';
|
|
3
|
-
import * as FallbackResolver from './resolvers/fallback.js';
|
|
4
|
-
import * as KnownResolvers from './resolvers/index.js';
|
|
5
|
-
const spawningBinaries = ['cross-env', 'dotenv'];
|
|
6
|
-
export const getBinariesFromScript = (script, { cwd, manifest, knownGlobalsOnly = false }) => {
|
|
7
|
-
if (!script)
|
|
8
|
-
return [];
|
|
9
|
-
const fromArgs = (args) => getBinariesFromScript(args.join(' '), { cwd, manifest });
|
|
10
|
-
const getBinariesFromNodes = (nodes) => nodes.flatMap(node => {
|
|
11
|
-
switch (node.type) {
|
|
12
|
-
case 'Command': {
|
|
13
|
-
const binary = node.name?.text;
|
|
14
|
-
const commandExpansions = node.prefix?.flatMap(prefix => prefix.expansion?.filter(expansion => expansion.type === 'CommandExpansion') ?? []) ?? [];
|
|
15
|
-
if (commandExpansions.length > 0) {
|
|
16
|
-
return commandExpansions.flatMap(expansion => getBinariesFromNodes(expansion.commandAST.commands)) ?? [];
|
|
17
|
-
}
|
|
18
|
-
if (!binary || binary === '.' || binary === 'source')
|
|
19
|
-
return [];
|
|
20
|
-
if (binary.startsWith('-') || binary.startsWith('"') || binary.startsWith('..'))
|
|
21
|
-
return [];
|
|
22
|
-
if (['bun', 'deno'].includes(binary))
|
|
23
|
-
return [];
|
|
24
|
-
const args = node.suffix?.map(arg => arg.text) ?? [];
|
|
25
|
-
if (['!', 'test'].includes(binary))
|
|
26
|
-
return fromArgs(args);
|
|
27
|
-
if (binary in KnownResolvers) {
|
|
28
|
-
return KnownResolvers[binary].resolve(binary, args, { cwd, manifest, fromArgs });
|
|
29
|
-
}
|
|
30
|
-
if (knownGlobalsOnly)
|
|
31
|
-
return [];
|
|
32
|
-
if (spawningBinaries.includes(binary)) {
|
|
33
|
-
const parsedArgs = parseArgs(args);
|
|
34
|
-
const [spawnedBinary] = parsedArgs._;
|
|
35
|
-
if (spawnedBinary) {
|
|
36
|
-
const restArgs = args.slice(args.indexOf(spawnedBinary));
|
|
37
|
-
return [binary, ...fromArgs(restArgs)];
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
return [];
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return FallbackResolver.resolve(binary, args, { cwd, manifest, fromArgs });
|
|
44
|
-
}
|
|
45
|
-
case 'LogicalExpression':
|
|
46
|
-
return getBinariesFromNodes([node.left, node.right]);
|
|
47
|
-
case 'If':
|
|
48
|
-
return getBinariesFromNodes([...node.clause.commands, ...node.then.commands]);
|
|
49
|
-
case 'For':
|
|
50
|
-
return getBinariesFromNodes(node.do.commands);
|
|
51
|
-
default:
|
|
52
|
-
return [];
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
const parsed = parse(script);
|
|
56
|
-
return parsed?.commands ? getBinariesFromNodes(parsed.commands) : [];
|
|
57
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { IGNORED_GLOBAL_BINARIES } from '../../constants.js';
|
|
2
|
-
import { compact } from '../array.js';
|
|
3
|
-
import { getPackageNameFromModuleSpecifier, stripBinary } from '../modules.js';
|
|
4
|
-
import { isAbsolute } from '../path.js';
|
|
5
|
-
import { timerify } from '../performance.js';
|
|
6
|
-
import { getBinariesFromScript } from './bash-parser.js';
|
|
7
|
-
const defaultCwd = process.cwd();
|
|
8
|
-
const partition = (values) => values.reduce((acc, value) => {
|
|
9
|
-
acc[isAbsolute(value) ? 1 : 0].push(value);
|
|
10
|
-
return acc;
|
|
11
|
-
}, [[], []]);
|
|
12
|
-
const getReferencesFromScripts = (npmScripts, options = {}) => {
|
|
13
|
-
const { cwd = defaultCwd, manifest = {}, ignore = [], knownGlobalsOnly = false } = options;
|
|
14
|
-
const results = [npmScripts]
|
|
15
|
-
.flat()
|
|
16
|
-
.flatMap(script => getBinariesFromScript(script, { cwd, manifest, knownGlobalsOnly }));
|
|
17
|
-
const [binaries, entryFiles] = partition(compact(results));
|
|
18
|
-
return {
|
|
19
|
-
entryFiles,
|
|
20
|
-
binaries: binaries
|
|
21
|
-
.map(stripBinary)
|
|
22
|
-
.filter(binary => !binary.startsWith('.'))
|
|
23
|
-
.map(getPackageNameFromModuleSpecifier)
|
|
24
|
-
.filter(binaryName => !IGNORED_GLOBAL_BINARIES.includes(binaryName) && !ignore.includes(binaryName)),
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
export const _getReferencesFromScripts = timerify(getReferencesFromScripts);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import parseArgs from 'minimist';
|
|
2
|
-
import { tryResolveFilePaths } from './node.js';
|
|
3
|
-
const argResolvers = {
|
|
4
|
-
'babel-node': parsed => [parsed._[0], parsed.require].flat(),
|
|
5
|
-
'ts-node': parsed => [parsed._[0], parsed.require].flat(),
|
|
6
|
-
tsx: parsed => parsed._.filter(p => p !== 'watch'),
|
|
7
|
-
default: parsed => [parsed.require].flat(),
|
|
8
|
-
};
|
|
9
|
-
export const resolve = (binary, args, { cwd }) => {
|
|
10
|
-
const parsed = parseArgs(args, { string: ['r'], alias: { require: ['r', 'loader'] } });
|
|
11
|
-
const resolver = argResolvers[binary] ?? argResolvers.default;
|
|
12
|
-
const resolve = resolver(parsed);
|
|
13
|
-
return [binary, ...tryResolveFilePaths(cwd, resolve)];
|
|
14
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import parseArgs from 'minimist';
|
|
2
|
-
import { isInNodeModules, join } from '../../path.js';
|
|
3
|
-
import { tryResolve } from '../../require.js';
|
|
4
|
-
const tryResolveFilePath = (cwd, specifier, fallback) => {
|
|
5
|
-
if (specifier) {
|
|
6
|
-
const filePath = join(cwd, specifier);
|
|
7
|
-
if (!isInNodeModules(filePath)) {
|
|
8
|
-
const resolvedFilePath = tryResolve(filePath);
|
|
9
|
-
if (resolvedFilePath)
|
|
10
|
-
return [resolvedFilePath];
|
|
11
|
-
}
|
|
12
|
-
return fallback ? [fallback] : [];
|
|
13
|
-
}
|
|
14
|
-
return [];
|
|
15
|
-
};
|
|
16
|
-
export const tryResolveFilePaths = (cwd, specifiers) => specifiers.flatMap(specifier => tryResolveFilePath(cwd, specifier, specifier));
|
|
17
|
-
export const resolve = (binary, args, { cwd }) => {
|
|
18
|
-
const parsed = parseArgs(args, { string: ['r'], alias: { require: ['r', 'loader', 'experimental-loader'] } });
|
|
19
|
-
return [...tryResolveFilePath(cwd, parsed._[0]), ...tryResolveFilePaths(cwd, [parsed.require].flat())];
|
|
20
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import parseArgs from 'minimist';
|
|
2
|
-
export const resolve = (binary, args, { fromArgs }) => {
|
|
3
|
-
const parsed = parseArgs(args, { '--': true, stopEarly: true, boolean: ['yes', 'no'], alias: { yes: 'y', no: 'n' } });
|
|
4
|
-
return [...(parsed.yes ? [] : fromArgs(parsed._)), ...(parsed['--'] ? fromArgs(parsed['--']) : [])];
|
|
5
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import parseArgs from 'minimist';
|
|
2
|
-
const commands = [
|
|
3
|
-
'add',
|
|
4
|
-
'dlx',
|
|
5
|
-
'run',
|
|
6
|
-
'i',
|
|
7
|
-
'install',
|
|
8
|
-
'up',
|
|
9
|
-
'update',
|
|
10
|
-
'upgrade',
|
|
11
|
-
'remove',
|
|
12
|
-
'rm',
|
|
13
|
-
'uninstall',
|
|
14
|
-
'un',
|
|
15
|
-
'link',
|
|
16
|
-
'ln',
|
|
17
|
-
'unlink',
|
|
18
|
-
'import',
|
|
19
|
-
'rebuild',
|
|
20
|
-
'rb',
|
|
21
|
-
'prune',
|
|
22
|
-
'fetch',
|
|
23
|
-
'install-test',
|
|
24
|
-
'it',
|
|
25
|
-
'patch',
|
|
26
|
-
'patch-commit',
|
|
27
|
-
'audit',
|
|
28
|
-
'list',
|
|
29
|
-
'ls',
|
|
30
|
-
'outdated',
|
|
31
|
-
'why',
|
|
32
|
-
'test',
|
|
33
|
-
't',
|
|
34
|
-
'tst',
|
|
35
|
-
];
|
|
36
|
-
export const resolve = (binary, args, { manifest }) => {
|
|
37
|
-
const scripts = manifest.scripts ? Object.keys(manifest.scripts) : [];
|
|
38
|
-
const parsed = parseArgs(args, {});
|
|
39
|
-
const [command, result] = parsed._;
|
|
40
|
-
if (scripts.includes(command) || commands.includes(command))
|
|
41
|
-
return [];
|
|
42
|
-
if (command === 'exec')
|
|
43
|
-
return [result];
|
|
44
|
-
return command ? [command] : [];
|
|
45
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import parseArgs from 'minimist';
|
|
2
|
-
const commands = [
|
|
3
|
-
'add',
|
|
4
|
-
'bin',
|
|
5
|
-
'cache',
|
|
6
|
-
'config',
|
|
7
|
-
'constraints',
|
|
8
|
-
'dedupe',
|
|
9
|
-
'dlx',
|
|
10
|
-
'explain',
|
|
11
|
-
'info',
|
|
12
|
-
'init',
|
|
13
|
-
'install',
|
|
14
|
-
'link',
|
|
15
|
-
'pack',
|
|
16
|
-
'patch',
|
|
17
|
-
'patch-commit',
|
|
18
|
-
'plugin',
|
|
19
|
-
'rebuild',
|
|
20
|
-
'remove',
|
|
21
|
-
'search',
|
|
22
|
-
'set',
|
|
23
|
-
'stage',
|
|
24
|
-
'unlink',
|
|
25
|
-
'unplug',
|
|
26
|
-
'up',
|
|
27
|
-
'upgrade-interactive',
|
|
28
|
-
'version',
|
|
29
|
-
'why',
|
|
30
|
-
'workspace',
|
|
31
|
-
'workspaces',
|
|
32
|
-
];
|
|
33
|
-
export const resolve = (binary, args, { manifest, fromArgs }) => {
|
|
34
|
-
const scripts = manifest.scripts ? Object.keys(manifest.scripts) : [];
|
|
35
|
-
const parsed = parseArgs(args, {});
|
|
36
|
-
const [command, result] = parsed._;
|
|
37
|
-
if (scripts.includes(command) || commands.includes(command))
|
|
38
|
-
return [];
|
|
39
|
-
if (command === 'run' && scripts.includes(result))
|
|
40
|
-
return [];
|
|
41
|
-
if (command === 'run' || command === 'exec')
|
|
42
|
-
return [result];
|
|
43
|
-
if (command === 'node')
|
|
44
|
-
return fromArgs(parsed._);
|
|
45
|
-
return command ? [command] : [];
|
|
46
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { PackageJson } from 'type-fest';
|
|
2
|
-
type Options = {
|
|
3
|
-
cwd?: string;
|
|
4
|
-
manifest?: PackageJson;
|
|
5
|
-
ignore?: string[];
|
|
6
|
-
knownGlobalsOnly?: boolean;
|
|
7
|
-
};
|
|
8
|
-
export type GetReferencesFromScripts = (npmScripts: string | string[], options?: Options) => {
|
|
9
|
-
entryFiles: string[];
|
|
10
|
-
binaries: string[];
|
|
11
|
-
};
|
|
12
|
-
type FromArgs = (args: string[]) => string[];
|
|
13
|
-
export type Resolver = (binary: string, args: string[], options: {
|
|
14
|
-
cwd: string;
|
|
15
|
-
manifest: PackageJson;
|
|
16
|
-
fromArgs: FromArgs;
|
|
17
|
-
}) => string[];
|
|
18
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { ts } from 'ts-morph';
|
|
3
|
-
import { findCallExpressionsByName } from 'ts-morph-helpers';
|
|
4
|
-
import { require } from '../util/require.js';
|
|
5
|
-
import { compact } from './array.js';
|
|
6
|
-
import { timerify } from './performance.js';
|
|
7
|
-
const getImportStringLiterals = (sourceFile) => sourceFile
|
|
8
|
-
.getImportDeclarations()
|
|
9
|
-
.filter(declaration => !declaration.isTypeOnly())
|
|
10
|
-
.flatMap(declaration => declaration.getDescendantsOfKind(ts.SyntaxKind.StringLiteral));
|
|
11
|
-
const findCommonJSModuleSpecifiers = (sourceFile) => [
|
|
12
|
-
...findCallExpressionsByName(sourceFile, 'require'),
|
|
13
|
-
...findCallExpressionsByName(sourceFile, 'require.resolve'),
|
|
14
|
-
].flatMap(expression => {
|
|
15
|
-
const list = expression.getFirstChildByKind(ts.SyntaxKind.SyntaxList);
|
|
16
|
-
return (list?.getFirstChildByKind(ts.SyntaxKind.StringLiteral) ??
|
|
17
|
-
list?.getFirstChildByKind(ts.SyntaxKind.NoSubstitutionTemplateLiteral) ??
|
|
18
|
-
list?.getFirstChildByKind(ts.SyntaxKind.TemplateExpression));
|
|
19
|
-
});
|
|
20
|
-
const resolveInternal = (filePath, moduleSpecifiers) => moduleSpecifiers
|
|
21
|
-
.filter(moduleSpecifier => moduleSpecifier.startsWith('.'))
|
|
22
|
-
.map(moduleSpecifier => {
|
|
23
|
-
try {
|
|
24
|
-
return require.resolve(path.join(path.dirname(filePath), moduleSpecifier));
|
|
25
|
-
}
|
|
26
|
-
catch (e) {
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
const findImportModuleSpecifiers = (sourceFile, options = { skipInternal: false, isStrict: false }) => {
|
|
30
|
-
const filePath = sourceFile.getFilePath();
|
|
31
|
-
const importLiterals = options.isStrict ? getImportStringLiterals(sourceFile) : sourceFile.getImportStringLiterals();
|
|
32
|
-
const requireCallExpressions = findCommonJSModuleSpecifiers(sourceFile);
|
|
33
|
-
const moduleSpecifiers = compact([...importLiterals, ...requireCallExpressions].map(importLiteral => {
|
|
34
|
-
if (!importLiteral)
|
|
35
|
-
return;
|
|
36
|
-
if (importLiteral.isKind(ts.SyntaxKind.TemplateExpression)) {
|
|
37
|
-
const literalText = importLiteral.getFullText();
|
|
38
|
-
if (literalText.includes('${'))
|
|
39
|
-
return;
|
|
40
|
-
return literalText.slice(1, -1);
|
|
41
|
-
}
|
|
42
|
-
return importLiteral?.getLiteralText();
|
|
43
|
-
}));
|
|
44
|
-
const internalModuleSpecifiers = options.skipInternal ? [] : resolveInternal(filePath, moduleSpecifiers);
|
|
45
|
-
const externalModuleSpecifiers = moduleSpecifiers.filter(moduleSpecifier => !moduleSpecifier.startsWith('.'));
|
|
46
|
-
return [compact(internalModuleSpecifiers), externalModuleSpecifiers];
|
|
47
|
-
};
|
|
48
|
-
export const _findImportModuleSpecifiers = timerify(findImportModuleSpecifiers);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import test from 'node:test';
|
|
3
|
-
import { ISSUE_TYPES } from '../../src/constants.js';
|
|
4
|
-
import { getIncludedIssueTypes } from '../../src/util/get-included-issue-types.js';
|
|
5
|
-
const all = Object.fromEntries(ISSUE_TYPES.map(type => [type, true]));
|
|
6
|
-
const none = Object.fromEntries(ISSUE_TYPES.map(type => [type, false]));
|
|
7
|
-
test('Resolve included issue types (default)', async () => {
|
|
8
|
-
const cliArgs = { include: [], exclude: [], dependencies: false, exports: false };
|
|
9
|
-
const config = getIncludedIssueTypes(cliArgs);
|
|
10
|
-
assert.deepEqual(config, { ...all });
|
|
11
|
-
});
|
|
12
|
-
test('Resolve included issue types (include single)', async () => {
|
|
13
|
-
const cliArgs = { include: ['duplicates'], exclude: [], dependencies: false, exports: false };
|
|
14
|
-
const config = getIncludedIssueTypes(cliArgs);
|
|
15
|
-
assert.deepEqual(config, { ...none, duplicates: true });
|
|
16
|
-
});
|
|
17
|
-
test('Resolve included issue types (exclude some)', async () => {
|
|
18
|
-
const cliArgs = { include: [], exclude: ['duplicates', 'nsTypes'], dependencies: false, exports: false };
|
|
19
|
-
const config = getIncludedIssueTypes(cliArgs);
|
|
20
|
-
assert.deepEqual(config, { ...all, duplicates: false, nsTypes: false });
|
|
21
|
-
});
|
|
22
|
-
test('Resolve included issue types (overlap)', async () => {
|
|
23
|
-
const cliArgs = {
|
|
24
|
-
include: ['exports', 'files', 'nsTypes'],
|
|
25
|
-
exclude: ['files', 'duplicates'],
|
|
26
|
-
dependencies: false,
|
|
27
|
-
exports: false,
|
|
28
|
-
};
|
|
29
|
-
const config = getIncludedIssueTypes(cliArgs);
|
|
30
|
-
assert.deepEqual(config, { ...none, exports: true, nsTypes: true });
|
|
31
|
-
});
|
|
32
|
-
test('Resolve included issue types (include devDependencies)', async () => {
|
|
33
|
-
const cliArgs = { include: ['dependencies'], exclude: [], dependencies: false, exports: false };
|
|
34
|
-
const config = getIncludedIssueTypes(cliArgs);
|
|
35
|
-
assert.deepEqual(config, { ...none, dependencies: true, devDependencies: true });
|
|
36
|
-
});
|
|
37
|
-
test('Resolve included issue types (include dependencies)', async () => {
|
|
38
|
-
const cliArgs = { include: ['dependencies'], exclude: [], dependencies: false, exports: false };
|
|
39
|
-
const config = getIncludedIssueTypes(cliArgs, { isProduction: true });
|
|
40
|
-
assert.deepEqual(config, { ...none, dependencies: true });
|
|
41
|
-
});
|
|
42
|
-
test('Resolve included issue types (exclude dependencies)', async () => {
|
|
43
|
-
const cliArgs = { include: [], exclude: ['dependencies'], dependencies: false, exports: false };
|
|
44
|
-
const config = getIncludedIssueTypes(cliArgs);
|
|
45
|
-
assert.deepEqual(config, { ...all, dependencies: false, devDependencies: false });
|
|
46
|
-
});
|
|
47
|
-
test('Resolve included issue types (--dependencies)', async () => {
|
|
48
|
-
const cliArgs = { include: [], exclude: [], dependencies: true, exports: false };
|
|
49
|
-
const config = getIncludedIssueTypes(cliArgs);
|
|
50
|
-
assert.deepEqual(config, { ...none, dependencies: true, devDependencies: true, unlisted: true, unresolved: true });
|
|
51
|
-
});
|
|
52
|
-
test('Resolve included issue types (--exports)', async () => {
|
|
53
|
-
const cliArgs = { include: [], exclude: [], dependencies: false, exports: true };
|
|
54
|
-
const config = getIncludedIssueTypes(cliArgs);
|
|
55
|
-
assert.deepEqual(config, {
|
|
56
|
-
...none,
|
|
57
|
-
exports: true,
|
|
58
|
-
nsExports: true,
|
|
59
|
-
classMembers: true,
|
|
60
|
-
types: true,
|
|
61
|
-
nsTypes: true,
|
|
62
|
-
enumMembers: true,
|
|
63
|
-
duplicates: true,
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
test('Resolve included issue types (all)', async () => {
|
|
67
|
-
const cliArgs = { include: ['files'], exclude: [], dependencies: true, exports: true };
|
|
68
|
-
const config = getIncludedIssueTypes(cliArgs);
|
|
69
|
-
assert.deepEqual(config, all);
|
|
70
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import test from 'node:test';
|
|
3
|
-
import { _getReferencesFromScripts } from '../../src/binaries/index.js';
|
|
4
|
-
import { join, resolve } from '../../src/util/path.js';
|
|
5
|
-
const cwd = resolve('tests/fixtures/binaries');
|
|
6
|
-
const js = join(cwd, 'script.js');
|
|
7
|
-
const ts = join(cwd, 'main.ts');
|
|
8
|
-
const req = join(cwd, 'require.js');
|
|
9
|
-
const index = join(cwd, 'dir', 'index.js');
|
|
10
|
-
const pkgScripts = { cwd, manifest: { scripts: { program: '' } } };
|
|
11
|
-
const knownOnly = { cwd, knownGlobalsOnly: true };
|
|
12
|
-
const t = (script, binaries = [], entryFiles = [], options = { cwd }) => assert.deepEqual(_getReferencesFromScripts(script, options), { binaries, entryFiles });
|
|
13
|
-
test('getReferencesFromScripts', () => {
|
|
14
|
-
t('program', ['program']);
|
|
15
|
-
t(['program', 'program'], ['program']);
|
|
16
|
-
t('program -short --long args', ['program']);
|
|
17
|
-
t('program && program2', ['program', 'program2']);
|
|
18
|
-
t('program -x && exec -y -- program2 -z', ['program', 'exec']);
|
|
19
|
-
t('program -x; exec -y -- program2', ['program', 'exec']);
|
|
20
|
-
t('program script.js -- program2', ['program']);
|
|
21
|
-
t("program '*.js' -- program2", ['program']);
|
|
22
|
-
t('program -s .', ['program']);
|
|
23
|
-
t('program command', ['program']);
|
|
24
|
-
});
|
|
25
|
-
test('getReferencesFromScripts (node)', () => {
|
|
26
|
-
t('node script.js', [], [js]);
|
|
27
|
-
t('node -r script.js', [], [js]);
|
|
28
|
-
t('node -r package/script', ['package']);
|
|
29
|
-
t('node -r ./require.js script.js', [], [js, req]);
|
|
30
|
-
t('node --require=pkg1 --require pkg2 script', ['pkg1', 'pkg2'], [js]);
|
|
31
|
-
t('node --experimental-loader ts-node/esm/transpile-only script.js', ['ts-node'], [js]);
|
|
32
|
-
t('node -r @scope/package/register ./dir', ['@scope/package'], [index]);
|
|
33
|
-
t('node dist/index.js', []);
|
|
34
|
-
});
|
|
35
|
-
test('getReferencesFromScripts (ts-node/tsx)', () => {
|
|
36
|
-
t('ts-node --require pkg/register main.ts', ['ts-node', 'pkg'], [ts]);
|
|
37
|
-
t('tsx ./main.ts', ['tsx'], [ts]);
|
|
38
|
-
t('tsx watch ./main.ts', ['tsx'], [ts]);
|
|
39
|
-
t('node --loader tsx ./main.ts', ['tsx'], [ts]);
|
|
40
|
-
t('npx tsx main', ['tsx'], [ts]);
|
|
41
|
-
t('babel-node --inspect=0.0.0.0 ./main.ts', ['babel-node'], [ts]);
|
|
42
|
-
});
|
|
43
|
-
test('getReferencesFromScripts (--require)', () => {
|
|
44
|
-
t('nodemon --require dotenv/config ./server.js --watch ./server.js', ['nodemon', 'dotenv']);
|
|
45
|
-
t('program --loader tsx --test "test/*.spec.ts"', ['program', 'tsx']);
|
|
46
|
-
t('program --loader ldr --loader tsx --test "test/*.spec.ts"', ['program', 'ldr', 'tsx']);
|
|
47
|
-
});
|
|
48
|
-
test('getReferencesFromScripts (.bin)', () => {
|
|
49
|
-
t('./node_modules/.bin/tsc --noEmit', ['tsc']);
|
|
50
|
-
t('node_modules/.bin/tsc --noEmit', ['tsc']);
|
|
51
|
-
t('$(npm bin)/tsc --noEmit', ['tsc']);
|
|
52
|
-
t('../../../scripts/node_modules/.bin/tsc --noEmit', []);
|
|
53
|
-
});
|
|
54
|
-
test('getReferencesFromScripts (dotenv)', () => {
|
|
55
|
-
t('dotenv program', ['dotenv', 'program']);
|
|
56
|
-
t('dotenv -- program', ['dotenv', 'program']);
|
|
57
|
-
t('dotenv -e .env3 -v VARIABLE=somevalue program -- exit', ['dotenv', 'program']);
|
|
58
|
-
t('dotenv -- mvn exec:java -Dexec.args="-g -f"', ['dotenv', 'mvn']);
|
|
59
|
-
});
|
|
60
|
-
test('getReferencesFromScripts (cross-env)', () => {
|
|
61
|
-
t('cross-env program', ['cross-env', 'program']);
|
|
62
|
-
t('cross-env NODE_ENV=production program', ['cross-env', 'program']);
|
|
63
|
-
t('cross-env NODE_ENV=production program subcommand', ['cross-env', 'program']);
|
|
64
|
-
t('cross-env NODE_OPTIONS=--max-size=3072 program subcommand', ['cross-env', 'program']);
|
|
65
|
-
t('cross-env NODE_ENV=production program -r pkg/config ./s.js -w ./s.js', ['cross-env', 'program', 'pkg']);
|
|
66
|
-
t('NODE_ENV=production cross-env -- program --cache', ['cross-env', 'program']);
|
|
67
|
-
});
|
|
68
|
-
test('getReferencesFromScripts (cross-env/node)', () => {
|
|
69
|
-
t('cross-env NODE_ENV=production node -r node_modules/dotenv/config ./script.js', ['cross-env', 'dotenv'], [js]);
|
|
70
|
-
t('cross-env NODE_ENV=production node -r esm script.js', ['cross-env', 'esm'], [js]);
|
|
71
|
-
});
|
|
72
|
-
test('getReferencesFromScripts (npm)', () => {
|
|
73
|
-
t('npm run script', []);
|
|
74
|
-
t('npm run publish:latest -- --npm-tag=debug --no-push', []);
|
|
75
|
-
});
|
|
76
|
-
test('getReferencesFromScripts (npx)', () => {
|
|
77
|
-
t('npx pkg', ['pkg']);
|
|
78
|
-
t('npx prisma migrate reset --force', ['prisma']);
|
|
79
|
-
t('npx @scope/pkg', ['@scope/pkg']);
|
|
80
|
-
t('npx tsx watch main', ['tsx'], [ts]);
|
|
81
|
-
t('npx -y pkg', []);
|
|
82
|
-
t('npx --yes pkg', []);
|
|
83
|
-
t('npx --no pkg --edit ${1}', ['pkg']);
|
|
84
|
-
t('npx --no -- pkg --edit ${1}', ['pkg']);
|
|
85
|
-
t('npx pkg install --with-deps', ['pkg']);
|
|
86
|
-
t('npx pkg migrate reset --force', ['pkg']);
|
|
87
|
-
t('npx pkg@0.6.0 -- curl --output /dev/null', ['pkg', 'curl']);
|
|
88
|
-
t('npx @scope/pkg@0.6.0 -- curl', ['@scope/pkg', 'curl']);
|
|
89
|
-
});
|
|
90
|
-
test('getReferencesFromScripts (pnpm)', () => {
|
|
91
|
-
t('pnpm exec program', ['program']);
|
|
92
|
-
t('pnpm run program', []);
|
|
93
|
-
t('pnpm program', ['program']);
|
|
94
|
-
t('pnpm run program', [], [], pkgScripts);
|
|
95
|
-
t('pnpm program', [], [], pkgScripts);
|
|
96
|
-
t('pnpm dlx pkg', []);
|
|
97
|
-
t('pnpm --package=pkg-a dlx pkg', []);
|
|
98
|
-
});
|
|
99
|
-
test('getReferencesFromScripts (yarn)', () => {
|
|
100
|
-
t('yarn exec program', ['program']);
|
|
101
|
-
t('yarn run program', ['program']);
|
|
102
|
-
t('yarn program', ['program']);
|
|
103
|
-
t('yarn run program', [], [], pkgScripts);
|
|
104
|
-
t('yarn program', [], [], pkgScripts);
|
|
105
|
-
t('yarn dlx pkg', []);
|
|
106
|
-
t('yarn --package=pkg-a -p pkg-b dlx pkg', []);
|
|
107
|
-
t('yarn node script.js', [], [js]);
|
|
108
|
-
});
|
|
109
|
-
test('getReferencesFromScripts (bash expressions)', () => {
|
|
110
|
-
t('if test "$NODE_ENV" = "production" ; then make install ; fi ', ['make']);
|
|
111
|
-
t('node -e "if (NODE_ENV === \'production\'){process.exit(1)} " || make install', ['make']);
|
|
112
|
-
t('if ! npx program --verbose ; then exit 1 ; fi', ['program']);
|
|
113
|
-
});
|
|
114
|
-
test('getReferencesFromScripts (bash expansion)', () => {
|
|
115
|
-
t('var=$(node ./script.js)', [], [js]);
|
|
116
|
-
t('var=`node ./script.js`;var=`node ./require.js`', [], [js, req]);
|
|
117
|
-
});
|
|
118
|
-
test('getReferencesFromScripts (multiline)', () => {
|
|
119
|
-
t('#!/bin/sh\n. "$(dirname "$0")/_/husky.sh"\nnpx lint-staged', ['lint-staged']);
|
|
120
|
-
t(`for S in "s"; do\n\tnpx rc@0.6.0\n\tnpx @scope/rc@0.6.0\ndone`, ['rc', '@scope/rc']);
|
|
121
|
-
});
|
|
122
|
-
test('getReferencesFromScripts (bail outs)', () => {
|
|
123
|
-
t('dotenv', [], [], knownOnly);
|
|
124
|
-
t('dotenv -- mvn exec:java -Dexec.args="-g -f"', [], [], knownOnly);
|
|
125
|
-
t('deno install --no-check -r -f https://deno.land/x/deploy/deployctl.ts', []);
|
|
126
|
-
});
|
package/dist/util/log.d.ts
DELETED
package/dist/util/log.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export const getLine = (value, text) => `${String(value).padStart(5)} ${text}`;
|
|
2
|
-
export class LineRewriter {
|
|
3
|
-
lines = 0;
|
|
4
|
-
clearLines(count) {
|
|
5
|
-
if (count > 0) {
|
|
6
|
-
for (let i = 0; i < count; i++) {
|
|
7
|
-
process.stdout.moveCursor(0, -1);
|
|
8
|
-
process.stdout.clearLine(1);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
process.stdout.cursorTo(0);
|
|
12
|
-
}
|
|
13
|
-
resetLines() {
|
|
14
|
-
this.clearLines(this.lines);
|
|
15
|
-
}
|
|
16
|
-
update(messages) {
|
|
17
|
-
this.resetLines();
|
|
18
|
-
process.stdout.write(messages.join('\n') + '\n');
|
|
19
|
-
this.lines = messages.length;
|
|
20
|
-
}
|
|
21
|
-
}
|
package/dist/util/members.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { ClassDeclaration, EnumDeclaration } from 'ts-morph';
|
|
2
|
-
export declare const findUnusedClassMembers: (declaration: ClassDeclaration, filePath: string) => string[];
|
|
3
|
-
export declare const findUnusedEnumMembers: (declaration: EnumDeclaration, filePath: string) => string[];
|
package/dist/util/members.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ts } from 'ts-morph';
|
|
2
|
-
import { _findReferences, hasExternalReferences, hasInternalReferences } from './project.js';
|
|
3
|
-
export const findUnusedClassMembers = (declaration, filePath) => {
|
|
4
|
-
const members = declaration.getMembers();
|
|
5
|
-
return members
|
|
6
|
-
.filter((member) => {
|
|
7
|
-
const isPrivate = Boolean(member.getCombinedModifierFlags() & ts.ModifierFlags.Private);
|
|
8
|
-
if (!isPrivate &&
|
|
9
|
-
(member.isKind(ts.SyntaxKind.PropertyDeclaration) || member.isKind(ts.SyntaxKind.MethodDeclaration))) {
|
|
10
|
-
const refs = _findReferences(member);
|
|
11
|
-
return !hasExternalReferences(refs, filePath) && !hasInternalReferences(refs);
|
|
12
|
-
}
|
|
13
|
-
return false;
|
|
14
|
-
})
|
|
15
|
-
.map(member => member.getName());
|
|
16
|
-
};
|
|
17
|
-
export const findUnusedEnumMembers = (declaration, filePath) => {
|
|
18
|
-
const members = declaration.getMembers();
|
|
19
|
-
return members
|
|
20
|
-
.filter(member => {
|
|
21
|
-
const refs = _findReferences(member);
|
|
22
|
-
return !hasExternalReferences(refs, filePath) && !hasInternalReferences(refs);
|
|
23
|
-
})
|
|
24
|
-
.map(member => member.getName().replace(/['"`]/g, ''));
|
|
25
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/util/module.test.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import test from 'node:test';
|
|
3
|
-
import { getDefinitelyTypedFor, getPackageFromDefinitelyTyped } from '../../src/util/modules.js';
|
|
4
|
-
test('Should return definitely typed package for package name', () => {
|
|
5
|
-
assert.equal(getDefinitelyTypedFor('node'), '@types/node');
|
|
6
|
-
assert.equal(getDefinitelyTypedFor('@npmcli/map-workspaces'), '@types/npmcli__map-workspaces');
|
|
7
|
-
assert.equal(getDefinitelyTypedFor('@types/node'), '@types/node');
|
|
8
|
-
});
|
|
9
|
-
test('Should return package name from definitely typed package name', () => {
|
|
10
|
-
assert.equal(getPackageFromDefinitelyTyped('node'), 'node');
|
|
11
|
-
assert.equal(getPackageFromDefinitelyTyped('npmcli__map-workspaces'), '@npmcli/map-workspaces');
|
|
12
|
-
});
|
package/dist/util/os.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/util/os.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/util/project.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Project } from 'ts-morph';
|
|
2
|
-
import type { ProjectOptions, SourceFile, ReferenceFindableNode, ReferencedSymbol } from 'ts-morph';
|
|
3
|
-
export declare const partitionSourceFiles: (project: SourceFile[] | Set<SourceFile>, productionFiles: SourceFile[]) => [Set<SourceFile>, Set<SourceFile>];
|
|
4
|
-
export declare const hasExternalReferences: (refs: ReferencedSymbol[], filePath: string) => boolean;
|
|
5
|
-
export declare const hasInternalReferences: (refs: ReferencedSymbol[]) => boolean;
|
|
6
|
-
export declare const _createProject: (projectOptions: ProjectOptions, paths?: string[]) => Project;
|
|
7
|
-
export declare const _resolveSourceFileDependencies: (project: Project) => SourceFile[];
|
|
8
|
-
export declare const _removeExternalSourceFiles: (project: Project) => SourceFile[];
|
|
9
|
-
export declare const _findReferencingNamespaceNodes: (sourceFile: SourceFile) => (import("ts-morph").ImportDeclaration | import("ts-morph").ExportDeclaration)[];
|
|
10
|
-
export declare const _hasReferencingDefaultImport: (sourceFile: SourceFile) => boolean;
|
|
11
|
-
export declare const _findDuplicateExportedNames: (sourceFile: SourceFile) => string[][];
|
|
12
|
-
export declare const _getExportedDeclarations: (sourceFile: SourceFile) => ReadonlyMap<string, import("ts-morph").ExportedDeclarations[]>;
|
|
13
|
-
export declare const _findReferences: (identifier?: ReferenceFindableNode) => ReferencedSymbol[];
|