@mocoto/mahoraga 0.14.1 → 0.14.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -34
- package/dist/analysts/architects/analyst-structure.js +20 -20
- package/dist/analysts/architects/archetypes-custom.js +16 -19
- package/dist/analysts/architects/detector-archetypes.js +43 -36
- package/dist/analysts/architects/orchestrator-archetypes.js +3 -3
- package/dist/analysts/architects/signals-project-advanced.js +26 -28
- package/dist/analysts/architects/signals-project.js +2 -2
- package/dist/analysts/architects/strategist-structure.js +47 -66
- package/dist/analysts/azure-pipelines/analysts/analyst-azure.js +41 -35
- package/dist/analysts/azure-pipelines/corrections/correction-azure.js +22 -19
- package/dist/analysts/azure-pipelines/detectors/detector-azure-performance.js +21 -18
- package/dist/analysts/azure-pipelines/detectors/detector-azure-security.js +25 -20
- package/dist/analysts/azure-pipelines/detectors/detector-azure-structure.js +39 -40
- package/dist/analysts/azure-pipelines/scorers/scorer-azure.js +10 -7
- package/dist/analysts/circleci/analysts/analyst-circleci.js +33 -27
- package/dist/analysts/circleci/corrections/correction-circleci.js +22 -20
- package/dist/analysts/circleci/detectors/detector-circleci-performance.js +23 -19
- package/dist/analysts/circleci/detectors/detector-circleci-security.js +78 -82
- package/dist/analysts/circleci/detectors/detector-circleci-structure.js +22 -22
- package/dist/analysts/converters/convert-registry.js +1 -1
- package/dist/analysts/converters/engines/converter-gha-to-gitlab.js +17 -15
- package/dist/analysts/converters/index.js +1 -1
- package/dist/analysts/corrections/analyst-quick-fixes.js +25 -28
- package/dist/analysts/corrections/analyst-scoring.js +24 -21
- package/dist/analysts/corrections/auto-fix-engine.js +1 -1
- package/dist/analysts/corrections/corrector-structure.js +43 -42
- package/dist/analysts/corrections/fix-alias-imports.js +10 -6
- package/dist/analysts/corrections/fix-md-fences.js +23 -23
- package/dist/analysts/corrections/map-reversion.js +56 -53
- package/dist/analysts/corrections/pruning.js +19 -16
- package/dist/analysts/corrections/quick-fixes/fix-any-to-proper-type.js +57 -61
- package/dist/analysts/corrections/quick-fixes/fix-unknown-to-specific-type.js +30 -30
- package/dist/analysts/corrections/reorganize-barrels.js +13 -13
- package/dist/analysts/corrections/rewrite-testes-aliases.js +23 -22
- package/dist/analysts/corrections/scoring-shared.js +19 -18
- package/dist/analysts/corrections/type-safety/context-analyzer.js +15 -10
- package/dist/analysts/corrections/type-safety/type-analyzer.js +3 -3
- package/dist/analysts/corrections/type-safety/type-validator.js +4 -3
- package/dist/analysts/corrections/type-safety/usage-analyzer.js +39 -42
- package/dist/analysts/css/analysts/analyst-css.js +42 -42
- package/dist/analysts/css/corrections/correction-css.js +19 -11
- package/dist/analysts/css/detectors/detector-css-best-practices.js +129 -118
- package/dist/analysts/css/scorers/scorer-css.js +23 -18
- package/dist/analysts/css-in-js/analysts/analyst-css-in-js.js +24 -17
- package/dist/analysts/css-in-js/corrections/correction-css-in-js.js +31 -16
- package/dist/analysts/css-in-js/detectors/detector-css-in-js-best-practices.js +28 -30
- package/dist/analysts/css-in-js/scorers/scorer-css-in-js.js +79 -54
- package/dist/analysts/css-in-js/shared.js +7 -0
- package/dist/analysts/detectors/detector-architecture.js +91 -85
- package/dist/analysts/detectors/detector-bugs-ml.js +29 -27
- package/dist/analysts/detectors/detector-code-fragile.js +41 -36
- package/dist/analysts/detectors/detector-dependencies.js +5 -5
- package/dist/analysts/detectors/detector-duplications.js +26 -26
- package/dist/analysts/detectors/detector-monorepo.js +51 -45
- package/dist/analysts/detectors/detector-performance.js +24 -17
- package/dist/analysts/detectors/detector-recommendation-architecture.js +40 -36
- package/dist/analysts/detectors/detector-security.js +43 -42
- package/dist/analysts/detectors/detector-structure.js +31 -28
- package/dist/analysts/github-actions/analysts/analyst-github-actions.js +5 -8
- package/dist/analysts/github-actions/detectors/detector-workflow-accessibility.js +1 -9
- package/dist/analysts/github-actions/detectors/detector-workflow-structure.js +1 -4
- package/dist/analysts/github-actions/detectors/detector-workflow-trigger-unsafe.js +6 -5
- package/dist/analysts/gitlab-ci/analysts/analyst-gitlab-ci.js +2 -2
- package/dist/analysts/gitlab-ci/detectors/detector-gitlab-ci-structure.js +0 -3
- package/dist/analysts/go/analysts/analyst-best-practices.js +2 -2
- package/dist/analysts/go/analysts/analyst-concurrency.js +1 -1
- package/dist/analysts/go/analysts/analyst-security.js +1 -1
- package/dist/analysts/go/detectors/detector-conventions.js +1 -1
- package/dist/analysts/html/analysts/analyst-html.js +10 -12
- package/dist/analysts/html/detectors/detector-html.js +3 -3
- package/dist/analysts/js-ts/analysts/analyst-commands-cli.js +22 -22
- package/dist/analysts/js-ts/analysts/analyst-functions-long.js +5 -5
- package/dist/analysts/js-ts/analysts/analyst-patterns-usage.js +6 -2
- package/dist/analysts/js-ts/detectors/detector-anti-patterns-async.js +84 -9
- package/dist/analysts/js-ts/detectors/detector-constructions-syntactic.js +33 -10
- package/dist/analysts/js-ts/detectors/detector-context-smart.js +6 -6
- package/dist/analysts/js-ts/detectors/detector-leaks-memory.js +1 -1
- package/dist/analysts/js-ts/detectors/detector-types-unsafe.js +33 -2
- package/dist/analysts/php/analysts/analyst-php.js +3 -3
- package/dist/analysts/php/detectors/detector-php-best-practices.js +5 -5
- package/dist/analysts/php/detectors/detector-php-security.js +5 -5
- package/dist/analysts/php/scorers/scorer-php.js +2 -2
- package/dist/analysts/plugins/detector-documentation.js +6 -6
- package/dist/analysts/plugins/detector-markdown.js +7 -7
- package/dist/analysts/python/analysts/analyst-python.js +2 -5
- package/dist/analysts/react/analysts/analyst-react-hooks.js +66 -9
- package/dist/analysts/react/analysts/analyst-react.js +46 -2
- package/dist/analysts/react/corrections/correction-react.js +41 -1
- package/dist/analysts/react/detectors/detector-react-best-practices.js +5 -5
- package/dist/analysts/react/scorers/scorer-react.js +36 -1
- package/dist/analysts/registry/autodiscovery.js +2 -2
- package/dist/analysts/rust/analysts/analyst-best-practices.js +42 -3
- package/dist/analysts/rust/analysts/analyst-memory.js +2 -2
- package/dist/analysts/rust/analysts/analyst-rust.js +52 -5
- package/dist/analysts/rust/analysts/analyst-security.js +29 -1
- package/dist/analysts/scorers/scorer.js +5 -5
- package/dist/analysts/shell/analysts/analyst-shell.js +81 -5
- package/dist/analysts/shell/corrections/correction-shell.js +34 -1
- package/dist/analysts/shell/detectors/detector-shell-security.js +88 -0
- package/dist/analysts/shell/scorers/scorer-shell.js +58 -1
- package/dist/analysts/strategists/operator-structure.js +5 -7
- package/dist/analysts/strategists/suggestions-contextuais.js +5 -2
- package/dist/analysts/svg/analysts/analyst-svg.js +1 -0
- package/dist/analysts/tailwind/analysts/analyst-tailwind.js +79 -55
- package/dist/analysts/tailwind/corrections/correction-tailwind.js +108 -9
- package/dist/analysts/tailwind/detectors/detector-tailwind-best-practices.js +122 -7
- package/dist/analysts/tailwind/scorers/scorer-tailwind.js +62 -11
- package/dist/analysts/xml/analysts/analyst-xml.js +2 -2
- package/dist/app/index.js +1 -0
- package/dist/bin/cli-bootstrap.js +6 -4
- package/dist/bin/index.js +6 -4
- package/dist/caretakers/scoring.js +1 -0
- package/dist/cli/commands/command-analysts.js +4 -3
- package/dist/cli/commands/command-azure.js +1 -1
- package/dist/cli/commands/command-circleci.js +1 -1
- package/dist/cli/commands/command-compliance.js +1 -1
- package/dist/cli/commands/command-diagnose.js +10 -13
- package/dist/cli/commands/command-fix-types.js +9 -32
- package/dist/cli/commands/command-formatters.js +2 -2
- package/dist/cli/commands/command-github-actions.js +1 -1
- package/dist/cli/commands/command-gitlab-ci.js +1 -1
- package/dist/cli/commands/command-guardian.js +1 -1
- package/dist/cli/commands/command-imports.js +6 -6
- package/dist/cli/commands/command-jenkins.js +1 -1
- package/dist/cli/commands/command-licenses.js +1 -1
- package/dist/cli/commands/command-marketplace.js +7 -7
- package/dist/cli/commands/command-names.js +3 -8
- package/dist/cli/commands/command-perf.js +7 -9
- package/dist/cli/commands/command-plugins.js +4 -4
- package/dist/cli/diagnostic/auto-fix.js +2 -2
- package/dist/cli/diagnostic/exporters/json-exporter.js +1 -1
- package/dist/cli/diagnostic/exporters/sharded-exporter.js +0 -3
- package/dist/cli/diagnostic/exporters/svg-optimization-exporter.js +1 -1
- package/dist/cli/diagnostic/filters.js +9 -9
- package/dist/cli/diagnostic/handlers/archetype-handler.js +3 -6
- package/dist/cli/diagnostic/handlers/auto-fix-handler.js +4 -4
- package/dist/cli/diagnostic/handlers/guardian-handler.js +1 -1
- package/dist/cli/diagnostic/processing-diagnostic.js +31 -35
- package/dist/cli/diagnostic/processing-helpers.js +2 -2
- package/dist/cli/handlers/fix-types-exporter.js +1 -4
- package/dist/cli/helpers/display-frame.js +5 -5
- package/dist/core/config/auto/auto-fix-config.js +0 -6
- package/dist/core/config/chalk-safe.js +6 -6
- package/dist/core/config/config.js +11 -13
- package/dist/core/config/conventions.js +1 -1
- package/dist/core/config/security.js +2 -2
- package/dist/core/execution/analysis-cache.js +5 -8
- package/dist/core/execution/ast-cache.js +1 -3
- package/dist/core/execution/executor.js +8 -21
- package/dist/core/execution/inquisitor.js +24 -21
- package/dist/core/execution/results.js +1 -0
- package/dist/core/execution/scanner.js +4 -4
- package/dist/core/messages/en/analysts/analyst-github-actions-messages.js +1 -1
- package/dist/core/messages/en/analysts/analyst-patterns-usage-messages.js +1 -0
- package/dist/core/messages/en/analysts/analyst-shell-messages.js +15 -0
- package/dist/core/messages/en/analysts/detector-constructions-syntactic-messages.js +6 -0
- package/dist/core/messages/en/analysts/detector-js-ts-messages.js +27 -0
- package/dist/core/messages/en/analysts/detector-react-messages.js +8 -0
- package/dist/core/messages/en/analysts/detector-shell-messages.js +17 -0
- package/dist/core/messages/en/analysts/detector-tailwind-messages.js +3 -3
- package/dist/core/messages/en/analysts/report-circleci-messages.js +7 -7
- package/dist/core/messages/en/caretakers/caretaker-messages.js +1 -7
- package/dist/core/messages/en/core/plugin-messages.js +31 -3
- package/dist/core/messages/en/log/log.js +4 -4
- package/dist/core/messages/en/ui/filter-config.js +1 -5
- package/dist/core/messages/i18n-system.js +3 -3
- package/dist/core/messages/index.js +3 -3
- package/dist/core/messages/ja/analysts/analyst-github-actions-messages.js +1 -1
- package/dist/core/messages/ja/analysts/analyst-patterns-usage-messages.js +1 -0
- package/dist/core/messages/ja/analysts/analyst-shell-messages.js +15 -0
- package/dist/core/messages/ja/analysts/detector-constructions-syntactic-messages.js +6 -0
- package/dist/core/messages/ja/analysts/detector-js-ts-messages.js +27 -0
- package/dist/core/messages/ja/analysts/detector-react-messages.js +8 -0
- package/dist/core/messages/ja/analysts/detector-shell-messages.js +17 -0
- package/dist/core/messages/ja/analysts/detector-tailwind-messages.js +3 -3
- package/dist/core/messages/ja/analysts/report-circleci-messages.js +7 -7
- package/dist/core/messages/ja/caretakers/caretaker-messages.js +1 -7
- package/dist/core/messages/ja/core/plugin-messages.js +31 -3
- package/dist/core/messages/ja/log/log.js +4 -4
- package/dist/core/messages/ja/ui/filter-config.js +1 -1
- package/dist/core/messages/pt/analysts/analyst-github-actions-messages.js +1 -1
- package/dist/core/messages/pt/analysts/analyst-patterns-usage-messages.js +1 -0
- package/dist/core/messages/pt/analysts/analyst-shell-messages.js +15 -0
- package/dist/core/messages/pt/analysts/detector-constructions-syntactic-messages.js +6 -0
- package/dist/core/messages/pt/analysts/detector-js-ts-messages.js +27 -0
- package/dist/core/messages/pt/analysts/detector-react-messages.js +8 -0
- package/dist/core/messages/pt/analysts/detector-shell-messages.js +17 -0
- package/dist/core/messages/pt/analysts/detector-tailwind-messages.js +3 -3
- package/dist/core/messages/pt/analysts/report-circleci-messages.js +7 -7
- package/dist/core/messages/pt/caretakers/caretaker-messages.js +1 -7
- package/dist/core/messages/pt/core/plugin-messages.js +31 -3
- package/dist/core/messages/pt/log/log-engine.js +6 -6
- package/dist/core/messages/pt/log/log.js +3 -3
- package/dist/core/messages/pt/ui/filter-config.js +1 -1
- package/dist/core/messages/shared/icons.js +3 -3
- package/dist/core/messages/zh/analysts/analyst-github-actions-messages.js +1 -1
- package/dist/core/messages/zh/analysts/analyst-patterns-usage-messages.js +1 -0
- package/dist/core/messages/zh/analysts/analyst-shell-messages.js +15 -0
- package/dist/core/messages/zh/analysts/detector-constructions-syntactic-messages.js +6 -0
- package/dist/core/messages/zh/analysts/detector-js-ts-messages.js +27 -0
- package/dist/core/messages/zh/analysts/detector-react-messages.js +8 -0
- package/dist/core/messages/zh/analysts/detector-shell-messages.js +17 -0
- package/dist/core/messages/zh/analysts/detector-tailwind-messages.js +3 -3
- package/dist/core/messages/zh/analysts/report-circleci-messages.js +7 -7
- package/dist/core/messages/zh/caretakers/caretaker-messages.js +1 -7
- package/dist/core/messages/zh/core/plugin-messages.js +31 -3
- package/dist/core/messages/zh/log/log.js +3 -3
- package/dist/core/messages/zh/ui/filter-config.js +1 -5
- package/dist/core/parsing/filters.js +3 -3
- package/dist/core/parsing/langs/json.js +1 -1
- package/dist/core/parsing/langs/python.js +1 -1
- package/dist/core/parsing/langs/typescript.js +1 -1
- package/dist/core/parsing/parser.js +3 -4
- package/dist/core/parsing/utils.js +1 -0
- package/dist/core/registry/file-registry.js +3 -2
- package/dist/core/registry/paths.js +3 -3
- package/dist/core/reporting/default-reporter.js +2 -2
- package/dist/core/schema/version.js +6 -6
- package/dist/core/workers/worker-executor.js +3 -3
- package/dist/core/workers/worker-pool.js +0 -0
- package/dist/guardian/baseline.js +1 -1
- package/dist/guardian/gpg.js +3 -1
- package/dist/guardian/integrity.js +2 -7
- package/dist/guardian/records.js +7 -1
- package/dist/guardian/result.js +1 -1
- package/dist/guardian/sentinel.js +7 -1
- package/dist/guardian/watcher-hidden.js +6 -1
- package/dist/licenses/fs-utils.js +5 -1
- package/dist/licenses/generate-notices.js +1 -1
- package/dist/licenses/index.js +1 -0
- package/dist/licenses/normalizer.js +10 -9
- package/dist/node.loader.js +224 -4
- package/dist/reports/analise-async-patterns.js +1 -1
- package/dist/reports/filter-smart.js +2 -5
- package/dist/reports/generator-report.js +7 -7
- package/dist/reports/report-archetypes.js +10 -10
- package/dist/reports/report-caretaker-health.js +2 -1
- package/dist/reports/report-patterns-usage.js +1 -1
- package/dist/sdk/analyzer.js +1 -1
- package/dist/shared/data-processing/fragment-report.js +11 -11
- package/dist/shared/data-processing/json.js +1 -1
- package/dist/shared/data-processing/occurrences.js +3 -2
- package/dist/shared/formatters/code-min-formatter.js +1 -1
- package/dist/shared/formatters/engines/prettier.js +1 -1
- package/dist/shared/formatters/engines/stylelint.js +43 -40
- package/dist/shared/formatters/formatter.js +8 -8
- package/dist/shared/formatters/formatters/code.js +3 -3
- package/dist/shared/formatters/formatters/css.js +2 -10
- package/dist/shared/formatters/formatters/dotfiles.js +1 -1
- package/dist/shared/formatters/formatters/html.js +1 -5
- package/dist/shared/formatters/formatters/json.js +0 -3
- package/dist/shared/formatters/formatters/markdown.js +19 -24
- package/dist/shared/formatters/formatters/properties.js +2 -2
- package/dist/shared/formatters/formatters/shell.js +1 -4
- package/dist/shared/formatters/formatters/sql.js +0 -3
- package/dist/shared/formatters/formatters/xml.js +5 -7
- package/dist/shared/formatters/formatters/yaml.js +2 -7
- package/dist/shared/formatters/index.js +1 -1
- package/dist/shared/helpers/framework-detector.js +6 -2
- package/dist/shared/helpers/json.js +1 -1
- package/dist/shared/helpers/magic-constants-whitelist.js +1 -1
- package/dist/shared/helpers/masking.js +17 -17
- package/dist/shared/helpers/reader-report.js +0 -12
- package/dist/shared/helpers/structural-hash.js +3 -2
- package/dist/shared/helpers/structure.js +1 -1
- package/dist/shared/marketplace/registry.js +1 -1
- package/dist/shared/marketplace/remote.js +4 -4
- package/dist/shared/persistence/persistence.js +13 -6
- package/dist/shared/plugins/core-plugin.js +5 -1
- package/dist/shared/plugins/registry.js +3 -2
- package/dist/types/analysts/tailwind-correction.js +2 -0
- package/dist/types/caretakers/imports-barrel.js +1 -0
- package/dist/types/caretakers/index.js +4 -0
- package/dist/types/caretakers/map-reversion.js +1 -0
- package/dist/types/caretakers/pruning.js +1 -0
- package/dist/types/caretakers/scoring.js +1 -0
- package/dist/types/common/analysts.js +1 -1
- package/dist/types/core/config/filters.js +1 -0
- package/dist/types/core/config/index.js +2 -0
- package/dist/types/core/execution/ambiente.js +1 -0
- package/dist/types/core/execution/linguagens.js +1 -0
- package/dist/types/core/execution/parse-errors.js +1 -0
- package/dist/types/core/execution/results.js +1 -0
- package/dist/types/core/execution/structure-json.js +1 -0
- package/dist/types/core/index.js +1 -0
- package/dist/types/core/messages/index.js +1 -0
- package/dist/types/core/messages/log.js +1 -0
- package/dist/types/core/parsing/babel-narrow.js +1 -0
- package/dist/types/core/parsing/index.js +1 -0
- package/dist/types/core/runtime.js +1 -0
- package/dist/types/guardian/index.js +2 -0
- package/dist/types/guardian/integrity.js +7 -0
- package/dist/types/guardian/snapshot.js +1 -0
- package/dist/types/index.js +4 -4
- package/dist/types/licenses/index.js +2 -0
- package/dist/types/processing/display.js +16 -13
- package/dist/types/processing/filters.js +8 -11
- package/dist/types/reports/compliance.js +1 -0
- package/dist/types/reports/streaming.js +1 -0
- package/dist/types/scripts/index.js +1 -0
- package/dist/types/scripts/migrar-aliases.js +1 -0
- package/dist/types/sdk/index.js +1 -0
- package/dist/types/shared/index.js +2 -0
- package/dist/types/vulnerabilities/index.js +2 -0
- package/dist/vulnerabilities/scanner.js +3 -2
- package/package.json +14 -20
|
@@ -1,17 +1,35 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
|
|
2
|
+
const V3_DEPRECATED_MAP = {
|
|
3
|
+
'shadow-sm': 'shadow-xs',
|
|
4
|
+
'drop-shadow-sm': 'drop-shadow-xs',
|
|
5
|
+
'blur-sm': 'blur-xs',
|
|
6
|
+
'rounded-sm': 'rounded-xs',
|
|
7
|
+
'outline-none': 'outline-hidden',
|
|
8
|
+
'flex-shrink': 'shrink',
|
|
9
|
+
'flex-grow': 'grow',
|
|
10
|
+
'overflow-ellipsis': 'text-ellipsis',
|
|
11
|
+
'decoration-slice': 'box-decoration-slice',
|
|
12
|
+
'decoration-clone': 'box-decoration-clone',
|
|
13
|
+
};
|
|
3
14
|
export function pontuarTailwind(src, _relPath) {
|
|
4
15
|
let score = 0;
|
|
5
16
|
const maxScore = 100;
|
|
6
17
|
const issues = [];
|
|
7
18
|
const strengths = [];
|
|
8
|
-
const _linhas = splitLines(src);
|
|
9
19
|
const srcCompleto = src;
|
|
10
20
|
const classMatches = srcCompleto.match(/\bclass(Name)?\s*=\s*["']([^"']*)["']/g) ?? [];
|
|
11
21
|
const allClasses = classMatches.map(metrica => {
|
|
12
22
|
const match = metrica.match(/["']([^"']*)["']/);
|
|
13
23
|
return match ? match[1].split(/\s+/).filter(Boolean) : [];
|
|
14
24
|
}).flat();
|
|
25
|
+
const v3Deprecated = allClasses.filter(c => c in V3_DEPRECATED_MAP);
|
|
26
|
+
if (v3Deprecated.length === 0) {
|
|
27
|
+
score += 5;
|
|
28
|
+
strengths.push('Sem classes obsoletas do v3');
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
issues.push(`${v3Deprecated.length} classe(s) obsoleta(s) do v3 detectadas: ${v3Deprecated.map(c => `${c}→${V3_DEPRECATED_MAP[c]}`).join(', ')}`);
|
|
32
|
+
}
|
|
15
33
|
const duplicates = allClasses.filter((elem, indice) => allClasses.indexOf(elem) !== indice);
|
|
16
34
|
if (duplicates.length === 0) {
|
|
17
35
|
score += 10;
|
|
@@ -55,7 +73,7 @@ export function pontuarTailwind(src, _relPath) {
|
|
|
55
73
|
}
|
|
56
74
|
else {
|
|
57
75
|
score += 2;
|
|
58
|
-
issues.push(`${arbitraryValues.length} valores arbitrários - considere
|
|
76
|
+
issues.push(`${arbitraryValues.length} valores arbitrários - considere @theme no CSS`);
|
|
59
77
|
}
|
|
60
78
|
const importantCount = (srcCompleto.match(/class(Name)?=.*!/g) ?? []).length;
|
|
61
79
|
if (importantCount === 0) {
|
|
@@ -123,15 +141,48 @@ export function pontuarTailwind(src, _relPath) {
|
|
|
123
141
|
else {
|
|
124
142
|
issues.push(`Média de ${avgClasses.toFixed(1)} classes por elemento - considere extrair componentes`);
|
|
125
143
|
}
|
|
126
|
-
const
|
|
127
|
-
|
|
144
|
+
const hasThemeDirective = /@theme\b/.test(srcCompleto);
|
|
145
|
+
const hasConfigRef = /\btailwind\.config|\b@config\b/.test(srcCompleto);
|
|
146
|
+
if (hasThemeDirective) {
|
|
128
147
|
score += 5;
|
|
129
|
-
strengths.push('Uso de @
|
|
148
|
+
strengths.push('Uso de @theme para design tokens (v4)');
|
|
130
149
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
150
|
+
else if (hasConfigRef) {
|
|
151
|
+
score += 2;
|
|
152
|
+
issues.push('Use @theme no CSS ao invés de tailwind.config.js (v4)');
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
score += 3;
|
|
156
|
+
}
|
|
157
|
+
const hasImportTailwindcss = /@import\s+["']tailwindcss["']/.test(srcCompleto);
|
|
158
|
+
const hasTailwindDirective = /@tailwind\s+(base|components|utilities)/.test(srcCompleto);
|
|
159
|
+
if (hasImportTailwindcss) {
|
|
160
|
+
score += 3;
|
|
161
|
+
strengths.push('Importa Tailwind via @import "tailwindcss" (v4)');
|
|
162
|
+
}
|
|
163
|
+
else if (hasTailwindDirective) {
|
|
164
|
+
issues.push('Use @import "tailwindcss" ao invés de @tailwind (v4)');
|
|
165
|
+
}
|
|
166
|
+
const hasUtilityDirective = /@utility\b/.test(srcCompleto);
|
|
167
|
+
const hasLayerUtilities = /@layer\s+utilities/.test(srcCompleto);
|
|
168
|
+
if (hasUtilityDirective) {
|
|
169
|
+
score += 4;
|
|
170
|
+
strengths.push('Uso de @utility para custom utilities (v4)');
|
|
171
|
+
}
|
|
172
|
+
else if (hasLayerUtilities) {
|
|
173
|
+
issues.push('Use @utility ao invés de @layer utilities (v4)');
|
|
174
|
+
}
|
|
175
|
+
const v3ImportantPrefix = (srcCompleto.match(/class(Name)?\s*=\s*["'][^"']*![\w-]/g) ?? []).length;
|
|
176
|
+
if (v3ImportantPrefix > 0) {
|
|
177
|
+
issues.push(`${v3ImportantPrefix} uso(s) de ! como prefixo (v3) - mova ! para o final (ex: flex! no lugar de !flex)`);
|
|
178
|
+
}
|
|
179
|
+
const v3VariableArbitrary = (srcCompleto.match(/\[--[^\]]+\]/g) ?? []).length;
|
|
180
|
+
if (v3VariableArbitrary > 0) {
|
|
181
|
+
issues.push(`${v3VariableArbitrary} variável(is) em colchetes - use bg-(--var) ao invés de bg-[--var] (v4)`);
|
|
182
|
+
}
|
|
183
|
+
const themeFunction = (srcCompleto.match(/\btheme\(/g) ?? []).length;
|
|
184
|
+
if (themeFunction > 0) {
|
|
185
|
+
issues.push(`${themeFunction} uso(s) de theme() - prefira CSS variables (var(--color-*)) (v4)`);
|
|
135
186
|
}
|
|
136
187
|
return {
|
|
137
188
|
score: Math.min(score, maxScore),
|
|
@@ -144,6 +195,6 @@ export function pontuarTailwind(src, _relPath) {
|
|
|
144
195
|
export const pontuadorTailwind = {
|
|
145
196
|
nome: 'pontuador-tailwind',
|
|
146
197
|
categoria: 'estilo',
|
|
147
|
-
descricao: 'Pontua qualidade de Tailwind CSS',
|
|
198
|
+
descricao: 'Pontua qualidade de Tailwind CSS v4',
|
|
148
199
|
pontuar: pontuarTailwind
|
|
149
200
|
};
|
|
@@ -147,7 +147,7 @@ function collectXmlIssues(src, relPath) {
|
|
|
147
147
|
}
|
|
148
148
|
// DOCTYPE + ENTITY (XXE)
|
|
149
149
|
for (const metrica of scan.matchAll(/<!DOCTYPE\b[\s\S]*?(?:\]\s*>|>)/gi)) {
|
|
150
|
-
const chunk = metrica[0]
|
|
150
|
+
const chunk = metrica[0];
|
|
151
151
|
const hasExternalId = /\b(SYSTEM|PUBLIC)\b/i.test(chunk);
|
|
152
152
|
const line = lineOf(metrica.index);
|
|
153
153
|
ocorrencias.push(warn(messages.XmlMensagens.doctypeDetectado, relPath, line));
|
|
@@ -156,7 +156,7 @@ function collectXmlIssues(src, relPath) {
|
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
for (const metrica of scan.matchAll(/<!ENTITY\b[\s\S]*?>/gi)) {
|
|
159
|
-
const chunk = metrica[0]
|
|
159
|
+
const chunk = metrica[0];
|
|
160
160
|
const hasExternal = /\b(SYSTEM|PUBLIC)\b/i.test(chunk);
|
|
161
161
|
const isParamEntity = /<!ENTITY\s+%/i.test(chunk);
|
|
162
162
|
const line = lineOf(metrica.index);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './github.js';
|
|
@@ -35,9 +35,11 @@ async function registrarLoader() {
|
|
|
35
35
|
const loaderCaminho = resolvePath(distRaiz, 'node.loader.js');
|
|
36
36
|
const loaderUrl = pathToFileURL(loaderCaminho).toString();
|
|
37
37
|
// Tenta registrar o loader via API experimental da v20+
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const moduleImport = await import('node:module');
|
|
39
|
+
const registerHooks = moduleImport.registerHooks;
|
|
40
|
+
if (typeof registerHooks === 'function') {
|
|
41
|
+
const hooks = await import(loaderUrl);
|
|
42
|
+
registerHooks(hooks);
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
catch (err) {
|
|
@@ -170,7 +172,7 @@ export async function mainCli() {
|
|
|
170
172
|
log.debug(CliBinMensagens.erroInicializarFormatadores.replace('{erro}', err instanceof Error ? err.message : String(err)));
|
|
171
173
|
}
|
|
172
174
|
// 4. Registro de Comandos
|
|
173
|
-
registrarComandos(program, ocorrencia => aplicarFlagsGlobais(ocorrencia));
|
|
175
|
+
registrarComandos(program, ocorrencia => void aplicarFlagsGlobais(ocorrencia));
|
|
174
176
|
program.addCommand(comandoPerf());
|
|
175
177
|
// 5. Flags de histórico
|
|
176
178
|
const argv = process.argv.slice(2);
|
package/dist/bin/index.js
CHANGED
|
@@ -35,9 +35,11 @@ async function registrarLoader() {
|
|
|
35
35
|
const loaderCaminho = resolvePath(distRaiz, 'node.loader.js');
|
|
36
36
|
const loaderUrl = pathToFileURL(loaderCaminho).toString();
|
|
37
37
|
// Tenta registrar o loader via API experimental da v20+
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const moduleImport = await import('node:module');
|
|
39
|
+
const registerHooks = moduleImport.registerHooks;
|
|
40
|
+
if (typeof registerHooks === 'function') {
|
|
41
|
+
const hooks = await import(loaderUrl);
|
|
42
|
+
registerHooks(hooks);
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
catch (err) {
|
|
@@ -170,7 +172,7 @@ export async function mainCli() {
|
|
|
170
172
|
log.debug(CliBinMensagens.erroInicializarFormatadores.replace('{erro}', err instanceof Error ? err.message : String(err)));
|
|
171
173
|
}
|
|
172
174
|
// 4. Registro de Comandos
|
|
173
|
-
registrarComandos(program, ocorrencia => aplicarFlagsGlobais(ocorrencia));
|
|
175
|
+
registrarComandos(program, ocorrencia => void aplicarFlagsGlobais(ocorrencia));
|
|
174
176
|
program.addCommand(comandoPerf());
|
|
175
177
|
// 5. Flags de histórico
|
|
176
178
|
const argv = process.argv.slice(2);
|
|
@@ -40,8 +40,9 @@ export function comandoAnalistas() {
|
|
|
40
40
|
for (const arquivo of lista) {
|
|
41
41
|
const registroOriginal = registroAnalistas.find(raiz => raiz.nome === arquivo.nome);
|
|
42
42
|
let limitesStr = '';
|
|
43
|
-
if (registroOriginal
|
|
44
|
-
|
|
43
|
+
if (registroOriginal && 'limites' in registroOriginal && registroOriginal.limites) {
|
|
44
|
+
const limites = registroOriginal.limites;
|
|
45
|
+
limitesStr = Object.entries(limites).map(([chave, valor]) => `${chave}:${String(valor)}`).join('<br>');
|
|
45
46
|
}
|
|
46
47
|
linhas.push(messages.CliComandoAnalistasMensagens.docLinhaAnalista(arquivo.nome, arquivo.categoria, arquivo.descricao || '', limitesStr));
|
|
47
48
|
}
|
|
@@ -56,7 +57,7 @@ export function comandoAnalistas() {
|
|
|
56
57
|
geradoEm: new Date().toISOString(),
|
|
57
58
|
total: lista.length,
|
|
58
59
|
analistas: lista,
|
|
59
|
-
configLimites: config.ANALISE_LIMITES
|
|
60
|
+
configLimites: config.ANALISE_LIMITES
|
|
60
61
|
});
|
|
61
62
|
log.sucesso(messages.CliComandoAnalistasMensagens.jsonExportado(destino));
|
|
62
63
|
return;
|
|
@@ -73,7 +73,7 @@ export function comandoAzure() {
|
|
|
73
73
|
console.log('');
|
|
74
74
|
ocorrencias.forEach((ocorrencia) => {
|
|
75
75
|
const prefix = ocorrencia.nivel === 'erro' ? '[RED]' : ocorrencia.nivel === 'aviso' ? '[YELLOW]' : '[BLUE]';
|
|
76
|
-
log.info(msgs.ocorrencia(prefix, ocorrencia.tipo ?? '', ocorrencia.linha ?? 0, ocorrencia.mensagem
|
|
76
|
+
log.info(msgs.ocorrencia(prefix, ocorrencia.tipo ?? '', ocorrencia.linha ?? 0, ocorrencia.mensagem));
|
|
77
77
|
if (ocorrencia.sugestao) {
|
|
78
78
|
log.info(msgs.sugestao(ocorrencia.sugestao));
|
|
79
79
|
}
|
|
@@ -69,7 +69,7 @@ export function comandoCircleCI() {
|
|
|
69
69
|
console.log('');
|
|
70
70
|
ocorrencias.forEach(ocorrencia => {
|
|
71
71
|
const prefix = ocorrencia.nivel === 'erro' ? '[RED]' : ocorrencia.nivel === 'aviso' ? '[YELLOW]' : '[BLUE]';
|
|
72
|
-
log.info(msgs.ocorrencia(prefix, ocorrencia.tipo ?? '', ocorrencia.linha ?? 0, ocorrencia.mensagem
|
|
72
|
+
log.info(msgs.ocorrencia(prefix, ocorrencia.tipo ?? '', ocorrencia.linha ?? 0, ocorrencia.mensagem));
|
|
73
73
|
if (ocorrencia.sugestao) {
|
|
74
74
|
log.info(msgs.sugestao(ocorrencia.sugestao));
|
|
75
75
|
}
|
|
@@ -28,7 +28,7 @@ export function comandoCompliance() {
|
|
|
28
28
|
}
|
|
29
29
|
const { processarDiagnostico } = await import('../diagnostic/index.js');
|
|
30
30
|
const resultado = await processarDiagnostico({ json: true });
|
|
31
|
-
const ocorrencias = resultado.resultadoFinal.ocorrencias
|
|
31
|
+
const ocorrencias = resultado.resultadoFinal.ocorrencias;
|
|
32
32
|
const relatorio = gerarRelatorioCompliance(framework, ocorrencias, {
|
|
33
33
|
nomeProjeto: process.cwd().split('/').pop() ?? 'projeto',
|
|
34
34
|
duracao: resultado.resultadoFinal.metricas.tempoTotal ?? 0,
|
|
@@ -44,10 +44,6 @@ async function mostrarSugestoesVerbose(opts, command, logNivel) {
|
|
|
44
44
|
const activeFlags = [];
|
|
45
45
|
const details = [];
|
|
46
46
|
const parentOpts = obterOptsParent(command);
|
|
47
|
-
if (json) {
|
|
48
|
-
activeFlags.push('--json');
|
|
49
|
-
details.push(messages.CliComandoDiagnosticarMensagens.detalheSaidaEstruturada);
|
|
50
|
-
}
|
|
51
47
|
if (Boolean(opts['guardianCheck'])) {
|
|
52
48
|
activeFlags.push('--guardian-check');
|
|
53
49
|
details.push(messages.CliComandoDiagnosticarMensagens.detalheGuardian);
|
|
@@ -81,28 +77,29 @@ async function mostrarSugestoesVerbose(opts, command, logNivel) {
|
|
|
81
77
|
activeFlags.push('--auto-fix-conservative');
|
|
82
78
|
details.push(messages.CliComandoDiagnosticarMensagens.detalheAutoFixConservative);
|
|
83
79
|
}
|
|
84
|
-
const includes = opts['include']
|
|
85
|
-
const excludes = opts['exclude']
|
|
80
|
+
const includes = opts['include'];
|
|
81
|
+
const excludes = opts['exclude'];
|
|
86
82
|
if (includes.length) {
|
|
87
83
|
details.push(messages.CliComandoDiagnosticarMensagens.detalheIncludePatterns(includes.length, includes.join(', ')));
|
|
88
84
|
}
|
|
89
85
|
if (excludes.length) {
|
|
90
86
|
details.push(messages.CliComandoDiagnosticarMensagens.detalheExcludePatterns(excludes.length, excludes.join(', ')));
|
|
91
87
|
}
|
|
92
|
-
const parentExport = (
|
|
93
|
-
const parentExportFull = (
|
|
88
|
+
const parentExport = (Object.prototype.hasOwnProperty.call(parentOpts, 'export') && Boolean(parentOpts['export']));
|
|
89
|
+
const parentExportFull = (Object.prototype.hasOwnProperty.call(parentOpts, 'exportFull') && Boolean(parentOpts['exportFull']));
|
|
94
90
|
const localExport = Boolean(opts['export']);
|
|
95
91
|
const localExportFull = Boolean(opts['exportFull']);
|
|
96
92
|
if (parentExport || localExport) {
|
|
97
93
|
activeFlags.push('--export');
|
|
98
|
-
const
|
|
99
|
-
|
|
94
|
+
const relDirValue = config?.['REPORTS_DIR'];
|
|
95
|
+
const relDir = typeof relDirValue === 'string' ? relDirValue : 'reports';
|
|
96
|
+
details.push(messages.CliComandoDiagnosticarMensagens.detalheExport(relDir));
|
|
100
97
|
}
|
|
101
98
|
if (parentExportFull || localExportFull) {
|
|
102
99
|
activeFlags.push('--export-full');
|
|
103
100
|
details.push(messages.CliComandoDiagnosticarMensagens.detalheExportFull);
|
|
104
101
|
}
|
|
105
|
-
const resolvedParentLogNivel =
|
|
102
|
+
const resolvedParentLogNivel = Object.prototype.hasOwnProperty.call(parentOpts, 'logLevel') ? String(parentOpts['logLevel']) : undefined;
|
|
106
103
|
const effectiveLogNivel = logNivel || (resolvedParentLogNivel ?? 'info');
|
|
107
104
|
details.push(messages.CliComandoDiagnosticarMensagens.detalheLogLevel(effectiveLogNivel));
|
|
108
105
|
details.push(messages.CliComandoDiagnosticarMensagens.dicaPrefiraLogLevelDebug);
|
|
@@ -151,7 +148,7 @@ export function comandoDiagnosticar(aplicarFlagsGlobais) {
|
|
|
151
148
|
cmd.allowUnknownOption(true);
|
|
152
149
|
cmd.allowExcessArguments(true);
|
|
153
150
|
for (const opt of optionsDiagnosticar) {
|
|
154
|
-
if ('parser' in opt
|
|
151
|
+
if ('parser' in opt) {
|
|
155
152
|
cmd.option(opt.flags, opt.desc, opt.parser, opt.defaultValue);
|
|
156
153
|
}
|
|
157
154
|
else if ('defaultValue' in opt) {
|
|
@@ -162,7 +159,7 @@ export function comandoDiagnosticar(aplicarFlagsGlobais) {
|
|
|
162
159
|
}
|
|
163
160
|
}
|
|
164
161
|
cmd.action(async (opts, command) => {
|
|
165
|
-
|
|
162
|
+
aplicarFlagsCombinadas(command, opts, aplicarFlagsGlobais);
|
|
166
163
|
if (process.env.SUKUNA_TEST_FAST === '1') {
|
|
167
164
|
if (opts.json) {
|
|
168
165
|
console.log(JSON.stringify({
|
|
@@ -8,7 +8,7 @@ import { PROJETO_RAIZ } from '../../core/registry/index.js';
|
|
|
8
8
|
import { exportarRelatoriosFixTypes } from '../handlers/index.js';
|
|
9
9
|
import { ExitCode, expandIncludePatterns, processPatternList, sair } from '../helpers/index.js';
|
|
10
10
|
import { asTecnicas, extrairMensagemErro } from '../../types/index.js';
|
|
11
|
-
const { CliComandoFixTypesMensagens, DICAS, formatarTipoInseguro, gerarResumoCategoria,
|
|
11
|
+
const { CliComandoFixTypesMensagens, DICAS, formatarTipoInseguro, gerarResumoCategoria, log, MENSAGENS_AUTOFIX, MENSAGENS_CLI_CORRECAO_TIPOS, MENSAGENS_ERRO_FIX_TYPES: MENSAGENS_ERRO, MENSAGENS_INICIO_FIX_TYPES: MENSAGENS_INICIO, MENSAGENS_PROGRESSO_FIX_TYPES: MENSAGENS_PROGRESSO, MENSAGENS_RESUMO, MENSAGENS_SUCESSO_FIX_TYPES: MENSAGENS_SUCESSO, TEXTOS_CATEGORIZACAO_CORRECAO_TIPOS, } = getMessages();
|
|
12
12
|
function mostrarErroDev(err) {
|
|
13
13
|
if (!config.DEV_MODE) {
|
|
14
14
|
return;
|
|
@@ -24,8 +24,8 @@ async function carregarInquisicao() {
|
|
|
24
24
|
const modInq = await import('../../core/execution/index.js');
|
|
25
25
|
const modReg = await import('../../analysts/registry/index.js');
|
|
26
26
|
registroAnalistasCache = modReg.registroAnalistas;
|
|
27
|
-
const analistaTiposInseguros = registroAnalistasCache
|
|
28
|
-
return typeof arquivo === 'object' && arquivo
|
|
27
|
+
const analistaTiposInseguros = registroAnalistasCache?.find((arquivo) => {
|
|
28
|
+
return typeof arquivo === 'object' && arquivo.nome === 'detector-tipos-inseguros';
|
|
29
29
|
});
|
|
30
30
|
return {
|
|
31
31
|
iniciarInquisicao: modInq.iniciarInquisicao,
|
|
@@ -210,12 +210,12 @@ async function aplicarCorrecoesAutomaticas(ocorrenciasCategorizadas, verbose) {
|
|
|
210
210
|
const porArquivo = {};
|
|
211
211
|
for (const item of ocorrenciasCategorizadas) {
|
|
212
212
|
const arquivo = item.ocorrencia.relPath || 'desconhecido';
|
|
213
|
-
if (!porArquivo
|
|
213
|
+
if (!(arquivo in porArquivo)) {
|
|
214
214
|
porArquivo[arquivo] = [];
|
|
215
215
|
}
|
|
216
216
|
porArquivo[arquivo].push(item);
|
|
217
217
|
}
|
|
218
|
-
const resultado =
|
|
218
|
+
const resultado = aplicarCorrecoesEmLote(porArquivo, {
|
|
219
219
|
dryRun: false,
|
|
220
220
|
minConfianca: 85,
|
|
221
221
|
verbose,
|
|
@@ -273,17 +273,6 @@ function mostrarExemplosDryRun(tiposInseguros, verbose, minConfidence) {
|
|
|
273
273
|
log.info(DICAS.usarInterativo);
|
|
274
274
|
log.info(DICAS.ajustarConfianca(minConfidence));
|
|
275
275
|
}
|
|
276
|
-
function mostrarMensagemDryRun() {
|
|
277
|
-
console.log();
|
|
278
|
-
log.aviso(MENSAGENS_CLI_CORRECAO_TIPOS.dryRunAviso(ICONES.inicio));
|
|
279
|
-
log.info(MENSAGENS_CLI_CORRECAO_TIPOS.linhaEmBranco);
|
|
280
|
-
log.info(TEMPLATE_RESUMO_FINAL.titulo);
|
|
281
|
-
for (const passo of TEMPLATE_RESUMO_FINAL.passos) {
|
|
282
|
-
log.info(MENSAGENS_CLI_CORRECAO_TIPOS.templatePasso(passo));
|
|
283
|
-
}
|
|
284
|
-
log.info(MENSAGENS_CLI_CORRECAO_TIPOS.linhaEmBranco);
|
|
285
|
-
log.info(MENSAGENS_AUTOFIX.dicas.removerDryRun);
|
|
286
|
-
}
|
|
287
276
|
export function criarComandoFixTypes() {
|
|
288
277
|
const cmd = new Command('fix-types');
|
|
289
278
|
cmd.description(CliComandoFixTypesMensagens.descricao).option('--dry-run', 'Mostra o que seria corrigido sem aplicar mudanças', false).option('--target <path>', 'Diretório ou arquivo específico para analisar', 'src').option('--confidence <number>', 'Nível mínimo de confiança para aplicar correções (0-100)', '85').option('--verbose', 'Mostra detalhes de cada correção', false).option('--interactive', 'Modo interativo: confirma cada correção', false).option('--export', 'Exporta relatórios JSON e Markdown para pasta relatorios/', false).option('--include <padrao>', 'Glob pattern a INCLUIR (pode repetir a flag ou usar vírgulas / espaços para múltiplos)', (val, prev) => {
|
|
@@ -342,7 +331,7 @@ async function executarFixTypes(options) {
|
|
|
342
331
|
sair(ExitCode.Failure);
|
|
343
332
|
return;
|
|
344
333
|
}
|
|
345
|
-
const ocorrencias = resultado.ocorrencias
|
|
334
|
+
const ocorrencias = resultado.ocorrencias;
|
|
346
335
|
const tiposInseguros = ocorrencias.filter((ocorrencia) => ocorrencia.tipo && ['tipo-inseguro-any', 'tipo-inseguro-any-assertion', 'tipo-inseguro-any-cast', 'tipo-inseguro-unknown'].includes(ocorrencia.tipo));
|
|
347
336
|
if (tiposInseguros.length === 0) {
|
|
348
337
|
log.sucesso(MENSAGENS_SUCESSO.nenhumTipoInseguro);
|
|
@@ -351,7 +340,7 @@ async function executarFixTypes(options) {
|
|
|
351
340
|
log.aviso(MENSAGENS_RESUMO.encontrados(tiposInseguros.length));
|
|
352
341
|
const porTipo = tiposInseguros.reduce((acc, ocorrencia) => {
|
|
353
342
|
const tipo = ocorrencia.tipo ?? 'desconhecido';
|
|
354
|
-
if (!acc
|
|
343
|
+
if (!(tipo in acc)) {
|
|
355
344
|
acc[tipo] = [];
|
|
356
345
|
}
|
|
357
346
|
acc[tipo].push(ocorrencia);
|
|
@@ -367,15 +356,9 @@ async function executarFixTypes(options) {
|
|
|
367
356
|
return;
|
|
368
357
|
}
|
|
369
358
|
log.fase(MENSAGENS_CLI_CORRECAO_TIPOS.aplicandoCorrecoesAuto);
|
|
370
|
-
const { fixAnyToProperTipo, fixUnknownToSpecificTipo } = await import('../../analysts/corrections/quick-fixes/index.js');
|
|
371
|
-
if (!fixAnyToProperTipo || !fixUnknownToSpecificTipo) {
|
|
372
|
-
log.erro(MENSAGENS_ERRO.modulosNaoEncontrados);
|
|
373
|
-
sair(ExitCode.Failure);
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
359
|
const porArquivo = tiposInseguros.reduce((acc, ocorrencia) => {
|
|
377
360
|
const arquivo = ocorrencia.relPath || 'desconhecido';
|
|
378
|
-
if (!acc
|
|
361
|
+
if (!(arquivo in acc)) {
|
|
379
362
|
acc[arquivo] = [];
|
|
380
363
|
}
|
|
381
364
|
acc[arquivo].push(ocorrencia);
|
|
@@ -395,9 +378,6 @@ async function executarFixTypes(options) {
|
|
|
395
378
|
if (casosAltaPrioridade.length > 0) {
|
|
396
379
|
await aplicarCorrecoesAutomaticas(ocorrenciasCategorizadas, verbose);
|
|
397
380
|
}
|
|
398
|
-
else if (isDryRun) {
|
|
399
|
-
mostrarMensagemDryRun();
|
|
400
|
-
}
|
|
401
381
|
else {
|
|
402
382
|
console.log();
|
|
403
383
|
log.info(MENSAGENS_SUCESSO.nenhumAltaConfianca);
|
|
@@ -423,10 +403,7 @@ async function executarFixTypes(options) {
|
|
|
423
403
|
verbose
|
|
424
404
|
});
|
|
425
405
|
}
|
|
426
|
-
|
|
427
|
-
if (temAny && !isDryRun) {
|
|
428
|
-
sair(ExitCode.Failure);
|
|
429
|
-
}
|
|
406
|
+
sair(ExitCode.Failure);
|
|
430
407
|
}
|
|
431
408
|
async function salvarAnaliseDetalhada(ocorrenciasCategorizadas, stats, mediaConfianca, verbose) {
|
|
432
409
|
if (!verbose) {
|
|
@@ -48,11 +48,11 @@ export function comandoFormatters() {
|
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
50
|
const mod = await import(caminhoResolvido);
|
|
51
|
-
if (
|
|
51
|
+
if (typeof mod.default.gerar !== 'function') {
|
|
52
52
|
log.erro(FormattersMensagens.moduloInvalido(caminho));
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
-
const formatter = { nome, ...mod.default };
|
|
55
|
+
const formatter = { nome, ...mod.default, descricao: mod.default.descricao ?? '', formato: mod.default.formato ?? 'json' };
|
|
56
56
|
registrarFormatter(formatter);
|
|
57
57
|
log.sucesso(FormattersMensagens.formatadorRegistrado(nome));
|
|
58
58
|
}
|
|
@@ -220,7 +220,7 @@ export function comandoGithubActions() {
|
|
|
220
220
|
sair(ExitCode.Failure);
|
|
221
221
|
return;
|
|
222
222
|
}
|
|
223
|
-
const formato = opts.format;
|
|
223
|
+
const formato = (opts.format ?? 'json');
|
|
224
224
|
if (!['json', 'markdown', 'html', 'csv'].includes(formato)) {
|
|
225
225
|
log.erro(CliComandoGithubActionsMensagens.formatoInvalido(formato));
|
|
226
226
|
sair(ExitCode.Failure);
|
|
@@ -69,7 +69,7 @@ export function comandoGitlabCI() {
|
|
|
69
69
|
console.log('');
|
|
70
70
|
ocorrencias.forEach(ocorrencia => {
|
|
71
71
|
const prefix = ocorrencia.nivel === 'erro' ? '[RED]' : ocorrencia.nivel === 'aviso' ? '[YELLOW]' : '[BLUE]';
|
|
72
|
-
log.info(msgs.ocorrencia(prefix, ocorrencia.tipo ?? '', ocorrencia.linha ?? 0, ocorrencia.mensagem
|
|
72
|
+
log.info(msgs.ocorrencia(prefix, ocorrencia.tipo ?? '', ocorrencia.linha ?? 0, ocorrencia.mensagem));
|
|
73
73
|
if (ocorrencia.sugestao) {
|
|
74
74
|
log.info(msgs.sugestao(ocorrencia.sugestao));
|
|
75
75
|
}
|
|
@@ -167,7 +167,7 @@ export function comandoGuardian(aplicarFlagsGlobais) {
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
catch (err) {
|
|
170
|
-
logGuardian.erroGuardian(err.message
|
|
170
|
+
logGuardian.erroGuardian(err instanceof Error ? err.message : String(err));
|
|
171
171
|
mostrarErroDev(err);
|
|
172
172
|
if (opts.json) {
|
|
173
173
|
console.log(JSON.stringify({ status: 'erro', mensagem: extrairMensagemErro(err) }));
|
|
@@ -156,13 +156,13 @@ function analisarDiferencas(pathsAtuais, pathsPropostos) {
|
|
|
156
156
|
const entradasPropostas = analisarTsconfigPaths(pathsPropostos);
|
|
157
157
|
const entradasRemovidas = [];
|
|
158
158
|
for (const entrada of entradasAtuais) {
|
|
159
|
-
if (!
|
|
159
|
+
if (!(entrada.alias in pathsPropostos)) {
|
|
160
160
|
entradasRemovidas.push(entrada);
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
const entradasNovas = [];
|
|
164
164
|
for (const [alias, targets] of Object.entries(pathsPropostos)) {
|
|
165
|
-
if (!pathsAtuais
|
|
165
|
+
if (!(alias in pathsAtuais)) {
|
|
166
166
|
entradasNovas.push({
|
|
167
167
|
alias,
|
|
168
168
|
targets,
|
|
@@ -253,14 +253,14 @@ async function aplicarImports(projectRoot, srcDir, paths) {
|
|
|
253
253
|
}
|
|
254
254
|
if (importPath.startsWith('@')) {
|
|
255
255
|
let barrelAlias = importToRewrite;
|
|
256
|
-
if (paths
|
|
256
|
+
if (importToRewrite in paths) {
|
|
257
257
|
barrelAlias = importToRewrite;
|
|
258
258
|
}
|
|
259
259
|
else {
|
|
260
260
|
const lastSlash = importToRewrite.lastIndexOf('/');
|
|
261
261
|
if (lastSlash > 0) {
|
|
262
262
|
const potentialBarrel = importToRewrite.substring(0, lastSlash);
|
|
263
|
-
if (paths
|
|
263
|
+
if (potentialBarrel in paths) {
|
|
264
264
|
barrelAlias = potentialBarrel;
|
|
265
265
|
}
|
|
266
266
|
}
|
|
@@ -304,7 +304,7 @@ async function aplicarImports(projectRoot, srcDir, paths) {
|
|
|
304
304
|
if (mesmoModuloPai(srcDir, arquivo, importToRewrite)) {
|
|
305
305
|
break;
|
|
306
306
|
}
|
|
307
|
-
if (
|
|
307
|
+
if (novoImport !== importPath && paths[novoImport]) {
|
|
308
308
|
const regexResult = criarRegexImport(importPath, importToRewrite, line);
|
|
309
309
|
if (regexResult) {
|
|
310
310
|
lines[indice] = line.replace(regexResult, `$1$2${novoImport}$2`);
|
|
@@ -312,7 +312,7 @@ async function aplicarImports(projectRoot, srcDir, paths) {
|
|
|
312
312
|
modified = true;
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
|
-
else
|
|
315
|
+
else {
|
|
316
316
|
const aliasDoPai = obterAliasPaiComBarrel(srcDir, relativeToSrc, aliasMap);
|
|
317
317
|
if (aliasDoPai && aliasDoPai !== importPath) {
|
|
318
318
|
const regexResult = criarRegexImport(importPath, importToRewrite, line);
|
|
@@ -64,7 +64,7 @@ export function comandoJenkins() {
|
|
|
64
64
|
console.log('');
|
|
65
65
|
ocorrencias.forEach((ocorrencia) => {
|
|
66
66
|
const prefix = ocorrencia.nivel === 'erro' ? '[RED]' : ocorrencia.nivel === 'aviso' ? '[YELLOW]' : '[BLUE]';
|
|
67
|
-
log.info(msgs.ocorrencia(prefix, ocorrencia.tipo ?? '', ocorrencia.linha ?? 0, ocorrencia.mensagem
|
|
67
|
+
log.info(msgs.ocorrencia(prefix, ocorrencia.tipo ?? '', ocorrencia.linha ?? 0, ocorrencia.mensagem));
|
|
68
68
|
if (ocorrencia.sugestao) {
|
|
69
69
|
log.info(msgs.sugestao(ocorrencia.sugestao));
|
|
70
70
|
}
|
|
@@ -21,7 +21,7 @@ export function comandoLicencas() {
|
|
|
21
21
|
root
|
|
22
22
|
});
|
|
23
23
|
console.log(JSON.stringify(result, null, 2));
|
|
24
|
-
process.exitCode = result.problematic
|
|
24
|
+
process.exitCode = result.problematic.length > 0 ? 2 : 0;
|
|
25
25
|
}
|
|
26
26
|
catch (err) {
|
|
27
27
|
log.erro(msgs.falhaScan(err instanceof Error ? err.message : String(err)));
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import { messages } from '../../core/messages/index.js';
|
|
4
4
|
import { ExitCode, sair } from '../helpers/index.js';
|
|
5
|
-
import { buscarPacotesInstalados, info
|
|
5
|
+
import { buscarPacotesInstalados, info, instalarPacote, listarPacotesInstalados, obterInfoPacote, removerPacote, resolverMelhorVersao, search } from '../../shared/marketplace/index.js';
|
|
6
6
|
const log = messages.log;
|
|
7
7
|
const msgs = messages.CliComandoMarketplaceMensagens;
|
|
8
8
|
export function comandoMarketplace() {
|
|
@@ -15,7 +15,7 @@ export function comandoMarketplace() {
|
|
|
15
15
|
.action(async (termo, opts) => {
|
|
16
16
|
try {
|
|
17
17
|
log.info(msgs.buscando(termo));
|
|
18
|
-
const { total, resultados } = await
|
|
18
|
+
const { total, resultados } = await search(termo);
|
|
19
19
|
if (opts.json) {
|
|
20
20
|
console.log(JSON.stringify({ total, resultados }, null, 2));
|
|
21
21
|
return;
|
|
@@ -26,8 +26,8 @@ export function comandoMarketplace() {
|
|
|
26
26
|
}
|
|
27
27
|
log.info(msgs.tituloBusca);
|
|
28
28
|
for (const r of resultados) {
|
|
29
|
-
const desc = r.descricao
|
|
30
|
-
const tags = r.tags
|
|
29
|
+
const desc = r.descricao;
|
|
30
|
+
const tags = r.tags;
|
|
31
31
|
log.info(msgs.itemBusca(r.nome, desc, tags));
|
|
32
32
|
}
|
|
33
33
|
log.info(msgs.totalResultados(total));
|
|
@@ -48,7 +48,7 @@ export function comandoMarketplace() {
|
|
|
48
48
|
log.info(msgs.jaInstalado(nome, instalado.versao));
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
|
-
const analista = await
|
|
51
|
+
const analista = await info(nome);
|
|
52
52
|
if (!analista) {
|
|
53
53
|
log.erro(msgs.analistaNaoEncontrado(nome));
|
|
54
54
|
sair(ExitCode.Failure);
|
|
@@ -122,7 +122,7 @@ export function comandoMarketplace() {
|
|
|
122
122
|
.option('--json', msgs.jsonDescricao)
|
|
123
123
|
.action(async (nome, opts) => {
|
|
124
124
|
try {
|
|
125
|
-
const analista = await
|
|
125
|
+
const analista = await info(nome);
|
|
126
126
|
const local = await obterInfoPacote(nome);
|
|
127
127
|
if (!analista && !local) {
|
|
128
128
|
log.erro(msgs.analistaNaoEncontrado(nome));
|
|
@@ -148,7 +148,7 @@ export function comandoMarketplace() {
|
|
|
148
148
|
}
|
|
149
149
|
if (analista) {
|
|
150
150
|
const versoes = analista.versoes.map((v) => v.version).join(', ');
|
|
151
|
-
const tags = analista.tags
|
|
151
|
+
const tags = analista.tags;
|
|
152
152
|
log.info(msgs.infoTitulo(nome));
|
|
153
153
|
log.info(msgs.infoDescricaoDetalhada(analista.descricao));
|
|
154
154
|
log.info(msgs.infoCategoria(analista.categoria));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
import
|
|
2
|
+
import generate from '@babel/generator';
|
|
3
3
|
import { parse } from '@babel/parser';
|
|
4
|
-
import
|
|
4
|
+
import traverse from '@babel/traverse';
|
|
5
5
|
import { Command } from 'commander';
|
|
6
6
|
import * as fs from 'fs';
|
|
7
7
|
import * as path from 'path';
|
|
@@ -9,12 +9,6 @@ import { chalk, config } from '../../core/config/index.js';
|
|
|
9
9
|
import { getMessages } from '../../core/messages/index.js';
|
|
10
10
|
import { ExitCode, getFilesWithExtension, getSourceFiles, sair } from '../helpers/index.js';
|
|
11
11
|
const { log, CliComandoNamesMensagens } = getMessages();
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- CJS default interop
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
const traverse = traverseModule.default ?? traverseModule;
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- CJS default interop
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
const generate = generateModule.default ?? generateModule;
|
|
18
12
|
function parseMappingLine(line) {
|
|
19
13
|
const parts = line.split('=');
|
|
20
14
|
if (parts.length < 2) {
|
|
@@ -174,6 +168,7 @@ function doApply(raizDir, srcDir, namesDir, mappingFile) {
|
|
|
174
168
|
}
|
|
175
169
|
}
|
|
176
170
|
});
|
|
171
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
177
172
|
if (changed) {
|
|
178
173
|
const output = generate(ast, {
|
|
179
174
|
retainLines: false,
|