@codefast/cli 0.11.0 → 0.13.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 +87 -0
- package/README.md +152 -56
- package/dist/arrange/command.js +24 -25
- 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 +5 -5
- package/dist/arrange/domain/ast/targets.d.ts +2 -2
- package/dist/arrange/domain/ast/targets.js +9 -9
- package/dist/arrange/domain/ast/translator.d.ts +1 -1
- package/dist/arrange/domain/ast/translator.js +43 -29
- 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 +1 -1
- package/dist/arrange/group/output.d.ts +1 -1
- package/dist/arrange/group/output.js +1 -1
- package/dist/arrange/group/suggest.d.ts +2 -2
- package/dist/arrange/group/suggest.js +2 -2
- package/dist/arrange/inspect/cli-result.d.ts +1 -1
- package/dist/arrange/inspect/domain/analyze-service.d.ts +2 -2
- package/dist/arrange/inspect/domain/analyze-service.js +7 -7
- package/dist/arrange/inspect/output.d.ts +1 -1
- package/dist/arrange/inspect/output.js +2 -2
- package/dist/arrange/inspect/run.d.ts +4 -4
- package/dist/arrange/inspect/run.js +6 -6
- package/dist/arrange/prepare.d.ts +4 -4
- package/dist/arrange/prepare.js +5 -5
- package/dist/arrange/regroup/cli-result.d.ts +1 -1
- package/dist/arrange/regroup/cli-result.js +1 -1
- package/dist/arrange/regroup/output.d.ts +2 -2
- package/dist/arrange/regroup/output.js +2 -2
- package/dist/arrange/regroup/process-file.d.ts +2 -2
- package/dist/arrange/regroup/process-file.js +3 -3
- package/dist/arrange/regroup/run.d.ts +5 -5
- package/dist/arrange/regroup/run.js +4 -4
- package/dist/arrange/resolve-target.d.ts +1 -1
- package/dist/arrange/resolve-target.js +2 -2
- package/dist/arrange/scan-target.d.ts +1 -1
- package/dist/arrange/scan-target.js +3 -3
- package/dist/arrange/simplify/cli-result.d.ts +1 -1
- package/dist/arrange/simplify/fold-targets.d.ts +3 -3
- package/dist/arrange/simplify/fold-targets.js +3 -3
- package/dist/arrange/simplify/output.d.ts +1 -1
- package/dist/arrange/simplify/output.js +1 -1
- package/dist/arrange/simplify/process-file.d.ts +4 -4
- package/dist/arrange/simplify/process-file.js +5 -5
- package/dist/arrange/simplify/run.d.ts +4 -4
- package/dist/arrange/simplify/run.js +4 -4
- package/dist/arrange/simplify/variant-classname-probe.js +1 -1
- package/dist/arrange/source-parse.d.ts +1 -1
- package/dist/arrange/source-parse.js +3 -3
- package/dist/audit/assertions/cli-result.d.ts +13 -0
- package/dist/audit/assertions/cli-result.js +22 -0
- package/dist/audit/assertions/cli-schema.d.ts +18 -0
- package/dist/audit/assertions/cli-schema.js +12 -0
- package/dist/audit/assertions/domain/double-assertion.d.ts +20 -0
- package/dist/audit/assertions/domain/double-assertion.js +122 -0
- package/dist/audit/assertions/output.d.ts +7 -0
- package/dist/audit/assertions/output.js +21 -0
- package/dist/audit/assertions/prepare.d.ts +16 -0
- package/dist/audit/assertions/prepare.js +12 -0
- package/dist/audit/assertions/run.d.ts +14 -0
- package/dist/audit/assertions/run.js +40 -0
- package/dist/audit/command.js +89 -28
- package/dist/audit/comments/cli-result.d.ts +1 -1
- package/dist/audit/comments/cli-result.js +1 -1
- package/dist/audit/comments/output.d.ts +1 -1
- package/dist/audit/comments/output.js +1 -1
- package/dist/audit/comments/prepare.d.ts +4 -4
- package/dist/audit/comments/prepare.js +1 -1
- package/dist/audit/comments/run.d.ts +4 -4
- package/dist/audit/comments/run.js +9 -9
- package/dist/audit/constants/cli-result.d.ts +13 -0
- package/dist/audit/constants/cli-result.js +22 -0
- package/dist/audit/constants/cli-schema.d.ts +18 -0
- package/dist/audit/constants/cli-schema.js +12 -0
- package/dist/audit/constants/domain/constants.d.ts +8 -0
- package/dist/audit/constants/domain/constants.js +66 -0
- package/dist/audit/constants/output.d.ts +7 -0
- package/dist/audit/constants/output.js +21 -0
- package/dist/audit/constants/prepare.d.ts +16 -0
- package/dist/audit/constants/prepare.js +37 -0
- package/dist/audit/constants/run.d.ts +14 -0
- package/dist/audit/constants/run.js +64 -0
- package/dist/audit/display-names/cli-result.d.ts +1 -1
- package/dist/audit/display-names/cli-result.js +1 -1
- package/dist/audit/display-names/domain/display-names.d.ts +1 -1
- package/dist/audit/display-names/domain/display-names.js +1 -9
- package/dist/audit/display-names/output.d.ts +1 -1
- package/dist/audit/display-names/output.js +1 -1
- package/dist/audit/display-names/prepare.d.ts +4 -4
- package/dist/audit/display-names/prepare.js +1 -1
- package/dist/audit/display-names/run.d.ts +4 -4
- package/dist/audit/display-names/run.js +5 -5
- package/dist/audit/domain/types.d.ts +128 -0
- package/dist/audit/imports/cli-result.d.ts +1 -1
- package/dist/audit/imports/cli-result.js +1 -1
- package/dist/audit/imports/domain/import-policy.d.ts +1 -1
- package/dist/audit/imports/domain/import-policy.js +4 -18
- package/dist/audit/imports/output.d.ts +1 -1
- package/dist/audit/imports/output.js +1 -1
- package/dist/audit/imports/prepare.d.ts +4 -4
- package/dist/audit/imports/prepare.js +1 -1
- package/dist/audit/imports/run.d.ts +4 -4
- package/dist/audit/imports/run.js +6 -6
- package/dist/audit/links/cli-result.d.ts +1 -1
- package/dist/audit/links/cli-result.js +1 -1
- package/dist/audit/links/domain/markdown-links.d.ts +3 -3
- package/dist/audit/links/domain/markdown-links.js +22 -8
- package/dist/audit/links/output.d.ts +1 -1
- package/dist/audit/links/output.js +1 -1
- package/dist/audit/links/prepare.d.ts +4 -4
- package/dist/audit/links/prepare.js +1 -1
- package/dist/audit/links/run.d.ts +4 -4
- package/dist/audit/links/run.js +4 -4
- package/dist/audit/prepare.d.ts +4 -4
- package/dist/audit/prepare.js +4 -4
- package/dist/audit/publish/cli-result.d.ts +13 -0
- package/dist/audit/publish/cli-result.js +25 -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/domain/stylesheet-sources.d.ts +22 -0
- package/dist/audit/publish/domain/stylesheet-sources.js +64 -0
- package/dist/audit/publish/output.d.ts +7 -0
- package/dist/audit/publish/output.js +33 -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 +15 -0
- package/dist/audit/publish/run.js +91 -0
- package/dist/audit/publish/shipped-files.d.ts +21 -0
- package/dist/audit/publish/shipped-files.js +36 -0
- package/dist/audit/rtl/cli-result.d.ts +1 -1
- package/dist/audit/rtl/cli-result.js +1 -1
- package/dist/audit/rtl/domain/audit-file.d.ts +1 -1
- package/dist/audit/rtl/domain/audit-file.js +2 -2
- package/dist/audit/rtl/domain/tokenize.d.ts +1 -1
- package/dist/audit/rtl/output.d.ts +1 -1
- package/dist/audit/rtl/output.js +1 -1
- package/dist/audit/rtl/prepare.d.ts +4 -4
- package/dist/audit/rtl/prepare.js +5 -5
- package/dist/audit/rtl/run.d.ts +4 -4
- package/dist/audit/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 +4 -5
- package/dist/core/cli/command-pipeline.js +7 -7
- package/dist/core/cli/format-error.d.ts +1 -1
- package/dist/core/cli/resolve-root.d.ts +3 -3
- package/dist/core/cli/resolve-root.js +3 -3
- package/dist/core/cli/result-handle.d.ts +2 -2
- package/dist/core/cli/result-handle.js +4 -4
- package/dist/core/config/define-config.d.ts +1 -1
- package/dist/core/config/loader.d.ts +2 -2
- package/dist/core/config/loader.js +2 -2
- package/dist/core/config/schema.d.ts +5 -0
- package/dist/core/config/schema.js +2 -0
- package/dist/core/config/warnings.js +1 -1
- package/dist/core/config.d.ts +4 -4
- package/dist/core/config.js +4 -4
- package/dist/core/filesystem/filesystem.d.ts +3 -4
- package/dist/core/filesystem/node.d.ts +1 -1
- package/dist/core/filesystem/node.js +1 -7
- package/dist/core/oxc-node.d.ts +32 -0
- package/dist/core/oxc-node.js +25 -0
- package/dist/core/schema-parse.d.ts +2 -2
- package/dist/core/schema-parse.js +2 -2
- package/dist/core/source-position.d.ts +15 -0
- package/dist/core/source-position.js +26 -0
- package/dist/core/workspace/markdown-walk.d.ts +1 -1
- package/dist/core/workspace/markdown-walk.js +1 -1
- package/dist/core/workspace/package-version.d.ts +1 -1
- package/dist/core/workspace/package-version.js +2 -2
- package/dist/core/workspace/resolver.d.ts +1 -1
- package/dist/core/workspace/resolver.js +5 -5
- package/dist/core/workspace/source-walk.d.ts +1 -1
- package/dist/core/workspace/source-walk.js +1 -1
- package/dist/core/workspace/typescript-walk.d.ts +1 -1
- package/dist/core/workspace/typescript-walk.js +1 -1
- package/dist/core/workspace/walk-files.d.ts +1 -1
- 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 +1 -1
- package/dist/mirror/command.js +7 -7
- package/dist/mirror/dist-filesystem-node.d.ts +2 -2
- package/dist/mirror/dist-filesystem-node.js +5 -15
- package/dist/mirror/domain/exports.d.ts +2 -2
- package/dist/mirror/domain/exports.js +1 -1
- package/dist/mirror/domain/types.d.ts +2 -2
- package/dist/mirror/output.d.ts +1 -1
- package/dist/mirror/output.js +2 -2
- package/dist/mirror/package-path.d.ts +3 -3
- package/dist/mirror/package-path.js +3 -3
- package/dist/mirror/prepare.d.ts +5 -5
- package/dist/mirror/prepare.js +4 -4
- package/dist/mirror/run.d.ts +6 -6
- package/dist/mirror/run.js +7 -7
- package/dist/mirror/supplement-exports.d.ts +1 -1
- package/dist/mirror/supplement-exports.js +2 -2
- package/dist/mirror/sync-workspace-package.d.ts +3 -3
- package/dist/mirror/sync-workspace-package.js +11 -14
- package/dist/mirror/write-exports.d.ts +2 -2
- 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/command.js +9 -9
- 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 +3 -3
- package/dist/pack-slim/prepare.js +2 -2
- package/dist/pack-slim/run.d.ts +5 -5
- package/dist/pack-slim/run.js +6 -6
- 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 +1 -1
- package/dist/tag/cli-result.js +1 -1
- package/dist/tag/cli-schema.d.ts +1 -1
- package/dist/tag/command.js +7 -7
- package/dist/tag/domain/skip-filter.d.ts +1 -1
- package/dist/tag/domain/skip-filter.js +1 -1
- package/dist/tag/domain/types.d.ts +1 -1
- package/dist/tag/domain/version-summary.d.ts +5 -2
- package/dist/tag/output.d.ts +1 -1
- package/dist/tag/output.js +1 -1
- package/dist/tag/prepare.d.ts +4 -4
- package/dist/tag/prepare.js +4 -4
- package/dist/tag/run.d.ts +4 -4
- package/dist/tag/run.js +7 -7
- package/dist/tag/target/candidates.d.ts +2 -2
- package/dist/tag/target/candidates.js +2 -2
- package/dist/tag/target/resolve-path.d.ts +1 -1
- package/dist/tag/target/runner.d.ts +2 -2
- package/dist/tag/target/runner.js +3 -3
- package/dist/tag/writer/since-writer.d.ts +2 -2
- package/dist/tag/writer/since-writer.js +3 -5
- package/dist/tag/writer/version-resolver.d.ts +1 -1
- package/dist/tag/writer/version-resolver.js +1 -1
- package/package.json +7 -7
- package/dist/mirror/domain/dirent-guard.d.ts +0 -10
- package/dist/mirror/domain/dirent-guard.js +0 -15
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Filesystem } from "
|
|
1
|
+
import type { Filesystem } from "#core/filesystem/filesystem";
|
|
2
2
|
/**
|
|
3
3
|
* Finds the `version` of the nearest enclosing `package.json`, or null when the first
|
|
4
4
|
* one found declares none (the private workspace root is version-less by design).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { findNearestAncestor } from "
|
|
3
|
-
import { packageJsonFileName } from "
|
|
2
|
+
import { findNearestAncestor } from "#core/workspace/ancestor-directories";
|
|
3
|
+
import { packageJsonFileName } from "#core/workspace/well-known-files";
|
|
4
4
|
/**
|
|
5
5
|
* Finds the `version` of the nearest enclosing `package.json`, or null when the first
|
|
6
6
|
* one found declares none (the private workspace root is version-less by design).
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { parse as parseYaml } from "yaml";
|
|
3
|
-
import { messageFrom } from "
|
|
4
|
-
import { createAnyGlobMatcher } from "
|
|
5
|
-
import { logger } from "
|
|
6
|
-
import { findNearestAncestor } from "
|
|
7
|
-
import { packageJsonFileName, workspaceYamlFileName } from "
|
|
3
|
+
import { messageFrom } from "#core/errors";
|
|
4
|
+
import { createAnyGlobMatcher } from "#core/glob";
|
|
5
|
+
import { logger } from "#core/logger";
|
|
6
|
+
import { findNearestAncestor } from "#core/workspace/ancestor-directories";
|
|
7
|
+
import { packageJsonFileName, workspaceYamlFileName } from "#core/workspace/well-known-files";
|
|
8
8
|
/**
|
|
9
9
|
* Resolves the project root: the `pnpm-workspace.yaml` directory, or the nearest `package.json` for a single package.
|
|
10
10
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { walkFiles } from "
|
|
2
|
+
import { walkFiles } from "#core/workspace/walk-files";
|
|
3
3
|
// Ignore files carry the divider convention over `#` comments — the content rules stay code-only.
|
|
4
4
|
const ignoreFileNames = new Set([
|
|
5
5
|
".gitignore",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { defaultSkipDirectoryNames } from "
|
|
2
|
+
import { defaultSkipDirectoryNames } from "#core/workspace/skip-directories";
|
|
3
3
|
/**
|
|
4
4
|
* Every file under a root the predicate accepts, skipping build output and vendored trees.
|
|
5
5
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `@codefast/cli` public API: run the CLI in-process, and author a typed `codefast.config.*`.
|
|
3
3
|
*/
|
|
4
|
-
export { runCli } from "
|
|
5
|
-
export { defineConfig } from "
|
|
6
|
-
export type { CodefastAfterWriteHook, CodefastArrangeConfig, CodefastConfig, CodefastTagConfig, MirrorConfig, } from "
|
|
4
|
+
export { runCli } from "#cli";
|
|
5
|
+
export { defineConfig } from "#core/config/define-config";
|
|
6
|
+
export type { CodefastAfterWriteHook, CodefastArrangeConfig, CodefastConfig, CodefastTagConfig, MirrorConfig, } from "#core/config/schema";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `@codefast/cli` public API: run the CLI in-process, and author a typed `codefast.config.*`.
|
|
3
3
|
*/
|
|
4
|
-
export { runCli } from "
|
|
5
|
-
export { defineConfig } from "
|
|
4
|
+
export { runCli } from "#cli";
|
|
5
|
+
export { defineConfig } from "#core/config/define-config";
|
package/dist/mirror/command.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
import { applyCommandPipeline } from "
|
|
3
|
-
import { nodeFilesystem } from "
|
|
4
|
-
import { exitCodeForMirrorSyncResult, formatMirrorSyncJsonOutput } from "
|
|
5
|
-
import { mirrorSyncRunRequestSchema } from "
|
|
6
|
-
import { MirrorSyncProgressPresenter } from "
|
|
7
|
-
import { prepareMirrorSync } from "
|
|
8
|
-
import { runMirrorSync } from "
|
|
2
|
+
import { applyCommandPipeline } from "#core/cli/command-pipeline";
|
|
3
|
+
import { nodeFilesystem } from "#core/filesystem/node";
|
|
4
|
+
import { exitCodeForMirrorSyncResult, formatMirrorSyncJsonOutput } from "#mirror/cli-result";
|
|
5
|
+
import { mirrorSyncRunRequestSchema } from "#mirror/cli-schema";
|
|
6
|
+
import { MirrorSyncProgressPresenter } from "#mirror/output";
|
|
7
|
+
import { prepareMirrorSync } from "#mirror/prepare";
|
|
8
|
+
import { runMirrorSync } from "#mirror/run";
|
|
9
9
|
const mirrorPipeline = {
|
|
10
10
|
positional: { name: "[package]", help: "Optional package path relative to repo root (e.g. packages/ui)" },
|
|
11
11
|
schema: mirrorSyncRunRequestSchema,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Filesystem } from "
|
|
2
|
-
import type { DistFilesystem } from "
|
|
1
|
+
import type { Filesystem } from "#core/filesystem/filesystem";
|
|
2
|
+
import type { DistFilesystem } from "#mirror/domain/dist-filesystem";
|
|
3
3
|
/**
|
|
4
4
|
* Creates the `DistFilesystem` the mirror scan uses, backed by a `Filesystem`.
|
|
5
5
|
*
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import {
|
|
3
|
-
import { normalizePath } from "#/mirror/domain/path-normalizer";
|
|
2
|
+
import { normalizePath } from "#mirror/domain/path-normalizer";
|
|
4
3
|
/**
|
|
5
4
|
* Creates the `DistFilesystem` the mirror scan uses, backed by a `Filesystem`.
|
|
6
5
|
*
|
|
@@ -10,11 +9,8 @@ export function createMirrorDistFilesystem(fs) {
|
|
|
10
9
|
return {
|
|
11
10
|
async listRelativeFilesRecursively(dirPath) {
|
|
12
11
|
try {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
return [];
|
|
16
|
-
}
|
|
17
|
-
return raw
|
|
12
|
+
const entries = await fs.readdirEntries(dirPath, { recursive: true });
|
|
13
|
+
return entries
|
|
18
14
|
.filter((dirent) => dirent.isFile())
|
|
19
15
|
.map((dirent) => {
|
|
20
16
|
const fullPath = path.join(dirent.parentPath, dirent.name);
|
|
@@ -31,14 +27,8 @@ export function createMirrorDistFilesystem(fs) {
|
|
|
31
27
|
},
|
|
32
28
|
async isDirectoryCssOnly(distDir, dirPath) {
|
|
33
29
|
try {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
if (raw.length === 0) {
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
return raw.every((dirent) => dirent.isFile() && dirent.name.endsWith(".css"));
|
|
30
|
+
const entries = await fs.readdirEntries(path.join(distDir, dirPath));
|
|
31
|
+
return entries.every((dirent) => dirent.isFile() && dirent.name.endsWith(".css"));
|
|
42
32
|
}
|
|
43
33
|
catch {
|
|
44
34
|
return false;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DistFilesystem } from "
|
|
2
|
-
import type { GenerateExportsResult } from "
|
|
1
|
+
import type { DistFilesystem } from "#mirror/domain/dist-filesystem";
|
|
2
|
+
import type { GenerateExportsResult } from "#mirror/domain/types";
|
|
3
3
|
/**
|
|
4
4
|
* Creates a transform that strips a configured prefix from export paths, or `null` when none is set.
|
|
5
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as nodePath from "node:path";
|
|
2
|
-
import { PACKAGE_JSON_EXPORT, VALID_DTS_EXTENSIONS, VALID_JS_EXTENSIONS } from "
|
|
2
|
+
import { PACKAGE_JSON_EXPORT, VALID_DTS_EXTENSIONS, VALID_JS_EXTENSIONS } from "#mirror/domain/constants";
|
|
3
3
|
function groupDistFilesByModule(relativeDistFiles) {
|
|
4
4
|
const distModulesByPath = new Map();
|
|
5
5
|
for (const relativeDistFile of relativeDistFiles) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { GlobalCliOptions } from "
|
|
2
|
-
import type { CodefastConfig } from "
|
|
1
|
+
import type { GlobalCliOptions } from "#core/cli/global-options";
|
|
2
|
+
import type { CodefastConfig } from "#core/config/schema";
|
|
3
3
|
/**
|
|
4
4
|
* One conditional exports entry, keyed by resolution condition.
|
|
5
5
|
*
|
package/dist/mirror/output.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GlobalStats, MirrorProcessingModeInput, MirrorSyncProgressListener, PackageStats } from "
|
|
1
|
+
import type { GlobalStats, MirrorProcessingModeInput, MirrorSyncProgressListener, PackageStats } from "#mirror/domain/types";
|
|
2
2
|
/**
|
|
3
3
|
* A progress listener that renders mirror run events through the CLI reporter.
|
|
4
4
|
*
|
package/dist/mirror/output.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import process from "node:process";
|
|
2
|
-
import { messageFrom } from "
|
|
3
|
-
import { logger } from "
|
|
2
|
+
import { messageFrom } from "#core/errors";
|
|
3
|
+
import { logger } from "#core/logger";
|
|
4
4
|
const cliLogger = logger;
|
|
5
5
|
/**
|
|
6
6
|
* A progress listener that renders mirror run events through the CLI reporter.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AppError } from "
|
|
2
|
-
import type { Filesystem } from "
|
|
3
|
-
import type { Result } from "
|
|
1
|
+
import { AppError } from "#core/errors";
|
|
2
|
+
import type { Filesystem } from "#core/filesystem/filesystem";
|
|
3
|
+
import type { Result } from "#core/result";
|
|
4
4
|
/**
|
|
5
5
|
* Resolves the optional positional package argument to a root-relative path, or `undefined` when absent.
|
|
6
6
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { AppError } from "
|
|
3
|
-
import { err, ok } from "
|
|
4
|
-
import { normalizePath } from "
|
|
2
|
+
import { AppError } from "#core/errors";
|
|
3
|
+
import { err, ok } from "#core/result";
|
|
4
|
+
import { normalizePath } from "#mirror/domain/path-normalizer";
|
|
5
5
|
/**
|
|
6
6
|
* Resolves the optional positional package argument to a root-relative path, or `undefined` when absent.
|
|
7
7
|
*
|
package/dist/mirror/prepare.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { GlobalCliOptions } from "
|
|
2
|
-
import type { AppError } from "
|
|
3
|
-
import type { Filesystem } from "
|
|
4
|
-
import type { Result } from "
|
|
5
|
-
import type { MirrorSyncCommandPrelude } from "
|
|
1
|
+
import type { GlobalCliOptions } from "#core/cli/global-options";
|
|
2
|
+
import type { AppError } from "#core/errors";
|
|
3
|
+
import type { Filesystem } from "#core/filesystem/filesystem";
|
|
4
|
+
import type { Result } from "#core/result";
|
|
5
|
+
import type { MirrorSyncCommandPrelude } from "#mirror/domain/types";
|
|
6
6
|
/**
|
|
7
7
|
* Resolves the repo root, config, and package filter into the prelude a mirror run starts from.
|
|
8
8
|
*
|
package/dist/mirror/prepare.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { resolveProjectRootResult } from "
|
|
2
|
-
import { loadCodefastConfig } from "
|
|
3
|
-
import { ok } from "
|
|
4
|
-
import { resolveMirrorPackageFromCliArg } from "
|
|
1
|
+
import { resolveProjectRootResult } from "#core/cli/resolve-root";
|
|
2
|
+
import { loadCodefastConfig } from "#core/config";
|
|
3
|
+
import { ok } from "#core/result";
|
|
4
|
+
import { resolveMirrorPackageFromCliArg } from "#mirror/package-path";
|
|
5
5
|
/**
|
|
6
6
|
* Resolves the repo root, config, and package filter into the prelude a mirror run starts from.
|
|
7
7
|
*
|
package/dist/mirror/run.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { AppError } from "
|
|
2
|
-
import type { Filesystem } from "
|
|
3
|
-
import type { Result } from "
|
|
4
|
-
import type { GlobalStats } from "
|
|
5
|
-
import type { MirrorSyncExecutionInput } from "
|
|
6
|
-
export type { MirrorSyncExecutionInput } from "
|
|
1
|
+
import { AppError } from "#core/errors";
|
|
2
|
+
import type { Filesystem } from "#core/filesystem/filesystem";
|
|
3
|
+
import type { Result } from "#core/result";
|
|
4
|
+
import type { GlobalStats } from "#mirror/domain/types";
|
|
5
|
+
import type { MirrorSyncExecutionInput } from "#mirror/domain/types";
|
|
6
|
+
export type { MirrorSyncExecutionInput } from "#mirror/domain/types";
|
|
7
7
|
/**
|
|
8
8
|
* Runs the mirror sync across the targeted packages and returns the aggregate stats.
|
|
9
9
|
*
|
package/dist/mirror/run.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { AppError } from "
|
|
3
|
-
import { messageFrom } from "
|
|
4
|
-
import { err, ok } from "
|
|
5
|
-
import { listWorkspacePackageDirectories } from "
|
|
6
|
-
import { normalizePath } from "
|
|
7
|
-
import { resolvePackageFilterUnderRoot } from "
|
|
8
|
-
import { syncExportsForWorkspacePackage } from "
|
|
2
|
+
import { AppError } from "#core/errors";
|
|
3
|
+
import { messageFrom } from "#core/errors";
|
|
4
|
+
import { err, ok } from "#core/result";
|
|
5
|
+
import { listWorkspacePackageDirectories } from "#core/workspace/resolver";
|
|
6
|
+
import { normalizePath } from "#mirror/domain/path-normalizer";
|
|
7
|
+
import { resolvePackageFilterUnderRoot } from "#mirror/package-path";
|
|
8
|
+
import { syncExportsForWorkspacePackage } from "#mirror/sync-workspace-package";
|
|
9
9
|
/**
|
|
10
10
|
* Runs the mirror sync across the targeted packages and returns the aggregate stats.
|
|
11
11
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { distDirName } from "
|
|
3
|
-
import { writePackageJsonExportsAtomic } from "
|
|
2
|
+
import { distDirName } from "#core/workspace/well-known-files";
|
|
3
|
+
import { writePackageJsonExportsAtomic } from "#mirror/write-exports";
|
|
4
4
|
const DTS_EXTENSIONS = [".d.mts", ".d.ts", ".d.cts"];
|
|
5
5
|
const JS_EXTENSIONS = [".mjs", ".js"];
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { MirrorConfig } from "
|
|
2
|
-
import type { Filesystem } from "
|
|
3
|
-
import type { PackageStats } from "
|
|
1
|
+
import type { MirrorConfig } from "#core/config/schema";
|
|
2
|
+
import type { Filesystem } from "#core/filesystem/filesystem";
|
|
3
|
+
import type { PackageStats } from "#mirror/domain/types";
|
|
4
4
|
/**
|
|
5
5
|
* Regenerates one package's `package.json#exports` from its `dist/` and returns the package's stats.
|
|
6
6
|
*
|
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { messageFrom } from "
|
|
3
|
-
import { distDirName, packageJsonFileName } from "
|
|
4
|
-
import { createMirrorDistFilesystem } from "
|
|
5
|
-
import { createPathTransform, generateExports } from "
|
|
6
|
-
import { resolvePackageDisplayName } from "
|
|
7
|
-
import { buildSourcePathResolver, supplementExportsInPackageJson } from "
|
|
8
|
-
import { writePackageJsonExportsAtomic } from "
|
|
2
|
+
import { messageFrom } from "#core/errors";
|
|
3
|
+
import { distDirName, packageJsonFileName } from "#core/workspace/well-known-files";
|
|
4
|
+
import { createMirrorDistFilesystem } from "#mirror/dist-filesystem-node";
|
|
5
|
+
import { createPathTransform, generateExports } from "#mirror/domain/exports";
|
|
6
|
+
import { resolvePackageDisplayName } from "#mirror/domain/package-display-name";
|
|
7
|
+
import { buildSourcePathResolver, supplementExportsInPackageJson } from "#mirror/supplement-exports";
|
|
8
|
+
import { writePackageJsonExportsAtomic } from "#mirror/write-exports";
|
|
9
9
|
/**
|
|
10
10
|
* Regenerates one package's `package.json#exports` from its `dist/` and returns the package's stats.
|
|
11
11
|
*
|
|
12
12
|
* @since 0.3.16-canary.0
|
|
13
13
|
*/
|
|
14
14
|
export async function syncExportsForWorkspacePackage(fs, rootDir, packagePathStr, config, write = true) {
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const distDir = pathJoin(packageDir, distDirName);
|
|
20
|
-
const packageJsonPath = pathJoin(packageDir, packageJsonFileName);
|
|
21
|
-
const folderBasename = pathBasename(packageDir);
|
|
15
|
+
const packageDir = path.resolve(rootDir, packagePathStr);
|
|
16
|
+
const distDir = path.join(packageDir, distDirName);
|
|
17
|
+
const packageJsonPath = path.join(packageDir, packageJsonFileName);
|
|
18
|
+
const folderBasename = path.basename(packageDir);
|
|
22
19
|
const distFilesystem = createMirrorDistFilesystem(fs);
|
|
23
20
|
const pkgStats = {
|
|
24
21
|
name: folderBasename,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Filesystem } from "
|
|
2
|
-
import type { ExportMapData, ExportOriginalPathBySpecifier } from "
|
|
1
|
+
import type { Filesystem } from "#core/filesystem/filesystem";
|
|
2
|
+
import type { ExportMapData, ExportOriginalPathBySpecifier } from "#mirror/domain/types";
|
|
3
3
|
/**
|
|
4
4
|
* Writes `exports` into `package.json` via a temp file + rename (atomic on same volume).
|
|
5
5
|
* Preserves a trailing newline after JSON.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { messageFrom } from "
|
|
2
|
-
import { PACKAGE_JSON_EXPORT } from "
|
|
3
|
-
import { MirrorError, MirrorErrorCode } from "
|
|
1
|
+
import { messageFrom } from "#core/errors";
|
|
2
|
+
import { PACKAGE_JSON_EXPORT } from "#mirror/domain/constants";
|
|
3
|
+
import { MirrorError, MirrorErrorCode } from "#mirror/domain/errors";
|
|
4
4
|
/**
|
|
5
5
|
* Writes `exports` into `package.json` via a temp file + rename (atomic on same volume).
|
|
6
6
|
* Preserves a trailing newline after JSON.
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
import { applyCommandPipeline } from "
|
|
3
|
-
import { nodeFilesystem } from "
|
|
4
|
-
import { ok } from "
|
|
5
|
-
import { exitCodeForPackSlimResult, formatPackSlimJsonOutput } from "
|
|
6
|
-
import { packSlimRunRequestSchema } from "
|
|
7
|
-
import { PackSlimProgressPresenter } from "
|
|
8
|
-
import { preparePackSlim } from "
|
|
9
|
-
import { runPackSlim } from "
|
|
10
|
-
import { ensureWorkingTreeClean } from "
|
|
2
|
+
import { applyCommandPipeline } from "#core/cli/command-pipeline";
|
|
3
|
+
import { nodeFilesystem } from "#core/filesystem/node";
|
|
4
|
+
import { ok } from "#core/result";
|
|
5
|
+
import { exitCodeForPackSlimResult, formatPackSlimJsonOutput } from "#pack-slim/cli-result";
|
|
6
|
+
import { packSlimRunRequestSchema } from "#pack-slim/cli-schema";
|
|
7
|
+
import { PackSlimProgressPresenter } from "#pack-slim/output";
|
|
8
|
+
import { preparePackSlim } from "#pack-slim/prepare";
|
|
9
|
+
import { runPackSlim } from "#pack-slim/run";
|
|
10
|
+
import { ensureWorkingTreeClean } from "#pack-slim/working-tree";
|
|
11
11
|
const packSlimPipeline = {
|
|
12
12
|
positional: { name: "[package]", help: "Optional package path relative to repo root (e.g. packages/ui)" },
|
|
13
13
|
schema: packSlimRunRequestSchema,
|
|
@@ -54,12 +54,33 @@ export declare function isLifecycleScript(name: string): boolean;
|
|
|
54
54
|
* Produces a publish manifest carrying only what a consumer's `tsc` and Node read.
|
|
55
55
|
*
|
|
56
56
|
* @remarks Operates on a structural clone, so the caller's manifest is left intact. A consumer never enables `source`
|
|
57
|
-
* and resolves
|
|
57
|
+
* and resolves `#` through `types`/`default` to `dist`, so dropping the source lane, the `imports` left pointing
|
|
58
58
|
* outside `files`, the scripts that are not lifecycle hooks, and `devDependencies` leaves the published surface whole.
|
|
59
59
|
*
|
|
60
60
|
* @since 0.8.1
|
|
61
61
|
*/
|
|
62
62
|
export declare function slimPublishManifest(manifest: Record<string, unknown>): SlimManifestResult;
|
|
63
|
+
/**
|
|
64
|
+
* A published `exports`/`imports` target the slimmed manifest points at but does not ship.
|
|
65
|
+
*
|
|
66
|
+
* @since 0.12.0
|
|
67
|
+
*/
|
|
68
|
+
export interface UnshippedTarget {
|
|
69
|
+
readonly field: "exports" | "imports";
|
|
70
|
+
readonly subpath: string;
|
|
71
|
+
readonly target: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The publish targets a package would resolve to a file it does not ship.
|
|
75
|
+
*
|
|
76
|
+
* @remarks Runs the same slim the publish step applies, then checks each surviving `exports`/`imports`
|
|
77
|
+
* target against the shipped `files`. A non-empty result means a consumer resolves that subpath to a
|
|
78
|
+
* missing file — the failure dropping a stylesheet's `src` subtree produces. With no `files` field npm
|
|
79
|
+
* ships everything, so nothing is unshipped.
|
|
80
|
+
*
|
|
81
|
+
* @since 0.12.0
|
|
82
|
+
*/
|
|
83
|
+
export declare function unshippedPublishTargets(manifest: Record<string, unknown>): Array<UnshippedTarget>;
|
|
63
84
|
/**
|
|
64
85
|
* Strips every `sourceMappingURL` directive line from an emitted file's text.
|
|
65
86
|
*
|
|
@@ -58,16 +58,16 @@ export function isLifecycleScript(name) {
|
|
|
58
58
|
* Produces a publish manifest carrying only what a consumer's `tsc` and Node read.
|
|
59
59
|
*
|
|
60
60
|
* @remarks Operates on a structural clone, so the caller's manifest is left intact. A consumer never enables `source`
|
|
61
|
-
* and resolves
|
|
61
|
+
* and resolves `#` through `types`/`default` to `dist`, so dropping the source lane, the `imports` left pointing
|
|
62
62
|
* outside `files`, the scripts that are not lifecycle hooks, and `devDependencies` leaves the published surface whole.
|
|
63
63
|
*
|
|
64
64
|
* @since 0.8.1
|
|
65
65
|
*/
|
|
66
66
|
export function slimPublishManifest(manifest) {
|
|
67
67
|
const draft = structuredClone(manifest);
|
|
68
|
-
const filesSrcRemoved = removeSrcFromFiles(draft);
|
|
69
68
|
const exportsSourceRemoved = deleteSourceConditions(draft.exports);
|
|
70
69
|
const importsSourceRemoved = deleteSourceConditions(draft.imports);
|
|
70
|
+
const filesSrcRemoved = removeSrcFromFiles(draft);
|
|
71
71
|
const importsUnshippedRemoved = deleteUnshippedImports(draft);
|
|
72
72
|
const scriptsRemoved = deleteDevOnlyScripts(draft);
|
|
73
73
|
const devDependenciesRemoved = deleteDevDependencies(draft);
|
|
@@ -85,6 +85,44 @@ export function slimPublishManifest(manifest) {
|
|
|
85
85
|
},
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* The publish targets a package would resolve to a file it does not ship.
|
|
90
|
+
*
|
|
91
|
+
* @remarks Runs the same slim the publish step applies, then checks each surviving `exports`/`imports`
|
|
92
|
+
* target against the shipped `files`. A non-empty result means a consumer resolves that subpath to a
|
|
93
|
+
* missing file — the failure dropping a stylesheet's `src` subtree produces. With no `files` field npm
|
|
94
|
+
* ships everything, so nothing is unshipped.
|
|
95
|
+
*
|
|
96
|
+
* @since 0.12.0
|
|
97
|
+
*/
|
|
98
|
+
export function unshippedPublishTargets(manifest) {
|
|
99
|
+
const { manifest: slimmed } = slimPublishManifest(manifest);
|
|
100
|
+
const files = Array.isArray(slimmed.files)
|
|
101
|
+
? slimmed.files.filter((entry) => typeof entry === "string")
|
|
102
|
+
: [];
|
|
103
|
+
if (files.length === 0) {
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
const unshipped = [];
|
|
107
|
+
for (const field of ["exports", "imports"]) {
|
|
108
|
+
const node = slimmed[field];
|
|
109
|
+
if (!isRecord(node)) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
for (const subpath of Object.keys(node)) {
|
|
113
|
+
for (const target of collectTargets(node[subpath])) {
|
|
114
|
+
// Only relative file targets can be unshipped; npm always includes package.json.
|
|
115
|
+
if (!target.startsWith("./") || stripDotSlash(target) === "package.json") {
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (!isShippedTarget(target, files)) {
|
|
119
|
+
unshipped.push({ field, subpath, target });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return unshipped;
|
|
125
|
+
}
|
|
88
126
|
/**
|
|
89
127
|
* Strips every `sourceMappingURL` directive line from an emitted file's text.
|
|
90
128
|
*
|
|
@@ -98,18 +136,37 @@ export function stripSourceMappingComment(text) {
|
|
|
98
136
|
}
|
|
99
137
|
return { text: kept.join("\n"), stripped: true };
|
|
100
138
|
}
|
|
139
|
+
// Replaces the `src` files entry with only the src subtrees the published surface still points into —
|
|
140
|
+
// a stylesheet export like `./css/*` -> `./src/css/*` ships Tailwind source, so dropping all of src
|
|
141
|
+
// would ship a broken export. Runs after the source conditions are stripped, so the `#*` source lane
|
|
142
|
+
// no longer counts; with nothing left pointing into src the entry is dropped outright.
|
|
101
143
|
function removeSrcFromFiles(manifest) {
|
|
102
144
|
const files = manifest.files;
|
|
103
|
-
if (!Array.isArray(files)) {
|
|
145
|
+
if (!Array.isArray(files) || !files.includes("src")) {
|
|
104
146
|
return false;
|
|
105
147
|
}
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
manifest.files = next;
|
|
148
|
+
const keep = srcPathsShippedBySurface(manifest);
|
|
149
|
+
manifest.files = files.flatMap((entry) => (entry === "src" ? keep : [entry]));
|
|
111
150
|
return true;
|
|
112
151
|
}
|
|
152
|
+
// The src subtrees a surviving `exports`/`imports` target still ships, e.g. `./src/css/*` -> `src/css`.
|
|
153
|
+
function srcPathsShippedBySurface(manifest) {
|
|
154
|
+
const targets = [...collectTargets(manifest.exports), ...collectTargets(manifest.imports)];
|
|
155
|
+
const kept = new Set();
|
|
156
|
+
for (const target of targets) {
|
|
157
|
+
const relative = stripDotSlash(target);
|
|
158
|
+
if (relative !== "src" && !relative.startsWith("src/")) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const segments = relative.split("/");
|
|
162
|
+
// A glob tail (`*`, `**`) ships its directory; a concrete file ships itself.
|
|
163
|
+
if (segments.at(-1)?.includes("*")) {
|
|
164
|
+
segments.pop();
|
|
165
|
+
}
|
|
166
|
+
kept.add(segments.join("/"));
|
|
167
|
+
}
|
|
168
|
+
return [...kept].sort();
|
|
169
|
+
}
|
|
113
170
|
// Walks a conditions tree deleting every `source` key. A subpath key always starts with ".", so only real condition
|
|
114
171
|
// objects match; an `imports` entry this leaves empty is what the unshipped pass removes.
|
|
115
172
|
function deleteSourceConditions(node) {
|