Package Tansy UI as @openkhalix/tansy-ui in a monorepo (v0.4.0)
Restructure the repo into npm workspaces so the component kit publishes as its own package, like MUI and shadcn/ui: - packages/ui: @openkhalix/tansy-ui (published), with components, stories, tests, tokens and the library build - packages/brand: private logo and catalogue data shared by both apps - apps/site: the landing page - apps/docs: Storybook The package: - MIT licence (copyright OpenKhalix) - per-component ES modules and type declarations - "use client" on component modules so they import into Next.js Server Components; helpers stay server-safe - tokens.css for Tailwind v4 apps, and a prebuilt styles.css for apps without Tailwind - lucide-react 1.x, whose types compile against current React 19 types The apps resolve the package through a "source" export condition, so they hot-reload component edits, while outside users get dist/. scripts/test-package.mjs packs the package and installs the tarball into Vite + Tailwind (strict types), plain React and Next.js apps; each must build and render correctly. Gitea workflows run CI on push and publish to npm when a vX.Y.Z tag matching the package version is pushed.
This commit is contained in:
1 parent
23e67006d3
commit
9255b255a6
214 files changed
+1521
-389
No files matched your search
@@ -3,12 +3,12 @@
|
||||
Generate the landing page's component catalogue from the built Storybook
|
||||
index, so it cannot drift from the stories again.
|
||||
|
||||
Run it after `npm run build-storybook` and before `npm run build` when you
|
||||
Run it after `npm run build:docs` and before `npm run build:site` when you
|
||||
add or remove a component. It prints the entries to paste into
|
||||
src/data/catalogue.ts and writes /tmp/component_catalogue.json.
|
||||
packages/brand/src/catalogue.ts and writes /tmp/component_catalogue.json.
|
||||
|
||||
python3 scripts/gen_catalogue.py # print entries
|
||||
python3 scripts/gen_catalogue.py --patch # also rewrite src/data/catalogue.ts
|
||||
python3 scripts/gen_catalogue.py --patch # also rewrite packages/brand/src/catalogue.ts
|
||||
|
||||
Components are read from story titles (`Group/Name`), so a new component
|
||||
appears here without editing this script; only DETAIL is hand-written.
|
||||
@@ -22,8 +22,8 @@ import sys
|
||||
from pathlib import Path
|
||||
|
||||
REPO = Path(__file__).resolve().parent.parent
|
||||
IDX = REPO / "storybook-static" / "index.json"
|
||||
CATALOGUE = REPO / "src" / "data" / "catalogue.ts"
|
||||
IDX = REPO / "apps" / "docs" / "storybook-static" / "index.json"
|
||||
CATALOGUE = REPO / "packages" / "brand" / "src" / "catalogue.ts"
|
||||
OUT = Path("/tmp/component_catalogue.json")
|
||||
|
||||
# Group order on the landing page; matches the Storybook sidebar.
|
||||
@@ -75,7 +75,7 @@ DETAIL = {
|
||||
|
||||
def collect():
|
||||
if not IDX.is_file():
|
||||
sys.exit(f"{IDX} not found - run: npm run build-storybook")
|
||||
sys.exit(f"{IDX} not found - run: npm run build:docs")
|
||||
|
||||
entries = json.loads(IDX.read_text())["entries"].values()
|
||||
comps: dict[str, dict] = {}
|
||||
@@ -150,7 +150,7 @@ def patch_catalogue(entries) -> None:
|
||||
def main() -> None:
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--patch", action="store_true",
|
||||
help="rewrite the catalogue and story counts in src/data/catalogue.ts")
|
||||
help="rewrite the catalogue and story counts in packages/brand/src/catalogue.ts")
|
||||
args = ap.parse_args()
|
||||
|
||||
entries = collect()
|
||||
@@ -167,7 +167,7 @@ def main() -> None:
|
||||
|
||||
if args.patch:
|
||||
patch_catalogue(entries)
|
||||
print("now run: npm run build")
|
||||
print("now run: npm run build:site")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user