@theholocron/cli 5.0.0-alpha.147 → 5.0.0-alpha.149

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
@@ -20,6 +20,7 @@ import ora from "ora";
20
20
  import { execFileSync, spawn, spawnSync } from "node:child_process";
21
21
  import { stringifyJson } from "@theholocron/json-utils";
22
22
  import { readGitRemote, updateGitignore } from "@theholocron/git-utils";
23
+ import { readPackageJson } from "@theholocron/pkg-utils";
23
24
  import { access, copyFile, mkdir, readFile, readdir, rename, rm, stat, symlink, unlink, writeFile } from "node:fs/promises";
24
25
  import { createHash, randomUUID } from "node:crypto";
25
26
  import { findRootSync } from "@theholocron/fs-utils";
@@ -4554,10 +4555,10 @@ function deriveCompliance(capabilities) {
4554
4555
  */
4555
4556
  async function readWorkspacePackageJsons(repoRoot, workspacePackages) {
4556
4557
  const results = [];
4557
- for (const { slug, dir = "packages" } of workspacePackages) try {
4558
- const raw = await readFile(join(repoRoot, dir, slug, "package.json"), "utf8");
4559
- results.push(JSON.parse(raw));
4560
- } catch {}
4558
+ for (const { slug, dir = "packages" } of workspacePackages) {
4559
+ const pkg = await readPackageJson(join(repoRoot, dir, slug));
4560
+ if (pkg) results.push(pkg);
4561
+ }
4561
4562
  return results;
4562
4563
  }
4563
4564
  //#endregion
@@ -8334,12 +8335,13 @@ async function loadConfig(cwd) {
8334
8335
  });
8335
8336
  if (!found) throw new ConfigFileError(`no holocron.config.{ts,js,mjs,cjs,json} found in ${cwd}. Create one — see the README for the schema.`);
8336
8337
  return {
8337
- resolved: resolveConfig(await deriveDefaults(dirname(found.filepath), found.config)),
8338
+ resolved: resolveConfig(await deriveDefaults(found)),
8338
8339
  filepath: found.filepath
8339
8340
  };
8340
8341
  }
8341
- async function deriveDefaults(configDir, raw) {
8342
- const result = { ...raw };
8342
+ async function deriveDefaults(found) {
8343
+ const configDir = dirname(found.filepath);
8344
+ const result = { ...found.config };
8343
8345
  if (!result.name) result.name = await readPackageJsonName(configDir) ?? basename(configDir);
8344
8346
  if (result.repo && !result.repo.name) {
8345
8347
  const remote = await readGitRemote(configDir);
@@ -8348,7 +8350,7 @@ async function deriveDefaults(configDir, raw) {
8348
8350
  name: remote.slug
8349
8351
  };
8350
8352
  }
8351
- const manifest = await loadTasksConfig(configDir);
8353
+ const manifest = await loadTasksConfig(configDir, { holocron: found });
8352
8354
  if (manifest.tasks) result.tasks = manifest.tasks;
8353
8355
  if (manifest.syncScripts !== void 0) result.syncScripts = manifest.syncScripts;
8354
8356
  if (manifest.holocronScript !== void 0) result.holocronScript = manifest.holocronScript;
@@ -8357,13 +8359,8 @@ async function deriveDefaults(configDir, raw) {
8357
8359
  return result;
8358
8360
  }
8359
8361
  async function readPackageJsonName(dir) {
8360
- try {
8361
- const content = await readFile(join(dir, "package.json"), "utf8");
8362
- const pkg = JSON.parse(content);
8363
- return typeof pkg.name === "string" ? pkg.name.replace(/^@[^/]+\//, "") : void 0;
8364
- } catch {
8365
- return;
8366
- }
8362
+ const name = (await readPackageJson(dir))?.name;
8363
+ return name === void 0 ? void 0 : name.replace(/^@[^/]+\//, "");
8367
8364
  }
8368
8365
  //#endregion
8369
8366
  //#region src/interactive-menu.ts