@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 +1 -1
- package/README.md +4 -8
- package/dist/cli.js +31 -21
- package/dist/core/slug.d.ts +2 -2
- package/dist/core/slug.js +4 -4
- package/dist/index.d.ts +0 -1
- package/dist/index.js +4 -5
- package/dist/package.json.js +1 -1
- package/dist/utils/pkg.d.ts +1 -1
- package/dist/utils/pkg.js +3 -3
- package/package.json +20 -9
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://npmjs.org/package/@dephub/slug)
|
|
6
6
|
[](https://nodejs.org/)
|
|
7
|
-
[](https://nodejs.org/)
|
|
8
7
|
|
|
9
8
|
---
|
|
10
9
|
|
|
@@ -21,13 +20,10 @@
|
|
|
21
20
|
|
|
22
21
|
## Installation 📲
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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 {
|
|
3
|
-
import {
|
|
4
|
-
import { compare as
|
|
5
|
-
import { slug as
|
|
6
|
-
import { isSlug as
|
|
7
|
-
import { name as
|
|
8
|
-
a.name(
|
|
9
|
-
a.command("generate", "Convert string to URL-friendly slug").argument("
|
|
10
|
-
|
|
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:
|
|
19
|
+
lowercase: e.noLowercase,
|
|
15
20
|
separator: e.separator
|
|
16
|
-
}, i =
|
|
17
|
-
|
|
21
|
+
}, i = l(r.input, t);
|
|
22
|
+
o.log(i);
|
|
18
23
|
} catch (t) {
|
|
19
|
-
|
|
24
|
+
o.error(t.message), process.exit(1);
|
|
20
25
|
}
|
|
21
26
|
});
|
|
22
|
-
a.command("validate", "Check if string is valid slug format").argument("
|
|
23
|
-
|
|
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("
|
|
27
|
-
const
|
|
28
|
-
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
|
-
|
|
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
|
-
|
|
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
|
+
}
|
package/dist/core/slug.d.ts
CHANGED
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
|
-
|
|
4
|
+
fallback: a = "default-slug",
|
|
5
5
|
lowercase: l = !0,
|
|
6
|
-
|
|
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,
|
|
9
|
-
return l && (e = e.toLowerCase()), e ||
|
|
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
package/dist/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { compare as e } from "./core/compare.js";
|
|
2
|
-
import { slug as
|
|
3
|
-
import { isSlug as
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
m as slug
|
|
6
|
+
t as isSlug,
|
|
7
|
+
p as slug
|
|
9
8
|
};
|
package/dist/package.json.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const n = "@dephub/slug", o = "1.0.
|
|
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
|
package/dist/utils/pkg.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const description: string, name: string, version: string;
|
package/dist/utils/pkg.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dephub/slug",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.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/
|
|
37
|
+
"homepage": "https://github.com/dephub-js/slug#readme",
|
|
38
38
|
"repository": {
|
|
39
39
|
"type": "git",
|
|
40
|
-
"url": "https://github.com/
|
|
41
|
-
"directory": "packages/slug"
|
|
40
|
+
"url": "https://github.com/dephub-js/slug.git"
|
|
42
41
|
},
|
|
43
42
|
"bugs": {
|
|
44
|
-
"url": "https://github.com/
|
|
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/
|
|
51
|
-
"@dephub/
|
|
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": "
|
|
57
|
-
"
|
|
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"
|