chore: rename utils package to shared
This commit is contained in:
9
packages/shared/eslint.config.js
Normal file
9
packages/shared/eslint.config.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import baseConfig from "@kan/eslint-config/base";
|
||||
|
||||
/** @type {import('typescript-eslint').Config} */
|
||||
export default [
|
||||
{
|
||||
ignores: [],
|
||||
},
|
||||
...baseConfig,
|
||||
];
|
||||
41
packages/shared/package.json
Normal file
41
packages/shared/package.json
Normal 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"
|
||||
}
|
||||
}
|
||||
12
packages/shared/src/constants/colours.ts
Normal file
12
packages/shared/src/constants/colours.ts
Normal 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];
|
||||
1
packages/shared/src/constants/index.ts
Normal file
1
packages/shared/src/constants/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./colours";
|
||||
4
packages/shared/src/index.ts
Normal file
4
packages/shared/src/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export const name = "shared";
|
||||
|
||||
export * from "./constants";
|
||||
export * from "./utils";
|
||||
8
packages/shared/src/utils/generateSlug.ts
Normal file
8
packages/shared/src/utils/generateSlug.ts
Normal 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
|
||||
}
|
||||
10
packages/shared/src/utils/generateUID.ts
Normal file
10
packages/shared/src/utils/generateUID.ts
Normal 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();
|
||||
}
|
||||
2
packages/shared/src/utils/index.ts
Normal file
2
packages/shared/src/utils/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./generateUID";
|
||||
export * from "./generateSlug";
|
||||
6
packages/shared/tsconfig.json
Normal file
6
packages/shared/tsconfig.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "@kan/tsconfig/internal-package.json",
|
||||
"compilerOptions": {},
|
||||
"include": ["*.ts", "src"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
Reference in New Issue
Block a user