@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
|
@@ -239,10 +239,6 @@ function parseCssTokens(tokenList) {
|
|
|
239
239
|
let idx = 0;
|
|
240
240
|
while (idx < tokenList.length) {
|
|
241
241
|
const tok = tokenList[idx];
|
|
242
|
-
if (!tok) {
|
|
243
|
-
idx++;
|
|
244
|
-
continue;
|
|
245
|
-
}
|
|
246
242
|
if (tok.kind === 'comment') {
|
|
247
243
|
items.push({
|
|
248
244
|
kind: 'comment',
|
|
@@ -261,10 +257,6 @@ function parseCssTokens(tokenList) {
|
|
|
261
257
|
let depth = 1;
|
|
262
258
|
while (idx < tokenList.length && depth > 0) {
|
|
263
259
|
const innerTok = tokenList[idx];
|
|
264
|
-
if (!innerTok) {
|
|
265
|
-
idx++;
|
|
266
|
-
continue;
|
|
267
|
-
}
|
|
268
260
|
if (innerTok.kind === 'text') {
|
|
269
261
|
if (innerTok.value === '{') {
|
|
270
262
|
depth++;
|
|
@@ -379,11 +371,11 @@ function renderCssItems(items, depth) {
|
|
|
379
371
|
lines.push(`${indent(depth)}${item.prop}: ${item.value};`);
|
|
380
372
|
}
|
|
381
373
|
}
|
|
382
|
-
else
|
|
374
|
+
else {
|
|
383
375
|
// Add blank line before top-level blocks (except the first)
|
|
384
376
|
if (depth === 0 && indice > 0) {
|
|
385
377
|
const prevLine = lines[lines.length - 1];
|
|
386
|
-
if (prevLine !==
|
|
378
|
+
if (prevLine !== '') {
|
|
387
379
|
lines.push('');
|
|
388
380
|
}
|
|
389
381
|
}
|
|
@@ -119,7 +119,7 @@ export function formatarEditorconfigMinimo(code) {
|
|
|
119
119
|
const sectionMatch = trimmed.match(/^\[(.+)\]$/);
|
|
120
120
|
if (sectionMatch) {
|
|
121
121
|
flushSection();
|
|
122
|
-
currentSection = sectionMatch[1].trim()
|
|
122
|
+
currentSection = sectionMatch[1].trim();
|
|
123
123
|
continue;
|
|
124
124
|
}
|
|
125
125
|
const eqIdx = trimmed.indexOf('=');
|
|
@@ -31,7 +31,7 @@ function parseTagAttributes(tagContent) {
|
|
|
31
31
|
if (!name) {
|
|
32
32
|
continue;
|
|
33
33
|
}
|
|
34
|
-
const value = metrica[2]
|
|
34
|
+
const value = metrica[2] || metrica[3] || metrica[4] || '';
|
|
35
35
|
attrs.push({
|
|
36
36
|
name,
|
|
37
37
|
value
|
|
@@ -358,10 +358,6 @@ export function formatarHtmlMinimo(code) {
|
|
|
358
358
|
let indice = 0;
|
|
359
359
|
while (indice < tokens.length) {
|
|
360
360
|
const tok = tokens[indice];
|
|
361
|
-
if (!tok) {
|
|
362
|
-
indice++;
|
|
363
|
-
continue;
|
|
364
|
-
}
|
|
365
361
|
if (tok.kind === 'comment') {
|
|
366
362
|
const commentLines = tok.value.trim().split('\n');
|
|
367
363
|
for (const cl of commentLines) {
|
|
@@ -6,8 +6,8 @@ export function matchMarkdownFence(line) {
|
|
|
6
6
|
if (!metrica) {
|
|
7
7
|
return null;
|
|
8
8
|
}
|
|
9
|
-
const ch = (metrica[1]
|
|
10
|
-
const len =
|
|
9
|
+
const ch = (metrica[1]) === '~' ? '~' : '`';
|
|
10
|
+
const len = metrica[0].length;
|
|
11
11
|
const rest = trimmedLeft.slice(len);
|
|
12
12
|
return {
|
|
13
13
|
ch,
|
|
@@ -31,8 +31,8 @@ function normalizarCercasMarkdown(code, protectedLines) {
|
|
|
31
31
|
}
|
|
32
32
|
const typo = line.match(/^(\s*)``è(.*)$/);
|
|
33
33
|
if (typo) {
|
|
34
|
-
const prefix = typo[1]
|
|
35
|
-
const after = typo[2]
|
|
34
|
+
const prefix = typo[1];
|
|
35
|
+
const after = typo[2];
|
|
36
36
|
const normalized = `${prefix}\`\`\`${after}`;
|
|
37
37
|
if (normalized !== line) {
|
|
38
38
|
changed = true;
|
|
@@ -43,16 +43,16 @@ function normalizarCercasMarkdown(code, protectedLines) {
|
|
|
43
43
|
if (!metrica) {
|
|
44
44
|
return line;
|
|
45
45
|
}
|
|
46
|
-
const prefix = metrica[1]
|
|
47
|
-
const fence = metrica[2]
|
|
48
|
-
const afterFence = metrica[3]
|
|
46
|
+
const prefix = metrica[1];
|
|
47
|
+
const fence = metrica[2];
|
|
48
|
+
const afterFence = metrica[3];
|
|
49
49
|
const info = afterFence.match(/^(\s*)(\S+)(.*)$/);
|
|
50
50
|
if (!info) {
|
|
51
51
|
return line;
|
|
52
52
|
}
|
|
53
|
-
const lead = info[1]
|
|
54
|
-
const token = info[2]
|
|
55
|
-
const tail = info[3]
|
|
53
|
+
const lead = info[1];
|
|
54
|
+
const token = info[2];
|
|
55
|
+
const tail = info[3];
|
|
56
56
|
const shouldNormalizeToken = /[^\x00-\x7F]/.test(token);
|
|
57
57
|
if (!shouldNormalizeToken) {
|
|
58
58
|
return line;
|
|
@@ -92,6 +92,7 @@ function corrigirHtmlInlineEmMarkdown(text, _protectedLines) {
|
|
|
92
92
|
function corrigirEnfaseMarkdown(text) {
|
|
93
93
|
let changed = false;
|
|
94
94
|
let out = text;
|
|
95
|
+
let current = text;
|
|
95
96
|
// Não corrigir ênfase em itens de lista markdown (podem ter sintaxe ambígua intencional)
|
|
96
97
|
if (/^\s*[-*+]\s/.test(out)) {
|
|
97
98
|
return {
|
|
@@ -103,10 +104,10 @@ function corrigirEnfaseMarkdown(text) {
|
|
|
103
104
|
out = out.replace(/\*\*\*([^\s*][^*\n]*?)\*\*\*(?!\*)/g, '**$1**');
|
|
104
105
|
out = out.replace(/(^|[^*])\*([^\s*][^*\n]*?)\*\*(?!\*)/g, '$1*$2*');
|
|
105
106
|
out = out.replace(/(^|[^*])\*([^\s*][^*\n]*?)\*\*\*(?!\*)/g, '$1*$2*');
|
|
106
|
-
if (out !==
|
|
107
|
+
if (out !== current) {
|
|
107
108
|
changed = true;
|
|
108
109
|
}
|
|
109
|
-
|
|
110
|
+
current = out;
|
|
110
111
|
const encontrarFimEnfase = (texto) => {
|
|
111
112
|
// Heurísticas para encontrar onde a ênfase deve terminar:
|
|
112
113
|
// 1. Se há vírgula seguida de espaço, pode indicar fim da ênfase
|
|
@@ -163,9 +164,6 @@ function corrigirEnfaseMarkdown(text) {
|
|
|
163
164
|
return str;
|
|
164
165
|
}
|
|
165
166
|
const ultimoIdx = posicoes[posicoes.length - 1];
|
|
166
|
-
if (ultimoIdx === undefined) {
|
|
167
|
-
return str;
|
|
168
|
-
}
|
|
169
167
|
// Não corrigir se o marcador órfão está no início ou fim da linha (pode ser intencional)
|
|
170
168
|
if (ultimoIdx === 0 || ultimoIdx + len >= str.trimEnd().length) {
|
|
171
169
|
return str;
|
|
@@ -212,9 +210,6 @@ function corrigirEnfaseMarkdown(text) {
|
|
|
212
210
|
return str;
|
|
213
211
|
}
|
|
214
212
|
const ultimoIdx = posicoes[posicoes.length - 1];
|
|
215
|
-
if (ultimoIdx === undefined) {
|
|
216
|
-
return str;
|
|
217
|
-
}
|
|
218
213
|
// Não corrigir se o marcador órfão está no início ou fim da linha (pode ser intencional)
|
|
219
214
|
if (ultimoIdx === 0 || ultimoIdx + len >= str.trimEnd().length) {
|
|
220
215
|
return str;
|
|
@@ -250,7 +245,7 @@ function corrigirEnfaseMarkdown(text) {
|
|
|
250
245
|
return raiz;
|
|
251
246
|
});
|
|
252
247
|
out = corrigidas.join('\n');
|
|
253
|
-
if (out !==
|
|
248
|
+
if (out !== current) {
|
|
254
249
|
changed = true;
|
|
255
250
|
}
|
|
256
251
|
return {
|
|
@@ -366,8 +361,8 @@ function assegurarLinhaVaziaAposTitulosMarkdown(code) {
|
|
|
366
361
|
out.push(line);
|
|
367
362
|
const ehHeading = /^#{1,6}\s+\S/.test(line.trim());
|
|
368
363
|
const proxima = lines[indice + 1];
|
|
369
|
-
const proximaTambemHeading = proxima
|
|
370
|
-
const precisaEspaco = ehHeading && proxima
|
|
364
|
+
const proximaTambemHeading = typeof proxima === 'string' && /^#{1,6}\s+\S/.test(proxima.trim());
|
|
365
|
+
const precisaEspaco = ehHeading && typeof proxima === 'string' && proxima.trim() !== '' && !proximaTambemHeading;
|
|
371
366
|
if (precisaEspaco) {
|
|
372
367
|
out.push('');
|
|
373
368
|
changed = true;
|
|
@@ -408,8 +403,8 @@ function formatarListasMarkdown(code) {
|
|
|
408
403
|
}
|
|
409
404
|
const listMatch = line.match(/^(\s*)([*+\-])\s+(.*)$/);
|
|
410
405
|
if (listMatch) {
|
|
411
|
-
const indent = listMatch[1]
|
|
412
|
-
const content = listMatch[3]
|
|
406
|
+
const indent = listMatch[1];
|
|
407
|
+
const content = listMatch[3];
|
|
413
408
|
const normalized = `${indent}- ${content}`;
|
|
414
409
|
if (normalized !== line) {
|
|
415
410
|
changed = true;
|
|
@@ -41,8 +41,8 @@ function parsePropertiesLines(code) {
|
|
|
41
41
|
// Key-value com separador := ou =
|
|
42
42
|
const sepMatch = trimmed.match(/^([^:=]+?)\s*[:=]\s*(.*)$/);
|
|
43
43
|
if (sepMatch) {
|
|
44
|
-
const key =
|
|
45
|
-
const val =
|
|
44
|
+
const key = sepMatch[1].trim();
|
|
45
|
+
const val = sepMatch[2].trim();
|
|
46
46
|
const isContinuation = val.endsWith('\\');
|
|
47
47
|
if (isContinuation) {
|
|
48
48
|
inContinuation = true;
|
|
@@ -42,9 +42,6 @@ function parseShellLine(raw, ctx) {
|
|
|
42
42
|
let indice = 0;
|
|
43
43
|
while (indice < trimmed.length) {
|
|
44
44
|
const ch = trimmed[indice];
|
|
45
|
-
if (ch === undefined) {
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
45
|
if (escaped) {
|
|
49
46
|
escaped = false;
|
|
50
47
|
indice++;
|
|
@@ -94,7 +91,7 @@ function parseShellLine(raw, ctx) {
|
|
|
94
91
|
const rest = trimmed.slice(indice);
|
|
95
92
|
const hereDocMatch = rest.match(/<<-?\s*['"]?(\w+)['"]?/);
|
|
96
93
|
if (hereDocMatch) {
|
|
97
|
-
const delimiter = hereDocMatch[1]
|
|
94
|
+
const delimiter = hereDocMatch[1];
|
|
98
95
|
const stripTabs = rest.includes('<<-');
|
|
99
96
|
return {
|
|
100
97
|
output: trimmed,
|
|
@@ -140,9 +140,6 @@ export function formatarSqlMinimo(code) {
|
|
|
140
140
|
};
|
|
141
141
|
for (let textoTitulo = 0; textoTitulo < tokens.length; textoTitulo++) {
|
|
142
142
|
const tok = tokens[textoTitulo];
|
|
143
|
-
if (!tok) {
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
143
|
// comments always on their own line
|
|
147
144
|
if (tok.type === 'comment') {
|
|
148
145
|
if (!lineStart) {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
import { XMLValidator } from 'fast-xml-parser';
|
|
3
2
|
import { corrigirPontuacaoECodigo, normalizarFimDeLinha, normalizarNewlinesFinais, removerBom, removerEspacosFinaisPorLinha } from './commons.js';
|
|
4
3
|
function tokenizeXml(src) {
|
|
5
4
|
const re = /(<\?[\s\S]*?\?>|<!--[\s\S]*?-->|<!\[CDATA\[[\s\S]*?\]\]>|<!DOCTYPE[\s\S]*?>|<\/?[^>\n]+?>)/gi;
|
|
6
5
|
const out = [];
|
|
7
6
|
let last = 0;
|
|
8
7
|
for (const metrica of src.matchAll(re)) {
|
|
9
|
-
const start = metrica.index
|
|
8
|
+
const start = metrica.index;
|
|
10
9
|
if (start < 0) {
|
|
11
10
|
continue;
|
|
12
11
|
}
|
|
@@ -18,9 +17,9 @@ function tokenizeXml(src) {
|
|
|
18
17
|
}
|
|
19
18
|
out.push({
|
|
20
19
|
kind: 'tag',
|
|
21
|
-
value: metrica[0]
|
|
20
|
+
value: metrica[0]
|
|
22
21
|
});
|
|
23
|
-
last = start +
|
|
22
|
+
last = start + metrica[0].length;
|
|
24
23
|
}
|
|
25
24
|
if (last < src.length) {
|
|
26
25
|
out.push({
|
|
@@ -174,12 +173,11 @@ export function formatarXmlMinimo(code) {
|
|
|
174
173
|
return raiz.tag;
|
|
175
174
|
}).join('');
|
|
176
175
|
let pretty = rebuilt;
|
|
177
|
-
|
|
178
|
-
if (valid === true) {
|
|
176
|
+
try {
|
|
179
177
|
const pp = prettyPrintXmlIfSafe(pretty);
|
|
180
178
|
pretty = pp.xml;
|
|
181
179
|
}
|
|
182
|
-
|
|
180
|
+
catch {
|
|
183
181
|
pretty = `${pretty.trimEnd()}\n`;
|
|
184
182
|
}
|
|
185
183
|
const formatted = normalizarNewlinesFinais(pretty);
|
|
@@ -230,7 +230,7 @@ function corrigirChavesDuplicadas(lines) {
|
|
|
230
230
|
if (line.kind === 'mapping') {
|
|
231
231
|
const keyMatch = line.content.match(/^([^:]+):/);
|
|
232
232
|
if (keyMatch) {
|
|
233
|
-
const key =
|
|
233
|
+
const key = keyMatch[1].trim();
|
|
234
234
|
if (seenKeys.has(key)) {
|
|
235
235
|
const count = (seenKeys.get(key) ?? 0) + 1;
|
|
236
236
|
warnings.push(`Chave duplicada "${key}" na linha ${(seenKeys.get(key) ?? 0) + 1} e ${out.length + 1}`);
|
|
@@ -253,18 +253,13 @@ function corrigirStringsMultilineYaml(lines) {
|
|
|
253
253
|
let indice = 0;
|
|
254
254
|
while (indice < lines.length) {
|
|
255
255
|
const line = lines[indice];
|
|
256
|
-
if (line === undefined) {
|
|
257
|
-
break;
|
|
258
|
-
}
|
|
259
256
|
if (line.kind === 'multiline-start') {
|
|
260
257
|
out.push(line);
|
|
261
258
|
indice++;
|
|
262
259
|
const contentLines = [];
|
|
263
260
|
while (indice < lines.length && (lines[indice]?.kind === 'multiline-content' || lines[indice]?.kind === 'empty')) {
|
|
264
261
|
const cl = lines[indice];
|
|
265
|
-
|
|
266
|
-
contentLines.push(cl);
|
|
267
|
-
}
|
|
262
|
+
contentLines.push(cl);
|
|
268
263
|
indice++;
|
|
269
264
|
}
|
|
270
265
|
if (contentLines.length > 0) {
|
|
@@ -23,7 +23,7 @@ export function formatarCodeMinimo(code, opts) {
|
|
|
23
23
|
const formatted = normalizarNewlinesFinais(removerEspacosFinaisPorLinha(normalized));
|
|
24
24
|
return {
|
|
25
25
|
ok: true,
|
|
26
|
-
parser: opts?.parser ?? 'code',
|
|
26
|
+
parser: (opts?.parser ?? 'code'),
|
|
27
27
|
formatted,
|
|
28
28
|
changed: formatted !== normalizarNewlinesFinais(normalized),
|
|
29
29
|
};
|
|
@@ -69,7 +69,7 @@ export function detectarFrameworks(rootDir) {
|
|
|
69
69
|
}
|
|
70
70
|
// Remover duplicatas (mesma framework em prod e dev)
|
|
71
71
|
const unique = frameworks.reduce((acc, curr) => {
|
|
72
|
-
if (!acc
|
|
72
|
+
if (!acc?.find(arquivo => arquivo.name === curr.name)) {
|
|
73
73
|
acc.push(curr);
|
|
74
74
|
}
|
|
75
75
|
return acc;
|
|
@@ -24,7 +24,7 @@ export function escapeNonAscii(string) {
|
|
|
24
24
|
let out = '';
|
|
25
25
|
for (const ch of string) {
|
|
26
26
|
const cp = ch.codePointAt(0);
|
|
27
|
-
if (cp === undefined || cp
|
|
27
|
+
if (cp === undefined || cp <= ASCII_MAX) {
|
|
28
28
|
out += ch;
|
|
29
29
|
}
|
|
30
30
|
else if (cp <= BMP_MAX) {
|
|
@@ -155,7 +155,7 @@ export function isWhitelistedConstant(value, frameworks, userWhitelist) {
|
|
|
155
155
|
*/
|
|
156
156
|
export function getConstantDescription(value, frameworks) {
|
|
157
157
|
// Verificar todas as whitelists
|
|
158
|
-
const allRules = [...MATH_CONSTANTES, ...COMUM_LIMITES, ...HTTP_STATUS_CODIGOS, ...frameworks.flatMap(arquivo => FRAMEWORK_WHITELISTS[arquivo]
|
|
158
|
+
const allRules = [...MATH_CONSTANTES, ...COMUM_LIMITES, ...HTTP_STATUS_CODIGOS, ...frameworks.flatMap(arquivo => FRAMEWORK_WHITELISTS[arquivo] ?? [])];
|
|
159
159
|
const rule = allRules.find(raiz => raiz.value === value);
|
|
160
160
|
return rule?.description;
|
|
161
161
|
}
|
|
@@ -23,7 +23,7 @@ export function maskKeepingNewlines(src, start, end) {
|
|
|
23
23
|
export function maskJsComments(src) {
|
|
24
24
|
let out = src;
|
|
25
25
|
for (const metrica of out.matchAll(/\/\*[\s\S]*?\*\//g)) {
|
|
26
|
-
const start = metrica.index
|
|
26
|
+
const start = metrica.index;
|
|
27
27
|
if (start < 0) {
|
|
28
28
|
continue;
|
|
29
29
|
}
|
|
@@ -31,11 +31,11 @@ export function maskJsComments(src) {
|
|
|
31
31
|
}
|
|
32
32
|
// Usa negative lookbehind para evitar match em URLs (://)
|
|
33
33
|
for (const metrica of out.matchAll(/(?<![\\:])\/\/.*$/gm)) {
|
|
34
|
-
const start = metrica.index
|
|
34
|
+
const start = metrica.index;
|
|
35
35
|
if (start < 0) {
|
|
36
36
|
continue;
|
|
37
37
|
}
|
|
38
|
-
out = maskKeepingNewlines(out, start, start +
|
|
38
|
+
out = maskKeepingNewlines(out, start, start + metrica[0].length);
|
|
39
39
|
}
|
|
40
40
|
return out;
|
|
41
41
|
}
|
|
@@ -47,7 +47,7 @@ export function maskJsComments(src) {
|
|
|
47
47
|
export function maskHtmlComments(src) {
|
|
48
48
|
let out = src;
|
|
49
49
|
for (const metrica of out.matchAll(/<!--([\s\S]*?)-->/g)) {
|
|
50
|
-
const start = metrica.index
|
|
50
|
+
const start = metrica.index;
|
|
51
51
|
if (start < 0) {
|
|
52
52
|
continue;
|
|
53
53
|
}
|
|
@@ -66,7 +66,7 @@ export function maskTagBlocks(src, tag) {
|
|
|
66
66
|
let out = src;
|
|
67
67
|
const re = new RegExp(`<${tag}\\b[^>]*>[\\s\\S]*?<\\/${tag}>`, 'gi');
|
|
68
68
|
for (const metrica of out.matchAll(re)) {
|
|
69
|
-
const start = metrica.index
|
|
69
|
+
const start = metrica.index;
|
|
70
70
|
if (start < 0) {
|
|
71
71
|
continue;
|
|
72
72
|
}
|
|
@@ -83,14 +83,14 @@ export function maskTagBlocks(src, tag) {
|
|
|
83
83
|
export function maskXmlNonCode(src) {
|
|
84
84
|
let out = src;
|
|
85
85
|
for (const metrica of out.matchAll(/<!--[\s\S]*?-->/g)) {
|
|
86
|
-
const start = metrica.index
|
|
86
|
+
const start = metrica.index;
|
|
87
87
|
if (start < 0) {
|
|
88
88
|
continue;
|
|
89
89
|
}
|
|
90
90
|
out = maskKeepingNewlines(out, start, start + metrica[0].length);
|
|
91
91
|
}
|
|
92
92
|
for (const metrica of out.matchAll(/<!\[CDATA\[[\s\S]*?\]\]>/g)) {
|
|
93
|
-
const start = metrica.index
|
|
93
|
+
const start = metrica.index;
|
|
94
94
|
if (start < 0) {
|
|
95
95
|
continue;
|
|
96
96
|
}
|
|
@@ -107,14 +107,14 @@ export function maskXmlNonCode(src) {
|
|
|
107
107
|
export function maskPythonStringsAndComments(src) {
|
|
108
108
|
let out = maskPythonComments(src);
|
|
109
109
|
for (const metrica of out.matchAll(/([ruRUfFbB]{0,3})("""|''')[\s\S]*?\2/g)) {
|
|
110
|
-
const start = metrica.index
|
|
110
|
+
const start = metrica.index;
|
|
111
111
|
if (start < 0) {
|
|
112
112
|
continue;
|
|
113
113
|
}
|
|
114
114
|
out = maskKeepingNewlines(out, start, start + metrica[0].length);
|
|
115
115
|
}
|
|
116
116
|
for (const metrica of out.matchAll(/([ruRUfFbB]{0,3})("([^"\\\n]|\\.)*"|'([^'\\\n]|\\.)*')/g)) {
|
|
117
|
-
const start = metrica.index
|
|
117
|
+
const start = metrica.index;
|
|
118
118
|
if (start < 0) {
|
|
119
119
|
continue;
|
|
120
120
|
}
|
|
@@ -130,11 +130,11 @@ export function maskPythonStringsAndComments(src) {
|
|
|
130
130
|
export function maskPythonComments(src) {
|
|
131
131
|
let out = src;
|
|
132
132
|
for (const metrica of out.matchAll(/(^|[^\\])#.*$/gm)) {
|
|
133
|
-
const start =
|
|
133
|
+
const start = metrica.index + (metrica[1] ? metrica[1].length : 0);
|
|
134
134
|
if (start < 0) {
|
|
135
135
|
continue;
|
|
136
136
|
}
|
|
137
|
-
out = maskKeepingNewlines(out, start, start + (metrica[0].length
|
|
137
|
+
out = maskKeepingNewlines(out, start, start + (metrica[0].length) - (metrica[1] ? metrica[1].length : 0));
|
|
138
138
|
}
|
|
139
139
|
return out;
|
|
140
140
|
}
|
|
@@ -146,14 +146,14 @@ export function maskPythonComments(src) {
|
|
|
146
146
|
export function maskGoComments(src) {
|
|
147
147
|
let out = src;
|
|
148
148
|
for (const metrica of out.matchAll(/\/\*[\s\S]*?\*\//g)) {
|
|
149
|
-
const start = metrica.index
|
|
149
|
+
const start = metrica.index;
|
|
150
150
|
if (start < 0) {
|
|
151
151
|
continue;
|
|
152
152
|
}
|
|
153
153
|
out = maskKeepingNewlines(out, start, start + metrica[0].length);
|
|
154
154
|
}
|
|
155
155
|
for (const metrica of out.matchAll(/\/\/.*$/gm)) {
|
|
156
|
-
const start = metrica.index
|
|
156
|
+
const start = metrica.index;
|
|
157
157
|
if (start < 0) {
|
|
158
158
|
continue;
|
|
159
159
|
}
|
|
@@ -178,14 +178,14 @@ export function maskRustComments(src) {
|
|
|
178
178
|
export function maskJavaComments(src) {
|
|
179
179
|
let out = src;
|
|
180
180
|
for (const metrica of out.matchAll(/\/\*[\s\S]*?\*\//g)) {
|
|
181
|
-
const start = metrica.index
|
|
181
|
+
const start = metrica.index;
|
|
182
182
|
if (start < 0) {
|
|
183
183
|
continue;
|
|
184
184
|
}
|
|
185
185
|
out = maskKeepingNewlines(out, start, start + metrica[0].length);
|
|
186
186
|
}
|
|
187
187
|
for (const metrica of out.matchAll(/\/\/.*$/gm)) {
|
|
188
|
-
const start = metrica.index
|
|
188
|
+
const start = metrica.index;
|
|
189
189
|
if (start < 0) {
|
|
190
190
|
continue;
|
|
191
191
|
}
|
|
@@ -202,14 +202,14 @@ export function maskJavaComments(src) {
|
|
|
202
202
|
export function maskPhpComments(src) {
|
|
203
203
|
let out = src;
|
|
204
204
|
for (const metrica of out.matchAll(/\/\*[\s\S]*?\*\//g)) {
|
|
205
|
-
const start = metrica.index
|
|
205
|
+
const start = metrica.index;
|
|
206
206
|
if (start < 0) {
|
|
207
207
|
continue;
|
|
208
208
|
}
|
|
209
209
|
out = maskKeepingNewlines(out, start, start + metrica[0].length);
|
|
210
210
|
}
|
|
211
211
|
for (const metrica of out.matchAll(/(\/\/|#).*$/gm)) {
|
|
212
|
-
const start = metrica.index
|
|
212
|
+
const start = metrica.index;
|
|
213
213
|
if (start < 0) {
|
|
214
214
|
continue;
|
|
215
215
|
}
|
|
@@ -12,12 +12,6 @@ export async function lerRelatorioVersionado(options) {
|
|
|
12
12
|
try {
|
|
13
13
|
// Ler arquivo
|
|
14
14
|
const conteudo = await lerEstado(caminho);
|
|
15
|
-
if (!conteudo) {
|
|
16
|
-
return {
|
|
17
|
-
sucesso: false,
|
|
18
|
-
erro: 'Arquivo não encontrado ou vazio',
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
15
|
let relatorioFinal = conteudo;
|
|
22
16
|
let migrado = false;
|
|
23
17
|
// Validar schema se solicitado
|
|
@@ -97,12 +91,6 @@ export async function lerDadosRelatorio(caminho) {
|
|
|
97
91
|
export async function verificarSchemaRelatorio(caminho) {
|
|
98
92
|
try {
|
|
99
93
|
const conteudo = await lerEstado(caminho);
|
|
100
|
-
if (!conteudo) {
|
|
101
|
-
return {
|
|
102
|
-
valido: false,
|
|
103
|
-
erros: ['Arquivo não encontrado ou vazio'],
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
94
|
const validacao = validarSchema(conteudo);
|
|
107
95
|
return {
|
|
108
96
|
valido: validacao.valido,
|
|
@@ -34,7 +34,7 @@ function extrairEstrutura(ast) {
|
|
|
34
34
|
return elementos;
|
|
35
35
|
}
|
|
36
36
|
const node = isNodePath(ast) ? ast.node : ast;
|
|
37
|
-
if (
|
|
37
|
+
if (typeof node !== 'object') {
|
|
38
38
|
return elementos;
|
|
39
39
|
}
|
|
40
40
|
const nodeRecord = toRecord(node);
|
|
@@ -47,7 +47,8 @@ function extrairEstrutura(ast) {
|
|
|
47
47
|
}
|
|
48
48
|
const body = Array.isArray(program.body) ? program.body : [];
|
|
49
49
|
for (const stmt of body) {
|
|
50
|
-
const
|
|
50
|
+
const rawTipo = stmt.type;
|
|
51
|
+
const tipo = typeof rawTipo === 'string' ? rawTipo : '';
|
|
51
52
|
const stmtRecord = toRecord(stmt);
|
|
52
53
|
if (!stmtRecord) {
|
|
53
54
|
continue;
|
|
@@ -268,7 +268,7 @@ export function normalizarRel(relPath) {
|
|
|
268
268
|
export async function carregarConfigEstrategia(baseDir, overrides) {
|
|
269
269
|
const caminho = path.join(baseDir, '.mahoraga', 'estrutura.json');
|
|
270
270
|
const lido = await lerEstado(caminho);
|
|
271
|
-
const cfgObj =
|
|
271
|
+
const cfgObj = !Array.isArray(lido) && typeof lido === 'object' ? lido : {};
|
|
272
272
|
const nomePreset = overrides?.preset ?? cfgObj['preset'];
|
|
273
273
|
const preset = nomePreset && PRESETS[nomePreset].nome ? PRESETS[nomePreset] : undefined;
|
|
274
274
|
const base = {
|
|
@@ -26,7 +26,7 @@ export async function salvarPacotesInstalados(pacotes) {
|
|
|
26
26
|
}
|
|
27
27
|
export async function pacoteEstaInstalado(nome) {
|
|
28
28
|
const pacotes = await listarPacotesInstalados();
|
|
29
|
-
return pacotes
|
|
29
|
+
return pacotes?.find(p => p.nome === nome) ?? null;
|
|
30
30
|
}
|
|
31
31
|
export async function instalarPacote(analista, versao, _conteudo) {
|
|
32
32
|
const pacotes = await listarPacotesInstalados();
|
|
@@ -15,7 +15,7 @@ const CONFIG_PATH = '.mahoraga/marketplace/registries.json';
|
|
|
15
15
|
async function carregarRegistries() {
|
|
16
16
|
try {
|
|
17
17
|
const configs = await lerEstado(CONFIG_PATH);
|
|
18
|
-
if (
|
|
18
|
+
if (configs.length === 0) {
|
|
19
19
|
return DEFAULT_REGISTRIES;
|
|
20
20
|
}
|
|
21
21
|
return configs;
|
|
@@ -55,7 +55,7 @@ export async function obterAnalistaDoRegistry(nome, registry) {
|
|
|
55
55
|
}
|
|
56
56
|
try {
|
|
57
57
|
const analistas = await fetchRegistry(reg);
|
|
58
|
-
const encontrado = analistas
|
|
58
|
+
const encontrado = analistas?.find(a => a.nome === nome);
|
|
59
59
|
if (encontrado) {
|
|
60
60
|
return encontrado;
|
|
61
61
|
}
|
|
@@ -74,7 +74,7 @@ async function fetchRegistry(reg) {
|
|
|
74
74
|
throw new Error(MarketplaceRemoteMensagens.httpStatus(res.status));
|
|
75
75
|
}
|
|
76
76
|
const data = await res.json();
|
|
77
|
-
return data.analistas
|
|
77
|
+
return data.analistas;
|
|
78
78
|
}
|
|
79
79
|
case 'github': {
|
|
80
80
|
const apiUrl = `https://api.github.com/repos/${reg.url}/contents/index.json`;
|
|
@@ -85,7 +85,7 @@ async function fetchRegistry(reg) {
|
|
|
85
85
|
throw new Error(MarketplaceRemoteMensagens.githubApiHttpStatus(res.status));
|
|
86
86
|
}
|
|
87
87
|
const data = await res.json();
|
|
88
|
-
return data.analistas
|
|
88
|
+
return data.analistas;
|
|
89
89
|
}
|
|
90
90
|
case "npm": {
|
|
91
91
|
throw new Error('Not implemented yet: "npm" case');
|
|
@@ -6,7 +6,6 @@ import * as fsCb from 'node:fs';
|
|
|
6
6
|
import { promises as fs } from 'node:fs';
|
|
7
7
|
import path from 'node:path';
|
|
8
8
|
import { messages } from '../../core/messages/index.js';
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
9
|
const getLog = () => messages.log;
|
|
11
10
|
const RAIZ = process.cwd();
|
|
12
11
|
const IS_TEST = (process.env.VITEST ?? '') !== '';
|
|
@@ -58,7 +58,9 @@ export class CorePlugin {
|
|
|
58
58
|
}
|
|
59
59
|
inferExtension(codigo, opts) {
|
|
60
60
|
if (opts?.pluginConfig?.extension) {
|
|
61
|
-
|
|
61
|
+
const ext = opts.pluginConfig.extension;
|
|
62
|
+
if (typeof ext === 'string')
|
|
63
|
+
return ext;
|
|
62
64
|
}
|
|
63
65
|
if (/^<\?php/.test(codigo.trim())) {
|
|
64
66
|
return '.php';
|
|
@@ -91,7 +91,8 @@ export class PluginRegistry {
|
|
|
91
91
|
// Usa import dinâmico mockável (globalThis.import pode ser substituído nos testes)
|
|
92
92
|
const dynImport = globalThis.import ?? ((caminho) => import(caminho));
|
|
93
93
|
const pluginModule = await dynImport(pluginCaminho);
|
|
94
|
-
const
|
|
94
|
+
const pluginModuleDefault = pluginModule.default;
|
|
95
|
+
const plugin = (pluginModuleDefault ?? pluginModule);
|
|
95
96
|
// Valida e registra
|
|
96
97
|
this.validatePlugin(plugin);
|
|
97
98
|
this.registerPlugin(plugin);
|
|
@@ -134,7 +135,7 @@ export class PluginRegistry {
|
|
|
134
135
|
// Verifica suporte da linguagem
|
|
135
136
|
const langChave = extension.substring(1); // remove o ponto
|
|
136
137
|
const langSuporte = this.languageSupport[langChave];
|
|
137
|
-
if (
|
|
138
|
+
if (!langSuporte.enabled) {
|
|
138
139
|
const msgLinguagem = messages.PluginRegistryMensagens.linguagemDesabilitada;
|
|
139
140
|
log.debug(msgLinguagem.replace('{linguagem}', langChave));
|
|
140
141
|
return null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,7 +4,7 @@ import { messages } from '../../core/messages/index.js';
|
|
|
4
4
|
* Fábrica para criar analista com validação mínima
|
|
5
5
|
*/
|
|
6
6
|
export function criarAnalista(def) {
|
|
7
|
-
if (
|
|
7
|
+
if (typeof def !== 'object') {
|
|
8
8
|
throw new Error(messages.ExcecoesMensagens.definicaoAnalistaInvalida);
|
|
9
9
|
}
|
|
10
10
|
if (!def.nome || /\s/.test(def.nome)) {
|