@codefast/cli 0.5.0-canary.5 → 0.5.0-canary.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +106 -480
- package/dist/arrange/analyze.js +25 -0
- package/dist/arrange/analyze.js.map +1 -0
- package/dist/arrange/cli-schema.js +29 -0
- package/dist/arrange/cli-schema.js.map +1 -0
- package/dist/arrange/command.js +170 -0
- package/dist/arrange/command.js.map +1 -0
- package/dist/arrange/domain/analyze-service.js +122 -0
- package/dist/arrange/domain/analyze-service.js.map +1 -0
- package/dist/arrange/domain/ast/ast-node.js +240 -0
- package/dist/arrange/domain/ast/ast-node.js.map +1 -0
- package/dist/arrange/domain/ast/collectors-cn.js +81 -0
- package/dist/arrange/domain/ast/collectors-cn.js.map +1 -0
- package/dist/arrange/domain/ast/collectors-jsx.js +24 -0
- package/dist/arrange/domain/ast/collectors-jsx.js.map +1 -0
- package/dist/arrange/domain/ast/collectors-tv.js +319 -0
- package/dist/arrange/domain/ast/collectors-tv.js.map +1 -0
- package/dist/arrange/domain/ast/helpers.js +151 -0
- package/dist/arrange/domain/ast/helpers.js.map +1 -0
- package/dist/arrange/domain/ast/simplify-targets.js +161 -0
- package/dist/arrange/domain/ast/simplify-targets.js.map +1 -0
- package/dist/arrange/domain/ast/targets.js +182 -0
- package/dist/arrange/domain/ast/targets.js.map +1 -0
- package/dist/arrange/domain/constants.js +225 -0
- package/dist/arrange/domain/constants.js.map +1 -0
- package/dist/arrange/domain/grouping-service.js +128 -0
- package/dist/arrange/domain/grouping-service.js.map +1 -0
- package/dist/arrange/domain/grouping.js +435 -0
- package/dist/arrange/domain/grouping.js.map +1 -0
- package/dist/arrange/domain/imports.js +160 -0
- package/dist/arrange/domain/imports.js.map +1 -0
- package/dist/arrange/domain/source-text-formatters.js +100 -0
- package/dist/arrange/domain/source-text-formatters.js.map +1 -0
- package/dist/arrange/domain/tailwind-token.js +50 -0
- package/dist/arrange/domain/tailwind-token.js.map +1 -0
- package/dist/arrange/domain/token-classifier.js +448 -0
- package/dist/arrange/domain/token-classifier.js.map +1 -0
- package/dist/arrange/domain/types.js +11 -0
- package/dist/arrange/domain/types.js.map +1 -0
- package/dist/arrange/output.js +120 -0
- package/dist/arrange/output.js.map +1 -0
- package/dist/arrange/process-file.js +44 -0
- package/dist/arrange/process-file.js.map +1 -0
- package/dist/arrange/resolve-target.js +33 -0
- package/dist/arrange/resolve-target.js.map +1 -0
- package/dist/arrange/scan-target.js +30 -0
- package/dist/arrange/scan-target.js.map +1 -0
- package/dist/arrange/simplify-process-file.js +29 -0
- package/dist/arrange/simplify-process-file.js.map +1 -0
- package/dist/arrange/simplify-sync.js +29 -0
- package/dist/arrange/simplify-sync.js.map +1 -0
- package/dist/arrange/source-parse.js +17 -0
- package/dist/arrange/source-parse.js.map +1 -0
- package/dist/arrange/suggest.js +14 -0
- package/dist/arrange/suggest.js.map +1 -0
- package/dist/arrange/sync.js +48 -0
- package/dist/arrange/sync.js.map +1 -0
- package/dist/arrange/typescript-ast-translator.js +455 -0
- package/dist/arrange/typescript-ast-translator.js.map +1 -0
- package/dist/arrange/workspace.js +31 -0
- package/dist/arrange/workspace.js.map +1 -0
- package/dist/audit/cli-schema.js +22 -0
- package/dist/audit/cli-schema.js.map +1 -0
- package/dist/audit/command.js +60 -0
- package/dist/audit/command.js.map +1 -0
- package/dist/audit/domain/audit-file.js +101 -0
- package/dist/audit/domain/audit-file.js.map +1 -0
- package/dist/audit/domain/mappings.js +103 -0
- package/dist/audit/domain/mappings.js.map +1 -0
- package/dist/audit/domain/tokenize.js +83 -0
- package/dist/audit/domain/tokenize.js.map +1 -0
- package/dist/audit/domain/types.js +2 -0
- package/dist/audit/domain/types.js.map +1 -0
- package/dist/audit/output.js +44 -0
- package/dist/audit/output.js.map +1 -0
- package/dist/audit/prepare.js +42 -0
- package/dist/audit/prepare.js.map +1 -0
- package/dist/audit/run.js +57 -0
- package/dist/audit/run.js.map +1 -0
- package/dist/{bin.mjs → bin.js} +2 -4
- package/dist/bin.js.map +1 -0
- package/dist/cli.js +45 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/cli/format-error.js +19 -0
- package/dist/core/cli/format-error.js.map +1 -0
- package/dist/core/cli/global-options.js +10 -0
- package/dist/core/cli/global-options.js.map +1 -0
- package/dist/core/cli/positional.js +9 -0
- package/dist/core/cli/positional.js.map +1 -0
- package/dist/core/cli/result-handle.js +69 -0
- package/dist/core/cli/result-handle.js.map +1 -0
- package/dist/core/config/loader.js +88 -0
- package/dist/core/config/loader.js.map +1 -0
- package/dist/core/config/schema.js +97 -0
- package/dist/core/config/schema.js.map +1 -0
- package/dist/core/config/warnings.js +12 -0
- package/dist/core/config/warnings.js.map +1 -0
- package/dist/core/config.js +18 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/errors.js +58 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/exit-codes.js +15 -0
- package/dist/core/exit-codes.js.map +1 -0
- package/dist/core/filesystem/node.js +33 -0
- package/dist/core/filesystem/node.js.map +1 -0
- package/dist/core/filesystem/port.js +2 -0
- package/dist/core/filesystem/port.js.map +1 -0
- package/dist/core/glob.js +20 -0
- package/dist/core/glob.js.map +1 -0
- package/dist/core/logger.js +13 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/result.js +16 -0
- package/dist/core/result.js.map +1 -0
- package/dist/core/schema-parse.js +21 -0
- package/dist/core/schema-parse.js.map +1 -0
- package/dist/core/source-text-edit.js +62 -0
- package/dist/core/source-text-edit.js.map +1 -0
- package/dist/core/verbose-diagnostics.js +9 -0
- package/dist/core/verbose-diagnostics.js.map +1 -0
- package/dist/core/workspace/resolver.js +208 -0
- package/dist/core/workspace/resolver.js.map +1 -0
- package/dist/core/workspace/typescript-walk.js +41 -0
- package/dist/core/workspace/typescript-walk.js.map +1 -0
- package/dist/mirror/cli-result.js +20 -0
- package/dist/mirror/cli-result.js.map +1 -0
- package/dist/mirror/cli-schema.js +11 -0
- package/dist/mirror/cli-schema.js.map +1 -0
- package/dist/mirror/command.js +73 -0
- package/dist/mirror/command.js.map +1 -0
- package/dist/mirror/dist-filesystem-impl.js +53 -0
- package/dist/mirror/dist-filesystem-impl.js.map +1 -0
- package/dist/mirror/domain/constants.js +21 -0
- package/dist/mirror/domain/constants.js.map +1 -0
- package/dist/mirror/domain/dirent-guard.js +16 -0
- package/dist/mirror/domain/dirent-guard.js.map +1 -0
- package/dist/mirror/domain/dist-filesystem.js +2 -0
- package/dist/mirror/domain/dist-filesystem.js.map +1 -0
- package/dist/mirror/domain/errors.js +19 -0
- package/dist/mirror/domain/errors.js.map +1 -0
- package/dist/mirror/domain/exports.js +284 -0
- package/dist/mirror/domain/exports.js.map +1 -0
- package/dist/mirror/domain/package-display-name.js +10 -0
- package/dist/mirror/domain/package-display-name.js.map +1 -0
- package/dist/mirror/domain/path-normalizer.js +8 -0
- package/dist/mirror/domain/path-normalizer.js.map +1 -0
- package/dist/mirror/domain/types.js +2 -0
- package/dist/mirror/domain/types.js.map +1 -0
- package/dist/mirror/output.js +47 -0
- package/dist/mirror/output.js.map +1 -0
- package/dist/mirror/package-path.js +40 -0
- package/dist/mirror/package-path.js.map +1 -0
- package/dist/mirror/prepare.js +37 -0
- package/dist/mirror/prepare.js.map +1 -0
- package/dist/mirror/supplement-exports.js +157 -0
- package/dist/mirror/supplement-exports.js.map +1 -0
- package/dist/mirror/sync-reporter.js +125 -0
- package/dist/mirror/sync-reporter.js.map +1 -0
- package/dist/mirror/sync-types.js +2 -0
- package/dist/mirror/sync-types.js.map +1 -0
- package/dist/mirror/sync-workspace-package.js +117 -0
- package/dist/mirror/sync-workspace-package.js.map +1 -0
- package/dist/mirror/sync.js +90 -0
- package/dist/mirror/sync.js.map +1 -0
- package/dist/mirror/write-exports.js +145 -0
- package/dist/mirror/write-exports.js.map +1 -0
- package/dist/tag/cli-result.js +12 -0
- package/dist/tag/cli-result.js.map +1 -0
- package/dist/tag/cli-schema.js +13 -0
- package/dist/tag/cli-schema.js.map +1 -0
- package/dist/tag/command.js +69 -0
- package/dist/tag/command.js.map +1 -0
- package/dist/tag/domain/types.js +2 -0
- package/dist/tag/domain/types.js.map +1 -0
- package/dist/tag/output.js +101 -0
- package/dist/tag/output.js.map +1 -0
- package/dist/tag/prepare.js +30 -0
- package/dist/tag/prepare.js.map +1 -0
- package/dist/tag/resolve-target-path.js +14 -0
- package/dist/tag/resolve-target-path.js.map +1 -0
- package/dist/tag/since-writer.js +231 -0
- package/dist/tag/since-writer.js.map +1 -0
- package/dist/tag/sync.js +166 -0
- package/dist/tag/sync.js.map +1 -0
- package/dist/tag/target-candidates.js +79 -0
- package/dist/tag/target-candidates.js.map +1 -0
- package/dist/tag/target-runner.js +25 -0
- package/dist/tag/target-runner.js.map +1 -0
- package/dist/tag/version-resolver.js +28 -0
- package/dist/tag/version-resolver.js.map +1 -0
- package/package.json +25 -20
- package/dist/arrange/analyze.mjs +0 -24
- package/dist/arrange/cli-schema.mjs +0 -27
- package/dist/arrange/command.mjs +0 -130
- package/dist/arrange/domain/analyze-service.mjs +0 -102
- package/dist/arrange/domain/ast/ast-node.mjs +0 -215
- package/dist/arrange/domain/ast/collectors-cn.mjs +0 -64
- package/dist/arrange/domain/ast/collectors-jsx.mjs +0 -23
- package/dist/arrange/domain/ast/collectors-tv.mjs +0 -189
- package/dist/arrange/domain/ast/helpers.mjs +0 -108
- package/dist/arrange/domain/ast/simplify-targets.mjs +0 -109
- package/dist/arrange/domain/ast/targets.mjs +0 -134
- package/dist/arrange/domain/constants.mjs +0 -213
- package/dist/arrange/domain/grouping-service.mjs +0 -121
- package/dist/arrange/domain/grouping.mjs +0 -338
- package/dist/arrange/domain/imports.mjs +0 -107
- package/dist/arrange/domain/source-text-formatters.mjs +0 -88
- package/dist/arrange/domain/tailwind-token.mjs +0 -40
- package/dist/arrange/domain/token-classifier.mjs +0 -218
- package/dist/arrange/domain/types.mjs +0 -1
- package/dist/arrange/output.mjs +0 -87
- package/dist/arrange/process-file.mjs +0 -42
- package/dist/arrange/resolve-target.mjs +0 -24
- package/dist/arrange/scan-target.mjs +0 -29
- package/dist/arrange/simplify-process-file.mjs +0 -35
- package/dist/arrange/simplify-sync.mjs +0 -32
- package/dist/arrange/source-parse.mjs +0 -18
- package/dist/arrange/suggest.mjs +0 -15
- package/dist/arrange/sync.mjs +0 -51
- package/dist/arrange/typescript-ast-translator.mjs +0 -354
- package/dist/arrange/workspace.mjs +0 -31
- package/dist/cli.mjs +0 -34
- package/dist/core/cli/format-error.mjs +0 -15
- package/dist/core/cli/global-options.mjs +0 -10
- package/dist/core/cli/positional.mjs +0 -11
- package/dist/core/cli/result-handle.mjs +0 -51
- package/dist/core/config/loader.mjs +0 -79
- package/dist/core/config/schema.mjs +0 -60
- package/dist/core/config/warnings.mjs +0 -12
- package/dist/core/config.mjs +0 -19
- package/dist/core/errors.mjs +0 -35
- package/dist/core/exit-codes.mjs +0 -17
- package/dist/core/filesystem/node.mjs +0 -32
- package/dist/core/filesystem/port.mjs +0 -1
- package/dist/core/glob.mjs +0 -20
- package/dist/core/logger.mjs +0 -15
- package/dist/core/result.mjs +0 -21
- package/dist/core/schema-parse.mjs +0 -18
- package/dist/core/source-text-edit.mjs +0 -56
- package/dist/core/verbose-diagnostics.mjs +0 -11
- package/dist/core/workspace/resolver.mjs +0 -177
- package/dist/core/workspace/typescript-walk.mjs +0 -36
- package/dist/mirror/cli-result.mjs +0 -22
- package/dist/mirror/cli-schema.mjs +0 -13
- package/dist/mirror/command.mjs +0 -58
- package/dist/mirror/dist-filesystem-impl.mjs +0 -42
- package/dist/mirror/domain/constants.mjs +0 -31
- package/dist/mirror/domain/dirent-guard.mjs +0 -16
- package/dist/mirror/domain/dist-filesystem.mjs +0 -1
- package/dist/mirror/domain/errors.mjs +0 -21
- package/dist/mirror/domain/exports.mjs +0 -226
- package/dist/mirror/domain/package-display-name.mjs +0 -12
- package/dist/mirror/domain/path-normalizer.mjs +0 -10
- package/dist/mirror/domain/types.mjs +0 -1
- package/dist/mirror/output.mjs +0 -48
- package/dist/mirror/package-path.mjs +0 -32
- package/dist/mirror/prepare.mjs +0 -33
- package/dist/mirror/supplement-exports.mjs +0 -114
- package/dist/mirror/sync-reporter.mjs +0 -107
- package/dist/mirror/sync-types.mjs +0 -1
- package/dist/mirror/sync-workspace-package.mjs +0 -109
- package/dist/mirror/sync.mjs +0 -88
- package/dist/mirror/write-exports.mjs +0 -94
- package/dist/tag/cli-result.mjs +0 -11
- package/dist/tag/cli-schema.mjs +0 -15
- package/dist/tag/command.mjs +0 -56
- package/dist/tag/domain/types.mjs +0 -1
- package/dist/tag/output.mjs +0 -87
- package/dist/tag/prepare.mjs +0 -29
- package/dist/tag/resolve-target-path.mjs +0 -12
- package/dist/tag/since-writer.mjs +0 -131
- package/dist/tag/sync.mjs +0 -149
- package/dist/tag/target-candidates.mjs +0 -68
- package/dist/tag/target-runner.mjs +0 -26
- package/dist/tag/version-resolver.mjs +0 -25
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import { PACKAGE_JSON_EXPORT, VALID_DTS_EXTENSIONS, VALID_JS_EXTENSIONS } from "./constants.mjs";
|
|
2
|
-
import * as nodePath from "node:path";
|
|
3
|
-
//#region src/mirror/domain/exports.ts
|
|
4
|
-
function groupDistFilesByModule(relativeDistFiles) {
|
|
5
|
-
const distModulesByPath = /* @__PURE__ */ new Map();
|
|
6
|
-
for (const relativeDistFile of relativeDistFiles) {
|
|
7
|
-
let fileExt;
|
|
8
|
-
let modulePath;
|
|
9
|
-
const declarationExt = Array.from(VALID_DTS_EXTENSIONS).find((candidate) => relativeDistFile.endsWith(candidate));
|
|
10
|
-
if (declarationExt) {
|
|
11
|
-
fileExt = declarationExt;
|
|
12
|
-
modulePath = relativeDistFile.slice(0, -declarationExt.length);
|
|
13
|
-
} else {
|
|
14
|
-
fileExt = nodePath.extname(relativeDistFile);
|
|
15
|
-
if (!VALID_JS_EXTENSIONS.has(fileExt)) continue;
|
|
16
|
-
modulePath = relativeDistFile.slice(0, -fileExt.length);
|
|
17
|
-
}
|
|
18
|
-
if (!nodePath.basename(modulePath)) continue;
|
|
19
|
-
let distModule = distModulesByPath.get(modulePath);
|
|
20
|
-
if (!distModule) {
|
|
21
|
-
distModule = {
|
|
22
|
-
path: modulePath,
|
|
23
|
-
files: {
|
|
24
|
-
js: null,
|
|
25
|
-
mjs: null,
|
|
26
|
-
cjs: null,
|
|
27
|
-
dts: null
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
distModulesByPath.set(modulePath, distModule);
|
|
31
|
-
}
|
|
32
|
-
if (fileExt === ".js") distModule.files.js = relativeDistFile;
|
|
33
|
-
else if (fileExt === ".mjs") distModule.files.mjs = relativeDistFile;
|
|
34
|
-
else if (fileExt === ".cjs") distModule.files.cjs = relativeDistFile;
|
|
35
|
-
else if (VALID_DTS_EXTENSIONS.has(fileExt)) distModule.files.dts = relativeDistFile;
|
|
36
|
-
}
|
|
37
|
-
return distModulesByPath;
|
|
38
|
-
}
|
|
39
|
-
function toExportPath(distPath) {
|
|
40
|
-
if (distPath === "index") return ".";
|
|
41
|
-
if (distPath.endsWith("/index")) return `./${distPath.slice(0, -6)}`;
|
|
42
|
-
return `./${distPath}`;
|
|
43
|
-
}
|
|
44
|
-
function isBundlerChunkPath(distPath) {
|
|
45
|
-
return distPath.split("/").includes("chunks");
|
|
46
|
-
}
|
|
47
|
-
const EXPORT_GROUP_ORDER = {
|
|
48
|
-
components: 100,
|
|
49
|
-
hooks: 200,
|
|
50
|
-
primitives: 300,
|
|
51
|
-
core: 400,
|
|
52
|
-
loaders: 500,
|
|
53
|
-
utils: 600,
|
|
54
|
-
adapters: 700,
|
|
55
|
-
script: 750,
|
|
56
|
-
css: 900
|
|
57
|
-
};
|
|
58
|
-
function getExportSortGroup(exportPath, pathTransform) {
|
|
59
|
-
if (exportPath === ".") return [
|
|
60
|
-
".",
|
|
61
|
-
"",
|
|
62
|
-
0,
|
|
63
|
-
0
|
|
64
|
-
];
|
|
65
|
-
const specifierPath = exportPath.startsWith("./") ? exportPath.slice(2) : exportPath;
|
|
66
|
-
if (specifierPath.endsWith("/*")) {
|
|
67
|
-
const dirName = specifierPath.slice(0, -2);
|
|
68
|
-
return [
|
|
69
|
-
dirName,
|
|
70
|
-
"",
|
|
71
|
-
dirName === "css" ? 900 : 100,
|
|
72
|
-
0
|
|
73
|
-
];
|
|
74
|
-
}
|
|
75
|
-
const parts = specifierPath.split("/");
|
|
76
|
-
if (parts.length === 1) {
|
|
77
|
-
const name = parts[0];
|
|
78
|
-
if (name === void 0) throw new Error("invariant: export path segment missing");
|
|
79
|
-
if (name in EXPORT_GROUP_ORDER) return [
|
|
80
|
-
name,
|
|
81
|
-
"",
|
|
82
|
-
EXPORT_GROUP_ORDER[name] ?? 0,
|
|
83
|
-
0
|
|
84
|
-
];
|
|
85
|
-
if (pathTransform) return [
|
|
86
|
-
"components",
|
|
87
|
-
name,
|
|
88
|
-
100,
|
|
89
|
-
1
|
|
90
|
-
];
|
|
91
|
-
return [
|
|
92
|
-
"",
|
|
93
|
-
name,
|
|
94
|
-
800,
|
|
95
|
-
1
|
|
96
|
-
];
|
|
97
|
-
}
|
|
98
|
-
const group = parts[0] ?? "";
|
|
99
|
-
return [
|
|
100
|
-
group,
|
|
101
|
-
parts.slice(1).join("/"),
|
|
102
|
-
EXPORT_GROUP_ORDER[group] ?? 700,
|
|
103
|
-
1
|
|
104
|
-
];
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* @since 0.3.16-canary.0
|
|
108
|
-
*/
|
|
109
|
-
function createPathTransform(strip) {
|
|
110
|
-
if (!strip) return null;
|
|
111
|
-
return (exportPath) => {
|
|
112
|
-
if (!exportPath.startsWith(strip)) return exportPath;
|
|
113
|
-
const trimmedExportPath = exportPath.slice(strip.length);
|
|
114
|
-
if (trimmedExportPath && trimmedExportPath !== "." && !trimmedExportPath.startsWith("./")) return `./${trimmedExportPath}`;
|
|
115
|
-
return trimmedExportPath;
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
function getExportSortKey(exportPath, pathTransform) {
|
|
119
|
-
const [groupName, subpath, groupOrder, indexRank] = getExportSortGroup(exportPath, pathTransform);
|
|
120
|
-
return [
|
|
121
|
-
groupOrder,
|
|
122
|
-
groupName,
|
|
123
|
-
indexRank,
|
|
124
|
-
subpath
|
|
125
|
-
];
|
|
126
|
-
}
|
|
127
|
-
function compareExportSortKeys(left, right) {
|
|
128
|
-
if (left[0] !== right[0]) return left[0] - right[0];
|
|
129
|
-
if (left[1] !== right[1]) return left[1] < right[1] ? -1 : 1;
|
|
130
|
-
if (left[2] !== right[2]) return left[2] - right[2];
|
|
131
|
-
if (left[3] !== right[3]) return left[3] < right[3] ? -1 : 1;
|
|
132
|
-
return 0;
|
|
133
|
-
}
|
|
134
|
-
async function generateCssExports(fileSystemService, distDir, cssConfig) {
|
|
135
|
-
if (cssConfig === false) return {};
|
|
136
|
-
if (cssConfig === true) cssConfig = { enabled: true };
|
|
137
|
-
if (!cssConfig || cssConfig.enabled === false) return {};
|
|
138
|
-
const cssFiles = (await fileSystemService.listRelativeFilesRecursively(distDir)).filter((relativeDistPath) => relativeDistPath.endsWith(".css"));
|
|
139
|
-
if (!cssFiles.length) return {};
|
|
140
|
-
const cssExports = { ...cssConfig.customExports };
|
|
141
|
-
const cssFilesByDir = /* @__PURE__ */ new Map();
|
|
142
|
-
const rootCssFiles = [];
|
|
143
|
-
for (const cssFile of cssFiles) {
|
|
144
|
-
const dirName = nodePath.dirname(cssFile).split(nodePath.sep).join("/");
|
|
145
|
-
if (dirName === ".") rootCssFiles.push(cssFile);
|
|
146
|
-
else {
|
|
147
|
-
const dirCssFiles = cssFilesByDir.get(dirName) || [];
|
|
148
|
-
dirCssFiles.push(cssFile);
|
|
149
|
-
cssFilesByDir.set(dirName, dirCssFiles);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
for (const cssFile of rootCssFiles) {
|
|
153
|
-
const exportPath = `./${cssFile}`;
|
|
154
|
-
if (!(exportPath in cssExports)) cssExports[exportPath] = `./dist/${cssFile}`;
|
|
155
|
-
}
|
|
156
|
-
for (const [dirName, dirCssFiles] of cssFilesByDir.entries()) if (await fileSystemService.isDirectoryCssOnly(distDir, dirName) && !cssConfig.forceExportFiles) {
|
|
157
|
-
const wildcardExport = `./${dirName}/*`;
|
|
158
|
-
if (!(wildcardExport in cssExports)) cssExports[wildcardExport] = `./dist/${dirName}/*`;
|
|
159
|
-
} else for (const cssFile of dirCssFiles) {
|
|
160
|
-
const exportPath = `./${cssFile}`;
|
|
161
|
-
if (!(exportPath in cssExports)) cssExports[exportPath] = `./dist/${cssFile}`;
|
|
162
|
-
}
|
|
163
|
-
return cssExports;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Compute `package.json#exports` from a built `dist/` tree. No logging; no writes.
|
|
167
|
-
*
|
|
168
|
-
* @since 0.3.16-canary.0
|
|
169
|
-
*/
|
|
170
|
-
async function generateExports(fileSystemService, distDir, pathTransform, cssConfig, extraExports, options) {
|
|
171
|
-
const relativeDistFiles = await fileSystemService.listRelativeFilesRecursively(distDir);
|
|
172
|
-
if (!relativeDistFiles.length) return {
|
|
173
|
-
exports: { [PACKAGE_JSON_EXPORT]: PACKAGE_JSON_EXPORT },
|
|
174
|
-
originalPathBySpecifier: { [PACKAGE_JSON_EXPORT]: PACKAGE_JSON_EXPORT },
|
|
175
|
-
jsCount: 0,
|
|
176
|
-
cssCount: 0
|
|
177
|
-
};
|
|
178
|
-
const distModulesByPath = groupDistFilesByModule(relativeDistFiles);
|
|
179
|
-
const exportableModules = Array.from(distModulesByPath.values()).filter((moduleEntry) => (moduleEntry.files.js || moduleEntry.files.mjs) && !isBundlerChunkPath(moduleEntry.path));
|
|
180
|
-
if (!exportableModules.length) return {
|
|
181
|
-
exports: { [PACKAGE_JSON_EXPORT]: PACKAGE_JSON_EXPORT },
|
|
182
|
-
originalPathBySpecifier: { [PACKAGE_JSON_EXPORT]: PACKAGE_JSON_EXPORT },
|
|
183
|
-
jsCount: 0,
|
|
184
|
-
cssCount: 0
|
|
185
|
-
};
|
|
186
|
-
const moduleExportsBySpecifier = {};
|
|
187
|
-
const originalPathBySpecifier = {};
|
|
188
|
-
for (const distModuleEntry of exportableModules) {
|
|
189
|
-
const originalExportPath = toExportPath(distModuleEntry.path);
|
|
190
|
-
let exportPath = originalExportPath;
|
|
191
|
-
if (pathTransform) exportPath = pathTransform(exportPath);
|
|
192
|
-
const exportEntry = {};
|
|
193
|
-
if (options?.source) if (typeof options.source === "string" && exportPath === ".") exportEntry.source = options.source;
|
|
194
|
-
else exportEntry.source = (options.resolveSourcePath ?? ((p) => `./src/${p}.ts`))(distModuleEntry.path);
|
|
195
|
-
const declarationFile = distModuleEntry.files.dts;
|
|
196
|
-
if (declarationFile && options?.types !== false) exportEntry.types = `./dist/${declarationFile}`;
|
|
197
|
-
if (options?.import !== false) {
|
|
198
|
-
if (distModuleEntry.files.mjs) exportEntry.import = `./dist/${distModuleEntry.files.mjs}`;
|
|
199
|
-
else if (distModuleEntry.files.js) exportEntry.import = `./dist/${distModuleEntry.files.js}`;
|
|
200
|
-
}
|
|
201
|
-
if (distModuleEntry.files.cjs) exportEntry.require = `./dist/${distModuleEntry.files.cjs}`;
|
|
202
|
-
moduleExportsBySpecifier[exportPath] = exportEntry;
|
|
203
|
-
originalPathBySpecifier[exportPath] = originalExportPath;
|
|
204
|
-
}
|
|
205
|
-
let sortedSpecifiers = Object.keys(moduleExportsBySpecifier).toSorted((leftSpecifier, rightSpecifier) => compareExportSortKeys(getExportSortKey(leftSpecifier, pathTransform), getExportSortKey(rightSpecifier, pathTransform)));
|
|
206
|
-
const sortedExports = {};
|
|
207
|
-
for (const exportKey of sortedSpecifiers) sortedExports[exportKey] = moduleExportsBySpecifier[exportKey];
|
|
208
|
-
const cssExports = await generateCssExports(fileSystemService, distDir, cssConfig ?? { enabled: true });
|
|
209
|
-
Object.assign(sortedExports, cssExports);
|
|
210
|
-
for (const [specifier, mappedPath] of Object.entries(extraExports || {})) if (specifier !== "./package.json") sortedExports[specifier] = mappedPath;
|
|
211
|
-
for (const cssSpecifier of Object.keys(cssExports)) if (!(cssSpecifier in originalPathBySpecifier)) originalPathBySpecifier[cssSpecifier] = cssSpecifier;
|
|
212
|
-
for (const extraSpecifier of Object.keys(extraExports || {})) if (extraSpecifier !== "./package.json" && !(extraSpecifier in originalPathBySpecifier)) originalPathBySpecifier[extraSpecifier] = extraSpecifier;
|
|
213
|
-
sortedSpecifiers = Object.keys(sortedExports).filter((exportKey) => exportKey !== PACKAGE_JSON_EXPORT).toSorted((leftSpecifier, rightSpecifier) => compareExportSortKeys(getExportSortKey(leftSpecifier, pathTransform), getExportSortKey(rightSpecifier, pathTransform)));
|
|
214
|
-
const finalExports = {};
|
|
215
|
-
for (const exportKey of sortedSpecifiers) finalExports[exportKey] = sortedExports[exportKey];
|
|
216
|
-
finalExports[PACKAGE_JSON_EXPORT] = PACKAGE_JSON_EXPORT;
|
|
217
|
-
originalPathBySpecifier[PACKAGE_JSON_EXPORT] = PACKAGE_JSON_EXPORT;
|
|
218
|
-
return {
|
|
219
|
-
exports: finalExports,
|
|
220
|
-
originalPathBySpecifier,
|
|
221
|
-
jsCount: Object.keys(moduleExportsBySpecifier).length,
|
|
222
|
-
cssCount: Object.keys(cssExports).length
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
//#endregion
|
|
226
|
-
export { createPathTransform, generateExports };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
//#region src/mirror/domain/package-display-name.ts
|
|
2
|
-
/**
|
|
3
|
-
* Domain rule: prefer `package.json#name` when it is present, otherwise use folder basename.
|
|
4
|
-
*
|
|
5
|
-
* @since 0.3.16-canary.0
|
|
6
|
-
*/
|
|
7
|
-
function resolvePackageDisplayName(packageJson, folderBasename) {
|
|
8
|
-
const declaredName = packageJson.name;
|
|
9
|
-
return typeof declaredName === "string" && declaredName.length > 0 ? declaredName : folderBasename;
|
|
10
|
-
}
|
|
11
|
-
//#endregion
|
|
12
|
-
export { resolvePackageDisplayName };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
//#region src/mirror/domain/path-normalizer.ts
|
|
3
|
-
/**
|
|
4
|
-
* @since 0.3.16-canary.0
|
|
5
|
-
*/
|
|
6
|
-
function normalizePath(pathString) {
|
|
7
|
-
return pathString.split(path.sep).join("/").replace(/\\/g, "/");
|
|
8
|
-
}
|
|
9
|
-
//#endregion
|
|
10
|
-
export { normalizePath };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/mirror/output.mjs
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { logger } from "../core/logger.mjs";
|
|
2
|
-
import { MirrorSyncReporter } from "./sync-reporter.mjs";
|
|
3
|
-
//#region src/mirror/output.ts
|
|
4
|
-
const cliLogger = logger;
|
|
5
|
-
/**
|
|
6
|
-
* @since 0.3.16-canary.0
|
|
7
|
-
*/
|
|
8
|
-
var MirrorSyncProgressPresenter = class {
|
|
9
|
-
reporter = new MirrorSyncReporter();
|
|
10
|
-
verbose = false;
|
|
11
|
-
dryRun = false;
|
|
12
|
-
configure(options) {
|
|
13
|
-
this.verbose = options.verbose;
|
|
14
|
-
this.dryRun = options.dryRun;
|
|
15
|
-
this.reporter.configureMirrorColors(options.noColor);
|
|
16
|
-
}
|
|
17
|
-
onBanner() {
|
|
18
|
-
this.reporter.mirrorBanner(cliLogger);
|
|
19
|
-
if (this.dryRun) this.reporter.mirrorDryRunNotice(cliLogger);
|
|
20
|
-
}
|
|
21
|
-
onProcessingMode(mode) {
|
|
22
|
-
this.reporter.mirrorProcessingMode(cliLogger, mode);
|
|
23
|
-
}
|
|
24
|
-
onNoPackages() {
|
|
25
|
-
this.reporter.mirrorNoPackages(cliLogger);
|
|
26
|
-
}
|
|
27
|
-
onPackageComplete(pkgStats, ordinal, total) {
|
|
28
|
-
if (pkgStats.skipped) {
|
|
29
|
-
this.reporter.logSkippedWorkspacePackage(cliLogger, ordinal, total, pkgStats.name, pkgStats.skipReason);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
if (pkgStats.error !== null) {
|
|
33
|
-
this.reporter.logPackageError(cliLogger, ordinal, total, pkgStats.name, pkgStats.error, this.verbose);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
for (const exportSpecifier of pkgStats.prunedExportKeys) this.reporter.logPrunedStaleExport(cliLogger, exportSpecifier);
|
|
37
|
-
this.reporter.logPackageSuccess(cliLogger, ordinal, total, pkgStats, {
|
|
38
|
-
jsCount: pkgStats.jsModules,
|
|
39
|
-
cssCount: pkgStats.cssExports
|
|
40
|
-
}, this.verbose);
|
|
41
|
-
}
|
|
42
|
-
onComplete(stats, elapsedSeconds) {
|
|
43
|
-
this.reporter.mirrorSummarySeparator(cliLogger);
|
|
44
|
-
this.reporter.mirrorSummary(cliLogger, stats, elapsedSeconds);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
//#endregion
|
|
48
|
-
export { MirrorSyncProgressPresenter };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { AppError } from "../core/errors.mjs";
|
|
2
|
-
import { err, ok } from "../core/result.mjs";
|
|
3
|
-
import { normalizePath } from "./domain/path-normalizer.mjs";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
//#region src/mirror/package-path.ts
|
|
6
|
-
/**
|
|
7
|
-
* @since 0.3.16-canary.0
|
|
8
|
-
*/
|
|
9
|
-
function resolveMirrorPackageFromCliArg(fs, args) {
|
|
10
|
-
const { rootDir, packageArg, currentWorkingDirectory } = args;
|
|
11
|
-
if (!packageArg) return ok(void 0);
|
|
12
|
-
const rootReal = fs.canonicalPathSync(path.resolve(rootDir));
|
|
13
|
-
const cwdReal = fs.canonicalPathSync(currentWorkingDirectory);
|
|
14
|
-
const resolved = path.isAbsolute(packageArg) ? path.resolve(packageArg) : path.resolve(cwdReal, packageArg);
|
|
15
|
-
const targetReal = fs.canonicalPathSync(resolved);
|
|
16
|
-
const normalized = normalizePath(path.relative(rootReal, targetReal));
|
|
17
|
-
if (normalized.startsWith("..") || path.isAbsolute(normalized) || normalized === "" || normalized === ".") return err(new AppError("VALIDATION_ERROR", `Package path must be a subdirectory under monorepo root: ${rootDir}`));
|
|
18
|
-
return ok(normalized);
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* @since 0.3.16-canary.0
|
|
22
|
-
*/
|
|
23
|
-
function resolvePackageFilterUnderRoot(fs, rootDir, packageFilter) {
|
|
24
|
-
const rootResolved = path.resolve(rootDir);
|
|
25
|
-
const rootReal = fs.canonicalPathSync(rootResolved);
|
|
26
|
-
const resolved = path.isAbsolute(packageFilter) ? fs.canonicalPathSync(path.resolve(packageFilter)) : fs.canonicalPathSync(path.join(rootReal, packageFilter));
|
|
27
|
-
const normalized = normalizePath(path.relative(rootReal, resolved));
|
|
28
|
-
if (normalized.startsWith("..") || path.isAbsolute(normalized) || normalized === "" || normalized === ".") return err(new AppError("VALIDATION_ERROR", `Package path must be a subdirectory under monorepo root: ${rootDir}`));
|
|
29
|
-
return ok(normalized);
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
|
-
export { resolveMirrorPackageFromCliArg, resolvePackageFilterUnderRoot };
|
package/dist/mirror/prepare.mjs
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { AppError, messageFrom } from "../core/errors.mjs";
|
|
2
|
-
import { err, ok } from "../core/result.mjs";
|
|
3
|
-
import { loadCodefastConfig } from "../core/config.mjs";
|
|
4
|
-
import { findRepoRoot } from "../core/workspace/resolver.mjs";
|
|
5
|
-
import { resolveMirrorPackageFromCliArg } from "./package-path.mjs";
|
|
6
|
-
//#region src/mirror/prepare.ts
|
|
7
|
-
/**
|
|
8
|
-
* @since 0.3.16-canary.0
|
|
9
|
-
*/
|
|
10
|
-
async function prepareMirrorSync(fs, args) {
|
|
11
|
-
let rootDir;
|
|
12
|
-
try {
|
|
13
|
-
rootDir = findRepoRoot(args.currentWorkingDirectory, fs);
|
|
14
|
-
} catch (caughtError) {
|
|
15
|
-
return err(new AppError("INFRA_FAILURE", messageFrom(caughtError), caughtError));
|
|
16
|
-
}
|
|
17
|
-
const filterOutcome = resolveMirrorPackageFromCliArg(fs, {
|
|
18
|
-
rootDir,
|
|
19
|
-
packageArg: args.packageArg,
|
|
20
|
-
currentWorkingDirectory: args.currentWorkingDirectory
|
|
21
|
-
});
|
|
22
|
-
if (!filterOutcome.ok) return filterOutcome;
|
|
23
|
-
const loadedOutcome = await loadCodefastConfig(rootDir, fs);
|
|
24
|
-
if (!loadedOutcome.ok) return loadedOutcome;
|
|
25
|
-
return ok({
|
|
26
|
-
globals: args.globals,
|
|
27
|
-
rootDir,
|
|
28
|
-
config: loadedOutcome.value.config,
|
|
29
|
-
packageFilter: filterOutcome.value
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
//#endregion
|
|
33
|
-
export { prepareMirrorSync };
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { DIST_DIR } from "./domain/constants.mjs";
|
|
2
|
-
import { writePackageJsonExportsAtomic } from "./write-exports.mjs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
//#region src/mirror/supplement-exports.ts
|
|
5
|
-
const DTS_EXTENSIONS = [
|
|
6
|
-
".d.mts",
|
|
7
|
-
".d.ts",
|
|
8
|
-
".d.cts"
|
|
9
|
-
];
|
|
10
|
-
const JS_EXTENSIONS = [".mjs", ".js"];
|
|
11
|
-
/**
|
|
12
|
-
* Infer the dist module path (e.g. `"index"`, `"components/button"`) from an existing
|
|
13
|
-
* conditional export entry. Prefers `import` / `require` values because their extensions
|
|
14
|
-
* are simpler than `.d.mts` etc.
|
|
15
|
-
*/
|
|
16
|
-
function inferModulePath(specifier, entry) {
|
|
17
|
-
for (const key of ["import", "require"]) {
|
|
18
|
-
const value = entry[key];
|
|
19
|
-
if (typeof value === "string" && value.startsWith("./dist/")) {
|
|
20
|
-
const relative = value.slice(7);
|
|
21
|
-
for (const ext of JS_EXTENSIONS) if (relative.endsWith(ext)) return relative.slice(0, -ext.length);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
const typesValue = entry.types;
|
|
25
|
-
if (typeof typesValue === "string" && typesValue.startsWith("./dist/")) {
|
|
26
|
-
const relative = typesValue.slice(7);
|
|
27
|
-
for (const ext of DTS_EXTENSIONS) if (relative.endsWith(ext)) return relative.slice(0, -ext.length);
|
|
28
|
-
}
|
|
29
|
-
if (specifier === ".") return "index";
|
|
30
|
-
if (specifier.startsWith("./")) return specifier.slice(2);
|
|
31
|
-
return specifier;
|
|
32
|
-
}
|
|
33
|
-
function findDtsSpecifier(fs, distDir, modulePath) {
|
|
34
|
-
for (const ext of DTS_EXTENSIONS) if (fs.existsSync(path.join(distDir, `${modulePath}${ext}`))) return `./dist/${modulePath}${ext}`;
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
function findImportSpecifier(fs, distDir, modulePath) {
|
|
38
|
-
for (const ext of JS_EXTENSIONS) if (fs.existsSync(path.join(distDir, `${modulePath}${ext}`))) return `./dist/${modulePath}${ext}`;
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Rebuild an export entry in canonical key order, adding any missing conditions.
|
|
43
|
-
* Key order: source → types → import → require → (remaining original keys).
|
|
44
|
-
*/
|
|
45
|
-
function buildSupplementedEntry(specifier, existing, modulePath, distDir, fs, options) {
|
|
46
|
-
const result = {};
|
|
47
|
-
const knownKeys = /* @__PURE__ */ new Set([
|
|
48
|
-
"source",
|
|
49
|
-
"types",
|
|
50
|
-
"import",
|
|
51
|
-
"require"
|
|
52
|
-
]);
|
|
53
|
-
if ("source" in existing) result.source = existing.source;
|
|
54
|
-
else if (options.source) if (typeof options.source === "string" && specifier === ".") result.source = options.source;
|
|
55
|
-
else result.source = options.resolveSourcePath(modulePath);
|
|
56
|
-
if ("types" in existing) result.types = existing.types;
|
|
57
|
-
else if (options.types) {
|
|
58
|
-
const found = findDtsSpecifier(fs, distDir, modulePath);
|
|
59
|
-
if (found) result.types = found;
|
|
60
|
-
}
|
|
61
|
-
if ("import" in existing) result.import = existing.import;
|
|
62
|
-
else if (options.import) {
|
|
63
|
-
const found = findImportSpecifier(fs, distDir, modulePath);
|
|
64
|
-
if (found) result.import = found;
|
|
65
|
-
}
|
|
66
|
-
if ("require" in existing) result.require = existing.require;
|
|
67
|
-
for (const [key, value] of Object.entries(existing)) if (!knownKeys.has(key) && !(key in result)) result[key] = value;
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* @since 0.3.16-canary.0
|
|
72
|
-
*/
|
|
73
|
-
async function supplementExportsInPackageJson(fs, packageJsonPath, packageDir, options, write = true) {
|
|
74
|
-
const raw = await fs.readFile(packageJsonPath, "utf8");
|
|
75
|
-
const existingExports = JSON.parse(raw).exports;
|
|
76
|
-
if (!existingExports || typeof existingExports !== "object" || Array.isArray(existingExports)) return { supplementedSpecifiers: [] };
|
|
77
|
-
const distDir = path.join(packageDir, DIST_DIR);
|
|
78
|
-
const supplementedSpecifiers = [];
|
|
79
|
-
const supplementedExports = {};
|
|
80
|
-
const originalPathBySpecifier = {};
|
|
81
|
-
for (const [specifier, entry] of Object.entries(existingExports)) {
|
|
82
|
-
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
|
|
83
|
-
supplementedExports[specifier] = entry;
|
|
84
|
-
originalPathBySpecifier[specifier] = specifier;
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
const entryRecord = entry;
|
|
88
|
-
const supplemented = buildSupplementedEntry(specifier, entryRecord, inferModulePath(specifier, entryRecord), distDir, fs, options);
|
|
89
|
-
if (JSON.stringify(supplemented) !== JSON.stringify(entryRecord)) supplementedSpecifiers.push(specifier);
|
|
90
|
-
supplementedExports[specifier] = supplemented;
|
|
91
|
-
originalPathBySpecifier[specifier] = specifier;
|
|
92
|
-
}
|
|
93
|
-
await writePackageJsonExportsAtomic(fs, packageJsonPath, {
|
|
94
|
-
generatedExports: supplementedExports,
|
|
95
|
-
managedExportSpecifiers: Object.keys(supplementedExports),
|
|
96
|
-
originalPathBySpecifier
|
|
97
|
-
}, write);
|
|
98
|
-
return { supplementedSpecifiers };
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Build a `resolveSourcePath` closure that checks the filesystem for `.tsx` before
|
|
102
|
-
* falling back to `.ts`. Mirrors the logic used in normal (non-custom) mode.
|
|
103
|
-
*
|
|
104
|
-
* @since 0.3.16-canary.0
|
|
105
|
-
*/
|
|
106
|
-
function buildSourcePathResolver(fs, packageDir) {
|
|
107
|
-
const srcDir = path.join(packageDir, "src");
|
|
108
|
-
return (modulePath) => {
|
|
109
|
-
const tsxPath = path.join(srcDir, `${modulePath}.tsx`);
|
|
110
|
-
return fs.existsSync(tsxPath) ? `./src/${modulePath}.tsx` : `./src/${modulePath}.ts`;
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
//#endregion
|
|
114
|
-
export { buildSourcePathResolver, supplementExportsInPackageJson };
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { messageFrom } from "../core/errors.mjs";
|
|
2
|
-
import process from "node:process";
|
|
3
|
-
//#region src/mirror/sync-reporter.ts
|
|
4
|
-
const ANSI = {
|
|
5
|
-
reset: "\x1B[0m",
|
|
6
|
-
bold: "\x1B[1m",
|
|
7
|
-
dim: "\x1B[2m",
|
|
8
|
-
green: "\x1B[32m",
|
|
9
|
-
yellow: "\x1B[33m",
|
|
10
|
-
cyan: "\x1B[36m",
|
|
11
|
-
gray: "\x1B[90m",
|
|
12
|
-
magenta: "\x1B[35m",
|
|
13
|
-
brightGreen: "\x1B[92m",
|
|
14
|
-
brightCyan: "\x1B[96m"
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Console implementation: ANSI styling and layout for the mirror command.
|
|
18
|
-
*
|
|
19
|
-
* @since 0.3.16-canary.0
|
|
20
|
-
*/
|
|
21
|
-
var MirrorSyncReporter = class {
|
|
22
|
-
colorsAreEnabled = true;
|
|
23
|
-
configureMirrorColors(noColor) {
|
|
24
|
-
this.colorsAreEnabled = !!process.stdout.isTTY && !noColor;
|
|
25
|
-
}
|
|
26
|
-
mirrorBanner(logger) {
|
|
27
|
-
logger.out(`\n${this.paint("📦 Mirror — package exports", ANSI.bold + ANSI.cyan)}`);
|
|
28
|
-
logger.out(`${this.paint("═".repeat(60), ANSI.dim)}\n`);
|
|
29
|
-
}
|
|
30
|
-
mirrorDryRunNotice(logger) {
|
|
31
|
-
logger.out(`${this.paint("Dry run — no files will be written.", ANSI.yellow)}\n`);
|
|
32
|
-
}
|
|
33
|
-
mirrorProcessingMode(logger, mode) {
|
|
34
|
-
if (mode.kind === "single") {
|
|
35
|
-
logger.out(`${this.paint("Processing single package...", ANSI.dim)}\n`);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
if (mode.source === "default-patterns") {
|
|
39
|
-
logger.out(`${this.paint("Discovering workspace packages using default patterns (packages/*)…", ANSI.dim)}\n`);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if (mode.source === "pnpm-workspace-yaml") {
|
|
43
|
-
logger.out(`${this.paint("Discovering workspace packages from pnpm-workspace.yaml…", ANSI.dim)}\n`);
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
logger.out(`${this.paint("pnpm-workspace.yaml declares an empty workspace package list.", ANSI.dim)}\n`);
|
|
47
|
-
}
|
|
48
|
-
mirrorNoPackages(logger) {
|
|
49
|
-
logger.out(this.paint("⚠ No packages found", ANSI.yellow));
|
|
50
|
-
}
|
|
51
|
-
logSkippedWorkspacePackage(logger, index, total, displayName, reason) {
|
|
52
|
-
const progress = this.paint(`[${index}/${total}]`, ANSI.dim);
|
|
53
|
-
logger.out(`${progress} ${this.paint("○", ANSI.gray)} ${this.paint(displayName, ANSI.dim)}`);
|
|
54
|
-
logger.out(` ${this.paint("└─", ANSI.dim)} ${this.paint(`Skipped: ${reason}`, ANSI.gray)}`);
|
|
55
|
-
logger.out("");
|
|
56
|
-
}
|
|
57
|
-
logPackageSuccess(logger, index, total, pkgStats, generatedDistAssetCounts, verbose) {
|
|
58
|
-
const progress = this.paint(`[${index}/${total}]`, ANSI.dim);
|
|
59
|
-
logger.out(`${progress} ${this.paint("✓", ANSI.brightGreen)} ${this.paint(pkgStats.name, ANSI.bold)}`);
|
|
60
|
-
if (verbose) {
|
|
61
|
-
logger.out(` ${this.paint("├─", ANSI.dim)} Path: ${pkgStats.path}`);
|
|
62
|
-
if (pkgStats.hasTransform) logger.out(` ${this.paint("├─", ANSI.dim)} ${this.paint("Custom path transformation", ANSI.cyan)}`);
|
|
63
|
-
if (pkgStats.cssConfigStatus) {
|
|
64
|
-
const status = pkgStats.cssConfigStatus === "disabled" ? "CSS disabled" : "CSS configured";
|
|
65
|
-
logger.out(` ${this.paint("├─", ANSI.dim)} ${this.paint(status, ANSI.cyan)}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
const breakdown = [];
|
|
69
|
-
if (generatedDistAssetCounts.jsCount > 0) breakdown.push(this.paint(`${generatedDistAssetCounts.jsCount} modules`, ANSI.green));
|
|
70
|
-
if (generatedDistAssetCounts.cssCount > 0) breakdown.push(this.paint(`${generatedDistAssetCounts.cssCount} CSS`, ANSI.magenta));
|
|
71
|
-
if (pkgStats.extraExports > 0) breakdown.push(this.paint(`${pkgStats.extraExports} custom`, ANSI.yellow));
|
|
72
|
-
const totalExportsText = this.paint(`${pkgStats.totalExports} exports`, ANSI.brightCyan);
|
|
73
|
-
if (breakdown.length === 0) logger.out(` ${this.paint("└─", ANSI.dim)} ${totalExportsText}`);
|
|
74
|
-
else logger.out(` ${this.paint("└─", ANSI.dim)} ${breakdown.join(" + ")} = ${totalExportsText}`);
|
|
75
|
-
logger.out("");
|
|
76
|
-
}
|
|
77
|
-
logPrunedStaleExport(logger, exportSpecifier) {
|
|
78
|
-
logger.out(` ${this.paint("└─", ANSI.dim)} ${this.paint(`Pruned stale export: ${exportSpecifier}`, ANSI.gray)}`);
|
|
79
|
-
}
|
|
80
|
-
logPackageError(logger, index, total, displayName, errorValue, verbose) {
|
|
81
|
-
logger.out(`${this.paint(`[${index}/${total}]`, ANSI.dim)} ${this.paint("✗", ANSI.yellow)} ${this.paint(displayName, ANSI.bold)}`);
|
|
82
|
-
logger.out(` ${this.paint("└─", ANSI.dim)} ${this.paint(`Error: ${messageFrom(errorValue)}`, ANSI.yellow)}\n`);
|
|
83
|
-
if (verbose) logger.err(errorValue instanceof Error && errorValue.stack ? errorValue.stack : messageFrom(errorValue));
|
|
84
|
-
}
|
|
85
|
-
mirrorSummarySeparator(logger) {
|
|
86
|
-
logger.out(this.paint("═".repeat(60), ANSI.dim));
|
|
87
|
-
}
|
|
88
|
-
mirrorSummary(logger, stats, elapsedSeconds) {
|
|
89
|
-
logger.out(`${this.paint("📊 Summary", ANSI.bold)} ${this.paint(`(completed in ${elapsedSeconds.toFixed(2)}s)`, ANSI.dim)}\n`);
|
|
90
|
-
logger.out(` ${this.paint("Packages:", ANSI.bold)}`);
|
|
91
|
-
logger.out(` ${this.paint("├─", ANSI.dim)} Processed: ${this.paint(String(stats.packagesProcessed), ANSI.green)}`);
|
|
92
|
-
if (stats.packagesSkipped > 0) logger.out(` ${this.paint("├─", ANSI.dim)} Skipped: ${this.paint(String(stats.packagesSkipped), ANSI.gray)}`);
|
|
93
|
-
if (stats.packagesErrored > 0) logger.out(` ${this.paint("├─", ANSI.dim)} Errors: ${this.paint(String(stats.packagesErrored), ANSI.yellow)}`);
|
|
94
|
-
logger.out(` ${this.paint("└─", ANSI.dim)} Total found: ${stats.packagesFound}\n`);
|
|
95
|
-
logger.out(` ${this.paint("Exports:", ANSI.bold)}`);
|
|
96
|
-
logger.out(` ${this.paint("├─", ANSI.dim)} JS Modules: ${this.paint(String(stats.totalJsModules), ANSI.cyan)}`);
|
|
97
|
-
logger.out(` ${this.paint("├─", ANSI.dim)} CSS Files: ${this.paint(String(stats.totalCssExports), ANSI.magenta)}`);
|
|
98
|
-
logger.out(` ${this.paint("└─", ANSI.dim)} Total: ${this.paint(String(stats.totalExports), ANSI.brightCyan)}\n`);
|
|
99
|
-
logger.out(`${this.paint("═".repeat(60), ANSI.dim)}\n`);
|
|
100
|
-
}
|
|
101
|
-
paint(text, openSequence) {
|
|
102
|
-
if (!this.colorsAreEnabled) return text;
|
|
103
|
-
return `${openSequence}${text}${ANSI.reset}`;
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
//#endregion
|
|
107
|
-
export { MirrorSyncReporter };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|