@codefast/cli 0.3.13-canary.0 → 0.3.13-canary.1

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.
Files changed (112) hide show
  1. package/dist/bin.mjs +1 -1
  2. package/dist/commands/arrange.mjs +106 -1
  3. package/dist/commands/mirror.mjs +65 -1
  4. package/dist/commands/tag.mjs +57 -1
  5. package/dist/lib/arrange/application/analyze.mjs +91 -1
  6. package/dist/lib/arrange/application/group-file.mjs +112 -1
  7. package/dist/lib/arrange/application/run-target.mjs +64 -1
  8. package/dist/lib/arrange/domain/ast/ast-helpers.mjs +114 -1
  9. package/dist/lib/arrange/domain/ast/collectors-cn.mjs +60 -1
  10. package/dist/lib/arrange/domain/ast/collectors-jsx.mjs +19 -1
  11. package/dist/lib/arrange/domain/ast/collectors-tv.mjs +169 -1
  12. package/dist/lib/arrange/domain/ast/targets.mjs +105 -1
  13. package/dist/lib/arrange/domain/constants.mjs +168 -1
  14. package/dist/lib/arrange/domain/errors.mjs +18 -1
  15. package/dist/lib/arrange/domain/grouping.mjs +234 -1
  16. package/dist/lib/arrange/domain/imports.mjs +53 -1
  17. package/dist/lib/arrange/domain/tokenizer.mjs +215 -1
  18. package/dist/lib/arrange/index.mjs +14 -15
  19. package/dist/lib/arrange/infra/walk.mjs +32 -1
  20. package/dist/lib/arrange/presentation/formatters.mjs +51 -1
  21. package/dist/lib/arrange/presentation/report.mjs +23 -1
  22. package/dist/lib/config/domain/schema.mjs +24 -1
  23. package/dist/lib/config/index.mjs +2 -3
  24. package/dist/lib/config/infra/loader.mjs +77 -1
  25. package/dist/lib/infra/caught-unknown-message.mjs +19 -1
  26. package/dist/lib/infra/config-reporter.mjs +9 -1
  27. package/dist/lib/infra/node-io.mjs +29 -1
  28. package/dist/lib/infra/workspace/repo-root.mjs +21 -1
  29. package/dist/lib/mirror/application/engine.mjs +247 -1
  30. package/dist/lib/mirror/application/sync.mjs +161 -1
  31. package/dist/lib/mirror/domain/constants.mjs +11 -1
  32. package/dist/lib/mirror/domain/errors.mjs +14 -1
  33. package/dist/lib/mirror/index.mjs +1 -2
  34. package/dist/lib/mirror/infra/dirent-list.mjs +13 -1
  35. package/dist/lib/mirror/infra/package-filter.mjs +25 -1
  36. package/dist/lib/mirror/infra/path-normalizer.mjs +6 -1
  37. package/dist/lib/mirror/infra/update-pkg.mjs +104 -1
  38. package/dist/lib/mirror/infra/workspace-packages.mjs +158 -1
  39. package/dist/lib/mirror/presentation/reporter.mjs +111 -2
  40. package/dist/lib/tag/application/engine.mjs +286 -1
  41. package/dist/lib/tag/index.mjs +3 -4
  42. package/dist/lib/tag/infra/target-resolver.mjs +169 -1
  43. package/dist/lib/tag/presentation/colors.mjs +11 -1
  44. package/dist/lib/tag/presentation/tag-presenter.mjs +62 -1
  45. package/dist/program.mjs +33 -1
  46. package/package.json +2 -2
  47. package/dist/analyze-DvtJ3j9m.mjs +0 -92
  48. package/dist/arrange-Bbh62DrU.mjs +0 -107
  49. package/dist/arrange-BqP2DI3w.mjs +0 -8
  50. package/dist/ast-helpers-MDRYuIAk.mjs +0 -115
  51. package/dist/caught-unknown-message-CRhkDWO7.mjs +0 -20
  52. package/dist/collectors-cn-BS8TTQ8O.mjs +0 -61
  53. package/dist/collectors-jsx-D9tL2ZPM.mjs +0 -20
  54. package/dist/collectors-tv-D2PXZaRt.mjs +0 -170
  55. package/dist/colors-BjdkCfGK.mjs +0 -12
  56. package/dist/commands/mirror.test.mjs +0 -48
  57. package/dist/config-DVia_f9a.mjs +0 -3
  58. package/dist/config-reporter-SCcWDZc1.mjs +0 -10
  59. package/dist/constants-AtPhF-Ct.mjs +0 -169
  60. package/dist/constants-Bq5wdyLC.mjs +0 -8
  61. package/dist/dirent-list-BSDeRG5i.mjs +0 -14
  62. package/dist/engine-CcWEHSCq.mjs +0 -287
  63. package/dist/engine-DRTdkc5u.mjs +0 -236
  64. package/dist/errors-CFH4w6ic.mjs +0 -15
  65. package/dist/errors-CpU1ogfA.mjs +0 -19
  66. package/dist/formatters-DGE8jJ53.mjs +0 -52
  67. package/dist/group-file-ClW7XdD6.mjs +0 -113
  68. package/dist/grouping-c1grpCQT.mjs +0 -235
  69. package/dist/imports-DSVq1xhB.mjs +0 -54
  70. package/dist/lib/arrange/application/analyze.test.mjs +0 -171
  71. package/dist/lib/arrange/application/group-file.test.mjs +0 -273
  72. package/dist/lib/arrange/application/run-target.test.mjs +0 -97
  73. package/dist/lib/arrange/domain/ast/ast-helpers.test.mjs +0 -148
  74. package/dist/lib/arrange/domain/ast/collectors-cn.test.mjs +0 -58
  75. package/dist/lib/arrange/domain/ast/collectors-jsx.test.mjs +0 -20
  76. package/dist/lib/arrange/domain/ast/collectors-tv.test.mjs +0 -145
  77. package/dist/lib/arrange/domain/ast/targets.test.mjs +0 -50
  78. package/dist/lib/arrange/domain/grouping.test.mjs +0 -186
  79. package/dist/lib/arrange/domain/imports.test.mjs +0 -48
  80. package/dist/lib/arrange/domain/tokenizer.test.mjs +0 -165
  81. package/dist/lib/arrange/infra/walk.test.mjs +0 -50
  82. package/dist/lib/arrange/presentation/formatters.test.mjs +0 -73
  83. package/dist/lib/config/infra/loader.test.mjs +0 -116
  84. package/dist/lib/infra/workspace/repo-root.test.mjs +0 -45
  85. package/dist/lib/mirror/application/sync.test.mjs +0 -482
  86. package/dist/lib/mirror/infra/dirent-list.test.mjs +0 -18
  87. package/dist/lib/mirror/infra/package-filter.test.mjs +0 -32
  88. package/dist/lib/mirror/infra/workspace-packages.test.mjs +0 -167
  89. package/dist/lib/tag/application/engine.test.mjs +0 -159
  90. package/dist/lib/tag/presentation/tag-presenter.test.mjs +0 -29
  91. package/dist/loader-DpN-zl5g.mjs +0 -78
  92. package/dist/mirror-CbGiLXKT.mjs +0 -2
  93. package/dist/mirror-DqJE3ejL.mjs +0 -66
  94. package/dist/node-io-DFRbHO6m.mjs +0 -30
  95. package/dist/package-filter-C_8ryqvz.mjs +0 -26
  96. package/dist/path-normalizer-D4ceBO3l.mjs +0 -7
  97. package/dist/program-DR-H4tH3.mjs +0 -34
  98. package/dist/repo-root-HmtIEm6J.mjs +0 -22
  99. package/dist/report-DYxvw34T.mjs +0 -24
  100. package/dist/reporter-CwIe_tAM.mjs +0 -108
  101. package/dist/run-target-CJWrqNT4.mjs +0 -65
  102. package/dist/schema-Or8RAARd.mjs +0 -25
  103. package/dist/sync-e1Sp-shi.mjs +0 -157
  104. package/dist/tag-Cd9JujU5.mjs +0 -2
  105. package/dist/tag-hEKVZ_-7.mjs +0 -58
  106. package/dist/tag-presenter-Cs66UBsH.mjs +0 -63
  107. package/dist/target-resolver-CR3FXMTy.mjs +0 -170
  108. package/dist/targets-pCTslnFh.mjs +0 -106
  109. package/dist/tokenizer-CeZx73Zu.mjs +0 -216
  110. package/dist/update-pkg-CnGfjWBy.mjs +0 -37
  111. package/dist/walk-DjgQn66n.mjs +0 -33
  112. package/dist/workspace-packages-K2NYTHJq.mjs +0 -159
