@mocoto/mahoraga 0.14.1 → 0.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analysts/architects/analyst-structure.js +1 -1
- package/dist/analysts/architects/archetypes-custom.js +8 -13
- package/dist/analysts/architects/detector-archetypes.js +39 -35
- package/dist/analysts/architects/orchestrator-archetypes.js +3 -3
- package/dist/analysts/architects/signals-project-advanced.js +2 -2
- package/dist/analysts/architects/signals-project.js +1 -1
- package/dist/analysts/azure-pipelines/analysts/analyst-azure.js +20 -21
- package/dist/analysts/azure-pipelines/detectors/detector-azure-structure.js +0 -3
- package/dist/analysts/circleci/analysts/analyst-circleci.js +22 -24
- package/dist/analysts/circleci/detectors/detector-circleci-structure.js +4 -7
- package/dist/analysts/converters/convert-registry.js +1 -1
- package/dist/analysts/converters/index.js +1 -1
- package/dist/analysts/corrections/auto-fix-engine.js +1 -1
- package/dist/analysts/corrections/corrector-structure.js +8 -7
- package/dist/analysts/corrections/map-reversion.js +2 -2
- package/dist/analysts/corrections/reorganize-barrels.js +3 -3
- package/dist/analysts/corrections/rewrite-testes-aliases.js +23 -22
- package/dist/analysts/corrections/type-safety/type-analyzer.js +3 -3
- package/dist/analysts/corrections/type-safety/type-validator.js +2 -2
- package/dist/analysts/corrections/type-safety/usage-analyzer.js +3 -3
- package/dist/analysts/css/analysts/analyst-css.js +27 -28
- package/dist/analysts/css-in-js/detectors/detector-css-in-js-best-practices.js +8 -15
- package/dist/analysts/detectors/detector-architecture.js +2 -2
- package/dist/analysts/detectors/detector-bugs-ml.js +8 -8
- package/dist/analysts/detectors/detector-code-fragile.js +11 -10
- package/dist/analysts/detectors/detector-dependencies.js +5 -5
- package/dist/analysts/detectors/detector-duplications.js +5 -8
- package/dist/analysts/detectors/detector-monorepo.js +10 -9
- package/dist/analysts/detectors/detector-performance.js +2 -1
- package/dist/analysts/detectors/detector-recommendation-architecture.js +1 -1
- package/dist/analysts/detectors/detector-security.js +1 -1
- package/dist/analysts/detectors/detector-structure.js +3 -3
- 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 +81 -9
- package/dist/analysts/js-ts/detectors/detector-constructions-syntactic.js +35 -6
- 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 +5 -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 +63 -8
- package/dist/analysts/react/analysts/analyst-react.js +45 -1
- package/dist/analysts/react/corrections/correction-react.js +40 -0
- package/dist/analysts/react/detectors/detector-react-best-practices.js +4 -4
- package/dist/analysts/react/scorers/scorer-react.js +36 -1
- 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 +116 -9
- package/dist/analysts/tailwind/detectors/detector-tailwind-best-practices.js +122 -7
- package/dist/analysts/tailwind/scorers/scorer-tailwind.js +62 -10
- 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 +1 -1
- 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-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 +3 -3
- 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/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 +2 -2
- package/dist/core/config/config.js +6 -8
- 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/executor.js +8 -19
- package/dist/core/execution/inquisitor.js +24 -21
- package/dist/core/execution/results.js +1 -0
- package/dist/core/execution/scanner.js +3 -3
- 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/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/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/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/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 +2 -2
- 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 +6 -1
- package/dist/guardian/result.js +1 -1
- package/dist/guardian/sentinel.js +6 -1
- package/dist/guardian/watcher-hidden.js +5 -1
- package/dist/licenses/fs-utils.js +4 -1
- package/dist/licenses/generate-notices.js +1 -1
- package/dist/licenses/header-options.js +0 -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 +4 -4
- package/dist/reports/report-archetypes.js +10 -10
- package/dist/reports/report-caretaker-health.js +2 -1
- package/dist/sdk/analyzer.js +1 -1
- package/dist/shared/data-processing/fragment-report.js +10 -10
- 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 +6 -9
- 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 +18 -23
- 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 +1 -1
- 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 +0 -1
- package/dist/shared/plugins/core-plugin.js +3 -1
- package/dist/shared/plugins/registry.js +3 -2
- 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 +3 -7
- 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/npm-audit.js +0 -1
- package/dist/vulnerabilities/scanner.js +2 -1
- package/dist/vulnerabilities/vulnerabilities.js +0 -1
- package/package.json +11 -12
|
@@ -5,13 +5,13 @@ export const DetectorTailwindMensagens = {
|
|
|
5
5
|
repeatedClasses: (duplicates) => `重复的类: ${duplicates}`,
|
|
6
6
|
repeatedClassesSugestao: '请删除重复的类',
|
|
7
7
|
arbitraryValue: (val) => `检测到任意值: ${val}`,
|
|
8
|
-
arbitraryValueSugestao: '
|
|
8
|
+
arbitraryValueSugestao: '请考虑通过 CSS 中的 @theme 添加 (Tailwind v4)',
|
|
9
9
|
important: '在Tailwind类中检测到!important',
|
|
10
10
|
importantSugestao: '避免使用!important - 请重构优先级',
|
|
11
11
|
arbitraryValueOveruse: '过度使用任意值 - 可能表明缺少设计令牌',
|
|
12
|
-
arbitraryValueOveruseSugestao: '
|
|
12
|
+
arbitraryValueOveruseSugestao: '通过 CSS 中的 @theme 定义自定义令牌,而不是使用任意值 (Tailwind v4)',
|
|
13
13
|
missingDesignToken: '检测到硬编码值 - 请使用 Tailwind 设计令牌',
|
|
14
|
-
missingDesignTokenSugestao: '将颜色、间距和大小提取到
|
|
14
|
+
missingDesignTokenSugestao: '将颜色、间距和大小提取到 CSS 的 @theme 中 (Tailwind v4)',
|
|
15
15
|
responsiveWithoutBase: '响应式类没有对应的基础类',
|
|
16
16
|
responsiveWithoutBaseSugestao: '在响应式变体之前添加基础类',
|
|
17
17
|
inlineStylesWithTailwind: '检测到内联样式与 Tailwind 类一起使用',
|
|
@@ -29,7 +29,16 @@ export const ReactMensagens = {
|
|
|
29
29
|
export const ReactHooksMensagens = {
|
|
30
30
|
useEffectNoDeps: 'useEffect 缺少依赖数组 (请评估依赖项以避免循环)。',
|
|
31
31
|
memoCallbackNoDeps: 'Hook 缺少依赖数组 (useMemo/useCallback)。',
|
|
32
|
-
hookInConditional: '在条件语句中声明了 Hook (违反了 Hooks 规则)。'
|
|
32
|
+
hookInConditional: '在条件语句中声明了 Hook (违反了 Hooks 规则)。',
|
|
33
|
+
react19Use: '检测到 use() 钩子 (React 19) — 请确保包裹在 <Suspense> 边界内。',
|
|
34
|
+
react19UseOptimistic: '检测到 useOptimistic 钩子 (React 19) — 需要更新函数。',
|
|
35
|
+
react19UseActionState: '检测到 useActionState 钩子 (React 19) — 用于表单操作。',
|
|
36
|
+
react19UseFormStatus: '检测到 useFormStatus 钩子 (React 19) — 访问表单待处理状态。',
|
|
37
|
+
react19ForwardRefDeprecated: 'forwardRef 在 React 19 中已弃用 — 将 ref 作为常规 prop 传递。',
|
|
38
|
+
react19FCDeprecated: 'React.FC/FunctionComponent 在 React 19 中已弃用 — 直接键入 props。',
|
|
39
|
+
react19DefaultPropsDeprecated: 'defaultProps 在 React 19 中已弃用 — 使用默认参数。',
|
|
40
|
+
react19UseClient: '文件使用了客户端功能 (hooks/events) 但缺少 \'use client\' 指令 (React 19)。',
|
|
41
|
+
react19FormAction: '检测到带有 action 属性的表单 (React 19)。'
|
|
33
42
|
};
|
|
34
43
|
// ─── Tailwind 消息 ──────────────────────────────────────────────
|
|
35
44
|
export const TailwindMensagens = {
|
|
@@ -38,7 +47,13 @@ export const TailwindMensagens = {
|
|
|
38
47
|
importantUsage: (token) => `在 (${token}) 中检测到使用 ! (important)。建议使用工具类或作用域增强,而非 important。`,
|
|
39
48
|
variantConflict: (prop, variants) => `${prop} 可能存在变体冲突 (变体: ${variants.slice(0, 6).join(', ')})。请检查顺序/作用域。`,
|
|
40
49
|
dangerousArbitraryValue: (token) => `带有潜在危险的 url 任意值 (${token})。避免使用 javascript:/data:text/html。`,
|
|
41
|
-
arbitraryValue: (token) => `带有任意值的类 (${token})
|
|
50
|
+
arbitraryValue: (token) => `带有任意值的类 (${token})。请确认是否符合设计。`,
|
|
51
|
+
v3DeprecatedUtility: (token, replacement) => `v3 废弃的工具类 "${token}" → 使用 "${replacement}" (Tailwind v4).`,
|
|
52
|
+
v3Directive: `检测到 @tailwind 指令 (v3) → 使用 @import "tailwindcss" (Tailwind v4).`,
|
|
53
|
+
v3LayerUtilities: `检测到 @layer utilities (v3) → 使用 @utility (Tailwind v4).`,
|
|
54
|
+
themeFunction: `检测到 theme() 函数 (v3 已弃用) → 优先使用 CSS 变量 (var(--color-*)).`,
|
|
55
|
+
v3ImportantPrefix: (token) => `"${token}" 中的 !important 前缀 (v3) → 将 ! 移到末尾 ("${token.replace('!', '')}!" ).`,
|
|
56
|
+
v3ArbitraryVar: `方括号中的变量 (v3) → 使用圆括号 (例如用 bg-(--var) 代替 bg-[--var]).`
|
|
42
57
|
};
|
|
43
58
|
// ─── CSS 消息 ───────────────────────────────────────────────────
|
|
44
59
|
export const CssMensagens = {
|
|
@@ -270,7 +285,20 @@ export const RustMensagens = {
|
|
|
270
285
|
missingDoc: (fnName) => `公开函数 '${fnName}' 缺少文档注释 (///)。`,
|
|
271
286
|
namingConvention: (constName) => `常量 '${constName}' 应遵循 SCREAMING_CASE 命名约定。`,
|
|
272
287
|
redundantReturn: '函数末尾的 return 是多余的;Rust 使用隐式返回 (最后一个表达式)。',
|
|
273
|
-
wildcardImport: (importPath) => `通配符导入 '${importPath}'
|
|
288
|
+
wildcardImport: (importPath) => `通配符导入 '${importPath}' 可能污染命名空间;建议使用显式导入。`,
|
|
289
|
+
lazyLockSuggestion: '检测到 once_cell::sync::Lazy — 使用 std::sync::LazyLock (Rust 1.80+)。',
|
|
290
|
+
onceLockSuggestion: '检测到 once_cell::sync::OnceCell — 使用 std::sync::OnceLock (Rust 1.70+)。',
|
|
291
|
+
offsetOfSuggestion: '手动指针偏移访问字段 — 使用 std::mem::offset_of! (Rust 1.77+)。',
|
|
292
|
+
letChainsPattern: '检测到 let_chains 模式 (Rust 1.78 起稳定)。',
|
|
293
|
+
assertMatchesSuggestion: 'assert!(matches!(...)) 模式 — 考虑 assert_matches!(...) (nightly)。',
|
|
294
|
+
isSomeAnd: '.is_some() && 谓词模式 — 使用 .is_some_and(|x| ...) (Rust 1.70+)。',
|
|
295
|
+
isOkAnd: '.is_ok() && 谓词模式 — 使用 .is_ok_and(|x| ...) (Rust 1.70+)。',
|
|
296
|
+
inspectMethod: '具有副作用的 map() — 使用 .inspect() (Rust 1.76+)。',
|
|
297
|
+
implicitFormatCapture: 'format!("...{var}...") 可使用隐式捕获 (Rust 1.80+)。',
|
|
298
|
+
pointerCast: '使用 `as` 进行指针转换 — 使用 .cast() (Rust 1.72+)。',
|
|
299
|
+
splitOnce: '使用索引访问的 splitn(2, ...) — 使用 .split_once() (Rust 1.62+)。',
|
|
300
|
+
okErrAntipattern: '.ok()?.unwrap() 反模式 — 直接在 Result 上使用 ?。',
|
|
301
|
+
collectOverPush: '循环中使用 push() 构建集合 — 使用 .map().collect()。'
|
|
274
302
|
};
|
|
275
303
|
// ─── Java / Kotlin 消息 ─────────────────────────────────────────
|
|
276
304
|
export const JavaMensagens = {
|
|
@@ -140,7 +140,7 @@ export function formatarLinha({ nivel, mensagem, sanitize = true }) {
|
|
|
140
140
|
if (!process.env.VITEST && process.env.SUKUNA_CENTER === '1') {
|
|
141
141
|
try {
|
|
142
142
|
const cols = obterColunasTerm();
|
|
143
|
-
const out =
|
|
143
|
+
const out = typeof process.stdout.isTTY !== 'undefined' ? process.stdout : undefined;
|
|
144
144
|
const isTty = !!out && out.isTTY;
|
|
145
145
|
if (isTty && cols && cols > 0) {
|
|
146
146
|
const ANSI_REGEX = /[\u001B\u009B][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
|
|
@@ -164,7 +164,7 @@ export function formatarLinha({ nivel, mensagem, sanitize = true }) {
|
|
|
164
164
|
function obterColunasTerm() {
|
|
165
165
|
// Tries to get terminal width safely
|
|
166
166
|
try {
|
|
167
|
-
const out =
|
|
167
|
+
const out = typeof process.stdout.columns !== 'undefined' ? process.stdout : undefined;
|
|
168
168
|
const cols = out?.columns;
|
|
169
169
|
if (typeof cols === 'number' && cols > 0) {
|
|
170
170
|
return cols;
|
|
@@ -414,7 +414,7 @@ export const log = {
|
|
|
414
414
|
const visibleLen = (string) => string.replace(ANSI_REGEX, '').length;
|
|
415
415
|
const frameWidth = Math.max(...lines.map(linha => visibleLen(linha)));
|
|
416
416
|
const cols = obterColunasTerm() ?? 0;
|
|
417
|
-
const outStream =
|
|
417
|
+
const outStream = typeof process.stdout.isTTY !== 'undefined' ? process.stdout : undefined;
|
|
418
418
|
const isTty = !!outStream && outStream.isTTY;
|
|
419
419
|
if (isTty) {
|
|
420
420
|
const pad = Math.floor(Math.max(0, cols - frameWidth) / 2);
|
|
@@ -221,11 +221,7 @@ export const AGRUPAMENTOS_MENSAGEM = [
|
|
|
221
221
|
* 获取问题类型的优先级
|
|
222
222
|
*/
|
|
223
223
|
export function getPrioridade(tipo) {
|
|
224
|
-
return PRIORIDADES[tipo]
|
|
225
|
-
prioridade: 'baixa',
|
|
226
|
-
icone: ICONES_ARQUIVO.arquivo,
|
|
227
|
-
descricao: '未分类问题'
|
|
228
|
-
};
|
|
224
|
+
return PRIORIDADES[tipo];
|
|
229
225
|
}
|
|
230
226
|
/**
|
|
231
227
|
* 按消息查找分组
|
|
@@ -16,7 +16,7 @@ export function aplicarSupressaoOcorrencias(ocorrencias, filtros) {
|
|
|
16
16
|
const relPath = ocorrencia.relPath || '';
|
|
17
17
|
const mensagem = (ocorrencia).mensagem || '';
|
|
18
18
|
// Suprime por tipo/regra (verifica tanto o tipo quanto a mensagem)
|
|
19
|
-
if (filtros.suppressRules?.some(rule => tipo.includes(rule) || mensagem.includes(rule))) {
|
|
19
|
+
if (filtros.suppressRules?.some((rule) => tipo.includes(rule) || mensagem.includes(rule))) {
|
|
20
20
|
return false;
|
|
21
21
|
}
|
|
22
22
|
// Suprime por severidade: se a regra tiver override de severidade "off", suprime
|
|
@@ -24,14 +24,14 @@ export function aplicarSupressaoOcorrencias(ocorrencias, filtros) {
|
|
|
24
24
|
return false;
|
|
25
25
|
}
|
|
26
26
|
// Suprime por caminho (glob patterns)
|
|
27
|
-
if (filtros.suppressByPath?.some(pattern => {
|
|
27
|
+
if (filtros.suppressByPath?.some((pattern) => {
|
|
28
28
|
const regex = globPatternToRegExp(pattern);
|
|
29
29
|
return regex.test(relPath);
|
|
30
30
|
})) {
|
|
31
31
|
return false;
|
|
32
32
|
}
|
|
33
33
|
// Suprime por padrão de arquivo
|
|
34
|
-
if (filtros.suppressByFilePattern?.some(pattern => {
|
|
34
|
+
if (filtros.suppressByFilePattern?.some((pattern) => {
|
|
35
35
|
const fileNome = relPath.split('/').pop() ?? '';
|
|
36
36
|
const regex = globPatternToRegExp(pattern);
|
|
37
37
|
return regex.test(fileNome);
|
|
@@ -7,7 +7,7 @@ export function parseComJson(codigo) {
|
|
|
7
7
|
const info = {
|
|
8
8
|
type: Array.isArray(parsed) ? 'array' : typeof parsed,
|
|
9
9
|
};
|
|
10
|
-
if (typeof parsed === 'object' &&
|
|
10
|
+
if (typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
11
11
|
const keys = Object.keys(parsed);
|
|
12
12
|
info.keys = keys;
|
|
13
13
|
info.depth = estimateDepth(parsed, 0);
|
|
@@ -8,7 +8,7 @@ export function parseComPython(codigo) {
|
|
|
8
8
|
const asyncFunctions = Array.from(codigo.matchAll(/^\s*async\s+def\s+([A-Za-z0-9_]+)/gm)).map(m => m[1]);
|
|
9
9
|
const imports = Array.from(codigo.matchAll(/^\s*(?:from\s+([\w.]+)\s+)?import\s+(.+)$/gm)).map(m => ({
|
|
10
10
|
module: m[1] || null,
|
|
11
|
-
names: m[2].split(',').map(s => s.trim().split(/\s+as\s+/)[0]).filter(Boolean)
|
|
11
|
+
names: m[2].split(',').map(s => s.trim().split(/\s+as\s+/)[0]).filter(Boolean)
|
|
12
12
|
}));
|
|
13
13
|
const decorators = Array.from(codigo.matchAll(/^\s*@([A-Za-z0-9_.]+)/gm)).map(m => m[1]);
|
|
14
14
|
const topLevelVars = Array.from(codigo.matchAll(/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=(?!=)/gm)).map(m => m[1]);
|
|
@@ -9,7 +9,7 @@ export function parseComTypeScript(codigo, tsx = false) {
|
|
|
9
9
|
const sf = ts.createSourceFile(tsx ? 'file.tsx' : 'file.ts', codigo, ts.ScriptTarget.Latest, false, tsx ? ts.ScriptKind.TSX : ts.ScriptKind.TS);
|
|
10
10
|
return wrapMinimal(tsx ? 'tsx-tsc' : 'ts-tsc', {
|
|
11
11
|
kind: sf.kind,
|
|
12
|
-
statements: sf.statements.length
|
|
12
|
+
statements: sf.statements.length
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
catch (erro) {
|
|
@@ -83,7 +83,7 @@ export async function decifrarSintaxe(codigo, ext, opts = {}) {
|
|
|
83
83
|
}
|
|
84
84
|
if (opts.timeoutMs) {
|
|
85
85
|
return (async () => {
|
|
86
|
-
let timer =
|
|
86
|
+
let timer = undefined;
|
|
87
87
|
try {
|
|
88
88
|
const race = Promise.race([Promise.resolve(parseResultado), new Promise(resolve => {
|
|
89
89
|
timer = setTimeout(() => {
|
|
@@ -94,7 +94,7 @@ export async function decifrarSintaxe(codigo, ext, opts = {}) {
|
|
|
94
94
|
return await race;
|
|
95
95
|
}
|
|
96
96
|
finally {
|
|
97
|
-
if (timer) {
|
|
97
|
+
if (timer !== undefined) {
|
|
98
98
|
clearTimeout(timer);
|
|
99
99
|
}
|
|
100
100
|
setCurrentParsingFile(undefined);
|
|
@@ -109,17 +109,18 @@ async function tryMigrate(targetPath) {
|
|
|
109
109
|
*/
|
|
110
110
|
export async function readJSON(fileCaminho, options = {}) {
|
|
111
111
|
const { default: defaultValue, migrate = true, validate } = options;
|
|
112
|
+
let resolvedPath = fileCaminho;
|
|
112
113
|
try {
|
|
113
114
|
// Tentar migração se habilitado
|
|
114
115
|
if (migrate) {
|
|
115
116
|
const migration = await tryMigrate(fileCaminho);
|
|
116
117
|
if (migration.migrated && migration.to) {
|
|
117
118
|
// Usar arquivo migrado
|
|
118
|
-
|
|
119
|
+
resolvedPath = migration.to;
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
122
|
// Ler e parsear diretamente (sem check de existência separado para evitar TOCTOU)
|
|
122
|
-
const content = await fs.readFile(
|
|
123
|
+
const content = await fs.readFile(resolvedPath, 'utf-8');
|
|
123
124
|
const parsed = JSON.parse(content);
|
|
124
125
|
// Validar se fornecido
|
|
125
126
|
if (validate && !validate(parsed)) {
|
|
@@ -87,11 +87,11 @@ export const REPORT_PADROES = {
|
|
|
87
87
|
*/
|
|
88
88
|
export const MIGRACAO_MAPA = {
|
|
89
89
|
// Guardian: baseline.json → guardian.baseline.json
|
|
90
|
-
[
|
|
90
|
+
[path.join(SUKUNA_DIRS.STATE, 'baseline.json')]: SUKUNA_ARQUIVOS.GUARDIAN_BASELINE,
|
|
91
91
|
// Estrutura: baseline-estrutura.json → estrutura.baseline.json
|
|
92
|
-
[
|
|
92
|
+
[path.join(SUKUNA_DIRS.STATE, 'baseline-estrutura.json')]: SUKUNA_ARQUIVOS.ESTRUTURA_BASELINE,
|
|
93
93
|
// Arquétipo: mahoraga.repo.arquetipo.json (raiz) → .mahoraga/estrutura.arquetipo.json
|
|
94
|
-
[
|
|
94
|
+
[path.join(PROJETO_RAIZ, 'mahoraga.repo.arquetipo.json')]: SUKUNA_ARQUIVOS.ESTRUTURA_ARQUETIPO
|
|
95
95
|
};
|
|
96
96
|
/**
|
|
97
97
|
* Retorna o caminho legado (se existir) ou o novo
|
|
@@ -23,7 +23,7 @@ export function createDefaultReporter() {
|
|
|
23
23
|
}
|
|
24
24
|
// Mapeamentos mínimos (incrementais) por code
|
|
25
25
|
if (code === 'ARQ_PADRAO') {
|
|
26
|
-
const padrao =
|
|
26
|
+
const padrao = typeof data?.padraoIdentificado === 'string' ? data.padraoIdentificado : '';
|
|
27
27
|
const confianca = Number((data?.confianca) ?? 0);
|
|
28
28
|
return criarOcorrencia({
|
|
29
29
|
tipo,
|
|
@@ -50,7 +50,7 @@ export function createDefaultReporter() {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
if (code === 'ARQ_VIOLACAO') {
|
|
53
|
-
const violacao =
|
|
53
|
+
const violacao = typeof data?.violacao === 'string' ? data.violacao : '';
|
|
54
54
|
return criarOcorrencia({
|
|
55
55
|
tipo,
|
|
56
56
|
nivel,
|
|
@@ -23,10 +23,10 @@ export const HISTORICO_VERSOES = {
|
|
|
23
23
|
* Cria metadados de schema para a versão atual
|
|
24
24
|
*/
|
|
25
25
|
export function criarSchemaMetadata(versao = VERSAO_ATUAL, descricaoPersonalizada) {
|
|
26
|
-
|
|
27
|
-
if (!base) {
|
|
26
|
+
if (!(versao in HISTORICO_VERSOES)) {
|
|
28
27
|
throw new Error(messages.ExcecoesMensagens.versaoSchemaDesconhecida(versao));
|
|
29
28
|
}
|
|
29
|
+
const base = HISTORICO_VERSOES[versao];
|
|
30
30
|
return {
|
|
31
31
|
...base,
|
|
32
32
|
...(descricaoPersonalizada && {
|
|
@@ -40,7 +40,7 @@ export function criarSchemaMetadata(versao = VERSAO_ATUAL, descricaoPersonalizad
|
|
|
40
40
|
export function validarSchema(relatorio) {
|
|
41
41
|
const erros = [];
|
|
42
42
|
// Verificar estrutura básica
|
|
43
|
-
if (
|
|
43
|
+
if (typeof relatorio !== 'object') {
|
|
44
44
|
erros.push('Relatório deve ser um objeto');
|
|
45
45
|
return {
|
|
46
46
|
valido: false,
|
|
@@ -64,7 +64,7 @@ export function validarSchema(relatorio) {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
// Verificar se a versão existe no histórico
|
|
67
|
-
if (schema.versao && typeof schema.versao === 'string' && !
|
|
67
|
+
if (schema.versao && typeof schema.versao === 'string' && !(schema.versao in HISTORICO_VERSOES)) {
|
|
68
68
|
erros.push(`Versão de schema desconhecida: ${schema.versao}`);
|
|
69
69
|
}
|
|
70
70
|
// Verificar presença dos dados
|
|
@@ -119,9 +119,9 @@ export function extrairDados(relatorio) {
|
|
|
119
119
|
* Verifica se uma versão é compatível com a atual
|
|
120
120
|
*/
|
|
121
121
|
export function versaoCompativel(versao) {
|
|
122
|
-
|
|
123
|
-
if (!metadata) {
|
|
122
|
+
if (!(versao in HISTORICO_VERSOES)) {
|
|
124
123
|
return false;
|
|
125
124
|
}
|
|
125
|
+
const metadata = HISTORICO_VERSOES[versao];
|
|
126
126
|
return metadata.compatibilidade.includes(VERSAO_ATUAL);
|
|
127
127
|
}
|
|
@@ -99,7 +99,7 @@ async function processarLote(lote, contexto) {
|
|
|
99
99
|
const inicio = Date.now();
|
|
100
100
|
const out = await executarTecnicaEmArquivo(tecnica, file, contexto, timeoutMs);
|
|
101
101
|
const dur = Date.now() - inicio;
|
|
102
|
-
if (
|
|
102
|
+
if (Array.isArray(out)) {
|
|
103
103
|
fileResultado.ocorrencias.push(...out);
|
|
104
104
|
}
|
|
105
105
|
fileResultado.tempos.push({
|
|
@@ -150,8 +150,8 @@ async function main() {
|
|
|
150
150
|
/* ignore */
|
|
151
151
|
}
|
|
152
152
|
const resultados = await processarLote(wd.lote ?? wd.files ?? [], contexto);
|
|
153
|
-
const occurrences = resultados.flatMap(raiz => raiz.ocorrencias
|
|
154
|
-
const metrics = resultados.flatMap(raiz => raiz.tempos
|
|
153
|
+
const occurrences = resultados.flatMap(raiz => raiz.ocorrencias);
|
|
154
|
+
const metrics = resultados.flatMap(raiz => raiz.tempos);
|
|
155
155
|
const processedArquivos = Array.isArray(wd.files) ? wd.files.length : resultados.length || 0;
|
|
156
156
|
if (port) {
|
|
157
157
|
port.postMessage({
|
|
Binary file
|
|
@@ -9,7 +9,7 @@ import { lerEstado, salvarEstado } from '../shared/persistence/index.js';
|
|
|
9
9
|
export async function carregarBaseline() {
|
|
10
10
|
try {
|
|
11
11
|
const json = await lerEstado(LINHA_BASE_CAMINHO);
|
|
12
|
-
if (
|
|
12
|
+
if (typeof json === 'object' && !Array.isArray(json)) {
|
|
13
13
|
const entries = Object.entries(json).filter(([chave, valor]) => typeof chave === 'string' && typeof valor === 'string');
|
|
14
14
|
return Object.fromEntries(entries);
|
|
15
15
|
}
|
package/dist/guardian/gpg.js
CHANGED
|
@@ -80,6 +80,8 @@ export async function inicializarChaves() {
|
|
|
80
80
|
}
|
|
81
81
|
const par = await gerarParDeChaves();
|
|
82
82
|
await salvarChavePublica(par.chavePublica);
|
|
83
|
-
|
|
83
|
+
if (par.chavePrivada) {
|
|
84
|
+
await salvarChavePrivada(par.chavePrivada);
|
|
85
|
+
}
|
|
84
86
|
return par;
|
|
85
87
|
}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
IntegridadeStatus["Criado"] = "baseline-criado";
|
|
5
|
-
IntegridadeStatus["Aceito"] = "baseline-aceito";
|
|
6
|
-
IntegridadeStatus["Ok"] = "ok";
|
|
7
|
-
IntegridadeStatus["AlteracoesDetectadas"] = "alteracoes-detectadas";
|
|
8
|
-
})(IntegridadeStatus || (IntegridadeStatus = {}));
|
|
2
|
+
import { IntegridadeStatus } from '../types/guardian/integrity.js';
|
|
3
|
+
export { IntegridadeStatus };
|
|
9
4
|
export class GuardianError extends Error {
|
|
10
5
|
detalhes;
|
|
11
6
|
constructor(erros) {
|
package/dist/guardian/records.js
CHANGED
|
@@ -5,8 +5,11 @@ import { config } from '../core/config/index.js';
|
|
|
5
5
|
import { getMessages } from '../core/messages/index.js';
|
|
6
6
|
import { ensureDir } from '../shared/helpers/index.js';
|
|
7
7
|
import { lerEstado, salvarEstado } from '../shared/persistence/index.js';
|
|
8
|
-
const { log, GuardianMensagens } = getMessages();
|
|
9
8
|
const DESTINO_PADRAO = path.join(config.STATE_DIR, 'integridade.json');
|
|
9
|
+
function getLog() {
|
|
10
|
+
const { log, GuardianMensagens } = getMessages();
|
|
11
|
+
return { log, GuardianMensagens };
|
|
12
|
+
}
|
|
10
13
|
/**
|
|
11
14
|
* Salva as assinaturas GPG dos arquivos fornecidos em um arquivo de integridade.
|
|
12
15
|
*/
|
|
@@ -21,6 +24,7 @@ export async function salvarRegistros(fileEntries, destino = DESTINO_PADRAO) {
|
|
|
21
24
|
}
|
|
22
25
|
await ensureDir(destino);
|
|
23
26
|
await salvarEstado(destino, registros);
|
|
27
|
+
const { log, GuardianMensagens } = getLog();
|
|
24
28
|
log.sucesso(GuardianMensagens.registroIntegridadeSalvo(destino));
|
|
25
29
|
}
|
|
26
30
|
/**
|
|
@@ -31,6 +35,7 @@ export async function carregarRegistros(caminho = DESTINO_PADRAO) {
|
|
|
31
35
|
return await lerEstado(caminho);
|
|
32
36
|
}
|
|
33
37
|
catch {
|
|
38
|
+
const { log, GuardianMensagens } = getLog();
|
|
34
39
|
log.aviso(GuardianMensagens.nenhumRegistroEncontrado(caminho));
|
|
35
40
|
return [];
|
|
36
41
|
}
|
package/dist/guardian/result.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Tipos para resultados do Guardian
|
|
4
4
|
*/
|
|
5
|
+
import { IntegridadeStatus } from './index.js';
|
|
5
6
|
/**
|
|
6
7
|
* Type guard para verificar se é resultado válido do Guardian
|
|
7
8
|
*/
|
|
@@ -19,7 +20,6 @@ export function isGuardianResult(value) {
|
|
|
19
20
|
const status = obj.status;
|
|
20
21
|
return (status === 'ok' || status === 'alteracoes-detectadas' || status === 'erro');
|
|
21
22
|
}
|
|
22
|
-
import { IntegridadeStatus } from './integrity.js';
|
|
23
23
|
/**
|
|
24
24
|
* Converte ResultadoGuardian (tipo legado) para GuardianResult
|
|
25
25
|
*/
|
|
@@ -7,7 +7,10 @@ import { config } from '../core/config/index.js';
|
|
|
7
7
|
import { getMessages } from '../core/messages/index.js';
|
|
8
8
|
import { ensureDir, normalizePath } from '../shared/helpers/index.js';
|
|
9
9
|
import { GuardianError, IntegridadeStatus } from '../types/index.js';
|
|
10
|
-
|
|
10
|
+
function getLog() {
|
|
11
|
+
const { log, GuardianMensagens } = getMessages();
|
|
12
|
+
return { log, GuardianMensagens };
|
|
13
|
+
}
|
|
11
14
|
function getErrMsg(err) {
|
|
12
15
|
return typeof err === 'object' && err && 'message' in err ? err.message : String(err);
|
|
13
16
|
}
|
|
@@ -21,6 +24,7 @@ async function construirSnapshot(fileEntries) {
|
|
|
21
24
|
snapshot[relPath] = await gerarSnapshotDoConteudo(content);
|
|
22
25
|
}
|
|
23
26
|
catch (err) {
|
|
27
|
+
const { log, GuardianMensagens } = getLog();
|
|
24
28
|
log.aviso(GuardianMensagens.falhaGerarAssinaturaGpg(relPath, getErrMsg(err)));
|
|
25
29
|
}
|
|
26
30
|
}
|
|
@@ -28,6 +32,7 @@ async function construirSnapshot(fileEntries) {
|
|
|
28
32
|
}
|
|
29
33
|
export async function scanSystemIntegrity(fileEntries, options) {
|
|
30
34
|
const agora = new Date().toISOString();
|
|
35
|
+
const { log, GuardianMensagens } = getLog();
|
|
31
36
|
await ensureDir(LINHA_BASE_CAMINHO);
|
|
32
37
|
let baselineAnterior = null;
|
|
33
38
|
try {
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
import { carregarRegistros, inicializarChaves, REGISTRO_VIGIA_CAMINHO_PADRAO, salvarRegistros, verificarAssinatura } from './index.js';
|
|
3
3
|
import { getMessages } from '../core/messages/index.js';
|
|
4
|
-
|
|
4
|
+
function getLog() {
|
|
5
|
+
const { log, VigiaOcultaMensagens } = getMessages();
|
|
6
|
+
return { log, VigiaOcultaMensagens };
|
|
7
|
+
}
|
|
5
8
|
export async function vigiaOculta(arquivos, caminhoRegistro = REGISTRO_VIGIA_CAMINHO_PADRAO, autoReset = true) {
|
|
9
|
+
const { log, VigiaOcultaMensagens } = getLog();
|
|
6
10
|
const registros = await carregarRegistros(caminhoRegistro);
|
|
7
11
|
const mapaAnterior = new Map(registros.map(raiz => [raiz.arquivo, raiz.assinatura]));
|
|
8
12
|
const corrompidos = [];
|
|
@@ -22,7 +22,10 @@ export function exists(caminho) {
|
|
|
22
22
|
export function readPackageJsonSync(pkgCaminho) {
|
|
23
23
|
try {
|
|
24
24
|
const data = fs.readFileSync(pkgCaminho, 'utf8');
|
|
25
|
-
|
|
25
|
+
const parsed = JSON.parse(data);
|
|
26
|
+
if (typeof parsed !== 'object' || parsed === null)
|
|
27
|
+
return null;
|
|
28
|
+
return parsed;
|
|
26
29
|
}
|
|
27
30
|
catch {
|
|
28
31
|
return null;
|
|
@@ -127,7 +127,7 @@ export async function generateNotices({ root = process.cwd(), ptBr = false, outp
|
|
|
127
127
|
await fs.writeFile(path.join(dir, 'licenses.json'), JSON.stringify(results, null, 2), 'utf-8');
|
|
128
128
|
}
|
|
129
129
|
catch { }
|
|
130
|
-
const entries = Object.entries(results
|
|
130
|
+
const entries = Object.entries(results).filter(([id]) => !id.startsWith(`${pkg.name}@`)).sort((arquivo, base) => arquivo[0].localeCompare(base[0]));
|
|
131
131
|
const parts = [header({
|
|
132
132
|
projectNome,
|
|
133
133
|
license: projectLicenca,
|
package/dist/licenses/index.js
CHANGED
|
@@ -15,19 +15,19 @@ async function tryLoadSpdx() {
|
|
|
15
15
|
}
|
|
16
16
|
spdxLoaded = true;
|
|
17
17
|
try {
|
|
18
|
-
spdxParse = (await import('spdx-expression-parse')).default ?? (await import('spdx-expression-parse'));
|
|
18
|
+
spdxParse = ((await import('spdx-expression-parse')).default ?? (await import('spdx-expression-parse')));
|
|
19
19
|
}
|
|
20
20
|
catch (err) {
|
|
21
21
|
log.debug(`${LicensasMensagens.erroCarregarSpdxExpressionParse} - ${err instanceof Error ? err.message : String(err)}`);
|
|
22
22
|
}
|
|
23
23
|
try {
|
|
24
|
-
spdxCorrect = (await import('spdx-correct')).default ?? (await import('spdx-correct'));
|
|
24
|
+
spdxCorrect = ((await import('spdx-correct')).default ?? (await import('spdx-correct')));
|
|
25
25
|
}
|
|
26
26
|
catch (err) {
|
|
27
27
|
log.debug(`${LicensasMensagens.erroCarregarSpdxCorrect} - ${err instanceof Error ? err.message : String(err)}`);
|
|
28
28
|
}
|
|
29
29
|
try {
|
|
30
|
-
spdxLicencaList = (await import('spdx-license-list')).default ?? (await import('spdx-license-list'));
|
|
30
|
+
spdxLicencaList = ((await import('spdx-license-list')).default ?? (await import('spdx-license-list')));
|
|
31
31
|
}
|
|
32
32
|
catch (err) {
|
|
33
33
|
log.debug(`${LicensasMensagens.erroCarregarSpdxLicenseList} - ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -46,7 +46,7 @@ function fallbackNormalize(raw) {
|
|
|
46
46
|
if (isRecord(raw)) {
|
|
47
47
|
return raw.type !== null ? fallbackNormalize(raw.type) : 'UNKNOWN';
|
|
48
48
|
}
|
|
49
|
-
let string =
|
|
49
|
+
let string = `${raw}`.trim();
|
|
50
50
|
string = string.replace(/\s+/g, ' ');
|
|
51
51
|
const map = {
|
|
52
52
|
mit: 'MIT',
|
|
@@ -113,7 +113,7 @@ export async function normalizeLicense(raw) {
|
|
|
113
113
|
return raw.map(raiz => awaitOrFallback(raiz)).join(' OR ');
|
|
114
114
|
}
|
|
115
115
|
if (isRecord(raw)) {
|
|
116
|
-
|
|
116
|
+
return awaitOrFallback(raw.type ?? raw);
|
|
117
117
|
}
|
|
118
118
|
return awaitOrFallback(raw);
|
|
119
119
|
}
|
|
@@ -154,11 +154,12 @@ export async function normalizeLicense(raw) {
|
|
|
154
154
|
if (!isRecord(ast)) {
|
|
155
155
|
return JSON.stringify(ast);
|
|
156
156
|
}
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
const astRecord = ast;
|
|
158
|
+
if (astRecord.license) {
|
|
159
|
+
return astRecord.license;
|
|
159
160
|
}
|
|
160
|
-
if (
|
|
161
|
-
return `${astToExpression(
|
|
161
|
+
if (astRecord.left !== null && astRecord.right !== null && astRecord.conjunction) {
|
|
162
|
+
return `${astToExpression(astRecord.left)} ${astRecord.conjunction.toUpperCase()} ${astToExpression(astRecord.right)}`;
|
|
162
163
|
}
|
|
163
164
|
return JSON.stringify(ast);
|
|
164
165
|
}
|