Make package

This commit is contained in:
2026-03-09 16:59:43 +01:00
parent 19bb022290
commit 5733a35459
7 changed files with 578 additions and 273 deletions

View File

@@ -1,11 +0,0 @@
#!/bin/sh
# Husky pre-commit hook: run lint-staged
# Generated by automation
npx --no-install lint-staged
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npm test
npx lint-staged
npx lint-staged

154
README.md
View File

@@ -1,73 +1,99 @@
# React + TypeScript + Vite
# CyberDuck
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
CyberDuck is a small React component library and theme (Cyberpunk yellow) built on Bootstrap and MUI styles.
Currently, two official plugins are available:
## Installation
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
If you are developing locally you can install from the repository directory:
## React Compiler
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
## Expanding the ESLint configuration
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
```js
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Remove tseslint.configs.recommended and replace with this
tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
tseslint.configs.stylisticTypeChecked,
// Other configs...
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```bash
npm pack
npm install /path/to/cyberduck-0.0.0.tgz
```
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
Install directly from the repository
```js
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'
If you don't want to publish to the npm registry you can install the package directly from the Git repository:
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```bash
npm install git+https://git.maze.io/maze/cyberduck.git
# or a specific branch or tag
npm install git+https://git.maze.io/maze/cyberduck.git#main
```
Note: when installing from a git repository, npm will clone the source. For consumers to get built artifacts (the `dist` bundle and compiled types) the repository must either include the `dist` output or provide a `prepare`/build step that runs on install. If you prefer not to publish, using `npm pack` from the repo owner (tarball) ensures the built `dist` is included.
## Including styles
CyberDuck emits a single bundled stylesheet. Preferred import options:
- Import the packaged CSS via the package export (recommended):
```ts
import 'cyberduck/css'
```
- Import the compiled CSS file directly (older setups):
```ts
import 'cyberduck/dist/cyberduck.css'
```
- If you want to include and compile the SCSS source in your app (allows customization), import the SCSS entry:
```scss
@use 'cyberduck/styles/cyberduck.scss' as *;
```
Or in a JS/TS entry that supports Sass imports:
```ts
import 'cyberduck/styles/cyberduck.scss'
```
## Using the `Layout` component
CyberDuck exports a small set of layout components. Example usage of the `Layout` component together with `Navbar` and `Footer`:
```tsx
import React from 'react'
import { Layout, Navbar, Footer } from 'cyberduck'
import 'cyberduck/css'
function App() {
return (
<Layout>
<Navbar />
<main className="container py-4">
<h1>Hello from CyberDuck</h1>
<p>Use the provided layout primitives and styles as building blocks.</p>
</main>
<Footer />
</Layout>
)
}
export default App
```
You can also import specific components via subpath imports if you prefer:
```ts
import { Navbar } from 'cyberduck'
// or
import { Navbar } from 'cyberduck/Navbar'
```
## Peer dependencies
- `react` and `react-dom` (install in your project)
- `bootstrap` (CSS utilities used by components)
- `react-router` / `react-router-dom` (if you use routing components)
## Publishing
The package repository is: `git+https://git.maze.io/maze/cyberduck.git`. The package exposes `main`, `module`, and TypeScript `types` fields and emits declaration files in `dist/types`.
## Contributing
See the repository for contributing guidelines and style rules.

