@ahmedrowaihi/8n 0.5.0 → 0.5.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.
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  import { builtinModules, createRequire } from "node:module";
3
3
  import { spawn } from "node:child_process";
4
4
  import path, { delimiter, dirname, join, normalize, resolve } from "node:path";
5
- import fs, { appendFileSync, existsSync, mkdirSync, promises, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
5
+ import fs, { appendFileSync, existsSync, mkdirSync, promises, readFileSync, readdirSync, realpathSync, statSync, writeFileSync } from "node:fs";
6
6
  import process$1, { cwd } from "node:process";
7
7
  import { PassThrough } from "node:stream";
8
8
  import c from "node:readline";
@@ -1065,7 +1065,7 @@ var require_suggestSimilar = /* @__PURE__ */ __commonJSMin(((exports) => {
1065
1065
  //#region ../../node_modules/.pnpm/commander@14.0.3/node_modules/commander/lib/command.js
1066
1066
  var require_command = /* @__PURE__ */ __commonJSMin(((exports) => {
1067
1067
  const EventEmitter = __require("node:events").EventEmitter;
1068
- const childProcess$1 = __require("node:child_process");
1068
+ const childProcess = __require("node:child_process");
1069
1069
  const path$2 = __require("node:path");
1070
1070
  const fs$2 = __require("node:fs");
1071
1071
  const process$2 = __require("node:process");
@@ -2018,13 +2018,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
2018
2018
  if (process$2.platform !== "win32") if (launchWithNode) {
2019
2019
  args.unshift(executableFile);
2020
2020
  args = incrementNodeInspectorPort(process$2.execArgv).concat(args);
2021
- proc = childProcess$1.spawn(process$2.argv[0], args, { stdio: "inherit" });
2022
- } else proc = childProcess$1.spawn(executableFile, args, { stdio: "inherit" });
2021
+ proc = childProcess.spawn(process$2.argv[0], args, { stdio: "inherit" });
2022
+ } else proc = childProcess.spawn(executableFile, args, { stdio: "inherit" });
2023
2023
  else {
2024
2024
  this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
2025
2025
  args.unshift(executableFile);
2026
2026
  args = incrementNodeInspectorPort(process$2.execArgv).concat(args);
2027
- proc = childProcess$1.spawn(process$2.execPath, args, { stdio: "inherit" });
2027
+ proc = childProcess.spawn(process$2.execPath, args, { stdio: "inherit" });
2028
2028
  }
2029
2029
  if (!proc.killed) [
2030
2030
  "SIGUSR1",
@@ -3741,35 +3741,35 @@ var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3741
3741
 
3742
3742
  //#endregion
3743
3743
  //#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
3744
- const _DRIVE_LETTER_START_RE$1 = /^[A-Za-z]:\//;
3745
- function normalizeWindowsPath$1(input = "") {
3744
+ const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
3745
+ function normalizeWindowsPath(input = "") {
3746
3746
  if (!input) return input;
3747
- return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE$1, (r) => r.toUpperCase());
3747
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
3748
3748
  }
3749
- const _UNC_REGEX$1 = /^[/\\]{2}/;
3750
- const _IS_ABSOLUTE_RE$1 = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
3751
- const _DRIVE_LETTER_RE$1 = /^[A-Za-z]:$/;
3749
+ const _UNC_REGEX = /^[/\\]{2}/;
3750
+ const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
3751
+ const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
3752
3752
  const _EXTNAME_RE = /.(\.[^./]+|\.)$/;
3753
- const normalize$2 = function(path) {
3753
+ const normalize$1 = function(path) {
3754
3754
  if (path.length === 0) return ".";
3755
- path = normalizeWindowsPath$1(path);
3756
- const isUNCPath = path.match(_UNC_REGEX$1);
3757
- const isPathAbsolute = isAbsolute$1(path);
3755
+ path = normalizeWindowsPath(path);
3756
+ const isUNCPath = path.match(_UNC_REGEX);
3757
+ const isPathAbsolute = isAbsolute(path);
3758
3758
  const trailingSeparator = path[path.length - 1] === "/";
3759
- path = normalizeString$1(path, !isPathAbsolute);
3759
+ path = normalizeString(path, !isPathAbsolute);
3760
3760
  if (path.length === 0) {
3761
3761
  if (isPathAbsolute) return "/";
3762
3762
  return trailingSeparator ? "./" : ".";
3763
3763
  }
3764
3764
  if (trailingSeparator) path += "/";
3765
- if (_DRIVE_LETTER_RE$1.test(path)) path += "/";
3765
+ if (_DRIVE_LETTER_RE.test(path)) path += "/";
3766
3766
  if (isUNCPath) {
3767
3767
  if (!isPathAbsolute) return `//./${path}`;
3768
3768
  return `//${path}`;
3769
3769
  }
3770
- return isPathAbsolute && !isAbsolute$1(path) ? `/${path}` : path;
3770
+ return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
3771
3771
  };
3772
- const join$2 = function(...segments) {
3772
+ const join$1 = function(...segments) {
3773
3773
  let path = "";
3774
3774
  for (const seg of segments) {
3775
3775
  if (!seg) continue;
@@ -3780,27 +3780,27 @@ const join$2 = function(...segments) {
3780
3780
  else path += pathTrailing || segLeading ? seg : `/${seg}`;
3781
3781
  } else path += seg;
3782
3782
  }
3783
- return normalize$2(path);
3783
+ return normalize$1(path);
3784
3784
  };
3785
- function cwd$2() {
3785
+ function cwd$1() {
3786
3786
  if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
3787
3787
  return "/";
3788
3788
  }
3789
- const resolve$2 = function(...arguments_) {
3790
- arguments_ = arguments_.map((argument) => normalizeWindowsPath$1(argument));
3789
+ const resolve$1 = function(...arguments_) {
3790
+ arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
3791
3791
  let resolvedPath = "";
3792
3792
  let resolvedAbsolute = false;
3793
3793
  for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
3794
- const path = index >= 0 ? arguments_[index] : cwd$2();
3794
+ const path = index >= 0 ? arguments_[index] : cwd$1();
3795
3795
  if (!path || path.length === 0) continue;
3796
3796
  resolvedPath = `${path}/${resolvedPath}`;
3797
- resolvedAbsolute = isAbsolute$1(path);
3797
+ resolvedAbsolute = isAbsolute(path);
3798
3798
  }
3799
- resolvedPath = normalizeString$1(resolvedPath, !resolvedAbsolute);
3800
- if (resolvedAbsolute && !isAbsolute$1(resolvedPath)) return `/${resolvedPath}`;
3799
+ resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
3800
+ if (resolvedAbsolute && !isAbsolute(resolvedPath)) return `/${resolvedPath}`;
3801
3801
  return resolvedPath.length > 0 ? resolvedPath : ".";
3802
3802
  };
3803
- function normalizeString$1(path, allowAboveRoot) {
3803
+ function normalizeString(path, allowAboveRoot) {
3804
3804
  let res = "";
3805
3805
  let lastSegmentLength = 0;
3806
3806
  let lastSlash = -1;
@@ -3850,21 +3850,21 @@ function normalizeString$1(path, allowAboveRoot) {
3850
3850
  }
3851
3851
  return res;
3852
3852
  }
3853
- const isAbsolute$1 = function(p) {
3854
- return _IS_ABSOLUTE_RE$1.test(p);
3853
+ const isAbsolute = function(p) {
3854
+ return _IS_ABSOLUTE_RE.test(p);
3855
3855
  };
3856
3856
  const extname$1 = function(p) {
3857
3857
  if (p === "..") return "";
3858
- const match = _EXTNAME_RE.exec(normalizeWindowsPath$1(p));
3858
+ const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
3859
3859
  return match && match[1] || "";
3860
3860
  };
3861
3861
  const dirname$1 = function(p) {
3862
- const segments = normalizeWindowsPath$1(p).replace(/\/$/, "").split("/").slice(0, -1);
3863
- if (segments.length === 1 && _DRIVE_LETTER_RE$1.test(segments[0])) segments[0] += "/";
3864
- return segments.join("/") || (isAbsolute$1(p) ? "/" : ".");
3862
+ const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
3863
+ if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
3864
+ return segments.join("/") || (isAbsolute(p) ? "/" : ".");
3865
3865
  };
3866
3866
  const basename = function(p, extension) {
3867
- const segments = normalizeWindowsPath$1(p).split("/");
3867
+ const segments = normalizeWindowsPath(p).split("/");
3868
3868
  let lastSegment = "";
3869
3869
  for (let i = segments.length - 1; i >= 0; i--) {
3870
3870
  const val = segments[i];
@@ -3878,7 +3878,6 @@ const basename = function(p, extension) {
3878
3878
 
3879
3879
  //#endregion
3880
3880
  //#region ../../node_modules/.pnpm/acorn@8.16.0/node_modules/acorn/dist/acorn.mjs
3881
- var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
3882
3881
  var astralIdentifierCodes = [
3883
3882
  509,
3884
3883
  0,
@@ -9437,18 +9436,18 @@ async function findFile(filename, _options = {}) {
9437
9436
  ...defaultFindOptions,
9438
9437
  ..._options
9439
9438
  };
9440
- const basePath = resolve$2(options.startingFrom);
9439
+ const basePath = resolve$1(options.startingFrom);
9441
9440
  const leadingSlash = basePath[0] === "/";
9442
9441
  const segments = basePath.split("/").filter(Boolean);
9443
9442
  if (leadingSlash) segments[0] = "/" + segments[0];
9444
9443
  let root = segments.findIndex((r) => r.match(options.rootPattern));
9445
9444
  if (root === -1) root = 0;
9446
9445
  if (options.reverse) for (let index = root + 1; index <= segments.length; index++) for (const filename2 of filenames) {
9447
- const filePath = join$2(...segments.slice(0, index), filename2);
9446
+ const filePath = join$1(...segments.slice(0, index), filename2);
9448
9447
  if (await options.test(filePath)) return filePath;
9449
9448
  }
9450
9449
  else for (let index = segments.length; index > root; index--) for (const filename2 of filenames) {
9451
- const filePath = join$2(...segments.slice(0, index), filename2);
9450
+ const filePath = join$1(...segments.slice(0, index), filename2);
9452
9451
  if (await options.test(filePath)) return filePath;
9453
9452
  }
9454
9453
  throw new Error(`Cannot find matching ${filename} in ${options.startingFrom} or parent directories`);
@@ -9473,7 +9472,7 @@ async function readPackageJSON(id, options = {}) {
9473
9472
  }
9474
9473
  async function resolvePackageJSON(id = process.cwd(), options = {}) {
9475
9474
  return findNearestFile("package.json", {
9476
- startingFrom: isAbsolute$1(id) ? id : await resolvePath(id, options),
9475
+ startingFrom: isAbsolute(id) ? id : await resolvePath(id, options),
9477
9476
  ...options
9478
9477
  });
9479
9478
  }
@@ -9487,7 +9486,7 @@ const lockFiles = [
9487
9486
  ];
9488
9487
  async function resolveLockfile(id = process.cwd(), options = {}) {
9489
9488
  const _options = {
9490
- startingFrom: isAbsolute$1(id) ? id : await resolvePath(id, options),
9489
+ startingFrom: isAbsolute(id) ? id : await resolvePath(id, options),
9491
9490
  ...options
9492
9491
  };
9493
9492
  try {
@@ -9496,13 +9495,13 @@ async function resolveLockfile(id = process.cwd(), options = {}) {
9496
9495
  throw new Error("No lockfile found from " + id);
9497
9496
  }
9498
9497
  async function findWorkspaceDir(id = process.cwd(), options = {}) {
9499
- const resolvedPath = isAbsolute$1(id) ? id : await resolvePath(id, options);
9498
+ const resolvedPath = isAbsolute(id) ? id : await resolvePath(id, options);
9500
9499
  const _options = {
9501
9500
  startingFrom: resolvedPath,
9502
9501
  ...options
9503
9502
  };
9504
9503
  try {
9505
- return resolve$2(await findNearestFile(".git/config", _options), "../..");
9504
+ return resolve$1(await findNearestFile(".git/config", _options), "../..");
9506
9505
  } catch {}
9507
9506
  try {
9508
9507
  return dirname$1(await resolveLockfile(resolvedPath, {
@@ -10656,7 +10655,7 @@ function _resolve(id, options = {}) {
10656
10655
  if (/(?:node|data|http|https):/.test(id)) return id;
10657
10656
  if (BUILTIN_MODULES.has(id)) return "node:" + id;
10658
10657
  if (id.startsWith("file://")) id = fileURLToPath$1(id);
10659
- if (isAbsolute$1(id)) try {
10658
+ if (isAbsolute(id)) try {
10660
10659
  if (statSync(id).isFile()) return pathToFileURL$1(id);
10661
10660
  } catch (error) {
10662
10661
  if (error?.code !== "ENOENT") throw error;
@@ -10982,7 +10981,7 @@ var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
10982
10981
  var require_main = /* @__PURE__ */ __commonJSMin(((exports, module) => {
10983
10982
  const fs$1 = __require("fs");
10984
10983
  const path$1 = __require("path");
10985
- const os$1 = __require("os");
10984
+ const os = __require("os");
10986
10985
  const crypto = __require("crypto");
10987
10986
  const version = require_package().version;
10988
10987
  const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
@@ -11087,7 +11086,7 @@ var require_main = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11087
11086
  return null;
11088
11087
  }
11089
11088
  function _resolveHome(envPath) {
11090
- return envPath[0] === "~" ? path$1.join(os$1.homedir(), envPath.slice(1)) : envPath;
11089
+ return envPath[0] === "~" ? path$1.join(os.homedir(), envPath.slice(1)) : envPath;
11091
11090
  }
11092
11091
  function _configVault(options) {
11093
11092
  const debug = Boolean(options && options.debug);
@@ -11225,7 +11224,7 @@ async function setupDotenv(options) {
11225
11224
  }
11226
11225
  async function loadDotenv(options) {
11227
11226
  const environment = /* @__PURE__ */ Object.create(null);
11228
- const dotenvFile = resolve$2(options.cwd, options.fileName);
11227
+ const dotenvFile = resolve$1(options.cwd, options.fileName);
11229
11228
  if (existsSync(dotenvFile)) {
11230
11229
  const parsed = import_main.parse(await promises.readFile(dotenvFile, "utf8"));
11231
11230
  Object.assign(environment, parsed);
@@ -11288,7 +11287,7 @@ const SUPPORTED_EXTENSIONS = [
11288
11287
  ".toml"
11289
11288
  ];
11290
11289
  async function loadConfig(options) {
11291
- options.cwd = resolve$2(process.cwd(), options.cwd || ".");
11290
+ options.cwd = resolve$1(process.cwd(), options.cwd || ".");
11292
11291
  options.name = options.name || "config";
11293
11292
  options.envName = options.envName ?? process.env.NODE_ENV;
11294
11293
  options.configFile = options.configFile ?? (options.name === "config" ? "config" : `${options.name}.config`);
@@ -11298,7 +11297,7 @@ async function loadConfig(options) {
11298
11297
  ...options.extend
11299
11298
  };
11300
11299
  const _merger = options.merger || defu;
11301
- options.jiti = options.jiti || createJiti(join$2(options.cwd, options.configFile), {
11300
+ options.jiti = options.jiti || createJiti(join$1(options.cwd, options.configFile), {
11302
11301
  interopDefault: true,
11303
11302
  moduleCache: false,
11304
11303
  extensions: [...SUPPORTED_EXTENSIONS],
@@ -11307,7 +11306,7 @@ async function loadConfig(options) {
11307
11306
  const r = {
11308
11307
  config: {},
11309
11308
  cwd: options.cwd,
11310
- configFile: resolve$2(options.cwd, options.configFile),
11309
+ configFile: resolve$1(options.cwd, options.configFile),
11311
11310
  layers: []
11312
11311
  };
11313
11312
  const _configs = {
@@ -11446,15 +11445,15 @@ async function resolveConfig$1(source, options, sourceOptions = {}) {
11446
11445
  }
11447
11446
  const _merger = options.merger || defu;
11448
11447
  if (options.giget !== false && GIGET_PREFIXES.some((prefix) => source.startsWith(prefix))) {
11449
- const { downloadTemplate } = await import("./dist-CXtIrUVB.mjs");
11450
- const { digest } = await import("./dist-DBVIGXMh.mjs");
11448
+ const { downloadTemplate } = await import("./dist-WXDcqMwg.mjs");
11449
+ const { digest } = await import("./dist-Chcd8TDR.mjs");
11451
11450
  const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + digest(source).slice(0, 10).replace(/[-_]/g, "");
11452
11451
  let cloneDir;
11453
- const localNodeModules = resolve$2(options.cwd, "node_modules");
11452
+ const localNodeModules = resolve$1(options.cwd, "node_modules");
11454
11453
  const parentDir = dirname$1(options.cwd);
11455
- if (basename(parentDir) === ".c12") cloneDir = join$2(parentDir, cloneName);
11456
- else if (existsSync(localNodeModules)) cloneDir = join$2(localNodeModules, ".c12", cloneName);
11457
- else cloneDir = process.env.XDG_CACHE_HOME ? resolve$2(process.env.XDG_CACHE_HOME, "c12", cloneName) : resolve$2(homedir(), ".cache/c12", cloneName);
11454
+ if (basename(parentDir) === ".c12") cloneDir = join$1(parentDir, cloneName);
11455
+ else if (existsSync(localNodeModules)) cloneDir = join$1(localNodeModules, ".c12", cloneName);
11456
+ else cloneDir = process.env.XDG_CACHE_HOME ? resolve$1(process.env.XDG_CACHE_HOME, "c12", cloneName) : resolve$1(homedir(), ".cache/c12", cloneName);
11458
11457
  if (existsSync(cloneDir) && !sourceOptions.install) await rm(cloneDir, { recursive: true });
11459
11458
  source = (await downloadTemplate(source, {
11460
11459
  dir: cloneDir,
@@ -11472,7 +11471,7 @@ async function resolveConfig$1(source, options, sourceOptions = {}) {
11472
11471
  if (NPM_PACKAGE_RE.test(source)) source = tryResolve(source) || source;
11473
11472
  const ext = extname$1(source);
11474
11473
  const isDir = !ext || ext === basename(source);
11475
- const cwd = resolve$2(options.cwd, isDir ? source : dirname$1(source));
11474
+ const cwd = resolve$1(options.cwd, isDir ? source : dirname$1(source));
11476
11475
  if (isDir) source = options.configFile;
11477
11476
  const res = {
11478
11477
  config: void 0,
@@ -11481,7 +11480,7 @@ async function resolveConfig$1(source, options, sourceOptions = {}) {
11481
11480
  source,
11482
11481
  sourceOptions
11483
11482
  };
11484
- res.configFile = tryResolve(resolve$2(cwd, source)) || tryResolve(resolve$2(cwd, ".config", source.replace(/\.config$/, ""))) || tryResolve(resolve$2(cwd, ".config", source)) || source;
11483
+ res.configFile = tryResolve(resolve$1(cwd, source)) || tryResolve(resolve$1(cwd, ".config", source.replace(/\.config$/, ""))) || tryResolve(resolve$1(cwd, ".config", source)) || source;
11485
11484
  if (!existsSync(res.configFile)) return res;
11486
11485
  const configFileExt = extname$1(res.configFile) || "";
11487
11486
  if (configFileExt in ASYNC_LOADERS) res.config = (await ASYNC_LOADERS[configFileExt]())(await readFile(res.configFile, "utf8"));
@@ -15050,6 +15049,7 @@ const pipelineType = ZodPipeline.create;
15050
15049
 
15051
15050
  //#endregion
15052
15051
  //#region ../core/dist/index.mjs
15052
+ var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
15053
15053
  const configSchema = objectType({
15054
15054
  content: stringType().default("./content"),
15055
15055
  locales: arrayType(stringType()).min(1).default(["en"]),
@@ -15079,243 +15079,61 @@ async function resolveConfig() {
15079
15079
  }
15080
15080
 
15081
15081
  //#endregion
15082
- //#region ../../node_modules/.pnpm/pathe@1.1.2/node_modules/pathe/dist/shared/pathe.ff20891b.mjs
15083
- const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
15084
- function normalizeWindowsPath(input = "") {
15085
- if (!input) return input;
15086
- return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
15087
- }
15088
- const _UNC_REGEX = /^[/\\]{2}/;
15089
- const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
15090
- const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
15091
- const normalize$1 = function(path) {
15092
- if (path.length === 0) return ".";
15093
- path = normalizeWindowsPath(path);
15094
- const isUNCPath = path.match(_UNC_REGEX);
15095
- const isPathAbsolute = isAbsolute(path);
15096
- const trailingSeparator = path[path.length - 1] === "/";
15097
- path = normalizeString(path, !isPathAbsolute);
15098
- if (path.length === 0) {
15099
- if (isPathAbsolute) return "/";
15100
- return trailingSeparator ? "./" : ".";
15101
- }
15102
- if (trailingSeparator) path += "/";
15103
- if (_DRIVE_LETTER_RE.test(path)) path += "/";
15104
- if (isUNCPath) {
15105
- if (!isPathAbsolute) return `//./${path}`;
15106
- return `//${path}`;
15107
- }
15108
- return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
15109
- };
15110
- const join$1 = function(...arguments_) {
15111
- if (arguments_.length === 0) return ".";
15112
- let joined;
15113
- for (const argument of arguments_) if (argument && argument.length > 0) if (joined === void 0) joined = argument;
15114
- else joined += `/${argument}`;
15115
- if (joined === void 0) return ".";
15116
- return normalize$1(joined.replace(/\/\/+/g, "/"));
15117
- };
15118
- function cwd$1() {
15119
- if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
15120
- return "/";
15121
- }
15122
- const resolve$1 = function(...arguments_) {
15123
- arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
15124
- let resolvedPath = "";
15125
- let resolvedAbsolute = false;
15126
- for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
15127
- const path = index >= 0 ? arguments_[index] : cwd$1();
15128
- if (!path || path.length === 0) continue;
15129
- resolvedPath = `${path}/${resolvedPath}`;
15130
- resolvedAbsolute = isAbsolute(path);
15131
- }
15132
- resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
15133
- if (resolvedAbsolute && !isAbsolute(resolvedPath)) return `/${resolvedPath}`;
15134
- return resolvedPath.length > 0 ? resolvedPath : ".";
15135
- };
15136
- function normalizeString(path, allowAboveRoot) {
15137
- let res = "";
15138
- let lastSegmentLength = 0;
15139
- let lastSlash = -1;
15140
- let dots = 0;
15141
- let char = null;
15142
- for (let index = 0; index <= path.length; ++index) {
15143
- if (index < path.length) char = path[index];
15144
- else if (char === "/") break;
15145
- else char = "/";
15146
- if (char === "/") {
15147
- if (lastSlash === index - 1 || dots === 1);
15148
- else if (dots === 2) {
15149
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
15150
- if (res.length > 2) {
15151
- const lastSlashIndex = res.lastIndexOf("/");
15152
- if (lastSlashIndex === -1) {
15153
- res = "";
15154
- lastSegmentLength = 0;
15155
- } else {
15156
- res = res.slice(0, lastSlashIndex);
15157
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
15158
- }
15159
- lastSlash = index;
15160
- dots = 0;
15161
- continue;
15162
- } else if (res.length > 0) {
15163
- res = "";
15164
- lastSegmentLength = 0;
15165
- lastSlash = index;
15166
- dots = 0;
15167
- continue;
15168
- }
15169
- }
15170
- if (allowAboveRoot) {
15171
- res += res.length > 0 ? "/.." : "..";
15172
- lastSegmentLength = 2;
15173
- }
15174
- } else {
15175
- if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
15176
- else res = path.slice(lastSlash + 1, index);
15177
- lastSegmentLength = index - lastSlash - 1;
15082
+ //#region src/web-app.ts
15083
+ const STARTER_PACKAGE = "@ahmedrowaihi/8n-starter";
15084
+ const FRAMES = [
15085
+ "⠋",
15086
+ "",
15087
+ "⠹",
15088
+ "⠸",
15089
+ "⠼",
15090
+ "⠴",
15091
+ "⠦",
15092
+ "",
15093
+ "⠇",
15094
+ "⠏"
15095
+ ];
15096
+ function spinner(text) {
15097
+ if (!process.stdout.isTTY) {
15098
+ process.stdout.write(import_picocolors.default.dim(` ${text}...\n`));
15099
+ return {
15100
+ succeed(msg) {
15101
+ process.stdout.write(import_picocolors.default.green("✓") + import_picocolors.default.dim(` ${msg}\n`));
15102
+ },
15103
+ fail(msg) {
15104
+ process.stdout.write(import_picocolors.default.red("✗") + ` ${msg}\n`);
15178
15105
  }
15179
- lastSlash = index;
15180
- dots = 0;
15181
- } else if (char === "." && dots !== -1) ++dots;
15182
- else dots = -1;
15183
- }
15184
- return res;
15185
- }
15186
- const isAbsolute = function(p) {
15187
- return _IS_ABSOLUTE_RE.test(p);
15188
- };
15189
-
15190
- //#endregion
15191
- //#region ../../node_modules/.pnpm/nypm@0.3.12/node_modules/nypm/dist/index.mjs
15192
- async function findup(cwd, match, options = {}) {
15193
- const segments = normalize$1(cwd).split("/");
15194
- while (segments.length > 0) {
15195
- const result = await match(segments.join("/") || "/");
15196
- if (result || !options.includeParentDirs) return result;
15197
- segments.pop();
15198
- }
15199
- }
15200
- function cached(fn) {
15201
- let v;
15202
- return () => {
15203
- if (v === void 0) v = fn().then((r) => {
15204
- v = r;
15205
- return v;
15206
- });
15207
- return v;
15208
- };
15209
- }
15210
- const importExeca = cached(() => import("./execa-cFSfK-pn.mjs").then((r) => r.execa));
15211
- const hasCorepack = cached(async () => {
15212
- try {
15213
- await (await importExeca())("corepack", ["--version"]);
15214
- return true;
15215
- } catch {
15216
- return false;
15106
+ };
15217
15107
  }
15218
- });
15219
- async function executeCommand(command, args, options = {}) {
15220
- const execaArgs = command === "npm" || command === "bun" || !await hasCorepack() ? [command, args] : ["corepack", [command, ...args]];
15221
- await (await importExeca())(execaArgs[0], execaArgs[1], {
15222
- cwd: resolve$1(options.cwd || process.cwd()),
15223
- stdio: options.silent ? "pipe" : "inherit"
15224
- });
15225
- }
15226
- const NO_PACKAGE_MANAGER_DETECTED_ERROR_MSG = "No package manager auto-detected.";
15227
- async function resolveOperationOptions(options = {}) {
15228
- const cwd = options.cwd || process.cwd();
15229
- const packageManager = (typeof options.packageManager === "string" ? packageManagers.find((pm) => pm.name === options.packageManager) : options.packageManager) || await detectPackageManager(options.cwd || process.cwd());
15230
- if (!packageManager) throw new Error(NO_PACKAGE_MANAGER_DETECTED_ERROR_MSG);
15108
+ let i = 0;
15109
+ const id = setInterval(() => {
15110
+ process.stdout.write(`\r${import_picocolors.default.cyan(FRAMES[i++ % FRAMES.length])} ${import_picocolors.default.dim(text)}`);
15111
+ }, 80);
15231
15112
  return {
15232
- cwd,
15233
- silent: options.silent ?? false,
15234
- packageManager,
15235
- dev: options.dev ?? false,
15236
- workspace: options.workspace,
15237
- global: options.global ?? false
15113
+ succeed(msg) {
15114
+ clearInterval(id);
15115
+ process.stdout.write(`\r${import_picocolors.default.green("✓")} ${import_picocolors.default.dim(msg)}\n`);
15116
+ },
15117
+ fail(msg) {
15118
+ clearInterval(id);
15119
+ process.stdout.write(`\r${import_picocolors.default.red("✗")} ${msg}\n`);
15120
+ }
15238
15121
  };
15239
15122
  }
15240
- const packageManagers = [
15241
- {
15242
- name: "npm",
15243
- command: "npm",
15244
- lockFile: "package-lock.json"
15245
- },
15246
- {
15247
- name: "pnpm",
15248
- command: "pnpm",
15249
- lockFile: "pnpm-lock.yaml",
15250
- files: ["pnpm-workspace.yaml"]
15251
- },
15252
- {
15253
- name: "bun",
15254
- command: "bun",
15255
- lockFile: ["bun.lockb", "bun.lock"]
15256
- },
15257
- {
15258
- name: "yarn",
15259
- command: "yarn",
15260
- majorVersion: "1",
15261
- lockFile: "yarn.lock"
15262
- },
15263
- {
15264
- name: "yarn",
15265
- command: "yarn",
15266
- majorVersion: "3",
15267
- lockFile: "yarn.lock",
15268
- files: [".yarnrc.yml"]
15269
- }
15270
- ];
15271
- async function detectPackageManager(cwd, options = {}) {
15272
- const detected = await findup(resolve$1(cwd || "."), async (path) => {
15273
- if (!options.ignorePackageJSON) {
15274
- const packageJSONPath = join$1(path, "package.json");
15275
- if (existsSync(packageJSONPath)) {
15276
- const packageJSON = JSON.parse(await readFile(packageJSONPath, "utf8"));
15277
- if (packageJSON?.packageManager) {
15278
- const [name, version = "0.0.0"] = packageJSON.packageManager.split("@");
15279
- const majorVersion = version.split(".")[0];
15280
- return {
15281
- ...packageManagers.find((pm) => pm.name === name && pm.majorVersion === majorVersion) || packageManagers.find((pm) => pm.name === name),
15282
- name,
15283
- command: name,
15284
- version,
15285
- majorVersion
15286
- };
15287
- }
15288
- }
15289
- }
15290
- if (!options.ignoreLockFile) {
15291
- for (const packageManager of packageManagers) if ([packageManager.lockFile, packageManager.files].flat().filter(Boolean).some((file) => existsSync(resolve$1(path, file)))) return { ...packageManager };
15292
- }
15293
- }, { includeParentDirs: options.includeParentDirs ?? true });
15294
- if (!detected && !options.ignoreArgv) {
15295
- const scriptArg = process.argv[1];
15296
- if (scriptArg) {
15297
- for (const packageManager of packageManagers) if (new RegExp(`[/\\\\]\\.?${packageManager.command}`).test(scriptArg)) return packageManager;
15298
- }
15299
- }
15300
- return detected;
15123
+ function getCacheBase() {
15124
+ if (process.platform === "win32") return join(process.env.LOCALAPPDATA ?? join(homedir(), "AppData", "Local"), "8n");
15125
+ return join(process.env.XDG_CACHE_HOME ?? join(homedir(), ".cache"), "8n");
15301
15126
  }
15302
- async function installDependencies(options = {}) {
15303
- const resolvedOptions = await resolveOperationOptions(options);
15304
- const commandArgs = options.frozenLockFile ? {
15305
- npm: ["ci"],
15306
- yarn: ["install", "--immutable"],
15307
- bun: ["install", "--frozen-lockfile"],
15308
- pnpm: ["install", "--frozen-lockfile"]
15309
- }[resolvedOptions.packageManager.name] : ["install"];
15310
- await executeCommand(resolvedOptions.packageManager.command, commandArgs, {
15311
- cwd: resolvedOptions.cwd,
15312
- silent: resolvedOptions.silent
15313
- });
15127
+ function getGlobalCacheDir(version) {
15128
+ return join(getCacheBase(), "starter", version);
15129
+ }
15130
+ function findAnyCachedStarterDir() {
15131
+ const base = join(getCacheBase(), "starter");
15132
+ if (!existsSync(base)) return null;
15133
+ const versions = readdirSync(base).filter((v) => existsSync(join(base, v, "package.json")));
15134
+ if (versions.length === 0) return null;
15135
+ return join(base, versions.at(-1));
15314
15136
  }
15315
-
15316
- //#endregion
15317
- //#region src/web-app.ts
15318
- const STARTER_PACKAGE = "@ahmedrowaihi/8n-starter";
15319
15137
  async function checkSelfUpdate() {
15320
15138
  try {
15321
15139
  const res = await fetch("https://registry.npmjs.org/@ahmedrowaihi/8n/latest", {
@@ -15324,7 +15142,7 @@ async function checkSelfUpdate() {
15324
15142
  });
15325
15143
  if (!res.ok) return;
15326
15144
  const { version: latest } = await res.json();
15327
- const current = "0.5.0";
15145
+ const current = "0.5.2";
15328
15146
  if (latest !== current) console.log(import_picocolors.default.yellow("⚠") + import_picocolors.default.dim(` new CLI version available: `) + import_picocolors.default.cyan(latest) + import_picocolors.default.dim(` (current: ${current}) — run `) + import_picocolors.default.cyan("npm i -g @ahmedrowaihi/8n") + import_picocolors.default.dim(" to update"));
15329
15147
  } catch {}
15330
15148
  }
@@ -15347,39 +15165,56 @@ async function downloadAndExtract(version, destDir) {
15347
15165
  await writeFile(outPath, file.data);
15348
15166
  }
15349
15167
  }
15350
- async function prepareSudocs(sudocsDir, options) {
15168
+ async function prepareSudocs(options) {
15351
15169
  if (process.env.SUDOCS_LOCAL) return {
15352
15170
  updated: false,
15353
15171
  version: "local",
15354
15172
  dir: resolve(process.env.SUDOCS_LOCAL)
15355
15173
  };
15356
15174
  const latestVersion = options?.version ?? await getLatestVersion();
15357
- const versionFile = join(sudocsDir, ".8n-version");
15358
- if ((existsSync(versionFile) ? readFileSync(versionFile, "utf8").trim() : null) === latestVersion && existsSync(sudocsDir)) return {
15175
+ const sudocsDir = getGlobalCacheDir(latestVersion);
15176
+ if (existsSync(join(sudocsDir, "node_modules"))) return {
15359
15177
  updated: false,
15360
15178
  version: latestVersion,
15361
15179
  dir: sudocsDir
15362
15180
  };
15363
- if (existsSync(sudocsDir)) rmSync(sudocsDir, {
15364
- recursive: true,
15365
- force: true
15366
- });
15367
- await downloadAndExtract(latestVersion, sudocsDir);
15368
- await installDependencies({
15369
- cwd: sudocsDir,
15370
- packageManager: {
15371
- name: "npm",
15372
- command: "npm"
15373
- }
15374
- });
15375
- writeFileSync(versionFile, latestVersion);
15181
+ const dlSpin = spinner(`downloading starter ${latestVersion}`);
15182
+ try {
15183
+ await downloadAndExtract(latestVersion, sudocsDir);
15184
+ dlSpin.succeed(`downloaded starter ${latestVersion}`);
15185
+ } catch (err) {
15186
+ dlSpin.fail(`download failed: ${err.message}`);
15187
+ throw err;
15188
+ }
15189
+ const installSpin = spinner("installing dependencies");
15190
+ try {
15191
+ await R("npm", existsSync(join(sudocsDir, "package-lock.json")) ? [
15192
+ "ci",
15193
+ "--prefer-offline",
15194
+ "--no-audit",
15195
+ "--no-fund",
15196
+ "--legacy-peer-deps"
15197
+ ] : [
15198
+ "install",
15199
+ "--prefer-offline",
15200
+ "--no-audit",
15201
+ "--no-fund",
15202
+ "--legacy-peer-deps"
15203
+ ], { nodeOptions: {
15204
+ cwd: sudocsDir,
15205
+ stdio: process.env.DEBUG_8N ? "inherit" : "pipe"
15206
+ } });
15207
+ installSpin.succeed("dependencies installed");
15208
+ } catch (err) {
15209
+ installSpin.fail(`install failed: ${err.message}`);
15210
+ throw err;
15211
+ }
15376
15212
  return {
15377
15213
  updated: true,
15378
15214
  version: latestVersion,
15379
15215
  dir: sudocsDir
15380
15216
  };
15381
15217
  }
15382
- /** Returns path to a binary in node_modules/.bin/ of the given dir */
15383
15218
  function getSudocsBin(sudocsDir, name) {
15384
15219
  return join(sudocsDir, "node_modules", ".bin", name);
15385
15220
  }
@@ -15401,10 +15236,9 @@ function buildEnv(config, contentDir) {
15401
15236
  async function dev() {
15402
15237
  const config = await resolveConfig();
15403
15238
  const contentDir = resolve(process.cwd(), config.content ?? "./content");
15404
- const fallbackDir = resolve(process.cwd(), ".sudocs");
15405
15239
  console.log(import_picocolors.default.cyan("8n") + import_picocolors.default.dim(` dev → ${contentDir}`));
15406
15240
  if (process.env.SUDOCS_LOCAL) {
15407
- const { dir: sudocsDir } = await prepareSudocs(fallbackDir, { version: config.version });
15241
+ const { dir: sudocsDir } = await prepareSudocs({ version: config.version });
15408
15242
  console.log(import_picocolors.default.yellow("⚑") + import_picocolors.default.dim(` using local starter → ${sudocsDir}`));
15409
15243
  await R(getSudocsBin(sudocsDir, "next"), ["dev"], { nodeOptions: {
15410
15244
  cwd: sudocsDir,
@@ -15417,16 +15251,17 @@ async function dev() {
15417
15251
  checkSelfUpdate();
15418
15252
  let sudocsDir;
15419
15253
  try {
15420
- const result = await prepareSudocs(fallbackDir, { version: config.version });
15254
+ const result = await prepareSudocs({ version: config.version });
15421
15255
  sudocsDir = result.dir;
15422
15256
  const v = result.version;
15423
15257
  if (result.updated) console.log(import_picocolors.default.green("✓") + ` starter updated to ${import_picocolors.default.cyan(v)}`);
15424
15258
  else console.log(import_picocolors.default.green("✓") + import_picocolors.default.dim(` already on latest (${v})`));
15425
15259
  } catch (err) {
15426
- if (existsSync(fallbackDir)) {
15260
+ const cached = findAnyCachedStarterDir();
15261
+ if (cached) {
15427
15262
  console.log(import_picocolors.default.yellow("⚠") + import_picocolors.default.dim(" update check failed — using cached starter"));
15428
15263
  console.log(import_picocolors.default.dim(` ${err.message}`));
15429
- sudocsDir = fallbackDir;
15264
+ sudocsDir = cached;
15430
15265
  } else {
15431
15266
  console.error(import_picocolors.default.red("✗") + " failed to download starter and no cache found");
15432
15267
  console.error(import_picocolors.default.dim(` ${err.message}`));
@@ -15442,27 +15277,19 @@ async function dev() {
15442
15277
 
15443
15278
  //#endregion
15444
15279
  //#region src/commands/build.ts
15445
- function cleanupSudocs(sudocsDir) {
15446
- for (const entry of readdirSync(sudocsDir)) if (entry !== ".next") rmSync(join(sudocsDir, entry), {
15447
- recursive: true,
15448
- force: true
15449
- });
15450
- }
15451
15280
  async function build() {
15452
15281
  const config = await resolveConfig();
15453
15282
  const contentDir = resolve(process.cwd(), config.content ?? "./content");
15454
- const fallbackDir = resolve(process.cwd(), ".sudocs");
15455
15283
  console.log(import_picocolors.default.cyan("8n") + import_picocolors.default.dim(` build → ${contentDir}`));
15456
15284
  if (!process.env.SUDOCS_LOCAL) console.log(import_picocolors.default.dim(" checking for updates..."));
15457
- const { updated, hash, dir: sudocsDir } = await prepareSudocs(fallbackDir, { version: config.version });
15458
- if (updated) console.log(import_picocolors.default.green("✓") + import_picocolors.default.dim(` starter updated to ${hash.slice(0, 7)}`));
15285
+ const { version, dir: sudocsDir } = await prepareSudocs({ version: config.version });
15286
+ console.log(import_picocolors.default.green("✓") + import_picocolors.default.dim(` starter ${version}`));
15459
15287
  await R(getSudocsBin(sudocsDir, "next"), ["build"], { nodeOptions: {
15460
15288
  cwd: sudocsDir,
15461
15289
  stdio: "inherit",
15462
15290
  env: buildEnv(config, contentDir)
15463
15291
  } });
15464
- cleanupSudocs(sudocsDir);
15465
- console.log(import_picocolors.default.green("✓") + import_picocolors.default.dim(" build complete → .sudocs/.next"));
15292
+ console.log(import_picocolors.default.green("✓") + import_picocolors.default.dim(" build complete"));
15466
15293
  }
15467
15294
 
15468
15295
  //#endregion
@@ -15470,8 +15297,8 @@ async function build() {
15470
15297
  async function start() {
15471
15298
  const config = await resolveConfig();
15472
15299
  const contentDir = resolve(process.cwd(), config.content ?? "./content");
15473
- const sudocsDir = resolve(process.cwd(), ".sudocs");
15474
15300
  console.log(import_picocolors.default.cyan("8n") + import_picocolors.default.dim(" start"));
15301
+ const { dir: sudocsDir } = await prepareSudocs({ version: config.version });
15475
15302
  await R(getSudocsBin(sudocsDir, "next"), ["start"], { nodeOptions: {
15476
15303
  cwd: sudocsDir,
15477
15304
  stdio: "inherit",
@@ -15602,7 +15429,9 @@ async function init() {
15602
15429
 
15603
15430
  //#endregion
15604
15431
  //#region src/index.ts
15605
- const program = new Command().name("8n").description("Run your Thmanyah docs site").version("0.5.0");
15432
+ const program = new Command().name("8n").description("Run your Thmanyah docs site").version("0.5.2").addOption(new Option("--debug").hideHelp()).hook("preAction", (cmd) => {
15433
+ if (cmd.opts().debug) process.env.DEBUG_8N = "1";
15434
+ });
15606
15435
  program.command("init").description("Scaffold a new docs project in the current directory").action(init);
15607
15436
  program.command("dev").description("Start the dev server").action(dev);
15608
15437
  program.command("build").description("Build for production").action(build);
@@ -15610,4 +15439,4 @@ program.command("start").description("Start the production server").action(start
15610
15439
  program.parse();
15611
15440
 
15612
15441
  //#endregion
15613
- export { dirname$1 as a, resolve$2 as c, __toESM as d, basename as i, __commonJSMin as l, h as n, join$2 as o, N$1 as r, normalize$2 as s, defu as t, __require as u };
15442
+ export { dirname$1 as a, resolve$1 as c, __toESM as d, basename as i, __commonJSMin as l, h as n, join$1 as o, N$1 as r, normalize$1 as s, defu as t, __require as u };