@ariestools/toolchain 8.7.1 → 8.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +44 -0
  2. package/dist/actions/deplint/deplint.d.ts +3 -1
  3. package/dist/actions/deplint/deplint.d.ts.map +1 -1
  4. package/dist/actions/deplint/engine.d.ts +2 -2
  5. package/dist/actions/deplint/engine.d.ts.map +1 -1
  6. package/dist/actions/deplint/findFiles.d.ts.map +1 -1
  7. package/dist/actions/deplint/getCliReferencedPackagesFromFiles.d.ts.map +1 -1
  8. package/dist/actions/deplint/getImportsFromFile.d.ts.map +1 -1
  9. package/dist/actions/deplint/getStorybookConfigImports.d.ts.map +1 -1
  10. package/dist/actions/deplint/index.d.ts +2 -0
  11. package/dist/actions/deplint/index.d.ts.map +1 -1
  12. package/dist/actions/deplint/reporters.d.ts +6 -1
  13. package/dist/actions/deplint/reporters.d.ts.map +1 -1
  14. package/dist/actions/deplint/runDeplint.d.ts +4 -0
  15. package/dist/actions/deplint/runDeplint.d.ts.map +1 -0
  16. package/dist/actions/deplint/snapshot.d.ts +7 -0
  17. package/dist/actions/deplint/snapshot.d.ts.map +1 -1
  18. package/dist/actions/deplint/sourceFileCache.d.ts +11 -0
  19. package/dist/actions/deplint/sourceFileCache.d.ts.map +1 -0
  20. package/dist/actions/deplint/types.d.ts +31 -0
  21. package/dist/actions/deplint/types.d.ts.map +1 -1
  22. package/dist/actions/package/compile/MonolithConfig.d.ts +10 -0
  23. package/dist/actions/package/compile/MonolithConfig.d.ts.map +1 -1
  24. package/dist/actions/package/compile/index.d.ts +1 -0
  25. package/dist/actions/package/compile/index.d.ts.map +1 -1
  26. package/dist/actions/package/compile/monolithCopyEntries.d.ts +14 -0
  27. package/dist/actions/package/compile/monolithCopyEntries.d.ts.map +1 -0
  28. package/dist/actions/package/compile/packageCompileMonolith.d.ts.map +1 -1
  29. package/dist/actions/package/expectedCompileOutputs.d.ts +1 -0
  30. package/dist/actions/package/expectedCompileOutputs.d.ts.map +1 -1
  31. package/dist/actions/package/exportMapPublint.d.ts.map +1 -1
  32. package/dist/bin/package/build.mjs +118 -14
  33. package/dist/bin/package/build.mjs.map +1 -1
  34. package/dist/bin/package/compile.mjs +84 -6
  35. package/dist/bin/package/compile.mjs.map +1 -1
  36. package/dist/bin/package/publint.mjs +95 -14
  37. package/dist/bin/package/publint.mjs.map +1 -1
  38. package/dist/bin/package/recompile.mjs +84 -6
  39. package/dist/bin/package/recompile.mjs.map +1 -1
  40. package/dist/bin/package/sync-layout.mjs +23 -6
  41. package/dist/bin/package/sync-layout.mjs.map +1 -1
  42. package/dist/bin/xy.mjs +1881 -1687
  43. package/dist/bin/xy.mjs.map +1 -1
  44. package/dist/lib/loadConfig.d.ts.map +1 -1
  45. package/dist/xy/lint/deplintCommand.d.ts.map +1 -1
  46. package/package.json +4 -4
@@ -9142,17 +9142,26 @@ var import_dist = (/* @__PURE__ */ __commonJSMin(((exports) => {
9142
9142
  })))();
9143
9143
  const configState = {
9144
9144
  config: void 0,
9145
+ /** In-flight root load so concurrent callers share one cosmiconfig search. */
9146
+ loadPromise: void 0,
9145
9147
  rootConfigPath: void 0
9146
9148
  };
