@dephub/slug 1.0.0 → 1.0.2

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright (c) 2025 Estarlin R
3
+ Copyright (c) 2025-2026 Estarlin R
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -4,7 +4,6 @@
4
4
 
5
5
  [![NPM version](https://img.shields.io/npm/v/@dephub/slug.svg?style=flat)](https://npmjs.org/package/@dephub/slug)
6
6
  [![ESM-only](https://img.shields.io/badge/ESM-only-brightgreen?style=flat)](https://nodejs.org/)
7
- [![Node.js version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg)](https://nodejs.org/)
8
7
 
9
8
  ---
10
9
 
@@ -21,13 +20,10 @@
21
20
 
22
21
  ## Installation 📲
23
22
 
24
- ```bash
25
- npm install @dephub/slug
26
- # or
27
- pnpm add @dephub/slug
28
- # or
29
- yarn add @dephub/slug
30
- ```
23
+ - npm: `npm install @dephub/slug`
24
+ - pnpm: `pnpm add @dephub/slug`
25
+ - yarn: `yarn add @dephub/slug`
26
+ - bun: `bun add @dephub/slug`
31
27
 
32
28
  ---
33
29
 
package/dist/cli.js CHANGED
@@ -1,33 +1,43 @@
1
1
  #!/usr/bin/env node
2
- import { cli as a } from "@dephub/cli";
3
- import { log as l, error as n, success as c } from "@dephub/log";
4
- import { compare as p } from "./core/compare.js";
5
- import { slug as m } from "./core/slug.js";
6
- import { isSlug as g } from "./core/valid.js";
7
- import { name as u, version as f, description as d } from "./utils/pkg.js";
8
- a.name(u.split("/")[1] ?? "slug").version(f).description(d);
9
- a.command("generate", "Convert string to URL-friendly slug").argument("<input>", "Input string to convert").option("--separator", 'Separator character (default: "-")').flag("--no-lowercase", "Keep original case").option("--fallback", "Fallback text if result is empty").action(({ args: r, options: e, flags: o }) => {
10
- const [s] = r;
2
+ import { Command as s, CommandError as n } from "@dephub/command";
3
+ import { logger as o } from "@dephub/logger";
4
+ import { compare as c } from "./core/compare.js";
5
+ import { slug as l } from "./core/slug.js";
6
+ import { isSlug as p } from "./core/valid.js";
7
+ import { name as m, version as d, description as g } from "./utils/pkg.js";
8
+ const a = new s().name(m.split("/")[1] ?? "slug").version(d).description(g);
9
+ a.command("generate", "Convert string to URL-friendly slug").argument("input", "Input string to convert").option("separator", {
10
+ description: 'Separator character (default: "-")',
11
+ optional: !0
12
+ }).option("--no-lowercase", { description: "Keep original case", kind: "flag" }).option("fallback", {
13
+ description: "Fallback text if result is empty",
14
+ optional: !0
15
+ }).handler(({ args: r, options: e }) => {
11
16
  try {
12
17
  const t = {
13
18
  fallback: e.fallback,
14
- lowercase: o.lowercase,
19
+ lowercase: e.noLowercase,
15
20
  separator: e.separator
16
- }, i = m(s, t);
17
- l(i);
21
+ }, i = l(r.input, t);
22
+ o.log(i);
18
23
  } catch (t) {
19
- n(t.message), process.exit(1);
24
+ o.error(t.message), process.exit(1);
20
25
  }
21
26
  });
22
- a.command("validate", "Check if string is valid slug format").argument("<input>", "String to validate").action(({ args: r }) => {
23
- const [e] = r;
24
- g(e) ? c("Valid slug format") : (n("Invalid slug format"), process.exit(1));
27
+ a.command("validate", "Check if string is valid slug format").argument("input", "String to validate").handler(({ args: r }) => {
28
+ p(r.input) ? o.success("Valid slug format") : (o.error("Invalid slug format"), process.exit(1));
25
29
  });
26
- a.command("compare", "Compare two strings by slugified versions").argument("<first>", "First string to compare").argument("<second>", "Second string to compare").option("--separator", "Separator character").flag("--no-lowercase", "Keep original case").action(({ args: r, options: e, flags: o }) => {
27
- const [s, t] = r, i = {
28
- lowercase: o.lowercase,
30
+ a.command("compare", "Compare two strings by slugified versions").argument("first", "First string to compare").argument("second", "Second string to compare").option("separator", { description: "Separator character", optional: !0 }).option("--no-lowercase", { description: "Keep original case", kind: "flag" }).handler(({ args: r, options: e }) => {
31
+ const t = {
32
+ lowercase: e.noLowercase,
29
33
  separator: e.separator
30
34
  };
31
- p(s, t, i) ? c("Strings are equivalent when slugified") : (n("Strings are different when slugified"), process.exit(1));
35
+ c(r.first, r.second, t) ? o.success("Strings are equivalent when slugified") : (o.error("Strings are different when slugified"), process.exit(1));
32
36
  });
33
- await a.run();
37
+ try {
38
+ await a.run();
39
+ } catch (r) {
40
+ throw r instanceof n && (o.error(`
41
+ Error: ${r.message}
42
+ `), a.help(), process.exit(1)), r;
43
+ }
@@ -2,9 +2,9 @@
2
2
  * Convert string to URL-friendly slug
3
3
  */
4
4
  export interface SlugOptions {
5
- separator?: string;
6
- lowercase?: boolean;
7
5
  fallback?: string;
6
+ lowercase?: boolean;
7
+ separator?: string;
8
8
  }
9
9
  /**
10
10
  * Convert string to URL-friendly slug
package/dist/core/slug.js CHANGED
@@ -1,12 +1,12 @@
1
1
  const o = (r, t = {}) => {
2
2
  if (typeof r != "string") throw new TypeError("Input must be string");
3
3
  const {
4
- separator: a = "-",
4
+ fallback: a = "default-slug",
5
5
  lowercase: l = !0,
6
- fallback: s = "default-slug"
6
+ separator: s = "-"
7
7
  } = t;
8
- let e = r.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-zA-Z0-9\s]/g, "").trim().replace(/\s+/g, a);
9
- return l && (e = e.toLowerCase()), e || s;
8
+ let e = r.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-zA-Z0-9\s]/g, "").trim().replace(/\s+/g, s);
9
+ return l && (e = e.toLowerCase()), e || a;
10
10
  };
11
11
  export {
12
12
  o as slug
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export { compare } from './core/compare.js';
2
2
  export { slug, type SlugOptions } from './core/slug.js';
3
- export { slug as default } from './core/slug.js';
4
3
  export { isSlug } from './core/valid.js';
package/dist/index.js CHANGED
@@ -1,9 +1,8 @@
1
1
  import { compare as e } from "./core/compare.js";
2
- import { slug as l, slug as m } from "./core/slug.js";
3
- import { isSlug as s } from "./core/valid.js";
2
+ import { slug as p } from "./core/slug.js";
3
+ import { isSlug as t } from "./core/valid.js";
4
4
  export {
5
5
  e as compare,
6
- l as default,
7
- s as isSlug,
8
- m as slug
6
+ t as isSlug,
7
+ p as slug
9
8
  };
@@ -1,4 +1,4 @@
1
- const n = "@dephub/slug", o = "1.0.0", s = "URL-friendly slug generator with semantic comparison and validation", t = {
1
+ const n = "@dephub/slug", o = "1.0.2", s = "URL-friendly slug generator with semantic comparison and validation", t = {
2
2
  name: n,
3
3
  version: o,
4
4
  description: s
@@ -1 +1 @@
1
- export declare const version: string, name: string, description: string;
1
+ export declare const description: string, name: string, version: string;
package/dist/utils/pkg.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import o from "../package.json.js";
2
- const { version: e, name: i, description: n } = o ?? {};
2
+ const { description: e, name: i, version: n } = o ?? {};
3
3
  export {
4
- n as description,
4
+ e as description,
5
5
  i as name,
6
- e as version
6
+ n as version
7
7
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dephub/slug",
3
3
  "type": "module",
4
- "version": "1.0.0",
4
+ "version": "1.0.2",
5
5
  "description": "URL-friendly slug generator with semantic comparison and validation",
6
6
  "types": "./dist/index.d.ts",
7
7
  "main": "./dist/index.js",
@@ -34,27 +34,38 @@
34
34
  "dist"
35
35
  ],
36
36
  "license": "MIT",
37
- "homepage": "https://github.com/dephubjs/slug#readme",
37
+ "homepage": "https://github.com/dephub-js/slug#readme",
38
38
  "repository": {
39
39
  "type": "git",
40
- "url": "https://github.com/dephubjs/slug.git",
41
- "directory": "packages/slug"
40
+ "url": "https://github.com/dephub-js/slug.git"
42
41
  },
43
42
  "bugs": {
44
- "url": "https://github.com/dephubjs/slug/issues"
43
+ "url": "https://github.com/dephub-js/slug/issues"
45
44
  },
46
45
  "publishConfig": {
47
46
  "access": "public"
48
47
  },
49
48
  "dependencies": {
50
- "@dephub/cli": "^1.0.0",
51
- "@dephub/log": "^1.0.0"
49
+ "@dephub/command": "^1.0.1",
50
+ "@dephub/logger": "^1.2.0"
51
+ },
52
+ "devDependencies": {
53
+ "@dephub/eslint-ts": "^1.0.2",
54
+ "@dephub/glob": "^1.0.2",
55
+ "@dephub/path": "^1.0.2",
56
+ "@types/node": "^25.3.3",
57
+ "eslint": "^10.0.2",
58
+ "prettier": "^3.8.1",
59
+ "typescript": "^5.9.3",
60
+ "vite": "^7.3.1",
61
+ "vite-plugin-dts": "^4.5.4"
52
62
  },
53
63
  "scripts": {
54
64
  "release": "pnpm publish",
65
+ "docs": "lineo md 'src/**/*.ts' --outFile code.md --outDir temp",
55
66
  "check-types": "tsc --noEmit --skipLibCheck",
56
- "lint": "lint . --max-warnings 0",
57
- "lint:fix": "lint . --fix",
67
+ "lint": "eslint . --fix --max-warnings 0",
68
+ "fmt": "prettier --write .",
58
69
  "clean": "rm -rf dist",
59
70
  "build": "vite build",
60
71
  "dev": "vite build -w --mode development"