chore: rename utils package to shared

This commit is contained in:
Henry
2025-01-29 16:21:30 +00:00
parent 8addf952a9
commit 34f8ad4def
26 changed files with 96 additions and 80 deletions

View File

@@ -0,0 +1,9 @@
import baseConfig from "@kan/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [
{
ignores: [],
},
...baseConfig,
];

View File

@@ -0,0 +1,41 @@
{
"name": "@kan/shared",
"private": true,
"version": "0.1.0",
"type": "module",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./utils": {
"types": "./dist/utils/index.d.ts",
"default": "./dist/utils/index.js"
},
"./constants": {
"types": "./dist/constants/index.d.ts",
"default": "./dist/constants/index.js"
}
},
"license": "MIT",
"scripts": {
"build": "tsc",
"clean": "git clean -xdf .cache .turbo dist node_modules",
"dev": "tsc",
"format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "eslint",
"typecheck": "tsc --noEmit --emitDeclarationOnly false"
},
"devDependencies": {
"@kan/eslint-config": "workspace:*",
"@kan/prettier-config": "workspace:*",
"@kan/tsconfig": "workspace:*",
"eslint": "catalog:",
"prettier": "catalog:",
"typescript": "catalog:"
},
"prettier": "@kan/prettier-config",
"dependencies": {
"nanoid": "^5.0.9"
}
}

View File

@@ -0,0 +1,12 @@
export const colours: { name: string; code: string }[] = [
{ name: "Teal", code: "#0d9488" },
{ name: "Green", code: "#65a30d" },
{ name: "Blue", code: "#0284c7" },
{ name: "Purple", code: "#4f46e5" },
{ name: "Yellow", code: "#ca8a04" },
{ name: "Orange", code: "#ea580c" },
{ name: "Red", code: "#dc2626" },
{ name: "Pink", code: "#db2777" },
] as const;
export type Colour = (typeof colours)[number];

View File

@@ -0,0 +1 @@
export * from "./colours";

View File

@@ -0,0 +1,4 @@
export const name = "shared";
export * from "./constants";
export * from "./utils";

View File

@@ -0,0 +1,8 @@
export function generateSlug(text: string): string {
return text
.toLowerCase()
.trim()
.replace(/[^\w\s-]/g, "") // Remove special characters
.replace(/\s+/g, "-") // Replace spaces with hyphens
.replace(/-+/g, "-"); // Remove consecutive hyphens
}

View File

@@ -0,0 +1,10 @@
import { customAlphabet } from "nanoid";
const alphabet = "0123456789abcdefghijklmnopqrstuvwxyz";
const length = 12;
const nanoid = customAlphabet(alphabet, length);
export function generateUID() {
return nanoid();
}

View File

@@ -0,0 +1,2 @@
export * from "./generateUID";
export * from "./generateSlug";

View File

@@ -0,0 +1,6 @@
{
"extends": "@kan/tsconfig/internal-package.json",
"compilerOptions": {},
"include": ["*.ts", "src"],
"exclude": ["node_modules"]
}