@@ -1,3 +1,2 @@
1
- import { t as runMirrorSync } from "../../sync-e1Sp-shi.mjs";
2
- import "../../mirror-CbGiLXKT.mjs";
1
+ import { runMirrorSync } from "./application/sync.mjs";
3
2
  export { runMirrorSync };
@@ -1,2 +1,14 @@
1
- import { t as isDirentList } from "../../../dirent-list-BSDeRG5i.mjs";
1
+ //#region src/lib/mirror/infra/dirent-list.ts
2
+ /**
3
+ * Narrow `fs.promises.readdir` overload result to `Dirent[]` when `withFileTypes: true`.
4
+ * Accepts both historical checks (`isFile` / `isDirectory`) in one guard.
5
+ * Returning `true` for an empty array is intentional: callers treat empty lists
6
+ * the same regardless of the element type, so `[]` is safely accepted as `Dirent[]`.
7
+ */
8
+ function isDirentList(x) {
9
+ if (x.length === 0) return true;
10
+ const first = x[0];
11
+ return typeof first === "object" && first !== null && "isFile" in first && "isDirectory" in first;
12
+ }
13
+ //#endregion
2
14
  export { isDirentList };
@@ -1,2 +1,26 @@
1
- import { t as resolvePackageFilterUnderRoot } from "../../../package-filter-C_8ryqvz.mjs";
1
+ import { normalizePath } from "./path-normalizer.mjs";
2
+ import { realpathSync } from "node:fs";
3
+ import path from "node:path";
4
+ //#region src/lib/mirror/infra/package-filter.ts
5
+ function tryRealpath(entryPath) {
6
+ try {
7
+ return realpathSync.native(entryPath);
8
+ } catch {
9
+ return path.resolve(entryPath);
10
+ }
11
+ }
12
+ /**
13
+ * Resolve `packageFilter` to a POSIX-ish path relative to `rootDir`, without using
14
+ * `process.cwd()`. Use for programmatic `runMirrorSync` calls.
15
+ *
16
+ * @throws If the resolved path is not a strict subdirectory of `rootDir`.
17
+ */
18
+ function resolvePackageFilterUnderRoot(rootDir, packageFilter) {
19
+ const rootReal = tryRealpath(path.resolve(rootDir));
20
+ const resolved = path.isAbsolute(packageFilter) ? tryRealpath(path.resolve(packageFilter)) : tryRealpath(path.join(rootReal, packageFilter));
21
+ const normalized = normalizePath(path.relative(rootReal, resolved));
22
+ if (normalized.startsWith("..") || path.isAbsolute(normalized) || normalized === "" || normalized === ".") throw new Error(`Package path must be a subdirectory under monorepo root: ${rootDir}`);
23
+ return normalized;
24
+ }
25
+ //#endregion
2
26
  export { resolvePackageFilterUnderRoot };
