@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
@@ -9127,17 +9127,26 @@ var import_dist = (/* @__PURE__ */ __commonJSMin(((exports) => {
9127
9127
  })))();
9128
9128
  const configState = {
9129
9129
  config: void 0,
9130
+ /** In-flight root load so concurrent callers share one cosmiconfig search. */
9131
+ loadPromise: void 0,
9130
9132
  rootConfigPath: void 0
9131
9133
  };
9132
- function createExplorer() {
9133
- return (0, import_dist.cosmiconfig)("xy", {
9134
+ const explorerState = {};
9135
+ function getExplorer() {
9136
+ explorerState.current ??= (0, import_dist.cosmiconfig)("xy", {
9134
9137
  cache: true,
9135
9138
  loaders: { ".ts": TypeScriptLoader() }
9136
9139
  });
9140
+ return explorerState.current;
9137
9141
  }
9138
- const loadConfig = async (params) => {
9139
- if (configState.config === void 0) {
9140
- const cosmicConfigResult = await createExplorer().search();
9142
+ async function ensureRootConfigLoaded() {
9143
+ if (configState.config !== void 0) return;
9144
+ if (configState.loadPromise !== void 0) {
9145
+ await configState.loadPromise;
9146
+ return;
9147
+ }
9148
+ configState.loadPromise = (async () => {
9149
+ const cosmicConfigResult = await getExplorer().search();
9141
9150
  configState.config = cosmicConfigResult?.config ?? {};
9142
9151
  configState.rootConfigPath = cosmicConfigResult?.filepath;
9143
9152
  const configFilePath = cosmicConfigResult?.filepath;
@@ -9145,8 +9154,16 @@ const loadConfig = async (params) => {
9145
9154
  console.log(chalk.green(`Loaded config from ${configFilePath}`));
9146
9155
  if (Boolean(configState.config.verbose)) console.log(chalk.gray(JSON.stringify(configState.config, null, 2)));
9147
9156
  }
9157
+ })();
9158
+ try {
9159
+ await configState.loadPromise;
9160
+ } finally {
9161
+ configState.loadPromise = void 0;
9148
9162
  }
9149
- return deepMerge$1(configState.config, params ?? {});
9163
+ }
9164
+ const loadConfig = async (params) => {
9165
+ await ensureRootConfigLoaded();
9166
+ return deepMerge$1(configState.config ?? {}, params ?? {});
9150
9167
  };
9151
9168
  //#endregion
9152
9169
  //#region ../../node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js
@@ -12929,6 +12946,65 @@ function buildMonolithEntries(config) {
12929
12946
  return entries;
12930
12947
  }
12931
12948
  //#endregion
12949
+ //#region src/actions/package/compile/monolithCopyEntries.ts
12950
+ const copyPlatforms = /* @__PURE__ */ new Set([
12951
+ "browser",
12952
+ "neutral",
12953
+ "node"
12954
+ ]);
12955
+ function isPathInside(parent, candidate) {
12956
+ const relative = PATH.relative(parent, candidate);
12957
+ return relative.length > 0 && relative !== ".." && !relative.startsWith(`..${PATH.sep}`) && !PATH.isAbsolute(relative);
12958
+ }
12959
+ /** Resolves configured copy destinations without requiring their sources to exist. */
12960
+ function listMonolithCopyEntries(packageDir, config) {
12961
+ const distDir = PATH.resolve(packageDir, "dist");
12962
+ const entries = [];
12963
+ const configuredCopyEntries = Object.entries(config.copyEntries ?? {});
12964
+ for (const [platformName, configuredEntries] of configuredCopyEntries) {
12965
+ if (!copyPlatforms.has(platformName)) throw new Error(`Unsupported monolith copy entry platform "${platformName}"`);
12966
+ const platform = platformName;
12967
+ const platformDir = PATH.join(distDir, platform);
12968
+ for (const [output, source] of Object.entries(configuredEntries)) {
12969
+ if (output.length === 0) throw new Error(`Monolith copy entry for ${platform} has an empty output path`);
12970
+ if (source.length === 0) throw new Error(`Monolith copy entry "${output}" has an empty source`);
12971
+ if (PATH.isAbsolute(output)) throw new Error(`Monolith copy entry output must be relative: "${output}"`);
12972
+ const destination = PATH.resolve(platformDir, output);
12973
+ if (!isPathInside(platformDir, destination)) throw new Error(`Monolith copy entry output escapes dist/${platform}: "${output}"`);
12974
+ const normalizedOutput = PATH.relative(platformDir, destination).split(PATH.sep).join("/");
12975
+ entries.push({
12976
+ destination,
12977
+ output: normalizedOutput,
12978
+ platform,
12979
+ source,
12980
+ subpath: `./${normalizedOutput}`
12981
+ });
12982
+ }
12983
+ }
12984
+ return entries;
12985
+ }
12986
+ function resolveCopySource(packageDir, source) {
12987
+ let resolved;
12988
+ try {
12989
+ resolved = PATH.isAbsolute(source) || source.startsWith(".") ? PATH.resolve(packageDir, source) : createRequire(PATH.join(packageDir, "package.json")).resolve(source);
12990
+ } catch (reason) {
12991
+ const detail = reason instanceof Error ? reason.message : String(reason);
12992
+ throw new Error(`Unable to resolve monolith copy entry source "${source}": ${detail}`, { cause: reason });
12993
+ }
12994
+ if (!fs.existsSync(resolved) || !fs.statSync(resolved).isFile()) throw new Error(`Monolith copy entry source is not a file: "${source}" (${resolved})`);
12995
+ return resolved;
12996
+ }
12997
+ /** Copies configured opaque entries into their exact dist destinations. */
12998
+ function copyMonolithEntries(packageDir, config) {
12999
+ const entries = listMonolithCopyEntries(packageDir, config);
13000
+ for (const entry of entries) {
13001
+ const source = resolveCopySource(packageDir, entry.source);
13002
+ fs.mkdirSync(PATH.dirname(entry.destination), { recursive: true });
13003
+ fs.copyFileSync(source, entry.destination);
13004
+ }
13005
+ return entries.length;
13006
+ }
13007
+ //#endregion
12932
13008
  //#region src/actions/package/compile/packageCompileMonolith.ts
12933
13009
  function assertNoManualEntries(compile) {
12934
13010
  if (compile.entryMode !== void 0) throw new Error("monolith mode computes entries; remove compile.entryMode");
@@ -13021,6 +13097,8 @@ const packageCompileMonolith = async (config, mode = {}) => {
13021
13097
  if (isVerbose && flattened > 0) console.log(chalk.gray(`monolith pure reexport flatten: ${flattened} files`));
13022
13098
  const rewritten = fixMonolithDeclarations(distDir, monolith);
13023
13099
  if (isVerbose) console.log(chalk.gray(`monolith declaration fixups: ${rewritten} files`));
13100
+ const copied = copyMonolithEntries(packageDir, monolith);
13101
+ if (isVerbose && copied > 0) console.log(chalk.gray(`monolith copied entries: ${copied} files`));
13024
13102
  const specifierProblems = verifyMonolithRuntimeSpecifiers(distDir, monolith);
13025
13103
  if (specifierProblems.length > 0) {
13026
13104
  for (const problem of specifierProblems) console.error(chalk.red(problem));