9147
- function createExplorer() {
9148
- return (0, import_dist.cosmiconfig)("xy", {
9149
+ const explorerState = {};
9150
+ function getExplorer() {
9151
+ explorerState.current ??= (0, import_dist.cosmiconfig)("xy", {
9149
9152
  cache: true,
9150
9153
  loaders: { ".ts": TypeScriptLoader() }
9151
9154
  });
9155
+ return explorerState.current;
9152
9156
  }
9153
- const loadConfig = async (params) => {
9154
- if (configState.config === void 0) {
9155
- const cosmicConfigResult = await createExplorer().search();
9157
+ async function ensureRootConfigLoaded() {
9158
+ if (configState.config !== void 0) return;
9159
+ if (configState.loadPromise !== void 0) {
9160
+ await configState.loadPromise;
9161
+ return;
9162
+ }
9163
+ configState.loadPromise = (async () => {
9164
+ const cosmicConfigResult = await getExplorer().search();
9156
9165
  configState.config = cosmicConfigResult?.config ?? {};
9157
9166
  configState.rootConfigPath = cosmicConfigResult?.filepath;
9158
9167
  const configFilePath = cosmicConfigResult?.filepath;
@@ -9160,8 +9169,16 @@ const loadConfig = async (params) => {
9160
9169
  console.log(chalk.green(`Loaded config from ${configFilePath}`));
9161
9170
  if (Boolean(configState.config.verbose)) console.log(chalk.gray(JSON.stringify(configState.config, null, 2)));
9162
9171
  }
9172
+ })();
9173
+ try {
9174
+ await configState.loadPromise;
9175
+ } finally {
9176
+ configState.loadPromise = void 0;
9163
9177
  }
9164
- return deepMerge$1(configState.config, params ?? {});
9178
+ }
9179
+ const loadConfig = async (params) => {
9180
+ await ensureRootConfigLoaded();
9181
+ return deepMerge$1(configState.config ?? {}, params ?? {});
9165
9182
  };
9166
9183
  //#endregion
9167
9184
  //#region ../../node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js
@@ -13001,6 +13018,65 @@ function buildMonolithEntries(config) {
13001
13018
  return entries;
13002
13019
  }
13003
13020
  //#endregion
13021
+ //#region src/actions/package/compile/monolithCopyEntries.ts
13022
+ const copyPlatforms = /* @__PURE__ */ new Set([
13023
+ "browser",
13024
+ "neutral",
13025
+ "node"
13026
+ ]);
13027
+ function isPathInside(parent, candidate) {
13028
+ const relative = PATH.relative(parent, candidate);
13029
+ return relative.length > 0 && relative !== ".." && !relative.startsWith(`..${PATH.sep}`) && !PATH.isAbsolute(relative);
13030
+ }
13031
+ /** Resolves configured copy destinations without requiring their sources to exist. */
13032
+ function listMonolithCopyEntries(packageDir, config) {
13033
+ const distDir = PATH.resolve(packageDir, "dist");
13034
+ const entries = [];
13035
+ const configuredCopyEntries = Object.entries(config.copyEntries ?? {});
13036
+ for (const [platformName, configuredEntries] of configuredCopyEntries) {
13037
+ if (!copyPlatforms.has(platformName)) throw new Error(`Unsupported monolith copy entry platform "${platformName}"`);
13038
+ const platform = platformName;
13039
+ const platformDir = PATH.join(distDir, platform);
13040
+ for (const [output, source] of Object.entries(configuredEntries)) {
13041
+ if (output.length === 0) throw new Error(`Monolith copy entry for ${platform} has an empty output path`);
13042
+ if (source.length === 0) throw new Error(`Monolith copy entry "${output}" has an empty source`);
13043
+ if (PATH.isAbsolute(output)) throw new Error(`Monolith copy entry output must be relative: "${output}"`);
13044
+ const destination = PATH.resolve(platformDir, output);
13045
+ if (!isPathInside(platformDir, destination)) throw new Error(`Monolith copy entry output escapes dist/${platform}: "${output}"`);
13046
+ const normalizedOutput = PATH.relative(platformDir, destination).split(PATH.sep).join("/");
13047
+ entries.push({
13048
+ destination,
13049
+ output: normalizedOutput,
13050
+ platform,
13051
+ source,
13052
+ subpath: `./${normalizedOutput}`
13053
+ });
13054
+ }
13055
+ }
13056
+ return entries;
13057
+ }
13058
+ function resolveCopySource(packageDir, source) {
13059
+ let resolved;
13060
+ try {
13061
+ resolved = PATH.isAbsolute(source) || source.startsWith(".") ? PATH.resolve(packageDir, source) : createRequire(PATH.join(packageDir, "package.json")).resolve(source);
13062
+ } catch (reason) {
13063
+ const detail = reason instanceof Error ? reason.message : String(reason);
13064
+ throw new Error(`Unable to resolve monolith copy entry source "${source}": ${detail}`, { cause: reason });
13065
+ }
13066
+ if (!fs.existsSync(resolved) || !fs.statSync(resolved).isFile()) throw new Error(`Monolith copy entry source is not a file: "${source}" (${resolved})`);
13067
+ return resolved;
13068
+ }
13069
+ /** Copies configured opaque entries into their exact dist destinations. */
13070
+ function copyMonolithEntries(packageDir, config) {
13071
+ const entries = listMonolithCopyEntries(packageDir, config);
13072
+ for (const entry of entries) {
13073
+ const source = resolveCopySource(packageDir, entry.source);
13074
+ fs.mkdirSync(PATH.dirname(entry.destination), { recursive: true });
13075
+ fs.copyFileSync(source, entry.destination);
13076
+ }
13077
+ return entries.length;
13078
+ }
13079
+ //#endregion
13004
13080
  //#region src/actions/package/compile/packageCompileMonolith.ts
13005
13081
  function assertNoManualEntries(compile) {
13006
13082
  if (compile.entryMode !== void 0) throw new Error("monolith mode computes entries; remove compile.entryMode");
@@ -13093,6 +13169,8 @@ const packageCompileMonolith = async (config, mode = {}) => {
13093
13169
  if (isVerbose && flattened > 0) console.log(chalk.gray(`monolith pure reexport flatten: ${flattened} files`));
13094
13170
  const rewritten = fixMonolithDeclarations(distDir, monolith);
13095
13171
  if (isVerbose) console.log(chalk.gray(`monolith declaration fixups: ${rewritten} files`));
13172
+ const copied = copyMonolithEntries(packageDir, monolith);
13173
+ if (isVerbose && copied > 0) console.log(chalk.gray(`monolith copied entries: ${copied} files`));
13096
13174
  const specifierProblems = verifyMonolithRuntimeSpecifiers(distDir, monolith);
13097
13175
  if (specifierProblems.length > 0) {
13098
13176
  for (const problem of specifierProblems) console.error(chalk.red(problem));