@mono-lit/utility 0.0.0-stage → 0.0.1
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/LICENSE.md +54 -0
- package/README.md +156 -2
- package/dist/app-roots-BJsIxzjk.d.ts +91 -0
- package/dist/app-roots-CvJnmXcs.js +128 -0
- package/dist/config-node-UzJrXg0Z.js +76 -0
- package/dist/config-node.d.ts +977 -0
- package/dist/config-node.js +7 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +3 -0
- package/dist/create-config-D3m6xTaQ.d.ts +733 -0
- package/dist/create-config-DdL3Fh6T.js +357 -0
- package/dist/fetching.d.ts +239 -0
- package/dist/fetching.js +867 -0
- package/dist/generate-CJ7MtcDd.js +291 -0
- package/dist/index-C2hZeNkq.d.ts +365 -0
- package/dist/index-ClrZbU7n.d.ts +518 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +939 -0
- package/dist/merge-file-C5nzi_MY.d.ts +122 -0
- package/dist/merge-file-CtyKTu5L.js +133 -0
- package/dist/mock-db-5mJTObSC.js +1282 -0
- package/dist/mock-db.d.ts +2 -0
- package/dist/mock-db.js +4 -0
- package/dist/mono-alias-DNDm-jB_.js +508 -0
- package/dist/mono-clone.mjs +958 -0
- package/dist/mono-db.d.ts +1 -0
- package/dist/mono-db.js +151 -0
- package/dist/mono-env.mjs +231 -0
- package/dist/mono-git.mjs +798 -0
- package/dist/mono-link-YlOQ2PVS.js +488 -0
- package/dist/mono-prepare.d.ts +1 -0
- package/dist/mono-prepare.js +27 -0
- package/dist/mono-skills.d.ts +1 -0
- package/dist/mono-skills.js +830 -0
- package/dist/mono-tsconfig-D2qRL9_R.js +204 -0
- package/dist/mono.mjs +34 -0
- package/dist/nuxt-layers-DP1m7f1-.js +176 -0
- package/dist/nuxt-layers.d.ts +34 -0
- package/dist/nuxt-layers.js +3 -0
- package/dist/nuxt-runtime.d.ts +18 -0
- package/dist/nuxt-runtime.js +102 -0
- package/dist/nuxt.d.ts +386 -0
- package/dist/nuxt.js +590 -0
- package/dist/runtime-C_IWNrAG.js +5817 -0
- package/dist/runtime.d.ts +2583 -0
- package/dist/runtime.js +4 -0
- package/dist/session-Bk985AIM.js +1721 -0
- package/dist/types-B6FdB7LJ.d.ts +57 -0
- package/dist/universal-B2eD9xho.d.ts +97 -0
- package/dist/universal-BNTo_83u.js +599 -0
- package/dist/virtual-mono-apps.d.ts +16 -0
- package/dist/vite.d.ts +940 -0
- package/dist/vite.js +1132 -0
- package/package.json +141 -3
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { o as MonoAppType } from "./create-config-D3m6xTaQ.js";
|
|
2
|
+
|
|
3
|
+
//#region src/composables/merge-file.d.ts
|
|
4
|
+
type EcoSub = "composables" | "stores" | "components";
|
|
5
|
+
type DirValue = string | string[];
|
|
6
|
+
type MatchValue = string | RegExp | ((value: string) => boolean);
|
|
7
|
+
type MergeEcosystemOptions<T = string> = {
|
|
8
|
+
dirname: string;
|
|
9
|
+
appDir?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Pre-resolved app roots, replacing the `.mono/apps/` listing.
|
|
12
|
+
*
|
|
13
|
+
* `monoEcosystem` passes these so an app pointed at a local checkout by
|
|
14
|
+
* `apps[].path` contributes its dirs — a directory listing cannot see one.
|
|
15
|
+
* Omit for the plain scan.
|
|
16
|
+
*/
|
|
17
|
+
appRoots?: {
|
|
18
|
+
name: string;
|
|
19
|
+
root: string;
|
|
20
|
+
}[];
|
|
21
|
+
/**
|
|
22
|
+
* App name filters.
|
|
23
|
+
*/
|
|
24
|
+
includes?: string[];
|
|
25
|
+
excludes?: string[];
|
|
26
|
+
/**
|
|
27
|
+
* Directory path.
|
|
28
|
+
*/
|
|
29
|
+
dir?: DirValue;
|
|
30
|
+
sub?: EcoSub;
|
|
31
|
+
/**
|
|
32
|
+
* Per-app directory override.
|
|
33
|
+
*/
|
|
34
|
+
appDirs?: Record<string, DirValue>;
|
|
35
|
+
/**
|
|
36
|
+
* Per-app ecosystem allowlist, from an `extends` entry's `ecosystems`.
|
|
37
|
+
* App absent = unrestricted; `[]` = contributes nothing. See
|
|
38
|
+
* {@link ecosystemSubAllowed}.
|
|
39
|
+
*
|
|
40
|
+
* Honoured here as well as in {@link monoEcosystem} so calling the
|
|
41
|
+
* low-level primitive directly cannot escape a config's policy.
|
|
42
|
+
*/
|
|
43
|
+
ecosystems?: Record<string, string[]>;
|
|
44
|
+
/**
|
|
45
|
+
* Resolved directory filters.
|
|
46
|
+
*/
|
|
47
|
+
dirIncludes?: MatchValue[];
|
|
48
|
+
dirExcludes?: MatchValue[];
|
|
49
|
+
/**
|
|
50
|
+
* Output mapper.
|
|
51
|
+
*/
|
|
52
|
+
map?: (dir: string, ctx: {
|
|
53
|
+
appName: string;
|
|
54
|
+
appRoot: string;
|
|
55
|
+
}) => T;
|
|
56
|
+
};
|
|
57
|
+
declare function mergeEcosystem<T = string>({
|
|
58
|
+
dirname,
|
|
59
|
+
appDir,
|
|
60
|
+
appRoots,
|
|
61
|
+
includes,
|
|
62
|
+
excludes,
|
|
63
|
+
dir,
|
|
64
|
+
sub,
|
|
65
|
+
appDirs,
|
|
66
|
+
ecosystems,
|
|
67
|
+
dirIncludes,
|
|
68
|
+
dirExcludes,
|
|
69
|
+
map
|
|
70
|
+
}: MergeEcosystemOptions<T>): T[];
|
|
71
|
+
type MonoEcosystemOptions = {
|
|
72
|
+
dirname: string;
|
|
73
|
+
/**
|
|
74
|
+
* Resolved apps (name + kind). Each app's srcDir is derived from `type`.
|
|
75
|
+
* `path` is read too — carry it through, or a locally-linked app silently
|
|
76
|
+
* contributes nothing.
|
|
77
|
+
*/
|
|
78
|
+
apps: {
|
|
79
|
+
name: string;
|
|
80
|
+
type: MonoAppType;
|
|
81
|
+
path?: string;
|
|
82
|
+
}[];
|
|
83
|
+
/**
|
|
84
|
+
* Subpath(s) relative to each app's srcDir — e.g. `'pages'`,
|
|
85
|
+
* `['composables/shared', 'stores/shared', 'composables']`. Resolved per app
|
|
86
|
+
* to `<srcDirForType(type)>/<sub>` (`src/pages` for a vue app, `app/pages`
|
|
87
|
+
* for a nuxt app).
|
|
88
|
+
*/
|
|
89
|
+
subs: string | string[];
|
|
90
|
+
appDir?: string;
|
|
91
|
+
includes?: string[];
|
|
92
|
+
excludes?: string[];
|
|
93
|
+
/**
|
|
94
|
+
* Per-app ecosystem allowlist from `resolveExtendsEcosystems(rawConfig)`.
|
|
95
|
+
* App absent = unrestricted; `[]` = contributes nothing.
|
|
96
|
+
*/
|
|
97
|
+
ecosystems?: Record<string, string[]>;
|
|
98
|
+
dirIncludes?: MatchValue[];
|
|
99
|
+
dirExcludes?: MatchValue[]; /** @deprecated `apps[].path` is authoritative in every command; ignored. */
|
|
100
|
+
link?: boolean;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Type-aware wrapper over {@link mergeEcosystem}: builds per-app `appDirs` from
|
|
104
|
+
* each app's `type` (`vue` -> `src/<sub>`, `nuxt` -> `app/<sub>`) so a host can
|
|
105
|
+
* pull in a remote without hardcoding its source folder. Only apps present in
|
|
106
|
+
* both `apps` and {@link resolveAppRoots} produce dirs — which means the
|
|
107
|
+
* `.mono/apps/` clone, or the local checkout an app's `path` names. Returns
|
|
108
|
+
* absolute, existing dirs.
|
|
109
|
+
*/
|
|
110
|
+
declare function monoEcosystem({
|
|
111
|
+
dirname,
|
|
112
|
+
apps,
|
|
113
|
+
subs,
|
|
114
|
+
appDir,
|
|
115
|
+
includes,
|
|
116
|
+
excludes,
|
|
117
|
+
ecosystems,
|
|
118
|
+
dirIncludes,
|
|
119
|
+
dirExcludes
|
|
120
|
+
}: MonoEcosystemOptions): string[];
|
|
121
|
+
//#endregion
|
|
122
|
+
export { monoEcosystem as i, MonoEcosystemOptions as n, mergeEcosystem as r, MergeEcosystemOptions as t };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { c as resolveAppRoots } from "./app-roots-CvJnmXcs.js";
|
|
2
|
+
import { l as srcDirForType } from "./create-config-DdL3Fh6T.js";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
|
|
6
|
+
//#region src/composables/merge-file.ts
|
|
7
|
+
function toArray(value) {
|
|
8
|
+
if (!value) return [];
|
|
9
|
+
return Array.isArray(value) ? value : [value];
|
|
10
|
+
}
|
|
11
|
+
function uniq(value) {
|
|
12
|
+
return [...new Set(value)];
|
|
13
|
+
}
|
|
14
|
+
function resolveDirValue({ dir, sub }) {
|
|
15
|
+
const dirs = toArray(dir);
|
|
16
|
+
if (!dirs.length && sub) return [path.join("src", sub)];
|
|
17
|
+
if (!sub) return dirs;
|
|
18
|
+
return dirs.map((d) => path.join(d, sub));
|
|
19
|
+
}
|
|
20
|
+
/** `.\Foo\bar/` -> `Foo/bar`, so policy and candidate compare on equal terms. */
|
|
21
|
+
function normalizeSub(value) {
|
|
22
|
+
return value.replaceAll("\\", "/").replace(/^\.\//, "").replace(/\/+$/, "");
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Does `sub` fall inside an `ecosystems` allowlist?
|
|
26
|
+
*
|
|
27
|
+
* Matching is **segment-wise**, not `startsWith`: `'composables'` admits
|
|
28
|
+
* `'composables/shared'` (the shape hosts actually pass), while `'compos'`
|
|
29
|
+
* admits nothing and `'composables/shared'` admits only itself.
|
|
30
|
+
*
|
|
31
|
+
* `undefined` means no policy was declared, so everything is allowed; an empty
|
|
32
|
+
* list is an explicit "nothing".
|
|
33
|
+
*/
|
|
34
|
+
function ecosystemSubAllowed(sub, allow) {
|
|
35
|
+
if (!allow) return true;
|
|
36
|
+
if (!allow.length) return false;
|
|
37
|
+
const target = normalizeSub(sub);
|
|
38
|
+
return allow.some((entry) => {
|
|
39
|
+
const allowed = normalizeSub(entry);
|
|
40
|
+
return target === allowed || target.startsWith(`${allowed}/`);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Reduce a candidate relative dir to the sub an `ecosystems` list is written
|
|
45
|
+
* in: `app/pages` and `src/pages` both mean `pages`. Lets the policy apply in
|
|
46
|
+
* {@link mergeEcosystem}, which — unlike {@link monoEcosystem} — only ever sees
|
|
47
|
+
* resolved directories, never the sub names they came from.
|
|
48
|
+
*/
|
|
49
|
+
function candidateSub(rel) {
|
|
50
|
+
const normalized = normalizeSub(rel);
|
|
51
|
+
const [head, ...rest] = normalized.split("/");
|
|
52
|
+
return rest.length && (head === "src" || head === "app") ? rest.join("/") : normalized;
|
|
53
|
+
}
|
|
54
|
+
function matches(value, matcher) {
|
|
55
|
+
if (typeof matcher === "string") return value.includes(matcher);
|
|
56
|
+
if (matcher instanceof RegExp) return matcher.test(value);
|
|
57
|
+
return matcher(value);
|
|
58
|
+
}
|
|
59
|
+
function passDirFilter({ dir, dirIncludes, dirExcludes }) {
|
|
60
|
+
const normalized = dir.replaceAll("\\", "/");
|
|
61
|
+
if (dirIncludes?.length) {
|
|
62
|
+
if (!dirIncludes.some((m) => matches(normalized, m))) return false;
|
|
63
|
+
}
|
|
64
|
+
if (dirExcludes?.length) {
|
|
65
|
+
if (dirExcludes.some((m) => matches(normalized, m))) return false;
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
function mergeEcosystem({ dirname, appDir = "./.mono/apps", appRoots, includes, excludes, dir, sub, appDirs = {}, ecosystems, dirIncludes, dirExcludes, map }) {
|
|
70
|
+
const appsDir = path.resolve(dirname, appDir);
|
|
71
|
+
const roots = appRoots ?? (fs.existsSync(appsDir) ? fs.readdirSync(appsDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => ({
|
|
72
|
+
name: d.name,
|
|
73
|
+
root: path.join(appsDir, d.name)
|
|
74
|
+
})) : []);
|
|
75
|
+
if (!roots.length) return [];
|
|
76
|
+
return roots.filter(({ name }) => {
|
|
77
|
+
if (includes?.length && !includes.includes(name)) return false;
|
|
78
|
+
if (excludes?.length && excludes.includes(name)) return false;
|
|
79
|
+
return true;
|
|
80
|
+
}).flatMap(({ name: appName, root: appRoot }) => {
|
|
81
|
+
return uniq((appDirs[appName] ? toArray(appDirs[appName]) : resolveDirValue({
|
|
82
|
+
dir,
|
|
83
|
+
sub
|
|
84
|
+
})).filter((rel) => ecosystemSubAllowed(candidateSub(rel), ecosystems?.[appName]))).map((rel) => path.resolve(appRoot, rel)).filter((resolvedDir) => fs.existsSync(resolvedDir)).filter((resolvedDir) => passDirFilter({
|
|
85
|
+
dir: resolvedDir,
|
|
86
|
+
dirIncludes,
|
|
87
|
+
dirExcludes
|
|
88
|
+
})).map((resolvedDir) => {
|
|
89
|
+
if (map) return map(resolvedDir, {
|
|
90
|
+
appName,
|
|
91
|
+
appRoot
|
|
92
|
+
});
|
|
93
|
+
return resolvedDir;
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Type-aware wrapper over {@link mergeEcosystem}: builds per-app `appDirs` from
|
|
99
|
+
* each app's `type` (`vue` -> `src/<sub>`, `nuxt` -> `app/<sub>`) so a host can
|
|
100
|
+
* pull in a remote without hardcoding its source folder. Only apps present in
|
|
101
|
+
* both `apps` and {@link resolveAppRoots} produce dirs — which means the
|
|
102
|
+
* `.mono/apps/` clone, or the local checkout an app's `path` names. Returns
|
|
103
|
+
* absolute, existing dirs.
|
|
104
|
+
*/
|
|
105
|
+
function monoEcosystem({ dirname, apps, subs, appDir, includes, excludes, ecosystems, dirIncludes, dirExcludes }) {
|
|
106
|
+
const subList = toArray(subs);
|
|
107
|
+
const appDirs = {};
|
|
108
|
+
for (const app of apps) {
|
|
109
|
+
if (!app?.name || !app?.type) continue;
|
|
110
|
+
const keep = subList.filter((s) => ecosystemSubAllowed(s, ecosystems?.[app.name]));
|
|
111
|
+
if (!keep.length) continue;
|
|
112
|
+
const src = srcDirForType(app.type);
|
|
113
|
+
appDirs[app.name] = keep.map((s) => path.join(src, s));
|
|
114
|
+
}
|
|
115
|
+
return mergeEcosystem({
|
|
116
|
+
dirname,
|
|
117
|
+
appDir,
|
|
118
|
+
appRoots: resolveAppRoots({
|
|
119
|
+
dirname,
|
|
120
|
+
...appDir ? { appsDir: appDir } : {},
|
|
121
|
+
apps,
|
|
122
|
+
onMissingPath: "ignore"
|
|
123
|
+
}),
|
|
124
|
+
appDirs,
|
|
125
|
+
includes,
|
|
126
|
+
excludes,
|
|
127
|
+
dirIncludes,
|
|
128
|
+
dirExcludes
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
//#endregion
|
|
133
|
+
export { mergeEcosystem as n, monoEcosystem as r, ecosystemSubAllowed as t };
|