@theholocron/cli 3.64.0 → 3.65.0

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/cli.mjs CHANGED
@@ -22,6 +22,7 @@ import { createGitHubClient } from "@theholocron/github-client";
22
22
  import * as Sentry from "@sentry/node";
23
23
  import { PostHog } from "posthog-node";
24
24
  import { promisify } from "node:util";
25
+ import { ConfigFileError, loadConfigFile } from "@theholocron/datapad";
25
26
  //#region src/env.ts
26
27
  /** Singleton env for simple global lookups throughout the CLI. */
27
28
  const env = createEnvLookup();
@@ -6698,74 +6699,32 @@ async function runUpgradeNode(input) {
6698
6699
  //#endregion
6699
6700
  //#region src/config/load-config.ts
6700
6701
  /**
6701
- * `holocron.config.{json,js,ts}` file loader.
6702
+ * `holocron.config.{ts,js,mjs,cjs,json}` loader.
6702
6703
  *
6703
- * Search order: json → js → ts. JSON is parsed directly; JS is loaded
6704
- * via native dynamic import; TS is loaded via `tsImport` from tsx (a
6705
- * runtime dep) so operators can write typed configs with `defineConfig`
6706
- * without needing a separate build step.
6704
+ * File discovery + module loading (typed configs via `tsx`, no build
6705
+ * step) is delegated to `@theholocron/datapad`. This module keeps the
6706
+ * holocron-specific parts: filling `name` / `repo.name` defaults and
6707
+ * running the config through `resolveConfig`.
6707
6708
  *
6708
- * All three forms are validated through the same `resolveConfig` path.
6709
- * Implements the lookup-order contract from issue #75 / #81.
6709
+ * Probe order is TS-first (`.ts` → `.js` → `.mjs` → `.cjs` → `.json`) —
6710
+ * see ADR-0010 / issue #75 / #81.
6710
6711
  */
6711
6712
  const execFileAsync = promisify(execFile);
6712
- const CANDIDATE_FILENAMES = [
6713
- "holocron.config.json",
6714
- "holocron.config.js",
6715
- "holocron.config.ts"
6716
- ];
6717
- var ConfigFileError = class extends Error {
6718
- name = "ConfigFileError";
6719
- };
6720
6713
  /**
6721
6714
  * Read + parse + resolve `holocron.config.*` from the given directory.
6722
- * Search order: json → js → ts. Throws `ConfigFileError` if nothing
6723
- * found, or `ConfigError` if the config is malformed / invalid.
6715
+ * Throws {@link ConfigFileError} when nothing is found or a file cannot
6716
+ * be loaded, or `ConfigError` when the config is invalid.
6724
6717
  */
6725
6718
  async function loadConfig(cwd) {
6726
- for (const filename of CANDIDATE_FILENAMES) {
6727
- const fullPath = join(cwd, filename);
6728
- if (await fileExists(fullPath)) {
6729
- if (filename.endsWith(".json")) return {
6730
- resolved: await loadJson(fullPath),
6731
- filepath: fullPath
6732
- };
6733
- if (filename.endsWith(".ts")) return {
6734
- resolved: await loadTs(fullPath),
6735
- filepath: fullPath
6736
- };
6737
- return {
6738
- resolved: await loadJs(fullPath),
6739
- filepath: fullPath
6740
- };
6741
- }
6742
- }
6743
- throw new ConfigFileError(`no holocron.config.{json,js,ts} found in ${cwd}. Create one — see the README for the schema.`);
6744
- }
6745
- async function loadJson(filepath) {
6746
- const raw = await readFile(filepath, "utf8");
6747
- let parsed;
6748
- try {
6749
- parsed = JSON.parse(raw);
6750
- } catch (err) {
6751
- throw new ConfigError(`${filepath} is not valid JSON: ${err instanceof Error ? err.message : String(err)}`);
6752
- }
6753
- return resolveConfig(await deriveDefaults(dirname(filepath), parsed));
6754
- }
6755
- async function loadJs(filepath) {
6756
- const mod = await import(pathToFileURL(filepath).href);
6757
- return resolveConfig(await deriveDefaults(dirname(filepath), extractRaw(filepath, mod)));
6758
- }
6759
- async function loadTs(filepath) {
6760
- const { tsImport } = await import("tsx/esm/api");
6761
- const mod = await tsImport(pathToFileURL(filepath).href, import.meta.url);
6762
- return resolveConfig(await deriveDefaults(dirname(filepath), extractRaw(filepath, mod)));
6763
- }
6764
- function extractRaw(filepath, mod) {
6765
- const outer = mod.default;
6766
- const raw = outer?.__esModule === true ? outer.default : outer;
6767
- if (raw === void 0 || raw === null) throw new ConfigFileError(`${filepath} must have a default export (use \`export default defineConfig({…})\`)`);
6768
- return raw;
6719
+ const found = await loadConfigFile({
6720
+ cwd,
6721
+ name: "holocron"
6722
+ });
6723
+ if (!found) throw new ConfigFileError(`no holocron.config.{ts,js,mjs,cjs,json} found in ${cwd}. Create one — see the README for the schema.`);
6724
+ return {
6725
+ resolved: resolveConfig(await deriveDefaults(dirname(found.filepath), found.config)),
6726
+ filepath: found.filepath
6727
+ };
6769
6728
  }
6770
6729
  async function deriveDefaults(configDir, raw) {
6771
6730
  const result = { ...raw };
@@ -6806,13 +6765,6 @@ function parseGitRemoteUrl(url) {
6806
6765
  const sshMatch = url.match(/github\.com:([^/]+\/[^/]+?)(?:\.git)?$/);
6807
6766
  if (sshMatch) return sshMatch[1];
6808
6767
  }
6809
- async function fileExists(path) {
6810
- try {
6811
- return (await stat(path)).isFile();
6812
- } catch {
6813
- return false;
6814
- }
6815
- }
6816
6768
  //#endregion
6817
6769
  //#region src/update-notifier.ts
6818
6770
  const PACKAGE_NAME = "@theholocron/cli";