zedbee 0.1.0-beta.16 → 0.1.0-beta.18
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/THIRD_PARTY_NOTICES.md +68 -74
- package/dist/attribution/metrics.d.ts.map +1 -1
- package/dist/attribution/metrics.js +8 -5
- package/dist/attribution/metrics.js.map +1 -1
- package/dist/attribution/pair-source-moves.d.ts +12 -0
- package/dist/attribution/pair-source-moves.d.ts.map +1 -0
- package/dist/attribution/pair-source-moves.js +108 -0
- package/dist/attribution/pair-source-moves.js.map +1 -0
- package/dist/attribution/source-moves.d.ts +47 -0
- package/dist/attribution/source-moves.d.ts.map +1 -0
- package/dist/attribution/source-moves.js +199 -0
- package/dist/attribution/source-moves.js.map +1 -0
- package/dist/cache/captured-dependencies.d.ts +24 -1
- package/dist/cache/captured-dependencies.d.ts.map +1 -1
- package/dist/cache/captured-dependencies.js +146 -25
- package/dist/cache/captured-dependencies.js.map +1 -1
- package/dist/cache/dependency-inputs.d.ts +3 -1
- package/dist/cache/dependency-inputs.d.ts.map +1 -1
- package/dist/cache/dependency-inputs.js +7 -3
- package/dist/cache/dependency-inputs.js.map +1 -1
- package/dist/checks/adapter.d.ts +1 -0
- package/dist/checks/adapter.d.ts.map +1 -1
- package/dist/checks/applicability.d.ts.map +1 -1
- package/dist/checks/applicability.js +1 -1
- package/dist/checks/applicability.js.map +1 -1
- package/dist/checks/changed-file-paths.d.ts.map +1 -1
- package/dist/checks/changed-file-paths.js +7 -1
- package/dist/checks/changed-file-paths.js.map +1 -1
- package/dist/checks/closed-compiler-project.d.ts +5 -0
- package/dist/checks/closed-compiler-project.d.ts.map +1 -0
- package/dist/checks/closed-compiler-project.js +106 -0
- package/dist/checks/closed-compiler-project.js.map +1 -0
- package/dist/checks/comparison-context.d.ts +3 -1
- package/dist/checks/comparison-context.d.ts.map +1 -1
- package/dist/checks/comparison-context.js +122 -7
- package/dist/checks/comparison-context.js.map +1 -1
- package/dist/checks/compiler-change-inputs.d.ts +12 -0
- package/dist/checks/compiler-change-inputs.d.ts.map +1 -0
- package/dist/checks/compiler-change-inputs.js +104 -0
- package/dist/checks/compiler-change-inputs.js.map +1 -0
- package/dist/checks/compiler-inputs.d.ts +1 -1
- package/dist/checks/compiler-inputs.d.ts.map +1 -1
- package/dist/checks/compiler-inputs.js +65 -5
- package/dist/checks/compiler-inputs.js.map +1 -1
- package/dist/checks/complexity/adapter.d.ts.map +1 -1
- package/dist/checks/complexity/adapter.js +21 -2
- package/dist/checks/complexity/adapter.js.map +1 -1
- package/dist/checks/dead-code/adapter.d.ts.map +1 -1
- package/dist/checks/dead-code/adapter.js +16 -5
- package/dist/checks/dead-code/adapter.js.map +1 -1
- package/dist/checks/dead-code/entry-configuration.d.ts +6 -0
- package/dist/checks/dead-code/entry-configuration.d.ts.map +1 -0
- package/dist/checks/dead-code/entry-configuration.js +48 -0
- package/dist/checks/dead-code/entry-configuration.js.map +1 -0
- package/dist/checks/dead-code/managed-config.d.ts +1 -1
- package/dist/checks/dead-code/managed-config.d.ts.map +1 -1
- package/dist/checks/dead-code/managed-config.js +24 -3
- package/dist/checks/dead-code/managed-config.js.map +1 -1
- package/dist/checks/dead-code/vite-entrypoints.d.ts +13 -0
- package/dist/checks/dead-code/vite-entrypoints.d.ts.map +1 -0
- package/dist/checks/dead-code/vite-entrypoints.js +314 -0
- package/dist/checks/dead-code/vite-entrypoints.js.map +1 -0
- package/dist/checks/diagnostic-details.d.ts.map +1 -1
- package/dist/checks/diagnostic-details.js +32 -0
- package/dist/checks/diagnostic-details.js.map +1 -1
- package/dist/checks/dispatch-cache.d.ts.map +1 -1
- package/dist/checks/dispatch-cache.js +9 -0
- package/dist/checks/dispatch-cache.js.map +1 -1
- package/dist/checks/dispatch-context.d.ts.map +1 -1
- package/dist/checks/dispatch-context.js +1 -0
- package/dist/checks/dispatch-context.js.map +1 -1
- package/dist/checks/dispatch-target.d.ts.map +1 -1
- package/dist/checks/dispatch-target.js +36 -5
- package/dist/checks/dispatch-target.js.map +1 -1
- package/dist/checks/dispatcher.d.ts.map +1 -1
- package/dist/checks/dispatcher.js +20 -7
- package/dist/checks/dispatcher.js.map +1 -1
- package/dist/checks/engine-identity.d.ts.map +1 -1
- package/dist/checks/engine-identity.js +9 -8
- package/dist/checks/engine-identity.js.map +1 -1
- package/dist/checks/eslint/convert-message.d.ts.map +1 -1
- package/dist/checks/eslint/convert-message.js +5 -2
- package/dist/checks/eslint/convert-message.js.map +1 -1
- package/dist/checks/incomplete-error.d.ts +3 -0
- package/dist/checks/incomplete-error.d.ts.map +1 -1
- package/dist/checks/incomplete-error.js +4 -0
- package/dist/checks/incomplete-error.js.map +1 -1
- package/dist/checks/incomplete-result.d.ts +1 -0
- package/dist/checks/incomplete-result.d.ts.map +1 -1
- package/dist/checks/incomplete-result.js +3 -0
- package/dist/checks/incomplete-result.js.map +1 -1
- package/dist/checks/installation-diagnostic.d.ts +11 -0
- package/dist/checks/installation-diagnostic.d.ts.map +1 -0
- package/dist/checks/installation-diagnostic.js +71 -0
- package/dist/checks/installation-diagnostic.js.map +1 -0
- package/dist/checks/observation-result.d.ts.map +1 -1
- package/dist/checks/observation-result.js +69 -7
- package/dist/checks/observation-result.js.map +1 -1
- package/dist/checks/prettier/settings.d.ts +2 -2
- package/dist/checks/project-inputs.d.ts +1 -1
- package/dist/checks/project-inputs.d.ts.map +1 -1
- package/dist/checks/project-inputs.js +13 -4
- package/dist/checks/project-inputs.js.map +1 -1
- package/dist/checks/react/adapter.d.ts.map +1 -1
- package/dist/checks/react/adapter.js +38 -5
- package/dist/checks/react/adapter.js.map +1 -1
- package/dist/checks/runner/envelope.d.ts.map +1 -1
- package/dist/checks/runner/envelope.js +1 -0
- package/dist/checks/runner/envelope.js.map +1 -1
- package/dist/checks/runner/worker.js +3 -0
- package/dist/checks/runner/worker.js.map +1 -1
- package/dist/checks/sanitize-result.d.ts +1 -0
- package/dist/checks/sanitize-result.d.ts.map +1 -1
- package/dist/checks/sanitize-result.js +7 -0
- package/dist/checks/sanitize-result.js.map +1 -1
- package/dist/checks/source-moves.d.ts +9 -0
- package/dist/checks/source-moves.d.ts.map +1 -0
- package/dist/checks/source-moves.js +184 -0
- package/dist/checks/source-moves.js.map +1 -0
- package/dist/checks/structural-security/adapter.d.ts.map +1 -1
- package/dist/checks/structural-security/adapter.js +35 -55
- package/dist/checks/structural-security/adapter.js.map +1 -1
- package/dist/checks/structural-security/parse-failures.d.ts +6 -0
- package/dist/checks/structural-security/parse-failures.d.ts.map +1 -0
- package/dist/checks/structural-security/parse-failures.js +76 -0
- package/dist/checks/structural-security/parse-failures.js.map +1 -0
- package/dist/checks/structural-security/parser.d.ts +18 -0
- package/dist/checks/structural-security/parser.d.ts.map +1 -0
- package/dist/checks/structural-security/parser.js +96 -0
- package/dist/checks/structural-security/parser.js.map +1 -0
- package/dist/checks/structural-security/rules.d.ts.map +1 -1
- package/dist/checks/structural-security/rules.js +67 -113
- package/dist/checks/structural-security/rules.js.map +1 -1
- package/dist/checks/typescript/compiler-host.d.ts.map +1 -1
- package/dist/checks/typescript/compiler-host.js +68 -49
- package/dist/checks/typescript/compiler-host.js.map +1 -1
- package/dist/checks/typescript/compiler-scope-graph.d.ts +11 -0
- package/dist/checks/typescript/compiler-scope-graph.d.ts.map +1 -0
- package/dist/checks/typescript/compiler-scope-graph.js +694 -0
- package/dist/checks/typescript/compiler-scope-graph.js.map +1 -0
- package/dist/checks/typescript/compiler-scope-inputs.d.ts +20 -0
- package/dist/checks/typescript/compiler-scope-inputs.d.ts.map +1 -0
- package/dist/checks/typescript/compiler-scope-inputs.js +183 -0
- package/dist/checks/typescript/compiler-scope-inputs.js.map +1 -0
- package/dist/checks/typescript/config.d.ts +3 -0
- package/dist/checks/typescript/config.d.ts.map +1 -1
- package/dist/checks/typescript/config.js +2 -2
- package/dist/checks/typescript/config.js.map +1 -1
- package/dist/checks/typescript/configuration-paths.d.ts +3 -2
- package/dist/checks/typescript/configuration-paths.d.ts.map +1 -1
- package/dist/checks/typescript/configuration-paths.js +67 -12
- package/dist/checks/typescript/configuration-paths.js.map +1 -1
- package/dist/checks/typescript/convert-diagnostic.d.ts +1 -2
- package/dist/checks/typescript/convert-diagnostic.d.ts.map +1 -1
- package/dist/checks/typescript/convert-diagnostic.js +2 -16
- package/dist/checks/typescript/convert-diagnostic.js.map +1 -1
- package/dist/checks/typescript/diagnostic-message.d.ts +3 -0
- package/dist/checks/typescript/diagnostic-message.d.ts.map +1 -0
- package/dist/checks/typescript/diagnostic-message.js +18 -0
- package/dist/checks/typescript/diagnostic-message.js.map +1 -0
- package/dist/checks/typescript/project-coverage.d.ts.map +1 -1
- package/dist/checks/typescript/project-coverage.js +3 -2
- package/dist/checks/typescript/project-coverage.js.map +1 -1
- package/dist/checks/typescript/reuse-inputs.d.ts +3 -0
- package/dist/checks/typescript/reuse-inputs.d.ts.map +1 -1
- package/dist/checks/typescript/reuse-inputs.js +14 -4
- package/dist/checks/typescript/reuse-inputs.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/checks.js +3 -3
- package/dist/commands/checks.js.map +1 -1
- package/dist/commands/diagnostics.d.ts +2 -0
- package/dist/commands/diagnostics.d.ts.map +1 -1
- package/dist/commands/diagnostics.js +34 -0
- package/dist/commands/diagnostics.js.map +1 -1
- package/dist/commands/fix.d.ts.map +1 -1
- package/dist/commands/fix.js +4 -1
- package/dist/commands/fix.js.map +1 -1
- package/dist/commands/scan.d.ts +1 -0
- package/dist/commands/scan.d.ts.map +1 -1
- package/dist/commands/scan.js +31 -3
- package/dist/commands/scan.js.map +1 -1
- package/dist/config/profiles.d.ts.map +1 -1
- package/dist/config/profiles.js +6 -0
- package/dist/config/profiles.js.map +1 -1
- package/dist/config/schema.d.ts +43 -23
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +16 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/config/settings-registry.js +2 -2
- package/dist/config/settings-registry.js.map +1 -1
- package/dist/core/types.d.ts +14 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/diagnostics/local-scan-diagnostics.d.ts +12 -0
- package/dist/diagnostics/local-scan-diagnostics.d.ts.map +1 -0
- package/dist/diagnostics/local-scan-diagnostics.js +138 -0
- package/dist/diagnostics/local-scan-diagnostics.js.map +1 -0
- package/dist/diagnostics/scan-performance.d.ts +2 -0
- package/dist/diagnostics/scan-performance.d.ts.map +1 -1
- package/dist/diagnostics/scan-performance.js +22 -20
- package/dist/diagnostics/scan-performance.js.map +1 -1
- package/dist/doctor/diagnostics.d.ts.map +1 -1
- package/dist/doctor/diagnostics.js +22 -3
- package/dist/doctor/diagnostics.js.map +1 -1
- package/dist/doctor/workspace-installation.d.ts +9 -0
- package/dist/doctor/workspace-installation.d.ts.map +1 -0
- package/dist/doctor/workspace-installation.js +165 -0
- package/dist/doctor/workspace-installation.js.map +1 -0
- package/dist/hooks/detect.d.ts +4 -0
- package/dist/hooks/detect.d.ts.map +1 -1
- package/dist/hooks/detect.js +5 -4
- package/dist/hooks/detect.js.map +1 -1
- package/dist/hooks/update-notice.d.ts +5 -0
- package/dist/hooks/update-notice.d.ts.map +1 -0
- package/dist/hooks/update-notice.js +145 -0
- package/dist/hooks/update-notice.js.map +1 -0
- package/dist/init/presentation.d.ts +2 -2
- package/dist/renderers/incomplete.d.ts +5 -1
- package/dist/renderers/incomplete.d.ts.map +1 -1
- package/dist/renderers/incomplete.js +29 -2
- package/dist/renderers/incomplete.js.map +1 -1
- package/dist/renderers/json.d.ts.map +1 -1
- package/dist/renderers/json.js +20 -3
- package/dist/renderers/json.js.map +1 -1
- package/dist/renderers/sarif.d.ts.map +1 -1
- package/dist/renderers/sarif.js +7 -0
- package/dist/renderers/sarif.js.map +1 -1
- package/dist/renderers/text.d.ts.map +1 -1
- package/dist/renderers/text.js +20 -0
- package/dist/renderers/text.js.map +1 -1
- package/dist/reporting/agent-guidance.d.ts.map +1 -1
- package/dist/reporting/agent-guidance.js +7 -0
- package/dist/reporting/agent-guidance.js.map +1 -1
- package/dist/reporting/finding-priority.d.ts +6 -0
- package/dist/reporting/finding-priority.d.ts.map +1 -0
- package/dist/reporting/finding-priority.js +69 -0
- package/dist/reporting/finding-priority.js.map +1 -0
- package/dist/reporting/fix-plan-store.d.ts +2 -5
- package/dist/reporting/fix-plan-store.d.ts.map +1 -1
- package/dist/reporting/fix-plan-store.js +2 -1
- package/dist/reporting/fix-plan-store.js.map +1 -1
- package/dist/reporting/fix-presentation.d.ts +1 -1
- package/dist/reporting/hook-update-notice.d.ts +12 -0
- package/dist/reporting/hook-update-notice.d.ts.map +1 -0
- package/dist/reporting/hook-update-notice.js +13 -0
- package/dist/reporting/hook-update-notice.js.map +1 -0
- package/dist/reporting/presentation.d.ts +3 -1
- package/dist/reporting/presentation.d.ts.map +1 -1
- package/dist/reporting/presentation.js +19 -7
- package/dist/reporting/presentation.js.map +1 -1
- package/dist/reporting/result-sections.d.ts +1 -0
- package/dist/reporting/result-sections.d.ts.map +1 -1
- package/dist/reporting/result-sections.js +12 -0
- package/dist/reporting/result-sections.js.map +1 -1
- package/dist/reporting/temporary-report-common.d.ts +13 -1
- package/dist/reporting/temporary-report-common.d.ts.map +1 -1
- package/dist/reporting/temporary-report-common.js +4 -1
- package/dist/reporting/temporary-report-common.js.map +1 -1
- package/dist/reporting/temporary-report-lifecycle.d.ts +3 -3
- package/dist/reporting/temporary-report-lifecycle.d.ts.map +1 -1
- package/dist/reporting/temporary-report-lifecycle.js +18 -4
- package/dist/reporting/temporary-report-lifecycle.js.map +1 -1
- package/dist/reporting/temporary-reports.d.ts +1 -1
- package/dist/reporting/temporary-reports.d.ts.map +1 -1
- package/dist/reporting/temporary-reports.js +22 -3
- package/dist/reporting/temporary-reports.js.map +1 -1
- package/dist/scan/analysis-session.d.ts.map +1 -1
- package/dist/scan/analysis-session.js +15 -1
- package/dist/scan/analysis-session.js.map +1 -1
- package/dist/scan/report.d.ts +6 -0
- package/dist/scan/report.d.ts.map +1 -1
- package/dist/scan/run-scan.d.ts.map +1 -1
- package/dist/scan/run-scan.js +17 -8
- package/dist/scan/run-scan.js.map +1 -1
- package/dist/service/server-connection.d.ts.map +1 -1
- package/dist/service/server-connection.js +2 -1
- package/dist/service/server-connection.js.map +1 -1
- package/dist/telemetry/schema.d.ts +45 -45
- package/dist/telemetry/state.d.ts +5 -5
- package/dist/ui/incomplete-list.d.ts.map +1 -1
- package/dist/ui/incomplete-list.js +4 -2
- package/dist/ui/incomplete-list.js.map +1 -1
- package/dist/ui/scan-result-dashboard.d.ts.map +1 -1
- package/dist/ui/scan-result-dashboard.js +7 -3
- package/dist/ui/scan-result-dashboard.js.map +1 -1
- package/docs/checks.md +106 -2
- package/docs/cli-reference.md +7 -1
- package/docs/privacy.md +15 -0
- package/docs/react-analysis.md +7 -0
- package/docs/reporting.md +43 -1
- package/docs/support.md +19 -0
- package/{node_modules/dependency-cruiser/node_modules/picomatch/LICENSE → licenses/overrides/jscpd-5.4.2-LICENSE} +5 -5
- package/licenses/overrides/napi-rs-wasm-runtime-1.2.5-LICENSE +43 -0
- package/licenses/reviewed-overrides.json +70 -0
- package/node_modules/acorn/CHANGELOG.md +14 -0
- package/node_modules/acorn/dist/acorn.js +42 -14
- package/node_modules/acorn/dist/acorn.mjs +42 -14
- package/node_modules/acorn/package.json +1 -1
- package/node_modules/dependency-cruiser/README.md +7 -8
- package/node_modules/dependency-cruiser/bin/depcruise-baseline.mjs +12 -5
- package/node_modules/dependency-cruiser/bin/{dependency-cruise.mjs → dependency-cruiser.mjs} +24 -14
- package/node_modules/dependency-cruiser/configs/rules/no-duplicate-dependency-types.cjs +1 -1
- package/node_modules/dependency-cruiser/node_modules/ignore/README.md +138 -8
- package/node_modules/dependency-cruiser/node_modules/ignore/index.d.ts +56 -20
- package/node_modules/dependency-cruiser/node_modules/ignore/index.js +1032 -229
- package/node_modules/dependency-cruiser/node_modules/ignore/legacy.js +868 -184
- package/node_modules/dependency-cruiser/node_modules/ignore/package.json +10 -4
- package/node_modules/dependency-cruiser/node_modules/semver/LICENSE +15 -0
- package/node_modules/dependency-cruiser/node_modules/semver/README.md +680 -0
- package/node_modules/dependency-cruiser/node_modules/semver/bin/semver.js +195 -0
- package/node_modules/dependency-cruiser/node_modules/semver/classes/comparator.js +143 -0
- package/node_modules/dependency-cruiser/node_modules/semver/classes/index.js +7 -0
- package/node_modules/dependency-cruiser/node_modules/semver/classes/range.js +577 -0
- package/node_modules/dependency-cruiser/node_modules/semver/classes/semver.js +350 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/clean.js +8 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/cmp.js +54 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/coerce.js +62 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/compare-build.js +9 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/compare-loose.js +5 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/compare.js +7 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/diff.js +60 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/eq.js +5 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/gt.js +5 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/gte.js +5 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/inc.js +21 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/lt.js +5 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/lte.js +5 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/major.js +5 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/minor.js +5 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/neq.js +5 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/parse.js +18 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/patch.js +5 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/prerelease.js +8 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/rcompare.js +5 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/rsort.js +5 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/satisfies.js +12 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/sort.js +5 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/truncate.js +48 -0
- package/node_modules/dependency-cruiser/node_modules/semver/functions/valid.js +8 -0
- package/node_modules/dependency-cruiser/node_modules/semver/index.js +93 -0
- package/node_modules/dependency-cruiser/node_modules/semver/internal/constants.js +67 -0
- package/node_modules/dependency-cruiser/node_modules/semver/internal/debug.js +11 -0
- package/node_modules/dependency-cruiser/node_modules/semver/internal/identifiers.js +29 -0
- package/node_modules/dependency-cruiser/node_modules/semver/internal/lrucache.js +42 -0
- package/node_modules/dependency-cruiser/node_modules/semver/internal/parse-options.js +17 -0
- package/node_modules/dependency-cruiser/node_modules/semver/internal/re.js +223 -0
- package/node_modules/dependency-cruiser/node_modules/semver/internal/trim-comparator-whitespace.js +438 -0
- package/node_modules/dependency-cruiser/node_modules/semver/package.json +78 -0
- package/node_modules/dependency-cruiser/node_modules/semver/preload.js +4 -0
- package/node_modules/dependency-cruiser/node_modules/semver/range.bnf +17 -0
- package/node_modules/dependency-cruiser/node_modules/semver/ranges/gtr.js +6 -0
- package/node_modules/dependency-cruiser/node_modules/semver/ranges/intersects.js +9 -0
- package/node_modules/dependency-cruiser/node_modules/semver/ranges/ltr.js +6 -0
- package/node_modules/dependency-cruiser/node_modules/semver/ranges/max-satisfying.js +27 -0
- package/node_modules/dependency-cruiser/node_modules/semver/ranges/min-satisfying.js +26 -0
- package/node_modules/dependency-cruiser/node_modules/semver/ranges/min-version.js +63 -0
- package/node_modules/dependency-cruiser/node_modules/semver/ranges/outside.js +82 -0
- package/node_modules/dependency-cruiser/node_modules/semver/ranges/simplify.js +49 -0
- package/node_modules/dependency-cruiser/node_modules/semver/ranges/subset.js +249 -0
- package/node_modules/dependency-cruiser/node_modules/semver/ranges/to-comparators.js +10 -0
- package/node_modules/dependency-cruiser/node_modules/semver/ranges/valid.js +13 -0
- package/node_modules/dependency-cruiser/package.json +16 -10
- package/node_modules/dependency-cruiser/src/analyze/analyze-modules.mjs +5 -1
- package/node_modules/dependency-cruiser/src/analyze/index.mjs +3 -3
- package/node_modules/dependency-cruiser/src/analyze/soften-known-violations.mjs +4 -2
- package/node_modules/dependency-cruiser/src/analyze/summarize/get-stats.mjs +38 -3
- package/node_modules/dependency-cruiser/src/analyze/summarize/index.mjs +28 -105
- package/node_modules/dependency-cruiser/src/analyze/summarize/summarize-options.mjs +3 -0
- package/node_modules/dependency-cruiser/src/analyze/summarize/verify-environment.mjs +146 -0
- package/node_modules/dependency-cruiser/src/cache/cache.mjs +1 -1
- package/node_modules/dependency-cruiser/src/cache/options-compatible.mjs +3 -0
- package/node_modules/dependency-cruiser/src/cli/defaults.mjs +0 -1
- package/node_modules/dependency-cruiser/src/cli/index.mjs +11 -3
- package/node_modules/dependency-cruiser/src/cli/init-config/build-config.mjs +14 -0
- package/node_modules/dependency-cruiser/src/cli/init-config/config-template.mjs +7 -2
- package/node_modules/dependency-cruiser/src/cli/init-config/environment-helpers.mjs +5 -1
- package/node_modules/dependency-cruiser/src/cli/init-config/get-user-input.mjs +11 -0
- package/node_modules/dependency-cruiser/src/cli/init-config/index.mjs +1 -0
- package/node_modules/dependency-cruiser/src/cli/init-config/normalize-init-options.mjs +1 -1
- package/node_modules/dependency-cruiser/src/cli/init-config/types.d.mts +4 -0
- package/node_modules/dependency-cruiser/src/cli/init-config/write-run-scripts-to-manifest.mjs +7 -7
- package/node_modules/dependency-cruiser/src/cli/normalize-cli-options.mjs +63 -2
- package/node_modules/dependency-cruiser/src/config-utl/extract-ts-config.mjs +1 -1
- package/node_modules/dependency-cruiser/src/extract/helpers.mjs +1 -0
- package/node_modules/dependency-cruiser/src/extract/resolve/determine-dependency-types.mjs +15 -7
- package/node_modules/dependency-cruiser/src/extract/resolve/merge-manifests.mjs +6 -3
- package/node_modules/dependency-cruiser/src/extract/swc/dependency-visitor.mjs +21 -4
- package/node_modules/dependency-cruiser/src/extract/swc/parse.mjs +14 -4
- package/node_modules/dependency-cruiser/src/extract/transpile/index.mjs +1 -1
- package/node_modules/dependency-cruiser/src/extract/transpile/meta.mjs +15 -3
- package/node_modules/dependency-cruiser/src/extract/transpile/svelte-wrap.mjs +23 -2
- package/node_modules/dependency-cruiser/src/extract/transpile/try-import-available.mjs +2 -2
- package/node_modules/dependency-cruiser/src/extract/transpile/typescript-wrap.mjs +23 -1
- package/node_modules/dependency-cruiser/src/extract/tsc/extract-typescript-deps.mjs +57 -12
- package/node_modules/dependency-cruiser/src/extract/tsc/extract.mjs +2 -0
- package/node_modules/dependency-cruiser/src/graph-utl/add-focus.mjs +2 -2
- package/node_modules/dependency-cruiser/src/graph-utl/compare.mjs +113 -14
- package/node_modules/dependency-cruiser/src/main/cruise.mjs +1 -2
- package/node_modules/dependency-cruiser/src/main/format.mjs +1 -1
- package/node_modules/dependency-cruiser/src/main/options/defaults.mjs +1 -0
- package/node_modules/dependency-cruiser/src/main/options/normalize.mjs +13 -4
- package/node_modules/dependency-cruiser/src/main/report-wrap.mjs +4 -2
- package/node_modules/dependency-cruiser/src/main/resolve-options/normalize.mjs +0 -27
- package/node_modules/dependency-cruiser/src/meta.cjs +1 -1
- package/node_modules/dependency-cruiser/src/report/anon/index.mjs +1 -1
- package/node_modules/dependency-cruiser/src/report/azure-devops.mjs +15 -11
- package/node_modules/dependency-cruiser/src/report/baseline.mjs +67 -10
- package/node_modules/dependency-cruiser/src/report/csv.mjs +1 -1
- package/node_modules/dependency-cruiser/src/report/dot/index.mjs +1 -1
- package/node_modules/dependency-cruiser/src/report/dot-webpage/dot-module.mjs +1 -1
- package/node_modules/dependency-cruiser/src/report/error-html/error-html-template.mjs +2 -0
- package/node_modules/dependency-cruiser/src/report/error-html/index.mjs +84 -8
- package/node_modules/dependency-cruiser/src/report/error.mjs +62 -13
- package/node_modules/dependency-cruiser/src/report/html/index.mjs +1 -1
- package/node_modules/dependency-cruiser/src/report/index.mjs +3 -2
- package/node_modules/dependency-cruiser/src/report/markdown.mjs +89 -19
- package/node_modules/dependency-cruiser/src/report/metrics.mjs +3 -3
- package/node_modules/dependency-cruiser/src/report/null.mjs +6 -3
- package/node_modules/dependency-cruiser/src/report/teamcity.mjs +4 -1
- package/node_modules/dependency-cruiser/src/schema/configuration.validate.mjs +1 -1
- package/node_modules/dependency-cruiser/src/schema/cruise-result.validate.mjs +1 -1
- package/node_modules/dependency-cruiser/src/utl/try-import.mjs +1 -1
- package/node_modules/dependency-cruiser/types/cruise-result.d.mts +14 -0
- package/node_modules/dependency-cruiser/types/dependency-cruiser.d.mts +6 -0
- package/node_modules/dependency-cruiser/types/options.d.mts +37 -2
- package/node_modules/dependency-cruiser/types/reporter-options.d.mts +30 -5
- package/node_modules/dependency-cruiser/types/restrictions.d.mts +2 -2
- package/node_modules/dependency-cruiser/types/shared-types.d.mts +16 -13
- package/node_modules/enhanced-resolve/README.md +46 -1
- package/node_modules/enhanced-resolve/lib/ExportsFieldPlugin.js +31 -6
- package/node_modules/enhanced-resolve/lib/ImportsFieldPlugin.js +27 -6
- package/node_modules/enhanced-resolve/lib/PackageMapPlugin.js +297 -0
- package/node_modules/enhanced-resolve/lib/Resolver.js +37 -30
- package/node_modules/enhanced-resolve/lib/ResolverFactory.js +104 -11
- package/node_modules/enhanced-resolve/lib/getPaths.js +6 -1
- package/node_modules/enhanced-resolve/lib/index.js +4 -0
- package/node_modules/enhanced-resolve/lib/util/entrypoints.js +104 -0
- package/node_modules/enhanced-resolve/lib/util/graceful-fs-browser.js +5 -1
- package/node_modules/enhanced-resolve/lib/util/identifier.js +4 -2
- package/node_modules/enhanced-resolve/lib/util/packageMap.js +224 -0
- package/node_modules/enhanced-resolve/lib/util/path.js +29 -8
- package/node_modules/enhanced-resolve/lib/util/pathToFileURL.js +87 -0
- package/node_modules/enhanced-resolve/package.json +8 -9
- package/node_modules/enhanced-resolve/types/AliasFieldPlugin.d.ts +41 -0
- package/node_modules/enhanced-resolve/types/AliasPlugin.d.ts +32 -0
- package/node_modules/enhanced-resolve/types/AliasUtils.d.ts +128 -0
- package/node_modules/enhanced-resolve/types/AppendPlugin.d.ts +27 -0
- package/node_modules/enhanced-resolve/types/CachedInputFileSystem.d.ts +224 -0
- package/node_modules/enhanced-resolve/types/CloneBasenamePlugin.d.ts +24 -0
- package/node_modules/enhanced-resolve/types/ConditionalPlugin.d.ts +33 -0
- package/node_modules/enhanced-resolve/types/DescriptionFilePlugin.d.ts +30 -0
- package/node_modules/enhanced-resolve/types/DescriptionFileUtils.d.ts +83 -0
- package/node_modules/enhanced-resolve/types/DirectoryExistsPlugin.d.ts +23 -0
- package/node_modules/enhanced-resolve/types/ExportsFieldPlugin.d.ts +45 -0
- package/node_modules/enhanced-resolve/types/ExtensionAliasPlugin.d.ts +31 -0
- package/node_modules/enhanced-resolve/types/FileExistsPlugin.d.ts +23 -0
- package/node_modules/enhanced-resolve/types/ImportsFieldPlugin.d.ts +45 -0
- package/node_modules/enhanced-resolve/types/JoinRequestPartPlugin.d.ts +24 -0
- package/node_modules/enhanced-resolve/types/JoinRequestPlugin.d.ts +24 -0
- package/node_modules/enhanced-resolve/types/LogInfoPlugin.d.ts +18 -0
- package/node_modules/enhanced-resolve/types/MainFieldPlugin.d.ts +41 -0
- package/node_modules/enhanced-resolve/types/ModulesInHierachicDirectoriesPlugin.d.ts +2 -0
- package/node_modules/enhanced-resolve/types/ModulesInHierarchicalDirectoriesPlugin.d.ts +26 -0
- package/node_modules/enhanced-resolve/types/ModulesInRootPlugin.d.ts +27 -0
- package/node_modules/enhanced-resolve/types/ModulesUtils.d.ts +25 -0
- package/node_modules/enhanced-resolve/types/NextPlugin.d.ts +23 -0
- package/node_modules/enhanced-resolve/types/PackageMapPlugin.d.ts +85 -0
- package/node_modules/enhanced-resolve/types/ParsePlugin.d.ts +27 -0
- package/node_modules/enhanced-resolve/types/PnpPlugin.d.ts +42 -0
- package/node_modules/enhanced-resolve/types/Resolver.d.ts +1545 -0
- package/node_modules/enhanced-resolve/types/ResolverFactory.d.ts +340 -0
- package/node_modules/enhanced-resolve/types/RestrictionsPlugin.d.ts +52 -0
- package/node_modules/enhanced-resolve/types/ResultPlugin.d.ts +18 -0
- package/node_modules/enhanced-resolve/types/RootsPlugin.d.ts +30 -0
- package/node_modules/enhanced-resolve/types/SelfReferencePlugin.d.ts +31 -0
- package/node_modules/enhanced-resolve/types/SymlinkPlugin.d.ts +24 -0
- package/node_modules/enhanced-resolve/types/SyncAsyncFileSystemDecorator.d.ts +52 -0
- package/node_modules/enhanced-resolve/types/TryNextPlugin.d.ts +26 -0
- package/node_modules/enhanced-resolve/types/TsconfigPathsPlugin.d.ts +204 -0
- package/node_modules/enhanced-resolve/types/UnsafeCachePlugin.d.ts +43 -0
- package/node_modules/enhanced-resolve/types/UseFilePlugin.d.ts +27 -0
- package/node_modules/enhanced-resolve/types/createInnerContext.d.ts +10 -0
- package/node_modules/enhanced-resolve/types/forEachBail.d.ts +15 -0
- package/node_modules/enhanced-resolve/types/getInnerRequest.d.ts +7 -0
- package/node_modules/enhanced-resolve/types/getPaths.d.ts +34 -0
- package/node_modules/enhanced-resolve/types/index.d.ts +131 -0
- package/node_modules/enhanced-resolve/types/util/entrypoints.d.ts +62 -0
- package/node_modules/enhanced-resolve/types/util/fileURLToPath.d.ts +14 -0
- package/node_modules/enhanced-resolve/types/util/fs.d.ts +38 -0
- package/node_modules/enhanced-resolve/types/util/graceful-fs-browser.d.ts +22 -0
- package/node_modules/enhanced-resolve/types/util/identifier.d.ts +7 -0
- package/node_modules/enhanced-resolve/types/util/memoize.d.ts +15 -0
- package/node_modules/enhanced-resolve/types/util/module-browser.d.ts +1 -0
- package/node_modules/enhanced-resolve/types/util/packageMap.d.ts +118 -0
- package/node_modules/enhanced-resolve/types/util/path-browser.d.ts +45 -0
- package/node_modules/enhanced-resolve/types/util/path.d.ts +125 -0
- package/node_modules/enhanced-resolve/types/util/pathToFileURL.d.ts +14 -0
- package/node_modules/enhanced-resolve/types/util/process-browser.d.ts +3 -0
- package/node_modules/enhanced-resolve/types/util/strip-json-comments.d.ts +24 -0
- package/node_modules/enhanced-resolve/types/util/url-browser.d.ts +1 -0
- package/node_modules/enhanced-resolve/types.d.ts +5 -2057
- package/node_modules/is-installed-globally/index.js +26 -4
- package/node_modules/is-installed-globally/package.json +1 -1
- package/package.json +5 -5
- package/schema/zedbee.schema.json +12 -1
- package/node_modules/dependency-cruiser/node_modules/picomatch/README.md +0 -743
- package/node_modules/dependency-cruiser/node_modules/picomatch/index.js +0 -17
- package/node_modules/dependency-cruiser/node_modules/picomatch/lib/constants.js +0 -184
- package/node_modules/dependency-cruiser/node_modules/picomatch/lib/parse.js +0 -1416
- package/node_modules/dependency-cruiser/node_modules/picomatch/lib/picomatch.js +0 -361
- package/node_modules/dependency-cruiser/node_modules/picomatch/lib/scan.js +0 -391
- package/node_modules/dependency-cruiser/node_modules/picomatch/lib/utils.js +0 -72
- package/node_modules/dependency-cruiser/node_modules/picomatch/package.json +0 -83
- package/node_modules/dependency-cruiser/node_modules/picomatch/posix.js +0 -3
|
@@ -9,8 +9,14 @@ const UNDEFINED = undefined
|
|
|
9
9
|
const EMPTY = ''
|
|
10
10
|
const SPACE = ' '
|
|
11
11
|
const ESCAPE = '\\'
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
// The characters that carry a meaning of their own inside a regular
|
|
14
|
+
// expression, so a literal one has to be escaped before it is emitted.
|
|
15
|
+
const REGEX_LITERAL_SPECIAL = /[.*+?()[\]{}^$|\\/]/
|
|
16
|
+
const BOM = '\uFEFF'
|
|
13
17
|
const REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/
|
|
18
|
+
// A run of two or more asterisks is a globstar (#175)
|
|
19
|
+
const REGEX_ANCHORED_GLOBSTAR = /^\/\*{2,}$/
|
|
14
20
|
const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/
|
|
15
21
|
const REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/
|
|
16
22
|
const REGEX_SPLITALL_CRLF = /\r?\n/g
|
|
@@ -23,9 +29,10 @@ const REGEX_SPLITALL_CRLF = /\r?\n/g
|
|
|
23
29
|
// - ..
|
|
24
30
|
// Valid:
|
|
25
31
|
// - .foo
|
|
26
|
-
const
|
|
32
|
+
const DOUBLE_SLASH = '//'
|
|
33
|
+
const SLASH_CODE = 47
|
|
34
|
+
const DOT_CODE = 46
|
|
27
35
|
|
|
28
|
-
const REGEX_TEST_TRAILING_SLASH = /\/$/
|
|
29
36
|
|
|
30
37
|
const SLASH = '/'
|
|
31
38
|
|
|
@@ -42,36 +49,336 @@ const define = (object, key, value) => {
|
|
|
42
49
|
return value
|
|
43
50
|
}
|
|
44
51
|
|
|
45
|
-
const REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g
|
|
46
|
-
|
|
47
52
|
const RETURN_FALSE = () => false
|
|
48
53
|
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
// > The range notation, e.g. [a-zA-Z],
|
|
55
|
+
// > can be used to match one of the characters in a range.
|
|
56
|
+
//
|
|
57
|
+
// gitignore(5) defers to fnmatch(3) for this, and git implements it in
|
|
58
|
+
// `wildmatch.c`. A bracket expression has a sub-grammar of its own, which
|
|
59
|
+
// is neither the surrounding pattern grammar nor the JavaScript one:
|
|
60
|
+
//
|
|
61
|
+
// - a `]` right after `[` or `[!` is a literal member, not the terminator
|
|
62
|
+
// - `[:alpha:]` names one of twelve POSIX classes
|
|
63
|
+
// - `\` escapes the next member, `]` included
|
|
64
|
+
// - `*`, `?` and `.` are plain literal members
|
|
65
|
+
// - an unterminated expression makes the whole pattern match nothing
|
|
66
|
+
//
|
|
67
|
+
// which means the expression can not be located -- let alone translated -- by
|
|
68
|
+
// a regular expression. It is scanned out of the pattern before the
|
|
69
|
+
// replacers below run, and put back once they are done, so that neither the
|
|
70
|
+
// metacharacter escaper nor the `?` / `*` replacers ever see its body.
|
|
71
|
+
|
|
72
|
+
// git classifies with its own ASCII-only ctype macros (`wildmatch.c`), never
|
|
73
|
+
// with the C library ones, so these must not be mapped onto `\d` / `\w` /
|
|
74
|
+
// `\s`, which are wider. `/` is left out of every expansion, because a
|
|
75
|
+
// bracket expression never matches a path separator.
|
|
76
|
+
const POSIX_CLASSES = {
|
|
77
|
+
alnum: '0-9A-Za-z',
|
|
78
|
+
alpha: 'A-Za-z',
|
|
79
|
+
blank: ' \\t',
|
|
80
|
+
cntrl: '\\x00-\\x1f\\x7f',
|
|
81
|
+
digit: '0-9',
|
|
82
|
+
graph: '!-.0-~',
|
|
83
|
+
lower: 'a-z',
|
|
84
|
+
print: ' -.0-~',
|
|
85
|
+
punct: '!-.:-@\\[-`{-~',
|
|
86
|
+
// git's `sane-ctype.h` classifies \v and \f as control, not space,
|
|
87
|
+
// unlike C's `isspace`
|
|
88
|
+
space: ' \\t\\n\\r',
|
|
89
|
+
upper: 'A-Z',
|
|
90
|
+
xdigit: '0-9A-Fa-f'
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const CLASS_MEMBERS_TO_ESCAPE = '\\]^-['
|
|
94
|
+
|
|
95
|
+
const escapeMember = char => CLASS_MEMBERS_TO_ESCAPE.indexOf(char) < 0
|
|
96
|
+
? char
|
|
97
|
+
: ESCAPE + char
|
|
98
|
+
|
|
99
|
+
// > if (matched == negated || ((flags & WM_PATHNAME) && text_ch == '/'))
|
|
100
|
+
// > return WM_ABORT_TO_STARSTAR; (git, `wildmatch.c`)
|
|
101
|
+
// A bracket expression never matches a path separator, whatever its members
|
|
102
|
+
// say, so a negated class gets `/` as one more excluded character, while a
|
|
103
|
+
// plain one -- where a literal member or a range could still let `/` in --
|
|
104
|
+
// is guarded with a lookahead, `/` being impossible to subtract from a
|
|
105
|
+
// JavaScript character class.
|
|
106
|
+
const NON_SLASH = '(?!\\/)'
|
|
107
|
+
|
|
108
|
+
const classSource = (negated, body) => {
|
|
109
|
+
if (negated) {
|
|
110
|
+
return `[^\\/${body}]`
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const source = `[${body}]`
|
|
114
|
+
|
|
115
|
+
return new RegExp(source).test('/')
|
|
116
|
+
? NON_SLASH + source
|
|
117
|
+
: source
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Scan the bracket expression that starts at `pattern[start] === '['`,
|
|
121
|
+
// mirroring the member loop of git's `wildmatch.c`.
|
|
122
|
+
// @returns {{end: number, source: string} | null} `null` if the expression is
|
|
123
|
+
// never terminated, which makes the whole pattern match nothing.
|
|
124
|
+
const scanBracket = (pattern, start) => {
|
|
125
|
+
const {length} = pattern
|
|
126
|
+
let index = start + 1
|
|
127
|
+
let negated = EMPTY
|
|
128
|
+
|
|
129
|
+
const lead = pattern[index]
|
|
130
|
+
if (lead === '!' || lead === '^') {
|
|
131
|
+
negated = '^'
|
|
132
|
+
index ++
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
let body = EMPTY
|
|
136
|
+
|
|
137
|
+
// The member a `-` could start a range from, or EMPTY when the previous
|
|
138
|
+
// member can not open one (start of the body, or a range / POSIX class
|
|
139
|
+
// that has just closed)
|
|
140
|
+
let prev = EMPTY
|
|
141
|
+
|
|
142
|
+
// git scans the members with a do-while, so the first one is consumed
|
|
143
|
+
// unconditionally. That is the whole reason a leading `]` is a member
|
|
144
|
+
// and not the terminator.
|
|
145
|
+
for (;;) {
|
|
146
|
+
const char = pattern[index]
|
|
147
|
+
|
|
148
|
+
if (char === UNDEFINED) {
|
|
149
|
+
return null
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (char === ESCAPE) {
|
|
153
|
+
const escaped = pattern[index + 1]
|
|
154
|
+
if (escaped === UNDEFINED) {
|
|
155
|
+
return null
|
|
156
|
+
}
|
|
157
|
+
body += escapeMember(escaped)
|
|
158
|
+
prev = escaped
|
|
159
|
+
index ++
|
|
160
|
+
} else if (
|
|
161
|
+
char === '-'
|
|
162
|
+
&& prev
|
|
163
|
+
&& index + 1 < length
|
|
164
|
+
&& pattern[index + 1] !== ']'
|
|
165
|
+
) {
|
|
166
|
+
index ++
|
|
167
|
+
let to = pattern[index]
|
|
168
|
+
if (to === ESCAPE) {
|
|
169
|
+
// A pattern can not end on a lone backslash -- `checkPattern` has
|
|
170
|
+
// already thrown it away -- so there is an upper bound to read.
|
|
171
|
+
to = pattern[index += 1]
|
|
172
|
+
}
|
|
173
|
+
// An out-of-order range matches nothing in git but is a syntax error in
|
|
174
|
+
// JavaScript, so it is dropped. Its lower bound stays: git tests it
|
|
175
|
+
// as a plain member before it ever looks at the `-`, so `[c-a]` does
|
|
176
|
+
// match `c`.
|
|
177
|
+
if (prev <= to) {
|
|
178
|
+
body += `-${escapeMember(to)}`
|
|
179
|
+
}
|
|
180
|
+
prev = EMPTY
|
|
181
|
+
} else if (char === '[' && pattern[index + 1] === ':') {
|
|
182
|
+
const nameStart = index + 2
|
|
183
|
+
let end = nameStart
|
|
184
|
+
while (end < length && pattern[end] !== ']') {
|
|
185
|
+
end ++
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (end === length) {
|
|
189
|
+
return null
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (end > nameStart && pattern[end - 1] === ':') {
|
|
193
|
+
const name = pattern.slice(nameStart, end - 1)
|
|
194
|
+
|
|
195
|
+
// An unknown class name makes the whole pattern match nothing
|
|
196
|
+
if (!Object.prototype.hasOwnProperty.call(POSIX_CLASSES, name)) {
|
|
197
|
+
return null
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
body += POSIX_CLASSES[name]
|
|
201
|
+
prev = EMPTY
|
|
202
|
+
index = end
|
|
203
|
+
} else {
|
|
204
|
+
// No `:]` to close it, so the `[` is a plain member and scanning
|
|
205
|
+
// resumes right after it.
|
|
206
|
+
body += escapeMember('[')
|
|
207
|
+
prev = '['
|
|
208
|
+
index = nameStart - 2
|
|
209
|
+
}
|
|
210
|
+
} else {
|
|
211
|
+
body += escapeMember(char)
|
|
212
|
+
prev = char
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
index ++
|
|
216
|
+
|
|
217
|
+
if (pattern[index] === ']') {
|
|
218
|
+
return {
|
|
219
|
+
end: index,
|
|
220
|
+
source: classSource(negated, body)
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// An empty JavaScript class can never match, which is how a pattern that git
|
|
227
|
+
// gives up on (`WM_ABORT_ALL`) is expressed here.
|
|
228
|
+
const NEVER_MATCH = '[]'
|
|
229
|
+
|
|
230
|
+
// A NUL can appear in neither a `.gitignore` line nor a path, which makes it
|
|
231
|
+
// the one safe placeholder character. A literal one in the pattern is
|
|
232
|
+
// held aside all the same, so a collision is impossible by construction.
|
|
233
|
+
const PLACEHOLDER = '\u0000'
|
|
234
|
+
const REGEX_RESTORE_PLACEHOLDER = new RegExp(
|
|
235
|
+
`${PLACEHOLDER}(\\d+)${PLACEHOLDER}`, 'g'
|
|
58
236
|
)
|
|
59
237
|
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
//
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
238
|
+
// The one wildcard the chain does not expand for itself is a trailing `*`. How
|
|
239
|
+
// it expands depends on the mode (`regex` vs `checkRegex`), so `_make` is
|
|
240
|
+
// left to do it, and until then the pending wildcard travels as this marker.
|
|
241
|
+
// That is what keeps it apart from a user-escaped literal `\*`: the unescape
|
|
242
|
+
// steps collapse the escaped one to the exact `\*` a wildcard would leave
|
|
243
|
+
// behind, so by the time `_make` runs the two are otherwise the same string
|
|
244
|
+
// and a literal star gets wrongly rewritten into a wildcard. The marker is a
|
|
245
|
+
// private-use character, and `extractBrackets` keeps one that came out of the
|
|
246
|
+
// pattern apart from it, so the only marker `_make` ever turns back into a
|
|
247
|
+
// real wildcard is the one this chain put there itself.
|
|
248
|
+
const TRAILING_WILDCARD = '\uE000'
|
|
249
|
+
|
|
250
|
+
// A trailing "/**" is deferred the same way, because `checkRegex` has to tell
|
|
251
|
+
// it apart from a trailing "/*" (see `checkSourceOf`). For `.ignores()` it
|
|
252
|
+
// still never matches the folder itself (#21).
|
|
253
|
+
const TRAILING_DOUBLESTAR = '\uE001'
|
|
254
|
+
|
|
255
|
+
// The three characters above mean something to the chain that builds the
|
|
256
|
+
// source rather than to the path, so one that came out of the pattern is
|
|
257
|
+
// held aside like a bracket expression instead of going straight out. Being
|
|
258
|
+
// held is what makes it safe: the restore runs after the step that anchors
|
|
259
|
+
// the source, so the character comes back in the middle of the source and
|
|
260
|
+
// not at its end, which is the one place `_make` and `checkSourceOf` look
|
|
261
|
+
// for a marker. Without it a pattern's own character lands where a pending
|
|
262
|
+
// marker sits, and `_make` turns it into a real trailing wildcard.
|
|
263
|
+
//
|
|
264
|
+
// It is held as a one-member class rather than bare, in both of the branches
|
|
265
|
+
// a reserved character can reach, so that the property can be
|
|
266
|
+
// read off this function alone -- a reserved character never goes out on
|
|
267
|
+
// its own -- rather than depending on where in the chain the restore
|
|
268
|
+
// happens to run. In the expression built here `[x]` matches exactly what
|
|
269
|
+
// `x` matches, none of the three being special to a regular expression or
|
|
270
|
+
// inside a class, so no test can tell the two apart: the class is insurance,
|
|
271
|
+
// and the paragraph above is the reason it is not needed.
|
|
272
|
+
const isReserved = char =>
|
|
273
|
+
char === PLACEHOLDER
|
|
274
|
+
|| char === TRAILING_WILDCARD
|
|
275
|
+
|| char === TRAILING_DOUBLESTAR
|
|
276
|
+
|
|
277
|
+
// Replace every bracket expression with a placeholder the replacers below
|
|
278
|
+
// leave alone, and translate it separately.
|
|
279
|
+
const extractBrackets = pattern => {
|
|
280
|
+
const sources = []
|
|
281
|
+
const hold = source =>
|
|
282
|
+
`${PLACEHOLDER}${sources.push(source) - 1}${PLACEHOLDER}`
|
|
283
|
+
|
|
284
|
+
const {length} = pattern
|
|
285
|
+
let out = EMPTY
|
|
286
|
+
let index = 0
|
|
287
|
+
|
|
288
|
+
while (index < length) {
|
|
289
|
+
const char = pattern[index]
|
|
290
|
+
|
|
291
|
+
if (char === ESCAPE) {
|
|
292
|
+
// > Put a backslash ("\") in front of ... a character to make it literal.
|
|
293
|
+
// (gitignore(5) -> fnmatch(3))
|
|
294
|
+
// A backslash quotes the next character, whatever it is, so `\d` is a
|
|
295
|
+
// literal `d`, not the regex digit class, and `\?` is a literal `?`,
|
|
296
|
+
// not a wildcard. Held aside as its literal here, the escape never
|
|
297
|
+
// reaches the replacers below, which would otherwise let `\d`, `\b`,
|
|
298
|
+
// `\1`, `\/` keep their regular-expression meaning, and would turn a
|
|
299
|
+
// `\?` into `[^\/]`.
|
|
300
|
+
//
|
|
301
|
+
// Three escapes are still left for the chain: `\*` (a literal star,
|
|
302
|
+
// told apart from a wildcard by `TRAILING_WILDCARD` and the wildcard
|
|
303
|
+
// replacers), `\[` (a literal bracket, the one `[` the bracket
|
|
304
|
+
// replacer still expects), and `\ ` (a quoted space, which one pass
|
|
305
|
+
// below rewrites in bulk -- holding each one aside instead costs more
|
|
306
|
+
// on a pattern built out of them). A lone trailing backslash can reach
|
|
307
|
+
// here after line-ending cleanup.
|
|
308
|
+
//
|
|
309
|
+
// A quoted backslash is not among them. The chain doubles every
|
|
310
|
+
// backslash, then takes the doubling back out again, and a quoted one
|
|
311
|
+
// standing next to a character the chain also escapes left the two
|
|
312
|
+
// counts sharing a run, so one of the escapes was lost. Held here as
|
|
313
|
+
// the literal it means, it never joins that run.
|
|
314
|
+
const escaped = pattern[index + 1]
|
|
315
|
+
|
|
316
|
+
if (
|
|
317
|
+
escaped === UNDEFINED
|
|
318
|
+
|| escaped === SLASH && index + 2 === length
|
|
319
|
+
) {
|
|
320
|
+
// Git removes a final directory slash before matching. An escape
|
|
321
|
+
// without a character after that removal makes the pattern invalid.
|
|
322
|
+
out += hold(NEVER_MATCH)
|
|
323
|
+
} else if (
|
|
324
|
+
escaped === '*'
|
|
325
|
+
|| escaped === '['
|
|
326
|
+
|| escaped === SPACE
|
|
327
|
+
) {
|
|
328
|
+
out += pattern.slice(index, index + 2)
|
|
329
|
+
} else {
|
|
330
|
+
out += hold(
|
|
331
|
+
REGEX_LITERAL_SPECIAL.test(escaped)
|
|
332
|
+
? ESCAPE + escaped
|
|
333
|
+
: isReserved(escaped)
|
|
334
|
+
? `[${escaped}]`
|
|
335
|
+
: escaped
|
|
336
|
+
)
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
index += 2
|
|
340
|
+
} else if (isReserved(char)) {
|
|
341
|
+
out += hold(`[${char}]`)
|
|
342
|
+
index ++
|
|
343
|
+
} else if (char === '[') {
|
|
344
|
+
const scanned = scanBracket(pattern, index)
|
|
345
|
+
|
|
346
|
+
if (scanned === null) {
|
|
347
|
+
// git gives up on the whole pattern (`WM_ABORT_ALL`), so whatever
|
|
348
|
+
// follows can not make it match either.
|
|
349
|
+
out += hold(NEVER_MATCH)
|
|
350
|
+
index = length
|
|
351
|
+
} else {
|
|
352
|
+
out += hold(scanned.source)
|
|
353
|
+
index = scanned.end + 1
|
|
354
|
+
}
|
|
355
|
+
} else {
|
|
356
|
+
out += char
|
|
357
|
+
index ++
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
return {
|
|
362
|
+
source: out,
|
|
363
|
+
sources
|
|
364
|
+
}
|
|
73
365
|
}
|
|
74
366
|
|
|
367
|
+
// A step of the chain below is normally a `[matcher, replacer]` pair handed
|
|
368
|
+
// to `String.replace`. `DIRECT` marks the ones that are plain string work
|
|
369
|
+
// instead, and take `(source, pattern)`.
|
|
370
|
+
//
|
|
371
|
+
// Anchoring the two ends is exactly that -- a test of one character and a
|
|
372
|
+
// concatenation -- and putting it through the regular expression engine
|
|
373
|
+
// cost a third of this chain for nothing: 167ns where 10ns does the same
|
|
374
|
+
// job. The two are still steps in the same list, in the same places,
|
|
375
|
+
// because their position in the order is part of what they mean.
|
|
376
|
+
const DIRECT = null
|
|
377
|
+
|
|
378
|
+
// A separator at the beginning or in the middle of a pattern, as opposed to
|
|
379
|
+
// one at the very end.
|
|
380
|
+
const REGEX_INNER_SLASH = /\/(?!$)/
|
|
381
|
+
|
|
75
382
|
// > If the pattern ends with a slash,
|
|
76
383
|
// > it is removed for the purpose of the following description,
|
|
77
384
|
// > but it would only find a match with a directory.
|
|
@@ -83,40 +390,54 @@ const cleanRangeBackSlash = slashes => {
|
|
|
83
390
|
// you could use option `mark: true` with `glob`
|
|
84
391
|
|
|
85
392
|
// '`foo/`' should not continue with the '`..`'
|
|
393
|
+
// The chain that turns one gitignore pattern into a regular expression
|
|
394
|
+
// source, in order. A step is either
|
|
395
|
+
//
|
|
396
|
+
// [matcher, replacer] handed to `String.replace`
|
|
397
|
+
// [matcher, replacer, required] the same, but skipped outright unless
|
|
398
|
+
// `required` appears in the string, which
|
|
399
|
+
// the matcher cannot match without
|
|
400
|
+
// [DIRECT, transform] plain string work, taking (source, pattern)
|
|
401
|
+
//
|
|
402
|
+
// The `required` character is only ever a shortcut: finding it does not mean
|
|
403
|
+
// the matcher will match, and not finding it means it cannot. It is there
|
|
404
|
+
// because scanning for one character costs a fraction of running a matcher
|
|
405
|
+
// that then finds nothing -- for the wildcard step, whose `[^\\]+`
|
|
406
|
+
// backtracks its way through the whole string before giving up, 11ns
|
|
407
|
+
// against 400ns.
|
|
86
408
|
const REPLACERS = [
|
|
87
409
|
|
|
88
|
-
[
|
|
89
|
-
// Remove BOM
|
|
90
|
-
// TODO:
|
|
91
|
-
// Other similar zero-width characters?
|
|
92
|
-
/^\uFEFF/,
|
|
93
|
-
() => EMPTY
|
|
94
|
-
],
|
|
95
|
-
|
|
96
|
-
// > Trailing spaces are ignored unless they are quoted with backslash ("\")
|
|
97
|
-
[
|
|
98
|
-
// (a\ ) -> (a )
|
|
99
|
-
// (a ) -> (a)
|
|
100
|
-
// (a ) -> (a)
|
|
101
|
-
// (a \ ) -> (a )
|
|
102
|
-
/((?:\\\\)*?)(\\?\s+)$/,
|
|
103
|
-
(_, m1, m2) => m1 + (
|
|
104
|
-
m2.indexOf('\\') === 0
|
|
105
|
-
? SPACE
|
|
106
|
-
: EMPTY
|
|
107
|
-
)
|
|
108
|
-
],
|
|
109
|
-
|
|
110
410
|
// Replace (\ ) with ' '
|
|
411
|
+
// Only a space: an escaped tab or other whitespace is already a literal by
|
|
412
|
+
// the time it reaches here, and a bare tab must be left as one, not turned
|
|
413
|
+
// into a space.
|
|
111
414
|
// (\ ) -> ' '
|
|
112
415
|
// (\\ ) -> '\\ '
|
|
113
416
|
// (\\\ ) -> '\\ '
|
|
114
417
|
[
|
|
115
|
-
|
|
116
|
-
(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
418
|
+
// A run of backslashes is taken whole, from its first one, so no match
|
|
419
|
+
// ever starts again inside it -- `(\\+?) ` did, which made a long run
|
|
420
|
+
// quadratic.
|
|
421
|
+
/(\\+)( ?)/g,
|
|
422
|
+
(_, run, space) => space
|
|
423
|
+
? run.slice(0, run.length - run.length % 2) + SPACE
|
|
424
|
+
: run,
|
|
425
|
+
ESCAPE + SPACE
|
|
426
|
+
],
|
|
427
|
+
|
|
428
|
+
// git's wildmatch() reads a run of two or more asterisks as one globstar
|
|
429
|
+
// whenever the run fills a path segment: it starts the pattern or follows
|
|
430
|
+
// a `/`, and it ends the pattern or comes before a `/`. A run of two is
|
|
431
|
+
// already `**`; a longer one is folded into `**` here, so the steps
|
|
432
|
+
// below only ever have to know `**`.
|
|
433
|
+
// `***/foo` -> `**/foo`, `a/***/b` -> `a/**/b`, `a/***` -> `a/**`
|
|
434
|
+
// git also takes a run beside a literal prefix (`a***/b`) or beside an
|
|
435
|
+
// escaped slash (`***\/b`) as a globstar, and this does not; the README
|
|
436
|
+
// lists both, under "A run of asterisks".
|
|
437
|
+
[
|
|
438
|
+
/(^|\/)\*{3,}(?=\/|$)/g,
|
|
439
|
+
(_, start) => `${start}**`,
|
|
440
|
+
'*'
|
|
120
441
|
],
|
|
121
442
|
|
|
122
443
|
// Escape metacharacters
|
|
@@ -144,7 +465,8 @@ const REPLACERS = [
|
|
|
144
465
|
[
|
|
145
466
|
// > a question mark (?) matches a single character
|
|
146
467
|
/(?!\\)\?/g,
|
|
147
|
-
() => '[^/]'
|
|
468
|
+
() => '[^/]',
|
|
469
|
+
'?'
|
|
148
470
|
],
|
|
149
471
|
|
|
150
472
|
// leading slash
|
|
@@ -154,13 +476,15 @@ const REPLACERS = [
|
|
|
154
476
|
// > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
|
|
155
477
|
// A leading slash matches the beginning of the pathname
|
|
156
478
|
/^\//,
|
|
157
|
-
() => '^'
|
|
479
|
+
() => '^',
|
|
480
|
+
SLASH
|
|
158
481
|
],
|
|
159
482
|
|
|
160
483
|
// replace special metacharacter slash after the leading slash
|
|
161
484
|
[
|
|
162
485
|
/\//g,
|
|
163
|
-
() => '\\/'
|
|
486
|
+
() => '\\/',
|
|
487
|
+
SLASH
|
|
164
488
|
],
|
|
165
489
|
|
|
166
490
|
[
|
|
@@ -173,7 +497,8 @@ const REPLACERS = [
|
|
|
173
497
|
/^\^*(?:\\\*\\\*\\\/)+/,
|
|
174
498
|
|
|
175
499
|
// '**/foo' <-> 'foo'
|
|
176
|
-
() => '^(?:.*\\/)?'
|
|
500
|
+
() => '^(?:.*\\/)?',
|
|
501
|
+
'*'
|
|
177
502
|
],
|
|
178
503
|
|
|
179
504
|
// starting
|
|
@@ -181,10 +506,15 @@ const REPLACERS = [
|
|
|
181
506
|
// there will be no leading '/'
|
|
182
507
|
// (which has been replaced by section "leading slash")
|
|
183
508
|
// If starts with '**', adding a '^' to the regular expression also works
|
|
184
|
-
|
|
185
|
-
|
|
509
|
+
DIRECT,
|
|
510
|
+
(source, pattern) => {
|
|
511
|
+
// Nothing to anchor to, or already anchored
|
|
512
|
+
if (!source || source[0] === '^') {
|
|
513
|
+
return source
|
|
514
|
+
}
|
|
515
|
+
|
|
186
516
|
// If has a slash `/` at the beginning or middle
|
|
187
|
-
|
|
517
|
+
const anchor = !REGEX_INNER_SLASH.test(pattern)
|
|
188
518
|
// > Prior to 2.22.1
|
|
189
519
|
// > If the pattern does not contain a slash /,
|
|
190
520
|
// > Git treats it as a shell glob pattern
|
|
@@ -202,6 +532,8 @@ const REPLACERS = [
|
|
|
202
532
|
// > Otherwise, Git treats the pattern as a shell glob suitable for
|
|
203
533
|
// > consumption by fnmatch(3)
|
|
204
534
|
: '^'
|
|
535
|
+
|
|
536
|
+
return anchor + source
|
|
205
537
|
}
|
|
206
538
|
],
|
|
207
539
|
|
|
@@ -216,18 +548,28 @@ const REPLACERS = [
|
|
|
216
548
|
// Check if it is not the last `'/**'`
|
|
217
549
|
(_, index, str) => index + 6 < str.length
|
|
218
550
|
|
|
219
|
-
// case: /**/
|
|
220
|
-
// > A
|
|
221
|
-
// >
|
|
222
|
-
// >
|
|
223
|
-
// '/**/'
|
|
224
|
-
?
|
|
551
|
+
// case: /**/ at the end of the pattern, i.e. a trailing `'/**/'`
|
|
552
|
+
// > A trailing `"/**/"` (a trailing `"/**"` restricted to directories)
|
|
553
|
+
// > matches everything inside, but it should not match the current
|
|
554
|
+
// > folder itself, so it requires at least one directory segment.
|
|
555
|
+
// 'a/**/' matches 'a/b/', 'a/x/y/' but not 'a/'
|
|
556
|
+
? str.slice(index + 6) === '\\/'
|
|
557
|
+
? '(?:\\/[^\\/]+)+'
|
|
558
|
+
|
|
559
|
+
// case: /**/
|
|
560
|
+
// > A slash followed by two consecutive asterisks then a slash matches
|
|
561
|
+
// > zero or more directories.
|
|
562
|
+
// > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
|
|
563
|
+
// '/**/'
|
|
564
|
+
: '(?:\\/[^\\/]+)*'
|
|
225
565
|
|
|
226
566
|
// case: /**
|
|
227
567
|
// > A trailing `"/**"` matches everything inside.
|
|
228
568
|
|
|
229
|
-
// #21: everything inside but it should not include the current folder
|
|
230
|
-
|
|
569
|
+
// #21: everything inside but it should not include the current folder,
|
|
570
|
+
// resolved by `_make`
|
|
571
|
+
: `\\/${TRAILING_DOUBLESTAR}`,
|
|
572
|
+
'*'
|
|
231
573
|
],
|
|
232
574
|
|
|
233
575
|
// normal intermediate wildcards
|
|
@@ -250,7 +592,33 @@ const REPLACERS = [
|
|
|
250
592
|
// > and will match according to the previous rules.
|
|
251
593
|
const unescaped = p2.replace(/\\\*/g, '[^\\/]*')
|
|
252
594
|
return p1 + unescaped
|
|
253
|
-
}
|
|
595
|
+
},
|
|
596
|
+
'*'
|
|
597
|
+
],
|
|
598
|
+
|
|
599
|
+
// trailing wildcard, held apart from a literal star
|
|
600
|
+
[
|
|
601
|
+
// The step above leaves a trailing `*` alone, so a single `\*` is all that
|
|
602
|
+
// can be left at the end here, and what stands in front of it says which
|
|
603
|
+
// kind it is. A wildcard arrives as the escaper wrote it, `\*` with
|
|
604
|
+
// nothing before it; a literal arrives as the user's own escape, which
|
|
605
|
+
// the escaper doubled, and then the star's own -- `\\` and then `\*`.
|
|
606
|
+
// There is no third case: every backslash still reaching the chain is
|
|
607
|
+
// one `\*`, `\[` or `\ ` carries itself, and each is followed by its
|
|
608
|
+
// own character, so a longer run can never form. This runs while the
|
|
609
|
+
// two are still distinct, before the unescape steps below collapse the
|
|
610
|
+
// literal onto the very `\*` a wildcard leaves behind.
|
|
611
|
+
/(^|[^\\])((?:\\\\)*)\\\*$/,
|
|
612
|
+
|
|
613
|
+
(match, p1, p2) =>
|
|
614
|
+
p2 === EMPTY
|
|
615
|
+
// A real wildcard: carry it to `_make` as the marker, so the unescape
|
|
616
|
+
// steps and the trailing-wildcard rewrite can never mistake it for a
|
|
617
|
+
// literal `\*` (nor the reverse).
|
|
618
|
+
? p1 + TRAILING_WILDCARD
|
|
619
|
+
// A literal star: leave it exactly as it stands for the unescape steps.
|
|
620
|
+
: match,
|
|
621
|
+
'*'
|
|
254
622
|
],
|
|
255
623
|
|
|
256
624
|
[
|
|
@@ -258,41 +626,36 @@ const REPLACERS = [
|
|
|
258
626
|
// For example, if a user escape a '\\*',
|
|
259
627
|
// after step 3, the result will be '\\\\\\*'
|
|
260
628
|
/\\\\\\(?=[$.|*+(){^])/g,
|
|
261
|
-
() => ESCAPE
|
|
629
|
+
() => ESCAPE,
|
|
630
|
+
ESCAPE + ESCAPE
|
|
262
631
|
],
|
|
263
632
|
|
|
264
633
|
[
|
|
265
634
|
// '\\\\' -> '\\'
|
|
266
635
|
/\\\\/g,
|
|
267
|
-
() => ESCAPE
|
|
636
|
+
() => ESCAPE,
|
|
637
|
+
ESCAPE + ESCAPE
|
|
268
638
|
],
|
|
269
639
|
|
|
270
640
|
[
|
|
271
|
-
//
|
|
272
|
-
//
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
// '[bar]'
|
|
283
|
-
// '[bar\\\\]'
|
|
284
|
-
? `[${negateRange(sanitizeRange(range))}${endEscape}]`
|
|
285
|
-
// Invalid range notaton
|
|
286
|
-
// '[bar\\]' -> '[bar\\\\]'
|
|
287
|
-
: '[]'
|
|
288
|
-
: '[]'
|
|
641
|
+
// Every real bracket expression -- POSIX classes included -- has already
|
|
642
|
+
// been held aside by `extractBrackets`, so the only `[` left in the
|
|
643
|
+
// pattern is an escaped, literal one.
|
|
644
|
+
|
|
645
|
+
// A backslash could only stand at the end of the range if it quoted the
|
|
646
|
+
// `]`, and `\]` is held aside long before this.
|
|
647
|
+
/\\\[([^\]/]*?)($|\])/g,
|
|
648
|
+
|
|
649
|
+
// '\\[bar]' -> '\\\\[bar]'
|
|
650
|
+
(match, range, close) => `\\[${range}${close}`,
|
|
651
|
+
'['
|
|
289
652
|
],
|
|
290
653
|
|
|
291
654
|
// ending
|
|
292
655
|
[
|
|
293
656
|
// 'js' will not match 'js.'
|
|
294
657
|
// 'ab' will not match 'abc'
|
|
295
|
-
|
|
658
|
+
DIRECT,
|
|
296
659
|
|
|
297
660
|
// WTF!
|
|
298
661
|
// https://git-scm.com/docs/gitignore
|
|
@@ -306,70 +669,359 @@ const REPLACERS = [
|
|
|
306
669
|
// 'js*' will not match 'a.js'
|
|
307
670
|
// 'js/' will not match 'a.js'
|
|
308
671
|
// 'js' will match 'a.js' and 'a.js/'
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
//
|
|
313
|
-
|
|
672
|
+
source => {
|
|
673
|
+
const last = source[source.length - 1]
|
|
674
|
+
|
|
675
|
+
// The pattern is empty, or ends in a pending marker `_make` owns --
|
|
676
|
+
// the trailing wildcard, or a trailing "/**". A trailing `*` that is
|
|
677
|
+
// not the marker is a literal star, which anchors like any other
|
|
678
|
+
// final character.
|
|
679
|
+
if (!last || last === TRAILING_WILDCARD || last === TRAILING_DOUBLESTAR) {
|
|
680
|
+
return source
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
return last === SLASH
|
|
684
|
+
// foo/ will not match 'foo'
|
|
685
|
+
? `${source}$`
|
|
686
|
+
// foo matches 'foo' and 'foo/'
|
|
687
|
+
: `${source}(?=$|\\/$)`
|
|
688
|
+
}
|
|
314
689
|
]
|
|
315
690
|
]
|
|
316
691
|
|
|
317
|
-
const REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)
|
|
692
|
+
const REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\uE000$/
|
|
318
693
|
const MODE_IGNORE = 'regex'
|
|
319
694
|
const MODE_CHECK_IGNORE = 'checkRegex'
|
|
320
695
|
const UNDERSCORE = '_'
|
|
321
696
|
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
// '/*' does not match everything
|
|
697
|
+
const replaceTrailingWildcard = (_, p1) => {
|
|
698
|
+
const prefix = p1
|
|
699
|
+
// '\^':
|
|
700
|
+
// '/*' does not match EMPTY
|
|
701
|
+
// '/*' does not match everything
|
|
328
702
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
703
|
+
// '\\\/':
|
|
704
|
+
// 'abc/*' does not match 'abc/'
|
|
705
|
+
? `${p1}[^/]+`
|
|
706
|
+
|
|
707
|
+
// 'a*' matches 'a'
|
|
708
|
+
// 'a*' matches 'aa'
|
|
709
|
+
: '[^/]*'
|
|
710
|
+
|
|
711
|
+
return `${prefix}(?=$|\\/$)`
|
|
712
|
+
}
|
|
332
713
|
|
|
333
|
-
|
|
334
|
-
// 'a*' matches 'aa'
|
|
335
|
-
: '[^/]*'
|
|
714
|
+
const REGEX_REPLACE_TRAILING_DOUBLESTAR = /\uE001$/
|
|
336
715
|
|
|
337
|
-
|
|
338
|
-
|
|
716
|
+
// 'abc/**' matches everything under 'abc', but not 'abc/' itself (#21)
|
|
717
|
+
const replaceTrailingDoublestar = () => '.+(?=$|\\/$)'
|
|
339
718
|
|
|
340
|
-
|
|
341
|
-
// When doing `git check-ignore`
|
|
342
|
-
const prefix = p1
|
|
343
|
-
// '\\\/':
|
|
344
|
-
// 'abc/*' DOES match 'abc/' !
|
|
345
|
-
? `${p1}[^/]*`
|
|
719
|
+
const WILDCARD = '[^\\/]*'
|
|
346
720
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
721
|
+
// The fixed piece between the wildcard at `at` and the next wildcard of the
|
|
722
|
+
// run: the tokens that separate them, joined as they appear in the source.
|
|
723
|
+
// A run never holds two wildcards in a row, so there is always at least one
|
|
724
|
+
// token.
|
|
725
|
+
const separatorAfter = (run, at) => {
|
|
726
|
+
let separator = EMPTY
|
|
350
727
|
|
|
351
|
-
|
|
728
|
+
for (let index = at + 1; index < run.length && !run[index].wildcard; index ++) {
|
|
729
|
+
separator += run[index].single
|
|
352
730
|
}
|
|
731
|
+
|
|
732
|
+
return separator
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
// Where a run of non-slash wildcards is split by fixed pieces --
|
|
736
|
+
// `[^/]*ab[^/]*cd...` -- the engine has many equivalent ways to lay the
|
|
737
|
+
// input across the wildcards, and on input that does not match it works
|
|
738
|
+
// through all of them, so the time grows with the number of wildcards
|
|
739
|
+
// rather than the length of the path. Every wildcard but the last in such a
|
|
740
|
+
// run can be pinned to stop where the piece after it begins, which leaves
|
|
741
|
+
// one way to lay out the input and no rewinding, without changing which
|
|
742
|
+
// paths match: the fixed pieces still bound the count, and the last
|
|
743
|
+
// wildcard still absorbs the rest.
|
|
744
|
+
//
|
|
745
|
+
// A wildcard is pinned to the whole piece, never to the piece's first
|
|
746
|
+
// character. The pin leaves no way back, so a wildcard that stopped at that
|
|
747
|
+
// first character would hand over wherever the character happens to turn
|
|
748
|
+
// up, including the places the rest of the piece cannot follow -- which is
|
|
749
|
+
// how `f*o/*/*` came to miss `foo/b/c`, the first `o` of `foo` not being
|
|
750
|
+
// the one the `o/` after it needs. Every token of a piece matches exactly
|
|
751
|
+
// one character, so the first place the whole piece fits is the leftmost
|
|
752
|
+
// place it can sit, and whatever is left over goes to the wildcards that
|
|
753
|
+
// follow.
|
|
754
|
+
//
|
|
755
|
+
// The source is read one token at a time -- a wildcard, a single-character
|
|
756
|
+
// piece (a literal, an escape, a class), or a parenthesised group or anchor
|
|
757
|
+
// that ends the run -- so only a genuine wildcard is touched.
|
|
758
|
+
const pinWildcards = source => {
|
|
759
|
+
if (source.indexOf(WILDCARD) < 0) {
|
|
760
|
+
return source
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
const tokens = []
|
|
764
|
+
const {length} = source
|
|
765
|
+
let index = 0
|
|
766
|
+
|
|
767
|
+
while (index < length) {
|
|
768
|
+
const char = source[index]
|
|
769
|
+
|
|
770
|
+
if (source.startsWith(WILDCARD, index)) {
|
|
771
|
+
tokens.push({wildcard: true})
|
|
772
|
+
index += WILDCARD.length
|
|
773
|
+
} else if (char === '[') {
|
|
774
|
+
let end = index + 1
|
|
775
|
+
|
|
776
|
+
if (source[end] === '^') {
|
|
777
|
+
end ++
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
if (source[end] === ']') {
|
|
781
|
+
end ++
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
while (end < length && source[end] !== ']') {
|
|
785
|
+
end += source[end] === ESCAPE
|
|
786
|
+
? 2
|
|
787
|
+
: 1
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
end ++
|
|
791
|
+
tokens.push({single: source.slice(index, end)})
|
|
792
|
+
index = end
|
|
793
|
+
} else if (char === ESCAPE) {
|
|
794
|
+
tokens.push({single: source.slice(index, index + 2)})
|
|
795
|
+
index += 2
|
|
796
|
+
} else if (char === '(') {
|
|
797
|
+
let depth = 0
|
|
798
|
+
let end = index
|
|
799
|
+
|
|
800
|
+
do {
|
|
801
|
+
if (source[end] === ESCAPE) {
|
|
802
|
+
end ++
|
|
803
|
+
} else if (source[end] === '(') {
|
|
804
|
+
depth ++
|
|
805
|
+
} else if (source[end] === ')') {
|
|
806
|
+
depth --
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
end ++
|
|
810
|
+
} while (end < length && depth > 0)
|
|
811
|
+
|
|
812
|
+
if ('*+?'.indexOf(source[end]) >= 0) {
|
|
813
|
+
end ++
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
tokens.push({boundary: source.slice(index, end)})
|
|
817
|
+
index = end
|
|
818
|
+
} else if (char === '^' || char === '$') {
|
|
819
|
+
tokens.push({boundary: char})
|
|
820
|
+
index ++
|
|
821
|
+
} else {
|
|
822
|
+
tokens.push({single: char})
|
|
823
|
+
index ++
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
let out = EMPTY
|
|
828
|
+
let run = []
|
|
829
|
+
|
|
830
|
+
const flush = () => {
|
|
831
|
+
let lastWildcard
|
|
832
|
+
|
|
833
|
+
run.forEach((token, at) => {
|
|
834
|
+
if (token.wildcard) {
|
|
835
|
+
lastWildcard = at
|
|
836
|
+
}
|
|
837
|
+
})
|
|
838
|
+
|
|
839
|
+
run.forEach((token, at) => {
|
|
840
|
+
if (!token.wildcard) {
|
|
841
|
+
out += token.single
|
|
842
|
+
return
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
// Every wildcard but the last is pinned to the whole piece that
|
|
846
|
+
// follows it, for the reason set out above this function. The last
|
|
847
|
+
// one stays as it is and takes up the rest.
|
|
848
|
+
out += at === lastWildcard
|
|
849
|
+
? WILDCARD
|
|
850
|
+
: `(?:(?!${separatorAfter(run, at)})[^\\/])*`
|
|
851
|
+
})
|
|
852
|
+
|
|
853
|
+
run = []
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
tokens.forEach(token => {
|
|
857
|
+
if (token.boundary === undefined) {
|
|
858
|
+
run.push(token)
|
|
859
|
+
return
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
flush()
|
|
863
|
+
out += token.boundary
|
|
864
|
+
})
|
|
865
|
+
|
|
866
|
+
flush()
|
|
867
|
+
|
|
868
|
+
return out
|
|
353
869
|
}
|
|
354
870
|
|
|
355
871
|
// @param {pattern}
|
|
356
|
-
const makeRegexPrefix = pattern =>
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
872
|
+
const makeRegexPrefix = pattern => {
|
|
873
|
+
// `/**` matches every path, as `**` does. The translation below only finds
|
|
874
|
+
// a globstar beside a slash it keeps, and the leading one is turned into
|
|
875
|
+
// an anchor, so `/**` would come out as `/*` and match one level only.
|
|
876
|
+
// Here rather than in `createRule`, so that `checkSourceOf`, which
|
|
877
|
+
// compiles `/**/` again without its trailing slash, gets it too.
|
|
878
|
+
if (REGEX_ANCHORED_GLOBSTAR.test(pattern)) {
|
|
879
|
+
pattern = '**'
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
const {source, sources} = extractBrackets(pattern)
|
|
883
|
+
|
|
884
|
+
const replaced = REPLACERS.reduce(
|
|
885
|
+
// A pass whose matcher finds nothing hands back the very string it was
|
|
886
|
+
// given, so asking first costs a search and saves a rewrite. Ten of the
|
|
887
|
+
// fifteen passes never fire for a typical .gitignore line, and between
|
|
888
|
+
// them they were 45% of this chain.
|
|
889
|
+
(prev, [matcher, replacer, required]) => {
|
|
890
|
+
if (matcher === DIRECT) {
|
|
891
|
+
return replacer(prev, pattern)
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
if (required !== UNDEFINED && prev.indexOf(required) < 0) {
|
|
895
|
+
return prev
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
// A pass whose matcher finds nothing hands back the very string it was
|
|
899
|
+
// given, so asking first costs a search and saves a rewrite.
|
|
900
|
+
return matcher.test(prev)
|
|
901
|
+
? prev.replace(matcher, replacer.bind(pattern))
|
|
902
|
+
: prev
|
|
903
|
+
},
|
|
904
|
+
source
|
|
905
|
+
)
|
|
906
|
+
|
|
907
|
+
// Most patterns hold no bracket expression at all, and then there is
|
|
908
|
+
// nothing to put back.
|
|
909
|
+
return sources.length
|
|
910
|
+
? replaced.replace(
|
|
911
|
+
REGEX_RESTORE_PLACEHOLDER,
|
|
912
|
+
(match, index) => sources[index]
|
|
913
|
+
)
|
|
914
|
+
: replaced
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
// `checkRegex` tests a path with a trailing slash, 'abc/', the way
|
|
918
|
+
// `git check-ignore` matches that literal string once the directory itself
|
|
919
|
+
// is known not to be excluded (see `checkIgnore`): a trailing '/' of the
|
|
920
|
+
// pattern is dropped, a basename pattern sees an empty basename, and only a
|
|
921
|
+
// pattern whose last segment is a pending wildcard can match what is left
|
|
922
|
+
// after the final slash -- 'abc/*' and 'abc/**' match 'abc/', and 'abc/**'
|
|
923
|
+
// also matches 'abc/d/' (#77, #169).
|
|
924
|
+
const checkSourceOf = (body, prefix) => {
|
|
925
|
+
if (body[body.length - 1] === SLASH) {
|
|
926
|
+
prefix = makeRegexPrefix(body.slice(0, - 1))
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
const head = prefix.slice(0, - 1)
|
|
930
|
+
const last = prefix[prefix.length - 1]
|
|
931
|
+
|
|
932
|
+
return last === TRAILING_WILDCARD
|
|
933
|
+
? `${head}$`
|
|
934
|
+
: last === TRAILING_DOUBLESTAR
|
|
935
|
+
? `${head}.*$`
|
|
936
|
+
: NEVER_MATCH
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
// A trailing slash does not stop a pattern being basename-only: it restricts
|
|
940
|
+
// the match to a directory, it does not let the pattern reach across one.
|
|
941
|
+
// Everything else a pattern can hold -- a wildcard, a character class, an
|
|
942
|
+
// escape -- stays inside a single path segment too, so a pattern with no
|
|
943
|
+
// separator in it can only ever describe the last one.
|
|
944
|
+
const matchesBasename = body => {
|
|
945
|
+
const index = body.indexOf(SLASH)
|
|
946
|
+
|
|
947
|
+
return index < 0 || index === body.length - 1
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
// The last segment of a path, keeping a trailing slash, because a pattern that
|
|
951
|
+
// ends in one matches only a directory.
|
|
952
|
+
// 'a/b/c.js' -> 'c.js'; 'a/b/' -> 'b/'; 'c.js' -> 'c.js' (no copy made)
|
|
953
|
+
const basenameOf = path => {
|
|
954
|
+
const end = path.length - 1
|
|
955
|
+
|
|
956
|
+
const index = path.lastIndexOf(
|
|
957
|
+
SLASH,
|
|
958
|
+
path[end] === SLASH
|
|
959
|
+
? end - 1
|
|
960
|
+
: end
|
|
961
|
+
)
|
|
962
|
+
|
|
963
|
+
return index < 0
|
|
964
|
+
? path
|
|
965
|
+
: path.slice(index + 1)
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
// The parent directory of a path, with its trailing separator, or EMPTY when
|
|
969
|
+
// the path has none.
|
|
970
|
+
// 'a/b/c' -> 'a/b/'; 'a/b/' -> 'a/'; 'a' -> EMPTY; 'a/' -> EMPTY
|
|
971
|
+
//
|
|
972
|
+
// A path holding an empty segment has to be taken apart, because its
|
|
973
|
+
// ancestors are not prefixes of it: the parent of 'a//b' is 'a/', not
|
|
974
|
+
// 'a//', and the parent of '/a/' is nothing at all. Both shapes reach here
|
|
975
|
+
// -- 'a//b' is accepted outright, and `checkIgnore` does not put the path
|
|
976
|
+
// it is given through the relative-path check.
|
|
977
|
+
//
|
|
978
|
+
// Every other path is a prefix of itself, and cutting one costs a fraction of
|
|
979
|
+
// splitting it into an array and joining that back at every level: 73ns
|
|
980
|
+
// against 207ns.
|
|
981
|
+
const parentOf = path => {
|
|
982
|
+
if (
|
|
983
|
+
path.charCodeAt(0) === SLASH_CODE
|
|
984
|
+
|| path.indexOf(DOUBLE_SLASH) >= 0
|
|
985
|
+
) {
|
|
986
|
+
const slices = path.split(SLASH).filter(Boolean)
|
|
987
|
+
|
|
988
|
+
slices.pop()
|
|
989
|
+
|
|
990
|
+
return slices.length
|
|
991
|
+
? slices.join(SLASH) + SLASH
|
|
992
|
+
: EMPTY
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
const end = path.length - 1
|
|
996
|
+
|
|
997
|
+
// Look back from before a trailing separator, since that one belongs to the
|
|
998
|
+
// path itself.
|
|
999
|
+
//
|
|
1000
|
+
// A negative place to start would be a trap here: `lastIndexOf` clamps one
|
|
1001
|
+
// to 0 and searches there rather than reporting no match, so '/' would
|
|
1002
|
+
// come back as its own parent and the walk would never end. It cannot
|
|
1003
|
+
// happen -- that is the only path short enough to produce one, and the
|
|
1004
|
+
// test above has already sent it the other way.
|
|
1005
|
+
const cut = path.lastIndexOf(
|
|
1006
|
+
SLASH,
|
|
1007
|
+
path.charCodeAt(end) === SLASH_CODE
|
|
1008
|
+
? end - 1
|
|
1009
|
+
: end
|
|
1010
|
+
)
|
|
1011
|
+
|
|
1012
|
+
return cut < 0
|
|
1013
|
+
? EMPTY
|
|
1014
|
+
: path.slice(0, cut + 1)
|
|
1015
|
+
}
|
|
361
1016
|
|
|
362
1017
|
const isString = subject => typeof subject === 'string'
|
|
363
1018
|
|
|
364
|
-
//
|
|
1019
|
+
// Blank lines and comments are told by `createRule`, once the pattern is
|
|
1020
|
+
// normalized.
|
|
365
1021
|
const checkPattern = pattern => pattern
|
|
366
1022
|
&& isString(pattern)
|
|
367
|
-
&& !REGEX_TEST_BLANK_LINE.test(pattern)
|
|
368
1023
|
&& !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern)
|
|
369
1024
|
|
|
370
|
-
// > A line starting with # serves as a comment.
|
|
371
|
-
&& pattern.indexOf('#') !== 0
|
|
372
|
-
|
|
373
1025
|
const splitPattern = pattern => pattern
|
|
374
1026
|
.split(REGEX_SPLITALL_CRLF)
|
|
375
1027
|
.filter(Boolean)
|
|
@@ -392,6 +1044,15 @@ class IgnoreRule {
|
|
|
392
1044
|
define(this, 'regexPrefix', prefix)
|
|
393
1045
|
}
|
|
394
1046
|
|
|
1047
|
+
// Worked out on first use and kept behind an own property, the way `regex`
|
|
1048
|
+
// caches itself in `_regex`. Deciding it in the constructor instead would
|
|
1049
|
+
// add a fourth `defineProperty` to every rule ever built, which cost 4% of
|
|
1050
|
+
// every compile -- including the compiles of rules that are never matched
|
|
1051
|
+
// against anything.
|
|
1052
|
+
get _basenameOnly () {
|
|
1053
|
+
return define(this, '_basenameOnly', matchesBasename(this.body))
|
|
1054
|
+
}
|
|
1055
|
+
|
|
395
1056
|
get regex () {
|
|
396
1057
|
const key = UNDERSCORE + MODE_IGNORE
|
|
397
1058
|
|
|
@@ -413,11 +1074,12 @@ class IgnoreRule {
|
|
|
413
1074
|
}
|
|
414
1075
|
|
|
415
1076
|
_make (mode, key) {
|
|
416
|
-
const str =
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
1077
|
+
const str = pinWildcards(
|
|
1078
|
+
mode === MODE_IGNORE
|
|
1079
|
+
? this.regexPrefix
|
|
1080
|
+
.replace(REGEX_REPLACE_TRAILING_WILDCARD, replaceTrailingWildcard)
|
|
1081
|
+
.replace(REGEX_REPLACE_TRAILING_DOUBLESTAR, replaceTrailingDoublestar)
|
|
1082
|
+
: checkSourceOf(this.body, this.regexPrefix)
|
|
421
1083
|
)
|
|
422
1084
|
|
|
423
1085
|
const regex = this.ignoreCase
|
|
@@ -428,17 +1090,79 @@ class IgnoreRule {
|
|
|
428
1090
|
}
|
|
429
1091
|
}
|
|
430
1092
|
|
|
1093
|
+
const isLineEnd = char => char === '\r' || char === '\n'
|
|
1094
|
+
|
|
1095
|
+
// Drop a line terminator, which can remain when patterns are passed as an
|
|
1096
|
+
// array, and then the trailing spaces. Git trims spaces only, and a space
|
|
1097
|
+
// escaped by an odd run of backslashes stays, unescaped, as the last one.
|
|
1098
|
+
// Scanned from the end: a regular expression can only try each start in
|
|
1099
|
+
// turn, which is quadratic over a long run of spaces or backslashes.
|
|
1100
|
+
// 'a ' -> 'a'; 'a\ ' -> 'a '; 'a\\ ' -> 'a\\'; 'a\t' -> 'a\t'
|
|
1101
|
+
const trimEnd = body => {
|
|
1102
|
+
let end = body.length
|
|
1103
|
+
|
|
1104
|
+
while (end && isLineEnd(body[end - 1])) {
|
|
1105
|
+
end --
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
const lineEnd = end
|
|
1109
|
+
|
|
1110
|
+
while (end && body[end - 1] === SPACE) {
|
|
1111
|
+
end --
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
if (end === lineEnd) {
|
|
1115
|
+
return body.slice(0, end)
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
let backslashes = 0
|
|
1119
|
+
|
|
1120
|
+
while (backslashes < end && body[end - backslashes - 1] === ESCAPE) {
|
|
1121
|
+
backslashes ++
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
return backslashes % 2
|
|
1125
|
+
? body.slice(0, end - 1) + SPACE
|
|
1126
|
+
: body.slice(0, end)
|
|
1127
|
+
}
|
|
1128
|
+
|
|
431
1129
|
const createRule = ({
|
|
432
1130
|
pattern,
|
|
433
1131
|
mark
|
|
434
1132
|
}, ignoreCase) => {
|
|
1133
|
+
// Git drops a BOM before it reads the first line, so before anything else.
|
|
1134
|
+
let body = pattern[0] === BOM
|
|
1135
|
+
? pattern.slice(1)
|
|
1136
|
+
: pattern
|
|
1137
|
+
|
|
1138
|
+
// > A line starting with # serves as a comment.
|
|
1139
|
+
if (body[0] === '#') {
|
|
1140
|
+
return
|
|
1141
|
+
}
|
|
1142
|
+
|
|
435
1143
|
let negative = false
|
|
436
|
-
let body = pattern
|
|
437
1144
|
|
|
438
1145
|
// > An optional prefix "!" which negates the pattern;
|
|
439
|
-
if (body
|
|
1146
|
+
if (body[0] === '!') {
|
|
440
1147
|
negative = true
|
|
441
|
-
body = body.
|
|
1148
|
+
body = body.slice(1)
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
// Normalize the body before checking which slashes anchor the pattern.
|
|
1152
|
+
// Otherwise `bar/ ` is mistaken for a pattern containing an inner slash.
|
|
1153
|
+
// Only a body ending in a space or a line terminator has anything to trim.
|
|
1154
|
+
const last = body[body.length - 1]
|
|
1155
|
+
|
|
1156
|
+
if (last === SPACE || last === '\r' || last === '\n') {
|
|
1157
|
+
body = trimEnd(body)
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
// > A blank line matches no files, so it can serve as a separator for
|
|
1161
|
+
// > readability.
|
|
1162
|
+
// Nor does a lone "!", or anything else left empty here: an empty pattern
|
|
1163
|
+
// would compile to a regex matching every path.
|
|
1164
|
+
if (!body) {
|
|
1165
|
+
return
|
|
442
1166
|
}
|
|
443
1167
|
|
|
444
1168
|
body = body
|
|
@@ -465,12 +1189,28 @@ class RuleManager {
|
|
|
465
1189
|
constructor (ignoreCase) {
|
|
466
1190
|
this._ignoreCase = ignoreCase
|
|
467
1191
|
this._rules = []
|
|
1192
|
+
|
|
1193
|
+
// How many of the rules git would tag `EXC_FLAG_NODIR`.
|
|
1194
|
+
//
|
|
1195
|
+
// The scan uses it to decide, once for the whole set, whether handing
|
|
1196
|
+
// those rules the basename is worth what it costs the others. The
|
|
1197
|
+
// shortcut saves a full-path scan on every rule it applies to and costs
|
|
1198
|
+
// a check on every rule it does not, so a set where almost nothing is
|
|
1199
|
+
// basename-only comes out behind -- a 955 pattern set with 44 of them
|
|
1200
|
+
// measured 19% slower with the shortcut always on.
|
|
1201
|
+
//
|
|
1202
|
+
// Deciding this by measurement rather than by meaning is safe: a
|
|
1203
|
+
// basename-only pattern gives the very same answer against the whole
|
|
1204
|
+
// path, it just takes longer to say so. The choice can only change how
|
|
1205
|
+
// fast the scan runs, never what it returns.
|
|
1206
|
+
this._basenameCount = 0
|
|
468
1207
|
}
|
|
469
1208
|
|
|
470
1209
|
_add (pattern) {
|
|
471
1210
|
// #32
|
|
472
1211
|
if (pattern && pattern[KEY_IGNORE]) {
|
|
473
1212
|
this._rules = this._rules.concat(pattern._rules._rules)
|
|
1213
|
+
this._basenameCount += pattern._rules._basenameCount
|
|
474
1214
|
this._added = true
|
|
475
1215
|
return
|
|
476
1216
|
}
|
|
@@ -481,10 +1221,19 @@ class RuleManager {
|
|
|
481
1221
|
}
|
|
482
1222
|
}
|
|
483
1223
|
|
|
484
|
-
|
|
485
|
-
|
|
1224
|
+
const rule = checkPattern(pattern.pattern)
|
|
1225
|
+
&& createRule(pattern, this._ignoreCase)
|
|
1226
|
+
|
|
1227
|
+
if (rule) {
|
|
486
1228
|
this._added = true
|
|
487
1229
|
this._rules.push(rule)
|
|
1230
|
+
|
|
1231
|
+
// Deliberately not `rule._basenameOnly`: reading that would materialise
|
|
1232
|
+
// the rule's own copy, and the whole point of leaving it lazy is that
|
|
1233
|
+
// a rule which is compiled and never matched never pays for it.
|
|
1234
|
+
if (matchesBasename(rule.body)) {
|
|
1235
|
+
this._basenameCount ++
|
|
1236
|
+
}
|
|
488
1237
|
}
|
|
489
1238
|
}
|
|
490
1239
|
|
|
@@ -498,56 +1247,41 @@ class RuleManager {
|
|
|
498
1247
|
: pattern
|
|
499
1248
|
).forEach(this._add, this)
|
|
500
1249
|
|
|
1250
|
+
if (this._added) {
|
|
1251
|
+
this._literalRules = UNDEFINED
|
|
1252
|
+
}
|
|
1253
|
+
|
|
501
1254
|
return this._added
|
|
502
1255
|
}
|
|
503
1256
|
|
|
504
|
-
//
|
|
505
|
-
//
|
|
506
|
-
//
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
1257
|
+
// Match the literal 'abc/' for `checkIgnore`, last rule wins. Only a rule
|
|
1258
|
+
// ending in a wildcard can match it (see `checkSourceOf`), so the rest
|
|
1259
|
+
// are left out once, rather than tested or compiled for every path.
|
|
1260
|
+
testLiteral (path) {
|
|
1261
|
+
const rules = this._literalRules || (
|
|
1262
|
+
this._literalRules = this._rules.filter(
|
|
1263
|
+
({body}) => body[body.length - (
|
|
1264
|
+
body[body.length - 1] === SLASH ? 2 : 1
|
|
1265
|
+
)] === '*'
|
|
1266
|
+
)
|
|
1267
|
+
)
|
|
510
1268
|
|
|
511
|
-
// @returns {TestResult} true if a file is ignored
|
|
512
|
-
test (path, checkUnignored, mode) {
|
|
513
1269
|
let ignored = false
|
|
514
1270
|
let unignored = false
|
|
515
1271
|
let matchedRule
|
|
516
1272
|
|
|
517
|
-
|
|
518
|
-
const
|
|
1273
|
+
for (let index = rules.length - 1; index >= 0; index --) {
|
|
1274
|
+
const rule = rules[index]
|
|
519
1275
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
// - SKIP: always skip
|
|
528
|
-
// - TEST: always test
|
|
529
|
-
// - TESTIF: only test if checkUnignored
|
|
530
|
-
// - X: that never happen
|
|
531
|
-
if (
|
|
532
|
-
unignored === negative && ignored !== unignored
|
|
533
|
-
|| negative && !ignored && !unignored && !checkUnignored
|
|
534
|
-
) {
|
|
535
|
-
return
|
|
1276
|
+
if (rule.checkRegex.test(path)) {
|
|
1277
|
+
ignored = !rule.negative
|
|
1278
|
+
unignored = rule.negative
|
|
1279
|
+
matchedRule = rule.negative
|
|
1280
|
+
? UNDEFINED
|
|
1281
|
+
: rule
|
|
1282
|
+
break
|
|
536
1283
|
}
|
|
537
|
-
|
|
538
|
-
const matched = rule[mode].test(path)
|
|
539
|
-
|
|
540
|
-
if (!matched) {
|
|
541
|
-
return
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
ignored = !negative
|
|
545
|
-
unignored = negative
|
|
546
|
-
|
|
547
|
-
matchedRule = negative
|
|
548
|
-
? UNDEFINED
|
|
549
|
-
: rule
|
|
550
|
-
})
|
|
1284
|
+
}
|
|
551
1285
|
|
|
552
1286
|
const ret = {
|
|
553
1287
|
ignored,
|
|
@@ -560,6 +1294,62 @@ class RuleManager {
|
|
|
560
1294
|
|
|
561
1295
|
return ret
|
|
562
1296
|
}
|
|
1297
|
+
|
|
1298
|
+
// Test one single path without recursively checking parent directories
|
|
1299
|
+
//
|
|
1300
|
+
// - mode `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
|
|
1301
|
+
|
|
1302
|
+
// @returns {TestResult}
|
|
1303
|
+
test (path, mode) {
|
|
1304
|
+
// Most of a .gitignore is patterns with no slash in them, and running
|
|
1305
|
+
// those against the whole path makes the regular expression engine walk
|
|
1306
|
+
// every directory name on the way to the only segment that could match.
|
|
1307
|
+
// Handing them the basename instead is what git does, and it is where
|
|
1308
|
+
// the time in a directory walk goes: the rule scan was two thirds of it.
|
|
1309
|
+
const rules = this._rules
|
|
1310
|
+
const {length} = rules
|
|
1311
|
+
|
|
1312
|
+
const shortcut = this._basenameCount * 2 >= length
|
|
1313
|
+
|
|
1314
|
+
const basename = shortcut
|
|
1315
|
+
? basenameOf(path)
|
|
1316
|
+
: path
|
|
1317
|
+
|
|
1318
|
+
// The last rule to match decides, as in git, and it is the rule
|
|
1319
|
+
// `git check-ignore -v` reports, so the scan runs from the end and stops
|
|
1320
|
+
// at the first match.
|
|
1321
|
+
// A plain loop rather than `forEach`, so that `path`, `basename` and
|
|
1322
|
+
// `shortcut` are locals. As a callback they became closure variables,
|
|
1323
|
+
// and reaching for one of those once per rule cost 10% of a scan over a
|
|
1324
|
+
// large rule set -- more than the shortcut they were there to serve.
|
|
1325
|
+
for (let index = length - 1; index >= 0; index --) {
|
|
1326
|
+
const rule = rules[index]
|
|
1327
|
+
|
|
1328
|
+
if (rule[mode].test(
|
|
1329
|
+
shortcut && rule._basenameOnly
|
|
1330
|
+
? basename
|
|
1331
|
+
: path
|
|
1332
|
+
)) {
|
|
1333
|
+
const {negative} = rule
|
|
1334
|
+
|
|
1335
|
+
const ret = {
|
|
1336
|
+
ignored: !negative,
|
|
1337
|
+
unignored: negative
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
if (!negative) {
|
|
1341
|
+
ret.rule = rule
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
return ret
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
return {
|
|
1349
|
+
ignored: false,
|
|
1350
|
+
unignored: false
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
563
1353
|
}
|
|
564
1354
|
|
|
565
1355
|
const throwError = (message, Ctor) => {
|
|
@@ -591,7 +1381,43 @@ const checkPath = (path, originalPath, doThrow) => {
|
|
|
591
1381
|
return true
|
|
592
1382
|
}
|
|
593
1383
|
|
|
594
|
-
|
|
1384
|
+
// > pathname should be a `path.relative()`d one
|
|
1385
|
+
//
|
|
1386
|
+
// The same thing `REGEX_TEST_INVALID_PATH` says, spelled out: a path is not
|
|
1387
|
+
// relative if it begins with a separator, or with `./` or `../`, or is
|
|
1388
|
+
// nothing but `.` or `..`. Every match is decided by the first three
|
|
1389
|
+
// characters, and this runs on every path handed to the library -- where it
|
|
1390
|
+
// was 55% of a cached lookup, more than the cache lookup itself.
|
|
1391
|
+
const isNotRelative = path => {
|
|
1392
|
+
const first = path.charCodeAt(0)
|
|
1393
|
+
|
|
1394
|
+
if (first === SLASH_CODE) {
|
|
1395
|
+
return true
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
if (first !== DOT_CODE) {
|
|
1399
|
+
return false
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
// '.'
|
|
1403
|
+
if (path.length === 1) {
|
|
1404
|
+
return true
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
const second = path.charCodeAt(1)
|
|
1408
|
+
|
|
1409
|
+
// './'
|
|
1410
|
+
if (second === SLASH_CODE) {
|
|
1411
|
+
return true
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
if (second !== DOT_CODE) {
|
|
1415
|
+
return false
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
// '..' or '../'
|
|
1419
|
+
return path.length === 2 || path.charCodeAt(2) === SLASH_CODE
|
|
1420
|
+
}
|
|
595
1421
|
|
|
596
1422
|
checkPath.isNotRelative = isNotRelative
|
|
597
1423
|
|
|
@@ -638,7 +1464,7 @@ class Ignore {
|
|
|
638
1464
|
}
|
|
639
1465
|
|
|
640
1466
|
// @returns {TestResult}
|
|
641
|
-
_test (originalPath, cache
|
|
1467
|
+
_test (originalPath, cache) {
|
|
642
1468
|
const path = originalPath
|
|
643
1469
|
// Supports nullable path
|
|
644
1470
|
&& checkPath.convert(originalPath)
|
|
@@ -651,33 +1477,30 @@ class Ignore {
|
|
|
651
1477
|
: RETURN_FALSE
|
|
652
1478
|
)
|
|
653
1479
|
|
|
654
|
-
return this._t(path, cache
|
|
1480
|
+
return this._t(path, cache)
|
|
655
1481
|
}
|
|
656
1482
|
|
|
657
1483
|
checkIgnore (path) {
|
|
658
1484
|
// If the path doest not end with a slash, `.ignores()` is much equivalent
|
|
659
1485
|
// to `git check-ignore`
|
|
660
|
-
if (
|
|
1486
|
+
if (path.charCodeAt(path.length - 1) !== SLASH_CODE) {
|
|
661
1487
|
return this.test(path)
|
|
662
1488
|
}
|
|
663
1489
|
|
|
664
|
-
|
|
665
|
-
|
|
1490
|
+
// Like `git check-ignore`: a directory excluded by itself or by an
|
|
1491
|
+
// ancestor settles it, and only then is the literal 'abc/' matched
|
|
1492
|
+
// against the rules (see `checkSourceOf`).
|
|
1493
|
+
const dir = this._t(path, this._testCache)
|
|
666
1494
|
|
|
667
|
-
if (
|
|
668
|
-
|
|
669
|
-
slices.join(SLASH) + SLASH,
|
|
670
|
-
this._testCache,
|
|
671
|
-
true,
|
|
672
|
-
slices
|
|
673
|
-
)
|
|
674
|
-
|
|
675
|
-
if (parent.ignored) {
|
|
676
|
-
return parent
|
|
677
|
-
}
|
|
1495
|
+
if (dir.ignored) {
|
|
1496
|
+
return dir
|
|
678
1497
|
}
|
|
679
1498
|
|
|
680
|
-
|
|
1499
|
+
const literal = this._rules.testLiteral(path)
|
|
1500
|
+
|
|
1501
|
+
return literal.ignored || literal.unignored
|
|
1502
|
+
? literal
|
|
1503
|
+
: dir
|
|
681
1504
|
}
|
|
682
1505
|
|
|
683
1506
|
_t (
|
|
@@ -685,48 +1508,28 @@ class Ignore {
|
|
|
685
1508
|
path,
|
|
686
1509
|
|
|
687
1510
|
// The cache for the result of a certain checking
|
|
688
|
-
cache
|
|
689
|
-
|
|
690
|
-
// Whether should check if the path is unignored
|
|
691
|
-
checkUnignored,
|
|
692
|
-
|
|
693
|
-
// The path slices
|
|
694
|
-
slices
|
|
1511
|
+
cache
|
|
695
1512
|
) {
|
|
696
1513
|
if (path in cache) {
|
|
697
1514
|
return cache[path]
|
|
698
1515
|
}
|
|
699
1516
|
|
|
700
|
-
|
|
701
|
-
// path/to/a.js
|
|
702
|
-
// ['path', 'to', 'a.js']
|
|
703
|
-
slices = path.split(SLASH).filter(Boolean)
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
slices.pop()
|
|
707
|
-
|
|
708
|
-
// If the path has no parent directory, just test it
|
|
709
|
-
if (!slices.length) {
|
|
710
|
-
return cache[path] = this._rules.test(path, checkUnignored, MODE_IGNORE)
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
const parent = this._t(
|
|
714
|
-
slices.join(SLASH) + SLASH,
|
|
715
|
-
cache,
|
|
716
|
-
checkUnignored,
|
|
717
|
-
slices
|
|
718
|
-
)
|
|
1517
|
+
const parentPath = parentOf(path)
|
|
719
1518
|
|
|
720
1519
|
// If the path contains a parent directory, check the parent first
|
|
721
|
-
|
|
1520
|
+
const parent = parentPath
|
|
1521
|
+
? this._t(parentPath, cache)
|
|
1522
|
+
: UNDEFINED
|
|
1523
|
+
|
|
1524
|
+
return cache[path] = parent && parent.ignored
|
|
722
1525
|
// > It is not possible to re-include a file if a parent directory of
|
|
723
1526
|
// > that file is excluded.
|
|
724
1527
|
? parent
|
|
725
|
-
: this._rules.test(path,
|
|
1528
|
+
: this._rules.test(path, MODE_IGNORE)
|
|
726
1529
|
}
|
|
727
1530
|
|
|
728
1531
|
ignores (path) {
|
|
729
|
-
return this._test(path, this._ignoreCache
|
|
1532
|
+
return this._test(path, this._ignoreCache).ignored
|
|
730
1533
|
}
|
|
731
1534
|
|
|
732
1535
|
createFilter () {
|
|
@@ -739,7 +1542,7 @@ class Ignore {
|
|
|
739
1542
|
|
|
740
1543
|
// @returns {TestResult}
|
|
741
1544
|
test (path) {
|
|
742
|
-
return this._test(path, this._testCache
|
|
1545
|
+
return this._test(path, this._testCache)
|
|
743
1546
|
}
|
|
744
1547
|
}
|
|
745
1548
|
|