@ariestools/toolchain 8.7.17 → 8.7.18

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/xy.mjs CHANGED
@@ -33341,8 +33341,9 @@ function resolveCleanRules(config) {
33341
33341
  gitignoredOnly: level("clean.gitignored-only", rules["clean.gitignored-only"])
33342
33342
  };
33343
33343
  }
33344
- /** Merge immutable + default + config exclude patterns (deduped, order preserved). */
33345
- function resolveCleanExclude(config) {
33344
+ /** Merge exclude patterns (deduped, order preserved). */
33345
+ function resolveCleanExclude(config, mode = "normal") {
33346
+ if (mode === "immutable-only") return [...CLEAN_IMMUTABLE_EXCLUDE];
33346
33347
  const merged = [
33347
33348
  ...CLEAN_IMMUTABLE_EXCLUDE,
33348
33349
  ...CLEAN_DEFAULT_EXCLUDE,
@@ -33365,6 +33366,9 @@ function resolveCleanPatterns(config) {
33365
33366
  init_index_min();
33366
33367
  /** Built-in clean targets — always cleaned (bypass gitignored-only). */
33367
33368
  const BUILTIN_CLEAN_PATTERNS = ["dist", "build"];
33369
+ function excludeModeForFull(fullMode) {
33370
+ return fullMode === "full-all" ? "immutable-only" : "normal";
33371
+ }
33368
33372
  function toPosix(relativePath) {
33369
33373
  return relativePath.split(PATH.sep).join("/");
33370
33374
  }
@@ -33455,14 +33459,14 @@ function applyGitignoredAll(params) {
33455
33459
  * 1. Hard safety on all configured patterns (throws on escape)
33456
33460
  * 2. Expand builtins + include (always-clean; bypass gitignored-only)
33457
33461
  * 3. Expand config patterns; enforce gitignored-only when enabled
33458
- * 4. Optionally add all gitignored paths under the package
33462
+ * 4. Optionally add all gitignored paths (`--full` / `--full-all` or rule)
33459
33463
  * 5. Apply exclude + re-check inside-root
33460
33464
  */
33461
33465
  function buildCleanPlan(options) {
33462
- const { config, extraPatterns = [], gitignore = gitCleanGitignoreBackend, packageDir, rootDir } = options;
33466
+ const { config, extraPatterns = [], fullMode = "none", gitignore = gitCleanGitignoreBackend, packageDir, rootDir } = options;
33463
33467
  const rules = resolveCleanRules(config);
33464
33468
  const issues = [];
33465
- const exclude = resolveCleanExclude(config);
33469
+ const exclude = resolveCleanExclude(config, excludeModeForFull(fullMode));
33466
33470
  const configuredPatterns = [...resolveCleanPatterns(config), ...extraPatterns];
33467
33471
  const safeBuiltin = resolveSafeCleanPatterns([...BUILTIN_CLEAN_PATTERNS], packageDir, rootDir);
33468
33472
  const safeInclude = resolveSafeCleanPatterns(resolveCleanInclude(config), packageDir, rootDir);
@@ -33482,12 +33486,13 @@ function buildCleanPlan(options) {
33482
33486
  targets
33483
33487
  });
33484
33488
  } else for (const absPath of patternCandidates) targets.add(absPath);
33485
- if (isCleanRuleEnabled(rules.gitignoredAll)) applyGitignoredAll({
33489
+ const forceGitignoredAll = fullMode === "full" || fullMode === "full-all";
33490
+ if (forceGitignoredAll || isCleanRuleEnabled(rules.gitignoredAll)) applyGitignoredAll({
33486
33491
  gitignore,
33487
33492
  issues,
33488
33493
  packageDir,
33489
33494
  rootDir,
33490
- ruleLevel: rules.gitignoredAll,
33495
+ ruleLevel: forceGitignoredAll ? "error" : rules.gitignoredAll,
33491
33496
  targets
33492
33497
  });
33493
33498
  return {
@@ -33524,6 +33529,7 @@ const packageCleanOutputs = async (options = {}) => {
33524
33529
  const baseConfig = options.skipConfigLoad ? { patterns: options.extraPatterns } : await loadCleanConfig(pkg);
33525
33530
  const plan = buildCleanPlan({
33526
33531
  config: options.skipConfigLoad ? baseConfig : mergeExtraPatterns(baseConfig, options.extraPatterns),
33532
+ fullMode: options.fullMode ?? "none",
33527
33533
  gitignore: options.gitignore,
33528
33534
  packageDir: pkg,
33529
33535
  rootDir
@@ -37952,15 +37958,18 @@ function hasPackageCleanScript(rootDir, workspace) {
37952
37958
  const pkg = readPackageJson$2(PATH.join(rootDir, workspace.location));
37953
37959
  return Object.hasOwn(pkg?.scripts ?? {}, "package-clean");
37954
37960
  }
37955
- async function cleanBuiltInWorkspaces(rootDir, workspaces, jobs) {
37961
+ async function cleanBuiltInWorkspaces(rootDir, workspaces, jobs, fullMode) {
37956
37962
  return await safeExitAsync(async () => {
37957
- (isJsonMode() ? console.error : console.log)(chalk.green(`Clean [${packageName()}]`));
37963
+ const log = isJsonMode() ? console.error : console.log;
37964
+ const fullLabel = fullMode === "none" ? "" : ` [${fullMode}]`;
37965
+ log(chalk.green(`Clean${fullLabel} [${packageName()}]`));
37958
37966
  const results = Array.from({ length: workspaces.length }, () => 0);
37959
37967
  await runWithConcurrency(workspaces.map((workspace, index) => ({
37960
37968
  index,
37961
37969
  workspace
37962
37970
  })), Math.max(1, jobs), async ({ index, workspace }) => {
37963
37971
  results[index] = await packageClean({
37972
+ fullMode,
37964
37973
  pkg: PATH.resolve(rootDir, workspace.location),
37965
37974
  pkgName: workspace.name,
37966
37975
  rootDir
@@ -37969,27 +37978,43 @@ async function cleanBuiltInWorkspaces(rootDir, workspaces, jobs) {
37969
37978
  return results.reduce((total, result) => total + result, 0);
37970
37979
  });
37971
37980
  }
37972
- const clean = async ({ deferLocalScript, jobs, verbose, pkg }) => {
37981
+ const clean = async ({ deferLocalScript, fullMode = "none", jobs, verbose, pkg }) => {
37973
37982
  if (pkg != null && pkg.length > 0) return await cleanPackage({
37983
+ fullMode,
37974
37984
  pkg,
37975
37985
  verbose
37976
37986
  });
37977
37987
  return cleanAll({
37978
37988
  deferLocalScript,
37989
+ fullMode,
37979
37990
  jobs,
37980
37991
  verbose
37981
37992
  });
37982
37993
  };
37983
- const cleanPackage = ({ pkg }) => {
37994
+ const cleanPackage = async ({ fullMode = "none", pkg }) => {
37984
37995
  const pm = getPackageManager();
37985
- return runStepsAsync(`Clean [${pkg}]`, [pm.runInWorkspace(pkg, "package-clean")]);
37996
+ if (fullMode === "none") return runStepsAsync(`Clean [${pkg}]`, [pm.runInWorkspace(pkg, "package-clean")]);
37997
+ const rootDir = INIT_CWD();
37998
+ const workspace = pm.listWorkspaces().find((entry) => entry.name === pkg || entry.location === pkg);
37999
+ return packageClean({
38000
+ fullMode,
38001
+ pkg: workspace === void 0 ? PATH.resolve(rootDir, pkg) : PATH.resolve(rootDir, workspace.location),
38002
+ pkgName: workspace?.name ?? pkg,
38003
+ rootDir: PATH.resolve(rootDir)
38004
+ });
37986
38005
  };
37987
- function cleanScriptArgs({ jobs, verbose }) {
37988
- return [...jobs === void 0 ? [] : ["-j", String(jobs)], ...verbose ?? false ? ["-v"] : []];
38006
+ function cleanScriptArgs({ fullMode = "none", jobs, verbose }) {
38007
+ return [
38008
+ ...jobs === void 0 ? [] : ["-j", String(jobs)],
38009
+ ...verbose ?? false ? ["-v"] : [],
38010
+ ...fullMode === "full" ? ["--full"] : [],
38011
+ ...fullMode === "full-all" ? ["--full-all"] : []
38012
+ ];
37989
38013
  }
37990
- const cleanAll = async ({ deferLocalScript = false, jobs = 64, verbose }) => {
38014
+ const cleanAll = async ({ deferLocalScript = false, fullMode = "none", jobs = 64, verbose }) => {
37991
38015
  if (deferLocalScript) {
37992
38016
  const deferredResult = tryRunLocalScript("clean", { args: cleanScriptArgs({
38017
+ fullMode,
37993
38018
  jobs,
37994
38019
  verbose
37995
38020
  }) });
@@ -37998,8 +38023,9 @@ const cleanAll = async ({ deferLocalScript = false, jobs = 64, verbose }) => {
37998
38023
  const pm = getPackageManager();
37999
38024
  const rootDir = INIT_CWD();
38000
38025
  const workspaces = cleanWorkspaces(rootDir, pm);
38001
- const scripted = workspaces.filter((workspace) => hasPackageCleanScript(rootDir, workspace));
38002
- const builtInResult = await cleanBuiltInWorkspaces(rootDir, workspaces.filter((workspace) => !hasPackageCleanScript(rootDir, workspace)), jobs);
38026
+ const useBuiltInForFull = fullMode !== "none";
38027
+ const scripted = useBuiltInForFull ? [] : workspaces.filter((workspace) => hasPackageCleanScript(rootDir, workspace));
38028
+ const builtInResult = await cleanBuiltInWorkspaces(rootDir, useBuiltInForFull ? workspaces : workspaces.filter((workspace) => !hasPackageCleanScript(rootDir, workspace)), jobs, fullMode);
38003
38029
  if (scripted.length === 0) return builtInResult;
38004
38030
  return builtInResult + await runStepsAsync("Clean [scripts]", scripted.map((workspace) => pm.runInWorkspace(workspace.name, "package-clean")));
38005
38031
  };
@@ -52056,16 +52082,31 @@ const xyDeployCommands = (args) => {
52056
52082
  };
52057
52083
  //#endregion
52058
52084
  //#region src/xy/install/cleanCommand.ts
52085
+ function resolveFullMode(argv) {
52086
+ if (Boolean(argv.fullAll) || Boolean(argv["full-all"])) return "full-all";
52087
+ if (Boolean(argv.full)) return "full";
52088
+ return "none";
52089
+ }
52059
52090
  const cleanCommand = {
52060
52091
  command: "clean [package]",
52061
52092
  describe: "Clean",
52062
52093
  builder: (yargs) => {
52063
- return yargs.positional("package", { describe: "Specific package to clean" });
52094
+ return yargs.positional("package", { describe: "Specific package to clean" }).option("full", {
52095
+ default: false,
52096
+ description: "Also remove all gitignored files under each package (fresh-clone hygiene; still honors clean.exclude)",
52097
+ type: "boolean"
52098
+ }).option("full-all", {
52099
+ default: false,
52100
+ description: "Like --full, but also ignores clean.exclude / default excludes (only .git is protected)",
52101
+ type: "boolean"
52102
+ });
52064
52103
  },
52065
52104
  handler: async (argv) => {
52066
- if (Boolean(argv.verbose)) console.log(`Cleaning: ${argv.package ?? "all"}`);
52105
+ const fullMode = resolveFullMode(argv);
52106
+ if (Boolean(argv.verbose)) console.log(`Cleaning: ${argv.package ?? "all"}${fullMode === "none" ? "" : ` (${fullMode})`}`);
52067
52107
  await withEnvelope("clean", () => clean({
52068
52108
  deferLocalScript: true,
52109
+ fullMode,
52069
52110
  jobs: argv.jobs,
52070
52111
  pkg: argv.package,
52071
52112
  verbose: !!Boolean(argv.verbose)