@g3nomaly/ui 0.3.0 → 0.3.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.
Files changed (92) hide show
  1. package/LICENSE +95 -0
  2. package/dist/cli/adapter.d.ts +86 -0
  3. package/dist/cli/adapter.d.ts.map +1 -0
  4. package/dist/cli/adapter.js +114 -0
  5. package/dist/cli/adapter.js.map +1 -0
  6. package/dist/cli/commands/add.d.ts +24 -0
  7. package/dist/cli/commands/add.d.ts.map +1 -0
  8. package/dist/cli/commands/add.js +24 -0
  9. package/dist/cli/commands/add.js.map +1 -0
  10. package/dist/cli/commands/index.d.ts +15 -0
  11. package/dist/cli/commands/index.d.ts.map +1 -0
  12. package/dist/cli/commands/index.js +9 -0
  13. package/dist/cli/commands/index.js.map +1 -0
  14. package/dist/cli/commands/init.d.ts +48 -0
  15. package/dist/cli/commands/init.d.ts.map +1 -0
  16. package/dist/cli/commands/init.js +167 -0
  17. package/dist/cli/commands/init.js.map +1 -0
  18. package/dist/cli/commands/ls.d.ts +20 -0
  19. package/dist/cli/commands/ls.d.ts.map +1 -0
  20. package/dist/cli/commands/ls.js +25 -0
  21. package/dist/cli/commands/ls.js.map +1 -0
  22. package/dist/cli/commands/manifest.d.ts +19 -0
  23. package/dist/cli/commands/manifest.d.ts.map +1 -0
  24. package/dist/cli/commands/manifest.js +95 -0
  25. package/dist/cli/commands/manifest.js.map +1 -0
  26. package/dist/cli/commands/remove.d.ts +15 -0
  27. package/dist/cli/commands/remove.d.ts.map +1 -0
  28. package/dist/cli/commands/remove.js +16 -0
  29. package/dist/cli/commands/remove.js.map +1 -0
  30. package/dist/cli/commands/source.d.ts +41 -0
  31. package/dist/cli/commands/source.d.ts.map +1 -0
  32. package/dist/cli/commands/source.js +38 -0
  33. package/dist/cli/commands/source.js.map +1 -0
  34. package/dist/cli/commands/update.d.ts +16 -0
  35. package/dist/cli/commands/update.d.ts.map +1 -0
  36. package/dist/cli/commands/update.js +17 -0
  37. package/dist/cli/commands/update.js.map +1 -0
  38. package/dist/cli/index.d.ts +3 -0
  39. package/dist/cli/index.d.ts.map +1 -0
  40. package/dist/cli/index.js +90 -0
  41. package/dist/cli/index.js.map +1 -0
  42. package/dist/components/basic/Card.css +32 -0
  43. package/dist/components/basic/Card.debug.ts +5 -0
  44. package/dist/components/basic/Card.tsx +31 -0
  45. package/dist/components/basic/CardFooter.css +16 -0
  46. package/dist/components/basic/CardFooter.debug.ts +5 -0
  47. package/dist/components/basic/CardFooter.tsx +29 -0
  48. package/dist/components/basic/CardHeader.css +14 -0
  49. package/dist/components/basic/CardHeader.debug.ts +5 -0
  50. package/dist/components/basic/CardHeader.tsx +29 -0
  51. package/dist/components/basic/card.meta.ts +14 -0
  52. package/dist/components/basic/cardfooter.meta.ts +14 -0
  53. package/dist/components/basic/cardheader.meta.ts +14 -0
  54. package/dist/components/input/Button.css +34 -0
  55. package/dist/components/input/Button.debug.ts +5 -0
  56. package/dist/components/input/Button.tsx +28 -0
  57. package/dist/components/input/button.meta.ts +14 -0
  58. package/dist/components.json +138 -0
  59. package/dist/index.d.ts +2 -0
  60. package/dist/index.d.ts.map +1 -0
  61. package/dist/index.js +3 -0
  62. package/dist/index.js.map +1 -0
  63. package/dist/registry/adapters/shadcn.adapter.d.ts +41 -0
  64. package/dist/registry/adapters/shadcn.adapter.d.ts.map +1 -0
  65. package/dist/registry/adapters/shadcn.adapter.js +123 -0
  66. package/dist/registry/adapters/shadcn.adapter.js.map +1 -0
  67. package/dist/registry/componentsJson.d.ts +24 -0
  68. package/dist/registry/componentsJson.d.ts.map +1 -0
  69. package/dist/registry/componentsJson.js +56 -0
  70. package/dist/registry/componentsJson.js.map +1 -0
  71. package/dist/registry/index.d.ts +6 -0
  72. package/dist/registry/index.d.ts.map +1 -0
  73. package/dist/registry/index.js +6 -0
  74. package/dist/registry/index.js.map +1 -0
  75. package/dist/registry/manifest.d.ts +21 -0
  76. package/dist/registry/manifest.d.ts.map +1 -0
  77. package/dist/registry/manifest.js +88 -0
  78. package/dist/registry/manifest.js.map +1 -0
  79. package/dist/registry/readSource.d.ts +37 -0
  80. package/dist/registry/readSource.d.ts.map +1 -0
  81. package/dist/registry/readSource.js +58 -0
  82. package/dist/registry/readSource.js.map +1 -0
  83. package/dist/registry/types.d.ts +100 -0
  84. package/dist/registry/types.d.ts.map +1 -0
  85. package/dist/registry/types.js +48 -0
  86. package/dist/registry/types.js.map +1 -0
  87. package/dist/sources/builtins.d.ts +8 -0
  88. package/dist/sources/builtins.d.ts.map +1 -0
  89. package/dist/sources/builtins.js +10 -0
  90. package/dist/sources/builtins.js.map +1 -0
  91. package/package.json +84 -3
  92. package/README.md +0 -3
