loadwise 0.6.2 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +175 -115
- package/dist/bin/loadwise.js +132 -67
- package/dist/lib/accessibility/analyze.js +5 -3
- package/dist/lib/accessibility/angular-inline.js +9 -11
- package/dist/lib/accessibility/angular-literal.js +39 -0
- package/dist/lib/accessibility/form-context.js +36 -0
- package/dist/lib/accessibility/frame-head.js +92 -0
- package/dist/lib/accessibility/frame-viewport.js +149 -0
- package/dist/lib/accessibility/frontend-detect.js +6 -5
- package/dist/lib/accessibility/jsx-elements.js +13 -3
- package/dist/lib/accessibility/markup-files.js +7 -2
- package/dist/lib/accessibility/rule-ids.js +3 -0
- package/dist/lib/accessibility/rules.js +128 -41
- package/dist/lib/accessibility/site-fixes/buttons.js +5 -1
- package/dist/lib/accessibility/template-attributes.js +5 -3
- package/dist/lib/accessibility/template-elements.js +25 -6
- package/dist/lib/accessibility/template-file.js +40 -25
- package/dist/lib/accessibility/usage.js +10 -2
- package/dist/lib/editor/accessibility-examples.js +6 -1
- package/dist/lib/editor/actions.js +46 -7
- package/dist/lib/editor/apply-fix.js +69 -4
- package/dist/lib/editor/configured-setup.js +63 -0
- package/dist/lib/editor/diagnostics.js +206 -17
- package/dist/lib/editor/dismissals.js +85 -26
- package/dist/lib/editor/editor-document.js +5 -2
- package/dist/lib/editor/editor-launcher.js +170 -0
- package/dist/lib/editor/fix-edits.js +19 -0
- package/dist/lib/editor/jetbrains-setup.js +53 -0
- package/dist/lib/editor/language-server.js +80 -24
- package/dist/lib/editor/managed-config.js +37 -0
- package/dist/lib/editor/native-setup.js +86 -0
- package/dist/lib/editor/perf-watch.js +8 -6
- package/dist/lib/editor/release-vsix.js +61 -0
- package/dist/lib/editor/reliability-examples.js +15 -0
- package/dist/lib/editor/scan-session.js +29 -8
- package/dist/lib/editor/server-commands.js +38 -9
- package/dist/lib/editor/setup-server.js +87 -0
- package/dist/lib/editor/setup-vim.js +63 -0
- package/dist/lib/editor/setup.js +131 -0
- package/dist/lib/editor/stdio-setup.js +6 -0
- package/dist/lib/editor/workspace-files.js +61 -7
- package/dist/lib/editor/workspace-paths.js +41 -1
- package/dist/lib/maintainability/analysis/analyze-source.js +1 -1
- package/dist/lib/maintainability/architecture/architecture.js +4 -4
- package/dist/lib/maintainability/cli/changed-lines.js +20 -2
- package/dist/lib/maintainability/cli/inputs.js +12 -3
- package/dist/lib/maintainability/cli.js +18 -5
- package/dist/lib/maintainability/entry-points/entry-points.js +44 -15
- package/dist/lib/maintainability/entry-points/html-entry-points.js +5 -1
- package/dist/lib/maintainability/examples.js +4 -0
- package/dist/lib/maintainability/quality/functions.js +9 -6
- package/dist/lib/maintainability/quality/limits.js +19 -0
- package/dist/lib/maintainability/quality/size-limits.js +8 -2
- package/dist/lib/maintainability/quality/stray-console.js +62 -1
- package/dist/lib/maintainability/quality/tsconfig-strict.js +2 -0
- package/dist/lib/maintainability/rule-ids.js +3 -0
- package/dist/lib/maintainability/scan-changed.js +4 -1
- package/dist/lib/maintainability/scan-worker.js +6 -2
- package/dist/lib/maintainability/scan.js +21 -8
- package/dist/lib/maintainability/site-fixes/unused-bindings.js +138 -3
- package/dist/lib/maintainability/unused/module-usage.js +43 -21
- package/dist/lib/maintainability/unused/unused-bindings.js +39 -4
- package/dist/lib/maintainability/unused/unused-modules.js +5 -10
- package/dist/lib/performance/analysis/source-inputs.js +7 -2
- package/dist/lib/performance/analysis/source-options.js +7 -6
- package/dist/lib/performance/analyze.js +16 -3
- package/dist/lib/performance/cli/changed-lines.js +8 -1
- package/dist/lib/performance/cli/cli-arguments.js +19 -8
- package/dist/lib/performance/cli/cli-output.js +4 -0
- package/dist/lib/performance/cli/cli-scan.js +21 -2
- package/dist/lib/performance/cli.js +16 -7
- package/dist/lib/performance/collections/memory-growth.js +55 -12
- package/dist/lib/performance/contracts/openapi.js +13 -4
- package/dist/lib/performance/datastores/pg-integrity.js +68 -22
- package/dist/lib/performance/datastores/pg-session-release.js +114 -0
- package/dist/lib/performance/datastores/pg-session-sql.js +144 -0
- package/dist/lib/performance/datastores/pooling.js +62 -3
- package/dist/lib/performance/datastores/redis.js +94 -18
- package/dist/lib/performance/datastores/session-store.js +2 -1
- package/dist/lib/performance/db/checks.js +19 -8
- package/dist/lib/performance/db/gateway.js +3 -1
- package/dist/lib/performance/db/plan-estimates.js +4 -4
- package/dist/lib/performance/engine/native-syntax.js +3 -0
- package/dist/lib/performance/engine/native.js +11 -7
- package/dist/lib/performance/evidence/plans.js +7 -5
- package/dist/lib/performance/evidence/traces.js +21 -1
- package/dist/lib/performance/frontend/angular-teardown.js +96 -0
- package/dist/lib/performance/frontend/effect-cleanup.js +148 -0
- package/dist/lib/performance/frontend/frontend-dom-perf.js +14 -2
- package/dist/lib/performance/frontend/frontend-helpers.js +1 -9
- package/dist/lib/performance/frontend/frontend-perf.js +149 -74
- package/dist/lib/performance/migrations/extract-code-sql.js +16 -4
- package/dist/lib/performance/migrations/extract-code.js +13 -5
- package/dist/lib/performance/migrations/extract-sql.js +82 -38
- package/dist/lib/performance/migrations/operations.js +56 -13
- package/dist/lib/performance/migrations/postgres-lock-timeout.js +52 -0
- package/dist/lib/performance/migrations/postgres-registry.js +127 -26
- package/dist/lib/performance/migrations/postgres-settings.js +78 -0
- package/dist/lib/performance/migrations/rules-postgres-add-column.js +3 -3
- package/dist/lib/performance/migrations/rules-postgres-shared.js +9 -0
- package/dist/lib/performance/migrations/rules-postgres.js +88 -39
- package/dist/lib/performance/orm/offset-pagination.js +6 -4
- package/dist/lib/performance/orm/prisma-aggregates.js +69 -18
- package/dist/lib/performance/orm/unbounded-list-chain.js +29 -0
- package/dist/lib/performance/orm/unbounded-list-queries.js +18 -13
- package/dist/lib/performance/polyglot.js +111 -14
- package/dist/lib/performance/projects.js +3 -3
- package/dist/lib/performance/query-loops/sequential-loops.js +1 -0
- package/dist/lib/performance/request/backend-mastery.js +151 -42
- package/dist/lib/performance/request/bulk-listener-registration.js +111 -0
- package/dist/lib/performance/request/fastify-receivers.js +93 -0
- package/dist/lib/performance/request/fresh-loop-socket.js +103 -0
- package/dist/lib/performance/request/mongoose-lean.js +298 -46
- package/dist/lib/performance/request/node-event-listener-leak.js +99 -5
- package/dist/lib/performance/request/phase5-ast.js +6 -7
- package/dist/lib/performance/request/phase5-rules.js +204 -23
- package/dist/lib/performance/request/request-handlers.js +120 -23
- package/dist/lib/performance/request/sql-select-star.js +150 -0
- package/dist/lib/performance/request/unbounded-promise-all.js +54 -29
- package/dist/lib/performance/request/upload-limits.js +5 -1
- package/dist/lib/performance/site-fix.js +4 -4
- package/dist/lib/performance/site-fixes/backend-mastery-fixes.js +298 -16
- package/dist/lib/performance/site-fixes/collection-existence.js +2 -1
- package/dist/lib/performance/site-fixes/collections.js +1 -2
- package/dist/lib/performance/site-fixes/frontend-fixes.js +358 -14
- package/dist/lib/performance/site-fixes/helpers.js +3 -4
- package/dist/lib/performance/site-fixes/integrity.js +2 -4
- package/dist/lib/performance/site-fixes/migration-context.js +8 -1
- package/dist/lib/performance/site-fixes/migration-lock-rules.js +66 -30
- package/dist/lib/performance/site-fixes/prisma-aggregates.js +29 -9
- package/dist/lib/performance/site-fixes/small-rewrites.js +168 -10
- package/dist/lib/performance/site-fixes/sync-calls.js +14 -12
- package/dist/lib/performance/site-fixes/upload-limits.js +13 -7
- package/dist/lib/performance/sql/mysql-tokens.js +38 -12
- package/dist/lib/reliability/boundary-access.js +114 -57
- package/dist/lib/reliability/react-bugs.js +29 -7
- package/dist/lib/reliability/resource-leak-intervals.js +258 -0
- package/dist/lib/reliability/resource-leaks.js +209 -195
- package/dist/lib/reliability/rule-ids.js +10 -1
- package/dist/lib/reliability/site-fixes/resource-leaks.js +16 -1
- package/dist/lib/reliability/swallowed-errors.js +107 -21
- package/dist/lib/reliability/test-cleanup-after-await.js +92 -18
- package/dist/lib/reliability/usage.js +16 -5
- package/dist/lib/reliability/walk.js +3 -2
- package/dist/lib/security/auth-crypto/hashing.js +24 -8
- package/dist/lib/security/auth-crypto/jwt.js +21 -6
- package/dist/lib/security/auth-crypto/secrets.js +44 -1
- package/dist/lib/security/auth-crypto/shared.js +3 -1
- package/dist/lib/security/auth-crypto/signing-algorithm.js +79 -0
- package/dist/lib/security/auth-crypto/transport-and-ciphers.js +85 -1
- package/dist/lib/security/cli.js +21 -6
- package/dist/lib/security/cookie-credentials.js +115 -0
- package/dist/lib/security/cookie-csrf.js +241 -0
- package/dist/lib/security/deps/advisory.js +50 -109
- package/dist/lib/security/deps/cli.js +1 -1
- package/dist/lib/security/deps/cvss-score.js +14 -0
- package/dist/lib/security/deps/fixed-version.js +97 -0
- package/dist/lib/security/deps/lockfiles.js +135 -74
- package/dist/lib/security/deps/osv.js +11 -3
- package/dist/lib/security/deps/scan.js +47 -20
- package/dist/lib/security/deps/yarn-lock.js +158 -0
- package/dist/lib/security/examples/injection.cjs +4 -0
- package/dist/lib/security/exposure/cookies.js +17 -2
- package/dist/lib/security/exposure/cors-origin-regex.js +2 -3
- package/dist/lib/security/exposure/frontend-security.js +21 -14
- package/dist/lib/security/exposure/jsx-url.js +18 -33
- package/dist/lib/security/exposure/logging.js +49 -10
- package/dist/lib/security/exposure/prototype-pollution.js +126 -56
- package/dist/lib/security/exposure/react-html.js +26 -0
- package/dist/lib/security/exposure/reflected-xss.js +34 -5
- package/dist/lib/security/files/compose.js +126 -1
- package/dist/lib/security/files/dockerfile.js +62 -4
- package/dist/lib/security/files/index.js +1 -1
- package/dist/lib/security/injection/command.js +46 -18
- package/dist/lib/security/injection/index.js +2 -0
- package/dist/lib/security/injection/ldap.js +86 -0
- package/dist/lib/security/injection/nosql.js +28 -4
- package/dist/lib/security/injection/redos.js +1 -1
- package/dist/lib/security/injection/rule-ids.js +1 -0
- package/dist/lib/security/injection/shared.js +5 -1
- package/dist/lib/security/injection/sql.js +28 -13
- package/dist/lib/security/lexical-declaration.js +113 -0
- package/dist/lib/security/pg-dynamic-query.js +28 -1
- package/dist/lib/security/pg-identifier-guards.js +107 -3
- package/dist/lib/security/phase5-rules.js +26 -135
- package/dist/lib/security/polyglot.js +2 -2
- package/dist/lib/security/redirect-settings.js +98 -0
- package/dist/lib/security/request-forgery/open-redirect.js +18 -5
- package/dist/lib/security/request-forgery/path-traversal.js +84 -6
- package/dist/lib/security/request-forgery/shared.js +1 -7
- package/dist/lib/security/request-forgery/ssrf.js +176 -14
- package/dist/lib/security/rule-descriptions.js +5 -1
- package/dist/lib/security/rule-ids.js +7 -0
- package/dist/lib/security/site-fixes/auth-crypto.js +5 -78
- package/dist/lib/security/site-fixes/exposure.js +21 -3
- package/dist/lib/security/site-fixes/files.js +11 -13
- package/dist/lib/security/site-fixes/frontend-security-fixes.js +2 -2
- package/dist/lib/security/site-fixes/injection.js +17 -4
- package/dist/lib/security/site-fixes/jwt.js +1 -20
- package/dist/lib/security/site-fixes/request-forgery.js +37 -29
- package/dist/lib/security/taint/binding-inputs.js +236 -0
- package/dist/lib/security/taint/filename-guard.js +45 -45
- package/dist/lib/security/taint/guards.js +14 -8
- package/dist/lib/security/taint/index.js +126 -154
- package/dist/lib/security/taint/propagate.js +43 -9
- package/dist/lib/security/taint/record-writes.js +161 -0
- package/dist/lib/security/taint/resolution-cache.js +13 -7
- package/dist/lib/security/taint/sanitizers.js +89 -5
- package/dist/lib/security/taint/trace-nodes.js +61 -0
- package/dist/lib/security/taint/validators.js +89 -9
- package/dist/lib/shared/agent/agent-init.js +28 -5
- package/dist/lib/shared/agent/agent-prompt.js +74 -0
- package/dist/lib/shared/agent/agent-session.js +6 -1
- package/dist/lib/shared/agent/agent-verify.js +58 -11
- package/dist/lib/shared/agent/git-hook.js +17 -6
- package/dist/lib/shared/agent/review-delivery.js +1 -1
- package/dist/lib/shared/agent/review-mcp.js +8 -2
- package/dist/lib/shared/analysis/ast-semantics.js +2 -2
- package/dist/lib/shared/analysis/scan-cache.js +99 -14
- package/dist/lib/shared/check.js +172 -20
- package/dist/lib/shared/cli-dispatch.js +17 -0
- package/dist/lib/shared/config.js +27 -10
- package/dist/lib/shared/explain.js +1 -1
- package/dist/lib/shared/fix/fix-convergence.js +19 -31
- package/dist/lib/shared/fix/fix-handoff.js +16 -11
- package/dist/lib/shared/fix/fix-imports.js +4 -162
- package/dist/lib/shared/fix/fix-presentation-comments.js +23 -9
- package/dist/lib/shared/fix/fix-presentation-prettier.js +1 -46
- package/dist/lib/shared/fix/fix-presentation-rows.js +45 -1
- package/dist/lib/shared/fix/fix-presentation.js +9 -6
- package/dist/lib/shared/fix/fix-safety.js +32 -1
- package/dist/lib/shared/fix/fix-scope.js +82 -0
- package/dist/lib/shared/fix/fix-terminal.js +28 -1
- package/dist/lib/shared/fix/fix-typecheck.js +8 -4
- package/dist/lib/shared/fix/import-text-edits.js +148 -0
- package/dist/lib/shared/fix/project-file-access.js +17 -26
- package/dist/lib/shared/fix/read-fix-text.js +20 -0
- package/dist/lib/shared/fix.js +241 -104
- package/dist/lib/shared/formats/finding-location.js +4 -1
- package/dist/lib/shared/formats/github.js +3 -3
- package/dist/lib/shared/formats/sarif.js +9 -3
- package/dist/lib/shared/report-fp.js +97 -0
- package/dist/lib/shared/reporting/automatic-fix-signal.js +10 -0
- package/dist/lib/shared/reporting/baseline.js +7 -5
- package/dist/lib/shared/reporting/check-text.js +50 -0
- package/dist/lib/shared/reporting/pillars.js +54 -19
- package/dist/lib/shared/reporting/source-report.js +3 -0
- package/dist/lib/shared/system/atomic-write.js +5 -2
- package/dist/lib/shared/system/glob.js +34 -8
- package/dist/lib/shared/system/sentry.js +222 -0
- package/dist/lib/shared/system/shell-argument.js +5 -1
- package/dist/lib/shared/system/terminal-safe.js +3 -2
- package/dist/lib/shared/system/terminal-style.js +131 -0
- package/dist/lib/shared/workspaces.js +15 -3
- package/docs/assets/cli-workflow.gif +0 -0
- package/integrations/sublime/plugin.py +22 -0
- package/integrations/zed/Cargo.lock +845 -0
- package/integrations/zed/Cargo.toml +11 -0
- package/integrations/zed/extension.toml +11 -0
- package/integrations/zed/src/lib.rs +25 -0
- package/package.json +15 -3
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/commands/loadwise.md +11 -6
- package/plugin/hooks/check-edited-file.mjs +27 -5
- package/polyglot/performance/rules/csharp.yml +34 -5
- package/polyglot/performance/rules/java.yml +24 -1
- package/polyglot/performance/rules/python.yml +74 -2
- package/polyglot/performance/sgconfig.yml +1 -0
- package/polyglot/reliability/rules/csharp.yml +12 -6
- package/polyglot/reliability/rules/go.yml +86 -6
- package/polyglot/reliability/rules/java.yml +22 -1
- package/polyglot/reliability/sgconfig.yml +1 -0
- package/polyglot/security/rules/go.yml +100 -22
- package/polyglot/security/rules/python.yml +74 -6
- package/polyglot/security/rules/rust.yml +65 -0
- package/polyglot/security/sgconfig.yml +1 -0
- package/schema/loadwise.config.schema.json +556 -76
- /package/polyglot/{performance/rules → shared-rules}/input.yml +0 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// TTY-aware ANSI styling for Loadwise terminal output.
|
|
2
|
+
// Always runs AFTER `terminalSafe()` so untrusted source code cannot inject escape sequences.
|
|
3
|
+
// When stdout is not a TTY, NO_COLOR is set, or an AI agent session is active, output stays plain text.
|
|
4
|
+
import { isAgentSession } from '../agent/agent-session.js';
|
|
5
|
+
const ansi = {
|
|
6
|
+
reset: '\x1b[0m',
|
|
7
|
+
bold: '\x1b[1m',
|
|
8
|
+
dim: '\x1b[2m',
|
|
9
|
+
red: '\x1b[31m',
|
|
10
|
+
green: '\x1b[32m',
|
|
11
|
+
yellow: '\x1b[33m',
|
|
12
|
+
cyan: '\x1b[36m',
|
|
13
|
+
magenta: '\x1b[35m',
|
|
14
|
+
boldRed: '\x1b[1;31m',
|
|
15
|
+
boldGreen: '\x1b[1;32m',
|
|
16
|
+
boldYellow: '\x1b[1;33m',
|
|
17
|
+
boldCyan: '\x1b[1;36m',
|
|
18
|
+
boldWhite: '\x1b[1;37m',
|
|
19
|
+
dimCyan: '\x1b[2;36m',
|
|
20
|
+
};
|
|
21
|
+
/** True when interactive ANSI color should be emitted for `stream`. */
|
|
22
|
+
function supportsColor(stream = process.stdout) {
|
|
23
|
+
if (process.env.NO_COLOR !== undefined && process.env.NO_COLOR !== '')
|
|
24
|
+
return false;
|
|
25
|
+
if (process.env.TERM === 'dumb')
|
|
26
|
+
return false;
|
|
27
|
+
const forced = process.env.FORCE_COLOR;
|
|
28
|
+
if (forced !== undefined)
|
|
29
|
+
return forced !== '0' && forced.toLowerCase() !== 'false';
|
|
30
|
+
if (isAgentSession())
|
|
31
|
+
return false;
|
|
32
|
+
return Boolean(stream.isTTY);
|
|
33
|
+
}
|
|
34
|
+
/** Formats a checker section header (`== Performance ==` in plain text, bold cyan rule in TTY). */
|
|
35
|
+
function styleSectionHeader(title, enabled = supportsColor()) {
|
|
36
|
+
if (!enabled)
|
|
37
|
+
return `== ${title} ==`;
|
|
38
|
+
const bar = '━'.repeat(Math.max(4, 52 - title.length));
|
|
39
|
+
return `${ansi.boldCyan}━━ ${title} ${ansi.dimCyan}${bar}${ansi.reset}`;
|
|
40
|
+
}
|
|
41
|
+
function styleSeverity(severity) {
|
|
42
|
+
if (severity === 'critical')
|
|
43
|
+
return `${ansi.boldRed}critical${ansi.reset}`;
|
|
44
|
+
if (severity === 'high')
|
|
45
|
+
return `${ansi.red}${ansi.bold}high${ansi.reset}`;
|
|
46
|
+
if (severity === 'medium')
|
|
47
|
+
return `${ansi.boldYellow}medium${ansi.reset}`;
|
|
48
|
+
return `${ansi.dimCyan}${severity}${ansi.reset}`;
|
|
49
|
+
}
|
|
50
|
+
function styleFindingHeader(line) {
|
|
51
|
+
// Single finding: `path:line:col [rule #id] severity: message`
|
|
52
|
+
const single = /^(\S.*:\d+(?::\d+)?) (\[[^\]]+\]) (critical|high|medium|low)(?:: (.*))?$/.exec(line);
|
|
53
|
+
if (single) {
|
|
54
|
+
const [, loc, rule, severity, message] = single;
|
|
55
|
+
const explanation = message === undefined ? '' : `${ansi.dim}:${ansi.reset} ${message}`;
|
|
56
|
+
return `${ansi.cyan}${loc}${ansi.reset} ${ansi.boldWhite}${rule}${ansi.reset} ${styleSeverity(severity)}${explanation}`;
|
|
57
|
+
}
|
|
58
|
+
// Grouped finding header: `[rule] severity: message (N findings)`
|
|
59
|
+
const grouped = /^(\[[^\]]+\]) (critical|high|medium|low)(?: (\(\d+ findings\)))?(?:: (.*))?$/.exec(line);
|
|
60
|
+
if (grouped) {
|
|
61
|
+
const [, rule, severity, count, message] = grouped;
|
|
62
|
+
const explanation = message === undefined ? '' : `${ansi.dim}:${ansi.reset} ${message}`;
|
|
63
|
+
const total = count ? ` ${ansi.dim}${count}${ansi.reset}` : '';
|
|
64
|
+
return `${ansi.boldWhite}${rule}${ansi.reset} ${styleSeverity(severity)}${total}${explanation}`;
|
|
65
|
+
}
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
/** Applies TTY color to a single already-sanitized output line. */
|
|
69
|
+
function styleTerminalLine(line, enabled = supportsColor()) {
|
|
70
|
+
if (!enabled || !line)
|
|
71
|
+
return line;
|
|
72
|
+
const header = styleFindingHeader(line);
|
|
73
|
+
if (header)
|
|
74
|
+
return header;
|
|
75
|
+
// Grouped finding location line: ` path:line:col #id`
|
|
76
|
+
const groupedLoc = /^( {2})(\S.*:\d+:\d+)( #[a-f0-9-]+)?$/.exec(line);
|
|
77
|
+
if (groupedLoc) {
|
|
78
|
+
const [, indent, loc, id = ''] = groupedLoc;
|
|
79
|
+
return `${indent}${ansi.cyan}${loc}${ansi.reset}${ansi.magenta}${id}${ansi.reset}`;
|
|
80
|
+
}
|
|
81
|
+
// Diff lines in Fix blocks
|
|
82
|
+
if (/^\s+\+ /.test(line))
|
|
83
|
+
return `${ansi.green}${line}${ansi.reset}`;
|
|
84
|
+
if (/^\s+- /.test(line))
|
|
85
|
+
return `${ansi.red}${line}${ansi.reset}`;
|
|
86
|
+
// Actionable fix commands
|
|
87
|
+
const reviewCmd = /^(\s*)(After individual review:|Fix all:) (.+)$/.exec(line);
|
|
88
|
+
if (reviewCmd) {
|
|
89
|
+
const [, indent, prefix, cmd] = reviewCmd;
|
|
90
|
+
return `${indent}${ansi.dim}${prefix}${ansi.reset} ${ansi.boldCyan}${cmd}${ansi.reset}`;
|
|
91
|
+
}
|
|
92
|
+
// Labels (` Fix (...)`, ` Example (...)`, ` Hot path: ...`, ` Note: ...`)
|
|
93
|
+
const labelLine = /^(\s*)(Fix \([^)]+\):|Example \([^)]+\):|Hot path:|Note:|Impact:|Why:)(.*)$/.exec(line);
|
|
94
|
+
if (labelLine) {
|
|
95
|
+
const [, indent, label, rest] = labelLine;
|
|
96
|
+
return `${indent}${ansi.dimCyan}${label}${ansi.reset}${rest}`;
|
|
97
|
+
}
|
|
98
|
+
// Checker summary lines
|
|
99
|
+
if (/^\d+ (?:(?:source|graph) )?file(?:s|\(s\))?\b.*\b0 finding(?:s|\(s\))/.test(line)) {
|
|
100
|
+
return `${ansi.boldGreen}✓ ${line}${ansi.reset}`;
|
|
101
|
+
}
|
|
102
|
+
if (/^\d+ (?:(?:source|graph) )?file(?:s|\(s\))?\b.*\b[1-9]\d* finding(?:s|\(s\))?/.test(line)) {
|
|
103
|
+
return `${ansi.boldYellow}${line}${ansi.reset}`;
|
|
104
|
+
}
|
|
105
|
+
return line;
|
|
106
|
+
}
|
|
107
|
+
/** Colors a sanitized unified diff. Paths and source keep their markers in plain-text output. */
|
|
108
|
+
function stylePatchLine(line, enabled = supportsColor()) {
|
|
109
|
+
if (!enabled)
|
|
110
|
+
return line;
|
|
111
|
+
let color = ansi.dim;
|
|
112
|
+
if (line.startsWith('--- ') || line.startsWith('+++ '))
|
|
113
|
+
color = ansi.boldWhite;
|
|
114
|
+
else if (line.startsWith('@@ '))
|
|
115
|
+
color = ansi.cyan;
|
|
116
|
+
else if (line.startsWith('+'))
|
|
117
|
+
color = ansi.green;
|
|
118
|
+
else if (line.startsWith('-'))
|
|
119
|
+
color = ansi.red;
|
|
120
|
+
return color + line + ansi.reset;
|
|
121
|
+
}
|
|
122
|
+
/** Applies TTY color to a multi-line already-sanitized text block, preserving trailing newline. */
|
|
123
|
+
function styleTerminalText(text, enabled = supportsColor()) {
|
|
124
|
+
if (!enabled || !text)
|
|
125
|
+
return text;
|
|
126
|
+
const endsWithNewline = text.endsWith('\n');
|
|
127
|
+
const lines = (endsWithNewline ? text.slice(0, -1) : text).split('\n');
|
|
128
|
+
const styled = lines.map((line) => styleTerminalLine(line, true)).join('\n');
|
|
129
|
+
return endsWithNewline ? styled + '\n' : styled;
|
|
130
|
+
}
|
|
131
|
+
export { stylePatchLine, styleSectionHeader, styleTerminalLine, styleTerminalText };
|
|
@@ -225,7 +225,9 @@ function workspacePackagesAround(directory) {
|
|
|
225
225
|
for (let current = path.resolve(directory);; current = path.dirname(current)) {
|
|
226
226
|
if (isTempRoot(current))
|
|
227
227
|
return new Map();
|
|
228
|
-
const patterns = isFile(path.join(current, 'package.json')) ||
|
|
228
|
+
const patterns = isFile(path.join(current, 'package.json')) ||
|
|
229
|
+
isFile(path.join(current, 'pnpm-workspace.yaml')) ||
|
|
230
|
+
isFile(path.join(current, 'lerna.json'))
|
|
229
231
|
? workspacePatterns(current)
|
|
230
232
|
: [];
|
|
231
233
|
if (patterns.length) {
|
|
@@ -270,6 +272,14 @@ function workspaceSourceEntry(directory, subpath) {
|
|
|
270
272
|
}
|
|
271
273
|
return undefined;
|
|
272
274
|
}
|
|
275
|
+
function realDirectory(directory) {
|
|
276
|
+
try {
|
|
277
|
+
return fs.realpathSync.native(directory);
|
|
278
|
+
}
|
|
279
|
+
catch {
|
|
280
|
+
return path.resolve(directory);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
273
283
|
// A selector is a package name or a path to its folder, relative to the working directory or to the
|
|
274
284
|
// root.
|
|
275
285
|
function selectWorkspaces(packages, root, selectors, caller = process.cwd()) {
|
|
@@ -277,8 +287,10 @@ function selectWorkspaces(packages, root, selectors, caller = process.cwd()) {
|
|
|
277
287
|
return packages;
|
|
278
288
|
const chosen = new Set();
|
|
279
289
|
for (const selector of selectors) {
|
|
280
|
-
const
|
|
281
|
-
const
|
|
290
|
+
const resolvedCandidates = [path.resolve(caller, selector), path.resolve(root, selector)];
|
|
291
|
+
const candidates = new Set(resolvedCandidates);
|
|
292
|
+
const realCandidates = new Set(resolvedCandidates.map(realDirectory));
|
|
293
|
+
const matched = packages.filter(({ name, directory }) => name === selector || candidates.has(directory) || realCandidates.has(realDirectory(directory)));
|
|
282
294
|
if (!matched.length) {
|
|
283
295
|
throw new Error(`--workspace ${selector} matches no workspace package.`);
|
|
284
296
|
}
|
|
Binary file
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
import sublime
|
|
4
|
+
from LSP.plugin import AbstractPlugin, register_plugin, unregister_plugin
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class LoadwisePlugin(AbstractPlugin):
|
|
8
|
+
@classmethod
|
|
9
|
+
def name(cls):
|
|
10
|
+
return "loadwise"
|
|
11
|
+
|
|
12
|
+
@classmethod
|
|
13
|
+
def additional_variables(cls):
|
|
14
|
+
return json.loads(sublime.load_resource("Packages/LSP-loadwise/runtime.json"))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def plugin_loaded():
|
|
18
|
+
register_plugin(LoadwisePlugin)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def plugin_unloaded():
|
|
22
|
+
unregister_plugin(LoadwisePlugin)
|