@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.
- package/dist/bin.mjs +1 -1
- package/dist/commands/arrange.mjs +106 -1
- package/dist/commands/mirror.mjs +65 -1
- package/dist/commands/tag.mjs +57 -1
- package/dist/lib/arrange/application/analyze.mjs +91 -1
- package/dist/lib/arrange/application/group-file.mjs +112 -1
- package/dist/lib/arrange/application/run-target.mjs +64 -1
- package/dist/lib/arrange/domain/ast/ast-helpers.mjs +114 -1
- package/dist/lib/arrange/domain/ast/collectors-cn.mjs +60 -1
- package/dist/lib/arrange/domain/ast/collectors-jsx.mjs +19 -1
- package/dist/lib/arrange/domain/ast/collectors-tv.mjs +169 -1
- package/dist/lib/arrange/domain/ast/targets.mjs +105 -1
- package/dist/lib/arrange/domain/constants.mjs +168 -1
- package/dist/lib/arrange/domain/errors.mjs +18 -1
- package/dist/lib/arrange/domain/grouping.mjs +234 -1
- package/dist/lib/arrange/domain/imports.mjs +53 -1
- package/dist/lib/arrange/domain/tokenizer.mjs +215 -1
- package/dist/lib/arrange/index.mjs +14 -15
- package/dist/lib/arrange/infra/walk.mjs +32 -1
- package/dist/lib/arrange/presentation/formatters.mjs +51 -1
- package/dist/lib/arrange/presentation/report.mjs +23 -1
- package/dist/lib/config/domain/schema.mjs +24 -1
- package/dist/lib/config/index.mjs +2 -3
- package/dist/lib/config/infra/loader.mjs +77 -1
- package/dist/lib/infra/caught-unknown-message.mjs +19 -1
- package/dist/lib/infra/config-reporter.mjs +9 -1
- package/dist/lib/infra/node-io.mjs +29 -1
- package/dist/lib/infra/workspace/repo-root.mjs +21 -1
- package/dist/lib/mirror/application/engine.mjs +247 -1
- package/dist/lib/mirror/application/sync.mjs +161 -1
- package/dist/lib/mirror/domain/constants.mjs +11 -1
- package/dist/lib/mirror/domain/errors.mjs +14 -1
- package/dist/lib/mirror/index.mjs +1 -2
- package/dist/lib/mirror/infra/dirent-list.mjs +13 -1
- package/dist/lib/mirror/infra/package-filter.mjs +25 -1
- package/dist/lib/mirror/infra/path-normalizer.mjs +6 -1
- package/dist/lib/mirror/infra/update-pkg.mjs +104 -1
- package/dist/lib/mirror/infra/workspace-packages.mjs +158 -1
- package/dist/lib/mirror/presentation/reporter.mjs +111 -2
- package/dist/lib/tag/application/engine.mjs +286 -1
- package/dist/lib/tag/index.mjs +3 -4
- package/dist/lib/tag/infra/target-resolver.mjs +169 -1
- package/dist/lib/tag/presentation/colors.mjs +11 -1
- package/dist/lib/tag/presentation/tag-presenter.mjs +62 -1
- package/dist/program.mjs +33 -1
- package/package.json +2 -2
- package/dist/analyze-DvtJ3j9m.mjs +0 -92
- package/dist/arrange-Bbh62DrU.mjs +0 -107
- package/dist/arrange-BqP2DI3w.mjs +0 -8
- package/dist/ast-helpers-MDRYuIAk.mjs +0 -115
- package/dist/caught-unknown-message-CRhkDWO7.mjs +0 -20
- package/dist/collectors-cn-BS8TTQ8O.mjs +0 -61
- package/dist/collectors-jsx-D9tL2ZPM.mjs +0 -20
- package/dist/collectors-tv-D2PXZaRt.mjs +0 -170
- package/dist/colors-BjdkCfGK.mjs +0 -12
- package/dist/commands/mirror.test.mjs +0 -48
- package/dist/config-DVia_f9a.mjs +0 -3
- package/dist/config-reporter-SCcWDZc1.mjs +0 -10
- package/dist/constants-AtPhF-Ct.mjs +0 -169
- package/dist/constants-Bq5wdyLC.mjs +0 -8
- package/dist/dirent-list-BSDeRG5i.mjs +0 -14
- package/dist/engine-CcWEHSCq.mjs +0 -287
- package/dist/engine-DRTdkc5u.mjs +0 -236
- package/dist/errors-CFH4w6ic.mjs +0 -15
- package/dist/errors-CpU1ogfA.mjs +0 -19
- package/dist/formatters-DGE8jJ53.mjs +0 -52
- package/dist/group-file-ClW7XdD6.mjs +0 -113
- package/dist/grouping-c1grpCQT.mjs +0 -235
- package/dist/imports-DSVq1xhB.mjs +0 -54
- package/dist/lib/arrange/application/analyze.test.mjs +0 -171
- package/dist/lib/arrange/application/group-file.test.mjs +0 -273
- package/dist/lib/arrange/application/run-target.test.mjs +0 -97
- package/dist/lib/arrange/domain/ast/ast-helpers.test.mjs +0 -148
- package/dist/lib/arrange/domain/ast/collectors-cn.test.mjs +0 -58
- package/dist/lib/arrange/domain/ast/collectors-jsx.test.mjs +0 -20
- package/dist/lib/arrange/domain/ast/collectors-tv.test.mjs +0 -145
- package/dist/lib/arrange/domain/ast/targets.test.mjs +0 -50
- package/dist/lib/arrange/domain/grouping.test.mjs +0 -186
- package/dist/lib/arrange/domain/imports.test.mjs +0 -48
- package/dist/lib/arrange/domain/tokenizer.test.mjs +0 -165
- package/dist/lib/arrange/infra/walk.test.mjs +0 -50
- package/dist/lib/arrange/presentation/formatters.test.mjs +0 -73
- package/dist/lib/config/infra/loader.test.mjs +0 -116
- package/dist/lib/infra/workspace/repo-root.test.mjs +0 -45
- package/dist/lib/mirror/application/sync.test.mjs +0 -482
- package/dist/lib/mirror/infra/dirent-list.test.mjs +0 -18
- package/dist/lib/mirror/infra/package-filter.test.mjs +0 -32
- package/dist/lib/mirror/infra/workspace-packages.test.mjs +0 -167
- package/dist/lib/tag/application/engine.test.mjs +0 -159
- package/dist/lib/tag/presentation/tag-presenter.test.mjs +0 -29
- package/dist/loader-DpN-zl5g.mjs +0 -78
- package/dist/mirror-CbGiLXKT.mjs +0 -2
- package/dist/mirror-DqJE3ejL.mjs +0 -66
- package/dist/node-io-DFRbHO6m.mjs +0 -30
- package/dist/package-filter-C_8ryqvz.mjs +0 -26
- package/dist/path-normalizer-D4ceBO3l.mjs +0 -7
- package/dist/program-DR-H4tH3.mjs +0 -34
- package/dist/repo-root-HmtIEm6J.mjs +0 -22
- package/dist/report-DYxvw34T.mjs +0 -24
- package/dist/reporter-CwIe_tAM.mjs +0 -108
- package/dist/run-target-CJWrqNT4.mjs +0 -65
- package/dist/schema-Or8RAARd.mjs +0 -25
- package/dist/sync-e1Sp-shi.mjs +0 -157
- package/dist/tag-Cd9JujU5.mjs +0 -2
- package/dist/tag-hEKVZ_-7.mjs +0 -58
- package/dist/tag-presenter-Cs66UBsH.mjs +0 -63
- package/dist/target-resolver-CR3FXMTy.mjs +0 -170
- package/dist/targets-pCTslnFh.mjs +0 -106
- package/dist/tokenizer-CeZx73Zu.mjs +0 -216
- package/dist/update-pkg-CnGfjWBy.mjs +0 -37
- package/dist/walk-DjgQn66n.mjs +0 -33
- package/dist/workspace-packages-K2NYTHJq.mjs +0 -159
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { t as messageFromCaughtUnknown } from "./caught-unknown-message-CRhkDWO7.mjs";
|
|
2
|
-
import { t as printConfigSchemaWarnings } from "./config-reporter-SCcWDZc1.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 logPackageError(logger, index, total, displayName, errValue, verbose) {
|
|
80
|
-
const { out, err: errLine } = logger;
|
|
81
|
-
out(`${Colors.DIM}[${index}/${total}]${Colors.RESET} ${Colors.YELLOW}✗${Colors.RESET} ${Colors.BOLD}${displayName}${Colors.RESET}`);
|
|
82
|
-
out(` ${Colors.DIM}└─${Colors.RESET} ${Colors.YELLOW}Error: ${messageFromCaughtUnknown(errValue)}${Colors.RESET}\n`);
|
|
83
|
-
if (verbose) errLine(errValue instanceof Error && errValue.stack ? errValue.stack : messageFromCaughtUnknown(errValue));
|
|
84
|
-
}
|
|
85
|
-
function mirrorSummarySeparator(logger) {
|
|
86
|
-
logger.out(`${Colors.DIM}${"═".repeat(60)}${Colors.RESET}`);
|
|
87
|
-
}
|
|
88
|
-
function mirrorSummary(logger, stats, elapsedSeconds) {
|
|
89
|
-
const { out } = logger;
|
|
90
|
-
out(`${Colors.BOLD}📊 Summary${Colors.RESET} ${Colors.DIM}(completed in ${elapsedSeconds.toFixed(2)}s)${Colors.RESET}\n`);
|
|
91
|
-
out(` ${Colors.BOLD}Packages:${Colors.RESET}`);
|
|
92
|
-
out(` ${Colors.DIM}├─${Colors.RESET} Processed: ${Colors.GREEN}${stats.packagesProcessed}${Colors.RESET}`);
|
|
93
|
-
if (stats.packagesSkipped > 0) out(` ${Colors.DIM}├─${Colors.RESET} Skipped: ${Colors.GRAY}${stats.packagesSkipped}${Colors.RESET}`);
|
|
94
|
-
if (stats.packagesErrored > 0) out(` ${Colors.DIM}├─${Colors.RESET} Errors: ${Colors.YELLOW}${stats.packagesErrored}${Colors.RESET}`);
|
|
95
|
-
out(` ${Colors.DIM}└─${Colors.RESET} Total found: ${stats.packagesFound}\n`);
|
|
96
|
-
out(` ${Colors.BOLD}Exports:${Colors.RESET}`);
|
|
97
|
-
out(` ${Colors.DIM}├─${Colors.RESET} JS Modules: ${Colors.CYAN}${stats.totalJsModules}${Colors.RESET}`);
|
|
98
|
-
out(` ${Colors.DIM}├─${Colors.RESET} CSS Files: ${Colors.MAGENTA}${stats.totalCssExports}${Colors.RESET}`);
|
|
99
|
-
out(` ${Colors.DIM}└─${Colors.RESET} Total: ${Colors.BRIGHT_CYAN}${stats.totalExports}${Colors.RESET}\n`);
|
|
100
|
-
out(`${Colors.DIM}${"═".repeat(60)}${Colors.RESET}\n`);
|
|
101
|
-
}
|
|
102
|
-
function mirrorFatalError(logger, caughtError) {
|
|
103
|
-
const { out, err: errLine } = logger;
|
|
104
|
-
out(`${Colors.YELLOW}Fatal error: ${messageFromCaughtUnknown(caughtError)}${Colors.RESET}`);
|
|
105
|
-
errLine(caughtError instanceof Error && caughtError.stack ? caughtError.stack : messageFromCaughtUnknown(caughtError));
|
|
106
|
-
}
|
|
107
|
-
//#endregion
|
|
108
|
-
export { mirrorBanner as a, mirrorNoPackages as c, mirrorSummarySeparator as d, printMirrorConfigWarnings as f, logSkippedWorkspacePackage as i, mirrorProcessingMode as l, logPackageError as n, mirrorFatalError as o, logPackageSuccess as r, mirrorGlobWarning as s, configureMirrorColors as t, mirrorSummary as u };
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { t as messageFromCaughtUnknown } from "./caught-unknown-message-CRhkDWO7.mjs";
|
|
2
|
-
import { n as walkTsxFiles } from "./walk-DjgQn66n.mjs";
|
|
3
|
-
import { t as groupFile } from "./group-file-ClW7XdD6.mjs";
|
|
4
|
-
import { n as ArrangeErrorCode, t as ArrangeError } from "./errors-CpU1ogfA.mjs";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
//#region src/lib/arrange/application/run-target.ts
|
|
7
|
-
function runOnTarget(target, options, fs, logger) {
|
|
8
|
-
const { out } = logger;
|
|
9
|
-
if (!fs.existsSync(target)) throw new ArrangeError(ArrangeErrorCode.TARGET_NOT_FOUND, `Not found: ${target}`);
|
|
10
|
-
const filePaths = fs.statSync(target).isDirectory() ? walkTsxFiles(target, fs) : [target];
|
|
11
|
-
const modifiedFiles = [];
|
|
12
|
-
let totalFound = 0;
|
|
13
|
-
let totalChanged = 0;
|
|
14
|
-
for (const filePath of filePaths) {
|
|
15
|
-
const result = groupFile(filePath, options, fs, logger);
|
|
16
|
-
totalFound += result.totalFound;
|
|
17
|
-
totalChanged += result.changed;
|
|
18
|
-
if (result.changed > 0) modifiedFiles.push(result.filePath);
|
|
19
|
-
}
|
|
20
|
-
out(`\nTotal: ${filePaths.length} file(s), ${totalFound} site(s) (cn/tv/JSX className) to review.`);
|
|
21
|
-
if (options.write) out(`Applied: ${totalChanged} site(s) updated.`);
|
|
22
|
-
else out(`(Run "apply" to write changes, or "pnpm cli:arrange-apply" / "pnpm exec codefast arrange apply")`);
|
|
23
|
-
if (options.write ? totalChanged > 0 : totalFound > 0) out("Note: class order may change across concern groups — smoke-test the UI if you rely on cascade order.");
|
|
24
|
-
return {
|
|
25
|
-
filePaths,
|
|
26
|
-
modifiedFiles,
|
|
27
|
-
totalFound,
|
|
28
|
-
totalChanged
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
async function runArrangeOnAfterWriteHook(logger, hook, modifiedFiles) {
|
|
32
|
-
if (!hook || modifiedFiles.length === 0) return;
|
|
33
|
-
try {
|
|
34
|
-
await hook({ files: modifiedFiles });
|
|
35
|
-
} catch (caughtHookError) {
|
|
36
|
-
logger.err(`[arrange] onAfterWrite hook failed: ${messageFromCaughtUnknown(caughtHookError)}`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* CLI entry: run arrange preview/apply using config injected by the command layer.
|
|
41
|
-
* @returns Process exit code (`0`, or `1` when the target path is missing).
|
|
42
|
-
*/
|
|
43
|
-
async function runArrangeSync(opts) {
|
|
44
|
-
opts.rootDir;
|
|
45
|
-
const { fs, logger } = opts;
|
|
46
|
-
const resolvedTarget = path.resolve(opts.targetPath);
|
|
47
|
-
let result;
|
|
48
|
-
try {
|
|
49
|
-
result = runOnTarget(resolvedTarget, {
|
|
50
|
-
write: opts.write,
|
|
51
|
-
withClassName: !!opts.withClassName,
|
|
52
|
-
cnImport: opts.cnImport
|
|
53
|
-
}, fs, logger);
|
|
54
|
-
} catch (caughtError) {
|
|
55
|
-
if (caughtError instanceof ArrangeError && caughtError.code === ArrangeErrorCode.TARGET_NOT_FOUND) {
|
|
56
|
-
logger.err(caughtError.message);
|
|
57
|
-
return 1;
|
|
58
|
-
}
|
|
59
|
-
throw caughtError;
|
|
60
|
-
}
|
|
61
|
-
if (opts.write && result.modifiedFiles.length > 0) await runArrangeOnAfterWriteHook(logger, opts.config?.onAfterWrite, result.modifiedFiles);
|
|
62
|
-
return 0;
|
|
63
|
-
}
|
|
64
|
-
//#endregion
|
|
65
|
-
export { runOnTarget as n, runArrangeSync as t };
|
package/dist/schema-Or8RAARd.mjs
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
//#region src/lib/config/domain/schema.ts
|
|
3
|
-
const hookSchema = z.custom((value) => typeof value === "function", { message: "Expected a function" });
|
|
4
|
-
const mirrorConfigSchema = z.object({
|
|
5
|
-
skipPackages: z.array(z.string()).optional(),
|
|
6
|
-
pathTransformations: z.record(z.string(), z.object({ removePrefix: z.string().optional() }).strict()).optional(),
|
|
7
|
-
customExports: z.record(z.string(), z.record(z.string(), z.string())).optional(),
|
|
8
|
-
cssExports: z.record(z.string(), z.union([z.boolean(), z.object({
|
|
9
|
-
enabled: z.boolean().optional(),
|
|
10
|
-
customExports: z.record(z.string(), z.string()).optional(),
|
|
11
|
-
forceExportFiles: z.boolean().optional()
|
|
12
|
-
}).strict()])).optional()
|
|
13
|
-
}).strict();
|
|
14
|
-
const codefastTagConfigSchema = z.object({
|
|
15
|
-
skipPackages: z.array(z.string()).optional(),
|
|
16
|
-
onAfterWrite: hookSchema.optional()
|
|
17
|
-
}).strict();
|
|
18
|
-
const codefastArrangeConfigSchema = z.object({ onAfterWrite: hookSchema.optional() }).strict();
|
|
19
|
-
const codefastConfigSchema = z.object({
|
|
20
|
-
mirror: mirrorConfigSchema.optional(),
|
|
21
|
-
tag: codefastTagConfigSchema.optional(),
|
|
22
|
-
arrange: codefastArrangeConfigSchema.optional()
|
|
23
|
-
}).strict();
|
|
24
|
-
//#endregion
|
|
25
|
-
export { mirrorConfigSchema as a, hookSchema as i, codefastConfigSchema as n, codefastTagConfigSchema as r, codefastArrangeConfigSchema as t };
|
package/dist/sync-e1Sp-shi.mjs
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { t as messageFromCaughtUnknown } from "./caught-unknown-message-CRhkDWO7.mjs";
|
|
2
|
-
import { r as PACKAGE_JSON, t as DIST_DIR } from "./constants-Bq5wdyLC.mjs";
|
|
3
|
-
import { n as generateExports, t as createPathTransform } from "./engine-DRTdkc5u.mjs";
|
|
4
|
-
import { t as resolvePackageFilterUnderRoot } from "./package-filter-C_8ryqvz.mjs";
|
|
5
|
-
import { a as mirrorBanner, c as mirrorNoPackages, d as mirrorSummarySeparator, i as logSkippedWorkspacePackage, l as mirrorProcessingMode, n as logPackageError, o as mirrorFatalError, r as logPackageSuccess, t as configureMirrorColors, u as mirrorSummary } from "./reporter-CwIe_tAM.mjs";
|
|
6
|
-
import { n as resolvePackageDisplayName, r as writePackageJsonExportsAtomic } from "./update-pkg-CnGfjWBy.mjs";
|
|
7
|
-
import { t as findWorkspacePackageRelPaths } from "./workspace-packages-K2NYTHJq.mjs";
|
|
8
|
-
import path from "node:path";
|
|
9
|
-
//#region src/lib/mirror/application/sync.ts
|
|
10
|
-
function resolvePackageScopedConfig(configMap, pkgMeta) {
|
|
11
|
-
if (!configMap) return void 0;
|
|
12
|
-
return configMap[pkgMeta.packageName];
|
|
13
|
-
}
|
|
14
|
-
function isPackageSkipped(skipPackagesArray, pkgMeta) {
|
|
15
|
-
if (!skipPackagesArray) return false;
|
|
16
|
-
return skipPackagesArray.includes(pkgMeta.packageName);
|
|
17
|
-
}
|
|
18
|
-
async function syncExportsForWorkspacePackage(fs, logger, rootDir, packagePathStr, index, total, config, verbose, stats) {
|
|
19
|
-
const packageDir = path.resolve(rootDir, packagePathStr);
|
|
20
|
-
const distDir = path.join(packageDir, DIST_DIR);
|
|
21
|
-
const packageJsonPath = path.join(packageDir, PACKAGE_JSON);
|
|
22
|
-
const folderBasename = path.basename(packageDir);
|
|
23
|
-
const pkgStats = {
|
|
24
|
-
name: folderBasename,
|
|
25
|
-
path: packageDir,
|
|
26
|
-
jsModules: 0,
|
|
27
|
-
cssExports: 0,
|
|
28
|
-
customExports: 0,
|
|
29
|
-
totalExports: 0,
|
|
30
|
-
hasTransform: false,
|
|
31
|
-
cssConfigStatus: "",
|
|
32
|
-
skipped: false,
|
|
33
|
-
skipReason: "",
|
|
34
|
-
error: null
|
|
35
|
-
};
|
|
36
|
-
if (!fs.existsSync(packageJsonPath)) {
|
|
37
|
-
pkgStats.skipped = true;
|
|
38
|
-
pkgStats.skipReason = "package.json not found";
|
|
39
|
-
stats.packagesSkipped++;
|
|
40
|
-
logSkippedWorkspacePackage(logger, index, total, folderBasename, pkgStats.skipReason);
|
|
41
|
-
return pkgStats;
|
|
42
|
-
}
|
|
43
|
-
let packageJsonParseError;
|
|
44
|
-
try {
|
|
45
|
-
const pkgContent = await fs.readFile(packageJsonPath, "utf8");
|
|
46
|
-
const raw = JSON.parse(pkgContent);
|
|
47
|
-
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) throw new SyntaxError("package.json root must be a JSON object");
|
|
48
|
-
pkgStats.name = resolvePackageDisplayName(raw, folderBasename);
|
|
49
|
-
} catch (caughtError) {
|
|
50
|
-
pkgStats.name = folderBasename;
|
|
51
|
-
packageJsonParseError = caughtError;
|
|
52
|
-
}
|
|
53
|
-
const pkgMeta = { packageName: pkgStats.name };
|
|
54
|
-
if (isPackageSkipped(config.skipPackages, pkgMeta)) {
|
|
55
|
-
pkgStats.skipped = true;
|
|
56
|
-
pkgStats.skipReason = "configured to skip";
|
|
57
|
-
stats.packagesSkipped++;
|
|
58
|
-
logSkippedWorkspacePackage(logger, index, total, pkgStats.name, pkgStats.skipReason);
|
|
59
|
-
return pkgStats;
|
|
60
|
-
}
|
|
61
|
-
if (packageJsonParseError !== void 0) {
|
|
62
|
-
if (!fs.existsSync(distDir)) {
|
|
63
|
-
pkgStats.skipped = true;
|
|
64
|
-
pkgStats.skipReason = "dist/ not found";
|
|
65
|
-
stats.packagesSkipped++;
|
|
66
|
-
logSkippedWorkspacePackage(logger, index, total, pkgStats.name, pkgStats.skipReason);
|
|
67
|
-
return pkgStats;
|
|
68
|
-
}
|
|
69
|
-
pkgStats.error = messageFromCaughtUnknown(packageJsonParseError);
|
|
70
|
-
stats.packagesErrored++;
|
|
71
|
-
logPackageError(logger, index, total, pkgStats.name, packageJsonParseError, verbose);
|
|
72
|
-
return pkgStats;
|
|
73
|
-
}
|
|
74
|
-
if (!fs.existsSync(distDir)) {
|
|
75
|
-
pkgStats.skipped = true;
|
|
76
|
-
pkgStats.skipReason = "dist/ not found";
|
|
77
|
-
stats.packagesSkipped++;
|
|
78
|
-
logSkippedWorkspacePackage(logger, index, total, pkgStats.name, pkgStats.skipReason);
|
|
79
|
-
return pkgStats;
|
|
80
|
-
}
|
|
81
|
-
try {
|
|
82
|
-
const pathTransform = createPathTransform(config, pkgMeta);
|
|
83
|
-
pkgStats.hasTransform = !!pathTransform;
|
|
84
|
-
const cssConfig = resolvePackageScopedConfig(config.cssExports, pkgMeta);
|
|
85
|
-
if (cssConfig === false) pkgStats.cssConfigStatus = "disabled";
|
|
86
|
-
else if (cssConfig !== void 0) pkgStats.cssConfigStatus = "configured";
|
|
87
|
-
const customExports = resolvePackageScopedConfig(config.customExports, pkgMeta) || {};
|
|
88
|
-
const generatedExports = await generateExports(fs, distDir, pathTransform, cssConfig, customExports);
|
|
89
|
-
await writePackageJsonExportsAtomic(fs, packageJsonPath, generatedExports.exports);
|
|
90
|
-
pkgStats.jsModules = generatedExports.jsCount;
|
|
91
|
-
pkgStats.cssExports = generatedExports.cssCount;
|
|
92
|
-
pkgStats.customExports = Object.keys(customExports).length;
|
|
93
|
-
pkgStats.totalExports = Object.keys(generatedExports.exports).length;
|
|
94
|
-
stats.packagesProcessed++;
|
|
95
|
-
stats.totalExports += pkgStats.totalExports;
|
|
96
|
-
stats.totalJsModules += pkgStats.jsModules;
|
|
97
|
-
stats.totalCssExports += pkgStats.cssExports;
|
|
98
|
-
logPackageSuccess(logger, index, total, pkgStats, generatedExports, verbose);
|
|
99
|
-
} catch (caughtError) {
|
|
100
|
-
pkgStats.error = messageFromCaughtUnknown(caughtError);
|
|
101
|
-
stats.packagesErrored++;
|
|
102
|
-
logPackageError(logger, index, total, pkgStats.name, caughtError, verbose);
|
|
103
|
-
}
|
|
104
|
-
return pkgStats;
|
|
105
|
-
}
|
|
106
|
-
/** @returns Process exit code (0 or 1). */
|
|
107
|
-
async function runMirrorSync(opts) {
|
|
108
|
-
const { fs, logger } = opts;
|
|
109
|
-
const config = opts.config ?? {};
|
|
110
|
-
configureMirrorColors(!!opts.noColor);
|
|
111
|
-
mirrorBanner(logger);
|
|
112
|
-
const startTime = performance.now();
|
|
113
|
-
const verbose = !!opts.verbose;
|
|
114
|
-
try {
|
|
115
|
-
const stats = {
|
|
116
|
-
packagesFound: 0,
|
|
117
|
-
packagesProcessed: 0,
|
|
118
|
-
packagesSkipped: 0,
|
|
119
|
-
packagesErrored: 0,
|
|
120
|
-
totalExports: 0,
|
|
121
|
-
totalJsModules: 0,
|
|
122
|
-
totalCssExports: 0,
|
|
123
|
-
packageDetails: []
|
|
124
|
-
};
|
|
125
|
-
let targetPackages = [];
|
|
126
|
-
if (opts.packageFilter) {
|
|
127
|
-
targetPackages = [resolvePackageFilterUnderRoot(opts.rootDir, opts.packageFilter)];
|
|
128
|
-
mirrorProcessingMode(logger, { kind: "single" });
|
|
129
|
-
} else {
|
|
130
|
-
const { relPaths, multiSource } = await findWorkspacePackageRelPaths(opts.rootDir, fs, logger);
|
|
131
|
-
targetPackages = relPaths;
|
|
132
|
-
mirrorProcessingMode(logger, {
|
|
133
|
-
kind: "multi",
|
|
134
|
-
source: multiSource
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
stats.packagesFound = targetPackages.length;
|
|
138
|
-
if (targetPackages.length === 0) {
|
|
139
|
-
mirrorNoPackages(logger);
|
|
140
|
-
return 0;
|
|
141
|
-
}
|
|
142
|
-
let nextPackageOrdinal = 1;
|
|
143
|
-
for (const pkgPath of targetPackages) {
|
|
144
|
-
const pkgStats = await syncExportsForWorkspacePackage(fs, logger, opts.rootDir, pkgPath, nextPackageOrdinal++, targetPackages.length, config, verbose, stats);
|
|
145
|
-
stats.packageDetails.push(pkgStats);
|
|
146
|
-
}
|
|
147
|
-
const elapsed = (performance.now() - startTime) / 1e3;
|
|
148
|
-
mirrorSummarySeparator(logger);
|
|
149
|
-
mirrorSummary(logger, stats, elapsed);
|
|
150
|
-
return stats.packagesErrored > 0 ? 1 : 0;
|
|
151
|
-
} catch (caughtError) {
|
|
152
|
-
mirrorFatalError(logger, caughtError);
|
|
153
|
-
return 1;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
//#endregion
|
|
157
|
-
export { runMirrorSync as t };
|
package/dist/tag-Cd9JujU5.mjs
DELETED
package/dist/tag-hEKVZ_-7.mjs
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { t as messageFromCaughtUnknown } from "./caught-unknown-message-CRhkDWO7.mjs";
|
|
2
|
-
import { t as loadConfig } from "./loader-DpN-zl5g.mjs";
|
|
3
|
-
import "./config-DVia_f9a.mjs";
|
|
4
|
-
import { t as printConfigSchemaWarnings } from "./config-reporter-SCcWDZc1.mjs";
|
|
5
|
-
import { n as createNodeCliLogger, t as createNodeCliFs } from "./node-io-DFRbHO6m.mjs";
|
|
6
|
-
import { t as findRepoRoot } from "./repo-root-HmtIEm6J.mjs";
|
|
7
|
-
import { r as runTagSync } from "./engine-CcWEHSCq.mjs";
|
|
8
|
-
import { a as formatWarningsAndErrors, i as formatTargetTable, r as formatSummary, t as createTagProgressListener } from "./tag-presenter-Cs66UBsH.mjs";
|
|
9
|
-
import "./tag-Cd9JujU5.mjs";
|
|
10
|
-
import process from "node:process";
|
|
11
|
-
import path from "node:path";
|
|
12
|
-
//#region src/commands/tag.ts
|
|
13
|
-
function resolveTagRootDir(fs, logger) {
|
|
14
|
-
try {
|
|
15
|
-
return findRepoRoot(fs);
|
|
16
|
-
} catch (caughtRepoRootError) {
|
|
17
|
-
logger.out(`[tag] workspace root auto-detection failed (${messageFromCaughtUnknown(caughtRepoRootError)}), using cwd=${process.cwd()}`);
|
|
18
|
-
return process.cwd();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function registerTagCommand(program) {
|
|
22
|
-
program.command("tag").alias("annotate").description("Add @since <version> JSDoc tags to exported declarations").argument("[target]", "Directory or file to annotate (default: auto-discover workspace packages)").option("--dry-run", "Show summary without writing files", false).action(async (target, options) => {
|
|
23
|
-
const fs = createNodeCliFs();
|
|
24
|
-
const logger = createNodeCliLogger();
|
|
25
|
-
const rootDir = resolveTagRootDir(fs, logger);
|
|
26
|
-
let tagConfig = {};
|
|
27
|
-
try {
|
|
28
|
-
const { config, warnings } = await loadConfig(fs, rootDir);
|
|
29
|
-
printConfigSchemaWarnings(logger, warnings);
|
|
30
|
-
tagConfig = config.tag ?? {};
|
|
31
|
-
} catch (caughtConfigError) {
|
|
32
|
-
logger.err(messageFromCaughtUnknown(caughtConfigError));
|
|
33
|
-
process.exitCode = 1;
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
const tagResult = await runTagSync({
|
|
37
|
-
rootDir,
|
|
38
|
-
config: tagConfig,
|
|
39
|
-
skipPackages: tagConfig.skipPackages,
|
|
40
|
-
targetPath: target ? path.resolve(target) : void 0,
|
|
41
|
-
write: !options.dryRun,
|
|
42
|
-
fs,
|
|
43
|
-
listener: createTagProgressListener((line) => logger.out(line))
|
|
44
|
-
});
|
|
45
|
-
logger.out(formatTargetTable(tagResult.selectedTargets, rootDir));
|
|
46
|
-
if (tagResult.selectedTargets.length === 0) {
|
|
47
|
-
logger.err("No packages found in workspace. Check your pnpm-workspace.yaml or provide an explicit target path.");
|
|
48
|
-
process.exitCode = 1;
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const warningsAndErrorsSection = formatWarningsAndErrors(tagResult);
|
|
52
|
-
if (warningsAndErrorsSection) logger.err(warningsAndErrorsSection);
|
|
53
|
-
logger.out(formatSummary(tagResult));
|
|
54
|
-
process.exitCode = tagResult.targetResults.some((targetResult) => targetResult.runError !== null) || tagResult.hookError ? 1 : 0;
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
//#endregion
|
|
58
|
-
export { registerTagCommand as t };
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { n as withTagColor, t as TAG_COLORS } from "./colors-BjdkCfGK.mjs";
|
|
2
|
-
//#region src/lib/tag/presentation/tag-presenter.ts
|
|
3
|
-
function targetDisplayName(target) {
|
|
4
|
-
return target.packageName ?? target.rootRelativeTargetPath;
|
|
5
|
-
}
|
|
6
|
-
function warningsAndErrorsFromResult(result) {
|
|
7
|
-
const entries = [];
|
|
8
|
-
for (const targetResult of result.targetResults) if (targetResult.runError) entries.push(targetResult.runError);
|
|
9
|
-
if (result.hookError) entries.push(result.hookError);
|
|
10
|
-
return entries;
|
|
11
|
-
}
|
|
12
|
-
function formatProgress(event) {
|
|
13
|
-
if (event.type === "target-started") return `[tag] Processing ${targetDisplayName(event.target)}...`;
|
|
14
|
-
const changedFiles = event.result.result?.filesChanged ?? 0;
|
|
15
|
-
return `[tag] Done ${targetDisplayName(event.target)} (${changedFiles} changes)`;
|
|
16
|
-
}
|
|
17
|
-
function formatTargetTable(targets, rootDir) {
|
|
18
|
-
const packageColumnWidth = Math.max(7, ...targets.map((target) => (target.packageName ?? "-").length));
|
|
19
|
-
const pathColumnWidth = Math.max(4, ...targets.map((target) => target.rootRelativeTargetPath.length));
|
|
20
|
-
const lines = [];
|
|
21
|
-
lines.push(`[tag] Root: ${rootDir}`);
|
|
22
|
-
lines.push(`[tag] Resolved targets: ${targets.length}`);
|
|
23
|
-
lines.push("[tag] Targets:");
|
|
24
|
-
lines.push(` ${"package".padEnd(packageColumnWidth)} ${"path".padEnd(pathColumnWidth)} source`);
|
|
25
|
-
lines.push(` ${"-".repeat(packageColumnWidth)} ${"-".repeat(pathColumnWidth)} ${"-".repeat(6)}`);
|
|
26
|
-
for (const target of targets) lines.push(` ${(target.packageName ?? "-").padEnd(packageColumnWidth)} ${target.rootRelativeTargetPath.padEnd(pathColumnWidth)} ${target.source}`);
|
|
27
|
-
return lines.join("\n");
|
|
28
|
-
}
|
|
29
|
-
function formatWarningsAndErrors(result) {
|
|
30
|
-
const entries = warningsAndErrorsFromResult(result);
|
|
31
|
-
if (entries.length === 0) return null;
|
|
32
|
-
const lines = [withTagColor("⚠️ Warnings & Errors", TAG_COLORS.YELLOW)];
|
|
33
|
-
for (const entry of entries) lines.push(withTagColor(`- ${entry}`, TAG_COLORS.RED));
|
|
34
|
-
return lines.join("\n");
|
|
35
|
-
}
|
|
36
|
-
function formatSummary(result) {
|
|
37
|
-
const isDryRun = result.mode === "dry-run";
|
|
38
|
-
const summaryPrefix = isDryRun ? "[tag:dry-run]" : "[tag]";
|
|
39
|
-
const versionSuffix = result.versionSummary === "mixed" && result.distinctVersions.length > 0 ? ` [${result.distinctVersions.join(", ")}]` : "";
|
|
40
|
-
const summaryColor = result.targetResults.some((targetResult) => targetResult.runError !== null) || result.hookError !== null ? TAG_COLORS.RED : isDryRun ? TAG_COLORS.YELLOW : TAG_COLORS.GREEN;
|
|
41
|
-
const lines = [withTagColor(`${summaryPrefix} version=${result.versionSummary}${versionSuffix} files=${result.filesChanged}/${result.filesScanned} declarations=${result.taggedDeclarations}`, summaryColor)];
|
|
42
|
-
if (result.skippedPackages.length > 0) lines.push(`[tag] Skipped: ${result.skippedPackages.length} package(s)`);
|
|
43
|
-
return lines.join("\n");
|
|
44
|
-
}
|
|
45
|
-
function createTagProgressListener(onProgressLine) {
|
|
46
|
-
return {
|
|
47
|
-
onTargetStarted: (target) => {
|
|
48
|
-
onProgressLine(formatProgress({
|
|
49
|
-
type: "target-started",
|
|
50
|
-
target
|
|
51
|
-
}));
|
|
52
|
-
},
|
|
53
|
-
onTargetCompleted: (target, result) => {
|
|
54
|
-
onProgressLine(formatProgress({
|
|
55
|
-
type: "target-completed",
|
|
56
|
-
target,
|
|
57
|
-
result
|
|
58
|
-
}));
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
//#endregion
|
|
63
|
-
export { formatWarningsAndErrors as a, formatTargetTable as i, formatProgress as n, formatSummary as r, createTagProgressListener as t };
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { t as messageFromCaughtUnknown } from "./caught-unknown-message-CRhkDWO7.mjs";
|
|
2
|
-
import { globSync } from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import picomatch from "picomatch";
|
|
6
|
-
import { parse } from "yaml";
|
|
7
|
-
//#region src/lib/tag/infra/target-resolver.ts
|
|
8
|
-
const PNPM_WORKSPACE_FILE = "pnpm-workspace.yaml";
|
|
9
|
-
const PACKAGE_JSON_FILE = "package.json";
|
|
10
|
-
const DEFAULT_WORKSPACE_PACKAGE_PATTERNS = ["packages/*"];
|
|
11
|
-
const PnpmWorkspaceSchema = z.object({ packages: z.array(z.string()).optional() }).passthrough();
|
|
12
|
-
const PackageNameSchema = z.object({ name: z.string().min(1).optional() }).passthrough();
|
|
13
|
-
function toPosix(filePath) {
|
|
14
|
-
return filePath.split(path.sep).join("/");
|
|
15
|
-
}
|
|
16
|
-
function workspacePatternToPackageJsonGlob(pattern) {
|
|
17
|
-
const normalizedPattern = toPosix(pattern.trim()).replace(/\/+$/, "");
|
|
18
|
-
if (!normalizedPattern) return `**/${PACKAGE_JSON_FILE}`;
|
|
19
|
-
return `${normalizedPattern}/${PACKAGE_JSON_FILE}`;
|
|
20
|
-
}
|
|
21
|
-
function splitWorkspacePackagePatterns(rawPatterns) {
|
|
22
|
-
const include = [];
|
|
23
|
-
const exclude = [];
|
|
24
|
-
for (const rawPattern of rawPatterns) {
|
|
25
|
-
const trimmedPattern = rawPattern.trim();
|
|
26
|
-
if (!trimmedPattern) continue;
|
|
27
|
-
if (trimmedPattern.startsWith("!")) {
|
|
28
|
-
exclude.push(trimmedPattern.slice(1).trim());
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
include.push(trimmedPattern);
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
include,
|
|
35
|
-
exclude
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
async function readWorkspacePackagePatterns(rootDir, fs) {
|
|
39
|
-
const workspaceYamlPath = path.join(rootDir, PNPM_WORKSPACE_FILE);
|
|
40
|
-
if (!fs.existsSync(workspaceYamlPath)) return {
|
|
41
|
-
patterns: [...DEFAULT_WORKSPACE_PACKAGE_PATTERNS],
|
|
42
|
-
hasWorkspaceFile: false,
|
|
43
|
-
declaredEmptyPackages: false
|
|
44
|
-
};
|
|
45
|
-
let workspaceYamlRaw = "";
|
|
46
|
-
try {
|
|
47
|
-
workspaceYamlRaw = await fs.readFile(workspaceYamlPath, "utf8");
|
|
48
|
-
} catch (caughtReadError) {
|
|
49
|
-
throw new Error(`Failed to read ${PNPM_WORKSPACE_FILE}: ${messageFromCaughtUnknown(caughtReadError)}`);
|
|
50
|
-
}
|
|
51
|
-
let parsedWorkspaceDoc;
|
|
52
|
-
try {
|
|
53
|
-
parsedWorkspaceDoc = parse(workspaceYamlRaw);
|
|
54
|
-
} catch (caughtParseError) {
|
|
55
|
-
throw new Error(`Failed to parse ${PNPM_WORKSPACE_FILE}: ${messageFromCaughtUnknown(caughtParseError)}`);
|
|
56
|
-
}
|
|
57
|
-
const parsedWorkspaceResult = PnpmWorkspaceSchema.safeParse(parsedWorkspaceDoc);
|
|
58
|
-
if (!parsedWorkspaceResult.success) {
|
|
59
|
-
const issuePath = parsedWorkspaceResult.error.issues[0]?.path.join(".") ?? "<root>";
|
|
60
|
-
const issueMessage = parsedWorkspaceResult.error.issues[0]?.message ?? "Invalid value";
|
|
61
|
-
throw new Error(`Invalid ${PNPM_WORKSPACE_FILE} schema at "${issuePath}": ${issueMessage}`);
|
|
62
|
-
}
|
|
63
|
-
const hasPackagesKey = typeof parsedWorkspaceDoc === "object" && parsedWorkspaceDoc !== null && Object.prototype.hasOwnProperty.call(parsedWorkspaceDoc, "packages");
|
|
64
|
-
const workspacePackages = parsedWorkspaceResult.data.packages;
|
|
65
|
-
if (!workspacePackages) return {
|
|
66
|
-
patterns: [...DEFAULT_WORKSPACE_PACKAGE_PATTERNS],
|
|
67
|
-
hasWorkspaceFile: true,
|
|
68
|
-
declaredEmptyPackages: false
|
|
69
|
-
};
|
|
70
|
-
if (workspacePackages.length === 0 && hasPackagesKey) return {
|
|
71
|
-
patterns: [],
|
|
72
|
-
hasWorkspaceFile: true,
|
|
73
|
-
declaredEmptyPackages: true
|
|
74
|
-
};
|
|
75
|
-
return {
|
|
76
|
-
patterns: workspacePackages,
|
|
77
|
-
hasWorkspaceFile: true,
|
|
78
|
-
declaredEmptyPackages: false
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
async function discoverWorkspacePackageDirs(rootDir, fs) {
|
|
82
|
-
const workspacePackages = await readWorkspacePackagePatterns(rootDir, fs);
|
|
83
|
-
const { include, exclude } = splitWorkspacePackagePatterns(workspacePackages.patterns);
|
|
84
|
-
const includePatterns = include.length > 0 ? include : [...DEFAULT_WORKSPACE_PACKAGE_PATTERNS];
|
|
85
|
-
const foundPackageDirs = /* @__PURE__ */ new Set();
|
|
86
|
-
const globOptions = {
|
|
87
|
-
cwd: rootDir,
|
|
88
|
-
posix: true,
|
|
89
|
-
...path.sep === "\\" ? { windowsPathsNoEscape: true } : {}
|
|
90
|
-
};
|
|
91
|
-
for (const pattern of includePatterns) {
|
|
92
|
-
const matches = globSync(workspacePatternToPackageJsonGlob(pattern), globOptions);
|
|
93
|
-
for (const matchedPath of matches) {
|
|
94
|
-
if (!matchedPath.endsWith(`/${PACKAGE_JSON_FILE}`)) continue;
|
|
95
|
-
const packageRelDir = matchedPath.slice(0, -`/${PACKAGE_JSON_FILE}`.length);
|
|
96
|
-
if (!packageRelDir) continue;
|
|
97
|
-
foundPackageDirs.add(path.resolve(rootDir, packageRelDir));
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
if (exclude.length === 0) return {
|
|
101
|
-
packageDirs: [...foundPackageDirs].sort((leftDir, rightDir) => leftDir.localeCompare(rightDir)),
|
|
102
|
-
hasWorkspaceFile: workspacePackages.hasWorkspaceFile,
|
|
103
|
-
declaredEmptyPackages: workspacePackages.declaredEmptyPackages
|
|
104
|
-
};
|
|
105
|
-
const excludeMatchers = exclude.map((excludePattern) => picomatch(excludePattern, { dot: true }));
|
|
106
|
-
const discoveredDirs = [...foundPackageDirs].filter((packageDir) => {
|
|
107
|
-
const relativePackagePath = toPosix(path.relative(rootDir, packageDir));
|
|
108
|
-
return !excludeMatchers.some((excludeMatcher) => excludeMatcher(relativePackagePath));
|
|
109
|
-
});
|
|
110
|
-
discoveredDirs.sort((leftDir, rightDir) => leftDir.localeCompare(rightDir));
|
|
111
|
-
return {
|
|
112
|
-
packageDirs: discoveredDirs,
|
|
113
|
-
hasWorkspaceFile: workspacePackages.hasWorkspaceFile,
|
|
114
|
-
declaredEmptyPackages: workspacePackages.declaredEmptyPackages
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
function readPackageName(packageDir, fs) {
|
|
118
|
-
const packageJsonPath = path.join(packageDir, PACKAGE_JSON_FILE);
|
|
119
|
-
if (!fs.existsSync(packageJsonPath)) return null;
|
|
120
|
-
try {
|
|
121
|
-
const rawPackageJson = fs.readFileSync(packageJsonPath, "utf8");
|
|
122
|
-
const parsedPackageJson = JSON.parse(rawPackageJson);
|
|
123
|
-
const parsedPackageName = PackageNameSchema.safeParse(parsedPackageJson);
|
|
124
|
-
if (!parsedPackageName.success) return null;
|
|
125
|
-
return parsedPackageName.data.name ?? null;
|
|
126
|
-
} catch {
|
|
127
|
-
return null;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
function toRootRelativePath(rootDir, absolutePath) {
|
|
131
|
-
const relativePath = path.relative(rootDir, absolutePath);
|
|
132
|
-
return relativePath ? toPosix(relativePath) : ".";
|
|
133
|
-
}
|
|
134
|
-
function toPackageTargetCandidate(rootDir, packageDir, fs) {
|
|
135
|
-
const packageName = readPackageName(packageDir, fs);
|
|
136
|
-
return {
|
|
137
|
-
candidatePath: packageDir,
|
|
138
|
-
rootRelativeCandidatePath: toRootRelativePath(rootDir, packageDir),
|
|
139
|
-
source: "workspace-package",
|
|
140
|
-
packageDir,
|
|
141
|
-
packageName
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
async function resolveTagTargetCandidates(rootDir, explicitTarget, fs) {
|
|
145
|
-
if (explicitTarget) {
|
|
146
|
-
const resolvedExplicitTarget = path.resolve(explicitTarget);
|
|
147
|
-
return [{
|
|
148
|
-
candidatePath: resolvedExplicitTarget,
|
|
149
|
-
rootRelativeCandidatePath: toRootRelativePath(rootDir, resolvedExplicitTarget),
|
|
150
|
-
source: "explicit-target",
|
|
151
|
-
packageDir: null,
|
|
152
|
-
packageName: null
|
|
153
|
-
}];
|
|
154
|
-
}
|
|
155
|
-
const workspaceDiscovery = await discoverWorkspacePackageDirs(rootDir, fs);
|
|
156
|
-
if (workspaceDiscovery.packageDirs.length === 0) {
|
|
157
|
-
if (workspaceDiscovery.hasWorkspaceFile) return [];
|
|
158
|
-
const repoSourceDir = path.join(rootDir, "src");
|
|
159
|
-
return [{
|
|
160
|
-
candidatePath: repoSourceDir,
|
|
161
|
-
rootRelativeCandidatePath: toRootRelativePath(rootDir, repoSourceDir),
|
|
162
|
-
source: "repo-src-fallback",
|
|
163
|
-
packageDir: null,
|
|
164
|
-
packageName: null
|
|
165
|
-
}];
|
|
166
|
-
}
|
|
167
|
-
return workspaceDiscovery.packageDirs.map((packageDir) => toPackageTargetCandidate(rootDir, packageDir, fs));
|
|
168
|
-
}
|
|
169
|
-
//#endregion
|
|
170
|
-
export { resolveTagTargetCandidates as t };
|