@@ -1,2 +1,7 @@
1
- import { t as normalizePath } from "../../../path-normalizer-D4ceBO3l.mjs";
1
+ import path from "node:path";
2
+ //#region src/lib/mirror/infra/path-normalizer.ts
3
+ function normalizePath(pathString) {
4
+ return pathString.split(path.sep).join("/").replace(/\\/g, "/");
5
+ }
6
+ //#endregion
2
7
  export { normalizePath };
@@ -1,2 +1,105 @@
1
- import { n as resolvePackageDisplayName, r as writePackageJsonExportsAtomic, t as readPackageJsonDisplayName } from "../../../update-pkg-CnGfjWBy.mjs";
1
+ import { messageFromCaughtUnknown } from "../../infra/caught-unknown-message.mjs";
2
+ import { PACKAGE_JSON_EXPORT } from "../domain/constants.mjs";
3
+ import { MirrorError, MirrorErrorCode } from "../domain/errors.mjs";
4
+ //#region src/lib/mirror/infra/update-pkg.ts
5
+ function containsDistTarget(value) {
6
+ if (typeof value === "string") return value.startsWith("./dist/");
7
+ if (Array.isArray(value)) return value.some((entryValue) => containsDistTarget(entryValue));
8
+ if (value && typeof value === "object") return Object.values(value).some((entryValue) => containsDistTarget(entryValue));
9
+ return false;
10
+ }
11
+ /**
12
+ * Keep `./package.json` at the very end for aesthetics by default.
13
+ * If a catch-all `./*` exists, move `./package.json` before wildcards so it remains reachable.
14
+ */
15
+ function exportSpecifierRank(exportSpecifier, hasCatchAllWildcard) {
16
+ if (exportSpecifier === ".") return 0;
17
+ if (exportSpecifier === "./package.json") return hasCatchAllWildcard ? 2 : 4;
18
+ if (exportSpecifier.includes("*")) return 3;
19
+ return 1;
20
+ }
21
+ function compareExportSpecifiers(leftSpecifier, rightSpecifier, originalPathBySpecifier, hasCatchAllWildcard) {
22
+ const leftRank = exportSpecifierRank(leftSpecifier, hasCatchAllWildcard);
23
+ const rightRank = exportSpecifierRank(rightSpecifier, hasCatchAllWildcard);
24
+ if (leftRank !== rightRank) return leftRank - rightRank;
25
+ const leftOriginalPath = originalPathBySpecifier[leftSpecifier] ?? leftSpecifier;
26
+ const rightOriginalPath = originalPathBySpecifier[rightSpecifier] ?? rightSpecifier;
27
+ const originalPathComparison = leftOriginalPath.localeCompare(rightOriginalPath);
28
+ if (originalPathComparison !== 0) return originalPathComparison;
29
+ return leftSpecifier.localeCompare(rightSpecifier);
30
+ }
31
+ /** Shared rule: show `package.json#name` when it is a non-empty string; else folder basename. */
32
+ function resolvePackageDisplayName(packageJson, folderBasename) {
33
+ const declaredName = packageJson.name;
34
+ return typeof declaredName === "string" && declaredName.length > 0 ? declaredName : folderBasename;
35
+ }
36
+ async function readPackageJsonDisplayName(fs, packageJsonPath, folderBasename) {
37
+ if (!fs.existsSync(packageJsonPath)) return folderBasename;
38
+ try {
39
+ const raw = await fs.readFile(packageJsonPath, "utf8");
40
+ return resolvePackageDisplayName(JSON.parse(raw), folderBasename);
41
+ } catch {
42
+ return folderBasename;
43
+ }
44
+ }
45
+ /**
46
+ * Writes `exports` into `package.json` via a temp file + rename (atomic on same volume).
47
+ * Preserves a trailing newline after JSON.
48
+ */
49
+ async function writePackageJsonExportsAtomic(fs, packageJsonPath, mergeInput) {
50
+ const raw = await fs.readFile(packageJsonPath, "utf8");
51
+ const packageJson = JSON.parse(raw);
52
+ const existingExports = packageJson.exports;
53
+ const existingExportMap = existingExports && typeof existingExports === "object" && !Array.isArray(existingExports) ? existingExports : {};
54
+ const managedSpecifiers = new Set(mergeInput.managedExportSpecifiers);
55
+ const originalPathBySpecifier = { ...mergeInput.originalPathBySpecifier };
56
+ const mergedExportMap = {};
57
+ const prunedKeys = [];
58
+ for (const [exportSpecifier, exportValue] of Object.entries(existingExportMap)) {
59
+ if (exportSpecifier === "./package.json") {
60
+ mergedExportMap[exportSpecifier] = exportValue;
61
+ if (!(exportSpecifier in originalPathBySpecifier)) originalPathBySpecifier[exportSpecifier] = exportSpecifier;
62
+ continue;
63
+ }
64
+ if (!managedSpecifiers.has(exportSpecifier)) if (containsDistTarget(exportValue)) prunedKeys.push(exportSpecifier);
65
+ else {
66
+ mergedExportMap[exportSpecifier] = exportValue;
67
+ if (!(exportSpecifier in originalPathBySpecifier)) originalPathBySpecifier[exportSpecifier] = exportSpecifier;
68
+ }
69
+ }
70
+ for (const [exportSpecifier, exportValue] of Object.entries(mergeInput.generatedExports)) mergedExportMap[exportSpecifier] = exportValue;
71
+ if (!("./package.json" in mergedExportMap)) mergedExportMap[PACKAGE_JSON_EXPORT] = PACKAGE_JSON_EXPORT;
72
+ originalPathBySpecifier[PACKAGE_JSON_EXPORT] = PACKAGE_JSON_EXPORT;
73
+ const rootExport = mergedExportMap["."];
74
+ if (rootExport && typeof rootExport === "object" && !Array.isArray(rootExport)) {
75
+ const rootEntry = rootExport;
76
+ const requirePath = typeof rootEntry.require === "string" ? rootEntry.require : void 0;
77
+ const importPath = typeof rootEntry.import === "string" ? rootEntry.import : void 0;
78
+ const typesPath = typeof rootEntry.types === "string" ? rootEntry.types : void 0;
79
+ if (requirePath || importPath) packageJson.main = requirePath ?? importPath;
80
+ if (importPath && importPath.endsWith(".mjs")) packageJson.module = importPath;
81
+ if (typesPath) packageJson.types = typesPath;
82
+ }
83
+ const filesField = packageJson.files;
84
+ if (Array.isArray(filesField)) {
85
+ const normalizedFiles = filesField.filter((entry) => typeof entry === "string");
86
+ if (!normalizedFiles.includes("dist")) normalizedFiles.push("dist");
87
+ packageJson.files = normalizedFiles;
88
+ } else packageJson.files = ["dist"];
89
+ const sortedExportMap = {};
90
+ const hasCatchAllWildcard = "./*" in mergedExportMap;
91
+ for (const exportSpecifier of Object.keys(mergedExportMap).sort((leftSpecifier, rightSpecifier) => compareExportSpecifiers(leftSpecifier, rightSpecifier, originalPathBySpecifier, hasCatchAllWildcard))) sortedExportMap[exportSpecifier] = mergedExportMap[exportSpecifier];
92
+ packageJson.exports = sortedExportMap;
93
+ const serialized = JSON.stringify(packageJson, null, 2) + "\n";
94
+ const tmpPath = `${packageJsonPath}.tmp`;
95
+ await fs.writeFile(tmpPath, serialized, "utf8");
96
+ try {
97
+ await fs.rename(tmpPath, packageJsonPath);
98
+ } catch (caughtRenameError) {
99
+ await fs.unlink(tmpPath).catch(() => {});
100
+ throw new MirrorError(MirrorErrorCode.PACKAGE_WRITE, `Failed to atomically update ${packageJsonPath}: ${messageFromCaughtUnknown(caughtRenameError)}`, caughtRenameError instanceof Error ? { cause: caughtRenameError } : void 0);
101
+ }
102
+ return { prunedKeys };
103
+ }
104
+ //#endregion
2
105
  export { readPackageJsonDisplayName, resolvePackageDisplayName, writePackageJsonExportsAtomic };
