@incajs/cli 0.0.1 → 0.0.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.
@@ -0,0 +1,114 @@
1
+ import { t as e } from "./jsonc-BdzClvC8.js";
2
+ import { c as t, d as n, f as r, l as i, s as a, u as o } from "./defaults-EWjAFeZ3.js";
3
+ import { n as s, t as c } from "./_format-BKs7bsc4.js";
4
+ import { promises as l, statSync as u } from "node:fs";
5
+ import "node:fs/promises";
6
+ import { fileURLToPath as d } from "node:url";
7
+ //#region ../../node_modules/.pnpm/confbox@0.3.1/node_modules/confbox/dist/json.mjs
8
+ function f(e, t) {
9
+ let n = JSON.parse(c(e), t?.reviver);
10
+ return s(e, n, t), n;
11
+ }
12
+ //#endregion
13
+ //#region ../../node_modules/.pnpm/pkg-types@2.3.2/node_modules/pkg-types/dist/index.mjs
14
+ var p = {
15
+ startingFrom: ".",
16
+ rootPattern: /^node_modules$/,
17
+ reverse: !1,
18
+ test: (e) => {
19
+ try {
20
+ if (u(e).isFile()) return !0;
21
+ } catch {}
22
+ }
23
+ };
24
+ async function m(e, t = {}) {
25
+ let n = Array.isArray(e) ? e : [e], i = {
26
+ ...p,
27
+ ...t
28
+ }, a = r(i.startingFrom), s = a[0] === "/", c = a.split("/").filter(Boolean);
29
+ if (n.includes(c.at(-1)) && await i.test(a)) return a;
30
+ s && (c[0] = "/" + c[0]);
31
+ let l = c.findIndex((e) => e.match(i.rootPattern));
32
+ if (l === -1 && (l = 0), i.reverse) for (let e = l + 1; e <= c.length; e++) for (let t of n) {
33
+ let n = o(...c.slice(0, e), t);
34
+ if (await i.test(n)) return n;
35
+ }
36
+ else for (let e = c.length; e > l; e--) for (let t of n) {
37
+ let n = o(...c.slice(0, e), t);
38
+ if (await i.test(n)) return n;
39
+ }
40
+ throw Error(`Cannot find matching ${e} in ${i.startingFrom} or parent directories`);
41
+ }
42
+ function h(e, t = {}) {
43
+ return m(e, t);
44
+ }
45
+ function g(e, t = {}) {
46
+ return e instanceof URL || e.startsWith("file://") ? n(d(e)) : i(e) ? n(e) : a(e, {
47
+ ...t,
48
+ from: t.from || t.parent || t.url
49
+ });
50
+ }
51
+ var _ = [
52
+ "yarn.lock",
53
+ "package-lock.json",
54
+ "pnpm-lock.yaml",
55
+ "npm-shrinkwrap.json",
56
+ "bun.lockb",
57
+ "bun.lock",
58
+ "deno.lock"
59
+ ], v = [
60
+ "package.json",
61
+ "package.json5",
62
+ "package.yaml"
63
+ ], y = [
64
+ "pnpm-workspace.yaml",
65
+ "lerna.json",
66
+ "turbo.json",
67
+ "rush.json",
68
+ "deno.json",
69
+ "deno.jsonc"
70
+ ], b = /* #__PURE__ */ new Map();
71
+ async function x(t, n = {}) {
72
+ let r = await S(t, n), i = n.cache && typeof n.cache != "boolean" ? n.cache : b;
73
+ if (n.cache && i.has(r)) return i.get(r);
74
+ let a = await l.readFile(r, "utf8"), o;
75
+ try {
76
+ o = f(a);
77
+ } catch {
78
+ o = e(a);
79
+ }
80
+ return i.set(r, o), o;
81
+ }
82
+ async function S(e = process.cwd(), t = {}) {
83
+ return h("package.json", {
84
+ ...t,
85
+ startingFrom: g(e, t)
86
+ });
87
+ }
88
+ var C = {
89
+ workspaceFile: (e) => m(y, e).then((e) => t(e)),
90
+ gitConfig: (e) => m(".git/config", e).then((e) => r(e, "../..")),
91
+ lockFile: (e) => m(_, e).then((e) => t(e)),
92
+ packageJson: (e) => m(v, e).then((e) => t(e))
93
+ };
94
+ async function w(e = process.cwd(), t = {}) {
95
+ let n = g(e, t), r = t.tests || [
96
+ "workspaceFile",
97
+ "gitConfig",
98
+ "lockFile",
99
+ "packageJson"
100
+ ];
101
+ for (let e of r) {
102
+ let r = C[e];
103
+ if (t[e] === !1 || !r) continue;
104
+ let i = t[e] || (e === "gitConfig" ? "closest" : "furthest"), a = await r({
105
+ ...t,
106
+ startingFrom: n,
107
+ reverse: i === "furthest"
108
+ }).catch(() => {});
109
+ if (a) return a;
110
+ }
111
+ throw Error(`Cannot detect workspace root from ${e}`);
112
+ }
113
+ //#endregion
114
+ export { w as findWorkspaceDir, x as readPackageJSON };