@ariestools/toolchain 8.7.17 → 8.7.19
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/actions/barrel/checkBarrelImportRestrictions.d.ts +10 -1
- package/dist/actions/barrel/checkBarrelImportRestrictions.d.ts.map +1 -1
- package/dist/actions/clean.d.ts +6 -3
- package/dist/actions/clean.d.ts.map +1 -1
- package/dist/actions/package/clean-outputs.d.ts +6 -0
- package/dist/actions/package/clean-outputs.d.ts.map +1 -1
- package/dist/actions/package/cleanPlan.d.ts +13 -1
- package/dist/actions/package/cleanPlan.d.ts.map +1 -1
- package/dist/actions/package/cleanRules.d.ts +8 -2
- package/dist/actions/package/cleanRules.d.ts.map +1 -1
- package/dist/bin/package/clean.mjs +13 -7
- package/dist/bin/package/clean.mjs.map +1 -1
- package/dist/bin/package/recompile.mjs +13 -7
- package/dist/bin/package/recompile.mjs.map +1 -1
- package/dist/bin/xy.mjs +141 -25
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/xy/install/cleanCommand.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/bin/xy.mjs
CHANGED
|
@@ -27063,7 +27063,53 @@ function collectDescriptorBarrelInfo(configDir, descriptors) {
|
|
|
27063
27063
|
}
|
|
27064
27064
|
return info;
|
|
27065
27065
|
}
|
|
27066
|
-
function
|
|
27066
|
+
function allReferencesForUsage(usage) {
|
|
27067
|
+
const references = [...usage.defaultReferences, ...usage.namespaceReferences];
|
|
27068
|
+
for (const named of usage.namedReferences.values()) references.push(...named);
|
|
27069
|
+
return references;
|
|
27070
|
+
}
|
|
27071
|
+
function workspacePackageForFile(file, rootDir, workspaces) {
|
|
27072
|
+
const absFile = PATH.resolve(file);
|
|
27073
|
+
let best;
|
|
27074
|
+
for (const workspace of workspaces) {
|
|
27075
|
+
const locationAbs = PATH.resolve(rootDir, workspace.location);
|
|
27076
|
+
if ((absFile === locationAbs || absFile.startsWith(locationAbs + PATH.sep)) && (best === void 0 || locationAbs.length > best.length)) best = {
|
|
27077
|
+
length: locationAbs.length,
|
|
27078
|
+
location: workspace.location,
|
|
27079
|
+
name: workspace.name
|
|
27080
|
+
};
|
|
27081
|
+
}
|
|
27082
|
+
return best?.name;
|
|
27083
|
+
}
|
|
27084
|
+
function pushUniqueImportSites(sites, seen, subPackage, usage, rootDir, workspaces) {
|
|
27085
|
+
for (const reference of allReferencesForUsage(usage)) {
|
|
27086
|
+
const key = `${reference.file}:${reference.line}:${subPackage}`;
|
|
27087
|
+
if (seen.has(key)) continue;
|
|
27088
|
+
seen.add(key);
|
|
27089
|
+
sites.push({
|
|
27090
|
+
file: reference.file,
|
|
27091
|
+
line: reference.line,
|
|
27092
|
+
subPackage,
|
|
27093
|
+
workspacePackage: workspacePackageForFile(reference.file, rootDir, workspaces)
|
|
27094
|
+
});
|
|
27095
|
+
}
|
|
27096
|
+
}
|
|
27097
|
+
function importSitesForSubPackages(subPackages, usage, rootDir, workspaces) {
|
|
27098
|
+
const sites = [];
|
|
27099
|
+
for (const subPackage of subPackages) {
|
|
27100
|
+
const entry = usage.get(subPackage);
|
|
27101
|
+
if (entry === void 0) continue;
|
|
27102
|
+
pushUniqueImportSites(sites, /* @__PURE__ */ new Set(), subPackage, entry, rootDir, workspaces);
|
|
27103
|
+
}
|
|
27104
|
+
return sites.toSorted((left, right) => {
|
|
27105
|
+
const byPkg = left.subPackage.localeCompare(right.subPackage);
|
|
27106
|
+
if (byPkg !== 0) return byPkg;
|
|
27107
|
+
const byFile = left.file.localeCompare(right.file);
|
|
27108
|
+
if (byFile !== 0) return byFile;
|
|
27109
|
+
return left.line - right.line;
|
|
27110
|
+
});
|
|
27111
|
+
}
|
|
27112
|
+
function findRestrictionIssues(barrelInfo, restrictedPaths, isRuleEnabled, usage, source, rootDir, workspaces) {
|
|
27067
27113
|
const issues = [];
|
|
27068
27114
|
for (const { descriptor, subPackages } of barrelInfo) {
|
|
27069
27115
|
const usedSubPackages = subPackages.filter((pkg) => usage.has(pkg));
|
|
@@ -27071,17 +27117,22 @@ function findRestrictionIssues(barrelInfo, restrictedPaths, isRuleEnabled, usage
|
|
|
27071
27117
|
const configured = configuredNamesForDescriptor(restrictedPaths, descriptor, source);
|
|
27072
27118
|
const configuredSet = new Set(configured);
|
|
27073
27119
|
const missingFromConfig = usedSubPackages.filter((pkg) => !configuredSet.has(pkg));
|
|
27120
|
+
const relevantSubPackages = !isRuleEnabled || configured.length === 0 ? usedSubPackages : missingFromConfig;
|
|
27121
|
+
if (relevantSubPackages.length === 0) continue;
|
|
27122
|
+
const importSites = importSitesForSubPackages(relevantSubPackages, usage, rootDir, workspaces);
|
|
27074
27123
|
if (!isRuleEnabled || configured.length === 0) {
|
|
27075
27124
|
issues.push({
|
|
27076
27125
|
descriptor,
|
|
27126
|
+
importSites,
|
|
27077
27127
|
kind: "missing",
|
|
27078
27128
|
missingFromConfig: usedSubPackages,
|
|
27079
27129
|
usedSubPackages
|
|
27080
27130
|
});
|
|
27081
27131
|
continue;
|
|
27082
27132
|
}
|
|
27083
|
-
|
|
27133
|
+
issues.push({
|
|
27084
27134
|
descriptor,
|
|
27135
|
+
importSites,
|
|
27085
27136
|
kind: "incomplete",
|
|
27086
27137
|
missingFromConfig,
|
|
27087
27138
|
usedSubPackages
|
|
@@ -27099,25 +27150,49 @@ async function findBarrelImportRestrictionIssues(rootDir) {
|
|
|
27099
27150
|
const watchSet = new Set(barrelInfo.flatMap((entry) => entry.subPackages));
|
|
27100
27151
|
const usage = collectExternalUsage(workspaces.map((workspace) => PATH.resolve(rootDir, workspace.location)), watchSet);
|
|
27101
27152
|
const source = readFileSync(resolved.eslintConfigPath, "utf8");
|
|
27102
|
-
return findRestrictionIssues(barrelInfo, resolved.restrictedPaths, resolved.ruleEnabled, usage, source);
|
|
27103
|
-
}
|
|
27104
|
-
function
|
|
27153
|
+
return findRestrictionIssues(barrelInfo, resolved.restrictedPaths, resolved.ruleEnabled, usage, source, rootDir, workspaces);
|
|
27154
|
+
}
|
|
27155
|
+
function formatImportSite(site, rootDir) {
|
|
27156
|
+
const relativeFile = PATH.relative(rootDir, site.file);
|
|
27157
|
+
const location = relativeFile.length > 0 ? relativeFile : site.file;
|
|
27158
|
+
const packageLabel = site.workspacePackage === void 0 ? "" : chalk.gray(` (${site.workspacePackage})`);
|
|
27159
|
+
return `${location}:${site.line}${packageLabel}`;
|
|
27160
|
+
}
|
|
27161
|
+
function reportImportSites(sites, rootDir) {
|
|
27162
|
+
if (sites.length === 0) return;
|
|
27163
|
+
const bySubPackage = /* @__PURE__ */ new Map();
|
|
27164
|
+
for (const site of sites) {
|
|
27165
|
+
const group = bySubPackage.get(site.subPackage) ?? [];
|
|
27166
|
+
group.push(site);
|
|
27167
|
+
bySubPackage.set(site.subPackage, group);
|
|
27168
|
+
}
|
|
27169
|
+
const sortedSubPackages = bySubPackage.keys().toArray().toSorted((left, right) => left.localeCompare(right));
|
|
27170
|
+
for (const subPackage of sortedSubPackages) {
|
|
27171
|
+
const group = bySubPackage.get(subPackage);
|
|
27172
|
+
if (group === void 0) continue;
|
|
27173
|
+
console.log(chalk.gray(` ${subPackage} imported by:`));
|
|
27174
|
+
for (const site of group) console.log(chalk.gray(` - ${formatImportSite(site, rootDir)}`));
|
|
27175
|
+
}
|
|
27176
|
+
}
|
|
27177
|
+
function reportBarrelImportRestrictionIssues(issues, rootDir = process.cwd()) {
|
|
27105
27178
|
if (issues.length === 0) return 0;
|
|
27106
27179
|
console.log(chalk.yellow("\nBarrel import restrictions"));
|
|
27107
27180
|
for (const issue of issues) {
|
|
27108
27181
|
if (issue.kind === "missing") {
|
|
27109
27182
|
console.log(chalk.yellow(` ${issue.descriptor.pkg}: sub-packages are imported but no-restricted-imports is not configured for this barrel`));
|
|
27110
27183
|
console.log(chalk.gray(` Run xy lint init to add restrictions for: ${issue.usedSubPackages.join(", ")}`));
|
|
27184
|
+
reportImportSites(issue.importSites, rootDir);
|
|
27111
27185
|
continue;
|
|
27112
27186
|
}
|
|
27113
27187
|
console.log(chalk.yellow(` ${issue.descriptor.pkg}: disallowed-imports list is missing entries for imported sub-packages`));
|
|
27114
27188
|
for (const name of issue.missingFromConfig) console.log(chalk.yellow(` - ${name}`));
|
|
27115
27189
|
console.log(chalk.gray(" Update eslint.config.ts or rerun xy lint init to include the missing entries"));
|
|
27190
|
+
reportImportSites(issue.importSites, rootDir);
|
|
27116
27191
|
}
|
|
27117
27192
|
return issues.length;
|
|
27118
27193
|
}
|
|
27119
27194
|
async function checkBarrelImportRestrictions(rootDir) {
|
|
27120
|
-
return reportBarrelImportRestrictionIssues(await findBarrelImportRestrictionIssues(rootDir));
|
|
27195
|
+
return reportBarrelImportRestrictionIssues(await findBarrelImportRestrictionIssues(rootDir), rootDir);
|
|
27121
27196
|
}
|
|
27122
27197
|
//#endregion
|
|
27123
27198
|
//#region src/actions/incremental.ts
|
|
@@ -33341,8 +33416,9 @@ function resolveCleanRules(config) {
|
|
|
33341
33416
|
gitignoredOnly: level("clean.gitignored-only", rules["clean.gitignored-only"])
|
|
33342
33417
|
};
|
|
33343
33418
|
}
|
|
33344
|
-
/** Merge
|
|
33345
|
-
function resolveCleanExclude(config) {
|
|
33419
|
+
/** Merge exclude patterns (deduped, order preserved). */
|
|
33420
|
+
function resolveCleanExclude(config, mode = "normal") {
|
|
33421
|
+
if (mode === "immutable-only") return [...CLEAN_IMMUTABLE_EXCLUDE];
|
|
33346
33422
|
const merged = [
|
|
33347
33423
|
...CLEAN_IMMUTABLE_EXCLUDE,
|
|
33348
33424
|
...CLEAN_DEFAULT_EXCLUDE,
|
|
@@ -33365,6 +33441,9 @@ function resolveCleanPatterns(config) {
|
|
|
33365
33441
|
init_index_min();
|
|
33366
33442
|
/** Built-in clean targets — always cleaned (bypass gitignored-only). */
|
|
33367
33443
|
const BUILTIN_CLEAN_PATTERNS = ["dist", "build"];
|
|
33444
|
+
function excludeModeForFull(fullMode) {
|
|
33445
|
+
return fullMode === "full-all" ? "immutable-only" : "normal";
|
|
33446
|
+
}
|
|
33368
33447
|
function toPosix(relativePath) {
|
|
33369
33448
|
return relativePath.split(PATH.sep).join("/");
|
|
33370
33449
|
}
|
|
@@ -33455,14 +33534,14 @@ function applyGitignoredAll(params) {
|
|
|
33455
33534
|
* 1. Hard safety on all configured patterns (throws on escape)
|
|
33456
33535
|
* 2. Expand builtins + include (always-clean; bypass gitignored-only)
|
|
33457
33536
|
* 3. Expand config patterns; enforce gitignored-only when enabled
|
|
33458
|
-
* 4. Optionally add all gitignored paths
|
|
33537
|
+
* 4. Optionally add all gitignored paths (`--full` / `--full-all` or rule)
|
|
33459
33538
|
* 5. Apply exclude + re-check inside-root
|
|
33460
33539
|
*/
|
|
33461
33540
|
function buildCleanPlan(options) {
|
|
33462
|
-
const { config, extraPatterns = [], gitignore = gitCleanGitignoreBackend, packageDir, rootDir } = options;
|
|
33541
|
+
const { config, extraPatterns = [], fullMode = "none", gitignore = gitCleanGitignoreBackend, packageDir, rootDir } = options;
|
|
33463
33542
|
const rules = resolveCleanRules(config);
|
|
33464
33543
|
const issues = [];
|
|
33465
|
-
const exclude = resolveCleanExclude(config);
|
|
33544
|
+
const exclude = resolveCleanExclude(config, excludeModeForFull(fullMode));
|
|
33466
33545
|
const configuredPatterns = [...resolveCleanPatterns(config), ...extraPatterns];
|
|
33467
33546
|
const safeBuiltin = resolveSafeCleanPatterns([...BUILTIN_CLEAN_PATTERNS], packageDir, rootDir);
|
|
33468
33547
|
const safeInclude = resolveSafeCleanPatterns(resolveCleanInclude(config), packageDir, rootDir);
|
|
@@ -33482,12 +33561,13 @@ function buildCleanPlan(options) {
|
|
|
33482
33561
|
targets
|
|
33483
33562
|
});
|
|
33484
33563
|
} else for (const absPath of patternCandidates) targets.add(absPath);
|
|
33485
|
-
|
|
33564
|
+
const forceGitignoredAll = fullMode === "full" || fullMode === "full-all";
|
|
33565
|
+
if (forceGitignoredAll || isCleanRuleEnabled(rules.gitignoredAll)) applyGitignoredAll({
|
|
33486
33566
|
gitignore,
|
|
33487
33567
|
issues,
|
|
33488
33568
|
packageDir,
|
|
33489
33569
|
rootDir,
|
|
33490
|
-
ruleLevel: rules.gitignoredAll,
|
|
33570
|
+
ruleLevel: forceGitignoredAll ? "error" : rules.gitignoredAll,
|
|
33491
33571
|
targets
|
|
33492
33572
|
});
|
|
33493
33573
|
return {
|
|
@@ -33524,6 +33604,7 @@ const packageCleanOutputs = async (options = {}) => {
|
|
|
33524
33604
|
const baseConfig = options.skipConfigLoad ? { patterns: options.extraPatterns } : await loadCleanConfig(pkg);
|
|
33525
33605
|
const plan = buildCleanPlan({
|
|
33526
33606
|
config: options.skipConfigLoad ? baseConfig : mergeExtraPatterns(baseConfig, options.extraPatterns),
|
|
33607
|
+
fullMode: options.fullMode ?? "none",
|
|
33527
33608
|
gitignore: options.gitignore,
|
|
33528
33609
|
packageDir: pkg,
|
|
33529
33610
|
rootDir
|
|
@@ -37952,15 +38033,18 @@ function hasPackageCleanScript(rootDir, workspace) {
|
|
|
37952
38033
|
const pkg = readPackageJson$2(PATH.join(rootDir, workspace.location));
|
|
37953
38034
|
return Object.hasOwn(pkg?.scripts ?? {}, "package-clean");
|
|
37954
38035
|
}
|
|
37955
|
-
async function cleanBuiltInWorkspaces(rootDir, workspaces, jobs) {
|
|
38036
|
+
async function cleanBuiltInWorkspaces(rootDir, workspaces, jobs, fullMode) {
|
|
37956
38037
|
return await safeExitAsync(async () => {
|
|
37957
|
-
|
|
38038
|
+
const log = isJsonMode() ? console.error : console.log;
|
|
38039
|
+
const fullLabel = fullMode === "none" ? "" : ` [${fullMode}]`;
|
|
38040
|
+
log(chalk.green(`Clean${fullLabel} [${packageName()}]`));
|
|
37958
38041
|
const results = Array.from({ length: workspaces.length }, () => 0);
|
|
37959
38042
|
await runWithConcurrency(workspaces.map((workspace, index) => ({
|
|
37960
38043
|
index,
|
|
37961
38044
|
workspace
|
|
37962
38045
|
})), Math.max(1, jobs), async ({ index, workspace }) => {
|
|
37963
38046
|
results[index] = await packageClean({
|
|
38047
|
+
fullMode,
|
|
37964
38048
|
pkg: PATH.resolve(rootDir, workspace.location),
|
|
37965
38049
|
pkgName: workspace.name,
|
|
37966
38050
|
rootDir
|
|
@@ -37969,27 +38053,43 @@ async function cleanBuiltInWorkspaces(rootDir, workspaces, jobs) {
|
|
|
37969
38053
|
return results.reduce((total, result) => total + result, 0);
|
|
37970
38054
|
});
|
|
37971
38055
|
}
|
|
37972
|
-
const clean = async ({ deferLocalScript, jobs, verbose, pkg }) => {
|
|
38056
|
+
const clean = async ({ deferLocalScript, fullMode = "none", jobs, verbose, pkg }) => {
|
|
37973
38057
|
if (pkg != null && pkg.length > 0) return await cleanPackage({
|
|
38058
|
+
fullMode,
|
|
37974
38059
|
pkg,
|
|
37975
38060
|
verbose
|
|
37976
38061
|
});
|
|
37977
38062
|
return cleanAll({
|
|
37978
38063
|
deferLocalScript,
|
|
38064
|
+
fullMode,
|
|
37979
38065
|
jobs,
|
|
37980
38066
|
verbose
|
|
37981
38067
|
});
|
|
37982
38068
|
};
|
|
37983
|
-
const cleanPackage = ({ pkg }) => {
|
|
38069
|
+
const cleanPackage = async ({ fullMode = "none", pkg }) => {
|
|
37984
38070
|
const pm = getPackageManager();
|
|
37985
|
-
return runStepsAsync(`Clean [${pkg}]`, [pm.runInWorkspace(pkg, "package-clean")]);
|
|
38071
|
+
if (fullMode === "none") return runStepsAsync(`Clean [${pkg}]`, [pm.runInWorkspace(pkg, "package-clean")]);
|
|
38072
|
+
const rootDir = INIT_CWD();
|
|
38073
|
+
const workspace = pm.listWorkspaces().find((entry) => entry.name === pkg || entry.location === pkg);
|
|
38074
|
+
return packageClean({
|
|
38075
|
+
fullMode,
|
|
38076
|
+
pkg: workspace === void 0 ? PATH.resolve(rootDir, pkg) : PATH.resolve(rootDir, workspace.location),
|
|
38077
|
+
pkgName: workspace?.name ?? pkg,
|
|
38078
|
+
rootDir: PATH.resolve(rootDir)
|
|
38079
|
+
});
|
|
37986
38080
|
};
|
|
37987
|
-
function cleanScriptArgs({ jobs, verbose }) {
|
|
37988
|
-
return [
|
|
38081
|
+
function cleanScriptArgs({ fullMode = "none", jobs, verbose }) {
|
|
38082
|
+
return [
|
|
38083
|
+
...jobs === void 0 ? [] : ["-j", String(jobs)],
|
|
38084
|
+
...verbose ?? false ? ["-v"] : [],
|
|
38085
|
+
...fullMode === "full" ? ["--full"] : [],
|
|
38086
|
+
...fullMode === "full-all" ? ["--full-all"] : []
|
|
38087
|
+
];
|
|
37989
38088
|
}
|
|
37990
|
-
const cleanAll = async ({ deferLocalScript = false, jobs = 64, verbose }) => {
|
|
38089
|
+
const cleanAll = async ({ deferLocalScript = false, fullMode = "none", jobs = 64, verbose }) => {
|
|
37991
38090
|
if (deferLocalScript) {
|
|
37992
38091
|
const deferredResult = tryRunLocalScript("clean", { args: cleanScriptArgs({
|
|
38092
|
+
fullMode,
|
|
37993
38093
|
jobs,
|
|
37994
38094
|
verbose
|
|
37995
38095
|
}) });
|
|
@@ -37998,8 +38098,9 @@ const cleanAll = async ({ deferLocalScript = false, jobs = 64, verbose }) => {
|
|
|
37998
38098
|
const pm = getPackageManager();
|
|
37999
38099
|
const rootDir = INIT_CWD();
|
|
38000
38100
|
const workspaces = cleanWorkspaces(rootDir, pm);
|
|
38001
|
-
const
|
|
38002
|
-
const
|
|
38101
|
+
const useBuiltInForFull = fullMode !== "none";
|
|
38102
|
+
const scripted = useBuiltInForFull ? [] : workspaces.filter((workspace) => hasPackageCleanScript(rootDir, workspace));
|
|
38103
|
+
const builtInResult = await cleanBuiltInWorkspaces(rootDir, useBuiltInForFull ? workspaces : workspaces.filter((workspace) => !hasPackageCleanScript(rootDir, workspace)), jobs, fullMode);
|
|
38003
38104
|
if (scripted.length === 0) return builtInResult;
|
|
38004
38105
|
return builtInResult + await runStepsAsync("Clean [scripts]", scripted.map((workspace) => pm.runInWorkspace(workspace.name, "package-clean")));
|
|
38005
38106
|
};
|
|
@@ -52056,16 +52157,31 @@ const xyDeployCommands = (args) => {
|
|
|
52056
52157
|
};
|
|
52057
52158
|
//#endregion
|
|
52058
52159
|
//#region src/xy/install/cleanCommand.ts
|
|
52160
|
+
function resolveFullMode(argv) {
|
|
52161
|
+
if (Boolean(argv.fullAll) || Boolean(argv["full-all"])) return "full-all";
|
|
52162
|
+
if (Boolean(argv.full)) return "full";
|
|
52163
|
+
return "none";
|
|
52164
|
+
}
|
|
52059
52165
|
const cleanCommand = {
|
|
52060
52166
|
command: "clean [package]",
|
|
52061
52167
|
describe: "Clean",
|
|
52062
52168
|
builder: (yargs) => {
|
|
52063
|
-
return yargs.positional("package", { describe: "Specific package to clean" })
|
|
52169
|
+
return yargs.positional("package", { describe: "Specific package to clean" }).option("full", {
|
|
52170
|
+
default: false,
|
|
52171
|
+
description: "Also remove all gitignored files under each package (fresh-clone hygiene; still honors clean.exclude)",
|
|
52172
|
+
type: "boolean"
|
|
52173
|
+
}).option("full-all", {
|
|
52174
|
+
default: false,
|
|
52175
|
+
description: "Like --full, but also ignores clean.exclude / default excludes (only .git is protected)",
|
|
52176
|
+
type: "boolean"
|
|
52177
|
+
});
|
|
52064
52178
|
},
|
|
52065
52179
|
handler: async (argv) => {
|
|
52066
|
-
|
|
52180
|
+
const fullMode = resolveFullMode(argv);
|
|
52181
|
+
if (Boolean(argv.verbose)) console.log(`Cleaning: ${argv.package ?? "all"}${fullMode === "none" ? "" : ` (${fullMode})`}`);
|
|
52067
52182
|
await withEnvelope("clean", () => clean({
|
|
52068
52183
|
deferLocalScript: true,
|
|
52184
|
+
fullMode,
|
|
52069
52185
|
jobs: argv.jobs,
|
|
52070
52186
|
pkg: argv.package,
|
|
52071
52187
|
verbose: !!Boolean(argv.verbose)
|