@@ -1,2 +1,159 @@
1
- import { i as workspacePatternToPackageJsonGlob, n as parsePnpmWorkspaceDocument, r as splitWorkspacePackageEntries, t as findWorkspacePackageRelPaths } from "../../../workspace-packages-K2NYTHJq.mjs";
1
+ import { messageFromCaughtUnknown } from "../../infra/caught-unknown-message.mjs";
2
+ import { normalizePath } from "./path-normalizer.mjs";
3
+ import { mirrorGlobWarning } from "../presentation/reporter.mjs";
4
+ import { globSync } from "node:fs";
5
+ import path from "node:path";
6
+ import picomatch from "picomatch";
7
+ import { parse } from "yaml";
8
+ //#region src/lib/mirror/infra/workspace-packages.ts
9
+ const PNPM_WORKSPACE = "pnpm-workspace.yaml";
10
+ /** Default when the workspace file is missing or has no `packages` key. */
11
+ const DEFAULT_INCLUDE = ["packages/*"];
12
+ function toPosix(filePath) {
13
+ return filePath.split(path.sep).join("/");
14
+ }
15
+ function isGlobPermissionError(caughtError) {
16
+ if (typeof caughtError !== "object" || caughtError === null || !("code" in caughtError)) return false;
17
+ const code = caughtError.code;
18
+ return code === "EACCES" || code === "EPERM";
19
+ }
20
+ /** Turn a pnpm `packages` glob into a `globSync` pattern that finds `package.json` files. */
21
+ function workspacePatternToPackageJsonGlob(pattern) {
22
+ const normalizedPattern = toPosix(pattern.trim()).replace(/\/+$/, "");
23
+ if (!normalizedPattern) return "**/package.json";
24
+ return `${normalizedPattern}/package.json`;
25
+ }
26
+ function splitWorkspacePackageEntries(raw) {
27
+ const include = [];
28
+ const exclude = [];
29
+ if (!Array.isArray(raw)) return {
30
+ include,
31
+ exclude
32
+ };
33
+ for (const entry of raw) {
34
+ if (typeof entry !== "string") continue;
35
+ const trimmed = entry.trim();
36
+ if (!trimmed) continue;
37
+ if (trimmed.startsWith("!")) exclude.push(trimmed.slice(1).trim());
38
+ else include.push(trimmed);
39
+ }
40
+ return {
41
+ include,
42
+ exclude
43
+ };
44
+ }
45
+ /**
46
+ * Reads `packages` from a parsed pnpm workspace document.
47
+ * @throws If the document is invalid or `packages` is present but not an array.
48
+ */
49
+ function parsePnpmWorkspaceDocument(doc) {
50
+ if (doc === null || doc === void 0) throw new Error(`${PNPM_WORKSPACE} root document must be an object (got empty or null)`);
51
+ if (typeof doc !== "object" || Array.isArray(doc)) throw new Error(`${PNPM_WORKSPACE} root must be a mapping, not an array or scalar`);
52
+ const parsedDoc = doc;
53
+ if (!Object.prototype.hasOwnProperty.call(parsedDoc, "packages")) return {
54
+ include: [],
55
+ exclude: [],
56
+ hasPackagesKey: false,
57
+ isEmptyPackagesArray: false
58
+ };
59
+ const pkgs = parsedDoc.packages;
60
+ if (!Array.isArray(pkgs)) throw new Error(`${PNPM_WORKSPACE} field "packages" must be an array`);
61
+ if (pkgs.length === 0) return {
62
+ include: [],
63
+ exclude: [],
64
+ hasPackagesKey: true,
65
+ isEmptyPackagesArray: true
66
+ };
67
+ return {
68
+ ...splitWorkspacePackageEntries(pkgs),
69
+ hasPackagesKey: true,
70
+ isEmptyPackagesArray: false
71
+ };
72
+ }
73
+ async function readWorkspaceYaml(rootDir, fs) {
74
+ const workspaceYamlPath = path.join(rootDir, PNPM_WORKSPACE);
75
+ if (!fs.existsSync(workspaceYamlPath)) return { exists: false };
76
+ let raw;
77
+ try {
78
+ raw = await fs.readFile(workspaceYamlPath, "utf8");
79
+ } catch (caughtReadError) {
80
+ throw new Error(`Failed to read ${PNPM_WORKSPACE}: ${messageFromCaughtUnknown(caughtReadError)}`);
81
+ }
82
+ let doc;
83
+ try {
84
+ doc = parse(raw);
85
+ } catch (caughtYamlParseError) {
86
+ throw new Error(`Failed to parse ${PNPM_WORKSPACE}: ${messageFromCaughtUnknown(caughtYamlParseError)}`);
87
+ }
88
+ if (doc === null || doc === void 0) throw new Error(`${PNPM_WORKSPACE} must define a mapping at the document root`);
89
+ return {
90
+ exists: true,
91
+ doc
92
+ };
93
+ }
94
+ /**
95
+ * Workspace package directories relative to `rootDir` (POSIX slashes), sorted.
96
+ * Reads `pnpm-workspace.yaml` when present; otherwise uses `packages/*`.
97
+ * Only paths with a `package.json` are returned (same practical rule as pnpm).
98
+ */
99
+ async function findWorkspacePackageRelPaths(rootDir, fs, logger) {
100
+ const workspaceYaml = await readWorkspaceYaml(rootDir, fs);
101
+ let include;
102
+ let exclude;
103
+ let multiSource;
104
+ if (!workspaceYaml.exists) {
105
+ include = [...DEFAULT_INCLUDE];
106
+ exclude = [];
107
+ multiSource = "default-patterns";
108
+ } else {
109
+ const parsed = parsePnpmWorkspaceDocument(workspaceYaml.doc);
110
+ if (!parsed.hasPackagesKey) {
111
+ include = [...DEFAULT_INCLUDE];
112
+ exclude = [];
113
+ multiSource = "default-patterns";
114
+ } else if (parsed.isEmptyPackagesArray) return {
115
+ relPaths: [],
116
+ multiSource: "declared-empty"
117
+ };
118
+ else {
119
+ include = parsed.include;
120
+ exclude = parsed.exclude;
121
+ multiSource = "pnpm-workspace-yaml";
122
+ }
123
+ }
124
+ const found = /* @__PURE__ */ new Set();
125
+ const globOpts = {
126
+ cwd: rootDir,
127
+ posix: true,
128
+ ...path.sep === "\\" ? { windowsPathsNoEscape: true } : {}
129
+ };
130
+ for (const pattern of include) {
131
+ const globPat = workspacePatternToPackageJsonGlob(pattern);
132
+ let matches;
133
+ try {
134
+ matches = globSync(globPat, globOpts);
135
+ } catch (caughtGlobError) {
136
+ if (isGlobPermissionError(caughtGlobError)) {
137
+ mirrorGlobWarning(logger, `Skipping workspace glob "${pattern}" (${messageFromCaughtUnknown(caughtGlobError)})`);
138
+ continue;
139
+ }
140
+ throw new Error(`Invalid workspace glob "${pattern}": ${messageFromCaughtUnknown(caughtGlobError)}`);
141
+ }
142
+ for (const matchedPath of matches) {
143
+ const posix = toPosix(matchedPath);
144
+ if (!posix.endsWith("/package.json")) continue;
145
+ const rel = posix.slice(0, -13);
146
+ if (!rel) continue;
147
+ found.add(normalizePath(rel));
148
+ }
149
+ }
150
+ const excludeMatchers = exclude.map((pat) => picomatch(pat, { dot: true }));
151
+ const relPaths = [...found].filter((rel) => !excludeMatchers.some((isMatch) => isMatch(rel)));
152
+ relPaths.sort((a, b) => a.localeCompare(b));
153
+ return {
154
+ relPaths,
155
+ multiSource
156
+ };
157
+ }
158
+ //#endregion
2
159
  export { findWorkspacePackageRelPaths, parsePnpmWorkspaceDocument, splitWorkspacePackageEntries, workspacePatternToPackageJsonGlob };
