torch-glare 2.5.0 → 2.5.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/apps/lib/registry.json +58 -1
- package/dist/bin/index.js +8 -4
- package/dist/bin/index.js.map +1 -1
- package/dist/src/commands/add.d.ts +3 -2
- package/dist/src/commands/add.d.ts.map +1 -1
- package/dist/src/commands/add.js +27 -35
- package/dist/src/commands/add.js.map +1 -1
- package/dist/src/commands/hook.d.ts.map +1 -1
- package/dist/src/commands/hook.js +23 -13
- package/dist/src/commands/hook.js.map +1 -1
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +6 -2
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/layout.d.ts.map +1 -1
- package/dist/src/commands/layout.js +23 -13
- package/dist/src/commands/layout.js.map +1 -1
- package/dist/src/commands/provider.d.ts.map +1 -1
- package/dist/src/commands/provider.js +22 -12
- package/dist/src/commands/provider.js.map +1 -1
- package/dist/src/commands/utils.d.ts.map +1 -1
- package/dist/src/commands/utils.js +21 -28
- package/dist/src/commands/utils.js.map +1 -1
- package/dist/src/shared/copyComponentsRecursively.d.ts +5 -3
- package/dist/src/shared/copyComponentsRecursively.d.ts.map +1 -1
- package/dist/src/shared/copyComponentsRecursively.js +5 -6
- package/dist/src/shared/copyComponentsRecursively.js.map +1 -1
- package/dist/src/shared/getDependenciesAndInstallNestedComponents.js +1 -1
- package/dist/src/shared/getDependenciesAndInstallNestedComponents.js.map +1 -1
- package/dist/src/shared/installDependencies.d.ts +16 -1
- package/dist/src/shared/installDependencies.d.ts.map +1 -1
- package/dist/src/shared/installDependencies.js +41 -21
- package/dist/src/shared/installDependencies.js.map +1 -1
- package/dist/src/shared/installFromPlan.d.ts +23 -0
- package/dist/src/shared/installFromPlan.d.ts.map +1 -0
- package/dist/src/shared/installFromPlan.js +77 -0
- package/dist/src/shared/installFromPlan.js.map +1 -0
- package/dist/src/shared/resolveEntry.d.ts +21 -0
- package/dist/src/shared/resolveEntry.d.ts.map +1 -0
- package/dist/src/shared/resolveEntry.js +54 -0
- package/dist/src/shared/resolveEntry.js.map +1 -0
- package/dist/src/shared/suggestOtherCommand.d.ts +8 -0
- package/dist/src/shared/suggestOtherCommand.d.ts.map +1 -0
- package/dist/src/shared/suggestOtherCommand.js +34 -0
- package/dist/src/shared/suggestOtherCommand.js.map +1 -0
- package/dist/src/shared/tailwindInit.d.ts +3 -1
- package/dist/src/shared/tailwindInit.d.ts.map +1 -1
- package/dist/src/shared/tailwindInit.js +3 -1
- package/dist/src/shared/tailwindInit.js.map +1 -1
- package/dist/src/shared/wireStylesheet.d.ts +32 -0
- package/dist/src/shared/wireStylesheet.d.ts.map +1 -0
- package/dist/src/shared/wireStylesheet.js +92 -0
- package/dist/src/shared/wireStylesheet.js.map +1 -0
- package/dist/src/types/main.d.ts +6 -0
- package/dist/src/types/main.d.ts.map +1 -1
- package/docs/reference/cli.md +28 -3
- package/docs/tutorials/getting-started.md +7 -0
- package/package.json +1 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
/**
|
|
4
|
+
* Where an entry stylesheet lives, in the order projects usually put it.
|
|
5
|
+
* Next.js app router first, then pages/Vite, then a `styles/` convention.
|
|
6
|
+
*/
|
|
7
|
+
const CANDIDATES = [
|
|
8
|
+
"app/globals.css",
|
|
9
|
+
"src/app/globals.css",
|
|
10
|
+
"src/index.css",
|
|
11
|
+
"styles/globals.css",
|
|
12
|
+
"src/styles/globals.css",
|
|
13
|
+
"app/global.css",
|
|
14
|
+
"src/styles/index.css",
|
|
15
|
+
];
|
|
16
|
+
/** The marker that tells us the block is already there. */
|
|
17
|
+
const MARKER = "glare-torch-mode";
|
|
18
|
+
/**
|
|
19
|
+
* Tailwind v4 registers the design system through the CSS file itself.
|
|
20
|
+
*
|
|
21
|
+
* The order matters and is not cosmetic: CSS requires every `@import` to precede other at-rules, so
|
|
22
|
+
* an `@import "tailwindcss"` placed *after* the `@plugin` lines is silently dropped by the bundler.
|
|
23
|
+
* That takes every `--color-*` registration with it and leaves every `bg-background-presentation-*`
|
|
24
|
+
* utility rendering as nothing — with no build error to explain it.
|
|
25
|
+
*/
|
|
26
|
+
const V4_BLOCK = `@import "tailwindcss";
|
|
27
|
+
@import "mapping-color-system-v4/tailwindVars.css";
|
|
28
|
+
@plugin "glare-torch-mode";
|
|
29
|
+
@plugin "tailwind-scrollbar-hide";
|
|
30
|
+
@plugin "tailwindcss-animate";
|
|
31
|
+
@plugin "glare-typography";
|
|
32
|
+
@plugin "mapping-color-system-v4";
|
|
33
|
+
`;
|
|
34
|
+
/** For v3 the plugins belong in `tailwind.config.*`, which is user-owned JS we do not rewrite. */
|
|
35
|
+
const V3_SNIPPET = `plugins: [
|
|
36
|
+
require("glare-torch-mode"),
|
|
37
|
+
require("tailwind-scrollbar-hide"),
|
|
38
|
+
require("tailwindcss-animate"),
|
|
39
|
+
require("glare-typography"),
|
|
40
|
+
require("mapping-color-system"),
|
|
41
|
+
require("@tailwindcss/container-queries"),
|
|
42
|
+
]`;
|
|
43
|
+
export function findStylesheet(cwd = process.cwd()) {
|
|
44
|
+
for (const candidate of CANDIDATES) {
|
|
45
|
+
const full = path.join(cwd, candidate);
|
|
46
|
+
if (fs.existsSync(full))
|
|
47
|
+
return full;
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Put the design system into the project's stylesheet.
|
|
53
|
+
*
|
|
54
|
+
* `init` used to install the five Tailwind packages and stop, leaving the wiring as a manual step
|
|
55
|
+
* buried in the docs — so a project would build cleanly and render every component unstyled. This
|
|
56
|
+
* closes that gap, and is a no-op when the block is already present, so re-running `init` is safe.
|
|
57
|
+
*
|
|
58
|
+
* @returns what happened, so the caller can report it truthfully.
|
|
59
|
+
*/
|
|
60
|
+
export function wireStylesheet(isV3, cwd = process.cwd()) {
|
|
61
|
+
// v3's plugins go in tailwind.config.*, whose shape is arbitrary user JS. A wrong edit there is
|
|
62
|
+
// worse than a printed instruction, so print and let the developer place it.
|
|
63
|
+
if (isV3) {
|
|
64
|
+
console.log("ℹ️ Tailwind v3 detected. Add these plugins to your `tailwind.config.*`:\n");
|
|
65
|
+
console.log(V3_SNIPPET + "\n");
|
|
66
|
+
return { status: "manual" };
|
|
67
|
+
}
|
|
68
|
+
const file = findStylesheet(cwd);
|
|
69
|
+
if (!file) {
|
|
70
|
+
console.log("⚠️ No entry stylesheet found (looked for " +
|
|
71
|
+
CANDIDATES.slice(0, 4).join(", ") +
|
|
72
|
+
").\n Add this to yours, keeping `@import \"tailwindcss\"` first:\n");
|
|
73
|
+
console.log(V4_BLOCK);
|
|
74
|
+
return { status: "not-found" };
|
|
75
|
+
}
|
|
76
|
+
const current = fs.readFileSync(file, "utf-8");
|
|
77
|
+
if (current.includes(MARKER)) {
|
|
78
|
+
console.log(`✅ ${path.relative(cwd, file)} is already wired — left alone.`);
|
|
79
|
+
return { status: "already", file };
|
|
80
|
+
}
|
|
81
|
+
// Replace the project's own `@import "tailwindcss"` rather than adding a second one; if there
|
|
82
|
+
// is none, the block goes at the very top, which is where the import has to be anyway.
|
|
83
|
+
const existing = /^[ \t]*@import\s+["']tailwindcss["'];?[ \t]*\r?\n/m;
|
|
84
|
+
const next = existing.test(current)
|
|
85
|
+
? current.replace(existing, V4_BLOCK)
|
|
86
|
+
: V4_BLOCK + "\n" + current;
|
|
87
|
+
fs.writeFileSync(file, next);
|
|
88
|
+
console.log(`✅ Wired ${path.relative(cwd, file)} with the TORCH Glare design system.`);
|
|
89
|
+
return { status: "written", file };
|
|
90
|
+
}
|
|
91
|
+
export { V4_BLOCK, MARKER, CANDIDATES };
|
|
92
|
+
//# sourceMappingURL=wireStylesheet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wireStylesheet.js","sourceRoot":"","sources":["../../../cli/src/shared/wireStylesheet.ts"],"names":[],"mappings":"AAA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jC,sEAAsE,CAC7E,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACtB,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IACnC,CAAC;IAED,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/C,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,iCAAiC,CAAC,CAAC;QAC5E,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACvC,CAAC;IAED,8FAA8F;IAC9F,uFAAuF;IACvF,MAAM,QAAQ,GAAG,oDAAoD,CAAC;IACtE,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;QAC/B,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC;QACrC,CAAC,CAAC,QAAQ,GAAG,IAAI,GAAG,OAAO,CAAC;IAEhC,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,sCAAsC,CAAC,CAAC;IACvF,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACvC,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC"}
|
package/dist/src/types/main.d.ts
CHANGED
|
@@ -20,6 +20,12 @@ export interface RegistryItem {
|
|
|
20
20
|
export interface Registry {
|
|
21
21
|
version: string;
|
|
22
22
|
generatedBy: string;
|
|
23
|
+
/**
|
|
24
|
+
* The version range the library builds each package against, e.g.
|
|
25
|
+
* `{"@tanstack/react-table": "^8.21.3"}`. Installing unpinned means an upstream major can
|
|
26
|
+
* break copied source the day it lands.
|
|
27
|
+
*/
|
|
28
|
+
npmVersions?: Record<string, string>;
|
|
23
29
|
items: RegistryItem[];
|
|
24
30
|
}
|
|
25
31
|
/** Fully resolved set of work needed to install one item. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../cli/src/types/main.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACnB,IAAI,EAAE,MAAM,CAAC;CAEhB;AAED,MAAM,WAAW,gBAAgB;IAC7B,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvB,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChD;AAED,gDAAgD;AAChD,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,IAAI,EAAE,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,WAAW,CAAC;IACjE,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,+DAA+D;IAC/D,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,QAAQ;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,YAAY,EAAE,CAAC;CACzB;AAED,6DAA6D;AAC7D,MAAM,WAAW,WAAW;IACxB,wEAAwE;IACxE,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,8CAA8C;IAC9C,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAChC"}
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../cli/src/types/main.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACnB,IAAI,EAAE,MAAM,CAAC;CAEhB;AAED,MAAM,WAAW,gBAAgB;IAC7B,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvB,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChD;AAED,gDAAgD;AAChD,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,IAAI,EAAE,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,WAAW,CAAC;IACjE,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,+DAA+D;IAC/D,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,QAAQ;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,KAAK,EAAE,YAAY,EAAE,CAAC;CACzB;AAED,6DAA6D;AAC7D,MAAM,WAAW,WAAW;IACxB,wEAAwE;IACxE,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,8CAA8C;IAC9C,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAChC"}
|
package/docs/reference/cli.md
CHANGED
|
@@ -23,7 +23,7 @@ Run a command **without** a name to pick from an interactive list.
|
|
|
23
23
|
|
|
24
24
|
| Command | Description |
|
|
25
25
|
| --- | --- |
|
|
26
|
-
| `init` | Create `glare.json
|
|
26
|
+
| `init` | Create `glare.json`, install the Tailwind packages, **and wire your stylesheet**. Run once per project. |
|
|
27
27
|
| `add [Component]` | Copy a component **and its dependencies** into your project. |
|
|
28
28
|
| `hook [hook]` | Copy a hook (usually pulled in automatically as a dependency). |
|
|
29
29
|
| `util [util]` | Copy a utility (e.g. `cn`, usually pulled in automatically). |
|
|
@@ -32,6 +32,8 @@ Run a command **without** a name to pick from an interactive list.
|
|
|
32
32
|
| `update` | Re-sync everything already installed with the latest templates. |
|
|
33
33
|
|
|
34
34
|
Component names are **case-sensitive PascalCase** — `add DatePicker`, not `add datepicker`.
|
|
35
|
+
Every command takes a **bare name** — `hook useDragDrop`, not `hook useDragDrop.tsx` — and every one
|
|
36
|
+
accepts `-f, --force`.
|
|
35
37
|
|
|
36
38
|
## `init`
|
|
37
39
|
|
|
@@ -39,7 +41,23 @@ Component names are **case-sensitive PascalCase** — `add DatePicker`, not `add
|
|
|
39
41
|
npx torch-glare@latest init
|
|
40
42
|
```
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
Three things, in order:
|
|
45
|
+
|
|
46
|
+
1. Creates `glare.json`.
|
|
47
|
+
2. Installs the Tailwind packages the design system needs, using your detected package manager.
|
|
48
|
+
3. **Wires your entry stylesheet** — `app/globals.css`, `src/app/globals.css`, `src/index.css`,
|
|
49
|
+
`styles/globals.css` — with the `@import`/`@plugin` block. Re-running is safe: if the block is
|
|
50
|
+
already there it says so and changes nothing.
|
|
51
|
+
|
|
52
|
+
On Tailwind v3 the plugins belong in `tailwind.config.*` instead. `init` prints the snippet rather
|
|
53
|
+
than editing that file, since its shape is yours.
|
|
54
|
+
|
|
55
|
+
> Without step 3 the project builds cleanly and renders every component **unstyled** — the design
|
|
56
|
+
> tokens simply resolve to nothing. If that happens, check that `@import "tailwindcss"` is the
|
|
57
|
+
> first line: CSS requires imports to precede other at-rules, so an import placed after a `@plugin`
|
|
58
|
+
> is silently dropped.
|
|
59
|
+
|
|
60
|
+
`glare.json` controls where files are copied:
|
|
43
61
|
|
|
44
62
|
```json
|
|
45
63
|
{
|
|
@@ -68,7 +86,14 @@ export function Example() {
|
|
|
68
86
|
}
|
|
69
87
|
```
|
|
70
88
|
|
|
71
|
-
|
|
89
|
+
It ends with a summary — `✅ DataViews → ./: 56 installed (56 items).` — so a partial install is
|
|
90
|
+
visible rather than something you discover at build time.
|
|
91
|
+
|
|
92
|
+
Dependencies come from the generated `registry.json`, resolved in one pass, so each item is copied
|
|
93
|
+
exactly once however many things import it.
|
|
94
|
+
|
|
95
|
+
Existing files are never overwritten. Use `--force` to re-copy — it applies to **the whole
|
|
96
|
+
dependency closure**, not just the component you named — or `update` to re-sync everything.
|
|
72
97
|
|
|
73
98
|
## `update`
|
|
74
99
|
|
|
@@ -32,6 +32,13 @@ Before you begin, make sure you have:
|
|
|
32
32
|
|
|
33
33
|
---
|
|
34
34
|
|
|
35
|
+
> **If you plan to build forms**, add the validation packages the guides use — no component
|
|
36
|
+
> imports them, so the CLI does not install them for you:
|
|
37
|
+
>
|
|
38
|
+
> ```bash
|
|
39
|
+
> npm install zod @hookform/resolvers
|
|
40
|
+
> ```
|
|
41
|
+
|
|
35
42
|
## Step 1: Initialize TORCH Glare
|
|
36
43
|
|
|
37
44
|
Run the following command to initialize your project:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "torch-glare",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A copy-in React component library (TypeScript + Radix UI + Tailwind CSS). Its CLI copies component source directly into your project — you own the code.",
|