@g3nomaly/ui 0.3.0 → 0.3.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 +95 -0
- package/dist/cli/adapter.d.ts +48 -0
- package/dist/cli/adapter.d.ts.map +1 -0
- package/dist/cli/adapter.js +87 -0
- package/dist/cli/adapter.js.map +1 -0
- package/dist/cli/commands/add.d.ts +16 -0
- package/dist/cli/commands/add.d.ts.map +1 -0
- package/dist/cli/commands/add.js +20 -0
- package/dist/cli/commands/add.js.map +1 -0
- package/dist/cli/commands/index.d.ts +15 -0
- package/dist/cli/commands/index.d.ts.map +1 -0
- package/dist/cli/commands/index.js +9 -0
- package/dist/cli/commands/index.js.map +1 -0
- package/dist/cli/commands/init.d.ts +25 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +148 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/ls.d.ts +11 -0
- package/dist/cli/commands/ls.d.ts.map +1 -0
- package/dist/cli/commands/ls.js +20 -0
- package/dist/cli/commands/ls.js.map +1 -0
- package/dist/cli/commands/manifest.d.ts +12 -0
- package/dist/cli/commands/manifest.d.ts.map +1 -0
- package/dist/cli/commands/manifest.js +83 -0
- package/dist/cli/commands/manifest.js.map +1 -0
- package/dist/cli/commands/remove.d.ts +10 -0
- package/dist/cli/commands/remove.d.ts.map +1 -0
- package/dist/cli/commands/remove.js +12 -0
- package/dist/cli/commands/remove.js.map +1 -0
- package/dist/cli/commands/source.d.ts +22 -0
- package/dist/cli/commands/source.d.ts.map +1 -0
- package/dist/cli/commands/source.js +23 -0
- package/dist/cli/commands/source.js.map +1 -0
- package/dist/cli/commands/update.d.ts +11 -0
- package/dist/cli/commands/update.d.ts.map +1 -0
- package/dist/cli/commands/update.js +13 -0
- package/dist/cli/commands/update.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +90 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/components/basic/Card.css +32 -0
- package/dist/components/basic/Card.debug.ts +5 -0
- package/dist/components/basic/Card.tsx +26 -0
- package/dist/components/basic/CardFooter.css +16 -0
- package/dist/components/basic/CardFooter.debug.ts +5 -0
- package/dist/components/basic/CardFooter.tsx +25 -0
- package/dist/components/basic/CardHeader.css +14 -0
- package/dist/components/basic/CardHeader.debug.ts +5 -0
- package/dist/components/basic/CardHeader.tsx +25 -0
- package/dist/components/basic/card.meta.ts +13 -0
- package/dist/components/basic/cardfooter.meta.ts +13 -0
- package/dist/components/basic/cardheader.meta.ts +13 -0
- package/dist/components/input/Button.css +34 -0
- package/dist/components/input/Button.debug.ts +5 -0
- package/dist/components/input/Button.tsx +25 -0
- package/dist/components/input/button.meta.ts +13 -0
- package/dist/components.json +138 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/registry/adapters/shadcn.adapter.d.ts +35 -0
- package/dist/registry/adapters/shadcn.adapter.d.ts.map +1 -0
- package/dist/registry/adapters/shadcn.adapter.js +107 -0
- package/dist/registry/adapters/shadcn.adapter.js.map +1 -0
- package/dist/registry/componentsJson.d.ts +23 -0
- package/dist/registry/componentsJson.d.ts.map +1 -0
- package/dist/registry/componentsJson.js +55 -0
- package/dist/registry/componentsJson.js.map +1 -0
- package/dist/registry/index.d.ts +6 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +6 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/manifest.d.ts +19 -0
- package/dist/registry/manifest.d.ts.map +1 -0
- package/dist/registry/manifest.js +76 -0
- package/dist/registry/manifest.js.map +1 -0
- package/dist/registry/readSource.d.ts +20 -0
- package/dist/registry/readSource.d.ts.map +1 -0
- package/dist/registry/readSource.js +44 -0
- package/dist/registry/readSource.js.map +1 -0
- package/dist/registry/types.d.ts +88 -0
- package/dist/registry/types.d.ts.map +1 -0
- package/dist/registry/types.js +44 -0
- package/dist/registry/types.js.map +1 -0
- package/dist/sources/builtins.d.ts +8 -0
- package/dist/sources/builtins.d.ts.map +1 -0
- package/dist/sources/builtins.js +10 -0
- package/dist/sources/builtins.js.map +1 -0
- package/package.json +84 -3
- package/README.md +0 -3
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
{
|
|
2
|
+
"button": {
|
|
3
|
+
"name": "Button",
|
|
4
|
+
"description": "A flexible button component.",
|
|
5
|
+
"category": "input",
|
|
6
|
+
"registryDependencies": [],
|
|
7
|
+
"files": [
|
|
8
|
+
{
|
|
9
|
+
"path": "input/Button.tsx",
|
|
10
|
+
"type": "component",
|
|
11
|
+
"version": "0.3.1",
|
|
12
|
+
"hash": "a17de3eb04c433ffcb69fa226de5d3ab599b413b51b0797acad310042970c84f"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"path": "input/Button.css",
|
|
16
|
+
"type": "style",
|
|
17
|
+
"version": "0.3.1",
|
|
18
|
+
"hash": "eaff21a3e7afa0e48210f146e6558df6997ff31fa8d239031ea110914d5ff208"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"path": "input/Button.debug.ts",
|
|
22
|
+
"type": "util",
|
|
23
|
+
"version": "0.3.1",
|
|
24
|
+
"hash": "441563d2d8ff62e64b7d5e143a6bc8eca23d0ec73fb45b937ca9d89be8041cd6"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"path": "input/button.meta.ts",
|
|
28
|
+
"type": "meta",
|
|
29
|
+
"version": "0.3.1",
|
|
30
|
+
"hash": "d7e774ce63e4f856190471a1780527bd90a964a7bce4b1137dc74d559eff378b"
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"version": "0.3.1"
|
|
34
|
+
},
|
|
35
|
+
"card": {
|
|
36
|
+
"name": "Card",
|
|
37
|
+
"description": "A flexible card component.",
|
|
38
|
+
"category": "basic",
|
|
39
|
+
"registryDependencies": [],
|
|
40
|
+
"files": [
|
|
41
|
+
{
|
|
42
|
+
"path": "basic/Card.tsx",
|
|
43
|
+
"type": "component",
|
|
44
|
+
"version": "0.3.1",
|
|
45
|
+
"hash": "d1a17437e38b4c5f2d2235e4f08fbf3a1fd3463b2ac88979494d5b0f1b26bc61"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"path": "basic/Card.css",
|
|
49
|
+
"type": "style",
|
|
50
|
+
"version": "0.3.1",
|
|
51
|
+
"hash": "5315468962112167dd37b4893e7d38404c19a7f2ba76bf51372bc30d67d5dc42"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"path": "basic/Card.debug.ts",
|
|
55
|
+
"type": "util",
|
|
56
|
+
"version": "0.3.1",
|
|
57
|
+
"hash": "8f1e22c6b9e625d64b9cb969fe06430d8e98634a0e3ad2debd24d6229415817a"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"path": "basic/card.meta.ts",
|
|
61
|
+
"type": "meta",
|
|
62
|
+
"version": "0.3.1",
|
|
63
|
+
"hash": "d55ae66acd3dae60122afd8d0eabe5b6bb818981397986d7c846fa2691666e7a"
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"version": "0.3.1"
|
|
67
|
+
},
|
|
68
|
+
"cardfooter": {
|
|
69
|
+
"name": "CardFooter",
|
|
70
|
+
"description": "Footer section for Card component.",
|
|
71
|
+
"category": "basic",
|
|
72
|
+
"registryDependencies": [
|
|
73
|
+
"card"
|
|
74
|
+
],
|
|
75
|
+
"files": [
|
|
76
|
+
{
|
|
77
|
+
"path": "basic/CardFooter.tsx",
|
|
78
|
+
"type": "component",
|
|
79
|
+
"version": "0.3.1",
|
|
80
|
+
"hash": "4b8409bba0bd034f455f24750c06998286a26f9472bbe47d02b4b2713d207305"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"path": "basic/CardFooter.css",
|
|
84
|
+
"type": "style",
|
|
85
|
+
"version": "0.3.1",
|
|
86
|
+
"hash": "751573c89dc46e83c9f240e58895f42652399f0519907c058568b14aaa52cb4d"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"path": "basic/CardFooter.debug.ts",
|
|
90
|
+
"type": "util",
|
|
91
|
+
"version": "0.3.1",
|
|
92
|
+
"hash": "c6917e9e85165656f7446ce5e9003721911caec097535defd27d43812f9beace"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"path": "basic/cardfooter.meta.ts",
|
|
96
|
+
"type": "meta",
|
|
97
|
+
"version": "0.3.1",
|
|
98
|
+
"hash": "222b8675c7fa742f255e524d47a51c810c70acd82e28fad7937289b50e1a4f90"
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
"version": "0.3.1"
|
|
102
|
+
},
|
|
103
|
+
"cardheader": {
|
|
104
|
+
"name": "CardHeader",
|
|
105
|
+
"description": "Header section for Card component.",
|
|
106
|
+
"category": "basic",
|
|
107
|
+
"registryDependencies": [
|
|
108
|
+
"card"
|
|
109
|
+
],
|
|
110
|
+
"files": [
|
|
111
|
+
{
|
|
112
|
+
"path": "basic/CardHeader.tsx",
|
|
113
|
+
"type": "component",
|
|
114
|
+
"version": "0.3.1",
|
|
115
|
+
"hash": "62e9c557526961b3fd0be553468f7694f901fd637b49e02d623c1bf9bbb4142f"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"path": "basic/CardHeader.css",
|
|
119
|
+
"type": "style",
|
|
120
|
+
"version": "0.3.1",
|
|
121
|
+
"hash": "e36cf86636d2e7619dd69725faaedac9604a9605be11c0e2a6aa3663db8c3b53"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"path": "basic/CardHeader.debug.ts",
|
|
125
|
+
"type": "util",
|
|
126
|
+
"version": "0.3.1",
|
|
127
|
+
"hash": "4c31f97140767fde2d161d97ddb671a3ad54113682eea99e1f86584aed9c8ea0"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"path": "basic/cardheader.meta.ts",
|
|
131
|
+
"type": "meta",
|
|
132
|
+
"version": "0.3.1",
|
|
133
|
+
"hash": "711c603072f52e39389ae2fed341a458d6d9d1bf02eceab447fa686094c1008c"
|
|
134
|
+
}
|
|
135
|
+
],
|
|
136
|
+
"version": "0.3.1"
|
|
137
|
+
}
|
|
138
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { EntrySource } from "@g3nomaly/core/cli";
|
|
2
|
+
import type { ComponentFileType, ComponentMeta } from "../types";
|
|
3
|
+
/** A single file returned by fetchShadcnComponentFiles(). */
|
|
4
|
+
export interface ShadcnFileContent {
|
|
5
|
+
/** File path relative to the user's installDir, e.g. "shadcn/button.tsx" */
|
|
6
|
+
path: string;
|
|
7
|
+
/** Full source code content */
|
|
8
|
+
content: string;
|
|
9
|
+
/** Mapped to g3nui ComponentFileType */
|
|
10
|
+
type: ComponentFileType;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Fetches the shadcn component index as entries keyed `@shadcn/<name>`,
|
|
14
|
+
* recorded under the `shadcn` source. Hashes are absent until install.
|
|
15
|
+
*
|
|
16
|
+
* @returns no entries and a warning when shadcn is not installed or the index cannot be fetched
|
|
17
|
+
*/
|
|
18
|
+
export declare function readShadcnEntries(): Promise<{
|
|
19
|
+
entries: [string, ComponentMeta][];
|
|
20
|
+
warnings: string[];
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Fetches the file contents of one shadcn component through the installed
|
|
24
|
+
* shadcn package.
|
|
25
|
+
*
|
|
26
|
+
* @param name - Component name without the `@shadcn/` prefix, e.g. `button`
|
|
27
|
+
*/
|
|
28
|
+
export declare function fetchShadcnComponentFiles(name: string): Promise<ShadcnFileContent[]>;
|
|
29
|
+
/**
|
|
30
|
+
* File source that fetches shadcn components, one request per component,
|
|
31
|
+
* and writes each file from its content; entries of any other source go to
|
|
32
|
+
* `fallback`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function shadcnFileSource(fallback: EntrySource): EntrySource;
|
|
35
|
+
//# sourceMappingURL=shadcn.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadcn.adapter.d.ts","sourceRoot":"","sources":["../../../src/registry/adapters/shadcn.adapter.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAMjE,6DAA6D;AAC7D,MAAM,WAAW,iBAAiB;IAChC,4EAA4E;IAC5E,IAAI,EAAK,MAAM,CAAC;IAChB,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,IAAI,EAAK,iBAAiB,CAAC;CAC5B;AAuCD;;;;;GAKG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC;IAAE,OAAO,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CA6B7G;AAED;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAW1F;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,WAAW,GAAG,WAAW,CAanE"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// packages/ui/src/registry/adapters/shadcn.adapter.ts
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { OriginEntrySchema } from "@g3nomaly/core/installer";
|
|
5
|
+
import { SHADCN_SOURCE } from "../manifest";
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
const SHADCN_INDEX_URL = "https://ui.shadcn.com/r/index.json";
|
|
8
|
+
/** Root of the installed shadcn package; throws when it is not installed. */
|
|
9
|
+
function resolveShadcnRoot() {
|
|
10
|
+
return path.dirname(require.resolve("shadcn/package.json"));
|
|
11
|
+
}
|
|
12
|
+
/** The g3nui file type for a shadcn registry file type. */
|
|
13
|
+
function mapShadcnType(shadcnType) {
|
|
14
|
+
if (shadcnType === "registry:ui")
|
|
15
|
+
return "component";
|
|
16
|
+
if (shadcnType === "registry:hook")
|
|
17
|
+
return "hook";
|
|
18
|
+
if (shadcnType === "registry:lib")
|
|
19
|
+
return "util";
|
|
20
|
+
if (shadcnType.includes("style") || shadcnType.includes("css"))
|
|
21
|
+
return "style";
|
|
22
|
+
return "component";
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Every shadcn file lands in `shadcn/<filename>`, whatever folder shadcn
|
|
26
|
+
* keeps it in: `ui/button.tsx` and `registry/new-york-v4/ui/button.tsx` both
|
|
27
|
+
* become `shadcn/button.tsx`.
|
|
28
|
+
*/
|
|
29
|
+
function normalizeFilePath(fullPath) {
|
|
30
|
+
const parts = fullPath.split("/");
|
|
31
|
+
return `shadcn/${parts[parts.length - 1]}`;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Fetches the shadcn component index as entries keyed `@shadcn/<name>`,
|
|
35
|
+
* recorded under the `shadcn` source. Hashes are absent until install.
|
|
36
|
+
*
|
|
37
|
+
* @returns no entries and a warning when shadcn is not installed or the index cannot be fetched
|
|
38
|
+
*/
|
|
39
|
+
export async function readShadcnEntries() {
|
|
40
|
+
try {
|
|
41
|
+
resolveShadcnRoot();
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return { entries: [], warnings: ["shadcn is not installed: run `bun add shadcn@latest`"] };
|
|
45
|
+
}
|
|
46
|
+
let items;
|
|
47
|
+
try {
|
|
48
|
+
const res = await fetch(SHADCN_INDEX_URL);
|
|
49
|
+
if (!res.ok)
|
|
50
|
+
throw new Error(`HTTP ${res.status}`);
|
|
51
|
+
items = (await res.json());
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
return { entries: [], warnings: [`the shadcn index could not be fetched: ${String(err)}`] };
|
|
55
|
+
}
|
|
56
|
+
const entries = [];
|
|
57
|
+
for (const item of items) {
|
|
58
|
+
if (!item.name || !item.files?.length)
|
|
59
|
+
continue;
|
|
60
|
+
entries.push([`@shadcn/${item.name.toLowerCase()}`, {
|
|
61
|
+
name: item.name,
|
|
62
|
+
description: item.description,
|
|
63
|
+
group: SHADCN_SOURCE,
|
|
64
|
+
origin: { source: SHADCN_SOURCE, dir: "" },
|
|
65
|
+
registryDependencies: (item.registryDependencies ?? []).map((dep) => `@shadcn/${dep.toLowerCase()}`),
|
|
66
|
+
files: item.files.map((f) => ({ path: normalizeFilePath(f.path), type: mapShadcnType(f.type) })),
|
|
67
|
+
}]);
|
|
68
|
+
}
|
|
69
|
+
return { entries, warnings: [] };
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Fetches the file contents of one shadcn component through the installed
|
|
73
|
+
* shadcn package.
|
|
74
|
+
*
|
|
75
|
+
* @param name - Component name without the `@shadcn/` prefix, e.g. `button`
|
|
76
|
+
*/
|
|
77
|
+
export async function fetchShadcnComponentFiles(name) {
|
|
78
|
+
// Imported on use, so only commands that install shadcn components need the package.
|
|
79
|
+
const { getRegistryItems } = await import("shadcn/registry");
|
|
80
|
+
const items = await getRegistryItems([name]);
|
|
81
|
+
const item = items[0];
|
|
82
|
+
if (!item?.files?.length)
|
|
83
|
+
return [];
|
|
84
|
+
return item.files
|
|
85
|
+
.filter((f) => typeof f.content === "string")
|
|
86
|
+
.map((f) => ({ path: normalizeFilePath(f.path), content: f.content, type: mapShadcnType(f.type) }));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* File source that fetches shadcn components, one request per component,
|
|
90
|
+
* and writes each file from its content; entries of any other source go to
|
|
91
|
+
* `fallback`.
|
|
92
|
+
*/
|
|
93
|
+
export function shadcnFileSource(fallback) {
|
|
94
|
+
return async (entry) => {
|
|
95
|
+
const { origin } = OriginEntrySchema.pick({ origin: true }).parse(entry);
|
|
96
|
+
if (origin.source !== SHADCN_SOURCE)
|
|
97
|
+
return fallback(entry);
|
|
98
|
+
const fetched = await fetchShadcnComponentFiles(entry.name.toLowerCase());
|
|
99
|
+
const contents = new Map(fetched.map((f) => [f.path, f.content]));
|
|
100
|
+
const source = (file) => {
|
|
101
|
+
const content = contents.get(file.path);
|
|
102
|
+
return content === undefined ? null : { kind: "write", content };
|
|
103
|
+
};
|
|
104
|
+
return source;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=shadcn.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadcn.adapter.js","sourceRoot":"","sources":["../../../src/registry/adapters/shadcn.adapter.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAG7D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,MAAM,gBAAgB,GAAG,oCAAoC,CAAC;AAyB9D,6EAA6E;AAC7E,SAAS,iBAAiB;IACxB,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED,2DAA2D;AAC3D,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AE,CAAC;QACnE,CAAC,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { PackagedComponent } from "./types";
|
|
2
|
+
/** Where a package keeps its built components and their registry, relative to the package root. */
|
|
3
|
+
export declare const COMPONENTS_DIR: string;
|
|
4
|
+
export declare const COMPONENTS_JSON: string;
|
|
5
|
+
/**
|
|
6
|
+
* Builds `components.json` from every `*.meta.ts` under the built components
|
|
7
|
+
* folder: each component with its files hashed and stamped with the package
|
|
8
|
+
* version, the meta file itself included. Run by `scripts/build-registry.ts`.
|
|
9
|
+
*
|
|
10
|
+
* @param componentsDir - Absolute built components folder, e.g. `<package>/dist/components`
|
|
11
|
+
* @param outFile - Absolute path to write, e.g. `<package>/dist/components.json`
|
|
12
|
+
* @param version - Package version stamped on every component and file
|
|
13
|
+
* @returns how many components were written
|
|
14
|
+
*/
|
|
15
|
+
export declare function writeComponentsJson(componentsDir: string, outFile: string, version: string): Promise<number>;
|
|
16
|
+
/**
|
|
17
|
+
* Reads a package's `components.json`, keyed by lowercase component key.
|
|
18
|
+
*
|
|
19
|
+
* @param packageRoot - Absolute folder holding `dist/components.json`
|
|
20
|
+
* @throws naming the file when it is missing, not JSON, or does not match the schema
|
|
21
|
+
*/
|
|
22
|
+
export declare function readComponentsJson(packageRoot: string): Record<string, PackagedComponent>;
|
|
23
|
+
//# sourceMappingURL=componentsJson.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentsJson.d.ts","sourceRoot":"","sources":["../../src/registry/componentsJson.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,mGAAmG;AACnG,eAAO,MAAM,cAAc,QAAmC,CAAC;AAC/D,eAAO,MAAM,eAAe,QAAuC,CAAC;AAIpE;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAiBlH;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAMzF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// packages/ui/src/registry/componentsJson.ts
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { glob } from "glob";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { createRegistryStore, jsonHandler, register, writeTo } from "@g3nomaly/core/registry";
|
|
7
|
+
import { hashFile } from "@g3nomaly/core/hash";
|
|
8
|
+
import { getSafeObject } from "@g3nomaly/core/security";
|
|
9
|
+
import { PackagedComponentSchema } from "./types";
|
|
10
|
+
/** Where a package keeps its built components and their registry, relative to the package root. */
|
|
11
|
+
export const COMPONENTS_DIR = path.join("dist", "components");
|
|
12
|
+
export const COMPONENTS_JSON = path.join("dist", "components.json");
|
|
13
|
+
const ComponentsJsonSchema = z.record(z.string(), PackagedComponentSchema);
|
|
14
|
+
/**
|
|
15
|
+
* Builds `components.json` from every `*.meta.ts` under the built components
|
|
16
|
+
* folder: each component with its files hashed and stamped with the package
|
|
17
|
+
* version, the meta file itself included. Run by `scripts/build-registry.ts`.
|
|
18
|
+
*
|
|
19
|
+
* @param componentsDir - Absolute built components folder, e.g. `<package>/dist/components`
|
|
20
|
+
* @param outFile - Absolute path to write, e.g. `<package>/dist/components.json`
|
|
21
|
+
* @param version - Package version stamped on every component and file
|
|
22
|
+
* @returns how many components were written
|
|
23
|
+
*/
|
|
24
|
+
export async function writeComponentsJson(componentsDir, outFile, version) {
|
|
25
|
+
const store = createRegistryStore();
|
|
26
|
+
const metaFiles = await glob("**/*.meta.ts", { cwd: componentsDir, absolute: true });
|
|
27
|
+
for (const metaFile of metaFiles.sort()) {
|
|
28
|
+
const meta = await getSafeObject(metaFile, PackagedComponentSchema);
|
|
29
|
+
const files = [...meta.files, { path: path.relative(componentsDir, metaFile), type: "meta" }];
|
|
30
|
+
const hashed = await Promise.all(files.map(async (file) => ({
|
|
31
|
+
...file,
|
|
32
|
+
version,
|
|
33
|
+
hash: await hashFile(path.join(componentsDir, file.path)),
|
|
34
|
+
})));
|
|
35
|
+
register(store, meta.name.toLowerCase(), { ...meta, version, files: hashed });
|
|
36
|
+
}
|
|
37
|
+
writeTo(store, outFile, jsonHandler);
|
|
38
|
+
return Object.keys(store.store.state).length;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Reads a package's `components.json`, keyed by lowercase component key.
|
|
42
|
+
*
|
|
43
|
+
* @param packageRoot - Absolute folder holding `dist/components.json`
|
|
44
|
+
* @throws naming the file when it is missing, not JSON, or does not match the schema
|
|
45
|
+
*/
|
|
46
|
+
export function readComponentsJson(packageRoot) {
|
|
47
|
+
const file = path.join(packageRoot, COMPONENTS_JSON);
|
|
48
|
+
if (!fs.existsSync(file))
|
|
49
|
+
throw new Error(`${file} is missing: run \`bun run build\` in the package to create it`);
|
|
50
|
+
const parsed = ComponentsJsonSchema.safeParse(JSON.parse(fs.readFileSync(file, "utf8")));
|
|
51
|
+
if (!parsed.success)
|
|
52
|
+
throw new Error(`${file} is not a valid components.json:\n${z.prettifyError(parsed.error)}`);
|
|
53
|
+
return Object.fromEntries(Object.entries(parsed.data).map(([key, meta]) => [key.toLowerCase(), meta]));
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=componentsJson.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentsJson.js","sourceRoot":"","sources":["../../src/registry/componentsJson.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,O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CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AACzG,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./types";
|
|
2
|
+
export { COMPONENTS_DIR, COMPONENTS_JSON, readComponentsJson, writeComponentsJson } from "./componentsJson";
|
|
3
|
+
export { readComponentSource, filterFiles, groupOf } from "./readSource";
|
|
4
|
+
export type { ComponentFileFlags } from "./readSource";
|
|
5
|
+
export { uiManifestPath, migrateLegacyManifest, SHADCN_SOURCE } from "./manifest";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AACA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5G,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACzE,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// packages/ui/src/registry/index.ts
|
|
2
|
+
export * from "./types";
|
|
3
|
+
export { COMPONENTS_DIR, COMPONENTS_JSON, readComponentsJson, writeComponentsJson } from "./componentsJson";
|
|
4
|
+
export { readComponentSource, filterFiles, groupOf } from "./readSource";
|
|
5
|
+
export { uiManifestPath, migrateLegacyManifest, SHADCN_SOURCE } from "./manifest";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5G,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEzE,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Source name shadcn components are recorded under. */
|
|
2
|
+
export declare const SHADCN_SOURCE = "shadcn";
|
|
3
|
+
/**
|
|
4
|
+
* Path of the project's g3nui manifest.
|
|
5
|
+
*
|
|
6
|
+
* @returns absolute path, e.g. `/home/me/app/.g3n/.g3nui-manifest.json`
|
|
7
|
+
*/
|
|
8
|
+
export declare function uiManifestPath(projectRoot: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Rewrites a manifest from before the shared `{ sources, entries }` shape:
|
|
11
|
+
* a flat `.g3nui-manifest.json`, or a `.g3nui-manifest.ts` whose `registry`
|
|
12
|
+
* export becomes the JSON file and is then deleted. Does nothing when the
|
|
13
|
+
* manifest is already in the shared shape or does not exist.
|
|
14
|
+
*
|
|
15
|
+
* @returns the path that was migrated, or `null` when nothing changed
|
|
16
|
+
* @throws when a legacy manifest does not match the old entry shape
|
|
17
|
+
*/
|
|
18
|
+
export declare function migrateLegacyManifest(projectRoot: string): Promise<string | null>;
|
|
19
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/registry/manifest.ts"],"names":[],"mappings":"AAYA,wDAAwD;AACxD,eAAO,MAAM,aAAa,WAAW,CAAC;AAetC;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE1D;AAoBD;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAkBvF"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// packages/ui/src/registry/manifest.ts
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { COMPONENTS_DIR } from "./componentsJson";
|
|
6
|
+
import { groupOf } from "./readSource";
|
|
7
|
+
import { ComponentFileSchema } from "./types";
|
|
8
|
+
const MANIFEST_DIR = ".g3n";
|
|
9
|
+
const MANIFEST_BASE = ".g3nui-manifest";
|
|
10
|
+
/** Source name shadcn components are recorded under. */
|
|
11
|
+
export const SHADCN_SOURCE = "shadcn";
|
|
12
|
+
/** An entry as manifests before the shared `{ sources, entries }` shape recorded it. */
|
|
13
|
+
const LegacyEntrySchema = z.object({
|
|
14
|
+
name: z.string().min(1),
|
|
15
|
+
description: z.string().optional(),
|
|
16
|
+
version: z.string().optional(),
|
|
17
|
+
category: z.string().optional(),
|
|
18
|
+
group: z.string().optional(),
|
|
19
|
+
author: z.string().optional(),
|
|
20
|
+
packageOrigin: z.string().optional(),
|
|
21
|
+
registryDependencies: z.array(z.string()).optional(),
|
|
22
|
+
files: z.array(ComponentFileSchema).min(1),
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Path of the project's g3nui manifest.
|
|
26
|
+
*
|
|
27
|
+
* @returns absolute path, e.g. `/home/me/app/.g3n/.g3nui-manifest.json`
|
|
28
|
+
*/
|
|
29
|
+
export function uiManifestPath(projectRoot) {
|
|
30
|
+
return path.join(projectRoot, MANIFEST_DIR, `${MANIFEST_BASE}.json`);
|
|
31
|
+
}
|
|
32
|
+
/** One legacy entry in the shared shape, its origin taken from `packageOrigin`. */
|
|
33
|
+
function migrateEntry(entry) {
|
|
34
|
+
const { packageOrigin, group, ...rest } = entry;
|
|
35
|
+
const shadcn = packageOrigin === SHADCN_SOURCE;
|
|
36
|
+
return {
|
|
37
|
+
...rest,
|
|
38
|
+
group: group ?? groupOf(entry),
|
|
39
|
+
origin: shadcn ? { source: SHADCN_SOURCE, dir: "" } : { source: "g3nui", dir: COMPONENTS_DIR, version: entry.version },
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** Writes legacy entries as a shared-shape manifest at the JSON path. */
|
|
43
|
+
function writeMigrated(projectRoot, legacy) {
|
|
44
|
+
const entries = Object.fromEntries(Object.entries(z.record(z.string(), LegacyEntrySchema).parse(legacy)).map(([key, entry]) => [key, migrateEntry(entry)]));
|
|
45
|
+
fs.mkdirSync(path.join(projectRoot, MANIFEST_DIR), { recursive: true });
|
|
46
|
+
fs.writeFileSync(uiManifestPath(projectRoot), JSON.stringify({ sources: {}, entries }, null, 2) + "\n");
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Rewrites a manifest from before the shared `{ sources, entries }` shape:
|
|
50
|
+
* a flat `.g3nui-manifest.json`, or a `.g3nui-manifest.ts` whose `registry`
|
|
51
|
+
* export becomes the JSON file and is then deleted. Does nothing when the
|
|
52
|
+
* manifest is already in the shared shape or does not exist.
|
|
53
|
+
*
|
|
54
|
+
* @returns the path that was migrated, or `null` when nothing changed
|
|
55
|
+
* @throws when a legacy manifest does not match the old entry shape
|
|
56
|
+
*/
|
|
57
|
+
export async function migrateLegacyManifest(projectRoot) {
|
|
58
|
+
const jsonPath = uiManifestPath(projectRoot);
|
|
59
|
+
const tsPath = path.join(projectRoot, MANIFEST_DIR, `${MANIFEST_BASE}.ts`);
|
|
60
|
+
if (fs.existsSync(jsonPath)) {
|
|
61
|
+
const raw = JSON.parse(fs.readFileSync(jsonPath, "utf8"));
|
|
62
|
+
const shared = typeof raw === "object" && raw !== null && ("entries" in raw || "sources" in raw);
|
|
63
|
+
if (shared)
|
|
64
|
+
return null;
|
|
65
|
+
writeMigrated(projectRoot, raw);
|
|
66
|
+
return jsonPath;
|
|
67
|
+
}
|
|
68
|
+
if (fs.existsSync(tsPath)) {
|
|
69
|
+
const legacy = z.object({ registry: z.unknown() }).parse(await import(tsPath));
|
|
70
|
+
writeMigrated(projectRoot, legacy.registry);
|
|
71
|
+
fs.rmSync(tsPath);
|
|
72
|
+
return tsPath;
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/registry/manifest.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAG9C,MAAM,YAAY,GAAI,MAAM,CAAC;AAC7B,MAAM,aAAa,GAAG,iBAAiB,CAAC;AAExC,wDAAwD;AACxD,MAAM,CAAC,MAAM,aAAa,GAAG,QAAQ,CAAC;AAEtC,wFAAwF;AACxF,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,IAAI,EAAkB,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvC,WAAW,EAAW,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3C,OAAO,EAAe,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3C,QAAQ,EAAc,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3C,KAAK,EAAiB,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3C,MAAM,EAAgB,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3C,aAAa,EAAS,CAAC,CAAC,MAAM,EAAE,CAAC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AW,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC5C,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAClB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ReadSource } from "@g3nomaly/core/installer";
|
|
2
|
+
import type { ComponentFile, ComponentMeta, PackagedComponent } from "./types";
|
|
3
|
+
/** Which optional files of a component get installed. */
|
|
4
|
+
export interface ComponentFileFlags {
|
|
5
|
+
/** Install `.debug.ts` files */
|
|
6
|
+
includeDebug: boolean;
|
|
7
|
+
/** Install `.meta.ts` files */
|
|
8
|
+
includeMeta: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** The files of a component the flags allow: `.debug.ts` and `.meta.ts` files only when asked for. */
|
|
11
|
+
export declare function filterFiles(files: readonly ComponentFile[], flags: ComponentFileFlags): ComponentFile[];
|
|
12
|
+
/** A component's display group: its category, else the first folder of its first file. */
|
|
13
|
+
export declare function groupOf(meta: Pick<PackagedComponent, "category" | "files">): string;
|
|
14
|
+
/**
|
|
15
|
+
* Reader for a source that is a component package: its `dist/components.json`,
|
|
16
|
+
* with the files the flags leave out dropped. Handed to `loadSourceRegistry`
|
|
17
|
+
* by every g3nui command.
|
|
18
|
+
*/
|
|
19
|
+
export declare function readComponentSource(flags: ComponentFileFlags): ReadSource<ComponentMeta>;
|
|
20
|
+
//# sourceMappingURL=readSource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readSource.d.ts","sourceRoot":"","sources":["../../src/registry/readSource.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE/E,yDAAyD;AACzD,MAAM,WAAW,kBAAkB;IACjC,gCAAgC;IAChC,YAAY,EAAE,OAAO,CAAC;IACtB,+BAA+B;IAC/B,WAAW,EAAG,OAAO,CAAC;CACvB;AAED,sGAAsG;AACtG,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,EAAE,KAAK,EAAE,kBAAkB,GAAG,aAAa,EAAE,CAMvG;AAED,0FAA0F;AAC1F,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,iBAAiB,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,MAAM,CAInF;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,GAAG,UAAU,CAAC,aAAa,CAAC,CAmBxF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { COMPONENTS_DIR, readComponentsJson } from "./componentsJson";
|
|
2
|
+
/** The files of a component the flags allow: `.debug.ts` and `.meta.ts` files only when asked for. */
|
|
3
|
+
export function filterFiles(files, flags) {
|
|
4
|
+
return files.filter((file) => {
|
|
5
|
+
if (file.path.endsWith(".debug.ts"))
|
|
6
|
+
return flags.includeDebug;
|
|
7
|
+
if (file.path.endsWith(".meta.ts"))
|
|
8
|
+
return flags.includeMeta;
|
|
9
|
+
return true;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
/** A component's display group: its category, else the first folder of its first file. */
|
|
13
|
+
export function groupOf(meta) {
|
|
14
|
+
if (meta.category !== undefined)
|
|
15
|
+
return meta.category;
|
|
16
|
+
const first = meta.files[0]?.path ?? "";
|
|
17
|
+
return first.includes("/") ? first.split("/")[0] ?? "unknown" : "unknown";
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Reader for a source that is a component package: its `dist/components.json`,
|
|
21
|
+
* with the files the flags leave out dropped. Handed to `loadSourceRegistry`
|
|
22
|
+
* by every g3nui command.
|
|
23
|
+
*/
|
|
24
|
+
export function readComponentSource(flags) {
|
|
25
|
+
return async (checkout) => {
|
|
26
|
+
const entries = [];
|
|
27
|
+
const warnings = [];
|
|
28
|
+
for (const [key, meta] of Object.entries(readComponentsJson(checkout.dir))) {
|
|
29
|
+
const files = filterFiles(meta.files, flags);
|
|
30
|
+
if (files.length === 0) {
|
|
31
|
+
warnings.push(`${key} has no files left after filtering, skipped`);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
entries.push([key, {
|
|
35
|
+
...meta,
|
|
36
|
+
group: groupOf(meta),
|
|
37
|
+
origin: { source: checkout.name, dir: COMPONENTS_DIR, commit: checkout.commit, version: checkout.version },
|
|
38
|
+
files,
|
|
39
|
+
}]);
|
|
40
|
+
}
|
|
41
|
+
return { entries, warnings };
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=readSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readSource.js","sourceRoot":"","sources":["../../src/registry/readSource.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAWtE,sGAAsG;AACtG,MAAM,UAAU,WAAW,CAAC,KAA+B,EAAE,KAAyB;IACpF,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;QAC3B,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;YAAE,OAAO,KAAK,CAAC,YAAY,CAAC;QAC/D,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;YAAG,OAAO,KAAK,CAAC,WAAW,CAAC;QAC9D,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,OAAO,CAAC,IAAmD;IACzE,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,EAAE,CAA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