@codefast/cli 0.10.0 → 0.12.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/CHANGELOG.md +84 -0
- package/README.md +66 -41
- package/dist/arrange/command.js +99 -136
- package/dist/arrange/domain/ast/collectors-cn.d.ts +2 -2
- package/dist/arrange/domain/ast/collectors-cn.js +2 -2
- package/dist/arrange/domain/ast/collectors-jsx.d.ts +2 -2
- package/dist/arrange/domain/ast/collectors-jsx.js +1 -1
- package/dist/arrange/domain/ast/collectors-tv.d.ts +2 -2
- package/dist/arrange/domain/ast/collectors-tv.js +5 -5
- package/dist/arrange/domain/ast/helpers.d.ts +2 -2
- package/dist/arrange/domain/ast/helpers.js +3 -4
- package/dist/arrange/domain/ast/simplify-targets.d.ts +1 -1
- package/dist/arrange/domain/ast/simplify-targets.js +23 -28
- package/dist/arrange/domain/ast/targets.d.ts +2 -2
- package/dist/arrange/domain/ast/targets.js +9 -9
- package/dist/arrange/{typescript-ast-translator.d.ts → domain/ast/translator.d.ts} +6 -5
- package/dist/arrange/{typescript-ast-translator.js → domain/ast/translator.js} +20 -23
- package/dist/arrange/domain/constants.d.ts +1 -1
- package/dist/arrange/domain/grouping-service.d.ts +2 -2
- package/dist/arrange/domain/grouping-service.js +3 -3
- package/dist/arrange/domain/grouping.js +3 -3
- package/dist/arrange/domain/imports.d.ts +1 -1
- package/dist/arrange/domain/imports.js +2 -2
- package/dist/arrange/domain/source-text-formatters.js +1 -1
- package/dist/arrange/domain/tailwind-token.js +1 -1
- package/dist/arrange/domain/token-classifier.d.ts +1 -1
- package/dist/arrange/domain/token-classifier.js +2 -2
- package/dist/arrange/domain/types.d.ts +3 -3
- package/dist/arrange/group/cli-result.d.ts +7 -0
- package/dist/arrange/group/cli-result.js +12 -0
- package/dist/arrange/group/cli-schema.d.ts +17 -0
- package/dist/arrange/group/cli-schema.js +13 -0
- package/dist/arrange/group/output.d.ts +7 -0
- package/dist/arrange/group/output.js +10 -0
- package/dist/arrange/group/suggest.d.ts +8 -0
- package/dist/arrange/{suggest.js → group/suggest.js} +2 -2
- package/dist/arrange/inspect/cli-result.d.ts +7 -0
- package/dist/arrange/inspect/cli-result.js +8 -0
- package/dist/arrange/inspect/cli-schema.d.ts +15 -0
- package/dist/arrange/inspect/cli-schema.js +9 -0
- package/dist/arrange/{domain → inspect/domain}/analyze-service.d.ts +2 -2
- package/dist/arrange/{domain → inspect/domain}/analyze-service.js +7 -7
- package/dist/arrange/inspect/output.d.ts +7 -0
- package/dist/arrange/inspect/output.js +42 -0
- package/dist/arrange/inspect/run.d.ts +10 -0
- package/dist/arrange/{analyze.js → inspect/run.js} +7 -7
- package/dist/arrange/prepare.d.ts +13 -0
- package/dist/arrange/{workspace.js → prepare.js} +9 -12
- package/dist/arrange/regroup/cli-result.d.ts +13 -0
- package/dist/arrange/regroup/cli-result.js +23 -0
- package/dist/arrange/regroup/cli-schema.d.ts +20 -0
- package/dist/arrange/regroup/cli-schema.js +14 -0
- package/dist/arrange/regroup/output.d.ts +14 -0
- package/dist/arrange/regroup/output.js +72 -0
- package/dist/arrange/{process-file.d.ts → regroup/process-file.d.ts} +3 -3
- package/dist/arrange/{process-file.js → regroup/process-file.js} +3 -3
- package/dist/arrange/regroup/run.d.ts +11 -0
- package/dist/arrange/{sync.js → regroup/run.js} +5 -5
- package/dist/arrange/resolve-target.d.ts +2 -2
- package/dist/arrange/resolve-target.js +2 -2
- package/dist/arrange/scan-target.d.ts +2 -2
- package/dist/arrange/scan-target.js +3 -3
- package/dist/arrange/simplify/cli-result.d.ts +7 -0
- package/dist/arrange/simplify/cli-result.js +8 -0
- package/dist/arrange/simplify/cli-schema.d.ts +17 -0
- package/dist/arrange/simplify/cli-schema.js +11 -0
- package/dist/arrange/simplify/fold-targets.d.ts +13 -0
- package/dist/arrange/simplify/fold-targets.js +139 -0
- package/dist/arrange/simplify/output.d.ts +7 -0
- package/dist/arrange/simplify/output.js +15 -0
- package/dist/arrange/simplify/process-file.d.ts +13 -0
- package/dist/arrange/simplify/process-file.js +49 -0
- package/dist/arrange/simplify/run.d.ts +14 -0
- package/dist/arrange/simplify/run.js +38 -0
- package/dist/arrange/simplify/variant-classname-probe.d.ts +35 -0
- package/dist/arrange/simplify/variant-classname-probe.js +95 -0
- package/dist/arrange/source-parse.d.ts +1 -1
- package/dist/arrange/source-parse.js +3 -3
- package/dist/audit/command.js +152 -212
- package/dist/audit/comments/cli-result.d.ts +13 -0
- package/dist/audit/comments/cli-result.js +22 -0
- package/dist/audit/comments/cli-schema.d.ts +19 -0
- package/dist/audit/comments/cli-schema.js +13 -0
- package/dist/audit/comments/output.d.ts +7 -0
- package/dist/audit/comments/output.js +27 -0
- package/dist/audit/comments/prepare.d.ts +16 -0
- package/dist/audit/comments/prepare.js +12 -0
- package/dist/audit/{run-comments.d.ts → comments/run.d.ts} +5 -5
- package/dist/audit/{run-comments.js → comments/run.js} +9 -9
- package/dist/audit/display-names/cli-result.d.ts +13 -0
- package/dist/audit/display-names/cli-result.js +22 -0
- package/dist/audit/display-names/cli-schema.d.ts +18 -0
- package/dist/audit/display-names/cli-schema.js +12 -0
- package/dist/audit/{domain → display-names/domain}/display-names.d.ts +1 -1
- package/dist/audit/display-names/output.d.ts +7 -0
- package/dist/audit/display-names/output.js +21 -0
- package/dist/audit/display-names/prepare.d.ts +16 -0
- package/dist/audit/display-names/prepare.js +12 -0
- package/dist/audit/display-names/run.d.ts +14 -0
- package/dist/audit/{run-display-names.js → display-names/run.js} +5 -5
- package/dist/audit/domain/types.d.ts +43 -0
- package/dist/audit/imports/cli-result.d.ts +13 -0
- package/dist/audit/imports/cli-result.js +22 -0
- package/dist/audit/imports/cli-schema.d.ts +18 -0
- package/dist/audit/imports/cli-schema.js +12 -0
- package/dist/audit/{domain → imports/domain}/import-policy.d.ts +3 -3
- package/dist/audit/{domain → imports/domain}/import-policy.js +4 -11
- package/dist/audit/imports/output.d.ts +7 -0
- package/dist/audit/imports/output.js +21 -0
- package/dist/audit/imports/prepare.d.ts +16 -0
- package/dist/audit/imports/prepare.js +12 -0
- package/dist/audit/imports/run.d.ts +14 -0
- package/dist/audit/{run-imports.js → imports/run.js} +6 -6
- package/dist/audit/links/cli-result.d.ts +13 -0
- package/dist/audit/links/cli-result.js +22 -0
- package/dist/audit/links/cli-schema.d.ts +18 -0
- package/dist/audit/links/cli-schema.js +12 -0
- package/dist/audit/{domain → links/domain}/markdown-links.d.ts +3 -3
- package/dist/audit/{domain → links/domain}/markdown-links.js +22 -8
- package/dist/audit/links/output.d.ts +7 -0
- package/dist/audit/links/output.js +21 -0
- package/dist/audit/links/prepare.d.ts +16 -0
- package/dist/audit/links/prepare.js +12 -0
- package/dist/audit/links/run.d.ts +14 -0
- package/dist/audit/{run-links.js → links/run.js} +4 -4
- package/dist/audit/prepare.d.ts +13 -52
- package/dist/audit/prepare.js +13 -136
- package/dist/audit/publish/cli-result.d.ts +13 -0
- package/dist/audit/publish/cli-result.js +22 -0
- package/dist/audit/publish/cli-schema.d.ts +18 -0
- package/dist/audit/publish/cli-schema.js +12 -0
- package/dist/audit/publish/domain/legacy-subpath.d.ts +8 -0
- package/dist/audit/publish/domain/legacy-subpath.js +22 -0
- package/dist/audit/publish/output.d.ts +7 -0
- package/dist/audit/publish/output.js +24 -0
- package/dist/audit/publish/prepare.d.ts +16 -0
- package/dist/audit/publish/prepare.js +12 -0
- package/dist/audit/publish/run.d.ts +14 -0
- package/dist/audit/publish/run.js +62 -0
- package/dist/audit/rtl/cli-result.d.ts +13 -0
- package/dist/audit/rtl/cli-result.js +22 -0
- package/dist/audit/rtl/cli-schema.d.ts +18 -0
- package/dist/audit/rtl/cli-schema.js +12 -0
- package/dist/audit/{domain → rtl/domain}/audit-file.d.ts +1 -1
- package/dist/audit/{domain → rtl/domain}/audit-file.js +2 -2
- package/dist/audit/{domain → rtl/domain}/tokenize.d.ts +1 -1
- package/dist/audit/rtl/output.d.ts +7 -0
- package/dist/audit/rtl/output.js +21 -0
- package/dist/audit/rtl/prepare.d.ts +13 -0
- package/dist/audit/rtl/prepare.js +41 -0
- package/dist/audit/rtl/run.d.ts +14 -0
- package/dist/audit/{run.js → rtl/run.js} +4 -4
- package/dist/bin.js +1 -1
- package/dist/cli.js +5 -5
- package/dist/core/cli/command-pipeline.d.ts +90 -0
- package/dist/core/cli/command-pipeline.js +83 -0
- package/dist/core/cli/format-error.d.ts +1 -1
- package/dist/core/cli/global-options.d.ts +1 -1
- package/dist/core/cli/global-options.js +1 -1
- package/dist/core/cli/resolve-root.d.ts +9 -0
- package/dist/core/cli/resolve-root.js +16 -0
- package/dist/core/cli/result-handle.d.ts +3 -9
- package/dist/core/cli/result-handle.js +4 -17
- package/dist/core/config/define-config.d.ts +1 -1
- package/dist/core/config/loader.d.ts +3 -3
- package/dist/core/config/loader.js +2 -2
- package/dist/core/config/schema.d.ts +1 -1
- package/dist/core/config/schema.js +1 -1
- package/dist/core/config/warnings.js +1 -1
- package/dist/core/config.d.ts +5 -5
- package/dist/core/config.js +4 -4
- package/dist/core/filesystem/{port.d.ts → filesystem.d.ts} +1 -1
- package/dist/core/filesystem/node.d.ts +3 -3
- package/dist/core/filesystem/node.js +1 -1
- package/dist/core/schema-parse.d.ts +2 -2
- package/dist/core/schema-parse.js +2 -2
- package/dist/core/source-text-edit.d.ts +14 -0
- package/dist/core/source-text-edit.js +22 -0
- package/dist/core/workspace/markdown-walk.d.ts +2 -2
- package/dist/core/workspace/markdown-walk.js +1 -1
- package/dist/core/workspace/package-version.d.ts +2 -2
- package/dist/core/workspace/package-version.js +2 -2
- package/dist/core/workspace/resolver.d.ts +3 -3
- package/dist/core/workspace/resolver.js +5 -5
- package/dist/core/workspace/source-walk.d.ts +2 -2
- package/dist/core/workspace/source-walk.js +1 -1
- package/dist/core/workspace/typescript-walk.d.ts +2 -2
- package/dist/core/workspace/typescript-walk.js +1 -1
- package/dist/core/workspace/walk-files.d.ts +2 -2
- package/dist/core/workspace/walk-files.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/mirror/cli-result.d.ts +1 -1
- package/dist/mirror/cli-result.js +1 -1
- package/dist/mirror/cli-schema.d.ts +2 -2
- package/dist/mirror/cli-schema.js +1 -1
- package/dist/mirror/command.js +36 -65
- package/dist/mirror/dist-filesystem-node.d.ts +8 -0
- package/dist/mirror/{dist-filesystem-impl.js → dist-filesystem-node.js} +3 -3
- package/dist/mirror/domain/dirent-guard.d.ts +1 -1
- package/dist/mirror/domain/exports.d.ts +2 -2
- package/dist/mirror/domain/exports.js +1 -1
- package/dist/mirror/domain/types.d.ts +59 -2
- package/dist/mirror/output.d.ts +1 -3
- package/dist/mirror/output.js +127 -2
- package/dist/mirror/package-path.d.ts +5 -5
- package/dist/mirror/package-path.js +3 -3
- package/dist/mirror/prepare.d.ts +6 -6
- package/dist/mirror/prepare.js +8 -12
- package/dist/mirror/run.d.ts +12 -0
- package/dist/mirror/{sync.js → run.js} +7 -7
- package/dist/mirror/supplement-exports.d.ts +3 -3
- package/dist/mirror/supplement-exports.js +2 -2
- package/dist/mirror/sync-workspace-package.d.ts +4 -4
- package/dist/mirror/sync-workspace-package.js +11 -14
- package/dist/mirror/write-exports.d.ts +3 -3
- package/dist/mirror/write-exports.js +3 -3
- package/dist/pack-slim/cli-result.d.ts +1 -1
- package/dist/pack-slim/cli-result.js +1 -1
- package/dist/pack-slim/cli-schema.d.ts +1 -1
- package/dist/pack-slim/cli-schema.js +1 -1
- package/dist/pack-slim/command.js +36 -71
- package/dist/pack-slim/domain/transform.d.ts +22 -1
- package/dist/pack-slim/domain/transform.js +65 -8
- package/dist/pack-slim/output.d.ts +1 -1
- package/dist/pack-slim/output.js +1 -1
- package/dist/pack-slim/prepare.d.ts +21 -0
- package/dist/pack-slim/prepare.js +14 -0
- package/dist/pack-slim/{sync.d.ts → run.d.ts} +6 -6
- package/dist/pack-slim/{sync.js → run.js} +5 -5
- package/dist/pack-slim/working-tree.d.ts +2 -2
- package/dist/pack-slim/working-tree.js +2 -2
- package/dist/tag/cli-result.d.ts +8 -2
- package/dist/tag/cli-result.js +15 -2
- package/dist/tag/cli-schema.d.ts +4 -4
- package/dist/tag/cli-schema.js +3 -4
- package/dist/tag/command.js +34 -61
- package/dist/tag/domain/skip-filter.d.ts +13 -0
- package/dist/tag/domain/skip-filter.js +29 -0
- package/dist/tag/domain/types.d.ts +22 -2
- package/dist/tag/domain/version-summary.d.ts +13 -0
- package/dist/tag/domain/version-summary.js +24 -0
- package/dist/tag/output.d.ts +4 -4
- package/dist/tag/output.js +7 -10
- package/dist/tag/prepare.d.ts +5 -5
- package/dist/tag/prepare.js +5 -5
- package/dist/tag/run.d.ts +10 -0
- package/dist/tag/{sync.js → run.js} +23 -53
- package/dist/tag/target/candidates.d.ts +8 -0
- package/dist/tag/{target-candidates.js → target/candidates.js} +3 -3
- package/dist/tag/{resolve-target-path.d.ts → target/resolve-path.d.ts} +2 -2
- package/dist/tag/target/runner.d.ts +8 -0
- package/dist/tag/{target-runner.js → target/runner.js} +3 -3
- package/dist/tag/{since-writer.d.ts → writer/since-writer.d.ts} +3 -3
- package/dist/tag/{since-writer.js → writer/since-writer.js} +1 -1
- package/dist/tag/{version-resolver.d.ts → writer/version-resolver.d.ts} +2 -2
- package/dist/tag/{version-resolver.js → writer/version-resolver.js} +1 -1
- package/package.json +15 -7
- package/dist/arrange/analyze.d.ts +0 -10
- package/dist/arrange/cli-schema.d.ts +0 -50
- package/dist/arrange/cli-schema.js +0 -34
- package/dist/arrange/output.d.ts +0 -26
- package/dist/arrange/output.js +0 -127
- package/dist/arrange/simplify-process-file.d.ts +0 -11
- package/dist/arrange/simplify-process-file.js +0 -30
- package/dist/arrange/simplify-sync.d.ts +0 -13
- package/dist/arrange/simplify-sync.js +0 -30
- package/dist/arrange/suggest.d.ts +0 -8
- package/dist/arrange/sync.d.ts +0 -11
- package/dist/arrange/workspace.d.ts +0 -13
- package/dist/audit/cli-schema.d.ts +0 -93
- package/dist/audit/cli-schema.js +0 -66
- package/dist/audit/output.d.ts +0 -91
- package/dist/audit/output.js +0 -213
- package/dist/audit/run-display-names.d.ts +0 -14
- package/dist/audit/run-imports.d.ts +0 -14
- package/dist/audit/run-links.d.ts +0 -14
- package/dist/audit/run.d.ts +0 -14
- package/dist/mirror/dist-filesystem-impl.d.ts +0 -8
- package/dist/mirror/sync-reporter.d.ts +0 -60
- package/dist/mirror/sync-reporter.js +0 -128
- package/dist/mirror/sync-types.d.ts +0 -43
- package/dist/mirror/sync-types.js +0 -1
- package/dist/mirror/sync.d.ts +0 -12
- package/dist/tag/sync.d.ts +0 -42
- package/dist/tag/target-candidates.d.ts +0 -8
- package/dist/tag/target-runner.d.ts +0 -8
- /package/dist/audit/{domain → comments/domain}/comment-content.d.ts +0 -0
- /package/dist/audit/{domain → comments/domain}/comment-content.js +0 -0
- /package/dist/audit/{domain → comments/domain}/comment-dividers.d.ts +0 -0
- /package/dist/audit/{domain → comments/domain}/comment-dividers.js +0 -0
- /package/dist/audit/{domain → comments/domain}/link-references.d.ts +0 -0
- /package/dist/audit/{domain → comments/domain}/link-references.js +0 -0
- /package/dist/audit/{domain → comments/domain}/since-versions.d.ts +0 -0
- /package/dist/audit/{domain → comments/domain}/since-versions.js +0 -0
- /package/dist/audit/{domain → comments/domain}/tsdoc-syntax.d.ts +0 -0
- /package/dist/audit/{domain → comments/domain}/tsdoc-syntax.js +0 -0
- /package/dist/audit/{domain → display-names/domain}/display-names.js +0 -0
- /package/dist/audit/{domain → rtl/domain}/mappings.d.ts +0 -0
- /package/dist/audit/{domain → rtl/domain}/mappings.js +0 -0
- /package/dist/audit/{domain → rtl/domain}/tokenize.js +0 -0
- /package/dist/core/filesystem/{port.js → filesystem.js} +0 -0
- /package/dist/tag/{resolve-target-path.js → target/resolve-path.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DIRECTION_RESOLVED_VARIANT, PHYSICAL_SIDE_VARIANT, RTL_MAPPINGS, RTL_REVERSE_MAPPINGS, RTL_SWAP_MAPPINGS, RTL_TRANSLATE_X_MAPPINGS, SLIDE_PREFIXES, } from "
|
|
2
|
-
import { collectTokens } from "
|
|
1
|
+
import { DIRECTION_RESOLVED_VARIANT, PHYSICAL_SIDE_VARIANT, RTL_MAPPINGS, RTL_REVERSE_MAPPINGS, RTL_SWAP_MAPPINGS, RTL_TRANSLATE_X_MAPPINGS, SLIDE_PREFIXES, } from "#audit/rtl/domain/mappings";
|
|
2
|
+
import { collectTokens } from "#audit/rtl/domain/tokenize";
|
|
3
3
|
/**
|
|
4
4
|
* A token satisfies an "rtl companion" requirement when the same file has a
|
|
5
5
|
* token whose variants include `rtl` and whose value matches. Variant order
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RtlClassToken } from "
|
|
1
|
+
import type { RtlClassToken } from "#audit/domain/types";
|
|
2
2
|
/**
|
|
3
3
|
* Splits a class token into [variant, value, modifier], colon/slash-aware of
|
|
4
4
|
* brackets and parens (arbitrary values like data-[side=left] or calc(...)).
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { logger } from "#core/logger";
|
|
2
|
+
/**
|
|
3
|
+
* Human-readable RTL audit report (matches the former packages/ui script shape).
|
|
4
|
+
*
|
|
5
|
+
* @since 0.5.0-canary.6
|
|
6
|
+
*/
|
|
7
|
+
export function presentRtlAuditResult(result) {
|
|
8
|
+
for (const file of result.files) {
|
|
9
|
+
logger.out(`\n${file.relativePath}`);
|
|
10
|
+
for (const { line, raw, suggestion } of file.violations) {
|
|
11
|
+
logger.out(` ${line}: ${raw} → ${suggestion}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const allowlistSuffix = result.allowlistedCount > 0 ? ` (${result.allowlistedCount} allowlisted)` : "";
|
|
15
|
+
if (result.violationCount > 0) {
|
|
16
|
+
logger.out(`\n✖ ${result.violationCount} RTL violation(s)${allowlistSuffix}`);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
logger.out(`✓ No physical-direction classes outside the allowlist${allowlistSuffix}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AuditCommandPrelude } from "#audit/prepare";
|
|
2
|
+
import { AppError } from "#core/errors";
|
|
3
|
+
import type { Filesystem } from "#core/filesystem/filesystem";
|
|
4
|
+
import type { Result } from "#core/result";
|
|
5
|
+
/**
|
|
6
|
+
* Loads config and resolves the scan target for `audit rtl`.
|
|
7
|
+
*
|
|
8
|
+
* @since 0.5.0-canary.6
|
|
9
|
+
*/
|
|
10
|
+
export declare function prepareRtlAudit(fs: Filesystem, args: {
|
|
11
|
+
readonly currentWorkingDirectory: string;
|
|
12
|
+
readonly rawTarget: string | undefined;
|
|
13
|
+
}): Promise<Result<AuditCommandPrelude, AppError>>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { resolveRepoRelativePath } from "#audit/prepare";
|
|
2
|
+
import { loadCodefastConfig } from "#core/config";
|
|
3
|
+
import { AppError, messageFrom } from "#core/errors";
|
|
4
|
+
import { err, ok } from "#core/result";
|
|
5
|
+
import { resolveProjectRoot } from "#core/workspace/resolver";
|
|
6
|
+
/**
|
|
7
|
+
* Loads config and resolves the scan target for `audit rtl`.
|
|
8
|
+
*
|
|
9
|
+
* @since 0.5.0-canary.6
|
|
10
|
+
*/
|
|
11
|
+
export async function prepareRtlAudit(fs, args) {
|
|
12
|
+
let rootDir;
|
|
13
|
+
try {
|
|
14
|
+
// Realpath so allowlist keys (`path.relative(rootDir, file)`) stay stable when cwd is a symlink.
|
|
15
|
+
rootDir = fs.canonicalPathSync(resolveProjectRoot(args.currentWorkingDirectory, fs).rootDir);
|
|
16
|
+
}
|
|
17
|
+
catch (caughtError) {
|
|
18
|
+
return err(new AppError("INFRA_FAILURE", messageFrom(caughtError), caughtError));
|
|
19
|
+
}
|
|
20
|
+
const loadedOutcome = await loadCodefastConfig(rootDir, fs);
|
|
21
|
+
if (!loadedOutcome.ok) {
|
|
22
|
+
return loadedOutcome;
|
|
23
|
+
}
|
|
24
|
+
const { config } = loadedOutcome.value;
|
|
25
|
+
const rtlConfig = config.audit?.rtl ?? {};
|
|
26
|
+
const targetFromCli = args.rawTarget;
|
|
27
|
+
const targetFromConfig = rtlConfig.target;
|
|
28
|
+
const resolvedTargetInput = targetFromCli ?? targetFromConfig;
|
|
29
|
+
if (resolvedTargetInput === undefined) {
|
|
30
|
+
return err(new AppError("VALIDATION_ERROR", "Missing scan target: pass a path argument or set audit.rtl.target in codefast.config"));
|
|
31
|
+
}
|
|
32
|
+
const targetPath = resolveRepoRelativePath(targetFromCli !== undefined ? args.currentWorkingDirectory : rootDir, resolvedTargetInput);
|
|
33
|
+
if (!fs.existsSync(targetPath)) {
|
|
34
|
+
return err(new AppError("NOT_FOUND", `Not found: ${targetPath}`));
|
|
35
|
+
}
|
|
36
|
+
return ok({
|
|
37
|
+
rootDir,
|
|
38
|
+
targetPath: fs.canonicalPathSync(targetPath),
|
|
39
|
+
allowlist: rtlConfig.allowlist ?? [],
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RtlAuditResult } from "#audit/domain/types";
|
|
2
|
+
import { AppError } from "#core/errors";
|
|
3
|
+
import type { Filesystem } from "#core/filesystem/filesystem";
|
|
4
|
+
import type { Result } from "#core/result";
|
|
5
|
+
/**
|
|
6
|
+
* Scans a target path for physical-direction Tailwind class violations.
|
|
7
|
+
*
|
|
8
|
+
* @since 0.5.0-canary.6
|
|
9
|
+
*/
|
|
10
|
+
export declare function runRtlAudit(fs: Filesystem, args: {
|
|
11
|
+
readonly rootDir: string;
|
|
12
|
+
readonly targetPath: string;
|
|
13
|
+
readonly allowlist: ReadonlyArray<string>;
|
|
14
|
+
}): Result<RtlAuditResult, AppError>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { auditFileContent } from "
|
|
3
|
-
import { AppError, messageFrom } from "
|
|
4
|
-
import { err, ok } from "
|
|
5
|
-
import { walkTsxFiles } from "
|
|
2
|
+
import { auditFileContent } from "#audit/rtl/domain/audit-file";
|
|
3
|
+
import { AppError, messageFrom } from "#core/errors";
|
|
4
|
+
import { err, ok } from "#core/result";
|
|
5
|
+
import { walkTsxFiles } from "#core/workspace/typescript-walk";
|
|
6
6
|
/**
|
|
7
7
|
* Scans a target path for physical-direction Tailwind class violations.
|
|
8
8
|
*
|
package/dist/bin.js
CHANGED
package/dist/cli.js
CHANGED
|
@@ -3,11 +3,11 @@ import path from "node:path";
|
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { Command } from "commander";
|
|
6
|
-
import { createArrangeCommand } from "
|
|
7
|
-
import { createAuditCommand } from "
|
|
8
|
-
import { createMirrorCommand } from "
|
|
9
|
-
import { createPackSlimCommand } from "
|
|
10
|
-
import { createTagCommand } from "
|
|
6
|
+
import { createArrangeCommand } from "#arrange/command";
|
|
7
|
+
import { createAuditCommand } from "#audit/command";
|
|
8
|
+
import { createMirrorCommand } from "#mirror/command";
|
|
9
|
+
import { createPackSlimCommand } from "#pack-slim/command";
|
|
10
|
+
import { createTagCommand } from "#tag/command";
|
|
11
11
|
function readVersion() {
|
|
12
12
|
try {
|
|
13
13
|
const dir = path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { ZodType } from "zod";
|
|
3
|
+
import type { GlobalCliOptions } from "#core/cli/global-options";
|
|
4
|
+
import type { AppError } from "#core/errors";
|
|
5
|
+
import type { Filesystem } from "#core/filesystem/filesystem";
|
|
6
|
+
import type { Result } from "#core/result";
|
|
7
|
+
/**
|
|
8
|
+
* The options every command shares: the `--json` machine-output flag. Per-command option shapes extend this.
|
|
9
|
+
*
|
|
10
|
+
* @since 0.11.0
|
|
11
|
+
*/
|
|
12
|
+
export interface BaseCommandOptions {
|
|
13
|
+
readonly json?: boolean | undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A pipeline's `prepare` slot: resolves the argv context (cwd, positional, global options) into the command's prelude.
|
|
17
|
+
*
|
|
18
|
+
* @since 0.11.0
|
|
19
|
+
*/
|
|
20
|
+
export type CommandPrepare<Prelude> = (fs: Filesystem, input: {
|
|
21
|
+
readonly currentWorkingDirectory: string;
|
|
22
|
+
readonly rawArg: string | undefined;
|
|
23
|
+
readonly globals: GlobalCliOptions;
|
|
24
|
+
}) => Promise<Result<Prelude, AppError>>;
|
|
25
|
+
/** The prelude and options a request is built from, before the run. */
|
|
26
|
+
interface BuildInput<Prelude, Opts> {
|
|
27
|
+
readonly prelude: Prelude;
|
|
28
|
+
readonly opts: Opts;
|
|
29
|
+
readonly globals: GlobalCliOptions;
|
|
30
|
+
}
|
|
31
|
+
/** The run result and its surrounding context, for the report phase. */
|
|
32
|
+
interface ReportInput<Prelude, RunResult, Presenter, Opts> {
|
|
33
|
+
readonly result: RunResult;
|
|
34
|
+
readonly prelude: Prelude;
|
|
35
|
+
readonly opts: Opts;
|
|
36
|
+
readonly presenter: Presenter | undefined;
|
|
37
|
+
readonly elapsedSeconds: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The invariant shape every workspace command and subcommand shares: resolve a prelude, build and
|
|
41
|
+
* validate a request, run it, then report to one of two audiences and record a single exit code.
|
|
42
|
+
*
|
|
43
|
+
* @remarks The optional slots carry the per-command variations — a working-tree guard and a streaming
|
|
44
|
+
* presenter — so the control flow itself is written once.
|
|
45
|
+
*
|
|
46
|
+
* @since 0.11.0
|
|
47
|
+
*/
|
|
48
|
+
export interface CommandPipeline<Prelude, Request, RunResult, Presenter = never, Opts extends BaseCommandOptions = BaseCommandOptions> {
|
|
49
|
+
readonly name?: string | undefined;
|
|
50
|
+
readonly description?: string | undefined;
|
|
51
|
+
readonly positional?: {
|
|
52
|
+
readonly name: string;
|
|
53
|
+
readonly help: string;
|
|
54
|
+
} | undefined;
|
|
55
|
+
readonly configureArgv?: ((command: Command) => void) | undefined;
|
|
56
|
+
readonly prepare: CommandPrepare<Prelude>;
|
|
57
|
+
readonly guard?: ((input: {
|
|
58
|
+
readonly prelude: Prelude;
|
|
59
|
+
readonly opts: Opts;
|
|
60
|
+
}) => Promise<Result<void, AppError>>) | undefined;
|
|
61
|
+
readonly schema: ZodType<Request>;
|
|
62
|
+
readonly buildRequest: (input: BuildInput<Prelude, Opts>) => unknown;
|
|
63
|
+
readonly createPresenter?: ((input: BuildInput<Prelude, Opts>) => Presenter) | undefined;
|
|
64
|
+
readonly run: (fs: Filesystem, request: Request, presenter: Presenter | undefined) => Promise<Result<RunResult, AppError>>;
|
|
65
|
+
readonly presentHuman?: ((input: ReportInput<Prelude, RunResult, Presenter, Opts>) => void) | undefined;
|
|
66
|
+
readonly formatJson: (input: ReportInput<Prelude, RunResult, Presenter, Opts>) => string;
|
|
67
|
+
readonly exitCode: (result: RunResult) => number;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* A pipeline that names itself, so it can register as a subcommand under a parent command.
|
|
71
|
+
*
|
|
72
|
+
* @since 0.11.0
|
|
73
|
+
*/
|
|
74
|
+
export type NamedCommandPipeline<Prelude, Request, RunResult, Presenter = never, Opts extends BaseCommandOptions = BaseCommandOptions> = CommandPipeline<Prelude, Request, RunResult, Presenter, Opts> & {
|
|
75
|
+
readonly name: string;
|
|
76
|
+
readonly description: string;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Wires a pipeline onto a named Command: the shared positional, `--json`, any extra options, and the action.
|
|
80
|
+
*
|
|
81
|
+
* @since 0.11.0
|
|
82
|
+
*/
|
|
83
|
+
export declare function applyCommandPipeline<Prelude, Request, RunResult, Presenter, Opts extends BaseCommandOptions>(command: Command, fs: Filesystem, pipeline: CommandPipeline<Prelude, Request, RunResult, Presenter, Opts>): Command;
|
|
84
|
+
/**
|
|
85
|
+
* Registers a pipeline as a subcommand under `parent`, taking its name and description from the pipeline.
|
|
86
|
+
*
|
|
87
|
+
* @since 0.11.0
|
|
88
|
+
*/
|
|
89
|
+
export declare function registerPipelineSubcommand<Prelude, Request, RunResult, Presenter, Opts extends BaseCommandOptions>(parent: Command, fs: Filesystem, pipeline: NamedCommandPipeline<Prelude, Request, RunResult, Presenter, Opts>): void;
|
|
90
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import { globalCliCommanderOptionsSchema } from "#core/cli/global-options";
|
|
3
|
+
import { readOptionalPositionalArg } from "#core/cli/positional";
|
|
4
|
+
import { consumeCliAppError } from "#core/cli/result-handle";
|
|
5
|
+
import { logger } from "#core/logger";
|
|
6
|
+
import { parseWithSchema } from "#core/schema-parse";
|
|
7
|
+
const DEFAULT_JSON_HELP = "Print one JSON object on stdout instead of the human-readable output";
|
|
8
|
+
function readGlobalOptions(command) {
|
|
9
|
+
return (command.optsWithGlobals?.() ?? command.opts());
|
|
10
|
+
}
|
|
11
|
+
function makeAction(fs, pipeline) {
|
|
12
|
+
return async (rawArg, opts, command) => {
|
|
13
|
+
const globalsOutcome = parseWithSchema(globalCliCommanderOptionsSchema, readGlobalOptions(command));
|
|
14
|
+
if (!consumeCliAppError(globalsOutcome)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const globals = globalsOutcome.value;
|
|
18
|
+
const prelude = await pipeline.prepare(fs, {
|
|
19
|
+
currentWorkingDirectory: process.cwd(),
|
|
20
|
+
rawArg: readOptionalPositionalArg(rawArg),
|
|
21
|
+
globals,
|
|
22
|
+
});
|
|
23
|
+
if (!consumeCliAppError(prelude)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (pipeline.guard) {
|
|
27
|
+
const guarded = await pipeline.guard({ prelude: prelude.value, opts });
|
|
28
|
+
if (!consumeCliAppError(guarded)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const parsed = parseWithSchema(pipeline.schema, pipeline.buildRequest({ prelude: prelude.value, opts, globals }));
|
|
33
|
+
if (!consumeCliAppError(parsed)) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const json = !!opts.json;
|
|
37
|
+
const presenter = !json && pipeline.createPresenter
|
|
38
|
+
? pipeline.createPresenter({ prelude: prelude.value, opts, globals })
|
|
39
|
+
: undefined;
|
|
40
|
+
const startedAt = performance.now();
|
|
41
|
+
const outcome = await pipeline.run(fs, parsed.value, presenter);
|
|
42
|
+
if (!consumeCliAppError(outcome)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const elapsedSeconds = (performance.now() - startedAt) / 1000;
|
|
46
|
+
const report = {
|
|
47
|
+
result: outcome.value,
|
|
48
|
+
prelude: prelude.value,
|
|
49
|
+
opts,
|
|
50
|
+
presenter,
|
|
51
|
+
elapsedSeconds,
|
|
52
|
+
};
|
|
53
|
+
if (json) {
|
|
54
|
+
logger.out(pipeline.formatJson(report));
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
pipeline.presentHuman?.(report);
|
|
58
|
+
}
|
|
59
|
+
process.exitCode = pipeline.exitCode(outcome.value);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Wires a pipeline onto a named Command: the shared positional, `--json`, any extra options, and the action.
|
|
64
|
+
*
|
|
65
|
+
* @since 0.11.0
|
|
66
|
+
*/
|
|
67
|
+
export function applyCommandPipeline(command, fs, pipeline) {
|
|
68
|
+
if (pipeline.positional) {
|
|
69
|
+
command.argument(pipeline.positional.name, pipeline.positional.help);
|
|
70
|
+
}
|
|
71
|
+
command.option("--json", DEFAULT_JSON_HELP, false);
|
|
72
|
+
pipeline.configureArgv?.(command);
|
|
73
|
+
command.action(makeAction(fs, pipeline));
|
|
74
|
+
return command;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Registers a pipeline as a subcommand under `parent`, taking its name and description from the pipeline.
|
|
78
|
+
*
|
|
79
|
+
* @since 0.11.0
|
|
80
|
+
*/
|
|
81
|
+
export function registerPipelineSubcommand(parent, fs, pipeline) {
|
|
82
|
+
applyCommandPipeline(parent.command(pipeline.name).description(pipeline.description), fs, pipeline);
|
|
83
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AppError } from "#core/errors";
|
|
2
|
+
import type { Filesystem } from "#core/filesystem/filesystem";
|
|
3
|
+
import type { Result } from "#core/result";
|
|
4
|
+
/**
|
|
5
|
+
* Resolves the project root as a `Result`, mapping a resolution failure to an `INFRA_FAILURE` error.
|
|
6
|
+
*
|
|
7
|
+
* @since 0.11.0
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveProjectRootResult(fs: Filesystem, currentWorkingDirectory: string): Result<string, AppError>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AppError, messageFrom } from "#core/errors";
|
|
2
|
+
import { err, ok } from "#core/result";
|
|
3
|
+
import { resolveProjectRoot } from "#core/workspace/resolver";
|
|
4
|
+
/**
|
|
5
|
+
* Resolves the project root as a `Result`, mapping a resolution failure to an `INFRA_FAILURE` error.
|
|
6
|
+
*
|
|
7
|
+
* @since 0.11.0
|
|
8
|
+
*/
|
|
9
|
+
export function resolveProjectRootResult(fs, currentWorkingDirectory) {
|
|
10
|
+
try {
|
|
11
|
+
return ok(resolveProjectRoot(currentWorkingDirectory, fs).rootDir);
|
|
12
|
+
}
|
|
13
|
+
catch (caughtError) {
|
|
14
|
+
return err(new AppError("INFRA_FAILURE", messageFrom(caughtError), caughtError));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AppError } from "
|
|
2
|
-
import type { Result } from "
|
|
1
|
+
import type { AppError } from "#core/errors";
|
|
2
|
+
import type { Result } from "#core/result";
|
|
3
3
|
/**
|
|
4
4
|
* Narrows a `Result`, reporting a failure and setting the exit code, or logging an optional success message.
|
|
5
5
|
*
|
|
@@ -10,10 +10,4 @@ export declare function consumeCliAppError<Value>(outcome: Result<Value, AppErro
|
|
|
10
10
|
}): outcome is {
|
|
11
11
|
readonly ok: true;
|
|
12
12
|
readonly value: Value;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Awaits a `Result`, hands a success to `onSuccess`, and records the returned exit code on the process.
|
|
16
|
-
*
|
|
17
|
-
* @since 0.3.16-canary.0
|
|
18
|
-
*/
|
|
19
|
-
export declare function runCliResultAsync<Value>(outcomePromise: Promise<Result<Value, AppError>>, onSuccess: (value: Value) => number | void | Promise<number | void>): Promise<void>;
|
|
13
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import process from "node:process";
|
|
2
|
-
import { formatAppError } from "
|
|
3
|
-
import { CLI_EXIT_GENERAL_ERROR, CLI_EXIT_USAGE } from "
|
|
4
|
-
import { logger } from "
|
|
5
|
-
import { isVerboseCliDiagnostics } from "
|
|
2
|
+
import { formatAppError } from "#core/cli/format-error";
|
|
3
|
+
import { CLI_EXIT_GENERAL_ERROR, CLI_EXIT_USAGE } from "#core/exit-codes";
|
|
4
|
+
import { logger } from "#core/logger";
|
|
5
|
+
import { isVerboseCliDiagnostics } from "#core/verbose-diagnostics";
|
|
6
6
|
function exitCodeForAppError(error) {
|
|
7
7
|
switch (error.code) {
|
|
8
8
|
case "NOT_FOUND":
|
|
@@ -38,17 +38,4 @@ export function consumeCliAppError(outcome, options) {
|
|
|
38
38
|
logger.out(options.successMessage);
|
|
39
39
|
}
|
|
40
40
|
return true;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Awaits a `Result`, hands a success to `onSuccess`, and records the returned exit code on the process.
|
|
44
|
-
*
|
|
45
|
-
* @since 0.3.16-canary.0
|
|
46
|
-
*/
|
|
47
|
-
export async function runCliResultAsync(outcomePromise, onSuccess) {
|
|
48
|
-
const outcome = await outcomePromise;
|
|
49
|
-
if (!consumeCliAppError(outcome)) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
const exit = await onSuccess(outcome.value);
|
|
53
|
-
process.exitCode = exit === undefined ? 0 : exit;
|
|
54
41
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CodefastConfig } from "
|
|
2
|
-
import type {
|
|
1
|
+
import type { CodefastConfig } from "#core/config/schema";
|
|
2
|
+
import type { Filesystem } from "#core/filesystem/filesystem";
|
|
3
3
|
/**
|
|
4
4
|
* A loaded config together with its schema warnings and the path it was read from.
|
|
5
5
|
*
|
|
@@ -15,4 +15,4 @@ export type LoadConfigPayload = {
|
|
|
15
15
|
*
|
|
16
16
|
* @since 0.3.16-canary.0
|
|
17
17
|
*/
|
|
18
|
-
export declare function loadConfigPayload(startDir: string, fs:
|
|
18
|
+
export declare function loadConfigPayload(startDir: string, fs: Filesystem): Promise<LoadConfigPayload>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import jiti from "jiti";
|
|
3
|
-
import { codefastConfigRootSchema } from "
|
|
4
|
-
import { ancestorDirectories } from "
|
|
3
|
+
import { codefastConfigRootSchema } from "#core/config/schema";
|
|
4
|
+
import { ancestorDirectories } from "#core/workspace/ancestor-directories";
|
|
5
5
|
function formatZodError(error, filePath) {
|
|
6
6
|
const formatted = error.issues
|
|
7
7
|
.map((issue) => {
|
package/dist/core/config.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { CodefastConfig } from "
|
|
2
|
-
import { AppError } from "
|
|
3
|
-
import type {
|
|
4
|
-
import type { Result } from "
|
|
1
|
+
import type { CodefastConfig } from "#core/config/schema";
|
|
2
|
+
import { AppError } from "#core/errors";
|
|
3
|
+
import type { Filesystem } from "#core/filesystem/filesystem";
|
|
4
|
+
import type { Result } from "#core/result";
|
|
5
5
|
/**
|
|
6
6
|
* Loads the `codefast.config.js` for a workspace root, reporting schema warnings along the way.
|
|
7
7
|
*
|
|
8
8
|
* @since 0.3.16-canary.0
|
|
9
9
|
*/
|
|
10
|
-
export declare function loadCodefastConfig(rootDir: string, fs:
|
|
10
|
+
export declare function loadCodefastConfig(rootDir: string, fs: Filesystem): Promise<Result<{
|
|
11
11
|
config: CodefastConfig;
|
|
12
12
|
}, AppError>>;
|
package/dist/core/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { loadConfigPayload } from "
|
|
2
|
-
import { reportSchemaWarnings } from "
|
|
3
|
-
import { AppError, messageFrom } from "
|
|
4
|
-
import { err, ok } from "
|
|
1
|
+
import { loadConfigPayload } from "#core/config/loader";
|
|
2
|
+
import { reportSchemaWarnings } from "#core/config/warnings";
|
|
3
|
+
import { AppError, messageFrom } from "#core/errors";
|
|
4
|
+
import { err, ok } from "#core/result";
|
|
5
5
|
/**
|
|
6
6
|
* Loads the `codefast.config.js` for a workspace root, reporting schema warnings along the way.
|
|
7
7
|
*
|
|
@@ -20,7 +20,7 @@ export interface DirectoryEntry {
|
|
|
20
20
|
*
|
|
21
21
|
* @since 0.3.16-canary.0
|
|
22
22
|
*/
|
|
23
|
-
export interface
|
|
23
|
+
export interface Filesystem {
|
|
24
24
|
existsSync(filePath: string): boolean;
|
|
25
25
|
canonicalPathSync(inputPath: string): string;
|
|
26
26
|
statSync(filePath: string): {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Filesystem } from "#core/filesystem/filesystem";
|
|
2
2
|
/**
|
|
3
|
-
* The `
|
|
3
|
+
* The `Filesystem` implementation backed by Node's real filesystem.
|
|
4
4
|
*
|
|
5
5
|
* @since 0.3.16-canary.0
|
|
6
6
|
*/
|
|
7
|
-
export declare const nodeFilesystem:
|
|
7
|
+
export declare const nodeFilesystem: Filesystem;
|
|
@@ -2,7 +2,7 @@ import fsSync from "node:fs";
|
|
|
2
2
|
import fsPromises from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
/**
|
|
5
|
-
* The `
|
|
5
|
+
* The `Filesystem` implementation backed by Node's real filesystem.
|
|
6
6
|
*
|
|
7
7
|
* @since 0.3.16-canary.0
|
|
8
8
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ZodType } from "zod";
|
|
2
|
-
import { AppError } from "
|
|
3
|
-
import type { Result } from "
|
|
2
|
+
import { AppError } from "#core/errors";
|
|
3
|
+
import type { Result } from "#core/result";
|
|
4
4
|
/**
|
|
5
5
|
* Parses an input against a Zod schema and returns a `Result` with the value or a validation `AppError`.
|
|
6
6
|
*
|
|
@@ -24,6 +24,20 @@ export declare function textPrefixFromLineStartToPosition(source: string, pos: n
|
|
|
24
24
|
* @since 0.3.16-canary.0
|
|
25
25
|
*/
|
|
26
26
|
export declare function endAfterOptionalCommaFollowingInSource(source: string, tokenEnd: number): number;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the edits with every overlap removed, keeping the outermost of any overlapping pair.
|
|
29
|
+
*
|
|
30
|
+
* @remarks A planned edit replaces a whole AST node, so two ranges either nest or are disjoint and
|
|
31
|
+
* the outer replacement already contains the inner span verbatim — dropping the nested edit keeps
|
|
32
|
+
* the output valid. Higher-priority edits must come first so an exact-range tie keeps the earlier
|
|
33
|
+
* one. This is the invariant `applyEditsDescending` assumes; run it before applying.
|
|
34
|
+
*
|
|
35
|
+
* @since 0.11.0
|
|
36
|
+
*/
|
|
37
|
+
export declare function dropOverlappingEdits<Edit extends {
|
|
38
|
+
start: number;
|
|
39
|
+
end: number;
|
|
40
|
+
}>(edits: ReadonlyArray<Edit>): Array<Edit>;
|
|
27
41
|
/**
|
|
28
42
|
* Applies non-overlapping text edits from the highest offset down and returns the edited source.
|
|
29
43
|
*
|
|
@@ -54,6 +54,28 @@ export function endAfterOptionalCommaFollowingInSource(source, tokenEnd) {
|
|
|
54
54
|
}
|
|
55
55
|
return tokenEnd;
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Returns the edits with every overlap removed, keeping the outermost of any overlapping pair.
|
|
59
|
+
*
|
|
60
|
+
* @remarks A planned edit replaces a whole AST node, so two ranges either nest or are disjoint and
|
|
61
|
+
* the outer replacement already contains the inner span verbatim — dropping the nested edit keeps
|
|
62
|
+
* the output valid. Higher-priority edits must come first so an exact-range tie keeps the earlier
|
|
63
|
+
* one. This is the invariant `applyEditsDescending` assumes; run it before applying.
|
|
64
|
+
*
|
|
65
|
+
* @since 0.11.0
|
|
66
|
+
*/
|
|
67
|
+
export function dropOverlappingEdits(edits) {
|
|
68
|
+
const ordered = [...edits].toSorted((editA, editB) => editA.start - editB.start || editB.end - editA.end);
|
|
69
|
+
const kept = [];
|
|
70
|
+
let lastEnd = -1;
|
|
71
|
+
for (const edit of ordered) {
|
|
72
|
+
if (edit.start >= lastEnd) {
|
|
73
|
+
kept.push(edit);
|
|
74
|
+
lastEnd = edit.end;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return kept;
|
|
78
|
+
}
|
|
57
79
|
/**
|
|
58
80
|
* Applies non-overlapping text edits from the highest offset down and returns the edited source.
|
|
59
81
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Filesystem } from "#core/filesystem/filesystem";
|
|
2
2
|
/**
|
|
3
3
|
* Every markdown file under a root, skipping build output and vendored trees.
|
|
4
4
|
*
|
|
5
5
|
* @since 0.5.0
|
|
6
6
|
*/
|
|
7
|
-
export declare function walkMarkdownFiles(rootDirectoryPath: string, fs:
|
|
7
|
+
export declare function walkMarkdownFiles(rootDirectoryPath: string, fs: Filesystem): Array<string>;
|