@@ -1,2 +1,111 @@
1
- import { a as mirrorBanner, c as mirrorNoPackages, d as mirrorSummarySeparator, f as printMirrorConfigWarnings, i as logSkippedWorkspacePackage, l as mirrorProcessingMode, n as logPackageError, o as mirrorFatalError, r as logPackageSuccess, s as mirrorGlobWarning, t as configureMirrorColors, u as mirrorSummary } from "../../../reporter-CwIe_tAM.mjs";
2
- export { configureMirrorColors, logPackageError, logPackageSuccess, logSkippedWorkspacePackage, mirrorBanner, mirrorFatalError, mirrorGlobWarning, mirrorNoPackages, mirrorProcessingMode, mirrorSummary, mirrorSummarySeparator, printMirrorConfigWarnings };
1
+ import { messageFromCaughtUnknown } from "../../infra/caught-unknown-message.mjs";
2
+ import { printConfigSchemaWarnings } from "../../infra/config-reporter.mjs";
3
+ import process from "node:process";
4
+ //#region src/lib/mirror/presentation/reporter.ts
5
+ const Colors = {
6
+ RESET: "\x1B[0m",
7
+ BOLD: "\x1B[1m",
8
+ DIM: "\x1B[2m",
9
+ GREEN: "\x1B[32m",
10
+ YELLOW: "\x1B[33m",
11
+ CYAN: "\x1B[36m",
12
+ GRAY: "\x1B[90m",
13
+ MAGENTA: "\x1B[35m",
14
+ BRIGHT_GREEN: "\x1B[92m",
15
+ BRIGHT_YELLOW: "\x1B[93m",
16
+ BRIGHT_CYAN: "\x1B[96m",
17
+ disable() {
18
+ for (const key of Object.keys(this)) if (typeof this[key] === "string") this[key] = "";
19
+ }
20
+ };
21
+ function configureMirrorColors(noColor) {
22
+ if (!process.stdout.isTTY || noColor) Colors.disable();
23
+ }
24
+ function printMirrorConfigWarnings(logger, warnings) {
25
+ printConfigSchemaWarnings(logger, warnings);
26
+ }
27
+ function mirrorGlobWarning(logger, message) {
28
+ const { out } = logger;
29
+ out(`${Colors.YELLOW}⚠ ${message}${Colors.RESET}`);
30
+ }
31
+ function logSkippedWorkspacePackage(logger, index, total, displayName, reason) {
32
+ const { out } = logger;
33
+ out(`${`${Colors.DIM}[${index}/${total}]${Colors.RESET}`} ${Colors.GRAY}○${Colors.RESET} ${Colors.DIM}${displayName}${Colors.RESET}`);
34
+ out(` ${Colors.DIM}└─${Colors.RESET} ${Colors.GRAY}Skipped: ${reason}${Colors.RESET}`);
35
+ out("");
36
+ }
37
+ function mirrorBanner(logger) {
38
+ const { out } = logger;
39
+ out(`\n${Colors.BOLD}${Colors.CYAN}📦 Mirror — package exports${Colors.RESET}`);
40
+ out(`${Colors.DIM}${"═".repeat(60)}${Colors.RESET}\n`);
41
+ }
42
+ function mirrorProcessingMode(logger, mode) {
43
+ const { out } = logger;
44
+ if (mode.kind === "single") {
45
+ out(`${Colors.DIM}Processing single package...${Colors.RESET}\n`);
46
+ return;
47
+ }
48
+ switch (mode.source) {
49
+ case "default-patterns":
50
+ out(`${Colors.DIM}Discovering workspace packages using default patterns (packages/*)…${Colors.RESET}\n`);
51
+ break;
52
+ case "pnpm-workspace-yaml":
53
+ out(`${Colors.DIM}Discovering workspace packages from pnpm-workspace.yaml…${Colors.RESET}\n`);
54
+ break;
55
+ case "declared-empty":
56
+ out(`${Colors.DIM}pnpm-workspace.yaml declares an empty workspace package list.${Colors.RESET}\n`);
57
+ break;
58
+ }
59
+ }
60
+ function mirrorNoPackages(logger) {
61
+ logger.out(`${Colors.YELLOW}⚠ No packages found${Colors.RESET}`);
62
+ }
63
+ function logPackageSuccess(logger, index, total, pkgStats, generatedDistAssetCounts, verbose) {
64
+ const { out } = logger;
65
+ out(`${`${Colors.DIM}[${index}/${total}]${Colors.RESET}`} ${Colors.BRIGHT_GREEN}✓${Colors.RESET} ${Colors.BOLD}${pkgStats.name}${Colors.RESET}`);
66
+ if (verbose) {
67
+ out(` ${Colors.DIM}├─${Colors.RESET} Path: ${pkgStats.path}`);
68
+ if (pkgStats.hasTransform) out(` ${Colors.DIM}├─${Colors.RESET} ${Colors.CYAN}Custom path transformation${Colors.RESET}`);
69
+ if (pkgStats.cssConfigStatus) out(` ${Colors.DIM}├─${Colors.RESET} ${Colors.CYAN}${pkgStats.cssConfigStatus === "disabled" ? "CSS disabled" : "CSS configured"}${Colors.RESET}`);
70
+ }
71
+ const breakdown = [];
72
+ if (generatedDistAssetCounts.jsCount > 0) breakdown.push(`${Colors.GREEN}${generatedDistAssetCounts.jsCount} modules${Colors.RESET}`);
73
+ if (generatedDistAssetCounts.cssCount > 0) breakdown.push(`${Colors.MAGENTA}${generatedDistAssetCounts.cssCount} CSS${Colors.RESET}`);
74
+ if (pkgStats.customExports > 0) breakdown.push(`${Colors.YELLOW}${pkgStats.customExports} custom${Colors.RESET}`);
75
+ if (breakdown.length > 0) out(` ${Colors.DIM}└─${Colors.RESET} ${breakdown.join(" + ")} = ${Colors.BRIGHT_CYAN}${pkgStats.totalExports} exports${Colors.RESET}`);
76
+ else out(` ${Colors.DIM}└─${Colors.RESET} ${Colors.BRIGHT_CYAN}${pkgStats.totalExports} exports${Colors.RESET}`);
77
+ out("");
78
+ }
79
+ function logPrunedStaleExport(logger, exportSpecifier) {
80
+ logger.out(` ${Colors.DIM}└─${Colors.RESET} ${Colors.GRAY}Pruned stale export: ${exportSpecifier}${Colors.RESET}`);
81
+ }
82
+ function logPackageError(logger, index, total, displayName, errValue, verbose) {
83
+ const { out, err: errLine } = logger;
84
+ out(`${Colors.DIM}[${index}/${total}]${Colors.RESET} ${Colors.YELLOW}✗${Colors.RESET} ${Colors.BOLD}${displayName}${Colors.RESET}`);
85
+ out(` ${Colors.DIM}└─${Colors.RESET} ${Colors.YELLOW}Error: ${messageFromCaughtUnknown(errValue)}${Colors.RESET}\n`);
86
+ if (verbose) errLine(errValue instanceof Error && errValue.stack ? errValue.stack : messageFromCaughtUnknown(errValue));
87
+ }
88
+ function mirrorSummarySeparator(logger) {
89
+ logger.out(`${Colors.DIM}${"═".repeat(60)}${Colors.RESET}`);
90
+ }
91
+ function mirrorSummary(logger, stats, elapsedSeconds) {
92
+ const { out } = logger;
93
+ out(`${Colors.BOLD}📊 Summary${Colors.RESET} ${Colors.DIM}(completed in ${elapsedSeconds.toFixed(2)}s)${Colors.RESET}\n`);
94
+ out(` ${Colors.BOLD}Packages:${Colors.RESET}`);
95
+ out(` ${Colors.DIM}├─${Colors.RESET} Processed: ${Colors.GREEN}${stats.packagesProcessed}${Colors.RESET}`);
96
+ if (stats.packagesSkipped > 0) out(` ${Colors.DIM}├─${Colors.RESET} Skipped: ${Colors.GRAY}${stats.packagesSkipped}${Colors.RESET}`);
97
+ if (stats.packagesErrored > 0) out(` ${Colors.DIM}├─${Colors.RESET} Errors: ${Colors.YELLOW}${stats.packagesErrored}${Colors.RESET}`);
98
+ out(` ${Colors.DIM}└─${Colors.RESET} Total found: ${stats.packagesFound}\n`);
99
+ out(` ${Colors.BOLD}Exports:${Colors.RESET}`);
100
+ out(` ${Colors.DIM}├─${Colors.RESET} JS Modules: ${Colors.CYAN}${stats.totalJsModules}${Colors.RESET}`);
101
+ out(` ${Colors.DIM}├─${Colors.RESET} CSS Files: ${Colors.MAGENTA}${stats.totalCssExports}${Colors.RESET}`);
102
+ out(` ${Colors.DIM}└─${Colors.RESET} Total: ${Colors.BRIGHT_CYAN}${stats.totalExports}${Colors.RESET}\n`);
103
+ out(`${Colors.DIM}${"═".repeat(60)}${Colors.RESET}\n`);
104
+ }
105
+ function mirrorFatalError(logger, caughtError) {
106
+ const { out, err: errLine } = logger;
107
+ out(`${Colors.YELLOW}Fatal error: ${messageFromCaughtUnknown(caughtError)}${Colors.RESET}`);
108
+ errLine(caughtError instanceof Error && caughtError.stack ? caughtError.stack : messageFromCaughtUnknown(caughtError));
109
+ }
110
+ //#endregion
111
+ export { configureMirrorColors, logPackageError, logPackageSuccess, logPrunedStaleExport, logSkippedWorkspacePackage, mirrorBanner, mirrorFatalError, mirrorGlobWarning, mirrorNoPackages, mirrorProcessingMode, mirrorSummary, mirrorSummarySeparator, printMirrorConfigWarnings };