529
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,53 +1,113 @@
{
"name": "cyberduck",
"private": true,
"private": false,
"version": "0.0.0",
"repository": {
"type": "git",
"url": "git+https://git.maze.io/maze/cyberduck.git"
},
"bugs": {
"url": "https://git.maze.io/maze/cyberduck/-/issues"
},
"homepage": "https://git.maze.io/maze/cyberduck#readme",
"type": "module",
"main": "dist/cyberduck.cjs.js",
"module": "dist/cyberduck.es.js",
"types": "dist/types/index.d.ts",
"style": "dist/cyberduck.css",
"sideEffects": [
"dist/cyberduck.css",
"src/styles/**"
],
"files": [
"dist",
"src/styles"
],
"exports": {
".": {
"import": "./dist/cyberduck.es.js",
"require": "./dist/cyberduck.cjs.js",
"default": "./dist/cyberduck.es.js",
"types": "./dist/types/index.d.ts"
},
"./package.json": "./package.json",
"./styles": "./src/styles/cyberduck.scss",
"./styles/*": "./src/styles/*",
"./css": "./dist/cyberduck.css",
"./Navbar": {
"import": "./dist/cyberduck.es.js",
"require": "./dist/cyberduck.cjs.js",
"types": "./dist/types/index.d.ts"
},
"./Footer": {
"import": "./dist/cyberduck.es.js",
"require": "./dist/cyberduck.cjs.js",
"types": "./dist/types/index.d.ts"
},
"./Layout": {
"import": "./dist/cyberduck.es.js",
"require": "./dist/cyberduck.cjs.js",
"types": "./dist/types/index.d.ts"
},
"./Split": {
"import": "./dist/cyberduck.es.js",
"require": "./dist/cyberduck.cjs.js",
"types": "./dist/types/index.d.ts"
}
},
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"build": "tsc -p tsconfig.build.json && vite build",
"lint": "eslint .",
"lint:css": "stylelint \"src/**/*.{scss,css,sass}\"",
"format:css": "prettier --write \"src/**/*.{scss,css,sass}\"",
"prepare": "husky install",
"styles:build": "sass --no-source-map --style=compressed --load-path=node_modules src:dist",
"styles:check": "sass --no-source-map --update --load-path=node_modules src:dist",
"styles:dev": "sass --watch --no-source-map --load-path=node_modules src:dist",
"preview": "vite preview"
},
"dependencies": {
"@emotion/react": "^11.12.0",
"@emotion/styled": "^11.12.0",
"@mui/icons-material": "^5.14.11",
"@mui/material": "^5.14.11",
"bootstrap": "^5.3.8",
"react": "^19.2.0",
"react-bootstrap": "^2.10.10",
"react-dom": "^19.2.0",
"react-router": "^7.13.1",
"react-router-dom": "^7.13.1"
"peerDependencies": {
"@emotion/react": "^11.0.0",
"@emotion/styled": "^11.0.0",
"@mui/icons-material": "^5.0.0",
"@mui/material": "^5.0.0",
"bootstrap": "^5.0.0",
"react": "^19.0.0",
"react-bootstrap": "^2.0.0",
"react-dom": "^19.0.0 || ^18.0.0",
"react-router": "^7.0.0",
"react-router-dom": "^7.0.0"
},
"devDependencies": {
"@emotion/react": "^11.14.0",
"@emotion/styled": "^11.14.1",
"@eslint/js": "^9.39.1",
"@types/node": "^24.10.1",
"@types/react": "^19.2.7",
"@mui/icons-material": "^7.3.9",
"@mui/material": "^7.3.9",
"@types/node": "^25.3.5",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^5.1.1",
"@vitejs/plugin-react": "^5.1.4",
"bootstrap": "^5.3.8",
"eslint": "^9.39.1",
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-react-refresh": "^0.4.24",
"globals": "^16.5.0",
"husky": "^8.0.0",
"eslint-plugin-react-refresh": "^0.5.2",
"globals": "^17.4.0",
"lint-staged": "^16.3.2",
"postcss-scss": "^4.0.9",
"prettier": "^3.8.1",
"sass": "^1.73.0",
"react": "^19.2.4",
"react-bootstrap": "^2.10.10",
"react-dom": "^19.2.4",
"react-router": "^7.13.1",
"react-router-dom": "^7.13.1",
"sass": "^1.97.3",
"stylelint": "^17.4.0",
"stylelint-config-standard-scss": "^17.0.0",
"stylelint-order": "^7.0.1",
"stylelint-scss": "^7.0.0",
"typescript": "~5.9.3",
"typescript-eslint": "^8.48.0",
"typescript-eslint": "^8.56.1",
"vite": "^7.3.1"
},
"lint-staged": {

8
src/index.ts Normal file
View File

@@ -0,0 +1,8 @@
// Library entry: re-export key components and include styles
export { default as Navbar } from './components/Layout/Navbar'
export { default as Footer } from './components/Layout/Footer'
export { default as Layout } from './components/Layout/Layout'
export { default as Split } from './components/Layout/Split'
// Export styles so consumers can import the theme
import './index.scss'

10
tsconfig.build.json Normal file
View File

@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.app.json",
"compilerOptions": {
"noEmit": false,
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "dist/types"
},
"include": ["src"]
}

View File

@@ -1,7 +1,38 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
// https://vite.dev/config/
export default defineConfig({
export default defineConfig(({ command }) => ({
plugins: [react()],
})
build: {
// library mode configuration
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: 'CyberDuck',
formats: ['es', 'cjs'],
fileName: (format) => `cyberduck.${format}.js`,
},
rollupOptions: {
// don't bundle peer deps
external: [
'react',
'react-dom',
'react-router',
'react-router-dom',
'bootstrap',
'@mui/material',
'@mui/icons-material',
'@emotion/react',
'@emotion/styled',
'react-bootstrap',
],
output: {
globals: {
react: 'React',
'react-dom': 'ReactDOM',
},
},
},
},
}))