package/LICENSE ADDED
@@ -0,0 +1,95 @@
1
+ Copyright (c) 2026 G3NTs - G3nomaly
2
+
3
+ Elastic License 2.0
4
+
5
+ URL: https://www.elastic.co/licensing/elastic-license
6
+
7
+ ## Acceptance
8
+
9
+ By using the software, you agree to all of the terms and conditions below.
10
+
11
+ ## Copyright License
12
+
13
+ The licensor grants you a non-exclusive, royalty-free, worldwide,
14
+ non-sublicensable, non-transferable license to use, copy, distribute, make
15
+ available, and prepare derivative works of the software, in each case subject to
16
+ the limitations and conditions below.
17
+
18
+ ## Limitations
19
+
20
+ You may not provide the software to third parties as a hosted or managed
21
+ service, where the service provides users with access to any substantial set of
22
+ the features or functionality of the software.
23
+
24
+ You may not move, change, disable, or circumvent the license key functionality
25
+ in the software, and you may not remove or obscure any functionality in the
26
+ software that is protected by the license key.
27
+
28
+ You may not alter, remove, or obscure any licensing, copyright, or other notices
29
+ of the licensor in the software. Any use of the licensor’s trademarks is subject
30
+ to applicable law.
31
+
32
+ ## Patents
33
+
34
+ The licensor grants you a license, under any patent claims the licensor can
35
+ license, or becomes able to license, to make, have made, use, sell, offer for
36
+ sale, import and have imported the software, in each case subject to the
37
+ limitations and conditions in this license. This license does not cover any
38
+ patent claims that you cause to be infringed by modifications or additions to
39
+ the software. If you or your company make any written claim that the software
40
+ infringes or contributes to infringement of any patent, your patent license for
41
+ the software granted under these terms ends immediately. If your company makes
42
+ such a claim, your patent license ends immediately for work on behalf of your
43
+ company.
44
+
45
+ ## Notices
46
+
47
+ You must ensure that anyone who gets a copy of any part of the software from you
48
+ also gets a copy of these terms.
49
+
50
+ If you modify the software, you must include in any modified copies of the
51
+ software prominent notices stating that you have modified the software.
52
+
53
+ ## No Other Rights
54
+
55
+ These terms do not imply any licenses other than those expressly granted in
56
+ these terms.
57
+
58
+ ## Termination
59
+
60
+ If you use the software in violation of these terms, such use is not licensed,
61
+ and your licenses will automatically terminate. If the licensor provides you
62
+ with a notice of your violation, and you cease all violation of this license no
63
+ later than 30 days after you receive that notice, your licenses will be
64
+ reinstated retroactively. However, if you violate these terms after such
65
+ reinstatement, any additional violation of these terms will cause your licenses
66
+ to terminate automatically and permanently.
67
+
68
+ ## No Liability
69
+
70
+ *As far as the law allows, the software comes as is, without any warranty or
71
+ condition, and the licensor will not be liable to you for any damages arising
72
+ out of these terms or the use or nature of the software, under any kind of
73
+ legal claim.*
74
+
75
+ ## Definitions
76
+
77
+ The **licensor** is the entity offering these terms, and the **software** is the
78
+ software the licensor makes available under these terms, including any portion
79
+ of it.
80
+
81
+ **you** refers to the individual or entity agreeing to these terms.
82
+
83
+ **your company** is any legal entity, sole proprietorship, or other kind of
84
+ organization that you work for, plus all organizations that have control over,
85
+ are under the control of, or are under common control with that
86
+ organization. **control** means ownership of substantially all the assets of an
87
+ entity, or the power to direct its management and policies by vote, contract, or
88
+ otherwise. Control can be direct or indirect.
89
+
90
+ **your licenses** are all the licenses granted to you for the software under
91
+ these terms.
92
+
93
+ **use** means anything you do with the software requiring one of your licenses.
94
+
95
+ **trademark** means trademarks, service marks, and similar rights.
@@ -0,0 +1,86 @@
1
+ import { resolveProjectRoot } from "@g3nomaly/core/config";
2
+ import type { G3nConfig } from "@g3nomaly/core/config";
3
+ import type { InstallCommandContext, ManifestTarget, SourceCommandContext } from "@g3nomaly/core/cli";
4
+ import type { SourceRegistry } from "@g3nomaly/core/installer";
5
+ import type { RegisteredSource, SourceRecord } from "@g3nomaly/core/sources";
6
+ import type { ComponentFileFlags } from "../registry/readSource";
7
+ import type { ComponentMeta, ComponentRegistry } from "../registry/types";
8
+ /**
9
+ * @brief Injection points for tests; the real project root comes from git discovery, the components from this package.
10
+ *
11
+ * @property resolveProjectRoot - Replaces git discovery, e.g. `() => "/tmp/project"`.
12
+ * @property builtins - Built-in sources in place of this package's own folder.
13
+ */
14
+ export interface ProjectDeps {
15
+ resolveProjectRoot?: typeof resolveProjectRoot;
16
+ builtins?: SourceRecord;
17
+ }
18
+ /**
19
+ * @brief A project opened for a g3nui command: its root, config, the one install target and the built-in sources.
20
+ *
21
+ * @property projectRoot - Absolute project root.
22
+ * @property config - Loaded g3n config.
23
+ * @property target - The install target of the components, whose manifest records what is installed.
24
+ * @property builtins - Built-in sources.
25
+ */
26
+ export interface UiProject {
27
+ projectRoot: string;
28
+ config: G3nConfig;
29
+ target: ManifestTarget;
30
+ builtins: SourceRecord;
31
+ }
32
+ /** What the core install commands print, check and fetch for components. */
33
+ export declare const UI_CONTEXT: InstallCommandContext<ComponentMeta>;
34
+ /**
35
+ * @brief Anchors the command to the git project, loads its config, migrates a
36
+ * manifest from before the shared shape, and opens the manifest; exits when
37
+ * outside a repo or when the manifest cannot be read.
38
+ *
39
+ * @param deps - Test injection.
40
+ * @returns The opened project.
41
+ */
42
+ export declare function openUiProject(deps?: ProjectDeps): Promise<UiProject>;
43
+ /**
44
+ * @brief Built-in sources plus those registered in the project's manifest.
45
+ *
46
+ * @param project - The opened project.
47
+ * @returns The sources, built-in ones first.
48
+ */
49
+ export declare function uiSources(project: UiProject): RegisteredSource[];
50
+ /**
51
+ * @brief Installed components of the project.
52
+ *
53
+ * @param project - The opened project.
54
+ * @returns The installed components keyed by component key.
55
+ */
56
+ export declare function installedComponents(project: UiProject): ComponentRegistry;
57
+ /**
58
+ * @brief Optional files to install: the command's flags, else the project's settings.
59
+ *
60
+ * @param project - The opened project, whose settings are the fallback.
61
+ * @param options - `debug` and `meta` flags of the command; an absent one falls back to the setting.
62
+ * @returns Which optional file kinds to include.
63
+ */
64
+ export declare function fileFlags(project: UiProject, options?: {
65
+ debug?: boolean;
66
+ meta?: boolean;
67
+ }): ComponentFileFlags;
68
+ /**
69
+ * @brief Reads the components of the project's sources, plus shadcn's when it is in
70
+ * `g3nui.settings.registeredPackages`, and prints what could not be read;
71
+ * the caller disposes the result.
72
+ *
73
+ * @param project - The opened project.
74
+ * @param flags - Which optional file kinds to read.
75
+ * @param only - Source name to read alone; exits when no such source is registered.
76
+ * @returns The components per source; dispose it once read.
77
+ */
78
+ export declare function openComponentRegistry(project: UiProject, flags: ComponentFileFlags, only?: string): Promise<SourceRegistry<ComponentMeta>>;
79
+ /**
80
+ * @brief What the core source commands need to know about components in one project.
81
+ *
82
+ * @param project - The opened project.
83
+ * @returns The component context with the built-in sources and the component reader.
84
+ */
85
+ export declare function uiSourceContext(project: UiProject): SourceCommandContext<ComponentMeta>;
86
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/cli/adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAEtG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAI7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG1E;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,kBAAkB,CAAC,EAAE,OAAO,kBAAkB,CAAC;IAC/C,QAAQ,CAAC,EAAY,YAAY,CAAC;CACnC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAO,SAAS,CAAC;IACvB,MAAM,EAAO,cAAc,CAAC;IAC5B,QAAQ,EAAK,YAAY,CAAC;CAC3B;AAED,4EAA4E;AAC5E,eAAO,MAAM,UAAU,EAAE,qBAAqB,CAAC,aAAa,CAK3D,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAiB9E;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,SAAS,GAAG,gBAAgB,EAAE,CAEhE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,SAAS,GAAG,iBAAiB,CAEzE;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,kBAAkB,CAKnH;AAED;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,kBAAkB,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC,CAkBhJ;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,GAAG,oBAAoB,CAAC,aAAa,CAAC,CAEvF"}
@@ -0,0 +1,114 @@
1
+ // packages/ui/src/cli/adapter.ts
2
+ import path from "node:path";
3
+ import { loadConfig, resolveProjectRoot } from "@g3nomaly/core/config";
4
+ import { c, lineError, lineInfo, narrowSources, orExit, reportSourceRegistry } from "@g3nomaly/core/cli";
5
+ import { entrySource, installedEntries, loadInstallManifest, loadSourceRegistry, manifestSources } from "@g3nomaly/core/installer";
6
+ import { createRegistryStore, register } from "@g3nomaly/core/registry";
7
+ import { readShadcnEntries, shadcnFileSource } from "../registry/adapters/shadcn.adapter";
8
+ import { SHADCN_SOURCE, migrateLegacyManifest, uiManifestPath } from "../registry/manifest";
9
+ import { readComponentSource } from "../registry/readSource";
10
+ import { ComponentMetaSchema } from "../registry/types";
11
+ import { BUILTIN_SOURCES } from "../sources/builtins";
12
+ /** What the core install commands print, check and fetch for components. */
13
+ export const UI_CONTEXT = {
14
+ bin: "g3nui",
15
+ noun: "component",
16
+ entrySchema: ComponentMetaSchema,
17
+ fileSource: (registry) => shadcnFileSource(entrySource(registry)),
18
+ };
19
+ /**
20
+ * @brief Anchors the command to the git project, loads its config, migrates a
21
+ * manifest from before the shared shape, and opens the manifest; exits when
22
+ * outside a repo or when the manifest cannot be read.
23
+ *
24
+ * @param deps - Test injection.
25
+ * @returns The opened project.
26
+ */
27
+ export async function openUiProject(deps = {}) {
28
+ const projectRoot = (deps.resolveProjectRoot ?? resolveProjectRoot)();
29
+ if (projectRoot === null) {
30
+ console.error(lineError("No g3n project found: run `g3nui init` inside a git repository."));
31
+ process.exit(1);
32
+ }
33
+ const config = await loadConfig(projectRoot);
34
+ const migrated = await migrateLegacyManifest(projectRoot);
35
+ if (migrated !== null)
36
+ console.log(lineInfo(`Migrated ${c.file(path.relative(projectRoot, migrated))} to the shared manifest shape`));
37
+ const manifest = orExit(() => loadInstallManifest(uiManifestPath(projectRoot), ComponentMetaSchema));
38
+ return {
39
+ projectRoot,
40
+ config,
41
+ target: { label: "", installDir: path.join(projectRoot, config.g3nui.settings.componentsDir), store: manifest.store, manifest },
42
+ builtins: deps.builtins ?? BUILTIN_SOURCES,
43
+ };
44
+ }
45
+ /**
46
+ * @brief Built-in sources plus those registered in the project's manifest.
47
+ *
48
+ * @param project - The opened project.
49
+ * @returns The sources, built-in ones first.
50
+ */
51
+ export function uiSources(project) {
52
+ return manifestSources([project.target.manifest], project.builtins);
53
+ }
54
+ /**
55
+ * @brief Installed components of the project.
56
+ *
57
+ * @param project - The opened project.
58
+ * @returns The installed components keyed by component key.
59
+ */
60
+ export function installedComponents(project) {
61
+ return installedEntries(project.target.manifest, ComponentMetaSchema);
62
+ }
63
+ /**
64
+ * @brief Optional files to install: the command's flags, else the project's settings.
65
+ *
66
+ * @param project - The opened project, whose settings are the fallback.
67
+ * @param options - `debug` and `meta` flags of the command; an absent one falls back to the setting.
68
+ * @returns Which optional file kinds to include.
69
+ */
70
+ export function fileFlags(project, options = {}) {
71
+ return {
72
+ includeDebug: options.debug ?? project.config.g3nui.settings.includeDebugFiles,
73
+ includeMeta: options.meta ?? project.config.g3nui.settings.includeMetaFiles,
74
+ };
75
+ }
76
+ /**
77
+ * @brief Reads the components of the project's sources, plus shadcn's when it is in
78
+ * `g3nui.settings.registeredPackages`, and prints what could not be read;
79
+ * the caller disposes the result.
80
+ *
81
+ * @param project - The opened project.
82
+ * @param flags - Which optional file kinds to read.
83
+ * @param only - Source name to read alone; exits when no such source is registered.
84
+ * @returns The components per source; dispose it once read.
85
+ */
86
+ export async function openComponentRegistry(project, flags, only) {
87
+ const packages = project.config.g3nui.settings.registeredPackages;
88
+ const shadcnOn = packages.includes(SHADCN_SOURCE);
89
+ const named = narrowSources([...uiSources(project), ...(shadcnOn ? [{ name: SHADCN_SOURCE }] : [])], only, "g3nui").map((s) => s.name);
90
+ const sources = uiSources(project).filter((s) => named.includes(s.name));
91
+ const registry = await loadSourceRegistry(sources, project.projectRoot, readComponentSource(flags));
92
+ if (shadcnOn && named.includes(SHADCN_SOURCE)) {
93
+ const shadcn = await readShadcnEntries();
94
+ const store = createRegistryStore();
95
+ for (const [key, entry] of shadcn.entries)
96
+ register(store, key, entry);
97
+ registry.sources.set(SHADCN_SOURCE, store);
98
+ registry.warnings.push(...shadcn.warnings.map((warning) => `${SHADCN_SOURCE}: ${warning}`));
99
+ }
100
+ for (const name of packages.filter((p) => p !== SHADCN_SOURCE))
101
+ registry.warnings.push(`unknown external package "${name}", skipped`);
102
+ reportSourceRegistry(registry);
103
+ return registry;
104
+ }
105
+ /**
106
+ * @brief What the core source commands need to know about components in one project.
107
+ *
108
+ * @param project - The opened project.
109
+ * @returns The component context with the built-in sources and the component reader.
110
+ */
111
+ export function uiSourceContext(project) {
112
+ return { ...UI_CONTEXT, builtins: project.builtins, readSource: readComponentSource(fileFlags(project)), projectRoot: project.projectRoot };
113
+ }
114
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/cli/adapter.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEvE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAEzG,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEnI,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC5F,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AA4BtD,4EAA4E;AAC5E,MAAM,CAAC,MAAM,UAAU,GAAy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AAU,EAAE,mBAAmB,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;AAC9I,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { InstallOptions } from "@g3nomaly/core/cli";
2
+ import type { ProjectDeps } from "../adapter";
3
+ /**
4
+ * @brief Options of `addCommand`, on top of the core install options.
5
+ *
6
+ * @property debug - Install `.debug.ts` files; the project setting when absent.
7
+ * @property meta - Install `.meta.ts` files; the project setting when absent.
8
+ */
9
+ export interface AddOptions extends InstallOptions {
10
+ debug?: boolean;
11
+ meta?: boolean;
12
+ }
13
+ /**
14
+ * @brief Installs components or whole groups from the registered sources, each with
15
+ * the components it depends on, keeping locally modified files. A name more
16
+ * than one source offers is picked as `<name>@<source>`; with no names the
17
+ * user picks from what the sources offer.
18
+ *
19
+ * @param names - Component keys or groups to install, e.g. `button`; empty to pick from the sources.
20
+ * @param options - Force, debug and meta flags.
21
+ * @param deps - Test injection.
22
+ */
23
+ export declare function addCommand(names: string[], options?: AddOptions, deps?: ProjectDeps): Promise<void>;
24
+ //# sourceMappingURL=add.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/add.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,WAAW,UAAW,SAAQ,cAAc;IAChD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAG,OAAO,CAAC;CACjB;AAED;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,UAAe,EAAE,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAQjH"}
@@ -0,0 +1,24 @@
1
+ // packages/ui/src/cli/commands/add.ts
2
+ import { addFromSources } from "@g3nomaly/core/cli";
3
+ import { UI_CONTEXT, fileFlags, openComponentRegistry, openUiProject } from "../adapter";
4
+ /**
5
+ * @brief Installs components or whole groups from the registered sources, each with
6
+ * the components it depends on, keeping locally modified files. A name more
7
+ * than one source offers is picked as `<name>@<source>`; with no names the
8
+ * user picks from what the sources offer.
9
+ *
10
+ * @param names - Component keys or groups to install, e.g. `button`; empty to pick from the sources.
11
+ * @param options - Force, debug and meta flags.
12
+ * @param deps - Test injection.
13
+ */
14
+ export async function addCommand(names, options = {}, deps = {}) {
15
+ const project = await openUiProject(deps);
16
+ const registry = await openComponentRegistry(project, fileFlags(project, options));
17
+ try {
18
+ await addFromSources([project.target], names, registry, options, UI_CONTEXT);
19
+ }
20
+ finally {
21
+ registry.dispose();
22
+ }
23
+ }
24
+ //# sourceMappingURL=add.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add.js","sourceRoot":"","sources":["../../../src/cli/commands/add.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAczF;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,KAAe,EAAE,OAAO,GAAe,EAAE,EAAE,IAAI,GAAgB,EAAE;IAChG,MAAM,OAAO,GAAI,MAAM,aAAa,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,QAAQ,GAAG,MAAM,qBAAqB,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IACnF,IAAI,CAAC;QACH,MAAM,cAAc,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IAC/E,CAAC;YAAS,CAAC;QACT,QAAQ,CAAC,OAAO,EAAE,CAAC;IACrB,CAAC;AACH,CAAC"}
@@ -0,0 +1,15 @@
1
+ export { initCommand, initDialogue } from "./init";
2
+ export type { InitOptions, UiInitAnswers } from "./init";
3
+ export { addCommand } from "./add";
4
+ export type { AddOptions } from "./add";
5
+ export { removeCommand } from "./remove";
6
+ export type { RemoveOptions } from "./remove";
7
+ export { updateCommand } from "./update";
8
+ export type { UpdateOptions } from "./update";
9
+ export { lsCommand } from "./ls";
10
+ export type { LsOptions } from "./ls";
11
+ export { sourceAddCommand, sourceLsCommand, sourceRemoveCommand } from "./source";
12
+ export type { SourceAddOptions } from "./source";
13
+ export { manifestCommand } from "./manifest";
14
+ export type { ManifestDeps } from "./manifest";
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACnD,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,YAAY,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,YAAY,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAClF,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,9 @@
1
+ // packages/ui/src/cli/commands/index.ts
2
+ export { initCommand, initDialogue } from "./init";
3
+ export { addCommand } from "./add";
4
+ export { removeCommand } from "./remove";
5
+ export { updateCommand } from "./update";
6
+ export { lsCommand } from "./ls";
7
+ export { sourceAddCommand, sourceLsCommand, sourceRemoveCommand } from "./source";
8
+ export { manifestCommand } from "./manifest";
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/commands/index.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAElF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { z } from "zod";
2
+ import type { G3nuiSettings } from "@g3nomaly/core/config";
3
+ import type { Dialogue, DialogueAnswers } from "@g3nomaly/core/cli";
4
+ import type { ProjectDeps } from "../adapter";
5
+ /**
6
+ * @brief Options of `initCommand`; an install dir preset skips the prompts.
7
+ *
8
+ * @property force - Reconfigure without asking when a config already exists.
9
+ * @property installDir - Components install directory; skips the directory prompt when given.
10
+ * @property answers - Preset dialogue answers by step id; skips the terminal prompt.
11
+ */
12
+ export interface InitOptions {
13
+ force?: boolean;
14
+ installDir?: string;
15
+ answers?: DialogueAnswers;
16
+ }
17
+ declare const UiInitAnswersSchema: z.ZodObject<{
18
+ componentsDir: z.ZodString;
19
+ includeDebugFiles: z.ZodBoolean;
20
+ includeMetaFiles: z.ZodBoolean;
21
+ }, z.core.$strip>;
22
+ /**
23
+ * @brief Answers of the init dialogue, parsed into the g3nui settings.
24
+ *
25
+ * @property componentsDir - Install directory, relative to the project root, e.g. `src/components`.
26
+ * @property includeDebugFiles - Whether `.debug.ts` files are installed with components.
27
+ * @property includeMetaFiles - Whether `.meta.ts` files are installed with components.
28
+ */
29
+ export type UiInitAnswers = z.infer<typeof UiInitAnswersSchema>;
30
+ /**
31
+ * @brief Input of the init dialogue: the settings its steps start from.
32
+ *
33
+ * @property settings - Current g3nui settings, the initial value of each step.
34
+ */
35
+ interface UiInitInput extends Record<string, unknown> {
36
+ settings: G3nuiSettings;
37
+ }
38
+ export declare const orphanDialogue: Dialogue;
39
+ export declare const initDialogue: Dialogue<UiInitInput>;
40
+ /**
41
+ * @brief Initializes the g3nui config in this project.
42
+ *
43
+ * @param options - Force flag, install dir and preset answers.
44
+ * @param deps - Test injection.
45
+ */
46
+ export declare function initCommand(options?: InitOptions, deps?: ProjectDeps): Promise<void>;
47
+ export {};
48
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/init.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAI3D,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAO,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B;AAED,QAAA,MAAM,mBAAmB;;;;iBAIvB,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE;;;;GAIG;AACH,UAAU,WAAY,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACnD,QAAQ,EAAE,aAAa,CAAC;CACzB;AAYD,eAAO,MAAM,cAAc,EAAE,QAQ5B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAqB9C,CAAC;AAuCF;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,OAAO,GAAE,WAAgB,EAAE,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyElG"}
@@ -0,0 +1,167 @@
1
+ // packages/ui/src/cli/commands/init.ts
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import chalk from "chalk";
5
+ import * as p from "@clack/prompts";
6
+ import { z } from "zod";
7
+ import { configExists, loadConfig, resolveProjectRoot, saveConfig } from "@g3nomaly/core/config";
8
+ import { entries as storeEntries, unregister } from "@g3nomaly/core/registry";
9
+ import { StepKind, c, orExit, runDialogue, runDialogueValue } from "@g3nomaly/core/cli";
10
+ import { loadInstallManifest, saveInstallManifest } from "@g3nomaly/core/installer";
11
+ import { migrateLegacyManifest, uiManifestPath } from "../../registry/manifest";
12
+ import { ComponentMetaSchema } from "../../registry/types";
13
+ const UiInitAnswersSchema = z.object({
14
+ componentsDir: z.string().min(1),
15
+ includeDebugFiles: z.boolean(),
16
+ includeMetaFiles: z.boolean(),
17
+ });
18
+ const reconfigureDialogue = {
19
+ steps: {
20
+ reconfigure: {
21
+ kind: StepKind.Confirm,
22
+ message: "Config already exists. Reconfigure?",
23
+ initial: false,
24
+ },
25
+ },
26
+ };
27
+ export const orphanDialogue = {
28
+ steps: {
29
+ orphans: {
30
+ kind: StepKind.Confirm,
31
+ message: "Components installed at {dir} will no longer be tracked: {orphans}. Continue and clear the manifest?",
32
+ initial: false,
33
+ },
34
+ },
35
+ };
36
+ export const initDialogue = {
37
+ steps: {
38
+ componentsDir: {
39
+ kind: StepKind.Text,
40
+ message: "Where should components be installed?",
41
+ initial: ({ settings }) => settings.componentsDir,
42
+ validate: (v) => (v?.trim() ? undefined : "Install directory cannot be empty"),
43
+ next: "includeDebugFiles",
44
+ },
45
+ includeDebugFiles: {
46
+ kind: StepKind.Confirm,
47
+ message: "Include .debug.ts files when installing components?",
48
+ initial: ({ settings }) => settings.includeDebugFiles,
49
+ next: "includeMetaFiles",
50
+ },
51
+ includeMetaFiles: {
52
+ kind: StepKind.Confirm,
53
+ message: "Include .meta.ts files when installing components?",
54
+ initial: ({ settings }) => settings.includeMetaFiles,
55
+ },
56
+ },
57
+ };
58
+ /**
59
+ * @brief `true` in green or `false` dimmed, for the settings summary.
60
+ *
61
+ * @param v - The flag to label.
62
+ * @returns The colored label.
63
+ */
64
+ function boolLabel(v) {
65
+ return v ? chalk.green("true") : chalk.dim("false");
66
+ }
67
+ /**
68
+ * @brief One printed line per g3nui setting.
69
+ *
70
+ * @param answers - The settings to print.
71
+ */
72
+ function settingsLines(answers) {
73
+ return [
74
+ ` componentsDir: ${c.dir(answers.componentsDir)}`,
75
+ ` includeDebugFiles: ${boolLabel(answers.includeDebugFiles)}`,
76
+ ` includeMetaFiles: ${boolLabel(answers.includeMetaFiles)}`,
77
+ ];
78
+ }
79
+ /**
80
+ * @brief The init answers that keep the current settings.
81
+ *
82
+ * @param settings - The current g3nui settings.
83
+ * @returns Answers equal to the current settings.
84
+ */
85
+ function currentAnswers(settings) {
86
+ return {
87
+ componentsDir: settings.componentsDir,
88
+ includeDebugFiles: settings.includeDebugFiles,
89
+ includeMetaFiles: settings.includeMetaFiles,
90
+ };
91
+ }
92
+ /**
93
+ * @brief Initializes the g3nui config in this project.
94
+ *
95
+ * @param options - Force flag, install dir and preset answers.
96
+ * @param deps - Test injection.
97
+ */
98
+ export async function initCommand(options = {}, deps = {}) {
99
+ p.intro(chalk.bold.cyan("g3nui init"));
100
+ const projectRoot = (deps.resolveProjectRoot ?? resolveProjectRoot)();
101
+ if (projectRoot === null) {
102
+ console.error(chalk.red("Not inside a git repository — g3n projects are anchored to a repo. Run `git init` first."));
103
+ process.exitCode = 1;
104
+ return;
105
+ }
106
+ const exists = await configExists(projectRoot);
107
+ const config = await loadConfig(projectRoot);
108
+ const preset = options.installDir === undefined
109
+ ? null
110
+ : { ...currentAnswers(config.g3nui.settings), componentsDir: options.installDir };
111
+ if (exists && !options.force && preset === null) {
112
+ console.log(chalk.bold("Current config:"));
113
+ for (const line of settingsLines(currentAnswers(config.g3nui.settings)))
114
+ console.log(line);
115
+ console.log();
116
+ const reconfigure = await runDialogueValue(reconfigureDialogue, {}, options.answers);
117
+ if (reconfigure !== true) {
118
+ p.outro(chalk.dim("No changes made."));
119
+ return;
120
+ }
121
+ }
122
+ let answers;
123
+ if (preset !== null) {
124
+ answers = preset;
125
+ }
126
+ else {
127
+ const record = await runDialogue(initDialogue, { settings: config.g3nui.settings }, options.answers);
128
+ if (typeof record === "symbol") {
129
+ p.outro(chalk.dim("Init cancelled."));
130
+ return;
131
+ }
132
+ answers = UiInitAnswersSchema.parse(record);
133
+ }
134
+ // A changed install dir orphans everything the old manifest tracks —
135
+ // confirm, then clear the manifest so stale entries cannot resurrect.
136
+ const oldSettings = config.g3nui.settings;
137
+ if (exists && oldSettings.componentsDir !== answers.componentsDir) {
138
+ await migrateLegacyManifest(projectRoot);
139
+ const manifest = orExit(() => loadInstallManifest(uiManifestPath(projectRoot), ComponentMetaSchema));
140
+ const orphaned = Object.keys(storeEntries(manifest.store)).sort();
141
+ if (orphaned.length > 0) {
142
+ const proceed = await runDialogueValue(orphanDialogue, {
143
+ dir: c.dir(oldSettings.componentsDir),
144
+ orphans: orphaned.map((k) => c.key(k)).join(", "),
145
+ }, options.answers);
146
+ if (proceed !== true) {
147
+ p.outro(chalk.dim("No changes made."));
148
+ return;
149
+ }
150
+ for (const key of orphaned)
151
+ unregister(manifest.store, key);
152
+ saveInstallManifest(manifest, ComponentMetaSchema);
153
+ }
154
+ }
155
+ await saveConfig(projectRoot, {
156
+ g3nui: {
157
+ settings: {
158
+ componentsDir: answers.componentsDir,
159
+ includeDebugFiles: answers.includeDebugFiles,
160
+ includeMetaFiles: answers.includeMetaFiles,
161
+ },
162
+ },
163
+ });
164
+ fs.mkdirSync(path.join(projectRoot, ".g3n"), { recursive: true });
165
+ p.outro([`Config written to ${c.file(".g3n.config.json")}`, ...settingsLines(answers)].join("\n"));
166
+ }
167
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/cli/commands/init.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEjG,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpF,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAgB3D,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,aAAa,EAA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5D,mBAAmB,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IAED,MAAM,UAAU,CAAC,WAAW,EAAE;QAC5B,KAAK,EAAE;YACL,QAAQ,EAAE;gBACR,aAAa,EAAM,OAAO,CAAC,aAAa;gBACxC,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;gBAC5C,gBAAgB,EAAG,OAAO,CAAC,gBAAgB;aAC5C;SACF;KACF,CAAC,CAAC;IACH,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAElE,CAAC,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACrG,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { LSOptions } from "@g3nomaly/core/cli";
2
+ import type { ProjectDeps } from "../adapter";
3
+ /**
4
+ * @brief Options of `lsCommand`, on top of the core list options.
5
+ *
6
+ * @property installed - List what the manifest records instead of what the sources offer.
7
+ * @property source - Only the components of this source, e.g. `g3nui`.
8
+ */
9
+ export interface LsOptions extends LSOptions {
10
+ installed?: boolean;
11
+ source?: string;
12
+ }
13
+ /**
14
+ * @brief Lists the components the sources offer, `●` marking installed ones, or with `installed` only what is installed.
15
+ *
16
+ * @param options - Output and filter options.
17
+ * @param deps - Test injection.
18
+ */
19
+ export declare function lsCommand(options?: LsOptions, deps?: ProjectDeps): Promise<void>;
20
+ //# sourceMappingURL=ls.d.ts.map